Lines Matching refs:vdev

28 	struct vdpa_device *vdev = dev_to_vdpa(d);  in vdpa_dev_probe()  local
29 struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver); in vdpa_dev_probe()
30 const struct vdpa_config_ops *ops = vdev->config; in vdpa_dev_probe()
34 max_num = ops->get_vq_num_max(vdev); in vdpa_dev_probe()
36 min_num = ops->get_vq_num_min(vdev); in vdpa_dev_probe()
41 ret = drv->probe(vdev); in vdpa_dev_probe()
48 struct vdpa_device *vdev = dev_to_vdpa(d); in vdpa_dev_remove() local
49 struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver); in vdpa_dev_remove()
52 drv->remove(vdev); in vdpa_dev_remove()
63 struct vdpa_device *vdev = dev_to_vdpa(d); in vdpa_release_dev() local
64 const struct vdpa_config_ops *ops = vdev->config; in vdpa_release_dev()
67 ops->free(vdev); in vdpa_release_dev()
69 ida_simple_remove(&vdpa_index_ida, vdev->index); in vdpa_release_dev()
70 mutex_destroy(&vdev->cf_mutex); in vdpa_release_dev()
71 kfree(vdev); in vdpa_release_dev()
95 struct vdpa_device *vdev; in __vdpa_alloc_device() local
109 vdev = kzalloc(size, GFP_KERNEL); in __vdpa_alloc_device()
110 if (!vdev) in __vdpa_alloc_device()
117 vdev->dev.bus = &vdpa_bus; in __vdpa_alloc_device()
118 vdev->dev.parent = parent; in __vdpa_alloc_device()
119 vdev->dev.release = vdpa_release_dev; in __vdpa_alloc_device()
120 vdev->index = err; in __vdpa_alloc_device()
121 vdev->config = config; in __vdpa_alloc_device()
122 vdev->features_valid = false; in __vdpa_alloc_device()
123 vdev->use_va = use_va; in __vdpa_alloc_device()
126 err = dev_set_name(&vdev->dev, "%s", name); in __vdpa_alloc_device()
128 err = dev_set_name(&vdev->dev, "vdpa%u", vdev->index); in __vdpa_alloc_device()
132 mutex_init(&vdev->cf_mutex); in __vdpa_alloc_device()
133 device_initialize(&vdev->dev); in __vdpa_alloc_device()
135 return vdev; in __vdpa_alloc_device()
138 ida_simple_remove(&vdpa_index_ida, vdev->index); in __vdpa_alloc_device()
140 kfree(vdev); in __vdpa_alloc_device()
148 struct vdpa_device *vdev = container_of(dev, struct vdpa_device, dev); in vdpa_name_match() local
150 return (strcmp(dev_name(&vdev->dev), data) == 0); in vdpa_name_match()
153 static int __vdpa_register_device(struct vdpa_device *vdev, int nvqs) in __vdpa_register_device() argument
157 vdev->nvqs = nvqs; in __vdpa_register_device()
160 dev = bus_find_device(&vdpa_bus, NULL, dev_name(&vdev->dev), vdpa_name_match); in __vdpa_register_device()
165 return device_add(&vdev->dev); in __vdpa_register_device()
178 int _vdpa_register_device(struct vdpa_device *vdev, int nvqs) in _vdpa_register_device() argument
180 if (!vdev->mdev) in _vdpa_register_device()
183 return __vdpa_register_device(vdev, nvqs); in _vdpa_register_device()
195 int vdpa_register_device(struct vdpa_device *vdev, int nvqs) in vdpa_register_device() argument
200 err = __vdpa_register_device(vdev, nvqs); in vdpa_register_device()
212 void _vdpa_unregister_device(struct vdpa_device *vdev) in _vdpa_unregister_device() argument
215 WARN_ON(!vdev->mdev); in _vdpa_unregister_device()
216 device_unregister(&vdev->dev); in _vdpa_unregister_device()
224 void vdpa_unregister_device(struct vdpa_device *vdev) in vdpa_unregister_device() argument
227 device_unregister(&vdev->dev); in vdpa_unregister_device()
282 struct vdpa_device *vdev = container_of(dev, struct vdpa_device, dev); in vdpa_match_remove() local
283 struct vdpa_mgmt_dev *mdev = vdev->mdev; in vdpa_match_remove()
286 mdev->ops->dev_del(mdev, vdev); in vdpa_match_remove()
310 void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, in vdpa_get_config() argument
313 const struct vdpa_config_ops *ops = vdev->config; in vdpa_get_config()
315 mutex_lock(&vdev->cf_mutex); in vdpa_get_config()
320 if (!vdev->features_valid) in vdpa_get_config()
321 vdpa_set_features(vdev, 0); in vdpa_get_config()
322 ops->get_config(vdev, offset, buf, len); in vdpa_get_config()
323 mutex_unlock(&vdev->cf_mutex); in vdpa_get_config()
334 void vdpa_set_config(struct vdpa_device *vdev, unsigned int offset, in vdpa_set_config() argument
337 mutex_lock(&vdev->cf_mutex); in vdpa_set_config()
338 vdev->config->set_config(vdev, offset, buf, length); in vdpa_set_config()
339 mutex_unlock(&vdev->cf_mutex); in vdpa_set_config()
543 struct vdpa_device *vdev; in vdpa_nl_cmd_dev_del_set_doit() local
559 vdev = container_of(dev, struct vdpa_device, dev); in vdpa_nl_cmd_dev_del_set_doit()
560 if (!vdev->mdev) { in vdpa_nl_cmd_dev_del_set_doit()
565 mdev = vdev->mdev; in vdpa_nl_cmd_dev_del_set_doit()
566 mdev->ops->dev_del(mdev, vdev); in vdpa_nl_cmd_dev_del_set_doit()
575 vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq, in vdpa_dev_fill() argument
589 err = vdpa_nl_mgmtdev_handle_fill(msg, vdev->mdev); in vdpa_dev_fill()
593 device_id = vdev->config->get_device_id(vdev); in vdpa_dev_fill()
594 vendor_id = vdev->config->get_vendor_id(vdev); in vdpa_dev_fill()
595 max_vq_size = vdev->config->get_vq_num_max(vdev); in vdpa_dev_fill()
596 if (vdev->config->get_vq_num_min) in vdpa_dev_fill()
597 min_vq_size = vdev->config->get_vq_num_min(vdev); in vdpa_dev_fill()
600 if (nla_put_string(msg, VDPA_ATTR_DEV_NAME, dev_name(&vdev->dev))) in vdpa_dev_fill()
606 if (nla_put_u32(msg, VDPA_ATTR_DEV_MAX_VQS, vdev->nvqs)) in vdpa_dev_fill()
623 struct vdpa_device *vdev; in vdpa_nl_cmd_dev_get_doit() local
643 vdev = container_of(dev, struct vdpa_device, dev); in vdpa_nl_cmd_dev_get_doit()
644 if (!vdev->mdev) { in vdpa_nl_cmd_dev_get_doit()
648 err = vdpa_dev_fill(vdev, msg, info->snd_portid, info->snd_seq, 0, info->extack); in vdpa_nl_cmd_dev_get_doit()
669 struct vdpa_device *vdev = container_of(dev, struct vdpa_device, dev); in vdpa_dev_dump() local
673 if (!vdev->mdev) in vdpa_dev_dump()
679 err = vdpa_dev_fill(vdev, info->msg, NETLINK_CB(info->cb->skb).portid, in vdpa_dev_dump()
704 static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev, in vdpa_dev_net_mq_config_fill() argument
717 static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) in vdpa_dev_net_config_fill() argument
723 vdpa_get_config(vdev, 0, &config, sizeof(config)); in vdpa_dev_net_config_fill()
737 features = vdev->config->get_features(vdev); in vdpa_dev_net_config_fill()
739 return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config); in vdpa_dev_net_config_fill()
743 vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq, in vdpa_dev_config_fill() argument
755 if (nla_put_string(msg, VDPA_ATTR_DEV_NAME, dev_name(&vdev->dev))) { in vdpa_dev_config_fill()
760 device_id = vdev->config->get_device_id(vdev); in vdpa_dev_config_fill()
768 err = vdpa_dev_net_config_fill(vdev, msg); in vdpa_dev_config_fill()
787 struct vdpa_device *vdev; in vdpa_nl_cmd_dev_config_get_doit() local
807 vdev = container_of(dev, struct vdpa_device, dev); in vdpa_nl_cmd_dev_config_get_doit()
808 if (!vdev->mdev) { in vdpa_nl_cmd_dev_config_get_doit()
813 err = vdpa_dev_config_fill(vdev, msg, info->snd_portid, info->snd_seq, in vdpa_nl_cmd_dev_config_get_doit()
829 struct vdpa_device *vdev = container_of(dev, struct vdpa_device, dev); in vdpa_dev_config_dump() local
833 if (!vdev->mdev) in vdpa_dev_config_dump()
839 err = vdpa_dev_config_fill(vdev, info->msg, NETLINK_CB(info->cb->skb).portid, in vdpa_dev_config_dump()