From patchwork Tue Oct 9 18:45:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10633163 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 ED69C15E8 for ; Tue, 9 Oct 2018 18:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1D77294F9 for ; Tue, 9 Oct 2018 18:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6223294FD; Tue, 9 Oct 2018 18:47:01 +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 68C84294F9 for ; Tue, 9 Oct 2018 18:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbeJJCFU (ORCPT ); Tue, 9 Oct 2018 22:05:20 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55518 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbeJJCFU (ORCPT ); Tue, 9 Oct 2018 22:05:20 -0400 Received: by mail-wm1-f66.google.com with SMTP id 206-v6so2903873wmb.5 for ; Tue, 09 Oct 2018 11:46:58 -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=Zl8jCVdEdGBhcfRdNUEKYnO8aYChOnJurzzPax6VvlA=; b=NVIh8oJxzxz0Tg2wQB1SfAmVY3fbtg2gFwvf3J+9xDGghAU8geqk/CffS6Dd0YstO8 U2UL+hJGQBPEvnMZlQOKkuXN8GWnsSaNCUPXj6u8o6hZcbmJPsA0Fes/yppATrcXQV3B tbbhbkrUkwa5IO8TaEYUyNRVKC51NlvAAoDwsXMDKRuU2DaixaomuSLOJetMIgQpvPU/ 3WM8YoyIfkADvg6ArAuNS42OL15HzpvLCxcQsRq2QR1jknfoPy/YL7V9kr69/dA4gCWB NUS2IRCK4Fu/vlf1/oalwIpQz/vEugbWfNZklhZc+TBIij0/duIFHN1q6nq3oiiGz5Jf CqCw== 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=Zl8jCVdEdGBhcfRdNUEKYnO8aYChOnJurzzPax6VvlA=; b=LQLL6A7Msf7qI59/QR2FUUY0PVmpTjIGcLpaRSHmvvs9q5nWHOvMMVx3POsiEp9GAO bAAYaAeWlChtEEu+RyF6bI9R9F1NVgxUYbvjvwk/a0xKKJdAnG7ack9QEfy78cjDhI3O DySuA2r/uVPPCK6dM3b+SaAstuxomCJ9oqI4jzjr+Iak3cgM0dfAQFEI+PJGvcW4UIed BMlZyn2cMn1X8aH9C1KhWleO5jXXI0316hQ/eEopwGmiJ+uJHm/ut9ZLMmhTX6JD0uva M4awzVRfvcTeBy4v301674q/TSNlD5zt+11hBUopHirxXWeFRe0e8T0MV3UuTOKXWsmj PJ+Q== X-Gm-Message-State: ABuFfogoLesgY7dGf17mYyiSR5U22cDr2zwXEmWURFzcRYI6XzWc18ik VEiBifppKzBcAS1JP+GjqRsA14QM X-Google-Smtp-Source: ACcGV620j4fOOC0ITVTp7JTryMYzqQnCT74xCnTFNpmalY8QXXkhLTPjle5SjzXYEKAzRySpi1sJsQ== X-Received: by 2002:a1c:5e49:: with SMTP id s70-v6mr2836519wmb.131.1539110817916; Tue, 09 Oct 2018 11:46:57 -0700 (PDT) Received: from localhost.localdomain (bzq-79-179-121-186.red.bezeqint.net. [79.179.121.186]) by smtp.gmail.com with ESMTPSA id r16-v6sm27093327wrv.21.2018.10.09.11.46.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 11:46:57 -0700 (PDT) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, kamalheib1@gmail.com Subject: [PATCH rdma-next 10/18] RDMA/mthca: Initialize ib_device_ops struct Date: Tue, 9 Oct 2018 21:45:39 +0300 Message-Id: <20181009184547.5907-11-kamalheib1@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181009184547.5907-1-kamalheib1@gmail.com> References: <20181009184547.5907-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. Signed-off-by: Kamal Heib --- drivers/infiniband/hw/mthca/mthca_provider.c | 97 ++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 7bd7e2ad17e4..540d55dd75bc 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -1189,6 +1189,81 @@ static void get_dev_fw_str(struct ib_device *device, char *str) (int) dev->fw_ver & 0xffff); } +static 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 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 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 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 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 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 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; @@ -1249,10 +1324,15 @@ int mthca_register_device(struct mthca_dev *dev) (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) | (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ); - if (mthca_is_memfree(dev)) + if (mthca_is_memfree(dev)) { dev->ib_dev.post_srq_recv = mthca_arbel_post_srq_recv; - else + 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; @@ -1273,24 +1353,33 @@ int mthca_register_device(struct mthca_dev *dev) 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)) + if (mthca_is_memfree(dev)) { dev->ib_dev.map_phys_fmr = mthca_arbel_map_phys_fmr; - else + 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; + ib_set_device_ops(&dev->ib_dev, &mthca_dev_arbel_ops); } 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; + ib_set_device_ops(&dev->ib_dev, &mthca_dev_tavor_ops); } mutex_init(&dev->cap_mask_mutex);