From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0CE543C06; Tue, 27 Feb 2024 14:53:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 83FE34027D; Tue, 27 Feb 2024 14:53:15 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) by mails.dpdk.org (Postfix) with ESMTP id BF9F542EA9 for ; Tue, 27 Feb 2024 14:53:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cN/cLdGhDNkzy5fie3heSLKrEMFBLmFizKReepTgMb9p/S2d4DfZzSVlpxnaVXDfRBUy+8LTjrir9xS5Rm552G7rHovUF6GikcyBuK6dpd8ATgsKMD5Yx1PiJgj79/DpSMPQd6i7w3T/R0ouhijJlYsI5zI+J3ACVM2wHZRmM6waaWbPzsVDvI6ow/n727A6wNLU7iURPfhFpULrWGpmv5zKJ1WUf0d6nHT5W1rAzgN27NXPZCDx2ef3xtdd7ZjG1wxzDSfg/kG4TZfXPg01COoExvMQASI7y5XJul2uXen0FNVFdLIqPklsclyaSrUn0ZkMOgZz44/JZ9iLG/0kKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QozT0Uguifebe8HfZ8MOt62Tg7yITdz/HSa/zSFzjTc=; b=oANU1KeSL7zOmaV4jcFHaJfB8m9wpcQ+BOgREnlt3DrSTbGNwuBP1UIKszL5j/dNGAWUvN5YbqEtoUeHYT4WyMB56EFfT22S6S0bolmXi+78Xj0c9Hotrd75UwDf31t3wP0SMTvfzjm0Js2VLATkeaAvMEugVjwWI8jHFssQH0Lv8m95n18PmvLK65aDanSWRk8ovC+eANy4ZOys2HDFJT+6TGlD3p7H7cnMs+3qus8552BhVLQrBfu2P8R7YGEBt9bXswvN/CQzM7+U3ARtqBMZMF95BeEoTvOKrki8xLXY0ddvYv6/u8VcHozOfRhF6SPINAcQ69f9ubhW7jD0SA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QozT0Uguifebe8HfZ8MOt62Tg7yITdz/HSa/zSFzjTc=; b=j/SeE5Au9gEKe8hRJPVGLgACBJLz6alLdNjfr3KIwPBvOWJqLHnWq6IELqtAbzvWmRkZsgS7LuMrLzr14kOE9lK6SrZEn0MV4f6ULy8YoQBy9C3GHJsuRy7HXzZS6WfiVzhLe1G87w2dnv4b0xV/1FofQfVTdJGO0Ibs4EL2aPnjBCumBVtlnzaG/LgCFrIvMo7bKpPglhm4NEmnCMqfm7RjzoIslvZwtdUn/SNkTWD9Hq7pY4f9BIenBqoP/OWZKfpGNpVETTubqnw7pATP/w5bLQUst4AlD5Q6hi+npU45eKodRUUO5EdqlkpF22MOdQnUc2RnirIVBoZ8oF59nA== Received: from SJ0P220CA0005.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::12) by DS7PR12MB6263.namprd12.prod.outlook.com (2603:10b6:8:95::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.31; Tue, 27 Feb 2024 13:53:09 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:a03:41b:cafe::be) by SJ0P220CA0005.outlook.office365.com (2603:10b6:a03:41b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.50 via Frontend Transport; Tue, 27 Feb 2024 13:53:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 27 Feb 2024 13:53:09 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 27 Feb 2024 05:52:48 -0800 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 27 Feb 2024 05:52:45 -0800 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 3/4] net/mlx5: add cross port CT object sharing Date: Tue, 27 Feb 2024 15:52:23 +0200 Message-ID: <20240227135224.20066-4-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240227135224.20066-1-dsosnowski@nvidia.com> References: <20240223142320.49470-1-dsosnowski@nvidia.com> <20240227135224.20066-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CC:EE_|DS7PR12MB6263:EE_ X-MS-Office365-Filtering-Correlation-Id: 24021e30-cdb3-46f3-30d9-08dc379b6e89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +eWiJ4MprUUHPy1bWDG6UfsjGu1LFYAGllCt54y08leG0r/gJlcV6C92eXTV5nJ0TtDLbjvUpWZziVLk2JoKy8S2UpS7lr0CxBTqiVR+EsNm7U8O+KnehANf+jcm0W83sDTdvrCyOPqUYd4I96Z77fOwcout5UlvRFb5b+AAYo52JG1dhLQ3hU8acXhPocYnEV4ZzJlqK2RY4fAQEmzoWPXCzwvq4IaubpBuiUZiWzKLXKaGfTORn7gi7FVcWPHwMG102eDYc81hgRAAjic5WdCM0Lt9UZIHtcQsuWhWeeIuA36LHaVFc32WoQVBMkEJ3zh/RNpVCWhp54elYcGf9jpQ40T4GmAAFiMbtGGvf97w2SMEwGQBwTg6kLdwQvfqkd0sjdAOTWVK94OS/TKXbbloag2ULIztKZDtPG9VwX3982udDhsyLg7SocWIeL8OjYkDFo5jMbg+sIBecHdLWM9KiamfMJhDxn4fIPWL8E4LoZ4luHcq9ftgGxE922s/afyQEXjemZ74hP4v2p7Oq0xqz8SBlfqV0IWPyhHlTptyH/qFq5PdYbr76fkf70gQkTINbV8aAg2jFfiEMRuNtmLSvjxjjZdgI2NXTFMrqKNLDBkU8bQGQADX2H1HjHiI+60oFf08q3f05sNGcBBsghZx9EtlAJSWIiFQmeCwhVIwXMGORR5ncSV9CgIAn2jFaIsCLYiBYqojpNP0DM0XsU/85kYfwpklNgQ4GMdzypv6R8q1zxfmQrIo/ZnR3M+z X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(82310400014)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 13:53:09.1211 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24021e30-cdb3-46f3-30d9-08dc379b6e89 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6263 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Suanming Mou This commit adds cross port CT object sharing. Shared CT object shares the same DevX objects, but allocate port's own action locally. Once the CT object is shared between two flows in different ports, the two flows use their own local action with the same offset index. The shared CT object can only be created/updated/queried/destroyed by host port. Signed-off-by: Suanming Mou Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- doc/guides/rel_notes/release_24_03.rst | 2 + drivers/net/mlx5/mlx5_flow_hw.c | 143 ++++++++++++++----------- 2 files changed, 83 insertions(+), 62 deletions(-) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 76d2e60f59..23ac6568ac 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -135,6 +135,8 @@ New Features * Added support for copy inner fields in HWS flow engine. * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_METER_MARK`` in HWS flow engine. + * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_CONNTRACK`` + with HW steering flow engine. * **Updated Marvell cnxk crypto driver.** diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index a8e2c9cc9e..2550e0604f 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -564,7 +564,7 @@ flow_hw_ct_compile(struct rte_eth_dev *dev, struct mlx5_aso_ct_action *ct; ct = mlx5_ipool_get(priv->hws_ctpool->cts, MLX5_ACTION_CTX_CT_GET_IDX(idx)); - if (!ct || mlx5_aso_ct_available(priv->sh, queue, ct)) + if (!ct || (!priv->shared_host && mlx5_aso_ct_available(priv->sh, queue, ct))) return -1; rule_act->action = priv->hws_ctpool->dr_action; rule_act->aso_ct.offset = ct->offset; @@ -3845,10 +3845,10 @@ __flow_hw_pull_indir_action_comp(struct rte_eth_dev *dev, if (ret_comp < n_res && priv->hws_mpool) ret_comp += mlx5_aso_pull_completion(&priv->hws_mpool->sq[queue], &res[ret_comp], n_res - ret_comp); + if (ret_comp < n_res && priv->hws_ctpool) + ret_comp += mlx5_aso_pull_completion(&priv->ct_mng->aso_sqs[queue], + &res[ret_comp], n_res - ret_comp); } - if (ret_comp < n_res && priv->hws_ctpool) - ret_comp += mlx5_aso_pull_completion(&priv->ct_mng->aso_sqs[queue], - &res[ret_comp], n_res - ret_comp); if (ret_comp < n_res && priv->quota_ctx.sq) ret_comp += mlx5_aso_pull_completion(&priv->quota_ctx.sq[queue], &res[ret_comp], @@ -9027,15 +9027,19 @@ flow_hw_ct_mng_destroy(struct rte_eth_dev *dev, } static void -flow_hw_ct_pool_destroy(struct rte_eth_dev *dev __rte_unused, +flow_hw_ct_pool_destroy(struct rte_eth_dev *dev, struct mlx5_aso_ct_pool *pool) { + struct mlx5_priv *priv = dev->data->dev_private; + if (pool->dr_action) mlx5dr_action_destroy(pool->dr_action); - if (pool->devx_obj) - claim_zero(mlx5_devx_cmd_destroy(pool->devx_obj)); - if (pool->cts) - mlx5_ipool_destroy(pool->cts); + if (!priv->shared_host) { + if (pool->devx_obj) + claim_zero(mlx5_devx_cmd_destroy(pool->devx_obj)); + if (pool->cts) + mlx5_ipool_destroy(pool->cts); + } mlx5_free(pool); } @@ -9059,51 +9063,56 @@ flow_hw_ct_pool_create(struct rte_eth_dev *dev, .type = "mlx5_hw_ct_action", }; int reg_id; - uint32_t flags; + uint32_t flags = 0; - if (port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) { - DRV_LOG(ERR, "Connection tracking is not supported " - "in cross vHCA sharing mode"); - rte_errno = ENOTSUP; - return NULL; - } pool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pool), 0, SOCKET_ID_ANY); if (!pool) { rte_errno = ENOMEM; return NULL; } - obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx, - priv->sh->cdev->pdn, - log_obj_size); - if (!obj) { - rte_errno = ENODATA; - DRV_LOG(ERR, "Failed to create conn_track_offload_obj using DevX."); - goto err; + if (!priv->shared_host) { + /* + * No need for local cache if CT number is a small number. Since + * flow insertion rate will be very limited in that case. Here let's + * set the number to less than default trunk size 4K. + */ + if (nb_cts <= cfg.trunk_size) { + cfg.per_core_cache = 0; + cfg.trunk_size = nb_cts; + } else if (nb_cts <= MLX5_HW_IPOOL_SIZE_THRESHOLD) { + cfg.per_core_cache = MLX5_HW_IPOOL_CACHE_MIN; + } + cfg.max_idx = nb_cts; + pool->cts = mlx5_ipool_create(&cfg); + if (!pool->cts) + goto err; + obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx, + priv->sh->cdev->pdn, + log_obj_size); + if (!obj) { + rte_errno = ENODATA; + DRV_LOG(ERR, "Failed to create conn_track_offload_obj using DevX."); + goto err; + } + pool->devx_obj = obj; + } else { + struct rte_eth_dev *host_dev = priv->shared_host; + struct mlx5_priv *host_priv = host_dev->data->dev_private; + + pool->devx_obj = host_priv->hws_ctpool->devx_obj; + pool->cts = host_priv->hws_ctpool->cts; + MLX5_ASSERT(pool->cts); + MLX5_ASSERT(!port_attr->nb_conn_tracks); } - pool->devx_obj = obj; reg_id = mlx5_flow_get_reg_id(dev, MLX5_ASO_CONNTRACK, 0, NULL); - flags = MLX5DR_ACTION_FLAG_HWS_RX | MLX5DR_ACTION_FLAG_HWS_TX; + flags |= MLX5DR_ACTION_FLAG_HWS_RX | MLX5DR_ACTION_FLAG_HWS_TX; if (priv->sh->config.dv_esw_en && priv->master) flags |= MLX5DR_ACTION_FLAG_HWS_FDB; pool->dr_action = mlx5dr_action_create_aso_ct(priv->dr_ctx, - (struct mlx5dr_devx_obj *)obj, + (struct mlx5dr_devx_obj *)pool->devx_obj, reg_id - REG_C_0, flags); if (!pool->dr_action) goto err; - /* - * No need for local cache if CT number is a small number. Since - * flow insertion rate will be very limited in that case. Here let's - * set the number to less than default trunk size 4K. - */ - if (nb_cts <= cfg.trunk_size) { - cfg.per_core_cache = 0; - cfg.trunk_size = nb_cts; - } else if (nb_cts <= MLX5_HW_IPOOL_SIZE_THRESHOLD) { - cfg.per_core_cache = MLX5_HW_IPOOL_CACHE_MIN; - } - pool->cts = mlx5_ipool_create(&cfg); - if (!pool->cts) - goto err; pool->sq = priv->ct_mng->aso_sqs; /* Assign the last extra ASO SQ as public SQ. */ pool->shared_sq = &priv->ct_mng->aso_sqs[priv->nb_queue - 1]; @@ -9980,14 +9989,16 @@ flow_hw_configure(struct rte_eth_dev *dev, if (!priv->shared_host) flow_hw_create_send_to_kernel_actions(priv); if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) { - mem_size = sizeof(struct mlx5_aso_sq) * nb_q_updated + - sizeof(*priv->ct_mng); - priv->ct_mng = mlx5_malloc(MLX5_MEM_ZERO, mem_size, - RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); - if (!priv->ct_mng) - goto err; - if (mlx5_aso_ct_queue_init(priv->sh, priv->ct_mng, nb_q_updated)) - goto err; + if (!priv->shared_host) { + mem_size = sizeof(struct mlx5_aso_sq) * nb_q_updated + + sizeof(*priv->ct_mng); + priv->ct_mng = mlx5_malloc(MLX5_MEM_ZERO, mem_size, + RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); + if (!priv->ct_mng) + goto err; + if (mlx5_aso_ct_queue_init(priv->sh, priv->ct_mng, nb_q_updated)) + goto err; + } priv->hws_ctpool = flow_hw_ct_pool_create(dev, port_attr); if (!priv->hws_ctpool) goto err; @@ -10210,17 +10221,20 @@ flow_hw_clear_port_info(struct rte_eth_dev *dev) } static int -flow_hw_conntrack_destroy(struct rte_eth_dev *dev __rte_unused, +flow_hw_conntrack_destroy(struct rte_eth_dev *dev, uint32_t idx, struct rte_flow_error *error) { - uint16_t owner = (uint16_t)MLX5_ACTION_CTX_CT_GET_OWNER(idx); uint32_t ct_idx = MLX5_ACTION_CTX_CT_GET_IDX(idx); - struct rte_eth_dev *owndev = &rte_eth_devices[owner]; - struct mlx5_priv *priv = owndev->data->dev_private; + struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_aso_ct_pool *pool = priv->hws_ctpool; struct mlx5_aso_ct_action *ct; + if (priv->shared_host) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "CT destruction is not allowed to guest port"); ct = mlx5_ipool_get(pool->cts, ct_idx); if (!ct) { return rte_flow_error_set(error, EINVAL, @@ -10243,14 +10257,13 @@ flow_hw_conntrack_query(struct rte_eth_dev *dev, uint32_t queue, uint32_t idx, struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_aso_ct_pool *pool = priv->hws_ctpool; struct mlx5_aso_ct_action *ct; - uint16_t owner = (uint16_t)MLX5_ACTION_CTX_CT_GET_OWNER(idx); uint32_t ct_idx; - if (owner != PORT_ID(priv)) - return rte_flow_error_set(error, EACCES, + if (priv->shared_host) + return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Can't query CT object owned by another port"); + "CT query is not allowed to guest port"); ct_idx = MLX5_ACTION_CTX_CT_GET_IDX(idx); ct = mlx5_ipool_get(pool->cts, ct_idx); if (!ct) { @@ -10280,15 +10293,14 @@ flow_hw_conntrack_update(struct rte_eth_dev *dev, uint32_t queue, struct mlx5_aso_ct_pool *pool = priv->hws_ctpool; struct mlx5_aso_ct_action *ct; const struct rte_flow_action_conntrack *new_prf; - uint16_t owner = (uint16_t)MLX5_ACTION_CTX_CT_GET_OWNER(idx); uint32_t ct_idx; int ret = 0; - if (PORT_ID(priv) != owner) - return rte_flow_error_set(error, EACCES, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "Can't update CT object owned by another port"); + if (priv->shared_host) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "CT update is not allowed to guest port"); ct_idx = MLX5_ACTION_CTX_CT_GET_IDX(idx); ct = mlx5_ipool_get(pool->cts, ct_idx); if (!ct) { @@ -10338,6 +10350,13 @@ flow_hw_conntrack_create(struct rte_eth_dev *dev, uint32_t queue, int ret; bool async = !!(queue != MLX5_HW_INV_QUEUE); + if (priv->shared_host) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "CT create is not allowed to guest port"); + return NULL; + } if (!pool) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, -- 2.25.1