From patchwork Tue Sep 19 21:18:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9960361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74EFA6038F for ; Tue, 19 Sep 2017 21:33:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6893C28EF7 for ; Tue, 19 Sep 2017 21:33:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D73128EF9; Tue, 19 Sep 2017 21:33:33 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D441728EF7 for ; Tue, 19 Sep 2017 21:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbdISVdb (ORCPT ); Tue, 19 Sep 2017 17:33:31 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:59870 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751394AbdISVdb (ORCPT ); Tue, 19 Sep 2017 17:33:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=QulqmWP7UPAQ2Up4fO7uQfnb1sMSiyaB/Z3CrCIfnlo=; b=5E7Q8a9c0wyA7QpomeHpPqxfCZhtsXUZSR1MvzzPVjlnttl15BAxmCk0sxWCtcGiSvuv3VGlgF3frjz9KPsx126drnIn7W4H44l9C+Ni2UPwQ5bVpQ+mmkCtV41hh85sRw/ea+TgZV/15Yz6dXuvJC1ziBugHD20EVTKduWz63Y=; Received: from [10.0.0.156] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1duPvN-0000On-07; Tue, 19 Sep 2017 15:19:21 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Moni Shoua Subject: [PATCH rdma-core 10/10] rxe: Use VERBS_NAME_MATCH to match the rxe device Date: Tue, 19 Sep 2017 15:18:51 -0600 Message-Id: <1505855931-4956-11-git-send-email-jgunthorpe@obsidianresearch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505855931-4956-1-git-send-email-jgunthorpe@obsidianresearch.com> References: <1505855931-4956-1-git-send-email-jgunthorpe@obsidianresearch.com> X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.156 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 This is a placeholder, it obviously cannot work this way once we add rdma device renaming. A synthetic modalias is produced that contains the device name, and the existing modalias framework is used to match it. Signed-off-by: Jason Gunthorpe --- providers/rxe/rxe.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c index d9857aac70d745..683ffaa2a8af9c 100644 --- a/providers/rxe/rxe.c +++ b/providers/rxe/rxe.c @@ -57,6 +57,12 @@ #include "rxe-abi.h" #include "rxe.h" +static const struct verbs_match_ent hca_table[] = { + /* FIXME: rxe needs a more reliable way to detect the rxe device */ + VERBS_NAME_MATCH("rxe", NULL), + {}, +}; + static int rxe_query_device(struct ibv_context *context, struct ibv_device_attr *attr) { @@ -893,22 +899,6 @@ static void rxe_uninit_device(struct verbs_device *verbs_device) free(dev); } -static bool rxe_device_match(struct verbs_sysfs_dev *sysfs_dev) -{ - const char *uverbs_sys_path = sysfs_dev->sysfs_path; - char value[16]; - - /* make sure it is a rxe device */ - if (ibv_read_sysfs_file(uverbs_sys_path, "ibdev", - value, sizeof(value)) < 0) - return false; - - if (strncmp(value, "rxe", 3)) - return false; - - return true; -} - static struct verbs_device *rxe_device_alloc(struct verbs_sysfs_dev *sysfs_dev) { struct rxe_device *dev; @@ -925,7 +915,7 @@ static const struct verbs_device_ops rxe_dev_ops = { .name = "rxe", .match_min_abi_version = 0, .match_max_abi_version = INT_MAX, - .match_device = rxe_device_match, + .match_table = hca_table, .alloc_device = rxe_device_alloc, .uninit_device = rxe_uninit_device, .alloc_context = rxe_alloc_context,