Lines Matching refs:nsim_bus_dev
25 static struct nsim_bus_dev *to_nsim_bus_dev(struct device *dev) in to_nsim_bus_dev()
27 return container_of(dev, struct nsim_bus_dev, dev); in to_nsim_bus_dev()
34 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_dev_numvfs_store() local
45 ret = nsim_drv_configure_vfs(nsim_bus_dev, num_vfs); in nsim_bus_dev_numvfs_store()
55 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_dev_numvfs_show() local
57 return sprintf(buf, "%u\n", nsim_bus_dev->num_vfs); in nsim_bus_dev_numvfs_show()
68 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in new_port_store() local
73 if (!smp_load_acquire(&nsim_bus_dev->init)) in new_port_store()
79 ret = nsim_drv_port_add(nsim_bus_dev, NSIM_DEV_PORT_TYPE_PF, port_index); in new_port_store()
89 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in del_port_store() local
94 if (!smp_load_acquire(&nsim_bus_dev->init)) in del_port_store()
100 ret = nsim_drv_port_del(nsim_bus_dev, NSIM_DEV_PORT_TYPE_PF, port_index); in del_port_store()
124 struct nsim_bus_dev *nsim_bus_dev; in nsim_bus_dev_release() local
126 nsim_bus_dev = container_of(dev, struct nsim_bus_dev, dev); in nsim_bus_dev_release()
127 kfree(nsim_bus_dev); in nsim_bus_dev_release()
137 static struct nsim_bus_dev *
144 struct nsim_bus_dev *nsim_bus_dev; in new_device_store() local
173 nsim_bus_dev = nsim_bus_dev_new(id, port_count, num_queues); in new_device_store()
174 if (IS_ERR(nsim_bus_dev)) { in new_device_store()
175 err = PTR_ERR(nsim_bus_dev); in new_device_store()
181 smp_store_release(&nsim_bus_dev->init, true); in new_device_store()
183 list_add_tail(&nsim_bus_dev->list, &nsim_bus_dev_list); in new_device_store()
193 static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev);
198 struct nsim_bus_dev *nsim_bus_dev, *tmp; in del_device_store() local
222 list_for_each_entry_safe(nsim_bus_dev, tmp, &nsim_bus_dev_list, list) { in del_device_store()
223 if (nsim_bus_dev->dev.id != id) in del_device_store()
225 list_del(&nsim_bus_dev->list); in del_device_store()
226 nsim_bus_dev_del(nsim_bus_dev); in del_device_store()
389 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_probe() local
391 return nsim_drv_probe(nsim_bus_dev); in nsim_bus_probe()
396 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_bus_remove() local
398 nsim_drv_remove(nsim_bus_dev); in nsim_bus_remove()
403 struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); in nsim_num_vf() local
405 return nsim_bus_dev->num_vfs; in nsim_num_vf()
419 static struct nsim_bus_dev *
422 struct nsim_bus_dev *nsim_bus_dev; in nsim_bus_dev_new() local
425 nsim_bus_dev = kzalloc(sizeof(*nsim_bus_dev), GFP_KERNEL); in nsim_bus_dev_new()
426 if (!nsim_bus_dev) in nsim_bus_dev_new()
432 nsim_bus_dev->dev.id = err; in nsim_bus_dev_new()
433 nsim_bus_dev->dev.bus = &nsim_bus; in nsim_bus_dev_new()
434 nsim_bus_dev->dev.type = &nsim_bus_dev_type; in nsim_bus_dev_new()
435 nsim_bus_dev->port_count = port_count; in nsim_bus_dev_new()
436 nsim_bus_dev->num_queues = num_queues; in nsim_bus_dev_new()
437 nsim_bus_dev->initial_net = current->nsproxy->net_ns; in nsim_bus_dev_new()
438 nsim_bus_dev->max_vfs = NSIM_BUS_DEV_MAX_VFS; in nsim_bus_dev_new()
440 smp_store_release(&nsim_bus_dev->init, false); in nsim_bus_dev_new()
442 err = device_register(&nsim_bus_dev->dev); in nsim_bus_dev_new()
446 return nsim_bus_dev; in nsim_bus_dev_new()
449 ida_free(&nsim_bus_dev_ids, nsim_bus_dev->dev.id); in nsim_bus_dev_new()
450 put_device(&nsim_bus_dev->dev); in nsim_bus_dev_new()
451 nsim_bus_dev = NULL; in nsim_bus_dev_new()
453 kfree(nsim_bus_dev); in nsim_bus_dev_new()
457 static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev) in nsim_bus_dev_del() argument
460 smp_store_release(&nsim_bus_dev->init, false); in nsim_bus_dev_del()
461 ida_free(&nsim_bus_dev_ids, nsim_bus_dev->dev.id); in nsim_bus_dev_del()
462 device_unregister(&nsim_bus_dev->dev); in nsim_bus_dev_del()
493 struct nsim_bus_dev *nsim_bus_dev, *tmp; in nsim_bus_exit() local
501 list_for_each_entry_safe(nsim_bus_dev, tmp, &nsim_bus_dev_list, list) { in nsim_bus_exit()
502 list_del(&nsim_bus_dev->list); in nsim_bus_exit()
503 nsim_bus_dev_del(nsim_bus_dev); in nsim_bus_exit()