xref: /openbmc/qemu/include/net/vhost_net.h (revision 6fae7ce1488e3f5bdcc1747564ea68e7f6f0e931)
1 #ifndef VHOST_NET_H
2 #define VHOST_NET_H
3 
4 #include "net/net.h"
5 #include "hw/virtio/vhost-backend.h"
6 
7 struct vhost_net;
8 typedef struct vhost_net VHostNetState;
9 
10 typedef uint64_t (GetAckedFeatures)(NetClientState *nc);
11 typedef void (SaveAcketFeatures)(NetClientState *nc);
12 
13 typedef struct VhostNetOptions {
14     VhostBackendType backend_type;
15     NetClientState *net_backend;
16     uint32_t busyloop_timeout;
17     unsigned int nvqs;
18     const int *feature_bits;
19     int max_tx_queue_size;
20     bool is_vhost_user;
21     GetAckedFeatures *get_acked_features;
22     SaveAcketFeatures *save_acked_features;
23     void *opaque;
24 } VhostNetOptions;
25 
26 uint64_t vhost_net_get_max_queues(VHostNetState *net);
27 struct vhost_net *vhost_net_init(VhostNetOptions *options);
28 
29 int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
30                     int data_queue_pairs, int cvq);
31 void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
32                     int data_queue_pairs, int cvq);
33 
34 void vhost_net_cleanup(VHostNetState *net);
35 
36 uint64_t vhost_net_get_features(VHostNetState *net, uint64_t features);
37 void vhost_net_ack_features(VHostNetState *net, uint64_t features);
38 
39 int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
40                          uint32_t config_len);
41 
42 int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
43                          uint32_t offset, uint32_t size, uint32_t flags);
44 bool vhost_net_virtqueue_pending(VHostNetState *net, int n);
45 void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
46                               int idx, bool mask);
47 bool vhost_net_config_pending(VHostNetState *net);
48 void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask);
49 int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr);
50 VHostNetState *get_vhost_net(NetClientState *nc);
51 
52 int vhost_net_set_vring_enable(NetClientState *nc, int enable);
53 
54 uint64_t vhost_net_get_acked_features(VHostNetState *net);
55 
56 int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu);
57 
58 void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
59                                int vq_index);
60 int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
61                                 int vq_index);
62 
63 void vhost_net_save_acked_features(NetClientState *nc);
64 #endif
65