From patchwork Fri Feb 3 13:33:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawei Wang X-Patchwork-Id: 123038 X-Patchwork-Delegate: ferruh.yigit@amd.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 44B9E41BBD; Fri, 3 Feb 2023 14:34:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2CDC941611; Fri, 3 Feb 2023 14:34:18 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2056.outbound.protection.outlook.com [40.107.244.56]) by mails.dpdk.org (Postfix) with ESMTP id DF6A541148 for ; Fri, 3 Feb 2023 14:34:16 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cd2BvqPVYAmniqAdXxSmLVQFZ9EvLXaswWbvceEd3CHn7ViDjice0m0E0ZwSiMotG68NdG8izqIYrFcAFa7E0NIpVPT3x5q7QX2wSsiijOsJwoowVuB1ZkL87YDDjULEW9uxsXjENNR1xeSmDH50I5l6tGTjeV9waPsIyBlapC594ZaHltQ7Y5F3p2TzCDNdc1tItzm7GSoVCP4jEa09N5qgF+8hAtPNI+sJ4v6gWSTBWtdLQIK1jSmzPAtq0NIYNXdcvRUSX85phPuvt5r/Npg0ow9TOmb0s0IW148fLMZeMrgX7r4xPPIG/W3Q9NT7BNqQI49Kke5z5mpayF/7cg== 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=AM2sNpxJ6ih/br/xuX9JBtKP3MkPkWUtNqeiAu7xKYg=; b=aZgUwrc6LM2H0pK79TDLIEq+gU/6dekfAsPjgJQMDseI7wuCFTEhxy85/5Ue42ljTyr/f8zjXS8PLwxWvGDH3fBaCFQPHxtVwT3CW7zr6jVAFH/OWdt6a5TNKZDYV33xOkFuakt8Yq7H1exuwCQw3LHAfPaHjml5txXTE6VP6PyFDcBX5LzSfGpDZnva2Nt6qWThCtNNiUmnJTRAGn4RMIeAKE5hg4ED+6hMmPMyA0pgowVMgW8O/4zL12BXP5Uzd1pp+vjqfdxPvgO7OzujKZkY7kozFqs6pcfiNS+u4Jrtgxh47VHgOkGC27CNsjvDfIF0EaXIgvxe1Vm8daoKeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net 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=AM2sNpxJ6ih/br/xuX9JBtKP3MkPkWUtNqeiAu7xKYg=; b=suODKBS3pJTEfl9vcJOSzSNONWWSjRSjCOADoFlTWUhXVPWVkVMYRt5layxT21hnpVMZgswEQdpwM0iQx7SSjdUj30k6bM0vhOgnf+z8RCn3l0ozhnMjup13IOYEY8VGwxjSfSzVnnmIgk+s5PwylBZIk02qJGwQvEruWxdAw1nODCNrgMlgT3snTlPJcoLqZcv4x/Vib/hqsF4WzWxEDjq1djQod4MvcktMtMm45Gu0NFRtfK7UbO77xdwsCzXJnj+61SMTNRgERBMfM5EMV6BgMYcQ2uGwz8wmT54cx3vOb2XxoK7TXvTYcreXdSEsZENXI/VM6nijRSbs3Ll66g== Received: from DM5PR07CA0110.namprd07.prod.outlook.com (2603:10b6:4:ae::39) by DS0PR12MB7629.namprd12.prod.outlook.com (2603:10b6:8:13e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 13:34:14 +0000 Received: from DS1PEPF0000E65D.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::18) by DM5PR07CA0110.outlook.office365.com (2603:10b6:4:ae::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.31 via Frontend Transport; Fri, 3 Feb 2023 13:34:14 +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 DS1PEPF0000E65D.mail.protection.outlook.com (10.167.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.21 via Frontend Transport; Fri, 3 Feb 2023 13:34:14 +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.36; Fri, 3 Feb 2023 05:34:05 -0800 Received: from nvidia.com (10.126.231.37) 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.36; Fri, 3 Feb 2023 05:34:02 -0800 From: Jiawei Wang To: , , , , Aman Singh , Yuying Zhang , Ferruh Yigit CC: , Subject: [PATCH v4 2/2] ethdev: add PHY affinity match item Date: Fri, 3 Feb 2023 15:33:39 +0200 Message-ID: <20230203133339.30271-3-jiaweiw@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20230203133339.30271-1-jiaweiw@nvidia.com> References: <20230203050717.46914-1-jiaweiw@nvidia.com> <20230203133339.30271-1-jiaweiw@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] 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: DS1PEPF0000E65D:EE_|DS0PR12MB7629:EE_ X-MS-Office365-Filtering-Correlation-Id: 731068c2-c408-41c6-b0a3-08db05eb579b X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jWmxpq5pWlbSXZhLY3yGKVscvkjc98b/9YN6+zJC3jXLs8MZ2ds17/2ZQ/2Bywnv82EKCkeVmKqFP+bm0j6vJdipIi87W6y+mKyj6Ac0HTnvvHW4x0GRkJOrbYgchHAtiTmvmpiO3UQCKSvNw0u17S4EG2wvp/jgDwz084KVs5iWEDytpUb4YgyQj3XsriVOMXSOjjb/IZ41I+29axeXh0VNno/4UwUfLxqD9MHaKZe6EkErD91Qqx06yKp4xE5Y3lhNsUOUcnKxKZ/az/YFJwMlL4RSpmB6Bk+XQh9Q8Ym1xAX3sG254Py7D7AHUC81yX8T5ooXgnFTwR2fvCLpw77LsIZLMRqxqmbE2k46ydyxMiavhE8TEBBBgAW/B/tIN56q0h2Kmi3l0+Fl+QYgifDec7xumFbRvqsBGXX+ZXvtBHABOFzZRJaAENg40igE1aUSEhOVHbQuf/nngLmLEJ5NreddoMpspzTNCkl1KPr4Ao2NT3qc877Uv7NbV11BhaX3J0D2y1Scak//31ENErpNZRgtclMgX+gele9PATv/aJkSn68ERsalJRVWWe0OJFMkhX3aTcOAnYzjG1nScTYcZ47dw54V0g00xOgWnUN/AHLdAIW4zN+1t9evSGQou0q1kO6IWcfUVFMilLXXoNKGpVlnD/WToK9grH4x5sMfvxYXyRjiImLjPJv7FkQaGSNY9cv4Sb43+cV34wHahA== 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:(13230025)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199018)(36840700001)(40470700004)(46966006)(356005)(55016003)(40480700001)(47076005)(7636003)(336012)(2616005)(426003)(83380400001)(82740400003)(36860700001)(40460700003)(8676002)(70586007)(70206006)(8936002)(41300700001)(5660300002)(86362001)(2906002)(4326008)(107886003)(7696005)(478600001)(54906003)(6666004)(1076003)(316002)(186003)(82310400005)(6286002)(26005)(110136005)(36756003)(16526019); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 13:34:14.6769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 731068c2-c408-41c6-b0a3-08db05eb579b 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: DS1PEPF0000E65D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7629 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 When multiple physical ports are connected to a single DPDK port, (example: kernel bonding, DPDK bonding, failsafe, etc.), we want to know which physical port is used for Rx and Tx. This patch allows to map a Rx queue with a physical port by using a flow rule. The new item is called RTE_FLOW_ITEM_TYPE_PHY_AFFINITY. While uses the phy affinity as a matching item in the flow rule, and sets the same phy_affinity value on the Tx queue, then the packet can be sent from the same physical port as the receiving one. The physical affinity numbering starts from 1, then trying to match on phy_affinity 0 will result in an error. Add the testpmd command line to match the new item: flow create 0 ingress group 0 pattern phy_affinity affinity is 1 / end actions queue index 0 / end The above command means that creates a flow on a single DPDK port and matches the packet from the first physical port and redirects these packets into Rx queue 0. Signed-off-by: Jiawei Wang Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 28 +++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 8 +++++ doc/guides/rel_notes/release_23_03.rst | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 35 +++++++++++++++++++++ 6 files changed, 77 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..5e9e617674 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -465,6 +465,8 @@ enum index { ITEM_METER, ITEM_METER_COLOR, ITEM_METER_COLOR_NAME, + ITEM_PHY_AFFINITY, + ITEM_PHY_AFFINITY_VALUE, /* Validate/create actions. */ ACTIONS, @@ -1355,6 +1357,7 @@ static const enum index next_item[] = { ITEM_L2TPV2, ITEM_PPP, ITEM_METER, + ITEM_PHY_AFFINITY, END_SET, ZERO, }; @@ -1821,6 +1824,12 @@ static const enum index item_meter[] = { ZERO, }; +static const enum index item_phy_affinity[] = { + ITEM_PHY_AFFINITY_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -6443,6 +6452,22 @@ static const struct token token_list[] = { ARGS_ENTRY(struct buffer, port)), .call = parse_mp, }, + [ITEM_PHY_AFFINITY] = { + .name = "phy_affinity", + .help = "match on the physical port receiving the packets", + .priv = PRIV_ITEM(PHY_AFFINITY, + sizeof(struct rte_flow_item_phy_affinity)), + .next = NEXT(item_phy_affinity), + .call = parse_vc, + }, + [ITEM_PHY_AFFINITY_VALUE] = { + .name = "affinity", + .help = "physical affinity value", + .next = NEXT(item_phy_affinity, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_affinity, + affinity)), + }, }; /** Remove and return last entry from argument stack. */ @@ -10981,6 +11006,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_METER_COLOR: mask = &rte_flow_item_meter_color_mask; break; + case RTE_FLOW_ITEM_TYPE_PHY_AFFINITY: + mask = &rte_flow_item_phy_affinity_mask; + break; default: break; } diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..fa43b9bb66 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1544,6 +1544,14 @@ Matches Color Marker set by a Meter. - ``color``: Metering color marker. +Item: ``PHY_AFFINITY`` +^^^^^^^^^^^^^^^^^^^^^^ + +Matches on the physical port of the received packet. +In case of multiple physical ports, the affinity numbering starts from 1. + +- ``affinity``: Physical affinity. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index e99bd2dcb6..320b7f2efc 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -58,6 +58,7 @@ New Features * **Added affinity for multiple physical ports connected to a single DPDK port.** * Added Tx affinity in queue setup to map a physical port. + * Added Rx affinity flow matching of a physical port. * **Updated AMD axgbe driver.** diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 5c716f7679..6079ca1ed6 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3754,6 +3754,10 @@ This section lists supported pattern items and their attributes, if any. - ``color {value}``: meter color value (green/yellow/red). +- ``phy_affinity``: match physical port. + + - ``affinity {value}``: physical port (starts from 1). + - ``send_to_kernel``: send packets to kernel. diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..0c2d3b679b 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -157,6 +157,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)), + MK_FLOW_ITEM(PHY_AFFINITY, sizeof(struct rte_flow_item_phy_affinity)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..da32f9e383 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -624,6 +624,15 @@ enum rte_flow_item_type { * See struct rte_flow_item_meter_color. */ RTE_FLOW_ITEM_TYPE_METER_COLOR, + + /** + * Matches on the physical port of the received packet. + * Used in case multiple physical ports are connected to the DPDK port. + * First port is number 1. + * + * @see struct rte_flow_item_phy_affinity. + */ + RTE_FLOW_ITEM_TYPE_PHY_AFFINITY, }; /** @@ -2103,6 +2112,32 @@ static const struct rte_flow_item_meter_color rte_flow_item_meter_color_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_PHY_AFFINITY + * + * For multiple physical ports connected to a single DPDK port, + * match the physical port receiving the packets. + */ +struct rte_flow_item_phy_affinity { + /** + * Physical port receiving the packets. + * Numbering starts from 1. + * Number of physical ports is reported by nb_phy_ports in rte_eth_dev_info. + */ + uint8_t affinity; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PHY_AFFINITY. */ +#ifndef __cplusplus +static const struct rte_flow_item_phy_affinity +rte_flow_item_phy_affinity_mask = { + .affinity = 0xff, +}; +#endif + /** * Action types. *