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 6EC4EA0547; Mon, 27 Sep 2021 10:33:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9821D410F2; Mon, 27 Sep 2021 10:33:36 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2089.outbound.protection.outlook.com [40.107.95.89]) by mails.dpdk.org (Postfix) with ESMTP id 38E56410EE for ; Mon, 27 Sep 2021 10:33:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HFnyXknVrQTQpm1goPmo26YntPhiZaPHqRjGRtLfeHu4kXO8V4YXQeYrvUDYZuBPjk1NHJyJ2QZDb3WdWs589XeRcLACUU8G0xRxpWwo6xL1YLP9slDy8LxPhXIHyMZRSf0MZdn6zmNe9/zra0GRk15BJa0FThSt1qTSCAjtUveX0guORBqbiozhHEHitXaXqwYvhmYkgyumOrUOczGQ4BlP4I8MuFvXg7z+qLaulcwDMOLuh43GFWCX01eqSJgJXzJV88/OUo7pTCNz8wup/l+Iu4AP1pn1o/J39i3gjtc1ieWVARK+tS1UN/4Bmoq53SX6cTVkdhsYBJgOuYGxWg== 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=4pmiKl4sfzmhDFonlmKVQKsBwFiQFgYO8FKwM9pdJn4=; b=Sg/t3PfAl0phKgT4CIfBa1e4GCeVYjUjoVqChWmyE610VioWCiyRkJK8K38S80gIPdV/Tj+fcn2RQvgO724J2P4b/na7wLSgGgUtK3KPped59Z2QviMZkZGk32c2j2AKyjQq/cYJHOyy4whWHs6curPFL1xN4gJnGCTfkeuABpduGxT8XeYlSsy/RqPBC28ygqVdQknYFAqFvC8xHRFcoang3PNfuTHi0BOKqG/Ngl7j11yhLdVmDgqEzMHUvHmULRfjLcfe5D8S+TRiqTGB27HWpibj6BjQrRbJp77/LP/0LNrLXgeweQKMbxMPjgozsJv+kNGyyrFv4Jj99SCfhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) 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=4pmiKl4sfzmhDFonlmKVQKsBwFiQFgYO8FKwM9pdJn4=; b=p09NPUMTJJmcTBYQDNIK6Z5r2fIeF3BFjWMZAB5KV5r7W6d/F7egLzd91XMu9DJltHSH+xHNpXa+TYBSbBaXYmjmH2jV0N6ebERKvJs4IIWzdz9CVxDvbVzc35VvEddYvFDhPAApg6KDhV+FWVHrs2rEnnaSD/+OCW5wfwxt7wVTSWk8CpVaosA0odYmIIkeU02VKdnL1WQLwkFQUQFxU4SXlayDW78gLyiSz/Xj3ETSqgPkWuTnRoLLQRfySlvLff7uXvCtF1WtDd11ZpxKBD1sHLLajBfGQqcE5phyOunFLIXiqzsym+NQM0Rp4Ma0aJ/+ajtqsdrGdmmSU8WvYQ== Received: from MWHPR1201CA0005.namprd12.prod.outlook.com (2603:10b6:301:4a::15) by DM4PR12MB5248.namprd12.prod.outlook.com (2603:10b6:5:39c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Mon, 27 Sep 2021 08:33:34 +0000 Received: from CO1NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:301:4a:cafe::64) by MWHPR1201CA0005.outlook.office365.com (2603:10b6:301:4a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 08:33:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) 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.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT064.mail.protection.outlook.com (10.13.175.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 08:33:32 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 27 Sep 2021 08:33:31 +0000 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.18; Mon, 27 Sep 2021 08:33:30 +0000 From: Xueming Li To: CC: , Matan Azrad , "Viacheslav Ovsiienko" Date: Mon, 27 Sep 2021 16:32:50 +0800 Message-ID: <20210927083256.337450-3-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927083256.337450-1-xuemingl@nvidia.com> References: <20210927083256.337450-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6991e97-f2c9-4683-a3b9-08d981917e2d X-MS-TrafficTypeDiagnostic: DM4PR12MB5248: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8zB5y4Nt/vtBRv+kn0Z0kKmDcF1xi/2Gf4baIcvJ/IM0k9lbBNh+2he6vqLfVDElffqtgFnE30F4NE4xNbbfFVpXh4zVxl6AxUvBz7qeW10MvrBhGwQkTbf6HwL6vComeDKDfXlFp5NeL1g8EFP73Am44vHrHI1o8ra/WU8/RQ1ZYRxlOlcqhYtEVW4X1LKi7tTiPtAJqXQCtm14FFjNjIEfhBATfQVxwuCohfYVxaSZuqwcliQCZYwXhWncSdKxl5pl8iLiaYsGSTThO2H3bp15b5z9NEdoaRdjXJEolmMG08AD2Zh9TRHc4x8RiJxCGHzE/Ylu8Rie1KPwTOjXfi582XzJ23yvoX2hIhneT//dqwaGfNxzP+cDvjIttX7aLANRxF2ZOciMkpL1fkr1nNHDenIhgvbRmKiKAQI//PryKrHRfHolU50ZA04mCOMtO4BThvY2gh7KzhoFjfEV5I5P0M2UC7Z6NolA/h22Uc/sEf4bhYeyn/vJIiv85GiyUioBChik0pQYz6Io/Bg9nBQJvsw8NPQ5H5X49Q/MAcCcysWpyNzeh0fHLwKI0fwdGyN0fLo5K0rmOwNKZJW1GQf5Qwtz27yrad79y5+fKAq81JMLEmJXVMnY9SEX95YyVAlkhcLtO+eSfvpNBhWQJfUpupDixzJitY4K3Vy9t4+j6e1bRmnGXoekZhm4NbJH3IlzYph7Fyy/r6693d5B4a2sEcFQUV3MOYtMbJ1khc8= X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(6916009)(26005)(7636003)(8676002)(16526019)(6286002)(83380400001)(7696005)(36906005)(186003)(5660300002)(508600001)(356005)(6666004)(82310400003)(55016002)(336012)(70206006)(70586007)(54906003)(2906002)(36756003)(2616005)(107886003)(8936002)(316002)(1076003)(426003)(4326008)(86362001)(47076005)(36860700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 08:33:32.4494 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6991e97-f2c9-4683-a3b9-08d981917e2d 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.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5248 Subject: [dpdk-dev] [PATCH 2/8] net/mlx5: use netlink when IB port greater than 255 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" IB spec doesn't allow 255 ports on a single HCA, port number of 256 was cast to u8 value 0 which invalid to ibv_query_port() This patch invoke netlink api to query port state when port number greater than 255. Signed-off-by: Xueming Li --- drivers/net/mlx5/linux/mlx5_os.c | 39 ++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 470b16cb9ad..79ab789df43 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -956,7 +956,7 @@ 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 ibv_port_attr port_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; @@ -976,6 +976,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, int own_domain_id = 0; uint16_t port_id; struct mlx5_port_info vport_info = { .query_flags = 0 }; + int nl_rdma = -1; int i; /* Determine if this port representor is supposed to be spawned. */ @@ -1170,19 +1171,29 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, " old OFED/rdma-core version or firmware configuration"); #endif config->mpls_en = mpls_en; + nl_rdma = mlx5_nl_init(NETLINK_RDMA); /* Check port status. */ - err = mlx5_glue->query_port(sh->ctx, spawn->phys_port, &port_attr); - if (err) { - DRV_LOG(ERR, "port query failed: %s", strerror(err)); - goto error; - } - if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { - DRV_LOG(ERR, "port is not configured in Ethernet mode"); - err = EINVAL; - goto error; + if (spawn->phys_port <= UINT8_MAX) { + /* Legacy Verbs api only support u8 port number. */ + err = mlx5_glue->query_port(sh->ctx, spawn->phys_port, + &port_attr); + if (err) { + DRV_LOG(ERR, "port query failed: %s", strerror(err)); + goto error; + } + if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { + DRV_LOG(ERR, "port is not configured in Ethernet mode"); + err = EINVAL; + goto error; + } + } else if (nl_rdma >= 0) { + /* IB doesn't allow more than 255 ports, must be Ethernet. */ + port_attr.state = mlx5_nl_port_state(nl_rdma, + ((struct ibv_device *)spawn->phys_dev)->name, + spawn->phys_port); } if (port_attr.state != IBV_PORT_ACTIVE) - DRV_LOG(DEBUG, "port is not active: \"%s\" (%d)", + DRV_LOG(INFO, "port is not active: \"%s\" (%d)", mlx5_glue->port_state_str(port_attr.state), port_attr.state); /* Allocate private eth device data. */ @@ -1199,7 +1210,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->pci_dev = spawn->pci_dev; priv->mtu = RTE_ETHER_MTU; /* Some internal functions rely on Netlink sockets, open them now. */ - priv->nl_socket_rdma = mlx5_nl_init(NETLINK_RDMA); + priv->nl_socket_rdma = nl_rdma; priv->nl_socket_route = mlx5_nl_init(NETLINK_ROUTE); priv->representor = !!switch_info->representor; priv->master = !!switch_info->master; @@ -1910,8 +1921,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mlx5_os_free_shared_dr(priv); if (priv->nl_socket_route >= 0) close(priv->nl_socket_route); - if (priv->nl_socket_rdma >= 0) - close(priv->nl_socket_rdma); if (priv->vmwa_context) mlx5_vlan_vmwa_exit(priv->vmwa_context); if (eth_dev && priv->drop_queue.hrxq) @@ -1935,6 +1944,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } if (sh) mlx5_free_shared_dev_ctx(sh); + if (nl_rdma >= 0) + close(nl_rdma); MLX5_ASSERT(err > 0); rte_errno = err; return NULL; -- 2.33.0