From patchwork Tue Oct 31 09:42:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rongwei Liu X-Patchwork-Id: 133639 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AEA2243251; Tue, 31 Oct 2023 10:43:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A303402E6; Tue, 31 Oct 2023 10:43:18 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id 48342402D4 for ; Tue, 31 Oct 2023 10:43:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PUh6D48JXMzdUaMZXwxeeaRaOblnkpjtUk8bS2ItH8sXNzlikrbxq1yALcc+0jUdX9n0AIi2W5HPuTZL3S8GkkIHbuL4WKz5MlgDhp0CXQ1tWX1pl/FXL/6diGXiR+11LgLiZSnw6bkUKLBRdICVMRcir0xVf9uUcTt9vTZu1dHITNWdhYM5api+cKqXWvzVjg9423RHNK7LieH4AKB5orADhypGbCZZtSTL2aM4mKy4sL9vy2JtN0QYRkMJf19ERvGs/soSPu2WCjqMyQdtjIapu9p/0r6dpCNNZoLSWW5Fhsate65AaJiC1nya6/fC1Nbf4iG9yrUoTzVIwYzoMg== 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=YimV24x4sTgeMpzEouBqon6r0PC68ZuMyg/tQxo6JCg=; b=J/20aA2beEYowPkkshkWsjh9vCbLkMnqKaejba5WZHaGqMS7JZiEeLapUavbN8wR6xoV3siCaTwlcCuDj9NfilxifvYhhjQmZ4XXMGNPGzWYZ2+Nzj3Qe5rwT296EXHVr5M4aX93ypsYj7X69Lz8Hpk9UFuSXa6ijyVDwYsWRcij+aVfLLxGLInthNwqwMD/DLj4VOepOBrjtcSeevrM7wiyCel3Ere2TiNXjOrHn+nMTOBwWGcYFYVZSyM55yZMSWFJmnQPu0JYoWCII6wOpCvkn1fcwX7OSAqF+X5s+wOHp5BSFE8rtWyZxrgNxgRjJ4Oa716mc54AZQlzRdQT6A== 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=YimV24x4sTgeMpzEouBqon6r0PC68ZuMyg/tQxo6JCg=; b=IwOkOE3rw9joH/VkGdxjIzm8XW8rJjZUyI06BicSwRB36rOZ1+I8wUANor2Z5STIjsepSHusNg+56PztSYS3YablIBeBEx3ILYV5ASahVPg6je6CmhbvWjQf8eFpTB1A4EJjkL4QPvp6U8tNtBjytg1NgYrD9ag3Se499hh6rqzhxV4OOS6WDw1jyhQ3Vyd58ltbh5UF1ptp6Qx1rOt4u5daj/z9A+iZLlqaPjDsm2Lm74YMbbCHXe4aCbnRijuFIOPqCnZenuWVCqWKLXgMQJnYvAhJVaUBrRtn+CtCJHU6F6VROL28Je/1ppaOWSKHWWXhRDi3NZmu+m60PAEYbw== Received: from CH2PR08CA0030.namprd08.prod.outlook.com (2603:10b6:610:5a::40) by BL0PR12MB4897.namprd12.prod.outlook.com (2603:10b6:208:17e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29; Tue, 31 Oct 2023 09:43:15 +0000 Received: from DS2PEPF00003444.namprd04.prod.outlook.com (2603:10b6:610:5a:cafe::1f) by CH2PR08CA0030.outlook.office365.com (2603:10b6:610:5a::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29 via Frontend Transport; Tue, 31 Oct 2023 09:43:15 +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 DS2PEPF00003444.mail.protection.outlook.com (10.167.17.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Tue, 31 Oct 2023 09:43:14 +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 02:43:01 -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 02:42:59 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v2 1/6] net/mlx5: sample the srv6 last segment Date: Tue, 31 Oct 2023 11:42:39 +0200 Message-ID: <20231031094244.381557-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231031094244.381557-1-rongweil@nvidia.com> References: <20230417092540.2617450-5-rongweil@nvidia.com> <20231031094244.381557-1-rongweil@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003444:EE_|BL0PR12MB4897:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fa9c3bf-9c99-4355-0059-08dbd9f5ce14 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: R7euKRSYVJhkyLatwwZ5SzufpY5Poz2kEzl+5rb46trMcwWijFkLMkTTnVFKnFga1rIU4IBuZ9dTLX5870GTp4HpY/MpsBt6ly7Yu12F6ITWwTVxg4/zkgG9+huGRi5pUTPGAzAFTWTFc1MfZpMuWWLCIEiZDznu3V51PPbr1qV3uFZLibBNIpt8m+jsvOZ7dIA2/yTBfuwIomY4/QG+vZe46+TVLz/aWb8r/6Uw6YIXbSAxpMmfe+hesNT6io9R4L93TqMYkZjLCJvEc+kc9040h2HhWyIDDHYenpTlFZZofY7v6XsPrL8ErjWNEPe91Il01ee/n2eKYImS3wyyBy6rq4NgTAoX9LRXXJcRgAfoagA2vc3r1Wadd/uiY6L46Q4hn/d9oKzdPvq6FcdjmFiLKgx2dXOmU2FeTvU8LZLu5XISDSJR//pMp73v347CPamsyydZXWdTZ9KG6dpn5ikl2e13feZnWacivp3MNC/bfPCmHrXGI5acoA43kY4Pk+lIGOh003UawQXuzYS80DXDNyPvK2PVebLkrvlzRK26v1zO6W8MlPE7Y6dkpugW5QT4i9MI+92tEKAtaOkyGXZ7HeCeFNmfovCDDt+COHxlkVJBpyzSZHP22STmPNw0sUF8Q7VBMhgW11MzwWSIqNthd6sLIiwKNGhhRraNWXbQfHkx78MD+JauM12BjrurfZB4TUXg4pKLjuruJW+qOWNXiMpb1ubu7GWeBzVUOWGD3rOJdhqN3TLjYFIBMsoQ 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)(346002)(396003)(376002)(136003)(230922051799003)(451199024)(1800799009)(82310400011)(64100799003)(186009)(40470700004)(46966006)(36840700001)(55016003)(40460700003)(26005)(1076003)(6286002)(16526019)(478600001)(7696005)(47076005)(6666004)(36860700001)(336012)(426003)(83380400001)(2906002)(41300700001)(70206006)(70586007)(110136005)(5660300002)(2616005)(8676002)(8936002)(316002)(82740400003)(7636003)(356005)(86362001)(40480700001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 09:43:14.9126 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fa9c3bf-9c99-4355-0059-08dbd9f5ce14 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: DS2PEPF00003444.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4897 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 f929d6547c..92d66e8f23 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1067,6 +1067,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; @@ -1100,10 +1101,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; @@ -1116,8 +1125,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); @@ -1125,12 +1134,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 a20acb6ca8..f13a56ee9e 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1335,6 +1335,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. */ @@ -1346,6 +1347,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;