From patchwork Sun Oct 21 12:49:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10650781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E798014DE for ; Sun, 21 Oct 2018 12:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71AC28765 for ; Sun, 21 Oct 2018 12:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB9A12877B; Sun, 21 Oct 2018 12:50:32 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 588EB28765 for ; Sun, 21 Oct 2018 12:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727699AbeJUVEo (ORCPT ); Sun, 21 Oct 2018 17:04:44 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38853 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbeJUVEo (ORCPT ); Sun, 21 Oct 2018 17:04:44 -0400 Received: by mail-wm1-f65.google.com with SMTP id 193-v6so7629451wme.3 for ; Sun, 21 Oct 2018 05:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1hofGQXM9OBI6EeT10R5ecE+CdqpQYe7oF9HdInIXuU=; b=S34/+mYqY3GKct8UxR53XMqoUfiGIfKfHGn/ES7KbFvqHMpCYsBcyVYwNOy8bs886o AGDL8oirurz2vnqiz7b+8XOUBrhXF5sMyYVo4vG+XW41XXoCgx+5yiLt9krUmwdSI1eN R5Fck1euK95FkMT6Do98aUoYEsfPAfShqwKwpwUw1kbpXnPSntp5SdO0PunEg17weR3d qV4ImG5C902S5rpxxmTeyKdsga/M78s5i4aLP1P/FZ2M+oHxemeP8anzEL4mXh+J2wdZ YDZVHaItrZ02dhu3hrH9MskAbYsq147gT4q0YUaYwHhtXObfog+1DBsIkHbB76Yq0YR6 YbPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1hofGQXM9OBI6EeT10R5ecE+CdqpQYe7oF9HdInIXuU=; b=lAZCNO0AEZ1xuE9YgOrGnJw3aAz83zS8e6FU+w6IDVrL8kCYoFBPSWGZRCLexznjTH vDY3I6tDB0g4TA9J+TVBghjuLVqUQFJ4G8xRT+i0mb3PO6sUxV9jg7DMHuXL7S7Amm1y JsitkOTBm1qt37YvsP09rUixMjkUtFee7thpxUmVQSdti99vp0GWN7WIBjeN9byEFkMY +nrsvRYk9SeMNG0CBgX+tvwOCVq7V5DcURAkxrf3n6d2ZfSrVQaFI8s27ooWrwQcoQFV YErdFICCp8DnMCj4jxWAvRJf1omXmwlEcazjph0X17howNEStTlv1IlvbOsWeP5C7Win neEQ== X-Gm-Message-State: ABuFfogZcaQl2zdNnOC2LBsKg4szVWsPfIlkJkyZe3z1tUXeKSHxl5uM FeX4bEWzZTfdTcmwR5wCH1Y= X-Google-Smtp-Source: ACcGV60qrNLWAgq2yeD85peF6VG6xlMep/jl9Rg1ah737+aulUJUZ9Bhaey9qaCO7HviDxdt2nLigQ== X-Received: by 2002:a1c:c64c:: with SMTP id w73-v6mr11500382wmf.21.1540126229233; Sun, 21 Oct 2018 05:50:29 -0700 (PDT) Received: from kheib-workstation.redhat.com ([192.116.94.216]) by smtp.gmail.com with ESMTPSA id v76-v6sm14375380wmd.32.2018.10.21.05.50.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Oct 2018 05:50:28 -0700 (PDT) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, kamalheib1@gmail.com Subject: [PATCH rdma-next v2 13/18] RDMA/qedr: Initialize ib_device_ops struct Date: Sun, 21 Oct 2018 15:49:48 +0300 Message-Id: <20181021124953.11558-14-kamalheib1@gmail.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181021124953.11558-1-kamalheib1@gmail.com> References: <20181021124953.11558-1-kamalheib1@gmail.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 Initialize ib_device_ops with the supported operations using ib_set_device_ops(). Signed-off-by: Kamal Heib --- drivers/infiniband/hw/qedr/main.c | 103 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c index 8d6ff9df49fe..188927aa99d9 100644 --- a/drivers/infiniband/hw/qedr/main.c +++ b/drivers/infiniband/hw/qedr/main.c @@ -160,12 +160,16 @@ static const struct attribute_group qedr_attr_group = { .attrs = qedr_attributes, }; +static const struct ib_device_ops qedr_iw_dev_ops = { + .query_gid = qedr_iw_query_gid, + .get_port_immutable = qedr_iw_port_immutable, +}; + static int qedr_iw_register_device(struct qedr_dev *dev) { dev->ibdev.node_type = RDMA_NODE_RNIC; - dev->ibdev.query_gid = qedr_iw_query_gid; - dev->ibdev.get_port_immutable = qedr_iw_port_immutable; + ib_set_device_ops(&dev->ibdev, &qedr_iw_dev_ops); dev->ibdev.iwcm = kzalloc(sizeof(*dev->ibdev.iwcm), GFP_KERNEL); if (!dev->ibdev.iwcm) @@ -186,13 +190,56 @@ static int qedr_iw_register_device(struct qedr_dev *dev) return 0; } +static const struct ib_device_ops qedr_roce_dev_ops = { + .get_port_immutable = qedr_roce_port_immutable, +}; + static void qedr_roce_register_device(struct qedr_dev *dev) { dev->ibdev.node_type = RDMA_NODE_IB_CA; - dev->ibdev.get_port_immutable = qedr_roce_port_immutable; + ib_set_device_ops(&dev->ibdev, &qedr_roce_dev_ops); } +static const struct ib_device_ops qedr_dev_ops = { + .query_device = qedr_query_device, + .query_port = qedr_query_port, + .modify_port = qedr_modify_port, + .alloc_ucontext = qedr_alloc_ucontext, + .dealloc_ucontext = qedr_dealloc_ucontext, + .mmap = qedr_mmap, + .alloc_pd = qedr_alloc_pd, + .dealloc_pd = qedr_dealloc_pd, + .create_cq = qedr_create_cq, + .destroy_cq = qedr_destroy_cq, + .resize_cq = qedr_resize_cq, + .req_notify_cq = qedr_arm_cq, + .create_qp = qedr_create_qp, + .modify_qp = qedr_modify_qp, + .query_qp = qedr_query_qp, + .destroy_qp = qedr_destroy_qp, + .create_srq = qedr_create_srq, + .destroy_srq = qedr_destroy_srq, + .modify_srq = qedr_modify_srq, + .query_srq = qedr_query_srq, + .post_srq_recv = qedr_post_srq_recv, + .query_pkey = qedr_query_pkey, + .create_ah = qedr_create_ah, + .destroy_ah = qedr_destroy_ah, + .get_dma_mr = qedr_get_dma_mr, + .dereg_mr = qedr_dereg_mr, + .reg_user_mr = qedr_reg_user_mr, + .alloc_mr = qedr_alloc_mr, + .map_mr_sg = qedr_map_mr_sg, + .poll_cq = qedr_poll_cq, + .post_send = qedr_post_send, + .post_recv = qedr_post_recv, + .process_mad = qedr_process_mad, + .get_netdev = qedr_get_netdev, + .get_link_layer = qedr_link_layer, + .get_dev_fw_str = qedr_get_dev_fw_str, +}; + static int qedr_register_device(struct qedr_dev *dev) { int rc; @@ -237,57 +284,11 @@ static int qedr_register_device(struct qedr_dev *dev) dev->ibdev.phys_port_cnt = 1; dev->ibdev.num_comp_vectors = dev->num_cnq; - - dev->ibdev.query_device = qedr_query_device; - dev->ibdev.query_port = qedr_query_port; - dev->ibdev.modify_port = qedr_modify_port; - - dev->ibdev.alloc_ucontext = qedr_alloc_ucontext; - dev->ibdev.dealloc_ucontext = qedr_dealloc_ucontext; - dev->ibdev.mmap = qedr_mmap; - - dev->ibdev.alloc_pd = qedr_alloc_pd; - dev->ibdev.dealloc_pd = qedr_dealloc_pd; - - dev->ibdev.create_cq = qedr_create_cq; - dev->ibdev.destroy_cq = qedr_destroy_cq; - dev->ibdev.resize_cq = qedr_resize_cq; - dev->ibdev.req_notify_cq = qedr_arm_cq; - - dev->ibdev.create_qp = qedr_create_qp; - dev->ibdev.modify_qp = qedr_modify_qp; - dev->ibdev.query_qp = qedr_query_qp; - dev->ibdev.destroy_qp = qedr_destroy_qp; - - dev->ibdev.create_srq = qedr_create_srq; - dev->ibdev.destroy_srq = qedr_destroy_srq; - dev->ibdev.modify_srq = qedr_modify_srq; - dev->ibdev.query_srq = qedr_query_srq; - dev->ibdev.post_srq_recv = qedr_post_srq_recv; - dev->ibdev.query_pkey = qedr_query_pkey; - - dev->ibdev.create_ah = qedr_create_ah; - dev->ibdev.destroy_ah = qedr_destroy_ah; - - dev->ibdev.get_dma_mr = qedr_get_dma_mr; - dev->ibdev.dereg_mr = qedr_dereg_mr; - dev->ibdev.reg_user_mr = qedr_reg_user_mr; - dev->ibdev.alloc_mr = qedr_alloc_mr; - dev->ibdev.map_mr_sg = qedr_map_mr_sg; - - dev->ibdev.poll_cq = qedr_poll_cq; - dev->ibdev.post_send = qedr_post_send; - dev->ibdev.post_recv = qedr_post_recv; - - dev->ibdev.process_mad = qedr_process_mad; - - dev->ibdev.get_netdev = qedr_get_netdev; - dev->ibdev.dev.parent = &dev->pdev->dev; - dev->ibdev.get_link_layer = qedr_link_layer; - dev->ibdev.get_dev_fw_str = qedr_get_dev_fw_str; rdma_set_device_sysfs_group(&dev->ibdev, &qedr_attr_group); + ib_set_device_ops(&dev->ibdev, &qedr_dev_ops); + dev->ibdev.driver_id = RDMA_DRIVER_QEDR; return ib_register_device(&dev->ibdev, "qedr%d", NULL); }