| 422 | } |
| 423 | |
| 424 | int |
| 425 | vduse_device_create(const char *path, bool compliant_ol_flags) |
| 426 | { |
| 427 | int control_fd, dev_fd, vid, ret; |
| 428 | rte_thread_t fdset_tid; |
| 429 | uint32_t i, max_queue_pairs, total_queues; |
| 430 | struct virtio_net *dev; |
| 431 | struct virtio_net_config vnet_config = {{ 0 }}; |
| 432 | uint64_t ver = VHOST_VDUSE_API_VERSION; |
| 433 | uint64_t features; |
| 434 | struct vduse_dev_config *dev_config = NULL; |
| 435 | const char *name = path + strlen("/dev/vduse/"); |
| 436 | |
| 437 | /* If first device, create events dispatcher thread */ |
| 438 | if (vduse_events_thread == false) { |
| 439 | /** |
| 440 | * create a pipe which will be waited by poll and notified to |
| 441 | * rebuild the wait list of poll. |
| 442 | */ |
| 443 | if (fdset_pipe_init(&vduse.fdset) < 0) { |
| 444 | VHOST_LOG_CONFIG(path, ERR, "failed to create pipe for vduse fdset\n"); |
| 445 | return -1; |
| 446 | } |
| 447 | |
| 448 | ret = rte_thread_create_internal_control(&fdset_tid, "vduse-evt", |
| 449 | fdset_event_dispatch, &vduse.fdset); |
| 450 | if (ret != 0) { |
| 451 | VHOST_LOG_CONFIG(path, ERR, "failed to create vduse fdset handling thread\n"); |
| 452 | fdset_pipe_uninit(&vduse.fdset); |
| 453 | return -1; |
| 454 | } |
| 455 | |
| 456 | vduse_events_thread = true; |
| 457 | } |
| 458 | |
| 459 | control_fd = open(VDUSE_CTRL_PATH, O_RDWR); |
| 460 | if (control_fd < 0) { |
| 461 | VHOST_LOG_CONFIG(name, ERR, "Failed to open %s: %s\n", |
| 462 | VDUSE_CTRL_PATH, strerror(errno)); |
| 463 | return -1; |
| 464 | } |
| 465 | |
| 466 | if (ioctl(control_fd, VDUSE_SET_API_VERSION, &ver)) { |
| 467 | VHOST_LOG_CONFIG(name, ERR, "Failed to set API version: %" PRIu64 ": %s\n", |
| 468 | ver, strerror(errno)); |
| 469 | ret = -1; |
| 470 | goto out_ctrl_close; |
| 471 | } |
| 472 | |
| 473 | dev_config = malloc(offsetof(struct vduse_dev_config, config) + |
| 474 | sizeof(vnet_config)); |
| 475 | if (!dev_config) { |
| 476 | VHOST_LOG_CONFIG(name, ERR, "Failed to allocate VDUSE config\n"); |
| 477 | ret = -1; |
| 478 | goto out_ctrl_close; |
| 479 | } |
| 480 | |
| 481 | ret = rte_vhost_driver_get_features(path, &features); |
no test coverage detected