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 6680D44119; Fri, 31 May 2024 05:52:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5974C406B7; Fri, 31 May 2024 05:52:20 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.61]) by mails.dpdk.org (Postfix) with ESMTP id 36C28406B7 for ; Fri, 31 May 2024 05:52:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JEcvHSAkUOS3q2IDV/Kqp7YHRHKrXH3bK3f3k/w7gtT12S/+99v3gLIN1DOYIqsCi3y6muT3C3ZpuZ0OWgptkCe1CGYw02bMJthiNnXiYy0yvmbC3cMLsOHuv3MLo/GskjsBzKZ8VnV4dgCEtARAP9hCzQLqsjbYcuol7LmXu0ELaLJrsS7tFTg/wRfBr8gsnadsk2u1ARePMFYFjk4QXR1ZZ7lmX9QMAma09j+Q8djx8lueDrr94VJ7z5Uc2FzlpFdJqgqa71vlxnd29Skqx1VBE6141RWD6P3U3HUeL9mLALj5nH6IQ3QhZPO7e9yeopjkpjAzHk32Q0GQoX6Bog== 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=3DCXt9mumJErEPz2dX8GY7ZMnBUP31pP5CC+XwLs4Nw=; b=JdFl0lNn36EuixqJO1IcVY7E+dwtwXCW8NJpoo2tKYFWlujl9CvSczWoFdVw+ymZXoZQAElhayaYk43C7z4Dy3inRlLvJLfOoU8WpduQF8+wL+d2VFfYHZjXNITZHVFmMXj7BOk1KG9u6yy8Cpa4TPdMdiYL0ghhxB7HHIexQh8sDnPg2Yj0r/QP/R0Ax83He89SvPiFM4+Gjz4oCMq6JFA7SHfW9Xtu+POElbvEmXMNjHFU6oyA9wri35Lr0kCCV7swDRzC9noCWxfz1OSXVhHwu5DxGyqVoN67b8dOaF5miqRz2T33azy9/Zsm0KpBRJFAnp/+PgBdmN2coU9Klg== 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=3DCXt9mumJErEPz2dX8GY7ZMnBUP31pP5CC+XwLs4Nw=; b=Ht2YfjUTLfTx8SJSJbzU3DrFPgvF0DePV9a9rAq66vztJy9n7wHHkmHX/fjOBRY49D0rXB/VYDtBDD7p2MsVG+3QB89qs4vZE6lm3D3o0EZVWp8/jm/LjPNWMIJoOgv+dVAaRn/BTHa6S4wUuGfzyKn/r6SLbOTCmeWfu9HOTqeDp/iySGe5M3YN/mgNUhub+pkwjIskoJurWk8y2MJO9LeiyLIC5NQr8cXh1nAg5Qs445+jYJ/z2vlf+nedGtz0XLDCOA0i4uSEYykuB3RFUvZZZAgFdsVO8FTwbddPFtT+a9CpR9V5ZkW9hlUXhzOe0mbhCBe9nl+kSmigxkxTBA== Received: from BL1P222CA0017.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::22) by DS0PR12MB7928.namprd12.prod.outlook.com (2603:10b6:8:14c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22; Fri, 31 May 2024 03:52:11 +0000 Received: from BL02EPF0001A107.namprd05.prod.outlook.com (2603:10b6:208:2c7:cafe::d) by BL1P222CA0017.outlook.office365.com (2603:10b6:208:2c7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24 via Frontend Transport; Fri, 31 May 2024 03:52:11 +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 BL02EPF0001A107.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Fri, 31 May 2024 03:52:11 +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.1544.4; Thu, 30 May 2024 20:51:59 -0700 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.1544.4; Thu, 30 May 2024 20:51:57 -0700 From: Suanming Mou To: Dariusz Sosnowski , Viacheslav Ovsiienko , Ori Kam , Matan Azrad CC: , Subject: [PATCH 1/2] net/mlx5: support match with switch manager Date: Fri, 31 May 2024 11:51:43 +0800 Message-ID: <20240531035144.1732054-1-suanmingm@nvidia.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A107:EE_|DS0PR12MB7928:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c702462-922d-4212-70f1-08dc81250d65 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DrArLZMH6YraCT1aWoCBNNCH3DVCLD+j1UmUVWuikx9UVQHlA0BlQJPpjwey?= =?us-ascii?Q?S557gkLWzM6ExsQI//MYsMpOMQ/INysXr5IEGcM9ChqSXQQSfyr7hoAzPqiT?= =?us-ascii?Q?N0/6JqBy/zqEYZUeGUnpy/Q6SUkznd4DC1JT8b8Aec2K/bxhtSOMj1R3sQw3?= =?us-ascii?Q?B06FVFvuQXJdn4LXv+WBeN8SjlJOnTZEBISn+QC3psVL0DmEWOH3oIjr8Vhh?= =?us-ascii?Q?SeXlwh2iVR7x9lagm31HdwDBheG+or9jVA1AHL9B7Y7lMB0ujT5WQBjXKvmf?= =?us-ascii?Q?7OORIcqCNDxYNlNkm4emvUwS/uru6kJXlti+dc5Oi9OlNADZXaCrjPGZ2CAS?= =?us-ascii?Q?nE1bE4hNRsjyWDUECXERYPO65pdpeUMiG8U4klosL7oOzXWjFeSm/y/rxtzg?= =?us-ascii?Q?cFcT3xTPN9oG8a0xbRbkpdVlNMsj+yaljMxhrUxH6g9RmZSXS68NBfLhAO0x?= =?us-ascii?Q?rdon7uvbeBdIazvDQ8mPoYKLqYqF7iQ0shmgUdcnpUAW+of47zTJWK1ThbR4?= =?us-ascii?Q?xdvbTuVCPc5yiBQJS/H922JQJyW5UzaPiT1YRd9jawI96QvsqSPYgb34AbAY?= =?us-ascii?Q?8vGsc7yMiil2BcimCBYb5SjYcFNOUeZGcU2Clgh4oATWUOMh3DCbLyqYoVU/?= =?us-ascii?Q?nqSYg+6ZUKtZ1hJ35mK+8A6PwzFkmpflihYz/md+HW3dtK6VHvE1DFggrOZe?= =?us-ascii?Q?qm6B8qmqSJxoQgnrMIiIPU0+5+LRosr1nE/1bVXz9+kNlwa3jj8Rf7lKFPfK?= =?us-ascii?Q?flB+tkR4RabGPegYJ51/5ujh9EwXY9+ew5shLR6O8b8OYJlSagyB1ORXWMfL?= =?us-ascii?Q?JE83jToQm+0xmFnHgLQ+57KZh/zuI95vf+8Z7dQCBKmsECN9/1GwUIiNROhe?= =?us-ascii?Q?CsPaznvYosjnXLWuZl+Jw+bNPAM+ixzxmstL8l6zoHciCTYSaJ+kEVKOyWfd?= =?us-ascii?Q?VhzXL8YngfRkubWz7k3lHOaxd4cfCrufub4DV+nueQt/EmxIoNWRauXer+ED?= =?us-ascii?Q?F+yi4SnA5FrI1M8ZB8YtfJ3hd7qEskFEqw35L8mSGNS+721zafEynuAEtd+9?= =?us-ascii?Q?mgItvSepPt6atjYvMtOcFr7t50ohaU22A7/eozZTumecJI8oWSPtepa35PsZ?= =?us-ascii?Q?c4kSwpRJ1VkQRk3xR97jpyXPpkiSKQe7T8tlFFyFabr5g2LhJrVwvVv+cEE7?= =?us-ascii?Q?Y4y5A1PUiRYUBp+WXGVIFCOd9l58nnWqk2Q3RZ4zB6RiW7QHTTZ8ZRqLs5aS?= =?us-ascii?Q?7K9rXx7hg3BqY2uy/2ORFEAAU7d5TiW+I4Uq+vJWfhX8JDcQ4zFPilBhYbwk?= =?us-ascii?Q?NN3OHcSGOiNOnaN9wmfb91UMpkBOgTkAs18Mb15qPZTgo1lLlmUB1OZhOS2V?= =?us-ascii?Q?eHi3c0Qx6lyBtEAzD6YBTuDR2jKV?= 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)(376005)(1800799015)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 03:52:11.6261 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c702462-922d-4212-70f1-08dc81250d65 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: BL02EPF0001A107.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7928 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 Currently, in switch mode, mlx5 PMD only supports match with dedicate vport. There is a usercase which user may want to offload the rules only to match with all the pkt sent by application not from vport. Since the port_id info of pkt sent by application is switch manager, and kernel driver has exposed the switch manager register value, this commit adds the support of register matching for switch manager. Signed-off-by: Suanming Mou --- doc/guides/rel_notes/release_24_07.rst | 1 + drivers/common/mlx5/linux/meson.build | 2 ++ drivers/net/mlx5/linux/mlx5_os.c | 12 ++++++++++++ drivers/net/mlx5/mlx5.h | 14 ++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 6 ------ drivers/net/mlx5/mlx5_flow_dv.c | 24 +++++++++++++++++++----- 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/doc/guides/rel_notes/release_24_07.rst b/doc/guides/rel_notes/release_24_07.rst index 46efc04eac..389178acb0 100644 --- a/doc/guides/rel_notes/release_24_07.rst +++ b/doc/guides/rel_notes/release_24_07.rst @@ -84,6 +84,7 @@ New Features * **Updated NVIDIA mlx5 driver.** * Added match with Tx queue. + * Added match with switch manager. Removed Items diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build index cdee40c553..82e8046e0c 100644 --- a/drivers/common/mlx5/linux/meson.build +++ b/drivers/common/mlx5/linux/meson.build @@ -201,6 +201,8 @@ has_sym_args = [ 'mlx5dv_create_steering_anchor'], [ 'HAVE_IBV_FORK_UNNEEDED', 'infiniband/verbs.h', 'ibv_is_fork_initialized'], + [ 'HAVE_IBV_DEVICE_ATTR_ESW_MGR_REG_C0', 'infiniband/mlx5dv.h', + 'MLX5DV_CONTEXT_MASK_REG_C0' ], ] if libmtcr_ul_found has_sym_args += [ diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index bb566ea236..24ea58fd01 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -160,6 +160,9 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh) #endif #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ; +#endif +#ifdef HAVE_IBV_DEVICE_ATTR_ESW_MGR_REG_C0 + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_REG_C0; #endif err = mlx5_glue->dv_query_device(cdev->ctx, &dv_attr); if (err) { @@ -374,6 +377,15 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh) hca_attr->scatter_fcs_w_decap_disable; sh->dev_cap.rq_delay_drop_en = hca_attr->rq_delay_drop; mlx5_rt_timestamp_config(sh, hca_attr); +#ifdef HAVE_IBV_DEVICE_ATTR_ESW_MGR_REG_C0 + if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_REG_C0) { + sh->dev_cap.esw_info.regc_value = dv_attr.reg_c0.value; + sh->dev_cap.esw_info.regc_mask = dv_attr.reg_c0.mask; + } +#else + sh->dev_cap.esw_info.regc_value = 0; + sh->dev_cap.esw_info.regc_mask = 0; +#endif return 0; } diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 5b23043b8b..13718273dc 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -141,6 +141,19 @@ struct mlx5_flow_cb_ctx { void *data2; }; +struct flow_hw_port_info { + uint32_t regc_mask; + uint32_t regc_value; + uint32_t is_wire:1; + uint32_t direction:2; +}; + +enum mlx5_vport_direction { + MLX5_VPORT_DIRECTION_ANY = 0, + MLX5_VPORT_DIRECTION_NORTH, + MLX5_VPORT_DIRECTION_SOUTH, +}; + /* Device capabilities structure which isn't changed in any stage. */ struct mlx5_dev_cap { int max_cq; /* Maximum number of supported CQs */ @@ -184,6 +197,7 @@ struct mlx5_dev_cap { /* Log min WQE size, (size of single stride)*(num of strides).*/ } mprq; /* Capability for Multi-Packet RQ. */ char fw_ver[64]; /* Firmware version of this device. */ + struct flow_hw_port_info esw_info; /* E-switch manager reg_c0. */ }; #define MLX5_MPESW_PORT_INVALID (-1) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 9a359da042..0a6d33f8ee 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1938,12 +1938,6 @@ struct mlx5_hl_data { uint32_t dw_mask; }; -struct flow_hw_port_info { - uint32_t regc_mask; - uint32_t regc_value; - uint32_t is_wire:1; -}; - extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS]; /* diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index a834b3e2e0..5477eba4a0 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -10837,17 +10837,31 @@ flow_dv_translate_item_represented_port(struct rte_eth_dev *dev, void *key, const struct rte_flow_item_ethdev *pid_m = item ? item->mask : NULL; const struct rte_flow_item_ethdev *pid_v = item ? item->spec : NULL; struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace(); - struct mlx5_priv *priv; + struct mlx5_priv *priv = dev->data->dev_private; uint16_t mask, id; uint32_t vport_meta; + bool vport_match = false; MLX5_ASSERT(wks); +#ifndef HAVE_IBV_DEVICE_ATTR_ESW_MGR_REG_C0 + if (priv->sh->config.dv_flow_en == 2) + vport_match = true; +#endif if (!pid_m && !pid_v) return 0; if (pid_v && pid_v->port_id == UINT16_MAX) { - flow_dv_translate_item_source_vport(key, - key_type & MLX5_SET_MATCHER_V ? - mlx5_flow_get_esw_manager_vport_id(dev) : 0xffff); + if (priv->sh->config.dv_flow_en != 2 || vport_match) { + flow_dv_translate_item_source_vport + (key, key_type & MLX5_SET_MATCHER_V ? + mlx5_flow_get_esw_manager_vport_id(dev) : 0xffff); + } else { + if (key_type & MLX5_SET_MATCHER_M) + vport_meta = priv->sh->dev_cap.esw_info.regc_mask; + else + vport_meta = priv->sh->dev_cap.esw_info.regc_value; + flow_dv_translate_item_meta_vport(key, vport_meta, + priv->sh->dev_cap.esw_info.regc_mask); + } return 0; } mask = pid_m ? pid_m->port_id : UINT16_MAX; @@ -10868,7 +10882,7 @@ flow_dv_translate_item_represented_port(struct rte_eth_dev *dev, void *key, * Kernel can use either misc.source_port or half of C0 metadata * register. */ - if (priv->vport_meta_mask) { + if (priv->vport_meta_mask && !vport_match) { /* * Provide the hint for SW steering library * to insert the flow into ingress domain and -- 2.34.1