1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
10 #include <rte_ether.h>
13 /* Macros for printing using RTE_LOG */
14 #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
15 #define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER2
16 #define RTE_LOGTYPE_VHOST_PORT RTE_LOGTYPE_USER3
18 enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
20 #define MAX_PKT_BURST 32 /* Max burst size for RX/TX */
22 struct device_statistics {
26 uint64_t rx_total_atomic;
30 struct rte_vhost_vring vr;
31 uint16_t last_avail_idx;
32 uint16_t last_used_idx;
36 /**< Number of memory regions for gpa to hpa translation. */
37 uint32_t nregions_hpa;
38 /**< Device MAC address (Obtained on first TX packet). */
39 struct rte_ether_addr mac_address;
40 /**< RX VMDQ queue number. */
42 /**< Vlan tag assigned to the pool */
44 /**< Data core that the device is added to. */
46 /**< A device is set as ready if the MAC address has been set. */
47 volatile uint8_t ready;
48 /**< Device is marked for removal from the data core. */
49 volatile uint8_t remove;
55 uint16_t pkts_inflight;
56 struct rte_vhost_memory *mem;
57 struct device_statistics stats;
58 TAILQ_ENTRY(vhost_dev) global_vdev_entry;
59 TAILQ_ENTRY(vhost_dev) lcore_vdev_entry;
61 #define MAX_QUEUE_PAIRS 4
62 struct vhost_queue queues[MAX_QUEUE_PAIRS * 2];
63 } __rte_cache_aligned;
65 TAILQ_HEAD(vhost_dev_tailq_list, vhost_dev);
68 #define REQUEST_DEV_REMOVAL 1
69 #define ACK_DEV_REMOVAL 0
72 * Structure containing data core specific information.
77 /* Flag to synchronize device removal. */
78 volatile uint8_t dev_removal_flag;
80 struct vhost_dev_tailq_list vdev_list;
84 struct rte_pci_addr addr;
89 struct dma_for_vhost {
90 struct dma_info dmas[RTE_MAX_QUEUES_PER_PORT * 2];
93 /* we implement non-extra virtio net features */
94 #define VIRTIO_NET_FEATURES 0
96 void vs_vhost_net_setup(struct vhost_dev *dev);
97 void vs_vhost_net_remove(struct vhost_dev *dev);
98 uint16_t vs_enqueue_pkts(struct vhost_dev *dev, uint16_t queue_id,
99 struct rte_mbuf **pkts, uint32_t count);
101 uint16_t vs_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id,
102 struct rte_mempool *mbuf_pool,
103 struct rte_mbuf **pkts, uint16_t count);
104 #endif /* _MAIN_H_ */