From patchwork Thu Mar 19 17:28:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wan, Kaike" X-Patchwork-Id: 6051641 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 59DBF9F440 for ; Thu, 19 Mar 2015 17:29:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 94AA3204FC for ; Thu, 19 Mar 2015 17:29:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A0232051D for ; Thu, 19 Mar 2015 17:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030229AbbCSR2z (ORCPT ); Thu, 19 Mar 2015 13:28:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:49202 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755915AbbCSR2x (ORCPT ); Thu, 19 Mar 2015 13:28:53 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 19 Mar 2015 10:28:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,430,1422950400"; d="scan'208";a="543336599" Received: from phlsvsds.ph.intel.com ([10.228.195.38]) by orsmga003.jf.intel.com with ESMTP; 19 Mar 2015 10:28:44 -0700 Received: from phlsvsds.ph.intel.com (localhost.localdomain [127.0.0.1]) by phlsvsds.ph.intel.com (8.13.8/8.13.8) with ESMTP id t2JHShB2024287; Thu, 19 Mar 2015 13:28:43 -0400 Received: (from kaikewan@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id t2JHShRo024284; Thu, 19 Mar 2015 13:28:43 -0400 X-Authentication-Warning: phlsvsds.ph.intel.com: kaikewan set sender to kaike.wan@intel.com using -f From: kaike.wan@intel.com To: sean.hefty@intel.com Cc: linux-rdma@vger.kernel.org, Kaike Wan Subject: [PATCH 1/1] ibacm: Use pkey 0xffff or 0x7fff for SA query Date: Thu, 19 Mar 2015 13:28:37 -0400 Message-Id: <1426786117-24257-1-git-send-email-kaike.wan@intel.com> X-Mailer: git-send-email 1.7.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kaike Wan Currently, ibacm uses the first pkey on the local port to query SA. More appropriately, it should use either 0xffff or 0x7fff for SA query. However, if the local port is not configured with either pkey, ibacm will continue to use the first pkey. Signed-off-by: Kaike Wan --- src/acm.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/src/acm.c b/src/acm.c index 815a916..7649725 100644 --- a/src/acm.c +++ b/src/acm.c @@ -106,6 +106,7 @@ struct acmc_port { union ibv_gid *gid_tbl; uint16_t lid; uint16_t lid_mask; + int default_pkey_index; }; struct acmc_device { @@ -1844,6 +1845,7 @@ static void acm_port_up(struct acmc_port *port) uint16_t pkey; int i, ret; struct acmc_prov_context *dev_ctx; + int index = -1; acm_log(1, "%s %d\n", port->dev->device.verbs->device->name, port->port.port_num); @@ -1889,6 +1891,25 @@ static void acm_port_up(struct acmc_port *port) goto err1; } + /* Determine the default pkey first. + Order of preference: 0xffff, 0x7fff, first pkey + */ + for (i = 0; i < attr.pkey_tbl_len; i++) { + ret = ibv_query_pkey(port->dev->device.verbs, + port->port.port_num, i, &pkey); + if (ret) + continue; + pkey = ntohs(pkey); + if (pkey == 0xffff) { + index = i; + break; + } + else if (pkey == 0x7fff) { + index = i; + } + } + port->default_pkey_index = index < 0 ? 0: index; + for (i = 0; i < attr.pkey_tbl_len; i++) { ret = ibv_query_pkey(port->dev->device.verbs, port->port.port_num, i, &pkey); @@ -2397,7 +2418,7 @@ int acm_send_sa_mad(struct acm_sa_mad *mad) mad->umad.addr.qkey = port->sa_addr.qkey; mad->umad.addr.lid = htons(port->sa_addr.lid); mad->umad.addr.sl = port->sa_addr.sl; - // TODO: mad->umad.addr.pkey_index = req->ep->?; + mad->umad.addr.pkey_index = req->ep->port->default_pkey_index; lock_acquire(&port->lock); if (port->sa_credits && DListEmpty(&port->sa_wait)) {