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 17114A0C43; Thu, 30 Sep 2021 19:40:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3303E41130; Thu, 30 Sep 2021 19:39:51 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2069.outbound.protection.outlook.com [40.107.237.69]) by mails.dpdk.org (Postfix) with ESMTP id C8068410EA for ; Thu, 30 Sep 2021 19:28:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rk9Eb9W0PUze06wuMoOFCrqGXQVwiprWKYveBQNJrYqih03JqtQRC6CLvwpWiaXKaNknjg1NbqZtoaLOB5FtEBBXY/dlG1u9C8wxgIHE6RvfrlHoCPkV+Sm6JH7duOjc5c4led1vXkopc0pJBIYK1YQ4MjjTvCuAJbihyk8R98aGjzqtCFzrUk5s2JZkablkI1BRxm6c9PJB4kcFQBwkx43b2E4G1kOwmrH+LtAu6P8qAl4J+Zn2Pfhfie5OPUO6QkcY5MzORVj/o+msGtOofr/zpvUJc4i8BSnPPzD/UNinh8hVdgj6GUKKKMiWQw+fOGQli5TWx2Kf0/f4udGr7w== 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; bh=lLvARIuu92X2DIlXfxu9QBJPG0RHDR4JARxoimrkXQM=; b=gzc/gt+kCmlFuEm6yrTNkyizVuv+lXmH6ZVgEdl/0OK4s5143eoLHhHIhx//8SzkvIj+f+o+4lMDKVVoq1HlAAzZPhNBH9ENm/jevyyIzw5FNfBgVTYUs2a+gCc+pYQVnzmjHo3g8PH5JgHccKL1K+QtzHFHxlJVRvjJkyCiEWwt5u6npXcwXg68HThycIMeYBNnn7o2ZLNU8cNOQ9RPUAu1FPdMbOGtHyN8/eu2h1BiOlNJFoKYIr5YsoDJV29eX4qkipQzzstAM/HWfgIna6DbFVcnTB7GPR1y5wua2aI7Hb/avcNRbBzsR6kvgz1no+9eHEjMy6ecuuEcXkGE2g== 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=none 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=Rqpt3o7uOsqNU8zDZ/bRBO0qW3KEx4A2tj97KG9qvMUMseGdgGvqntcDI/7V2TCP4cRZZ2B6rBTJPfAxr9shVaRB2RaWeiWq6sIYcXh2J9BojTsUXFLbksf+6fTIC0jvrigKzmCLwNIz2/MInNwn3XGHNgL4X7vODtzykmOJll2/LZIbW3kbfhOOmB6Vjb3nJe7yd4VqAy7br7hp1hPzzUfLpHZa37wHovgHe1QKZpWWGcxmAYk3IDPGS3QZ/rmdsKrYYVEpwZLxU2HKf+17ByzDX5ezQDrgOEzAKenU6RD689bMX5PnYacY4zVURciD+TQcVG1pOYxhgo/SHqN33g== Received: from BN9PR03CA0885.namprd03.prod.outlook.com (2603:10b6:408:13c::20) by DM6PR12MB3129.namprd12.prod.outlook.com (2603:10b6:5:3b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Thu, 30 Sep 2021 17:28:52 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::2a) by BN9PR03CA0885.outlook.office365.com (2603:10b6:408:13c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Thu, 30 Sep 2021 17:28:52 +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 BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 17:28:52 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 30 Sep 2021 17:28:50 +0000 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum Date: Thu, 30 Sep 2021 20:28:09 +0300 Message-ID: <20210930172822.1949969-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930172822.1949969-1-michaelba@nvidia.com> References: <20210930172822.1949969-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3b22fdd-8656-4f1b-1fd8-08d98437c5b5 X-MS-TrafficTypeDiagnostic: DM6PR12MB3129: 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: P6v15fucAPmOQGBPrFZrU1SyKIbQ8CKc0TApYjlqU4zmiHJM1YLfgz1fmdyBDx5gVlFR04/gHjadwUssdONjIA/laASdGS3zUdjw7d7q6L6olpvKVzqKgHWrS6+YWFPGKteTYfVod32L3WV9+p5SOUl8kbGmuWzO5eYoNbFaAWdEm8ezwN6Wh+kCPUC9OT73WODjYUtPcZtj70TwoFbDa0bqEpDC6C+dRQcyExbMnprYGfTz1BgGOcxhU86jmAQuSVm1nsj9mWN3oXJCtEKxk7tfJvIsSOgs8D+Z5zawH0u3hNfX9EeCgsvsTYITfI00nhMXJ2IW2GLo4qtqxoOOcUzmtX2lvD3P9ve3dMve9SwtNnhDK/+bn1UTi+F2wJmsaH5XloWtORg+A41dRTirwtiNL68Fnrt43N+buI7l9UikekilEDZV1E0T9BzLPgPPHYZlHlsAuO5fJ4DnhFe5oACS1gN1lzlnJk8UdUVo+0sNTz1KTL49vvoRwhXJZnpvEdD3I6AJ19ksEWZPQWc9Riy6umdGcCfCmROWEoGLEWWE/1MRe4asU0OTdyl/JzqJBmuAOSeEbftUrJyH/Q+f3B3DvtH1qDDElrNzi89hwoXUgwTJLW78sNEh/59udwjnyM1tkH8I3y8NHYpdD0QAqRoExLNJiBnNZvsYIc9ILZBYVEC3g/c2O3czovbJQOaG22QZWyT3K1mimc+HBnw7Ew== 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)(8936002)(36860700001)(70586007)(316002)(6916009)(70206006)(36906005)(7696005)(55016002)(4326008)(6666004)(356005)(82310400003)(2876002)(5660300002)(336012)(1076003)(8676002)(26005)(7636003)(47076005)(16526019)(54906003)(107886003)(6286002)(2906002)(36756003)(2616005)(83380400001)(426003)(86362001)(508600001)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 17:28:52.3106 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3b22fdd-8656-4f1b-1fd8-08d98437c5b5 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: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3129 X-Mailman-Approved-At: Thu, 30 Sep 2021 19:39:43 +0200 Subject: [dpdk-dev] [PATCH 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