From patchwork Mon Apr 13 12:32:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6208951 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 C3C40BF4A6 for ; Mon, 13 Apr 2015 12:46:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B01C6202D1 for ; Mon, 13 Apr 2015 12:46:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 672C7202F8 for ; Mon, 13 Apr 2015 12:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932599AbbDMMqN (ORCPT ); Mon, 13 Apr 2015 08:46:13 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:35343 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754268AbbDMMcN (ORCPT ); Mon, 13 Apr 2015 08:32:13 -0400 Received: by widdi4 with SMTP id di4so70249381wid.0 for ; Mon, 13 Apr 2015 05:32:12 -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=3SzCAhQn92au+18Wm6ZAwP1gI7WB5HkLDdqYgiy3nTw=; b=beEV8jEdMs0QfrO7XnY/K/pYSlaCCPA2D4eg9lgnY/SvXAnUEvAKkqkIYB6DZtMFRP vpNM7HLQHesSVNBw+g2pAyI1xn20hxGIpbxS0kT1RyKxT/7uEOgkt73O+yhAyapmtVPI ORp/Zvc34uK0DBvpdzl2oxjs+N93Mx28S4J7RP9bBpd7ObnB30UzOLPVwRwSTSFh+9iU nL9vpe3he6PRQw2ESApvB4u4g7nR2pkyhtgpPh86C5EAD4OQPe+qWE2vaw04IdJKpGXD W8yN4jFw+EeUOcjgKjCd4LgSaF33McTpvaXesPlJYx6CGcH+j1NY/AoKi9IO07e9m+qE 9Crg== X-Gm-Message-State: ALoCoQkcepv+SoKemsWP53idDDsWeGmOYWKHcxc+Gkl3rHtmHZAzgvCProOj2BWld9LpaTCCpbmZ X-Received: by 10.180.73.111 with SMTP id k15mr21149699wiv.34.1428928332032; Mon, 13 Apr 2015 05:32:12 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id dj5sm11314966wjb.28.2015.04.13.05.32.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 05:32:11 -0700 (PDT) Message-ID: <552BB749.1030102@profitbricks.com> Date: Mon, 13 Apr 2015 14:32:09 +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 19/28] IB/Verbs: Use management helper cap_iw_cm() 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=ham 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_iw_cm() to help us check if the port of an IB device support IWARP Communication Manager. 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 | 17 ++++++++--------- include/rdma/ib_verbs.h | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index ccd319a..4f4a420 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -776,8 +776,7 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr, if (qp_attr->qp_state == IB_QPS_RTR) qp_attr->rq_psn = id_priv->seq_num; - } else if (rdma_tech_iwarp(id_priv->id.device, - id_priv->id.port_num)) { + } else if (cap_iw_cm(id_priv->id.device, id_priv->id.port_num)) { if (!id_priv->cm_id.iw) { qp_attr->qp_access_flags = 0; *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS; @@ -1059,8 +1058,8 @@ void rdma_destroy_id(struct rdma_cm_id *id) if (cap_ib_cm(id_priv->id.device, id_priv->id.port_num)) { if (id_priv->cm_id.ib) ib_destroy_cm_id(id_priv->cm_id.ib); - } else if (rdma_tech_iwarp(id_priv->id.device, - id_priv->id.port_num)) { + } else if (cap_iw_cm(id_priv->id.device, + id_priv->id.port_num)) { if (id_priv->cm_id.iw) iw_destroy_cm_id(id_priv->cm_id.iw); } @@ -2545,7 +2544,7 @@ int rdma_listen(struct rdma_cm_id *id, int backlog) ret = cma_ib_listen(id_priv); if (ret) goto err; - } else if (rdma_tech_iwarp(id->device, id->port_num)) { + } else if (cap_iw_cm(id->device, id->port_num)) { ret = cma_iw_listen(id_priv, backlog); if (ret) goto err; @@ -2890,7 +2889,7 @@ int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) ret = cma_resolve_ib_udp(id_priv, conn_param); else ret = cma_connect_ib(id_priv, conn_param); - } else if (rdma_tech_iwarp(id->device, id->port_num)) + } else if (cap_iw_cm(id->device, id->port_num)) ret = cma_connect_iw(id_priv, conn_param); else ret = -ENOSYS; @@ -3012,7 +3011,7 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) else ret = cma_rep_recv(id_priv); } - } else if (rdma_tech_iwarp(id->device, id->port_num)) + } else if (cap_iw_cm(id->device, id->port_num)) ret = cma_accept_iw(id_priv, conn_param); else ret = -ENOSYS; @@ -3067,7 +3066,7 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data, ret = ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED, NULL, 0, private_data, private_data_len); - } else if (rdma_tech_iwarp(id->device, id->port_num)) { + } else if (cap_iw_cm(id->device, id->port_num)) { ret = iw_cm_reject(id_priv->cm_id.iw, private_data, private_data_len); } else @@ -3093,7 +3092,7 @@ int rdma_disconnect(struct rdma_cm_id *id) /* Initiate or respond to a disconnect. */ if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0); - } else if (rdma_tech_iwarp(id->device, id->port_num)) { + } else if (cap_iw_cm(id->device, id->port_num)) { ret = iw_cm_disconnect(id_priv->cm_id.iw, 0); } else ret = -EINVAL; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 6805e3e..e4999f6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device *device, u8 port_num) return rdma_ib_or_iboe(device, port_num); } +/** + * cap_iw_cm - Check if the port of device has the capability IWARP + * Communication Manager. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return 0 when port of the device don't support IWARP + * Communication Manager. + */ +static inline int cap_iw_cm(struct ib_device *device, u8 port_num) +{ + return rdma_tech_iwarp(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);