RDMA: Introduce and use rdma_device_to_ibdev()
Introduce and use rdma_device_to_ibdev() API for those drivers which are registering one sysfs group and also use in ib_core. In subsequent patch, device->provider_ibdev one-to-one mapping is no longer holds true during accessing sysfs entries. Therefore, introduce an API rdma_device_to_ibdev() that provides such information. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
ea4baf7f11
commit
5474723115
|
@ -296,8 +296,6 @@ struct ib_device *ib_alloc_device(size_t size)
|
|||
device->dev.class = &ib_class;
|
||||
device_initialize(&device->dev);
|
||||
|
||||
dev_set_drvdata(&device->dev, device);
|
||||
|
||||
INIT_LIST_HEAD(&device->event_handler_list);
|
||||
spin_lock_init(&device->event_handler_lock);
|
||||
rwlock_init(&device->client_data_lock);
|
||||
|
|
|
@ -1187,7 +1187,7 @@ err_put:
|
|||
static ssize_t node_type_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
switch (dev->node_type) {
|
||||
case RDMA_NODE_IB_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
|
||||
|
@ -1204,7 +1204,7 @@ static DEVICE_ATTR_RO(node_type);
|
|||
static ssize_t sys_image_guid_show(struct device *device,
|
||||
struct device_attribute *dev_attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
return sprintf(buf, "%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[0]),
|
||||
|
@ -1217,7 +1217,7 @@ static DEVICE_ATTR_RO(sys_image_guid);
|
|||
static ssize_t node_guid_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
return sprintf(buf, "%04x:%04x:%04x:%04x\n",
|
||||
be16_to_cpu(((__be16 *) &dev->node_guid)[0]),
|
||||
|
@ -1230,7 +1230,7 @@ static DEVICE_ATTR_RO(node_guid);
|
|||
static ssize_t node_desc_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
return sprintf(buf, "%.64s\n", dev->node_desc);
|
||||
}
|
||||
|
@ -1239,7 +1239,7 @@ static ssize_t node_desc_store(struct device *device,
|
|||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
struct ib_device_modify desc = {};
|
||||
int ret;
|
||||
|
||||
|
@ -1258,7 +1258,7 @@ static DEVICE_ATTR_RW(node_desc);
|
|||
static ssize_t fw_ver_show(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
struct ib_device *dev = rdma_device_to_ibdev(device);
|
||||
|
||||
ib_get_device_fw_str(dev, buf);
|
||||
strlcat(buf, "\n", IB_FW_VERSION_NAME_MAX);
|
||||
|
|
|
@ -538,7 +538,8 @@ static struct bnxt_en_dev *bnxt_re_dev_probe(struct net_device *netdev)
|
|||
static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct bnxt_re_dev *rdev = to_bnxt_re_dev(device, ibdev.dev);
|
||||
struct bnxt_re_dev *rdev =
|
||||
rdma_device_to_drv_device(device, struct bnxt_re_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "0x%x\n", rdev->en_dev->pdev->vendor);
|
||||
}
|
||||
|
@ -547,7 +548,8 @@ static DEVICE_ATTR_RO(hw_rev);
|
|||
static ssize_t hca_type_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct bnxt_re_dev *rdev = to_bnxt_re_dev(device, ibdev.dev);
|
||||
struct bnxt_re_dev *rdev =
|
||||
rdma_device_to_drv_device(device, struct bnxt_re_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", rdev->ibdev.node_desc);
|
||||
}
|
||||
|
|
|
@ -1130,8 +1130,9 @@ static int iwch_query_port(struct ib_device *ibdev,
|
|||
static ssize_t hw_rev_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
|
||||
ibdev.dev);
|
||||
struct iwch_dev *iwch_dev =
|
||||
rdma_device_to_drv_device(dev, struct iwch_dev, ibdev);
|
||||
|
||||
pr_debug("%s dev 0x%p\n", __func__, dev);
|
||||
return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
|
||||
}
|
||||
|
@ -1140,8 +1141,8 @@ static DEVICE_ATTR_RO(hw_rev);
|
|||
static ssize_t hca_type_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
|
||||
ibdev.dev);
|
||||
struct iwch_dev *iwch_dev =
|
||||
rdma_device_to_drv_device(dev, struct iwch_dev, ibdev);
|
||||
struct ethtool_drvinfo info;
|
||||
struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
|
||||
|
||||
|
@ -1154,8 +1155,9 @@ static DEVICE_ATTR_RO(hca_type);
|
|||
static ssize_t board_id_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
|
||||
ibdev.dev);
|
||||
struct iwch_dev *iwch_dev =
|
||||
rdma_device_to_drv_device(dev, struct iwch_dev, ibdev);
|
||||
|
||||
pr_debug("%s dev 0x%p\n", __func__, dev);
|
||||
return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor,
|
||||
iwch_dev->rdev.rnic_info.pdev->device);
|
||||
|
|
|
@ -376,8 +376,9 @@ static int c4iw_query_port(struct ib_device *ibdev, u8 port,
|
|||
static ssize_t hw_rev_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
|
||||
ibdev.dev);
|
||||
struct c4iw_dev *c4iw_dev =
|
||||
rdma_device_to_drv_device(dev, struct c4iw_dev, ibdev);
|
||||
|
||||
pr_debug("dev 0x%p\n", dev);
|
||||
return sprintf(buf, "%d\n",
|
||||
CHELSIO_CHIP_RELEASE(c4iw_dev->rdev.lldi.adapter_type));
|
||||
|
@ -387,8 +388,8 @@ static DEVICE_ATTR_RO(hw_rev);
|
|||
static ssize_t hca_type_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
|
||||
ibdev.dev);
|
||||
struct c4iw_dev *c4iw_dev =
|
||||
rdma_device_to_drv_device(dev, struct c4iw_dev, ibdev);
|
||||
struct ethtool_drvinfo info;
|
||||
struct net_device *lldev = c4iw_dev->rdev.lldi.ports[0];
|
||||
|
||||
|
@ -401,8 +402,9 @@ static DEVICE_ATTR_RO(hca_type);
|
|||
static ssize_t board_id_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
|
||||
ibdev.dev);
|
||||
struct c4iw_dev *c4iw_dev =
|
||||
rdma_device_to_drv_device(dev, struct c4iw_dev, ibdev);
|
||||
|
||||
pr_debug("dev 0x%p\n", dev);
|
||||
return sprintf(buf, "%x.%x\n", c4iw_dev->rdev.lldi.pdev->vendor,
|
||||
c4iw_dev->rdev.lldi.pdev->device);
|
||||
|
|
|
@ -498,7 +498,7 @@ static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
|
|||
char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
|
||||
return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev);
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ static ssize_t board_id_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
int ret;
|
||||
|
||||
|
@ -524,7 +524,7 @@ static ssize_t boardversion_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* The string printed here is already newline-terminated. */
|
||||
|
@ -536,7 +536,7 @@ static ssize_t nctxts_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/*
|
||||
|
@ -555,7 +555,7 @@ static ssize_t nfreectxts_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* Return the number of free user ports (contexts) available. */
|
||||
|
@ -567,7 +567,7 @@ static ssize_t serial_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s", dd->serial);
|
||||
|
@ -579,7 +579,7 @@ static ssize_t chip_reset_store(struct device *device,
|
|||
size_t count)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
int ret;
|
||||
|
||||
|
@ -609,7 +609,7 @@ static ssize_t tempsense_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hfi1_ibdev *dev =
|
||||
container_of(device, struct hfi1_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
|
||||
struct hfi1_devdata *dd = dd_from_dev(dev);
|
||||
struct hfi1_temp temp;
|
||||
int ret;
|
||||
|
|
|
@ -2139,9 +2139,8 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr)
|
|||
static ssize_t hw_rev_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i40iw_ib_device *iwibdev = container_of(dev,
|
||||
struct i40iw_ib_device,
|
||||
ibdev.dev);
|
||||
struct i40iw_ib_device *iwibdev =
|
||||
rdma_device_to_drv_device(dev, struct i40iw_ib_device, ibdev);
|
||||
u32 hw_rev = iwibdev->iwdev->sc_dev.hw_rev;
|
||||
|
||||
return sprintf(buf, "%x\n", hw_rev);
|
||||
|
|
|
@ -2043,7 +2043,7 @@ static ssize_t hca_type_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx4_ib_dev *dev =
|
||||
container_of(device, struct mlx4_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx4_ib_dev, ib_dev);
|
||||
return sprintf(buf, "MT%d\n", dev->dev->persist->pdev->device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
@ -2052,7 +2052,7 @@ static ssize_t hw_rev_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx4_ib_dev *dev =
|
||||
container_of(device, struct mlx4_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx4_ib_dev, ib_dev);
|
||||
return sprintf(buf, "%x\n", dev->dev->rev_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
@ -2061,7 +2061,8 @@ static ssize_t board_id_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx4_ib_dev *dev =
|
||||
container_of(device, struct mlx4_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx4_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN,
|
||||
dev->dev->board_id);
|
||||
}
|
||||
|
|
|
@ -4104,7 +4104,7 @@ static ssize_t fw_pages_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx5_ib_dev *dev =
|
||||
container_of(device, struct mlx5_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%d\n", dev->mdev->priv.fw_pages);
|
||||
}
|
||||
|
@ -4114,7 +4114,7 @@ static ssize_t reg_pages_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx5_ib_dev *dev =
|
||||
container_of(device, struct mlx5_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%d\n", atomic_read(&dev->mdev->priv.reg_pages));
|
||||
}
|
||||
|
@ -4124,7 +4124,8 @@ static ssize_t hca_type_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx5_ib_dev *dev =
|
||||
container_of(device, struct mlx5_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "MT%d\n", dev->mdev->pdev->device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hca_type);
|
||||
|
@ -4133,7 +4134,8 @@ static ssize_t hw_rev_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx5_ib_dev *dev =
|
||||
container_of(device, struct mlx5_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%x\n", dev->mdev->rev_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
@ -4142,7 +4144,8 @@ static ssize_t board_id_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mlx5_ib_dev *dev =
|
||||
container_of(device, struct mlx5_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mlx5_ib_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%.*s\n", MLX5_BOARD_ID_LEN,
|
||||
dev->mdev->board_id);
|
||||
}
|
||||
|
|
|
@ -1081,7 +1081,8 @@ static ssize_t hw_rev_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mthca_dev *dev =
|
||||
container_of(device, struct mthca_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mthca_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%x\n", dev->rev_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(hw_rev);
|
||||
|
@ -1090,7 +1091,8 @@ static ssize_t hca_type_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mthca_dev *dev =
|
||||
container_of(device, struct mthca_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mthca_dev, ib_dev);
|
||||
|
||||
switch (dev->pdev->device) {
|
||||
case PCI_DEVICE_ID_MELLANOX_TAVOR:
|
||||
return sprintf(buf, "MT23108\n");
|
||||
|
@ -1111,7 +1113,8 @@ static ssize_t board_id_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mthca_dev *dev =
|
||||
container_of(device, struct mthca_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct mthca_dev, ib_dev);
|
||||
|
||||
return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(board_id);
|
||||
|
|
|
@ -2560,7 +2560,7 @@ static ssize_t hw_rev_show(struct device *dev,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct nes_ib_device *nesibdev =
|
||||
container_of(dev, struct nes_ib_device, ibdev.dev);
|
||||
rdma_device_to_drv_device(dev, struct nes_ib_device, ibdev);
|
||||
struct nes_vnic *nesvnic = nesibdev->nesvnic;
|
||||
|
||||
nes_debug(NES_DBG_INIT, "\n");
|
||||
|
|
|
@ -118,7 +118,8 @@ static void get_dev_fw_str(struct ib_device *device, char *str)
|
|||
static ssize_t hw_rev_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ocrdma_dev *dev = dev_get_drvdata(device);
|
||||
struct ocrdma_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct ocrdma_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "0x%x\n", dev->nic_info.pdev->vendor);
|
||||
}
|
||||
|
@ -127,7 +128,8 @@ static DEVICE_ATTR_RO(hw_rev);
|
|||
static ssize_t hca_type_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ocrdma_dev *dev = dev_get_drvdata(device);
|
||||
struct ocrdma_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct ocrdma_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->model_number[0]);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,8 @@ static int qedr_iw_port_immutable(struct ib_device *ibdev, u8 port_num,
|
|||
static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct qedr_dev *dev = dev_get_drvdata(device);
|
||||
struct qedr_dev *dev =
|
||||
rdma_device_to_drv_device(device, struct qedr_dev, ibdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "0x%x\n", dev->pdev->vendor);
|
||||
}
|
||||
|
|
|
@ -555,7 +555,7 @@ static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
|
|||
char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
|
||||
return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev);
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ static ssize_t hca_type_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
int ret;
|
||||
|
||||
|
@ -590,7 +590,7 @@ static ssize_t boardversion_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* The string printed here is already newline-terminated. */
|
||||
|
@ -602,7 +602,7 @@ static ssize_t localbus_info_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* The string printed here is already newline-terminated. */
|
||||
|
@ -614,7 +614,7 @@ static ssize_t nctxts_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* Return the number of user ports (contexts) available. */
|
||||
|
@ -630,7 +630,7 @@ static ssize_t nfreectxts_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
/* Return the number of free user ports (contexts) available. */
|
||||
|
@ -642,7 +642,7 @@ static ssize_t serial_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
|
||||
buf[sizeof(dd->serial)] = '\0';
|
||||
|
@ -657,7 +657,7 @@ static ssize_t chip_reset_store(struct device *device,
|
|||
size_t count)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
int ret;
|
||||
|
||||
|
@ -679,7 +679,7 @@ static ssize_t tempsense_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct qib_ibdev *dev =
|
||||
container_of(device, struct qib_ibdev, rdi.ibdev.dev);
|
||||
rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
|
||||
struct qib_devdata *dd = dd_from_dev(dev);
|
||||
int ret;
|
||||
int idx;
|
||||
|
|
|
@ -50,7 +50,7 @@ static ssize_t board_id_show(struct device *device,
|
|||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
rdma_device_to_drv_device(device, struct usnic_ib_dev, ib_dev);
|
||||
unsigned short subsystem_device_id;
|
||||
|
||||
mutex_lock(&us_ibdev->usdev_lock);
|
||||
|
@ -67,14 +67,13 @@ static DEVICE_ATTR_RO(board_id);
|
|||
static ssize_t
|
||||
config_show(struct device *device, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
rdma_device_to_drv_device(device, struct usnic_ib_dev, ib_dev);
|
||||
char *ptr;
|
||||
unsigned left;
|
||||
unsigned n;
|
||||
enum usnic_vnic_res_type res_type;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
|
||||
/* Buffer space limit is 1 page */
|
||||
ptr = buf;
|
||||
left = PAGE_SIZE;
|
||||
|
@ -130,9 +129,8 @@ static DEVICE_ATTR_RO(config);
|
|||
static ssize_t
|
||||
iface_show(struct device *device, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
rdma_device_to_drv_device(device, struct usnic_ib_dev, ib_dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
||||
netdev_name(us_ibdev->netdev));
|
||||
|
@ -142,9 +140,8 @@ static DEVICE_ATTR_RO(iface);
|
|||
static ssize_t
|
||||
max_vf_show(struct device *device, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
rdma_device_to_drv_device(device, struct usnic_ib_dev, ib_dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n",
|
||||
kref_read(&us_ibdev->vf_cnt));
|
||||
|
@ -154,10 +151,10 @@ static DEVICE_ATTR_RO(max_vf);
|
|||
static ssize_t
|
||||
qp_per_vf_show(struct device *device, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
rdma_device_to_drv_device(device, struct usnic_ib_dev, ib_dev);
|
||||
int qp_per_vf;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
qp_per_vf = max(us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_WQ],
|
||||
us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_RQ]);
|
||||
|
||||
|
@ -169,9 +166,8 @@ static DEVICE_ATTR_RO(qp_per_vf);
|
|||
static ssize_t
|
||||
cq_per_vf_show(struct device *device, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
rdma_device_to_drv_device(device, struct usnic_ib_dev, ib_dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_CQ]);
|
||||
|
|
|
@ -1129,8 +1129,8 @@ static int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid)
|
|||
static ssize_t parent_show(struct device *device,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct rxe_dev *rxe = container_of(device, struct rxe_dev,
|
||||
ib_dev.dev);
|
||||
struct rxe_dev *rxe =
|
||||
rdma_device_to_drv_device(device, struct rxe_dev, ib_dev);
|
||||
|
||||
return snprintf(buf, 16, "%s\n", rxe_parent_name(rxe, 1));
|
||||
}
|
||||
|
|
|
@ -4241,4 +4241,27 @@ rdma_set_device_sysfs_group(struct ib_device *dev,
|
|||
dev->groups[1] = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* rdma_device_to_ibdev - Get ib_device pointer from device pointer
|
||||
*
|
||||
* @device: device pointer for which ib_device pointer to retrieve
|
||||
*
|
||||
* rdma_device_to_ibdev() retrieves ib_device pointer from device.
|
||||
*
|
||||
*/
|
||||
static inline struct ib_device *rdma_device_to_ibdev(struct device *device)
|
||||
{
|
||||
return container_of(device, struct ib_device, dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* rdma_device_to_drv_device - Helper macro to reach back to driver's
|
||||
* ib_device holder structure from device pointer.
|
||||
*
|
||||
* NOTE: New drivers should not make use of this API; This API is only for
|
||||
* existing drivers who have exposed sysfs entries using
|
||||
* rdma_set_device_sysfs_group().
|
||||
*/
|
||||
#define rdma_device_to_drv_device(dev, drv_dev_struct, ibdev_member) \
|
||||
container_of(rdma_device_to_ibdev(dev), drv_dev_struct, ibdev_member)
|
||||
#endif /* IB_VERBS_H */
|
||||
|
|
Loading…
Reference in New Issue