From patchwork Mon Apr 13 12:35:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6208311 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 622C0BF4A6 for ; Mon, 13 Apr 2015 12:36:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6AFBD2035B for ; Mon, 13 Apr 2015 12:36:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EAE9202E9 for ; Mon, 13 Apr 2015 12:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754127AbbDMMgR (ORCPT ); Mon, 13 Apr 2015 08:36:17 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:33340 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754121AbbDMMfl (ORCPT ); Mon, 13 Apr 2015 08:35:41 -0400 Received: by wgin8 with SMTP id n8so78995866wgi.0 for ; Mon, 13 Apr 2015 05:35:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=siUiBZmJCP80Otew7DW9KWw3V5wR2TiOuhhtNN+P/WI=; b=dEm98BiBl+w5uJJZObKwtIxryz3nSfOYa9zw/zsI+NJySZlBXrDrTuhMsBj6+cKLrH C1AF0ZRes+rvzB7JgwXyQyHu6Sax+sJwqpgL25t5GK8FbvIi31uNLWkYY56BTIXIaoBU /21tYjDo73wK4rniMOd10l9aosHivo0rf20P0JhoAC48aGJ0Rois7kfaYdnULFBZ0CW1 LqZjUKZWQo/1BmTeDR8ZEjmU9z9k6EDpPe9GRSg55dLLBrtl5LjOMLu0UTNcWw7BQUek 9L3oUk32M78BPByFr12VXlYfIguc3C9Oys27xNCU1yQuSov9n7UrqegQM7IgNFnh3yTe gaDQ== X-Gm-Message-State: ALoCoQlqkubhJMp+v7LoxBxO19lu7zL9it9FyHXzhCKjO0FKUx2/06NlZVoj/enElOGWYxPVDe3H X-Received: by 10.194.61.12 with SMTP id l12mr27450669wjr.139.1428928540727; Mon, 13 Apr 2015 05:35:40 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id ng5sm11307098wic.24.2015.04.13.05.35.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 05:35:39 -0700 (PDT) Message-ID: <552BB81A.4020104@profitbricks.com> Date: Mon, 13 Apr 2015 14:35:38 +0200 From: Michael Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Roland Dreier , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org CC: Tom Tucker , Steve Wise , Hoang-Nam Nguyen , Christoph Raisch , Mike Marciniszyn , Eli Cohen , Faisal Latif , Jack Morgenstein , Or Gerlitz , Haggai Eran , Ira Weiny , Tom Talpey , Jason Gunthorpe , Doug Ledford , Michael Wang Subject: [PATCH v3 26/28] IB/Verbs: Use management helper cap_eth_ah() References: <552BB470.4090407@profitbricks.com> In-Reply-To: <552BB470.4090407@profitbricks.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_BLACK 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 Introduce helper cap_eth_ah() to help us check if the port of an IB device support Ethernet Address Handler. Cc: Steve Wise Cc: Tom Talpey Cc: Jason Gunthorpe Cc: Doug Ledford Cc: Ira Weiny Cc: Sean Hefty Signed-off-by: Michael Wang --- drivers/infiniband/core/cma.c | 6 +++--- drivers/infiniband/core/sa_query.c | 2 +- drivers/infiniband/core/verbs.c | 2 +- include/rdma/ib_verbs.h | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 7f5815d..4b083f5 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -733,10 +733,10 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv, int ret; u16 pkey; - if (rdma_tech_ib(id_priv->id.device, id_priv->id.port_num)) - pkey = ib_addr_get_pkey(dev_addr); - else + if (cap_eth_ah(id_priv->id.device, id_priv->id.port_num)) pkey = 0xffff; + else + pkey = ib_addr_get_pkey(dev_addr); ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num, pkey, &qp_attr->pkey_index); diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index fc7e161..409ec4e 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num, ah_attr->port_num = port_num; ah_attr->static_rate = rec->rate; - force_grh = rdma_tech_iboe(device, port_num); + force_grh = cap_eth_ah(device, port_num); if (rec->hop_limit > 1 || force_grh) { ah_attr->ah_flags = IB_AH_GRH; diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 6b5fd9d..2e0c2cf1 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -202,7 +202,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc, int ret; memset(ah_attr, 0, sizeof *ah_attr); - if (rdma_tech_iboe(device, port_num)) { + if (cap_eth_ah(device, port_num)) { if (!(wc->wc_flags & IB_WC_GRH)) return -EPROTOTYPE; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index dfe33f3..78a5cdb2 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1894,6 +1894,21 @@ static inline int cap_af_ib(struct ib_device *device, u8 port_num) } /** + * cap_eth_ah - Check if the port of device has the capability + * Ethernet Address Handler. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return 0 when port of the device don't support + * Ethernet Address Handler. + */ +static inline int cap_eth_ah(struct ib_device *device, u8 port_num) +{ + return rdma_tech_iboe(device, port_num); +} + +/** * cap_read_multi_sge - Check if the port of device has the capability * RDMA Read Multiple Scatter-Gather Entries. *