From patchwork Wed Apr 17 07:23:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 139437 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 AF77C43E8E; Wed, 17 Apr 2024 09:23:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4964406B8; Wed, 17 Apr 2024 09:23:35 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2043.outbound.protection.outlook.com [40.107.236.43]) by mails.dpdk.org (Postfix) with ESMTP id B8E6A406B8 for ; Wed, 17 Apr 2024 09:23:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=URE/epfxMhd+K3ywQuYzFQ5FLTNU9AdIw2dw3OjqM+GGNZjj9KRk8Wck/goDTt9oM/565ARI6AO9pQgtfrutPq2IiPnJXf0oL7sJGwIkG/1dRVJDqc7MSSB6shaEufInnDlshaTk9szNc5/3DsDQFvwQfuOC3cfNw7GiNqR4kvg7CzAzjYs7XbnDOHfcHl+cfnykcvi0q/7uBh5JFzxIbfmK+OmUB88SHK5tY4YOYutolu0nR0bHx5TKKgcR4T6jpKFL8flNcZeIZYNZVqcTmJiefIsnMaMMbm5xDx+4t+PVz/ZhXkNs51pFXlMEjRrme/Ka7HF9MzH7ynVnb4JscA== 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=vnpaSibvuf3jHporDpIkNhAI5Vl3OzZLeoO1y5kR8Tg=; b=jjl+bTW6c8oVzW50qYtZWpYRsfsPiIXprfPOnqlHmFRDieFCyK6iklhWk9w5cRexnGXTZZwd6lfJ3XnaZOjavY5pMP7TO6/54FhaIwlc64XR+ysEeRWBcTY2/pubDlRI83RtmDxDwaLYTOIRguba9zKMvOXV4/p7CDJRMLR8j+dldQkbdqRwBG9H3NeK3x5/bPzhwT89bRdS9T3bfFDc4w8jV9la0B1yU3yV1ZHK5VBNpYis1c3L3F4AHHESs2Al/8HAHsJQOAfRhKdYW8UGlKh5+T3+PjQGxrgOFT4XHFLKjNNOd4l01BoBRRa2LhUMdt5udRmVzyiveKAIQTKCHw== 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 (0) 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=vnpaSibvuf3jHporDpIkNhAI5Vl3OzZLeoO1y5kR8Tg=; b=nsnQ0fhrdy5wKViYDCI96ZqX//HG8D9a5X3uwXLRrkosKnjIJRT3p46pHe0ADc871e+jzw/Q5eeUPVxTCzlq08UOsFhdOeEwTr/EW7nKJrDR6Uokkv1iPzK8IJyK9d52QHpSAFKWw2alMK0BWRpwiZSRzR1ACXwgyFlmHemD28N9tCqFtEI+hpXnhidjZlLyM2guA6dZQDMpbOTtn/fTgyA3xlhJmzqSjlmeLCs9v6w/6sNF+e4g4/smSjBi/BEbQuyCbDs/QSNjXeJ6TOaOy8smN2B9S6PS294ZNtO55LJgnZqbPle8fpQBegIh6WsRm9pp/hxT5yWb/iAy0wtJFw== Received: from CH5PR02CA0009.namprd02.prod.outlook.com (2603:10b6:610:1ed::10) by LV3PR12MB9258.namprd12.prod.outlook.com (2603:10b6:408:1bb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.37; Wed, 17 Apr 2024 07:23:29 +0000 Received: from DS3PEPF000099DE.namprd04.prod.outlook.com (2603:10b6:610:1ed:cafe::92) by CH5PR02CA0009.outlook.office365.com (2603:10b6:610:1ed::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.23 via Frontend Transport; Wed, 17 Apr 2024 07:23:29 +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 DS3PEPF000099DE.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Wed, 17 Apr 2024 07:23:29 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.41; Wed, 17 Apr 2024 00:23:15 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 17 Apr 2024 00:23:14 -0700 Received: from nvidia.com (10.127.8.13) by mail.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.1258.12 via Frontend Transport; Wed, 17 Apr 2024 00:23:13 -0700 From: Michael Baum To: CC: Dariusz Sosnowski , Thomas Monjalon , Ferruh Yigit , Ori Kam Subject: [RFC 2/2] ethdev: add data size field to GENEVE option item Date: Wed, 17 Apr 2024 10:23:04 +0300 Message-ID: <20240417072304.3260172-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240417072304.3260172-1-michaelba@nvidia.com> References: <20240417072304.3260172-1-michaelba@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DE:EE_|LV3PR12MB9258:EE_ X-MS-Office365-Filtering-Correlation-Id: f2f31199-8ecb-4313-af52-08dc5eaf47bf 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: /hT8Z2/amjda2cQ/dqoeTogXJH3JAZFsgAbBVzgv8Hsf4iSrl9NXuw5+qC2hhvF9wRMYF8V8ijvDhLQzlzgryjSsfErcd+TdUE9wdC1J/TjGJgQDKE9htIiiiIV4fWDdG0ZvSj9KiFbqHemCfQ433g7xIh6GjpzPFN9nm4e8bUnmd9il+oeM6/LmCHNUiL2w+17Lu7X6MaQCf5U0TBeMDWEe8E+RNwnt7vL77Bc37o6koxJ7LeSoggqaAungsFRfDahzHftVXRAUp7zY0I00ajqmyn+obpNNrJNWdlgiTZHjzFQrHJxtU2D5/roA01cetX2D+myQwfXwGo+iuigcm6PhOEzbIo78WeFhDQPKreXluKd2iEOzchOIqNiiiFe9CtxGI+jBuv6BFFbQ5TZ6sGp0rDjohlhL850irHTLiDukfYvn3tnKH66P5Nx9NNqCB4vrq812surA/VcR/dzCjTgfolTB5+/2/4o5EGNEuYI9LcGcJS83xOWvVeWDlr6Pnr95fnsEYqgcEmzkXkh+t3YxPE2xZP34QrKGoHmH9P+rPlzDCkMiqhX8NfU13q5WmoN4FOxLUtwvBctzVB3xieAb0ndMGpNyncpxcxwrymDhEz1eRWSd06HifvrvsggFly9sHP8BMmGmw6pRwikyOugBVd5WtmPqcdYTqX0nSF7PiezULHr9d7yCjSGkoVpfzAuaPz8uFg9Y07aSfPVfbfoLXBCtC+YdfT1msLCrCqW2bCyT2NWk5hBYfd3qf1jY 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:(13230031)(36860700004)(82310400014)(376005)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 07:23:29.4393 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2f31199-8ecb-4313-af52-08dc5eaf47bf 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: DS3PEPF000099DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9258 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 "rte_flow_item_geneve_opt" structure has field for option length. This field has 2 different usages which might limit each other: 1. field to matching with value/mask. 2. descriptor for data array size. This patch adds a new field "data_array_size" into "rte_flow_item_geneve_opt" structure in addition to existing "option_len" field. Signed-off-by: Michael Baum --- app/test-pmd/cmdline_flow.c | 10 ++++++ doc/guides/prog_guide/rte_flow.rst | 16 +++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 +- lib/ethdev/rte_flow.c | 36 ++++++++++----------- lib/ethdev/rte_flow.h | 3 +- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 60ee9337cf..966a47936a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -492,6 +492,7 @@ enum index { ITEM_GENEVE_OPT_TYPE, ITEM_GENEVE_OPT_LENGTH, ITEM_GENEVE_OPT_DATA, + ITEM_GENEVE_OPT_DATA_ARRAY_SIZE, ITEM_INTEGRITY, ITEM_INTEGRITY_LEVEL, ITEM_INTEGRITY_VALUE, @@ -2032,6 +2033,7 @@ static const enum index item_geneve_opt[] = { ITEM_GENEVE_OPT_TYPE, ITEM_GENEVE_OPT_LENGTH, ITEM_GENEVE_OPT_DATA, + ITEM_GENEVE_OPT_DATA_ARRAY_SIZE, ITEM_NEXT, ZERO, }; @@ -5772,6 +5774,14 @@ static const struct token token_list[] = { (sizeof(struct rte_flow_item_geneve_opt), ITEM_GENEVE_OPT_DATA_SIZE)), }, + [ITEM_GENEVE_OPT_DATA_ARRAY_SIZE] = { + .name = "data_size", + .help = "GENEVE option data array size", + .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, + data_array_size)), + }, [ITEM_INTEGRITY] = { .name = "integrity", .help = "match packet integrity", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index dad588763f..cce02fe1d6 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1092,6 +1092,22 @@ Matches a GENEVE header. - ``rsvd1``: reserved, normally 0x00. - Default ``mask`` matches VNI only. + +Item: ``GENEVE_OPT`` +^^^^^^^^^^^^^^^^^^^^ + +Matches a GENEVE TLV option header. + +- ``option_class``: option class ID. +- ``option_type``: option type. +- ``option_len``: option data length in 4-bytes granularity. +- ``data``: option data array. +- ``data_array_size``: option data array size. + This field is not matchable, it is descriptor how to read the array. + It should be specified in ``mask`` as well. +- Default ``mask`` matches type only. + + Item: ``VXLAN-GPE`` ^^^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 2fbf9220d8..97623044e9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3743,7 +3743,8 @@ This section lists supported pattern items and their attributes, if any. - ``type {unsigned}``: GENEVE option type. - ``length {unsigned}``: GENEVE option length in 32-bit words. - ``data {hex string}``: GENEVE option data, the length is defined by - ``length`` field. + ``data_size`` field. + - ``data_size {unsigned}``: GENEVE option data size in 32-bit words. - ``vxlan-gpe``: match VXLAN-GPE header. diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 2803507462..d68359961d 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -81,6 +81,21 @@ rte_flow_item_flex_conv(void *buf, const void *data) return src->length; } +static size_t +rte_flow_item_geneve_opt_conv(void *buf, const void *data) +{ + const struct rte_flow_item_geneve_opt *src = data; + uint16_t byte_size = src->data_array_size << 2; + + if (buf) { + struct rte_flow_item_geneve_opt *dst = buf; + void *deep_src = (void *)((uintptr_t)(dst + 1)); + + dst->data = rte_memcpy(deep_src, src->data, byte_size); + } + return byte_size; +} + /** Generate flow_item[] entry. */ #define MK_FLOW_ITEM(t, s) \ [RTE_FLOW_ITEM_TYPE_ ## t] = { \ @@ -155,7 +170,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(L2TPV3OIP, sizeof(struct rte_flow_item_l2tpv3oip)), MK_FLOW_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)), MK_FLOW_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)), - MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)), + MK_FLOW_ITEM_FN(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt), + rte_flow_item_geneve_opt_conv), MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), MK_FLOW_ITEM(PORT_REPRESENTOR, sizeof(struct rte_flow_item_ethdev)), @@ -622,7 +638,6 @@ rte_flow_conv_item_spec(void *buf, const size_t size, switch (item->type) { union { const struct rte_flow_item_raw *raw; - const struct rte_flow_item_geneve_opt *geneve_opt; } spec; union { const struct rte_flow_item_raw *raw; @@ -632,11 +647,9 @@ rte_flow_conv_item_spec(void *buf, const size_t size, } mask; union { const struct rte_flow_item_raw *raw; - const struct rte_flow_item_geneve_opt *geneve_opt; } src; union { struct rte_flow_item_raw *raw; - struct rte_flow_item_geneve_opt *geneve_opt; } dst; void *deep_src; size_t tmp; @@ -676,21 +689,6 @@ rte_flow_conv_item_spec(void *buf, const size_t size, off += tmp; } break; - case RTE_FLOW_ITEM_TYPE_GENEVE_OPT: - off = rte_flow_conv_copy(buf, data, size, - rte_flow_desc_item, item->type); - spec.geneve_opt = item->spec; - src.geneve_opt = data; - dst.geneve_opt = buf; - tmp = spec.geneve_opt->option_len << 2; - if (size > 0 && src.geneve_opt->data) { - deep_src = (void *)((uintptr_t)(dst.geneve_opt + 1)); - dst.geneve_opt->data = rte_memcpy(deep_src, - src.geneve_opt->data, - tmp); - } - off += tmp; - break; default: off = rte_flow_conv_copy(buf, data, size, rte_flow_desc_item, item->type); diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 6e8ab1d4c7..0ccb7562bd 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -1876,7 +1876,8 @@ struct rte_flow_item_geneve_opt { rte_be16_t option_class; uint8_t option_type; uint8_t option_len; - uint32_t *data; + rte_be32_t *data; + uint8_t data_array_size; }; /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */