From patchwork Sun Nov 15 12:30:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 7618881 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 C502AC05CA for ; Sun, 15 Nov 2015 12:33:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA163205B9 for ; Sun, 15 Nov 2015 12:33:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB386205EB for ; Sun, 15 Nov 2015 12:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751242AbbKOMdh (ORCPT ); Sun, 15 Nov 2015 07:33:37 -0500 Received: from [193.47.165.129] ([193.47.165.129]:48564 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751272AbbKOMd0 (ORCPT ); Sun, 15 Nov 2015 07:33:26 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from matanb@mellanox.com) with ESMTPS (AES256-SHA encrypted); 15 Nov 2015 14:32:51 +0200 Received: from rsws33.mtr.labs.mlnx (dev-r-vrt-064.mtr.labs.mlnx [10.212.64.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id tAFCWo61019038; Sun, 15 Nov 2015 14:32:51 +0200 From: Matan Barak To: Eli Cohen Cc: linux-rdma@vger.kernel.org, Doug Ledford , Matan Barak , Eran Ben Elisha , Christoph Lameter Subject: [PATCH libmlx5 4/7] Add ibv_create_cq_ex support Date: Sun, 15 Nov 2015 14:30:31 +0200 Message-Id: <1447590634-12858-5-git-send-email-matanb@mellanox.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1447590634-12858-1-git-send-email-matanb@mellanox.com> References: <1447590634-12858-1-git-send-email-matanb@mellanox.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=-7.5 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 In order to create a CQ which supports timestamp, the user needs to specify the timestamp flag for ibv_create_cq_ex. Adding support for ibv_create_cq_ex in the mlx5's vendor library. Signed-off-by: Matan Barak --- src/mlx5.c | 1 + src/mlx5.h | 2 ++ src/verbs.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/mlx5.c b/src/mlx5.c index eac332b..229d99d 100644 --- a/src/mlx5.c +++ b/src/mlx5.c @@ -664,6 +664,7 @@ static int mlx5_init_context(struct verbs_device *vdev, verbs_set_ctx_op(v_ctx, create_srq_ex, mlx5_create_srq_ex); verbs_set_ctx_op(v_ctx, get_srq_num, mlx5_get_srq_num); verbs_set_ctx_op(v_ctx, query_device_ex, mlx5_query_device_ex); + verbs_set_ctx_op(v_ctx, create_cq_ex, mlx5_create_cq_ex); if (context->cqe_version && context->cqe_version == 1) verbs_set_ctx_op(v_ctx, poll_cq_ex, mlx5_poll_cq_v1_ex); else diff --git a/src/mlx5.h b/src/mlx5.h index e27e79c..66dc4a9 100644 --- a/src/mlx5.h +++ b/src/mlx5.h @@ -608,6 +608,8 @@ int mlx5_dereg_mr(struct ibv_mr *mr); struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, struct ibv_comp_channel *channel, int comp_vector); +struct ibv_cq *mlx5_create_cq_ex(struct ibv_context *context, + struct ibv_create_cq_attr_ex *cq_attr); int mlx5_poll_cq_ex(struct ibv_cq *ibcq, struct ibv_wc_ex *wc, struct ibv_poll_cq_ex_attr *attr); int mlx5_poll_cq_v1_ex(struct ibv_cq *ibcq, struct ibv_wc_ex *wc, diff --git a/src/verbs.c b/src/verbs.c index 4c054f1..76885f3 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -240,9 +240,21 @@ static int qp_sig_enabled(void) return 0; } -struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, - struct ibv_comp_channel *channel, - int comp_vector) +enum { + CREATE_CQ_SUPPORTED_WC_FLAGS = IBV_WC_STANDARD_FLAGS | + IBV_WC_EX_WITH_COMPLETION_TIMESTAMP +}; + +enum { + CREATE_CQ_SUPPORTED_COMP_MASK = IBV_CREATE_CQ_ATTR_FLAGS +}; + +enum { + CREATE_CQ_SUPPORTED_FLAGS = IBV_CREATE_CQ_ATTR_COMPLETION_TIMESTAMP +}; + +static struct ibv_cq *create_cq(struct ibv_context *context, + const struct ibv_create_cq_attr_ex *cq_attr) { struct mlx5_create_cq cmd; struct mlx5_create_cq_resp resp; @@ -254,12 +266,31 @@ struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, FILE *fp = to_mctx(context)->dbg_fp; #endif - if (!cqe) { + if (!cq_attr->cqe) { + mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); + errno = EINVAL; + return NULL; + } + + if (cq_attr->comp_mask & ~CREATE_CQ_SUPPORTED_COMP_MASK) { + mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); + errno = EINVAL; + return NULL; + } + + if (cq_attr->comp_mask & IBV_CREATE_CQ_ATTR_FLAGS && + cq_attr->flags & ~CREATE_CQ_SUPPORTED_FLAGS) { mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); errno = EINVAL; return NULL; } + if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS) { + mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); + errno = ENOTSUP; + return NULL; + } + cq = calloc(1, sizeof *cq); if (!cq) { mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); @@ -273,14 +304,14 @@ struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, goto err; /* The additional entry is required for resize CQ */ - if (cqe <= 0) { + if (cq_attr->cqe <= 0) { mlx5_dbg(fp, MLX5_DBG_CQ, "\n"); errno = EINVAL; goto err_spl; } - ncqe = align_queue_size(cqe + 1); - if ((ncqe > (1 << 24)) || (ncqe < (cqe + 1))) { + ncqe = align_queue_size(cq_attr->cqe + 1); + if ((ncqe > (1 << 24)) || (ncqe < (cq_attr->cqe + 1))) { mlx5_dbg(fp, MLX5_DBG_CQ, "ncqe %d\n", ncqe); errno = EINVAL; goto err_spl; @@ -313,7 +344,8 @@ struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, cmd.db_addr = (uintptr_t) cq->dbrec; cmd.cqe_size = cqe_sz; - ret = ibv_cmd_create_cq(context, ncqe - 1, channel, comp_vector, + ret = ibv_cmd_create_cq(context, ncqe - 1, cq_attr->channel, + cq_attr->comp_vector, &cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd, &resp.ibv_resp, sizeof resp); if (ret) { @@ -328,6 +360,9 @@ struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, cq->stall_adaptive_enable = to_mctx(context)->stall_adaptive_enable; cq->stall_cycles = to_mctx(context)->stall_cycles; + cq->wc_flags = cq_attr->wc_flags; + cq->poll_one = mlx5_poll_one_ex; + return &cq->ibv_cq; err_db: @@ -345,6 +380,23 @@ err: return NULL; } +struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe, + struct ibv_comp_channel *channel, + int comp_vector) +{ + struct ibv_create_cq_attr_ex cq_attr = {.cqe = cqe, .channel = channel, + .comp_vector = comp_vector, + .wc_flags = IBV_WC_STANDARD_FLAGS}; + + return create_cq(context, &cq_attr); +} + +struct ibv_cq *mlx5_create_cq_ex(struct ibv_context *context, + struct ibv_create_cq_attr_ex *cq_attr) +{ + return create_cq(context, cq_attr); +} + int mlx5_resize_cq(struct ibv_cq *ibcq, int cqe) { struct mlx5_cq *cq = to_mcq(ibcq);