Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | #ifndef __VIRTIO_VHOST_USER_H__ |
| 16 | #define __VIRTIO_VHOST_USER_H__ |
Mohsin Kazmi | a7a2281 | 2020-08-31 17:17:16 +0200 | [diff] [blame] | 17 | |
| 18 | #include <vnet/devices/virtio/virtio_std.h> |
| 19 | #include <vnet/devices/virtio/vhost_std.h> |
| 20 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 21 | /* vhost-user data structures */ |
| 22 | |
| 23 | #define VHOST_MEMORY_MAX_NREGIONS 8 |
| 24 | #define VHOST_USER_MSG_HDR_SZ 12 |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 25 | #define VHOST_VRING_MAX_N 16 //8TX + 8RX |
| 26 | #define VHOST_VRING_IDX_RX(qid) (2*qid) |
| 27 | #define VHOST_VRING_IDX_TX(qid) (2*qid + 1) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 28 | |
Steven | 49a04b9 | 2017-07-29 08:56:08 -0700 | [diff] [blame] | 29 | #define VHOST_USER_VRING_NOFD_MASK 0x100 |
Shesha Sreenivasamurthy | b8f45b3 | 2016-02-03 09:38:36 -0800 | [diff] [blame] | 30 | |
Yoann Desmouceaux | 4667c22 | 2016-02-24 22:51:00 +0100 | [diff] [blame] | 31 | #define VHOST_USER_PROTOCOL_F_MQ 0 |
| 32 | #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 |
Yoann Desmouceaux | fe2da0e | 2016-03-08 14:54:28 +0100 | [diff] [blame] | 33 | #define VHOST_VRING_F_LOG 0 |
Yoann Desmouceaux | 4667c22 | 2016-02-24 22:51:00 +0100 | [diff] [blame] | 34 | |
Shesha Sreenivasamurthy | 0666dc4 | 2016-04-18 16:38:20 -0400 | [diff] [blame] | 35 | #define VHOST_USER_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \ |
| 36 | (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD)) |
Shesha Sreenivasamurthy | b8f45b3 | 2016-02-03 09:38:36 -0800 | [diff] [blame] | 37 | |
Jerome Tollet | 2f54c27 | 2018-10-02 11:41:11 +0200 | [diff] [blame] | 38 | #define vu_log_debug(dev, f, ...) \ |
| 39 | { \ |
| 40 | vlib_log(VLIB_LOG_LEVEL_DEBUG, vhost_user_main.log_default, "%U: " f, \ |
| 41 | format_vnet_hw_if_index_name, vnet_get_main(), \ |
| 42 | dev->hw_if_index, ##__VA_ARGS__); \ |
| 43 | }; |
Mohsin Kazmi | e7cde31 | 2018-06-26 17:20:11 +0200 | [diff] [blame] | 44 | |
Jerome Tollet | 2f54c27 | 2018-10-02 11:41:11 +0200 | [diff] [blame] | 45 | #define vu_log_warn(dev, f, ...) \ |
| 46 | { \ |
| 47 | vlib_log(VLIB_LOG_LEVEL_WARNING, vhost_user_main.log_default, "%U: " f, \ |
| 48 | format_vnet_hw_if_index_name, vnet_get_main(), \ |
| 49 | dev->hw_if_index, ##__VA_ARGS__); \ |
| 50 | }; |
| 51 | #define vu_log_err(dev, f, ...) \ |
| 52 | { \ |
| 53 | vlib_log(VLIB_LOG_LEVEL_ERR, vhost_user_main.log_default, "%U: " f, \ |
| 54 | format_vnet_hw_if_index_name, vnet_get_main(), \ |
| 55 | dev->hw_if_index, ##__VA_ARGS__); \ |
| 56 | }; |
Mohsin Kazmi | e7cde31 | 2018-06-26 17:20:11 +0200 | [diff] [blame] | 57 | |
| 58 | #define UNIX_GET_FD(unixfd_idx) ({ \ |
| 59 | typeof(unixfd_idx) __unixfd_idx = (unixfd_idx); \ |
| 60 | (__unixfd_idx != ~0) ? \ |
| 61 | pool_elt_at_index (file_main.file_pool, \ |
| 62 | __unixfd_idx)->file_descriptor : -1; }) |
| 63 | |
| 64 | #define foreach_virtio_trace_flags \ |
| 65 | _ (SIMPLE_CHAINED, 0, "Simple descriptor chaining") \ |
| 66 | _ (SINGLE_DESC, 1, "Single descriptor packet") \ |
| 67 | _ (INDIRECT, 2, "Indirect descriptor") \ |
| 68 | _ (MAP_ERROR, 4, "Memory mapping error") |
| 69 | |
| 70 | typedef enum |
| 71 | { |
| 72 | #define _(n,i,s) VIRTIO_TRACE_F_##n, |
| 73 | foreach_virtio_trace_flags |
| 74 | #undef _ |
| 75 | } virtio_trace_flag_t; |
| 76 | |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 77 | #define FEATURE_VIRTIO_NET_F_HOST_TSO_FEATURE_BITS \ |
Mohsin Kazmi | a7a2281 | 2020-08-31 17:17:16 +0200 | [diff] [blame] | 78 | (VIRTIO_FEATURE (VIRTIO_NET_F_CSUM) | \ |
| 79 | VIRTIO_FEATURE (VIRTIO_NET_F_HOST_UFO) | \ |
| 80 | VIRTIO_FEATURE (VIRTIO_NET_F_HOST_TSO4) | \ |
| 81 | VIRTIO_FEATURE (VIRTIO_NET_F_HOST_TSO6)) |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 82 | |
| 83 | #define FEATURE_VIRTIO_NET_F_GUEST_TSO_FEATURE_BITS \ |
Mohsin Kazmi | a7a2281 | 2020-08-31 17:17:16 +0200 | [diff] [blame] | 84 | (VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_CSUM) | \ |
| 85 | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_UFO) | \ |
| 86 | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_TSO4) | \ |
| 87 | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_TSO6)) |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 88 | |
| 89 | #define FEATURE_VIRTIO_NET_F_HOST_GUEST_TSO_FEATURE_BITS \ |
| 90 | (FEATURE_VIRTIO_NET_F_HOST_TSO_FEATURE_BITS | \ |
| 91 | FEATURE_VIRTIO_NET_F_GUEST_TSO_FEATURE_BITS) |
| 92 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 93 | int vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm, |
| 94 | const char *sock_filename, u8 is_server, |
| 95 | u32 * sw_if_index, u64 feature_mask, |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 96 | u8 renumber, u32 custom_dev_instance, u8 * hwaddr, |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 97 | u8 enable_gso, u8 enable_packed); |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 98 | int vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm, |
| 99 | const char *sock_filename, u8 is_server, |
| 100 | u32 sw_if_index, u64 feature_mask, |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 101 | u8 renumber, u32 custom_dev_instance, |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 102 | u8 enable_gso, u8 enable_packed); |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 103 | int vhost_user_delete_if (vnet_main_t * vnm, vlib_main_t * vm, |
| 104 | u32 sw_if_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 105 | |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 106 | /* *INDENT-OFF* */ |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 107 | typedef struct vhost_user_memory_region |
| 108 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 109 | u64 guest_phys_addr; |
| 110 | u64 memory_size; |
| 111 | u64 userspace_addr; |
| 112 | u64 mmap_offset; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 113 | } __attribute ((packed)) vhost_user_memory_region_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 114 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 115 | typedef struct vhost_user_memory |
| 116 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 117 | u32 nregions; |
| 118 | u32 padding; |
| 119 | vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS]; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 120 | } __attribute ((packed)) vhost_user_memory_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 121 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 122 | typedef enum vhost_user_req |
| 123 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 124 | VHOST_USER_NONE = 0, |
| 125 | VHOST_USER_GET_FEATURES = 1, |
| 126 | VHOST_USER_SET_FEATURES = 2, |
| 127 | VHOST_USER_SET_OWNER = 3, |
| 128 | VHOST_USER_RESET_OWNER = 4, |
| 129 | VHOST_USER_SET_MEM_TABLE = 5, |
| 130 | VHOST_USER_SET_LOG_BASE = 6, |
| 131 | VHOST_USER_SET_LOG_FD = 7, |
| 132 | VHOST_USER_SET_VRING_NUM = 8, |
| 133 | VHOST_USER_SET_VRING_ADDR = 9, |
| 134 | VHOST_USER_SET_VRING_BASE = 10, |
| 135 | VHOST_USER_GET_VRING_BASE = 11, |
| 136 | VHOST_USER_SET_VRING_KICK = 12, |
| 137 | VHOST_USER_SET_VRING_CALL = 13, |
| 138 | VHOST_USER_SET_VRING_ERR = 14, |
Shesha Sreenivasamurthy | b8f45b3 | 2016-02-03 09:38:36 -0800 | [diff] [blame] | 139 | VHOST_USER_GET_PROTOCOL_FEATURES = 15, |
| 140 | VHOST_USER_SET_PROTOCOL_FEATURES = 16, |
| 141 | VHOST_USER_GET_QUEUE_NUM = 17, |
Yoann Desmouceaux | 4667c22 | 2016-02-24 22:51:00 +0100 | [diff] [blame] | 142 | VHOST_USER_SET_VRING_ENABLE = 18, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 143 | VHOST_USER_MAX |
| 144 | } vhost_user_req_t; |
| 145 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 146 | typedef struct vhost_user_msg { |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 147 | vhost_user_req_t request; |
| 148 | u32 flags; |
| 149 | u32 size; |
| 150 | union |
| 151 | { |
| 152 | u64 u64; |
| 153 | vhost_vring_state_t state; |
| 154 | vhost_vring_addr_t addr; |
| 155 | vhost_user_memory_t memory; |
| 156 | vhost_user_log_t log; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 157 | }; |
| 158 | } __attribute ((packed)) vhost_user_msg_t; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 159 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 160 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 161 | typedef struct |
| 162 | { |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 163 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); |
Steven | 9787889 | 2017-08-29 09:23:26 -0700 | [diff] [blame] | 164 | u16 qsz_mask; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 165 | u16 last_avail_idx; |
| 166 | u16 last_used_idx; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 167 | u16 n_since_last_int; |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 168 | union |
| 169 | { |
| 170 | vring_desc_t *desc; |
| 171 | vring_packed_desc_t *packed_desc; |
| 172 | }; |
| 173 | union |
| 174 | { |
| 175 | vring_avail_t *avail; |
| 176 | vring_desc_event_t *avail_event; |
| 177 | }; |
| 178 | union |
| 179 | { |
| 180 | vring_used_t *used; |
| 181 | vring_desc_event_t *used_event; |
| 182 | }; |
Steven Luong | 4442f7c | 2019-10-02 07:33:48 -0700 | [diff] [blame] | 183 | uword desc_user_addr; |
| 184 | uword used_user_addr; |
| 185 | uword avail_user_addr; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 186 | f64 int_deadline; |
| 187 | u8 started; |
| 188 | u8 enabled; |
| 189 | u8 log_used; |
| 190 | //Put non-runtime in a different cache line |
| 191 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 192 | int errfd; |
| 193 | u32 callfd_idx; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 194 | u32 kickfd_idx; |
| 195 | u64 log_guest_addr; |
Steven | f3b5364 | 2017-05-01 14:03:02 -0700 | [diff] [blame] | 196 | |
| 197 | /* The rx queue policy (interrupt/adaptive/polling) for this queue */ |
| 198 | u32 mode; |
Steven Luong | 67f935e | 2019-02-01 10:23:56 -0800 | [diff] [blame] | 199 | |
| 200 | /* |
| 201 | * It contains the device queue number. -1 if it does not. The idea is |
| 202 | * to not invoke vnet_hw_interface_assign_rx_thread and |
| 203 | * vnet_hw_interface_unassign_rx_thread more than once for the duration of |
| 204 | * the interface even if it is disconnected and reconnected. |
| 205 | */ |
| 206 | i16 qid; |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 207 | |
| 208 | u16 used_wrap_counter; |
| 209 | u16 avail_wrap_counter; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 210 | } vhost_user_vring_t; |
| 211 | |
Steven | 7312cc7 | 2017-03-15 21:18:55 -0700 | [diff] [blame] | 212 | #define VHOST_USER_EVENT_START_TIMER 1 |
Steven | f3b5364 | 2017-05-01 14:03:02 -0700 | [diff] [blame] | 213 | #define VHOST_USER_EVENT_STOP_TIMER 2 |
Steven | 7312cc7 | 2017-03-15 21:18:55 -0700 | [diff] [blame] | 214 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 215 | typedef struct |
| 216 | { |
| 217 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); |
Juraj Sloboda | b192feb | 2018-10-01 12:42:07 +0200 | [diff] [blame] | 218 | u32 is_ready; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 219 | u32 admin_up; |
Pierre Pfister | dbb3c25 | 2016-11-22 10:33:34 +0000 | [diff] [blame] | 220 | u32 unix_server_index; |
Damjan Marion | 56dd543 | 2017-09-08 19:52:02 +0200 | [diff] [blame] | 221 | u32 clib_file_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 222 | char sock_filename[256]; |
| 223 | int sock_errno; |
Steven | 5445f5f | 2017-04-25 16:16:00 -0700 | [diff] [blame] | 224 | uword if_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 225 | u32 hw_if_index, sw_if_index; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 226 | |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 227 | //Feature negotiation |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 228 | u64 features; |
| 229 | u64 feature_mask; |
Yoann Desmouceaux | 4667c22 | 2016-02-24 22:51:00 +0100 | [diff] [blame] | 230 | u64 protocol_features; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 231 | |
| 232 | //Memory region information |
| 233 | u32 nregions; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 234 | vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS]; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 235 | void *region_mmap_addr[VHOST_MEMORY_MAX_NREGIONS]; |
Damjan Marion | 3762370 | 2016-09-20 11:25:27 +0200 | [diff] [blame] | 236 | u64 region_guest_addr_lo[VHOST_MEMORY_MAX_NREGIONS]; |
| 237 | u64 region_guest_addr_hi[VHOST_MEMORY_MAX_NREGIONS]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 238 | u32 region_mmap_fd[VHOST_MEMORY_MAX_NREGIONS]; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 239 | |
| 240 | //Virtual rings |
| 241 | vhost_user_vring_t vrings[VHOST_VRING_MAX_N]; |
| 242 | volatile u32 *vring_locks[VHOST_VRING_MAX_N]; |
| 243 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 244 | int virtio_net_hdr_sz; |
| 245 | int is_any_layout; |
Yoann Desmouceaux | 4667c22 | 2016-02-24 22:51:00 +0100 | [diff] [blame] | 246 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 247 | void *log_base_addr; |
Yoann Desmouceaux | 4667c22 | 2016-02-24 22:51:00 +0100 | [diff] [blame] | 248 | u64 log_size; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 249 | |
| 250 | /* Whether to use spinlock or per_cpu_tx_qid assignment */ |
| 251 | u8 use_tx_spinlock; |
| 252 | u16 *per_cpu_tx_qid; |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 253 | |
| 254 | u8 enable_gso; |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 255 | |
| 256 | /* Packed ring configured */ |
| 257 | u8 enable_packed; |
| 258 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 259 | } vhost_user_intf_t; |
| 260 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 261 | typedef struct |
| 262 | { |
Pierre Pfister | d3eb90e | 2016-11-29 15:36:14 +0000 | [diff] [blame] | 263 | uword dst; |
| 264 | uword src; |
| 265 | u32 len; |
| 266 | } vhost_copy_t; |
| 267 | |
| 268 | typedef struct |
| 269 | { |
| 270 | u16 qid; /** The interface queue index (Not the virtio vring idx) */ |
| 271 | u16 device_index; /** The device index */ |
| 272 | u32 virtio_ring_flags; /** Runtime queue flags **/ |
| 273 | u16 first_desc_len; /** Length of the first data descriptor **/ |
| 274 | virtio_net_hdr_mrg_rxbuf_t hdr; /** Virtio header **/ |
| 275 | } vhost_trace_t; |
| 276 | |
Pierre Pfister | d3eb90e | 2016-11-29 15:36:14 +0000 | [diff] [blame] | 277 | #define VHOST_USER_RX_BUFFERS_N (2 * VLIB_FRAME_SIZE + 2) |
| 278 | #define VHOST_USER_COPY_ARRAY_N (4 * VLIB_FRAME_SIZE) |
| 279 | |
| 280 | typedef struct |
| 281 | { |
Pierre Pfister | d3eb90e | 2016-11-29 15:36:14 +0000 | [diff] [blame] | 282 | u32 rx_buffers_len; |
| 283 | u32 rx_buffers[VHOST_USER_RX_BUFFERS_N]; |
| 284 | |
| 285 | virtio_net_hdr_mrg_rxbuf_t tx_headers[VLIB_FRAME_SIZE]; |
| 286 | vhost_copy_t copy[VHOST_USER_COPY_ARRAY_N]; |
| 287 | |
| 288 | /* This is here so it doesn't end-up |
| 289 | * using stack or registers. */ |
| 290 | vhost_trace_t *current_trace; |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 291 | |
| 292 | u32 *to_next_list; |
| 293 | vlib_buffer_t **rx_buffers_pdesc; |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 294 | } vhost_cpu_t; |
| 295 | |
| 296 | typedef struct |
| 297 | { |
Steven | 5445f5f | 2017-04-25 16:16:00 -0700 | [diff] [blame] | 298 | mhash_t if_index_by_sock_name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 299 | u32 mtu_bytes; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 300 | vhost_user_intf_t *vhost_user_interfaces; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 301 | u32 *show_dev_instance_by_real_dev_instance; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 302 | u32 coalesce_frames; |
| 303 | f64 coalesce_time; |
| 304 | int dont_dump_vhost_user_memory; |
Damjan Marion | 0dafaa7 | 2016-09-20 23:21:02 +0200 | [diff] [blame] | 305 | |
Pierre Pfister | e21c528 | 2016-09-21 08:04:59 +0100 | [diff] [blame] | 306 | /** Per-CPU data for vhost-user */ |
| 307 | vhost_cpu_t *cpus; |
Pierre Pfister | dbb3c25 | 2016-11-22 10:33:34 +0000 | [diff] [blame] | 308 | |
| 309 | /** Pseudo random iterator */ |
| 310 | u32 random; |
Steven | 7312cc7 | 2017-03-15 21:18:55 -0700 | [diff] [blame] | 311 | |
Steven | f3b5364 | 2017-05-01 14:03:02 -0700 | [diff] [blame] | 312 | /* The number of rx interface/queue pairs in interrupt mode */ |
| 313 | u32 ifq_count; |
Steven | 388e51a | 2017-06-01 12:49:23 -0700 | [diff] [blame] | 314 | |
Jerome Tollet | 2f54c27 | 2018-10-02 11:41:11 +0200 | [diff] [blame] | 315 | /* logging */ |
| 316 | vlib_log_class_t log_default; |
Steven Luong | 4208a4c | 2019-05-06 08:51:56 -0700 | [diff] [blame] | 317 | |
| 318 | /* gso interface count */ |
| 319 | u32 gso_count; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 320 | } vhost_user_main_t; |
| 321 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 322 | typedef struct |
| 323 | { |
| 324 | u8 if_name[64]; |
| 325 | u32 sw_if_index; |
| 326 | u32 virtio_net_hdr_sz; |
| 327 | u64 features; |
| 328 | u8 is_server; |
| 329 | u8 sock_filename[256]; |
| 330 | u32 num_regions; |
| 331 | int sock_errno; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 332 | } vhost_user_intf_details_t; |
| 333 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 334 | int vhost_user_dump_ifs (vnet_main_t * vnm, vlib_main_t * vm, |
| 335 | vhost_user_intf_details_t ** out_vuids); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 336 | |
Mohsin Kazmi | e7cde31 | 2018-06-26 17:20:11 +0200 | [diff] [blame] | 337 | extern vlib_node_registration_t vhost_user_send_interrupt_node; |
| 338 | extern vnet_device_class_t vhost_user_device_class; |
| 339 | extern vlib_node_registration_t vhost_user_input_node; |
| 340 | extern vhost_user_main_t vhost_user_main; |
| 341 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 342 | #endif |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 343 | |
| 344 | /* |
| 345 | * fd.io coding-style-patch-verification: ON |
| 346 | * |
| 347 | * Local Variables: |
| 348 | * eval: (c-set-style "gnu") |
| 349 | * End: |
| 350 | */ |