Skip to contentSkip to conversation

librte_table: add key_mask parameter to 8-byte key

PATCH Superseded [email protected] 5 participants 32 messages Sep 25, 2015 – Oct 21, 2015

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover librte_table: add key_mask parameter to 8-byte key

From: Fan Zhang <[email protected]>

This patchset links to ABI change announced for librte_table. Key_mask parameters has been added to the hash table parameter structure for 8-byte key and 16-byte key extendible bucket and LRU tables.

Fan Zhang (8):
librte_table: add key_mask parameter to 8-byte key hash parameters
librte_table: add key_mask parameter to 16-byte key hash parameters
librte_table: add 16 byte hash table operations with computed lookup app/test: modify app/test_table_combined and app/test_table_tables app/test-pipeline: modify pipeline test example/ip_pipeline: add parse_hex_string for internal use example/ip_pipeline/pipeline: update flow_classification pipeline
librte_table: modify release notes and deprecation notice

 app/test-pipeline/pipeline_hash.c                  |   4 +
 app/test/test_table_combined.c                     |   4 +
 app/test/test_table_tables.c                       |   6 +-
 doc/guides/rel_notes/deprecation.rst               |   3 -
 doc/guides/rel_notes/release_2_2.rst               |   5 +-
 examples/ip_pipeline/config_parse.c                |  70 ++++
 examples/ip_pipeline/pipeline.h                    |   4 +
 .../pipeline/pipeline_flow_classification_be.c     |  56 ++-
 lib/librte_table/Makefile                          |   2 +-
 lib/librte_table/rte_table_hash.h                  |  20 +
 lib/librte_table/rte_table_hash_key16.c            | 411 ++++++++++++++++++++-
 lib/librte_table/rte_table_hash_key8.c             |  54 ++-
 12 files changed, 608 insertions(+), 31 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/8 librte_table: add key_mask parameter to 8-byte key hash parameters

From: Fan Zhang <[email protected]>

This patch relates to ABI change proposed for librte_table. key_mask parameter is added for 8-byte key extendible bucket and LRU tables.

---
 lib/librte_table/rte_table_hash.h      |  6 ++++
 lib/librte_table/rte_table_hash_key8.c | 54 +++++++++++++++++++++++++++-------
 2 files changed, 50 insertions(+), 10 deletions(-)
lib/librte_table/rte_table_hash.h +6 -0
index 9181942..ef65355 100644
@@ -196,6 +196,9 @@ struct rte_table_hash_key8_lru_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** LRU hash table operations for pre-computed key signature */
@@ -226,6 +229,9 @@ struct rte_table_hash_key8_ext_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** Extendible bucket hash table operations for pre-computed key signature */
lib/librte_table/rte_table_hash_key8.c +44 -10

148 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/8 librte_table: add key_mask parameter to 16-byte key hash parameters

In reply to [email protected]

From: Fan Zhang <[email protected]>

This patch relates to ABI change proposed for librte_table. key_mask parameter is added for 16-byte key extendible bucket and LRU tables.

---
 lib/librte_table/rte_table_hash.h       |  6 ++++
 lib/librte_table/rte_table_hash_key16.c | 53 ++++++++++++++++++++++++++++-----
 2 files changed, 52 insertions(+), 7 deletions(-)
lib/librte_table/rte_table_hash.h +6 -0
index ef65355..e2c60e1 100644
@@ -263,6 +263,9 @@ struct rte_table_hash_key16_lru_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** LRU hash table operations for pre-computed key signature */
@@ -290,6 +293,9 @@ struct rte_table_hash_key16_ext_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** Extendible bucket operations for pre-computed key signature */
lib/librte_table/rte_table_hash_key16.c +46 -7

127 lines not on this page · raw message

Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/8 librte_table: add 16 byte hash table operations with computed lookup

In reply to [email protected]

From: Fan Zhang <[email protected]>

This patch is to adding hash table operations for key signature computed on lookup ("do-sig") for LRU hash tables and Extendible buckets.

---
 lib/librte_table/rte_table_hash.h       |   8 +
 lib/librte_table/rte_table_hash_key16.c | 358 +++++++++++++++++++++++++++++++-
 2 files changed, 363 insertions(+), 3 deletions(-)
lib/librte_table/rte_table_hash.h +8 -0
index e2c60e1..9d17516 100644
@@ -271,6 +271,10 @@ struct rte_table_hash_key16_lru_params {
 /** LRU hash table operations for pre-computed key signature */
 extern struct rte_table_ops rte_table_hash_key16_lru_ops;
 
+/** LRU hash table operations for key signature computed on lookup
+    ("do-sig") */
+extern struct rte_table_ops rte_table_hash_key16_lru_dosig_ops;
+
 /** Extendible bucket hash table parameters */
 struct rte_table_hash_key16_ext_params {
 	/** Maximum number of entries (and keys) in the table */
@@ -301,6 +305,10 @@ struct rte_table_hash_key16_ext_params {
 /** Extendible bucket operations for pre-computed key signature */
 extern struct rte_table_ops rte_table_hash_key16_ext_ops;
 
+/** Extendible bucket hash table operations for key signature computed on
+    lookup ("do-sig") */
+extern struct rte_table_ops rte_table_hash_key16_ext_dosig_ops;
+
 /**
  * 32-byte key hash tables
  *
lib/librte_table/rte_table_hash_key16.c +355 -3

405 lines not on this page · raw message

Signature · 1 line
2.1.0
#4 lore raw

PATCH 4/8 app/test: modify app/test_table_combined and app/test_table_tables

In reply to [email protected]

From: Fan Zhang <[email protected]>

Tests have been updated to work on added key_mask parameter for 8-byte key extendible bucket and LRU tables.

---
 app/test/test_table_combined.c | 4 ++++
 app/test/test_table_tables.c   | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
app/test/test_table_combined.c +4 -0
index dd09da5..359ac45 100644
@@ -419,6 +419,7 @@ test_table_hash8lru(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key8lru[8];
@@ -477,6 +478,7 @@ test_table_hash16lru(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key16lru[16];
@@ -594,6 +596,7 @@ test_table_hash8ext(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key8ext[8];
@@ -660,6 +663,7 @@ test_table_hash16ext(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key16ext[16];
app/test/test_table_tables.c +4 -2
index 566964b..cc222f1 100644
@@ -651,7 +651,8 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
 		.signature_offset = 1,
-		.key_offset = 32
+		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	hash_params.n_entries = 0;
@@ -766,7 +767,8 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
 		.signature_offset = 1,
-		.key_offset = 32
+		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	hash_params.n_entries = 0;
Signature · 1 line
2.1.0
#5 lore raw

PATCH 5/8 app/test-pipeline: modify pipeline test

In reply to [email protected]

From: Fan Zhang <[email protected]>

Test-pipeline have been updated to work on added key_mask parameter for 8-byte key extendible bucket and LRU tables.

---
 app/test-pipeline/pipeline_hash.c | 4 ++++
 1 file changed, 4 insertions(+)
app/test-pipeline/pipeline_hash.c +4 -0
index 548615f..dda0d4d 100644
@@ -216,6 +216,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_entries_ext = 1 << 23,
 			.signature_offset = 0,
 			.key_offset = 32,
+			.key_mask = NULL,
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -240,6 +241,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_entries = 1 << 24,
 			.signature_offset = 0,
 			.key_offset = 32,
+			.key_mask = NULL,
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -267,6 +269,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.key_offset = 32,
 			.f_hash = test_hash,
 			.seed = 0,
+			.key_mask = NULL,
 		};
 
 		struct rte_pipeline_table_params table_params = {
@@ -291,6 +294,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.key_offset = 32,
 			.f_hash = test_hash,
 			.seed = 0,
+			.key_mask = NULL
 		};
 
 		struct rte_pipeline_table_params table_params = {
Signature · 1 line
2.1.0
#6 lore raw

PATCH 6/8 example/ip_pipeline: add parse_hex_string for internal use

In reply to [email protected]

From: Fan Zhang <[email protected]>

This patch adds parse_hex_string function to parse hex string to uint8_t array.

---
 examples/ip_pipeline/config_parse.c | 70 +++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h     |  4 +++
 2 files changed, 74 insertions(+)
examples/ip_pipeline/config_parse.c +70 -0
index c9b78f9..d7ee707 100644
@@ -455,6 +455,76 @@ parse_pipeline_core(uint32_t *socket,
 	return 0;
 }
 
+static uint32_t
+get_hex_val(char c)
+{
+	switch (c) {
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+		return c - '0';
+	case 'A':
+	case 'B':
+	case 'C':
+	case 'D':
+	case 'E':
+	case 'F':
+		return c - 'A' + 10;
+	case 'a':
+	case 'b':
+	case 'c':
+	case 'd':
+	case 'e':
+	case 'f':
+		return c - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c;
+	uint32_t len, i;
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	len = strlen(src);
+	if (((len & 3) != 0) ||
+		(len > (*size) * 2))
+		return -1;
+	*size = len / 2;
+
+	for (c = src; *c != 0; c++) {
+		if ((((*c) >= '0') && ((*c) <= '9')) ||
+			(((*c) >= 'A') && ((*c) <= 'F')) ||
+			(((*c) >= 'a') && ((*c) <= 'f')))
+			continue;
+
+		return -1;
+	}
+
+	/* Convert chars to bytes */
+	for (i = 0; i < *size; i++)
+		dst[i] = get_hex_val(src[2 * i]) * 16 +
+			get_hex_val(src[2 * i + 1]);
+
+	return 0;
+}
+
 static size_t
 skip_digits(const char *src)
 {
examples/ip_pipeline/pipeline.h +4 -0
index b9a56ea..4063594 100644
@@ -84,4 +84,8 @@ pipeline_type_cmds_count(struct pipeline_type *ptype)
 	return n_cmds;
 }
 
+/* Parse hex string to uint8_t array */
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
+
 #endif
Signature · 1 line
2.1.0
#7 lore raw

PATCH 7/8 example/ip_pipeline/pipeline: update flow_classification pipeline

In reply to [email protected]

From: Fan Zhang <[email protected]>

This patch updates the flow_classification pipeline for added key_mask parameter in 8/16-byte key hash parameters. The update provides user optional key_mask configuration item applying to the packets.

---
 .../pipeline/pipeline_flow_classification_be.c     | 56 ++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c +52 -4
index 06a648d..e22f96f 100644
@@ -37,6 +37,7 @@
 #include <rte_malloc.h>
 #include <rte_table_hash.h>
 #include <rte_byteorder.h>
+#include <pipeline.h>
 
 #include "pipeline_flow_classification_be.h"
 #include "hash_func.h"
@@ -49,6 +50,7 @@ struct pipeline_flow_classification {
 	uint32_t key_offset;
 	uint32_t key_size;
 	uint32_t hash_offset;
+	uint8_t *key_mask;
 } __rte_cache_aligned;
 
 static void *
@@ -125,8 +127,12 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	uint32_t key_offset_present = 0;
 	uint32_t key_size_present = 0;
 	uint32_t hash_offset_present = 0;
+	uint32_t key_mask_present = 0;
 
 	uint32_t i;
+	char *key_mask_str = NULL;
+
+	p->hash_offset = 0;
 
 	for (i = 0; i < params->n_args; i++) {
 		char *arg_name = params->args_name[i];
@@ -171,6 +177,20 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 			continue;
 		}
 
+		/* key_mask */
+		if (strcmp(arg_name, "key_mask") == 0) {
+			if (key_mask_present)
+				return -1;
+
+			key_mask_str = strdup(arg_value);
+			if (key_mask_str == NULL)
+				return -1;
+
+			key_mask_present = 1;
+
+			continue;
+		}
+
 		/* hash_offset */
 		if (strcmp(arg_name, "hash_offset") == 0) {
 			if (hash_offset_present)
@@ -189,10 +209,23 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	/* Check that mandatory arguments are present */
 	if ((n_flows_present == 0) ||
 		(key_offset_present == 0) ||
-		(key_size_present == 0) ||
-		(hash_offset_present == 0))
+		(key_size_present == 0))
 		return -1;
 
+	if (key_mask_present) {
+		p->key_mask = rte_malloc(NULL, p->key_size, 0);
+		if (p->key_mask == NULL)
+			return -1;
+
+		if (parse_hex_string(key_mask_str, p->key_mask, &p->key_size)
+			!= 0) {
+			free(p->key_mask);
+			return -1;
+		}
+
+		free(key_mask_str);
+	}
+
 	return 0;
 }
 
@@ -297,6 +330,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
+			.key_mask = p_fc->key_mask,
 			.seed = 0,
 		};
 
@@ -307,6 +341,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
+			.key_mask = p_fc->key_mask,
 			.seed = 0,
 		};
 
@@ -336,12 +371,25 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 
 		switch (p_fc->key_size) {
 		case 8:
-			table_params.ops = &rte_table_hash_key8_lru_ops;
+			if (p_fc->hash_offset != 0) {
+				table_params.ops =
+					&rte_table_hash_key8_ext_ops;
+			} else {
+				table_params.ops =
+					&rte_table_hash_key8_ext_dosig_ops;
+			}
 			table_params.arg_create = &table_hash_key8_params;
 			break;
+			break;
 
 		case 16:
-			table_params.ops = &rte_table_hash_key16_ext_ops;
+			if (p_fc->hash_offset != 0) {
+				table_params.ops =
+					&rte_table_hash_key16_ext_ops;
+			} else {
+				table_params.ops =
+					&rte_table_hash_key16_ext_dosig_ops;
+			}
 			table_params.arg_create = &table_hash_key16_params;
 			break;
 
Signature · 1 line
2.1.0
#8 lore raw

PATCH 8/8 librte_table: modify release notes and deprecation notice

In reply to [email protected]

From: Fan Zhang <[email protected]>

The LIBABIVER number is incremented. The release notes is updated and the deprecation announce is removed.

---
 doc/guides/rel_notes/deprecation.rst | 3 ---
 doc/guides/rel_notes/release_2_2.rst | 5 ++++-
 lib/librte_table/Makefile            | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -3
index fffad80..2b6954e 100644
@@ -63,9 +63,6 @@ Deprecation Notices
 * librte_table: New functions for table entry bulk add/delete will be added
   to the table operations structure.
 
-* librte_table hash: Key mask parameter will be added to the hash table
-  parameter structure for 8-byte key and 16-byte key extendible bucket and
-  LRU tables.
 
 * librte_pipeline: The prototype for the pipeline input port, output port
   and table action handlers will be updated:
doc/guides/rel_notes/release_2_2.rst +4 -1
index 9a70dae..a62f641 100644
@@ -95,6 +95,9 @@ ABI Changes
 
 * The LPM structure is changed. The deprecated field mem_location is removed.
 
+* Key mask parameter is added to the hash table parameter structure for
+  8-byte key and 16-byte key extendible bucket and LRU tables. The
+  deprecated field mem_location is removed.
 
 Shared Library Versions
 -----------------------
@@ -127,6 +130,6 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_reorder.so.1
      librte_ring.so.1
      librte_sched.so.1
-     librte_table.so.1
+     librte_table.so.2
      librte_timer.so.1
      librte_vhost.so.1
lib/librte_table/Makefile +1 -1
index c5b3eaf..7f02af3 100644
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
 
 EXPORT_MAP := rte_table_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
Signature · 1 line
2.1.0
#9 lore raw

Re: [PATCH 8/8] librte_table: modify release notes and deprecation notice

Hi and welcome,
(it seems to be your first patch on DPDK)

2015-09-25 23:33, [email protected]:

doc/guides/rel_notes/release_2_2.rst ABI Changes · line 100

Quoted 9 lines
doc/guides/rel_notes/release_2_2.rst +3 -0
@@ -95,6 +95,9 @@ ABI Changes
 
 * The LPM structure is changed. The deprecated field mem_location is removed.
 
+* Key mask parameter is added to the hash table parameter structure for
+  8-byte key and 16-byte key extendible bucket and LRU tables. The
+  deprecated field mem_location is removed.

It seems the last sentence is a wrong copy/paste.

If a v2 is needed, please squash the release notes changes with the API changes (patches 1 and 2).

Thanks

#10 lore raw

Re: [PATCH 8/8] librte_table: modify release notes and deprecation notice

Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, October 12, 2015 3:24 PM
To: Zhang, Roy Fan
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH 8/8] librte_table: modify release notes and deprecation notice

If a v2 is needed, please squash the release notes changes with the API changes (patches 1 and 2).

Hi Thomas,

Could you clarify this? In general shouldn't we keep all lib/drivers/examples/doc changes in separate patches in the patchset?

John

#11 lore raw

v2 cover librte_table: add key_mask parameter to 8-byte key

From: Fan Zhang <[email protected]>

This patchset links to ABI change announced for librte_table. Key_mask parameters has been added to the hash table parameter structure for 8-byte key and 16-byte key extendible bucket and LRU tables.

v2:
*change in release note.

Fan Zhang (8):
librte_table: add key_mask parameter to 8-byte key hash parameters
librte_table: add key_mask parameter to 16-byte key hash parameters
librte_table: add 16 byte hash table operations with computed lookup app/test: modify app/test_table_combined and app/test_table_tables app/test-pipeline: modify pipeline test example/ip_pipeline: add parse_hex_string for internal use example/ip_pipeline/pipeline: update flow_classification pipeline
librte_table: modify release notes and deprecation notice

 app/test-pipeline/pipeline_hash.c                  |   4 +
 app/test/test_table_combined.c                     |   4 +
 app/test/test_table_tables.c                       |   6 +-
 doc/guides/rel_notes/deprecation.rst               |   3 -
 doc/guides/rel_notes/release_2_2.rst               |   4 +-
 examples/ip_pipeline/config_parse.c                |  70 ++++
 examples/ip_pipeline/pipeline.h                    |   4 +
 .../pipeline/pipeline_flow_classification_be.c     |  56 ++-
 lib/librte_table/Makefile                          |   2 +-
 lib/librte_table/rte_table_hash.h                  |  20 +
 lib/librte_table/rte_table_hash_key16.c            | 411 ++++++++++++++++++++-
 lib/librte_table/rte_table_hash_key8.c             |  54 ++-
 12 files changed, 607 insertions(+), 31 deletions(-)
Signature · 1 line
2.1.0
#12 lore raw

PATCH v2 1/8 librte_table: add key_mask parameter to 8-byte key hash parameters

From: Fan Zhang <[email protected]>

This patch relates to ABI change proposed for librte_table. key_mask parameter is added for 8-byte key extendible bucket and LRU tables.

---
 lib/librte_table/rte_table_hash.h      |  6 ++++
 lib/librte_table/rte_table_hash_key8.c | 54 +++++++++++++++++++++++++++-------
 2 files changed, 50 insertions(+), 10 deletions(-)
lib/librte_table/rte_table_hash.h +6 -0
index 9181942..ef65355 100644
@@ -196,6 +196,9 @@ struct rte_table_hash_key8_lru_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** LRU hash table operations for pre-computed key signature */
@@ -226,6 +229,9 @@ struct rte_table_hash_key8_ext_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** Extendible bucket hash table operations for pre-computed key signature */
lib/librte_table/rte_table_hash_key8.c +44 -10

148 lines not on this page · raw message

Signature · 1 line
2.1.0
#13 lore raw

PATCH v2 2/8 librte_table: add key_mask parameter to 16-byte key hash parameters

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch relates to ABI change proposed for librte_table. key_mask parameter is added for 16-byte key extendible bucket and LRU tables.

---
 lib/librte_table/rte_table_hash.h       |  6 ++++
 lib/librte_table/rte_table_hash_key16.c | 53 ++++++++++++++++++++++++++++-----
 2 files changed, 52 insertions(+), 7 deletions(-)
lib/librte_table/rte_table_hash.h +6 -0
index ef65355..e2c60e1 100644
@@ -263,6 +263,9 @@ struct rte_table_hash_key16_lru_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** LRU hash table operations for pre-computed key signature */
@@ -290,6 +293,9 @@ struct rte_table_hash_key16_ext_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** Extendible bucket operations for pre-computed key signature */
lib/librte_table/rte_table_hash_key16.c +46 -7

127 lines not on this page · raw message

Signature · 1 line
2.1.0
#14 lore raw

PATCH v2 3/8 librte_table: add 16 byte hash table operations with computed lookup

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch is to adding hash table operations for key signature computed on lookup ("do-sig") for LRU hash tables and Extendible buckets.

---
 lib/librte_table/rte_table_hash.h       |   8 +
 lib/librte_table/rte_table_hash_key16.c | 358 +++++++++++++++++++++++++++++++-
 2 files changed, 363 insertions(+), 3 deletions(-)
lib/librte_table/rte_table_hash.h +8 -0
index e2c60e1..9d17516 100644
@@ -271,6 +271,10 @@ struct rte_table_hash_key16_lru_params {
 /** LRU hash table operations for pre-computed key signature */
 extern struct rte_table_ops rte_table_hash_key16_lru_ops;
 
+/** LRU hash table operations for key signature computed on lookup
+    ("do-sig") */
+extern struct rte_table_ops rte_table_hash_key16_lru_dosig_ops;
+
 /** Extendible bucket hash table parameters */
 struct rte_table_hash_key16_ext_params {
 	/** Maximum number of entries (and keys) in the table */
@@ -301,6 +305,10 @@ struct rte_table_hash_key16_ext_params {
 /** Extendible bucket operations for pre-computed key signature */
 extern struct rte_table_ops rte_table_hash_key16_ext_ops;
 
+/** Extendible bucket hash table operations for key signature computed on
+    lookup ("do-sig") */
+extern struct rte_table_ops rte_table_hash_key16_ext_dosig_ops;
+
 /**
  * 32-byte key hash tables
  *
lib/librte_table/rte_table_hash_key16.c +355 -3

405 lines not on this page · raw message

Signature · 1 line
2.1.0
#15 lore raw

PATCH v2 4/8 app/test: modify app/test_table_combined and app/test_table_tables

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

Tests have been updated to work on added key_mask parameter for 8-byte key extendible bucket and LRU tables.

---
 app/test/test_table_combined.c | 4 ++++
 app/test/test_table_tables.c   | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
app/test/test_table_combined.c +4 -0
index dd09da5..359ac45 100644
@@ -419,6 +419,7 @@ test_table_hash8lru(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key8lru[8];
@@ -477,6 +478,7 @@ test_table_hash16lru(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key16lru[16];
@@ -594,6 +596,7 @@ test_table_hash8ext(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key8ext[8];
@@ -660,6 +663,7 @@ test_table_hash16ext(void)
 		.seed = 0,
 		.signature_offset = 0,
 		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	uint8_t key16ext[16];
app/test/test_table_tables.c +4 -2
index 566964b..cc222f1 100644
@@ -651,7 +651,8 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
 		.signature_offset = 1,
-		.key_offset = 32
+		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	hash_params.n_entries = 0;
@@ -766,7 +767,8 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
 		.signature_offset = 1,
-		.key_offset = 32
+		.key_offset = 32,
+		.key_mask = NULL,
 	};
 
 	hash_params.n_entries = 0;
Signature · 1 line
2.1.0
#16 lore raw

PATCH v2 5/8 app/test-pipeline: modify pipeline test

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

Test-pipeline have been updated to work on added key_mask parameter for 8-byte key extendible bucket and LRU tables.

---
 app/test-pipeline/pipeline_hash.c | 4 ++++
 1 file changed, 4 insertions(+)
app/test-pipeline/pipeline_hash.c +4 -0
index 548615f..dda0d4d 100644
@@ -216,6 +216,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_entries_ext = 1 << 23,
 			.signature_offset = 0,
 			.key_offset = 32,
+			.key_mask = NULL,
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -240,6 +241,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_entries = 1 << 24,
 			.signature_offset = 0,
 			.key_offset = 32,
+			.key_mask = NULL,
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -267,6 +269,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.key_offset = 32,
 			.f_hash = test_hash,
 			.seed = 0,
+			.key_mask = NULL,
 		};
 
 		struct rte_pipeline_table_params table_params = {
@@ -291,6 +294,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.key_offset = 32,
 			.f_hash = test_hash,
 			.seed = 0,
+			.key_mask = NULL
 		};
 
 		struct rte_pipeline_table_params table_params = {
Signature · 1 line
2.1.0
#17 lore raw

PATCH v2 6/8 example/ip_pipeline: add parse_hex_string for internal use

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch adds parse_hex_string function to parse hex string to uint8_t array.

---
 examples/ip_pipeline/config_parse.c | 70 +++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h     |  4 +++
 2 files changed, 74 insertions(+)
examples/ip_pipeline/config_parse.c +70 -0
index c9b78f9..d7ee707 100644
@@ -455,6 +455,76 @@ parse_pipeline_core(uint32_t *socket,
 	return 0;
 }
 
+static uint32_t
+get_hex_val(char c)
+{
+	switch (c) {
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+		return c - '0';
+	case 'A':
+	case 'B':
+	case 'C':
+	case 'D':
+	case 'E':
+	case 'F':
+		return c - 'A' + 10;
+	case 'a':
+	case 'b':
+	case 'c':
+	case 'd':
+	case 'e':
+	case 'f':
+		return c - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c;
+	uint32_t len, i;
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	len = strlen(src);
+	if (((len & 3) != 0) ||
+		(len > (*size) * 2))
+		return -1;
+	*size = len / 2;
+
+	for (c = src; *c != 0; c++) {
+		if ((((*c) >= '0') && ((*c) <= '9')) ||
+			(((*c) >= 'A') && ((*c) <= 'F')) ||
+			(((*c) >= 'a') && ((*c) <= 'f')))
+			continue;
+
+		return -1;
+	}
+
+	/* Convert chars to bytes */
+	for (i = 0; i < *size; i++)
+		dst[i] = get_hex_val(src[2 * i]) * 16 +
+			get_hex_val(src[2 * i + 1]);
+
+	return 0;
+}
+
 static size_t
 skip_digits(const char *src)
 {
examples/ip_pipeline/pipeline.h +4 -0
index b9a56ea..4063594 100644
@@ -84,4 +84,8 @@ pipeline_type_cmds_count(struct pipeline_type *ptype)
 	return n_cmds;
 }
 
+/* Parse hex string to uint8_t array */
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
+
 #endif
Signature · 1 line
2.1.0
#18 lore raw

Re: [PATCH v2 6/8] example/ip_pipeline: add parse_hex_string for internal use

2015-10-13 14:57, Jasvinder Singh:

Quoted 60 lines

From: Fan Zhang <[email protected]>

examples/ip_pipeline/config_parse.c +59 -0
+static uint32_t
+get_hex_val(char c)
+{
+	switch (c) {
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+		return c - '0';
+	case 'A':
+	case 'B':
+	case 'C':
+	case 'D':
+	case 'E':
+	case 'F':
+		return c - 'A' + 10;
+	case 'a':
+	case 'b':
+	case 'c':
+	case 'd':
+	case 'e':
+	case 'f':
+		return c - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c;
+	uint32_t len, i;
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	len = strlen(src);
+	if (((len & 3) != 0) ||
+		(len > (*size) * 2))
+		return -1;
+	*size = len / 2;
+
+	for (c = src; *c != 0; c++) {
+		if ((((*c) >= '0') && ((*c) <= '9')) ||
+			(((*c) >= 'A') && ((*c) <= 'F')) ||
+			(((*c) >= 'a') && ((*c) <= 'f')))
+			continue;
+

examples/ip_pipeline/config_parse.c parse_pipeline_core(uint32_t *socket, · line 526

Quoted 10 lines
examples/ip_pipeline/config_parse.c +10 -0
+		return -1;
+	}
+
+	/* Convert chars to bytes */
+	for (i = 0; i < *size; i++)
+		dst[i] = get_hex_val(src[2 * i]) * 16 +
+			get_hex_val(src[2 * i + 1]);
+
+	return 0;
+}

Why not use strtol()?

#19 lore raw

Re: [PATCH v2 6/8] example/ip_pipeline: add parse_hex_string for internal use

Quoted 75 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, October 19, 2015 4:50 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 6/8] example/ip_pipeline: add parse_hex_string for internal use

2015-10-13 14:57, Jasvinder Singh:

Quoted 64 lines

From: Fan Zhang <[email protected]>

examples/ip_pipeline/config_parse.c +63 -0
+static uint32_t
+get_hex_val(char c)
+{
+	switch (c) {
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+		return c - '0';
+	case 'A':
+	case 'B':
+	case 'C':
+	case 'D':
+	case 'E':
+	case 'F':
+		return c - 'A' + 10;
+	case 'a':
+	case 'b':
+	case 'c':
+	case 'd':
+	case 'e':
+	case 'f':
+		return c - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c;
+	uint32_t len, i;
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	len = strlen(src);
+	if (((len & 3) != 0) ||
+		(len > (*size) * 2))
+		return -1;
+	*size = len / 2;
+
+	for (c = src; *c != 0; c++) {
+		if ((((*c) >= '0') && ((*c) <= '9')) ||
+			(((*c) >= 'A') && ((*c) <= 'F')) ||
+			(((*c) >= 'a') && ((*c) <= 'f')))
+			continue;
+
+		return -1;
+	}
+
+	/* Convert chars to bytes */
Quoted 8 lines

examples/ip_pipeline/config_parse.c parse_pipeline_core(uint32_t *socket, · line 526

Quoted 6 lines
examples/ip_pipeline/config_parse.c +6 -0
+	for (i = 0; i < *size; i++)
+		dst[i] = get_hex_val(src[2 * i]) * 16 +
+			get_hex_val(src[2 * i + 1]);
+
+	return 0;
+}

Why not use strtol()?

Strtol() was considered, but the code would have been more complicated (more corner case errors to handle) and less readable (more difficult to maintain), so our vote went for this simpler solution.

This function needs to convert an array of characters of up to 128 hex digits to the associated array of bytes, with output byte on position I representing the value of the i-th pair of input characters. For example, "010203" gets converted to array [1, 2, 3]. It only needs very simple math, which leads to the above code, which looks very readable.

Strtol() was not really intended for this. Strtol() is primarily intended to convert up to 8 characters to the associated value. Using strtol() would be possible to use (to convert each 2 characters to the byte) but we end up with a lot of error cases to handle, which leads to more complex code in our opinion.

Thanks,
Cristian

#20 lore raw

PATCH v2 7/8 example/ip_pipeline/pipeline: update flow_classification pipeline

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch updates the flow_classification pipeline for added key_mask parameter in 8/16-byte key hash parameters. The update provides user optional key_mask configuration item applying to the packets.

---
 .../pipeline/pipeline_flow_classification_be.c     | 56 ++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c +52 -4
index 06a648d..e22f96f 100644
@@ -37,6 +37,7 @@
 #include <rte_malloc.h>
 #include <rte_table_hash.h>
 #include <rte_byteorder.h>
+#include <pipeline.h>
 
 #include "pipeline_flow_classification_be.h"
 #include "hash_func.h"
@@ -49,6 +50,7 @@ struct pipeline_flow_classification {
 	uint32_t key_offset;
 	uint32_t key_size;
 	uint32_t hash_offset;
+	uint8_t *key_mask;
 } __rte_cache_aligned;
 
 static void *
@@ -125,8 +127,12 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	uint32_t key_offset_present = 0;
 	uint32_t key_size_present = 0;
 	uint32_t hash_offset_present = 0;
+	uint32_t key_mask_present = 0;
 
 	uint32_t i;
+	char *key_mask_str = NULL;
+
+	p->hash_offset = 0;
 
 	for (i = 0; i < params->n_args; i++) {
 		char *arg_name = params->args_name[i];
@@ -171,6 +177,20 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 			continue;
 		}
 
+		/* key_mask */
+		if (strcmp(arg_name, "key_mask") == 0) {
+			if (key_mask_present)
+				return -1;
+
+			key_mask_str = strdup(arg_value);
+			if (key_mask_str == NULL)
+				return -1;
+
+			key_mask_present = 1;
+
+			continue;
+		}
+
 		/* hash_offset */
 		if (strcmp(arg_name, "hash_offset") == 0) {
 			if (hash_offset_present)
@@ -189,10 +209,23 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	/* Check that mandatory arguments are present */
 	if ((n_flows_present == 0) ||
 		(key_offset_present == 0) ||
-		(key_size_present == 0) ||
-		(hash_offset_present == 0))
+		(key_size_present == 0))
 		return -1;
 
+	if (key_mask_present) {
+		p->key_mask = rte_malloc(NULL, p->key_size, 0);
+		if (p->key_mask == NULL)
+			return -1;
+
+		if (parse_hex_string(key_mask_str, p->key_mask, &p->key_size)
+			!= 0) {
+			free(p->key_mask);
+			return -1;
+		}
+
+		free(key_mask_str);
+	}
+
 	return 0;
 }
 
@@ -297,6 +330,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
+			.key_mask = p_fc->key_mask,
 			.seed = 0,
 		};
 
@@ -307,6 +341,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
+			.key_mask = p_fc->key_mask,
 			.seed = 0,
 		};
 
@@ -336,12 +371,25 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 
 		switch (p_fc->key_size) {
 		case 8:
-			table_params.ops = &rte_table_hash_key8_lru_ops;
+			if (p_fc->hash_offset != 0) {
+				table_params.ops =
+					&rte_table_hash_key8_ext_ops;
+			} else {
+				table_params.ops =
+					&rte_table_hash_key8_ext_dosig_ops;
+			}
 			table_params.arg_create = &table_hash_key8_params;
 			break;
+			break;
 
 		case 16:
-			table_params.ops = &rte_table_hash_key16_ext_ops;
+			if (p_fc->hash_offset != 0) {
+				table_params.ops =
+					&rte_table_hash_key16_ext_ops;
+			} else {
+				table_params.ops =
+					&rte_table_hash_key16_ext_dosig_ops;
+			}
 			table_params.arg_create = &table_hash_key16_params;
 			break;
 
Signature · 1 line
2.1.0
#21 lore raw

Re: [PATCH v2 7/8] example/ip_pipeline/pipeline: update flow_classification pipeline

2015-10-13 14:57, Jasvinder Singh:

examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c static void *pipeline_fc_init(struct pipeline_params *params, · line 392

Quoted 4 lines

From: Fan Zhang <[email protected]>

examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c +3 -0
+				table_params.ops =
+					&rte_table_hash_key16_ext_dosig_ops;
+			}

It doesn't build with shared library.
pipeline_flow_classification_be.c:(.text+0xa84): undefined reference to `rte_table_hash_key16_ext_dosig_ops'

Some functions are missing in lib/librte_table/rte_table_version.map

#22 lore raw

PATCH v2 8/8 librte_table: modify release notes and deprecation notice

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

The LIBABIVER number is incremented. The release notes is updated and the deprecation announce is removed.

---
 doc/guides/rel_notes/deprecation.rst | 3 ---
 doc/guides/rel_notes/release_2_2.rst | 4 +++-
 lib/librte_table/Makefile            | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -3
index fa55117..06e0078 100644
@@ -56,9 +56,6 @@ Deprecation Notices
 * librte_table: New functions for table entry bulk add/delete will be added
   to the table operations structure.
 
-* librte_table hash: Key mask parameter will be added to the hash table
-  parameter structure for 8-byte key and 16-byte key extendible bucket and
-  LRU tables.
 
 * librte_pipeline: The prototype for the pipeline input port, output port
   and table action handlers will be updated:
doc/guides/rel_notes/release_2_2.rst +3 -1
index 5687676..30197ec 100644
@@ -98,6 +98,8 @@ ABI Changes
 
 * The LPM structure is changed. The deprecated field mem_location is removed.
 
+* Key mask parameter is added to the hash table parameter structure for
+  8-byte key and 16-byte key extendible bucket and LRU tables.
 
 Shared Library Versions
 -----------------------
@@ -130,6 +132,6 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_reorder.so.1
      librte_ring.so.1
      librte_sched.so.1
-     librte_table.so.1
+     librte_table.so.2
      librte_timer.so.1
      librte_vhost.so.1
lib/librte_table/Makefile +1 -1
index c5b3eaf..7f02af3 100644
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
 
 EXPORT_MAP := rte_table_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
Signature · 1 line
2.1.0
#23 lore raw

v3 cover librte_table: add key_mask parameter to hash table parameter structure

In reply to Jasvinder Singh

This patchset links to ABI change announced for librte_table. The key_mask parameters has been added to the hash table parameter structure for 8-byte key and 16-byte key extendible bucket and LRU tables.

v2:
*updated release note

v3:
*merged release note with source code patch
*fixed build error: added missing symbol to
librte_table/rte_table_version.map

Fan Zhang (6):
librte_table: add 16 byte hash table operations with computed lookup app/test: modify app/test_table_combined and app/test_table_tables app/test-pipeline: modify pipeline test example/ip_pipeline: add parse_hex_string for internal use example/ip_pipeline/pipeline: update flow_classification pipeline
librte_table: add key_mask parameter to 8- and 16-bytes key hash
parameters

 app/test-pipeline/pipeline_hash.c                  |   4 +
 app/test/test_table_combined.c                     |   5 +-
 app/test/test_table_tables.c                       |   6 +-
 doc/guides/rel_notes/deprecation.rst               |   4 -
 doc/guides/rel_notes/release_2_2.rst               |   4 +
 examples/ip_pipeline/config_parse.c                |  70 ++++
 examples/ip_pipeline/pipeline.h                    |   4 +
 .../pipeline/pipeline_flow_classification_be.c     |  56 ++-
 lib/librte_table/rte_table_hash.h                  |  20 +
 lib/librte_table/rte_table_hash_key16.c            | 411 ++++++++++++++++++++-
 lib/librte_table/rte_table_hash_key8.c             |  54 ++-
 lib/librte_table/rte_table_version.map             |   7 +
 12 files changed, 614 insertions(+), 31 deletions(-)
Signature · 1 line
2.1.0
#24 lore raw

PATCH v3 1/6 librte_table: add key_mask parameter to 8- and 16-bytes key hash parameters

From: Fan Zhang <[email protected]>

This patch relates to ABI change proposed for librte_table. The key_mask parameter is added for 8-byte and 16-byte key extendible bucket and LRU tables.The release notes is updated and the deprecation notice is removed.

---
 doc/guides/rel_notes/deprecation.rst    |  4 ---
 doc/guides/rel_notes/release_2_2.rst    |  4 +++
 lib/librte_table/rte_table_hash.h       | 12 ++++++++
 lib/librte_table/rte_table_hash_key16.c | 52 ++++++++++++++++++++++++++-----
 lib/librte_table/rte_table_hash_key8.c  | 54 +++++++++++++++++++++++++++------
 lib/librte_table/rte_table_version.map  |  7 +++++
 6 files changed, 112 insertions(+), 21 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -4
index 018a119..f8b8ca9 100644
@@ -48,10 +48,6 @@ Deprecation Notices
 * librte_table: New functions for table entry bulk add/delete will be added
   to the table operations structure.
 
-* librte_table hash: Key mask parameter will be added to the hash table
-  parameter structure for 8-byte key and 16-byte key extendible bucket and
-  LRU tables.
-
 * librte_pipeline: The prototype for the pipeline input port, output port
   and table action handlers will be updated:
   the pipeline parameter will be added, the packets mask parameter will be
doc/guides/rel_notes/release_2_2.rst +4 -0
index 4f75cff..deb36c7 100644
@@ -117,6 +117,10 @@ ABI Changes
 * librte_port: Macros to access the packet meta-data stored within the packet
   buffer has been adjusted to cover the packet mbuf structure.
 
+* librte_table hash: The key mask parameter is added to the hash table
+  parameter structure for 8-byte key and 16-byte key extendible bucket
+  and LRU tables.
+
 
 Shared Library Versions
 -----------------------
lib/librte_table/rte_table_hash.h +12 -0
index 9181942..e2c60e1 100644
@@ -196,6 +196,9 @@ struct rte_table_hash_key8_lru_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** LRU hash table operations for pre-computed key signature */
@@ -226,6 +229,9 @@ struct rte_table_hash_key8_ext_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** Extendible bucket hash table operations for pre-computed key signature */
@@ -257,6 +263,9 @@ struct rte_table_hash_key16_lru_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** LRU hash table operations for pre-computed key signature */
@@ -284,6 +293,9 @@ struct rte_table_hash_key16_ext_params {
 
 	/** Byte offset within packet meta-data where the key is located */
 	uint32_t key_offset;
+
+	/** Bit-mask to be AND-ed to the key on lookup */
+	uint8_t *key_mask;
 };
 
 /** Extendible bucket operations for pre-computed key signature */
lib/librte_table/rte_table_hash_key16.c +45 -7

123 lines not on this page · raw message

lib/librte_table/rte_table_hash_key8.c +44 -10

148 lines not on this page · raw message

lib/librte_table/rte_table_version.map +7 -0
index d33f926..f767a50 100644
@@ -19,3 +19,10 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_2.2 {
+	global:
+
+	rte_table_hash_key16_ext_dosig_ops;
+
+} DPDK_2.0;
\ No newline at end of file
Signature · 1 line
2.1.0
#25 lore raw

PATCH v3 2/6 librte_table: add 16 byte hash table operations with computed lookup

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch is to adding hash table operations for key signature computed on lookup ("do-sig") for LRU hash tables and Extendible buckets.

---
 lib/librte_table/rte_table_hash.h       |   8 +
 lib/librte_table/rte_table_hash_key16.c | 359 +++++++++++++++++++++++++++++++-
 2 files changed, 364 insertions(+), 3 deletions(-)
lib/librte_table/rte_table_hash.h +8 -0
index e2c60e1..9d17516 100644
@@ -271,6 +271,10 @@ struct rte_table_hash_key16_lru_params {
 /** LRU hash table operations for pre-computed key signature */
 extern struct rte_table_ops rte_table_hash_key16_lru_ops;
 
+/** LRU hash table operations for key signature computed on lookup
+    ("do-sig") */
+extern struct rte_table_ops rte_table_hash_key16_lru_dosig_ops;
+
 /** Extendible bucket hash table parameters */
 struct rte_table_hash_key16_ext_params {
 	/** Maximum number of entries (and keys) in the table */
@@ -301,6 +305,10 @@ struct rte_table_hash_key16_ext_params {
 /** Extendible bucket operations for pre-computed key signature */
 extern struct rte_table_ops rte_table_hash_key16_ext_ops;
 
+/** Extendible bucket hash table operations for key signature computed on
+    lookup ("do-sig") */
+extern struct rte_table_ops rte_table_hash_key16_ext_dosig_ops;
+
 /**
  * 32-byte key hash tables
  *
lib/librte_table/rte_table_hash_key16.c +356 -3

406 lines not on this page · raw message

Signature · 1 line
2.1.0
#26 lore raw

PATCH v3 3/6 app/test: modify app/test_table_combined and app/test_table_tables

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

Tests have been updated to work on added key_mask parameter for 8-byte key extendible bucket and LRU tables.

---
 app/test/test_table_combined.c | 5 ++++-
 app/test/test_table_tables.c   | 6 ++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
app/test/test_table_combined.c +4 -1
index 18daeec..8bf4aeb 100644
@@ -418,9 +418,9 @@ test_table_hash8lru(void)
 	struct rte_table_hash_key8_lru_params key8lru_params = {
 		.n_entries = 1<<24,
 		.f_hash = pipeline_test_hash,
-		.seed = 0,
 		.signature_offset = APP_METADATA_OFFSET(0),
 		.key_offset = APP_METADATA_OFFSET(32),
+		.key_mask = NULL,
 	};
 
 	uint8_t key8lru[8];
@@ -479,6 +479,7 @@ test_table_hash16lru(void)
 		.seed = 0,
 		.signature_offset = APP_METADATA_OFFSET(0),
 		.key_offset = APP_METADATA_OFFSET(32),
+		.key_mask = NULL,
 	};
 
 	uint8_t key16lru[16];
@@ -596,6 +597,7 @@ test_table_hash8ext(void)
 		.seed = 0,
 		.signature_offset = APP_METADATA_OFFSET(0),
 		.key_offset = APP_METADATA_OFFSET(32),
+		.key_mask = NULL,
 	};
 
 	uint8_t key8ext[8];
@@ -662,6 +664,7 @@ test_table_hash16ext(void)
 		.seed = 0,
 		.signature_offset = APP_METADATA_OFFSET(0),
 		.key_offset = APP_METADATA_OFFSET(32),
+		.key_mask = NULL,
 	};
 
 	uint8_t key16ext[16];
app/test/test_table_tables.c +4 -2
index cf7c62d..b6364c4 100644
@@ -669,7 +669,8 @@ test_table_hash_lru_generic(struct rte_table_ops *ops)
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
 		.signature_offset = APP_METADATA_OFFSET(1),
-		.key_offset = APP_METADATA_OFFSET(32)
+		.key_offset = APP_METADATA_OFFSET(32),
+		.key_mask = NULL,
 	};
 
 	hash_params.n_entries = 0;
@@ -784,7 +785,8 @@ test_table_hash_ext_generic(struct rte_table_ops *ops)
 		.f_hash = pipeline_test_hash,
 		.seed = 0,
 		.signature_offset = APP_METADATA_OFFSET(1),
-		.key_offset = APP_METADATA_OFFSET(32)
+		.key_offset = APP_METADATA_OFFSET(32),
+		.key_mask = NULL,
 	};
 
 	hash_params.n_entries = 0;
Signature · 1 line
2.1.0
#27 lore raw

PATCH v3 4/6 app/test-pipeline: modify pipeline test

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

Test-pipeline has been updated to work on added
key_mask parameter for 8-byte key extendible
bucket and LRU tables.

---
 app/test-pipeline/pipeline_hash.c | 4 ++++
 1 file changed, 4 insertions(+)
app/test-pipeline/pipeline_hash.c +4 -0
index 5e4e17f..8b888d7 100644
@@ -216,6 +216,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_entries_ext = 1 << 23,
 			.signature_offset = APP_METADATA_OFFSET(0),
 			.key_offset = APP_METADATA_OFFSET(32),
+			.key_mask = NULL,
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -240,6 +241,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.n_entries = 1 << 24,
 			.signature_offset = APP_METADATA_OFFSET(0),
 			.key_offset = APP_METADATA_OFFSET(32),
+			.key_mask = NULL,
 			.f_hash = test_hash,
 			.seed = 0,
 		};
@@ -267,6 +269,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
+			.key_mask = NULL,
 		};
 
 		struct rte_pipeline_table_params table_params = {
@@ -291,6 +294,7 @@ app_main_loop_worker_pipeline_hash(void) {
 			.key_offset = APP_METADATA_OFFSET(32),
 			.f_hash = test_hash,
 			.seed = 0,
+			.key_mask = NULL,
 		};
 
 		struct rte_pipeline_table_params table_params = {
Signature · 1 line
2.1.0
#28 lore raw

PATCH v3 5/6 example/ip_pipeline: add parse_hex_string for internal use

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch adds parse_hex_string function to parse hex string to uint8_t array.

---
 examples/ip_pipeline/config_parse.c | 70 +++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h     |  4 +++
 2 files changed, 74 insertions(+)
examples/ip_pipeline/config_parse.c +70 -0
index c9b78f9..d7ee707 100644
@@ -455,6 +455,76 @@ parse_pipeline_core(uint32_t *socket,
 	return 0;
 }
 
+static uint32_t
+get_hex_val(char c)
+{
+	switch (c) {
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+		return c - '0';
+	case 'A':
+	case 'B':
+	case 'C':
+	case 'D':
+	case 'E':
+	case 'F':
+		return c - 'A' + 10;
+	case 'a':
+	case 'b':
+	case 'c':
+	case 'd':
+	case 'e':
+	case 'f':
+		return c - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c;
+	uint32_t len, i;
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	len = strlen(src);
+	if (((len & 3) != 0) ||
+		(len > (*size) * 2))
+		return -1;
+	*size = len / 2;
+
+	for (c = src; *c != 0; c++) {
+		if ((((*c) >= '0') && ((*c) <= '9')) ||
+			(((*c) >= 'A') && ((*c) <= 'F')) ||
+			(((*c) >= 'a') && ((*c) <= 'f')))
+			continue;
+
+		return -1;
+	}
+
+	/* Convert chars to bytes */
+	for (i = 0; i < *size; i++)
+		dst[i] = get_hex_val(src[2 * i]) * 16 +
+			get_hex_val(src[2 * i + 1]);
+
+	return 0;
+}
+
 static size_t
 skip_digits(const char *src)
 {
examples/ip_pipeline/pipeline.h +4 -0
index b9a56ea..4063594 100644
@@ -84,4 +84,8 @@ pipeline_type_cmds_count(struct pipeline_type *ptype)
 	return n_cmds;
 }
 
+/* Parse hex string to uint8_t array */
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
+
 #endif
Signature · 1 line
2.1.0
#29 lore raw

PATCH v3 6/6 example/ip_pipeline/pipeline: update flow_classification pipeline

In reply to Jasvinder Singh

From: Fan Zhang <[email protected]>

This patch updates the flow_classification pipeline for added key_mask parameter in 8/16-byte key hash parameters. The update provides user optional key_mask configuration item applying to the packets.

---
 .../pipeline/pipeline_flow_classification_be.c     | 56 ++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c +52 -4
index 06a648d..e22f96f 100644
@@ -37,6 +37,7 @@
 #include <rte_malloc.h>
 #include <rte_table_hash.h>
 #include <rte_byteorder.h>
+#include <pipeline.h>
 
 #include "pipeline_flow_classification_be.h"
 #include "hash_func.h"
@@ -49,6 +50,7 @@ struct pipeline_flow_classification {
 	uint32_t key_offset;
 	uint32_t key_size;
 	uint32_t hash_offset;
+	uint8_t *key_mask;
 } __rte_cache_aligned;
 
 static void *
@@ -125,8 +127,12 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	uint32_t key_offset_present = 0;
 	uint32_t key_size_present = 0;
 	uint32_t hash_offset_present = 0;
+	uint32_t key_mask_present = 0;
 
 	uint32_t i;
+	char *key_mask_str = NULL;
+
+	p->hash_offset = 0;
 
 	for (i = 0; i < params->n_args; i++) {
 		char *arg_name = params->args_name[i];
@@ -171,6 +177,20 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 			continue;
 		}
 
+		/* key_mask */
+		if (strcmp(arg_name, "key_mask") == 0) {
+			if (key_mask_present)
+				return -1;
+
+			key_mask_str = strdup(arg_value);
+			if (key_mask_str == NULL)
+				return -1;
+
+			key_mask_present = 1;
+
+			continue;
+		}
+
 		/* hash_offset */
 		if (strcmp(arg_name, "hash_offset") == 0) {
 			if (hash_offset_present)
@@ -189,10 +209,23 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	/* Check that mandatory arguments are present */
 	if ((n_flows_present == 0) ||
 		(key_offset_present == 0) ||
-		(key_size_present == 0) ||
-		(hash_offset_present == 0))
+		(key_size_present == 0))
 		return -1;
 
+	if (key_mask_present) {
+		p->key_mask = rte_malloc(NULL, p->key_size, 0);
+		if (p->key_mask == NULL)
+			return -1;
+
+		if (parse_hex_string(key_mask_str, p->key_mask, &p->key_size)
+			!= 0) {
+			free(p->key_mask);
+			return -1;
+		}
+
+		free(key_mask_str);
+	}
+
 	return 0;
 }
 
@@ -297,6 +330,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
+			.key_mask = p_fc->key_mask,
 			.seed = 0,
 		};
 
@@ -307,6 +341,7 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
+			.key_mask = p_fc->key_mask,
 			.seed = 0,
 		};
 
@@ -336,12 +371,25 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 
 		switch (p_fc->key_size) {
 		case 8:
-			table_params.ops = &rte_table_hash_key8_lru_ops;
+			if (p_fc->hash_offset != 0) {
+				table_params.ops =
+					&rte_table_hash_key8_ext_ops;
+			} else {
+				table_params.ops =
+					&rte_table_hash_key8_ext_dosig_ops;
+			}
 			table_params.arg_create = &table_hash_key8_params;
 			break;
+			break;
 
 		case 16:
-			table_params.ops = &rte_table_hash_key16_ext_ops;
+			if (p_fc->hash_offset != 0) {
+				table_params.ops =
+					&rte_table_hash_key16_ext_ops;
+			} else {
+				table_params.ops =
+					&rte_table_hash_key16_ext_dosig_ops;
+			}
 			table_params.arg_create = &table_hash_key16_params;
 			break;
 
Signature · 1 line
2.1.0
#30 lore raw

Re: [PATCH 8/8] librte_table: modify release notes and deprecation notice

In reply to Mcnamara, John

2015-10-12 16:30, Mcnamara, John:

Quoted 7 lines

From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon

Quoted 2 lines

If a v2 is needed, please squash the release notes changes with the API changes (patches 1 and 2).

Hi Thomas,

Could you clarify this? In general shouldn't we keep all lib/drivers/examples/doc changes in separate patches in the patchset?

Why should we?
When reviewing a patch, having the doc atomically updated with the code change will help to understand it.

Acked-by on the v1 series
#31 lore raw
In reply to [email protected]
Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, September 25, 2015 11:33 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/8] librte_table: add key_mask parameter to 8- byte key

Quoted 6 lines

From: Fan Zhang <[email protected]>

This patchset links to ABI change announced for librte_table. Key_mask parameters has been added to the hash table parameter structure for 8-byte key and 16-byte key extendible bucket and LRU tables.