From patchwork Mon May 22 19:28:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 127184 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 4376942B76; Mon, 22 May 2023 21:28:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DAFC742D4F; Mon, 22 May 2023 21:28:38 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) by mails.dpdk.org (Postfix) with ESMTP id DC50A427EE for ; Mon, 22 May 2023 21:28:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CGJFtjsk3a97UzpW9vFr8EOo501s93xM6y8Fcm/lNPd/Q3XjqpduPjULXHRy+ZWbPKC6gCFXVf7A+7gBVJtjO9k/aeszJDnRONM8PCfAEYT3SBUtjvJB7naPnicVNJRAPt9203VJOba6/SwiNt/XNbuyaITrPZGtCgW38d/4tq4ysmmV3//co80XA64UWhBHSz8GIn5kqiHJmZsjSLUqraOE6BT+mk8v/yeJe8XlDHsHSDbt1JF4R6Xxpi6rvTLv3aHAQ8uA/hx1ZcYBrBx6Rw1f31/hO2clD2t5Pn0kHhYXqfUd709VJqcdupTekOMxHnqpO+wQAniYWtCw05QYmw== 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=ysBUHqD5GhoqtG0MhkrlHcs0yH3ua4f7Q8oj+lxg19A=; b=MUWfTWpdEGkTlizUYoXrABVwbJrduMz+nSJMJC0c7ftfFkBL+L6NnuP15Tdx/qb0FRTFZfScYHhtttMX82UNgiKxwoNwrqYnqaS62qzmNe6pcRUT1wr173jiFTQhlvkC7j0R+GT+mVas3LULrx8Rb/vZZrS+46PlDS0Y16tJuXmB33CcoixkWZdKGBN5aoBTxnlYvU30pcOFcvvfJj+rPD5NoSt1/er7rJEd3GfEP7EiL42Fre2RzIogWhUqmCJ8KladkG1Ex4+c68cpgzeTm6Ig1UTTLpKnNUK9NVcQiz7ykNiSMcnVvixHCN90yumBc/o0N8IXfJ7SWwsX3UgOpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=ysBUHqD5GhoqtG0MhkrlHcs0yH3ua4f7Q8oj+lxg19A=; b=eOC0FvOt4tztMfNk3eSNFppfcL9Q7l/8g68vheTFPo+NjyZBEAILPaTC5uXh5P8WdUmQoG7vYLc2folpjQlObvuAtXFLRhybZ121BFpB8quGk9XRQZmDvJyyAqW29204YE+QMABas+CXzqYWwcI5M8OQM7emgv+ZlJEH2IWRxMD0tzNhskvuKfOewn6EhgQe9kFLMz9lXPSwFtyG3jIimhD8wIrf+2ODOzIovaLjhuRyNVhoEhXp7jW26V5dP9tq/aT7wqjILEtXoRpo7bx5bJBHqn/2Yuxdd6A2Px0GC9kOoeotwz31Bu1+O21zxDLjVpgtjSC2/W6vDT6YdVROcg== Received: from BN0PR04CA0193.namprd04.prod.outlook.com (2603:10b6:408:e9::18) by IA1PR12MB6092.namprd12.prod.outlook.com (2603:10b6:208:3ec::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Mon, 22 May 2023 19:28:33 +0000 Received: from BN8NAM11FT073.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::73) by BN0PR04CA0193.outlook.office365.com (2603:10b6:408:e9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Mon, 22 May 2023 19:28:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT073.mail.protection.outlook.com (10.13.177.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Mon, 22 May 2023 19:28:33 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 22 May 2023 12:28:22 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 22 May 2023 12:28:21 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Mon, 22 May 2023 12:28:20 -0700 From: Michael Baum To: CC: Ori Kam , Aman Singh , "Yuying Zhang" , Ferruh Yigit , "Thomas Monjalon" Subject: [PATCH v3 5/5] ethdev: add MPLS header modification support Date: Mon, 22 May 2023 22:28:04 +0300 Message-ID: <20230522192804.3759072-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230522192804.3759072-1-michaelba@nvidia.com> References: <20230518174015.3373185-1-michaelba@nvidia.com> <20230522192804.3759072-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT073:EE_|IA1PR12MB6092:EE_ X-MS-Office365-Filtering-Correlation-Id: e2e6acf5-9cd3-4d79-e43e-08db5afabb40 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: yN9f52ebQ3abJ9EmZ7kI7HpOPV5qtDho76FpwT1F0qUd0wYjqXRTQYVIx1LWMoWCm7WIphEUhGmMZA6c7papOkkL8mtFAn+PBusw4NMra7r3JTLQy8LTWF4U/g9w3UH5OS6qpROanXgrmDvuDnnApAx5q/OvwY947gidUzsRZqLCT28QC64hMsI88EU2rmrTbjIJXmLXft7eLh2GLXnRXvnFzPM2wz/w1f9kog4gbTXiPutupETmSlV9nFSvC4+jq+rlrOwgoBh7optksqKLJB2c5WGBW1YAQqXE8LC9P5Xsb9nz6AK/1FAL8mNhYAXoB8b64go+s+Pt0+RlRqKqXAEvF+1NCf0/6dWpsskPeBiUKJxroydjkHyWFcPaxH1Pw0MR6acYgvHmP+m5N0iUesBnW08hj1h5SaN/yDVx0OWOmj8lUxpvOh8mXYfuhIJvOF996raV8BfhzD3xM0dSdmSa+L/0JCh9sd2mxv8TTXFakyF7okkLXCOTJ+YQ8jTZ7lxmqVWMkKZlHZfecGPHOdzmEpM+4cjal8BnSGSp//dj5cKMQpyfLWEGKODhPQLnFAVeOxWnYIZGNmxdAdUv7ZyL1K3UMsZdxA4ni8kCPCBetK/icSd0IjG05MNxpVwLuxfHdAYcvypnWofZxj0QVOr7kfGdiuVaR4aUWj1YqCJWXLDc/+c1n9rQbeiSu4pVSXEQhccXt1s6IRM4ozNx/Z4ePBWkuoo6hssWdyfynA3x8sChkKndT1kF4Xtjr3Le X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(8676002)(8936002)(5660300002)(83380400001)(47076005)(36860700001)(6286002)(186003)(356005)(26005)(2616005)(336012)(426003)(86362001)(1076003)(82740400003)(7636003)(40460700003)(82310400005)(55016003)(6666004)(40480700001)(478600001)(7696005)(41300700001)(4326008)(6916009)(36756003)(70586007)(70206006)(316002)(54906003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2023 19:28:33.0942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2e6acf5-9cd3-4d79-e43e-08db5afabb40 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT073.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6092 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 "tag_index" 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 | 18 ++++++--- doc/guides/rel_notes/release_23_07.rst | 8 +++- lib/ethdev/rte_flow.h | 51 ++++++++++++++++++-------- 4 files changed, 77 insertions(+), 24 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 8c1dea53c0..a51e37276b 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_TAG_INDEX, 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_TAG_INDEX, 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", + "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls", NULL }; @@ -2301,6 +2303,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_TAG_INDEX, ACTION_MODIFY_FIELD_DST_TYPE_ID, ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, @@ -2310,6 +2313,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_TAG_INDEX, ACTION_MODIFY_FIELD_SRC_TYPE_ID, ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, @@ -6398,6 +6402,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_DST_TAG_INDEX] = { + .name = "dst_tag_index", + .help = "destination field tag array", + .next = NEXT(action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.tag_index)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_DST_TYPE_ID] = { .name = "dst_type_id", .help = "destination field type ID", @@ -6451,6 +6464,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_SRC_TAG_INDEX] = { + .name = "stc_tag_index", + .help = "source field tag array", + .next = NEXT(action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.tag_index)), + .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 ec812de335..e4328e7ed6 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2925,8 +2925,7 @@ See ``enum rte_flow_field_id`` for the list of supported fields. ``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: +``level`` is used to access any packet field on any encapsulation level: - ``0`` means the default behaviour. Depending on the packet type, it can mean outermost, innermost or anything in between. @@ -2934,8 +2933,15 @@ as well as any tag element in the tag array: - ``2`` and subsequent values requests access to the specified packet 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. +``tag_index`` is the index of the header inside encapsulation level. +It is used for modify either ``VLAN`` or ``MPLS`` or ``TAG`` headers which +multiple of them might be supported in same encapsulation level. + +.. note:: + + For ``RTE_FLOW_FIELD_TAG`` type, the tag array was provided in ``level`` + field and it is still supported for backwards compatibility. + When ``tag_index`` is zero, the tag array is taken from ``level`` field. ``type`` is used to specify (along with ``class_id``) the Geneve option which is being modified. @@ -3011,7 +3017,9 @@ and provide immediate value 0xXXXX85XX. +=================+==========================================================+ | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | +-----------------+----------------------------------------------------------+ - | ``level`` | encapsulation level of a packet field or tag array index | + | ``level`` | encapsulation level of a packet field | + +-----------------+----------------------------------------------------------+ + | ``tag_index`` | tag index inside encapsulation level | +-----------------+----------------------------------------------------------+ | ``type`` | geneve option type | +-----------------+----------------------------------------------------------+ diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index ce1755096f..fd3e35eea3 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -84,8 +84,12 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* The ``level`` field in experimental structure - ``struct rte_flow_action_modify_data`` was reduced to 8 bits. +* ethdev: in experimental structure ``struct rte_flow_action_modify_data``: + + * ``level`` field was reduced to 8 bits. + + * ``tag_index`` field replaced ``level`` field in representing tag array for + ``RTE_FLOW_FIELD_TAG`` type. ABI Changes diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index f30d4b033f..1df4b49219 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. */ }; /** @@ -3789,7 +3790,7 @@ struct rte_flow_action_modify_data { RTE_STD_C11 union { struct { - /** Encapsulation level or tag index or flex item handle. */ + /** Encapsulation level and tag index or flex item handle. */ union { struct { /** @@ -3820,20 +3821,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. */ 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 { + /** + * Tag index array inside + * encapsulation level. + * Used for VLAN, MPLS or TAG + * types. + */ + uint8_t tag_index; + /** + * 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; };