From patchwork Thu Apr 20 09:21:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 126305 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 3121242995; Thu, 20 Apr 2023 11:22:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C52CD42BD9; Thu, 20 Apr 2023 11:22:10 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062.outbound.protection.outlook.com [40.107.220.62]) by mails.dpdk.org (Postfix) with ESMTP id 89BCD40687 for ; Thu, 20 Apr 2023 11:22:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i85sZ7bn/87W9Uoy736unz4oB05E2ZG5VhosORaef5RyQyHTEjZTwrNSiV/AtxqLxU82gc/yXe9aSCrB0V027NOGtM+qaqL1uF/8/LmevlDT/nmPOhe00J9UKSNiBeES2r8FYUayB3BjbkOuDbIImrJ4VpNoNww5+Qd9CpLQBrted9GKSiu5Gmiyu9mrVdSXHYrZjhj7fAURnOfrI1Y7/nZkHTYRnMA2ZnCSiOaGJA8h3SVtjWN0AivPs3mPZL+bMGxEaSlvdWFHRGPDEXeB+apLXkvPv77ObFJV6vPlg0U90ZvQZEddh35VAoZIphTPPt3uF1urtkIGowHkJ6vXOg== 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=YbZiPxFXUVD+eJKzOSjw4IZkOfwkXHjwSlFb2pfGwnA=; b=bykwbCFRUtpQn6frTrojyDKE6jLrjRls+yQA3Md5l/wtS0JugjlTXkGTNWnPSVfaseFy9GXLPll+YShEGn5jg+CiJcrBIh/4nQqlymKxeaGmCu+555JttHIvc/5WeVBav/iCt44fdtlhdcXAS3NT/H4kzGRzlLT6xXefSN7vhdTPre9O2ebhm+hFmQKlKa/9GiS8oms6nJqK6UbmDtTVpCrVGiOY2Tj8IDXZTxLA/dwZRQvuWDfe8iNHQwnwO5q8tKgWWN5DfQNkxUVF7KUuufhK6657vYX4bWSkHZ3xKNzMCob+XQhMTaCZD7ft2ml+Jl4z0tKr38kzoeMl0z7H4A== 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=YbZiPxFXUVD+eJKzOSjw4IZkOfwkXHjwSlFb2pfGwnA=; b=sG/WAbMJKPZMMsoyJLrGJiMReFx6TbwcrhYoOLZAm7gpOkOo3mbOGTEy0tfBSlJA968KdUOal3mKDYAyqXaWnXcdosAKo6ZHWjNKOkFaS6BNPdgEz98XRuAl0q8eZcAzl04u3WW0YpHE4KqkISr5sa5jErGXkFy5fIYcQ4fJ05MeNVjtiQVxvqpl+rjADr/jbSDr4YYFUW8qMjSiU+Zm6Pa7FaKXpmahHp8DjymByahq1Zz6T/xVcHnbQG2yy9nvQUnmZn4hgt+kJrzptfG4QaOsSQYr5AIiVvelB+U1fNwMl07EHPfEqBzy+onH3Y5G4MPdBrUVlIi2DGpVvRgfSw== Received: from BN9PR03CA0749.namprd03.prod.outlook.com (2603:10b6:408:110::34) by SJ0PR12MB7081.namprd12.prod.outlook.com (2603:10b6:a03:4ae::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.20; Thu, 20 Apr 2023 09:22:06 +0000 Received: from BN8NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:408:110:cafe::33) by BN9PR03CA0749.outlook.office365.com (2603:10b6:408:110::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.25 via Frontend Transport; Thu, 20 Apr 2023 09:22:05 +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 BN8NAM11FT043.mail.protection.outlook.com (10.13.177.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.23 via Frontend Transport; Thu, 20 Apr 2023 09:22:05 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.5; Thu, 20 Apr 2023 02:21:54 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 20 Apr 2023 02:21:54 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Thu, 20 Apr 2023 02:21:52 -0700 From: Michael Baum To: CC: Ori Kam , Aman Singh , "Yuying Zhang" , Ferruh Yigit , "Thomas Monjalon" Subject: [RFC 1/2] ethdev: add GENEVE TLV option modification support Date: Thu, 20 Apr 2023 12:21:44 +0300 Message-ID: <20230420092145.522389-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420092145.522389-1-michaelba@nvidia.com> References: <20230420092145.522389-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT043:EE_|SJ0PR12MB7081:EE_ X-MS-Office365-Filtering-Correlation-Id: 14427f98-524f-4fd0-4074-08db4180b53d 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: pAGYmkD7S+FQfSMNfZE1hRhzGNYfM4VvFTBo7Daq9MhaLczctMZ7oEN8GBAMi536DR+LKsP0BWy1N96106Jc/ntlxRcJhcUesWUebTZdsPGwtFWWUGlgBVbg4iSkb19ygP/MPaYltncEJoSo9d3dTYZzXw21msG122sQ+6pQ6NoBwH/dgjMQ1gGcSseKRrSfBMMkMjybzWxHxLMOzQ2SYAzZNfq2Pml9wp9ydPfUzGBji8yhXuj4IpEGER2QKD9SuGn5GykCyzh1/poej1WYyXy8iFIAZUvrA6wqHqZIRuUWHPBuwfeBz+8rKXWdzAIDGVBY+cW9gq1noVAjILFo/kN3/ikw3FnQDBTLgFV+3VdJiXPjRZ5k6u+/Jf9+vIEAxK3a1xmxnLdga6Q9z+VNN3klgzrTQruk8WQEQ8MMX9MB+WYyJMBNkHGnIdFDx+Hj8DAIGQ/5CqUNXVief10ydF9ID40j6j2IllG6lzopDDW4iva7tzBjzVC5ZDdIG9Gxk4vhhm6UxilGD3mfizqf9yUfQvfWPukB1X528TvjCmH+JFY6OQ+0XbbDHdeSFKm1ayoXXz+yIELrYdqqr/Qm0YcDIGD4FffR6noKo66Y7x59cso3PdAUsVk5HLB1NIqoTUXLAyW9Kfcbmie5D1A5DxnLlaP3dw1/gF8ATHB5FIF0NE2zQ9ojAIl4qZmEJ6H2u9htslB1MEXPH11p960Xm67RscqeV/7tOnDatbAr0EoFUEHUXzvnChDOXQDtFtfw8g7F1QMICkThqjcvlT7CXoisrXtmzkppJq0TBoVbkWS+Z7hNRCH63dN0EPD1Fx4g 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:(13230028)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199021)(36840700001)(46966006)(40470700004)(5660300002)(40480700001)(55016003)(40460700003)(316002)(41300700001)(4326008)(6916009)(70586007)(70206006)(478600001)(54906003)(8936002)(82740400003)(8676002)(356005)(7636003)(47076005)(186003)(36860700001)(336012)(426003)(83380400001)(6286002)(2616005)(7696005)(34020700004)(6666004)(1076003)(26005)(86362001)(36756003)(82310400005)(2906002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2023 09:22:05.3335 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14427f98-524f-4fd0-4074-08db4180b53d 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: BN8NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7081 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 modify field support for GENEVE option fields: - "RTE_FLOW_FIELD_GENEVE_OPT_TYPE" - "RTE_FLOW_FIELD_GENEVE_OPT_CLASS" - "RTE_FLOW_FIELD_GENEVE_OPT_DATA" Each GENEVE TLV option is identified by both its "class" and "type", so 2 new fields were added to "rte_flow_action_modify_data" structure to help specify which option to modify. To get room for those 2 new fields, the "level" field move to use "uint8_t" which is more than enough for encapsulation level. Signed-off-by: Michael Baum --- app/test-pmd/cmdline_flow.c | 47 ++++++++++++++++++++++++++- doc/guides/prog_guide/rte_flow.rst | 27 +++++++++++++--- lib/ethdev/rte_flow.h | 51 +++++++++++++++++++++++++++++- 3 files changed, 118 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 58939ec321..db8bd30cb1 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -636,11 +636,15 @@ enum index { ACTION_MODIFY_FIELD_DST_TYPE_VALUE, ACTION_MODIFY_FIELD_DST_LEVEL, ACTION_MODIFY_FIELD_DST_LEVEL_VALUE, + ACTION_MODIFY_FIELD_DST_TYPE_ID, + ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, ACTION_MODIFY_FIELD_SRC_TYPE, ACTION_MODIFY_FIELD_SRC_TYPE_VALUE, ACTION_MODIFY_FIELD_SRC_LEVEL, ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE, + ACTION_MODIFY_FIELD_SRC_TYPE_ID, + ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, ACTION_MODIFY_FIELD_SRC_VALUE, ACTION_MODIFY_FIELD_SRC_POINTER, @@ -854,7 +858,8 @@ static const char *const modify_field_ids[] = { "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", "ipv6_proto", "flex_item", - "hash_result", NULL + "hash_result", + "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", NULL }; static const char *const meter_colors[] = { @@ -2295,6 +2300,8 @@ static const enum index next_action_sample[] = { static const enum index action_modify_field_dst[] = { ACTION_MODIFY_FIELD_DST_LEVEL, + ACTION_MODIFY_FIELD_DST_TYPE_ID, + ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, ACTION_MODIFY_FIELD_SRC_TYPE, ZERO, @@ -2302,6 +2309,8 @@ static const enum index action_modify_field_dst[] = { static const enum index action_modify_field_src[] = { ACTION_MODIFY_FIELD_SRC_LEVEL, + ACTION_MODIFY_FIELD_SRC_TYPE_ID, + ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, ACTION_MODIFY_FIELD_SRC_VALUE, ACTION_MODIFY_FIELD_SRC_POINTER, @@ -6388,6 +6397,24 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_DST_TYPE_ID] = { + .name = "dst_type_id", + .help = "destination field type ID", + .next = NEXT(action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.type)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_CLASS_ID] = { + .name = "dst_class", + .help = "destination field class ID", + .next = NEXT(action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.class_id)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_DST_OFFSET] = { .name = "dst_offset", .help = "destination field bit offset", @@ -6423,6 +6450,24 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = { + .name = "src_type_id", + .help = "source field type ID", + .next = NEXT(action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.type)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_CLASS_ID] = { + .name = "src_class", + .help = "source field class ID", + .next = NEXT(action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.class_id)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_SRC_OFFSET] = { .name = "src_offset", .help = "source field bit offset", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 32fc45516a..dc86e040ec 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2917,23 +2917,36 @@ The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it ``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. See ``enum rte_flow_field_id`` for the list of supported fields. -``op`` selects the operation to perform on a destination field. +``op`` selects the operation to perform on a destination field: + - ``set`` copies the data from ``src`` field to ``dst`` field. - ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. -- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst`` +- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst``. ``width`` defines a number of bits to use from ``src`` field. ``level`` is used to access any packet field on any encapsulation level -as well as any tag element in the tag array. +as well as any tag element in the tag array: + - ``0`` means the default behaviour. Depending on the packet type, it can -mean outermost, innermost or anything in between. + mean outermost, innermost or anything in between. + - ``1`` requests access to the outermost packet encapsulation level. + - ``2`` and subsequent values requests access to the specified packet -encapsulation level, from outermost to innermost (lower to higher values). + encapsulation level, from outermost to innermost (lower to higher values). + For the tag array (in case of multiple tags are supported and present) ``level`` translates directly into the array index. +``type`` is used to specify (along with ``class_id``) the Geneve option which +is being modified. +This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type. + +``class_id`` is used to specify (along with ``type``) the Geneve option which +is being modified. +This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type. + ``flex_handle`` is used to specify the flex item pointer which is being modified. ``flex_handle`` and ``level`` are mutually exclusive. @@ -2991,6 +3004,10 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. +-----------------+----------------------------------------------------------+ | ``level`` | encapsulation level of a packet field or tag array index | +-----------------+----------------------------------------------------------+ + | ``type`` | geneve option type | + +-----------------+----------------------------------------------------------+ + | ``class_id`` | geneve option class ID | + +-----------------+----------------------------------------------------------+ | ``flex_handle`` | flex item handle of a packet field | +-----------------+----------------------------------------------------------+ | ``offset`` | number of bits to skip at the beginning | diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 713ba8b65c..b82eb0c0a8 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3773,6 +3773,9 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */ RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ + RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type */ + RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class */ + RTE_FLOW_FIELD_GENEVE_OPT_DATA /**< GENEVE option data */ }; /** @@ -3788,7 +3791,53 @@ struct rte_flow_action_modify_data { struct { /** Encapsulation level or tag index or flex item handle. */ union { - uint32_t level; + struct { + /** + * Packet encapsulation level containing + * the field modify to. + * + * - @p 0 requests the default behavior. + * Depending on the packet type, it + * can mean outermost, innermost or + * anything in between. + * + * It basically stands for the + * innermost encapsulation level + * modification can be performed on + * according to PMD and device + * capabilities. + * + * - @p 1 requests modification to be + * performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request + * modification to be performed on + * the specified inner packet + * encapsulation level, from + * outermost to innermost (lower to + * higher values). + * + * Values other than @p 0 are not + * necessarily supported. + * + * For RTE_FLOW_FIELD_TAG it represents + * the tag element in the tag array. + */ + uint8_t level; + /** + * Geneve option type. relevant only + * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX + * modification type. + */ + uint8_t type; + /** + * Geneve option class. relevant only + * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX + * modification type. + */ + rte_be16_t class_id; + }; struct rte_flow_item_flex_handle *flex_handle; }; /** Number of bits to skip from a field. */ From patchwork Thu Apr 20 09:21:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 126306 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 A68D342995; Thu, 20 Apr 2023 11:22:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B08B42D0C; Thu, 20 Apr 2023 11:22:12 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by mails.dpdk.org (Postfix) with ESMTP id 02DFD41156 for ; Thu, 20 Apr 2023 11:22:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZyGVPwGwnMelLVgFlsIxOm5I6YMPhsxGild0PZcjqI57q/mcj7YAKHM8OeRI+FQ1Cq/naeANYZ/soIX/ygn1wD+MQm4LB2PpIeaiQr+SHWUNMHCiA4iBFxTF+DZc39MeBZds9vaHJCTdxyPt0sOUOsJyJ9lwJn8JnRze95IlLG+kc8iTPJxICRmDrefS/hei5Swsr1303nGykkQez7nch2dxY4KLUezIxVPjYD65p9NHYpdXxg+Ig7ipx7Dtnwv+GWdbtB7GAh3kFeyOC14Ib9RLG5euWxOaOTyIaGLo2TS8jvFu/bMqN97LfV77VCJZphXzRPQtfjl+9RxO06r08A== 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=dGrHoXNX7hGyhPSGfNAiNoCH5VtK4QyhERdoAf9Ylrw=; b=M1AsBhYNzY51I3o/4l9DPV0Sncc51oLtkuf+QlFXO4FGEi/UZK5badi1arSZpXoTEOnCQNWuwaZV4p9VPLfo4uK6oWIlNi4BQ0HqexJLEefji/K7fbyqEl4p3dJ8E4EM0nVGe6V9S4a0t3hkU02v8R2SCty5UlhwFfTxPFgxXhPDMzoO8u2gSP/qsYzNRa6W6j4kXVI2W8+USAwR1rnF/vi8GWPorqFcgI3mrXhYzIZOfmecChRX/W0qQhw2oNR0sox2fGGblzJprbFte1srisyB5i6BTH5Q12rD85XmOx917hfPdupz+oiFRbfDKwmT/FK7cvmlgNwSHobaM6nuFw== 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=dGrHoXNX7hGyhPSGfNAiNoCH5VtK4QyhERdoAf9Ylrw=; b=Sk2Aysb2emlvUsDSeQkiFQ9mDhCmwqA/UaArLkKf55e/0+Qnd9lbCAgDHuSjv488QVyDFq1L7jRgFL7dB4ocVLPgZMvDVpEwVb4D60gMHeF9b014R9lRhctNRoqX39rPJI0Yp2TJhj0h1QncEMUnUuu0OUq4F4aPfLj1IlHsusMhZT5sWB6OWHSaHh8p39wApxEgzl3qheFXX7WUmulIk/BiMYzUoUokSAfJg35EXZxsAHERspoY+IRAPUAcZFTUGSd/Mza4cGDTch2+A/N7BxfHgcsJXqyu9KYxhupd4Ne3GLqbmdxd5poLiH6RgTY7HLqH+hb9un3yAiFb3mjESQ== Received: from BN9PR03CA0730.namprd03.prod.outlook.com (2603:10b6:408:110::15) by DM4PR12MB5182.namprd12.prod.outlook.com (2603:10b6:5:395::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Thu, 20 Apr 2023 09:22:07 +0000 Received: from BN8NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:408:110:cafe::cc) by BN9PR03CA0730.outlook.office365.com (2603:10b6:408:110::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22 via Frontend Transport; Thu, 20 Apr 2023 09:22:06 +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 BN8NAM11FT043.mail.protection.outlook.com (10.13.177.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.23 via Frontend Transport; Thu, 20 Apr 2023 09:22:06 +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.5; Thu, 20 Apr 2023 02:21:56 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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, 20 Apr 2023 02:21:56 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Thu, 20 Apr 2023 02:21:54 -0700 From: Michael Baum To: CC: Ori Kam , Aman Singh , "Yuying Zhang" , Ferruh Yigit , "Thomas Monjalon" Subject: [RFC 2/2] ethdev: add MPLS header modification support Date: Thu, 20 Apr 2023 12:21:45 +0300 Message-ID: <20230420092145.522389-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420092145.522389-1-michaelba@nvidia.com> References: <20230420092145.522389-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT043:EE_|DM4PR12MB5182:EE_ X-MS-Office365-Filtering-Correlation-Id: b1be31ac-7c50-4d8e-f929-08db4180b5fb 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: Di+r3bs+grZ4K4XQGkVWBQv9ZPmoRYimskfgPa8vPAktrdk7UmQLHvMPhUlSEZLtDHjEZTeW+o2OaT4xovg+f3/HFtCK566prSqq/Dd45yIFX1h6FXcW2Wp3XokdEfI4n+rd+trBTP0aJ+h1EGeQ+TiR8VxXHrem0rptKBXT4h9+3OZ1uOGFi2X8F/Ps4iGSCAa2YIf+aZawJ7SsDUtdRP8Ac3+/aS5uDAW7Pi2BEr8hZEhiB+pV/DcRFDli30gj5PBzWu39o95/HPoXfsGMFF3ZuHyOilzSfQgT9yJ3/9b9sUj04fvz+5GF3T+W4KE+R48h9kx5XEgMycIiTO5UhrTfxBPILP0oVsV6H/ZODvqA3IsE2FaWIeOvzVCJVAUoyqf8sqrQ7S21kfRQVD2Vu5pg+n5rnn4/faROPz1/u5EgFK0d/C13Q9GWf+9cDpV2MpI7AHKiJxROdUVuL1/D8w7LNukl2SsyeDyePahJNvTtRNWGr8hM5MyYlws3zDWwHBDowoxDMY09Z0ibSazNxrAudWk/eBSXrSf9N3Em7pvonkSvuUFNp6LFeYZ0RQoUvgbhXOu8vEMmSD3NrMa0YInVxHy79g8XFhYyhvR57idlAK93PCIIo8+124smxg7Lch2C5eOSUP37jZUcYU6MTJkBnIcyfMremzH659zC3DNEN+3i2BN1Vdbb1zzHoiJeAvdlauAocm4yhqxOj0B1HdCaCbj0PBV8+L2T5an+vzBT9MwlIVDeaCqH7GQ9xL2jH5mDQgxwwEl40NiZpQFwMJh9Rkw7oSsIvGP0fvp/cOMbiuUQeOWl9t/4nA1pmzuH 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:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(36756003)(55016003)(40480700001)(40460700003)(478600001)(54906003)(34020700004)(7696005)(6666004)(7636003)(356005)(41300700001)(8936002)(8676002)(70206006)(70586007)(316002)(82740400003)(4326008)(6916009)(36860700001)(2616005)(83380400001)(47076005)(336012)(426003)(186003)(6286002)(1076003)(26005)(86362001)(2906002)(5660300002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2023 09:22:06.5834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1be31ac-7c50-4d8e-f929-08db4180b5fb 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: BN8NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5182 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 support for MPLS modify header using "RTE_FLOW_FIELD_MPLS" id. Since MPLS heaser might appear more the one time in inner/outer/tunnel, a new field was added to "rte_flow_action_modify_data" structure in addition to "level" field. The "sub_level" field is the index of the header inside encapsulation level. It is used for modify multiple MPLS headers in same encapsulation level. This addition enables to modify multiple VLAN headers too, so the description of "RTE_FLOW_FIELD_VLAN_XXXX" was updated. Signed-off-by: Michael Baum --- app/test-pmd/cmdline_flow.c | 24 ++++++++++++++- doc/guides/prog_guide/rte_flow.rst | 6 ++++ lib/ethdev/rte_flow.h | 47 ++++++++++++++++++++---------- 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index db8bd30cb1..ffeedefc35 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -636,6 +636,7 @@ enum index { ACTION_MODIFY_FIELD_DST_TYPE_VALUE, ACTION_MODIFY_FIELD_DST_LEVEL, ACTION_MODIFY_FIELD_DST_LEVEL_VALUE, + ACTION_MODIFY_FIELD_DST_SUB_LEVEL, ACTION_MODIFY_FIELD_DST_TYPE_ID, ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, @@ -643,6 +644,7 @@ enum index { ACTION_MODIFY_FIELD_SRC_TYPE_VALUE, ACTION_MODIFY_FIELD_SRC_LEVEL, ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE, + ACTION_MODIFY_FIELD_SRC_SUB_LEVEL, ACTION_MODIFY_FIELD_SRC_TYPE_ID, ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, @@ -859,7 +861,7 @@ static const char *const modify_field_ids[] = { "ipv6_proto", "flex_item", "hash_result", - "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", NULL + "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls", NULL }; static const char *const meter_colors[] = { @@ -2300,6 +2302,7 @@ static const enum index next_action_sample[] = { static const enum index action_modify_field_dst[] = { ACTION_MODIFY_FIELD_DST_LEVEL, + ACTION_MODIFY_FIELD_DST_SUB_LEVEL, ACTION_MODIFY_FIELD_DST_TYPE_ID, ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, @@ -2309,6 +2312,7 @@ static const enum index action_modify_field_dst[] = { static const enum index action_modify_field_src[] = { ACTION_MODIFY_FIELD_SRC_LEVEL, + ACTION_MODIFY_FIELD_SRC_SUB_LEVEL, ACTION_MODIFY_FIELD_SRC_TYPE_ID, ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, @@ -6397,6 +6401,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_DST_SUB_LEVEL] = { + .name = "dst_sub_level", + .help = "destination field sub level", + .next = NEXT(action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.sub_level)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_DST_TYPE_ID] = { .name = "dst_type_id", .help = "destination field type ID", @@ -6450,6 +6463,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_SRC_SUB_LEVEL] = { + .name = "stc_sub_level", + .help = "source field sub level", + .next = NEXT(action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.sub_level)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = { .name = "src_type_id", .help = "source field type ID", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index dc86e040ec..b5d8ce26c5 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2939,6 +2939,10 @@ as well as any tag element in the tag array: For the tag array (in case of multiple tags are supported and present) ``level`` translates directly into the array index. +- ``sub_level`` is the index of the header inside encapsulation level. + It is used for modify either ``VLAN`` or ``MPLS`` headers which multiple of + them might be supported in same encapsulation level. + ``type`` is used to specify (along with ``class_id``) the Geneve option which is being modified. This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type. @@ -3004,6 +3008,8 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. +-----------------+----------------------------------------------------------+ | ``level`` | encapsulation level of a packet field or tag array index | +-----------------+----------------------------------------------------------+ + | ``sub_level`` | header level inside encapsulation level | + +-----------------+----------------------------------------------------------+ | ``type`` | geneve option type | +-----------------+----------------------------------------------------------+ | ``class_id`` | geneve option class ID | diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b82eb0c0a8..4b2e17e266 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3740,8 +3740,8 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ - RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */ - RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */ + RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ + RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ @@ -3775,7 +3775,8 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type */ RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class */ - RTE_FLOW_FIELD_GENEVE_OPT_DATA /**< GENEVE option data */ + RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data */ + RTE_FLOW_FIELD_MPLS /**< MPLS header. */ }; /** @@ -3821,22 +3822,38 @@ struct rte_flow_action_modify_data { * Values other than @p 0 are not * necessarily supported. * + * @note that for MPLS field, + * encapsulation level also include + * tunnel since MPLS may appear in + * outer, inner or tunnel. + * * For RTE_FLOW_FIELD_TAG it represents * the tag element in the tag array. */ uint8_t level; - /** - * Geneve option type. relevant only - * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX - * modification type. - */ - uint8_t type; - /** - * Geneve option class. relevant only - * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX - * modification type. - */ - rte_be16_t class_id; + union { + /** + * Header level inside + * encapsulation level. + */ + uint8_t sub_level; + /** + * Geneve option identifier. + * relevant only for + * RTE_FLOW_FIELD_GENEVE_OPT_XXXX + * modification type. + */ + struct { + /** + * Geneve option type. + */ + uint8_t type; + /** + * Geneve option class. + */ + rte_be16_t class_id; + }; + }; }; struct rte_flow_item_flex_handle *flex_handle; };