From patchwork Thu Aug 10 16:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 130091 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 940B64302C; Thu, 10 Aug 2023 18:15:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 859774324E; Thu, 10 Aug 2023 18:15:23 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2065.outbound.protection.outlook.com [40.107.237.65]) by mails.dpdk.org (Postfix) with ESMTP id 3E88240691 for ; Thu, 10 Aug 2023 18:15:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C0gYCsjp9c3bh5v8e5AH+eG2mKWvSVWGfOavZBcztrcZy3p1cXnnSgpIqfiTNjgfzPOD9TuiYmKDdG9TjuyGtyyhdUuzsRwchyip4+OyYtl7nqf1lqiZwXvmtZf505/KV3CzppGKVPOWqcl6Dc8+oHga7zA+goYYdOlPdSMp8lruVseUnf1NCNyw7ROPCJ9Ns1SnlBNeZTFOcCBwSumBfxJumbhrCqT+tjMgAjGoe8kWLl2U47Ct+lzUstFfcFoNh7nBFPoBMou6wPNBYPZZUNQmCr0XwRw/PeYcFgKyUDuz15HN5zhK05gIlnk3ZGbfYa6gtGr7idFDebV2S+5/2g== 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=bAKTFc/2TOqZ0K1dpX6tS5+OeIwg0/x51ZhrB8AYgp0=; b=AZRx6ObQPL/uq4bQkrGj1A9Db7spAB4NTquU98Y8q5H4FaexVCPXyncwMhtGf+foketYidku93QqXbXwel9qvbxxkSJmnmLksI59d/sfTqPAw4MUwLC4stm2/scGeXljascH/30IgvlUoC/9auqyfvKSaZnA+nJjb9O35awApmqzQ92Uubua9pissuCpii/4BLBXX6j5DK0j73uC6e5xrGr/vjdrjqXY0HvzZLbE89umTF8gT8LwrBYh22xPC9B+pyrFuvwiF3a2CoICAitwObnTRcjzCAEEneWzgiINLswcCD6T/AJdOOCaaDXhcKRBkMn6ScqX75ZveMKPR0HTLQ== 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 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=bAKTFc/2TOqZ0K1dpX6tS5+OeIwg0/x51ZhrB8AYgp0=; b=Co2+aT5dqVyrJwFmSBq1t9iz0cUQqb/1KIHd+ZEu3iJhYEJ6ZUApIw+fH1Ef/Cm01z9UBE7uMXDARgGXGYvRVtDFBloCSgwgwCC3b3l903PwCVQkNB3WT376zWESPO02bprQZtvdetfz1uUlSOPZr5adGFNTuKd0lzvPu15i0k2Fk7b4eIsKFE92D6kXh6Q0yppehEldDhtqAvWi/wEMb0Ks4ITcuj9ayx7/z3U7IPaW6fK/sqapn/E0Nhr//aXvwVRBLUNSsBKHfKdOpMbP8I9uTuDA5gwsseZZVS9nQBBKCMRsvSGoDEnCyEcDdEqi6yw7uCWbFY4jXqbazS9/Cw== Received: from PH0PR07CA0061.namprd07.prod.outlook.com (2603:10b6:510:f::6) by BY5PR12MB4193.namprd12.prod.outlook.com (2603:10b6:a03:20c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 16:15:20 +0000 Received: from SA2PEPF000015CA.namprd03.prod.outlook.com (2603:10b6:510:f:cafe::4e) by PH0PR07CA0061.outlook.office365.com (2603:10b6:510:f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 16:15:19 +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 SA2PEPF000015CA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 16:15:16 +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.5; Thu, 10 Aug 2023 09:15:03 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.230.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.37; Thu, 10 Aug 2023 09:15:01 -0700 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH] ethdev: add packet type matching item Date: Thu, 10 Aug 2023 19:14:47 +0300 Message-ID: <20230810161447.2108369-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] 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: SA2PEPF000015CA:EE_|BY5PR12MB4193:EE_ X-MS-Office365-Filtering-Correlation-Id: 535d58a9-9896-4f60-8a2a-08db99bcfc30 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: 1z9M3qD1UEPpx4a0W/o3RSwrJ7X56JwfM6wQDj3w1zM3kLz5OJNhXsuJEVyUqHpwe4o1+KRs3ogc9e6dcmz6ZWKBYg8ZBI/Xq4VtvHlrPew4mo3QcTRdNGSZBqNfg9AidKCxy7wycATRFgqN/x24Iprq7nLSMdUB1n+Ax0WsDPnJ4gEIeFR28AljRUxYRdoLB499T5StJzI7qvrLyqMIM8FU3O3Y7/4M0h1Y0vLj8KXJ0tKRkmvuHDgRAJkFCKqSwcI170G0n6K0rqHd50IX1BT0BnmNXZA7yUNrxxDRyllnCd+Zts1+7jKx76nmapPyzfwUPMfm/Uh+qTlusqQMzOe8+1sT5S8M1Uh5Me8ZQd5g7F8nUgw/+4EitQleEy7ANs0cpgkyiafGv0DF9Hzpl2uX2qxj4UF+4kCtW73XLgbM5nbKuqzJmEPd0TAyHERcOIS25FkADUIwdCR+zyuHV+/ZBCQmk3LuUBZrBr/dWLbXpv6da/BjwLeiLf9xRMRxbqHGCUMcaPZ2Jt4FrMjk6iTokrLRckUc/SgxlA5p92aLweKGDvbarOK/tSw2gta2Y6t1Dd1nyI/gRU6THohjGQ4GKp4eLd3QcM2Y4iSxpTNrJO36eRFtzNVSTQn6r+MZvRfQ7pJ9eN3tcXdceA0+ZYPBReo8ONVrwXEUpe+l0Iz1PqCdRBQx9howiH1niGKXR1A+DwNATbFeE06PiU4vjkL9Sq/qdXlM9xOBvlmNSAM= 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:(13230028)(4636009)(376002)(346002)(136003)(39860400002)(396003)(82310400008)(451199021)(1800799006)(186006)(36840700001)(46966006)(40470700004)(426003)(40460700003)(336012)(83380400001)(7636003)(2906002)(16526019)(40480700001)(54906003)(478600001)(86362001)(2616005)(4326008)(36860700001)(5660300002)(6666004)(1076003)(82740400003)(316002)(36756003)(26005)(8676002)(8936002)(41300700001)(70586007)(47076005)(70206006)(356005)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 16:15:16.5591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 535d58a9-9896-4f60-8a2a-08db99bcfc30 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: SA2PEPF000015CA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4193 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. 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 94827bcc4a..853a6d25e0 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -524,6 +524,8 @@ enum index { ITEM_IB_BTH_PSN, ITEM_IPV6_PUSH_REMOVE_EXT, ITEM_IPV6_PUSH_REMOVE_EXT_TYPE, + ITEM_PTYPE, + ITEM_PTYPE_VALUE, /* Validate/create actions. */ ACTIONS, @@ -1561,6 +1563,7 @@ static const enum index next_item[] = { ITEM_AGGR_AFFINITY, ITEM_TX_QUEUE, ITEM_IB_BTH, + ITEM_PTYPE, END_SET, ZERO, }; @@ -2079,6 +2082,12 @@ static const enum index item_ib_bth[] = { ZERO, }; +static const enum index item_ptype[] = { + ITEM_PTYPE_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -5827,6 +5836,21 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth, hdr.psn)), }, + [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] = { .name = "actions", @@ -12689,6 +12713,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 5bc998a433..62a6dbb7f9 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 a182479ab2..8dc711bfc4 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3805,6 +3805,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 271d854f78..71583bc174 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -166,6 +166,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 86ed98c562..de941a5867 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -688,6 +688,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, }; /** @@ -2311,6 +2319,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. *