4 #ifndef __RDMA_TYPES_H_
5 #define __RDMA_TYPES_H_
7 #include <sys/malloc.h>
16 typedef uint16_t __u16;
17 typedef uint32_t __u32;
18 typedef uint64_t __u64;
19 typedef uint8_t __be8;
20 typedef uint16_t __be16;
21 typedef uint32_t __be32;
22 typedef uint64_t __be64;
24 typedef int32_t __s32;
27 #define LINUX_TYPES_DEFINED
28 #define ERR_PTR(err) ((void *)((long)(err)))
29 #define IS_ERR(ptr) ((unsigned long)(ptr) > (unsigned long)(-1000))
30 #define PTR_ERR(ptr) ((long)(ptr))
33 #define PANIC_IF(exp) do { \
35 panic("BUG func %s line %u: %s", __FUNCTION__, __LINE__, #exp); \
39 #define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field)))
42 find_first_zero_bit(volatile void *p, int max)
45 volatile int *ptr = (volatile int *)p;
47 for (b = 0; b < max; b += 32) {
48 if (ptr[b >> 5] != ~0) {
50 if ((ptr[b >> 5] & (1 << (b & 0x1f))) == 0)
66 #define DEFINE_KVL(x) struct kvl x;
68 static __inline void *
69 kvl_lookup(struct kvl *x, uint32_t key)
72 for (i=x->next;i;i=i->next) if (i->key==key) return(i->value);
77 kvl_alloc_above(struct kvl *idp, void *ptr, int starting_id, int *id)
79 int newid = starting_id;
82 for (i=idp->next;i;i=i->next)
86 i=malloc(sizeof(struct kvl),M_TEMP,M_NOWAIT);
96 kvl_delete(struct kvl *idp, int id)
99 struct kvl *i, *prev=NULL;
100 for (i=idp->next;i;prev=i,i=i->next)
105 prev->next = i->next;
112 kvl_free(struct kvl *idp)
115 for (i=idp->next;i;i=tmp) {