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 A929E41B8D; Tue, 31 Jan 2023 10:37:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 989DE410EA; Tue, 31 Jan 2023 10:37:35 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2053.outbound.protection.outlook.com [40.107.212.53]) by mails.dpdk.org (Postfix) with ESMTP id BD22A4067B for ; Tue, 31 Jan 2023 10:37:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RKKjIQ8QxUKnawRaUGbl2r+9U84MSNU7Y8EiJmCXeWd2TBV13LdnqsWjP3qKBrS9XSdGzgguDE0gd4dC28sVeQuSBZhkgBs+12acEPtZIx7IaFtRzga7qzYW8N2S2ex4GNbbCH4vA/cnwhJnBhqhqDfSOTg11oUZhut/RzD4FamGRxIV/J494mcaiyEelCGJvTCUYyrGPs9pC+bxGfFUDlWCpYllimnsi25Pzcl6Vuwc2c44m88Mav35eCbDvD9vbQR2yVopAnnRUAS3y0qaB+EHACwPaoQFK9r/SJZYkDeCeyA1EGkIZ/Ze582t8w3vKF2wJTY9E35gEMoJ692NCA== 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=U2fnKJi+lP4L1nAKdUm+Ke359Ymn7xDaI3ZWvS45/eI=; b=YxyClu84YRG9ZAsL3uc+CMefQND0plESw1OKGes2zWkdcj3W3lpWwzBEJhqQoSsuUuqDTsw3S+yFvIUGwFahUzcpt0YB3uLgDhHTNluxURhzb7q1qBS6Wiod72Qvb4yLL6WHhoW7LqkqqDMiZnMJPdSIs1qvogVyhNfTwKCbJAMgniGwfZL8JEOiSg2Qt+hA+8jbyX0ZaU+XCZniF8ak/4ZN7blBQmJ4W8w4M/9FKmMzsB/us1sEzXLjcn8EhxThM7Lhs0zIjlJYoOb7xP1ov01Tom31kDI+ZyoJ04+My/20jYKfrcXOspjTBBUleOuvcoeVSt4oaR2F722OqmYkRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=U2fnKJi+lP4L1nAKdUm+Ke359Ymn7xDaI3ZWvS45/eI=; b=flsgLfYf+bFAiFLlsf4IXzJxVT0TYRvogj1TA046JwDIvCRH9wCqJtT+o/jt2CQcW1ATSUFfsyXtsT91/jZI25g0cGsgfcvMFZT8WQDbxkcSNNzdaH+8t0omHAwwijOM6uqbk0NO/ett6JIfCA3ae1hnQ+7En0V+pRBTwOG8mGBYDqSZWQBFaQFGkj6e7chcvWFqauuCjo9sxur67hIz0Q/kXVpxsbEEejvguJqs6DX6ZEKHLQwOtTmtR9HDE/GUSB0aIpMYTH8hHxrWF+FJqJqHyPkOLMvlPm5wqxaXkLPZ5vbSr1mZeTknE7Efc0AWd7DXtDjANx36jfXsw3DjAw== Received: from DS7P222CA0026.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::32) by PH7PR12MB8054.namprd12.prod.outlook.com (2603:10b6:510:27f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 09:37:29 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::57) by DS7P222CA0026.outlook.office365.com (2603:10b6:8:2e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Tue, 31 Jan 2023 09:37:28 +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 DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Tue, 31 Jan 2023 09:37:28 +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; Tue, 31 Jan 2023 01:37:16 -0800 Received: from nvidia.com (10.126.231.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; Tue, 31 Jan 2023 01:37:12 -0800 From: Rongwei Liu To: , , , , CC: , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" , Olivier Matz Subject: [PATCH v4 1/3] ethdev: add IPv6 routing extension header definition Date: Tue, 31 Jan 2023 11:36:55 +0200 Message-ID: <20230131093657.2240006-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230131093657.2240006-1-rongweil@nvidia.com> References: <20230130190218.0f6b1b5c@hermes.local> <20230131093657.2240006-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.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: DM6NAM11FT068:EE_|PH7PR12MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fbd5904-41be-4286-980c-08db036ec4c2 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: BULzUnicI+1KNwqrFPvprux0yByZn3x8VsooWNCW8uPqSUAV5HYtwN+JtFVu3k4efpNoLARDW8TiiMyL/+xG+C0kpaq6rScuDsr++QIeBlXggb+rbw/2KnqHDPsdv6NBx+l3iyU5/wVlFUQf7L1qU5o4HbMtub5yWlniB4yvODyFVpxuqjynpJd793ZRCeGoVfYzYDmIATmmAOxtTRssO8bMh1azfULnoOpZaZiiEwidYxHJ6d/O8YVzxq+VIstbeZtMuPqauWjk48NurMLEuePFEd/6iV0TD0R8pCfwVZEz5RX165fYlrhnFKiEYIZsWzLL+j9udgfMKMA1q7GMCT/sCGDA6HOztGaNkUCx/RA+xqPkgqFE14/NPmobC+0v9alT4ssEsWmc6/i1EoPDxZov234BkDDmNY6zaVXV9MsJdf1Vl3lJvaXgj6+FiB3PfdX/2TKmCe++rvQsmZi4S7CkNLTj5okDradIU4NSC7U2K10utj1YGvp4I4y7Lf9+kIar3lvu9kH3VDQsgpxJm3gUOYLuDUDrFj+uLcrrzt0djnDfQPBh8hZPbJs4FSNtpDiO1m0lyV30G/TNmpiLV3npGQMY/2oCTQ7atZ+7UJbcQVp8wTtoHVPDlq3BN3OT3TinPyTxgdCmS2xgzIhjW9bNQ7WCvw+bhNN1aIDIdwIsMKophjHgVymIkvYEUgvMR9yiHRyQLZEkSpTrtcsLwA== 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)(136003)(39860400002)(396003)(346002)(376002)(451199018)(40470700004)(36840700001)(46966006)(2906002)(86362001)(5660300002)(47076005)(426003)(336012)(83380400001)(40460700003)(82310400005)(54906003)(26005)(70206006)(1076003)(186003)(36756003)(41300700001)(8936002)(4326008)(16526019)(70586007)(8676002)(356005)(7636003)(110136005)(316002)(82740400003)(36860700001)(478600001)(7696005)(6666004)(2616005)(6286002)(40480700001)(55016003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 09:37:28.3555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fbd5904-41be-4286-980c-08db036ec4c2 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: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8054 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 | 21 ++++++++++++ lib/net/rte_ip.h | 19 +++++++++++ 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 c15f6fbb9f..1337da73b8 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -69,6 +69,11 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* **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 ------------- @@ -98,6 +103,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..833382c466 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; + memcpy(dst->segments, src->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..ff9270690c 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,20 @@ 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; + __extension__ + rte_be32_t segments[]; /**< Each hop IPv6 address. */ +}; + /** 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..778fb5ef83 100644 --- a/lib/net/rte_ip.h +++ b/lib/net/rte_ip.h @@ -539,6 +539,25 @@ 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. */ + }; + }; +} __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