From patchwork Mon May 18 09:02:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?U8OpYmFzdGllbiBEdWd1w6k=?= X-Patchwork-Id: 6427201 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 0FF35C0432 for ; Mon, 18 May 2015 09:29:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3804C20611 for ; Mon, 18 May 2015 09:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97FEA2060C for ; Mon, 18 May 2015 09:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753173AbbERJ3J (ORCPT ); Mon, 18 May 2015 05:29:09 -0400 Received: from odin2.bull.net ([129.184.85.11]:48743 "EHLO odin2.bull.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbbERJ3I convert rfc822-to-8bit (ORCPT ); Mon, 18 May 2015 05:29:08 -0400 X-Greylist: delayed 1746 seconds by postgrey-1.27 at vger.kernel.org; Mon, 18 May 2015 05:29:08 EDT Received: from BUMSG3WM.fr.ad.bull.net (bumsg3wm.fr.ad.bull.net [10.192.1.139]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by odin2.bull.net (Bull S.A.) with ESMTP id 527941CC74; Mon, 18 May 2015 10:59:56 +0200 (CEST) Received: from dingo (10.192.1.123) by BUMSG3WM.fr.ad.bull.net (10.192.1.139) with Microsoft SMTP Server (TLS) id 14.3.210.2; Mon, 18 May 2015 10:59:55 +0200 Date: Mon, 18 May 2015 11:02:49 +0200 From: =?UTF-8?B?U8OpYmFzdGllbiBEdWd1w6k=?= To: Eli Cohen CC: linux-rdma , OF EWG Subject: [PATCH] libmlx5: Implement missing open_qp verb Message-ID: <20150518110249.33fb161d@dingo> Organization: BULL X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [10.192.1.123] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY 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 Commit 0c7ac1083831 added XRC support for mlx5, however this is missing the open_qp verb. Signed-off-by: Sébastien Dugué --- src/mlx5.c | 1 + src/mlx5.h | 2 ++ src/verbs.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/mlx5.c b/src/mlx5.c index d02328881992..39f59975d3d2 100644 --- a/src/mlx5.c +++ b/src/mlx5.c @@ -579,6 +579,7 @@ static int mlx5_init_context(struct verbs_device *vdev, context->ibv_ctx.ops = mlx5_ctx_ops; verbs_set_ctx_op(v_ctx, create_qp_ex, mlx5_create_qp_ex); + verbs_set_ctx_op(v_ctx, open_qp, mlx5_open_qp); verbs_set_ctx_op(v_ctx, open_xrcd, mlx5_open_xrcd); verbs_set_ctx_op(v_ctx, close_xrcd, mlx5_close_xrcd); verbs_set_ctx_op(v_ctx, create_srq_ex, mlx5_create_srq_ex); diff --git a/src/mlx5.h b/src/mlx5.h index 6ad79fe324d3..f548e51ee338 100644 --- a/src/mlx5.h +++ b/src/mlx5.h @@ -613,6 +613,8 @@ void *mlx5_get_send_wqe(struct mlx5_qp *qp, int n); int mlx5_copy_to_recv_wqe(struct mlx5_qp *qp, int idx, void *buf, int size); int mlx5_copy_to_send_wqe(struct mlx5_qp *qp, int idx, void *buf, int size); int mlx5_copy_to_recv_srq(struct mlx5_srq *srq, int idx, void *buf, int size); +struct ibv_qp *mlx5_open_qp(struct ibv_context *context, + struct ibv_qp_open_attr *attr); struct ibv_xrcd *mlx5_open_xrcd(struct ibv_context *context, struct ibv_xrcd_init_attr *xrcd_init_attr); int mlx5_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num); diff --git a/src/verbs.c b/src/verbs.c index 8ddf4e631c9f..dc899bce4e00 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -1122,6 +1122,44 @@ int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, return ret; } +struct ibv_qp *mlx5_open_qp(struct ibv_context *context, + struct ibv_qp_open_attr *attr) +{ + struct ibv_open_qp cmd; + struct ibv_create_qp_resp resp; + struct mlx5_qp *qp; + int ret; + struct mlx5_context *ctx = to_mctx(context); + + qp = calloc(1, sizeof(*qp)); + + if (!qp) + return NULL; + + ret = ibv_cmd_open_qp(context, &qp->verbs_qp, sizeof(qp->verbs_qp), + attr, &cmd, sizeof(cmd), &resp, sizeof(resp)); + if (ret) + goto err; + + pthread_mutex_lock(&ctx->qp_table_mutex); + ret = mlx5_store_qp(ctx, qp->verbs_qp.qp.qp_num, qp); + + if (ret) { + pthread_mutex_unlock(&ctx->qp_table_mutex); + fprintf(stderr, "mlx5_store_qp failed ret=%d\n", ret); + goto destroy; + } + pthread_mutex_unlock(&ctx->qp_table_mutex); + + return (struct ibv_qp *)&qp->verbs_qp; + +destroy: + ibv_cmd_destroy_qp(&qp->verbs_qp.qp); +err: + free(qp); + return NULL; +} + struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) { struct mlx5_ah *ah;