]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause |
2 | * Copyright(c) 2010-2015 Intel Corporation | |
7c673cae FG |
3 | */ |
4 | ||
5 | #ifndef _MAIN_H_ | |
6 | #define _MAIN_H_ | |
7 | ||
8 | #include <rte_ether.h> | |
9 | ||
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 | |
14 | ||
15 | /* State of virtio device. */ | |
16 | #define DEVICE_MAC_LEARNING 0 | |
17 | #define DEVICE_RX 1 | |
18 | #define DEVICE_SAFE_REMOVE 2 | |
19 | ||
20 | #define MAX_QUEUES 512 | |
21 | ||
22 | /* Max burst size for RX/TX */ | |
23 | #define MAX_PKT_BURST 32 | |
24 | ||
25 | /* Max number of devices. Limited by the application. */ | |
26 | #define MAX_DEVICES 64 | |
27 | ||
11fdf7f2 TL |
28 | enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM}; |
29 | ||
7c673cae FG |
30 | /* Per-device statistics struct */ |
31 | struct device_statistics { | |
32 | uint64_t tx_total; | |
33 | rte_atomic64_t rx_total_atomic; | |
34 | uint64_t rx_total; | |
35 | uint64_t tx; | |
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; | |
42 | ||
43 | /** | |
44 | * Device linked list structure for data path. | |
45 | */ | |
46 | struct vhost_dev { | |
47 | int vid; | |
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. */ | |
55 | uint16_t rx_q; | |
56 | /**< Data core that the device is added to. */ | |
57 | uint16_t coreid; | |
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; | |
63 | ||
64 | /** | |
65 | * Structure containing data core specific information. | |
66 | */ | |
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. */ | |
73 | uint32_t device_num; | |
74 | /**< Flag to synchronize device removal. */ | |
75 | volatile uint8_t dev_removal_flag; | |
76 | }; | |
77 | ||
78 | struct lcore_info { | |
79 | /**< Pointer to data core specific lcore_ll_info struct */ | |
80 | struct lcore_ll_info *lcore_ll; | |
81 | }; | |
82 | ||
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; | |
88 | }; | |
89 | ||
90 | uint32_t | |
91 | virtio_dev_rx(int vid, struct rte_mbuf **pkts, uint32_t count); | |
92 | ||
93 | #endif /* _MAIN_H_ */ |