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 AB165A04E0; Wed, 27 Nov 2019 10:59:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EDC7858C3; Wed, 27 Nov 2019 10:59:49 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 183425596 for ; Wed, 27 Nov 2019 10:59:49 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 27 Nov 2019 11:59:47 +0200 Received: from pegasus11.mtr.labs.mlnx (pegasus11.mtr.labs.mlnx [10.210.16.104]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xAR9xlV9017444; Wed, 27 Nov 2019 11:59:47 +0200 Received: from pegasus11.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id xAR9xlwe031599; Wed, 27 Nov 2019 09:59:47 GMT Received: (from viacheslavo@localhost) by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id xAR9xlpS031598; Wed, 27 Nov 2019 09:59:47 GMT X-Authentication-Warning: pegasus11.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: matan@mellanox.com, rasland@mellanox.com, orika@mellanox.com Date: Wed, 27 Nov 2019 09:59:45 +0000 Message-Id: <1574848785-31552-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix default mark copy 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" In extensive metadata mode the MARK copy table is engaged, if the application creates the flow with zero MARK ID action: flow create 1 ingress pattern eth / ... / end actions mark id 0 / .. end And then destroys that, the traffic to the port stops. This happens due to default flow for the copy table has the zero ID and is removed with the application rule. The patch extends internal ID variable to 64 bits and provide the UINT64_MAX ID for the copy table default rule. Fixes: dd3c774f6ffb ("net/mlx5: add metadata register copy table") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_defs.h | 1 + drivers/net/mlx5/mlx5_flow.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index 9e113c5..a577ad8 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -174,6 +174,7 @@ /* Size of the simple hash table for metadata register table. */ #define MLX5_FLOW_MREG_HTABLE_SZ 4096 #define MLX5_FLOW_MREG_HNAME "MARK_COPY_TABLE" +#define MLX5_DEFAULT_COPY_ID UINT64_MAX /* Definition of static_assert found in /usr/include/assert.h */ #ifndef HAVE_STATIC_ASSERT diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 5c78ea7..f464d01 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2903,7 +2903,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, * Associated resource on success, NULL otherwise and rte_errno is set. */ static struct mlx5_flow_mreg_copy_resource * -flow_mreg_add_copy_action(struct rte_eth_dev *dev, uint32_t mark_id, +flow_mreg_add_copy_action(struct rte_eth_dev *dev, uint64_t mark_id, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; @@ -2912,13 +2912,13 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, .ingress = 1, }; struct mlx5_rte_flow_item_tag tag_spec = { - .data = mark_id, + .data = (uint32_t)(mark_id & UINT32_MAX), }; struct rte_flow_item items[] = { [1] = { .type = RTE_FLOW_ITEM_TYPE_END, }, }; struct rte_flow_action_mark ftag = { - .id = mark_id, + .id = (uint32_t)(mark_id & UINT32_MAX), }; struct mlx5_flow_action_copy_mreg cp_mreg = { .dst = REG_B, @@ -2947,16 +2947,16 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, mcp_res = (void *)mlx5_hlist_lookup(priv->mreg_cp_tbl, mark_id); if (mcp_res) { /* For non-default rule. */ - if (mark_id) + if (mark_id != MLX5_DEFAULT_COPY_ID) mcp_res->refcnt++; - assert(mark_id || mcp_res->refcnt == 1); + assert(mark_id != MLX5_DEFAULT_COPY_ID || mcp_res->refcnt == 1); return mcp_res; } /* Provide the full width of FLAG specific value. */ if (mark_id == (priv->sh->dv_regc0_mask & MLX5_FLOW_MARK_DEFAULT)) tag_spec.data = MLX5_FLOW_MARK_DEFAULT; /* Build a new flow. */ - if (mark_id) { + if (mark_id != MLX5_DEFAULT_COPY_ID) { items[0] = (struct rte_flow_item){ .type = MLX5_RTE_FLOW_ITEM_TYPE_TAG, .spec = &tag_spec, @@ -3054,7 +3054,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, } /* * We do not check availability of metadata registers here, - * because copy resources are allocated in this case. + * because copy resources are not allocated in this case. */ if (--mcp_res->refcnt) return; @@ -3133,7 +3133,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, /* Check if default flow is registered. */ if (!priv->mreg_cp_tbl) return; - mcp_res = (void *)mlx5_hlist_lookup(priv->mreg_cp_tbl, 0ULL); + mcp_res = (void *)mlx5_hlist_lookup(priv->mreg_cp_tbl, + MLX5_DEFAULT_COPY_ID); if (!mcp_res) return; assert(mcp_res->flow); @@ -3166,7 +3167,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, !mlx5_flow_ext_mreg_supported(dev) || !priv->sh->dv_regc0_mask) return 0; - mcp_res = flow_mreg_add_copy_action(dev, 0, error); + mcp_res = flow_mreg_add_copy_action(dev, MLX5_DEFAULT_COPY_ID, error); if (!mcp_res) return -rte_errno; return 0; -- 1.8.3.1