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 40714A058A; Tue, 24 Mar 2020 16:35:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1BA6C1C07D; Tue, 24 Mar 2020 16:34:20 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id B28951C029 for ; Tue, 24 Mar 2020 16:34:16 +0100 (CET) From: Bing Zhao To: orika@mellanox.com, rasland@mellanox.com, matan@mellanox.com Cc: viacheslavo@mellanox.com, dev@dpdk.org Date: Tue, 24 Mar 2020 15:34:00 +0000 Message-Id: <1585064040-28201-5-git-send-email-bingz@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1585064040-28201-1-git-send-email-bingz@mellanox.com> References: <1580816002-159035-1-git-send-email-bingz@mellanox.com> <1585064040-28201-1-git-send-email-bingz@mellanox.com> Subject: [dpdk-dev] [PATCH v4 4/4] net/mlx5: check device stat before creating flow 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" By default, flows are categorized into two types of a mlx5 device. 1. The PMD driver will create some default flows to enable the traffic and give some default behaviors on the packets. And this is transparent to the upper layer application. 2. Other flows will be created in the application based on its needs. When in the old cached mode for application flows, it is allowed to created the flow before the device is started. And when starting the device, all the flows will be applied to the hardware and take effect. The cached flows will be also applied in the same time. In non-cached mode, all the flows will never be cached when stopping a device. So it makes no sense to insert any flow into the device before it is started. Default flows owned by PMD driver are not affected in this case. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f2d3730..6438a14 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4328,7 +4328,11 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, if (ret) goto error; } - if (dev->data->dev_started) { + /* + * If the flow is external (from application) OR device is started, then + * the flow will be applied immediately. + */ + if (external || dev->data->dev_started) { ret = flow_drv_apply(dev, flow, error); if (ret < 0) goto error; @@ -4420,6 +4424,17 @@ struct rte_flow * { struct mlx5_priv *priv = dev->data->dev_private; + /* + * If the device is not started yet, it is not allowed to created a + * flow from application. PMD default flows and traffic control flows + * are not affected. + */ + if (unlikely(!dev->data->dev_started)) { + rte_errno = ENODEV; + DRV_LOG(DEBUG, "port %u is not started when " + "inserting a flow", dev->data->port_id); + return NULL; + } return flow_list_create(dev, &priv->flows, attr, items, actions, true, error); } -- 1.8.3.1