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 B668EA034F; Sat, 16 Oct 2021 10:08:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5947841102; Sat, 16 Oct 2021 10:08:08 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) by mails.dpdk.org (Postfix) with ESMTP id 78BB54003F for ; Sat, 16 Oct 2021 10:08:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZFbF5xrN5voCoWqEKRiWx6SPPtej85pCM0n9N4+4tJoc2CnItkcWJBK7BpVMz7gXS2FWrjY4aE0QrIGJwj93HIJJiKC1oVzesnC2v6E1tyHPJymlqkAF7+upPJqFXDvfUCw3FH9drC2ijp5Q4kaxjbyHBVpBvHv8LcCmesjBshMWBT2mvujauJRva2ALZvWB+yXz8CwsPqjK2xp0bUPVz/7MOLVXcei4QU00gTtBmwSGndsWz1X1guJmiQqHKE1TQ27W8URRMooFshn1fskqUHr9nNio8M3yg0YXv54oCP6UVwohz7zazRwzRijeccQK+iOdh/xgiWhmrkcOoahmA== 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=EVR9xEt+DAtnw1YYpOil2KCQYR+LHceXOVPVWUMOQYU=; b=lsyBLw81U79Ws90wsxz+Vuxs/LFb3GMdDc/7JQvd1334nzeYxZFP/5qjQ5F5dJQlt3n+7MGPHYMksyyk+m6oiWrTOtXzzAtkuR+7by0Jc/UgDs2m0rBLKQjVaU5eDXGPVQtW78GNn+C083Hx8XJZHkrnmou5iseC97u4T92uxboUn4BYAC9xter20SJLIzuE3nYipN7eBoCTcxPz6SWM4L2Yomt48T3FcEs2wAiK1Wxtjk0La45sHmq+MBJMT2Mn6WICgEunepZSrYQEXq2FzWEWCZ+KRjV1ZYnyA2768IryELq1VWa3GTEP71mWhZeoTpkstPhFAO10VCtnbUkQkA== 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=EVR9xEt+DAtnw1YYpOil2KCQYR+LHceXOVPVWUMOQYU=; b=foNzws61A9Ye+0RxzGIS70alG1L+3+eKjamave/PHO3cLfd+kUY0QdgelYJ7J/ic+EB/TRmV8ptBTFuUFniCDzLU2aOdAZ1moJ7UXvrdTdmgUInurf1BLWAIiPPuXTUtJ6F1ajr/JN1MXv/V3+j0KGjp/B+V65jjFnkI7/FlZo4GMCV2ZHJMysmTr/4jp+yDIvWPePntKC6SkTwseVfiRK7pX8ciXeiD6VnrG0NjMbU7J9e2veIVDheznLcd6cgg1naiYe8XgjILV9h/DjzkCWOYQ5sEp2nLN6FVu/Io+PcsX/X8rowx7aw2PeLjPypKeREaNex+ljFnZ3ND9SuoNg== Received: from MWHPR1201CA0020.namprd12.prod.outlook.com (2603:10b6:301:4a::30) by DM6PR12MB2602.namprd12.prod.outlook.com (2603:10b6:5:4a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25; Sat, 16 Oct 2021 08:08:04 +0000 Received: from CO1NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:301:4a:cafe::6d) by MWHPR1201CA0020.outlook.office365.com (2603:10b6:301:4a::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Sat, 16 Oct 2021 08:08:04 +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 CO1NAM11FT067.mail.protection.outlook.com (10.13.174.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Sat, 16 Oct 2021 08:08:03 +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; Sat, 16 Oct 2021 08:08:01 +0000 From: Xueming Li To: CC: , Viacheslav Ovsiienko , "Lior Margalit" , Matan Azrad Date: Sat, 16 Oct 2021 16:07:26 +0800 Message-ID: <20211016080732.1781622-3-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211016080732.1781622-1-xuemingl@nvidia.com> References: <20210927083256.337450-1-xuemingl@nvidia.com> <20211016080732.1781622-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: 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: 8a384264-d535-44b5-1f10-08d9907c1441 X-MS-TrafficTypeDiagnostic: DM6PR12MB2602: 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: VmwBUWOsYzTTGN2s+cIGhGJglmrxJ85My/gcKwIe/TxZI2F6cKl5nyWnGQ6B5T1JDIzY1jjN7CWIrM3ao35Cb8GtcQzIUR5/0MwWHFrXsYWjrWH72iawVDcNYWms8tDJ0Tr/4qizzu70+JQt4bbjIl6T/fTeYvI2NbIYNHCESEjsMh97EunPByv+njHJ8ByLJg86APr4pDtMJP55np6zI3M1BfdMC6bokv3hmzSTk7XSlD5GAwrGsUTFEJOol4xlv+Hx8tzqpOSj5WyDofNIlGk0jOwAmRqlN0E0WAXvGBl7RrC4JgeuPuyzyLPXHQBFHfPQptzDXkmAKXfPTOVXapanaG0rcfuUCfX0h05Vu5jhHtiwqquJF3FZ91fuKP+sdFFfVPpgqBG0XC/RpYZN0dgxvZN19SmbsWft9qWDRpSrz+Bv/geDmAwmxWTkVKPWQaCBqZFcSgv5/JSOXrKPX+akOW7WhuIlgO6gtj5yO0r4w9BQ0viYb4H9hPwupVRHbKa4eVUhFtyPxhR1rZviKpYOPhT9iBOGg/p/ThcHG3TmCGt28gJEpTlwbIDSXXj8H2W4Uwiy8YBL4C6Eyg9C7HXgpLLWM2IhpuI3GHVF8Fq13Hq/w2b9EVpNR7BQxw/8XUK1R62JJckFsaRYruyMSlpJRyqlSI+lIsK91aLFrQPJNhnKs1BjLa0YzCV/dcunib4SPwj8hd2LNQFNBcvijBVFIuqUKNaEMXbcJA4yri4= 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)(426003)(2616005)(8676002)(6286002)(186003)(7636003)(55016002)(36860700001)(82310400003)(356005)(5660300002)(107886003)(6666004)(336012)(26005)(8936002)(70586007)(7696005)(316002)(54906003)(1076003)(2906002)(86362001)(4326008)(83380400001)(508600001)(6916009)(16526019)(36756003)(36906005)(70206006)(47076005)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2021 08:08:03.7903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a384264-d535-44b5-1f10-08d9907c1441 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: CO1NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2602 Subject: [dpdk-dev] [PATCH v2 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 --- 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