DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes
@ 2018-03-23 12:58 Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 1/9] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
                   ` (9 more replies)
  0 siblings, 10 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev

This series contains several fixes for rte_flow and its implementation in
mlx4 and testpmd. Upcoming work on the flow API depends on it.

Adrien Mazarguil (9):
  net/mlx4: fix RSS resource leak in case of error
  net/mlx4: fix ignored RSS hash types
  app/testpmd: fix flow completion for RSS queues
  app/testpmd: fix lack of flow action configuration
  app/testpmd: fix RSS flow action configuration
  app/testpmd: fix missing RSS fields in flow action
  ethdev: fix shallow copy of flow API RSS action
  ethdev: fix missing boolean values in flow command
  ethdev: fix ABI version in meson build

 app/test-pmd/cmdline_flow.c                 | 255 ++++++++++++++++++++---
 app/test-pmd/config.c                       | 161 +++++++++-----
 app/test-pmd/testpmd.h                      |  13 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/mlx4/mlx4_flow.c                |  17 +-
 lib/librte_ether/meson.build                |   2 +-
 lib/librte_ether/rte_flow.c                 | 145 +++++++++----
 7 files changed, 477 insertions(+), 124 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 1/9] net/mlx4: fix RSS resource leak in case of error
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 2/9] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When memory cannot be allocated for a flow rule, its RSS context reference
is not dropped.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 2d55bfe03..a3b4480b4 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
 			},
 		};
 
-		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
+		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
+			if (temp.rss)
+				mlx4_rss_put(temp.rss);
 			return rte_flow_error_set
 				(error, -rte_errno,
 				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				 "flow rule handle allocation failure");
+		}
 		/* Most fields will be updated by second pass. */
 		*flow = (struct rte_flow){
 			.ibv_attr = temp.ibv_attr,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 2/9] net/mlx4: fix ignored RSS hash types
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 1/9] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 3/9] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When an unsupported hash type is part of a RSS configuration structure, it
is silently ignored instead of triggering an error. This may lead
applications to assume that such types are accepted, while they are in fact
not part of the resulting flow rules.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index a3b4480b4..4d26df326 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
 			const struct rte_flow_action_queue *queue;
 			const struct rte_flow_action_rss *rss;
 			const struct rte_eth_rss_conf *rss_conf;
+			uint64_t fields;
 			unsigned int i;
 
 		case RTE_FLOW_ACTION_TYPE_VOID:
@@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
 					" of the context size";
 				goto exit_action_not_supported;
 			}
+			rte_errno = 0;
+			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
+			if (fields == (uint64_t)-1 && rte_errno) {
+				msg = "unsupported RSS hash type requested";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
-				(priv,
-				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
-				 rss_conf->rss_key, rss->num, rss->queue);
+				(priv, fields, rss_conf->rss_key, rss->num,
+				 rss->queue);
 			if (!flow->rss) {
 				msg = "either invalid parameters or not enough"
 					" resources for additional multi-queue"
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 3/9] app/testpmd: fix flow completion for RSS queues
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 1/9] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 2/9] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 4/9] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

The lack of a working completion for RSS queues was overlooked during
development; until now only "end" was displayed as a valid token.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a5cf84f79..9cac8e9bf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2663,17 +2663,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			 unsigned int ent, char *buf, unsigned int size)
 {
-	static const char *const str[] = { "", "end", NULL };
-	unsigned int i;
-
 	(void)ctx;
 	(void)token;
-	for (i = 0; str[i] != NULL; ++i)
-		if (buf && i == ent)
-			return snprintf(buf, size, "%s", str[i]);
-	if (buf)
-		return -1;
-	return i;
+	if (!buf)
+		return nb_rxq + 1;
+	if (ent < nb_rxq)
+		return snprintf(buf, size, "%u", ent);
+	if (ent == nb_rxq)
+		return snprintf(buf, size, "end");
+	return -1;
 }
 
 /** Internal context. */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 4/9] app/testpmd: fix lack of flow action configuration
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (2 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 3/9] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS " Adrien Mazarguil
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Configuration structure is not optional with flow rule actions that expect
one; this pointer is not supposed to be NULL and PMDs should not have to
verify it.

Like pattern item spec/last/mask fields, it is currently set when at least
one configuration parameter is provided on the command line. This patch
sets it as soon as an action is created instead.

Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 9cac8e9bf..c2cf415ef 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
 			return -1;
 		*action = (struct rte_flow_action){
 			.type = priv->type,
+			.conf = data_size ? data : NULL,
 		};
 		++out->args.vc.actions_n;
 		ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	      void *buf, unsigned int size)
 {
 	struct buffer *out = buf;
-	struct rte_flow_action *action;
 
 	(void)size;
 	/* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
-	if (!out->args.vc.actions_n)
-		return -1;
-	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
 	/* Point to selected object. */
 	ctx->object = out->args.vc.data;
 	ctx->objmask = NULL;
-	/* Update configuration pointer. */
-	action->conf = ctx->object;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS flow action configuration
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (3 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 4/9] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-05-07  6:53   ` Zhao1, Wei
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 6/9] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Except for a list of queues, RSS configuration (hash key and fields) cannot
be specified from the flow command line and testpmd does not provide safe
defaults either.

In order to validate their implementation with testpmd, PMDs had to
interpret its NULL RSS configuration parameters somehow, however this has
never been valid to begin with.

This patch makes testpmd always provide default values.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 104 +++++++++++++++++++++++++----
 app/test-pmd/config.c       | 141 +++++++++++++++++++++++++++------------
 2 files changed, 192 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index c2cf415ef..890c36d8e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */
-#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */
-#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
 #define CTX_STACK_SIZE 16
@@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
 static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,64 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		if (rte_eth_dev_rss_hash_conf_get
+		    (ctx->port, &action_rss_data->s.rss_conf) < 0) {
+			struct rte_eth_dev_info info;
+
+			rte_eth_dev_info_get(ctx->port, &info);
+			action_rss_data->s.rss_conf.rss_key_len =
+				RTE_MIN(sizeof(action_rss_data->s.rss_key),
+					info.hash_key_size);
+		}
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2089,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2103,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2124,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4bb255c62..a4b54f86a 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -982,31 +982,52 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
 };
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1036,31 +1057,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */
@@ -1073,7 +1135,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1091,24 +1152,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -1125,12 +1185,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 6/9] app/testpmd: fix missing RSS fields in flow action
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (4 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 7/9] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Users cannot override the default RSS settings when entering a RSS action,
only a list of queues can be provided.

This patch enables them to set a RSS hash key and types for a flow rule.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 133 ++++++++++++++++++++++-
 app/test-pmd/config.c                       |  20 ++--
 app/test-pmd/testpmd.h                      |  13 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 ++
 4 files changed, 163 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 890c36d8e..38aa6099d 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -167,6 +167,10 @@ enum index {
 	ACTION_DUP,
 	ACTION_DUP_INDEX,
 	ACTION_RSS,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
+	ACTION_RSS_TYPES,
+	ACTION_RSS_TYPE,
 	ACTION_RSS_QUEUES,
 	ACTION_RSS_QUEUE,
 	ACTION_PF,
@@ -223,6 +227,9 @@ struct context {
 struct arg {
 	uint32_t hton:1; /**< Use network byte ordering. */
 	uint32_t sign:1; /**< Value is signed. */
+	uint32_t bounded:1; /**< Value is bounded. */
+	uintmax_t min; /**< Minimum value if bounded. */
+	uintmax_t max; /**< Maximum value if bounded. */
 	uint32_t offset; /**< Relative offset from ctx->object. */
 	uint32_t size; /**< Field size. */
 	const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
@@ -329,6 +336,16 @@ struct token {
 		.size = (s), \
 	})
 
+/** Same as ARGS_ENTRY_ARB() with bounded values. */
+#define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
+	(&(const struct arg){ \
+		.bounded = 1, \
+		.min = (i), \
+		.max = (a), \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -635,6 +652,9 @@ static const enum index action_dup[] = {
 };
 
 static const enum index action_rss[] = {
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
+	ACTION_RSS_TYPES,
 	ACTION_RSS_QUEUES,
 	ACTION_NEXT,
 	ZERO,
@@ -666,6 +686,9 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
+static int parse_vc_action_rss_type(struct context *, const struct token *,
+				    const char *, unsigned int, void *,
+				    unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -721,6 +744,8 @@ static int comp_port(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_rule_id(struct context *, const struct token *,
 			unsigned int, char *, unsigned int);
+static int comp_vc_action_rss_type(struct context *, const struct token *,
+				   unsigned int, char *, unsigned int);
 static int comp_vc_action_rss_queue(struct context *, const struct token *,
 				    unsigned int, char *, unsigned int);
 
@@ -1593,6 +1618,43 @@ static const struct token token_list[] = {
 		.next = NEXT(action_rss),
 		.call = parse_vc_action_rss,
 	},
+	[ACTION_RSS_KEY] = {
+		.name = "key",
+		.help = "RSS hash key",
+		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len)),
+			     ARGS_ENTRY_ARB
+			     (((uintptr_t)((union action_rss_data *)0)->
+			       s.rss_key),
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_KEY_LEN] = {
+		.name = "key_len",
+		.help = "RSS hash key length in bytes",
+		.next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB_BOUNDED
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len),
+			      0,
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_TYPES] = {
+		.name = "types",
+		.help = "RSS hash types",
+		.next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
+	},
+	[ACTION_RSS_TYPE] = {
+		.name = "{type}",
+		.help = "RSS hash type",
+		.call = parse_vc_action_rss_type,
+		.comp = comp_vc_action_rss_type,
+	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
 		.help = "queue indices to use",
@@ -2079,6 +2141,50 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
 }
 
 /**
+ * Parse type field for RSS action.
+ *
+ * Valid tokens are type field names and the "end" token.
+ */
+static int
+parse_vc_action_rss_type(struct context *ctx, const struct token *token,
+			  const char *str, unsigned int len,
+			  void *buf, unsigned int size)
+{
+	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+
+	(void)token;
+	(void)buf;
+	(void)size;
+	if (ctx->curr != ACTION_RSS_TYPE)
+		return -1;
+	if (!(ctx->objdata >> 16) && ctx->object) {
+		action_rss_data = ctx->object;
+		action_rss_data->s.rss_conf.rss_hf = 0;
+	}
+	if (!strcmp_partial("end", str, len)) {
+		ctx->objdata &= 0xffff;
+		return len;
+	}
+	for (i = 0; rss_type_table[i].str; ++i)
+		if (!strcmp_partial(rss_type_table[i].str, str, len))
+			break;
+	if (!rss_type_table[i].str)
+		return -1;
+	ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
+	/* Repeat token. */
+	if (ctx->next_num == RTE_DIM(ctx->next))
+		return -1;
+	ctx->next[ctx->next_num++] = next;
+	if (!ctx->object)
+		return len;
+	action_rss_data = ctx->object;
+	action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type;
+	return len;
+}
+
+/**
  * Parse queue field for RSS action.
  *
  * Valid tokens are queue indices and the "end" token.
@@ -2344,6 +2450,11 @@ parse_int(struct context *ctx, const struct token *token,
 		strtoumax(str, &end, 0);
 	if (errno || (size_t)(end - str) != len)
 		goto error;
+	if (arg->bounded &&
+	    ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
+			    (intmax_t)u > (intmax_t)arg->max)) ||
+	     (!arg->sign && (u < arg->min || u > arg->max))))
+		goto error;
 	if (!ctx->object)
 		return len;
 	if (arg->mask) {
@@ -2437,7 +2548,7 @@ parse_string(struct context *ctx, const struct token *token,
 	buf = (uint8_t *)ctx->object + arg_data->offset;
 	/* Output buffer is not necessarily NUL-terminated. */
 	memcpy(buf, str, len);
-	memset((uint8_t *)buf + len, 0x55, size - len);
+	memset((uint8_t *)buf + len, 0x00, size - len);
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
 	return len;
@@ -2733,6 +2844,26 @@ comp_rule_id(struct context *ctx, const struct token *token,
 	return i;
 }
 
+/** Complete type field for RSS action. */
+static int
+comp_vc_action_rss_type(struct context *ctx, const struct token *token,
+			unsigned int ent, char *buf, unsigned int size)
+{
+	unsigned int i;
+
+	(void)ctx;
+	(void)token;
+	for (i = 0; rss_type_table[i].str; ++i)
+		;
+	if (!buf)
+		return i + 1;
+	if (ent < i)
+		return snprintf(buf, size, "%s", rss_type_table[ent].str);
+	if (ent == i)
+		return snprintf(buf, size, "end");
+	return -1;
+}
+
 /** Complete queue field for RSS action. */
 static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a4b54f86a..7ade30f47 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -73,12 +73,7 @@ static const struct {
 	},
 };
 
-struct rss_type_info {
-	char str[32];
-	uint64_t rss_type;
-};
-
-static const struct rss_type_info rss_type_table[] = {
+const struct rss_type_info rss_type_table[] = {
 	{ "ipv4", ETH_RSS_IPV4 },
 	{ "ipv4-frag", ETH_RSS_FRAG_IPV4 },
 	{ "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
@@ -99,7 +94,12 @@ static const struct rss_type_info rss_type_table[] = {
 	{ "vxlan", ETH_RSS_VXLAN },
 	{ "geneve", ETH_RSS_GENEVE },
 	{ "nvgre", ETH_RSS_NVGRE },
-
+	{ "ip", ETH_RSS_IP },
+	{ "udp", ETH_RSS_UDP },
+	{ "tcp", ETH_RSS_TCP },
+	{ "sctp", ETH_RSS_SCTP },
+	{ "tunnel", ETH_RSS_TUNNEL },
+	{ NULL, 0 },
 };
 
 static void
@@ -1820,7 +1820,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 	}
 
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_info, rss_type_table[i].str))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
@@ -1849,7 +1849,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 		return;
 	}
 	printf("RSS functions:\n ");
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (rss_hf & rss_type_table[i].rss_type)
 			printf("%s ", rss_type_table[i].str);
 	}
@@ -1873,7 +1873,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = hash_key_len;
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_type_table[i].str, rss_type))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea05..593ae2160 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -79,6 +79,19 @@ struct pkt_burst_stats {
 };
 #endif
 
+/** Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /**< Type name. */
+	uint64_t rss_type; /**< Type value. */
+};
+
+/**
+ * RSS type information table.
+ *
+ * An entry with a NULL type name terminates the list.
+ */
+extern const struct rss_type_info rss_type_table[];
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a766ac795..f85628109 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3406,6 +3406,14 @@ This section lists supported actions and their attributes, if any.
 
 - ``rss``: spread packets among several queues.
 
+  - ``key {string}``: RSS hash key, overrides ``key_len``.
+
+  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
+    conjunction with ``key`` to pad or truncate it.
+
+  - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens
+    are the same as `set_hash_input_set`_, an empty list means none (0).
+
   - ``queues [{unsigned} [...]] end``: queue indices to use.
 
 - ``pf``: redirect packets to physical device function.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 7/9] ethdev: fix shallow copy of flow API RSS action
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (5 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 6/9] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 8/9] ethdev: fix missing boolean values in flow command Adrien Mazarguil
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Gaetan Rivet, Thomas Monjalon

The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.

Even assuming it is permanently allocated and a pointer copy is safe,
pointed data may change and not reflect an applied flow rule anymore.

This patch aligns with testpmd by making a deep copy instead.

Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
Cc: stable@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 43 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index 38f2d27be..ba6feddee 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,
 	return -code;
 }
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
-	/* Not a fall-through */
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = rte_flow_desc_item[item->type].size;
+		size = rte_flow_desc_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
-	/* Not a fall-through. */
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = rte_flow_desc_action[action->type].size;
+		size = rte_flow_desc_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Store a full rte_flow description. */
@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 {
 	struct rte_flow_desc *fd = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	size_t size = 0;
@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, item,
 					     sizeof(*item));
 			off1 += sizeof(*item);
-			flow_item_spec_size(item, &tmp, &pad);
 			if (item->spec) {
 				if (fd)
-					dst->spec = memcpy(fd->data + off2,
-							   item->spec, tmp);
-				off2 += tmp + pad;
+					dst->spec = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_SPEC);
 			}
 			if (item->last) {
 				if (fd)
-					dst->last = memcpy(fd->data + off2,
-							   item->last, tmp);
-				off2 += tmp + pad;
+					dst->last = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_LAST);
 			}
 			if (item->mask) {
 				if (fd)
-					dst->mask = memcpy(fd->data + off2,
-							   item->mask, tmp);
-				off2 += tmp + pad;
+					dst->mask = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_MASK);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, action,
 					     sizeof(*action));
 			off1 += sizeof(*action);
-			flow_action_conf_size(action, &tmp, &pad);
 			if (action->conf) {
 				if (fd)
-					dst->conf = memcpy(fd->data + off2,
-							   action->conf, tmp);
-				off2 += tmp + pad;
+					dst->conf = fd->data + off2;
+				off2 += flow_action_conf_copy
+					(fd ? fd->data + off2 : NULL, action);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 8/9] ethdev: fix missing boolean values in flow command
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (6 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 7/9] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 9/9] ethdev: fix ABI version in meson build Adrien Mazarguil
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: stable

Original implementation lacks the on/off toggle.

This patch shows up as a fix because it has been a popular request ever
since the first DPDK release with the original implementation but was never
addressed.

Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 38aa6099d..f2be10d20 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2695,6 +2695,7 @@ static const char *const boolean_name[] = {
 	"false", "true",
 	"no", "yes",
 	"N", "Y",
+	"off", "on",
 	NULL,
 };
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v1 9/9] ethdev: fix ABI version in meson build
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (7 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 8/9] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-03-23 12:58 ` Adrien Mazarguil
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
  9 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-03-23 12:58 UTC (permalink / raw)
  To: dev; +Cc: Kirill Rybalchenko

Must remain synchronized with its Makefile counterpart.

Fixes: a4b0b30723b2 ("ethdev: remove versioning of ethdev filter control function")
Cc: Kirill Rybalchenko <kirill.rybalchenko@intel.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 lib/librte_ether/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/meson.build b/lib/librte_ether/meson.build
index 7fed86056..12bdb6b61 100644
--- a/lib/librte_ether/meson.build
+++ b/lib/librte_ether/meson.build
@@ -2,7 +2,7 @@
 # Copyright(c) 2017 Intel Corporation
 
 name = 'ethdev'
-version = 8
+version = 9
 allow_experimental_apis = true
 sources = files('ethdev_profile.c',
 	'rte_ethdev.c',
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes
  2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
                   ` (8 preceding siblings ...)
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 9/9] ethdev: fix ABI version in meson build Adrien Mazarguil
@ 2018-04-04 14:57 ` Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 01/13] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
                     ` (13 more replies)
  9 siblings, 14 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev

This series contains several fixes for rte_flow and its implementation in
PMDs and testpmd. Upcoming work on the flow API depends on it.

v2 changes:

- mlx5 fix (patch #3).
- bnxt fix (patch #4).
- sfc fix (patch #6).
- Missing include (patch #13).

Adrien Mazarguil (13):
  net/mlx4: fix RSS resource leak in case of error
  net/mlx4: fix ignored RSS hash types
  net/mlx5: fix RSS flow action bounds check
  net/bnxt: fix matching of flow API item masks
  net/sfc: fix endian conversions in flow API
  app/testpmd: fix flow completion for RSS queues
  app/testpmd: fix lack of flow action configuration
  app/testpmd: fix RSS flow action configuration
  app/testpmd: fix missing RSS fields in flow action
  ethdev: fix shallow copy of flow API RSS action
  ethdev: fix missing boolean values in flow command
  ethdev: fix ABI version in meson build
  ethdev: fix missing include in flow API

 app/test-pmd/cmdline_flow.c                 | 255 ++++++++++++++++++++---
 app/test-pmd/config.c                       | 160 +++++++++-----
 app/test-pmd/testpmd.h                      |  13 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bnxt/bnxt_filter.c              |  14 +-
 drivers/net/mlx4/mlx4_flow.c                |  17 +-
 drivers/net/mlx5/mlx5_flow.c                |   9 +
 drivers/net/sfc/sfc_flow.c                  |  13 +-
 lib/librte_ether/meson.build                |   2 +-
 lib/librte_ether/rte_flow.c                 | 145 +++++++++----
 lib/librte_ether/rte_flow.h                 |   2 +
 11 files changed, 503 insertions(+), 135 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 01/13] net/mlx4: fix RSS resource leak in case of error
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 02/13] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When memory cannot be allocated for a flow rule, its RSS context reference
is not dropped.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 2d55bfe03..a3b4480b4 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
 			},
 		};
 
-		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
+		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
+			if (temp.rss)
+				mlx4_rss_put(temp.rss);
 			return rte_flow_error_set
 				(error, -rte_errno,
 				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				 "flow rule handle allocation failure");
+		}
 		/* Most fields will be updated by second pass. */
 		*flow = (struct rte_flow){
 			.ibv_attr = temp.ibv_attr,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 02/13] net/mlx4: fix ignored RSS hash types
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 01/13] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 03/13] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
                     ` (11 subsequent siblings)
  13 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When an unsupported hash type is part of a RSS configuration structure, it
is silently ignored instead of triggering an error. This may lead
applications to assume that such types are accepted, while they are in fact
not part of the resulting flow rules.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index a3b4480b4..4d26df326 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
 			const struct rte_flow_action_queue *queue;
 			const struct rte_flow_action_rss *rss;
 			const struct rte_eth_rss_conf *rss_conf;
+			uint64_t fields;
 			unsigned int i;
 
 		case RTE_FLOW_ACTION_TYPE_VOID:
@@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
 					" of the context size";
 				goto exit_action_not_supported;
 			}
+			rte_errno = 0;
+			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
+			if (fields == (uint64_t)-1 && rte_errno) {
+				msg = "unsupported RSS hash type requested";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
-				(priv,
-				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
-				 rss_conf->rss_key, rss->num, rss->queue);
+				(priv, fields, rss_conf->rss_key, rss->num,
+				 rss->queue);
 			if (!flow->rss) {
 				msg = "either invalid parameters or not enough"
 					" resources for additional multi-queue"
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 03/13] net/mlx5: fix RSS flow action bounds check
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 01/13] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 02/13] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-05  6:57     ` Nélio Laranjeiro
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 04/13] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
                     ` (10 subsequent siblings)
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Nelio Laranjeiro

The number of queues provided by the application is not checked against
parser's supported maximum.

Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
Cc: stable@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e6af3243d..f051fbef5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -16,6 +16,7 @@
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include <rte_common.h>
 #include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
+			if (rss->num > RTE_DIM(parser->queues)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "too many queues for RSS"
+						   " context");
+				return -rte_errno;
+			}
 			for (n = 0; n < rss->num; ++n) {
 				if (rss->queue[n] >= priv->rxqs_n) {
 					rte_flow_error_set(error, EINVAL,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 04/13] net/bnxt: fix matching of flow API item masks
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (2 preceding siblings ...)
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 03/13] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API Adrien Mazarguil
                     ` (9 subsequent siblings)
  13 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Ajit Khaparde

Some values are interpreted without endian conversion and/or without
taking the proper mask into account.

Fixes: 5ef3b79fdfe6 ("net/bnxt: support flow filter ops")
Cc: stable@dpdk.org
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/bnxt/bnxt_filter.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index bbaae1a07..0d735edf6 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -33,6 +33,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
@@ -374,7 +375,8 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			/* Mask is not allowed. Only exact matches are */
-			if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
+			if (eth_mask->type &&
+			    eth_mask->type != RTE_BE16(0xffff)) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
@@ -400,7 +402,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			   *  RTE_LOG(ERR, PMD, "Handle this condition\n");
 			   * }
 			   */
-			if (eth_spec->type) {
+			if (eth_mask->type) {
 				filter->ethertype =
 					rte_be_to_cpu_16(eth_spec->type);
 				en |= use_ntuple ?
@@ -412,13 +414,15 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			vlan_spec = item->spec;
 			vlan_mask = item->mask;
-			if (vlan_mask->tci & 0xFFFF && !vlan_mask->tpid) {
+			if (vlan_mask->tci &&
+			    vlan_mask->tci == RTE_BE16(0x0fff) &&
+			    !vlan_mask->tpid) {
 				/* Only the VLAN ID can be matched. */
 				filter->l2_ovlan =
 					rte_be_to_cpu_16(vlan_spec->tci &
-							 0xFFF);
+							 RTE_BE16(0x0fff));
 				en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID;
-			} else {
+			} else if (vlan_mask->tci || vlan_mask->tpid) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (3 preceding siblings ...)
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 04/13] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-04 15:30     ` Andrew Rybchenko
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 06/13] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
                     ` (8 subsequent siblings)
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Roman Zhukov, Andrew Rybchenko

These conversions do not use the adequate function.

Fixes: a9825ccf5bb8 ("net/sfc: support flow API filters")
Fixes: 894080975e1e ("net/sfc: support VLAN in flow API filters")
Fixes: e2675132444e ("net/sfc: support TCP in flow API filters")
Fixes: e01f84f42cad ("net/sfc: support UDP in flow API filters")
Cc: stable@dpdk.org
Cc: Roman Zhukov <roman.zhukov@oktetlabs.ru>
Cc: Andrew Rybchenko <arybchenko@solarflare.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/sfc/sfc_flow.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index fe4c0b0c5..9060fdc2f 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -7,6 +7,7 @@
  * for Solarflare) and Solarflare Communications, Inc.
  */
 
+#include <rte_byteorder.h>
 #include <rte_tailq.h>
 #include <rte_common.h>
 #include <rte_ethdev_driver.h>
@@ -315,7 +316,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
 	 */
 	if (mask->type == supp_mask.type) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
-		efx_spec->efs_ether_type = rte_bswap16(spec->type);
+		efx_spec->efs_ether_type = rte_be_to_cpu_16(spec->type);
 	} else if (mask->type != 0) {
 		goto fail_bad_mask;
 	}
@@ -370,7 +371,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item,
 	 * the outer tag and the next matches the inner tag.
 	 */
 	if (mask->tci == supp_mask.tci) {
-		vid = rte_bswap16(spec->tci);
+		vid = rte_be_to_cpu_16(spec->tci);
 
 		if (!(efx_spec->efs_match_flags &
 		      EFX_FILTER_MATCH_OUTER_VID)) {
@@ -654,14 +655,14 @@ sfc_flow_parse_tcp(const struct rte_flow_item *item,
 	 */
 	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
-		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
+		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
 	} else if (mask->hdr.src_port != 0) {
 		goto fail_bad_mask;
 	}
 
 	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
-		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
+		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
 	} else if (mask->hdr.dst_port != 0) {
 		goto fail_bad_mask;
 	}
@@ -735,14 +736,14 @@ sfc_flow_parse_udp(const struct rte_flow_item *item,
 	 */
 	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
-		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
+		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
 	} else if (mask->hdr.src_port != 0) {
 		goto fail_bad_mask;
 	}
 
 	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
-		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
+		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
 	} else if (mask->hdr.dst_port != 0) {
 		goto fail_bad_mask;
 	}
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 06/13] app/testpmd: fix flow completion for RSS queues
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (4 preceding siblings ...)
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 07/13] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
                     ` (7 subsequent siblings)
  13 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

The lack of a working completion for RSS queues was overlooked during
development; until now only "end" was displayed as a valid token.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a5cf84f79..9cac8e9bf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2663,17 +2663,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			 unsigned int ent, char *buf, unsigned int size)
 {
-	static const char *const str[] = { "", "end", NULL };
-	unsigned int i;
-
 	(void)ctx;
 	(void)token;
-	for (i = 0; str[i] != NULL; ++i)
-		if (buf && i == ent)
-			return snprintf(buf, size, "%s", str[i]);
-	if (buf)
-		return -1;
-	return i;
+	if (!buf)
+		return nb_rxq + 1;
+	if (ent < nb_rxq)
+		return snprintf(buf, size, "%u", ent);
+	if (ent == nb_rxq)
+		return snprintf(buf, size, "end");
+	return -1;
 }
 
 /** Internal context. */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 07/13] app/testpmd: fix lack of flow action configuration
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (5 preceding siblings ...)
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 06/13] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-05  6:59     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 08/13] app/testpmd: fix RSS " Adrien Mazarguil
                     ` (6 subsequent siblings)
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Configuration structure is not optional with flow rule actions that expect
one; this pointer is not supposed to be NULL and PMDs should not have to
verify it.

Like pattern item spec/last/mask fields, it is currently set when at least
one configuration parameter is provided on the command line. This patch
sets it as soon as an action is created instead.

Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 9cac8e9bf..c2cf415ef 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
 			return -1;
 		*action = (struct rte_flow_action){
 			.type = priv->type,
+			.conf = data_size ? data : NULL,
 		};
 		++out->args.vc.actions_n;
 		ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	      void *buf, unsigned int size)
 {
 	struct buffer *out = buf;
-	struct rte_flow_action *action;
 
 	(void)size;
 	/* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
-	if (!out->args.vc.actions_n)
-		return -1;
-	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
 	/* Point to selected object. */
 	ctx->object = out->args.vc.data;
 	ctx->objmask = NULL;
-	/* Update configuration pointer. */
-	action->conf = ctx->object;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 08/13] app/testpmd: fix RSS flow action configuration
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (6 preceding siblings ...)
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 07/13] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-04-04 14:57   ` Adrien Mazarguil
  2018-04-05  7:39     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 09/13] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
                     ` (5 subsequent siblings)
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:57 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Except for a list of queues, RSS configuration (hash key and fields) cannot
be specified from the flow command line and testpmd does not provide safe
defaults either.

In order to validate their implementation with testpmd, PMDs had to
interpret its NULL RSS configuration parameters somehow, however this has
never been valid to begin with.

This patch makes testpmd always provide default values.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 104 +++++++++++++++++++++++++----
 app/test-pmd/config.c       | 140 +++++++++++++++++++++++++++------------
 2 files changed, 191 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index c2cf415ef..890c36d8e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */
-#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */
-#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
 #define CTX_STACK_SIZE 16
@@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
 static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,64 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		if (rte_eth_dev_rss_hash_conf_get
+		    (ctx->port, &action_rss_data->s.rss_conf) < 0) {
+			struct rte_eth_dev_info info;
+
+			rte_eth_dev_info_get(ctx->port, &info);
+			action_rss_data->s.rss_conf.rss_key_len =
+				RTE_MIN(sizeof(action_rss_data->s.rss_key),
+					info.hash_key_size);
+		}
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2089,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2103,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2124,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4bb255c62..aab5db355 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -982,31 +982,51 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
 };
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1036,31 +1056,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */
@@ -1073,7 +1134,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1091,24 +1151,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -1125,12 +1184,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 09/13] app/testpmd: fix missing RSS fields in flow action
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (7 preceding siblings ...)
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 08/13] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-04-04 14:58   ` Adrien Mazarguil
  2018-04-05  8:15     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 10/13] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
                     ` (4 subsequent siblings)
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Users cannot override the default RSS settings when entering a RSS action,
only a list of queues can be provided.

This patch enables them to set a RSS hash key and types for a flow rule.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 133 ++++++++++++++++++++++-
 app/test-pmd/config.c                       |  20 ++--
 app/test-pmd/testpmd.h                      |  13 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 ++
 4 files changed, 163 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 890c36d8e..dbf4afebf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -167,6 +167,10 @@ enum index {
 	ACTION_DUP,
 	ACTION_DUP_INDEX,
 	ACTION_RSS,
+	ACTION_RSS_TYPES,
+	ACTION_RSS_TYPE,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_RSS_QUEUE,
 	ACTION_PF,
@@ -223,6 +227,9 @@ struct context {
 struct arg {
 	uint32_t hton:1; /**< Use network byte ordering. */
 	uint32_t sign:1; /**< Value is signed. */
+	uint32_t bounded:1; /**< Value is bounded. */
+	uintmax_t min; /**< Minimum value if bounded. */
+	uintmax_t max; /**< Maximum value if bounded. */
 	uint32_t offset; /**< Relative offset from ctx->object. */
 	uint32_t size; /**< Field size. */
 	const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
@@ -329,6 +336,16 @@ struct token {
 		.size = (s), \
 	})
 
+/** Same as ARGS_ENTRY_ARB() with bounded values. */
+#define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
+	(&(const struct arg){ \
+		.bounded = 1, \
+		.min = (i), \
+		.max = (a), \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -635,6 +652,9 @@ static const enum index action_dup[] = {
 };
 
 static const enum index action_rss[] = {
+	ACTION_RSS_TYPES,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_NEXT,
 	ZERO,
@@ -666,6 +686,9 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
+static int parse_vc_action_rss_type(struct context *, const struct token *,
+				    const char *, unsigned int, void *,
+				    unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -721,6 +744,8 @@ static int comp_port(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_rule_id(struct context *, const struct token *,
 			unsigned int, char *, unsigned int);
+static int comp_vc_action_rss_type(struct context *, const struct token *,
+				   unsigned int, char *, unsigned int);
 static int comp_vc_action_rss_queue(struct context *, const struct token *,
 				    unsigned int, char *, unsigned int);
 
@@ -1593,6 +1618,43 @@ static const struct token token_list[] = {
 		.next = NEXT(action_rss),
 		.call = parse_vc_action_rss,
 	},
+	[ACTION_RSS_TYPES] = {
+		.name = "types",
+		.help = "RSS hash types",
+		.next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
+	},
+	[ACTION_RSS_TYPE] = {
+		.name = "{type}",
+		.help = "RSS hash type",
+		.call = parse_vc_action_rss_type,
+		.comp = comp_vc_action_rss_type,
+	},
+	[ACTION_RSS_KEY] = {
+		.name = "key",
+		.help = "RSS hash key",
+		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len)),
+			     ARGS_ENTRY_ARB
+			     (((uintptr_t)((union action_rss_data *)0)->
+			       s.rss_key),
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_KEY_LEN] = {
+		.name = "key_len",
+		.help = "RSS hash key length in bytes",
+		.next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB_BOUNDED
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len),
+			      0,
+			      RSS_HASH_KEY_LENGTH)),
+	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
 		.help = "queue indices to use",
@@ -2079,6 +2141,50 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
 }
 
 /**
+ * Parse type field for RSS action.
+ *
+ * Valid tokens are type field names and the "end" token.
+ */
+static int
+parse_vc_action_rss_type(struct context *ctx, const struct token *token,
+			  const char *str, unsigned int len,
+			  void *buf, unsigned int size)
+{
+	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+
+	(void)token;
+	(void)buf;
+	(void)size;
+	if (ctx->curr != ACTION_RSS_TYPE)
+		return -1;
+	if (!(ctx->objdata >> 16) && ctx->object) {
+		action_rss_data = ctx->object;
+		action_rss_data->s.rss_conf.rss_hf = 0;
+	}
+	if (!strcmp_partial("end", str, len)) {
+		ctx->objdata &= 0xffff;
+		return len;
+	}
+	for (i = 0; rss_type_table[i].str; ++i)
+		if (!strcmp_partial(rss_type_table[i].str, str, len))
+			break;
+	if (!rss_type_table[i].str)
+		return -1;
+	ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
+	/* Repeat token. */
+	if (ctx->next_num == RTE_DIM(ctx->next))
+		return -1;
+	ctx->next[ctx->next_num++] = next;
+	if (!ctx->object)
+		return len;
+	action_rss_data = ctx->object;
+	action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type;
+	return len;
+}
+
+/**
  * Parse queue field for RSS action.
  *
  * Valid tokens are queue indices and the "end" token.
@@ -2344,6 +2450,11 @@ parse_int(struct context *ctx, const struct token *token,
 		strtoumax(str, &end, 0);
 	if (errno || (size_t)(end - str) != len)
 		goto error;
+	if (arg->bounded &&
+	    ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
+			    (intmax_t)u > (intmax_t)arg->max)) ||
+	     (!arg->sign && (u < arg->min || u > arg->max))))
+		goto error;
 	if (!ctx->object)
 		return len;
 	if (arg->mask) {
@@ -2437,7 +2548,7 @@ parse_string(struct context *ctx, const struct token *token,
 	buf = (uint8_t *)ctx->object + arg_data->offset;
 	/* Output buffer is not necessarily NUL-terminated. */
 	memcpy(buf, str, len);
-	memset((uint8_t *)buf + len, 0x55, size - len);
+	memset((uint8_t *)buf + len, 0x00, size - len);
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
 	return len;
@@ -2733,6 +2844,26 @@ comp_rule_id(struct context *ctx, const struct token *token,
 	return i;
 }
 
+/** Complete type field for RSS action. */
+static int
+comp_vc_action_rss_type(struct context *ctx, const struct token *token,
+			unsigned int ent, char *buf, unsigned int size)
+{
+	unsigned int i;
+
+	(void)ctx;
+	(void)token;
+	for (i = 0; rss_type_table[i].str; ++i)
+		;
+	if (!buf)
+		return i + 1;
+	if (ent < i)
+		return snprintf(buf, size, "%s", rss_type_table[ent].str);
+	if (ent == i)
+		return snprintf(buf, size, "end");
+	return -1;
+}
+
 /** Complete queue field for RSS action. */
 static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index aab5db355..2058e6ec8 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -73,12 +73,7 @@ static const struct {
 	},
 };
 
-struct rss_type_info {
-	char str[32];
-	uint64_t rss_type;
-};
-
-static const struct rss_type_info rss_type_table[] = {
+const struct rss_type_info rss_type_table[] = {
 	{ "ipv4", ETH_RSS_IPV4 },
 	{ "ipv4-frag", ETH_RSS_FRAG_IPV4 },
 	{ "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
@@ -99,7 +94,12 @@ static const struct rss_type_info rss_type_table[] = {
 	{ "vxlan", ETH_RSS_VXLAN },
 	{ "geneve", ETH_RSS_GENEVE },
 	{ "nvgre", ETH_RSS_NVGRE },
-
+	{ "ip", ETH_RSS_IP },
+	{ "udp", ETH_RSS_UDP },
+	{ "tcp", ETH_RSS_TCP },
+	{ "sctp", ETH_RSS_SCTP },
+	{ "tunnel", ETH_RSS_TUNNEL },
+	{ NULL, 0 },
 };
 
 static void
@@ -1819,7 +1819,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 	}
 
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_info, rss_type_table[i].str))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
@@ -1848,7 +1848,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 		return;
 	}
 	printf("RSS functions:\n ");
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (rss_hf & rss_type_table[i].rss_type)
 			printf("%s ", rss_type_table[i].str);
 	}
@@ -1872,7 +1872,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = hash_key_len;
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_type_table[i].str, rss_type))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea05..593ae2160 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -79,6 +79,19 @@ struct pkt_burst_stats {
 };
 #endif
 
+/** Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /**< Type name. */
+	uint64_t rss_type; /**< Type value. */
+};
+
+/**
+ * RSS type information table.
+ *
+ * An entry with a NULL type name terminates the list.
+ */
+extern const struct rss_type_info rss_type_table[];
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a766ac795..cb6f201e1 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3406,6 +3406,14 @@ This section lists supported actions and their attributes, if any.
 
 - ``rss``: spread packets among several queues.
 
+  - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens
+    are the same as `set_hash_input_set`_, an empty list means none (0).
+
+  - ``key {string}``: RSS hash key, overrides ``key_len``.
+
+  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
+    conjunction with ``key`` to pad or truncate it.
+
   - ``queues [{unsigned} [...]] end``: queue indices to use.
 
 - ``pf``: redirect packets to physical device function.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 10/13] ethdev: fix shallow copy of flow API RSS action
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (8 preceding siblings ...)
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 09/13] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-04-04 14:58   ` Adrien Mazarguil
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 11/13] ethdev: fix missing boolean values in flow command Adrien Mazarguil
                     ` (3 subsequent siblings)
  13 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:58 UTC (permalink / raw)
  To: dev; +Cc: stable, Gaetan Rivet, Thomas Monjalon

The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.

Even assuming it is permanently allocated and a pointer copy is safe,
pointed data may change and not reflect an applied flow rule anymore.

This patch aligns with testpmd by making a deep copy instead.

Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
Cc: stable@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 43 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index 38f2d27be..ba6feddee 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,
 	return -code;
 }
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
-	/* Not a fall-through */
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = rte_flow_desc_item[item->type].size;
+		size = rte_flow_desc_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
-	/* Not a fall-through. */
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = rte_flow_desc_action[action->type].size;
+		size = rte_flow_desc_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Store a full rte_flow description. */
@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 {
 	struct rte_flow_desc *fd = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	size_t size = 0;
@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, item,
 					     sizeof(*item));
 			off1 += sizeof(*item);
-			flow_item_spec_size(item, &tmp, &pad);
 			if (item->spec) {
 				if (fd)
-					dst->spec = memcpy(fd->data + off2,
-							   item->spec, tmp);
-				off2 += tmp + pad;
+					dst->spec = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_SPEC);
 			}
 			if (item->last) {
 				if (fd)
-					dst->last = memcpy(fd->data + off2,
-							   item->last, tmp);
-				off2 += tmp + pad;
+					dst->last = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_LAST);
 			}
 			if (item->mask) {
 				if (fd)
-					dst->mask = memcpy(fd->data + off2,
-							   item->mask, tmp);
-				off2 += tmp + pad;
+					dst->mask = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_MASK);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, action,
 					     sizeof(*action));
 			off1 += sizeof(*action);
-			flow_action_conf_size(action, &tmp, &pad);
 			if (action->conf) {
 				if (fd)
-					dst->conf = memcpy(fd->data + off2,
-							   action->conf, tmp);
-				off2 += tmp + pad;
+					dst->conf = fd->data + off2;
+				off2 += flow_action_conf_copy
+					(fd ? fd->data + off2 : NULL, action);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 11/13] ethdev: fix missing boolean values in flow command
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (9 preceding siblings ...)
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 10/13] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-04-04 14:58   ` Adrien Mazarguil
  2018-04-05  8:17     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 12/13] ethdev: fix ABI version in meson build Adrien Mazarguil
                     ` (2 subsequent siblings)
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:58 UTC (permalink / raw)
  To: dev; +Cc: stable

Original implementation lacks the on/off toggle.

This patch shows up as a fix because it has been a popular request ever
since the first DPDK release with the original implementation but was never
addressed.

Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index dbf4afebf..30450f1a4 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2695,6 +2695,7 @@ static const char *const boolean_name[] = {
 	"false", "true",
 	"no", "yes",
 	"N", "Y",
+	"off", "on",
 	NULL,
 };
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 12/13] ethdev: fix ABI version in meson build
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (10 preceding siblings ...)
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 11/13] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-04 14:58   ` Adrien Mazarguil
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 13/13] ethdev: fix missing include in flow API Adrien Mazarguil
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  13 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:58 UTC (permalink / raw)
  To: dev; +Cc: Kirill Rybalchenko

Must remain synchronized with its Makefile counterpart.

Fixes: 653e038efc9b ("ethdev: remove versioning of filter control function")
Cc: Kirill Rybalchenko <kirill.rybalchenko@intel.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 lib/librte_ether/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/meson.build b/lib/librte_ether/meson.build
index 7fed86056..12bdb6b61 100644
--- a/lib/librte_ether/meson.build
+++ b/lib/librte_ether/meson.build
@@ -2,7 +2,7 @@
 # Copyright(c) 2017 Intel Corporation
 
 name = 'ethdev'
-version = 8
+version = 9
 allow_experimental_apis = true
 sources = files('ethdev_profile.c',
 	'rte_ethdev.c',
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v2 13/13] ethdev: fix missing include in flow API
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (11 preceding siblings ...)
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 12/13] ethdev: fix ABI version in meson build Adrien Mazarguil
@ 2018-04-04 14:58   ` Adrien Mazarguil
  2018-04-05  8:18     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  13 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 14:58 UTC (permalink / raw)
  To: dev; +Cc: stable

Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 lib/librte_ether/rte_flow.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index 13e420218..cdaaa3a5b 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -14,6 +14,8 @@
  * associated actions in hardware through flow rules.
  */
 
+#include <stdint.h>
+
 #include <rte_arp.h>
 #include <rte_ether.h>
 #include <rte_icmp.h>
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API Adrien Mazarguil
@ 2018-04-04 15:30     ` Andrew Rybchenko
  2018-04-04 16:08       ` Adrien Mazarguil
  0 siblings, 1 reply; 93+ messages in thread
From: Andrew Rybchenko @ 2018-04-04 15:30 UTC (permalink / raw)
  To: Adrien Mazarguil, dev; +Cc: stable, Roman Zhukov

Adrien,

On 04/04/2018 05:57 PM, Adrien Mazarguil wrote:
> These conversions do not use the adequate function.
>
> Fixes: a9825ccf5bb8 ("net/sfc: support flow API filters")
> Fixes: 894080975e1e ("net/sfc: support VLAN in flow API filters")
> Fixes: e2675132444e ("net/sfc: support TCP in flow API filters")
> Fixes: e01f84f42cad ("net/sfc: support UDP in flow API filters")
> Cc: stable@dpdk.org
> Cc: Roman Zhukov <roman.zhukov@oktetlabs.ru>
> Cc: Andrew Rybchenko <arybchenko@solarflare.com>
>
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---
>   drivers/net/sfc/sfc_flow.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
> index fe4c0b0c5..9060fdc2f 100644
> --- a/drivers/net/sfc/sfc_flow.c
> +++ b/drivers/net/sfc/sfc_flow.c
> @@ -7,6 +7,7 @@
>    * for Solarflare) and Solarflare Communications, Inc.
>    */
>   
> +#include <rte_byteorder.h>
>   #include <rte_tailq.h>
>   #include <rte_common.h>
>   #include <rte_ethdev_driver.h>
> @@ -315,7 +316,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
>   	 */
>   	if (mask->type == supp_mask.type) {
>   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
> -		efx_spec->efs_ether_type = rte_bswap16(spec->type);
> +		efx_spec->efs_ether_type = rte_be_to_cpu_16(spec->type);
>   	} else if (mask->type != 0) {
>   		goto fail_bad_mask;
>   	}
> @@ -370,7 +371,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item,
>   	 * the outer tag and the next matches the inner tag.
>   	 */
>   	if (mask->tci == supp_mask.tci) {
> -		vid = rte_bswap16(spec->tci);
> +		vid = rte_be_to_cpu_16(spec->tci);
>   
>   		if (!(efx_spec->efs_match_flags &
>   		      EFX_FILTER_MATCH_OUTER_VID)) {
> @@ -654,14 +655,14 @@ sfc_flow_parse_tcp(const struct rte_flow_item *item,
>   	 */
>   	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
>   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
> -		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
> +		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
>   	} else if (mask->hdr.src_port != 0) {
>   		goto fail_bad_mask;
>   	}
>   
>   	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
>   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
> -		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
> +		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
>   	} else if (mask->hdr.dst_port != 0) {
>   		goto fail_bad_mask;
>   	}
> @@ -735,14 +736,14 @@ sfc_flow_parse_udp(const struct rte_flow_item *item,
>   	 */
>   	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
>   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
> -		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
> +		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
>   	} else if (mask->hdr.src_port != 0) {
>   		goto fail_bad_mask;
>   	}
>   
>   	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
>   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
> -		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
> +		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
>   	} else if (mask->hdr.dst_port != 0) {
>   		goto fail_bad_mask;
>   	}

efs_filter_spec_t members are little-endian (_not_ host-endian). At 
least comments
say so and to be consistent we use rte_bswap*() functions intentionally.
Yes, may be it is buggy in fact - I don't know. The code never worked on 
big-endian.
So, we're aware and thanks for the reminder.
We'd prefer to keep it as is if there is no strong reasons to change.

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API
  2018-04-04 15:30     ` Andrew Rybchenko
@ 2018-04-04 16:08       ` Adrien Mazarguil
  2018-04-05 15:10         ` Andrew Rybchenko
  0 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-04 16:08 UTC (permalink / raw)
  To: Andrew Rybchenko; +Cc: dev, stable, Roman Zhukov

Hi Andrew,

On Wed, Apr 04, 2018 at 06:30:24PM +0300, Andrew Rybchenko wrote:
> Adrien,
> 
> On 04/04/2018 05:57 PM, Adrien Mazarguil wrote:
> > These conversions do not use the adequate function.
> > 
> > Fixes: a9825ccf5bb8 ("net/sfc: support flow API filters")
> > Fixes: 894080975e1e ("net/sfc: support VLAN in flow API filters")
> > Fixes: e2675132444e ("net/sfc: support TCP in flow API filters")
> > Fixes: e01f84f42cad ("net/sfc: support UDP in flow API filters")
> > Cc: stable@dpdk.org
> > Cc: Roman Zhukov <roman.zhukov@oktetlabs.ru>
> > Cc: Andrew Rybchenko <arybchenko@solarflare.com>
> > 
> > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > ---
> >   drivers/net/sfc/sfc_flow.c | 13 +++++++------
> >   1 file changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
> > index fe4c0b0c5..9060fdc2f 100644
> > --- a/drivers/net/sfc/sfc_flow.c
> > +++ b/drivers/net/sfc/sfc_flow.c
> > @@ -7,6 +7,7 @@
> >    * for Solarflare) and Solarflare Communications, Inc.
> >    */
> > +#include <rte_byteorder.h>
> >   #include <rte_tailq.h>
> >   #include <rte_common.h>
> >   #include <rte_ethdev_driver.h>
> > @@ -315,7 +316,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
> >   	 */
> >   	if (mask->type == supp_mask.type) {
> >   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
> > -		efx_spec->efs_ether_type = rte_bswap16(spec->type);
> > +		efx_spec->efs_ether_type = rte_be_to_cpu_16(spec->type);
> >   	} else if (mask->type != 0) {
> >   		goto fail_bad_mask;
> >   	}
> > @@ -370,7 +371,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item,
> >   	 * the outer tag and the next matches the inner tag.
> >   	 */
> >   	if (mask->tci == supp_mask.tci) {
> > -		vid = rte_bswap16(spec->tci);
> > +		vid = rte_be_to_cpu_16(spec->tci);
> >   		if (!(efx_spec->efs_match_flags &
> >   		      EFX_FILTER_MATCH_OUTER_VID)) {
> > @@ -654,14 +655,14 @@ sfc_flow_parse_tcp(const struct rte_flow_item *item,
> >   	 */
> >   	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
> >   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
> > -		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
> > +		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
> >   	} else if (mask->hdr.src_port != 0) {
> >   		goto fail_bad_mask;
> >   	}
> >   	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
> >   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
> > -		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
> > +		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
> >   	} else if (mask->hdr.dst_port != 0) {
> >   		goto fail_bad_mask;
> >   	}
> > @@ -735,14 +736,14 @@ sfc_flow_parse_udp(const struct rte_flow_item *item,
> >   	 */
> >   	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
> >   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
> > -		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
> > +		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
> >   	} else if (mask->hdr.src_port != 0) {
> >   		goto fail_bad_mask;
> >   	}
> >   	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
> >   		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
> > -		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
> > +		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
> >   	} else if (mask->hdr.dst_port != 0) {
> >   		goto fail_bad_mask;
> >   	}
> 
> efs_filter_spec_t members are little-endian (_not_ host-endian). At least
> comments
> say so and to be consistent we use rte_bswap*() functions intentionally.
> Yes, may be it is buggy in fact - I don't know. The code never worked on
> big-endian.
> So, we're aware and thanks for the reminder.
> We'd prefer to keep it as is if there is no strong reasons to change.

I didn't notice those members had to be little endian, I'll drop this patch
from the series and fix subsequent patch [1] accordingly.

Can you have a look at this patch before I roll new version for both series?

Thanks.

[1] http://dpdk.org/ml/archives/dev/2018-April/095311.html

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v2 03/13] net/mlx5: fix RSS flow action bounds check
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 03/13] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
@ 2018-04-05  6:57     ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-05  6:57 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable

On Wed, Apr 04, 2018 at 04:57:50PM +0200, Adrien Mazarguil wrote:
> The number of queues provided by the application is not checked against
> parser's supported maximum.
> 
> Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
> Cc: stable@dpdk.org
> Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index e6af3243d..f051fbef5 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -16,6 +16,7 @@
>  #pragma GCC diagnostic error "-Wpedantic"
>  #endif
>  
> +#include <rte_common.h>
>  #include <rte_ethdev_driver.h>
>  #include <rte_flow.h>
>  #include <rte_flow_driver.h>
> @@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
>  					return -rte_errno;
>  				}
>  			}
> +			if (rss->num > RTE_DIM(parser->queues)) {
> +				rte_flow_error_set(error, EINVAL,
> +						   RTE_FLOW_ERROR_TYPE_ACTION,
> +						   actions,
> +						   "too many queues for RSS"
> +						   " context");
> +				return -rte_errno;
> +			}
>  			for (n = 0; n < rss->num; ++n) {
>  				if (rss->queue[n] >= priv->rxqs_n) {
>  					rte_flow_error_set(error, EINVAL,
> -- 
> 2.11.0

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v2 07/13] app/testpmd: fix lack of flow action configuration
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 07/13] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-04-05  6:59     ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-05  6:59 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable, Wenzhuo Lu, Jingjing Wu

On Wed, Apr 04, 2018 at 04:57:58PM +0200, Adrien Mazarguil wrote:
> Configuration structure is not optional with flow rule actions that expect
> one; this pointer is not supposed to be NULL and PMDs should not have to
> verify it.
> 
> Like pattern item spec/last/mask fields, it is currently set when at least
> one configuration parameter is provided on the command line. This patch
> sets it as soon as an action is created instead.
> 
> Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Cc: Jingjing Wu <jingjing.wu@intel.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  app/test-pmd/cmdline_flow.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 9cac8e9bf..c2cf415ef 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
>  			return -1;
>  		*action = (struct rte_flow_action){
>  			.type = priv->type,
> +			.conf = data_size ? data : NULL,
>  		};
>  		++out->args.vc.actions_n;
>  		ctx->object = action;
> @@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
>  	      void *buf, unsigned int size)
>  {
>  	struct buffer *out = buf;
> -	struct rte_flow_action *action;
>  
>  	(void)size;
>  	/* Token name must match. */
> @@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
>  	/* Nothing else to do if there is no buffer. */
>  	if (!out)
>  		return len;
> -	if (!out->args.vc.actions_n)
> -		return -1;
> -	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
>  	/* Point to selected object. */
>  	ctx->object = out->args.vc.data;
>  	ctx->objmask = NULL;
> -	/* Update configuration pointer. */
> -	action->conf = ctx->object;
>  	return len;
>  }
>  
> -- 
> 2.11.0

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v2 08/13] app/testpmd: fix RSS flow action configuration
  2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 08/13] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-04-05  7:39     ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-05  7:39 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable, Wenzhuo Lu, Jingjing Wu

On Wed, Apr 04, 2018 at 04:57:59PM +0200, Adrien Mazarguil wrote:
> Except for a list of queues, RSS configuration (hash key and fields) cannot
> be specified from the flow command line and testpmd does not provide safe
> defaults either.
> 
> In order to validate their implementation with testpmd, PMDs had to
> interpret its NULL RSS configuration parameters somehow, however this has
> never been valid to begin with.
> 
> This patch makes testpmd always provide default values.
> 
> Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Cc: Jingjing Wu <jingjing.wu@intel.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v2 09/13] app/testpmd: fix missing RSS fields in flow action
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 09/13] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-04-05  8:15     ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-05  8:15 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable, Wenzhuo Lu, Jingjing Wu

On Wed, Apr 04, 2018 at 04:58:01PM +0200, Adrien Mazarguil wrote:
> Users cannot override the default RSS settings when entering a RSS action,
> only a list of queues can be provided.
> 
> This patch enables them to set a RSS hash key and types for a flow rule.
> 
> Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Cc: Jingjing Wu <jingjing.wu@intel.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v2 11/13] ethdev: fix missing boolean values in flow command
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 11/13] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-05  8:17     ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-05  8:17 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable

On Wed, Apr 04, 2018 at 04:58:05PM +0200, Adrien Mazarguil wrote:
> Original implementation lacks the on/off toggle.
> 
> This patch shows up as a fix because it has been a popular request ever
> since the first DPDK release with the original implementation but was never
> addressed.
> 
> Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  app/test-pmd/cmdline_flow.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index dbf4afebf..30450f1a4 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -2695,6 +2695,7 @@ static const char *const boolean_name[] = {
>  	"false", "true",
>  	"no", "yes",
>  	"N", "Y",
> +	"off", "on",
>  	NULL,
>  };
>  
> -- 
> 2.11.0

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v2 13/13] ethdev: fix missing include in flow API
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 13/13] ethdev: fix missing include in flow API Adrien Mazarguil
@ 2018-04-05  8:18     ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-05  8:18 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable

On Wed, Apr 04, 2018 at 04:58:08PM +0200, Adrien Mazarguil wrote:
> Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  lib/librte_ether/rte_flow.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
> index 13e420218..cdaaa3a5b 100644
> --- a/lib/librte_ether/rte_flow.h
> +++ b/lib/librte_ether/rte_flow.h
> @@ -14,6 +14,8 @@
>   * associated actions in hardware through flow rules.
>   */
>  
> +#include <stdint.h>
> +
>  #include <rte_arp.h>
>  #include <rte_ether.h>
>  #include <rte_icmp.h>
> -- 
> 2.11.0

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API
  2018-04-04 16:08       ` Adrien Mazarguil
@ 2018-04-05 15:10         ` Andrew Rybchenko
  0 siblings, 0 replies; 93+ messages in thread
From: Andrew Rybchenko @ 2018-04-05 15:10 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, Roman Zhukov

Hi Adrien,

On 04/04/2018 07:08 PM, Adrien Mazarguil wrote:
> Hi Andrew,
>
> On Wed, Apr 04, 2018 at 06:30:24PM +0300, Andrew Rybchenko wrote:
>> Adrien,
>>
>> On 04/04/2018 05:57 PM, Adrien Mazarguil wrote:
>>> These conversions do not use the adequate function.
>>>
>>> Fixes: a9825ccf5bb8 ("net/sfc: support flow API filters")
>>> Fixes: 894080975e1e ("net/sfc: support VLAN in flow API filters")
>>> Fixes: e2675132444e ("net/sfc: support TCP in flow API filters")
>>> Fixes: e01f84f42cad ("net/sfc: support UDP in flow API filters")
>>> Cc: stable@dpdk.org
>>> Cc: Roman Zhukov <roman.zhukov@oktetlabs.ru>
>>> Cc: Andrew Rybchenko <arybchenko@solarflare.com>
>>>
>>> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
>>> ---
>>>    drivers/net/sfc/sfc_flow.c | 13 +++++++------
>>>    1 file changed, 7 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
>>> index fe4c0b0c5..9060fdc2f 100644
>>> --- a/drivers/net/sfc/sfc_flow.c
>>> +++ b/drivers/net/sfc/sfc_flow.c
>>> @@ -7,6 +7,7 @@
>>>     * for Solarflare) and Solarflare Communications, Inc.
>>>     */
>>> +#include <rte_byteorder.h>
>>>    #include <rte_tailq.h>
>>>    #include <rte_common.h>
>>>    #include <rte_ethdev_driver.h>
>>> @@ -315,7 +316,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
>>>    	 */
>>>    	if (mask->type == supp_mask.type) {
>>>    		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
>>> -		efx_spec->efs_ether_type = rte_bswap16(spec->type);
>>> +		efx_spec->efs_ether_type = rte_be_to_cpu_16(spec->type);
>>>    	} else if (mask->type != 0) {
>>>    		goto fail_bad_mask;
>>>    	}
>>> @@ -370,7 +371,7 @@ sfc_flow_parse_vlan(const struct rte_flow_item *item,
>>>    	 * the outer tag and the next matches the inner tag.
>>>    	 */
>>>    	if (mask->tci == supp_mask.tci) {
>>> -		vid = rte_bswap16(spec->tci);
>>> +		vid = rte_be_to_cpu_16(spec->tci);
>>>    		if (!(efx_spec->efs_match_flags &
>>>    		      EFX_FILTER_MATCH_OUTER_VID)) {
>>> @@ -654,14 +655,14 @@ sfc_flow_parse_tcp(const struct rte_flow_item *item,
>>>    	 */
>>>    	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
>>>    		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
>>> -		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
>>> +		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
>>>    	} else if (mask->hdr.src_port != 0) {
>>>    		goto fail_bad_mask;
>>>    	}
>>>    	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
>>>    		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
>>> -		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
>>> +		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
>>>    	} else if (mask->hdr.dst_port != 0) {
>>>    		goto fail_bad_mask;
>>>    	}
>>> @@ -735,14 +736,14 @@ sfc_flow_parse_udp(const struct rte_flow_item *item,
>>>    	 */
>>>    	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
>>>    		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
>>> -		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
>>> +		efx_spec->efs_rem_port = rte_be_to_cpu_16(spec->hdr.src_port);
>>>    	} else if (mask->hdr.src_port != 0) {
>>>    		goto fail_bad_mask;
>>>    	}
>>>    	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
>>>    		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
>>> -		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
>>> +		efx_spec->efs_loc_port = rte_be_to_cpu_16(spec->hdr.dst_port);
>>>    	} else if (mask->hdr.dst_port != 0) {
>>>    		goto fail_bad_mask;
>>>    	}
>> efs_filter_spec_t members are little-endian (_not_ host-endian). At least
>> comments
>> say so and to be consistent we use rte_bswap*() functions intentionally.
>> Yes, may be it is buggy in fact - I don't know. The code never worked on
>> big-endian.
>> So, we're aware and thanks for the reminder.
>> We'd prefer to keep it as is if there is no strong reasons to change.
> I didn't notice those members had to be little endian, I'll drop this patch
> from the series and fix subsequent patch [1] accordingly.
>
> Can you have a look at this patch before I roll new version for both series?
>
> Thanks.
>
> [1] http://dpdk.org/ml/archives/dev/2018-April/095311.html

We're still testing these patches since it requires fixes in test harness.
We'll provide feedback tomorrow.

Thanks,
Andrew.

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes
  2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
                     ` (12 preceding siblings ...)
  2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 13/13] ethdev: fix missing include in flow API Adrien Mazarguil
@ 2018-04-06 13:22   ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
                       ` (11 more replies)
  13 siblings, 12 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev

This series contains several fixes for rte_flow and its implementation in
PMDs and testpmd. Upcoming work on the flow API depends on it.

v3 changes:

- Rebased series.
- Dropped unnecessary "net/sfc: fix endian conversions in flow API".
- Dropped "ethdev: fix ABI version in meson build", handled by prior commit
  d9736a248785 ("ethdev: fix library version in meson build").

v2 changes:

- mlx5 fix (patch #3).
- bnxt fix (patch #4).
- sfc fix (patch #6).
- Missing include (patch #13).

Adrien Mazarguil (11):
  net/mlx4: fix RSS resource leak in case of error
  net/mlx4: fix ignored RSS hash types
  net/mlx5: fix RSS flow action bounds check
  net/bnxt: fix matching of flow API item masks
  app/testpmd: fix flow completion for RSS queues
  app/testpmd: fix lack of flow action configuration
  app/testpmd: fix RSS flow action configuration
  app/testpmd: fix missing RSS fields in flow action
  ethdev: fix shallow copy of flow API RSS action
  ethdev: fix missing boolean values in flow command
  ethdev: fix missing include in flow API

 app/test-pmd/cmdline_flow.c                 | 255 ++++++++++++++++++++---
 app/test-pmd/config.c                       | 160 +++++++++-----
 app/test-pmd/testpmd.h                      |  13 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bnxt/bnxt_filter.c              |  14 +-
 drivers/net/mlx4/mlx4_flow.c                |  17 +-
 drivers/net/mlx5/mlx5_flow.c                |   9 +
 lib/librte_ether/rte_flow.c                 | 145 +++++++++----
 lib/librte_ether/rte_flow.h                 |   2 +
 9 files changed, 495 insertions(+), 128 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 01/11] net/mlx4: fix RSS resource leak in case of error
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
                       ` (10 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When memory cannot be allocated for a flow rule, its RSS context reference
is not dropped.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 2d55bfe03..a3b4480b4 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
 			},
 		};
 
-		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
+		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
+			if (temp.rss)
+				mlx4_rss_put(temp.rss);
 			return rte_flow_error_set
 				(error, -rte_errno,
 				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				 "flow rule handle allocation failure");
+		}
 		/* Most fields will be updated by second pass. */
 		*flow = (struct rte_flow){
 			.ibv_attr = temp.ibv_attr,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 02/11] net/mlx4: fix ignored RSS hash types
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
                       ` (9 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When an unsupported hash type is part of a RSS configuration structure, it
is silently ignored instead of triggering an error. This may lead
applications to assume that such types are accepted, while they are in fact
not part of the resulting flow rules.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index a3b4480b4..4d26df326 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
 			const struct rte_flow_action_queue *queue;
 			const struct rte_flow_action_rss *rss;
 			const struct rte_eth_rss_conf *rss_conf;
+			uint64_t fields;
 			unsigned int i;
 
 		case RTE_FLOW_ACTION_TYPE_VOID:
@@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
 					" of the context size";
 				goto exit_action_not_supported;
 			}
+			rte_errno = 0;
+			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
+			if (fields == (uint64_t)-1 && rte_errno) {
+				msg = "unsupported RSS hash type requested";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
-				(priv,
-				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
-				 rss_conf->rss_key, rss->num, rss->queue);
+				(priv, fields, rss_conf->rss_key, rss->num,
+				 rss->queue);
 			if (!flow->rss) {
 				msg = "either invalid parameters or not enough"
 					" resources for additional multi-queue"
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 03/11] net/mlx5: fix RSS flow action bounds check
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
                       ` (8 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Nelio Laranjeiro

The number of queues provided by the application is not checked against
parser's supported maximum.

Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
Cc: stable@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e6af3243d..f051fbef5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -16,6 +16,7 @@
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include <rte_common.h>
 #include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
+			if (rss->num > RTE_DIM(parser->queues)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "too many queues for RSS"
+						   " context");
+				return -rte_errno;
+			}
 			for (n = 0; n < rss->num; ++n) {
 				if (rss->queue[n] >= priv->rxqs_n) {
 					rte_flow_error_set(error, EINVAL,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 04/11] net/bnxt: fix matching of flow API item masks
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (2 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
                       ` (7 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Ajit Khaparde

Some values are interpreted without endian conversion and/or without
taking the proper mask into account.

Fixes: 5ef3b79fdfe6 ("net/bnxt: support flow filter ops")
Cc: stable@dpdk.org
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/bnxt/bnxt_filter.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 96b382ba8..0f9c1c9ae 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -5,6 +5,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
@@ -346,7 +347,8 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			/* Mask is not allowed. Only exact matches are */
-			if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
+			if (eth_mask->type &&
+			    eth_mask->type != RTE_BE16(0xffff)) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
@@ -372,7 +374,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			   *  RTE_LOG(ERR, PMD, "Handle this condition\n");
 			   * }
 			   */
-			if (eth_spec->type) {
+			if (eth_mask->type) {
 				filter->ethertype =
 					rte_be_to_cpu_16(eth_spec->type);
 				en |= use_ntuple ?
@@ -384,13 +386,15 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			vlan_spec = item->spec;
 			vlan_mask = item->mask;
-			if (vlan_mask->tci & 0xFFFF && !vlan_mask->tpid) {
+			if (vlan_mask->tci &&
+			    vlan_mask->tci == RTE_BE16(0x0fff) &&
+			    !vlan_mask->tpid) {
 				/* Only the VLAN ID can be matched. */
 				filter->l2_ovlan =
 					rte_be_to_cpu_16(vlan_spec->tci &
-							 0xFFF);
+							 RTE_BE16(0x0fff));
 				en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID;
-			} else {
+			} else if (vlan_mask->tci || vlan_mask->tpid) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 05/11] app/testpmd: fix flow completion for RSS queues
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (3 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
                       ` (6 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

The lack of a working completion for RSS queues was overlooked during
development; until now only "end" was displayed as a valid token.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a5cf84f79..9cac8e9bf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2663,17 +2663,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			 unsigned int ent, char *buf, unsigned int size)
 {
-	static const char *const str[] = { "", "end", NULL };
-	unsigned int i;
-
 	(void)ctx;
 	(void)token;
-	for (i = 0; str[i] != NULL; ++i)
-		if (buf && i == ent)
-			return snprintf(buf, size, "%s", str[i]);
-	if (buf)
-		return -1;
-	return i;
+	if (!buf)
+		return nb_rxq + 1;
+	if (ent < nb_rxq)
+		return snprintf(buf, size, "%u", ent);
+	if (ent == nb_rxq)
+		return snprintf(buf, size, "end");
+	return -1;
 }
 
 /** Internal context. */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 06/11] app/testpmd: fix lack of flow action configuration
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (4 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 07/11] app/testpmd: fix RSS " Adrien Mazarguil
                       ` (5 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Configuration structure is not optional with flow rule actions that expect
one; this pointer is not supposed to be NULL and PMDs should not have to
verify it.

Like pattern item spec/last/mask fields, it is currently set when at least
one configuration parameter is provided on the command line. This patch
sets it as soon as an action is created instead.

Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 9cac8e9bf..c2cf415ef 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
 			return -1;
 		*action = (struct rte_flow_action){
 			.type = priv->type,
+			.conf = data_size ? data : NULL,
 		};
 		++out->args.vc.actions_n;
 		ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	      void *buf, unsigned int size)
 {
 	struct buffer *out = buf;
-	struct rte_flow_action *action;
 
 	(void)size;
 	/* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
-	if (!out->args.vc.actions_n)
-		return -1;
-	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
 	/* Point to selected object. */
 	ctx->object = out->args.vc.data;
 	ctx->objmask = NULL;
-	/* Update configuration pointer. */
-	action->conf = ctx->object;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 07/11] app/testpmd: fix RSS flow action configuration
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (5 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
                       ` (4 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Except for a list of queues, RSS configuration (hash key and fields) cannot
be specified from the flow command line and testpmd does not provide safe
defaults either.

In order to validate their implementation with testpmd, PMDs had to
interpret its NULL RSS configuration parameters somehow, however this has
never been valid to begin with.

This patch makes testpmd always provide default values.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 104 +++++++++++++++++++++++++----
 app/test-pmd/config.c       | 140 +++++++++++++++++++++++++++------------
 2 files changed, 191 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index c2cf415ef..890c36d8e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */
-#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */
-#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
 #define CTX_STACK_SIZE 16
@@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
 static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,64 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		if (rte_eth_dev_rss_hash_conf_get
+		    (ctx->port, &action_rss_data->s.rss_conf) < 0) {
+			struct rte_eth_dev_info info;
+
+			rte_eth_dev_info_get(ctx->port, &info);
+			action_rss_data->s.rss_conf.rss_key_len =
+				RTE_MIN(sizeof(action_rss_data->s.rss_key),
+					info.hash_key_size);
+		}
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2089,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2103,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2124,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4bb255c62..aab5db355 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -982,31 +982,51 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
 };
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1036,31 +1056,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */
@@ -1073,7 +1134,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1091,24 +1151,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -1125,12 +1184,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 08/11] app/testpmd: fix missing RSS fields in flow action
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (6 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 07/11] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
                       ` (3 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Users cannot override the default RSS settings when entering a RSS action,
only a list of queues can be provided.

This patch enables them to set a RSS hash key and types for a flow rule.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 133 ++++++++++++++++++++++-
 app/test-pmd/config.c                       |  20 ++--
 app/test-pmd/testpmd.h                      |  13 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 ++
 4 files changed, 163 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 890c36d8e..dbf4afebf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -167,6 +167,10 @@ enum index {
 	ACTION_DUP,
 	ACTION_DUP_INDEX,
 	ACTION_RSS,
+	ACTION_RSS_TYPES,
+	ACTION_RSS_TYPE,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_RSS_QUEUE,
 	ACTION_PF,
@@ -223,6 +227,9 @@ struct context {
 struct arg {
 	uint32_t hton:1; /**< Use network byte ordering. */
 	uint32_t sign:1; /**< Value is signed. */
+	uint32_t bounded:1; /**< Value is bounded. */
+	uintmax_t min; /**< Minimum value if bounded. */
+	uintmax_t max; /**< Maximum value if bounded. */
 	uint32_t offset; /**< Relative offset from ctx->object. */
 	uint32_t size; /**< Field size. */
 	const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
@@ -329,6 +336,16 @@ struct token {
 		.size = (s), \
 	})
 
+/** Same as ARGS_ENTRY_ARB() with bounded values. */
+#define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
+	(&(const struct arg){ \
+		.bounded = 1, \
+		.min = (i), \
+		.max = (a), \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -635,6 +652,9 @@ static const enum index action_dup[] = {
 };
 
 static const enum index action_rss[] = {
+	ACTION_RSS_TYPES,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_NEXT,
 	ZERO,
@@ -666,6 +686,9 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
+static int parse_vc_action_rss_type(struct context *, const struct token *,
+				    const char *, unsigned int, void *,
+				    unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -721,6 +744,8 @@ static int comp_port(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_rule_id(struct context *, const struct token *,
 			unsigned int, char *, unsigned int);
+static int comp_vc_action_rss_type(struct context *, const struct token *,
+				   unsigned int, char *, unsigned int);
 static int comp_vc_action_rss_queue(struct context *, const struct token *,
 				    unsigned int, char *, unsigned int);
 
@@ -1593,6 +1618,43 @@ static const struct token token_list[] = {
 		.next = NEXT(action_rss),
 		.call = parse_vc_action_rss,
 	},
+	[ACTION_RSS_TYPES] = {
+		.name = "types",
+		.help = "RSS hash types",
+		.next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
+	},
+	[ACTION_RSS_TYPE] = {
+		.name = "{type}",
+		.help = "RSS hash type",
+		.call = parse_vc_action_rss_type,
+		.comp = comp_vc_action_rss_type,
+	},
+	[ACTION_RSS_KEY] = {
+		.name = "key",
+		.help = "RSS hash key",
+		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len)),
+			     ARGS_ENTRY_ARB
+			     (((uintptr_t)((union action_rss_data *)0)->
+			       s.rss_key),
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_KEY_LEN] = {
+		.name = "key_len",
+		.help = "RSS hash key length in bytes",
+		.next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB_BOUNDED
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len),
+			      0,
+			      RSS_HASH_KEY_LENGTH)),
+	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
 		.help = "queue indices to use",
@@ -2079,6 +2141,50 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
 }
 
 /**
+ * Parse type field for RSS action.
+ *
+ * Valid tokens are type field names and the "end" token.
+ */
+static int
+parse_vc_action_rss_type(struct context *ctx, const struct token *token,
+			  const char *str, unsigned int len,
+			  void *buf, unsigned int size)
+{
+	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+
+	(void)token;
+	(void)buf;
+	(void)size;
+	if (ctx->curr != ACTION_RSS_TYPE)
+		return -1;
+	if (!(ctx->objdata >> 16) && ctx->object) {
+		action_rss_data = ctx->object;
+		action_rss_data->s.rss_conf.rss_hf = 0;
+	}
+	if (!strcmp_partial("end", str, len)) {
+		ctx->objdata &= 0xffff;
+		return len;
+	}
+	for (i = 0; rss_type_table[i].str; ++i)
+		if (!strcmp_partial(rss_type_table[i].str, str, len))
+			break;
+	if (!rss_type_table[i].str)
+		return -1;
+	ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
+	/* Repeat token. */
+	if (ctx->next_num == RTE_DIM(ctx->next))
+		return -1;
+	ctx->next[ctx->next_num++] = next;
+	if (!ctx->object)
+		return len;
+	action_rss_data = ctx->object;
+	action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type;
+	return len;
+}
+
+/**
  * Parse queue field for RSS action.
  *
  * Valid tokens are queue indices and the "end" token.
@@ -2344,6 +2450,11 @@ parse_int(struct context *ctx, const struct token *token,
 		strtoumax(str, &end, 0);
 	if (errno || (size_t)(end - str) != len)
 		goto error;
+	if (arg->bounded &&
+	    ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
+			    (intmax_t)u > (intmax_t)arg->max)) ||
+	     (!arg->sign && (u < arg->min || u > arg->max))))
+		goto error;
 	if (!ctx->object)
 		return len;
 	if (arg->mask) {
@@ -2437,7 +2548,7 @@ parse_string(struct context *ctx, const struct token *token,
 	buf = (uint8_t *)ctx->object + arg_data->offset;
 	/* Output buffer is not necessarily NUL-terminated. */
 	memcpy(buf, str, len);
-	memset((uint8_t *)buf + len, 0x55, size - len);
+	memset((uint8_t *)buf + len, 0x00, size - len);
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
 	return len;
@@ -2733,6 +2844,26 @@ comp_rule_id(struct context *ctx, const struct token *token,
 	return i;
 }
 
+/** Complete type field for RSS action. */
+static int
+comp_vc_action_rss_type(struct context *ctx, const struct token *token,
+			unsigned int ent, char *buf, unsigned int size)
+{
+	unsigned int i;
+
+	(void)ctx;
+	(void)token;
+	for (i = 0; rss_type_table[i].str; ++i)
+		;
+	if (!buf)
+		return i + 1;
+	if (ent < i)
+		return snprintf(buf, size, "%s", rss_type_table[ent].str);
+	if (ent == i)
+		return snprintf(buf, size, "end");
+	return -1;
+}
+
 /** Complete queue field for RSS action. */
 static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index aab5db355..2058e6ec8 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -73,12 +73,7 @@ static const struct {
 	},
 };
 
-struct rss_type_info {
-	char str[32];
-	uint64_t rss_type;
-};
-
-static const struct rss_type_info rss_type_table[] = {
+const struct rss_type_info rss_type_table[] = {
 	{ "ipv4", ETH_RSS_IPV4 },
 	{ "ipv4-frag", ETH_RSS_FRAG_IPV4 },
 	{ "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
@@ -99,7 +94,12 @@ static const struct rss_type_info rss_type_table[] = {
 	{ "vxlan", ETH_RSS_VXLAN },
 	{ "geneve", ETH_RSS_GENEVE },
 	{ "nvgre", ETH_RSS_NVGRE },
-
+	{ "ip", ETH_RSS_IP },
+	{ "udp", ETH_RSS_UDP },
+	{ "tcp", ETH_RSS_TCP },
+	{ "sctp", ETH_RSS_SCTP },
+	{ "tunnel", ETH_RSS_TUNNEL },
+	{ NULL, 0 },
 };
 
 static void
@@ -1819,7 +1819,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 	}
 
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_info, rss_type_table[i].str))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
@@ -1848,7 +1848,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 		return;
 	}
 	printf("RSS functions:\n ");
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (rss_hf & rss_type_table[i].rss_type)
 			printf("%s ", rss_type_table[i].str);
 	}
@@ -1872,7 +1872,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = hash_key_len;
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_type_table[i].str, rss_type))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea05..593ae2160 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -79,6 +79,19 @@ struct pkt_burst_stats {
 };
 #endif
 
+/** Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /**< Type name. */
+	uint64_t rss_type; /**< Type value. */
+};
+
+/**
+ * RSS type information table.
+ *
+ * An entry with a NULL type name terminates the list.
+ */
+extern const struct rss_type_info rss_type_table[];
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a766ac795..cb6f201e1 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3406,6 +3406,14 @@ This section lists supported actions and their attributes, if any.
 
 - ``rss``: spread packets among several queues.
 
+  - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens
+    are the same as `set_hash_input_set`_, an empty list means none (0).
+
+  - ``key {string}``: RSS hash key, overrides ``key_len``.
+
+  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
+    conjunction with ``key`` to pad or truncate it.
+
   - ``queues [{unsigned} [...]] end``: queue indices to use.
 
 - ``pf``: redirect packets to physical device function.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 09/11] ethdev: fix shallow copy of flow API RSS action
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (7 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
                       ` (2 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Gaetan Rivet, Thomas Monjalon

The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.

Even assuming it is permanently allocated and a pointer copy is safe,
pointed data may change and not reflect an applied flow rule anymore.

This patch aligns with testpmd by making a deep copy instead.

Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
Cc: stable@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 43 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index 38f2d27be..ba6feddee 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,
 	return -code;
 }
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
-	/* Not a fall-through */
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = rte_flow_desc_item[item->type].size;
+		size = rte_flow_desc_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
-	/* Not a fall-through. */
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = rte_flow_desc_action[action->type].size;
+		size = rte_flow_desc_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Store a full rte_flow description. */
@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 {
 	struct rte_flow_desc *fd = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	size_t size = 0;
@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, item,
 					     sizeof(*item));
 			off1 += sizeof(*item);
-			flow_item_spec_size(item, &tmp, &pad);
 			if (item->spec) {
 				if (fd)
-					dst->spec = memcpy(fd->data + off2,
-							   item->spec, tmp);
-				off2 += tmp + pad;
+					dst->spec = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_SPEC);
 			}
 			if (item->last) {
 				if (fd)
-					dst->last = memcpy(fd->data + off2,
-							   item->last, tmp);
-				off2 += tmp + pad;
+					dst->last = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_LAST);
 			}
 			if (item->mask) {
 				if (fd)
-					dst->mask = memcpy(fd->data + off2,
-							   item->mask, tmp);
-				off2 += tmp + pad;
+					dst->mask = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_MASK);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, action,
 					     sizeof(*action));
 			off1 += sizeof(*action);
-			flow_action_conf_size(action, &tmp, &pad);
 			if (action->conf) {
 				if (fd)
-					dst->conf = memcpy(fd->data + off2,
-							   action->conf, tmp);
-				off2 += tmp + pad;
+					dst->conf = fd->data + off2;
+				off2 += flow_action_conf_copy
+					(fd ? fd->data + off2 : NULL, action);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 10/11] ethdev: fix missing boolean values in flow command
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (8 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable

Original implementation lacks the on/off toggle.

This patch shows up as a fix because it has been a popular request ever
since the first DPDK release with the original implementation but was never
addressed.

Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index dbf4afebf..30450f1a4 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2695,6 +2695,7 @@ static const char *const boolean_name[] = {
 	"false", "true",
 	"no", "yes",
 	"N", "Y",
+	"off", "on",
 	NULL,
 };
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v3 11/11] ethdev: fix missing include in flow API
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (9 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-06 13:22     ` Adrien Mazarguil
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-06 13:22 UTC (permalink / raw)
  To: dev; +Cc: stable

Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 lib/librte_ether/rte_flow.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index 13e420218..cdaaa3a5b 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -14,6 +14,8 @@
  * associated actions in hardware through flow rules.
  */
 
+#include <stdint.h>
+
 #include <rte_arp.h>
 #include <rte_ether.h>
 #include <rte_icmp.h>
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes
  2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                       ` (10 preceding siblings ...)
  2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
@ 2018-04-10 16:34     ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
                         ` (11 more replies)
  11 siblings, 12 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev

This series contains several fixes for rte_flow and its implementation in
PMDs and testpmd. Upcoming work on the flow API depends on it.

v4 changes:

- Rebased again.
- The reliance on rte_eth_dev_rss_hash_conf_get() was removed from patch #7,
  see updated patch for details.

v3 changes:

- Rebased series.
- Dropped unnecessary "net/sfc: fix endian conversions in flow API".
- Dropped "ethdev: fix ABI version in meson build", handled by prior commit
  d9736a248785 ("ethdev: fix library version in meson build").

v2 changes:

- mlx5 fix (patch #3).
- bnxt fix (patch #4).
- sfc fix (patch #6).
- Missing include (patch #13).

Adrien Mazarguil (11):
  net/mlx4: fix RSS resource leak in case of error
  net/mlx4: fix ignored RSS hash types
  net/mlx5: fix RSS flow action bounds check
  net/bnxt: fix matching of flow API item masks
  app/testpmd: fix flow completion for RSS queues
  app/testpmd: fix lack of flow action configuration
  app/testpmd: fix RSS flow action configuration
  app/testpmd: fix missing RSS fields in flow action
  ethdev: fix shallow copy of flow API RSS action
  ethdev: fix missing boolean values in flow command
  ethdev: fix missing include in flow API

 app/test-pmd/cmdline.c                      |   2 +
 app/test-pmd/cmdline_flow.c                 | 252 ++++++++++++++++++++---
 app/test-pmd/config.c                       | 160 +++++++++-----
 app/test-pmd/testpmd.h                      |  13 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bnxt/bnxt_filter.c              |  14 +-
 drivers/net/mlx4/mlx4_flow.c                |  17 +-
 drivers/net/mlx5/mlx5_flow.c                |   9 +
 lib/librte_ether/rte_flow.c                 | 145 +++++++++----
 lib/librte_ether/rte_flow.h                 |   2 +
 10 files changed, 494 insertions(+), 128 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 01/11] net/mlx4: fix RSS resource leak in case of error
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
                         ` (10 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When memory cannot be allocated for a flow rule, its RSS context reference
is not dropped.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 2d55bfe03..a3b4480b4 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
 			},
 		};
 
-		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
+		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
+			if (temp.rss)
+				mlx4_rss_put(temp.rss);
 			return rte_flow_error_set
 				(error, -rte_errno,
 				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				 "flow rule handle allocation failure");
+		}
 		/* Most fields will be updated by second pass. */
 		*flow = (struct rte_flow){
 			.ibv_attr = temp.ibv_attr,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 02/11] net/mlx4: fix ignored RSS hash types
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
                         ` (9 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When an unsupported hash type is part of a RSS configuration structure, it
is silently ignored instead of triggering an error. This may lead
applications to assume that such types are accepted, while they are in fact
not part of the resulting flow rules.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index a3b4480b4..4d26df326 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
 			const struct rte_flow_action_queue *queue;
 			const struct rte_flow_action_rss *rss;
 			const struct rte_eth_rss_conf *rss_conf;
+			uint64_t fields;
 			unsigned int i;
 
 		case RTE_FLOW_ACTION_TYPE_VOID:
@@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
 					" of the context size";
 				goto exit_action_not_supported;
 			}
+			rte_errno = 0;
+			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
+			if (fields == (uint64_t)-1 && rte_errno) {
+				msg = "unsupported RSS hash type requested";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
-				(priv,
-				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
-				 rss_conf->rss_key, rss->num, rss->queue);
+				(priv, fields, rss_conf->rss_key, rss->num,
+				 rss->queue);
 			if (!flow->rss) {
 				msg = "either invalid parameters or not enough"
 					" resources for additional multi-queue"
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 03/11] net/mlx5: fix RSS flow action bounds check
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
                         ` (8 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Nelio Laranjeiro

The number of queues provided by the application is not checked against
parser's supported maximum.

Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
Cc: stable@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e6af3243d..f051fbef5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -16,6 +16,7 @@
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include <rte_common.h>
 #include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
+			if (rss->num > RTE_DIM(parser->queues)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "too many queues for RSS"
+						   " context");
+				return -rte_errno;
+			}
 			for (n = 0; n < rss->num; ++n) {
 				if (rss->queue[n] >= priv->rxqs_n) {
 					rte_flow_error_set(error, EINVAL,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 04/11] net/bnxt: fix matching of flow API item masks
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (2 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
                         ` (7 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Ajit Khaparde

Some values are interpreted without endian conversion and/or without
taking the proper mask into account.

Fixes: 5ef3b79fdfe6 ("net/bnxt: support flow filter ops")
Cc: stable@dpdk.org
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/bnxt/bnxt_filter.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 96b382ba8..0f9c1c9ae 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -5,6 +5,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
@@ -346,7 +347,8 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			/* Mask is not allowed. Only exact matches are */
-			if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
+			if (eth_mask->type &&
+			    eth_mask->type != RTE_BE16(0xffff)) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
@@ -372,7 +374,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			   *  RTE_LOG(ERR, PMD, "Handle this condition\n");
 			   * }
 			   */
-			if (eth_spec->type) {
+			if (eth_mask->type) {
 				filter->ethertype =
 					rte_be_to_cpu_16(eth_spec->type);
 				en |= use_ntuple ?
@@ -384,13 +386,15 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			vlan_spec = item->spec;
 			vlan_mask = item->mask;
-			if (vlan_mask->tci & 0xFFFF && !vlan_mask->tpid) {
+			if (vlan_mask->tci &&
+			    vlan_mask->tci == RTE_BE16(0x0fff) &&
+			    !vlan_mask->tpid) {
 				/* Only the VLAN ID can be matched. */
 				filter->l2_ovlan =
 					rte_be_to_cpu_16(vlan_spec->tci &
-							 0xFFF);
+							 RTE_BE16(0x0fff));
 				en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID;
-			} else {
+			} else if (vlan_mask->tci || vlan_mask->tpid) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 05/11] app/testpmd: fix flow completion for RSS queues
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (3 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
                         ` (6 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

The lack of a working completion for RSS queues was overlooked during
development; until now only "end" was displayed as a valid token.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a5cf84f79..9cac8e9bf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2663,17 +2663,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			 unsigned int ent, char *buf, unsigned int size)
 {
-	static const char *const str[] = { "", "end", NULL };
-	unsigned int i;
-
 	(void)ctx;
 	(void)token;
-	for (i = 0; str[i] != NULL; ++i)
-		if (buf && i == ent)
-			return snprintf(buf, size, "%s", str[i]);
-	if (buf)
-		return -1;
-	return i;
+	if (!buf)
+		return nb_rxq + 1;
+	if (ent < nb_rxq)
+		return snprintf(buf, size, "%u", ent);
+	if (ent == nb_rxq)
+		return snprintf(buf, size, "end");
+	return -1;
 }
 
 /** Internal context. */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 06/11] app/testpmd: fix lack of flow action configuration
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (4 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 07/11] app/testpmd: fix RSS " Adrien Mazarguil
                         ` (5 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Configuration structure is not optional with flow rule actions that expect
one; this pointer is not supposed to be NULL and PMDs should not have to
verify it.

Like pattern item spec/last/mask fields, it is currently set when at least
one configuration parameter is provided on the command line. This patch
sets it as soon as an action is created instead.

Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 9cac8e9bf..c2cf415ef 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
 			return -1;
 		*action = (struct rte_flow_action){
 			.type = priv->type,
+			.conf = data_size ? data : NULL,
 		};
 		++out->args.vc.actions_n;
 		ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	      void *buf, unsigned int size)
 {
 	struct buffer *out = buf;
-	struct rte_flow_action *action;
 
 	(void)size;
 	/* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
-	if (!out->args.vc.actions_n)
-		return -1;
-	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
 	/* Point to selected object. */
 	ctx->object = out->args.vc.data;
 	ctx->objmask = NULL;
-	/* Update configuration pointer. */
-	action->conf = ctx->object;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 07/11] app/testpmd: fix RSS flow action configuration
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (5 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
                         ` (4 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu, Xueming Li

Except for a list of queues, RSS configuration (hash key and fields) cannot
be specified from the flow command line and testpmd does not provide safe
defaults either.

In order to validate their implementation with testpmd, PMDs had to
interpret its NULL RSS configuration parameters somehow, however this has
never been valid to begin with.

This patch makes testpmd always provide default values.

The list of RSS types to use is exclusively taken from the global "rss_hf"
variable, itself configured through the "port config all rss" command or
--rss-ip/--rss-udp command-line options.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>

---

v4 changes:

Removed reliance on rte_eth_dev_rss_hash_conf_get(), which as reported by
Xueming, is not necessarily supported and triggers a misleading "Function
not implemented" warning. Updated commit log to reflect this.
---
 app/test-pmd/cmdline.c      |   2 +
 app/test-pmd/cmdline_flow.c | 101 ++++++++++++++++++++++++----
 app/test-pmd/config.c       | 140 +++++++++++++++++++++++++++------------
 3 files changed, 190 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 40b31ad7e..da784187d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1914,6 +1914,8 @@ cmd_config_rss_parsed(void *parsed_result,
 		return;
 	}
 	rss_conf.rss_key = NULL;
+	/* Update global configuration for RSS types. */
+	rss_hf = rss_conf.rss_hf;
 	for (i = 0; i < rte_eth_dev_count(); i++) {
 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
 		if (diag < 0)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index c2cf415ef..0e250d595 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */
-#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */
-#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
 #define CTX_STACK_SIZE 16
@@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
 static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,61 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		struct rte_eth_dev_info info;
+
+		rte_eth_dev_info_get(ctx->port, &info);
+		action_rss_data->s.rss_conf.rss_key_len =
+			RTE_MIN(sizeof(action_rss_data->s.rss_key),
+				info.hash_key_size);
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2086,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2100,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2121,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4bb255c62..aab5db355 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -982,31 +982,51 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
 };
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1036,31 +1056,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */
@@ -1073,7 +1134,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1091,24 +1151,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -1125,12 +1184,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 08/11] app/testpmd: fix missing RSS fields in flow action
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (6 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 07/11] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
                         ` (3 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Users cannot override the default RSS settings when entering a RSS action,
only a list of queues can be provided.

This patch enables them to set a RSS hash key and types for a flow rule.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 133 ++++++++++++++++++++++-
 app/test-pmd/config.c                       |  20 ++--
 app/test-pmd/testpmd.h                      |  13 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 ++
 4 files changed, 163 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 0e250d595..e43705303 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -167,6 +167,10 @@ enum index {
 	ACTION_DUP,
 	ACTION_DUP_INDEX,
 	ACTION_RSS,
+	ACTION_RSS_TYPES,
+	ACTION_RSS_TYPE,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_RSS_QUEUE,
 	ACTION_PF,
@@ -223,6 +227,9 @@ struct context {
 struct arg {
 	uint32_t hton:1; /**< Use network byte ordering. */
 	uint32_t sign:1; /**< Value is signed. */
+	uint32_t bounded:1; /**< Value is bounded. */
+	uintmax_t min; /**< Minimum value if bounded. */
+	uintmax_t max; /**< Maximum value if bounded. */
 	uint32_t offset; /**< Relative offset from ctx->object. */
 	uint32_t size; /**< Field size. */
 	const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
@@ -329,6 +336,16 @@ struct token {
 		.size = (s), \
 	})
 
+/** Same as ARGS_ENTRY_ARB() with bounded values. */
+#define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
+	(&(const struct arg){ \
+		.bounded = 1, \
+		.min = (i), \
+		.max = (a), \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -635,6 +652,9 @@ static const enum index action_dup[] = {
 };
 
 static const enum index action_rss[] = {
+	ACTION_RSS_TYPES,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_NEXT,
 	ZERO,
@@ -666,6 +686,9 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
+static int parse_vc_action_rss_type(struct context *, const struct token *,
+				    const char *, unsigned int, void *,
+				    unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -721,6 +744,8 @@ static int comp_port(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_rule_id(struct context *, const struct token *,
 			unsigned int, char *, unsigned int);
+static int comp_vc_action_rss_type(struct context *, const struct token *,
+				   unsigned int, char *, unsigned int);
 static int comp_vc_action_rss_queue(struct context *, const struct token *,
 				    unsigned int, char *, unsigned int);
 
@@ -1593,6 +1618,43 @@ static const struct token token_list[] = {
 		.next = NEXT(action_rss),
 		.call = parse_vc_action_rss,
 	},
+	[ACTION_RSS_TYPES] = {
+		.name = "types",
+		.help = "RSS hash types",
+		.next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
+	},
+	[ACTION_RSS_TYPE] = {
+		.name = "{type}",
+		.help = "RSS hash type",
+		.call = parse_vc_action_rss_type,
+		.comp = comp_vc_action_rss_type,
+	},
+	[ACTION_RSS_KEY] = {
+		.name = "key",
+		.help = "RSS hash key",
+		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len)),
+			     ARGS_ENTRY_ARB
+			     (((uintptr_t)((union action_rss_data *)0)->
+			       s.rss_key),
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_KEY_LEN] = {
+		.name = "key_len",
+		.help = "RSS hash key length in bytes",
+		.next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB_BOUNDED
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len),
+			      0,
+			      RSS_HASH_KEY_LENGTH)),
+	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
 		.help = "queue indices to use",
@@ -2076,6 +2138,50 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
 }
 
 /**
+ * Parse type field for RSS action.
+ *
+ * Valid tokens are type field names and the "end" token.
+ */
+static int
+parse_vc_action_rss_type(struct context *ctx, const struct token *token,
+			  const char *str, unsigned int len,
+			  void *buf, unsigned int size)
+{
+	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+
+	(void)token;
+	(void)buf;
+	(void)size;
+	if (ctx->curr != ACTION_RSS_TYPE)
+		return -1;
+	if (!(ctx->objdata >> 16) && ctx->object) {
+		action_rss_data = ctx->object;
+		action_rss_data->s.rss_conf.rss_hf = 0;
+	}
+	if (!strcmp_partial("end", str, len)) {
+		ctx->objdata &= 0xffff;
+		return len;
+	}
+	for (i = 0; rss_type_table[i].str; ++i)
+		if (!strcmp_partial(rss_type_table[i].str, str, len))
+			break;
+	if (!rss_type_table[i].str)
+		return -1;
+	ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
+	/* Repeat token. */
+	if (ctx->next_num == RTE_DIM(ctx->next))
+		return -1;
+	ctx->next[ctx->next_num++] = next;
+	if (!ctx->object)
+		return len;
+	action_rss_data = ctx->object;
+	action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type;
+	return len;
+}
+
+/**
  * Parse queue field for RSS action.
  *
  * Valid tokens are queue indices and the "end" token.
@@ -2341,6 +2447,11 @@ parse_int(struct context *ctx, const struct token *token,
 		strtoumax(str, &end, 0);
 	if (errno || (size_t)(end - str) != len)
 		goto error;
+	if (arg->bounded &&
+	    ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
+			    (intmax_t)u > (intmax_t)arg->max)) ||
+	     (!arg->sign && (u < arg->min || u > arg->max))))
+		goto error;
 	if (!ctx->object)
 		return len;
 	if (arg->mask) {
@@ -2434,7 +2545,7 @@ parse_string(struct context *ctx, const struct token *token,
 	buf = (uint8_t *)ctx->object + arg_data->offset;
 	/* Output buffer is not necessarily NUL-terminated. */
 	memcpy(buf, str, len);
-	memset((uint8_t *)buf + len, 0x55, size - len);
+	memset((uint8_t *)buf + len, 0x00, size - len);
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
 	return len;
@@ -2730,6 +2841,26 @@ comp_rule_id(struct context *ctx, const struct token *token,
 	return i;
 }
 
+/** Complete type field for RSS action. */
+static int
+comp_vc_action_rss_type(struct context *ctx, const struct token *token,
+			unsigned int ent, char *buf, unsigned int size)
+{
+	unsigned int i;
+
+	(void)ctx;
+	(void)token;
+	for (i = 0; rss_type_table[i].str; ++i)
+		;
+	if (!buf)
+		return i + 1;
+	if (ent < i)
+		return snprintf(buf, size, "%s", rss_type_table[ent].str);
+	if (ent == i)
+		return snprintf(buf, size, "end");
+	return -1;
+}
+
 /** Complete queue field for RSS action. */
 static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index aab5db355..2058e6ec8 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -73,12 +73,7 @@ static const struct {
 	},
 };
 
-struct rss_type_info {
-	char str[32];
-	uint64_t rss_type;
-};
-
-static const struct rss_type_info rss_type_table[] = {
+const struct rss_type_info rss_type_table[] = {
 	{ "ipv4", ETH_RSS_IPV4 },
 	{ "ipv4-frag", ETH_RSS_FRAG_IPV4 },
 	{ "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
@@ -99,7 +94,12 @@ static const struct rss_type_info rss_type_table[] = {
 	{ "vxlan", ETH_RSS_VXLAN },
 	{ "geneve", ETH_RSS_GENEVE },
 	{ "nvgre", ETH_RSS_NVGRE },
-
+	{ "ip", ETH_RSS_IP },
+	{ "udp", ETH_RSS_UDP },
+	{ "tcp", ETH_RSS_TCP },
+	{ "sctp", ETH_RSS_SCTP },
+	{ "tunnel", ETH_RSS_TUNNEL },
+	{ NULL, 0 },
 };
 
 static void
@@ -1819,7 +1819,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 	}
 
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_info, rss_type_table[i].str))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
@@ -1848,7 +1848,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 		return;
 	}
 	printf("RSS functions:\n ");
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (rss_hf & rss_type_table[i].rss_type)
 			printf("%s ", rss_type_table[i].str);
 	}
@@ -1872,7 +1872,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = hash_key_len;
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_type_table[i].str, rss_type))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea05..593ae2160 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -79,6 +79,19 @@ struct pkt_burst_stats {
 };
 #endif
 
+/** Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /**< Type name. */
+	uint64_t rss_type; /**< Type value. */
+};
+
+/**
+ * RSS type information table.
+ *
+ * An entry with a NULL type name terminates the list.
+ */
+extern const struct rss_type_info rss_type_table[];
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a766ac795..cb6f201e1 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3406,6 +3406,14 @@ This section lists supported actions and their attributes, if any.
 
 - ``rss``: spread packets among several queues.
 
+  - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens
+    are the same as `set_hash_input_set`_, an empty list means none (0).
+
+  - ``key {string}``: RSS hash key, overrides ``key_len``.
+
+  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
+    conjunction with ``key`` to pad or truncate it.
+
   - ``queues [{unsigned} [...]] end``: queue indices to use.
 
 - ``pf``: redirect packets to physical device function.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 09/11] ethdev: fix shallow copy of flow API RSS action
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (7 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
                         ` (2 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable, Gaetan Rivet, Thomas Monjalon

The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.

Even assuming it is permanently allocated and a pointer copy is safe,
pointed data may change and not reflect an applied flow rule anymore.

This patch aligns with testpmd by making a deep copy instead.

Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
Cc: stable@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 43 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index 38f2d27be..ba6feddee 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,
 	return -code;
 }
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
-	/* Not a fall-through */
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = rte_flow_desc_item[item->type].size;
+		size = rte_flow_desc_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
-	/* Not a fall-through. */
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = rte_flow_desc_action[action->type].size;
+		size = rte_flow_desc_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Store a full rte_flow description. */
@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 {
 	struct rte_flow_desc *fd = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	size_t size = 0;
@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, item,
 					     sizeof(*item));
 			off1 += sizeof(*item);
-			flow_item_spec_size(item, &tmp, &pad);
 			if (item->spec) {
 				if (fd)
-					dst->spec = memcpy(fd->data + off2,
-							   item->spec, tmp);
-				off2 += tmp + pad;
+					dst->spec = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_SPEC);
 			}
 			if (item->last) {
 				if (fd)
-					dst->last = memcpy(fd->data + off2,
-							   item->last, tmp);
-				off2 += tmp + pad;
+					dst->last = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_LAST);
 			}
 			if (item->mask) {
 				if (fd)
-					dst->mask = memcpy(fd->data + off2,
-							   item->mask, tmp);
-				off2 += tmp + pad;
+					dst->mask = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_MASK);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, action,
 					     sizeof(*action));
 			off1 += sizeof(*action);
-			flow_action_conf_size(action, &tmp, &pad);
 			if (action->conf) {
 				if (fd)
-					dst->conf = memcpy(fd->data + off2,
-							   action->conf, tmp);
-				off2 += tmp + pad;
+					dst->conf = fd->data + off2;
+				off2 += flow_action_conf_copy
+					(fd ? fd->data + off2 : NULL, action);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 10/11] ethdev: fix missing boolean values in flow command
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (8 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable

Original implementation lacks the on/off toggle.

This patch shows up as a fix because it has been a popular request ever
since the first DPDK release with the original implementation but was never
addressed.

Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e43705303..ac4b51a8a 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2692,6 +2692,7 @@ static const char *const boolean_name[] = {
 	"false", "true",
 	"no", "yes",
 	"N", "Y",
+	"off", "on",
 	NULL,
 };
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v4 11/11] ethdev: fix missing include in flow API
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (9 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-10 16:34       ` Adrien Mazarguil
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-10 16:34 UTC (permalink / raw)
  To: dev; +Cc: stable

Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 lib/librte_ether/rte_flow.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index 13e420218..cdaaa3a5b 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -14,6 +14,8 @@
  * associated actions in hardware through flow rules.
  */
 
+#include <stdint.h>
+
 #include <rte_arp.h>
 #include <rte_ether.h>
 #include <rte_icmp.h>
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes
  2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                         ` (10 preceding siblings ...)
  2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
@ 2018-04-16 16:21       ` Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
                           ` (12 more replies)
  11 siblings, 13 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev

This series contains several fixes for rte_flow and its implementation in
PMDs and testpmd. Upcoming work on the flow API depends on it.

v5 changes:

- No change, rebased series to address conflicts.

v4 changes:

- Rebased again.
- The reliance on rte_eth_dev_rss_hash_conf_get() was removed from patch #7,
  see updated patch for details.

v3 changes:

- Rebased series.
- Dropped unnecessary "net/sfc: fix endian conversions in flow API".
- Dropped "ethdev: fix ABI version in meson build", handled by prior commit
  d9736a248785 ("ethdev: fix library version in meson build").

v2 changes:

- mlx5 fix (patch #3).
- bnxt fix (patch #4).
- sfc fix (patch #6).
- Missing include (patch #13).

Adrien Mazarguil (11):
  net/mlx4: fix RSS resource leak in case of error
  net/mlx4: fix ignored RSS hash types
  net/mlx5: fix RSS flow action bounds check
  net/bnxt: fix matching of flow API item masks
  app/testpmd: fix flow completion for RSS queues
  app/testpmd: fix lack of flow action configuration
  app/testpmd: fix RSS flow action configuration
  app/testpmd: fix missing RSS fields in flow action
  ethdev: fix shallow copy of flow API RSS action
  ethdev: fix missing boolean values in flow command
  ethdev: fix missing include in flow API

 app/test-pmd/cmdline.c                      |   2 +
 app/test-pmd/cmdline_flow.c                 | 252 ++++++++++++++++++++---
 app/test-pmd/config.c                       | 160 +++++++++-----
 app/test-pmd/testpmd.h                      |  13 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bnxt/bnxt_filter.c              |  14 +-
 drivers/net/mlx4/mlx4_flow.c                |  17 +-
 drivers/net/mlx5/mlx5_flow.c                |   9 +
 lib/librte_ether/rte_flow.c                 | 145 +++++++++----
 lib/librte_ether/rte_flow.h                 |   2 +
 10 files changed, 494 insertions(+), 128 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-17  9:19           ` Nélio Laranjeiro
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
                           ` (11 subsequent siblings)
  12 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When memory cannot be allocated for a flow rule, its RSS context reference
is not dropped.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index f3063ee8a..2b4bf7094 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
 			},
 		};
 
-		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
+		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
+			if (temp.rss)
+				mlx4_rss_put(temp.rss);
 			return rte_flow_error_set
 				(error, -rte_errno,
 				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				 "flow rule handle allocation failure");
+		}
 		/* Most fields will be updated by second pass. */
 		*flow = (struct rte_flow){
 			.ibv_attr = temp.ibv_attr,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 02/11] net/mlx4: fix ignored RSS hash types
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-17  9:20           ` Nélio Laranjeiro
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
                           ` (10 subsequent siblings)
  12 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When an unsupported hash type is part of a RSS configuration structure, it
is silently ignored instead of triggering an error. This may lead
applications to assume that such types are accepted, while they are in fact
not part of the resulting flow rules.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 2b4bf7094..67fd568bc 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
 			const struct rte_flow_action_queue *queue;
 			const struct rte_flow_action_rss *rss;
 			const struct rte_eth_rss_conf *rss_conf;
+			uint64_t fields;
 			unsigned int i;
 
 		case RTE_FLOW_ACTION_TYPE_VOID:
@@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
 					" of the context size";
 				goto exit_action_not_supported;
 			}
+			rte_errno = 0;
+			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
+			if (fields == (uint64_t)-1 && rte_errno) {
+				msg = "unsupported RSS hash type requested";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
-				(priv,
-				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
-				 rss_conf->rss_key, rss->num, rss->queue);
+				(priv, fields, rss_conf->rss_key, rss->num,
+				 rss->queue);
 			if (!flow->rss) {
 				msg = "either invalid parameters or not enough"
 					" resources for additional multi-queue"
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 03/11] net/mlx5: fix RSS flow action bounds check
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
                           ` (9 subsequent siblings)
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Nelio Laranjeiro

The number of queues provided by the application is not checked against
parser's supported maximum.

Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
Cc: stable@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 7ef68de49..1ca413e32 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -16,6 +16,7 @@
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include <rte_common.h>
 #include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
+			if (rss->num > RTE_DIM(parser->queues)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "too many queues for RSS"
+						   " context");
+				return -rte_errno;
+			}
 			for (n = 0; n < rss->num; ++n) {
 				if (rss->queue[n] >= priv->rxqs_n) {
 					rte_flow_error_set(error, EINVAL,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 04/11] net/bnxt: fix matching of flow API item masks
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (2 preceding siblings ...)
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
                           ` (8 subsequent siblings)
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Ajit Khaparde

Some values are interpreted without endian conversion and/or without
taking the proper mask into account.

Fixes: 5ef3b79fdfe6 ("net/bnxt: support flow filter ops")
Cc: stable@dpdk.org
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/bnxt/bnxt_filter.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 96b382ba8..0f9c1c9ae 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -5,6 +5,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
@@ -346,7 +347,8 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			/* Mask is not allowed. Only exact matches are */
-			if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
+			if (eth_mask->type &&
+			    eth_mask->type != RTE_BE16(0xffff)) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
@@ -372,7 +374,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			   *  RTE_LOG(ERR, PMD, "Handle this condition\n");
 			   * }
 			   */
-			if (eth_spec->type) {
+			if (eth_mask->type) {
 				filter->ethertype =
 					rte_be_to_cpu_16(eth_spec->type);
 				en |= use_ntuple ?
@@ -384,13 +386,15 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			vlan_spec = item->spec;
 			vlan_mask = item->mask;
-			if (vlan_mask->tci & 0xFFFF && !vlan_mask->tpid) {
+			if (vlan_mask->tci &&
+			    vlan_mask->tci == RTE_BE16(0x0fff) &&
+			    !vlan_mask->tpid) {
 				/* Only the VLAN ID can be matched. */
 				filter->l2_ovlan =
 					rte_be_to_cpu_16(vlan_spec->tci &
-							 0xFFF);
+							 RTE_BE16(0x0fff));
 				en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID;
-			} else {
+			} else if (vlan_mask->tci || vlan_mask->tpid) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 05/11] app/testpmd: fix flow completion for RSS queues
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (3 preceding siblings ...)
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
                           ` (7 subsequent siblings)
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

The lack of a working completion for RSS queues was overlooked during
development; until now only "end" was displayed as a valid token.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 59f3b3b57..4640f18f7 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2663,17 +2663,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			 unsigned int ent, char *buf, unsigned int size)
 {
-	static const char *const str[] = { "", "end", NULL };
-	unsigned int i;
-
 	(void)ctx;
 	(void)token;
-	for (i = 0; str[i] != NULL; ++i)
-		if (buf && i == ent)
-			return snprintf(buf, size, "%s", str[i]);
-	if (buf)
-		return -1;
-	return i;
+	if (!buf)
+		return nb_rxq + 1;
+	if (ent < nb_rxq)
+		return snprintf(buf, size, "%u", ent);
+	if (ent == nb_rxq)
+		return snprintf(buf, size, "end");
+	return -1;
 }
 
 /** Internal context. */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 06/11] app/testpmd: fix lack of flow action configuration
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (4 preceding siblings ...)
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 07/11] app/testpmd: fix RSS " Adrien Mazarguil
                           ` (6 subsequent siblings)
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Configuration structure is not optional with flow rule actions that expect
one; this pointer is not supposed to be NULL and PMDs should not have to
verify it.

Like pattern item spec/last/mask fields, it is currently set when at least
one configuration parameter is provided on the command line. This patch
sets it as soon as an action is created instead.

Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 4640f18f7..a0e06db36 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
 			return -1;
 		*action = (struct rte_flow_action){
 			.type = priv->type,
+			.conf = data_size ? data : NULL,
 		};
 		++out->args.vc.actions_n;
 		ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	      void *buf, unsigned int size)
 {
 	struct buffer *out = buf;
-	struct rte_flow_action *action;
 
 	(void)size;
 	/* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
-	if (!out->args.vc.actions_n)
-		return -1;
-	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
 	/* Point to selected object. */
 	ctx->object = out->args.vc.data;
 	ctx->objmask = NULL;
-	/* Update configuration pointer. */
-	action->conf = ctx->object;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 07/11] app/testpmd: fix RSS flow action configuration
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (5 preceding siblings ...)
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-04-16 16:21         ` Adrien Mazarguil
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
                           ` (5 subsequent siblings)
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:21 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu, Xueming Li

Except for a list of queues, RSS configuration (hash key and fields) cannot
be specified from the flow command line and testpmd does not provide safe
defaults either.

In order to validate their implementation with testpmd, PMDs had to
interpret its NULL RSS configuration parameters somehow, however this has
never been valid to begin with.

This patch makes testpmd always provide default values.

The list of RSS types to use is exclusively taken from the global "rss_hf"
variable, itself configured through the "port config all rss" command or
--rss-ip/--rss-udp command-line options.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>

---

v4 changes:

Removed reliance on rte_eth_dev_rss_hash_conf_get(), which as reported by
Xueming, is not necessarily supported and triggers a misleading "Function
not implemented" warning. Updated commit log to reflect this.
---
 app/test-pmd/cmdline.c      |   2 +
 app/test-pmd/cmdline_flow.c | 101 ++++++++++++++++++++++++----
 app/test-pmd/config.c       | 140 +++++++++++++++++++++++++++------------
 3 files changed, 190 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 512e3b55e..9704d0454 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2033,6 +2033,8 @@ cmd_config_rss_parsed(void *parsed_result,
 		return;
 	}
 	rss_conf.rss_key = NULL;
+	/* Update global configuration for RSS types. */
+	rss_hf = rss_conf.rss_hf;
 	for (i = 0; i < rte_eth_dev_count(); i++) {
 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
 		if (diag < 0)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a0e06db36..d37c5f39f 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */
-#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */
-#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
 #define CTX_STACK_SIZE 16
@@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
 static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,61 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		struct rte_eth_dev_info info;
+
+		rte_eth_dev_info_get(ctx->port, &info);
+		action_rss_data->s.rss_conf.rss_key_len =
+			RTE_MIN(sizeof(action_rss_data->s.rss_key),
+				info.hash_key_size);
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2086,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2100,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2121,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dd051f5ca..97a959b2a 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -998,31 +998,51 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
 };
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1052,31 +1072,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */
@@ -1089,7 +1150,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1107,24 +1167,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -1141,12 +1200,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 08/11] app/testpmd: fix missing RSS fields in flow action
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (6 preceding siblings ...)
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 07/11] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-04-16 16:22         ` Adrien Mazarguil
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
                           ` (4 subsequent siblings)
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Users cannot override the default RSS settings when entering a RSS action,
only a list of queues can be provided.

This patch enables them to set a RSS hash key and types for a flow rule.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 133 ++++++++++++++++++++++-
 app/test-pmd/config.c                       |  20 ++--
 app/test-pmd/testpmd.h                      |  13 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 ++
 4 files changed, 163 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index d37c5f39f..fcd76b56e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -167,6 +167,10 @@ enum index {
 	ACTION_DUP,
 	ACTION_DUP_INDEX,
 	ACTION_RSS,
+	ACTION_RSS_TYPES,
+	ACTION_RSS_TYPE,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_RSS_QUEUE,
 	ACTION_PF,
@@ -223,6 +227,9 @@ struct context {
 struct arg {
 	uint32_t hton:1; /**< Use network byte ordering. */
 	uint32_t sign:1; /**< Value is signed. */
+	uint32_t bounded:1; /**< Value is bounded. */
+	uintmax_t min; /**< Minimum value if bounded. */
+	uintmax_t max; /**< Maximum value if bounded. */
 	uint32_t offset; /**< Relative offset from ctx->object. */
 	uint32_t size; /**< Field size. */
 	const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
@@ -329,6 +336,16 @@ struct token {
 		.size = (s), \
 	})
 
+/** Same as ARGS_ENTRY_ARB() with bounded values. */
+#define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
+	(&(const struct arg){ \
+		.bounded = 1, \
+		.min = (i), \
+		.max = (a), \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -635,6 +652,9 @@ static const enum index action_dup[] = {
 };
 
 static const enum index action_rss[] = {
+	ACTION_RSS_TYPES,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_NEXT,
 	ZERO,
@@ -666,6 +686,9 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
+static int parse_vc_action_rss_type(struct context *, const struct token *,
+				    const char *, unsigned int, void *,
+				    unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -721,6 +744,8 @@ static int comp_port(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_rule_id(struct context *, const struct token *,
 			unsigned int, char *, unsigned int);
+static int comp_vc_action_rss_type(struct context *, const struct token *,
+				   unsigned int, char *, unsigned int);
 static int comp_vc_action_rss_queue(struct context *, const struct token *,
 				    unsigned int, char *, unsigned int);
 
@@ -1593,6 +1618,43 @@ static const struct token token_list[] = {
 		.next = NEXT(action_rss),
 		.call = parse_vc_action_rss,
 	},
+	[ACTION_RSS_TYPES] = {
+		.name = "types",
+		.help = "RSS hash types",
+		.next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
+	},
+	[ACTION_RSS_TYPE] = {
+		.name = "{type}",
+		.help = "RSS hash type",
+		.call = parse_vc_action_rss_type,
+		.comp = comp_vc_action_rss_type,
+	},
+	[ACTION_RSS_KEY] = {
+		.name = "key",
+		.help = "RSS hash key",
+		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len)),
+			     ARGS_ENTRY_ARB
+			     (((uintptr_t)((union action_rss_data *)0)->
+			       s.rss_key),
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_KEY_LEN] = {
+		.name = "key_len",
+		.help = "RSS hash key length in bytes",
+		.next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB_BOUNDED
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len),
+			      0,
+			      RSS_HASH_KEY_LENGTH)),
+	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
 		.help = "queue indices to use",
@@ -2076,6 +2138,50 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
 }
 
 /**
+ * Parse type field for RSS action.
+ *
+ * Valid tokens are type field names and the "end" token.
+ */
+static int
+parse_vc_action_rss_type(struct context *ctx, const struct token *token,
+			  const char *str, unsigned int len,
+			  void *buf, unsigned int size)
+{
+	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+
+	(void)token;
+	(void)buf;
+	(void)size;
+	if (ctx->curr != ACTION_RSS_TYPE)
+		return -1;
+	if (!(ctx->objdata >> 16) && ctx->object) {
+		action_rss_data = ctx->object;
+		action_rss_data->s.rss_conf.rss_hf = 0;
+	}
+	if (!strcmp_partial("end", str, len)) {
+		ctx->objdata &= 0xffff;
+		return len;
+	}
+	for (i = 0; rss_type_table[i].str; ++i)
+		if (!strcmp_partial(rss_type_table[i].str, str, len))
+			break;
+	if (!rss_type_table[i].str)
+		return -1;
+	ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
+	/* Repeat token. */
+	if (ctx->next_num == RTE_DIM(ctx->next))
+		return -1;
+	ctx->next[ctx->next_num++] = next;
+	if (!ctx->object)
+		return len;
+	action_rss_data = ctx->object;
+	action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type;
+	return len;
+}
+
+/**
  * Parse queue field for RSS action.
  *
  * Valid tokens are queue indices and the "end" token.
@@ -2341,6 +2447,11 @@ parse_int(struct context *ctx, const struct token *token,
 		strtoumax(str, &end, 0);
 	if (errno || (size_t)(end - str) != len)
 		goto error;
+	if (arg->bounded &&
+	    ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
+			    (intmax_t)u > (intmax_t)arg->max)) ||
+	     (!arg->sign && (u < arg->min || u > arg->max))))
+		goto error;
 	if (!ctx->object)
 		return len;
 	if (arg->mask) {
@@ -2434,7 +2545,7 @@ parse_string(struct context *ctx, const struct token *token,
 	buf = (uint8_t *)ctx->object + arg_data->offset;
 	/* Output buffer is not necessarily NUL-terminated. */
 	memcpy(buf, str, len);
-	memset((uint8_t *)buf + len, 0x55, size - len);
+	memset((uint8_t *)buf + len, 0x00, size - len);
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
 	return len;
@@ -2730,6 +2841,26 @@ comp_rule_id(struct context *ctx, const struct token *token,
 	return i;
 }
 
+/** Complete type field for RSS action. */
+static int
+comp_vc_action_rss_type(struct context *ctx, const struct token *token,
+			unsigned int ent, char *buf, unsigned int size)
+{
+	unsigned int i;
+
+	(void)ctx;
+	(void)token;
+	for (i = 0; rss_type_table[i].str; ++i)
+		;
+	if (!buf)
+		return i + 1;
+	if (ent < i)
+		return snprintf(buf, size, "%s", rss_type_table[ent].str);
+	if (ent == i)
+		return snprintf(buf, size, "end");
+	return -1;
+}
+
 /** Complete queue field for RSS action. */
 static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 97a959b2a..5daa93bb3 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -73,12 +73,7 @@ static const struct {
 	},
 };
 
-struct rss_type_info {
-	char str[32];
-	uint64_t rss_type;
-};
-
-static const struct rss_type_info rss_type_table[] = {
+const struct rss_type_info rss_type_table[] = {
 	{ "ipv4", ETH_RSS_IPV4 },
 	{ "ipv4-frag", ETH_RSS_FRAG_IPV4 },
 	{ "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
@@ -99,7 +94,12 @@ static const struct rss_type_info rss_type_table[] = {
 	{ "vxlan", ETH_RSS_VXLAN },
 	{ "geneve", ETH_RSS_GENEVE },
 	{ "nvgre", ETH_RSS_NVGRE },
-
+	{ "ip", ETH_RSS_IP },
+	{ "udp", ETH_RSS_UDP },
+	{ "tcp", ETH_RSS_TCP },
+	{ "sctp", ETH_RSS_SCTP },
+	{ "tunnel", ETH_RSS_TUNNEL },
+	{ NULL, 0 },
 };
 
 static void
@@ -1835,7 +1835,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 	}
 
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_info, rss_type_table[i].str))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
@@ -1864,7 +1864,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 		return;
 	}
 	printf("RSS functions:\n ");
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (rss_hf & rss_type_table[i].rss_type)
 			printf("%s ", rss_type_table[i].str);
 	}
@@ -1888,7 +1888,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = hash_key_len;
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_type_table[i].str, rss_type))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 98d84da84..070919822 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -79,6 +79,19 @@ struct pkt_burst_stats {
 };
 #endif
 
+/** Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /**< Type name. */
+	uint64_t rss_type; /**< Type value. */
+};
+
+/**
+ * RSS type information table.
+ *
+ * An entry with a NULL type name terminates the list.
+ */
+extern const struct rss_type_info rss_type_table[];
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a766ac795..cb6f201e1 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3406,6 +3406,14 @@ This section lists supported actions and their attributes, if any.
 
 - ``rss``: spread packets among several queues.
 
+  - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens
+    are the same as `set_hash_input_set`_, an empty list means none (0).
+
+  - ``key {string}``: RSS hash key, overrides ``key_len``.
+
+  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
+    conjunction with ``key`` to pad or truncate it.
+
   - ``queues [{unsigned} [...]] end``: queue indices to use.
 
 - ``pf``: redirect packets to physical device function.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 09/11] ethdev: fix shallow copy of flow API RSS action
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (7 preceding siblings ...)
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-04-16 16:22         ` Adrien Mazarguil
  2018-04-17  9:18           ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
                           ` (3 subsequent siblings)
  12 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw)
  To: dev; +Cc: stable, Gaetan Rivet, Thomas Monjalon

The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.

Even assuming it is permanently allocated and a pointer copy is safe,
pointed data may change and not reflect an applied flow rule anymore.

This patch aligns with testpmd by making a deep copy instead.

Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
Cc: stable@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 43 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index a3823d874..ada280810 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,
 	return -code;
 }
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
-	/* Not a fall-through */
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = rte_flow_desc_item[item->type].size;
+		size = rte_flow_desc_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
-	/* Not a fall-through. */
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = rte_flow_desc_action[action->type].size;
+		size = rte_flow_desc_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Store a full rte_flow description. */
@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 {
 	struct rte_flow_desc *fd = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	size_t size = 0;
@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, item,
 					     sizeof(*item));
 			off1 += sizeof(*item);
-			flow_item_spec_size(item, &tmp, &pad);
 			if (item->spec) {
 				if (fd)
-					dst->spec = memcpy(fd->data + off2,
-							   item->spec, tmp);
-				off2 += tmp + pad;
+					dst->spec = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_SPEC);
 			}
 			if (item->last) {
 				if (fd)
-					dst->last = memcpy(fd->data + off2,
-							   item->last, tmp);
-				off2 += tmp + pad;
+					dst->last = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_LAST);
 			}
 			if (item->mask) {
 				if (fd)
-					dst->mask = memcpy(fd->data + off2,
-							   item->mask, tmp);
-				off2 += tmp + pad;
+					dst->mask = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_MASK);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, action,
 					     sizeof(*action));
 			off1 += sizeof(*action);
-			flow_action_conf_size(action, &tmp, &pad);
 			if (action->conf) {
 				if (fd)
-					dst->conf = memcpy(fd->data + off2,
-							   action->conf, tmp);
-				off2 += tmp + pad;
+					dst->conf = fd->data + off2;
+				off2 += flow_action_conf_copy
+					(fd ? fd->data + off2 : NULL, action);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (8 preceding siblings ...)
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-04-16 16:22         ` Adrien Mazarguil
  2018-04-16 19:17           ` Matan Azrad
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
                           ` (2 subsequent siblings)
  12 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw)
  To: dev; +Cc: stable

Original implementation lacks the on/off toggle.

This patch shows up as a fix because it has been a popular request ever
since the first DPDK release with the original implementation but was never
addressed.

Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fcd76b56e..f0b4b7bc4 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2692,6 +2692,7 @@ static const char *const boolean_name[] = {
 	"false", "true",
 	"no", "yes",
 	"N", "Y",
+	"off", "on",
 	NULL,
 };
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v5 11/11] ethdev: fix missing include in flow API
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (9 preceding siblings ...)
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-16 16:22         ` Adrien Mazarguil
  2018-04-17  9:17         ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Ferruh Yigit
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
  12 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-16 16:22 UTC (permalink / raw)
  To: dev; +Cc: stable

Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 lib/librte_ether/rte_flow.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index 56c733451..44ae19d3b 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -14,6 +14,8 @@
  * associated actions in hardware through flow rules.
  */
 
+#include <stdint.h>
+
 #include <rte_arp.h>
 #include <rte_ether.h>
 #include <rte_icmp.h>
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-16 19:17           ` Matan Azrad
  2018-04-17  8:25             ` Adrien Mazarguil
  0 siblings, 1 reply; 93+ messages in thread
From: Matan Azrad @ 2018-04-16 19:17 UTC (permalink / raw)
  To: Adrien Mazarguil, dev; +Cc: stable

Hi Adrien

I think the title should be "app/testpmd: ..." ...

From: Adrien Mazarguil, Monday, April 16, 2018 7:22 PM
> Original implementation lacks the on/off toggle.
> 
> This patch shows up as a fix because it has been a popular request ever since
> the first DPDK release with the original implementation but was never
> addressed.
> 
> Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> ---
>  app/test-pmd/cmdline_flow.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index fcd76b56e..f0b4b7bc4 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -2692,6 +2692,7 @@ static const char *const boolean_name[] = {
>  	"false", "true",
>  	"no", "yes",
>  	"N", "Y",
> +	"off", "on",
>  	NULL,
>  };
> 
> --
> 2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command
  2018-04-16 19:17           ` Matan Azrad
@ 2018-04-17  8:25             ` Adrien Mazarguil
  2018-04-18 17:16               ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
  0 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-17  8:25 UTC (permalink / raw)
  To: Matan Azrad; +Cc: dev, stable

On Mon, Apr 16, 2018 at 07:17:44PM +0000, Matan Azrad wrote:
> Hi Adrien
> 
> I think the title should be "app/testpmd: ..." ...

Indeed, I'll update it in the next iteration, thanks.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (10 preceding siblings ...)
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
@ 2018-04-17  9:17         ` Ferruh Yigit
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
  12 siblings, 0 replies; 93+ messages in thread
From: Ferruh Yigit @ 2018-04-17  9:17 UTC (permalink / raw)
  To: Adrien Mazarguil, dev

On 4/16/2018 5:21 PM, Adrien Mazarguil wrote:
> This series contains several fixes for rte_flow and its implementation in
> PMDs and testpmd. Upcoming work on the flow API depends on it.
> 
> v5 changes:
> 
> - No change, rebased series to address conflicts.
> 
> v4 changes:
> 
> - Rebased again.
> - The reliance on rte_eth_dev_rss_hash_conf_get() was removed from patch #7,
>   see updated patch for details.
> 
> v3 changes:
> 
> - Rebased series.
> - Dropped unnecessary "net/sfc: fix endian conversions in flow API".
> - Dropped "ethdev: fix ABI version in meson build", handled by prior commit
>   d9736a248785 ("ethdev: fix library version in meson build").
> 
> v2 changes:
> 
> - mlx5 fix (patch #3).
> - bnxt fix (patch #4).
> - sfc fix (patch #6).
> - Missing include (patch #13).
> 
> Adrien Mazarguil (11):
>   net/mlx4: fix RSS resource leak in case of error
>   net/mlx4: fix ignored RSS hash types
>   net/mlx5: fix RSS flow action bounds check
>   net/bnxt: fix matching of flow API item masks
>   app/testpmd: fix flow completion for RSS queues
>   app/testpmd: fix lack of flow action configuration
>   app/testpmd: fix RSS flow action configuration
>   app/testpmd: fix missing RSS fields in flow action
>   ethdev: fix shallow copy of flow API RSS action
>   ethdev: fix missing boolean values in flow command
>   ethdev: fix missing include in flow API

Is there any more comments / objections to this patchset?
If there is no objection it will be merged soon.

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v5 09/11] ethdev: fix shallow copy of flow API RSS action
  2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-04-17  9:18           ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-17  9:18 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable, Gaetan Rivet, Thomas Monjalon

On Mon, Apr 16, 2018 at 06:22:03PM +0200, Adrien Mazarguil wrote:
> The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.
> 
> Even assuming it is permanently allocated and a pointer copy is safe,
> pointed data may change and not reflect an applied flow rule anymore.
> 
> This patch aligns with testpmd by making a deep copy instead.
> 
> Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
> Cc: stable@dpdk.org
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-04-17  9:19           ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-17  9:19 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable, Shahaf Shuler

On Mon, Apr 16, 2018 at 06:21:48PM +0200, Adrien Mazarguil wrote:
> When memory cannot be allocated for a flow rule, its RSS context reference
> is not dropped.
> 
> Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  drivers/net/mlx4/mlx4_flow.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
> index f3063ee8a..2b4bf7094 100644
> --- a/drivers/net/mlx4/mlx4_flow.c
> +++ b/drivers/net/mlx4/mlx4_flow.c
> @@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
>  			},
>  		};
>  
> -		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
> +		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
> +			if (temp.rss)
> +				mlx4_rss_put(temp.rss);
>  			return rte_flow_error_set
>  				(error, -rte_errno,
>  				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
>  				 "flow rule handle allocation failure");
> +		}
>  		/* Most fields will be updated by second pass. */
>  		*flow = (struct rte_flow){
>  			.ibv_attr = temp.ibv_attr,
> -- 
> 2.11.0

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v5 02/11] net/mlx4: fix ignored RSS hash types
  2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-04-17  9:20           ` Nélio Laranjeiro
  0 siblings, 0 replies; 93+ messages in thread
From: Nélio Laranjeiro @ 2018-04-17  9:20 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, stable, Shahaf Shuler

On Mon, Apr 16, 2018 at 06:21:50PM +0200, Adrien Mazarguil wrote:
> When an unsupported hash type is part of a RSS configuration structure, it
> is silently ignored instead of triggering an error. This may lead
> applications to assume that such types are accepted, while they are in fact
> not part of the resulting flow rules.
> 
> Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> ---
>  drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
> index 2b4bf7094..67fd568bc 100644
> --- a/drivers/net/mlx4/mlx4_flow.c
> +++ b/drivers/net/mlx4/mlx4_flow.c
> @@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
>  			const struct rte_flow_action_queue *queue;
>  			const struct rte_flow_action_rss *rss;
>  			const struct rte_eth_rss_conf *rss_conf;
> +			uint64_t fields;
>  			unsigned int i;
>  
>  		case RTE_FLOW_ACTION_TYPE_VOID:
> @@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
>  					" of the context size";
>  				goto exit_action_not_supported;
>  			}
> +			rte_errno = 0;
> +			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
> +			if (fields == (uint64_t)-1 && rte_errno) {
> +				msg = "unsupported RSS hash type requested";
> +				goto exit_action_not_supported;
> +			}
>  			flow->rss = mlx4_rss_get
> -				(priv,
> -				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
> -				 rss_conf->rss_key, rss->num, rss->queue);
> +				(priv, fields, rss_conf->rss_key, rss->num,
> +				 rss->queue);
>  			if (!flow->rss) {
>  				msg = "either invalid parameters or not enough"
>  					" resources for additional multi-queue"
> -- 
> 2.11.0

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command
  2018-04-17  8:25             ` Adrien Mazarguil
@ 2018-04-18 17:16               ` Ferruh Yigit
  2018-04-19 10:18                 ` Adrien Mazarguil
  0 siblings, 1 reply; 93+ messages in thread
From: Ferruh Yigit @ 2018-04-18 17:16 UTC (permalink / raw)
  To: Adrien Mazarguil, Matan Azrad; +Cc: dev, stable

On 4/17/2018 9:25 AM, Adrien Mazarguil wrote:
> On Mon, Apr 16, 2018 at 07:17:44PM +0000, Matan Azrad wrote:
>> Hi Adrien
>>
>> I think the title should be "app/testpmd: ..." ...
> 
> Indeed, I'll update it in the next iteration, thanks.

If this is the only issue, it can be fixed while applying.
Are there more outstanding issues, will there be a new version of the set?

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes
  2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
                           ` (11 preceding siblings ...)
  2018-04-17  9:17         ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Ferruh Yigit
@ 2018-04-19 10:07         ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
                             ` (11 more replies)
  12 siblings, 12 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev

This series contains several fixes for rte_flow and its implementation in
PMDs and testpmd. Upcoming work on the flow API depends on it.

v6 changes:

- No change, rebased series and updated/fixed commit messages.

v5 changes:

- No change, rebased series to address conflicts.

v4 changes:

- Rebased again.
- The reliance on rte_eth_dev_rss_hash_conf_get() was removed from patch #7,
  see updated patch for details.

v3 changes:

- Rebased series.
- Dropped unnecessary "net/sfc: fix endian conversions in flow API".
- Dropped "ethdev: fix ABI version in meson build", handled by prior commit
  d9736a248785 ("ethdev: fix library version in meson build").

v2 changes:

- mlx5 fix (patch #3).
- bnxt fix (patch #4).
- sfc fix (patch #6).
- Missing include (patch #13).

Adrien Mazarguil (11):
  net/mlx4: fix RSS resource leak in case of error
  net/mlx4: fix ignored RSS hash types
  net/mlx5: fix RSS flow action bounds check
  net/bnxt: fix matching of flow API item masks
  app/testpmd: fix flow completion for RSS queues
  app/testpmd: fix lack of flow action configuration
  app/testpmd: fix RSS flow action configuration
  app/testpmd: fix missing RSS fields in flow action
  app/testpmd: fix missing boolean values in flow command
  ethdev: fix shallow copy of flow API RSS action
  ethdev: fix missing include in flow API

 app/test-pmd/cmdline.c                      |   2 +
 app/test-pmd/cmdline_flow.c                 | 252 ++++++++++++++++++++---
 app/test-pmd/config.c                       | 160 +++++++++-----
 app/test-pmd/testpmd.h                      |  13 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bnxt/bnxt_filter.c              |  14 +-
 drivers/net/mlx4/mlx4_flow.c                |  17 +-
 drivers/net/mlx5/mlx5_flow.c                |   9 +
 lib/librte_ether/rte_flow.c                 | 145 +++++++++----
 lib/librte_ether/rte_flow.h                 |   2 +
 10 files changed, 494 insertions(+), 128 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 01/11] net/mlx4: fix RSS resource leak in case of error
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
                             ` (10 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When memory cannot be allocated for a flow rule, its RSS context reference
is not dropped.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index f3063ee8a..2b4bf7094 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -820,11 +820,14 @@ mlx4_flow_prepare(struct priv *priv,
 			},
 		};
 
-		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec)))
+		if (!mlx4_zmallocv(__func__, vec, RTE_DIM(vec))) {
+			if (temp.rss)
+				mlx4_rss_put(temp.rss);
 			return rte_flow_error_set
 				(error, -rte_errno,
 				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 				 "flow rule handle allocation failure");
+		}
 		/* Most fields will be updated by second pass. */
 		*flow = (struct rte_flow){
 			.ibv_attr = temp.ibv_attr,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 02/11] net/mlx4: fix ignored RSS hash types
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
                             ` (9 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Shahaf Shuler

When an unsupported hash type is part of a RSS configuration structure, it
is silently ignored instead of triggering an error. This may lead
applications to assume that such types are accepted, while they are in fact
not part of the resulting flow rules.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 2b4bf7094..67fd568bc 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -706,6 +706,7 @@ mlx4_flow_prepare(struct priv *priv,
 			const struct rte_flow_action_queue *queue;
 			const struct rte_flow_action_rss *rss;
 			const struct rte_eth_rss_conf *rss_conf;
+			uint64_t fields;
 			unsigned int i;
 
 		case RTE_FLOW_ACTION_TYPE_VOID:
@@ -780,10 +781,15 @@ mlx4_flow_prepare(struct priv *priv,
 					" of the context size";
 				goto exit_action_not_supported;
 			}
+			rte_errno = 0;
+			fields = mlx4_conv_rss_hf(priv, rss_conf->rss_hf);
+			if (fields == (uint64_t)-1 && rte_errno) {
+				msg = "unsupported RSS hash type requested";
+				goto exit_action_not_supported;
+			}
 			flow->rss = mlx4_rss_get
-				(priv,
-				 mlx4_conv_rss_hf(priv, rss_conf->rss_hf),
-				 rss_conf->rss_key, rss->num, rss->queue);
+				(priv, fields, rss_conf->rss_key, rss->num,
+				 rss->queue);
 			if (!flow->rss) {
 				msg = "either invalid parameters or not enough"
 					" resources for additional multi-queue"
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 03/11] net/mlx5: fix RSS flow action bounds check
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
                             ` (8 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Nelio Laranjeiro

The number of queues provided by the application is not checked against
parser's supported maximum.

Fixes: 3d821d6fea40 ("net/mlx5: support RSS action flow rule")
Cc: stable@dpdk.org
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 7ef68de49..1ca413e32 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -16,6 +16,7 @@
 #pragma GCC diagnostic error "-Wpedantic"
 #endif
 
+#include <rte_common.h>
 #include <rte_ethdev_driver.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -713,6 +714,14 @@ mlx5_flow_convert_actions(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
+			if (rss->num > RTE_DIM(parser->queues)) {
+				rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "too many queues for RSS"
+						   " context");
+				return -rte_errno;
+			}
 			for (n = 0; n < rss->num; ++n) {
 				if (rss->queue[n] >= priv->rxqs_n) {
 					rte_flow_error_set(error, EINVAL,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 04/11] net/bnxt: fix matching of flow API item masks
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (2 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
                             ` (7 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Ajit Khaparde

Some values are interpreted without endian conversion and/or without
taking the proper mask into account.

Fixes: 5ef3b79fdfe6 ("net/bnxt: support flow filter ops")
Cc: stable@dpdk.org
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/bnxt/bnxt_filter.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 9351460c2..fdd94bf02 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -5,6 +5,7 @@
 
 #include <sys/queue.h>
 
+#include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
@@ -354,7 +355,8 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			/* Mask is not allowed. Only exact matches are */
-			if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
+			if (eth_mask->type &&
+			    eth_mask->type != RTE_BE16(0xffff)) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
@@ -380,7 +382,7 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			   *  RTE_LOG(ERR, PMD, "Handle this condition\n");
 			   * }
 			   */
-			if (eth_spec->type) {
+			if (eth_mask->type) {
 				filter->ethertype =
 					rte_be_to_cpu_16(eth_spec->type);
 				en |= use_ntuple ?
@@ -392,13 +394,15 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 		case RTE_FLOW_ITEM_TYPE_VLAN:
 			vlan_spec = item->spec;
 			vlan_mask = item->mask;
-			if (vlan_mask->tci & 0xFFFF && !vlan_mask->tpid) {
+			if (vlan_mask->tci &&
+			    vlan_mask->tci == RTE_BE16(0x0fff) &&
+			    !vlan_mask->tpid) {
 				/* Only the VLAN ID can be matched. */
 				filter->l2_ovlan =
 					rte_be_to_cpu_16(vlan_spec->tci &
-							 0xFFF);
+							 RTE_BE16(0x0fff));
 				en |= EM_FLOW_ALLOC_INPUT_EN_OVLAN_VID;
-			} else {
+			} else if (vlan_mask->tci || vlan_mask->tpid) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 05/11] app/testpmd: fix flow completion for RSS queues
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (3 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
                             ` (6 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

The lack of a working completion for RSS queues was overlooked during
development; until now only "end" was displayed as a valid token.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 59f3b3b57..4640f18f7 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2663,17 +2663,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			 unsigned int ent, char *buf, unsigned int size)
 {
-	static const char *const str[] = { "", "end", NULL };
-	unsigned int i;
-
 	(void)ctx;
 	(void)token;
-	for (i = 0; str[i] != NULL; ++i)
-		if (buf && i == ent)
-			return snprintf(buf, size, "%s", str[i]);
-	if (buf)
-		return -1;
-	return i;
+	if (!buf)
+		return nb_rxq + 1;
+	if (ent < nb_rxq)
+		return snprintf(buf, size, "%u", ent);
+	if (ent == nb_rxq)
+		return snprintf(buf, size, "end");
+	return -1;
 }
 
 /** Internal context. */
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 06/11] app/testpmd: fix lack of flow action configuration
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (4 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS " Adrien Mazarguil
                             ` (5 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Configuration structure is not optional with flow rule actions that expect
one; this pointer is not supposed to be NULL and PMDs should not have to
verify it.

Like pattern item spec/last/mask fields, it is currently set when at least
one configuration parameter is provided on the command line. This patch
sets it as soon as an action is created instead.

Fixes: 7a91969ad35e ("app/testpmd: add various actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 4640f18f7..a0e06db36 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
 			return -1;
 		*action = (struct rte_flow_action){
 			.type = priv->type,
+			.conf = data_size ? data : NULL,
 		};
 		++out->args.vc.actions_n;
 		ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	      void *buf, unsigned int size)
 {
 	struct buffer *out = buf;
-	struct rte_flow_action *action;
 
 	(void)size;
 	/* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
-	if (!out->args.vc.actions_n)
-		return -1;
-	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
 	/* Point to selected object. */
 	ctx->object = out->args.vc.data;
 	ctx->objmask = NULL;
-	/* Update configuration pointer. */
-	action->conf = ctx->object;
 	return len;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS flow action configuration
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (5 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-05-07  5:23             ` Peng, Yuan
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
                             ` (4 subsequent siblings)
  11 siblings, 1 reply; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu, Xueming Li

Except for a list of queues, RSS configuration (hash key and fields) cannot
be specified from the flow command line and testpmd does not provide safe
defaults either.

In order to validate their implementation with testpmd, PMDs had to
interpret its NULL RSS configuration parameters somehow, however this has
never been valid to begin with.

This patch makes testpmd always provide default values.

The list of RSS types to use is exclusively taken from the global "rss_hf"
variable, itself configured through the "port config all rss" command or
--rss-ip/--rss-udp command-line options.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>

---

v4 changes:

Removed reliance on rte_eth_dev_rss_hash_conf_get(), which as reported by
Xueming, is not necessarily supported and triggers a misleading "Function
not implemented" warning. Updated commit log to reflect this.
---
 app/test-pmd/cmdline.c      |   2 +
 app/test-pmd/cmdline_flow.c | 101 ++++++++++++++++++++++++----
 app/test-pmd/config.c       | 140 +++++++++++++++++++++++++++------------
 3 files changed, 190 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 512e3b55e..9704d0454 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2033,6 +2033,8 @@ cmd_config_rss_parsed(void *parsed_result,
 		return;
 	}
 	rss_conf.rss_key = NULL;
+	/* Update global configuration for RSS types. */
+	rss_hf = rss_conf.rss_hf;
 	for (i = 0; i < rte_eth_dev_count(); i++) {
 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
 		if (diag < 0)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a0e06db36..d37c5f39f 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */
-#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */
-#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */
 #define CTX_STACK_SIZE 16
@@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
 static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,61 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		struct rte_eth_dev_info info;
+
+		rte_eth_dev_info_get(ctx->port, &info);
+		action_rss_data->s.rss_conf.rss_key_len =
+			RTE_MIN(sizeof(action_rss_data->s.rss_key),
+				info.hash_key_size);
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2086,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2100,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2121,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dd051f5ca..97a959b2a 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -998,31 +998,51 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
 };
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1052,31 +1072,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */
@@ -1089,7 +1150,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1107,24 +1167,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -1141,12 +1200,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 08/11] app/testpmd: fix missing RSS fields in flow action
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (6 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 09/11] app/testpmd: fix missing boolean values in flow command Adrien Mazarguil
                             ` (3 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Wenzhuo Lu, Jingjing Wu

Users cannot override the default RSS settings when entering a RSS action,
only a list of queues can be provided.

This patch enables them to set a RSS hash key and types for a flow rule.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 133 ++++++++++++++++++++++-
 app/test-pmd/config.c                       |  20 ++--
 app/test-pmd/testpmd.h                      |  13 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 ++
 4 files changed, 163 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index d37c5f39f..fcd76b56e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -167,6 +167,10 @@ enum index {
 	ACTION_DUP,
 	ACTION_DUP_INDEX,
 	ACTION_RSS,
+	ACTION_RSS_TYPES,
+	ACTION_RSS_TYPE,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_RSS_QUEUE,
 	ACTION_PF,
@@ -223,6 +227,9 @@ struct context {
 struct arg {
 	uint32_t hton:1; /**< Use network byte ordering. */
 	uint32_t sign:1; /**< Value is signed. */
+	uint32_t bounded:1; /**< Value is bounded. */
+	uintmax_t min; /**< Minimum value if bounded. */
+	uintmax_t max; /**< Maximum value if bounded. */
 	uint32_t offset; /**< Relative offset from ctx->object. */
 	uint32_t size; /**< Field size. */
 	const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
@@ -329,6 +336,16 @@ struct token {
 		.size = (s), \
 	})
 
+/** Same as ARGS_ENTRY_ARB() with bounded values. */
+#define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
+	(&(const struct arg){ \
+		.bounded = 1, \
+		.min = (i), \
+		.max = (a), \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */
 #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -635,6 +652,9 @@ static const enum index action_dup[] = {
 };
 
 static const enum index action_rss[] = {
+	ACTION_RSS_TYPES,
+	ACTION_RSS_KEY,
+	ACTION_RSS_KEY_LEN,
 	ACTION_RSS_QUEUES,
 	ACTION_NEXT,
 	ZERO,
@@ -666,6 +686,9 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
+static int parse_vc_action_rss_type(struct context *, const struct token *,
+				    const char *, unsigned int, void *,
+				    unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -721,6 +744,8 @@ static int comp_port(struct context *, const struct token *,
 		     unsigned int, char *, unsigned int);
 static int comp_rule_id(struct context *, const struct token *,
 			unsigned int, char *, unsigned int);
+static int comp_vc_action_rss_type(struct context *, const struct token *,
+				   unsigned int, char *, unsigned int);
 static int comp_vc_action_rss_queue(struct context *, const struct token *,
 				    unsigned int, char *, unsigned int);
 
@@ -1593,6 +1618,43 @@ static const struct token token_list[] = {
 		.next = NEXT(action_rss),
 		.call = parse_vc_action_rss,
 	},
+	[ACTION_RSS_TYPES] = {
+		.name = "types",
+		.help = "RSS hash types",
+		.next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
+	},
+	[ACTION_RSS_TYPE] = {
+		.name = "{type}",
+		.help = "RSS hash type",
+		.call = parse_vc_action_rss_type,
+		.comp = comp_vc_action_rss_type,
+	},
+	[ACTION_RSS_KEY] = {
+		.name = "key",
+		.help = "RSS hash key",
+		.next = NEXT(action_rss, NEXT_ENTRY(STRING)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len)),
+			     ARGS_ENTRY_ARB
+			     (((uintptr_t)((union action_rss_data *)0)->
+			       s.rss_key),
+			      RSS_HASH_KEY_LENGTH)),
+	},
+	[ACTION_RSS_KEY_LEN] = {
+		.name = "key_len",
+		.help = "RSS hash key length in bytes",
+		.next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB_BOUNDED
+			     (((uintptr_t)&((union action_rss_data *)0)->
+			       s.rss_conf.rss_key_len),
+			      sizeof(((struct rte_eth_rss_conf *)0)->
+				     rss_key_len),
+			      0,
+			      RSS_HASH_KEY_LENGTH)),
+	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
 		.help = "queue indices to use",
@@ -2076,6 +2138,50 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
 }
 
 /**
+ * Parse type field for RSS action.
+ *
+ * Valid tokens are type field names and the "end" token.
+ */
+static int
+parse_vc_action_rss_type(struct context *ctx, const struct token *token,
+			  const char *str, unsigned int len,
+			  void *buf, unsigned int size)
+{
+	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+
+	(void)token;
+	(void)buf;
+	(void)size;
+	if (ctx->curr != ACTION_RSS_TYPE)
+		return -1;
+	if (!(ctx->objdata >> 16) && ctx->object) {
+		action_rss_data = ctx->object;
+		action_rss_data->s.rss_conf.rss_hf = 0;
+	}
+	if (!strcmp_partial("end", str, len)) {
+		ctx->objdata &= 0xffff;
+		return len;
+	}
+	for (i = 0; rss_type_table[i].str; ++i)
+		if (!strcmp_partial(rss_type_table[i].str, str, len))
+			break;
+	if (!rss_type_table[i].str)
+		return -1;
+	ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
+	/* Repeat token. */
+	if (ctx->next_num == RTE_DIM(ctx->next))
+		return -1;
+	ctx->next[ctx->next_num++] = next;
+	if (!ctx->object)
+		return len;
+	action_rss_data = ctx->object;
+	action_rss_data->s.rss_conf.rss_hf |= rss_type_table[i].rss_type;
+	return len;
+}
+
+/**
  * Parse queue field for RSS action.
  *
  * Valid tokens are queue indices and the "end" token.
@@ -2341,6 +2447,11 @@ parse_int(struct context *ctx, const struct token *token,
 		strtoumax(str, &end, 0);
 	if (errno || (size_t)(end - str) != len)
 		goto error;
+	if (arg->bounded &&
+	    ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
+			    (intmax_t)u > (intmax_t)arg->max)) ||
+	     (!arg->sign && (u < arg->min || u > arg->max))))
+		goto error;
 	if (!ctx->object)
 		return len;
 	if (arg->mask) {
@@ -2434,7 +2545,7 @@ parse_string(struct context *ctx, const struct token *token,
 	buf = (uint8_t *)ctx->object + arg_data->offset;
 	/* Output buffer is not necessarily NUL-terminated. */
 	memcpy(buf, str, len);
-	memset((uint8_t *)buf + len, 0x55, size - len);
+	memset((uint8_t *)buf + len, 0x00, size - len);
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
 	return len;
@@ -2730,6 +2841,26 @@ comp_rule_id(struct context *ctx, const struct token *token,
 	return i;
 }
 
+/** Complete type field for RSS action. */
+static int
+comp_vc_action_rss_type(struct context *ctx, const struct token *token,
+			unsigned int ent, char *buf, unsigned int size)
+{
+	unsigned int i;
+
+	(void)ctx;
+	(void)token;
+	for (i = 0; rss_type_table[i].str; ++i)
+		;
+	if (!buf)
+		return i + 1;
+	if (ent < i)
+		return snprintf(buf, size, "%s", rss_type_table[ent].str);
+	if (ent == i)
+		return snprintf(buf, size, "end");
+	return -1;
+}
+
 /** Complete queue field for RSS action. */
 static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 97a959b2a..5daa93bb3 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -73,12 +73,7 @@ static const struct {
 	},
 };
 
-struct rss_type_info {
-	char str[32];
-	uint64_t rss_type;
-};
-
-static const struct rss_type_info rss_type_table[] = {
+const struct rss_type_info rss_type_table[] = {
 	{ "ipv4", ETH_RSS_IPV4 },
 	{ "ipv4-frag", ETH_RSS_FRAG_IPV4 },
 	{ "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
@@ -99,7 +94,12 @@ static const struct rss_type_info rss_type_table[] = {
 	{ "vxlan", ETH_RSS_VXLAN },
 	{ "geneve", ETH_RSS_GENEVE },
 	{ "nvgre", ETH_RSS_NVGRE },
-
+	{ "ip", ETH_RSS_IP },
+	{ "udp", ETH_RSS_UDP },
+	{ "tcp", ETH_RSS_TCP },
+	{ "sctp", ETH_RSS_SCTP },
+	{ "tunnel", ETH_RSS_TUNNEL },
+	{ NULL, 0 },
 };
 
 static void
@@ -1835,7 +1835,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 	}
 
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_info, rss_type_table[i].str))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
@@ -1864,7 +1864,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 		return;
 	}
 	printf("RSS functions:\n ");
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (rss_hf & rss_type_table[i].rss_type)
 			printf("%s ", rss_type_table[i].str);
 	}
@@ -1888,7 +1888,7 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = hash_key_len;
 	rss_conf.rss_hf = 0;
-	for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+	for (i = 0; rss_type_table[i].str; i++) {
 		if (!strcmp(rss_type_table[i].str, rss_type))
 			rss_conf.rss_hf = rss_type_table[i].rss_type;
 	}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 98d84da84..070919822 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -79,6 +79,19 @@ struct pkt_burst_stats {
 };
 #endif
 
+/** Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /**< Type name. */
+	uint64_t rss_type; /**< Type value. */
+};
+
+/**
+ * RSS type information table.
+ *
+ * An entry with a NULL type name terminates the list.
+ */
+extern const struct rss_type_info rss_type_table[];
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a766ac795..cb6f201e1 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3406,6 +3406,14 @@ This section lists supported actions and their attributes, if any.
 
 - ``rss``: spread packets among several queues.
 
+  - ``types [{RSS hash type} [...]] end``: RSS hash types, allowed tokens
+    are the same as `set_hash_input_set`_, an empty list means none (0).
+
+  - ``key {string}``: RSS hash key, overrides ``key_len``.
+
+  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
+    conjunction with ``key`` to pad or truncate it.
+
   - ``queues [{unsigned} [...]] end``: queue indices to use.
 
 - ``pf``: redirect packets to physical device function.
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 09/11] app/testpmd: fix missing boolean values in flow command
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (7 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 10/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
                             ` (2 subsequent siblings)
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Matan Azrad

Original implementation lacks the on/off toggle.

This patch shows up as a fix because it has been a popular request ever
since the first DPDK release with the original implementation but was never
addressed.

Fixes: abc3d81aca1b ("app/testpmd: add item raw to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Matan Azrad <matan@mellanox.com>

--

v6 changes:

Fixed title (ethdev => app/testpmd) following Matan's comment [1].

[1] http://dpdk.org/ml/archives/dev/2018-April/097457.html
---
 app/test-pmd/cmdline_flow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fcd76b56e..f0b4b7bc4 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -2692,6 +2692,7 @@ static const char *const boolean_name[] = {
 	"false", "true",
 	"no", "yes",
 	"N", "Y",
+	"off", "on",
 	NULL,
 };
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 10/11] ethdev: fix shallow copy of flow API RSS action
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (8 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 09/11] app/testpmd: fix missing boolean values in flow command Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
  2018-04-19 14:03           ` [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes Ferruh Yigit
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable, Gaetan Rivet, Thomas Monjalon

The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.

Even assuming it is permanently allocated and a pointer copy is safe,
pointed data may change and not reflect an applied flow rule anymore.

This patch aligns with testpmd by making a deep copy instead.

Fixes: 18da437b5f63 ("ethdev: add flow rule copy function")
Cc: stable@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 43 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index a3823d874..ada280810 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,
 	return -code;
 }
 
-/** Compute storage space needed by item specification. */
-static void
-flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */
+enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */
+static size_t
+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
-	/* Not a fall-through */
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = rte_flow_desc_item[item->type].size;
+		size = rte_flow_desc_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
-/** Compute storage space needed by action configuration. */
-static void
-flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. */
+static size_t
+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
-	/* Not a fall-through. */
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = rte_flow_desc_action[action->type].size;
+		size = rte_flow_desc_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Store a full rte_flow description. */
@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 {
 	struct rte_flow_desc *fd = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	size_t size = 0;
@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, item,
 					     sizeof(*item));
 			off1 += sizeof(*item);
-			flow_item_spec_size(item, &tmp, &pad);
 			if (item->spec) {
 				if (fd)
-					dst->spec = memcpy(fd->data + off2,
-							   item->spec, tmp);
-				off2 += tmp + pad;
+					dst->spec = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_SPEC);
 			}
 			if (item->last) {
 				if (fd)
-					dst->last = memcpy(fd->data + off2,
-							   item->last, tmp);
-				off2 += tmp + pad;
+					dst->last = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_LAST);
 			}
 			if (item->mask) {
 				if (fd)
-					dst->mask = memcpy(fd->data + off2,
-							   item->mask, tmp);
-				off2 += tmp + pad;
+					dst->mask = fd->data + off2;
+				off2 += flow_item_spec_copy
+					(fd ? fd->data + off2 : NULL, item,
+					 ITEM_MASK);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);
@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,
 				dst = memcpy(fd->data + off1, action,
 					     sizeof(*action));
 			off1 += sizeof(*action);
-			flow_action_conf_size(action, &tmp, &pad);
 			if (action->conf) {
 				if (fd)
-					dst->conf = memcpy(fd->data + off2,
-							   action->conf, tmp);
-				off2 += tmp + pad;
+					dst->conf = fd->data + off2;
+				off2 += flow_action_conf_copy
+					(fd ? fd->data + off2 : NULL, action);
 			}
 			off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 		} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* [dpdk-dev] [PATCH v6 11/11] ethdev: fix missing include in flow API
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (9 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 10/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
@ 2018-04-19 10:07           ` Adrien Mazarguil
  2018-04-19 14:03           ` [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes Ferruh Yigit
  11 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:07 UTC (permalink / raw)
  To: dev; +Cc: stable

Fixes: b1a4b4cbc0a8 ("ethdev: introduce generic flow API")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 lib/librte_ether/rte_flow.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index 56c733451..44ae19d3b 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -14,6 +14,8 @@
  * associated actions in hardware through flow rules.
  */
 
+#include <stdint.h>
+
 #include <rte_arp.h>
 #include <rte_ether.h>
 #include <rte_icmp.h>
-- 
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command
  2018-04-18 17:16               ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
@ 2018-04-19 10:18                 ` Adrien Mazarguil
  0 siblings, 0 replies; 93+ messages in thread
From: Adrien Mazarguil @ 2018-04-19 10:18 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: Matan Azrad, dev, stable

On Wed, Apr 18, 2018 at 06:16:18PM +0100, Ferruh Yigit wrote:
> On 4/17/2018 9:25 AM, Adrien Mazarguil wrote:
> > On Mon, Apr 16, 2018 at 07:17:44PM +0000, Matan Azrad wrote:
> >> Hi Adrien
> >>
> >> I think the title should be "app/testpmd: ..." ...
> > 
> > Indeed, I'll update it in the next iteration, thanks.
> 
> If this is the only issue, it can be fixed while applying.
> Are there more outstanding issues, will there be a new version of the set?

Yes, submitted after rebasing it [1].

[1] http://dpdk.org/ml/archives/dev/2018-April/098035.html

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes
  2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
                             ` (10 preceding siblings ...)
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
@ 2018-04-19 14:03           ` Ferruh Yigit
  2018-04-19 14:07             ` Ferruh Yigit
  11 siblings, 1 reply; 93+ messages in thread
From: Ferruh Yigit @ 2018-04-19 14:03 UTC (permalink / raw)
  To: Adrien Mazarguil, dev

On 4/19/2018 11:07 AM, Adrien Mazarguil wrote:
> This series contains several fixes for rte_flow and its implementation in
> PMDs and testpmd. Upcoming work on the flow API depends on it.
> 
> v6 changes:
> 
> - No change, rebased series and updated/fixed commit messages.
> 
> v5 changes:
> 
> - No change, rebased series to address conflicts.
> 
> v4 changes:
> 
> - Rebased again.
> - The reliance on rte_eth_dev_rss_hash_conf_get() was removed from patch #7,
>   see updated patch for details.
> 
> v3 changes:
> 
> - Rebased series.
> - Dropped unnecessary "net/sfc: fix endian conversions in flow API".
> - Dropped "ethdev: fix ABI version in meson build", handled by prior commit
>   d9736a248785 ("ethdev: fix library version in meson build").
> 
> v2 changes:
> 
> - mlx5 fix (patch #3).
> - bnxt fix (patch #4).
> - sfc fix (patch #6).
> - Missing include (patch #13).
> 
> Adrien Mazarguil (11):
>   net/mlx4: fix RSS resource leak in case of error
>   net/mlx4: fix ignored RSS hash types
>   net/mlx5: fix RSS flow action bounds check
>   net/bnxt: fix matching of flow API item masks
>   app/testpmd: fix flow completion for RSS queues
>   app/testpmd: fix lack of flow action configuration
>   app/testpmd: fix RSS flow action configuration
>   app/testpmd: fix missing RSS fields in flow action
>   app/testpmd: fix missing boolean values in flow command
>   ethdev: fix shallow copy of flow API RSS action
>   ethdev: fix missing include in flow API

For series,
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes
  2018-04-19 14:03           ` [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes Ferruh Yigit
@ 2018-04-19 14:07             ` Ferruh Yigit
  0 siblings, 0 replies; 93+ messages in thread
From: Ferruh Yigit @ 2018-04-19 14:07 UTC (permalink / raw)
  To: Adrien Mazarguil, dev

On 4/19/2018 3:03 PM, Ferruh Yigit wrote:
> On 4/19/2018 11:07 AM, Adrien Mazarguil wrote:
>> This series contains several fixes for rte_flow and its implementation in
>> PMDs and testpmd. Upcoming work on the flow API depends on it.
>>
>> v6 changes:
>>
>> - No change, rebased series and updated/fixed commit messages.
>>
>> v5 changes:
>>
>> - No change, rebased series to address conflicts.
>>
>> v4 changes:
>>
>> - Rebased again.
>> - The reliance on rte_eth_dev_rss_hash_conf_get() was removed from patch #7,
>>   see updated patch for details.
>>
>> v3 changes:
>>
>> - Rebased series.
>> - Dropped unnecessary "net/sfc: fix endian conversions in flow API".
>> - Dropped "ethdev: fix ABI version in meson build", handled by prior commit
>>   d9736a248785 ("ethdev: fix library version in meson build").
>>
>> v2 changes:
>>
>> - mlx5 fix (patch #3).
>> - bnxt fix (patch #4).
>> - sfc fix (patch #6).
>> - Missing include (patch #13).
>>
>> Adrien Mazarguil (11):
>>   net/mlx4: fix RSS resource leak in case of error
>>   net/mlx4: fix ignored RSS hash types
>>   net/mlx5: fix RSS flow action bounds check
>>   net/bnxt: fix matching of flow API item masks
>>   app/testpmd: fix flow completion for RSS queues
>>   app/testpmd: fix lack of flow action configuration
>>   app/testpmd: fix RSS flow action configuration
>>   app/testpmd: fix missing RSS fields in flow action
>>   app/testpmd: fix missing boolean values in flow command
>>   ethdev: fix shallow copy of flow API RSS action
>>   ethdev: fix missing include in flow API
> 
> For series,
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS flow action configuration
  2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-05-07  5:23             ` Peng, Yuan
  0 siblings, 0 replies; 93+ messages in thread
From: Peng, Yuan @ 2018-05-07  5:23 UTC (permalink / raw)
  To: Adrien Mazarguil, dev
  Cc: stable, Lu, Wenzhuo, Wu, Jingjing, Xueming Li, Zhao1, Wei, Xing, Beilei

Hi Adrien,

There is a core dump when I set i40e fdir flexbytes rule, I bisect the commit version,
d0ad8648b1c57c0e311ab7a3192bc3b507de5bf6 is the first bad commit
commit d0ad8648b1c57c0e311ab7a3192bc3b507de5bf6
Author: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Date:   Thu Apr 19 12:07:37 2018 +0200

    app/testpmd: fix RSS flow action configuration

    Except for a list of queues, RSS configuration (hash key and fields) cannot
    be specified from the flow command line and testpmd does not provide safe
    defaults either.

    In order to validate their implementation with testpmd, PMDs had to
    interpret its NULL RSS configuration parameters somehow, however this has
    never been valid to begin with.

    This patch makes testpmd always provide default values.

    The list of RSS types to use is exclusively taken from the global "rss_hf"
    variable, itself configured through the "port config all rss" command or
    --rss-ip/--rss-udp command-line options.

    Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
    Cc: stable@dpdk.org

    Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
    Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
    Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

:040000 040000 1e01ca01e840f43334f576a2fe8cf755433e9c90 1ff48b7ff1f01a399cd3403c5fc6e537d2f33021 M      app

The test steps are as below:
./usertools/dpdk-devbind.py -b igb_uio 05:00.0 05:00.1
 ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x1fffe -n 4 -w 0000:05:00.0 --file-prefix=pf - -i --pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16
 testpmd> flow create 0 ingress pattern eth type is 0x0807 / raw relative is 1 pattern is abcdefghijklmnop / end actions queue index 1 / end
 PMD: Global register is changed during enable FDIR flexible payload
 Segmentation fault (core dumped)

Could you help to check it?
Thank you very much.
Yuan.

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil
Sent: Thursday, April 19, 2018 6:08 PM
To: dev@dpdk.org
Cc: stable@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xueming Li <xuemingl@mellanox.com>
Subject: [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS flow action configuration

Except for a list of queues, RSS configuration (hash key and fields) cannot be specified from the flow command line and testpmd does not provide safe defaults either.

In order to validate their implementation with testpmd, PMDs had to interpret its NULL RSS configuration parameters somehow, however this has never been valid to begin with.

This patch makes testpmd always provide default values.

The list of RSS types to use is exclusively taken from the global "rss_hf"
variable, itself configured through the "port config all rss" command or --rss-ip/--rss-udp command-line options.

Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
Cc: Jingjing Wu <jingjing.wu@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>

---

v4 changes:

Removed reliance on rte_eth_dev_rss_hash_conf_get(), which as reported by Xueming, is not necessarily supported and triggers a misleading "Function not implemented" warning. Updated commit log to reflect this.
---
 app/test-pmd/cmdline.c      |   2 +
 app/test-pmd/cmdline_flow.c | 101 ++++++++++++++++++++++++----
 app/test-pmd/config.c       | 140 +++++++++++++++++++++++++++------------
 3 files changed, 190 insertions(+), 53 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 512e3b55e..9704d0454 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2033,6 +2033,8 @@ cmd_config_rss_parsed(void *parsed_result,
 		return;
 	}
 	rss_conf.rss_key = NULL;
+	/* Update global configuration for RSS types. */
+	rss_hf = rss_conf.rss_hf;
 	for (i = 0; i < rte_eth_dev_count(); i++) {
 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
 		if (diag < 0)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index a0e06db36..d37c5f39f 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -184,13 +184,19 @@ enum index {
 #define ITEM_RAW_SIZE \
 	(offsetof(struct rte_flow_item_raw, pattern) + ITEM_RAW_PATTERN_SIZE)
 
-/** Number of queue[] entries in struct rte_flow_action_rss. */ -#define ACTION_RSS_NUM 32
-
-/** Storage size for struct rte_flow_action_rss including queues. */ -#define ACTION_RSS_SIZE \
-	(offsetof(struct rte_flow_action_rss, queue) + \
-	 sizeof(*((struct rte_flow_action_rss *)0)->queue) * ACTION_RSS_NUM)
+/** Maximum number of queue indices in struct rte_flow_action_rss. */ 
+#define ACTION_RSS_QUEUE_NUM 32
+
+/** Storage for struct rte_flow_action_rss including external data. */ 
+union action_rss_data {
+	struct rte_flow_action_rss conf;
+	struct {
+		uint8_t conf_data[offsetof(struct rte_flow_action_rss, queue)];
+		uint16_t queue[ACTION_RSS_QUEUE_NUM];
+		struct rte_eth_rss_conf rss_conf;
+		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
+	} s;
+};
 
 /** Maximum number of subsequent tokens and arguments on the stack. */  #define CTX_STACK_SIZE 16 @@ -316,6 +322,13 @@ struct token {
 		.size = (sz), \
 	})
 
+/** Static initializer for ARGS() with arbitrary offset and size. */ 
+#define ARGS_ENTRY_ARB(o, s) \
+	(&(const struct arg){ \
+		.offset = (o), \
+		.size = (s), \
+	})
+
 /** Same as ARGS_ENTRY() using network byte ordering. */  #define ARGS_ENTRY_HTON(s, f) \
 	(&(const struct arg){ \
@@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);  static int parse_vc_conf(struct context *, const struct token *,
 			 const char *, unsigned int, void *, unsigned int);
+static int parse_vc_action_rss(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
@@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
 	[ACTION_RSS] = {
 		.name = "rss",
 		.help = "spread packets among several queues",
-		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
+		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
 		.next = NEXT(action_rss),
-		.call = parse_vc,
+		.call = parse_vc_action_rss,
 	},
 	[ACTION_RSS_QUEUES] = {
 		.name = "queues",
@@ -2004,6 +2020,61 @@ parse_vc_conf(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse RSS action. */
+static int
+parse_vc_action_rss(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	union action_rss_data *action_rss_data;
+	unsigned int i;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_rss_data = ctx->object;
+	*action_rss_data = (union action_rss_data){
+		.conf = (struct rte_flow_action_rss){
+			.rss_conf = &action_rss_data->s.rss_conf,
+			.num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
+		},
+	};
+	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
+		.rss_key = action_rss_data->s.rss_key,
+		.rss_key_len = sizeof(action_rss_data->s.rss_key),
+		.rss_hf = rss_hf,
+	};
+	strncpy((void *)action_rss_data->s.rss_key,
+		"testpmd's default RSS hash key",
+		sizeof(action_rss_data->s.rss_key));
+	for (i = 0; i < action_rss_data->conf.num; ++i)
+		action_rss_data->conf.queue[i] = i;
+	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
+	    ctx->port != (portid_t)RTE_PORT_ALL) {
+		struct rte_eth_dev_info info;
+
+		rte_eth_dev_info_get(ctx->port, &info);
+		action_rss_data->s.rss_conf.rss_key_len =
+			RTE_MIN(sizeof(action_rss_data->s.rss_key),
+				info.hash_key_size);
+	}
+	action->conf = &action_rss_data->conf;
+	return ret;
+}
+
 /**
  * Parse queue field for RSS action.
  *
@@ -2015,6 +2086,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 			  void *buf, unsigned int size)
 {
 	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
+	union action_rss_data *action_rss_data;
 	int ret;
 	int i;
 
@@ -2028,9 +2100,13 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 		ctx->objdata &= 0xffff;
 		return len;
 	}
-	if (i >= ACTION_RSS_NUM)
+	if (i >= ACTION_RSS_QUEUE_NUM)
 		return -1;
-	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss, queue[i])))
+	if (push_args(ctx,
+		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
+					      queue) +
+				     i * sizeof(action_rss_data->s.queue[i]),
+				     sizeof(action_rss_data->s.queue[i]))))
 		return -1;
 	ret = parse_int(ctx, token, str, len, NULL, 0);
 	if (ret < 0) {
@@ -2045,7 +2121,8 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
 	ctx->next[ctx->next_num++] = next;
 	if (!ctx->object)
 		return len;
-	((struct rte_flow_action_rss *)ctx->object)->num = i;
+	action_rss_data = ctx->object;
+	action_rss_data->conf.num = i;
 	return len;
 }
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index dd051f5ca..97a959b2a 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -998,31 +998,51 @@ static const struct {
 	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),  };
 
-/** Compute storage space needed by item specification. */ -static void -flow_item_spec_size(const struct rte_flow_item *item,
-		    size_t *size, size_t *pad)
+/** Pattern item specification types. */ enum item_spec_type {
+	ITEM_SPEC,
+	ITEM_LAST,
+	ITEM_MASK,
+};
+
+/** Compute storage space needed by item specification and copy it. */ 
+static size_t flow_item_spec_copy(void *buf, const struct rte_flow_item 
+*item,
+		    enum item_spec_type type)
 {
-	if (!item->spec) {
-		*size = 0;
+	size_t size = 0;
+	const void *item_spec =
+		type == ITEM_SPEC ? item->spec :
+		type == ITEM_LAST ? item->last :
+		type == ITEM_MASK ? item->mask :
+		NULL;
+
+	if (!item_spec)
 		goto empty;
-	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-		} spec;
+		} src;
+		union {
+			struct rte_flow_item_raw *raw;
+		} dst;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
-		spec.raw = item->spec;
-		*size = offsetof(struct rte_flow_item_raw, pattern) +
-			spec.raw->length * sizeof(*spec.raw->pattern);
+		src.raw = item_spec;
+		dst.raw = buf;
+		size = offsetof(struct rte_flow_item_raw, pattern) +
+			src.raw->length * sizeof(*src.raw->pattern);
+		if (dst.raw)
+			memcpy(dst.raw, src.raw, size);
 		break;
 	default:
-		*size = flow_item[item->type].size;
+		size = flow_item[item->type].size;
+		if (buf)
+			memcpy(buf, item_spec, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate flow_action[] entry. */
@@ -1052,31 +1072,72 @@ static const struct {
 	MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),  };
 
-/** Compute storage space needed by action configuration. */ -static void -flow_action_conf_size(const struct rte_flow_action *action,
-		      size_t *size, size_t *pad)
+/** Compute storage space needed by action configuration and copy it. 
+*/ static size_t flow_action_conf_copy(void *buf, const struct 
+rte_flow_action *action)
 {
-	if (!action->conf) {
-		*size = 0;
+	size_t size = 0;
+
+	if (!action->conf)
 		goto empty;
-	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
-		} conf;
+		} src;
+		union {
+			struct rte_flow_action_rss *rss;
+		} dst;
+		size_t off;
 
 	case RTE_FLOW_ACTION_TYPE_RSS:
-		conf.rss = action->conf;
-		*size = offsetof(struct rte_flow_action_rss, queue) +
-			conf.rss->num * sizeof(*conf.rss->queue);
+		src.rss = action->conf;
+		dst.rss = buf;
+		off = 0;
+		if (dst.rss)
+			*dst.rss = (struct rte_flow_action_rss){
+				.num = src.rss->num,
+			};
+		off += offsetof(struct rte_flow_action_rss, queue);
+		if (src.rss->num) {
+			size = sizeof(*src.rss->queue) * src.rss->num;
+			if (dst.rss)
+				memcpy(dst.rss->queue, src.rss->queue, size);
+			off += size;
+		}
+		off = RTE_ALIGN_CEIL(off, sizeof(double));
+		if (dst.rss) {
+			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
+			*(struct rte_eth_rss_conf *)(uintptr_t)
+				dst.rss->rss_conf = (struct rte_eth_rss_conf){
+				.rss_key_len = src.rss->rss_conf->rss_key_len,
+				.rss_hf = src.rss->rss_conf->rss_hf,
+			};
+		}
+		off += sizeof(*src.rss->rss_conf);
+		if (src.rss->rss_conf->rss_key_len) {
+			off = RTE_ALIGN_CEIL(off, sizeof(double));
+			size = sizeof(*src.rss->rss_conf->rss_key) *
+				src.rss->rss_conf->rss_key_len;
+			if (dst.rss) {
+				((struct rte_eth_rss_conf *)(uintptr_t)
+				 dst.rss->rss_conf)->rss_key =
+					(void *)((uintptr_t)dst.rss + off);
+				memcpy(dst.rss->rss_conf->rss_key,
+				       src.rss->rss_conf->rss_key,
+				       size);
+			}
+			off += size;
+		}
+		size = off;
 		break;
 	default:
-		*size = flow_action[action->type].size;
+		size = flow_action[action->type].size;
+		if (buf)
+			memcpy(buf, action->conf, size);
 		break;
 	}
 empty:
-	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
+	return RTE_ALIGN_CEIL(size, sizeof(double));
 }
 
 /** Generate a port_flow entry from attributes/pattern/actions. */ @@ -1089,7 +1150,6 @@ port_flow_new(const struct rte_flow_attr *attr,
 	const struct rte_flow_action *action;
 	struct port_flow *pf = NULL;
 	size_t tmp;
-	size_t pad;
 	size_t off1 = 0;
 	size_t off2 = 0;
 	int err = ENOTSUP;
@@ -1107,24 +1167,23 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, item, sizeof(*item));
 		off1 += sizeof(*item);
-		flow_item_spec_size(item, &tmp, &pad);
 		if (item->spec) {
 			if (pf)
-				dst->spec = memcpy(pf->data + off2,
-						   item->spec, tmp);
-			off2 += tmp + pad;
+				dst->spec = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_SPEC);
 		}
 		if (item->last) {
 			if (pf)
-				dst->last = memcpy(pf->data + off2,
-						   item->last, tmp);
-			off2 += tmp + pad;
+				dst->last = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_LAST);
 		}
 		if (item->mask) {
 			if (pf)
-				dst->mask = memcpy(pf->data + off2,
-						   item->mask, tmp);
-			off2 += tmp + pad;
+				dst->mask = pf->data + off2;
+			off2 += flow_item_spec_copy
+				(pf ? pf->data + off2 : NULL, item, ITEM_MASK);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END); @@ -1141,12 +1200,11 @@ port_flow_new(const struct rte_flow_attr *attr,
 		if (pf)
 			dst = memcpy(pf->data + off1, action, sizeof(*action));
 		off1 += sizeof(*action);
-		flow_action_conf_size(action, &tmp, &pad);
 		if (action->conf) {
 			if (pf)
-				dst->conf = memcpy(pf->data + off2,
-						   action->conf, tmp);
-			off2 += tmp + pad;
+				dst->conf = pf->data + off2;
+			off2 += flow_action_conf_copy
+				(pf ? pf->data + off2 : NULL, action);
 		}
 		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
 	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
--
2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

* Re: [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS flow action configuration
  2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS " Adrien Mazarguil
@ 2018-05-07  6:53   ` Zhao1, Wei
  0 siblings, 0 replies; 93+ messages in thread
From: Zhao1, Wei @ 2018-05-07  6:53 UTC (permalink / raw)
  To: Adrien Mazarguil, dev; +Cc: Peng, Yuan

Hi,  Adrien Mazarguil

	Once we apply this patch ,we will meet an abnormal issue, rte_flow command will cause core dump.
If we do not apply it, this will disappear. I have check this issue, it seems there is something wrong in function
of port_flow_new() in Config.c file, core dump happen here every time.
This is find out by Peng yuan first,  she will tell you how reappear this issue.



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil
> Sent: Friday, March 23, 2018 8:58 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS flow action
> configuration
> 
> Except for a list of queues, RSS configuration (hash key and fields) cannot be
> specified from the flow command line and testpmd does not provide safe
> defaults either.
> 
> In order to validate their implementation with testpmd, PMDs had to
> interpret its NULL RSS configuration parameters somehow, however this has
> never been valid to begin with.
> 
> This patch makes testpmd always provide default values.
> 
> Fixes: 05d34c6e9d2c ("app/testpmd: add queue actions to flow command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Cc: Jingjing Wu <jingjing.wu@intel.com>
> ---
>  app/test-pmd/cmdline_flow.c | 104 +++++++++++++++++++++++++----
>  app/test-pmd/config.c       | 141 +++++++++++++++++++++++++++-----------
> -
>  2 files changed, 192 insertions(+), 53 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index c2cf415ef..890c36d8e 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -184,13 +184,19 @@ enum index {
>  #define ITEM_RAW_SIZE \
>  	(offsetof(struct rte_flow_item_raw, pattern) +
> ITEM_RAW_PATTERN_SIZE)
> 
> -/** Number of queue[] entries in struct rte_flow_action_rss. */ -#define
> ACTION_RSS_NUM 32
> -
> -/** Storage size for struct rte_flow_action_rss including queues. */ -
> #define ACTION_RSS_SIZE \
> -	(offsetof(struct rte_flow_action_rss, queue) + \
> -	 sizeof(*((struct rte_flow_action_rss *)0)->queue) *
> ACTION_RSS_NUM)
> +/** Maximum number of queue indices in struct rte_flow_action_rss. */
> +#define ACTION_RSS_QUEUE_NUM 32
> +
> +/** Storage for struct rte_flow_action_rss including external data. */
> +union action_rss_data {
> +	struct rte_flow_action_rss conf;
> +	struct {
> +		uint8_t conf_data[offsetof(struct rte_flow_action_rss,
> queue)];
> +		uint16_t queue[ACTION_RSS_QUEUE_NUM];
> +		struct rte_eth_rss_conf rss_conf;
> +		uint8_t rss_key[RSS_HASH_KEY_LENGTH];
> +	} s;
> +};
> 
>  /** Maximum number of subsequent tokens and arguments on the stack.
> */  #define CTX_STACK_SIZE 16 @@ -316,6 +322,13 @@ struct token {
>  		.size = (sz), \
>  	})
> 
> +/** Static initializer for ARGS() with arbitrary offset and size. */
> +#define ARGS_ENTRY_ARB(o, s) \
> +	(&(const struct arg){ \
> +		.offset = (o), \
> +		.size = (s), \
> +	})
> +
>  /** Same as ARGS_ENTRY() using network byte ordering. */  #define
> ARGS_ENTRY_HTON(s, f) \
>  	(&(const struct arg){ \
> @@ -650,6 +663,9 @@ static int parse_vc_spec(struct context *, const struct
> token *,
>  			 const char *, unsigned int, void *, unsigned int);
> static int parse_vc_conf(struct context *, const struct token *,
>  			 const char *, unsigned int, void *, unsigned int);
> +static int parse_vc_action_rss(struct context *, const struct token *,
> +			       const char *, unsigned int, void *,
> +			       unsigned int);
>  static int parse_vc_action_rss_queue(struct context *, const struct token *,
>  				     const char *, unsigned int, void *,
>  				     unsigned int);
> @@ -1573,9 +1589,9 @@ static const struct token token_list[] = {
>  	[ACTION_RSS] = {
>  		.name = "rss",
>  		.help = "spread packets among several queues",
> -		.priv = PRIV_ACTION(RSS, ACTION_RSS_SIZE),
> +		.priv = PRIV_ACTION(RSS, sizeof(union action_rss_data)),
>  		.next = NEXT(action_rss),
> -		.call = parse_vc,
> +		.call = parse_vc_action_rss,
>  	},
>  	[ACTION_RSS_QUEUES] = {
>  		.name = "queues",
> @@ -2004,6 +2020,64 @@ parse_vc_conf(struct context *ctx, const struct
> token *token,
>  	return len;
>  }
> 
> +/** Parse RSS action. */
> +static int
> +parse_vc_action_rss(struct context *ctx, const struct token *token,
> +		    const char *str, unsigned int len,
> +		    void *buf, unsigned int size)
> +{
> +	struct buffer *out = buf;
> +	struct rte_flow_action *action;
> +	union action_rss_data *action_rss_data;
> +	unsigned int i;
> +	int ret;
> +
> +	ret = parse_vc(ctx, token, str, len, buf, size);
> +	if (ret < 0)
> +		return ret;
> +	/* Nothing else to do if there is no buffer. */
> +	if (!out)
> +		return ret;
> +	if (!out->args.vc.actions_n)
> +		return -1;
> +	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
> +	/* Point to selected object. */
> +	ctx->object = out->args.vc.data;
> +	ctx->objmask = NULL;
> +	/* Set up default configuration. */
> +	action_rss_data = ctx->object;
> +	*action_rss_data = (union action_rss_data){
> +		.conf = (struct rte_flow_action_rss){
> +			.rss_conf = &action_rss_data->s.rss_conf,
> +			.num = RTE_MIN(nb_rxq,
> ACTION_RSS_QUEUE_NUM),
> +		},
> +	};
> +	action_rss_data->s.rss_conf = (struct rte_eth_rss_conf){
> +		.rss_key = action_rss_data->s.rss_key,
> +		.rss_key_len = sizeof(action_rss_data->s.rss_key),
> +		.rss_hf = rss_hf,
> +	};
> +	strncpy((void *)action_rss_data->s.rss_key,
> +		"testpmd's default RSS hash key",
> +		sizeof(action_rss_data->s.rss_key));
> +	for (i = 0; i < action_rss_data->conf.num; ++i)
> +		action_rss_data->conf.queue[i] = i;
> +	if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
> +	    ctx->port != (portid_t)RTE_PORT_ALL) {
> +		if (rte_eth_dev_rss_hash_conf_get
> +		    (ctx->port, &action_rss_data->s.rss_conf) < 0) {
> +			struct rte_eth_dev_info info;
> +
> +			rte_eth_dev_info_get(ctx->port, &info);
> +			action_rss_data->s.rss_conf.rss_key_len =
> +				RTE_MIN(sizeof(action_rss_data->s.rss_key),
> +					info.hash_key_size);
> +		}
> +	}
> +	action->conf = &action_rss_data->conf;
> +	return ret;
> +}
> +
>  /**
>   * Parse queue field for RSS action.
>   *
> @@ -2015,6 +2089,7 @@ parse_vc_action_rss_queue(struct context *ctx,
> const struct token *token,
>  			  void *buf, unsigned int size)
>  {
>  	static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
> +	union action_rss_data *action_rss_data;
>  	int ret;
>  	int i;
> 
> @@ -2028,9 +2103,13 @@ parse_vc_action_rss_queue(struct context *ctx,
> const struct token *token,
>  		ctx->objdata &= 0xffff;
>  		return len;
>  	}
> -	if (i >= ACTION_RSS_NUM)
> +	if (i >= ACTION_RSS_QUEUE_NUM)
>  		return -1;
> -	if (push_args(ctx, ARGS_ENTRY(struct rte_flow_action_rss,
> queue[i])))
> +	if (push_args(ctx,
> +		      ARGS_ENTRY_ARB(offsetof(struct rte_flow_action_rss,
> +					      queue) +
> +				     i * sizeof(action_rss_data->s.queue[i]),
> +				     sizeof(action_rss_data->s.queue[i]))))
>  		return -1;
>  	ret = parse_int(ctx, token, str, len, NULL, 0);
>  	if (ret < 0) {
> @@ -2045,7 +2124,8 @@ parse_vc_action_rss_queue(struct context *ctx,
> const struct token *token,
>  	ctx->next[ctx->next_num++] = next;
>  	if (!ctx->object)
>  		return len;
> -	((struct rte_flow_action_rss *)ctx->object)->num = i;
> +	action_rss_data = ctx->object;
> +	action_rss_data->conf.num = i;
>  	return len;
>  }
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 4bb255c62..a4b54f86a 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -982,31 +982,52 @@ static const struct {
>  	MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),  };
> 
> -/** Compute storage space needed by item specification. */ -static void -
> flow_item_spec_size(const struct rte_flow_item *item,
> -		    size_t *size, size_t *pad)
> +/** Pattern item specification types. */ enum item_spec_type {
> +	ITEM_SPEC,
> +	ITEM_LAST,
> +	ITEM_MASK,
> +};
> +
> +/** Compute storage space needed by item specification and copy it. */
> +static size_t flow_item_spec_copy(void *buf, const struct rte_flow_item
> +*item,
> +		    enum item_spec_type type)
>  {
> -	if (!item->spec) {
> -		*size = 0;
> +	size_t size = 0;
> +
> +	const void *item_spec =
> +		type == ITEM_SPEC ? item->spec :
> +		type == ITEM_LAST ? item->last :
> +		type == ITEM_MASK ? item->mask :
> +		NULL;
> +
> +	if (!item_spec)
>  		goto empty;
> -	}
>  	switch (item->type) {
>  		union {
>  			const struct rte_flow_item_raw *raw;
> -		} spec;
> +		} src;
> +		union {
> +			struct rte_flow_item_raw *raw;
> +		} dst;
> 
>  	case RTE_FLOW_ITEM_TYPE_RAW:
> -		spec.raw = item->spec;
> -		*size = offsetof(struct rte_flow_item_raw, pattern) +
> -			spec.raw->length * sizeof(*spec.raw->pattern);
> +		src.raw = item_spec;
> +		dst.raw = buf;
> +		size = offsetof(struct rte_flow_item_raw, pattern) +
> +			src.raw->length * sizeof(*src.raw->pattern);
> +		if (dst.raw)
> +			memcpy(dst.raw, src.raw, size);
>  		break;
>  	default:
> -		*size = flow_item[item->type].size;
> +		size = flow_item[item->type].size;
> +		if (buf)
> +			memcpy(buf, item_spec, size);
>  		break;
>  	}
>  empty:
> -	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
> +	return RTE_ALIGN_CEIL(size, sizeof(double));
>  }
> 
>  /** Generate flow_action[] entry. */
> @@ -1036,31 +1057,72 @@ static const struct {
>  	MK_FLOW_ACTION(METER, sizeof(struct
> rte_flow_action_meter)),  };
> 
> -/** Compute storage space needed by action configuration. */ -static void -
> flow_action_conf_size(const struct rte_flow_action *action,
> -		      size_t *size, size_t *pad)
> +/** Compute storage space needed by action configuration and copy it.
> +*/ static size_t flow_action_conf_copy(void *buf, const struct
> +rte_flow_action *action)
>  {
> -	if (!action->conf) {
> -		*size = 0;
> +	size_t size = 0;
> +
> +	if (!action->conf)
>  		goto empty;
> -	}
>  	switch (action->type) {
>  		union {
>  			const struct rte_flow_action_rss *rss;
> -		} conf;
> +		} src;
> +		union {
> +			struct rte_flow_action_rss *rss;
> +		} dst;
> +		size_t off;
> 
>  	case RTE_FLOW_ACTION_TYPE_RSS:
> -		conf.rss = action->conf;
> -		*size = offsetof(struct rte_flow_action_rss, queue) +
> -			conf.rss->num * sizeof(*conf.rss->queue);
> +		src.rss = action->conf;
> +		dst.rss = buf;
> +		off = 0;
> +		if (dst.rss)
> +			*dst.rss = (struct rte_flow_action_rss){
> +				.num = src.rss->num,
> +			};
> +		off += offsetof(struct rte_flow_action_rss, queue);
> +		if (src.rss->num) {
> +			size = sizeof(*src.rss->queue) * src.rss->num;
> +			if (dst.rss)
> +				memcpy(dst.rss->queue, src.rss->queue,
> size);
> +			off += size;
> +		}
> +		off = RTE_ALIGN_CEIL(off, sizeof(double));
> +		if (dst.rss) {
> +			dst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);
> +			*(struct rte_eth_rss_conf *)(uintptr_t)
> +				dst.rss->rss_conf = (struct
> rte_eth_rss_conf){
> +				.rss_key_len = src.rss->rss_conf-
> >rss_key_len,
> +				.rss_hf = src.rss->rss_conf->rss_hf,
> +			};
> +		}
> +		off += sizeof(*src.rss->rss_conf);
> +		if (src.rss->rss_conf->rss_key_len) {
> +			off = RTE_ALIGN_CEIL(off, sizeof(double));
> +			size = sizeof(*src.rss->rss_conf->rss_key) *
> +				src.rss->rss_conf->rss_key_len;
> +			if (dst.rss) {
> +				((struct rte_eth_rss_conf *)(uintptr_t)
> +				 dst.rss->rss_conf)->rss_key =
> +					(void *)((uintptr_t)dst.rss + off);
> +				memcpy(dst.rss->rss_conf->rss_key,
> +				       src.rss->rss_conf->rss_key,
> +				       size);
> +			}
> +			off += size;
> +		}
> +		size = off;
>  		break;
>  	default:
> -		*size = flow_action[action->type].size;
> +		size = flow_action[action->type].size;
> +		if (buf)
> +			memcpy(buf, action->conf, size);
>  		break;
>  	}
>  empty:
> -	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
> +	return RTE_ALIGN_CEIL(size, sizeof(double));
>  }
> 
>  /** Generate a port_flow entry from attributes/pattern/actions. */ @@ -
> 1073,7 +1135,6 @@ port_flow_new(const struct rte_flow_attr *attr,
>  	const struct rte_flow_action *action;
>  	struct port_flow *pf = NULL;
>  	size_t tmp;
> -	size_t pad;
>  	size_t off1 = 0;
>  	size_t off2 = 0;
>  	int err = ENOTSUP;
> @@ -1091,24 +1152,23 @@ port_flow_new(const struct rte_flow_attr *attr,
>  		if (pf)
>  			dst = memcpy(pf->data + off1, item, sizeof(*item));
>  		off1 += sizeof(*item);
> -		flow_item_spec_size(item, &tmp, &pad);
>  		if (item->spec) {
>  			if (pf)
> -				dst->spec = memcpy(pf->data + off2,
> -						   item->spec, tmp);
> -			off2 += tmp + pad;
> +				dst->spec = pf->data + off2;
> +			off2 += flow_item_spec_copy
> +				(pf ? pf->data + off2 : NULL, item,
> ITEM_SPEC);
>  		}
>  		if (item->last) {
>  			if (pf)
> -				dst->last = memcpy(pf->data + off2,
> -						   item->last, tmp);
> -			off2 += tmp + pad;
> +				dst->last = pf->data + off2;
> +			off2 += flow_item_spec_copy
> +				(pf ? pf->data + off2 : NULL, item,
> ITEM_LAST);
>  		}
>  		if (item->mask) {
>  			if (pf)
> -				dst->mask = memcpy(pf->data + off2,
> -						   item->mask, tmp);
> -			off2 += tmp + pad;
> +				dst->mask = pf->data + off2;
> +			off2 += flow_item_spec_copy
> +				(pf ? pf->data + off2 : NULL, item,
> ITEM_MASK);
>  		}
>  		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
>  	} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END); @@ -
> 1125,12 +1185,11 @@ port_flow_new(const struct rte_flow_attr *attr,
>  		if (pf)
>  			dst = memcpy(pf->data + off1, action,
> sizeof(*action));
>  		off1 += sizeof(*action);
> -		flow_action_conf_size(action, &tmp, &pad);
>  		if (action->conf) {
>  			if (pf)
> -				dst->conf = memcpy(pf->data + off2,
> -						   action->conf, tmp);
> -			off2 += tmp + pad;
> +				dst->conf = pf->data + off2;
> +			off2 += flow_action_conf_copy
> +				(pf ? pf->data + off2 : NULL, action);
>  		}
>  		off2 = RTE_ALIGN_CEIL(off2, sizeof(double));
>  	} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);
> --
> 2.11.0

^ permalink raw reply	[flat|nested] 93+ messages in thread

end of thread, other threads:[~2018-05-07  6:54 UTC | newest]

Thread overview: 93+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-23 12:58 [dpdk-dev] [PATCH v1 0/9] Bunch of flow API-related fixes Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 1/9] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 2/9] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 3/9] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 4/9] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 5/9] app/testpmd: fix RSS " Adrien Mazarguil
2018-05-07  6:53   ` Zhao1, Wei
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 6/9] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 7/9] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 8/9] ethdev: fix missing boolean values in flow command Adrien Mazarguil
2018-03-23 12:58 ` [dpdk-dev] [PATCH v1 9/9] ethdev: fix ABI version in meson build Adrien Mazarguil
2018-04-04 14:57 ` [dpdk-dev] [PATCH v2 00/13] Bunch of flow API-related fixes Adrien Mazarguil
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 01/13] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 02/13] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 03/13] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
2018-04-05  6:57     ` Nélio Laranjeiro
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 04/13] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 05/13] net/sfc: fix endian conversions in flow API Adrien Mazarguil
2018-04-04 15:30     ` Andrew Rybchenko
2018-04-04 16:08       ` Adrien Mazarguil
2018-04-05 15:10         ` Andrew Rybchenko
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 06/13] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 07/13] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
2018-04-05  6:59     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
2018-04-04 14:57   ` [dpdk-dev] [PATCH v2 08/13] app/testpmd: fix RSS " Adrien Mazarguil
2018-04-05  7:39     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 09/13] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
2018-04-05  8:15     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 10/13] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 11/13] ethdev: fix missing boolean values in flow command Adrien Mazarguil
2018-04-05  8:17     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 12/13] ethdev: fix ABI version in meson build Adrien Mazarguil
2018-04-04 14:58   ` [dpdk-dev] [PATCH v2 13/13] ethdev: fix missing include in flow API Adrien Mazarguil
2018-04-05  8:18     ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
2018-04-06 13:22   ` [dpdk-dev] [PATCH v3 00/11] Bunch of flow API-related fixes Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 07/11] app/testpmd: fix RSS " Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
2018-04-06 13:22     ` [dpdk-dev] [PATCH v3 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
2018-04-10 16:34     ` [dpdk-dev] [PATCH v4 00/11] Bunch of flow API-related fixes Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 07/11] app/testpmd: fix RSS " Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
2018-04-10 16:34       ` [dpdk-dev] [PATCH v4 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
2018-04-16 16:21       ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Adrien Mazarguil
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
2018-04-17  9:19           ` Nélio Laranjeiro
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
2018-04-17  9:20           ` Nélio Laranjeiro
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
2018-04-16 16:21         ` [dpdk-dev] [PATCH v5 07/11] app/testpmd: fix RSS " Adrien Mazarguil
2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 09/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
2018-04-17  9:18           ` [dpdk-dev] [dpdk-stable] " Nélio Laranjeiro
2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 10/11] ethdev: fix missing boolean values in flow command Adrien Mazarguil
2018-04-16 19:17           ` Matan Azrad
2018-04-17  8:25             ` Adrien Mazarguil
2018-04-18 17:16               ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2018-04-19 10:18                 ` Adrien Mazarguil
2018-04-16 16:22         ` [dpdk-dev] [PATCH v5 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
2018-04-17  9:17         ` [dpdk-dev] [PATCH v5 00/11] Bunch of flow API-related fixes Ferruh Yigit
2018-04-19 10:07         ` [dpdk-dev] [PATCH v6 " Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 01/11] net/mlx4: fix RSS resource leak in case of error Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 02/11] net/mlx4: fix ignored RSS hash types Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 03/11] net/mlx5: fix RSS flow action bounds check Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 04/11] net/bnxt: fix matching of flow API item masks Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 05/11] app/testpmd: fix flow completion for RSS queues Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 06/11] app/testpmd: fix lack of flow action configuration Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 07/11] app/testpmd: fix RSS " Adrien Mazarguil
2018-05-07  5:23             ` Peng, Yuan
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 08/11] app/testpmd: fix missing RSS fields in flow action Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 09/11] app/testpmd: fix missing boolean values in flow command Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 10/11] ethdev: fix shallow copy of flow API RSS action Adrien Mazarguil
2018-04-19 10:07           ` [dpdk-dev] [PATCH v6 11/11] ethdev: fix missing include in flow API Adrien Mazarguil
2018-04-19 14:03           ` [dpdk-dev] [PATCH v6 00/11] Bunch of flow API-related fixes Ferruh Yigit
2018-04-19 14:07             ` Ferruh Yigit

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).