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 C09AD43EDC for ; Mon, 22 Apr 2024 18:51:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95CB5402F1; Mon, 22 Apr 2024 18:51:40 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2063.outbound.protection.outlook.com [40.107.212.63]) by mails.dpdk.org (Postfix) with ESMTP id C0AC7402C5 for ; Mon, 22 Apr 2024 18:51:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nntnu37RrN8CMtGut5YwUYK0JPKQ8ytNa4pY3gml7NY0hJydT3CCMBpNynUR2wdARDUFft4dNpL+Y/FnTWvp203UD5ULmHdmx5dm1V+nXLXUdpKl1UGExAiBW+Dc27rmOWG0ouJWmIh/xDNHfl7SOdHnAOWp2bqWPMf2rrufEWl0hsd+CyxyrBle5mV/3Pehk/PZ13wq2UYbBO9pk9T0hfyTkUncUnisA7yI2V2WM3XiGvUiUFEZYOuP4qNW3wCP6JFKW55FaecXkD0tfBUG7MVAR686Sp7sF/0nde7UELazJPTyNRxDab8F5laOhSOpfGmqNcpazBUyQqyC5rJ6Aw== 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=VtQkbG8Kp49iDg9moa3tyurTdRRKdsDYeGT5+Oc1AH4=; b=cpvk+ZHwO8p7T8CV/mhLnyaU3oqvyahNyl13lgYn/WRXq64DW9kMwUtdBiV09ECGNmneC+8ZmkuEPhdn383CWiiO/RmlqaD9MLi4Y0GkJec9EqFbL2aCk5oZcvvTyX55v1dH2qfLL6rPh0beVRSk3TN9xexKrRbK8O9IzX3xUasyLpKdHLxhN3LpjV32yN/dzXSPviwAW92LENfBo9rJIVLmjw54KVSiFCiY20yySuLzFN1doGL9gK+hFq9aq0K/H+nkFxxCTmGV0AtaAWOlHN0S3v1da3ZZXizeq6KDLXSQuCZtjrsJqI9V537I93h7u5I5qnA8pityBRRpheKF7Q== 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=VtQkbG8Kp49iDg9moa3tyurTdRRKdsDYeGT5+Oc1AH4=; b=kgQ1agQTM1DkNGbEVrDwAyRshcyBBfAUM4wB6AcSprDVz/D4xIStxqIN+9O3Zmdr8zzjLANrhristAoTYTG+OQibola+Amyka171dhyjRv/6A+qNwxuE/F/4vsinCyBwN/8CqFB8ObxFJtzdjO5jDAboBjZcJiugOZWL3BIocwwuZEOEgNiurNA0ZcTb7GOET5roOvDzJf3t0E/q/Suu1PB/hScZqrRPnzaZ6ANFi1INGWqJ/ckYdKPtuuq04RaFpG6wUkbCuiE+znMmHO+1buXoxxbOB/EhEJRzOw76+IJ84q+Y9oTLRLApWwRoXqLTahgwgOFVhlYY/5L/UYarSQ== Received: from MW4PR03CA0284.namprd03.prod.outlook.com (2603:10b6:303:b5::19) by SJ0PR12MB7034.namprd12.prod.outlook.com (2603:10b6:a03:449::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 16:51:35 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:303:b5:cafe::54) by MW4PR03CA0284.outlook.office365.com (2603:10b6:303:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.31 via Frontend Transport; Mon, 22 Apr 2024 16:51:35 +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 MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Mon, 22 Apr 2024 16:51:35 +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; Mon, 22 Apr 2024 09:51:14 -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; Mon, 22 Apr 2024 09:51:12 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad , "Erez Shitrit" , Alex Vesker CC: , Yevgeny Kliteynik Subject: [PATCH 23.11 1/3] net/mlx5/hws: fix port ID for root table Date: Mon, 22 Apr 2024 18:50:14 +0200 Message-ID: <20240422165016.197542-2-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240422165016.197542-1-dsosnowski@nvidia.com> References: <20240422165016.197542-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|SJ0PR12MB7034:EE_ X-MS-Office365-Filtering-Correlation-Id: 093b2ee0-b7e2-41cd-4627-08dc62ec7891 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?C3T/qDympZ41nn5SFgK7xMyFmsxU/fC0hovPGV7O+wDeZHjUMZKLSvBPNV2H?= =?us-ascii?Q?gSGKhSSczSxdaGIW4B+41k5rGLwIij+MnbF4ro3Itp9dTc1Fe2LaN1rbXUXy?= =?us-ascii?Q?yeiTfyq6SauAor/K8jsQhg4qtmucaueQLP5FLAcQgfVzm15lXKGiyh/L0e/1?= =?us-ascii?Q?1BM0H+oAPTWeU+cB+mDCgEr5glwccY4JEnmyucQLT34zYiz4y67PqVAdW/9H?= =?us-ascii?Q?PqZpJf+GMoHe3jewYAjiLwaEshnFNz/Oyuc301gKrfJgyV5BzJRbqf9mtO6x?= =?us-ascii?Q?yuF2XBBThFjlXUu5xdk2wMB6bebIRvIJw1CJwE4aaiiBT+cG01kh4l6N4yUu?= =?us-ascii?Q?f1jNl5keYhfexNEnAPTnmQYGQYv+meWwKbfYQuto1bG3eXp7oGkXzC2ngBkC?= =?us-ascii?Q?R9hcLUJ5OjndEGi2iaJcva7X9z/QvEkfUzbbanx1RX5Q7ls53X2mUGUmGAa3?= =?us-ascii?Q?edVyhGKtmtSHSZ3eUOEvPCogIRpg+ZQU+RMrvgOcFRA6pl9fzM6pUz9VtCpz?= =?us-ascii?Q?SqKc2ymRuYiuUvS8Lhqi3bdjoavH1yy9rR9i/TQ5ZGr6DCxNs55wnkLDDRyz?= =?us-ascii?Q?o7apfkJZpJu3ys4t9VxSilRf5stOdHk/QczWK+JXT7kjo8OGCNReJBg6Wzwe?= =?us-ascii?Q?W+tLyZ6Fs+VT+Tm6ZB8lHtXLHvpPf7F3SSYC9u6ErzGNasjnv8RoeEszGDBK?= =?us-ascii?Q?+V3uMiAprQLm6DUwY241QsjyBoI30Cv6a3pW2cNwtSdiB8QqA+NDTHijCfSG?= =?us-ascii?Q?yYRmkrbkAbUzLeM6f4pK5ci1bO0wC0Qejd0O/BC6LHinihRQ8S5EEC/jfs8a?= =?us-ascii?Q?ppetnMJRT6gftPeqcxucMtZcbEFKt0YvfgBnZtJUVYqQJigaehTW8qwrpydR?= =?us-ascii?Q?IL2FwLy4W+L2F1hR/c1IDnHwzuMc8+BuhHPZYc7Qr6ZIqSJ/x6ZWiG7FmnjJ?= =?us-ascii?Q?adRda9b9LNQzdCiIy0HSBF1KOkOQZlLUnGR5AW4bMTE2vrxikDLUAHmh+hyS?= =?us-ascii?Q?SfvG98T6+wp9xBaRxze7x5lKtonVRuiTBuOD1nUY+JbnEmdxUt7BF4p5B1pM?= =?us-ascii?Q?P0Pix7ZsBM5SjamAZWdXb7IuR3+p4vMUuo5yThIyUNhqpoaYgpg0n5w2d6i8?= =?us-ascii?Q?PGRINei9xycTXyVrsQy1bJl1omFFDBw7omWoUaGUPxCQHLts2RI1kYsEGQtj?= =?us-ascii?Q?3yruzlhvenocIEz68rkykGogl9T4bMwgVzaOhGvvnIT2AOyDS2jgWxzC6IEo?= =?us-ascii?Q?Kci4daYUem0jC8bNQjd5eMIN0mFvd15ynQGJEjNViBxkQx0Uyz0mAnnsCuwi?= =?us-ascii?Q?gDq47xiqMQMKdI3n//oYTuM/PCihBsFARjGtHgOBNh+JHF9JZmIgmGXjcN3i?= =?us-ascii?Q?bFpH7MY=3D?= 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)(82310400014)(1800799015)(376005)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 16:51:35.2795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 093b2ee0-b7e2-41cd-4627-08dc62ec7891 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: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7034 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Erez Shitrit [ upstream commit 572fe9ef2f461b7e7e195a3a4da5bf0c11f35949 ] In root tables matcher and rule need to have their port-id, otherwise the translate function that done in dpdk layer will not get the right attributes. For that whenever the matcher is matching the source-port we need to get the relevant port-id before calling the translate function. Fixes: 405242c52dd5 ("net/mlx5/hws: add rule object") Cc: stable@dpdk.org Signed-off-by: Erez Shitrit Signed-off-by: Yevgeny Kliteynik Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr_matcher.c | 17 +++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_rule.c | 18 ++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 22 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index 4ea161eae6..71478dab33 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -1143,6 +1143,7 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher) struct mlx5dv_flow_match_parameters *mask; struct mlx5_flow_attr flow_attr = {0}; struct rte_flow_error rte_error; + struct rte_flow_item *item; uint8_t match_criteria; int ret; @@ -1171,6 +1172,22 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher) return rte_errno; } + /* We need the port id in case of matching representor */ + item = matcher->mt[0].items; + while (item->type != RTE_FLOW_ITEM_TYPE_END) { + if (item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR || + item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) { + ret = flow_hw_get_port_id_from_ctx(ctx, &flow_attr.port_id); + if (ret) { + DR_LOG(ERR, "Failed to get port id for dev %s", + ctx->ibv_ctx->device->name); + rte_errno = EINVAL; + return rte_errno; + } + } + ++item; + } + mask = simple_calloc(1, MLX5_ST_SZ_BYTES(fte_match_param) + offsetof(struct mlx5dv_flow_match_parameters, match_buf)); if (!mask) { diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c index 77245ad97d..02d57409ab 100644 --- a/drivers/net/mlx5/hws/mlx5dr_rule.c +++ b/drivers/net/mlx5/hws/mlx5dr_rule.c @@ -594,10 +594,28 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule, struct mlx5dv_flow_match_parameters *value; struct mlx5_flow_attr flow_attr = {0}; struct mlx5dv_flow_action_attr *attr; + const struct rte_flow_item *cur_item; struct rte_flow_error error; uint8_t match_criteria; int ret; + /* We need the port id in case of matching representor */ + cur_item = items; + while (cur_item->type != RTE_FLOW_ITEM_TYPE_END) { + if (cur_item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR || + cur_item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) { + ret = flow_hw_get_port_id_from_ctx(rule->matcher->tbl->ctx, + &flow_attr.port_id); + if (ret) { + DR_LOG(ERR, "Failed to get port id for dev %s", + rule->matcher->tbl->ctx->ibv_ctx->device->name); + rte_errno = EINVAL; + return rte_errno; + } + } + ++cur_item; + } + attr = simple_calloc(num_actions, sizeof(*attr)); if (!attr) { rte_errno = ENOMEM; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 7a5e334a83..bde7dc43a8 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1759,6 +1759,28 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx, return REG_NON; } +static __rte_always_inline int +flow_hw_get_port_id_from_ctx(void *dr_ctx, uint32_t *port_val) +{ +#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) + uint32_t port; + + MLX5_ETH_FOREACH_DEV(port, NULL) { + struct mlx5_priv *priv; + priv = rte_eth_devices[port].data->dev_private; + + if (priv->dr_ctx == dr_ctx) { + *port_val = port; + return 0; + } + } +#else + RTE_SET_USED(dr_ctx); + RTE_SET_USED(port_val); +#endif + return -EINVAL; +} + void flow_hw_set_port_info(struct rte_eth_dev *dev); void flow_hw_clear_port_info(struct rte_eth_dev *dev); int flow_hw_create_vport_action(struct rte_eth_dev *dev); -- 2.39.2