From patchwork Tue Sep 12 12:53:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9949133 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 E53B460325 for ; Tue, 12 Sep 2017 12:53:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6CDB28F34 for ; Tue, 12 Sep 2017 12:53:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBCD028F77; Tue, 12 Sep 2017 12:53:28 +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 7226228F34 for ; Tue, 12 Sep 2017 12:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbdILMx1 (ORCPT ); Tue, 12 Sep 2017 08:53:27 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:52412 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751395AbdILMxX (ORCPT ); Tue, 12 Sep 2017 08:53:23 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Sep 2017 15:53:19 +0300 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 v8CCrJBe031222; Tue, 12 Sep 2017 15:53:19 +0300 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 v8CCrJS0023913; Tue, 12 Sep 2017 15:53:19 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v8CCrJDc023912; Tue, 12 Sep 2017 15:53:19 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, guyle@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 3/6] mlx4: Add support for WQ indirection table related verbs Date: Tue, 12 Sep 2017 15:53:05 +0300 Message-Id: <1505220788-23849-4-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1505220788-23849-1-git-send-email-yishaih@mellanox.com> References: <1505220788-23849-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 From: Guy Levi To enable RSS functionality the IB indirection table object should be used. This patch implements the related verbs as of create and destroy an indirection table. In downstream patches the indirection table will be used as part of RSS QP creation. Signed-off-by: Guy Levi Reviewed-by: Yishai Hadas --- providers/mlx4/mlx4.c | 2 ++ providers/mlx4/mlx4.h | 3 +++ providers/mlx4/verbs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c index 6158924..5daea3b 100644 --- a/providers/mlx4/mlx4.c +++ b/providers/mlx4/mlx4.c @@ -259,6 +259,8 @@ static int mlx4_init_context(struct verbs_device *v_device, verbs_set_ctx_op(verbs_ctx, create_wq, mlx4_create_wq); verbs_set_ctx_op(verbs_ctx, modify_wq, mlx4_modify_wq); verbs_set_ctx_op(verbs_ctx, destroy_wq, mlx4_destroy_wq); + verbs_set_ctx_op(verbs_ctx, create_rwq_ind_table, mlx4_create_rwq_ind_table); + verbs_set_ctx_op(verbs_ctx, destroy_rwq_ind_table, mlx4_destroy_rwq_ind_table); return 0; diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h index 204542b..13a561f 100644 --- a/providers/mlx4/mlx4.h +++ b/providers/mlx4/mlx4.h @@ -411,5 +411,8 @@ struct ibv_wq *mlx4_create_wq(struct ibv_context *context, struct ibv_wq_init_attr *attr); int mlx4_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr); int mlx4_destroy_wq(struct ibv_wq *wq); +struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context, + struct ibv_rwq_ind_table_init_attr *init_attr); +int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table); #endif /* MLX4_H */ diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c index 5ded2c5..369f437 100644 --- a/providers/mlx4/verbs.c +++ b/providers/mlx4/verbs.c @@ -1441,3 +1441,58 @@ int mlx4_destroy_wq(struct ibv_wq *ibwq) return 0; } + +struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context, + struct ibv_rwq_ind_table_init_attr *init_attr) +{ + struct ibv_create_rwq_ind_table *cmd; + struct ibv_create_rwq_ind_table_resp resp = {}; + struct ibv_rwq_ind_table *ind_table; + uint32_t required_tbl_size; + unsigned int num_tbl_entries; + int cmd_size; + int err; + + num_tbl_entries = 1 << init_attr->log_ind_tbl_size; + /* Data must be u64 aligned */ + required_tbl_size = + (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? + sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); + + cmd_size = required_tbl_size + sizeof(*cmd); + cmd = calloc(1, cmd_size); + if (!cmd) + return NULL; + + ind_table = calloc(1, sizeof(*ind_table)); + if (!ind_table) + goto free_cmd; + + err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd, + cmd_size, cmd_size, &resp, + sizeof(resp), sizeof(resp)); + if (err) + goto err; + + free(cmd); + return ind_table; + +err: + free(ind_table); +free_cmd: + free(cmd); + return NULL; +} + +int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) +{ + int ret; + + ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table); + + if (ret && !cleanup_on_fatal(ret)) + return ret; + + free(rwq_ind_table); + return 0; +}