DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongseok Koh <yskoh@mellanox.com>
To: Thomas Monjalon <thomas@monjalon.net>,
	Shahaf Shuler <shahafs@mellanox.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Ori Kam <orika@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 08/11] net/mlx5: add Direct Verbs translate actions
Date: Mon, 24 Sep 2018 23:17:49 +0000	[thread overview]
Message-ID: <20180924231721.15799-9-yskoh@mellanox.com> (raw)
In-Reply-To: <20180924231721.15799-1-yskoh@mellanox.com>

From: Ori Kam <orika@mellanox.com>

In this commit we add the translation of flow actions.
Unlike the Verbs API actions are separeted from the items and are passed
to the API in array structure.
Since the target action like RSS require the QP information those
actions are handled both in the translate action and in the apply.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  7 +++++
 drivers/net/mlx5/mlx5_flow_dv.c | 61 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 7f0566fc9..ec860ef4b 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -136,6 +136,8 @@ struct mlx5_flow_dv_match_params {
 	/**< Matcher value. This value is used as the mask or as a key. */
 };
 
+#define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
+
 /* Matcher structure. */
 struct mlx5_flow_dv_matcher {
 	struct mlx5_cache cache; /**< Cache to struct mlx5dv_flow_matcher. */
@@ -154,6 +156,11 @@ struct mlx5_flow_dv {
 	struct mlx5_flow_dv_match_params value;
 	/**< Holds the value that the packet is compared to. */
 	struct ibv_flow *flow; /**< Installed flow. */
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+	struct mlx5dv_flow_action_attr actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
+	/**< Action list. */
+#endif
+	int actions_n; /**< number of actions. */
 };
 
 /* Verbs specification header. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index acb1b7549..916989988 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -942,6 +942,65 @@ flow_dv_create_item(void *matcher, void *key,
 	}
 }
 
+/**
+ * Store the requested actions in an array.
+ *
+ * @param[in] action
+ *   Flow action to translate.
+ * @param[in, out] dev_flow
+ *   Pointer to the mlx5_flow.
+ */
+static void
+flow_dv_create_action(const struct rte_flow_action *action,
+		      struct mlx5_flow *dev_flow)
+{
+	const struct rte_flow_action_queue *queue;
+	const struct rte_flow_action_rss *rss;
+	int actions_n = dev_flow->dv.actions_n;
+	struct rte_flow *flow = dev_flow->flow;
+
+	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_VOID:
+		break;
+	case RTE_FLOW_ACTION_TYPE_FLAG:
+		dev_flow->dv.actions[actions_n].type = MLX5DV_FLOW_ACTION_TAG;
+		dev_flow->dv.actions[actions_n].tag_value =
+			MLX5_FLOW_MARK_DEFAULT;
+		actions_n++;
+		break;
+	case RTE_FLOW_ACTION_TYPE_MARK:
+		dev_flow->dv.actions[actions_n].type = MLX5DV_FLOW_ACTION_TAG;
+		dev_flow->dv.actions[actions_n].tag_value =
+			((const struct rte_flow_action_mark *)
+			 (action->conf))->id;
+		actions_n++;
+		break;
+	case RTE_FLOW_ACTION_TYPE_DROP:
+		dev_flow->dv.actions[actions_n].type = MLX5DV_FLOW_ACTION_DROP;
+		flow->actions |= MLX5_ACTION_DROP;
+		break;
+	case RTE_FLOW_ACTION_TYPE_QUEUE:
+		queue = action->conf;
+		flow->rss.queue_num = 1;
+		(*flow->queue)[0] = queue->index;
+		break;
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		rss = action->conf;
+		if (flow->queue)
+			memcpy((*flow->queue), rss->queue,
+			       rss->queue_num * sizeof(uint16_t));
+		flow->rss.queue_num = rss->queue_num;
+		memcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);
+		flow->rss.types = rss->types;
+		flow->rss.level = rss->level;
+		/* Added to array only in apply since we need the QP */
+		break;
+	default:
+		break;
+	}
+	dev_flow->dv.actions_n = actions_n;
+}
+
 static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] = { 0 };
 
 #define HEADER_IS_ZERO(match_criteria, headers)				     \
@@ -1103,6 +1162,8 @@ flow_dv_translate(struct rte_eth_dev *dev,
 	matcher.egress = attr->egress;
 	if (flow_dv_matcher_register(dev, &matcher, dev_flow, error))
 		return -rte_errno;
+	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++)
+		flow_dv_create_action(actions, dev_flow);
 	return 0;
 }
 
-- 
2.11.0

  parent reply	other threads:[~2018-09-24 23:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19  7:21 [dpdk-dev] [PATCH 0/3] migrate Linux TC flower driver to new flow engine Yongseok Koh
2018-09-19  7:21 ` [dpdk-dev] [PATCH 1/3] net/mlx5: add abstraction for multiple flow drivers Yongseok Koh
2018-09-19  7:21 ` [dpdk-dev] [PATCH 2/3] net/mlx5: remove Netlink flow driver Yongseok Koh
2018-09-19  7:21 ` [dpdk-dev] [PATCH 3/3] net/mlx5: add Linux TC flower driver for E-Switch flow Yongseok Koh
2018-09-24 19:55 ` [dpdk-dev] [PATCH v2 0/3] net/mlx5: migrate Linux TC flower driver to new flow engine Yongseok Koh
2018-09-24 19:55   ` [dpdk-dev] [PATCH v2 1/3] net/mlx5: add abstraction for multiple flow drivers Yongseok Koh
2018-09-24 19:55   ` [dpdk-dev] [PATCH v2 2/3] net/mlx5: remove Netlink flow driver Yongseok Koh
2018-09-24 19:55   ` [dpdk-dev] [PATCH v2 3/3] net/mlx5: add Linux TC flower driver for E-Switch flow Yongseok Koh
2018-10-04 16:16   ` [dpdk-dev] [PATCH v2 0/3] net/mlx5: migrate Linux TC flower driver to new flow engine Thomas Monjalon
2018-09-24 23:17 ` [dpdk-dev] [PATCH v3 00/11] net/mlx5: add Direct Verbs flow driver support Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 01/11] net/mlx5: split flow validation to dedicated function Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 02/11] net/mlx5: add flow prepare function Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 03/11] net/mlx5: add flow translate function Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 04/11] net/mlx5: add support for multiple flow drivers Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 05/11] net/mlx5: add Direct Verbs validation function Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 06/11] net/mlx5: add Direct Verbs prepare function Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 07/11] net/mlx5: add Direct Verbs translate items Yongseok Koh
2018-09-24 23:17   ` Yongseok Koh [this message]
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 09/11] net/mlx5: add Direct Verbs driver to glue Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 10/11] net/mlx5: add Direct Verbs final functions Yongseok Koh
2018-09-24 23:17   ` [dpdk-dev] [PATCH v3 11/11] net/mlx5: add runtime parameter to enable Direct Verbs Yongseok Koh
2018-10-04 16:17   ` [dpdk-dev] [PATCH v3 00/11] net/mlx5: add Direct Verbs flow driver support Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180924231721.15799-9-yskoh@mellanox.com \
    --to=yskoh@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=orika@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).