00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <linux/types.h>
00031 #include <asm/spinlock.h>
00032
00033 #ifndef QUEUE_H
00034 #define QUEUE_H
00035
00036 #define NAME_SIZE 32
00037
00038
00039
00040
00041 #define HB_NOLOCK 0
00042 #define HB_GLOBAL 1
00043 #define HB_LOCAL 2
00044 #define HB_SORTED 4
00045
00046
00047
00048
00049 #define HASHBIN_SIZE 8
00050 #define HASHBIN_MASK 0x7
00051
00052 #ifndef ALIGN
00053 #define ALIGN __attribute__((aligned))
00054 #endif
00055
00056 #define Q_NULL { NULL, NULL, "", 0 }
00057
00058 typedef void (*FREE_FUNC)(void *arg);
00059
00060
00061
00062
00063 #define GET_HASHBIN(x) ( x & HASHBIN_MASK )
00064
00065 struct irqueue {
00066 struct irqueue *q_next;
00067 struct irqueue *q_prev;
00068
00069 char q_name[NAME_SIZE];
00070 __u32 q_hash;
00071 };
00072 typedef struct irqueue queue_t;
00073
00074 typedef struct hashbin_t {
00075 __u32 magic;
00076 int hb_type;
00077 int hb_size;
00078 spinlock_t hb_mutex[HASHBIN_SIZE] ALIGN;
00079 queue_t *hb_queue[HASHBIN_SIZE] ALIGN;
00080
00081 queue_t* hb_current;
00082 } hashbin_t;
00083
00084 hashbin_t *hashbin_new(int type);
00085 int hashbin_delete(hashbin_t* hashbin, FREE_FUNC func);
00086 int hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func);
00087 void hashbin_insert(hashbin_t* hashbin, queue_t* entry, __u32 hashv,
00088 char* name);
00089 void* hashbin_find(hashbin_t* hashbin, __u32 hashv, char* name);
00090 void* hashbin_remove(hashbin_t* hashbin, __u32 hashv, char* name);
00091 void* hashbin_remove_first(hashbin_t *hashbin);
00092 queue_t *hashbin_get_first(hashbin_t *hashbin);
00093 queue_t *hashbin_get_next(hashbin_t *hashbin);
00094
00095 void enqueue_last(queue_t **queue, queue_t* element);
00096 void enqueue_first(queue_t **queue, queue_t* element);
00097 queue_t *dequeue_first(queue_t **queue);
00098
00099 #define HASHBIN_GET_SIZE(hashbin) hashbin->hb_size
00100
00101 #endif