DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@mellanox.com>
To: Matan Azrad <matan@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Cc: wentaoc@mellanox.com, rasland@mellanox.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH 02/10] net/mlx5: optimize action flags in flow handle
Date: Wed, 15 Apr 2020 14:39:49 +0800	[thread overview]
Message-ID: <1586932797-99533-3-git-send-email-suanmingm@mellanox.com> (raw)
In-Reply-To: <1586932797-99533-1-git-send-email-suanmingm@mellanox.com>

As only limited bits is used in act_flags for flow destroy, it's a bit
expensive to save the whole 64 bits. Move the act_flags out of flow
handle and save the needed bits for flow destroy to save some bytes for
the flow handle data struct.

The fate action type and mark bits are reserved as they will be used in
flow destroy.

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c       |  8 +++-----
 drivers/net/mlx5/mlx5_flow.h       | 16 ++++++++++++++--
 drivers/net/mlx5/mlx5_flow_dv.c    | 30 ++++++++++++++++--------------
 drivers/net/mlx5/mlx5_flow_verbs.c | 23 +++++++++++++----------
 4 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index bf95a40..ffc2910 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -722,8 +722,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 		       struct mlx5_flow_handle *dev_handle)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	const int mark = !!(dev_handle->act_flags &
-			    (MLX5_FLOW_ACTION_FLAG | MLX5_FLOW_ACTION_MARK));
+	const int mark = dev_handle->mark;
 	const int tunnel = !!(dev_handle->layers & MLX5_FLOW_LAYER_TUNNEL);
 	unsigned int i;
 
@@ -800,8 +799,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 			struct mlx5_flow_handle *dev_handle)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	const int mark = !!(dev_handle->act_flags &
-			    (MLX5_FLOW_ACTION_FLAG | MLX5_FLOW_ACTION_MARK));
+	const int mark = dev_handle->mark;
 	const int tunnel = !!(dev_handle->layers & MLX5_FLOW_LAYER_TUNNEL);
 	unsigned int i;
 
@@ -2718,7 +2716,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	 * help to do the optimization work for source code.
 	 * If no decap actions, use the layers directly.
 	 */
-	if (!(dev_flow->handle->act_flags & MLX5_FLOW_ACTION_DECAP))
+	if (!(dev_flow->act_flags & MLX5_FLOW_ACTION_DECAP))
 		return dev_flow->handle->layers;
 	/* Convert L3 layers with decap action. */
 	if (dev_flow->handle->layers & MLX5_FLOW_LAYER_INNER_L3_IPV4)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index e89a092..0f5c5d4 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -339,6 +339,16 @@ enum mlx5_flow_drv_type {
 	MLX5_FLOW_TYPE_MAX,
 };
 
+/* Fate action type. */
+enum mlx5_flow_fate_type {
+	MLX5_FLOW_FATE_NONE, /* Egress flow. */
+	MLX5_FLOW_FATE_QUEUE,
+	MLX5_FLOW_FATE_JUMP,
+	MLX5_FLOW_FATE_PORT_ID,
+	MLX5_FLOW_FATE_DROP,
+	MLX5_FLOW_FATE_MAX,
+};
+
 /* Matcher PRM representation */
 struct mlx5_flow_dv_match_params {
 	size_t size;
@@ -502,14 +512,14 @@ struct mlx5_flow_handle {
 	/**< Index to next device flow handle. */
 	uint64_t layers;
 	/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */
-	uint64_t act_flags;
-	/**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
 	void *ib_flow; /**< Verbs flow pointer. */
 	struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
 	union {
 		uint32_t qrss_id; /**< Uniqie Q/RSS suffix subflow tag. */
 		uint32_t mtr_flow_id; /**< Unique meter match flow id. */
 	};
+	uint32_t mark:1; /**< Metadate rxq mark flag. */
+	uint32_t fate_action:3; /**< Fate action type. */
 	union {
 		uint32_t hrxq; /**< Hash Rx queue object index. */
 		uint32_t jump; /**< Index to the jump action resource. */
@@ -624,6 +634,8 @@ struct mlx5_flow_verbs_workspace {
 struct mlx5_flow {
 	struct rte_flow *flow; /**< Pointer to the main flow. */
 	uint64_t hash_fields; /**< Verbs hash Rx queue hash fields. */
+	uint64_t act_flags;
+	/**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
 	bool external; /**< true if the flow is created external to PMD. */
 	uint8_t ingress; /**< 1 if the flow is ingress. */
 	union {
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 54bd3fd..de27b74 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7409,9 +7409,11 @@ struct field_modify_info modify_tcp[] = {
 			dev_flow->dv.actions[actions_n++] =
 					dev_flow->dv.port_id_action->action;
 			action_flags |= MLX5_FLOW_ACTION_PORT_ID;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_PORT_ID;
 			break;
 		case RTE_FLOW_ACTION_TYPE_FLAG:
 			action_flags |= MLX5_FLOW_ACTION_FLAG;
+			dev_flow->handle->mark = 1;
 			if (dev_conf->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
 				struct rte_flow_action_mark mark = {
 					.id = MLX5_FLOW_MARK_DEFAULT,
@@ -7440,6 +7442,7 @@ struct field_modify_info modify_tcp[] = {
 			break;
 		case RTE_FLOW_ACTION_TYPE_MARK:
 			action_flags |= MLX5_FLOW_ACTION_MARK;
+			dev_flow->handle->mark = 1;
 			if (dev_conf->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
 				const struct rte_flow_action_mark *mark =
 					(const struct rte_flow_action_mark *)
@@ -7484,6 +7487,7 @@ struct field_modify_info modify_tcp[] = {
 			break;
 		case RTE_FLOW_ACTION_TYPE_DROP:
 			action_flags |= MLX5_FLOW_ACTION_DROP;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_DROP;
 			break;
 		case RTE_FLOW_ACTION_TYPE_QUEUE:
 			MLX5_ASSERT(flow->rss.queue);
@@ -7491,6 +7495,7 @@ struct field_modify_info modify_tcp[] = {
 			flow->rss.queue_num = 1;
 			(*flow->rss.queue)[0] = queue->index;
 			action_flags |= MLX5_FLOW_ACTION_QUEUE;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_QUEUE;
 			break;
 		case RTE_FLOW_ACTION_TYPE_RSS:
 			MLX5_ASSERT(flow->rss.queue);
@@ -7507,6 +7512,7 @@ struct field_modify_info modify_tcp[] = {
 			 * when expanding items for RSS.
 			 */
 			action_flags |= MLX5_FLOW_ACTION_RSS;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_QUEUE;
 			break;
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			if (!dev_conf->devx) {
@@ -7664,6 +7670,7 @@ struct field_modify_info modify_tcp[] = {
 			dev_flow->dv.actions[actions_n++] =
 					dev_flow->dv.jump->action;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_JUMP;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
 		case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
@@ -7806,7 +7813,7 @@ struct field_modify_info modify_tcp[] = {
 			modify_action_position = actions_n++;
 	}
 	dev_flow->dv.actions_n = actions_n;
-	handle->act_flags = action_flags;
+	dev_flow->act_flags = action_flags;
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
 		int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
 		int item_type = items->type;
@@ -8062,7 +8069,7 @@ struct field_modify_info modify_tcp[] = {
 		dh = dev_flow->handle;
 		dv_h = &dh->dvh;
 		n = dv->actions_n;
-		if (dh->act_flags & MLX5_FLOW_ACTION_DROP) {
+		if (dh->fate_action == MLX5_FLOW_FATE_DROP) {
 			if (dv->transfer) {
 				dv->actions[n++] = priv->sh->esw_drop_action;
 			} else {
@@ -8085,8 +8092,7 @@ struct field_modify_info modify_tcp[] = {
 				dh->hrxq = UINT32_MAX;
 				dv->actions[n++] = drop_hrxq->action;
 			}
-		} else if (dh->act_flags &
-			   (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)) {
+		} else if (dh->fate_action == MLX5_FLOW_FATE_QUEUE) {
 			struct mlx5_hrxq *hrxq;
 			uint32_t hrxq_idx;
 
@@ -8147,12 +8153,10 @@ struct field_modify_info modify_tcp[] = {
 		       handle_idx, dh, next) {
 		/* hrxq is union, don't clear it if the flag is not set. */
 		if (dh->hrxq) {
-			if (dh->act_flags & MLX5_FLOW_ACTION_DROP) {
+			if (dh->fate_action == MLX5_FLOW_FATE_DROP) {
 				mlx5_hrxq_drop_release(dev);
 				dh->hrxq = 0;
-			} else if (dh->act_flags &
-				  (MLX5_FLOW_ACTION_QUEUE |
-				  MLX5_FLOW_ACTION_RSS)) {
+			} else if (dh->fate_action == MLX5_FLOW_FATE_QUEUE) {
 				mlx5_hrxq_release(dev, dh->hrxq);
 				dh->hrxq = 0;
 			}
@@ -8423,12 +8427,10 @@ struct field_modify_info modify_tcp[] = {
 		}
 		/* hrxq is union, don't touch it only the flag is set. */
 		if (dh->hrxq) {
-			if (dh->act_flags & MLX5_FLOW_ACTION_DROP) {
+			if (dh->fate_action == MLX5_FLOW_FATE_DROP) {
 				mlx5_hrxq_drop_release(dev);
 				dh->hrxq = 0;
-			} else if (dh->act_flags &
-				  (MLX5_FLOW_ACTION_QUEUE |
-				  MLX5_FLOW_ACTION_RSS)) {
+			} else if (dh->fate_action == MLX5_FLOW_FATE_QUEUE) {
 				mlx5_hrxq_release(dev, dh->hrxq);
 				dh->hrxq = 0;
 			}
@@ -8479,9 +8481,9 @@ struct field_modify_info modify_tcp[] = {
 			flow_dv_encap_decap_resource_release(dev, dev_handle);
 		if (dev_handle->dvh.modify_hdr)
 			flow_dv_modify_hdr_resource_release(dev_handle);
-		if (dev_handle->act_flags & MLX5_FLOW_ACTION_JUMP)
+		if (dev_handle->fate_action == MLX5_FLOW_FATE_JUMP)
 			flow_dv_jump_tbl_resource_release(dev, dev_handle);
-		if (dev_handle->act_flags & MLX5_FLOW_ACTION_PORT_ID)
+		if (dev_handle->fate_action == MLX5_FLOW_FATE_PORT_ID)
 			flow_dv_port_id_action_resource_release(dev,
 								dev_handle);
 		if (dev_handle->dvh.push_vlan_res)
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 931d547..1d56b03 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -1589,22 +1589,27 @@
 		case RTE_FLOW_ACTION_TYPE_FLAG:
 			flow_verbs_translate_action_flag(dev_flow, actions);
 			action_flags |= MLX5_FLOW_ACTION_FLAG;
+			dev_flow->handle->mark = 1;
 			break;
 		case RTE_FLOW_ACTION_TYPE_MARK:
 			flow_verbs_translate_action_mark(dev_flow, actions);
 			action_flags |= MLX5_FLOW_ACTION_MARK;
+			dev_flow->handle->mark = 1;
 			break;
 		case RTE_FLOW_ACTION_TYPE_DROP:
 			flow_verbs_translate_action_drop(dev_flow, actions);
 			action_flags |= MLX5_FLOW_ACTION_DROP;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_DROP;
 			break;
 		case RTE_FLOW_ACTION_TYPE_QUEUE:
 			flow_verbs_translate_action_queue(dev_flow, actions);
 			action_flags |= MLX5_FLOW_ACTION_QUEUE;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_QUEUE;
 			break;
 		case RTE_FLOW_ACTION_TYPE_RSS:
 			flow_verbs_translate_action_rss(dev_flow, actions);
 			action_flags |= MLX5_FLOW_ACTION_RSS;
+			dev_flow->handle->fate_action = MLX5_FLOW_FATE_QUEUE;
 			break;
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			ret = flow_verbs_translate_action_count(dev_flow,
@@ -1621,7 +1626,7 @@
 						  "action not supported");
 		}
 	}
-	dev_flow->handle->act_flags = action_flags;
+	dev_flow->act_flags = action_flags;
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
 		int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
 
@@ -1756,12 +1761,11 @@
 		}
 		/* hrxq is union, don't touch it only the flag is set. */
 		if (handle->hrxq) {
-			if (handle->act_flags & MLX5_FLOW_ACTION_DROP) {
+			if (handle->fate_action == MLX5_FLOW_FATE_DROP) {
 				mlx5_hrxq_drop_release(dev);
 				handle->hrxq = 0;
-			} else if (handle->act_flags &
-				  (MLX5_FLOW_ACTION_QUEUE |
-				  MLX5_FLOW_ACTION_RSS)) {
+			} else if (handle->fate_action ==
+				   MLX5_FLOW_FATE_QUEUE) {
 				mlx5_hrxq_release(dev, handle->hrxq);
 				handle->hrxq = 0;
 			}
@@ -1833,7 +1837,7 @@
 	for (idx = priv->flow_idx - 1; idx >= priv->flow_nested_idx; idx--) {
 		dev_flow = &((struct mlx5_flow *)priv->inter_flows)[idx];
 		handle = dev_flow->handle;
-		if (handle->act_flags & MLX5_FLOW_ACTION_DROP) {
+		if (handle->fate_action == MLX5_FLOW_FATE_DROP) {
 			hrxq = mlx5_hrxq_drop_new(dev);
 			if (!hrxq) {
 				rte_flow_error_set
@@ -1898,12 +1902,11 @@
 		       dev_handles, handle, next) {
 		/* hrxq is union, don't touch it only the flag is set. */
 		if (handle->hrxq) {
-			if (handle->act_flags & MLX5_FLOW_ACTION_DROP) {
+			if (handle->fate_action == MLX5_FLOW_FATE_DROP) {
 				mlx5_hrxq_drop_release(dev);
 				handle->hrxq = 0;
-			} else if (handle->act_flags &
-				  (MLX5_FLOW_ACTION_QUEUE |
-				  MLX5_FLOW_ACTION_RSS)) {
+			} else if (handle->fate_action ==
+				   MLX5_FLOW_FATE_QUEUE) {
 				mlx5_hrxq_release(dev, handle->hrxq);
 				handle->hrxq = 0;
 			}
-- 
1.8.3.1


  parent reply	other threads:[~2020-04-15  6:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  6:39 [dpdk-dev] [PATCH 00/10] net/mlx5: optimize flow structure Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 01/10] net/mlx5: reorganize fate actions as union Suanming Mou
2020-04-15  6:39 ` Suanming Mou [this message]
2020-04-15  6:39 ` [dpdk-dev] [PATCH 03/10] net/mlx5: reorganize the mlx5 flow handle struct Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 04/10] net/mlx5: optimize mlx5 flow RSS struct Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 05/10] net/mlx5: allocate rte flow from indexed pool Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 06/10] net/mlx5: optimize flow meter handle type Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 07/10] net/mlx5: allocate meter from indexed pool Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 08/10] net/mlx5: allocate metadata object " Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 09/10] net/mlx5: optimize flow director filter memory Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 10/10] net/mlx5: reorganize rte flow structure Suanming Mou

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=1586932797-99533-3-git-send-email-suanmingm@mellanox.com \
    --to=suanmingm@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=viacheslavo@mellanox.com \
    --cc=wentaoc@mellanox.com \
    /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).