提交 ec3f2c12 编写于 作者: D Dennis Dalessandro 提交者: Doug Ledford

staging/rdma/hfi1: Begin to use rdmavt for verbs

This patch begins to make use of rdmavt by registering with it and
providing access to the header files. This is just the beginning of
rdmavt support in hfi1.
Reviewed-by: NIra Weiny <ira.weiny@intel.com>
Reviewed-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 530a5d8e
config INFINIBAND_HFI1 config INFINIBAND_HFI1
tristate "Intel OPA Gen1 support" tristate "Intel OPA Gen1 support"
depends on X86_64 depends on X86_64 && INFINIBAND_RDMAVT
select MMU_NOTIFIER select MMU_NOTIFIER
default m default m
---help--- ---help---
......
...@@ -9925,7 +9925,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state) ...@@ -9925,7 +9925,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
sdma_all_running(dd); sdma_all_running(dd);
/* Signal the IB layer that the port has went active */ /* Signal the IB layer that the port has went active */
event.device = &dd->verbs_dev.ibdev; event.device = &dd->verbs_dev.rdi.ibdev;
event.element.port_num = ppd->port; event.element.port_num = ppd->port;
event.event = IB_EVENT_PORT_ACTIVE; event.event = IB_EVENT_PORT_ACTIVE;
} }
......
...@@ -860,7 +860,7 @@ static ssize_t hfi1_snoop_write(struct file *fp, const char __user *data, ...@@ -860,7 +860,7 @@ static ssize_t hfi1_snoop_write(struct file *fp, const char __user *data,
vl = sc4; vl = sc4;
} else { } else {
sl = (byte_two >> 4) & 0xf; sl = (byte_two >> 4) & 0xf;
ibp = to_iport(&dd->verbs_dev.ibdev, 1); ibp = to_iport(&dd->verbs_dev.rdi.ibdev, 1);
sc5 = ibp->sl_to_sc[sl]; sc5 = ibp->sl_to_sc[sl];
vl = sc_to_vlt(dd, sc5); vl = sc_to_vlt(dd, sc5);
if (vl != sc4) { if (vl != sc4) {
......
...@@ -65,8 +65,7 @@ ...@@ -65,8 +65,7 @@
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/mmu_notifier.h> #include <rdma/rdma_vt.h>
#include <linux/rbtree.h>
#include "chip_registers.h" #include "chip_registers.h"
#include "common.h" #include "common.h"
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/hrtimer.h> #include <linux/hrtimer.h>
#include <rdma/rdma_vt.h>
#include "hfi.h" #include "hfi.h"
#include "device.h" #include "device.h"
...@@ -983,7 +984,7 @@ void hfi1_free_devdata(struct hfi1_devdata *dd) ...@@ -983,7 +984,7 @@ void hfi1_free_devdata(struct hfi1_devdata *dd)
rcu_barrier(); /* wait for rcu callbacks to complete */ rcu_barrier(); /* wait for rcu callbacks to complete */
free_percpu(dd->int_counter); free_percpu(dd->int_counter);
free_percpu(dd->rcv_limit); free_percpu(dd->rcv_limit);
ib_dealloc_device(&dd->verbs_dev.ibdev); ib_dealloc_device(&dd->verbs_dev.rdi.ibdev);
} }
/* /*
...@@ -1079,7 +1080,7 @@ struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra) ...@@ -1079,7 +1080,7 @@ struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra)
bail: bail:
if (!list_empty(&dd->list)) if (!list_empty(&dd->list))
list_del_init(&dd->list); list_del_init(&dd->list);
ib_dealloc_device(&dd->verbs_dev.ibdev); ib_dealloc_device(&dd->verbs_dev.rdi.ibdev);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -98,7 +98,7 @@ static void signal_ib_event(struct hfi1_pportdata *ppd, enum ib_event_type ev) ...@@ -98,7 +98,7 @@ static void signal_ib_event(struct hfi1_pportdata *ppd, enum ib_event_type ev)
*/ */
if (!(dd->flags & HFI1_INITTED)) if (!(dd->flags & HFI1_INITTED))
return; return;
event.device = &dd->verbs_dev.ibdev; event.device = &dd->verbs_dev.rdi.ibdev;
event.element.port_num = ppd->port; event.element.port_num = ppd->port;
event.event = ev; event.event = ev;
ib_dispatch_event(&event); ib_dispatch_event(&event);
......
...@@ -1388,7 +1388,7 @@ static int set_pkeys(struct hfi1_devdata *dd, u8 port, u16 *pkeys) ...@@ -1388,7 +1388,7 @@ static int set_pkeys(struct hfi1_devdata *dd, u8 port, u16 *pkeys)
(void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0); (void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
event.event = IB_EVENT_PKEY_CHANGE; event.event = IB_EVENT_PKEY_CHANGE;
event.device = &dd->verbs_dev.ibdev; event.device = &dd->verbs_dev.rdi.ibdev;
event.element.port_num = port; event.element.port_num = port;
ib_dispatch_event(&event); ib_dispatch_event(&event);
} }
...@@ -4171,7 +4171,8 @@ int hfi1_create_agents(struct hfi1_ibdev *dev) ...@@ -4171,7 +4171,8 @@ int hfi1_create_agents(struct hfi1_ibdev *dev)
for (p = 0; p < dd->num_pports; p++) { for (p = 0; p < dd->num_pports; p++) {
ibp = &dd->pport[p].ibport_data; ibp = &dd->pport[p].ibport_data;
agent = ib_register_mad_agent(&dev->ibdev, p + 1, IB_QPT_SMI, agent = ib_register_mad_agent(&dev->rdi.ibdev, p + 1,
IB_QPT_SMI,
NULL, 0, send_handler, NULL, 0, send_handler,
NULL, NULL, 0); NULL, NULL, 0);
if (IS_ERR(agent)) { if (IS_ERR(agent)) {
......
...@@ -1570,7 +1570,7 @@ struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev) ...@@ -1570,7 +1570,7 @@ struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev)
return NULL; return NULL;
iter->dev = dev; iter->dev = dev;
iter->specials = dev->ibdev.phys_port_cnt * 2; iter->specials = dev->rdi.ibdev.phys_port_cnt * 2;
if (qp_iter_next(iter)) { if (qp_iter_next(iter)) {
kfree(iter); kfree(iter);
return NULL; return NULL;
...@@ -1610,7 +1610,7 @@ int qp_iter_next(struct qp_iter *iter) ...@@ -1610,7 +1610,7 @@ int qp_iter_next(struct qp_iter *iter)
struct hfi1_ibport *ibp; struct hfi1_ibport *ibp;
int pidx; int pidx;
pidx = n % dev->ibdev.phys_port_cnt; pidx = n % dev->rdi.ibdev.phys_port_cnt;
ppd = &dd_from_dev(dev)->pport[pidx]; ppd = &dd_from_dev(dev)->pport[pidx];
ibp = &ppd->ibport_data; ibp = &ppd->ibport_data;
......
...@@ -446,7 +446,7 @@ static ssize_t show_rev(struct device *device, struct device_attribute *attr, ...@@ -446,7 +446,7 @@ static ssize_t show_rev(struct device *device, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev); return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev);
} }
...@@ -455,7 +455,7 @@ static ssize_t show_hfi(struct device *device, struct device_attribute *attr, ...@@ -455,7 +455,7 @@ static ssize_t show_hfi(struct device *device, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
int ret; int ret;
...@@ -470,7 +470,7 @@ static ssize_t show_boardversion(struct device *device, ...@@ -470,7 +470,7 @@ static ssize_t show_boardversion(struct device *device,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
/* The string printed here is already newline-terminated. */ /* The string printed here is already newline-terminated. */
...@@ -482,7 +482,7 @@ static ssize_t show_nctxts(struct device *device, ...@@ -482,7 +482,7 @@ static ssize_t show_nctxts(struct device *device,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
/* /*
...@@ -500,7 +500,7 @@ static ssize_t show_nfreectxts(struct device *device, ...@@ -500,7 +500,7 @@ static ssize_t show_nfreectxts(struct device *device,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
/* Return the number of free user ports (contexts) available. */ /* Return the number of free user ports (contexts) available. */
...@@ -511,7 +511,7 @@ static ssize_t show_serial(struct device *device, ...@@ -511,7 +511,7 @@ static ssize_t show_serial(struct device *device,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
return scnprintf(buf, PAGE_SIZE, "%s", dd->serial); return scnprintf(buf, PAGE_SIZE, "%s", dd->serial);
...@@ -523,7 +523,7 @@ static ssize_t store_chip_reset(struct device *device, ...@@ -523,7 +523,7 @@ static ssize_t store_chip_reset(struct device *device,
size_t count) size_t count)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
int ret; int ret;
...@@ -552,7 +552,7 @@ static ssize_t show_tempsense(struct device *device, ...@@ -552,7 +552,7 @@ static ssize_t show_tempsense(struct device *device,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct hfi1_ibdev *dev = struct hfi1_ibdev *dev =
container_of(device, struct hfi1_ibdev, ibdev.dev); container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
struct hfi1_devdata *dd = dd_from_dev(dev); struct hfi1_devdata *dd = dd_from_dev(dev);
struct hfi1_temp temp; struct hfi1_temp temp;
int ret; int ret;
...@@ -700,7 +700,7 @@ int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num, ...@@ -700,7 +700,7 @@ int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num,
*/ */
int hfi1_verbs_register_sysfs(struct hfi1_devdata *dd) int hfi1_verbs_register_sysfs(struct hfi1_devdata *dd)
{ {
struct ib_device *dev = &dd->verbs_dev.ibdev; struct ib_device *dev = &dd->verbs_dev.rdi.ibdev;
int i, ret; int i, ret;
for (i = 0; i < ARRAY_SIZE(hfi1_attributes); ++i) { for (i = 0; i < ARRAY_SIZE(hfi1_attributes); ++i) {
......
...@@ -1903,7 +1903,7 @@ static void verbs_txreq_kmem_cache_ctor(void *obj) ...@@ -1903,7 +1903,7 @@ static void verbs_txreq_kmem_cache_ctor(void *obj)
int hfi1_register_ib_device(struct hfi1_devdata *dd) int hfi1_register_ib_device(struct hfi1_devdata *dd)
{ {
struct hfi1_ibdev *dev = &dd->verbs_dev; struct hfi1_ibdev *dev = &dd->verbs_dev;
struct ib_device *ibdev = &dev->ibdev; struct ib_device *ibdev = &dev->rdi.ibdev;
struct hfi1_pportdata *ppd = dd->pport; struct hfi1_pportdata *ppd = dd->pport;
unsigned i, lk_tab_size; unsigned i, lk_tab_size;
int ret; int ret;
...@@ -2069,7 +2069,13 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd) ...@@ -2069,7 +2069,13 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
strncpy(ibdev->node_desc, init_utsname()->nodename, strncpy(ibdev->node_desc, init_utsname()->nodename,
sizeof(ibdev->node_desc)); sizeof(ibdev->node_desc));
ret = ib_register_device(ibdev, hfi1_create_port_files); /*
* Fill in rvt info object.
*/
dd->verbs_dev.rdi.driver_f.port_callback = hfi1_create_port_files;
dd->verbs_dev.rdi.dparms.props.max_pd = hfi1_max_pds;
ret = rvt_register_device(&dd->verbs_dev.rdi);
if (ret) if (ret)
goto err_reg; goto err_reg;
...@@ -2086,7 +2092,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd) ...@@ -2086,7 +2092,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
err_class: err_class:
hfi1_free_agents(dev); hfi1_free_agents(dev);
err_agents: err_agents:
ib_unregister_device(ibdev); rvt_unregister_device(&dd->verbs_dev.rdi);
err_reg: err_reg:
err_verbs_txreq: err_verbs_txreq:
kmem_cache_destroy(dev->verbs_txreq_cache); kmem_cache_destroy(dev->verbs_txreq_cache);
...@@ -2102,13 +2108,12 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd) ...@@ -2102,13 +2108,12 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
void hfi1_unregister_ib_device(struct hfi1_devdata *dd) void hfi1_unregister_ib_device(struct hfi1_devdata *dd)
{ {
struct hfi1_ibdev *dev = &dd->verbs_dev; struct hfi1_ibdev *dev = &dd->verbs_dev;
struct ib_device *ibdev = &dev->ibdev;
hfi1_verbs_unregister_sysfs(dd); hfi1_verbs_unregister_sysfs(dd);
hfi1_free_agents(dev); hfi1_free_agents(dev);
ib_unregister_device(ibdev); rvt_unregister_device(&dd->verbs_dev.rdi);
if (!list_empty(&dev->txwait)) if (!list_empty(&dev->txwait))
dd_dev_err(dd, "txwait list not empty!\n"); dd_dev_err(dd, "txwait list not empty!\n");
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include <rdma/ib_pack.h> #include <rdma/ib_pack.h>
#include <rdma/ib_user_verbs.h> #include <rdma/ib_user_verbs.h>
#include <rdma/ib_mad.h> #include <rdma/ib_mad.h>
#include <rdma/rdma_vt.h>
struct hfi1_ctxtdata; struct hfi1_ctxtdata;
struct hfi1_pportdata; struct hfi1_pportdata;
...@@ -749,7 +750,7 @@ struct hfi1_ibport { ...@@ -749,7 +750,7 @@ struct hfi1_ibport {
struct hfi1_qp_ibdev; struct hfi1_qp_ibdev;
struct hfi1_ibdev { struct hfi1_ibdev {
struct ib_device ibdev; struct rvt_dev_info rdi; /* Must be first */
struct list_head pending_mmaps; struct list_head pending_mmaps;
spinlock_t mmap_offset_lock; /* protect mmap_offset */ spinlock_t mmap_offset_lock; /* protect mmap_offset */
u32 mmap_offset; u32 mmap_offset;
...@@ -843,7 +844,10 @@ static inline struct hfi1_qp *to_iqp(struct ib_qp *ibqp) ...@@ -843,7 +844,10 @@ static inline struct hfi1_qp *to_iqp(struct ib_qp *ibqp)
static inline struct hfi1_ibdev *to_idev(struct ib_device *ibdev) static inline struct hfi1_ibdev *to_idev(struct ib_device *ibdev)
{ {
return container_of(ibdev, struct hfi1_ibdev, ibdev); struct rvt_dev_info *rdi;
rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
return container_of(rdi, struct hfi1_ibdev, rdi);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册