| 264 | } |
| 265 | |
| 266 | static int |
| 267 | insert_vdev(const char *name, const char *args, |
| 268 | struct rte_vdev_device **p_dev, |
| 269 | bool init) |
| 270 | { |
| 271 | struct rte_vdev_device *dev; |
| 272 | struct rte_devargs *devargs; |
| 273 | int ret; |
| 274 | |
| 275 | if (name == NULL) |
| 276 | return -EINVAL; |
| 277 | |
| 278 | devargs = alloc_devargs(name, args); |
| 279 | |
| 280 | if (!devargs) |
| 281 | return -ENOMEM; |
| 282 | |
| 283 | dev = calloc(1, sizeof(*dev)); |
| 284 | if (!dev) { |
| 285 | ret = -ENOMEM; |
| 286 | goto fail; |
| 287 | } |
| 288 | |
| 289 | dev->device.bus = &rte_vdev_bus; |
| 290 | dev->device.numa_node = SOCKET_ID_ANY; |
| 291 | |
| 292 | if (find_vdev(name)) { |
| 293 | /* |
| 294 | * A vdev is expected to have only one port. |
| 295 | * So there is no reason to try probing again, |
| 296 | * even with new arguments. |
| 297 | */ |
| 298 | ret = -EEXIST; |
| 299 | goto fail; |
| 300 | } |
| 301 | |
| 302 | if (init) |
| 303 | rte_devargs_insert(&devargs); |
| 304 | dev->device.devargs = devargs; |
| 305 | dev->device.name = devargs->name; |
| 306 | TAILQ_INSERT_TAIL(&vdev_device_list, dev, next); |
| 307 | |
| 308 | if (p_dev) |
| 309 | *p_dev = dev; |
| 310 | |
| 311 | return 0; |
| 312 | fail: |
| 313 | rte_devargs_reset(devargs); |
| 314 | free(devargs); |
| 315 | free(dev); |
| 316 | return ret; |
| 317 | } |
| 318 | |
| 319 | int |
| 320 | rte_vdev_init(const char *name, const char *args) |
no test coverage detected