[dpdk-stable] patch 'app/testpmd: fix hex string parser support for flow API' has been queued to LTS release 18.11.2

Kevin Traynor ktraynor at redhat.com
Tue Apr 30 19:01:11 CEST 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/07/19. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches can be viewed on a temporary branch at:
	https://github.com/kevintraynor/dpdk-stable-queue.git

Thanks.

Kevin Traynor

---
>From 7548453b0461ea73824d2d2771d2c4db0af64e7d Mon Sep 17 00:00:00 2001
From: Wei Zhao <wei.zhao1 at intel.com>
Date: Tue, 9 Apr 2019 16:41:31 +0800
Subject: [PATCH] app/testpmd: fix hex string parser support for flow API

[ upstream commit 169a9fed1f4cbca7e432fdc9ad1d44922ad783f6 ]

There is need for users to set configuration of HEX number for RSS
key. The key byte should be pass down as hex number not as char
string. This patch enable cmdline flow parse HEX number,
in order to not using string which pass ASIC number.

Fixes: f4d623f96119 ("app/testpmd: fix missing RSS fields in flow action")

Signed-off-by: Wei Zhao <wei.zhao1 at intel.com>
Tested-by: Yuan Peng <yuan.peng at intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 app/test-pmd/cmdline_flow.c | 128 +++++++++++++++++++++++++++++++++++-
 1 file changed, 127 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5c0108fa7..d202566b2 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -36,4 +36,5 @@ enum index {
 	BOOLEAN,
 	STRING,
+	HEX,
 	MAC_ADDR,
 	IPV4_ADDR,
@@ -1123,4 +1124,7 @@ static int parse_string(struct context *, const struct token *,
 			const char *, unsigned int,
 			void *, unsigned int);
+static int parse_hex(struct context *ctx, const struct token *token,
+			const char *str, unsigned int len,
+			void *buf, unsigned int size);
 static int parse_mac_addr(struct context *, const struct token *,
 			  const char *, unsigned int,
@@ -1199,4 +1203,11 @@ static const struct token token_list[] = {
 		.comp = comp_none,
 	},
+	[HEX] = {
+		.name = "{hex}",
+		.type = "HEX",
+		.help = "fixed string",
+		.call = parse_hex,
+		.comp = comp_none,
+	},
 	[MAC_ADDR] = {
 		.name = "{MAC address}",
@@ -2307,5 +2318,5 @@ static const struct token token_list[] = {
 		.name = "key",
 		.help = "RSS hash key",
-		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.next = NEXT(action_rss, NEXT_ENTRY(HEX)),
 		.args = ARGS(ARGS_ENTRY_ARB(0, 0),
 			     ARGS_ENTRY_ARB
@@ -4442,4 +4453,119 @@ error:
 }
 
+static int
+parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c = NULL;
+	uint32_t i, len;
+	char tmp[3];
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	/* Convert chars to bytes */
+	for (i = 0, len = 0; i < *size; i += 2) {
+		snprintf(tmp, 3, "%s", src + i);
+		dst[len++] = strtoul(tmp, &c, 16);
+		if (*c != 0) {
+			len--;
+			dst[len] = 0;
+			*size = len;
+			return -1;
+		}
+	}
+	dst[len] = 0;
+	*size = len;
+
+	return 0;
+}
+
+static int
+parse_hex(struct context *ctx, const struct token *token,
+		const char *str, unsigned int len,
+		void *buf, unsigned int size)
+{
+	const struct arg *arg_data = pop_args(ctx);
+	const struct arg *arg_len = pop_args(ctx);
+	const struct arg *arg_addr = pop_args(ctx);
+	char tmp[16]; /* Ought to be enough. */
+	int ret;
+	unsigned int hexlen = len;
+	unsigned int length = 256;
+	uint8_t hex_tmp[length];
+
+	/* Arguments are expected. */
+	if (!arg_data)
+		return -1;
+	if (!arg_len) {
+		push_args(ctx, arg_data);
+		return -1;
+	}
+	if (!arg_addr) {
+		push_args(ctx, arg_len);
+		push_args(ctx, arg_data);
+		return -1;
+	}
+	size = arg_data->size;
+	/* Bit-mask fill is not supported. */
+	if (arg_data->mask)
+		goto error;
+	if (!ctx->object)
+		return len;
+
+	/* translate bytes string to array. */
+	if (str[0] == '0' && ((str[1] == 'x') ||
+			(str[1] == 'X'))) {
+		str += 2;
+		hexlen -= 2;
+	}
+	if (hexlen > length)
+		return -1;
+	ret = parse_hex_string(str, hex_tmp, &hexlen);
+	if (ret < 0)
+		goto error;
+	/* Let parse_int() fill length information first. */
+	ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
+	if (ret < 0)
+		goto error;
+	push_args(ctx, arg_len);
+	ret = parse_int(ctx, token, tmp, ret, NULL, 0);
+	if (ret < 0) {
+		pop_args(ctx);
+		goto error;
+	}
+	buf = (uint8_t *)ctx->object + arg_data->offset;
+	/* Output buffer is not necessarily NUL-terminated. */
+	memcpy(buf, hex_tmp, hexlen);
+	memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
+	if (ctx->objmask)
+		memset((uint8_t *)ctx->objmask + arg_data->offset,
+					0xff, hexlen);
+	/* Save address if requested. */
+	if (arg_addr->size) {
+		memcpy((uint8_t *)ctx->object + arg_addr->offset,
+		       (void *[]){
+			(uint8_t *)ctx->object + arg_data->offset
+		       },
+		       arg_addr->size);
+		if (ctx->objmask)
+			memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
+			       (void *[]){
+				(uint8_t *)ctx->objmask + arg_data->offset
+			       },
+			       arg_addr->size);
+	}
+	return len;
+error:
+	push_args(ctx, arg_addr);
+	push_args(ctx, arg_len);
+	push_args(ctx, arg_data);
+	return -1;
+
+}
+
 /**
  * Parse a MAC address.
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-04-30 17:58:14.577048644 +0100
+++ 0016-app-testpmd-fix-hex-string-parser-support-for-flow-A.patch	2019-04-30 17:58:13.784140250 +0100
@@ -1 +1 @@
-From 169a9fed1f4cbca7e432fdc9ad1d44922ad783f6 Mon Sep 17 00:00:00 2001
+From 7548453b0461ea73824d2d2771d2c4db0af64e7d Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 169a9fed1f4cbca7e432fdc9ad1d44922ad783f6 ]
+
@@ -12 +13,0 @@
-Cc: stable at dpdk.org
@@ -22 +23 @@
-index 1c83bc9bc..54ff1753c 100644
+index 5c0108fa7..d202566b2 100644
@@ -25 +26 @@
-@@ -37,4 +37,5 @@ enum index {
+@@ -36,4 +36,5 @@ enum index {
@@ -31 +32 @@
-@@ -1124,4 +1125,7 @@ static int parse_string(struct context *, const struct token *,
+@@ -1123,4 +1124,7 @@ static int parse_string(struct context *, const struct token *,
@@ -39 +40 @@
-@@ -1200,4 +1204,11 @@ static const struct token token_list[] = {
+@@ -1199,4 +1203,11 @@ static const struct token token_list[] = {
@@ -51 +52 @@
-@@ -2308,5 +2319,5 @@ static const struct token token_list[] = {
+@@ -2307,5 +2318,5 @@ static const struct token token_list[] = {
@@ -58 +59 @@
-@@ -4477,4 +4488,119 @@ error:
+@@ -4442,4 +4453,119 @@ error:


More information about the stable mailing list