From patchwork Mon Jul 23 16:48:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10540603 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 A641BA636 for ; Mon, 23 Jul 2018 16:48:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E3B28C9A for ; Mon, 23 Jul 2018 16:48:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B2A428C64; Mon, 23 Jul 2018 16:48:20 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 3746E28CC0 for ; Mon, 23 Jul 2018 16:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388283AbeGWRuX (ORCPT ); Mon, 23 Jul 2018 13:50:23 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:54919 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388722AbeGWRuV (ORCPT ); Mon, 23 Jul 2018 13:50:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1532364497; x=1563900497; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=3eL6oXWpWaNsV23feK5rZK4A5ffGpe3ks77K71vDajI=; b=X4tt2o/v9OES63zwMPMpCiLVoRIIMxauGDTPvGVUw03X+obcwN89wu93 R8TTTgeu0IOe9a5QXIP6xy3Lh6QX+h/o6yUe9sq6m64bm/Tk7l/SrWgL3 CMwbDbxMlmH18Q/2UbQtr02LtRahDIJH61ij7gw+jK+VkznDOB3LZtBZn 9huwYabC93pVoStpoJ0UxFx6u6dUI8FnAOstqS+iXxtVGaIbMLZOF7rxS OphE5AHqWMf8JrxLyb8daUKe3/yfnyR1pdeqnRybnxPqhnahI7wk+lvjo Pxi6U5neVQ9tjFIpzlfLfFGWwGLneG+JHt3WyGbgNXMAPxk5CNcAfrFIW A==; X-IronPort-AV: E=Sophos;i="5.51,393,1526313600"; d="scan'208";a="88094276" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Jul 2018 00:48:16 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 23 Jul 2018 09:36:26 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Jul 2018 09:48:17 -0700 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Daniel Ahlin , Bart Van Assche Subject: [PATCH 3/5] srp_daemon: Use ibv_query_pkey() Date: Mon, 23 Jul 2018 09:48:13 -0700 Message-Id: <20180723164815.26448-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723164815.26448-1-bart.vanassche@wdc.com> References: <20180723164815.26448-1-bart.vanassche@wdc.com> 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 patch does not change any functionality. Signed-off-by: Bart Van Assche --- srp_daemon/srp_daemon.c | 11 +++-------- srp_daemon/srp_daemon.h | 1 + 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c index 08d1134dca7d..9be37f3ced1d 100644 --- a/srp_daemon/srp_daemon.c +++ b/srp_daemon/srp_daemon.c @@ -796,15 +796,9 @@ static int check_sm_cap(struct umad_resources *umad_res, int *mask_match) int pkey_index_to_pkey(struct umad_resources *umad_res, int pkey_index, uint16_t *pkey) { - char pkey_file[18], pkey_str[16]; - - /* Read pkey */ - snprintf(pkey_file, sizeof(pkey_file), "pkeys/%d", pkey_index); - if (srpd_sys_read_string(umad_res->port_sysfs_path, pkey_file, - pkey_str, sizeof(pkey_str)) < 0) + if (ibv_query_pkey(umad_res->ib_ctx, config->port_num, pkey_index, + pkey) < 0) return -1; - - *pkey = strtoul(pkey_str, NULL, 0); if (*pkey) pr_debug("discover Targets for P_key %04x (index %d)\n", *pkey, pkey_index); @@ -1934,6 +1928,7 @@ static struct resources *alloc_res(void) if (ret) goto err; res->res.ud_res = &res->ud_res; + res->umad_res.ib_ctx = res->ud_res.ib_ctx; ret = sync_resources_init(&res->sync_res); if (ret) diff --git a/srp_daemon/srp_daemon.h b/srp_daemon/srp_daemon.h index b29beb3f2d6a..dcc848aa6ed5 100644 --- a/srp_daemon/srp_daemon.h +++ b/srp_daemon/srp_daemon.h @@ -234,6 +234,7 @@ struct ud_resources { }; struct umad_resources { + struct ibv_context *ib_ctx; int portid; int agent; char *port_sysfs_path;