DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alexander Kozyrev <akozyrev@nvidia.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <ferruh.yigit@amd.com>,
	<andrew.rybchenko@oktetlabs.ru>, <orika@nvidia.com>
Subject: [PATCH 4/4] app/testpmd: add template table hash calculation function
Date: Sat, 21 Jan 2023 07:21:58 +0200	[thread overview]
Message-ID: <20230121052158.2928238-5-akozyrev@nvidia.com> (raw)
In-Reply-To: <20230121052158.2928238-1-akozyrev@nvidia.com>

Add testpmd CLI interface for a template table hash function.
Available types are: default, linear, crc32 and crc16.
flow template_table 0 create table_id 0 hash_func linear ...

Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 69 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index f1d6813baa..007d31c5cf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -180,6 +180,8 @@ enum index {
 	TABLE_DESTROY_ID,
 	TABLE_INSERTION_TYPE,
 	TABLE_INSERTION_TYPE_NAME,
+	TABLE_HASH_FUNC,
+	TABLE_HASH_FUNC_NAME,
 	TABLE_GROUP,
 	TABLE_PRIORITY,
 	TABLE_INGRESS,
@@ -808,7 +810,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"hash_result", NULL
 };
 
 static const char *const meter_colors[] = {
@@ -819,6 +822,10 @@ static const char *const table_insertion_types[] = {
 	"pattern", "index", NULL
 };
 
+static const char *const table_hash_funcs[] = {
+	"default", "linear", "crc32", "crc16", NULL
+};
+
 #define RAW_IPSEC_CONFS_MAX_NUM 8
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
@@ -1163,6 +1170,7 @@ static const enum index next_table_attr[] = {
 	TABLE_CREATE_ID,
 	TABLE_GROUP,
 	TABLE_INSERTION_TYPE,
+	TABLE_HASH_FUNC,
 	TABLE_PRIORITY,
 	TABLE_INGRESS,
 	TABLE_EGRESS,
@@ -2417,6 +2425,9 @@ static int parse_meter_color(struct context *ctx, const struct token *token,
 static int parse_insertion_table_type(struct context *ctx, const struct token *token,
 				      const char *str, unsigned int len, void *buf,
 				      unsigned int size);
+static int parse_hash_table_type(struct context *ctx, const struct token *token,
+				 const char *str, unsigned int len, void *buf,
+				 unsigned int size);
 static int comp_none(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_boolean(struct context *, const struct token *,
@@ -2451,6 +2462,8 @@ static int comp_meter_color(struct context *, const struct token *,
 			    unsigned int, char *, unsigned int);
 static int comp_insertion_table_type(struct context *, const struct token *,
 				     unsigned int, char *, unsigned int);
+static int comp_hash_table_type(struct context *, const struct token *,
+				unsigned int, char *, unsigned int);
 
 /** Token definitions. */
 static const struct token token_list[] = {
@@ -2935,6 +2948,20 @@ static const struct token token_list[] = {
 		.call = parse_insertion_table_type,
 		.comp = comp_insertion_table_type,
 	},
+	[TABLE_HASH_FUNC] = {
+		.name = "hash_func",
+		.help = "specify hash calculation function",
+		.next = NEXT(next_table_attr,
+			     NEXT_ENTRY(TABLE_HASH_FUNC_NAME)),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
+					args.table.attr.hash_func)),
+	},
+	[TABLE_HASH_FUNC_NAME] = {
+		.name = "hash_func_name",
+		.help = "hash calculation function name",
+		.call = parse_hash_table_type,
+		.comp = comp_hash_table_type,
+	},
 	[TABLE_GROUP] = {
 		.name = "group",
 		.help = "specify a group",
@@ -10123,6 +10150,32 @@ parse_insertion_table_type(struct context *ctx, const struct token *token,
 	return ret > 0 ? (int)len : ret;
 }
 
+/** Parse Hash Calculation Table Type name */
+static int
+parse_hash_table_type(struct context *ctx, const struct token *token,
+		      const char *str, unsigned int len, void *buf,
+		      unsigned int size)
+{
+	const struct arg *arg = pop_args(ctx);
+	unsigned int i;
+	char tmp[2];
+	int ret;
+
+	(void)size;
+	/* Argument is expected. */
+	if (!arg)
+		return -1;
+	for (i = 0; table_hash_funcs[i]; ++i)
+		if (!strcmp_partial(table_hash_funcs[i], str, len))
+			break;
+	if (!table_hash_funcs[i])
+		return -1;
+	push_args(ctx, arg);
+	snprintf(tmp, sizeof(tmp), "%u", i);
+	ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
+	return ret > 0 ? (int)len : ret;
+}
+
 /** No completion. */
 static int
 comp_none(struct context *ctx, const struct token *token,
@@ -10442,6 +10495,20 @@ comp_insertion_table_type(struct context *ctx, const struct token *token,
 	return -1;
 }
 
+/** Complete available Hash Calculation Table types. */
+static int
+comp_hash_table_type(struct context *ctx, const struct token *token,
+		     unsigned int ent, char *buf, unsigned int size)
+{
+	RTE_SET_USED(ctx);
+	RTE_SET_USED(token);
+	if (!buf)
+		return RTE_DIM(table_hash_funcs);
+	if (ent < RTE_DIM(table_hash_funcs) - 1)
+		return rte_strscpy(buf, table_hash_funcs[ent], size);
+	return -1;
+}
+
 /** Internal context. */
 static struct context cmd_flow_context;
 
-- 
2.18.2


  parent reply	other threads:[~2023-01-21  5:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14  2:21 [RFC] ethdev: add template table insertion and matching types Alexander Kozyrev
2023-01-08 14:22 ` Ori Kam
2023-01-18  8:50 ` Thomas Monjalon
2023-01-20 23:06   ` Alexander Kozyrev
2023-01-22 20:55     ` Thomas Monjalon
2023-01-23 22:02       ` Alexander Kozyrev
2023-01-30 14:47         ` Thomas Monjalon
2023-01-21  5:21 ` [PATCH 0/4] " Alexander Kozyrev
2023-01-21  5:21   ` [PATCH 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-01-21  5:21   ` [PATCH 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-01-21  5:21   ` [PATCH 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-01-21  5:21   ` Alexander Kozyrev [this message]
2023-01-26 23:27   ` [PATCH v2 0/4] ethdev: add template table insertion and matching types Alexander Kozyrev
2023-01-26 23:27     ` [PATCH v2 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-02-02 10:57       ` Andrew Rybchenko
2023-02-07 15:06         ` Alexander Kozyrev
2023-01-26 23:28     ` [PATCH v2 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-01-26 23:28     ` [PATCH v2 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-01-26 23:28     ` [PATCH v2 4/4] app/testpmd: add template table hash calculation function Alexander Kozyrev
2023-02-01 16:09     ` [PATCH v2 0/4] ethdev: add template table insertion and matching types Ori Kam
2023-02-08  2:47     ` [PATCH v3 " Alexander Kozyrev
2023-02-08  2:47       ` [PATCH v3 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-02-08  2:47       ` [PATCH v3 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-02-08  2:47       ` [PATCH v3 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-02-08  2:47       ` [PATCH v3 4/4] app/testpmd: add template table hash calculation function Alexander Kozyrev
2023-02-08  3:06       ` [PATCH v4 0/4] ethdev: add template table insertion and matching types Alexander Kozyrev
2023-02-08  3:06         ` [PATCH v4 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-02-08  3:06         ` [PATCH v4 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-02-08  3:06         ` [PATCH v4 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-02-08  3:06         ` [PATCH v4 4/4] app/testpmd: add template table hash calculation function Alexander Kozyrev
2023-02-10 17:42         ` [PATCH v4 0/4] ethdev: add template table insertion and matching types Ferruh Yigit

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=20230121052158.2928238-5-akozyrev@nvidia.com \
    --to=akozyrev@nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=orika@nvidia.com \
    --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).