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 7758FA034C; Wed, 21 Dec 2022 11:30:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B4F742D12; Wed, 21 Dec 2022 11:30:35 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2064.outbound.protection.outlook.com [40.107.244.64]) by mails.dpdk.org (Postfix) with ESMTP id 5459642D12 for ; Wed, 21 Dec 2022 11:30:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fdzj3vB1rLReBHpLeCt4+2V9SSM947+FrD9I4CG0ewD15DfXEE69p8bHkrju8A+PvABr3NmHw+8zipgmDTuuK3Yxj4cghgC9KmyyPl/Zo+suD2+NJU3hCxv2LCID9NqzbfaiIDyhRUmuCCFdz7e7LAzz9VhugoXBCcyGEOJuNl2yZD/AbJCdNUowdFfql423H+RVBzm5+TWrEqrSvyYQx4aFz9YQnGQZmJA9pN4tmPs4LwqC6UgIuYf7nm9mEQVXaLn9tSf0WsQLMSusqQK4WSOUPPrCLlOHESbu0dXBOnnTn0yLVJImZ41gX8xgNAjSZo71eexLfYTdY2pgChvN7w== 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=BRO2rc4mbZaywwWnz2rOx00mC7JpV+luOr829hjGKp0=; b=ObyNJEj08OSSixKztp3q9uepyJS2lxKuueVBAs6goYiWgRRmOzWzNXMsvGwuQwGqaeAKEYDepNwh/Mn5or5gau7Dcws0uyEA4nzD9AymADUPvpiPmY2ibWQL/+fEBeW1nhVVn0WjXKFuOz9xPNNBwcHtW22IKSFPo297Kp48F4QQlV6s7t0mGgAktTAGsO5UobLR1ZARmMn4CcX3uTTtLdhIGBTNCBVYcOcvAeoo385dgNX22ptyKG9cVXEMlaZ3e8sG+7Czv3gLci+2l5fbtvm4ygqo2Do9Zr+Hs+65VxxHa0sPr1Xd5s7GDWBbAP/UZQC+SiKN6wNycds1pF0R7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=BRO2rc4mbZaywwWnz2rOx00mC7JpV+luOr829hjGKp0=; b=jDEPnnKHH81pHXLk11hPIpN7knYCCelGXgLGxAhEYBPWvFLrqLCEut+7bNjMRGKCxT65z5MPRO5Xvhdqv58U/33MPNcTn28Hsd8n2tZlA1DvMsgF8OxGzEu+hj/JxrZwSfR/6Xih7F/ZT7l/lVFJtTyf5V0yTdtuvTZ8+KZjJGyITxBgpK2eYd0cLMvAFvy/YX8CAmuVUsZ1aqxmb8qDW6gfO6aDLHuUDpklhbmS+cyJVppEiWe+dB3F5UCu+eQUsHGCPCWFhkz68m1ONHsi9vIk8KRcqgVGzRsPoJCh50n1lGUg22dEJIDRbI077aOF8nm27Gjn0vd5L5zKJKXJGg== Received: from BL0PR05CA0001.namprd05.prod.outlook.com (2603:10b6:208:91::11) by PH7PR12MB8155.namprd12.prod.outlook.com (2603:10b6:510:2b2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 10:30:31 +0000 Received: from BL02EPF00010208.namprd05.prod.outlook.com (2603:10b6:208:91:cafe::48) by BL0PR05CA0001.outlook.office365.com (2603:10b6:208:91::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.5 via Frontend Transport; Wed, 21 Dec 2022 10:30:31 +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 BL02EPF00010208.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.8 via Frontend Transport; Wed, 21 Dec 2022 10:30:30 +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.986.36; Wed, 21 Dec 2022 02:30:15 -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; Wed, 21 Dec 2022 02:30:12 -0800 From: Jiawei Wang To: , , , "Aman Singh" , Yuying Zhang , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [RFC 1/5] ethdev: add port affinity match item Date: Wed, 21 Dec 2022 12:29:30 +0200 Message-ID: <20221221102934.13822-2-jiaweiw@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221221102934.13822-1-jiaweiw@nvidia.com> References: <20221221102934.13822-1-jiaweiw@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain 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: BL02EPF00010208:EE_|PH7PR12MB8155:EE_ X-MS-Office365-Filtering-Correlation-Id: 38b89c39-6db5-4304-eee8-08dae33e62ae 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: qwagVGQKEGbFVWARmMQ+vl+Muz2HHtQfwYHTanJ7DnX9+zArujG2Qit6aptHM5XcmsFXhtxPjkxZOvmacpAN9OCnoU8bqDrS7YF+L88hKouX1Qd/MdyMPCb8pB5cCR5mhHnxKHjh3y7GWAUnqw259lGjbmlPg80ils7ZIaK6sMJ3DuQV16OlDPqKzObXphVnETDLNCpVN9R8FdTMmhfW83q/rvA/WWNjxOf1P4dAezPmRaT/q95BEQzwgLROgpzdiXeGUsFDzR8UkiN8Y64ix266nv3mXLo4KfipW/HsXNn+B+CpwUAGbZasECWT0XUgLTYAznCB1/Xh85d8aUa9zbZ8/e7lGGHGQXTql+ixjtcUPTS44n/k5vvXLWtvGQKmZrJGD0jeuBQzr1JmpNCbOD1imca8RTvlx84S3L+QZGsoqtRKgLcttgSl4KZ+bdPawY5cSVgJRK+lwfHTF6utvqTLZEz6Pf5bJ43mObivUtAaGHq8Jzx/3ivuhY4E8L4U406oRpofdy0GwEwUk4hzvHCKIsXg5zvEahh7gR4UcrRx6pr7LPEheEGIDjblFtsfxpMWO/NZwvP14TpYWK2c7AIGY4zV2QMvURliNAqChOv96Ekhx5pYJ2EoE2R2hpOrX5a5O9ML/cjUSgvBLI/eceL000hlvKkMXMaOKE5euVhd3jnMDccOs6qAFi3XFxl4+LbA7G0zBZfOUj6kOjk7wA== 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:(13230022)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(86362001)(36860700001)(82740400003)(107886003)(6666004)(2616005)(6286002)(54906003)(336012)(40460700003)(26005)(40480700001)(16526019)(2906002)(186003)(7696005)(36756003)(478600001)(110136005)(316002)(8936002)(55016003)(82310400005)(356005)(70206006)(8676002)(7636003)(41300700001)(4326008)(83380400001)(5660300002)(1076003)(70586007)(47076005)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 10:30:30.7424 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38b89c39-6db5-4304-eee8-08dae33e62ae 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: BL02EPF00010208.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8155 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 For the multiple hardware ports connect to a single DPDK port (mhpsdp), currently there is no information to indicate the packet belongs to which hardware port. This patch introduces a new port affinity item in rte flow API, and the port affinity value reflects the physical port affinity of the received packets. While uses the port affinity as a matching item in the flow, and sets the same affinity on the tx queue, then the packet can be sent from the same hardware port with received. This patch also adds the testpmd command line to match the new item: flow create 0 ingress group 0 pattern port_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 (assumes the affinity 1 stands for the first port) and redirects these packets into RxQ 0. Signed-off-by: Jiawei Wang --- app/test-pmd/cmdline_flow.c | 29 +++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 7 +++++ doc/guides/rel_notes/release_22_03.rst | 5 ++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 28 ++++++++++++++++++++ 6 files changed, 74 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 426585387f..3bc19e112a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -514,6 +514,8 @@ enum index { ITEM_QUOTA, ITEM_QUOTA_STATE, ITEM_QUOTA_STATE_NAME, + ITEM_PORT_AFFINITY, + ITEM_PORT_AFFINITY_VALUE, /* Validate/create actions. */ ACTIONS, @@ -1490,6 +1492,7 @@ static const enum index next_item[] = { ITEM_PPP, ITEM_METER, ITEM_QUOTA, + ITEM_PORT_AFFINITY, END_SET, ZERO, }; @@ -1976,6 +1979,12 @@ static const enum index item_quota[] = { ZERO, }; +static const enum index item_port_affinity[] = { + ITEM_PORT_AFFINITY_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -7239,6 +7248,23 @@ static const struct token token_list[] = { ARGS_ENTRY(struct buffer, port)), .call = parse_mp, }, + [ITEM_PORT_AFFINITY] = { + .name = "port_affinity", + .help = "match on the physical port affinity of the" + " received packet.", + .priv = PRIV_ITEM(PORT_AFFINITY, + sizeof(struct rte_flow_item_port_affinity)), + .next = NEXT(item_port_affinity), + .call = parse_vc, + }, + [ITEM_PORT_AFFINITY_VALUE] = { + .name = "affinity", + .help = "port affinity value", + .next = NEXT(item_port_affinity, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_affinity, + affinity)), + }, }; /** Remove and return last entry from argument stack. */ @@ -12329,6 +12355,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_PORT_AFFINITY: + mask = &rte_flow_item_port_affinity_mask; + break; default: break; } diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 59932e82a6..dbf0e9a41f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1558,6 +1558,13 @@ Matches Color Marker set by a Meter. - ``color``: Metering color marker. +Item: ``PORT_AFFINITY`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Matches on the physical port affinity of the received packet. + +- ``affinity``: Physical port affinity. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 0923707cb8..8acd3174f6 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -58,6 +58,11 @@ New Features Added ``gre_option`` item in rte_flow to support checksum/key/sequence matching in GRE packets. +* **Added rte_flow support for matching Port Affinity fields.** + + Added ``port_affinity`` item in rte_flow to support hardware port affinity of + the packets. + * **Added new RSS offload types for L2TPv2 in RSS flow.** Added ``RTE_ETH_RSS_L2TPV2`` macro so that he L2TPv2 session ID field can be used as diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f497bba26d..c0ace56c1f 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3722,6 +3722,10 @@ This section lists supported pattern items and their attributes, if any. - ``color {value}``: meter color value (green/yellow/red). +- ``port_affinity``: match port affinity. + + - ``affinity {value}``: port affinity value. + - ``send_to_kernel``: send packets to kernel. diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 07b9ea48a9..645f392b24 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -162,6 +162,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { 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(QUOTA, sizeof(struct rte_flow_item_quota)), + MK_FLOW_ITEM(PORT_AFFINITY, sizeof(struct rte_flow_item_port_affinity)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 21f7caf540..7907b7c0c2 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -667,6 +667,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_sft. */ RTE_FLOW_ITEM_TYPE_SFT, + + /** + * Matches on the physical port affinity of the received packet. + * + * See struct rte_flow_item_port_affinity. + */ + RTE_FLOW_ITEM_TYPE_PORT_AFFINITY, }; /** @@ -2227,6 +2234,27 @@ 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_PORT_AFFINITY + * + * For the multiple hardware ports connect to a single DPDK port (mhpsdp), + * use this item to match the hardware port affinity of the packets. + */ +struct rte_flow_item_port_affinity { + uint8_t affinity; /**< port affinity value. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_AFFINITY. */ +#ifndef __cplusplus +static const struct rte_flow_item_port_affinity +rte_flow_item_port_affinity_mask = { + .affinity = 0xff, +}; +#endif + /** * Action types. * -- 2.18.1