From patchwork Sun Oct 21 12:49:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10650775 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 ADAA314DE for ; Sun, 21 Oct 2018 12:50:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CFDE2877E for ; Sun, 21 Oct 2018 12:50:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 910A828779; Sun, 21 Oct 2018 12:50:29 +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 F0A9C28779 for ; Sun, 21 Oct 2018 12:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727683AbeJUVEl (ORCPT ); Sun, 21 Oct 2018 17:04:41 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39935 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727603AbeJUVEl (ORCPT ); Sun, 21 Oct 2018 17:04:41 -0400 Received: by mail-wr1-f65.google.com with SMTP id s18-v6so189285wrw.6 for ; Sun, 21 Oct 2018 05:50:26 -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=ZAinZmo8Fhv76wHl28aj58+YTYM1iNs4xxok4goByfk=; b=BwzI4aVsvpWO4/MmAtYzg/gy4w5XwcaZF2sDemt51xNjBfL9U7CQ/MOjTWU5hLkJmL oXMJunPNpVoKPBSLRqVY4fRIEMAEuwA4isGHSdXVz6AMjufy/epuARWsMHwd9wuyNwpH VIsWrloS8bcG/WgQZll+dGaPbHlrRRHGWX2d+6rcVhQ+W7u8iPDrRt36TXsyVjY/h+9b HOW7yq2q3oq7oRYeDjpoOdtEoT08SvIGRgvb4k52adJ0WOcfMrElxhE0ttuGaj57zzbQ +2GekLM0nmR3uTi4g+jio3H8/+zpcLn8P4/KyNYWFEiieKR8Q7GVfZnPIXKhvdvuGEJ/ z3IA== 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=ZAinZmo8Fhv76wHl28aj58+YTYM1iNs4xxok4goByfk=; b=A+uYICD0Z01EdI7UALFHbDziDEqm+8EZf7yGg4JrK5SId2nia5KqHcWPl5y1KJJlMq apIMEdF3Y/gpurbWhNbNpI0IzufTBvsTophaIGMgFm3/gywXiRIYYrPAqxyi6LFVRQ26 vL2fKLfNECCdvaTrJBdnWw/sUVRsN7e6SV4/Q+hMl/w43+jRC6m/qI2BjOcrYXT3KToy TSyPH/h5QQ6nnuVSmA4HTV4mI9XSyYrnrBc/t868lfZJ3ecqhYG2xxkyTb9KlMTlB34e vf+MEuCrI9WXHAKnnlYD9U/Hk5fJD1jkCCFTCxKSwXsS7+wL4uelf3Wz+EWoBr7hnmSY +wyw== X-Gm-Message-State: AGRZ1gJUkZFWRruAVhUS/jtgY7zGkFkv3q3pYI6EkvOy4uQNyfypsG60 Ni0Jf1QkuiEo1s45gCWUiWE= X-Google-Smtp-Source: AJdET5cKrPpUolf6gO9B070mUtc7rGFQfbfX5YL1ADGluHwno5/S1gYPW9+2TMn76I+4MSN677eZIg== X-Received: by 2002:adf:fc10:: with SMTP id i16-v6mr92707wrr.9.1540126225391; Sun, 21 Oct 2018 05:50:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Oct 2018 05:50:24 -0700 (PDT) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, kamalheib1@gmail.com Subject: [PATCH rdma-next v2 10/18] RDMA/mthca: Initialize ib_device_ops struct Date: Sun, 21 Oct 2018 15:49:45 +0300 Message-Id: <20181021124953.11558-11-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/mthca/mthca_provider.c | 139 +++++++++++++++++---------- 1 file changed, 88 insertions(+), 51 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 691c6f048938..a1ac48b0b7b7 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -1193,6 +1193,81 @@ static void get_dev_fw_str(struct ib_device *device, char *str) (int) dev->fw_ver & 0xffff); } +static const struct ib_device_ops mthca_dev_ops = { + .query_device = mthca_query_device, + .query_port = mthca_query_port, + .modify_device = mthca_modify_device, + .modify_port = mthca_modify_port, + .query_pkey = mthca_query_pkey, + .query_gid = mthca_query_gid, + .alloc_ucontext = mthca_alloc_ucontext, + .dealloc_ucontext = mthca_dealloc_ucontext, + .mmap = mthca_mmap_uar, + .alloc_pd = mthca_alloc_pd, + .dealloc_pd = mthca_dealloc_pd, + .create_ah = mthca_ah_create, + .query_ah = mthca_ah_query, + .destroy_ah = mthca_ah_destroy, + .create_qp = mthca_create_qp, + .modify_qp = mthca_modify_qp, + .query_qp = mthca_query_qp, + .destroy_qp = mthca_destroy_qp, + .create_cq = mthca_create_cq, + .resize_cq = mthca_resize_cq, + .destroy_cq = mthca_destroy_cq, + .poll_cq = mthca_poll_cq, + .get_dma_mr = mthca_get_dma_mr, + .reg_user_mr = mthca_reg_user_mr, + .dereg_mr = mthca_dereg_mr, + .get_port_immutable = mthca_port_immutable, + .get_dev_fw_str = get_dev_fw_str, + .attach_mcast = mthca_multicast_attach, + .detach_mcast = mthca_multicast_detach, + .process_mad = mthca_process_mad, +}; + +static const struct ib_device_ops mthca_dev_arbel_srq_ops = { + .create_srq = mthca_create_srq, + .modify_srq = mthca_modify_srq, + .query_srq = mthca_query_srq, + .destroy_srq = mthca_destroy_srq, + .post_srq_recv = mthca_arbel_post_srq_recv, +}; + +static const struct ib_device_ops mthca_dev_tavor_srq_ops = { + .create_srq = mthca_create_srq, + .modify_srq = mthca_modify_srq, + .query_srq = mthca_query_srq, + .destroy_srq = mthca_destroy_srq, + .post_srq_recv = mthca_tavor_post_srq_recv, +}; + +static const struct ib_device_ops mthca_dev_arbel_fmr_ops = { + .alloc_fmr = mthca_alloc_fmr, + .unmap_fmr = mthca_unmap_fmr, + .dealloc_fmr = mthca_dealloc_fmr, + .map_phys_fmr = mthca_arbel_map_phys_fmr, +}; + +static const struct ib_device_ops mthca_dev_tavor_fmr_ops = { + .alloc_fmr = mthca_alloc_fmr, + .unmap_fmr = mthca_unmap_fmr, + .dealloc_fmr = mthca_dealloc_fmr, + .map_phys_fmr = mthca_tavor_map_phys_fmr, +}; + +static const struct ib_device_ops mthca_dev_arbel_ops = { + .req_notify_cq = mthca_arbel_arm_cq, + .post_send = mthca_arbel_post_send, + .post_recv = mthca_arbel_post_receive, +}; + +static const struct ib_device_ops mthca_dev_tavor_ops = { + .req_notify_cq = mthca_tavor_arm_cq, + .post_send = mthca_tavor_post_send, + .post_recv = mthca_tavor_post_receive, +}; + int mthca_register_device(struct mthca_dev *dev) { int ret; @@ -1226,26 +1301,8 @@ int mthca_register_device(struct mthca_dev *dev) dev->ib_dev.phys_port_cnt = dev->limits.num_ports; dev->ib_dev.num_comp_vectors = 1; dev->ib_dev.dev.parent = &dev->pdev->dev; - dev->ib_dev.query_device = mthca_query_device; - dev->ib_dev.query_port = mthca_query_port; - dev->ib_dev.modify_device = mthca_modify_device; - dev->ib_dev.modify_port = mthca_modify_port; - dev->ib_dev.query_pkey = mthca_query_pkey; - dev->ib_dev.query_gid = mthca_query_gid; - dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext; - dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext; - dev->ib_dev.mmap = mthca_mmap_uar; - dev->ib_dev.alloc_pd = mthca_alloc_pd; - dev->ib_dev.dealloc_pd = mthca_dealloc_pd; - dev->ib_dev.create_ah = mthca_ah_create; - dev->ib_dev.query_ah = mthca_ah_query; - dev->ib_dev.destroy_ah = mthca_ah_destroy; if (dev->mthca_flags & MTHCA_FLAG_SRQ) { - dev->ib_dev.create_srq = mthca_create_srq; - dev->ib_dev.modify_srq = mthca_modify_srq; - dev->ib_dev.query_srq = mthca_query_srq; - dev->ib_dev.destroy_srq = mthca_destroy_srq; dev->ib_dev.uverbs_cmd_mask |= (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) | (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) | @@ -1253,48 +1310,28 @@ int mthca_register_device(struct mthca_dev *dev) (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ); if (mthca_is_memfree(dev)) - dev->ib_dev.post_srq_recv = mthca_arbel_post_srq_recv; + ib_set_device_ops(&dev->ib_dev, + &mthca_dev_arbel_srq_ops); else - dev->ib_dev.post_srq_recv = mthca_tavor_post_srq_recv; + ib_set_device_ops(&dev->ib_dev, + &mthca_dev_tavor_srq_ops); } - dev->ib_dev.create_qp = mthca_create_qp; - dev->ib_dev.modify_qp = mthca_modify_qp; - dev->ib_dev.query_qp = mthca_query_qp; - dev->ib_dev.destroy_qp = mthca_destroy_qp; - dev->ib_dev.create_cq = mthca_create_cq; - dev->ib_dev.resize_cq = mthca_resize_cq; - dev->ib_dev.destroy_cq = mthca_destroy_cq; - dev->ib_dev.poll_cq = mthca_poll_cq; - dev->ib_dev.get_dma_mr = mthca_get_dma_mr; - dev->ib_dev.reg_user_mr = mthca_reg_user_mr; - dev->ib_dev.dereg_mr = mthca_dereg_mr; - dev->ib_dev.get_port_immutable = mthca_port_immutable; - dev->ib_dev.get_dev_fw_str = get_dev_fw_str; - if (dev->mthca_flags & MTHCA_FLAG_FMR) { - dev->ib_dev.alloc_fmr = mthca_alloc_fmr; - dev->ib_dev.unmap_fmr = mthca_unmap_fmr; - dev->ib_dev.dealloc_fmr = mthca_dealloc_fmr; if (mthca_is_memfree(dev)) - dev->ib_dev.map_phys_fmr = mthca_arbel_map_phys_fmr; + ib_set_device_ops(&dev->ib_dev, + &mthca_dev_arbel_fmr_ops); else - dev->ib_dev.map_phys_fmr = mthca_tavor_map_phys_fmr; + ib_set_device_ops(&dev->ib_dev, + &mthca_dev_tavor_fmr_ops); } - dev->ib_dev.attach_mcast = mthca_multicast_attach; - dev->ib_dev.detach_mcast = mthca_multicast_detach; - dev->ib_dev.process_mad = mthca_process_mad; + ib_set_device_ops(&dev->ib_dev, &mthca_dev_ops); - if (mthca_is_memfree(dev)) { - dev->ib_dev.req_notify_cq = mthca_arbel_arm_cq; - dev->ib_dev.post_send = mthca_arbel_post_send; - dev->ib_dev.post_recv = mthca_arbel_post_receive; - } else { - dev->ib_dev.req_notify_cq = mthca_tavor_arm_cq; - dev->ib_dev.post_send = mthca_tavor_post_send; - dev->ib_dev.post_recv = mthca_tavor_post_receive; - } + if (mthca_is_memfree(dev)) + ib_set_device_ops(&dev->ib_dev, &mthca_dev_arbel_ops); + else + ib_set_device_ops(&dev->ib_dev, &mthca_dev_tavor_ops); mutex_init(&dev->cap_mask_mutex);