From patchwork Tue Jul 19 15:23:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 9237719 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 D1F7A607DA for ; Tue, 19 Jul 2016 15:23:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C340B27165 for ; Tue, 19 Jul 2016 15:23:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B803F277D9; Tue, 19 Jul 2016 15:23: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 41DF12756B for ; Tue, 19 Jul 2016 15:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753455AbcGSPX5 (ORCPT ); Tue, 19 Jul 2016 11:23:57 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:35827 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753408AbcGSPX4 (ORCPT ); Tue, 19 Jul 2016 11:23:56 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from matanb@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Jul 2016 18:23:41 +0300 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 u6JFNdpp025849; Tue, 19 Jul 2016 18:23:41 +0300 From: Matan Barak To: linux-rdma@vger.kernel.org Cc: Doug Ledford , Jason Gunthorpe , Sean Hefty , Liran Liss , Haggai Eran , Tal Alon , Majd Dibbiny , Christoph Lameter , Leon Romanovsky , Matan Barak Subject: [RFC ABI V2 8/8] RDMA/mlx5: Add mlx5 initial support of the new infrastructure Date: Tue, 19 Jul 2016 18:23:32 +0300 Message-Id: <1468941812-32286-9-git-send-email-matanb@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468941812-32286-1-git-send-email-matanb@mellanox.com> References: <1468941812-32286-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-Virus-Scanned: ClamAV using ClamSMTP It adds the following: * Creating a context command * handler * validator * Querying a device * handler * validator It also populate the type table in the IB device. Signed-off-by: Matan Barak --- drivers/infiniband/hw/mlx5/Makefile | 3 +- drivers/infiniband/hw/mlx5/main.c | 12 +++++- drivers/infiniband/hw/mlx5/mlx5_user_cmd.c | 69 ++++++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/user.h | 3 ++ 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 drivers/infiniband/hw/mlx5/mlx5_user_cmd.c diff --git a/drivers/infiniband/hw/mlx5/Makefile b/drivers/infiniband/hw/mlx5/Makefile index 7493a83..c1fed38 100644 --- a/drivers/infiniband/hw/mlx5/Makefile +++ b/drivers/infiniband/hw/mlx5/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_MLX5_INFINIBAND) += mlx5_ib.o -mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq.o mr.o ah.o mad.o gsi.o ib_virt.o +mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq.o mr.o ah.o mad.o gsi.o \ + ib_virt.o mlx5_user_cmd.o mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index c72797c..9ba97b0 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -2467,10 +2468,16 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) if (err) goto err_rsrc; - err = ib_register_device(&dev->ib_dev, NULL); + err = rdma_initialize_common_types(&dev->ib_dev, UVERBS_COMMON_TYPES); if (err) goto err_odp; + dev->ib_dev.types = &mlx5_types; + + err = ib_register_device(&dev->ib_dev, NULL); + if (err) + goto err_remove_common_types; + err = create_umr_res(dev); if (err) goto err_dev; @@ -2491,7 +2498,8 @@ err_umrc: err_dev: ib_unregister_device(&dev->ib_dev); - +err_remove_common_types: + ib_uverbs_uobject_types_remove(&dev->ib_dev); err_odp: mlx5_ib_odp_remove_one(dev); diff --git a/drivers/infiniband/hw/mlx5/mlx5_user_cmd.c b/drivers/infiniband/hw/mlx5/mlx5_user_cmd.c new file mode 100644 index 0000000..d1f7a02 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/mlx5_user_cmd.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016, Mellanox Technologies. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include "user.h" + +/* Refactor this to separate the versions */ +enum mlx5_alloc_ucontext_args { + ALLOC_UCONTEXT_IN, + ALLOC_UCONTEXT_OUT, +}; + +enum mlx5_device_actions { + DEVICE_ALLOC_CONTEXT, + DEVICE_QUERY, +}; + +DECLARE_UVERBS_TYPE( + mlx5_device, + UVERBS_CTX_ACTION( + DEVICE_ALLOC_CONTEXT, uverbs_get_context, NULL, + &uverbs_get_context_spec, + &UVERBS_ATTR_CHAIN_SPEC( + /* + * Declared with size 0 as we current provide + * backward compatibility (0 = variable size) + */ + UVERBS_ATTR_PTR_IN(ALLOC_UCONTEXT_IN, 0), + UVERBS_ATTR_PTR_OUT(ALLOC_UCONTEXT_OUT, 0), + ), + ), + UVERBS_ACTION( + DEVICE_QUERY, uverbs_query_device_handler, NULL, + &uverbs_query_device_spec, + ), +); + +struct uverbs_types mlx5_types = UVERBS_TYPES( + UVERBS_TYPE(UVERBS_TYPE_DEVICE, mlx5_device) +); diff --git a/drivers/infiniband/hw/mlx5/user.h b/drivers/infiniband/hw/mlx5/user.h index 61bc308..ae6d8ab 100644 --- a/drivers/infiniband/hw/mlx5/user.h +++ b/drivers/infiniband/hw/mlx5/user.h @@ -194,4 +194,7 @@ static inline int get_srq_user_index(struct mlx5_ib_ucontext *ucontext, return verify_assign_uidx(cqe_version, ucmd->uidx, user_index); } + +extern struct uverbs_types mlx5_types; + #endif /* MLX5_IB_USER_H */