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 8D227423CB; Thu, 19 Jan 2023 04:12:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2480942D15; Thu, 19 Jan 2023 04:12:12 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2077.outbound.protection.outlook.com [40.107.244.77]) by mails.dpdk.org (Postfix) with ESMTP id 227114161A for ; Thu, 19 Jan 2023 04:12:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DUYOp3HkkJSyGm7WlpH9/j6WjKm9YVBcoO6XJYwbcsUj52Rg5vCPoASms1v1iY5ILewkMfuHJOQuJYdjXhXtme8amV8nyovq5kSXxlLrjBp0A8DZjF8R2+COTiXtYvHzC6JuImh1a34UUZMKaznRdGzWdXCvz5CStacMYDwPC+24V1My+neYbdedThaC0dD1tJHyZHBZdUfk1GKwvz1P5rYYvfhX+jcRVW5Pab4q4361gZrIMHMlgAqrnOOiOGMZi0xwtgQPTCl74k5GdzJ2HHJrXc9tj7p1+1z18frVeHGXfDrsX5w4XxNy/ELmzDkdGq2H7khnNvaYjB/nPezdLA== 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=ihPz+RTI2J10Ap/DCW5pYq/QcsI9U+JbLf6yAyQvVvQ=; b=QqwpJQxNawaSidLuWPH8TLcyvm9UjDEWwVjZO/mbWsgvb7NMhRkqAlBP9FJbg21StUU7sQBL1tRAky9S+mC4woRAzYu6vu6WLNlLUQbwTpjfr+ntJzmaEXbVpWQo+mJ2tXP+dkiwmBtgxuknUS9T9wXtQE4t9zhkNS0xzf//F5ZJsGunmEzKISWF6DMegD+vtCNHXAWKggGCFYMQZo7X9YHHjM2qLbRhBmsIssn5RwAqhcPN9PuXMYdUoG/OorIhnzKvT9XlFp6TKdjEwg16hA6d6a8jpaq2AH9Ysqp/RiB/dfsit6i+fiv+FIUqthRvXec/sG1l8WYVp6RzRTomtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=ihPz+RTI2J10Ap/DCW5pYq/QcsI9U+JbLf6yAyQvVvQ=; b=W80kfWr7qK92bAAr+US6GEdkRZJW3llu6haZNw1wXPC1b4oP1dYrMjLsZWm1w+WlxIUrJGADaS35V7XkqPZKjBgRz2gNI1AgaIljIr5F5QaczhiFmgJzffIwaeR4gtdrEbGHi6ejmcfGb1IuW/GbAG3joUtpaDQ+plCaNik6TrMpxDiVyWLh6G2ZeLwZ742pWfYbQTCFq8wfEGqHPBEPhf+v4KLIlDIm8A/YM0babHn1F96xNW9y66geL4bpdJG67TKYD1djbaOCZqDppJAy67CrO1HPCzrVPPzp/lYhtbzC1QX0TuYpVpzSJuuxn/GfBthzw+flimcDPyWZa1KLxA== Received: from BN8PR16CA0009.namprd16.prod.outlook.com (2603:10b6:408:4c::22) by PH7PR12MB6764.namprd12.prod.outlook.com (2603:10b6:510:1ae::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.22; Thu, 19 Jan 2023 03:12:09 +0000 Received: from BN8NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::b) by BN8PR16CA0009.outlook.office365.com (2603:10b6:408:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25 via Frontend Transport; Thu, 19 Jan 2023 03:12:08 +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 BN8NAM11FT085.mail.protection.outlook.com (10.13.176.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24 via Frontend Transport; Thu, 19 Jan 2023 03:12:08 +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.36; Wed, 18 Jan 2023 19:11:57 -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; Wed, 18 Jan 2023 19:11:54 -0800 From: Rongwei Liu To: , , , , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" , Olivier Matz CC: , Subject: [PATCH v2 1/8] ethdev: add IPv6 routing extension header definition Date: Thu, 19 Jan 2023 05:11:32 +0200 Message-ID: <20230119031139.621217-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230119031139.621217-1-rongweil@nvidia.com> References: <20221221084304.3680690-2-rongweil@nvidia.com> <20230119031139.621217-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: BN8NAM11FT085:EE_|PH7PR12MB6764:EE_ X-MS-Office365-Filtering-Correlation-Id: 90322b7d-a120-4eaf-4cc1-08daf9caf352 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: M9G6mSW0TP9uUks9zeB5oJx+tJCrtWjqtXI9HVsw4qvQ1IA1tJTJ8xEVuapUqLJ6PgIrYU1DhPJXLkykoycrG1RdWLw/ekWrJrntiyHPfkSs0GpKoH/k+cC5vY1ySaQH+2y09DF09ctsbehmf59zYgjeLVLoG2U0F3SI3ciA8c1t00hycliAUyGZaUbBm5WZfJJdoj59tvmVDqLCSfSKaOVEQKKmqTM0y1p/BTl3GoKMbruA3OFyeKTtilbE5Sk4bBkPvtrgudp45AdFSZvbwFKnh3ZUSBOhJo1Zo07TeHXHStcRBRGRWB3T5wp3eYC5j9cLskMdJ6WgWQLWCRypx5FZLgji28dD7b+7Q3qn5BDegiycHugf98epwU/eXmy6eDoUE+k+eo/cRk3JMb13aY6WrT0tqlTU6Yy88VMduMBWzhPr4JIfnY+84HneZWu+zjwRkctu9xOnwMlyf9QgFVFdTPNNMI1srKbl1jyfrXKbeSBIgOLPy0F3bQryR546MGaPh68yhFyvqJYK1D0ZHtERVnGjMRM7fLSq8mMP66xu6KGbYjIa0QT7tMb2j8lknRTRloTUcV6H4v21RekuvOqnHrynhKQO2KrTntNihlXirMBmkBgXnOxv/JV6fgqfzWZCjkwTwKuXYwQjLuIDYdnpTz8RIiZEJo1kFk6TYLA5cYVC9u4NSHf59wL1JKoPkz6/FpZ85ngk8BNquq0E8Q== 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:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199015)(36840700001)(40470700004)(46966006)(7636003)(82740400003)(36756003)(40480700001)(40460700003)(55016003)(82310400005)(356005)(86362001)(26005)(70206006)(6286002)(70586007)(8676002)(4326008)(336012)(186003)(478600001)(7696005)(47076005)(110136005)(1076003)(54906003)(2616005)(316002)(426003)(36860700001)(16526019)(8936002)(41300700001)(6666004)(83380400001)(107886003)(2906002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 03:12:08.5126 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90322b7d-a120-4eaf-4cc1-08daf9caf352 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: BN8NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6764 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 | 10 ++++++ lib/ethdev/rte_flow.c | 16 +++++++++ lib/ethdev/rte_flow.h | 19 +++++++++++ lib/net/rte_ip.h | 21 ++++++++++++ 6 files changed, 121 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..ae99036be0 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..2a794d598e 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,11 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: added a new structure: + + - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and + ``rte_ipv6_routing_ext`` + ABI Changes ----------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..4074b475c8 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -76,6 +76,20 @@ 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; + + len = src->hdr.hdr_len ? src->hdr.hdr_len << 3 : src->hdr.segments_left << 4; + if (buf) + 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 +171,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..0120d3e7d2 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..158a2f83ce 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 { + uint32_t flags; + struct { + uint8_t last_entry; /**< The last_entry field of SRH */ + uint8_t flag; /**< Packet flag. */ + uint16_t tag; /**< Packet tag. */ + }; + }; + __extension__ + uint32_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