From patchwork Thu Oct 20 22:40:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Wise X-Patchwork-Id: 9387699 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 7711A607D0 for ; Thu, 20 Oct 2016 22:44:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E60429CBF for ; Thu, 20 Oct 2016 22:44:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5333E29CD0; Thu, 20 Oct 2016 22:44:16 +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 EB77B29CBF for ; Thu, 20 Oct 2016 22:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754790AbcJTWoP (ORCPT ); Thu, 20 Oct 2016 18:44:15 -0400 Received: from smtp.opengridcomputing.com ([72.48.136.20]:36755 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754285AbcJTWoO (ORCPT ); Thu, 20 Oct 2016 18:44:14 -0400 Received: from smtp.ogc.us (build2.ogc.int [10.10.0.32]) by smtp.opengridcomputing.com (Postfix) with ESMTP id 44B3629ECA; Thu, 20 Oct 2016 17:44:14 -0500 (CDT) Received: by smtp.ogc.us (Postfix, from userid 503) id 35576E0C53; Thu, 20 Oct 2016 17:44:14 -0500 (CDT) Message-Id: In-Reply-To: References: From: Steve Wise Date: Thu, 20 Oct 2016 15:40:26 -0700 Subject: [PATCH RFC v2 2/3] rdma_cm: add rdma_consumer_reject() helper function To: dledford@redhat.com, sean.hefty@intel.com Cc: linux-rdma@vger.kernel.org, bart.vanassche@sandisk.com, linux-nvme@lists.infradead.org, sagig@grimberg.me, hch@lst.de, axboe@fb.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 Return true if the peer consumer application rejected the connection attempt. Signed-off-by: Steve Wise --- drivers/infiniband/core/cma.c | 13 +++++++++++++ include/rdma/ib_cm.h | 9 +++++++++ include/rdma/iw_cm.h | 9 +++++++++ include/rdma/rdma_cm.h | 6 ++++++ 4 files changed, 37 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 7cc7346..4ec16a3 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -114,6 +114,19 @@ const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id, } EXPORT_SYMBOL(rdma_reject_msg); +bool rdma_consumer_reject(struct rdma_cm_id *id, int reason) +{ + if (rdma_ib_or_roce(id->device, id->port_num)) + return ib_consumer_reject(reason); + + if (rdma_protocol_iwarp(id->device, id->port_num)) + return iw_consumer_reject(reason); + + /* FIXME should we WARN_ONCE() here? */ + return false; +} +EXPORT_SYMBOL(rdma_consumer_reject); + static void cma_add_one(struct ib_device *device); static void cma_remove_one(struct ib_device *device, void *client_data); diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h index af193b7..5595529 100644 --- a/include/rdma/ib_cm.h +++ b/include/rdma/ib_cm.h @@ -609,4 +609,13 @@ int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, */ const char *__attribute_const__ ib_reject_msg(int reason); +/** + * ib_consumer_reject - return true if the user rejected the connection. + * @reason: Value returned in the REJECT event status field. + */ +static inline bool ib_consumer_reject(int reason) +{ + return reason == IB_CM_REJ_CONSUMER_DEFINED; +}; + #endif /* IB_CM_H */ diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h index 15b437e..1e5bd33 100644 --- a/include/rdma/iw_cm.h +++ b/include/rdma/iw_cm.h @@ -259,4 +259,13 @@ int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr, */ const char *__attribute_const__ iw_reject_msg(int reason); +/** + * iw_consumer_reject - return true if the consumer rejected the connection. + * @reason: Value returned in the REJECT event status field. + */ +static inline bool iw_consumer_reject(int reason) +{ + return reason == -ECONNREFUSED; +} + #endif /* IW_CM_H */ diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h index 712a70c..058dfbb 100644 --- a/include/rdma/rdma_cm.h +++ b/include/rdma/rdma_cm.h @@ -395,5 +395,11 @@ __be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr); */ const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id, int reason); +/** + * rdma_consumer_reject - return true if the consumer rejected the connection. + * @id: Communication identifier that received the REJECT event + * @reason: Value returned in the REJECT event status field. + */ +bool rdma_consumer_reject(struct rdma_cm_id *id, int reason); #endif /* RDMA_CM_H */