1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
10 /* Macros for printing using RTE_LOG */
11 #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
12 #define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER2
13 #define RTE_LOGTYPE_VHOST_PORT RTE_LOGTYPE_USER3
15 /* State of virtio device. */
16 #define DEVICE_MAC_LEARNING 0
18 #define DEVICE_SAFE_REMOVE 2
20 #define MAX_QUEUES 512
22 /* Max burst size for RX/TX */
23 #define MAX_PKT_BURST 32
25 /* Max number of devices. Limited by the application. */
26 #define MAX_DEVICES 64
28 enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
30 /* Per-device statistics struct */
31 struct device_statistics {
33 rte_atomic64_t rx_total_atomic;
36 rte_atomic64_t rx_atomic;
37 /**< Bad inner IP csum for tunneling pkt */
38 rte_atomic64_t rx_bad_ip_csum;
39 /**< Bad inner L4 csum for tunneling pkt */
40 rte_atomic64_t rx_bad_l4_csum;
41 } __rte_cache_aligned;
44 * Device linked list structure for data path.
48 /**< Number of memory regions for gpa to hpa translation. */
49 uint32_t nregions_hpa;
50 /**< Memory region information for gpa to hpa translation. */
51 struct virtio_memory_regions_hpa *regions_hpa;
52 /**< Device MAC address (Obtained on first TX packet). */
53 struct ether_addr mac_address;
54 /**< RX queue number. */
56 /**< Data core that the device is added to. */
58 /**< A device is set as ready if the MAC address has been set. */
59 volatile uint8_t ready;
60 /**< Device is marked for removal from the data core. */
61 volatile uint8_t remove;
62 } __rte_cache_aligned;
65 * Structure containing data core specific information.
67 struct lcore_ll_info {
68 /**< Pointer to head in free linked list. */
69 struct virtio_net_data_ll *ll_root_free;
70 /**< Pointer to head of used linked list. */
71 struct virtio_net_data_ll *ll_root_used;
72 /**< Number of devices on lcore. */
74 /**< Flag to synchronize device removal. */
75 volatile uint8_t dev_removal_flag;
79 /**< Pointer to data core specific lcore_ll_info struct */
80 struct lcore_ll_info *lcore_ll;
83 struct virtio_net_data_ll {
84 /**< Pointer to device created by configuration core. */
85 struct vhost_dev *vdev;
86 /**< Pointer to next device in linked list. */
87 struct virtio_net_data_ll *next;
91 virtio_dev_rx(int vid, struct rte_mbuf **pkts, uint32_t count);