From patchwork Fri Sep 23 17:44:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 9348545 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 9BEC1607F2 for ; Fri, 23 Sep 2016 17:44:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 926122AB8A for ; Fri, 23 Sep 2016 17:44:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86C832AD56; Fri, 23 Sep 2016 17:44:56 +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 212552AB8A for ; Fri, 23 Sep 2016 17:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965988AbcIWRow (ORCPT ); Fri, 23 Sep 2016 13:44:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:31522 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965963AbcIWRov (ORCPT ); Fri, 23 Sep 2016 13:44:51 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 23 Sep 2016 10:44:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,382,1470726000"; d="scan'208";a="1061093265" Received: from phlsvsds.ph.intel.com ([10.228.195.38]) by fmsmga002.fm.intel.com with ESMTP; 23 Sep 2016 10:44:50 -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 u8NHinoo013601; Fri, 23 Sep 2016 13:44:49 -0400 Received: (from iweiny@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id u8NHinBc013598; Fri, 23 Sep 2016 13:44:49 -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: Don Hiatt , Dasaratharaman Chandramouli Subject: [RFC PATCH 07/11] IB/mad: Change slid in RMPP recv from 16 to 32 bits Date: Fri, 23 Sep 2016 13:44:30 -0400 Message-Id: <1474652674-13110-8-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: Don Hiatt OPA devices will contain larger lids in the wc.slid which is now 32 bits. This change ensures RMPP handler is able to retrieve the correct lid. Reviewed-by: Ira Weiny Signed-off-by: Dasaratharaman Chandramouli Signed-off-by: Don Hiatt --- drivers/infiniband/core/mad_rmpp.c | 22 ++++++++++++++++++---- include/rdma/ib_addr.h | 12 ++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index 1fc9469b5e66..1cc452c2e03d 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c @@ -33,6 +33,7 @@ */ #include +#include #include "mad_priv.h" #include "mad_rmpp.h" @@ -64,7 +65,7 @@ struct mad_rmpp_recv { __be64 tid; u32 src_qp; - u16 slid; + u32 slid; u8 mgmt_class; u8 class_version; u8 method; @@ -316,7 +317,7 @@ create_rmpp_recv(struct ib_mad_agent_private *agent, mad_hdr = &mad_recv_wc->recv_buf.mad->mad_hdr; rmpp_recv->tid = mad_hdr->tid; rmpp_recv->src_qp = mad_recv_wc->wc->src_qp; - rmpp_recv->slid = (u16)mad_recv_wc->wc->slid; + rmpp_recv->slid = mad_recv_wc->wc->slid; rmpp_recv->mgmt_class = mad_hdr->mgmt_class; rmpp_recv->class_version = mad_hdr->class_version; rmpp_recv->method = mad_hdr->method; @@ -337,7 +338,7 @@ find_rmpp_recv(struct ib_mad_agent_private *agent, list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) { if (rmpp_recv->tid == mad_hdr->tid && rmpp_recv->src_qp == mad_recv_wc->wc->src_qp && - rmpp_recv->slid == (u16)mad_recv_wc->wc->slid && + rmpp_recv->slid == mad_recv_wc->wc->slid && rmpp_recv->mgmt_class == mad_hdr->mgmt_class && rmpp_recv->class_version == mad_hdr->class_version && rmpp_recv->method == mad_hdr->method) @@ -850,11 +851,14 @@ out: static int init_newwin(struct ib_mad_send_wr_private *mad_send_wr) { struct ib_mad_agent_private *agent = mad_send_wr->mad_agent_priv; + struct ib_device *ib_dev = agent->qp_info->port_priv->device; + u8 port = agent->qp_info->port_priv->port_num; struct ib_mad_hdr *mad_hdr = mad_send_wr->send_buf.mad; struct mad_rmpp_recv *rmpp_recv; struct ib_ah_attr ah_attr; unsigned long flags; int newwin = 1; + u32 dlid; if (!(mad_hdr->method & IB_MGMT_METHOD_RESP)) goto out; @@ -870,7 +874,17 @@ static int init_newwin(struct ib_mad_send_wr_private *mad_send_wr) if (ib_query_ah(mad_send_wr->send_buf.ah, &ah_attr)) continue; - if (rmpp_recv->slid == ah_attr.dlid) { + if (rdma_cap_opa_ah(ib_dev, port)) { + if ((ah_attr.ah_flags & IB_AH_GRH) && + (ib_is_opa_gid(&ah_attr.grh.dgid))) + dlid = opa_get_lid_from_gid(&ah_attr.grh.dgid); + else + dlid = OPA_TO_IB_UCAST_LID(ah_attr.dlid); + } else { + dlid = ah_attr.dlid; + } + + if (rmpp_recv->slid == dlid) { newwin = rmpp_recv->repwin; break; } diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index 0d4fa0cdf0ab..fbd532652655 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -347,4 +347,16 @@ static inline bool ib_is_opa_gid(union ib_gid *gid) OPA_STL_OUI); } +/** + * opa_get_lid_from_gid: Returns the last 32 bits of the gid. + * OPA devices use one of the gids in the gid table to also + * store the lid. + * + * @gid: The Global identifier + */ +static inline u32 opa_get_lid_from_gid(union ib_gid *gid) +{ + return be64_to_cpu(gid->global.interface_id) & 0xFFFFFFFF; +} + #endif /* IB_ADDR_H */