Lines Matching refs:nsim_bus_dev
22 static struct nsim_bus_dev *to_nsim_bus_dev(struct device *dev) in to_nsim_bus_dev()
24 return container_of(dev, struct nsim_bus_dev, dev); in to_nsim_bus_dev()
27 static int nsim_bus_dev_vfs_enable(struct nsim_bus_dev *nsim_bus_dev, in nsim_bus_dev_vfs_enable() argument
30 nsim_bus_dev->vfconfigs = kcalloc(num_vfs, in nsim_bus_dev_vfs_enable()
33 if (!nsim_bus_dev->vfconfigs) in nsim_bus_dev_vfs_enable()
35 nsim_bus_dev->num_vfs = num_vfs; in nsim_bus_dev_vfs_enable()
40 static void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev) in nsim_bus_dev_vfs_disable() argument
42 kfree(nsim_bus_dev->vfconfigs); in nsim_bus_dev_vfs_disable()
43 nsim_bus_dev->vfconfigs = NULL; in nsim_bus_dev_vfs_disable()
44 nsim_bus_dev->num_vfs = 0; in nsim_bus_dev_vfs_disable()
51 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_dev_numvfs_store() local
60 if (nsim_bus_dev->num_vfs == num_vfs) in nsim_bus_dev_numvfs_store()
62 if (nsim_bus_dev->num_vfs && num_vfs) { in nsim_bus_dev_numvfs_store()
68 ret = nsim_bus_dev_vfs_enable(nsim_bus_dev, num_vfs); in nsim_bus_dev_numvfs_store()
72 nsim_bus_dev_vfs_disable(nsim_bus_dev); in nsim_bus_dev_numvfs_store()
86 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_dev_numvfs_show() local
88 return sprintf(buf, "%u\n", nsim_bus_dev->num_vfs); in nsim_bus_dev_numvfs_show()
99 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in new_port_store() local
106 if (!smp_load_acquire(&nsim_bus_dev->init)) in new_port_store()
114 mutex_lock(&nsim_bus_dev->nsim_bus_reload_lock); in new_port_store()
116 ret = nsim_dev_port_add(nsim_bus_dev, port_index); in new_port_store()
118 mutex_unlock(&nsim_bus_dev->nsim_bus_reload_lock); in new_port_store()
128 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in del_port_store() local
135 if (!smp_load_acquire(&nsim_bus_dev->init)) in del_port_store()
143 mutex_lock(&nsim_bus_dev->nsim_bus_reload_lock); in del_port_store()
145 ret = nsim_dev_port_del(nsim_bus_dev, port_index); in del_port_store()
147 mutex_unlock(&nsim_bus_dev->nsim_bus_reload_lock); in del_port_store()
171 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_dev_release() local
173 nsim_bus_dev_vfs_disable(nsim_bus_dev); in nsim_bus_dev_release()
181 static struct nsim_bus_dev *
187 struct nsim_bus_dev *nsim_bus_dev; in new_device_store() local
215 nsim_bus_dev = nsim_bus_dev_new(id, port_count); in new_device_store()
216 if (IS_ERR(nsim_bus_dev)) { in new_device_store()
217 err = PTR_ERR(nsim_bus_dev); in new_device_store()
222 smp_store_release(&nsim_bus_dev->init, true); in new_device_store()
224 list_add_tail(&nsim_bus_dev->list, &nsim_bus_dev_list); in new_device_store()
234 static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev);
239 struct nsim_bus_dev *nsim_bus_dev, *tmp; in del_device_store() local
263 list_for_each_entry_safe(nsim_bus_dev, tmp, &nsim_bus_dev_list, list) { in del_device_store()
264 if (nsim_bus_dev->dev.id != id) in del_device_store()
266 list_del(&nsim_bus_dev->list); in del_device_store()
267 nsim_bus_dev_del(nsim_bus_dev); in del_device_store()
285 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_probe() local
287 return nsim_dev_probe(nsim_bus_dev); in nsim_bus_probe()
292 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_remove() local
294 nsim_dev_remove(nsim_bus_dev); in nsim_bus_remove()
300 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_num_vf() local
302 return nsim_bus_dev->num_vfs; in nsim_num_vf()
314 static struct nsim_bus_dev *
317 struct nsim_bus_dev *nsim_bus_dev; in nsim_bus_dev_new() local
320 nsim_bus_dev = kzalloc(sizeof(*nsim_bus_dev), GFP_KERNEL); in nsim_bus_dev_new()
321 if (!nsim_bus_dev) in nsim_bus_dev_new()
327 nsim_bus_dev->dev.id = err; in nsim_bus_dev_new()
328 nsim_bus_dev->dev.bus = &nsim_bus; in nsim_bus_dev_new()
329 nsim_bus_dev->dev.type = &nsim_bus_dev_type; in nsim_bus_dev_new()
330 nsim_bus_dev->port_count = port_count; in nsim_bus_dev_new()
331 nsim_bus_dev->initial_net = current->nsproxy->net_ns; in nsim_bus_dev_new()
332 mutex_init(&nsim_bus_dev->nsim_bus_reload_lock); in nsim_bus_dev_new()
334 smp_store_release(&nsim_bus_dev->init, false); in nsim_bus_dev_new()
336 err = device_register(&nsim_bus_dev->dev); in nsim_bus_dev_new()
339 return nsim_bus_dev; in nsim_bus_dev_new()
342 ida_free(&nsim_bus_dev_ids, nsim_bus_dev->dev.id); in nsim_bus_dev_new()
344 kfree(nsim_bus_dev); in nsim_bus_dev_new()
348 static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev) in nsim_bus_dev_del() argument
351 smp_store_release(&nsim_bus_dev->init, false); in nsim_bus_dev_del()
352 device_unregister(&nsim_bus_dev->dev); in nsim_bus_dev_del()
353 ida_free(&nsim_bus_dev_ids, nsim_bus_dev->dev.id); in nsim_bus_dev_del()
354 kfree(nsim_bus_dev); in nsim_bus_dev_del()
384 struct nsim_bus_dev *nsim_bus_dev, *tmp; in nsim_bus_exit() local
390 list_for_each_entry_safe(nsim_bus_dev, tmp, &nsim_bus_dev_list, list) { in nsim_bus_exit()
391 list_del(&nsim_bus_dev->list); in nsim_bus_exit()
392 nsim_bus_dev_del(nsim_bus_dev); in nsim_bus_exit()