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 F20BE43258; Wed, 1 Nov 2023 05:45:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB80C42D6A; Wed, 1 Nov 2023 05:45:08 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 4D95742C24 for ; Wed, 1 Nov 2023 05:45:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nhKhLb7chKWS6ryp4tv5ToDsvx1tUNQrtDMdlZHmlAuMfTqQhLlnAzHsnktjkrvloxDR90mRVq0lrhExY77vgw9Jf0QeY+jNaWTsZT+PjzD+/c6Nl52/syEdNkl+2JWBtoFCSEhiVUqxBUfPi2AzUUcCvdJvOwvT1nEZLhtpuOE4yAiJ1XHqUddXqQa2OVBXKELf1LdkX2kE/ygRTPi6sVJsIjf9fkSQm15vbKv3UuC0KgQaAeNVNECWvq0DomlaYVMAR4MpE4LCimn4rYz7HkaBWc2SUGdQNKfN2Rx2tcpmHdgdSFx/VEsWZYG97nlbG4JSkM+hmC9CrwzwkhNjuw== 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=Gw17Tl63JE9W6Yle0VipMekrHJxRLo9IRVojVQ0g4zQ=; b=f2oic0OnSZRMg6DLf0JevIvmpStnc8142HASlEz8MI3cguVrAxIwkVbiXNOkMQEZtlf0zR5rzTyidiXloMZqdjQVpDQkWpRy/oHQuu+Q/nxrcLAMw+/f39dsszyklEhcPDxEBJsDRDV9LsGsISl3U8O5pXNBJm5dAJxbOZYoESYBe4ypuDxUkU/PQzdRw8aQJFcNb7+4YCkM9Di6YB5vpTSl2BoNb4p9jNYD8LX9VWL0xg6Hf5T/+iOFp5XYHVqpAxaoJyv6IhhejLZEyTwWprUa52yFYTaJlbNab9d+VCLodHQerEeJa2mUKWOQohNHBv6wwtUt4gm4kPlQucHaQg== 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 (0) 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=Gw17Tl63JE9W6Yle0VipMekrHJxRLo9IRVojVQ0g4zQ=; b=AA44xKanCxMfF0jf5ahwgnLd+aLKMbdN61zfKZJ8+RUFCqAu5ATPGucCA/ntB91gy745Li5hutAsO9mVQYpmCpwi/cTofS9TE6zZOKfgGqxozwPF1olz56SCC5GP/bpmZBmgd5ZDRpUvXRog1yiwuCgab7BFpqUcu7Tvc3d11FHLgvU/Nq+8ejmznKqplxE7k7NVIL0lu8+w3XiyMM5pufCDeyy1ZYSRkAEEMJyPLERGn3bBrKEflFQrz0T13X4gLzAazz87fzI1JoXs21qDgGfcxujkA7BeKjcBXVmgbtm8UkMXWytVm4OvKccQbQJzyJAu8tBjE5GU7CG89+ep8A== Received: from CY5P221CA0040.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:4::11) by SN7PR12MB8818.namprd12.prod.outlook.com (2603:10b6:806:34b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Wed, 1 Nov 2023 04:45:05 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:930:4:cafe::55) by CY5P221CA0040.outlook.office365.com (2603:10b6:930:4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29 via Frontend Transport; Wed, 1 Nov 2023 04:45:05 +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 CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Wed, 1 Nov 2023 04:45:05 +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.41; Tue, 31 Oct 2023 21:44:54 -0700 Received: from nvidia.com (10.126.230.35) 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.41; Tue, 31 Oct 2023 21:44:51 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v4 07/13] net/mlx5: sample the srv6 last segment Date: Wed, 1 Nov 2023 06:44:13 +0200 Message-ID: <20231101044419.732726-8-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231101044419.732726-1-rongweil@nvidia.com> References: <20231031105131.441078-1-rongweil@nvidia.com> <20231101044419.732726-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] 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: CY4PEPF0000FCC1:EE_|SN7PR12MB8818:EE_ X-MS-Office365-Filtering-Correlation-Id: 743c78a0-c2b6-48e3-0f20-08dbda955157 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: nKrfdLpoqzPgjsrzn6UtClZH2eEV0/FeQUxGbxdg+N4BTStyPKnZXo4PEXw7jQXZrQ5RpOJ6Z3Jx79aXOI+9CkOIiO9utaJlS8bO60wxGZEdM6j/+JvrSL73nbkQ6LkJaQo2wKfg+9Hyox12ReNzP1yxIdXsF5DJ/KskWkNh9MQvvRW6LVx5MUh2iCsNcqcMF0agNL4iXOPLydpyVVj+PsOYgp6UwrZEpceB0NGo1cGlH3eqi4lly2uYdsNo2tLdrbAa28jqABskrc3cE1zZL7uPeVppWfEM1zcTkSmZucz81dGIkNXnmgAmyPQvl86J/6HMqN5vsd3o23gtZiQq9N+2d3wQFpsB1mOvaExlLUQkka2NafZ2mOqqJnm+paJgvr9KLuv2yR9Iax6QIIQk3oQa6GzfPHf6wSJOGyxMUGS2LOB2/xdKdmpVowWaW2623e+vK+EYiutu363f9jbd/DlLw7U9qs9bBIvbcjlKyF1GOvtgAA9MOSNlW4sEl2XOYHSX5P5Pn6RNSeaa4Mw1gCvRZJNeurp08jTjL3kHJ65xpe3aIrsaZVayqNU0CNFu7+SaEFdW2ffXxQhzpaRKy2IppmU6ZdhRCKH1IRw5qdpBf5Nnf8XMjvcGbh+xdGLanFGaHx+dY1aNTrSkCnf1IJ2ZTA4g1KYyJTofvwEeSk0ZlPaoUTUlMtF8F8qEOq+hD3BVEMeaV9nrbals7RS0/pmY9XhIe0NQoLPa1y9tXdlG77EJiL3QcELR8pILpURC 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:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(1800799009)(82310400011)(186009)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(47076005)(316002)(2616005)(86362001)(40460700003)(1076003)(2906002)(426003)(336012)(83380400001)(26005)(55016003)(70586007)(16526019)(70206006)(7636003)(356005)(6286002)(7696005)(478600001)(41300700001)(36756003)(6666004)(8676002)(8936002)(110136005)(40480700001)(82740400003)(36860700001)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 04:45:05.1136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 743c78a0-c2b6-48e3-0f20-08dbda955157 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: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8818 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 When removing the IPv6 routing extension header from the packets, the destination address should be updated to the last one in the segment list. Enlarge the hardware sample scope to cover the last segment. Signed-off-by: Rongwei Liu Acked-by: Ori Kam Acked-by: Suanming Mou --- drivers/net/mlx5/mlx5.c | 41 ++++++++++++++++++++++++++++++----------- drivers/net/mlx5/mlx5.h | 6 ++++++ 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index c275cdfee8..e3e36098c2 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1070,6 +1070,7 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev) struct mlx5_devx_graph_node_attr node = { .modify_field_select = 0, }; + uint32_t i; uint32_t ids[MLX5_GRAPH_NODE_SAMPLE_NUM]; struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_common_dev_config *config = &priv->sh->cdev->config; @@ -1103,10 +1104,18 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev) node.next_header_field_size = 0x8; node.in[0].arc_parse_graph_node = MLX5_GRAPH_ARC_NODE_IP; node.in[0].compare_condition_value = IPPROTO_ROUTING; - node.sample[0].flow_match_sample_en = 1; - /* First come first serve no matter inner or outer. */ - node.sample[0].flow_match_sample_tunnel_mode = MLX5_GRAPH_SAMPLE_TUNNEL_FIRST; - node.sample[0].flow_match_sample_offset_mode = MLX5_GRAPH_SAMPLE_OFFSET_FIXED; + /* Final IPv6 address. */ + for (i = 0; i <= MLX5_SRV6_SAMPLE_NUM - 1 && i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) { + node.sample[i].flow_match_sample_en = 1; + node.sample[i].flow_match_sample_offset_mode = + MLX5_GRAPH_SAMPLE_OFFSET_FIXED; + /* First come first serve no matter inner or outer. */ + node.sample[i].flow_match_sample_tunnel_mode = + MLX5_GRAPH_SAMPLE_TUNNEL_FIRST; + node.sample[i].flow_match_sample_field_base_offset = + (i + 1) * sizeof(uint32_t); /* in bytes */ + } + node.sample[0].flow_match_sample_field_base_offset = 0; node.out[0].arc_parse_graph_node = MLX5_GRAPH_ARC_NODE_TCP; node.out[0].compare_condition_value = IPPROTO_TCP; node.out[1].arc_parse_graph_node = MLX5_GRAPH_ARC_NODE_UDP; @@ -1119,8 +1128,8 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev) goto error; } priv->sh->srh_flex_parser.flex.devx_fp->devx_obj = fp; - priv->sh->srh_flex_parser.flex.mapnum = 1; - priv->sh->srh_flex_parser.flex.devx_fp->num_samples = 1; + priv->sh->srh_flex_parser.flex.mapnum = MLX5_SRV6_SAMPLE_NUM; + priv->sh->srh_flex_parser.flex.devx_fp->num_samples = MLX5_SRV6_SAMPLE_NUM; ret = mlx5_devx_cmd_query_parse_samples(fp, ids, priv->sh->srh_flex_parser.flex.mapnum, &priv->sh->srh_flex_parser.flex.devx_fp->anchor_id); @@ -1128,12 +1137,22 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev) DRV_LOG(ERR, "Failed to query sample IDs."); goto error; } - ret = mlx5_devx_cmd_match_sample_info_query(ibv_ctx, ids[0], - &priv->sh->srh_flex_parser.flex.devx_fp->sample_info[0]); - if (ret) { - DRV_LOG(ERR, "Failed to query sample id information."); - goto error; + for (i = 0; i <= MLX5_SRV6_SAMPLE_NUM - 1 && i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) { + ret = mlx5_devx_cmd_match_sample_info_query(ibv_ctx, ids[i], + &priv->sh->srh_flex_parser.flex.devx_fp->sample_info[i]); + if (ret) { + DRV_LOG(ERR, "Failed to query sample id %u information.", ids[i]); + goto error; + } + } + for (i = 0; i <= MLX5_SRV6_SAMPLE_NUM - 1 && i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) { + priv->sh->srh_flex_parser.flex.devx_fp->sample_ids[i] = ids[i]; + priv->sh->srh_flex_parser.flex.map[i].width = sizeof(uint32_t) * CHAR_BIT; + priv->sh->srh_flex_parser.flex.map[i].reg_id = i; + priv->sh->srh_flex_parser.flex.map[i].shift = + (i + 1) * sizeof(uint32_t) * CHAR_BIT; } + priv->sh->srh_flex_parser.flex.map[0].shift = 0; return 0; error: if (fp) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 8f82aff0a5..635dd73674 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1356,6 +1356,7 @@ struct mlx5_flex_pattern_field { uint16_t shift:5; uint16_t reg_id:5; }; + #define MLX5_INVALID_SAMPLE_REG_ID 0x1F /* Port flex item context. */ @@ -1367,6 +1368,11 @@ struct mlx5_flex_item { struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM]; }; +/* + * Sample an IPv6 address and the first dword of SRv6 header. + * Then it is 16 + 4 = 20 bytes which is 5 dwords. + */ +#define MLX5_SRV6_SAMPLE_NUM 5 /* Mlx5 internal flex parser profile structure. */ struct mlx5_internal_flex_parser_profile { uint32_t refcnt; -- 2.27.0