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 09FC8A0C41; Tue, 19 Oct 2021 22:57:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63FC841157; Tue, 19 Oct 2021 22:56:44 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by mails.dpdk.org (Postfix) with ESMTP id DFE704113A for ; Tue, 19 Oct 2021 22:56:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKE/5nCc4FsXMjWN7Si64rgbygA/0DlCIPZ2tlEav/sp6ecXIl3g7vCmZJH1jSRGIa7EKlwFB28+L7/OXxnn0uj6VvIodjUOX2kZT86d6F3b9oybM6TZgZcxveXAz5oP7Wl6Exmw720ktyxkz5xHWtzHlAa0JIRd6cRejJ/axUxbwFoc+icHBDy17AH6KDeB1XmOjbjueFOxAe5RmTOuP0M/N2eXheu4p9FEuTZnXomf0SbJmiuLTtegv3kg+vIOgY2ydzDBo7OorSIQUivWLvIEdkKIXO3rl0RvlA72w0Ta1t5Tp4FapukqY4dcwl5vP0FVd3X7grzuwDrBj9h4BA== 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=lLvARIuu92X2DIlXfxu9QBJPG0RHDR4JARxoimrkXQM=; b=e3p2Iik23Oei/ddUWTl75YdEp9joKEttIE8lEPcJp2MpaGTGa3mJ1fn3ofNNCjAIRYrOtZqBW/gYgjAhf0b9oJ9T69BHRV0bADUgb5H2lLXXrJqjZPXG22tAbwcX32TwWSGNYo0IOGI4HdYQhgLkcnCPQbY82UAiPLB3E7yRZqNNpWeJRC9SN7EcGl4OUUIui595EUN2p0yRtBCbPzCQUWKx3QiW+xiaH/6rPafxmNk88yiTpeBkL6XnHv1He5AbpC8M2ZoShXUb3bygt/XNF2OE9sbrN4JoEzcktpI9UNe7N1oMCZOczbN8IifuAxSVjOZ8DU/scwR6iTgt8ugHcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=lLvARIuu92X2DIlXfxu9QBJPG0RHDR4JARxoimrkXQM=; b=GG29wHeD/Cw4U4jvoFoQLKPQEwu7qI3BN6pSIntxLJGWG+KViuBEOqnBGRzg9UYFGClDEfyEZq5Xk3Moq8McrKl6knmvud9z+cRllEX0cDFyQZgz9Ed6jk7jl7I+Isyka4/bR4Qg1doytzNEo81UIa2GMzfMgaST2peid6lOc5puEb+GEKOKpoEqESbUJFuaSeTY9942xS7Sl/uJtdkvVxF6injZ+XEO+2GLiwJ/c/XYUXBwPm64qESUIl49Pn+KWSj9H4D4wMZ8u4ofXsSZOlYlf/FanbupnIK3Zw1oRJKD4lpGcZzWSY3R4IyGO302YxlK/dtV8GHck0uRFVxEuA== Received: from BN9PR03CA0912.namprd03.prod.outlook.com (2603:10b6:408:107::17) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Tue, 19 Oct 2021 20:56:34 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::21) by BN9PR03CA0912.outlook.office365.com (2603:10b6:408:107::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Tue, 19 Oct 2021 20:56:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 20:56:33 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 19 Oct 2021 20:56:30 +0000 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum Date: Tue, 19 Oct 2021 23:55:49 +0300 Message-ID: <20211019205602.3188203-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019205602.3188203-1-michaelba@nvidia.com> References: <20211006220350.2357487-1-michaelba@nvidia.com> <20211019205602.3188203-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d7d43ad-46c2-4df6-da78-08d99342ef2c X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WUSfZrOnWJU62ZSLJtlEVgPgWA2zM3ArWMxnlebMACmePTRNu5S60nNtMO28bo1L+7GweoTRzShRHuEJiICp+Nfs5gz9KZNDlmj1I/pZmSEqTWHvRpdL0/dA3t7DkyQ27BGUu3Z5TN6VR+f6/QmxZjrwKtDIZLWzkqj22B5aGdm97N01UWgKgzG1CZ9QMsrsqp6+Au6goM1cJHHzpUvwiWDKJvI+v36DpvpiQqqsiOGGjlEQOvVtYB7f2/jq7MJuNRm233u2uoZxIwMlZ1EYWbUBr54uYXJDBbAiZuFutLq0OqKIxGdkkYZ9Cz87NGdFJFUAp8HYkC0+Y0OyJErX7hOWGeNYtvZroNY6mT1LOuC5ayQ9SbYgj6AMYAPjIuW9YWe9+K423uaMqOqybrIwhjEiF24a0TzTwaQa5b7oNp0SFOZ1Xq0V5Wp7PYkkQ0Yd0aJBpfW/rlUCSa22z/fIvIl02eUZqE7zyVDZ2Rwifj96hqkk+cetpIbc5eK1o0tqWs+8vCWMCLI4225ilc4Ism8skLhVv5WAdaFcJqT8nmX4mKYRcpDOCAdpIctn3z1lwypDUA/nl4Vgjwk72gl2QJmkMzsCPJYrVPV+4Jmj+mWTwy6cv2kbiphGT2XeD9JTSOK75sjg0q7yHDo7RkTdu8Ey+fyotRBjJ9szzhDY0E3I0Mn0Nmcbe0YU6z0G+WEK2DQLreKX819TaC6/JEJf1g== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(54906003)(356005)(2616005)(107886003)(508600001)(86362001)(83380400001)(82310400003)(36860700001)(1076003)(47076005)(6666004)(8676002)(26005)(16526019)(8936002)(70206006)(6286002)(426003)(4326008)(186003)(36756003)(2876002)(316002)(336012)(7636003)(7696005)(6916009)(2906002)(5660300002)(55016002)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 20:56:33.7735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d7d43ad-46c2-4df6-da78-08d99342ef2c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Subject: [dpdk-dev] [PATCH v3 05/18] net/mlx5/windows: rearrange probing code 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 Sender: "dev" From: Michael Baum Rearrange device detection code. Rearrange configuration structures filling. Remove unneeded variables. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/windows/mlx5_os.c | 224 ++++++++++++----------------- 1 file changed, 94 insertions(+), 130 deletions(-) diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index ea2d45bbce..90e21479e3 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -956,9 +956,9 @@ mlx5_match_devx_devices_to_addr(struct devx_device_bdf *devx_bdf, if (mlx5_match_devx_bdf_to_addr(devx_bdf, addr)) return 1; - /** - * Didn't match on Native/PF BDF, could still - * Match a VF BDF, check it next + /* + * Didn't match on Native/PF BDF, could still match a VF BDF, + * check it next. */ err = mlx5_glue->query_device(devx_bdf, &mlx5_dev); if (err) { @@ -971,6 +971,52 @@ mlx5_match_devx_devices_to_addr(struct devx_device_bdf *devx_bdf, return 0; } +/** + * Look for DevX device that match to given rte_device. + * + * @param dev + * Pointer to the generic device. + * @param orig_devx_list + * Pointer to head of DevX devices list. + * @param n + * Number of devices in given DevX devices list. + * + * @return + * A device match on success, NULL otherwise and rte_errno is set. + */ +static struct devx_device_bdf * +mlx5_os_get_devx_device(struct rte_device *dev, + struct devx_device_bdf *orig_devx_list, int n) +{ + struct devx_device_bdf *devx_list = orig_devx_list; + struct devx_device_bdf *devx_match = NULL; + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev); + struct rte_pci_addr *addr = &pci_dev->addr; + + while (n-- > 0) { + int ret = mlx5_match_devx_devices_to_addr(devx_list, addr); + if (!ret) { + devx_list++; + continue; + } + if (ret != 1) { + rte_errno = ret; + return NULL; + } + devx_match = devx_list; + break; + } + if (devx_match == NULL) { + /* No device matches, just complain and bail out. */ + DRV_LOG(WARNING, + "No DevX device matches PCI device " PCI_PRI_FMT "," + " is DevX Configured?", + addr->domain, addr->bus, addr->devid, addr->function); + rte_errno = ENOENT; + } + return devx_match; +} + /** * DPDK callback to register a PCI device. * @@ -986,37 +1032,34 @@ int mlx5_os_net_probe(struct mlx5_common_device *cdev) { struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); - struct devx_device_bdf *devx_bdf_devs, *orig_devx_bdf_devs; - /* - * Number of found IB Devices matching with requested PCI BDF. - * nd != 1 means there are multiple IB devices over the same - * PCI device and we have representors and master. - */ - unsigned int nd = 0; - /* - * Number of found IB device Ports. nd = 1 and np = 1..n means - * we have the single multiport IB device, and there may be - * representors attached to some of found ports. - * Currently not supported. - * unsigned int np = 0; - */ - - /* - * Number of DPDK ethernet devices to Spawn - either over - * multiple IB devices or multiple ports of single IB device. - * Actually this is the number of iterations to spawn. - */ - unsigned int ns = 0; - /* - * Bonding device - * < 0 - no bonding device (single one) - * >= 0 - bonding device (value is slave PF index) - */ - int bd = -1; - struct mlx5_dev_spawn_data *list = NULL; - struct mlx5_dev_config dev_config; - unsigned int dev_config_vf; - int ret, err; + struct devx_device_bdf *devx_list; + struct devx_device_bdf *devx_bdf_match; + struct mlx5_dev_spawn_data spawn = { + .pf_bond = -1, + .max_port = 1, + .phys_port = 1, + .pci_dev = pci_dev, + .cdev = cdev, + .ifindex = -1, /* Spawn will assign */ + .info = (struct mlx5_switch_info){ + .name_type = MLX5_PHYS_PORT_NAME_TYPE_UPLINK, + }, + }; + struct mlx5_dev_config dev_config = { + .rx_vec_en = 1, + .txq_inline_max = MLX5_ARG_UNSET, + .txq_inline_min = MLX5_ARG_UNSET, + .txq_inline_mpw = MLX5_ARG_UNSET, + .txqs_inline = MLX5_ARG_UNSET, + .mprq = { + .max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN, + .min_rxqs_num = MLX5_MPRQ_MIN_RXQS, + }, + .dv_flow_en = 1, + .log_hp_size = MLX5_ARG_UNSET, + }; + int ret; + int n; uint32_t restore; if (rte_eal_process_type() == RTE_PROC_SECONDARY) { @@ -1030,74 +1073,18 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) return -rte_errno; } errno = 0; - devx_bdf_devs = mlx5_glue->get_device_list(&ret); - orig_devx_bdf_devs = devx_bdf_devs; - if (!devx_bdf_devs) { + devx_list = mlx5_glue->get_device_list(&n); + if (devx_list == NULL) { rte_errno = errno ? errno : ENOSYS; - DRV_LOG(ERR, "cannot list devices, is ib_uverbs loaded?"); + DRV_LOG(ERR, "Cannot list devices, is DevX enabled?"); return -rte_errno; } - /* - * First scan the list of all Infiniband devices to find - * matching ones, gathering into the list. - */ - struct devx_device_bdf *devx_bdf_match[ret + 1]; - - while (ret-- > 0) { - err = mlx5_match_devx_devices_to_addr(devx_bdf_devs, - &pci_dev->addr); - if (!err) { - devx_bdf_devs++; - continue; - } - if (err != 1) { - ret = -err; - goto exit; - } - devx_bdf_match[nd++] = devx_bdf_devs; - } - devx_bdf_match[nd] = NULL; - if (!nd) { - /* No device matches, just complain and bail out. */ - DRV_LOG(WARNING, - "no DevX device matches PCI device " PCI_PRI_FMT "," - " is DevX Configured?", - pci_dev->addr.domain, pci_dev->addr.bus, - pci_dev->addr.devid, pci_dev->addr.function); - rte_errno = ENOENT; + devx_bdf_match = mlx5_os_get_devx_device(cdev->dev, devx_list, n); + if (devx_bdf_match == NULL) { ret = -rte_errno; goto exit; } - /* - * Now we can determine the maximal - * amount of devices to be spawned. - */ - list = mlx5_malloc(MLX5_MEM_ZERO, - sizeof(struct mlx5_dev_spawn_data), - RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); - if (!list) { - DRV_LOG(ERR, "spawn data array allocation failure"); - rte_errno = ENOMEM; - ret = -rte_errno; - goto exit; - } - memset(&list[ns].info, 0, sizeof(list[ns].info)); - list[ns].max_port = 1; - list[ns].phys_port = 1; - list[ns].phys_dev = devx_bdf_match[ns]; - list[ns].eth_dev = NULL; - list[ns].pci_dev = pci_dev; - list[ns].cdev = cdev; - list[ns].pf_bond = bd; - list[ns].ifindex = -1; /* Spawn will assign */ - list[ns].info = - (struct mlx5_switch_info){ - .master = 0, - .representor = 0, - .name_type = MLX5_PHYS_PORT_NAME_TYPE_UPLINK, - .port_name = 0, - .switch_id = 0, - }; + spawn.phys_dev = devx_bdf_match; /* Device specific configuration. */ switch (pci_dev->id.device_id) { case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF: @@ -1107,47 +1094,24 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) case PCI_DEVICE_ID_MELLANOX_CONNECTX5BFVF: case PCI_DEVICE_ID_MELLANOX_CONNECTX6VF: case PCI_DEVICE_ID_MELLANOX_CONNECTXVF: - dev_config_vf = 1; + dev_config.vf = 1; break; default: - dev_config_vf = 0; + dev_config.vf = 0; break; } - /* Default configuration. */ - memset(&dev_config, 0, sizeof(struct mlx5_dev_config)); - dev_config.vf = dev_config_vf; - dev_config.mps = 0; - dev_config.rx_vec_en = 1; - dev_config.txq_inline_max = MLX5_ARG_UNSET; - dev_config.txq_inline_min = MLX5_ARG_UNSET; - dev_config.txq_inline_mpw = MLX5_ARG_UNSET; - dev_config.txqs_inline = MLX5_ARG_UNSET; - dev_config.vf_nl_en = 0; - dev_config.mprq.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN; - dev_config.mprq.min_rxqs_num = MLX5_MPRQ_MIN_RXQS; - dev_config.dv_esw_en = 0; - dev_config.dv_flow_en = 1; - dev_config.decap_en = 0; - dev_config.log_hp_size = MLX5_ARG_UNSET; - list[ns].eth_dev = mlx5_dev_spawn(cdev->dev, &list[ns], &dev_config); - if (!list[ns].eth_dev) + spawn.eth_dev = mlx5_dev_spawn(cdev->dev, &spawn, &dev_config); + if (!spawn.eth_dev) { + ret = -rte_errno; goto exit; - restore = list[ns].eth_dev->data->dev_flags; - rte_eth_copy_pci_info(list[ns].eth_dev, pci_dev); + } + restore = spawn.eth_dev->data->dev_flags; + rte_eth_copy_pci_info(spawn.eth_dev, pci_dev); /* Restore non-PCI flags cleared by the above call. */ - list[ns].eth_dev->data->dev_flags |= restore; - rte_eth_dev_probing_finish(list[ns].eth_dev); - ret = 0; + spawn.eth_dev->data->dev_flags |= restore; + rte_eth_dev_probing_finish(spawn.eth_dev); exit: - /* - * Do the routine cleanup: - * - free allocated spawn data array - * - free the device list - */ - if (list) - mlx5_free(list); - MLX5_ASSERT(orig_devx_bdf_devs); - mlx5_glue->free_device_list(orig_devx_bdf_devs); + mlx5_glue->free_device_list(devx_list); return ret; } -- 2.25.1