From patchwork Sat Aug 17 13:38:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 2845992 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6E5BC9F271 for ; Sat, 17 Aug 2013 14:37:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55F5120221 for ; Sat, 17 Aug 2013 14:37:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 201A62021F for ; Sat, 17 Aug 2013 14:37:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753401Ab3HQOhq (ORCPT ); Sat, 17 Aug 2013 10:37:46 -0400 Received: from smtp2-g21.free.fr ([212.27.42.2]:36216 "EHLO smtp2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753375Ab3HQOhp (ORCPT ); Sat, 17 Aug 2013 10:37:45 -0400 X-Greylist: delayed 3546 seconds by postgrey-1.27 at vger.kernel.org; Sat, 17 Aug 2013 10:37:44 EDT Received: from dworkin.quest-ce.net (unknown [IPv6:2a01:e35:2e9f:6ac0:224:1dff:fe13:dbb2]) by smtp2-g21.free.fr (Postfix) with ESMTP id 157C14B00C1; Sat, 17 Aug 2013 16:37:32 +0200 (CEST) Received: from dworkin.quest-ce.net (localhost [127.0.0.1]) by dworkin.quest-ce.net (8.14.7/8.14.5) with ESMTP id r7HDcViD019774; Sat, 17 Aug 2013 15:38:31 +0200 Received: (from ydroneaud@localhost) by dworkin.quest-ce.net (8.14.7/8.14.7/Submit) id r7HDcVbY019767; Sat, 17 Aug 2013 15:38:31 +0200 From: Yann Droneaud To: Sean Hefty , infinipath@intel.com Cc: linux-rdma@vger.kernel.org, Yann Droneaud Subject: [PATCH librdmacm 2/3] adds rdma_query_qp() function. Date: Sat, 17 Aug 2013 15:38:15 +0200 Message-Id: X-Mailer: git-send-email 1.8.1.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY 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 This patch adds a new function used to retrieve the QP initial parameters and capabilities. This function is especially useful to retrieve information on QP created by rdma_get_request(): its parameters and capabilities might be slightly different from those registered as part of rdma_create_ep(). Signed-off-by: Yann Droneaud --- include/rdma/rdma_cma.h | 16 ++++++++++++++++ src/cma.c | 24 ++++++++++++++++++++++++ src/librdmacm.map | 1 + 3 files changed, 41 insertions(+) diff --git a/include/rdma/rdma_cma.h b/include/rdma/rdma_cma.h index 4c4a057..5b433ab 100644 --- a/include/rdma/rdma_cma.h +++ b/include/rdma/rdma_cma.h @@ -386,6 +386,22 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr); /** + * rdma_query_qp - Query a QP. + * @id: RDMA identifier. + * @qp_init_attr: initial QP attributes. + * Description: + * Query QP init attributes. + * Notes: + * The rdma_cm_id must be bound to QP before calling this function. + * This function should be used to check QP capabilities. + * See also: + * rdma_create_ep, rdma_get_request, rdma_create_qp, ibv_create_qp, + * ibv_query_qp + */ +int rdma_query_qp(struct rdma_cm_id *id, + struct ibv_qp_init_attr *qp_init_attr); + +/** * rdma_destroy_qp - Deallocate a QP. * @id: RDMA identifier. * Description: diff --git a/src/cma.c b/src/cma.c index 374844c..24fd86b 100644 --- a/src/cma.c +++ b/src/cma.c @@ -1265,6 +1265,30 @@ err1: return ret; } +int rdma_query_qp(struct rdma_cm_id *id, + struct ibv_qp_init_attr *qp_init_attr) +{ + struct ibv_qp_attr attr; + int ret; + + memset(&attr, 0, sizeof attr); + memset(qp_init_attr, 0, sizeof *qp_init_attr); + + ret = ibv_query_qp(id->qp, &attr, IBV_QP_CAP, qp_init_attr); + if (ret) + return ERR(ret); + + assert(attr.cap.max_send_wr == qp_init_attr->cap.max_send_wr); + assert(attr.cap.max_recv_wr == qp_init_attr->cap.max_recv_wr); + + assert(attr.cap.max_send_sge == qp_init_attr->cap.max_send_sge); + assert(attr.cap.max_recv_sge == qp_init_attr->cap.max_recv_sge); + + assert(attr.cap.max_inline_data == qp_init_attr->cap.max_inline_data); + + return 0; +} + void rdma_destroy_qp(struct rdma_cm_id *id) { ibv_destroy_qp(id->qp); diff --git a/src/librdmacm.map b/src/librdmacm.map index d5ef736..fd2daef 100644 --- a/src/librdmacm.map +++ b/src/librdmacm.map @@ -8,6 +8,7 @@ RDMACM_1.0 { rdma_resolve_addr; rdma_resolve_route; rdma_create_qp; + rdma_query_qp; rdma_destroy_qp; rdma_connect; rdma_listen;