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 9FF4843B61; Wed, 21 Feb 2024 11:22:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C06C406BA; Wed, 21 Feb 2024 11:22:13 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062.outbound.protection.outlook.com [40.107.220.62]) by mails.dpdk.org (Postfix) with ESMTP id 22C3040691 for ; Wed, 21 Feb 2024 11:22:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YCGtwvu0x063EONT6yBkEDZx54pebu0DOC9c/az7kOqsxfxoRiDNYP8asnQ5DhilPuEgR2BtFEXi6WAXQqLbN9Fz/wVxYcoilsp9sYo4MYL31Nsyll6XqN3+qpQvKM4KdYI+/roUIGY5xppXvzBXadduSK8uH2r02tlornS96ujZ1NaCoN4dgBAgXtkNjxPMBtga4fOKcDSetC1/sabRJ7TNsO07m2YyWmKBfkZxD3EAm3Isjf0MhMuW+SnkJuNUWgNUjtctNVIQMqTM6a0jDMvNX4Ty0FWZcEM6Bfg1rQjsoKKcSBD4MINpxXjaKDrVt8YWUq/A8USI6sP6uXFnpg== 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=TSbM/9SjQdLS8o53S5DUrSCMafbDJrve0+DT3E0oB/I=; b=d4NZNXjaLuhPHwIXB+Ge9d2MZu/HhtIMdU7s/Cch59ElXC5Juggdsc2q9sWd0PoGskjRTyu7qgnzzjUSjnmg15Fx8poxW3ZMDhLKSu5O9ZkG8LounmM3JBb+CY/hGFO9h7uQtCsqJZ9mh0hVqnYoZ9spNhymvs87H5eCgY0Ow/DYej1brZN09m5mKczT/+LwRwtOeKuRm5KYx4Q1heTAtw2hruc1n+xeziMIFO6y7G8Cro/BeZXSsUncRY1MLsHkTAAh4dGp2BFMjAZobZKxlXwfGWDu06OuoSgD8/SfbnPYw9fVkBZMbPjRdymbR7T0nbEcQLD8klOVkp3YQuje8Q== 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=TSbM/9SjQdLS8o53S5DUrSCMafbDJrve0+DT3E0oB/I=; b=eXa3rXSH2iVFdlBGEjM42osbjBfMQbWZQxSGoHIZ+L/GyH3lJxkFbhZ2x87YFVqDrD5Ckom34oqNihUXmhjDJQ7ka1ehXnZqw6gOhkmxS/lJlz+d1EqIR2x+50fHs+ImEzRjIm41xvI8+N2hmyGH9e8VuBNXOVKuYcc8Wm3w8HwuRLJeFiVPBee1WXpFib7gL5RAWbm+XRkDVju0J4w7waJ2jdzC+2jVC5XtT7iT6+7+B8/n3p2KEwRzqzAvmnScGg8IbvCLSsZ1gHKbf4JcsYXbb6S8Wt7pTSHdaN876MQU9JpXZm/ybrBRke2upr1vTVQANU85Y4zR8qH4dgPi+g== Received: from BYAPR02CA0011.namprd02.prod.outlook.com (2603:10b6:a02:ee::24) by CH3PR12MB8725.namprd12.prod.outlook.com (2603:10b6:610:170::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.21; Wed, 21 Feb 2024 10:22:06 +0000 Received: from SJ5PEPF000001D2.namprd05.prod.outlook.com (2603:10b6:a02:ee:cafe::83) by BYAPR02CA0011.outlook.office365.com (2603:10b6:a02:ee::24) 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:22: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 SJ5PEPF000001D2.mail.protection.outlook.com (10.167.242.54) 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:22:05 +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; Wed, 21 Feb 2024 02:21:51 -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:21:49 -0800 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 2/2] net/mlx5: add cross port meter mark action sharing Date: Wed, 21 Feb 2024 12:21:30 +0200 Message-ID: <20240221102130.10124-3-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221102130.10124-1-dsosnowski@nvidia.com> References: <20240221101327.9820-1-dsosnowski@nvidia.com> <20240221102130.10124-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: SJ5PEPF000001D2:EE_|CH3PR12MB8725:EE_ X-MS-Office365-Filtering-Correlation-Id: e743214f-ae76-42f0-9dbc-08dc32c6f409 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B8n6xSY8UpcYDN/gVmzNUvRTY2SWRQ3L1sYyD09B63pYmF1wSC4mz2vug27l+Fk3IaiYd4b3pO3phUEnr/5/VFQNWxvGvxjoUG4ytbdLe1FqirpkQJTUhpT4vG2lKNdGkktEUb+bs/CEOti4ombqppenoT6r2NI6RZxLHUU2MJDQaT9f9ak0QkepqN/QqClG6Z/I3OMTijlZWGyMR2y2CuQvo5ITY/fNEM3Ly7cukKBf3ym7VWWBOLZZDt/3dm5KxCgS216r97031+vaYuKSj8L/eIKayVFxYGXkt09bT3Rae+lt7X3rzA1vf9fm4z/xN5I5PtmKlDvuvn/tBw84eUu9eNxAT1ZZXHNMe4KV6R7LmqyZKpxrXgnQkTN3zbmQZVJY4a6qlE9Lz73ht8eBHdb+8B5J/sTOINzYj9nnv6uFXYlLZPUMbkrjBu/TK+N0O+Ow4VqbOrxbc3HY8wAV67SATRKJZRqN9yBgWJRjIu02LwK/tevrH8pcoSOWZqBgCqCM9mUzsUz++gzCvoxqSQfeNFXRDe8r3ctL/9Ny3N3BoERmWMqwoTqptyxH643NUYz/qYHdTPRytkMbx+YW9P6xP+FdJqhd3X3ZvzMTDDa9TKnftpCxOV0GRq087lJZtwKa4RoyQRzfCy3WYyQXbw== 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)(46966006)(40470700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2024 10:22:05.7233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e743214f-ae76-42f0-9dbc-08dc32c6f409 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: SJ5PEPF000001D2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8725 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 This patch adds support for sharing meter mark actions between multiple ports of the same physical NIC. Meter objects pool, meter mark actions and meter profiles can be created only on the host port. Guest ports are allowed to use meter objects created on the host port through indirect actions. Direct use of meter mark actions (e.g. putting meter mark action in actions template), creation of indirect meters and meter profiles on the guest port is not allowed. 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 | 34 ++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 77 ++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 10 deletions(-) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 619459baae..2e73a7a37a 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_METER_MARK`` + 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 4d6b22c4e3..a6b2ef4863 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -1545,7 +1545,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions) static __rte_always_inline struct mlx5_aso_mtr * flow_hw_meter_mark_alloc(struct rte_eth_dev *dev, uint32_t queue, const struct rte_flow_action *action, - void *user_data, bool push) + void *user_data, bool push, + struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_aso_mtr_pool *pool = priv->hws_mpool; @@ -1554,6 +1555,11 @@ flow_hw_meter_mark_alloc(struct rte_eth_dev *dev, uint32_t queue, struct mlx5_flow_meter_info *fm; uint32_t mtr_id; + if (priv->shared_host) { + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Meter mark actions can only be created on the host port"); + return NULL; + } if (meter_mark->profile == NULL) return NULL; aso_mtr = mlx5_ipool_malloc(priv->hws_mpool->idx_pool, &mtr_id); @@ -1592,13 +1598,14 @@ flow_hw_meter_mark_compile(struct rte_eth_dev *dev, const struct rte_flow_action *action, struct mlx5dr_rule_action *acts, uint32_t *index, - uint32_t queue) + uint32_t queue, + struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_aso_mtr_pool *pool = priv->hws_mpool; struct mlx5_aso_mtr *aso_mtr; - aso_mtr = flow_hw_meter_mark_alloc(dev, queue, action, NULL, true); + aso_mtr = flow_hw_meter_mark_alloc(dev, queue, action, NULL, true, error); if (!aso_mtr) return -1; @@ -2474,7 +2481,8 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev, dr_pos, actions, acts->rule_acts, &acts->mtr_id, - MLX5_HW_INV_QUEUE); + MLX5_HW_INV_QUEUE, + error); if (err) goto err; } else if (__flow_hw_act_data_general_append(priv, acts, @@ -3197,7 +3205,8 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, */ ret = flow_hw_meter_mark_compile(dev, act_data->action_dst, action, - rule_acts, &job->flow->mtr_id, MLX5_HW_INV_QUEUE); + rule_acts, &job->flow->mtr_id, + MLX5_HW_INV_QUEUE, error); if (ret != 0) return ret; break; @@ -5322,6 +5331,8 @@ flow_hw_validate_action_count(struct rte_eth_dev *dev, * Pointer to rte_eth_dev structure. * @param[in] action * Pointer to the indirect action. + * @param[in] indirect + * If true, then provided action was passed using an indirect action. * @param[out] error * Pointer to error structure. * @@ -5331,6 +5342,7 @@ flow_hw_validate_action_count(struct rte_eth_dev *dev, static int flow_hw_validate_action_meter_mark(struct rte_eth_dev *dev, const struct rte_flow_action *action, + bool indirect, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; @@ -5341,6 +5353,9 @@ flow_hw_validate_action_meter_mark(struct rte_eth_dev *dev, return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, action, "meter_mark action not supported"); + if (!indirect && priv->shared_host) + return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, action, + "meter_mark action can only be used on host port"); if (!priv->hws_mpool) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, @@ -5384,7 +5399,7 @@ flow_hw_validate_action_indirect(struct rte_eth_dev *dev, type = mask->type; switch (type) { case RTE_FLOW_ACTION_TYPE_METER_MARK: - ret = flow_hw_validate_action_meter_mark(dev, mask, error); + ret = flow_hw_validate_action_meter_mark(dev, mask, true, error); if (ret < 0) return ret; *action_flags |= MLX5_FLOW_ACTION_METER; @@ -5841,8 +5856,7 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_METER; break; case RTE_FLOW_ACTION_TYPE_METER_MARK: - ret = flow_hw_validate_action_meter_mark(dev, action, - error); + ret = flow_hw_validate_action_meter_mark(dev, action, false, error); if (ret < 0) return ret; action_flags |= MLX5_FLOW_ACTION_METER; @@ -10138,7 +10152,7 @@ flow_hw_action_handle_validate(struct rte_eth_dev *dev, uint32_t queue, "CT pool not initialized"); return mlx5_validate_action_ct(dev, action->conf, error); case RTE_FLOW_ACTION_TYPE_METER_MARK: - return flow_hw_validate_action_meter_mark(dev, action, error); + return flow_hw_validate_action_meter_mark(dev, action, true, error); case RTE_FLOW_ACTION_TYPE_RSS: return flow_dv_action_validate(dev, conf, action, error); case RTE_FLOW_ACTION_TYPE_QUOTA: @@ -10297,7 +10311,7 @@ flow_hw_action_handle_create(struct rte_eth_dev *dev, uint32_t queue, break; case RTE_FLOW_ACTION_TYPE_METER_MARK: aso = true; - aso_mtr = flow_hw_meter_mark_alloc(dev, queue, action, job, push); + aso_mtr = flow_hw_meter_mark_alloc(dev, queue, action, job, push, error); if (!aso_mtr) break; mtr_id = (MLX5_INDIRECT_ACTION_TYPE_METER_MARK << diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 9cb4614436..c0578ce6e9 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -17,11 +17,32 @@ #ifdef HAVE_MLX5_HWS_SUPPORT +static void +mlx5_flow_meter_uninit_guest(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + if (priv->hws_mpool) { + if (priv->hws_mpool->action) { + claim_zero(mlx5dr_action_destroy(priv->hws_mpool->action)); + priv->hws_mpool->action = NULL; + } + priv->hws_mpool->devx_obj = NULL; + priv->hws_mpool->idx_pool = NULL; + mlx5_free(priv->hws_mpool); + priv->hws_mpool = NULL; + } +} + void mlx5_flow_meter_uninit(struct rte_eth_dev *dev) { struct mlx5_priv *priv = dev->data->dev_private; + if (priv->shared_host) { + mlx5_flow_meter_uninit_guest(dev); + return; + } if (priv->mtr_policy_arr) { mlx5_free(priv->mtr_policy_arr); priv->mtr_policy_arr = NULL; @@ -52,6 +73,54 @@ mlx5_flow_meter_uninit(struct rte_eth_dev *dev) } } +static int +mlx5_flow_meter_init_guest(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct rte_eth_dev *host_dev = priv->shared_host; + struct mlx5_priv *host_priv = host_dev->data->dev_private; + int reg_id = 0; + uint32_t flags; + int ret = 0; + + MLX5_ASSERT(priv->shared_host); + reg_id = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, NULL); + if (reg_id < 0) { + rte_errno = ENOMEM; + ret = -rte_errno; + DRV_LOG(ERR, "Meter register is not available."); + goto err; + } + priv->hws_mpool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(struct mlx5_aso_mtr_pool), + RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); + if (!priv->hws_mpool) { + rte_errno = ENOMEM; + ret = -rte_errno; + DRV_LOG(ERR, "Meter ipool allocation failed."); + goto err; + } + MLX5_ASSERT(host_priv->hws_mpool->idx_pool); + MLX5_ASSERT(host_priv->hws_mpool->devx_obj); + priv->hws_mpool->idx_pool = host_priv->hws_mpool->idx_pool; + priv->hws_mpool->devx_obj = host_priv->hws_mpool->devx_obj; + 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; + priv->hws_mpool->action = mlx5dr_action_create_aso_meter + (priv->dr_ctx, (struct mlx5dr_devx_obj *)priv->hws_mpool->devx_obj, + reg_id - REG_C_0, flags); + if (!priv->hws_mpool->action) { + rte_errno = ENOMEM; + ret = -rte_errno; + DRV_LOG(ERR, "Meter action creation failed."); + goto err; + } + return 0; +err: + mlx5_flow_meter_uninit(dev); + return ret; +} + int mlx5_flow_meter_init(struct rte_eth_dev *dev, uint32_t nb_meters, @@ -81,6 +150,8 @@ mlx5_flow_meter_init(struct rte_eth_dev *dev, .type = "mlx5_hw_mtr_mark_action", }; + if (priv->shared_host) + return mlx5_flow_meter_init_guest(dev); if (!nb_meters) { ret = ENOTSUP; rte_flow_error_set(&error, ENOMEM, @@ -850,6 +921,9 @@ mlx5_flow_meter_profile_hws_add(struct rte_eth_dev *dev, struct mlx5_flow_meter_profile *fmp; int ret; + if (priv->shared_host) + return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, + "Meter profiles cannot be created on guest port"); if (!priv->mtr_profile_arr) return mlx5_flow_meter_profile_add(dev, meter_profile_id, profile, error); /* Check input params. */ @@ -887,6 +961,9 @@ mlx5_flow_meter_profile_hws_delete(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_flow_meter_profile *fmp; + if (priv->shared_host) + return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, + "Meter profiles cannot be destroyed through guest port"); if (!priv->mtr_profile_arr) return mlx5_flow_meter_profile_delete(dev, meter_profile_id, error); /* Meter profile must exist. */ -- 2.34.1