From patchwork Sun Jan 6 09:23:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gal Pressman X-Patchwork-Id: 10749485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 712946C5 for ; Sun, 6 Jan 2019 09:23:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EE02858B for ; Sun, 6 Jan 2019 09:23:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53D312859F; Sun, 6 Jan 2019 09:23:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E16D92858B for ; Sun, 6 Jan 2019 09:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfAFJXr (ORCPT ); Sun, 6 Jan 2019 04:23:47 -0500 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:5244 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbfAFJXr (ORCPT ); Sun, 6 Jan 2019 04:23:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1546766626; x=1578302626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=eRaufqBBlXNdWMwLiiHEO09EwJtkBKwFgw2yzxv5ILw=; b=snqWHA+ATWgt98Ml/ecO4Syreaf8+Ae3/rcWPTVGNdKUKd/uUsaw1zfR jjG0XCmSopmjbEBs146clMDGq5/QDUmXYdNPYYTBD+/e9yIgxMKnbAckj k6W68hmwPHuUa6PbDjQJO4bvmqWWJqi7B0QIi01U7dkRlI8kowR/RMHv6 s=; X-IronPort-AV: E=Sophos;i="5.56,253,1539648000"; d="scan'208";a="651603704" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Jan 2019 09:23:43 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-67b371d8.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x069NcLt063904 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Sun, 6 Jan 2019 09:23:42 GMT Received: from EX13D04UWB003.ant.amazon.com (10.43.161.231) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 6 Jan 2019 09:23:42 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D04UWB003.ant.amazon.com (10.43.161.231) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 6 Jan 2019 09:23:42 +0000 Received: from galpress-VirtualBox.amazon.com (10.218.62.26) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Sun, 6 Jan 2019 09:23:39 +0000 From: Gal Pressman To: Jason Gunthorpe , Doug Ledford CC: , Alexander Matushevsky , Yossi Leybovich , Dave Goodell , "Brian Barrett" , Leah Shalev , Sean Hefty , Sagi Grimberg , Leon Romanovsky , Gal Pressman Subject: [PATCH RFC v2 1/2] RDMA: Add indication for in kernel API support to IB device Date: Sun, 6 Jan 2019 11:23:02 +0200 Message-ID: <1546766583-27979-2-git-send-email-galpress@amazon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546766583-27979-1-git-send-email-galpress@amazon.com> References: <1546766583-27979-1-git-send-email-galpress@amazon.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drivers that do not provide kernel verbs support should not be used by ib kernel clients and fail. In case a device does not implement all mandatory verbs for kverbs usage mark it as a non kverbs provider and prevent its usage for all clients except for uverbs. The device is marked as a non kverbs provider using the 'kverbs_provider' flag which should only be set by the core code. The clients can choose whether kverbs are requested for it usage using the 'no_kverbs_req' flag which is currently set for uverbs only. This patch allows drivers to remove mandatory verbs stubs and simply set the callback to NULL. The IB device will be registered as a non-kverbs provider. Signed-off-by: Gal Pressman Reviewed-by: Leon Romanovsky --- drivers/infiniband/core/device.c | 12 ++++++++---- drivers/infiniband/core/uverbs_main.c | 1 + include/rdma/ib_verbs.h | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 47ab34ee1a9d..6c1f71007ec4 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -121,13 +121,15 @@ static int ib_device_check_mandatory(struct ib_device *device) }; int i; + device->kverbs_provider = true; for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) { if (!*(void **) ((void *) &device->ops + mandatory_table[i].offset)) { dev_warn(&device->dev, - "Device is missing mandatory function %s\n", + "Device is missing mandatory function %s, disabling kverbs support\n", mandatory_table[i].name); - return -EINVAL; + device->kverbs_provider = false; + break; } } @@ -624,7 +626,8 @@ int ib_register_device(struct ib_device *device, const char *name, list_for_each_entry(client, &client_list, list) if (!add_client_context(device, client) && client->add) - client->add(device); + if (device->kverbs_provider || client->no_kverbs_req) + client->add(device); down_write(&lists_rwsem); list_add_tail(&device->core_list, &device_list); @@ -721,7 +724,8 @@ int ib_register_client(struct ib_client *client) list_for_each_entry(device, &device_list, core_list) if (!add_client_context(device, client) && client->add) - client->add(device); + if (device->kverbs_provider || client->no_kverbs_req) + client->add(device); down_write(&lists_rwsem); list_add_tail(&client->list, &client_list); diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 9f9172eb1512..f0cef5693414 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -1128,6 +1128,7 @@ static const struct file_operations uverbs_mmap_fops = { static struct ib_client uverbs_client = { .name = "uverbs", + .no_kverbs_req = true, .add = ib_uverbs_add_one, .remove = ib_uverbs_remove_one }; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a3ceed3a040a..6ac5b7c3dddc 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2561,6 +2561,8 @@ struct ib_device { __be64 node_guid; u32 local_dma_lkey; u16 is_switch:1; + /* Indicates kernel verbs support, should not be used in drivers */ + u8 kverbs_provider:1; u8 node_type; u8 phys_port_cnt; struct ib_device_attr attrs; @@ -2615,6 +2617,9 @@ struct ib_client { const struct sockaddr *addr, void *client_data); struct list_head list; + + /* kverbs are not required by the device */ + u8 no_kverbs_req:1; }; struct ib_device *ib_alloc_device(size_t size);