From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 480BFA0679 for ; Tue, 30 Apr 2019 19:02:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3EB8A58CB; Tue, 30 Apr 2019 19:02:13 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id E486C58CB for ; Tue, 30 Apr 2019 19:02:10 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32A363199389; Tue, 30 Apr 2019 17:02:10 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-211.ams2.redhat.com [10.36.117.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2CAF6D0AF; Tue, 30 Apr 2019 17:02:08 +0000 (UTC) From: Kevin Traynor To: Wei Zhao Cc: Yuan Peng , Ferruh Yigit , dpdk stable Date: Tue, 30 Apr 2019 18:01:11 +0100 Message-Id: <20190430170133.2331-16-ktraynor@redhat.com> In-Reply-To: <20190430170133.2331-1-ktraynor@redhat.com> References: <20190430170133.2331-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 30 Apr 2019 17:02:10 +0000 (UTC) Subject: [dpdk-stable] patch 'app/testpmd: fix hex string parser support for flow API' has been queued to LTS release 18.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 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 Tested-by: Yuan Peng Reviewed-by: Ferruh Yigit --- 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@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: