public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kamal Heib <kamalheib1@gmail.com>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org, kamalheib1@gmail.com
Subject: [PATCH rdma-next 06/18] RDMA/hns: Initialize ib_device_ops struct
Date: Tue,  9 Oct 2018 19:28:05 +0300	[thread overview]
Message-ID: <20181009162817.4635-7-kamalheib1@gmail.com> (raw)
In-Reply-To: <20181009162817.4635-1-kamalheib1@gmail.com>

Initialize ib_device_ops with the supported operations.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
---
 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");
-- 
2.14.4


  parent reply	other threads:[~2018-10-09 16:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 16:27 [PATCH rdma-next 00/18] RDMA: Add support for ib_device_ops Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 01/18] RDMA/core: Introduce ib_device_ops Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 02/18] RDMA/bnxt_re: Initialize ib_device_ops struct Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 03/18] RDMA/cxgb3: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 04/18] RDMA/cxgb4: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 05/18] RDMA/hfi1: " Kamal Heib
2018-10-09 16:28 ` Kamal Heib [this message]
2018-10-09 16:28 ` [PATCH rdma-next 07/18] RDMA/i40iw: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 08/18] RDMA/mlx4: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 09/18] RDMA/mlx5: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 10/18] RDMA/mthca: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 11/18] RDMA/nes: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 12/18] RDMA/ocrdma: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 13/18] RDMA/qedr: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 14/18] RDMA/qib: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 15/18] RDMA/usnic: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 16/18] RDMA/vmw_pvrdma: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 17/18] RDMA/rxe: " Kamal Heib
2018-10-09 16:28 ` [PATCH rdma-next 18/18] RDMA: Start use ib_device_ops Kamal Heib
2018-10-09 18:31 ` [PATCH rdma-next 00/18] RDMA: Add support for ib_device_ops Doug Ledford
2018-10-09 18:44   ` Kamal Heib
     [not found]     ` <CALEgSQuQyA9JiqaLfC5Un=foTeDHQG6EFJSCqBLTevD1KKKBhA@mail.gmail.com>
2018-10-09 19:01       ` Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181009162817.4635-7-kamalheib1@gmail.com \
    --to=kamalheib1@gmail.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox