1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
5 #ifndef _VIRTIO_USER_DEV_H
6 #define _VIRTIO_USER_DEV_H
9 #include "../virtio_pci.h"
10 #include "../virtio_ring.h"
13 struct virtio_user_dev {
14 /* for vhost_user backend */
17 /* for vhost_kernel backend */
22 /* for both vhost_user and vhost_kernel */
23 int callfds[VIRTIO_MAX_VIRTQUEUES];
24 int kickfds[VIRTIO_MAX_VIRTQUEUES];
26 uint32_t max_queue_pairs;
29 uint64_t features; /* the negotiated features with driver,
30 * and will be sync with device
32 uint64_t device_features; /* supported features by device */
35 uint8_t mac_addr[ETHER_ADDR_LEN];
37 struct vring vrings[VIRTIO_MAX_VIRTQUEUES];
38 struct virtio_user_backend_ops *ops;
41 int is_vhost_user_by_type(const char *path);
42 int virtio_user_start_device(struct virtio_user_dev *dev);
43 int virtio_user_stop_device(struct virtio_user_dev *dev);
44 int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
45 int cq, int queue_size, const char *mac, char **ifname);
46 void virtio_user_dev_uninit(struct virtio_user_dev *dev);
47 void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);