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 254A7A0545; Tue, 20 Dec 2022 08:45:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAD4542D17; Tue, 20 Dec 2022 08:44:57 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) by mails.dpdk.org (Postfix) with ESMTP id 31FA540395 for ; Tue, 20 Dec 2022 08:44:55 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJNXYI7Bg3SOMFTn/TPSWICWy41XF183qIIq07RlT5/1oqZc+NEavVM0m1UmTJGwc/Q3SyQ2Xazj4UJczB/hjHIvVRdRagO0sitYw670RbNSiibF9UP7hbGD5vOBBp2s3PuhGoMxpXtD4wJrf6qRKuwrLlxBJNC+WmLs341lm1jeEuIwNzpo3ySkzcyFnrYyOOCLNbdpp3WCUg1XueW7vLV0Yo/XDxb7KndsqJARuoVpvNxVXaEB1zl8aSIs3bwUarAPXJUFTe86iI+yoeU++S+4T64ib95o56SQtIdAEEmEuH/i1SGbXIAB+Re2D49NT4+KQR4OIsQUSfKnUY2Feg== 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=9vIa99VJZDtKC+wO6ZkI08HK7vcs2t9/HdsHkhmRQvk=; b=WdmuiN8FNOAuDc8O33n83UL8G2F/2p1wfb0Uzwf2+blEwj+DjtH+06IQOYp6x8rzJGWz51gGeuTMj5IpNgdjlM6oZfAyNlhBOMQxVf9iH62V0OO6mU/CoV6jWp9lDv5Yq5RSNogJWoqHm/59N8gDjaysjZ5tj+A+0fNPIm23JnjMfZ7W1ykI0u7WmkYL5Ry8JyOepY+iqjcnI6SDyGy5eiNbWBEdw3UjkMLOrGrQBRQjQImsSTTh/mpeWsLxb5t0kcsERSZ1iPzk4r5/3Ul1v/YzX/7IR8aRs/aMcwn9MgVMCJLN/RuZgAnpZWuUKK2rMiIaoKkL16JbyUt+4kituw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=9vIa99VJZDtKC+wO6ZkI08HK7vcs2t9/HdsHkhmRQvk=; b=bOTiiCsmfJJG7wDzf93HCBYYpYYDNYk3HAaTxKAGtc9xuzvXm4DIOQQ0riYHbc/ZRfLcnMM2mzyiM6nRUz1o12w588U6e6eyI3hvzujUM9gZUmJTN+uhp2gtuigERy/H01h6ROVj6BDhFYlRG2xvS6jrC6wDfys1bqJ0BeKBRCo8/7tApWJhgiClI0XXuGqKO1EbgWNgunDlLLZZsvw++YYavSz2Zt24LrcSeVX8rXY1UzE1I4Bfe//QCdZrlM5H2Oy2zQvsmzX3YhbjCOUe0kutd2jWW0Pmxi72MBHGdnA54ONu0693UGOyUT/dJGNdV8ys91wdOJxNgDirm6qirw== Received: from BN9PR03CA0709.namprd03.prod.outlook.com (2603:10b6:408:ef::24) by DM4PR12MB6326.namprd12.prod.outlook.com (2603:10b6:8:a3::15) 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:53 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ef:cafe::24) by BN9PR03CA0709.outlook.office365.com (2603:10b6:408:ef::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.21 via Frontend Transport; Tue, 20 Dec 2022 07:44:53 +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 BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) 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.67) 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:39 -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:38 -0800 From: Leo Xu To: CC: Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH v2 3/3] net/mlx5/hws: add ICMPv6 ID and sequence match support Date: Tue, 20 Dec 2022 09:44:03 +0200 Message-ID: <20221220074403.1015411-4-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: BN8NAM11FT032:EE_|DM4PR12MB6326:EE_ X-MS-Office365-Filtering-Correlation-Id: d8be27aa-519b-499d-7c4b-08dae25e14d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OfTpmOo9KPTEbLgPKBdduGtcfYqsHyizHsqUENEnNNtNk3JWT3BrCi4AuUekQtnpUbhyImnnkJXJln3yUz5yWlrObHM7FyCmBhNpk7UkSGDRR5bj3MGrcKOcIb34tRAjvp9bQ7ZZz/Kor7s/mi6LBb84yCA0s62QdeF4mFwZO0ppO2GRH/fP1iemoJz9TvQt1et2LYMu2eGEIglUg88fO7qQnVKI/ZNP7lmPhNGAvPcAZ+EPuWJ7pb2MraE3bpLPqRd6U8IhjviFwbptehFEESUEvbdqxrn+57h8TS/O0v+UOWv8o72VG/mf5hyxRJriyn9cwL7zRxiTF7RwT3MkN0WxsodAyHyLj3ZATjrV/iWWlX3a2y0PngYzc64uOudS3lyBbaYYFZ+EUNs10L0XPeZ80JgLkhlR8jHh3ob03ECV8O3QItjSygbCqhwy9PsmnQXK31CABX9wVZ2m0c49ATfZpm27ofs5iegwb3shEzeCUdD87ocWiJIqYXUMdfYRg4qiYjI6Vhi0dZzoM2/cBr3g1ommlCWcEIiM+E5YpbbU/52FxYwiS1CHU3oiCLGuQFMqNmCwCMYOB5NhBcRR+VTo061wa1CstK+518SnXLAVneG/CIk0Q9x3dwme4zhuHATYh4mHVU3/s8aAGFhxy7faiFgX/LEBQMfHBvmADBhadRRLHAQT/mQ1txMN4BC1OxYcWm96RRD7HQ3GbLf0HQ== 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)(39860400002)(136003)(396003)(346002)(376002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(6666004)(107886003)(7696005)(86362001)(186003)(40480700001)(316002)(2616005)(6286002)(16526019)(70206006)(6916009)(55016003)(26005)(54906003)(70586007)(2906002)(336012)(36756003)(83380400001)(41300700001)(82310400005)(4326008)(1076003)(8676002)(356005)(7636003)(82740400003)(40460700003)(36860700001)(47076005)(8936002)(426003)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2022 07:44:52.8588 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8be27aa-519b-499d-7c4b-08dae25e14d4 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: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6326 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 for HWS. 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 This patch also fixes these issues in ICMP definer. 1. Parsing inner ICMP item gets and overwrites the outer IP_PROTOCOL function, which will remove the outer L4 match incorrectly. Fix this by getting correct inner function. 2. Member order of mlx5_ifc_header_icmp_bits doesn't follow ICMP format. Reorder them to make it more consistent. Signed-off-by: Leo Xu --- drivers/net/mlx5/hws/mlx5dr_definer.c | 88 +++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index 6b98eb8c96..8fbc40ff15 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -368,6 +368,47 @@ mlx5dr_definer_icmp6_dw1_set(struct mlx5dr_definer_fc *fc, DR_SET(tag, icmp_dw1, fc->byte_off, fc->bit_off, fc->bit_mask); } +static void +mlx5dr_definer_icmp6_echo_dw1_mask_set(struct mlx5dr_definer_fc *fc, + __rte_unused const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6 spec = {0xFF, 0xFF, 0x0}; + mlx5dr_definer_icmp6_dw1_set(fc, &spec, tag); +} + +static void +mlx5dr_definer_icmp6_echo_request_dw1_set(struct mlx5dr_definer_fc *fc, + __rte_unused const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6 spec = {RTE_ICMP6_ECHO_REQUEST, 0, 0}; + mlx5dr_definer_icmp6_dw1_set(fc, &spec, tag); +} + +static void +mlx5dr_definer_icmp6_echo_reply_dw1_set(struct mlx5dr_definer_fc *fc, + __rte_unused const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6 spec = {RTE_ICMP6_ECHO_REPLY, 0, 0}; + mlx5dr_definer_icmp6_dw1_set(fc, &spec, tag); +} + +static void +mlx5dr_definer_icmp6_echo_dw2_set(struct mlx5dr_definer_fc *fc, + const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6_echo *v = item_spec; + rte_be32_t dw2; + + dw2 = (rte_be_to_cpu_16(v->echo.identifier) << __mlx5_dw_bit_off(header_icmp, ident)) | + (rte_be_to_cpu_16(v->echo.sequence) << __mlx5_dw_bit_off(header_icmp, seq_nb)); + + DR_SET(tag, dw2, fc->byte_off, fc->bit_off, fc->bit_mask); +} + static void mlx5dr_definer_ipv6_flow_label_set(struct mlx5dr_definer_fc *fc, const void *item_spec, @@ -1441,6 +1482,48 @@ mlx5dr_definer_conv_item_icmp6(struct mlx5dr_definer_conv_data *cd, return 0; } +static int +mlx5dr_definer_conv_item_icmp6_echo(struct mlx5dr_definer_conv_data *cd, + struct rte_flow_item *item, + int item_idx) +{ + const struct rte_flow_item_icmp6_echo *m = item->mask; + struct mlx5dr_definer_fc *fc; + bool inner = cd->tunnel; + + if (!cd->relaxed) { + /* Overwrite match on L4 type ICMP6 */ + fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, inner)]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_icmp_protocol_set; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + DR_CALC_SET(fc, eth_l2, l4_type, inner); + + /* Set fixed type and code for icmp6 echo request/reply */ + fc = &cd->fc[MLX5DR_DEFINER_FNAME_ICMP_DW1]; + fc->item_idx = item_idx; + fc->tag_mask_set = &mlx5dr_definer_icmp6_echo_dw1_mask_set; + if (item->type == RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST) + fc->tag_set = &mlx5dr_definer_icmp6_echo_request_dw1_set; + else /* RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY */ + fc->tag_set = &mlx5dr_definer_icmp6_echo_reply_dw1_set; + DR_CALC_SET_HDR(fc, tcp_icmp, icmp_dw1); + } + + if (!m) + return 0; + + /* Set identifier & sequence into icmp_dw2 */ + if (m->echo.identifier || m->echo.sequence) { + fc = &cd->fc[MLX5DR_DEFINER_FNAME_ICMP_DW2]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_icmp6_echo_dw2_set; + DR_CALC_SET_HDR(fc, tcp_icmp, icmp_dw2); + } + + return 0; +} + static int mlx5dr_definer_conv_item_meter_color(struct mlx5dr_definer_conv_data *cd, struct rte_flow_item *item, @@ -1577,6 +1660,11 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret = mlx5dr_definer_conv_item_icmp6(&cd, items, i); item_flags |= MLX5_FLOW_LAYER_ICMP6; break; + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: + ret = mlx5dr_definer_conv_item_icmp6_echo(&cd, items, i); + item_flags |= MLX5_FLOW_LAYER_ICMP6; + break; case RTE_FLOW_ITEM_TYPE_METER_COLOR: ret = mlx5dr_definer_conv_item_meter_color(&cd, items, i); item_flags |= MLX5_FLOW_ITEM_METER_COLOR; -- 2.27.0