From patchwork Mon Oct 9 16:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 132437 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 53ECA4233F; Mon, 9 Oct 2023 18:09:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29B43402C2; Mon, 9 Oct 2023 18:09:21 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by mails.dpdk.org (Postfix) with ESMTP id 343B3402A3 for ; Mon, 9 Oct 2023 18:09:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qz3McjVoshivi9xLARERiLXZke7/MSHZevJ+saprphIBfAKtxa4w4NJuO6KSpCdg3iZGbhDWViic2OF0DLDYBRFnIOWUya2BOybuVRbg111+6kcxLrCO5S2C9QOQWVS2F7MVZab9Zys2wjEZi+YZNrUavnpZTpyBw903TU+m6NnEslyvB6Cc+mOGQqMyEj2wRIDZTJnRIkjH84GDv6t3V4fOikBRxxvJMo0AX2wAPUvornkj2ESRvyRdFE+01lqwzewruDAWDR8HufO2ynmTVUwKBqFGUISauCuPfXYlEDR2bSUmgq3v3AwW3c5Jqx48I1CFdf+bhYa8vY7lqoBJeA== 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=9TLb8W0IfvT19aUKBa1BTX83AsgLU1vd0tKHJic1JHI=; b=jhGm5ewqL3kskwJRO4D2y5oU99biXbuh6qNFezo3yQPOl8I7GlvHkDmhnQx4gFFX9X/xRK430Rv24Ra0HlvycblCIPDomERdOIq5SzU4o4PlNiklzjVomUxxTV2DYZprPwusGDqQSpi7S7Y5COQ8FSrfxUro3xYgy1132RWLRZJXpr55oXj8hIJs1ofij9zf8XROltOhsU5xBQvbS9YPi++6wFwlpi7a44XUNyYg2wR7C1Je0qOWZh37k0F296IO4n12Y28+qe0wK6efWd53RMn6co+2IwqTHOJvRXDr4AEsWQH9u3exQEbzYIIwBUVzAKVBg8V3zLRExAMEhRBZ6Q== 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=9TLb8W0IfvT19aUKBa1BTX83AsgLU1vd0tKHJic1JHI=; b=ax5x1rDT1NPOTjXVpEWQPmBo0l99W5JzxFozad3Os4VwphERtyo0tsg5reHWuM3SV9NtMd1UQnXTIf99mmm65WLjSGx+dQd1SZcyW2Q1AkKwJmlQqoNfsRGHv8JhFwB4xbfcU3ja3eQ6cHCxb+kr3/swDvH4kSFTpTxh477A6ugSM2HHjrcGXLDV+wvem1TEsanQU9jDVQxmzDQbiFBpL3sD2kw+/hDQzdOEOvwPvDH9xqZTd44L/q+QAOvtU/ee/7wWjw7SkwQvL+YrGOYbWid9OnjOvnwrVg7sF3ofBlF+c35OLEWpvPesZepz6eC/sbDZrIkYRYWQby5wixnKtw== Received: from CH2PR16CA0017.namprd16.prod.outlook.com (2603:10b6:610:50::27) by IA1PR12MB6411.namprd12.prod.outlook.com (2603:10b6:208:388::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.38; Mon, 9 Oct 2023 16:09:18 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:610:50:cafe::7b) by CH2PR16CA0017.outlook.office365.com (2603:10b6:610:50::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36 via Frontend Transport; Mon, 9 Oct 2023 16:09:18 +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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 16:09:17 +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, 9 Oct 2023 09:09:06 -0700 Received: from pegasus01.mtr.labs.mlnx (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, 9 Oct 2023 09:09:04 -0700 From: Alexander Kozyrev To: CC: , , , , Subject: [PATCH v2] ethdev: add packet type matching item Date: Mon, 9 Oct 2023 19:08:50 +0300 Message-ID: <20231009160850.3997269-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230810161447.2108369-1-akozyrev@nvidia.com[D> References: <20230810161447.2108369-1-akozyrev@nvidia.com[D> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] 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: DS1PEPF0001708F:EE_|IA1PR12MB6411:EE_ X-MS-Office365-Filtering-Correlation-Id: bd7fe930-8fbb-4f1b-20ce-08dbc8e21726 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: 9DOwqU+tFlLftGBOA8wWvNKw8VvolhjjoEHhWiXFjpUF86T5DxbM555OZjTr5RvF5xPU54fX9zi1r+PgSzpyeOdmnLbGDz2E7VqEIf3fE3ESwz8+Ny+RkWp3y0twC/biOTY3pfSRGFqMGfB/iVdeoVg3QJGLEFIKoB6EJW8r2kIaZdNn1QiQfXmNGawvArJE6A65Wn7LS+DLB13nh4jCJgK51nLCINgh6LJFjFPogSwKuXXpcZKG12J8ImXn53ZB0RVlpDAVhj7yecmkT9UEB4UVzTFtIOz8zdOXYcVlEdkgGhPusc2MeIBkFAoYgAl4W6ZQOBzHH2lEb7wu1l4lWaG9zIgwyhdWsiBrwz+yiUgpQ77pNICsPbK1gC4cJPpXer3GH3PG8MoP7Mem8UFuTnB+lPBGQBQ8NCALnKVlw8WMIezGjROhfdhU+pRvVGX+ksokX6UOZ7P/aDiphq2NUrRkq0QWapSiri9iCDj5BMKG0NyO7FDdwy0E0ns4F7lnjUotXqbMeWhjbaHxr3M6+SNMfiazX+N2ldNo9vWkB1QraOtz9PzohdQhRu4buFSMUUf4g+h3YcKY8PDypKqDp7VyysKaOF6m21tlPFG8iun3kkABMmT3ebqc+bVuKch1nj/r4HB6rXo7ke0N//HDaCWzjV/iv0PCYB8PnljS2AejIgJ1eNf7HJQ8xZXqF5ETEVUzXijubiLXkLZj1LkpK/r4bxBnfbeXcsV7cb53QI4= 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)(396003)(376002)(136003)(39860400002)(346002)(230922051799003)(1800799009)(186009)(451199024)(82310400011)(64100799003)(36840700001)(46966006)(40470700004)(1076003)(2616005)(2906002)(40460700003)(7636003)(356005)(82740400003)(16526019)(86362001)(47076005)(36860700001)(40480700001)(36756003)(336012)(26005)(426003)(83380400001)(5660300002)(8676002)(4326008)(8936002)(478600001)(316002)(6916009)(41300700001)(54906003)(70586007)(6666004)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 16:09:17.7877 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd7fe930-8fbb-4f1b-20ce-08dbc8e21726 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6411 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 Add RTE_FLOW_ITEM_TYPE_PTYPE to allow matching on L2/L3/L4 and tunnel information as defined in mbuf. To match on RTE_PTYPE_L4_TCP and RTE_PTYPE_INNER_L4_UDP: flow pattern_template 0 create pattern_template_id 1 ingress template ptype packet_type mask 0x0f000f00 / end flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 pattern ptype packet_type is 0x02000100 / end actions queue index 1 / end Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 27 +++++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 ++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 25 +++++++++++++++++++ 6 files changed, 65 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 12809f1042..cb203ad99c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -535,6 +535,8 @@ enum index { ITEM_IPV6_PUSH_REMOVE_EXT, ITEM_IPV6_PUSH_REMOVE_EXT_TYPE, ITEM_NSH, + ITEM_PTYPE, + ITEM_PTYPE_VALUE, /* Validate/create actions. */ ACTIONS, @@ -1581,6 +1583,7 @@ static const enum index next_item[] = { ITEM_TX_QUEUE, ITEM_IB_BTH, ITEM_NSH, + ITEM_PTYPE, END_SET, ZERO, }; @@ -2106,6 +2109,12 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_ptype[] = { + ITEM_PTYPE_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -5921,6 +5930,21 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_PTYPE] = { + .name = "ptype", + .help = "match L2/L3/L4 and tunnel information", + .priv = PRIV_ITEM(PTYPE, + sizeof(struct rte_flow_item_ptype)), + .next = NEXT(item_ptype), + .call = parse_vc, + }, + [ITEM_PTYPE_VALUE] = { + .name = "packet_type", + .help = "packet type as defined in rte_mbuf_ptype", + .next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)), + }, /* Validate/create actions. */ [ACTIONS] = { @@ -12836,6 +12860,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_IB_BTH: mask = &rte_flow_item_ib_bth_mask; break; + case RTE_FLOW_ITEM_TYPE_PTYPE: + mask = &rte_flow_item_ptype_mask; + break; default: break; } diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 2011e97127..e41a97b3bb 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -137,6 +137,7 @@ ppp = pppoed = pppoes = pppoe_proto_id = +ptype = quota = raw = represented_port = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 860e42025f..b65b25d443 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1566,6 +1566,13 @@ Matches an InfiniBand base transport header in RoCE packet. - ``hdr``: InfiniBand base transport header definition (``rte_ib.h``). +Item: ``PTYPE`` +^^^^^^^^^^^^^^^ + +Matches the packet type as defined in rte_mbuf_ptype. + +- ``packet_type``: L2/L3/L4 and tunnel information. + Actions ~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index e6d218caaa..07bac9a311 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3808,6 +3808,10 @@ This section lists supported pattern items and their attributes, if any. - ``send_to_kernel``: send packets to kernel. +- ``ptype``: match the packet type (L2/L3/L4 and tunnel information). + + - ``packet_type {unsigned}``: packet type. + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index c9d23da702..ba8bf27090 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(AGGR_AFFINITY, sizeof(struct rte_flow_item_aggr_affinity)), MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)), MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)), + MK_FLOW_ITEM(PTYPE, sizeof(struct rte_flow_item_ptype)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index e576b15e3d..b79bb9968b 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -694,6 +694,14 @@ enum rte_flow_item_type { * @see struct rte_flow_item_ib_bth. */ RTE_FLOW_ITEM_TYPE_IB_BTH, + + /** + * Matches the packet type as defined in rte_mbuf_ptype. + * + * See struct rte_flow_item_ptype. + * + */ + RTE_FLOW_ITEM_TYPE_PTYPE, }; /** @@ -2309,6 +2317,23 @@ static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = { }; #endif +/** + * + * RTE_FLOW_ITEM_TYPE_PTYPE + * + * Matches the packet type as defined in rte_mbuf_ptype. + */ +struct rte_flow_item_ptype { + uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PTYPE. */ +#ifndef __cplusplus +static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { + .packet_type = 0xffffffff, +}; +#endif + /** * Action types. *