From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 72BAE424B9; Mon, 30 Jan 2023 05:00:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F1C040EE7; Mon, 30 Jan 2023 05:00:12 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2058.outbound.protection.outlook.com [40.107.101.58]) by mails.dpdk.org (Postfix) with ESMTP id 1CB7040EE6 for ; Mon, 30 Jan 2023 05:00:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k7aJgz4Vc4nJemZgOj1gyhjM1OZqDvjzDJlxXCN6FhXmtNSPA2cCgGBnrrOeEy6TI0zbqb0yz+JooFXLCFNk7BU3Fu6O6LoOZL9YtNUUiDOFOiWRgRzigHho60+T+aiSc95I7ODlTf+XJxHGM2sStuU6gi72/ofh7U7DHAxlBMFc3VhwfXbMdeGqTCxC+9T16phETIREyzLc4dIc4wTdAnvTdn0TdS2s0aj/LWFcrFDlnBtmh0upxKOjGJBaqdIpjLE41m+0n66B/jfLjIHgELy9cIcfxkio6OZOIE25hFmoiPLbeyDxvSmorC9cehGfbzPksc/YLkGVy/2ZQ/p4yw== 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=+QKExW9oY5FOCLWEu+0xbLZxBunIuqvxsMQGFJYo5vA=; b=EQrdcTGtMoDNvOjNOCT+gLlmQNMRlz2hOajIBN7bzcClkYM/labBbm0bc2ANVFc5O4iA8E6Gi/+v+HUn+qk7/HKa4t5qHto6apIT1Jn95gwXpvluF4qWGl2CWyYsLE2DFIC/a7aT8NxRSaTEP5BPFDA1RcZVZFfC33oTgLmEl2NOjiKdgWpmTi5wdxnizE/3a8bfPKqS1dYHmdqyx9yN4+EULbIflacVlXriU9LbrIipOLNlm7JSQXi42rXPwGt325JT52Q309bxsbexPrhkYbzDAim9cOVhM0LzdDZ1xBTmPbBso0nuZZ0ZSgHoTyIL86y5ZFF1xF0Q4N8D6SL75w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=monjalon.net 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=+QKExW9oY5FOCLWEu+0xbLZxBunIuqvxsMQGFJYo5vA=; b=OdpMBmwYCBYRhSk1EjEd//iWsIdKtTY3sPwtsxP/shizdMu4btCf/KGTY/ewMz1yx3qCKrWQM9qqwwE9oDf7erDxAENjyYW0CcybQITgrVY9xfIdbEKPT/WtAqOpZqoaZ9cbZaZe+YcuNnvS4fCQn2QXkQE+NjyNFGBb8r0/YCOjIgYkBPk4Sv2HU6nmwSxf6KBDLojcXWX3zY3aISkecgcc9/7DdJ1OLJRiGt+eL2ZOTG+WKFygS5uGHJhm5NK7vN07RghEoXBE7zqy8najT41m/70hviqZ4W6IcIuYRCQ5ZrpUd1fQf8w+a0xpzt0ucQErcGuZMfZ5M68uSrH87w== Received: from CY5PR15CA0194.namprd15.prod.outlook.com (2603:10b6:930:82::12) by MN2PR12MB4301.namprd12.prod.outlook.com (2603:10b6:208:1d4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 04:00:08 +0000 Received: from CY4PEPF0000C967.namprd02.prod.outlook.com (2603:10b6:930:82:cafe::62) by CY5PR15CA0194.outlook.office365.com (2603:10b6:930:82::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36 via Frontend Transport; Mon, 30 Jan 2023 04:00:07 +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 CY4PEPF0000C967.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17 via Frontend Transport; Mon, 30 Jan 2023 04:00:07 +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.36; Sun, 29 Jan 2023 19:59:59 -0800 Received: from nvidia.com (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.36; Sun, 29 Jan 2023 19:59:56 -0800 From: Rongwei Liu To: , , , , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" , Olivier Matz CC: , Subject: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition Date: Mon, 30 Jan 2023 05:59:33 +0200 Message-ID: <20230130035941.1495874-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230130035941.1495874-1-rongweil@nvidia.com> References: <5da6632a-0976-dc1f-facb-f778c8aad8e6@oktetlabs.ru> <20230130035941.1495874-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C967:EE_|MN2PR12MB4301:EE_ X-MS-Office365-Filtering-Correlation-Id: 40392a2d-c0aa-45f3-f803-08db027679cb 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: EqE1EYhwHAVgQk7C/dU3W0EtSssC04DVqaKJSzmJx79jEjEdvefhoyhVNAo1xeyaBOsU7TASuwMTFPDHxH99tNqhWbLA69ph5Gwh++ysgRYA+mSyg6/d0Sd7+0aXgQDwpEhc+36a9TgQF8jmXVHIDJ4bixcadF2k+G+xWtFPto3UOAP0f7Kb1fU9FWzdDdBDWLlAxYqd0O5ytG+SgDuHTezaXBFZi4UMYMBIbZKfKfphFGgcorCGEG62evdgTbB+AaY/pUxXm7e29+6p9INTKxte6PDETzM0Ah/xFAL1gQBu+19cHMnV3A86+foIdwTKoeQc8PsKmReFLgSdH1lYjgq3afFyzrmYzXVmU/M+U8uV9uT3xjwIfnCubNfwrkvvK1ujX2JK5Ec2kklMWbhx4KidRCeIv/Y89F8tVlkXgrRAtO9fN+p58YhJeWH0rwrXPZf6UdmekfxfrBdu5PDBP3MX0I4KF4laOZnxe/vDRWCfEs/W2DJ1IUNTgXpbxzelB2Yqr2MZSwbDniPKpde/8ks0B1EoBlhNIWCb0CYDlz5OX35MOfO9JIotABKvkTdaqOxEMN3jZQGnho2TDSSEFf0D+karzN8XRx1+57KjC9+fWxeQFJxbqv5cbEsEeXX4iQYqD8FXJ3njfgtV06FQ8r5vbeKgJqHfWb6LAahtPtpPNspBlkGHDqQHS82sW67WWbOnNExAMv91R6djLwb/Lg== 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:(13230025)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199018)(36840700001)(40470700004)(46966006)(82310400005)(2906002)(5660300002)(86362001)(47076005)(336012)(6286002)(426003)(83380400001)(8936002)(40460700003)(41300700001)(356005)(36756003)(478600001)(1076003)(6666004)(26005)(7696005)(186003)(107886003)(55016003)(82740400003)(7636003)(2616005)(36860700001)(70586007)(70206006)(4326008)(8676002)(40480700001)(54906003)(16526019)(110136005)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 04:00:07.4769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40392a2d-c0aa-45f3-f803-08db027679cb 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: CY4PEPF0000C967.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4301 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 IPv6 routing extension header definition and no TLV support for now. At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field. Add command line support for IPv6 routing extension header matching: type/nexthdr/segment_list. Signed-off-by: Rongwei Liu Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 46 ++++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 9 +++++ doc/guides/rel_notes/release_23_03.rst | 9 +++++ lib/ethdev/rte_flow.c | 19 +++++++++++ lib/ethdev/rte_flow.h | 19 +++++++++++ lib/net/rte_ip.h | 21 ++++++++++++ 6 files changed, 123 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..7a8516829c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -298,6 +298,10 @@ enum index { ITEM_IPV6_SRC, ITEM_IPV6_DST, ITEM_IPV6_HAS_FRAG_EXT, + ITEM_IPV6_ROUTING_EXT, + ITEM_IPV6_ROUTING_EXT_TYPE, + ITEM_IPV6_ROUTING_EXT_NEXT_HDR, + ITEM_IPV6_ROUTING_EXT_SEG_LEFT, ITEM_ICMP, ITEM_ICMP_TYPE, ITEM_ICMP_CODE, @@ -1326,6 +1330,7 @@ static const enum index next_item[] = { ITEM_ARP_ETH_IPV4, ITEM_IPV6_EXT, ITEM_IPV6_FRAG_EXT, + ITEM_IPV6_ROUTING_EXT, ITEM_ICMP6, ITEM_ICMP6_ND_NS, ITEM_ICMP6_ND_NA, @@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = { ITEM_IPV6_SRC, ITEM_IPV6_DST, ITEM_IPV6_HAS_FRAG_EXT, + ITEM_IPV6_ROUTING_EXT, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_ipv6_routing_ext[] = { + ITEM_IPV6_ROUTING_EXT_TYPE, + ITEM_IPV6_ROUTING_EXT_NEXT_HDR, + ITEM_IPV6_ROUTING_EXT_SEG_LEFT, ITEM_NEXT, ZERO, }; @@ -3844,6 +3858,38 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6, has_frag_ext, 1)), }, + [ITEM_IPV6_ROUTING_EXT] = { + .name = "ipv6_routing_ext", + .help = "match IPv6 routing extension header", + .priv = PRIV_ITEM(IPV6_ROUTING_EXT, + sizeof(struct rte_flow_item_ipv6_routing_ext)), + .next = NEXT(item_ipv6_routing_ext), + .call = parse_vc, + }, + [ITEM_IPV6_ROUTING_EXT_TYPE] = { + .name = "ext_type", + .help = "match IPv6 routing extension header type", + .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext, + hdr.type)), + }, + [ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = { + .name = "ext_next_hdr", + .help = "match IPv6 routing extension header next header type", + .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext, + hdr.next_hdr)), + }, + [ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = { + .name = "ext_seg_left", + .help = "match IPv6 routing extension header segment left", + .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext, + hdr.segments_left)), + }, [ITEM_ICMP] = { .name = "icmp", .help = "match ICMP header", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..602fab29d3 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter. - ``color``: Metering color marker. +Item: ``IPV6_ROUTING_EXT`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Matches IPv6 routing extension header. + +- ``next_hdr``: Next layer header type. +- ``type``: IPv6 routing extension header type. +- ``segments_left``: How many IPv6 destination addresses carries on. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index b8c5b68d6c..8f482301f7 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added rte_flow support for matching IPv6 routing extension header fields.** + + Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension + header. + Removed Items ------------- @@ -84,6 +89,10 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* net: added a new structure: + + - IPv6 routing extension header ``rte_ipv6_routing_ext``. + ABI Changes ----------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..5c423db160 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -76,6 +76,23 @@ rte_flow_item_flex_conv(void *buf, const void *data) return src->length; } +static size_t +rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data) +{ + struct rte_flow_item_ipv6_routing_ext *dst = buf; + const struct rte_flow_item_ipv6_routing_ext *src = data; + size_t len; + + if (src->hdr.hdr_len) + len = src->hdr.hdr_len << 3; + else + len = src->hdr.segments_left << 4; + if (dst == NULL) + return 0; + rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)), src->hdr.segments, len); + return len; +} + /** Generate flow_item[] entry. */ #define MK_FLOW_ITEM(t, s) \ [RTE_FLOW_ITEM_TYPE_ ## t] = { \ @@ -157,6 +174,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)), + MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext), + rte_flow_item_ipv6_routing_ext_conv), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..9b9018cba2 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -624,6 +624,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_meter_color. */ RTE_FLOW_ITEM_TYPE_METER_COLOR, + + /** + * Matches the presence of IPv6 routing extension header. + * + * @see struct rte_flow_item_ipv6_routing_ext. + */ + RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT, }; /** @@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 { uint32_t reserved:23; }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT. + * + * Matches an IPv6 routing extension header. + */ +struct rte_flow_item_ipv6_routing_ext { + struct rte_ipv6_routing_ext hdr; +}; + /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */ #ifndef __cplusplus static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h index 9c8e8206f0..56c151372a 100644 --- a/lib/net/rte_ip.h +++ b/lib/net/rte_ip.h @@ -539,6 +539,27 @@ struct rte_ipv6_hdr { uint8_t dst_addr[16]; /**< IP address of destination host(s). */ } __rte_packed; +/** + * IPv6 Routing Extension Header + */ +struct rte_ipv6_routing_ext { + uint8_t next_hdr; /**< Protocol, next header. */ + uint8_t hdr_len; /**< Header length. */ + uint8_t type; /**< Extension header type. */ + uint8_t segments_left; /**< Valid segments number. */ + __extension__ + union { + rte_be32_t flags; + struct { + uint8_t last_entry; /**< The last_entry field of SRH */ + uint8_t flag; /**< Packet flag. */ + rte_be16_t tag; /**< Packet tag. */ + }; + }; + __extension__ + rte_be32_t segments[0]; /**< Each hop IPv6 address. */ +} __rte_packed; + /* IPv6 vtc_flow: IPv / TC / flow_label */ #define RTE_IPV6_HDR_FL_SHIFT 0 #define RTE_IPV6_HDR_TC_SHIFT 20 -- 2.27.0