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 62051A04A6; Thu, 27 Jan 2022 16:41:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B914428AC; Thu, 27 Jan 2022 16:40:20 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2041.outbound.protection.outlook.com [40.107.237.41]) by mails.dpdk.org (Postfix) with ESMTP id 1313542854 for ; Thu, 27 Jan 2022 16:40:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=blyrV5EBKXhxu6Ucfg6JaKrWh3Z1hLKJaXZSfguTjnUVuqJmRAelgitcH2Say53Rqfo6pJrKc6/bJ3B4rUVZDcr9kuMH6D6ALm/BjAqoUGfAfpmrHyXXaZ17f8EYPHJIYsfkHu5InGYj62LJjPhWy3BpR9jtVyXLzGKJcmylqhKbidhVzP4ZI2UuTkPaR8+p50Jt9ExSjThu5kRKz/TgzZWBhvBvVwmplwpFqJPKxNAeNfuvAR8nzO/TfjkEuX+LVYUSWTIOInmfCF75fA2NHLcoqCNhUbX8szRjP7RzqQoCuyQEa0BQ0NnqqE+sAO2PmvUgMma4Ibv3hXR6HJaJbw== 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=eo6GQZwKV3hE8EWyLFfL/ll9Mq5VjvPbKS2GlESi9Jk=; b=YZnZIzAfno9GZpapVaN6SBy/illdOlCiaLfh9WovFLtOw+PUMMJpSIzGEIlEOey5x40IrDA1VOKW59onDTG0qsGGGP95xVEhQXBNjMwMRxeNXXAIvkZXSG8VaLxuke/9nuiWQutpLW4VLuIjGdqVYZRbQ/mwFtbVSlRh/HFMWXjWzMT+E13XxVBOyS26CDdn/F8YgGUbTfTLWrOJe9DgO80mGqMIG7iOfCNJY59phHWycKmvS6RyPGNPEZqmH8HNnfmEnozkR1Yy2DOU++lOjpYqgxUfKTwaHcyHRGovmhuqn6nyaC0HpXYIW1YB5O8h+LBOuCvVZS5cvi6+cZJH1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=eo6GQZwKV3hE8EWyLFfL/ll9Mq5VjvPbKS2GlESi9Jk=; b=cmO7L0C1tJG0N5Wo+Le818P+OzuWsV3Ec9Rz9VBevZWZUzThi45i2YsuhkKDIr0tcKBHIHau8D/eXo/hIVMgNAnaYbnhlhHMwaQjCIW8Bs5Mz+rdiL2q5gSs9XUbF3gD3nwq+QuiVBiGhO7ykRD0aOWoakQC9qa2w8eKbWdkrE/SpxoSMkFMMj88v9z6NzIx5iZtS4ymDKjgocU0CAHqRD8RpC6w885Zfpb5gcabOOFnpoAVtUsEaXcdmJdLnr6968F9MPEV24zk/i5g0HHgvfrYr7VmNRdoA5QIsaL/rw4nbzj+uNMVPbApoQMF/XdcSM7XyRMA2tbmKq2id4vxAA== Received: from BN1PR13CA0022.namprd13.prod.outlook.com (2603:10b6:408:e2::27) by BYAPR12MB4616.namprd12.prod.outlook.com (2603:10b6:a03:a2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17; Thu, 27 Jan 2022 15:40:14 +0000 Received: from BN8NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::71) by BN1PR13CA0022.outlook.office365.com (2603:10b6:408:e2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.5 via Frontend Transport; Thu, 27 Jan 2022 15:40:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT059.mail.protection.outlook.com (10.13.177.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 15:40:14 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 27 Jan 2022 15:40:13 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 27 Jan 2022 07:40:13 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Thu, 27 Jan 2022 07:40:11 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH 09/20] net/mlx5: remove Verbs query device duplication Date: Thu, 27 Jan 2022 17:39:39 +0200 Message-ID: <20220127153950.812953-10-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127153950.812953-1-michaelba@nvidia.com> References: <20220127153950.812953-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a15ea657-1514-4e9d-c20c-08d9e1ab4fb8 X-MS-TrafficTypeDiagnostic: BYAPR12MB4616:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: So7rzEs29qOWpppA3/AEbN+q0zr9AZzAel3WmbS9uRT5sH/g+9WJ0bo45QEfFiKYqlDdFG5GhDWSHVOHX8OYLoaqt2FBEtT7nfognv15++ofJj100h1plbufjWGcO4nmLw3/xrS861ocuRQwsjNr2+cpW51ZWxAXJ/2/GvTci/zXqNX/Q7bYg3UTjfWIdHNksDD5JA2ai+HI86R/sO6SNV+6k+jVUYpbOBBUQz1W06ztuRm3MjAjt2przcoWJ5h7l/Kk5WirN2wcLcjfqIsxo//AbGSPr5HYvFIV12tx1FcZgn5Xw22AWWJpjo4xNe3Ku0RyWtdNQg8Bxkv6XVniC5oz+NV/PMiFYxsNVxRbUFMnuUrsiqlJU7CgWCpbwi8qQNHaG/oZT1PJG14pM0yP8IHceOegtHECTWAvehB4KRF6SneljILt4jAppBbwIBrSjBYSwipXSd00892ZdNSIc5OWh/l85iYF5NKvJ/xRzEtKYrmVUdfftnR0tvv07FK3jPiYzEUXM/tMPV2b01zc9FsQuBM9m+Im+oFX7UfQVHTVYoFSxR6qIb0xXw6AFfmeJ3LuNgXYu9RFRIDKUE5+Cc2zHb8stQ7uIF2+EkpPvjMPyXmm5X7lUComCVf8GZze/oMaNhw5AvsnhzbOPT9berZD44/TAYt/H9iQuo9lvZB2jRD2UNO/Y7sj7Tx/qRsJ8u5tHUQDRnqNrt1jMo7obo1kil+p6tAfF1g2nNXsWGQDH+ezlwr9TRROlvg/K/fjhFzaZBR2GItz571dOrqqFu6MwLzuep1bFAChhEqmxhQ= X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700004)(4326008)(186003)(70206006)(8936002)(107886003)(54906003)(6916009)(81166007)(1076003)(2616005)(336012)(2906002)(55016003)(82310400004)(356005)(5660300002)(7696005)(6666004)(47076005)(36756003)(70586007)(26005)(6286002)(8676002)(426003)(508600001)(40460700003)(83380400001)(316002)(36860700001)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 15:40:14.1082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a15ea657-1514-4e9d-c20c-08d9e1ab4fb8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4616 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 The sharing device context structure has a field named "device_attr" which s filled by mlx5_os_get_dev_attr() function. The spawn function calls mlx5_os_get_dev_attr() again and save it to local variable identical to "device_attr" field. There is no need for this duplication, because there is a reference to the sharing device context structure from spawn function. This patch removes the local "device_attr" from spawn function, and uses the context's field instead. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 63 ++++++++++++++---------------- drivers/net/mlx5/windows/mlx5_os.c | 6 +-- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index b579be25cb..e8e842a09e 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -171,6 +171,15 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, device_attr->tso_supported_qpts = attr_ex.tso_caps.supported_qpts; struct mlx5dv_context dv_attr = { .comp_mask = 0 }; +#ifdef HAVE_IBV_MLX5_MOD_SWP + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP; +#endif +#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS; +#endif +#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ; +#endif err = mlx5_glue->dv_query_device(ctx, &dv_attr); if (err) { rte_errno = errno; @@ -183,6 +192,7 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, device_attr->sw_parsing_offloads = dv_attr.sw_parsing_caps.sw_parsing_offloads; #endif +#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT device_attr->min_single_stride_log_num_of_bytes = dv_attr.striding_rq_caps.min_single_stride_log_num_of_bytes; device_attr->max_single_stride_log_num_of_bytes = @@ -193,6 +203,7 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, dv_attr.striding_rq_caps.max_single_wqe_log_num_of_strides; device_attr->stride_supported_qpts = dv_attr.striding_rq_caps.supported_qpts; +#endif #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT device_attr->tunnel_offloads_caps = dv_attr.tunnel_offloads_caps; #endif @@ -878,7 +889,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, struct mlx5_dev_ctx_shared *sh = NULL; struct mlx5_hca_attr *hca_attr = &spawn->cdev->config.hca_attr; struct ibv_port_attr port_attr = { .state = IBV_PORT_NOP }; - struct mlx5dv_context dv_attr = { .comp_mask = 0 }; struct rte_eth_dev *eth_dev = NULL; struct mlx5_priv *priv = NULL; int err = 0; @@ -1011,23 +1021,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR config->dest_tir = 1; -#endif -#ifdef HAVE_IBV_MLX5_MOD_SWP - dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP; #endif /* * Multi-packet send is supported by ConnectX-4 Lx PF as well * as all ConnectX-5 devices. */ -#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT - dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS; -#endif -#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT - dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ; -#endif - mlx5_glue->dv_query_device(sh->cdev->ctx, &dv_attr); - if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) { - if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) { + if (sh->device_attr.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) { + if (sh->device_attr.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) { DRV_LOG(DEBUG, "enhanced MPW is supported"); mps = MLX5_MPW_ENHANCED; } else { @@ -1039,44 +1039,41 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mps = MLX5_MPW_DISABLED; } #ifdef HAVE_IBV_MLX5_MOD_SWP - if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP) - swp = dv_attr.sw_parsing_caps.sw_parsing_offloads; + if (sh->device_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP) + swp = sh->device_attr.sw_parsing_offloads; DRV_LOG(DEBUG, "SWP support: %u", swp); #endif config->swp = swp & (MLX5_SW_PARSING_CAP | MLX5_SW_PARSING_CSUM_CAP | MLX5_SW_PARSING_TSO_CAP); #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT - if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) { - struct mlx5dv_striding_rq_caps mprq_caps = - dv_attr.striding_rq_caps; - + if (sh->device_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) { DRV_LOG(DEBUG, "\tmin_single_stride_log_num_of_bytes: %d", - mprq_caps.min_single_stride_log_num_of_bytes); + sh->device_attr.min_single_stride_log_num_of_bytes); DRV_LOG(DEBUG, "\tmax_single_stride_log_num_of_bytes: %d", - mprq_caps.max_single_stride_log_num_of_bytes); + sh->device_attr.max_single_stride_log_num_of_bytes); DRV_LOG(DEBUG, "\tmin_single_wqe_log_num_of_strides: %d", - mprq_caps.min_single_wqe_log_num_of_strides); + sh->device_attr.min_single_wqe_log_num_of_strides); DRV_LOG(DEBUG, "\tmax_single_wqe_log_num_of_strides: %d", - mprq_caps.max_single_wqe_log_num_of_strides); + sh->device_attr.max_single_wqe_log_num_of_strides); DRV_LOG(DEBUG, "\tsupported_qpts: %d", - mprq_caps.supported_qpts); + sh->device_attr.stride_supported_qpts); DRV_LOG(DEBUG, "\tmin_stride_wqe_log_size: %d", config->mprq.log_min_stride_wqe_size); DRV_LOG(DEBUG, "device supports Multi-Packet RQ"); mprq = 1; config->mprq.log_min_stride_size = - mprq_caps.min_single_stride_log_num_of_bytes; + sh->device_attr.min_single_stride_log_num_of_bytes; config->mprq.log_max_stride_size = - mprq_caps.max_single_stride_log_num_of_bytes; + sh->device_attr.max_single_stride_log_num_of_bytes; config->mprq.log_min_stride_num = - mprq_caps.min_single_wqe_log_num_of_strides; + sh->device_attr.min_single_wqe_log_num_of_strides; config->mprq.log_max_stride_num = - mprq_caps.max_single_wqe_log_num_of_strides; + sh->device_attr.max_single_wqe_log_num_of_strides; } #endif #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT - if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) { - config->tunnel_en = dv_attr.tunnel_offloads_caps & + if (sh->device_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) { + config->tunnel_en = sh->device_attr.tunnel_offloads_caps & (MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_VXLAN | MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GRE | MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GENEVE); @@ -1098,9 +1095,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, "tunnel offloading disabled due to old OFED/rdma-core version"); #endif #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT - mpls_en = ((dv_attr.tunnel_offloads_caps & + mpls_en = ((sh->device_attr.tunnel_offloads_caps & MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_GRE) && - (dv_attr.tunnel_offloads_caps & + (sh->device_attr.tunnel_offloads_caps & MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_UDP)); DRV_LOG(DEBUG, "MPLS over GRE/UDP tunnel offloading is %ssupported", mpls_en ? "" : "not "); @@ -1429,7 +1426,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, #endif } if (config->cqe_comp && RTE_CACHE_LINE_SIZE == 128 && - !(dv_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP)) { + !(sh->device_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP)) { DRV_LOG(WARNING, "Rx CQE 128B compression is not supported"); config->cqe_comp = 0; } diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 5396365ec9..31f0247be7 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -318,7 +318,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, { const struct mlx5_switch_info *switch_info = &spawn->info; struct mlx5_dev_ctx_shared *sh = NULL; - struct mlx5_dev_attr device_attr; struct mlx5_hca_attr *hca_attr; struct rte_eth_dev *eth_dev = NULL; struct mlx5_priv *priv = NULL; @@ -376,13 +375,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; } DRV_LOG(DEBUG, "MPW isn't supported"); - mlx5_os_get_dev_attr(sh->cdev, &device_attr); - config->swp = device_attr.sw_parsing_offloads & + config->swp = sh->device_attr.sw_parsing_offloads & (MLX5_SW_PARSING_CAP | MLX5_SW_PARSING_CSUM_CAP | MLX5_SW_PARSING_TSO_CAP); config->ind_table_max_size = sh->device_attr.max_rwq_indirection_table_size; - config->tunnel_en = device_attr.tunnel_offloads_caps & + config->tunnel_en = sh->device_attr.tunnel_offloads_caps & (MLX5_TUNNELED_OFFLOADS_VXLAN_CAP | MLX5_TUNNELED_OFFLOADS_GRE_CAP | MLX5_TUNNELED_OFFLOADS_GENEVE_CAP); -- 2.25.1