DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net
Subject: [dpdk-dev] [PATCH v3 07/18] librte_table: add unified params structure and mask-based hash func
Date: Wed, 18 Oct 2017 16:03:43 +0100	[thread overview]
Message-ID: <1508339034-171115-27-git-send-email-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <1508339034-171115-1-git-send-email-cristian.dumitrescu@intel.com>

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 <cristian.dumitrescu@intel.com>
---
 .../pipeline/pipeline_flow_classification_be.c     |  2 +-
 .../ip_pipeline/pipeline/pipeline_passthrough_be.c |  4 +-
 lib/librte_table/rte_table_hash.h                  | 52 ++++++++++++++++++----
 lib/librte_table/rte_table_hash_cuckoo.c           |  2 +-
 lib/librte_table/rte_table_hash_ext.c              |  4 +-
 lib/librte_table/rte_table_hash_key16.c            |  2 +-
 lib/librte_table/rte_table_hash_key32.c            |  2 +-
 lib/librte_table/rte_table_hash_key8.c             |  4 +-
 lib/librte_table/rte_table_hash_lru.c              |  4 +-
 9 files changed, 55 insertions(+), 21 deletions(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
index 191cb15..e131a5b 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 8cb2f0c..6b57f83
--- 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 5f655ee..bb5b83d 100644
--- a/lib/librte_table/rte_table_hash.h
+++ b/lib/librte_table/rte_table_hash.h
@@ -98,6 +98,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 beb45c5..9b42423 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 c4824c3..72802b8 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 4ed5c78..7f6651c 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 31fe6fd..f8f6662 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 f2b285d..4fbb02e 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 0a85123..61050f3 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;			\
-- 
2.7.4

  parent reply	other threads:[~2017-10-18 15:04 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 13:53 [dpdk-dev] [PATCH 0/5] table: add key mask for hash tables Cristian Dumitrescu
2017-08-24 13:53 ` [dpdk-dev] [PATCH 1/5] " Cristian Dumitrescu
2017-10-10 11:18   ` [dpdk-dev] [PATCH V2 0/5] " Cristian Dumitrescu
2017-10-10 11:18     ` [dpdk-dev] [PATCH V2 1/5] " Cristian Dumitrescu
2017-10-18 15:03       ` [dpdk-dev] [PATCH v3 00/18] librte_table: " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 01/18] test: removing calls to deprecated " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 02/18] librte_table: remove deprecated 8-byte key " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 03/18] librte_table: remove deprecated 16-byte " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 04/18] librte_table: remove deprecated variable size key ext " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 05/18] librte_table: remove deprecated variable size key lru " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 06/18] librte_table: rename cuckoo hash table ops Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 07/18] librte_table: add unified params structure and mask-based hash func Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 08/18] librte_table: rework variable size key ext hash tables Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 09/18] librte_table: rework variable size key lru hash table Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 10/18] librte_table: rework 8-byte key hash tables Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 11/18] librte_table: rework 16-byte " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 12/18] librte_table: rework 32-byte " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 13/18] librte_table: rework cuckoo hash table Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 14/18] test: add mask-based hash functions Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 15/18] librte_table: cosmetic enhancements in api file Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 16/18] librte_table: copyright cosmetic updates Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 17/18] librte_table: map file updates Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 18/18] doc: remove deprecation notice for librte_table Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 00/18] librte_table: add key mask for hash tables Cristian Dumitrescu
2017-10-18 17:10           ` Dumitrescu, Cristian
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 01/18] test: removing calls to deprecated " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 02/18] librte_table: remove deprecated 8-byte key " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 03/18] librte_table: remove deprecated 16-byte " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 04/18] librte_table: remove deprecated variable size key ext " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 05/18] librte_table: remove deprecated variable size key lru " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 06/18] librte_table: rename cuckoo hash table ops Cristian Dumitrescu
2017-10-18 15:03         ` Cristian Dumitrescu [this message]
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 08/18] librte_table: rework variable size key ext hash tables Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 09/18] librte_table: rework variable size key lru hash table Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 10/18] librte_table: rework 8-byte key hash tables Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 11/18] librte_table: rework 16-byte " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 12/18] librte_table: rework 32-byte " Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 13/18] librte_table: rework cuckoo hash table Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 14/18] test: add mask-based hash functions Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 15/18] librte_table: cosmetic enhancements in api file Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 16/18] librte_table: copyright cosmetic updates Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 17/18] librte_table: map file updates Cristian Dumitrescu
2017-10-18 15:03         ` [dpdk-dev] [PATCH v3 18/18] doc: remove deprecation notice for librte_table Cristian Dumitrescu
2017-10-18 18:30           ` Mcnamara, John
2017-10-10 11:18     ` [dpdk-dev] [PATCH V2 2/5] test: update due to api changes in librte_table Cristian Dumitrescu
2017-10-10 11:18     ` [dpdk-dev] [PATCH V2 3/5] test-pipeline: " Cristian Dumitrescu
2017-10-10 11:19     ` [dpdk-dev] [PATCH V2 4/5] ip_pipeline: " Cristian Dumitrescu
2017-10-10 11:19     ` [dpdk-dev] [PATCH V2 5/5] deprecation: removed the librte_table notice Cristian Dumitrescu
2017-10-11 14:22     ` [dpdk-dev] [PATCH V2 0/5] table: add key mask for hash tables Dumitrescu, Cristian
2017-08-24 13:53 ` [dpdk-dev] [PATCH 2/5] test: update due to api changes in librte_table Cristian Dumitrescu
2017-08-24 13:53 ` [dpdk-dev] [PATCH 3/5] test-pipeline: " Cristian Dumitrescu
2017-08-24 13:53 ` [dpdk-dev] [PATCH 4/5] ip_pipeline: " Cristian Dumitrescu
2017-08-24 13:53 ` [dpdk-dev] [PATCH 5/5] deprecation: removed the librte_table notice Cristian Dumitrescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508339034-171115-27-git-send-email-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).