net/virtio-user: fix multiple queues fail in server mode
[dpdk.git] / drivers / net / virtio / virtio_user / virtio_user_dev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation
3  */
4
5 #ifndef _VIRTIO_USER_DEV_H
6 #define _VIRTIO_USER_DEV_H
7
8 #include <limits.h>
9 #include <stdbool.h>
10 #include "../virtio_pci.h"
11 #include "../virtio_ring.h"
12 #include "vhost.h"
13
14 struct virtio_user_dev {
15         /* for vhost_user backend */
16         int             vhostfd;
17         int             listenfd;   /* listening fd */
18         bool            is_server;  /* server or client mode */
19
20         /* for vhost_kernel backend */
21         char            *ifname;
22         int             *vhostfds;
23         int             *tapfds;
24
25         /* for both vhost_user and vhost_kernel */
26         int             callfds[VIRTIO_MAX_VIRTQUEUES];
27         int             kickfds[VIRTIO_MAX_VIRTQUEUES];
28         int             mac_specified;
29         uint32_t        max_queue_pairs;
30         uint32_t        queue_pairs;
31         uint32_t        queue_size;
32         uint64_t        features; /* the negotiated features with driver,
33                                    * and will be sync with device
34                                    */
35         uint64_t        device_features; /* supported features by device */
36         uint8_t         status;
37         uint16_t        port_id;
38         uint8_t         mac_addr[ETHER_ADDR_LEN];
39         char            path[PATH_MAX];
40         struct vring    vrings[VIRTIO_MAX_VIRTQUEUES];
41         struct virtio_user_backend_ops *ops;
42         pthread_mutex_t mutex;
43         bool            started;
44 };
45
46 int is_vhost_user_by_type(const char *path);
47 int virtio_user_start_device(struct virtio_user_dev *dev);
48 int virtio_user_stop_device(struct virtio_user_dev *dev);
49 int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
50                          int cq, int queue_size, const char *mac, char **ifname);
51 void virtio_user_dev_uninit(struct virtio_user_dev *dev);
52 void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
53 uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);
54 #endif