[v2,3/6] net/mlx5: flow type check before creating
diff mbox series

Message ID 1580816002-159035-4-git-send-email-bingz@mellanox.com
State New
Delegated to: Raslan Darawsheh
Headers show
Series
  • net/mlx5: move to non-cached mode for flow rules
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Bing Zhao Feb. 4, 2020, 11:33 a.m. UTC
When creating a flow, the driver mode needs to be checked in order
to call the corresponding functions. Now the driver mode checking
part is moved out of the flow creating function, then the flow could
be added into the correct tailq list.

Signed-off-by: Bing Zhao <bingz@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 0560874..8fb973b 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2874,8 +2874,8 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 flow_list_create(struct rte_eth_dev *dev, struct mlx5_flows *list,
 		 const struct rte_flow_attr *attr,
 		 const struct rte_flow_item items[],
-		 const struct rte_flow_action actions[],
-		 bool external, struct rte_flow_error *error);
+		 const struct rte_flow_action actions[], bool external,
+		 enum mlx5_flow_drv_type type, struct rte_flow_error *error);
 
 static void
 flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list,
@@ -3015,7 +3015,8 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	 * by list traversing.
 	 */
 	mcp_res->flow = flow_list_create(dev, NULL, &attr, items,
-					 actions, false, error);
+					 actions, false,
+					 flow_get_drv_type(dev, &attr), error);
 	if (!mcp_res->flow)
 		goto error;
 	mcp_res->refcnt++;
@@ -4119,6 +4120,8 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
  *   Associated actions (list terminated by the END action).
  * @param[in] external
  *   This flow rule is created by request external to PMD.
+ * @param[in] type
+ *   Flow rule type, DV or VERBS.
  * @param[out] error
  *   Perform verbose error reporting if not NULL.
  *
@@ -4129,8 +4132,8 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 flow_list_create(struct rte_eth_dev *dev, struct mlx5_flows *list,
 		 const struct rte_flow_attr *attr,
 		 const struct rte_flow_item items[],
-		 const struct rte_flow_action actions[],
-		 bool external, struct rte_flow_error *error)
+		 const struct rte_flow_action actions[], bool external,
+		 enum mlx5_flow_drv_type type, struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct rte_flow *flow = NULL;
@@ -4188,7 +4191,7 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 		rte_errno = ENOMEM;
 		goto error_before_flow;
 	}
-	flow->drv_type = flow_get_drv_type(dev, attr);
+	flow->drv_type = type;
 	if (hairpin_id != 0)
 		flow->hairpin_flow_id = hairpin_id;
 	MLX5_ASSERT(flow->drv_type > MLX5_FLOW_TYPE_MIN &&
@@ -4339,7 +4342,8 @@  struct rte_flow *
 	struct rte_flow_error error;
 
 	return flow_list_create(dev, &priv->ctrl_flows, &attr, &pattern,
-				actions, false, &error);
+				actions, false,
+				flow_get_drv_type(dev, &attr), &error);
 }
 
 /**
@@ -4356,9 +4360,13 @@  struct rte_flow *
 		 struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_flows *flow_list;
+	enum mlx5_flow_drv_type type = flow_get_drv_type(dev, attr);
 
-	return flow_list_create(dev, &priv->noncached_flows,
-				attr, items, actions, true, error);
+	flow_list = (type == MLX5_FLOW_TYPE_DV) ? &priv->noncached_flows :
+						  &priv->cached_flows;
+	return flow_list_create(dev, flow_list, attr,
+				items, actions, true, type, error);
 }
 
 /**
@@ -4548,8 +4556,8 @@  struct rte_flow *
 	actions[0].type = RTE_FLOW_ACTION_TYPE_JUMP;
 	actions[0].conf = &jump;
 	actions[1].type = RTE_FLOW_ACTION_TYPE_END;
-	flow = flow_list_create(dev, &priv->ctrl_flows,
-				&attr, items, actions, false, &error);
+	flow = flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions,
+				false, flow_get_drv_type(dev, &attr), &error);
 	if (!flow) {
 		DRV_LOG(DEBUG,
 			"Failed to create ctrl flow: rte_errno(%d),"
@@ -4636,8 +4644,8 @@  struct rte_flow *
 	}
 	for (i = 0; i != priv->reta_idx_n; ++i)
 		queue[i] = (*priv->reta_idx)[i];
-	flow = flow_list_create(dev, &priv->ctrl_flows,
-				&attr, items, actions, false, &error);
+	flow = flow_list_create(dev, &priv->ctrl_flows, &attr, items, actions,
+				false, flow_get_drv_type(dev, &attr), &error);
 	if (!flow)
 		return -rte_errno;
 	return 0;
@@ -5078,7 +5086,7 @@  struct rte_flow *
 	}
 	flow = flow_list_create(dev, &priv->noncached_flows, &fdir_flow->attr,
 				fdir_flow->items, fdir_flow->actions, true,
-				NULL);
+				flow_get_drv_type(dev, &fdir_flow->attr), NULL);
 	if (!flow)
 		goto error;
 	MLX5_ASSERT(!flow->fdir);
@@ -5695,8 +5703,8 @@  struct mlx5_flow_counter *
 		if (!config->dv_flow_en)
 			break;
 		/* Create internal flow, validation skips copy action. */
-		flow = flow_list_create(dev, NULL, &attr, items,
-					actions, false, &error);
+		flow = flow_list_create(dev, NULL, &attr, items, actions, false,
+					flow_get_drv_type(dev, &attr), &error);
 		if (!flow)
 			continue;
 		if (dev->data->dev_started || !flow_drv_apply(dev, flow, NULL))