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 68DECA0545; Tue, 20 Dec 2022 08:45:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C226D42D10; Tue, 20 Dec 2022 08:44:56 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071.outbound.protection.outlook.com [40.107.243.71]) by mails.dpdk.org (Postfix) with ESMTP id 97D2F40395 for ; Tue, 20 Dec 2022 08:44:54 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fgt88IV0CB4txih+R793alR2AXyac7TUYhg+0N8QHf9YqEDMVCJN1zHZcQrbxWtRpKrjhX9xH6KfjgI7c9yrtuy9FhgB0NFGwEQR4DaYixKfZpb1iyDsnXdYoPkcBLubvaN6/9JeZNP4cVqWUFhnesJ74Og8f9UQWBVPsCw9d809Odi61dskZaoWdq0mRzCxqgN2a1NtWtxxTUIOxwwFGKES1JsreRDBjTilTwMABnAKvB9BmtQ1n9Z+8AtxKUNDX3UgMuhXpdP9M+dEDLDiSFWXvb9CzmcZW6zmzZ6Fzf+rchRCMpxG9oGcf6vRdGLIXWr9IuQgRpzEzSMtZQXItA== 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=BVbDg0Q6NG2MM//qNbUklAsEGY625j04Ar0H80P006U=; b=P41uQ7N4v1xulElIRtYjQh/wAnjl/fTGFOKfV/2iuRRt7biyTbtHV/WdtE5bghJu/tQWfLX3+5wLVHzRHruOM8KnKuNkInXmxoh61q6PYp8wqYVMZV9bGLEWQk5t0k1vorkmKjkmiy9f++q75p/inWyl0GksOz+NC6wfLN9pZPbuQspMcpeMphYsDDAzOf887/hEfBrxrloBc6QGUxOibUuaOiumDcFpvvYl3uM6DRwd3/pI1pAi2/jM5mrajEVgt0g0Uzi3VjQFSm2orRJpy0V/QBfPG7ceJJ3e/K6cIGXDB6lED97bBOWKvn85AS+OGfMbCk4gZ15FYMIEOmjk6w== 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=BVbDg0Q6NG2MM//qNbUklAsEGY625j04Ar0H80P006U=; b=t95lmo7+DHpMaKX83u08NnVl12ab5ZVToTZ3GZ0egX4AffPOWuvA6KJmxXheJm4YK4u4JRaBcE98s4szTvN3Z2w6FaFEViAbDwyi3TYHK7AOwz6HrsYHGyzFgCIKGP4AI0f+j/ahBcn7W0TZ8kVFMpO9jmcbiXC99/X5iKi/3xgiX95h2Tkv3N4FGjdXrxPQFcw5093GdwbfcojuSpwZQ8HpIeuyLp8lpXofQ02QPPXpu1rVuaLeHqaqp/QBPKRz/QgiejLQtrsjzcdhIVit7qQ9wthhYPTjjHdwh1lM5ANJi6VpaUbDmpxwMNG0Bus0GMPGEn3rXKBlNpZSntC6TQ== Received: from MW4PR03CA0264.namprd03.prod.outlook.com (2603:10b6:303:b4::29) by SJ1PR12MB6194.namprd12.prod.outlook.com (2603:10b6:a03:458::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Tue, 20 Dec 2022 07:44:52 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::f2) by MW4PR03CA0264.outlook.office365.com (2603:10b6:303:b4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.20 via Frontend Transport; Tue, 20 Dec 2022 07:44:52 +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 CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.6 via Frontend Transport; Tue, 20 Dec 2022 07:44:52 +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; Mon, 19 Dec 2022 23:44:37 -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; Mon, 19 Dec 2022 23:44:36 -0800 From: Leo Xu To: CC: Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH v2 2/3] net/mlx5: add ICMPv6 ID and sequence match support Date: Tue, 20 Dec 2022 09:44:02 +0200 Message-ID: <20221220074403.1015411-3-yongquanx@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221220074403.1015411-1-yongquanx@nvidia.com> References: <20221212085923.2314350-1-yongquanx@nvidia.com> <20221220074403.1015411-1-yongquanx@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT034:EE_|SJ1PR12MB6194:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a97fa31-a88a-4199-89c8-08dae25e14b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OyAeK623i/ukpwzvO+sLaJ7ZTHXS5b2zkkQR/ZkcvRBmXgH6NvXbTR+d7GlzJ8xXkE9sViGittZwkRq2hjHLbVcQm8LuzZUiAPK431yc/GbvdUBKe4fEWepZzyh67VARc/2zt5LzSsxCsTD3pJq19SZr0z/aXnr7hRZmgsfj14O9de7o9kMMG5GDjOOvAR9FooUDW2ymxDcrEX2x+DpzVLp4cfva7oiySXxBOJpRwbpzSenKJexEptYHo28i1e/9efD+5sEF+U1Xo/HaaOunY9QqR/KD8an1a/3wITKNmZolHF0bkBepx+PFBGZKgAdsmOOeWwMpQpoWmwo1wEc+W7FlcULuiiPtf7kOX26EvHpSHO7MHj4vpajlY/iyqUQWoKiVqhLei+0oshLGmNE9T7EI+ob6l6APntQgzrIhniq611BZGpn1/rLPu9pdfq/t0+MkrGg6D0N7ajdc9YNdSQfZgmSxYBwliB1OqoxvWa0w6V9W78FT82Hmq4BsV7Cs/eZNn7zFDrfv3mp/bjj68zRJPxWywZs43n6dVDV6Rw8uyXK6ZtyUXc6phdfgWLB4rv2MTTq8YeSWD8VN/Cb4L2yZnfy0RKjof44FV9qpC0N66J1hC6KsiGiZnOLb/kOIP1EQpBQJ603MAWmcBmNuvm0vIsrALxi71HI9a4qyk0R8gF8O1uhLWGXH/U9R6ngFrlrnM0TLLCFRou583rw+0Q== 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:(13230022)(4636009)(396003)(39860400002)(346002)(376002)(136003)(451199015)(46966006)(36840700001)(40470700004)(41300700001)(8676002)(5660300002)(70206006)(4326008)(8936002)(70586007)(6916009)(82310400005)(316002)(2906002)(54906003)(336012)(40460700003)(36756003)(86362001)(40480700001)(55016003)(82740400003)(16526019)(478600001)(1076003)(26005)(7696005)(107886003)(6286002)(186003)(7636003)(6666004)(356005)(36860700001)(2616005)(47076005)(426003)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2022 07:44:52.7653 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a97fa31-a88a-4199-89c8-08dae25e14b5 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: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6194 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 This patch adds ICMPv6 ID and sequence match support. Since type and code of ICMPv6 echo is already specified by ITEM type: RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY mlx5 pmd will set appropriate type and code automatically: Echo request: type(128), code(0) Echo reply: type(129), code(0) type and code provided by application will be ignored. Signed-off-by: Leo Xu --- doc/guides/nics/mlx5.rst | 2 +- doc/guides/rel_notes/release_23_03.rst | 6 ++ drivers/net/mlx5/mlx5_flow.c | 61 +++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 4 ++ drivers/net/mlx5/mlx5_flow_dv.c | 76 ++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 2 + 6 files changed, 150 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 51f51259e3..78693d19b0 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -405,7 +405,7 @@ Limitations - The input buffer, providing the removal size, is not validated. - The buffer size must match the length of the headers to be removed. -- ICMP(code/type/identifier/sequence number) / ICMP6(code/type) matching, IP-in-IP and MPLS flow matching are all +- ICMP(code/type/identifier/sequence number) / ICMP6(code/type/identifier/sequence number) matching, IP-in-IP and MPLS flow matching are all mutually exclusive features which cannot be supported together (see :ref:`mlx5_firmware_config`). diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 5af9c43dd9..011c2489f7 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -60,6 +60,12 @@ New Features Added ``icmp6_echo`` item in rte_flow to support ID and sequence matching in ICMPv6 echo request/reply packets. +* **Updated Mellanox mlx5 driver.** + + Updated the Mellanox mlx5 driver with new features and improvements, including: + + * Added support for matching on ICMPv6 ID and sequence fields. + Removed Items ------------- diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a0cf677fb0..8eea78251e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2352,6 +2352,67 @@ mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item, return 0; } +/** + * Validate ICMP6 echo request/reply item. + * + * @param[in] item + * Item specification. + * @param[in] item_flags + * Bit-fields that holds the items detected until now. + * @param[in] ext_vlan_sup + * Whether extended VLAN features are supported or not. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_validate_item_icmp6_echo(const struct rte_flow_item *item, + uint64_t item_flags, + uint8_t target_protocol, + struct rte_flow_error *error) +{ + const struct rte_flow_item_icmp6_echo *mask = item->mask; + const struct rte_flow_item_icmp6_echo nic_mask = { + .echo.hdr.type = 0xff, + .echo.hdr.code = 0xff, + .echo.identifier = RTE_BE16(0xffff), + .echo.sequence = RTE_BE16(0xffff), + }; + const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); + const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 : + MLX5_FLOW_LAYER_OUTER_L3_IPV6; + const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 : + MLX5_FLOW_LAYER_OUTER_L4; + int ret; + + if (target_protocol != 0xFF && target_protocol != IPPROTO_ICMPV6) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "protocol filtering not compatible" + " with ICMP6 layer"); + if (!(item_flags & l3m)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "IPv6 is mandatory to filter on" + " ICMP6"); + if (item_flags & l4m) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "multiple L4 layers not supported"); + if (!mask) + mask = &nic_mask; + ret = mlx5_flow_item_acceptable + (item, (const uint8_t *)mask, + (const uint8_t *)&nic_mask, + sizeof(struct rte_flow_item_icmp6_echo), + MLX5_ITEM_RANGE_NOT_ACCEPTED, error); + if (ret < 0) + return ret; + return 0; +} + /** * Validate ICMP item. * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 1f57ecd6e1..9243f58b4c 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2322,6 +2322,10 @@ int mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item, uint64_t item_flags, uint8_t target_protocol, struct rte_flow_error *error); +int mlx5_flow_validate_item_icmp6_echo(const struct rte_flow_item *item, + uint64_t item_flags, + uint8_t target_protocol, + struct rte_flow_error *error); int mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item, uint64_t item_flags, uint8_t target_protocol, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 7ca909999b..62381c6346 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7370,6 +7370,17 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, item_ipv6_proto = IPPROTO_ICMPV6; last_item = MLX5_FLOW_LAYER_ICMP6; break; + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: + ret = mlx5_flow_validate_item_icmp6_echo(items, + item_flags, + next_protocol, + error); + if (ret < 0) + return ret; + item_ipv6_proto = IPPROTO_ICMPV6; + last_item = MLX5_FLOW_LAYER_ICMP6; + break; case RTE_FLOW_ITEM_TYPE_TAG: ret = flow_dv_validate_item_tag(dev, items, attr, error); @@ -10269,6 +10280,65 @@ flow_dv_translate_item_icmp6(void *key, const struct rte_flow_item *item, icmp6_v->code & icmp6_m->code); } +/** + * Add ICMP6 echo request/reply item to the value. + * + * @param[in, out] key + * Flow matcher value. + * @param[in] item + * Flow pattern to translate. + * @param[in] inner + * Item is inner pattern. + * @param[in] key_type + * Set flow matcher mask or value. + */ +static void +flow_dv_translate_item_icmp6_echo(void *key, const struct rte_flow_item *item, + int inner, uint32_t key_type) +{ + const struct rte_flow_item_icmp6_echo *icmp6_m; + const struct rte_flow_item_icmp6_echo *icmp6_v; + uint32_t icmp6_header_data_m = 0; + uint32_t icmp6_header_data_v = 0; + void *headers_v; + void *misc3_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_3); + uint8_t icmp6_type = 0; + struct rte_flow_item_icmp6_echo zero_mask; + + memset(&zero_mask, 0, sizeof(zero_mask)); + headers_v = inner ? MLX5_ADDR_OF(fte_match_param, key, inner_headers) : + MLX5_ADDR_OF(fte_match_param, key, outer_headers); + if (key_type & MLX5_SET_MATCHER_M) + MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, 0xFF); + else + MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, + IPPROTO_ICMPV6); + MLX5_ITEM_UPDATE(item, key_type, icmp6_v, icmp6_m, &zero_mask); + /* Set fixed type and code for icmpv6 echo request or reply */ + icmp6_type = (item->type == RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST ? + RTE_ICMP6_ECHO_REQUEST : RTE_ICMP6_ECHO_REPLY); + if (key_type & MLX5_SET_MATCHER_M) { + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_type, 0xFF); + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_code, 0xFF); + } else { + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_type, icmp6_type); + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_code, 0); + } + if (icmp6_v == NULL) + return; + /* Set icmp6 header data (identifier & sequence) accordingly */ + icmp6_header_data_m = + (rte_be_to_cpu_16(icmp6_m->echo.identifier) << 16) | + rte_be_to_cpu_16(icmp6_m->echo.sequence); + if (icmp6_header_data_m) { + icmp6_header_data_v = + (rte_be_to_cpu_16(icmp6_v->echo.identifier) << 16) | + rte_be_to_cpu_16(icmp6_v->echo.sequence); + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_header_data, + icmp6_header_data_v & icmp6_header_data_m); + } +} + /** * Add ICMP item to the value. * @@ -13381,6 +13451,12 @@ flow_dv_translate_items(struct rte_eth_dev *dev, wks->priority = MLX5_PRIORITY_MAP_L4; last_item = MLX5_FLOW_LAYER_ICMP6; break; + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: + flow_dv_translate_item_icmp6_echo(key, items, tunnel, key_type); + wks->priority = MLX5_PRIORITY_MAP_L4; + last_item = MLX5_FLOW_LAYER_ICMP6; + break; case RTE_FLOW_ITEM_TYPE_TAG: flow_dv_translate_item_tag(dev, key, items, key_type); last_item = MLX5_FLOW_ITEM_TAG; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 20c71ff7f0..dbf935ca26 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4731,6 +4731,8 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_GRE_OPTION: case RTE_FLOW_ITEM_TYPE_ICMP: case RTE_FLOW_ITEM_TYPE_ICMP6: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: case RTE_FLOW_ITEM_TYPE_CONNTRACK: break; case RTE_FLOW_ITEM_TYPE_INTEGRITY: -- 2.27.0