From patchwork Tue Aug 17 13:44:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 96999 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 1FC6BA0548; Tue, 17 Aug 2021 15:46:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D60D5411ED; Tue, 17 Aug 2021 15:45:32 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2041.outbound.protection.outlook.com [40.107.92.41]) by mails.dpdk.org (Postfix) with ESMTP id A672A411DD for ; Tue, 17 Aug 2021 15:45:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O9C3MP9BA1AEsAcn9g3046i/HARJO7TWNrqiTK7fucNC/ym0ynwdzUqogFgCCuT8+f1DZJwQYXweG077EPsRi/rd2QBntHnIHF4IiOouQW2HLOH3Zeby2svc/2lkXdw3022KxZSX9DJ0G2T+pKQugdJ8uUY7TvAst5V8vlhyR4j1WdRF03kgelVG9Z8XAL2efeP1/G5l2t0QIisQ5q2HGIsolQpQScDCUFIiipxNzWQoUipPnKqHY9+ev31aebzRAGHf2n8EznivqbOv+nLeSDJCMiN8w2S0Zpo7q05YFuEBn10vrByMwZswWS5uCThNUQ/qRxVEZkc8+wU605SLjA== 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-SenderADCheck; bh=8Zx1kK4VZC4/lrxToNWcmpObEPh8PdI6sG0yMr3/OnM=; b=DZWyrTnkDwltBdqSM/RW4T/l81pBS7yLJ+WltKSaIVU/4OKzIdpFFPG4S94vRs1yx1ypd6J1KLYxsR0X1+DujI4bYKvfu66PQ0kvesXB0DKapuvWuchskykLp0IyWU2a/607U1kJc+WkZhUrcFX23huzwt7ThnhCIoZL5bIXB4ZJW7eQqo6AgRK9CzjlXb/l+HIpLoCRriNbmp/2Vp4T+Mo1w/bYsmrnnIAXKyjcvvtW0k6aRUKm8IhUCjXO/xRNtbbtpulxX+YnCO0rBX1e4B7KZkPfRAzb0DBhYg+A2wWUB72RjCzdKaOfZDaiHZT9wItc7P6vUQAVPy2cMRUhYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=dpdk.org 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=8Zx1kK4VZC4/lrxToNWcmpObEPh8PdI6sG0yMr3/OnM=; b=Cdi0aqdEY5axVlWfeAFPLberWiZdHsaAF9cMX25wJVVmOlmLcgSiNkahNC/DDJf7zI43goueznJZZu7XR9EYV2c4XEHlv+eYBnLujyHZXdS7jZ5BuwAOVffQYkLiznDBKaEQgQotUBxZSfYDHlVxpG1DlZ3dbvWgJUO8/thzt//0oQwc8R3Xk+ckP1weAtvuuLDjF21BoPixn5J3URJkqeef7T2n5fGLosqiswT3vW1M5SlagoqziYEjOoqMaKIg99ewwyaCp5bTaJ8AQTXtwQh0YNc8nFT7V2tCbPzPV3+TyKciCWeceSYupz5qvoDzQqa8+D+VXiyDv6zCHC3UqQ== Received: from MWHPR04CA0053.namprd04.prod.outlook.com (2603:10b6:300:6c::15) by SA0PR12MB4480.namprd12.prod.outlook.com (2603:10b6:806:99::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.14; Tue, 17 Aug 2021 13:45:28 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:300:6c:cafe::bf) by MWHPR04CA0053.outlook.office365.com (2603:10b6:300:6c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Tue, 17 Aug 2021 13:45:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4415.14 via Frontend Transport; Tue, 17 Aug 2021 13:45:28 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 17 Aug 2021 06:45:27 -0700 Received: from nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 17 Aug 2021 13:45:26 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Tue, 17 Aug 2021 16:44:28 +0300 Message-ID: <20210817134441.1966618-9-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210817134441.1966618-1-michaelba@nvidia.com> References: <20210817134441.1966618-1-michaelba@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 220e2380-142e-4234-82ef-08d961854615 X-MS-TrafficTypeDiagnostic: SA0PR12MB4480: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x5sdsBhlApU9OzX9iB4e5dJYc/i0fjourFW/x0cHJmp4Nr2LLVvfbIBxUyTw54WarufybRyS1kRq2he0/+8N8HnHFdCmX5f4lEh12IiCfdvNNSZcsAfXszEps2nkZ5fk2WZS2L3vu39depqiD/fAUpZvIB6bmWZA2/yaANQlYyrPJwgFoKlvZwdR/BtmL0Ii+vdXf4h00Lq4fYS71r4icb+vgymNJn009ZmswsNtvWyIbeom3NcJU8mukK8yRPreq+u8P5kA/zHB5+l3OcO9xD7PTL/O4FiQBdZUMGYbJ39zg/tfW9Y9oXrW/XXHuE/9GFyiVIy+NUpOMbJS1X+YaYKPy6gN4DeKqNF7tvA1E2AYCJQltIvr9f6sV9PVHPM5m0RWmatMXkaFNcq86oetIdcrw2YbiPBK7ATc6i3Whuw1CWSCz1tsWHQPB/UK+UIdOop1+Wr3hyONstZNZ1UE52vmNwju1HsZELf/lIIkEK9CipA18t2/AsOHyFEWSk2S6EFh8LQ3LMrHaxfbyIbtPKkKy1oM12JMDBwnmkf8rsniCdtpmXJ8uF9k1ree/0Nk3hdozEC4ZQtIsTp7N+wSxo0grlAterT2lHS84kZjyAZwOqkN2A5/L+FAf+uH1kQY7q2P47An+VrkQMDUZr9G0166YjtReXinaESz88s8OOhC+L4WQZgh79PchOWZ50djajLRpra1dXYcMqcQ6OvHqg== X-Forefront-Antispam-Report: CIP:216.228.112.32; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid01.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(36860700001)(336012)(47076005)(16526019)(186003)(26005)(54906003)(356005)(6916009)(426003)(2616005)(2906002)(1076003)(7636003)(107886003)(5660300002)(83380400001)(316002)(82310400003)(4326008)(7696005)(508600001)(8936002)(86362001)(70206006)(36756003)(8676002)(70586007)(6286002)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2021 13:45:28.3045 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 220e2380-142e-4234-82ef-08d961854615 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.32]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4480 Subject: [dpdk-dev] [RFC 08/21] net/mlx5: improve probe function on Linux 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" some improvements: - Update parameters for mlx5_device_bond_pci_match function. - Fix spelling and typos in comments. - Prevent breaking lines on drv logs. Signed-off-by: Michael Baum --- drivers/net/mlx5/linux/mlx5_os.c | 96 ++++++++++++++------------------ 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 3d204f99f7..375bc55e79 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1984,14 +1984,14 @@ mlx5_dev_spawn_data_cmp(const void *a, const void *b) /** * Match PCI information for possible slaves of bonding device. * - * @param[in] ibv_dev - * Pointer to Infiniband device structure. + * @param[in] ibdev_name + * Name of Infiniband device. * @param[in] pci_dev * Pointer to primary PCI address structure to match. * @param[in] nl_rdma * Netlink RDMA group socket handle. * @param[in] owner - * Rerepsentor owner PF index. + * Representor owner PF index. * @param[out] bond_info * Pointer to bonding information. * @@ -2000,7 +2000,7 @@ mlx5_dev_spawn_data_cmp(const void *a, const void *b) * positive index of slave PF in bonding. */ static int -mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, +mlx5_device_bond_pci_match(const char *ibdev_name, const struct rte_pci_addr *pci_dev, int nl_rdma, uint16_t owner, struct mlx5_bond_info *bond_info) @@ -2013,27 +2013,25 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, int ret; /* - * Try to get master device name. If something goes - * wrong suppose the lack of kernel support and no - * bonding devices. + * Try to get master device name. If something goes wrong suppose + * the lack of kernel support and no bonding devices. */ memset(bond_info, 0, sizeof(*bond_info)); if (nl_rdma < 0) return -1; - if (!strstr(ibv_dev->name, "bond")) + if (!strstr(ibdev_name, "bond")) return -1; - np = mlx5_nl_portnum(nl_rdma, ibv_dev->name); + np = mlx5_nl_portnum(nl_rdma, ibdev_name); if (!np) return -1; /* - * The Master device might not be on the predefined - * port (not on port index 1, it is not garanted), - * we have to scan all Infiniband device port and - * find master. + * The master device might not be on the predefined port(not on port + * index 1, it is not guaranteed), we have to scan all Infiniband + * device ports and find master. */ for (i = 1; i <= np; ++i) { /* Check whether Infiniband port is populated. */ - ifindex = mlx5_nl_ifindex(nl_rdma, ibv_dev->name, i); + ifindex = mlx5_nl_ifindex(nl_rdma, ibdev_name, i); if (!ifindex) continue; if (!if_indextoname(ifindex, ifname)) @@ -2058,8 +2056,9 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, snprintf(tmp_str, sizeof(tmp_str), "/sys/class/net/%s", ifname); if (mlx5_get_pci_addr(tmp_str, &pci_addr)) { - DRV_LOG(WARNING, "can not get PCI address" - " for netdev \"%s\"", ifname); + DRV_LOG(WARNING, + "Cannot get PCI address for netdev \"%s\".", + ifname); continue; } /* Slave interface PCI address match found. */ @@ -2218,9 +2217,8 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, struct rte_pci_addr pci_addr; DRV_LOG(DEBUG, "checking device \"%s\"", ibv_list[ret]->name); - bd = mlx5_device_bond_pci_match - (ibv_list[ret], &owner_pci, nl_rdma, owner_id, - &bond_info); + bd = mlx5_device_bond_pci_match(ibv_list[ret]->name, &owner_pci, + nl_rdma, owner_id, &bond_info); if (bd >= 0) { /* * Bonding device detected. Only one match is allowed, @@ -2240,9 +2238,9 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, /* Amend owner pci address if owner PF ID specified. */ if (eth_da.nb_representor_ports) owner_pci.function += owner_id; - DRV_LOG(INFO, "PCI information matches for" - " slave %d bonding device \"%s\"", - bd, ibv_list[ret]->name); + DRV_LOG(INFO, + "PCI information matches for slave %d bonding device \"%s\"", + bd, ibv_list[ret]->name); ibv_match[nd++] = ibv_list[ret]; break; } else { @@ -2281,23 +2279,19 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, if (nl_rdma >= 0) np = mlx5_nl_portnum(nl_rdma, ibv_match[0]->name); if (!np) - DRV_LOG(WARNING, "can not get IB device \"%s\"" - " ports number", ibv_match[0]->name); + DRV_LOG(WARNING, + "Cannot get IB device \"%s\" ports number.", + ibv_match[0]->name); if (bd >= 0 && !np) { - DRV_LOG(ERR, "can not get ports" - " for bonding device"); + DRV_LOG(ERR, "Cannot get ports for bonding device."); rte_errno = ENOENT; ret = -rte_errno; goto exit; } } - /* - * Now we can determine the maximal - * amount of devices to be spawned. - */ + /* Now we can determine the maximal amount of devices to be spawned. */ list = mlx5_malloc(MLX5_MEM_ZERO, - sizeof(struct mlx5_dev_spawn_data) * - (np ? np : nd), + sizeof(struct mlx5_dev_spawn_data) * (np ? np : nd), RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); if (!list) { DRV_LOG(ERR, "spawn data array allocation failure"); @@ -2339,10 +2333,9 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, } ret = -1; if (nl_route >= 0) - ret = mlx5_nl_switch_info - (nl_route, - list[ns].ifindex, - &list[ns].info); + ret = mlx5_nl_switch_info(nl_route, + list[ns].ifindex, + &list[ns].info); if (ret || (!list[ns].info.representor && !list[ns].info.master)) { /* @@ -2350,9 +2343,8 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, * Netlink, let's try to perform the task * with sysfs. */ - ret = mlx5_sysfs_switch_info - (list[ns].ifindex, - &list[ns].info); + ret = mlx5_sysfs_switch_info(list[ns].ifindex, + &list[ns].info); } if (!ret && bd >= 0) { switch (list[ns].info.name_type) { @@ -2465,10 +2457,9 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, } ret = -1; if (nl_route >= 0) - ret = mlx5_nl_switch_info - (nl_route, - list[ns].ifindex, - &list[ns].info); + ret = mlx5_nl_switch_info(nl_route, + list[ns].ifindex, + &list[ns].info); if (ret || (!list[ns].info.representor && !list[ns].info.master)) { /* @@ -2476,9 +2467,8 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, * Netlink, let's try to perform the task * with sysfs. */ - ret = mlx5_sysfs_switch_info - (list[ns].ifindex, - &list[ns].info); + ret = mlx5_sysfs_switch_info(list[ns].ifindex, + &list[ns].info); } if (!ret && (list[ns].info.representor ^ list[ns].info.master)) { @@ -2487,11 +2477,10 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, !list[ns].info.representor && !list[ns].info.master) { /* - * Single IB device with - * one physical port and + * Single IB device with one physical port and * attached network device. - * May be SRIOV is not enabled - * or there is no representors. + * May be SRIOV is not enabled or there is no + * representors. */ DRV_LOG(INFO, "no E-Switch support detected"); ns++; @@ -2508,10 +2497,9 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, } /* * New kernels may add the switch_id attribute for the case - * there is no E-Switch and we wrongly recognized the - * only device as master. Override this if there is the - * single device with single port and new device name - * format present. + * there is no E-Switch and we wrongly recognized the only + * device as master. Override this if there is the single + * device with single port and new device name format present. */ if (nd == 1 && list[0].info.name_type == MLX5_PHYS_PORT_NAME_TYPE_UPLINK) {