From patchwork Tue Oct 17 00:43:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 132683 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2CBE43184; Tue, 17 Oct 2023 02:44:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8056240689; Tue, 17 Oct 2023 02:44:44 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) by mails.dpdk.org (Postfix) with ESMTP id 0C0494021D for ; Tue, 17 Oct 2023 02:44:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cCLcYdDtXnjlGwJsiKsvU3AFB5LI6erFQVCHVkgnOOBrHVB78gvBE+g+bsKVySldI9esvVtO2mcSfGCArhy9S3HYFG/mT3rEyZvud0lgjYpKrqNJCFdeLebqeP/ld84cPxZuO4KDP246dz23r6RWxKmPpjLUB+aXB7Rw/O+GSRpHDTzjOQKmhJls0tJUmtr++Hf9hx5r1Lk8+cLoakMtfqdzeNIh+NR4z4VkoLXB07LyC1WpVyaqFrEIJAiMK6wHKZmMH44IY6RoKZPWIcc8yKRDhFalaVZd+feJsJqtZKiRcVfQxGbCjuWyFYGyZUCFBmGMbwn3nvfC2StIfqzyng== 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=W9Ju/SljZ6nYnRZmRHRqEQ8g1RkGyrxP1EZNQjDavh8=; b=GLDpsM8gvBiqTbAXW6zheBTcr/s81fh2r6cj0+Qoas9Ya4H8muYBrkyR5sQzcC4i4eDxm6eKRNTVYzbxjKzQ1/PzBKjNy2lQUXy0St1vrNPfTCidjIrwQ7W/LJi+oLxfTw4/WQDwuMsB7inLHZTAYlqoRFm4CBclEXwVFNLWlrFPt2Y4bqyVSV+xQnuBCy5mMahvsyC2wy9L7AFd43ZiAK+xhPEDiI0Hd4y5pz2/LKm2oYahpUnAb4+pISwazXVjYkZA2WIdtewbU9RYpNZDcyub9FQvB7wHeC3/4cZvr5g07IP6gJsO/BxyBnn8TsUxWNbQCVd30KkWOp3x1JG8mw== 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 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=W9Ju/SljZ6nYnRZmRHRqEQ8g1RkGyrxP1EZNQjDavh8=; b=dpL+baTLvKeeNB+tOUGNZ4dPK14m8ZccN7I6H/7Lq2hOuaZ7jLPHEfREDGdgnfLvV3TjFMz9drZsByw29aTXzZuELXZvNJS7jiT5w8PIjjZBF2jp+8GbXjTye5i3KuOPFA9B/AD7NEhVVXMuvh27+q7QJbWN5V0D/ixoezklAVA9hPws2dpNHRDV5fkrjc+pyu90Y4o7TUseB24dNy9K7LoAynE7V0aBkbPJ435L/N71TB82shYTSKyF1eISCgmsalp+PeMxInVZYStJPVx9MhNvWtH0Y+avg4Kx3khvD2hKVALQFBaKjSJuetfz1x05VqZ2OdUAm0RSR2FUjN5qEQ== Received: from MN2PR12CA0014.namprd12.prod.outlook.com (2603:10b6:208:a8::27) by PH0PR12MB8030.namprd12.prod.outlook.com (2603:10b6:510:28d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34; Tue, 17 Oct 2023 00:44:40 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:a8:cafe::f2) by MN2PR12CA0014.outlook.office365.com (2603:10b6:208:a8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35 via Frontend Transport; Tue, 17 Oct 2023 00:44:40 +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 MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Tue, 17 Oct 2023 00:44:39 +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; Mon, 16 Oct 2023 17:44:26 -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.986.41; Mon, 16 Oct 2023 17:44:22 -0700 From: Suanming Mou To: , Matan Azrad , Viacheslav Ovsiienko CC: , Subject: [PATCH 1/3] net/mlx5: add port representor action Date: Tue, 17 Oct 2023 08:43:59 +0800 Message-ID: <20231017004401.698745-2-suanmingm@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017004401.698745-1-suanmingm@nvidia.com> References: <20231017004401.698745-1-suanmingm@nvidia.com> MIME-Version: 1.0 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: MN1PEPF0000F0E2:EE_|PH0PR12MB8030:EE_ X-MS-Office365-Filtering-Correlation-Id: f6409ea6-3f13-4259-648d-08dbceaa3efa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JqZHb7thlOHIkWDHaLehl0ACpc2YBtHvH1CGcnuXJmHCY1aIiOLeXpzWo4zkE3RFuncF17EH0yIix8OsVJLtSdUaXOo7j1Z4mJSeiO33ftr942jYa4DSFxxCu18qlg+es33gneY1Ki5dVH1dsTE8bgs+I2DGI6ghhKnFE3mpKrNUL3wIWgazP+kRzVGWQJiiK3j8uFFuwglfbFRW2/sooSIffOEDnIl9tFEdIKTJqffLpe/KKLVre15X1yzIer0MyuR89d5ttFNlQuBq0JNMXG2Zv7st1N3Q+9gDglNWWyuhihllhaqPqe7NQzObtFiK3alt+Pr2BjWoqoDMeQwABLhBm1y570FxE65yXjit4VQpMdZ/gO7n8g1lkeDOaFAnC2LB91lJy/r/jx7KmXpaXp8qazRpchVG/9NLld6kulLRoivPXrWGW75/C2ouSswj72Ty7J9FA9HcFm7dGvPQA6Ktw6+K9lFGoScrx7EQTEtJ+vD5E/jw48hcIbNOMLIr12b9cva25RLpSrY+RaaoIn8cc/KlFg7oGoz9REZlEogyxcj40qAHWeOsiptxmUIJSEkUizYUw2zd6jEogstMRVLhQ2/xm4jw/ZiIi3xKamlsHqejc+mUxRFZds5NE5OWJp1A6FCZ2KVmMpv0iaoXNl8cbBwlqxLU/hLI26haVGfAZlnEfkU6hvOOtQ8PK4YnzPqIRQJIRZxRz/RlBPtPsZ2+bywsqKTMT3C9QQt0wuhoJkJe84YvL49/w7JFMBTg 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)(4636009)(346002)(39860400002)(376002)(136003)(396003)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(82310400011)(46966006)(40470700004)(36840700001)(55016003)(40460700003)(40480700001)(356005)(82740400003)(36756003)(36860700001)(7636003)(47076005)(83380400001)(6286002)(26005)(7696005)(16526019)(6666004)(70586007)(70206006)(478600001)(2616005)(6636002)(426003)(1076003)(54906003)(336012)(110136005)(316002)(2906002)(41300700001)(86362001)(8676002)(4326008)(5660300002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 00:44:39.7385 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6409ea6-3f13-4259-648d-08dbceaa3efa 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: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8030 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 The packets handled by port representor action will be steered to E-Switch manager and received by software. This commit adds port representor action. Signed-off-by: Suanming Mou --- doc/guides/nics/mlx5.rst | 6 ++++ drivers/net/mlx5/mlx5.h | 2 ++ drivers/net/mlx5/mlx5_flow.h | 4 ++- drivers/net/mlx5/mlx5_flow_hw.c | 55 +++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 7086f3d1d4..3c1da980e2 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -728,6 +728,12 @@ 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. +- A driver limitation for ``RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR`` action restricts + the ``port_id`` configuration to only accept the value 0xffff, indicating the E-Switch + manager. If the ``repr_matching_en`` flag is enabled, the traffic will be directed + to the representor of the source virtual port (SF/VF), while if it is disabled, the + traffic will be routed based on the steering rules in the ingress domain. + Statistics ---------- diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index f3b872f59c..dad3600aa0 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1858,6 +1858,8 @@ struct mlx5_priv { struct mlx5dr_action *hw_drop[2]; /* HW steering global tag action. */ struct mlx5dr_action *hw_tag[2]; + /* HW steering global default miss action. */ + struct mlx5dr_action *hw_def_miss; /* HW steering global send to kernel action. */ struct mlx5dr_action *hw_send_to_kernel[MLX5DR_TABLE_TYPE_MAX]; /* HW steering create ongoing rte flow table list header. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 53c11651c8..a851c6b506 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -359,6 +359,7 @@ enum mlx5_feature_name { #define MLX5_FLOW_ACTION_INDIRECT_COUNT (1ull << 43) #define MLX5_FLOW_ACTION_INDIRECT_AGE (1ull << 44) #define MLX5_FLOW_ACTION_QUOTA (1ull << 46) +#define MLX5_FLOW_ACTION_PORT_REPRESENTOR (1ull << 47) #define MLX5_FLOW_DROP_INCLUSIVE_ACTIONS \ (MLX5_FLOW_ACTION_COUNT | MLX5_FLOW_ACTION_SAMPLE | MLX5_FLOW_ACTION_AGE) @@ -368,7 +369,8 @@ enum mlx5_feature_name { MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \ MLX5_FLOW_ACTION_DEFAULT_MISS | \ MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \ - MLX5_FLOW_ACTION_SEND_TO_KERNEL) + MLX5_FLOW_ACTION_SEND_TO_KERNEL | \ + MLX5_FLOW_ACTION_PORT_REPRESENTOR) #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 5114cc1920..9feb40ddb3 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -1726,6 +1726,13 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev, acts->rule_acts[dr_pos].action = priv->hw_drop[!!attr->group]; break; + case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: + if (!attr->group) { + DRV_LOG(ERR, "Port representor is not supported in root table."); + goto err; + } + acts->rule_acts[dr_pos].action = priv->hw_def_miss; + break; case RTE_FLOW_ACTION_TYPE_MARK: acts->mark = true; if (masks->conf && @@ -4140,6 +4147,36 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action, "MPLS cannot be used as destination"); return 0; } +static int +flow_hw_validate_action_port_representor(struct rte_eth_dev *dev __rte_unused, + const struct rte_flow_actions_template_attr *attr, + const struct rte_flow_action *action, + const struct rte_flow_action *mask, + struct rte_flow_error *error) +{ + const struct rte_flow_action_ethdev *action_conf = NULL; + const struct rte_flow_action_ethdev *mask_conf = NULL; + + /* If transfer is set, port has been validated as proxy port. */ + if (!attr->transfer) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "cannot use port_representor actions" + " without an E-Switch"); + if (!action || !mask) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "actiona and mask configuration must be set"); + action_conf = action->conf; + mask_conf = mask->conf; + if (!mask_conf || mask_conf->port_id != MLX5_REPRESENTED_PORT_ESW_MGR || + !action_conf || action_conf->port_id != MLX5_REPRESENTED_PORT_ESW_MGR) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "only eswitch manager port 0xffff is" + " supported"); + return 0; +} static int flow_hw_validate_action_represented_port(struct rte_eth_dev *dev, @@ -4504,6 +4541,7 @@ flow_hw_template_expand_modify_field(struct rte_flow_action actions[], case RTE_FLOW_ACTION_TYPE_QUEUE: case RTE_FLOW_ACTION_TYPE_RSS: case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: + case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: case RTE_FLOW_ACTION_TYPE_VOID: case RTE_FLOW_ACTION_TYPE_END: @@ -4740,6 +4778,13 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, return ret; action_flags |= MLX5_FLOW_ACTION_PORT_ID; break; + case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: + ret = flow_hw_validate_action_port_representor + (dev, attr, action, mask, error); + if (ret < 0) + return ret; + action_flags |= MLX5_FLOW_ACTION_PORT_REPRESENTOR; + break; case RTE_FLOW_ACTION_TYPE_AGE: if (count_mask && count_mask->id) fixed_cnt = true; @@ -4818,6 +4863,7 @@ static enum mlx5dr_action_type mlx5_hw_dr_action_types[] = { [RTE_FLOW_ACTION_TYPE_NVGRE_DECAP] = MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2, [RTE_FLOW_ACTION_TYPE_MODIFY_FIELD] = MLX5DR_ACTION_TYP_MODIFY_HDR, [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = MLX5DR_ACTION_TYP_VPORT, + [RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR] = MLX5DR_ACTION_TYP_MISS, [RTE_FLOW_ACTION_TYPE_CONNTRACK] = MLX5DR_ACTION_TYP_ASO_CT, [RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = MLX5DR_ACTION_TYP_POP_VLAN, [RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN] = MLX5DR_ACTION_TYP_PUSH_VLAN, @@ -8215,6 +8261,11 @@ flow_hw_configure(struct rte_eth_dev *dev, goto err; } if (is_proxy) { + /* Only supported on proxy port. */ + priv->hw_def_miss = mlx5dr_action_create_default_miss + (priv->dr_ctx, MLX5DR_ACTION_FLAG_HWS_FDB); + if (!priv->hw_def_miss) + goto err; ret = flow_hw_create_vport_actions(priv); if (ret) { rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -8303,6 +8354,8 @@ flow_hw_configure(struct rte_eth_dev *dev, if (priv->hw_tag[i]) mlx5dr_action_destroy(priv->hw_tag[i]); } + if (priv->hw_def_miss) + mlx5dr_action_destroy(priv->hw_def_miss); flow_hw_destroy_vlan(dev); if (dr_ctx) claim_zero(mlx5dr_context_close(dr_ctx)); @@ -8375,6 +8428,8 @@ flow_hw_resource_release(struct rte_eth_dev *dev) if (priv->hw_tag[i]) mlx5dr_action_destroy(priv->hw_tag[i]); } + if (priv->hw_def_miss) + mlx5dr_action_destroy(priv->hw_def_miss); flow_hw_destroy_vlan(dev); flow_hw_destroy_send_to_kernel_action(priv); flow_hw_free_vport_actions(priv);