From patchwork Sun Nov 12 21:41:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10055005 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 20A7160586 for ; Sun, 12 Nov 2017 23:40:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12611292C7 for ; Sun, 12 Nov 2017 23:40:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0742B292CC; Sun, 12 Nov 2017 23:40:58 +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, 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 9C9D5292C7 for ; Sun, 12 Nov 2017 23:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751052AbdKLXkz (ORCPT ); Sun, 12 Nov 2017 18:40:55 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58354 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751376AbdKLXkh (ORCPT ); Sun, 12 Nov 2017 18:40:37 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Nov 2017 23:42:05 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id vACLg5Fc010466; Sun, 12 Nov 2017 23:42:05 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id vACLg5ai006998; Sun, 12 Nov 2017 23:42:05 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id vACLg5kh006997; Sun, 12 Nov 2017 23:42:05 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, majd@mellanox.com, Alexr@mellanox.com, dledford@redhat.com Subject: [PATCH RFC rdma-core 3/5] mlx5: Add support for ibv_td object and its related verbs Date: Sun, 12 Nov 2017 23:41:41 +0200 Message-Id: <1510522903-6838-4-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1510522903-6838-1-git-send-email-yishaih@mellanox.com> References: <1510522903-6838-1-git-send-email-yishaih@mellanox.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 This patch introduces the initial implementation of the ibv_alloc/dealloc_td verbs. Upon td creation a dedicated UAR should be attached to this thread domain object and upon destruction the UAR is detached. The motivation behind this is to let an application supply this ibv_td as part of QP creation (by using the ibv_parent_domain) so that this internal UAR will be used by both QPs, dropping any need to take a lock upon post_send when those QPs will be used. A full implementation of the attach/detach dedicated UAR will be given post the acceptance of the RFC API as part of the final series. Signed-off-by: Yishai Hadas --- providers/mlx5/mlx5.c | 2 ++ providers/mlx5/mlx5.h | 13 +++++++++++++ providers/mlx5/verbs.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c index cbdfc40..0c073e2 100644 --- a/providers/mlx5/mlx5.c +++ b/providers/mlx5/mlx5.c @@ -1009,6 +1009,8 @@ static int mlx5_init_context(struct verbs_device *vdev, verbs_set_ctx_op(v_ctx, create_rwq_ind_table, mlx5_create_rwq_ind_table); verbs_set_ctx_op(v_ctx, destroy_rwq_ind_table, mlx5_destroy_rwq_ind_table); verbs_set_ctx_op(v_ctx, post_srq_ops, mlx5_post_srq_ops); + verbs_set_ctx_op(v_ctx, alloc_td, mlx5_alloc_td); + verbs_set_ctx_op(v_ctx, dealloc_td, mlx5_dealloc_td); memset(&device_attr, 0, sizeof(device_attr)); if (!mlx5_query_device_ex(ctx, NULL, &device_attr, diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h index 5978e2e..da0aa91 100644 --- a/providers/mlx5/mlx5.h +++ b/providers/mlx5/mlx5.h @@ -321,6 +321,11 @@ struct mlx5_pd { uint32_t pdn; }; +struct mlx5_td { + struct ibv_td ibv_td; + struct mlx5_bf *bf; +}; + enum { MLX5_CQ_SET_CI = 0, MLX5_CQ_ARM_DB = 1, @@ -569,6 +574,11 @@ static inline struct mlx5_srq *to_msrq(struct ibv_srq *ibsrq) return container_of(vsrq, struct mlx5_srq, vsrq); } +static inline struct mlx5_td *to_mtd(struct ibv_td *ibtd) +{ + return to_mxxx(td, td); +} + static inline struct mlx5_qp *to_mqp(struct ibv_qp *ibqp) { struct verbs_qp *vqp = (struct verbs_qp *)ibqp; @@ -753,6 +763,9 @@ int mlx5_post_srq_ops(struct ibv_srq *srq, struct ibv_ops_wr *wr, struct ibv_ops_wr **bad_wr); +struct ibv_td *mlx5_alloc_td(struct ibv_context *context); +int mlx5_dealloc_td(struct ibv_td *td); + static inline void *mlx5_find_uidx(struct mlx5_context *ctx, uint32_t uidx) { int tind = uidx >> MLX5_UIDX_TABLE_SHIFT; diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index fea81f9..8cf14c0 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -153,6 +153,49 @@ struct ibv_pd *mlx5_alloc_pd(struct ibv_context *context) return &pd->ibv_pd; } +static struct mlx5_bf *mlx5_attach_dedicated_bf(struct ibv_context *context) +{ + /* TBD: allocate a dedciated BF to be used by that thread domain */ + return NULL; +} + +static int mlx5_detach_dedicated_bf(struct mlx5_bf *bf) +{ + /* TBD */ + return 0; +} + +struct ibv_td *mlx5_alloc_td(struct ibv_context *context) +{ + struct mlx5_td *td; + + td = calloc(1, sizeof *td); + if (!td) + return NULL; + + td->bf = mlx5_attach_dedicated_bf(context); + if (td->bf) + return NULL; + + td->ibv_td.context = context; + return &td->ibv_td; +} + +int mlx5_dealloc_td(struct ibv_td *ib_td) +{ + struct mlx5_td *td; + int err; + + td = to_mtd(ib_td); + err = mlx5_detach_dedicated_bf(td->bf); + + if (err) + return err; + + free(td); + return 0; +} + int mlx5_free_pd(struct ibv_pd *pd) { int ret;