From patchwork Thu Mar 29 12:20:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10315331 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 13D916055B for ; Thu, 29 Mar 2018 12:21:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F098D2A333 for ; Thu, 29 Mar 2018 12:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E590F2A335; Thu, 29 Mar 2018 12:21:13 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY 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 8BA8B2A333 for ; Thu, 29 Mar 2018 12:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751207AbeC2MVM (ORCPT ); Thu, 29 Mar 2018 08:21:12 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36216 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbeC2MVM (ORCPT ); Thu, 29 Mar 2018 08:21:12 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2TCGKjt083917; Thu, 29 Mar 2018 12:21:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=La2g8xXTfkhY1kTEGocLFo1wtIu9/fXnx46eIPzbBGg=; b=Q7Bmzlsl5rNmhZfLv0I2FGL+A343LWvuxLm6Aeo/qEb/DnnUoy46tZ8rU/Z9XHfMsFzX HiG4T8l8DOiKoN53RNNRY91OxRc4DQ2TsOAoGrX6Ej7AlxBJXbZDiNH0MoYh2kpUL94l F2VfUpoUUTlsup8F5jM2CCZDfKd/fOaG6bxq4aeuIhjmU8OQx1yc4Q6Vbklp2M05h6qc 8CdKbW/ZtiOELIz5SknhItOjK9sbk8bPXYQbM0Abn92SV+reQeX8A75fKcEDui8iB4ZX adDkNs4DUy1RWqi3CELgWbA5uZ2P6pRzmm0AtjKsmql2nTs+ccYvwSnJF2ohsFTRLxx8 vA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2h100k80py-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 12:21:05 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2TCL4Mc006178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 12:21:04 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2TCKxCA015449; Thu, 29 Mar 2018 12:21:04 GMT Received: from yuvallap.nl.oracle.com (/10.175.35.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 29 Mar 2018 05:20:58 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH v2 1/1] librdmacm: Return errno on create_qp failure Date: Thu, 29 Mar 2018 15:20:45 +0300 Message-Id: <20180329122045.5049-2-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180329122045.5049-1-yuval.shaia@oracle.com> References: <20180329122045.5049-1-yuval.shaia@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8846 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803290129 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 Upon QP creation failure provider's create_qp function sets errno with error code and return NULL to caller. Let's return this errno to caller to reflect the exact reason for the error. Signed-off-by: Yuval Shaia --- librdmacm/cma.c | 4 +++- librdmacm/cma.h | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/librdmacm/cma.c b/librdmacm/cma.c index fa370650..9920eaba 100644 --- a/librdmacm/cma.c +++ b/librdmacm/cma.c @@ -1367,9 +1367,11 @@ int rdma_create_qp_ex(struct rdma_cm_id *id, attr->recv_cq = id->recv_cq; if (id->srq && !attr->srq) attr->srq = id->srq; + + errno = 0; qp = ibv_create_qp_ex(id->verbs, attr); if (!qp) { - ret = ERR(ENOMEM); + ret = CHK_ERRNO("ibv_create_qp_ex"); goto err1; } diff --git a/librdmacm/cma.h b/librdmacm/cma.h index 62821055..c2dc4865 100644 --- a/librdmacm/cma.h +++ b/librdmacm/cma.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -92,6 +93,13 @@ static inline int ERR(int err) return -1; } +static inline int CHK_ERRNO(const char *funcname) +{ + if (!errno) + fprintf(stderr, "Function %s did not set errno\n", funcname); + return -1; +} + int ucma_init(void); extern int af_ib_support;