From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 75B95A0532; Tue, 4 Feb 2020 12:34:04 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 58B931C1A8; Tue, 4 Feb 2020 12:33:42 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 7A6401C139 for ; Tue, 4 Feb 2020 12:33:40 +0100 (CET) From: Bing Zhao To: orika@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com, matan@mellanox.com Cc: dev@dpdk.org Date: Tue, 4 Feb 2020 13:33:19 +0200 Message-Id: <1580816002-159035-4-git-send-email-bingz@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1580816002-159035-1-git-send-email-bingz@mellanox.com> References: <1580736735-19472-1-git-send-email-bingz@mellanox.com> <1580816002-159035-1-git-send-email-bingz@mellanox.com> Subject: [dpdk-dev] [PATCH v2 3/6] net/mlx5: flow type check before creating X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/mlx5/mlx5_flow.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) 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)) -- 1.8.3.1