1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
10 #include <rte_ether.h>
12 /* Macros for printing using RTE_LOG */
13 #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
14 #define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER2
15 #define RTE_LOGTYPE_VHOST_PORT RTE_LOGTYPE_USER3
17 enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
19 #define MAX_PKT_BURST 32 /* Max burst size for RX/TX */
21 struct device_statistics {
24 rte_atomic64_t rx_atomic;
25 rte_atomic64_t rx_total_atomic;
29 struct rte_vhost_vring vr;
30 uint16_t last_avail_idx;
31 uint16_t last_used_idx;
35 /**< Number of memory regions for gpa to hpa translation. */
36 uint32_t nregions_hpa;
37 /**< Device MAC address (Obtained on first TX packet). */
38 struct rte_ether_addr mac_address;
39 /**< RX VMDQ queue number. */
41 /**< Vlan tag assigned to the pool */
43 /**< Data core that the device is added to. */
45 /**< A device is set as ready if the MAC address has been set. */
46 volatile uint8_t ready;
47 /**< Device is marked for removal from the data core. */
48 volatile uint8_t remove;
54 struct rte_vhost_memory *mem;
55 struct device_statistics stats;
56 TAILQ_ENTRY(vhost_dev) global_vdev_entry;
57 TAILQ_ENTRY(vhost_dev) lcore_vdev_entry;
59 #define MAX_QUEUE_PAIRS 4
60 struct vhost_queue queues[MAX_QUEUE_PAIRS * 2];
61 } __rte_cache_aligned;
63 TAILQ_HEAD(vhost_dev_tailq_list, vhost_dev);
66 #define REQUEST_DEV_REMOVAL 1
67 #define ACK_DEV_REMOVAL 0
70 * Structure containing data core specific information.
75 /* Flag to synchronize device removal. */
76 volatile uint8_t dev_removal_flag;
78 struct vhost_dev_tailq_list vdev_list;
81 /* we implement non-extra virtio net features */
82 #define VIRTIO_NET_FEATURES 0
84 void vs_vhost_net_setup(struct vhost_dev *dev);
85 void vs_vhost_net_remove(struct vhost_dev *dev);
86 uint16_t vs_enqueue_pkts(struct vhost_dev *dev, uint16_t queue_id,
87 struct rte_mbuf **pkts, uint32_t count);
89 uint16_t vs_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id,
90 struct rte_mempool *mbuf_pool,
91 struct rte_mbuf **pkts, uint16_t count);