From: Cristian Dumitrescu Date: Wed, 18 Oct 2017 15:03:43 +0000 (+0100) Subject: table: add unified params struct and mask-based hash func X-Git-Tag: spdx-start~1258 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2dc5198907745009c8e89178b1366b96bfaafdb5;p=dpdk.git table: add unified params struct and mask-based hash func Add unified parameter structure for all hash tables in librte_table. Add mask-based hash function prototype, which is input parameter for all hash tables. Renamed the non-mask-based hash function prototype and all the calls to it (to be removed later). Signed-off-by: Cristian Dumitrescu --- diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c index 191cb15920..e131a5b085 100644 --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c @@ -118,7 +118,7 @@ struct flow_table_entry { uint32_t pad; }; -rte_table_hash_op_hash hash_func[] = { +rte_table_hash_op_hash_nomask hash_func[] = { hash_default_key8, hash_default_key16, hash_default_key24, diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c index 8cb2f0c716..6b57f83ac3 100644 --- a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c +++ b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c @@ -52,7 +52,7 @@ struct pipeline_passthrough { struct pipeline p; struct pipeline_passthrough_params params; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint32_t swap_field0_offset[SWAP_DIM]; uint32_t swap_field1_offset[SWAP_DIM]; uint64_t swap_field_mask[SWAP_DIM]; @@ -677,7 +677,7 @@ pipeline_passthrough_parse_args(struct pipeline_passthrough_params *p, return 0; } -static rte_table_hash_op_hash +static rte_table_hash_op_hash_nomask get_hash_function(struct pipeline_passthrough *p) { switch (p->params.dma_size) { diff --git a/lib/librte_table/rte_table_hash.h b/lib/librte_table/rte_table_hash.h index 5f655ee24b..bb5b83db62 100644 --- a/lib/librte_table/rte_table_hash.h +++ b/lib/librte_table/rte_table_hash.h @@ -97,6 +97,40 @@ extern "C" { /** Hash function */ typedef uint64_t (*rte_table_hash_op_hash)( + void *key, + void *key_mask, + uint32_t key_size, + uint64_t seed); + +/** Hash table parameters */ +struct rte_table_hash_params { + /** Name */ + const char *name; + + /** Key size (number of bytes) */ + uint32_t key_size; + + /** Byte offset within packet meta-data where the key is located */ + uint32_t key_offset; + + /** Key mask */ + uint8_t *key_mask; + + /** Number of keys */ + uint32_t n_keys; + + /** Number of buckets */ + uint32_t n_buckets; + + /** Hash function */ + rte_table_hash_op_hash f_hash; + + /** Seed value for the hash function */ + uint64_t seed; +}; + +/** Hash function */ +typedef uint64_t (*rte_table_hash_op_hash_nomask)( void *key, uint32_t key_size, uint64_t seed); @@ -121,7 +155,7 @@ struct rte_table_hash_ext_params { uint32_t n_buckets_ext; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed value for the hash function */ uint64_t seed; @@ -149,7 +183,7 @@ struct rte_table_hash_lru_params { uint32_t n_buckets; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed value for the hash function */ uint64_t seed; @@ -175,7 +209,7 @@ struct rte_table_hash_key8_lru_params { uint32_t n_entries; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed for the hash function */ uint64_t seed; @@ -204,7 +238,7 @@ struct rte_table_hash_key8_ext_params { uint32_t n_entries_ext; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed for the hash function */ uint64_t seed; @@ -233,7 +267,7 @@ struct rte_table_hash_key16_lru_params { uint32_t n_entries; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed for the hash function */ uint64_t seed; @@ -262,7 +296,7 @@ struct rte_table_hash_key16_ext_params { uint32_t n_entries_ext; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed for the hash function */ uint64_t seed; @@ -291,7 +325,7 @@ struct rte_table_hash_key32_lru_params { uint32_t n_entries; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed for the hash function */ uint64_t seed; @@ -318,7 +352,7 @@ struct rte_table_hash_key32_ext_params { uint32_t n_entries_ext; /** Hash function */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed for the hash function */ uint64_t seed; @@ -344,7 +378,7 @@ struct rte_table_hash_cuckoo_params { uint32_t n_keys; /** Hash function used to calculate hash */ - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; /** Seed value or Init value used by f_hash */ uint32_t seed; diff --git a/lib/librte_table/rte_table_hash_cuckoo.c b/lib/librte_table/rte_table_hash_cuckoo.c index beb45c5ed7..9b42423ee6 100644 --- a/lib/librte_table/rte_table_hash_cuckoo.c +++ b/lib/librte_table/rte_table_hash_cuckoo.c @@ -64,7 +64,7 @@ struct rte_table_hash { uint32_t key_size; uint32_t entry_size; uint32_t n_keys; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint32_t seed; uint32_t signature_offset; uint32_t key_offset; diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c index c4824c35db..72802b871d 100644 --- a/lib/librte_table/rte_table_hash_ext.c +++ b/lib/librte_table/rte_table_hash_ext.c @@ -104,7 +104,7 @@ struct rte_table_hash { uint32_t n_keys; uint32_t n_buckets; uint32_t n_buckets_ext; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint64_t seed; uint32_t signature_offset; uint32_t key_offset; @@ -688,7 +688,7 @@ static int rte_table_hash_ext_lookup_unoptimized( struct bucket *bkt10, *bkt11, *buckets = t->buckets; \ uint8_t *key10, *key11; \ uint64_t bucket_mask = t->bucket_mask; \ - rte_table_hash_op_hash f_hash = t->f_hash; \ + rte_table_hash_op_hash_nomask f_hash = t->f_hash; \ uint64_t seed = t->seed; \ uint32_t key_size = t->key_size; \ uint32_t key_offset = t->key_offset; \ diff --git a/lib/librte_table/rte_table_hash_key16.c b/lib/librte_table/rte_table_hash_key16.c index 4ed5c780df..7f6651c56e 100644 --- a/lib/librte_table/rte_table_hash_key16.c +++ b/lib/librte_table/rte_table_hash_key16.c @@ -86,7 +86,7 @@ struct rte_table_hash { uint32_t signature_offset; uint32_t key_offset; uint64_t key_mask[2]; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint64_t seed; /* Extendible buckets */ diff --git a/lib/librte_table/rte_table_hash_key32.c b/lib/librte_table/rte_table_hash_key32.c index 31fe6fda4b..f8f66626fa 100644 --- a/lib/librte_table/rte_table_hash_key32.c +++ b/lib/librte_table/rte_table_hash_key32.c @@ -85,7 +85,7 @@ struct rte_table_hash { uint32_t bucket_size; uint32_t signature_offset; uint32_t key_offset; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint64_t seed; /* Extendible buckets */ diff --git a/lib/librte_table/rte_table_hash_key8.c b/lib/librte_table/rte_table_hash_key8.c index f2b285df7d..4fbb02e1f0 100644 --- a/lib/librte_table/rte_table_hash_key8.c +++ b/lib/librte_table/rte_table_hash_key8.c @@ -83,7 +83,7 @@ struct rte_table_hash { uint32_t signature_offset; uint32_t key_offset; uint64_t key_mask; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint64_t seed; /* Extendible buckets */ @@ -733,7 +733,7 @@ rte_table_hash_entry_delete_key8_ext( uint64_t hash_offset_buffer11; \ uint64_t signature10, signature11; \ uint32_t bucket10_index, bucket11_index; \ - rte_table_hash_op_hash f_hash = f->f_hash; \ + rte_table_hash_op_hash_nomask f_hash = f->f_hash; \ uint64_t seed = f->seed; \ uint32_t key_offset = f->key_offset; \ \ diff --git a/lib/librte_table/rte_table_hash_lru.c b/lib/librte_table/rte_table_hash_lru.c index 0a85123963..61050f3b37 100644 --- a/lib/librte_table/rte_table_hash_lru.c +++ b/lib/librte_table/rte_table_hash_lru.c @@ -84,7 +84,7 @@ struct rte_table_hash { uint32_t entry_size; uint32_t n_keys; uint32_t n_buckets; - rte_table_hash_op_hash f_hash; + rte_table_hash_op_hash_nomask f_hash; uint64_t seed; uint32_t signature_offset; uint32_t key_offset; @@ -619,7 +619,7 @@ static int rte_table_hash_lru_lookup_unoptimized( struct bucket *bkt10, *bkt11, *buckets = t->buckets; \ uint8_t *key10, *key11; \ uint64_t bucket_mask = t->bucket_mask; \ - rte_table_hash_op_hash f_hash = t->f_hash; \ + rte_table_hash_op_hash_nomask f_hash = t->f_hash; \ uint64_t seed = t->seed; \ uint32_t key_size = t->key_size; \ uint32_t key_offset = t->key_offset; \