Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2977371pxf; Sun, 4 Apr 2021 22:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT/rXHtj2Rl7Sm0WZ3PLdkfipLWGjF9zyPWS0g+4sNtLlY+jaCN2Eb3VkdO1B/1og+Oc6u X-Received: by 2002:a05:6e02:214d:: with SMTP id d13mr19451662ilv.136.1617601935129; Sun, 04 Apr 2021 22:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617601935; cv=none; d=google.com; s=arc-20160816; b=Nlytz9wBO55KKGbf2aCf0IWE1SltLl/umnUsd755YWpnY0Q0weSFwBD8jIgfWxKOCQ MeOFKdKXwJAICwfl36U/ArG0WOB9i3IDELH0uqialuWSuO0xcCTS4RzoTBfHro0cY23J FcH+By47Po8nfAmBWkLtNKwiJNX57z//oPBXebVaOePRJvHSTyEELJPP/po+E21WESd7 1AQoV9HtcnxsMHCX+2bmjAJP8FdH2KLGB9FEoyKFykOoK1x/t6UImEasvI24+oTVlEyk bFnNIszB1MfMWecBF+kLybgm1caJ+HVoEhoY1loXI9lxCy4kz5pZHPGXsHo+ubpCG+pT XTeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XHGJHi5/MQI9bL9eLEssTsoO15Zlb1rlGWHUeHtGiTU=; b=XH9Z2SORBKQiQTW/GovzVGs3IXqUY6DReVW72sN8LksLSY2chYYPN9iZ4csBueehB2 ggXjpNDSzoWEjSTnvTuMDJ00FkgtlVmWW7y2QPx4Tb06DpZNFnaipXWyb06wOInvzvb0 ok77fP8UUOML1ojHXZILEROEQkXmXtBCsonH6x5MH6aglRDcEixDubMguuxcvHrvfoX0 ojccd8jmCjqX2bmc/PPUtVFF+udfbOLuneSi0wMIosSv/VRvqmOB/yTejC4wk+gxjDP1 3MFPKsseE8rLPqJfXc2NFmNnn+2owfqJAbvaDbtgIXvrLSnVyUMZv0hdAMH/UfIykkPl sAyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mi3dfg3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si14927826ili.57.2021.04.04.22.52.03; Sun, 04 Apr 2021 22:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mi3dfg3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbhDEFuW (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.30.2