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 0CC0F4415C; Wed, 5 Jun 2024 11:37:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEB51402DC; Wed, 5 Jun 2024 11:37:56 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2069.outbound.protection.outlook.com [40.107.94.69]) by mails.dpdk.org (Postfix) with ESMTP id 35AF840289 for ; Wed, 5 Jun 2024 11:37:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G0ZzltWYf2ljbUmLPd9vOwMl8xJ1GnrvjivBvO03gyD5r+6Z2lo1zkpiNO1y8XUY6hbpu8rBb5VSeEwCijXEsArOz2oXfbEeHWyobXTA0oS/l+klkcKXSmsAk+0uE1cUryTLpLmT8yFejHPM7wqytiVqubXmoQxeR/tWH2cucWgGcb10rSoBQi/O0TJ09Fb/qx8kUZvGJBc7bl61K8KbO0OhRvisi1eDiCYEIOPhtNUWEEzPXIbbdZ4ChG4FWjTvc3uCaQ24BCzkp8qKTTRB93wwPr++dpOVAH+jQa+88SDjjrVK7E2AF0PLYlbPd4FwOqXX2jl5Vgxyb6CLshMG4A== 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=oag/3OoU1GoiPFsVzGBtByaVyc+BGrluIIZQ2HXiKrM=; b=M1JXJsmbL9nfbtEkEsGqHI7tg6QnUegASWGZoHwaUobzeKKMGZC+QybjKymeeHgO6Z93VkG30I+mMMe/HcDLzA28eDF7ucACAdzhpeThGEu4rwe+A8TQoF9DS3GjyrcfRtzBGSB97cwovtdJIfdahijVWp4DQxcIU4knNbqec/IqpPQxz8+JVdMelQ6ctyk8HGCv2J+k2eqB5QJ6dU9+1yy487OlWyXXZcoRxAnSdIJoARisHKhnqtmMOaWxVMEgU5y+t7SBDysqwN0prevhWEFetylsqcBFpzfH4XLRk/JSiMGN7CdRqbJ89hQfD6Hi9r8oEe4Dkf/YhXytrZFNwg== 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=oag/3OoU1GoiPFsVzGBtByaVyc+BGrluIIZQ2HXiKrM=; b=koQvDOUgaWJ4PJUu4Znv2f/iUj67XpgrA2CTYrl4D4Rgzbj4Gb04nBf3ri08DGsdYLfShI5DPP+sscyZ39iYhaLhxX8/2/XPbLsa0Yljt9RZ0jhSmnChOZpliuHvCtoVHoFmRZAXxZ4DK5DGPA95ZG80RZTPIPhsxNIkERB3gXJ9SBxLvUeS7xe4kr/7jnbEBgbx4P/qOsFj5ZxZCKqBty4Uplrwp8jFDtHMGq2I3ZoWrsFFyreSlF6LSasAhqxHaZx3Qwf4TA6UdOKPoEN0sU0OhuxurAp6qmUZAqOp/ez18e5QrraKy4uvFn5CAmNCsCzWRGvcF5/wspOM/sKOTg== Received: from BN9PR03CA0529.namprd03.prod.outlook.com (2603:10b6:408:131::24) by CY8PR12MB8411.namprd12.prod.outlook.com (2603:10b6:930:6e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24; Wed, 5 Jun 2024 09:37:52 +0000 Received: from BN3PEPF0000B36F.namprd21.prod.outlook.com (2603:10b6:408:131:cafe::4) by BN9PR03CA0529.outlook.office365.com (2603:10b6:408:131::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31 via Frontend Transport; Wed, 5 Jun 2024 09:37:52 +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 BN3PEPF0000B36F.mail.protection.outlook.com (10.167.243.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.0 via Frontend Transport; Wed, 5 Jun 2024 09:37:51 +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; Wed, 5 Jun 2024 02:37:38 -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; Wed, 5 Jun 2024 02:37:36 -0700 From: Suanming Mou To: Dariusz Sosnowski , Viacheslav Ovsiienko , Ori Kam , Matan Azrad CC: , Subject: [PATCH v2] net/mlx5: support match with E-Switch manager Date: Wed, 5 Jun 2024 17:37:17 +0800 Message-ID: <20240605093717.1826380-1-suanmingm@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531035144.1732054-1-suanmingm@nvidia.com> References: <20240531035144.1732054-1-suanmingm@nvidia.com> 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: BN3PEPF0000B36F:EE_|CY8PR12MB8411:EE_ X-MS-Office365-Filtering-Correlation-Id: 017a7f43-9756-41de-a546-08dc85432ba9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|36860700004|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qJMmlpYUo2e6dn762vhEUVCFQk21cJAJYPhkCXM3ioVByfPSpDfjqBq4NU50?= =?us-ascii?Q?+l703S82kZkfOiESF7ertza9S4/IAFM2Nh1NM2JMgn8T+LiSH5y8Vc6TIbw8?= =?us-ascii?Q?cQxC3Gg37xfckuf1jcuqD2r6DFWT0aARkXzNvlDiYu8QXNvR+wmVSjw+ggKp?= =?us-ascii?Q?CNyJA9KPaLRX3ifO38bmGkmVrC8Tcc/23qGJqjJ1fBOzJd9rP/d1BYiQIqMz?= =?us-ascii?Q?Nf6KZupjS/iog4cHnYE8Zeq2kcsQMt0Fn2inrEHW0eAWR6LUF5wZzy7wI5ZV?= =?us-ascii?Q?hRRUeC7Ry3HRfvH2v1sV6OY4/Uby7dHomrIzbcKGH1SWDPT8CXDfxl/LlrUN?= =?us-ascii?Q?gcvepIbv3Ib7lrKzCCBHW1iI61YBUDHWQa81X0kFY6tsBOcXZwyVDf7Qjsb4?= =?us-ascii?Q?k370P2A2eIoHcHwhQjnXfmVlM6dyD2KpJGWuVPKMdfJ55XlN5mcAQpqXhx2E?= =?us-ascii?Q?jM3Am2mvWjQ3u7crVLuTUy11c0ySmBBBIVzMyBe1TC22BqYKmJ+MN5rgoQ8K?= =?us-ascii?Q?UsHCHhVtGHfoGAFsSAjUoZaonXjfLHAmEAFAN6V9orPHIRIxpeLzY5w4U4mP?= =?us-ascii?Q?bYsbGV6DOKKGcz/y1CB8CkFr39hG5nYgkxG2H+OMBvXLyg71GOL7IjeHDkzR?= =?us-ascii?Q?8cgJDqjJ7cQpfnQGOCDe2TKovcp8Zg5f+w6XtYHc3b3qJSclA0yIlcBYgMr+?= =?us-ascii?Q?P7YfWxAPv6yij1HF7MGIyIavfjxaCCVAKk6OxZgJeXunBYv0VWMva360RyXY?= =?us-ascii?Q?zJobFDiIfQXamYvwMvqXlM7wVLUQiXIEmdAaZIaS/D4ngYp+pL4dU9gwVflE?= =?us-ascii?Q?7ecneo8Eb4moE4GMUGRxPmtZUnXd4C07k82KizL1i/KWdUcXZ3Iw0uXiE55K?= =?us-ascii?Q?FGjC4oB1/hqJcck0WH9Oyhujhm32p8mDcj+Uv7HhS7b9ylA619KvYfddCD7T?= =?us-ascii?Q?rDm5HZf04/aXmhPJGx1/0037CC4msVmwqq8Gbk2/8Tww5LgiYu/qGJJ+KQt5?= =?us-ascii?Q?GwDqesWs6KihT9PkO1W+Z1UnDvVJr7/I0h6ugbwtmr5IlU4TM0Ua6KUqjfUQ?= =?us-ascii?Q?GBG91CgH9IGGuQPE2qKrApzbbu5vz2EugCXgPTwbJjfyNkppliKYERGGxcjL?= =?us-ascii?Q?zr18qs/GEc5kE2JdPtG8IK3mjsy3CNAl4a6JMPVcesIi07v3j64PB7WvY0dJ?= =?us-ascii?Q?owfA4yw6qCVP2Tcvenyr8yfP2XuwdTZ7kazMKlINaBJiUje8VnfhmRn/pT+4?= =?us-ascii?Q?rrwzZGioXFRrA7zh7RNvZP4Wuq04efvEDtMKO0y2GTcXjCv1QnVqZJvSq7Wy?= =?us-ascii?Q?yodIwxG65Oy1GwhPHHMj1fyZ0uxWB8W/dO7FacXtphlcQZbg/pnVlNA4M1G3?= =?us-ascii?Q?wZwWSCS7yLVJ9Qz7z/LI20NcjPul?= 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)(36860700004)(82310400017)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 09:37:51.9577 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 017a7f43-9756-41de-a546-08dc85432ba9 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: BN3PEPF0000B36F.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8411 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 dedicated vport. There is a use case which user may want to offload the rules only to match with all the packet sent by application not from vport. Since the port_id info of packet sent by application is E-Switch manager, and kernel driver has exposed the E-Switch manager register value, this commit adds the support of register matching for E-Switch manager. Signed-off-by: Suanming Mou --- v2: - align to single patch. - update doc. --- doc/guides/nics/mlx5.rst | 6 +++++ doc/guides/rel_notes/release_24_07.rst | 1 + drivers/common/mlx5/linux/meson.build | 2 ++ drivers/net/mlx5/hws/mlx5dr_definer.c | 3 ++- drivers/net/mlx5/hws/mlx5dr_definer.h | 5 +++- drivers/net/mlx5/hws/mlx5dr_rule.c | 2 +- drivers/net/mlx5/linux/mlx5_os.c | 12 +++++++++ drivers/net/mlx5/mlx5.h | 14 ++++++++++ drivers/net/mlx5/mlx5_flow.h | 36 ++++++++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 24 +++++++++++++---- 10 files changed, 89 insertions(+), 16 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 5cd41d3c7f..8afb32ed35 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -170,6 +170,7 @@ Features - Matching on represented port. - Matching on aggregated affinity. - Matching on external Tx queue. +- Matching on E-Switch manager. Limitations @@ -910,6 +911,10 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- In switch mode, flow rule matching ``RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT`` + item with port_id ``UINT16_MAX`` means matching with packets sent by E-Switch + manager from software. Need MLNX_OFED 24.04+. + Statistics ---------- @@ -1585,6 +1590,7 @@ entities on the HCA. With this configuration, mlx5 PMD supports: - matching traffic coming from physical port, PF, VF or SF using REPRESENTED_PORT items; +- matching traffic coming from E-Switch manager using REPRESENTED_PORT item with port_id UINT16_MAX; - forwarding traffic to physical port, PF, VF or SF using REPRESENTED_PORT actions; Requirements diff --git a/doc/guides/rel_notes/release_24_07.rst b/doc/guides/rel_notes/release_24_07.rst index 3a3257fcd5..7688ed2764 100644 --- a/doc/guides/rel_notes/release_24_07.rst +++ b/doc/guides/rel_notes/release_24_07.rst @@ -85,6 +85,7 @@ New Features * Added match with Tx queue. * Added match with external Tx queue. + * Added match with E-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/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index bc128c7b99..4be9012e25 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -721,7 +721,7 @@ mlx5dr_definer_vport_set(struct mlx5dr_definer_fc *fc, const struct flow_hw_port_info *port_info; uint32_t regc_value; - port_info = flow_hw_conv_port_id(v->port_id); + port_info = flow_hw_conv_port_id(fc->dr_ctx, v->port_id); if (unlikely(!port_info)) regc_value = BAD_PORT; else @@ -1548,6 +1548,7 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd, DR_CALC_SET_HDR(fc, registers, register_c_0); fc->bit_off = __builtin_ctz(caps->wire_regc_mask); fc->bit_mask = caps->wire_regc_mask >> fc->bit_off; + fc->dr_ctx = cd->ctx; } else { DR_LOG(ERR, "Pord ID item mask must specify ID mask"); rte_errno = EINVAL; diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.h b/drivers/net/mlx5/hws/mlx5dr_definer.h index 463e22732e..b583f78943 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.h +++ b/drivers/net/mlx5/hws/mlx5dr_definer.h @@ -223,9 +223,12 @@ enum mlx5dr_definer_type { struct mlx5dr_definer_fc { uint8_t item_idx; uint8_t is_range; - uint16_t extra_data; uint8_t compare_idx; bool compare_set_base; + union { + uint32_t extra_data; + void *dr_ctx; + }; uint32_t byte_off; int bit_off; uint32_t bit_mask; diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c index 171a0bff38..ea30c37270 100644 --- a/drivers/net/mlx5/hws/mlx5dr_rule.c +++ b/drivers/net/mlx5/hws/mlx5dr_rule.c @@ -28,7 +28,7 @@ static void mlx5dr_rule_skip(struct mlx5dr_matcher *matcher, if (mt->item_flags & MLX5_FLOW_ITEM_REPRESENTED_PORT) { v = items[mt->vport_item_id].spec; - vport = flow_hw_conv_port_id(v->port_id); + vport = flow_hw_conv_port_id(matcher->tbl->ctx, v->port_id); if (unlikely(!vport)) { DR_LOG(ERR, "Fail to map port ID %d, ignoring", v->port_id); return; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index f887501a9b..62ea151b6f 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 91ceceb34a..11b955ad12 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 ba75b99139..36ff567c61 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]; /* @@ -2009,15 +2003,41 @@ flow_hw_get_port_id(void *dr_ctx) return UINT16_MAX; } +/* + * Get given eswitch manager id. + * Used in HWS match with port creation. + */ +static __rte_always_inline const struct flow_hw_port_info * +flow_hw_get_esw_mgr_id(void *dr_ctx) +{ +#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) + uint16_t port_id; + + MLX5_ETH_FOREACH_DEV(port_id, NULL) { + struct mlx5_priv *priv; + + priv = rte_eth_devices[port_id].data->dev_private; + if (priv->dr_ctx == dr_ctx) + return &priv->sh->dev_cap.esw_info; + } +#else + RTE_SET_USED(dr_ctx); +#endif + return NULL; +} + /* * Get metadata match tag and mask for given rte_eth_dev port. * Used in HWS rule creation. */ static __rte_always_inline const struct flow_hw_port_info * -flow_hw_conv_port_id(const uint16_t port_id) +flow_hw_conv_port_id(void *ctx, const uint16_t port_id) { struct flow_hw_port_info *port_info; + if (port_id == UINT16_MAX && ctx) + return flow_hw_get_esw_mgr_id(ctx); + if (port_id >= RTE_MAX_ETHPORTS) return NULL; port_info = &mlx5_flow_hw_port_infos[port_id]; @@ -2043,7 +2063,7 @@ flow_hw_get_wire_port(struct ibv_context *ibctx) struct ibv_context *port_ibctx = priv->sh->cdev->ctx; if (port_ibctx->device == ibdev) - return flow_hw_conv_port_id(port_id); + return flow_hw_conv_port_id(priv->dr_ctx, port_id); } } return NULL; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 14cdd4468d..c30fbefe96 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -10839,17 +10839,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; @@ -10870,7 +10884,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