Commit ab7efbe2 authored by Steve Wise's avatar Steve Wise Committed by Jason Gunthorpe

RDMA/cxgb4: Use ib_device_set_netdev()

cxgb4 has a simple non-dynamic use of get_netdev, so conversion is
straightforward.
Signed-off-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 4b38da75
...@@ -482,24 +482,6 @@ static void get_dev_fw_str(struct ib_device *dev, char *str) ...@@ -482,24 +482,6 @@ static void get_dev_fw_str(struct ib_device *dev, char *str)
FW_HDR_FW_VER_BUILD_G(c4iw_dev->rdev.lldi.fw_vers)); FW_HDR_FW_VER_BUILD_G(c4iw_dev->rdev.lldi.fw_vers));
} }
static struct net_device *get_netdev(struct ib_device *dev, u8 port)
{
struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev, ibdev);
struct c4iw_rdev *rdev = &c4iw_dev->rdev;
struct net_device *ndev;
if (!port || port > rdev->lldi.nports)
return NULL;
rcu_read_lock();
ndev = rdev->lldi.ports[port - 1];
if (ndev)
dev_hold(ndev);
rcu_read_unlock();
return ndev;
}
static int fill_res_entry(struct sk_buff *msg, struct rdma_restrack_entry *res) static int fill_res_entry(struct sk_buff *msg, struct rdma_restrack_entry *res)
{ {
return (res->type < ARRAY_SIZE(c4iw_restrack_funcs) && return (res->type < ARRAY_SIZE(c4iw_restrack_funcs) &&
...@@ -527,7 +509,6 @@ static const struct ib_device_ops c4iw_dev_ops = { ...@@ -527,7 +509,6 @@ static const struct ib_device_ops c4iw_dev_ops = {
.get_dev_fw_str = get_dev_fw_str, .get_dev_fw_str = get_dev_fw_str,
.get_dma_mr = c4iw_get_dma_mr, .get_dma_mr = c4iw_get_dma_mr,
.get_hw_stats = c4iw_get_mib, .get_hw_stats = c4iw_get_mib,
.get_netdev = get_netdev,
.get_port_immutable = c4iw_port_immutable, .get_port_immutable = c4iw_port_immutable,
.map_mr_sg = c4iw_map_mr_sg, .map_mr_sg = c4iw_map_mr_sg,
.mmap = c4iw_mmap, .mmap = c4iw_mmap,
...@@ -549,6 +530,20 @@ static const struct ib_device_ops c4iw_dev_ops = { ...@@ -549,6 +530,20 @@ static const struct ib_device_ops c4iw_dev_ops = {
INIT_RDMA_OBJ_SIZE(ib_ucontext, c4iw_ucontext, ibucontext), INIT_RDMA_OBJ_SIZE(ib_ucontext, c4iw_ucontext, ibucontext),
}; };
static int set_netdevs(struct ib_device *ib_dev, struct c4iw_rdev *rdev)
{
int ret;
int i;
for (i = 0; i < rdev->lldi.nports; i++) {
ret = ib_device_set_netdev(ib_dev, rdev->lldi.ports[i],
i + 1);
if (ret)
return ret;
}
return 0;
}
void c4iw_register_device(struct work_struct *work) void c4iw_register_device(struct work_struct *work)
{ {
int ret; int ret;
...@@ -613,6 +608,9 @@ void c4iw_register_device(struct work_struct *work) ...@@ -613,6 +608,9 @@ void c4iw_register_device(struct work_struct *work)
rdma_set_device_sysfs_group(&dev->ibdev, &c4iw_attr_group); rdma_set_device_sysfs_group(&dev->ibdev, &c4iw_attr_group);
dev->ibdev.driver_id = RDMA_DRIVER_CXGB4; dev->ibdev.driver_id = RDMA_DRIVER_CXGB4;
ib_set_device_ops(&dev->ibdev, &c4iw_dev_ops); ib_set_device_ops(&dev->ibdev, &c4iw_dev_ops);
ret = set_netdevs(&dev->ibdev, &dev->rdev);
if (ret)
goto err_kfree_iwcm;
ret = ib_register_device(&dev->ibdev, "cxgb4_%d"); ret = ib_register_device(&dev->ibdev, "cxgb4_%d");
if (ret) if (ret)
goto err_kfree_iwcm; goto err_kfree_iwcm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment