From patchwork Fri Sep 23 17:44:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 9348551 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 924CF607F2 for ; Fri, 23 Sep 2016 17:44:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 891F62AB8A for ; Fri, 23 Sep 2016 17:44:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DEAA2AD56; Fri, 23 Sep 2016 17:44:59 +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.9 required=2.0 tests=BAYES_00,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 23E072AB8A for ; Fri, 23 Sep 2016 17:44:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965874AbcIWRo4 (ORCPT ); Fri, 23 Sep 2016 13:44:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:6972 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965908AbcIWRoy (ORCPT ); Fri, 23 Sep 2016 13:44:54 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 23 Sep 2016 10:44:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,382,1470726000"; d="scan'208";a="12604026" Received: from phlsvsds.ph.intel.com ([10.228.195.38]) by fmsmga005.fm.intel.com with ESMTP; 23 Sep 2016 10:44:52 -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 u8NHiquD013613; Fri, 23 Sep 2016 13:44:52 -0400 Received: (from iweiny@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id u8NHiqOS013610; Fri, 23 Sep 2016 13:44:52 -0400 X-Authentication-Warning: phlsvsds.ph.intel.com: iweiny set sender to ira.weiny@intel.com using -f From: ira.weiny@intel.com To: linux-rdma@vger.kernel.org Cc: Dasaratharaman Chandramouli , Don Hiatt Subject: [RFC PATCH 09/11] IB/IPoIB: Modify ipoib_get_net_dev_by_params to lookup gid table Date: Fri, 23 Sep 2016 13:44:32 -0400 Message-Id: <1474652674-13110-10-git-send-email-ira.weiny@intel.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1474652674-13110-1-git-send-email-ira.weiny@intel.com> References: <1474652674-13110-1-git-send-email-ira.weiny@intel.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 From: Dasaratharaman Chandramouli ipoib_get_net_dev_by_params compares incoming gid with local_gid which is gid at index 0 of the gid table. OPA devices using larger LIDs may have a different GID format than whats setup in the local_gid field. Do a search of the gid table in those cases. Reviewed-by: Ira Weiny Signed-off-by: Dasaratharaman Chandramouli Signed-off-by: Don Hiatt --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 2bcde9822e3a..76da1430b415 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -328,6 +328,40 @@ out: return result; } +/* retuns true if the incoming gid is assigned to the IPoIB + * netdev interface + * + * OPA devices may have the incoming GID in the OPA GID + * format which might not necessarily be assigned to the + * netdev interface. This necessitates searching the GID + * table to match this OPA GID. + */ +static bool ipoib_check_gid(struct ipoib_dev_priv *priv, + const union ib_gid *gid) +{ + bool is_local_gid; + struct ib_port_attr attr; + union ib_gid port_gid; + int i; + + if (!gid) + return true; + + is_local_gid = !memcmp(gid, &priv->local_gid, sizeof(*gid)); + + if (!rdma_cap_opa_ah(priv->ca, priv->port) || is_local_gid) + return is_local_gid; + + if (ib_query_port(priv->ca, priv->port, &attr)) + return false; + for (i = 1; i < attr.gid_tbl_len; i++) { + if (ib_query_gid(priv->ca, priv->port, i, &port_gid, NULL)) + return false; + if (!memcmp(gid, &port_gid, sizeof(*gid))) + return true; + } + return false; +} /* returns the number of IPoIB netdevs on top a given ipoib device matching a * pkey_index and address, if one exists. * @@ -344,8 +378,7 @@ static int ipoib_match_gid_pkey_addr(struct ipoib_dev_priv *priv, struct net_device *net_dev = NULL; int matches = 0; - if (priv->pkey_index == pkey_index && - (!gid || !memcmp(gid, &priv->local_gid, sizeof(*gid)))) { + if (priv->pkey_index == pkey_index && ipoib_check_gid(priv, gid)) { if (!addr) { net_dev = ipoib_get_master_net_dev(priv->dev); } else {