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 4751CA0C43; Tue, 19 Oct 2021 12:35:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34F4F4113A; Tue, 19 Oct 2021 12:35:51 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) by mails.dpdk.org (Postfix) with ESMTP id 8868141125 for ; Tue, 19 Oct 2021 12:35:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gZT+p5LAouZzFaByYeewGc0n6o0hopXZv+3tvdwP24X6VnZ9k1dsbawEClg+JKU2P+mjF51/mwnjf6Cpuqd9GbWHWVifSFy1G1N1i6Z42KIWRIlOPUbj2sZ0SHkk2xoBHyyGGBIe5ojZ7UXMM9xGNGAfbMVbe41DuOyQxo9F3xWW4LC1f2NEmF3tn+OjCJ4I9OH/6/i5A0sBbYxs2IFpbC0Iqhx/X0ULS1K3uhB8HwKj0d743GrngWexeWnwDhTDBfQtbK2taupz+Kn3anEaOFwv9KRSeEp3BBBL7bNhELIE9terP9BSTZGjZmk8A834deuqmpBlqIM93gTZNoxHXQ== 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=V+R9at4aF29P5QfuGDKd1QrNyBYntfiPsuynovN+wCw=; b=J6hf5ILWnlqP72f9z71o/YYrJnloJk5k+MiZF8kD4digSUXINLREDItox86AbgQQ4KNZpxs2jb2sIuMcg2ktdmLHX2i/lup/S0zb9wIgXhRVpaR02tmEkUVIgAGEXUkgCcHK7M6CLOC3ZizUBBwHZgYPwR43VfxRiR6Y5b50zZSANW9q6Q/cuZ4MlprR8p9IziFzzjY+oyEUZmEmFtj9O+3Bd/Wc95WPfHagYWVDDVnwq5vyFqNbSmg9bex34ZeZwWYtduL+i+drJ12QYagkk5TKz5JmFetDjK5ATVOTAgceDyaaAY2YYmI5NslfAoLZdsDcSgQRFqzaVNhuL6Qcyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org 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=V+R9at4aF29P5QfuGDKd1QrNyBYntfiPsuynovN+wCw=; b=tO6AO6NE4K6mLkA7bU4ks2PtqqEjZ3zc+ZI2AGo6l0D4h7vlefslsL4K2YaaT2dM3VeMFOr8I0SH5HjfXpGXaXjsBV+bQvw04GhNHutzovJYb51EzFSzZhNk2D/SN5emfa5NJrzue5t1bVUB55LPbnD3GZP4Jn/X+cyom7nIkiBUPeIMcA38mcMZHQpYB8wjjRuFqTO/XoMRi/+tLUEcCXgvTq76u6n6I/n4t+LU++GPAH1hr8iUd+s1jsOtn9fzm2Aojk/m7/oUrWfhB62BvwXtMfJ8M8ysSaRCcCGdul6gdmZ0RinjCdATIrM6mB6m0v5wz4AHrj9ZoDzLRUSUcQ== Received: from DM5PR2201CA0004.namprd22.prod.outlook.com (2603:10b6:4:14::14) by CH2PR12MB4101.namprd12.prod.outlook.com (2603:10b6:610:a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Tue, 19 Oct 2021 10:35:48 +0000 Received: from DM6NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:4:14:cafe::91) by DM5PR2201CA0004.outlook.office365.com (2603:10b6:4:14::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.15 via Frontend Transport; Tue, 19 Oct 2021 10:35:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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.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 DM6NAM11FT017.mail.protection.outlook.com (10.13.172.145) 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 10:35:48 +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; Tue, 19 Oct 2021 10:35:33 +0000 From: Xueming Li To: CC: , Viacheslav Ovsiienko , Lior Margalit , Matan Azrad Date: Tue, 19 Oct 2021 18:34:55 +0800 Message-ID: <20211019103501.2216840-3-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019103501.2216840-1-xuemingl@nvidia.com> References: <20210927083256.337450-1-xuemingl@nvidia.com> <20211019103501.2216840-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91e0b0b9-5b8a-4db4-7b9c-08d992ec36ef X-MS-TrafficTypeDiagnostic: CH2PR12MB4101: 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: aYXMpY6/RMDHtjeHn5kxZb8Siu49ny7y9lMsee5n55Gq0SbM0ghkPix6avT+mNK4tUfaiEyHrQuTDrBEr3XQEW6/hu0QZgvfK9J7hD9pU7WW80aabPQ0OaBtvyry9KdGe2PJlXzuxapJIJnPXhWVnUeLeiuZzVtYSXTthsturYupU/M3TUtxkhyHinwJKi7uNLw0WOXdzi6yEGSnf4XAwS9vHKLi4O0IoXhEt2G5Fjiqg1AubPaKRl5F9eDMNoGBRaEd1m39n6D9waocZE3r1SaT+hbPQZSWD++4iPq/i9iYITekD1w/WRn0TIKMt5jRF2IJKVJEmhmifsBVmDDtpVLiF6I3Xra0Uxul+LY/+HO621oRSBZhwB5nmMJiROCFaqEzDqNRX7wCqE8oNL/v2JAXhSq89kwwIEFsI1igGkdmliFXzmuQbhZxC+OBhXn+fSKuoF2/Ii6rBy3iKsZ+LiZKZcQeJAeH39qniWIQ/Sxn1DmcBCLX9Y7PkwQce9S604gojesKXJ0okDaFGQsFw0ycGdXi3GYT5qvJxhYYbtW9vETj7safqcQ2hNfEO8MOUzfTf8thls6EL2FNXrTqzQ5KTfAwJTTgmayrkF+be9oH/vrkqk78azTjN6bkVMh+QHSQRfOdbuZg93NW+A81wkIg8JbDIUKV47KF9/luua3buJHt4V9ugNMZyTRsoqjiEnK9d0WOXSCGScRfDQwld/QAwS1+2LW1ZfCk0w5fuAw= 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)(36840700001)(46966006)(5660300002)(426003)(8676002)(7636003)(2906002)(26005)(47076005)(8936002)(186003)(316002)(356005)(6286002)(36906005)(16526019)(82310400003)(36860700001)(7696005)(54906003)(2616005)(508600001)(6916009)(1076003)(86362001)(55016002)(336012)(83380400001)(6666004)(107886003)(36756003)(70586007)(70206006)(4326008)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 10:35:48.0158 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91e0b0b9-5b8a-4db4-7b9c-08d992ec36ef 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: DM6NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4101 Subject: [dpdk-dev] [PATCH v3 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 invokes Netlink api to query port state when port number greater than 255. Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_os.c | 46 ++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 3746057673d..f283a3779cc 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,36 @@ 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. */ + err = mlx5_nl_port_state(nl_rdma, + ((struct ibv_device *)spawn->phys_dev)->name, + spawn->phys_port); + if (err < 0) { + DRV_LOG(INFO, "Failed to get netlink port state: %s", + strerror(rte_errno)); + err = -rte_errno; + goto error; + } + port_attr.state = (enum ibv_port_state)err; } 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 +1217,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 +1928,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 +1951,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