From patchwork Thu May 18 17:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 127049 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 4E42D42B34; Thu, 18 May 2023 19:41:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BCB542D4F; Thu, 18 May 2023 19:40:53 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 0014F42BFE for ; Thu, 18 May 2023 19:40:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IY9wEVLZN5oFBgJOaKQzdvq9kutN4k5c8kfCsBz2V+xv0IOlDacg36iUDSoVdGFoMQ+jsIKdNvmTuiCJL+CWRqLfnzS8uAZ6IRL96cyfWumRN57I20CFdYqjbLWFAS4eHOSlV6vsSl9Eo7p0wzyPq74oXfxnJ3ol484QTcK+IYJfHSMc7pa9lsUeah98O+8RFCwErkndAOk5jKJEzd3UACT1a45u+stNibReeNTRnG1rT9AtGgZyc3ctu9+S5TqJnoskcIW/Z7XtiM51O2xvo96EOaCkh5o0HyK2PmTGYZQP9LEgVr6jQqnYv2ibA6TBbQA0CPb+vUJpCKbGhBk3wA== 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=kz2Qhqb923LJ9zgitOwK4rSwn5MyK9wq3a5dj0e0ruk=; b=Cr2d/iE0ZS1opaFpbGauuCGrR+iFEn7ZGYgicWSO60R2Vvlu3/iSc0o4gBM7HJFNDs/JRKm2F1KN3SVcuz7iyui7bQMumZquGblv/PDuGcSR9dULhwh+csox/jtpH3yizFpBEkzNl35wNdrcbes2pvwUJYiZXeX+6vsAVnhqbtudtDu6TkKyplNtiSF5RvgQTzDCxguWR0Z9unnZNnQJ4odLrpJMunaMC6JdYLY5ut6DAOrsquWLMIGdduSehBtpNYz+jEOTMXDwQ4R1POLqKSREMw2N39iTpw0vIiRt7jUkdN90JqRXfBe3KKBoc3Z4gf9CRdan/+Pp4q9y1XfhGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=kz2Qhqb923LJ9zgitOwK4rSwn5MyK9wq3a5dj0e0ruk=; b=ay7za0oHZvl6eJQhgcVqP3kaNdKn2fzZV692OFHQvxcJuKEXw/CO/YWnls2c2wRvALwmXwghPCIGFIOPVO3fOM1yi2JHBvy9sa+qyxGBrqX80wVXbTP8IVyeM9x2dA1z6lm3w/LX1/TA0jOer4amLPmmG03aTRmiBRZzV3P3iHbSN/ZtBqvd7zOT46DzVvPFM2iKoERO4CWjSUDT/1yl87yi1OVW+2FZHyCdizmBoywOWyAQKlJDlB5cgxV9jvBKTOgkVaZmFU3Ih0hZ6RFTNHOXkSHiiLLDKekWGua0DJkGhY2hXBMylQ01kjr2OpWylSJfvYmrOd9EtMIArPzbFw== Received: from BYAPR07CA0013.namprd07.prod.outlook.com (2603:10b6:a02:bc::26) by PH7PR12MB5949.namprd12.prod.outlook.com (2603:10b6:510:1d8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Thu, 18 May 2023 17:40:49 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:a02:bc:cafe::c4) by BYAPR07CA0013.outlook.office365.com (2603:10b6:a02:bc::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.20 via Frontend Transport; Thu, 18 May 2023 17:40:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.11 via Frontend Transport; Thu, 18 May 2023 17:40:48 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 18 May 2023 10:40:33 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 18 May 2023 10:40:33 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) 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, 18 May 2023 10:40:31 -0700 From: Michael Baum To: CC: Ori Kam , Aman Singh , "Yuying Zhang" , Ferruh Yigit , "Thomas Monjalon" Subject: [PATCH v2 5/5] ethdev: add MPLS header modification support Date: Thu, 18 May 2023 20:40:15 +0300 Message-ID: <20230518174015.3373185-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518174015.3373185-1-michaelba@nvidia.com> References: <20230516063747.3047758-1-michaelba@nvidia.com> <20230518174015.3373185-1-michaelba@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|PH7PR12MB5949:EE_ X-MS-Office365-Filtering-Correlation-Id: 8409a92c-ff48-432e-1f3c-08db57c70470 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: bdaVmCeGdqbNrHwyTIdtDMPNjROdvxAKnbXXvYvDVmHS+hUZF6F+dvaXeJ1rjQ2EOfNTH63kpSAXwMUN3HKdXmiB7ZpHQz8N1Xn64yEo70KAvaBeO1+vtMe6dz0/KUe8Zl0j5jO8mVL5whzVfgB0pr1MPHohrGgFka1hDbZZ5qoha3Ue+6re1u5jx/e94N/IYZ1QQtXuq4oQ78qmL2yLdX50eZovlCab508QC1XFW1JeaGn06eGgG2+qgAekwumuc7MHfBcZGDyE4h/66CjAf7DfYhFAPviUK33JmRLnlL8bhb7gzjbFLQlujiZjo9I+g3iFDEZbzDzXQWCSbtnqzvW6vCyKY0+7OMT8UzQfddjxf0+ebAT9GPYAh22r5irZiHY5FEU2XBI9ms0Z/ZOXQXWWaKNtKokUJ5IHP9TjM1kmxvR2HN37//bezi3drGiVSzYCGrKIJOfNe2kIVm/uw4gFnp+Lf7OwGlXHsvJTmorkmUWFpnkq50vw5zGjWboazeiIvJLq4mHZ2e6iIJ9g1vhEOwKD+i988NzKuHv7j7Ir2uIyDaMfOEiHNaTlsiJ/a5Hy25edLFBMK8hqltDGZxiZaO6eX1PWvWgYT9ti/7zLtfuQGVhxoHA82SZ5g/x1dvsQYKVky4XP4ZHWt8B+a1zz0ZQdv83iig2RVO2so+QOSABmwf8zsPnpwy9C036Wskb4lT1k8a/ylvXE8zueHn/NTzMEj+byDgUdWS8SlpXdCZPNQ0BpSVK5JJkX4oaP X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199021)(36840700001)(46966006)(40470700004)(55016003)(6916009)(40460700003)(426003)(6666004)(2616005)(2906002)(54906003)(41300700001)(7696005)(36860700001)(70206006)(83380400001)(70586007)(47076005)(478600001)(8936002)(336012)(26005)(1076003)(186003)(5660300002)(4326008)(6286002)(316002)(8676002)(40480700001)(82740400003)(86362001)(82310400005)(36756003)(7636003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 17:40:48.6841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8409a92c-ff48-432e-1f3c-08db57c70470 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.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5949 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 | 12 +++++--- lib/ethdev/rte_flow.h | 49 ++++++++++++++++++++---------- 3 files changed, 63 insertions(+), 22 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..591e43b5ac 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,9 @@ 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. ``type`` is used to specify (along with ``class_id``) the Geneve option which is being modified. @@ -3011,7 +3011,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/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index f30d4b033f..34e536d662 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,36 @@ 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. + */ + 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; };