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 E0C054296B; Mon, 17 Apr 2023 11:26:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A91BF42D31; Mon, 17 Apr 2023 11:26:25 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2040.outbound.protection.outlook.com [40.107.244.40]) by mails.dpdk.org (Postfix) with ESMTP id 2E1FE42D17 for ; Mon, 17 Apr 2023 11:26:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MCZwYd8Oi8SBd97DTUpBqNt2tomdz8oZxl9/8CJLjnacnFST39DLj1Hohin41ej172YHwVADqZMnggQL/jTA/JOA9Un9/rlv+P/0yQUFSgKmF02BFwqvijo+3ZAYDAigNEKkm6DkfVPPf+6lnVZqcP4Y4yAogYQbkrG63qmV0YN8AmWW93lGyCWC1UdWOLX82hTPtU/a5CxnjEk6+sD3VAQslGiQegDRSUZpmnf/ckJhvXqOcnvpGBWm6xDjhptBrEHAWjP4+Q3wJpDAUVuBkrnpjyvBp8HMGLSMpCfGO8rIrCI6oTRL8cF3s0x9Y05gdYzDoqbze4oHzq/gr1DHpA== 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=KQoDK4GyQm64RO8cLI/ZAEbsmWAdC+fNkZeYtpnc3UU=; b=ZcEJq3CrbVremTZGPLGDBl0s3owE5Fvj6PH5qP8icSTQvFZt/yuAF3TT+Si9GyUrc4yol3jS61UgmOUOXypBuoTg0XHOljXIQpCygizDnTtdWbyA1Guy9qaJPOZ0+WF3RV+CAhGZBxz8TfixGQ+kO+tZaCwMtZ8j0cbYrVWz5qgcPUNF4QnsQJoLi8B6t/MphusZqgOmMOUL+7kr0YUH4ZEsMVcvYkIhuTIVl0ttrz+t8Corz0ZLpLBMPrJvLOLV0ZkU+uISyBMVI4Bt68pHqX//laHYeB7c+5Ljt1J7RTEeYLFrPeeee8apMs9BXO7Idx2hmyZUZw8W5IzGJ+6IRg== 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=KQoDK4GyQm64RO8cLI/ZAEbsmWAdC+fNkZeYtpnc3UU=; b=mAE0s7eB9fy73BS+wb736n1N88sYOUZ4+V7cHpH5Mvzz26TXNR8Hksr5RoLt3nBJ55b4XVnx1BktlvH6P/CgFaelrE1XXPCL243FofI0ERmYHXEx2u9PVKFNoY6fvaHNYcKSH2qKi/2vDmvGhaHOP3xJmnup5HqyD1Xc9Z4i0NyfGUdThnjkK4yQOIeC1NviDNarRK/+WtH15PaAdhvY0FD8aZig4DtzVOowUfN706sAUYhT2Eo2/TfnL64HGHHLFsfAppb38yWRrE1FSfkkaQytdQa90WobMb/LlFm5LwLug7GKlaVf/pZIvoujBMG4AuHll4cajH/qavk5GYaH2Q== Received: from MW4PR03CA0311.namprd03.prod.outlook.com (2603:10b6:303:dd::16) by PH0PR12MB5647.namprd12.prod.outlook.com (2603:10b6:510:144::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Mon, 17 Apr 2023 09:26:20 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::18) by MW4PR03CA0311.outlook.office365.com (2603:10b6:303:dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Mon, 17 Apr 2023 09:26:19 +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 CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.19 via Frontend Transport; Mon, 17 Apr 2023 09:26:19 +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.5; Mon, 17 Apr 2023 02:26:04 -0700 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.37; Mon, 17 Apr 2023 02:26:02 -0700 From: Rongwei Liu To: , , , , Subject: [PATCH v1 4/8] net/mlx5: sample the srv6 last segment Date: Mon, 17 Apr 2023 12:25:36 +0300 Message-ID: <20230417092540.2617450-5-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230417092540.2617450-1-rongweil@nvidia.com> References: <20230417092540.2617450-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: CO1NAM11FT053:EE_|PH0PR12MB5647:EE_ X-MS-Office365-Filtering-Correlation-Id: e94013e3-fbc0-4bef-c529-08db3f25cd6d 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: H1j6RfX8Ue1W1CxAZTZz5BDozfWyF8G7N2Wcewk3CB5Sc82ioVkXNmxagN5ydwHtNMfFNV5rBlkOAhFtxveV01ljxqxk4MRKhIw3yGEE898LgyyHW0QusLZzhdiEZ0AVn7cmzXqxGSCCIH314Y3m5F8OGf0cq6V4OYhzFyK/PWF0UGthE1lq36nVLrFRydeeMgpbT9S9uUlWzC6hNfovTKpvWbeYwrKW4+l6caz/QEdI3HGBAy65bBSaK5ujUujzTbezSeYyj5SCsN8o73LAm9qwmn8/4a07yatSPw6Ec1lJZn/xR4fxlWHPU/oPD1+DNPZc60/+qRHjsVLHPfT339BTxjjJM7uJOKAVMGiQQcxT8pgejJbp4B39DhxgJFUjQrvC9jbiK/uMNdBk3XaYMLkkebTcQ9ay6PddgEtNfy2f+qOGSeW79bEPGx9FWtgLJpi07SKr5EgjyF7ePWfjk+1Agaj+AIJ2XOFtz5xJ8y2x59yKX/TktSK98sdTdHPJ6vDQU9GYMpcpWOxGXFYJCP4mPWMgkhMZoYFtfjDnUqKRBw8ZXTORGJ7z2VUg/isRLMBuoOFMVU1X5ZLg+bmVfnHPrVB3egcCTUoqYzW3aI1IIeW+HXvHh2LQNM/44KSyCfVVsL1fJks2AGLQcyQmRToMfFclEjnO3M71WgOlux8c5QZQzD0evGiLYcNlhcjQXY1FADkecf3w0UF4zuSNuvwjf7pK71ZhYJcr2R1RYYjr/XJWR2gGDRYUNbO4r9qX9TNUTSRn2+z0mlFAGCcEhX24l8DXqlGHMjxSnHP0Wsc= 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:(13230028)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(8676002)(36860700001)(426003)(47076005)(83380400001)(336012)(34020700004)(1076003)(110136005)(2616005)(7696005)(16526019)(478600001)(6286002)(6666004)(26005)(186003)(82740400003)(36756003)(5660300002)(82310400005)(316002)(7636003)(70586007)(70206006)(356005)(41300700001)(55016003)(8936002)(86362001)(2906002)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 09:26:19.4514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e94013e3-fbc0-4bef-c529-08db3f25cd6d 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: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5647 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 --- drivers/net/mlx5/mlx5.c | 42 +++++++++++++++++++++++++----------- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 15 +++++++++++++ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f24e20a2ef..1418ffdea7 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1054,7 +1054,7 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev) struct mlx5_devx_graph_node_attr node = { .modify_field_select = 0, }; - uint32_t ids[MLX5_GRAPH_NODE_SAMPLE_NUM]; + uint32_t i, ids[MLX5_GRAPH_NODE_SAMPLE_NUM]; struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_common_dev_config *config = &priv->sh->cdev->config; void *fp = NULL, *ibv_ctx = priv->sh->cdev->ctx; @@ -1084,10 +1084,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 <= 4 && 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; @@ -1100,8 +1108,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 = 5; + priv->sh->srh_flex_parser.flex.devx_fp->num_samples = 5; 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); @@ -1109,12 +1117,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 <= 4 && 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 <= 4 && 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 9eae692037..3fbec4db9e 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1323,6 +1323,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. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 1d116ea0f6..821c6ca281 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2666,4 +2666,19 @@ flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused) #endif return UINT32_MAX; } + +static __rte_always_inline void * +flow_hw_get_dev_from_ctx(void *dr_ctx) +{ + uint16_t port; + struct mlx5_priv *priv; + + MLX5_ETH_FOREACH_DEV(port, NULL) { + priv = rte_eth_devices[port].data->dev_private; + if (priv->dr_ctx == dr_ctx) + return &rte_eth_devices[port]; + } + return NULL; +} + #endif /* RTE_PMD_MLX5_FLOW_H_ */ -- 2.27.0