X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=datapath%2Ftable.h;h=dac57476a5526a2107eabcfc01f930fdbfbe2b06;hb=7f7ae89d2477e14b11c1355668366030fc590c64;hp=9ae1ee322164ecf358f644f1d2890f51482f6e3d;hpb=8d5ebd839b86463c72239fe972001e4f1a367a7b;p=openvswitch diff --git a/datapath/table.h b/datapath/table.h index 9ae1ee32..dac57476 100644 --- a/datapath/table.h +++ b/datapath/table.h @@ -9,13 +9,36 @@ #ifndef TABLE_H #define TABLE_H 1 -struct tbl; struct tbl_bucket; struct tbl_node { u32 hash; }; +/** + * struct tbl - hash table + * @n_buckets: number of buckets (a power of 2 between %TBL_L1_SIZE and + * %TBL_MAX_BUCKETS) + * @buckets: pointer to @n_buckets/%TBL_L1_SIZE pointers to %TBL_L1_SIZE pointers + * to buckets + * @rcu: RCU callback structure + * @obj_destructor: Called on each element when the table is destroyed. + * + * The @buckets array is logically an array of pointers to buckets. It is + * broken into two levels to avoid the need to kmalloc() any object larger than + * a single page or to use vmalloc(). @buckets is always nonnull, as is each + * @buckets[i], but each @buckets[i][j] is nonnull only if the specified hash + * bucket is nonempty (for 0 <= i < @n_buckets/%TBL_L1_SIZE, 0 <= j < + * %TBL_L1_SIZE). + */ +struct tbl { + struct rcu_head rcu; + unsigned int n_buckets; + struct tbl_bucket ***buckets; + unsigned int count; + void (*obj_destructor)(struct tbl_node *); +}; + #define TBL_L2_BITS (PAGE_SHIFT - ilog2(sizeof(struct tbl_bucket *))) #define TBL_L2_SIZE (1 << TBL_L2_BITS) #define TBL_L2_SHIFT 0