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 9137743B61; Wed, 21 Feb 2024 11:02:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2187B40A8B; Wed, 21 Feb 2024 11:02:31 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2059.outbound.protection.outlook.com [40.107.244.59]) by mails.dpdk.org (Postfix) with ESMTP id 5880B402CE for ; Wed, 21 Feb 2024 11:02:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+IiSN1K6uNc9TBbfy9n+skqxdtHUxU1VvJlh0eEI6/AQxkbjB8SNW59bJXju3BGoUHWuEunetwAtj4W+MblbV+UBwuxJkYYdMv5z8mDySFW9voelnXCrAkQpvkfhFCNshagFHyzqaO1cZ7PFY7zA9ZdoXcApU5Eo1ekESMPI4W0Ajm6ad7jxykNMm7MTNY0CGNs1IHub8xo8/+zo7tR8qWksrY/43yuFkWAmYYffGaMYMdSDlhLEolOjoLn/fgVWcjQFM29GHF+obKvCQQNj92ygNbQ26TLUkPiuFsUvXcn+GnaVOmUErcQ++gttxWZKinpC+mqBaby2NgyPNP1vQ== 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=LYycZkFDLy62m40kzZlz38toOGqYYHj1ALpo+H8E9RQ=; b=cC8GhqzyG4fVUBHUd51ZUslF8onWRysagcg3CDbAUycFDT+PEUoR4FdG8NopT+lEwl4ztOy+sRuyE/yz+p8GY54LPK8HPyicLNVE6GnrCEOHtpkg+5IZvZWtr+kl0MfpCiJYOnEIpu3NOHUAd7TjnR4iZx121gmKrNSlciT8VGLZ8O2BdNq550epP6mGVUOYNgqBTr+GJYWH8NRxO15Ix3oPRGIh3jUzjU+lDktg14gl3ZAKxUTFs5BKIxvABIsfvAnSbgYHgpDUkCgNdgtOhK5X9WNDwuO2DycC/d514Ozg+j4nJb2znPefSqcwYVABU6qq3lwLlv6RGBUFPxJ18g== 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=LYycZkFDLy62m40kzZlz38toOGqYYHj1ALpo+H8E9RQ=; b=hoZ084CRuRkk0Z1MXo1LHiRVdMQ1BpyrG3E1mIY1YThuMI6yWBKGA3R5Qid6XkUXW1xzcJBltMPU32v16QjKiMrg7peXuo1yLsfqrS10COGBUockDxxKKHgj+muye+FQB5iaypQNvTPpOlJdjhnJvR17Oex5fOCV3YmNNJ08blSZgqC5ciD2nASPDr8ZHlJKx74Viw+1FAMujcicmDtcuhFKZP/GBf2GRrhQ9F2NCfM1PAWUxXh156WELjbh3mS4sNO5G8UGusQl69lIn/u4Ydvv63UL0Hs5/BwVhxTekw5KyiAjRQffX4BEHi0i5E1QusdNP82W+meUW6Fnf0+PTA== Received: from CYXPR02CA0094.namprd02.prod.outlook.com (2603:10b6:930:ce::22) by CH0PR12MB5281.namprd12.prod.outlook.com (2603:10b6:610:d4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.19; Wed, 21 Feb 2024 10:02:26 +0000 Received: from CY4PEPF0000E9D1.namprd03.prod.outlook.com (2603:10b6:930:ce:cafe::72) by CYXPR02CA0094.outlook.office365.com (2603:10b6:930:ce::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.41 via Frontend Transport; Wed, 21 Feb 2024 10:02:26 +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 CY4PEPF0000E9D1.mail.protection.outlook.com (10.167.241.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Wed, 21 Feb 2024 10:02:26 +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; Wed, 21 Feb 2024 02:02:14 -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; Wed, 21 Feb 2024 02:02:11 -0800 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 3/4] net/mlx5: add cross port CT object sharing Date: Wed, 21 Feb 2024 12:01:44 +0200 Message-ID: <20240221100145.8234-4-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221100145.8234-1-dsosnowski@nvidia.com> References: <20240221100145.8234-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: CY4PEPF0000E9D1:EE_|CH0PR12MB5281:EE_ X-MS-Office365-Filtering-Correlation-Id: 0abf6f2c-7648-4806-4650-08dc32c4352f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fca6VwUDLXQnS/o5RG1oP8YNxD4wIGTK7veaaAVtIpb1JWoTnlyNk18bIrz45/75vuJnSH9bwxRVIC+lP0g9Tu3dRe5KZKPavWt5aEevkdJ6KL6Z3PGHrr6kEkES2wuFd/x/0k1hhrWCz3qSy9uXjYZjBvKbIku36zU6i8q6kJIZCzjvRxH8JI2nHb0DurDKw68ceVhTL51cv8Xma9SCretshdFxk0+LLTiTASPXp/XBu3OUBH6Mtg7r5Ib6geLWu6ruGrsH6AEDc780Bmy6TKcBQVSPDZ/Dtthpc3tTwnWBoh65/k/Ao0/r70KIYzPcGTnjy58JE02veSCtRYdEYwq5jiqZcda/v6knEhwSZ7dqTztDopjZb+4TPbcMb4MacQupOQiA0Eb0T7QP52FIE5KEqiIqCWnz+/piqQRioi6Lpl9CoXK0ADUX0QbX2bCUdN9UMul/Um8ccflsuDdSgJmw3DPkrrJH3mWfYAbqQlfRFBLqh1t0Uq/vbpEb6jsxeAMtXeSUs+4E2nZ5ZVIga2XPziqTkxlbfKw5j34WEMtWbObtpGndWv4qG+BzRc6NfniiB0C8MiXfPt8gCatHZlGFJg/UEGk+wEF5+ywMqWV4OjDt9kvrQOtp+nO+yiwrWW3ZLtSqtBs/OITvWdC3DzylRg212rnp2tqnY7gyLCI= 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)(36860700004)(46966006)(40470700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2024 10:02:26.4537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0abf6f2c-7648-4806-4650-08dc32c4352f 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: CY4PEPF0000E9D1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5281 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 | 3 + drivers/net/mlx5/mlx5_flow_hw.c | 145 ++++++++++++++----------- 2 files changed, 86 insertions(+), 62 deletions(-) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 619459baae..2262f350b5 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -133,6 +133,9 @@ New Features * Added HW steering support for modify field ``RTE_FLOW_FIELD_ESP_SEQ_NUM`` flow action. * Added HW steering support for modify field ``RTE_FLOW_FIELD_ESP_PROTO`` flow action. + * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_CONNTRACK`` + with HW steering flow engine. + Removed Items ------------- diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 2f366e9078..89066e7214 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.25.1