From patchwork Mon Apr 5 05:49:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 416368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37A8AC43460 for ; Mon, 5 Apr 2021 05:50:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB4D561395 for ; Mon, 5 Apr 2021 05:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232086AbhDEFuW (ORCPT ); Mon, 5 Apr 2021 01:50:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232078AbhDEFuV (ORCPT ); Mon, 5 Apr 2021 01:50:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ECC0A6138A; Mon, 5 Apr 2021 05:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601815; bh=OZcrC5GanjfRIBMiqGHldB7KHYyxXozI8j3d7T22USc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mi3dfg3at4/ueREeId3jg7bTAy/4OXL1XBmR9UH001oVmWDFY8KoNBkRoWlTR8Dx/ zHryp2NxJGbOPHv2uvxSwTXG2LIx2oop0vngtomkWjljR2ADN3sOthTu8bYalDEXSk jWhO6eqOzd5P5JlBNEtn5CbxWW56Y7jaREo0AgW3sGasikYwtia1fQUIuDq9vHP4wI Wltdboz7BB2mUeogc0dTNFtkfC6s8VOw8+cRbPjByJXPD0Xcj69LVZ3/CuXXG9UpEP 7nptGF1rYPcCt6/dj1sU/Ysa2bOANGNInQRP4el2NdanyOvhl1FwX+KpQmkyims/sN CcuTKY03/Kxmw== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 1/8] RDMA/core: Check if client supports IB device or not Date: Mon, 5 Apr 2021 08:49:53 +0300 Message-Id: <20210405055000.215792-2-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit RDMA devices are of different transport(iWarp, IB, RoCE) and have different attributes. Not all clients are interested in all type of devices. Implement a generic callback that each IB client can implement to decide if client add() or remove() should be done by the IB core or not for a given IB device, client combination. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/device.c | 3 +++ include/rdma/ib_verbs.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index c660cef66ac6..c9af2deba8c1 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -691,6 +691,9 @@ static int add_client_context(struct ib_device *device, if (!device->kverbs_provider && !client->no_kverbs_req) return 0; + if (client->is_supported && !client->is_supported(device)) + return 0; + down_write(&device->client_data_rwsem); /* * So long as the client is registered hold both the client and device diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 59138174affa..777fbcbd4858 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2756,6 +2756,15 @@ struct ib_client { const union ib_gid *gid, const struct sockaddr *addr, void *client_data); + /* + * Returns if the client is supported for a given device or not. + * @dev: An RDMA device to check if client can support this RDMA or not. + * + * A client that is interested in specific device attributes, should + * implement it to check if client can be supported for this device or + * not. + */ + bool (*is_supported)(struct ib_device *dev); refcount_t uses; struct completion uses_zero; From patchwork Mon Apr 5 05:49:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 416369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50ECC43461 for ; Mon, 5 Apr 2021 05:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2ACF61399 for ; Mon, 5 Apr 2021 05:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232049AbhDEFuP (ORCPT ); Mon, 5 Apr 2021 01:50:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:34180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbhDEFuO (ORCPT ); Mon, 5 Apr 2021 01:50:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 42EA761399; Mon, 5 Apr 2021 05:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601808; bh=F5IJVEwD/ds8nR2UWRrmKXAI11023OkVeObLtcX5Os8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NODekafGzp5kSojCg+hpr6B9AlQvD3zKz1kSQUnnab6bpFEEOrBv7H4HhlV/xDoFY TqFAkD/p2pVLkh3I28NPd/1jujvuwkWrGbTce9KKjJN/16uPujucZoym8KBnN1wLlc QKvVKGhzBkFZWDuJHsCWo1j2ZxDkXtxY53SB2B/tPDIPN7O8ZOy0WgPKkTKjRH+lQW C07RwZj1T/8gB8IjoV1gkCqJobugEN3Ocv/6PIomvbhVfoWbJP1831Zr9n3Xnb6wdM v7QgnCVGlTYCiSGHb7jlz3Xm72ANX8GWg/U5Rafawy+7PiQVcdMJ8O/EQs4ePWufCD EjCIRobdjqIrA== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 2/8] RDMA/cma: Skip device which doesn't support CM Date: Mon, 5 Apr 2021 08:49:54 +0300 Message-Id: <20210405055000.215792-3-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit A switchdev RDMA device do not support IB CM. When such device is added to the RDMA CM's device list, when application invokes rdma_listen(), cma attempts to listen to such device, however it has IB CM attribute disabled. Due to this, rdma_listen() call fails to listen for other non switchdev devices as well. A below error message can be seen. infiniband mlx5_0: RDMA CMA: cma_listen_on_dev, error -38 A failing call flow is below. rdma_listen() cma_listen_on_all() cma_listen_on_dev() _cma_attach_to_dev() rdma_listen() <- fails on a specific switchdev device Hence, when a IB device doesn't support IB CM or IW CM, avoid adding such device to the cma list. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/cma.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 42a1c8955c50..80156faf90de 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -157,11 +157,13 @@ EXPORT_SYMBOL(rdma_res_to_id); static int cma_add_one(struct ib_device *device); static void cma_remove_one(struct ib_device *device, void *client_data); +static bool cma_supported(struct ib_device *device); static struct ib_client cma_client = { .name = "cma", .add = cma_add_one, - .remove = cma_remove_one + .remove = cma_remove_one, + .is_supported = cma_supported, }; static struct ib_sa_client sa_client; @@ -4870,6 +4872,17 @@ static void cma_process_remove(struct cma_device *cma_dev) wait_for_completion(&cma_dev->comp); } +static bool cma_supported(struct ib_device *device) +{ + u32 i; + + rdma_for_each_port(device, i) { + if (rdma_cap_ib_cm(device, i) || rdma_cap_iw_cm(device, i)) + return true; + } + return false; +} + static int cma_add_one(struct ib_device *device) { struct rdma_id_private *to_destroy; From patchwork Mon Apr 5 05:49:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 415556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94E2CC43461 for ; Mon, 5 Apr 2021 05:50:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6248661395 for ; Mon, 5 Apr 2021 05:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbhDEFuU (ORCPT ); Mon, 5 Apr 2021 01:50:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:34270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232054AbhDEFuR (ORCPT ); Mon, 5 Apr 2021 01:50:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B1EC6138A; Mon, 5 Apr 2021 05:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601812; bh=PsROXfLh1PLcHMlKcwD6/kCYX1+1tHQ0rQ8neODxlfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0FAGW+541Z00Z1bI3RulQKM/s0QIS0cuSGHw/14luvghB1iYsKox5jHVeR1lI2bi qB8vcBK6/3Ar8Sw+el7Ed++NRSbD7E6Dvj2WyIDsk/MwiajX+53FRf3CoSRAMuBEc/ gV2jo1Feyzz62ybr0BgEgJv0VCleevlXrMyoXNhM0OkeraAc/46NOy6FUne8F9Uxpv qsHUphlPdcetw+nuSI1hAfevmQqpJ2jjoGd7B1S7aIbgvoQL9Iy3lVjqo3vHhfJSc/ KQg6VNmC9Mu0bb5GBqMzu+ELRy9e+ZmNhu6kKmOG04nX6prLNp8qOyJr0m1rUUP6tO I0eqv0aGIrOkw== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 3/8] IB/cm: Skip device which doesn't support IB CM Date: Mon, 5 Apr 2021 08:49:55 +0300 Message-Id: <20210405055000.215792-4-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit There are at least 3 types of RDMA devices which do not support IB CM. They are (1) A (eswitch) switchdev RDMA device, (2) iWARP device and (3) RDMA device without a RoCE capability Hence, avoid IB CM initialization for such devices. This saves 8Kbytes of memory for eswitch device consist of 512 ports and also avoids unnecessary initialization for all above 3 types of devices. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/cm.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 8a7791ebae69..5025f2c1347b 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -87,6 +87,7 @@ struct cm_id_private; struct cm_work; static int cm_add_one(struct ib_device *device); static void cm_remove_one(struct ib_device *device, void *client_data); +static bool cm_supported(struct ib_device *device); static void cm_process_work(struct cm_id_private *cm_id_priv, struct cm_work *work); static int cm_send_sidr_rep_locked(struct cm_id_private *cm_id_priv, @@ -103,7 +104,8 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv, static struct ib_client cm_client = { .name = "cm", .add = cm_add_one, - .remove = cm_remove_one + .remove = cm_remove_one, + .is_supported = cm_supported, }; static struct ib_cm { @@ -4371,6 +4373,17 @@ static void cm_remove_port_fs(struct cm_port *port) } +static bool cm_supported(struct ib_device *device) +{ + u32 i; + + rdma_for_each_port(device, i) { + if (rdma_cap_ib_cm(device, i)) + return true; + } + return false; +} + static int cm_add_one(struct ib_device *ib_device) { struct cm_device *cm_dev; From patchwork Mon Apr 5 05:49:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 416366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B236C43461 for ; Mon, 5 Apr 2021 05:50:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08E6E61399 for ; Mon, 5 Apr 2021 05:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbhDEFuk (ORCPT ); Mon, 5 Apr 2021 01:50:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:34688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232224AbhDEFue (ORCPT ); Mon, 5 Apr 2021 01:50:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9546061395; Mon, 5 Apr 2021 05:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601829; bh=OYi5oBfh+IkfxEpEvlyTxj1HUBFhA7hXBFWPylWIYsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHFr6cbp8xiOxYDsxElx2f7O7Ptj8Ct/tjaxo5V/6e9cALtKZuUkVoqFEGJedk4WS Kx7up2/a2QcbAfJj1MDAKg7p6nfhS4o+sL0khFkJ75Pj0D8GvA4VSrMeA84kzxYq6+ ciUfTpG1BKIXZ9JACRrAnjgT1lEidobeE0O36OF0DFx8GkwDn2H6CJYKNoBvkV24rM YT6hHscu+FiA0fO/6aPja/Vx5sw1K7Ja6a+OXOliz1AfR8rZkE0hwV5WsvfZugBm8H 1TQjrjKBOTZZXQT+6eCpF71cbOp+gwTs7DuI79vCkT6dO6SdCTh8ksbb1ae1haUJHl q2hC/gSz/SehA== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 4/8] IB/core: Skip device which doesn't have necessary capabilities Date: Mon, 5 Apr 2021 08:49:56 +0300 Message-Id: <20210405055000.215792-5-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit If device doesn't have multicast capability, avoid client registration for it. This saves 16Kbytes of memory for a RDMA device consist of 128 ports. If device doesn't support subnet administration, avoid client registration for it. This saves 8Kbytes of memory for a RDMA device consist of 128 ports. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/multicast.c | 15 ++++++++++++++- drivers/infiniband/core/sa_query.c | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index a5dd4b7a74bc..8c81acc24e3e 100644 --- a/drivers/infiniband/core/multicast.c +++ b/drivers/infiniband/core/multicast.c @@ -44,11 +44,13 @@ static int mcast_add_one(struct ib_device *device); static void mcast_remove_one(struct ib_device *device, void *client_data); +static bool mcast_client_supported(struct ib_device *device); static struct ib_client mcast_client = { .name = "ib_multicast", .add = mcast_add_one, - .remove = mcast_remove_one + .remove = mcast_remove_one, + .is_supported = mcast_client_supported, }; static struct ib_sa_client sa_client; @@ -816,6 +818,17 @@ static void mcast_event_handler(struct ib_event_handler *handler, } } +static bool mcast_client_supported(struct ib_device *device) +{ + u32 i; + + rdma_for_each_port(device, i) { + if (rdma_cap_ib_mcast(device, i)) + return true; + } + return false; +} + static int mcast_add_one(struct ib_device *device) { struct mcast_device *dev; diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 9a4a49c37922..7e00e24d9423 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -176,11 +176,13 @@ static const struct nla_policy ib_nl_policy[LS_NLA_TYPE_MAX] = { static int ib_sa_add_one(struct ib_device *device); static void ib_sa_remove_one(struct ib_device *device, void *client_data); +static bool ib_sa_client_supported(struct ib_device *device); static struct ib_client sa_client = { .name = "sa", .add = ib_sa_add_one, - .remove = ib_sa_remove_one + .remove = ib_sa_remove_one, + .is_supported = ib_sa_client_supported, }; static DEFINE_XARRAY_FLAGS(queries, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ); @@ -2293,6 +2295,17 @@ static void ib_sa_event(struct ib_event_handler *handler, } } +static bool ib_sa_client_supported(struct ib_device *device) +{ + unsigned int i; + + rdma_for_each_port(device, i) { + if (rdma_cap_ib_sa(device, i)) + return true; + } + return false; +} + static int ib_sa_add_one(struct ib_device *device) { struct ib_sa_device *sa_dev; From patchwork Mon Apr 5 05:49:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 415555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60711C43460 for ; Mon, 5 Apr 2021 05:50:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2800661399 for ; Mon, 5 Apr 2021 05:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbhDEFu1 (ORCPT ); Mon, 5 Apr 2021 01:50:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232096AbhDEFuY (ORCPT ); Mon, 5 Apr 2021 01:50:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6483661393; Mon, 5 Apr 2021 05:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601819; bh=546fGdgC8SELgOTgK16DtIQhtdQvE38vpzuMVIP5F1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ox73jiWftd/wanyKh8k00x9xX3j7k39NF4uvD1Ak6tQOV9KfBK+BZH8T1mUf5n+wR FJ2Nt4BbDlzYiGIz9mbnli/SEUh4JHAU2ASpED1/ocjPHChDnajmT22NXFM9WYbYL0 w6Y4/xDB0Ty2VQo+g7a1gTiRiJ8eiOEKZIoKekwZji7Ybxg71daCG4POi2fX7h8NLW rIE2SfTJ7P3BXWivrnxPnUazMZaNSsnW6z8pntprtryMyAP3Z19uBYmQQzaFFNoW7R 1pLFUV+S/50/gWtt+xdi2CC1PeSZQnlyH9XO1TrkK5n5S+q8mykPwUgQVw1gdTnioZ xeeSImH3O2VcA== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 5/8] IB/IPoIB: Skip device which doesn't have InfiniBand port Date: Mon, 5 Apr 2021 08:49:57 +0300 Message-Id: <20210405055000.215792-6-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit Skip RDMA device which doesn't have InfiniBand ports using newly introduced client_supported() callback. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 8f769ebaacc6..b02c10dea242 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -93,6 +93,7 @@ static struct net_device *ipoib_get_net_dev_by_params( struct ib_device *dev, u32 port, u16 pkey, const union ib_gid *gid, const struct sockaddr *addr, void *client_data); +static bool ipoib_client_supported(struct ib_device *device); static int ipoib_set_mac(struct net_device *dev, void *addr); static int ipoib_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); @@ -102,6 +103,7 @@ static struct ib_client ipoib_client = { .add = ipoib_add_one, .remove = ipoib_remove_one, .get_net_dev_by_params = ipoib_get_net_dev_by_params, + .is_supported = ipoib_client_supported, }; #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG @@ -2530,6 +2532,17 @@ static struct net_device *ipoib_add_port(const char *format, return ERR_PTR(-ENOMEM); } +static bool ipoib_client_supported(struct ib_device *device) +{ + u32 i; + + rdma_for_each_port(device, i) { + if (rdma_protocol_ib(device, i)) + return true; + } + return false; +} + static int ipoib_add_one(struct ib_device *device) { struct list_head *dev_list; From patchwork Mon Apr 5 05:49:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 416367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4DFAC43462 for ; Mon, 5 Apr 2021 05:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 811C061395 for ; Mon, 5 Apr 2021 05:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbhDEFua (ORCPT ); Mon, 5 Apr 2021 01:50:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:34500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbhDEFu2 (ORCPT ); Mon, 5 Apr 2021 01:50:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B823B6138A; Mon, 5 Apr 2021 05:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601822; bh=ZX6nMrTjbVRTF1HIZ1FsEV+ThojL4OW20xRXaCnWaVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rtNlK/zpqXVFmqJNkjBVG1/n2H61wpYEGMcLmjuJ+NKNQml0wJ7YOIthbbkZa2qRV BBhLKACy0SZ0gAPrYjjZOXQj33NyknO5tktvAf4Q8IEmGEacZGQXUz39GayNo+5ZVH wF2OmwOcxk/htZYzTAGJX8qvlja3+JxmBj3aEIZWPFEhB9WsTj32FV+oPrCfR9CKP4 FsEyJ0jgTOEohy+ovR/86YxtHe16s/yHFYMEiKAP6j/n3c/klRzJkQ4N3N0TciDaCH ksbTt0rZI+qwn4DljChW3yGeP7m14USIkfK3eKKR2r/eIEyUtBAi1cU0/HWVWLjumu DDR6MP8Sa7sew== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 6/8] IB/opa_vnic: Move to client_supported callback Date: Mon, 5 Apr 2021 08:49:58 +0300 Message-Id: <20210405055000.215792-7-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit Move to newly introduced client_supported callback Avoid client registration using newly introduced helper callback if the IB device doesn't have OPA VNIC capability. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c b/drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c index cecf0f7cadf9..58658eba97dd 100644 --- a/drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c +++ b/drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c @@ -121,6 +121,7 @@ static struct ib_client opa_vnic_client = { .name = opa_vnic_driver_name, .add = opa_vnic_vema_add_one, .remove = opa_vnic_vema_rem_one, + .is_supported = rdma_cap_opa_vnic, }; /** @@ -993,9 +994,6 @@ static int opa_vnic_vema_add_one(struct ib_device *device) struct opa_vnic_ctrl_port *cport; int rc, size = sizeof(*cport); - if (!rdma_cap_opa_vnic(device)) - return -EOPNOTSUPP; - size += device->phys_port_cnt * sizeof(struct opa_vnic_vema_port); cport = kzalloc(size, GFP_KERNEL); if (!cport) From patchwork Mon Apr 5 05:49:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 415554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51750C433ED for ; Mon, 5 Apr 2021 05:50:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C2FD6138A for ; Mon, 5 Apr 2021 05:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232215AbhDEFue (ORCPT ); Mon, 5 Apr 2021 01:50:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:34588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbhDEFub (ORCPT ); Mon, 5 Apr 2021 01:50:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A28A6138A; Mon, 5 Apr 2021 05:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601825; bh=rtcMcUL397sY/syxPEZjzfWCRFmVIU4Faf5zTlLK6L0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yhpy+5QmDVh1oxOKBVc9OjoRKKEF5l5jFNKO2B57otK0z0i680Jz7N92YtGNZBOd6 7S7Q/9UJv1AxU8fQ5/0U8qyi9Jn2BuAB2+SQcmNyV72/Twt3woLd2DXVGtijgC1Kwo 4tesDNu1hEwgN64PYFdTykUpxEqzJFf9cE0nNzvoK4fEAsve8lZhCJs1GQT7Rw8KW2 /fVQ/6wOKF97hqIcWnLVC7JcpCEyxV9rjW73srjbuhnnq5vAq/kNuH0+jWoDOY16CQ I9VqKAnIi1ex3J9jVtKwxflEHqCLPOtk8f1alhZSADrkFYllOq0Z0kjjuqXrfHDf2W yO25ShUdCHODg== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 7/8] net/smc: Move to client_supported callback Date: Mon, 5 Apr 2021 08:49:59 +0300 Message-Id: <20210405055000.215792-8-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit Use newly introduced client_supported() callback to avoid client additional if the RDMA device is not of IB type. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- net/smc/smc_ib.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index 6b65c5d1f957..f7186d9d1299 100644 --- a/net/smc/smc_ib.c +++ b/net/smc/smc_ib.c @@ -767,6 +767,11 @@ void smc_ib_ndev_change(struct net_device *ndev, unsigned long event) mutex_unlock(&smc_ib_devices.mutex); } +static bool smc_client_supported(struct ib_device *ibdev) +{ + return ibdev->node_type == RDMA_NODE_IB_CA; +} + /* callback function for ib_register_client() */ static int smc_ib_add_dev(struct ib_device *ibdev) { @@ -774,9 +779,6 @@ static int smc_ib_add_dev(struct ib_device *ibdev) u8 port_cnt; int i; - if (ibdev->node_type != RDMA_NODE_IB_CA) - return -EOPNOTSUPP; - smcibdev = kzalloc(sizeof(*smcibdev), GFP_KERNEL); if (!smcibdev) return -ENOMEM; @@ -840,6 +842,7 @@ static struct ib_client smc_ib_client = { .name = "smc_ib", .add = smc_ib_add_dev, .remove = smc_ib_remove_dev, + .is_supported = smc_client_supported, }; int __init smc_ib_register_client(void) From patchwork Mon Apr 5 05:50:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 415553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE364C43461 for ; Mon, 5 Apr 2021 05:50:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B1046138A for ; Mon, 5 Apr 2021 05:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232278AbhDEFuo (ORCPT ); Mon, 5 Apr 2021 01:50:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:34774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232255AbhDEFui (ORCPT ); Mon, 5 Apr 2021 01:50:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8D1E61393; Mon, 5 Apr 2021 05:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617601832; bh=aLTaImJggynKE0fFKmCwvZD8aLmzRiT3oFV9D4hqRH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SBEl2X9GiSm4UPtHzNNkC4LUzQNdfuB635NeE5hgeOA3mPdYwbgUyhCU6yJd9KUzc VfgQVLZORn20ZxtS98o4tzuUl0E/VQwxgJFPITucrHLeQJVQ3FkPnECqG4iD3MfNTi 3eK4gPXB16QStM+0heMrBy+wrOZLHwt2BU4xxnhTIJE3ZOgue1LozQ236iBnz5Kbx4 t44Kz+mpwFSYuIK7dFJQGuUsT1f7R+54ASJ25x6DwanfrpRVP6PS03yZ64EO9VOFyr Q5SRb+5La0oxL5Xic6JHxQ3Z3oZS5xPFGyMhqa+UbpDfatKeUNGjmuhQ3yDlmdeToL qOe6+InnDm3jQ== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Parav Pandit , "David S. Miller" , Dennis Dalessandro , Jakub Kicinski , Karsten Graul , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Mike Marciniszyn , netdev@vger.kernel.org, rds-devel@oss.oracle.com, Santosh Shilimkar Subject: [PATCH rdma-next 8/8] net/rds: Move to client_supported callback Date: Mon, 5 Apr 2021 08:50:00 +0300 Message-Id: <20210405055000.215792-9-leon@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210405055000.215792-1-leon@kernel.org> References: <20210405055000.215792-1-leon@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit Use newly introduced client_supported() callback to avoid client additional if the RDMA device is not of IB type or if it doesn't support device memory extensions. Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky --- net/rds/ib.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/net/rds/ib.c b/net/rds/ib.c index 24c9a9005a6f..bd2ff7d5a718 100644 --- a/net/rds/ib.c +++ b/net/rds/ib.c @@ -125,18 +125,23 @@ void rds_ib_dev_put(struct rds_ib_device *rds_ibdev) queue_work(rds_wq, &rds_ibdev->free_work); } -static int rds_ib_add_one(struct ib_device *device) +static bool rds_client_supported(struct ib_device *device) { - struct rds_ib_device *rds_ibdev; - int ret; - /* Only handle IB (no iWARP) devices */ if (device->node_type != RDMA_NODE_IB_CA) - return -EOPNOTSUPP; + return false; /* Device must support FRWR */ if (!(device->attrs.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) - return -EOPNOTSUPP; + return false; + + return true; +} + +static int rds_ib_add_one(struct ib_device *device) +{ + struct rds_ib_device *rds_ibdev; + int ret; rds_ibdev = kzalloc_node(sizeof(struct rds_ib_device), GFP_KERNEL, ibdev_to_node(device)); @@ -288,7 +293,8 @@ static void rds_ib_remove_one(struct ib_device *device, void *client_data) struct ib_client rds_ib_client = { .name = "rds_ib", .add = rds_ib_add_one, - .remove = rds_ib_remove_one + .remove = rds_ib_remove_one, + .is_supported = rds_client_supported, }; static int rds_ib_conn_info_visitor(struct rds_connection *conn,