From patchwork Tue Oct 9 18:45:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10633155 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 1ADF9933 for ; Tue, 9 Oct 2018 18:46:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 111BA294F9 for ; Tue, 9 Oct 2018 18:46:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05E90294FD; Tue, 9 Oct 2018 18:46:57 +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 80FD3294F9 for ; Tue, 9 Oct 2018 18:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbeJJCFP (ORCPT ); Tue, 9 Oct 2018 22:05:15 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33264 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbeJJCFP (ORCPT ); Tue, 9 Oct 2018 22:05:15 -0400 Received: by mail-wr1-f68.google.com with SMTP id e4-v6so2976446wrs.0 for ; Tue, 09 Oct 2018 11:46:53 -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=oc9+fOZpqXIzxaz8vCgKAGzanoNLXdD4T85GrX2mX8c=; b=dFT5/00pYr+V/UdMItVIYEdlfNyyyKHK6mm70FyZBQamG9laMkRlPfIo9bBrGmdGlK tSuZGkyT3+9TRzlSXJfB0V7kbL8hvc1yF137PYjchMOZawnQI/WC6BSjHnZvIw1qwmEg 9sN3El3DBegqpjL60Q4cclvScmnwcOFsVgF9rLJMhYZa+W2VnMcxaAUfsQ6gGDCG55RO hyN3H/xWoYpmHk+La7W1ck/rQGWGxBy/SJDwbm9XmY8ieZG6ETg7SYAXCV5EBt6pL4iA FNvYALoGbdt5kSsSRJXIzouDrBwHWiNzq8GQR76wblvvsuXaMbCY5dT7Y8xqIqMPNxDE 0GoA== 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=oc9+fOZpqXIzxaz8vCgKAGzanoNLXdD4T85GrX2mX8c=; b=BQNzIfsjeSvdIwVD73C/dpUUoRBS+p4GgBtA7G+dGMklCUTFlgIudRjSRTWTc0RqNf VB8TAcKJadoRIhCCxcusrQkOT5fyRWrUxNDX4u1rqjovqF+bQiHgIXnNYBiXt1dhyrob Jzek7u54nb0NQhBbeOLDUyw/FdrdRP2s4oIA5onDv+zZNmXWAbw7/XYwV6JKm6NukhsD LlfzxppJQjlmIHnX7XzwDirOfEaFtWE9DVgNAd9opUlhstoeP05eceDdw5sFgGecF6h4 UyyKRxf6TSHBQKGyb0FNMy8/hZsteYYmuLNRn3LNyfjndetEXX8tCs4pYGcJcnVOVcxC Z+YA== X-Gm-Message-State: ABuFfohyU2zUwEo9BdE9Q9RN7G437vhq9kEs5yH4VxVa7AJ+UVJfq0wd 2uKPeMv68k37AfUxrodHcN8= X-Google-Smtp-Source: ACcGV63hmkRtAlB/APYV3NZiy5Tjcv4qeDqLcLHRQyslzpk1nFdED1z6utZ5Cv+GMYPcCpHNBkpZgg== X-Received: by 2002:adf:fdc2:: with SMTP id i2-v6mr4872400wrs.276.1539110813161; Tue, 09 Oct 2018 11:46:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Oct 2018 11:46:52 -0700 (PDT) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, kamalheib1@gmail.com Subject: [PATCH rdma-next 06/18] RDMA/hns: Initialize ib_device_ops struct Date: Tue, 9 Oct 2018 21:45:35 +0300 Message-Id: <20181009184547.5907-7-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/hns/hns_roce_device.h | 1 + drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 11 ++++++++ drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 11 ++++++++ drivers/infiniband/hw/hns/hns_roce_main.c | 42 +++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index de9b8e391563..283ca30334fa 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -799,6 +799,7 @@ struct hns_roce_hw { int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period); int (*init_eq)(struct hns_roce_dev *hr_dev); void (*cleanup_eq)(struct hns_roce_dev *hr_dev); + struct ib_device_ops *hns_roce_dev_ops; }; struct hns_roce_dev { diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index ca05810c92dc..c9bc316366e0 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c @@ -4793,6 +4793,16 @@ static void hns_roce_v1_cleanup_eq_table(struct hns_roce_dev *hr_dev) kfree(eq_table->eq); } +static struct ib_device_ops hns_roce_v1_dev_ops = { + .query_qp = hns_roce_v1_query_qp, + .destroy_qp = hns_roce_v1_destroy_qp, + .post_send = hns_roce_v1_post_send, + .post_recv = hns_roce_v1_post_recv, + .modify_cq = hns_roce_v1_modify_cq, + .req_notify_cq = hns_roce_v1_req_notify_cq, + .poll_cq = hns_roce_v1_poll_cq, +}; + static const struct hns_roce_hw hns_roce_hw_v1 = { .reset = hns_roce_v1_reset, .hw_profile = hns_roce_v1_profile, @@ -4818,6 +4828,7 @@ static const struct hns_roce_hw hns_roce_hw_v1 = { .destroy_cq = hns_roce_v1_destroy_cq, .init_eq = hns_roce_v1_init_eq_table, .cleanup_eq = hns_roce_v1_cleanup_eq_table, + .hns_roce_dev_ops = hns_roce_v1_dev_ops, }; static const struct of_device_id hns_roce_of_match[] = { diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index e3d9f1de8899..82fb636c99ad 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -5247,6 +5247,16 @@ static void hns_roce_v2_cleanup_eq_table(struct hns_roce_dev *hr_dev) destroy_workqueue(hr_dev->irq_workq); } +static struct ib_device_ops hns_roce_v2_dev_ops = { + .query_qp = hns_roce_v2_query_qp, + .destroy_qp = hns_roce_v2_destroy_qp, + .post_send = hns_roce_v2_post_send, + .post_recv = hns_roce_v2_post_recv, + .modify_cq = hns_roce_v2_modify_cq, + .req_notify_cq = hns_roce_v2_req_notify_cq, + .poll_cq = hns_roce_v2_poll_cq, +}; + static const struct hns_roce_hw hns_roce_hw_v2 = { .cmq_init = hns_roce_v2_cmq_init, .cmq_exit = hns_roce_v2_cmq_exit, @@ -5273,6 +5283,7 @@ static const struct hns_roce_hw hns_roce_hw_v2 = { .poll_cq = hns_roce_v2_poll_cq, .init_eq = hns_roce_v2_init_eq_table, .cleanup_eq = hns_roce_v2_cleanup_eq_table, + .hns_roce_dev_ops = hns_roce_v2_dev_ops, }; static const struct pci_device_id hns_roce_hw_v2_pci_tbl[] = { diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 7e693b11c823..725678f138df 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -440,6 +440,44 @@ static void hns_roce_unregister_device(struct hns_roce_dev *hr_dev) ib_unregister_device(&hr_dev->ib_dev); } +static struct ib_device_ops hns_roce_dev_ops = { + .modify_device = hns_roce_modify_device, + .query_device = hns_roce_query_device, + .query_port = hns_roce_query_port, + .modify_port = hns_roce_modify_port, + .get_link_layer = hns_roce_get_link_layer, + .get_netdev = hns_roce_get_netdev, + .add_gid = hns_roce_add_gid, + .del_gid = hns_roce_del_gid, + .query_pkey = hns_roce_query_pkey, + .alloc_ucontext = hns_roce_alloc_ucontext, + .dealloc_ucontext = hns_roce_dealloc_ucontext, + .mmap = hns_roce_mmap, + .alloc_pd = hns_roce_alloc_pd, + .dealloc_pd = hns_roce_dealloc_pd, + .create_ah = hns_roce_create_ah, + .query_ah = hns_roce_query_ah, + .destroy_ah = hns_roce_destroy_ah, + .create_qp = hns_roce_create_qp, + .modify_qp = hns_roce_modify_qp, + .create_cq = hns_roce_ib_create_cq, + .destroy_cq = hns_roce_ib_destroy_cq, + .get_dma_mr = hns_roce_get_dma_mr, + .reg_user_mr = hns_roce_reg_user_mr, + .dereg_mr = hns_roce_dereg_mr, + .get_port_immutable = hns_roce_port_immutable, + .disassociate_ucontext = hns_roce_disassociate_ucontext, +}; + +static struct ib_device_ops hns_roce_dev_mr_ops = { + .rereg_user_mr = hns_roce_rereg_user_mr, +}; + +static struct ib_device_ops hns_roce_dev_mw_ops = { + .alloc_mw = hns_roce_alloc_mw, + .dealloc_mw = hns_roce_dealloc_mw, +}; + static int hns_roce_register_device(struct hns_roce_dev *hr_dev) { int ret; @@ -524,6 +562,7 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_REREG_MR) { ib_dev->rereg_user_mr = hns_roce_rereg_user_mr; ib_dev->uverbs_cmd_mask |= (1ULL << IB_USER_VERBS_CMD_REREG_MR); + ib_set_device_ops(ib_dev, &hns_roce_dev_mr_ops); } /* MW */ @@ -533,6 +572,7 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) ib_dev->uverbs_cmd_mask |= (1ULL << IB_USER_VERBS_CMD_ALLOC_MW) | (1ULL << IB_USER_VERBS_CMD_DEALLOC_MW); + ib_set_device_ops(ib_dev, &hns_roce_dev_mw_ops); } /* OTHERS */ @@ -540,6 +580,8 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) ib_dev->disassociate_ucontext = hns_roce_disassociate_ucontext; ib_dev->driver_id = RDMA_DRIVER_HNS; + ib_set_device_ops(ib_dev, hr_dev->hw->hns_roce_dev_ops); + ib_set_device_ops(ib_dev, &hns_roce_dev_ops); ret = ib_register_device(ib_dev, "hns_%d", NULL); if (ret) { dev_err(dev, "ib_register_device failed!\n");