1 #ifndef __tailq_hash__ 2 #define __tailq_hash__ 3 4 /* Must be powers of 2 */ 5 #define MAX_HASH_ENTRIES 128 6 #define SEQ_BUCKET_SIZE 262144 7 /* 8 * The max seq range that can be stored is 9 * 64 x 262144 or 16Meg. We have one extra slot 10 * for fall-over but must keep it so we never have 11 * wrap in hashing over valid other entries. 12 */ 13 #define MAX_ALLOWED_SEQ_RANGE (SEQ_BUCKET_SIZE * (MAX_HASH_ENTRIES-1)) 14 15 struct tailq_hash { 16 uint32_t min; 17 uint32_t max; 18 uint32_t count; 19 struct rack_sendmap *rsm_min; 20 struct rack_sendmap *rsm_max; 21 struct rack_head ht[MAX_HASH_ENTRIES]; 22 }; 23 24 struct rack_sendmap * 25 tqhash_min(struct tailq_hash *hs); 26 27 struct rack_sendmap * 28 tqhash_max(struct tailq_hash *hs); 29 30 int 31 tqhash_empty(struct tailq_hash *hs); 32 33 struct rack_sendmap * 34 tqhash_find(struct tailq_hash *hs, uint32_t seq); 35 36 struct rack_sendmap * 37 tqhash_next(struct tailq_hash *hs, struct rack_sendmap *rsm); 38 39 struct rack_sendmap * 40 tqhash_prev(struct tailq_hash *hs, struct rack_sendmap *rsm); 41 42 #define REMOVE_TYPE_CUMACK 1 /* Cumack moved */ 43 #define REMOVE_TYPE_MERGE 2 /* Merging two blocks */ 44 #define REMOVE_TYPE_FINI 3 /* The connection is over */ 45 46 void 47 tqhash_remove(struct tailq_hash *hs, struct rack_sendmap *rsm, int type); 48 49 int 50 tqhash_insert(struct tailq_hash *hs, struct rack_sendmap *rsm); 51 52 void 53 tqhash_init(struct tailq_hash *hs); 54 55 int 56 tqhash_trim(struct tailq_hash *hs, uint32_t th_ack); 57 58 void 59 tqhash_update_end(struct tailq_hash *hs, struct rack_sendmap *rsm, 60 uint32_t th_ack); 61 62 63 #define TQHASH_FOREACH(var, head) \ 64 for ((var) = tqhash_min((head)); \ 65 (var); \ 66 (var) = tqhash_next((head), (var))) 67 68 #define TQHASH_FOREACH_FROM(var, head, fvar) \ 69 for ((var) = ((fvar) ? (fvar) : tqhash_min((head))); \ 70 (var); \ 71 (var) = tqhash_next((head), (var))) 72 73 #define TQHASH_FOREACH_REVERSE_FROM(var, head) \ 74 for ((var) = ((var) ? (var) : tqhash_max((head))); \ 75 (var); \ 76 (var) = tqhash_prev((head), (var))) 77 78 79 #endif 80