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 08E5443BA9; Fri, 23 Feb 2024 15:24:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35D7742D26; Fri, 23 Feb 2024 15:24:13 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2052.outbound.protection.outlook.com [40.107.244.52]) by mails.dpdk.org (Postfix) with ESMTP id AA1104281D for ; Fri, 23 Feb 2024 15:24:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c6II/6WNJceiBIwxuoeR+NWFtawy1h0AyYEAf8fYKvrgk1SOEqaPgqmETVgMDpI1mwm6rOhJ3/XlHt1/f8NnjaEeY+zYT3V7E8KO/lffILCQ6ShKTohY1sy6xdAeieL6rVm1glMKgchuPUyvkc/LNUDyWt1rlja3VwaVI3PE1O9HWFXdOAF4v2zrtrHesl9S7Fx1a1kjCp+7bnIM6vr5A2ZmdM4K+R4sylD+9wdB9TRATM5HGoWYhpQ1iJLA0SPWFzu/1T+MzTGOFf3p8fgeBBBg1CcA6Fe3Dvh8M5LcpS0niG/Am+tWPc88xlAfsk7i0A1CzeNsL9fpd+2m6TdBmw== 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=dAirZCofblIwXLu/3zZuf1fT0Tc2O9120q7779IRhVE=; b=O8cJ662VNq3pulnkqaozIBdOwjZdiQWmbLkSdyE4s+X54DeUCMvbl91oKkENu56wTgLB44JKnh2U5d5/8G198+9OHkAjNlTnzKyWWXMeT8mcDWoNMzH2tenDIANklLOfrTZJUDPJbd7F/1nV+YhGOet5PV94x6OD3VhzllG9VTXMsECxvr5+XAROMRUDjrrv74joO0koaxwtmIPm6urOcISXFugB118907Ws1MK5csVITNkBaneMgYH28CanTRrv6/cZ5kbEjRjl+SPcQwR/gdHkWJjxMXlmqPPUpllLUNWtjznzJDvxGi16pnzav6Tz4prm9BaUfX+hxvxoJUQY3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=dAirZCofblIwXLu/3zZuf1fT0Tc2O9120q7779IRhVE=; b=hYLM6h91YscZMlNN0HH3lhXM+sRGUL073UIj3ifGHoWBPScVo1gi9yIppeFcscKw7S8b56V63M/fIcWsR3HTykMJo4ub6TYLM6xldMm3TxghPYO8puQ52P9fA7rgoCnXQUliKSh4Xc6Hha8z2WdS5/0IRlkmxXY5Q2vTPpOfswRQC17vpMXcZTfv5l5vi+dvUPcQUJzzAQ/B/548WT2zSRlwVH43I1OcdkGdKlE7S58iiYOD828aSYBLN4eYPdxPWe/lIzCBwjxcwJ1ounkf0/2WorbngovoJ6P7hd4ZLHO0vQBJmSTU1ITnQ/K5TzQBK3vw6sOzL5UtfHo/sjqMUQ== Received: from PH8PR20CA0016.namprd20.prod.outlook.com (2603:10b6:510:23c::20) by BN9PR12MB5196.namprd12.prod.outlook.com (2603:10b6:408:11d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 14:24:07 +0000 Received: from SN1PEPF000252A4.namprd05.prod.outlook.com (2603:10b6:510:23c:cafe::8d) by PH8PR20CA0016.outlook.office365.com (2603:10b6:510:23c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.43 via Frontend Transport; Fri, 23 Feb 2024 14:24:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF000252A4.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Fri, 23 Feb 2024 14:24:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 23 Feb 2024 06:23:46 -0800 Received: from nvidia.com (10.126.231.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; Fri, 23 Feb 2024 06:23:41 -0800 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 3/4] net/mlx5: add cross port CT object sharing Date: Fri, 23 Feb 2024 16:23:19 +0200 Message-ID: <20240223142320.49470-4-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223142320.49470-1-dsosnowski@nvidia.com> References: <20240221100145.8234-1-dsosnowski@nvidia.com> <20240223142320.49470-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.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: SN1PEPF000252A4:EE_|BN9PR12MB5196:EE_ X-MS-Office365-Filtering-Correlation-Id: b2be1cde-860f-448a-490f-08dc347b17b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5ZXxSFx/6RIDGEg4IXGY1FYjgYV8mPeFtHph00TEDFV4ncEc9EJperYMoNF1sWUpWz6JRvLY/0gLamELUuCN1z8FAljuekAZ0CWXgVZDAZtSHk8q1yeHgOUwX6/Xy0J9d23TK5++AkH6BryznOQ/VieVAqqt/paBxT5RCWIdVAs2G7IJesQUoJgDMiDs1tX/OOy79uHBW8etvJVsVNP6fkoqiQp1yAxh5i+JvJCle96ezUdkg5ETrhWNgCthL5q2A9UdXtbJdxOC99Mp2ZWDbsBOfzn4SOVIMxn5RUNy8zwLXtenz/aQan/98liO2RiTpW3fz4IREPb1uWKHFKGCAsZsIKJ4/4qhTxMqzs3l+C9cxcLJh8gHIONQprK4Qm8Ep51lQfM0R9WTpbmRA4KErgypxg6nX1oSlCdVxs7Aj5MVAqCY+fWMVEePdTU8CRTCkwRsoX7LAd5aOOg1ZFCfMeVWAzPGVxrkRw5oAylzpD6PqVSJACUcNxtwZoFUKfRSiCQX2YCX7dLu5Y6Ar0RrD/HqWYccLOS54/GVRcq+CXBfj2f053wKnZPtBP27J2aMpaF5AUjr6hgK59nFnAxpiMegduBZ/qR/NxpCKewcps1vlL3Dv8h+c+WLt+5SRnigFVSgVKXo78HKZr9fuEKy15C2XQAvJjgbgT8kiWMIvl0= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(40470700004)(46966006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 14:24:06.1533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2be1cde-860f-448a-490f-08dc347b17b9 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000252A4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5196 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 | 145 ++++++++++++++----------- 2 files changed, 85 insertions(+), 62 deletions(-) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 879bb4944c..b660c2c7cf 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -130,6 +130,8 @@ New Features * Added support for matching a random value. * Added support for comparing result between packet fields or value. * Added support for accumulating value of field into another one. + * 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 366a6956d2..f53ed1144b 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; @@ -3835,9 +3835,11 @@ __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 (!priv->shared_host) { + 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], @@ -8797,15 +8799,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); } @@ -8829,51 +8835,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]; @@ -9686,14 +9697,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; @@ -9914,17 +9927,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, @@ -9947,14 +9963,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) { @@ -9984,15 +9999,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) { @@ -10042,6 +10056,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.34.1