21 #include <sys/ioctl.h> 22 #include <sys/socket.h> 25 #include <sys/types.h> 27 #include <netinet/in.h> 30 #include <linux/if_arp.h> 31 #include <linux/if_tun.h> 52 #define VHOST_USER_DEBUG_SOCKET 0 53 #define VHOST_DEBUG_VQ 0 55 #if VHOST_USER_DEBUG_SOCKET == 1 56 #define DBG_SOCK(args...) clib_warning(args); 58 #define DBG_SOCK(args...) 61 #if VHOST_DEBUG_VQ == 1 62 #define DBG_VQ(args...) clib_warning(args); 64 #define DBG_VQ(args...) 72 #define VHOST_USER_DOWN_DISCARD_COUNT 256 78 #define VHOST_USER_RX_BUFFER_STARVATION 32 88 #define VHOST_USER_RX_COPY_THRESHOLD 64 90 #define UNIX_GET_FD(unixfd_idx) \ 91 (unixfd_idx != ~0) ? \ 92 pool_elt_at_index (unix_main.file_pool, \ 93 unixfd_idx)->file_descriptor : -1; 95 #define foreach_virtio_trace_flags \ 96 _ (SIMPLE_CHAINED, 0, "Simple descriptor chaining") \ 97 _ (SINGLE_DESC, 1, "Single descriptor packet") \ 98 _ (INDIRECT, 2, "Indirect descriptor") \ 99 _ (MAP_ERROR, 4, "Memory mapping error") 103 #define _(n,i,s) VIRTIO_TRACE_F_##n, 110 #define foreach_vhost_user_tx_func_error \ 111 _(NONE, "no error") \ 112 _(NOT_READY, "vhost vring not ready") \ 113 _(DOWN, "vhost interface is down") \ 114 _(PKT_DROP_NOBUF, "tx packet drops (no available descriptors)") \ 115 _(PKT_DROP_NOMRG, "tx packet drops (cannot merge descriptors)") \ 116 _(MMAP_FAIL, "mmap failure") \ 117 _(INDIRECT_OVERFLOW, "indirect descriptor table overflow") 121 #define _(f,s) VHOST_USER_TX_FUNC_ERROR_##f, 133 #define foreach_vhost_user_input_func_error \ 134 _(NO_ERROR, "no error") \ 135 _(NO_BUFFER, "no available buffer") \ 136 _(MMAP_FAIL, "mmap failure") \ 137 _(INDIRECT_OVERFLOW, "indirect descriptor overflows table") \ 138 _(UNDERSIZED_FRAME, "undersized ethernet frame received (< 14 bytes)") \ 139 _(FULL_RX_QUEUE, "full rx queue (possible driver tx drop)") 143 #define _(f,s) VHOST_USER_INPUT_FUNC_ERROR_##f, 161 .name =
"vhost-user",
169 u32 show_dev_instance = ~0;
175 if (show_dev_instance != ~0)
176 i = show_dev_instance;
178 s =
format (s,
"VirtualEthernet0/0/%d", i);
193 DBG_SOCK (
"renumbered vhost-user interface dev_instance %d to %d",
204 ((vui->
regions[i].guest_phys_addr +
205 vui->
regions[i].memory_size) > addr)))
211 __m128i rl, rh, al, ah, r;
212 al = _mm_set1_epi64x (addr + 1);
213 ah = _mm_set1_epi64x (addr);
216 rl = _mm_cmpgt_epi64 (al, rl);
218 rh = _mm_cmpgt_epi64 (rh, ah);
219 r = _mm_and_si128 (rl, rh);
222 rl = _mm_cmpgt_epi64 (al, rl);
224 rh = _mm_cmpgt_epi64 (rh, ah);
225 r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x22);
228 rl = _mm_cmpgt_epi64 (al, rl);
230 rh = _mm_cmpgt_epi64 (rh, ah);
231 r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x44);
234 rl = _mm_cmpgt_epi64 (al, rl);
236 rh = _mm_cmpgt_epi64 (rh, ah);
237 r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x88);
239 r = _mm_shuffle_epi8 (r, _mm_set_epi64x (0, 0x0e060c040a020800));
240 i = __builtin_ctzll (_mm_movemask_epi8 (r) |
253 if ((vui->
regions[i].guest_phys_addr <= addr) &&
263 DBG_VQ (
"failed to map guest mem addr %llx", addr);
274 if ((vui->
regions[i].userspace_addr <= addr) &&
304 ssize_t map_sz = (vui->
regions[
i].memory_size +
306 page_sz - 1) & ~(page_sz - 1);
313 (
"unmap memory region %d addr 0x%lx len 0x%lx page_sz 0x%x", i,
320 clib_warning (
"failed to unmap memory region (errno %d)",
380 VLIB_NODE_STATE_DISABLED);
393 u32 *vui_workers = vec_len (vui->workers) ? vui->workers : workers;
395 for (qid = 0; qid < VHOST_VRING_MAX_N / 2; qid++)
397 vhost_user_vring_t *txvq =
398 &vui->vrings[VHOST_VRING_IDX_TX (qid)];
402 i %= vec_len (vui_workers);
403 cpu_index = vui_workers[i];
405 vhc = &vum->cpus[cpu_index];
408 iaq.vhost_iface_index = vui - vum->vhost_user_interfaces;
409 vec_add1 (vhc->rx_queues, iaq);
429 vhc->operation_mode = mode;
432 for (cpu_index = vum->input_cpu_first_index;
433 cpu_index < vum->input_cpu_first_index + vum->input_cpu_count;
438 vhc = &vum->cpus[cpu_index];
440 switch (vhc->operation_mode)
443 state = VLIB_NODE_STATE_INTERRUPT;
446 state = VLIB_NODE_STATE_POLLING;
449 clib_warning (
"BUG: bad operation mode %d", vhc->operation_mode);
465 if (worker_thread_index < vum->input_cpu_first_index ||
466 worker_thread_index >=
477 if (*w == worker_thread_index)
490 else if (found == ~0)
503 int i, found[2] = { };
509 return found[0] && found[1];
517 if (is_up != vui->
is_up)
520 is_up ?
"ready" :
"down");
556 cpu_index = vhc - vum->
cpus;
563 ifq2 = ((ifq >> 8) << 8) | vhiq->
qid;
581 __attribute__ ((unused))
int n;
598 __attribute__ ((unused))
int n;
628 return __sync_lock_test_and_set (vui->
vring_locks[qid], 1);
654 memset (vring, 0,
sizeof (*vring));
668 if (qid == 0 || qid == 1)
690 if (vring->
errfd != -1)
692 close (vring->
errfd);
721 #define VHOST_LOG_PAGE 0x1000 727 || !(vui->
features & (1 << FEAT_VHOST_F_LOG_ALL))))
737 DBG_SOCK (
"vhost_user_log_dirty_pages(): out of range\n");
756 #define vhost_user_log_dirty_ring(vui, vq, member) \ 757 if (PREDICT_FALSE(vq->log_used)) { \ 758 vhost_user_log_dirty_pages(vui, vq->log_guest_addr + STRUCT_OFFSET_OF(vring_used_t, member), \ 759 sizeof(vq->used->member)); \ 766 int fd, number_of_fds = 0;
768 vhost_user_msg_t msg;
773 struct cmsghdr *cmsg;
782 memset (&mh, 0,
sizeof (mh));
783 memset (control, 0,
sizeof (control));
789 iov[0].iov_base = (
void *) &msg;
794 mh.msg_control = control;
795 mh.msg_controllen =
sizeof (control);
806 DBG_SOCK (
"recvmsg returned error %d %s", errno, strerror (errno));
810 DBG_SOCK (
"n (%d) != VHOST_USER_MSG_HDR_SZ (%d)",
816 if (mh.msg_flags & MSG_CTRUNC)
822 cmsg = CMSG_FIRSTHDR (&mh);
824 if (cmsg && (cmsg->cmsg_len > 0) && (cmsg->cmsg_level == SOL_SOCKET) &&
825 (cmsg->cmsg_type == SCM_RIGHTS) &&
826 (cmsg->cmsg_len - CMSG_LEN (0) <=
827 VHOST_MEMORY_MAX_NREGIONS *
sizeof (
int)))
829 number_of_fds = (cmsg->cmsg_len - CMSG_LEN (0)) /
sizeof (
int);
830 clib_memcpy (fds, CMSG_DATA (cmsg), number_of_fds *
sizeof (
int));
834 if ((msg.flags & 7) != 1)
836 DBG_SOCK (
"malformed message received. closing socket");
847 DBG_SOCK (
"read failed %s", strerror (errno));
850 else if (rv != msg.size)
852 DBG_SOCK (
"message too short (read %dB should be %dB)", rv, msg.size);
861 msg.u64 = (1ULL << FEAT_VIRTIO_NET_F_MRG_RXBUF) |
862 (1ULL << FEAT_VIRTIO_NET_F_CTRL_VQ) |
863 (1ULL << FEAT_VIRTIO_F_ANY_LAYOUT) |
864 (1ULL << FEAT_VIRTIO_F_INDIRECT_DESC) |
865 (1ULL << FEAT_VHOST_F_LOG_ALL) |
866 (1ULL << FEAT_VIRTIO_NET_F_GUEST_ANNOUNCE) |
867 (1ULL << FEAT_VIRTIO_NET_F_MQ) |
868 (1ULL << FEAT_VHOST_USER_F_PROTOCOL_FEATURES) |
869 (1ULL << FEAT_VIRTIO_F_VERSION_1);
871 msg.size =
sizeof (msg.u64);
872 DBG_SOCK (
"if %d msg VHOST_USER_GET_FEATURES - reply 0x%016llx",
877 DBG_SOCK (
"if %d msg VHOST_USER_SET_FEATURES features 0x%016llx",
883 ((1 << FEAT_VIRTIO_NET_F_MRG_RXBUF) |
884 (1ULL << FEAT_VIRTIO_F_VERSION_1)))
890 (vui->
features & (1 << FEAT_VIRTIO_F_ANY_LAYOUT)) ? 1 : 0;
902 DBG_SOCK (
"if %d msg VHOST_USER_SET_MEM_TABLE nregions %d",
905 if ((msg.memory.nregions < 1) ||
906 (msg.memory.nregions > VHOST_MEMORY_MAX_NREGIONS))
909 DBG_SOCK (
"number of mem regions must be between 1 and %i",
910 VHOST_MEMORY_MAX_NREGIONS);
915 if (msg.memory.nregions != number_of_fds)
917 DBG_SOCK (
"each memory region must have FD");
921 for (i = 0; i < msg.memory.nregions; i++)
924 sizeof (vhost_user_memory_region_t));
929 ssize_t map_sz = (vui->
regions[
i].memory_size +
931 page_sz - 1) & ~(page_sz - 1);
934 MAP_SHARED, fds[i], 0);
940 (
"map memory region %d addr 0 len 0x%lx fd %d mapped 0x%lx " 946 clib_warning (
"failed to map memory. errno is %d", errno);
952 vui->
nregions = msg.memory.nregions;
956 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_NUM idx %d num %d",
959 if ((msg.state.num > 32768) ||
960 (msg.state.num == 0) ||
961 ((msg.state.num - 1) & msg.state.num))
963 vui->
vrings[msg.state.index].
qsz = msg.state.num;
967 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_ADDR idx %d",
972 DBG_SOCK (
"invalid vring index VHOST_USER_SET_VRING_ADDR:" 977 if (msg.size < sizeof (msg.addr))
979 DBG_SOCK (
"vhost message is too short (%d < %d)",
980 msg.size, sizeof (msg.addr));
984 vui->
vrings[msg.state.index].
desc = (vring_desc_t *)
986 vui->
vrings[msg.state.index].
used = (vring_used_t *)
988 vui->
vrings[msg.state.index].
avail = (vring_avail_t *)
995 DBG_SOCK (
"failed to map user memory for hw_if_index %d",
1006 if (!(vui->
features & (1 << FEAT_VHOST_USER_F_PROTOCOL_FEATURES)))
1020 vui->
vrings[msg.state.index].
used->flags = 0;
1032 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_CALL u64 %d",
1035 q = (
u8) (msg.u64 & 0xFF);
1046 if (!(msg.u64 & 0x100))
1048 if (number_of_fds != 1)
1050 DBG_SOCK (
"More than one fd received !");
1055 template.file_descriptor = fds[0];
1056 template.private_data =
1065 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_KICK u64 %d",
1068 q = (
u8) (msg.u64 & 0xFF);
1078 if (!(msg.u64 & 0x100))
1080 if (number_of_fds != 1)
1082 DBG_SOCK (
"More than one fd received !");
1087 template.file_descriptor = fds[0];
1088 template.private_data =
1103 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_ERR u64 %d",
1106 q = (
u8) (msg.u64 & 0xFF);
1111 if (!(msg.u64 & 0x100))
1113 if (number_of_fds != 1)
1124 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_BASE idx %d num %d",
1125 vui->
hw_if_index, msg.state.index, msg.state.num);
1131 DBG_SOCK (
"if %d msg VHOST_USER_GET_VRING_BASE idx %d num %d",
1132 vui->
hw_if_index, msg.state.index, msg.state.num);
1136 DBG_SOCK (
"invalid vring index VHOST_USER_GET_VRING_BASE:" 1147 msg.size =
sizeof (msg.state);
1162 if (msg.size != sizeof (msg.log))
1165 (
"invalid msg size for VHOST_USER_SET_LOG_BASE: %d instead of %d",
1166 msg.size, sizeof (msg.log));
1174 (
"VHOST_USER_PROTOCOL_F_LOG_SHMFD not set but VHOST_USER_SET_LOG_BASE received");
1182 (msg.log.size + msg.log.offset + page_sz - 1) & ~(page_sz - 1);
1184 vui->
log_base_addr = mmap (0, map_sz, PROT_READ | PROT_WRITE,
1188 (
"map log region addr 0 len 0x%lx off 0x%lx fd %d mapped 0x%lx",
1193 clib_warning (
"failed to map memory. errno is %d", errno);
1201 msg.size =
sizeof (msg.u64);
1212 DBG_SOCK (
"if %d msg VHOST_USER_GET_PROTOCOL_FEATURES",
1218 msg.size =
sizeof (msg.u64);
1222 DBG_SOCK (
"if %d msg VHOST_USER_SET_PROTOCOL_FEATURES features 0x%lx",
1233 msg.size =
sizeof (msg.u64);
1237 DBG_SOCK (
"if %d VHOST_USER_SET_VRING_ENABLE: %s queue %d",
1238 vui->
hw_if_index, msg.state.num ?
"enable" :
"disable",
1242 DBG_SOCK (
"invalid vring index VHOST_USER_SET_VRING_ENABLE:" 1251 DBG_SOCK (
"unknown vhost-user message %d received. closing socket",
1263 DBG_SOCK (
"could not send message response");
1298 int client_fd, client_len;
1299 struct sockaddr_un client;
1306 client_len =
sizeof (client);
1308 (
struct sockaddr *) &client,
1309 (socklen_t *) & client_len);
1317 template.file_descriptor = client_fd;
1355 if (tr && tr->
count > 0)
1397 if (t->virtio_ring_flags & (1 << VIRTIO_TRACE_F_##n)) \ 1398 s = format (s, "%U %s %s\n", format_white_space, indent, #n, st); 1401 s =
format (s,
"%U virtio_net_hdr first_desc_len %u\n",
1404 s =
format (s,
"%U flags 0x%02x gso_type %u\n",
1406 t->
hdr.hdr.flags, t->
hdr.hdr.gso_type);
1409 s =
format (s,
"%U num_buff %u",
1421 u32 qsz_mask = txvq->
qsz - 1;
1423 u32 desc_current = txvq->
avail->ring[last_avail_idx & qsz_mask];
1424 vring_desc_t *hdr_desc = 0;
1425 virtio_net_hdr_mrg_rxbuf_t *hdr;
1428 memset (t, 0,
sizeof (*t));
1432 hdr_desc = &txvq->
desc[desc_current];
1443 if (!(txvq->
desc[desc_current].flags & VIRTQ_DESC_F_NEXT) &&
1444 !(txvq->
desc[desc_current].flags & VIRTQ_DESC_F_INDIRECT))
1451 if (!hdr_desc || !(hdr =
map_guest_mem (vui, hdr_desc->addr, &hint)))
1458 memcpy (&t->
hdr, hdr, len > hdr_desc->len ? hdr_desc->len : len);
1468 int rv __attribute__ ((unused));
1470 rv = write (fd, &x,
sizeof (x));
1477 u16 copy_len,
u32 * map_hint)
1479 void *src0, *src1, *src2, *src3;
1502 clib_memcpy ((
void *) cpy[0].dst, src0, cpy[0].len);
1503 clib_memcpy ((
void *) cpy[1].dst, src1, cpy[1].len);
1533 u32 discarded_packets = 0;
1535 u16 qsz_mask = txvq->
qsz - 1;
1536 while (discarded_packets != discard_max)
1541 u16 desc_chain_head =
1549 discarded_packets++;
1556 return discarded_packets;
1569 b_current->
flags = 0;
1570 while (b_current != b_head)
1576 b_current->
flags = 0;
1588 u16 n_rx_packets = 0;
1591 u32 n_left_to_next, *to_next;
1641 VHOST_USER_INPUT_FUNC_ERROR_FULL_RX_QUEUE, 1);
1644 qsz_mask = txvq->
qsz - 1;
1678 interface_main.sw_if_counters +
1684 VHOST_USER_INPUT_FUNC_ERROR_NO_BUFFER, flush);
1692 while (n_left > 0 && n_left_to_next > 0)
1697 u32 desc_data_offset;
1698 vring_desc_t *desc_table = txvq->
desc;
1715 to_next[0] = bi_current;
1721 [vum->
cpus[cpu_index].
1722 rx_buffers_len - 1], LOAD);
1757 VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1);
1771 desc_data_offset = desc_table[desc_current].len;
1777 if (desc_data_offset == desc_table[desc_current].len)
1782 desc_current = desc_table[desc_current].next;
1783 desc_data_offset = 0;
1810 &vum->
cpus[cpu_index],
1823 bi_current = bi_next;
1831 desc_table[desc_current].
len - desc_data_offset;
1833 cpy->
len = (cpy->
len > desc_data_l) ? desc_data_l : cpy->
len;
1836 cpy->
src = desc_table[desc_current].addr + desc_data_offset;
1838 desc_data_offset += cpy->
len;
1870 u32 bi = to_next[-1];
1872 to_next, n_left_to_next,
1887 copy_len, &map_hint)))
1890 VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1);
1907 copy_len, &map_hint)))
1910 VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1);
1936 return n_rx_packets;
1944 uword n_rx_packets = 0;
1950 vhc = &vum->
cpus[cpu_index];
1967 clib_bitmap_set (vhc->pending_input_bitmap, i, 0);
1968 vui = pool_elt_at_index (vum->vhost_user_interfaces, i >> 8);
1969 n_rx_packets += vhost_user_if_input (vm, vum, vui, qid, node);
1973 return n_rx_packets;
1980 .name =
"vhost-user-input",
1981 .sibling_of =
"device-input",
1984 .state = VLIB_NODE_STATE_DISABLED,
2003 u32 qsz_mask = rxvq->
qsz - 1;
2005 u32 desc_current = rxvq->
avail->ring[last_avail_idx & qsz_mask];
2006 vring_desc_t *hdr_desc = 0;
2009 memset (t, 0,
sizeof (*t));
2013 hdr_desc = &rxvq->
desc[desc_current];
2024 if (!(rxvq->
desc[desc_current].flags & VIRTQ_DESC_F_NEXT) &&
2025 !(rxvq->
desc[desc_current].flags & VIRTQ_DESC_F_INDIRECT))
2035 u16 copy_len,
u32 * map_hint)
2037 void *dst0, *dst1, *dst2, *dst3;
2059 clib_memcpy (dst0, (
void *) cpy[0].src, cpy[0].len);
2060 clib_memcpy (dst1, (
void *) cpy[1].src, cpy[1].len);
2103 error = VHOST_USER_TX_FUNC_ERROR_DOWN;
2109 error = VHOST_USER_TX_FUNC_ERROR_NOT_READY;
2116 rxvq = &vui->vrings[qid];
2120 qsz_mask = rxvq->
qsz - 1;
2123 error = VHOST_USER_TX_FUNC_ERROR_NONE;
2129 u16 desc_head, desc_index, desc_len;
2130 vring_desc_t *desc_table;
2131 uword buffer_map_addr;
2146 vui, qid / 2, b0, rxvq);
2151 error = VHOST_USER_TX_FUNC_ERROR_PKT_DROP_NOBUF;
2155 desc_table = rxvq->
desc;
2156 desc_head = desc_index =
2164 (rxvq->
desc[desc_head].len < sizeof (vring_desc_t)))
2166 error = VHOST_USER_TX_FUNC_ERROR_INDIRECT_OVERFLOW;
2174 error = VHOST_USER_TX_FUNC_ERROR_MMAP_FAIL;
2180 desc_len = vui->virtio_net_hdr_sz;
2181 buffer_map_addr = desc_table[desc_index].addr;
2182 buffer_len = desc_table[desc_index].len;
2186 virtio_net_hdr_mrg_rxbuf_t *hdr =
2190 hdr->hdr.gso_type = 0;
2191 hdr->num_buffers = 1;
2196 cpy->
len = vui->virtio_net_hdr_sz;
2197 cpy->
dst = buffer_map_addr;
2201 buffer_map_addr += vui->virtio_net_hdr_sz;
2202 buffer_len -= vui->virtio_net_hdr_sz;
2207 if (buffer_len == 0)
2212 desc_index = desc_table[desc_index].next;
2213 buffer_map_addr = desc_table[desc_index].addr;
2214 buffer_len = desc_table[desc_index].len;
2216 else if (vui->virtio_net_hdr_sz == 12)
2218 virtio_net_hdr_mrg_rxbuf_t *hdr =
2241 error = VHOST_USER_TX_FUNC_ERROR_PKT_DROP_NOBUF;
2245 desc_table = rxvq->
desc;
2246 desc_head = desc_index =
2249 (rxvq->
desc[desc_head].flags & VIRTQ_DESC_F_INDIRECT))
2254 (rxvq->
desc[desc_head].len < sizeof (vring_desc_t)))
2256 error = VHOST_USER_TX_FUNC_ERROR_INDIRECT_OVERFLOW;
2262 rxvq->
desc[desc_index].addr,
2265 error = VHOST_USER_TX_FUNC_ERROR_MMAP_FAIL;
2270 buffer_map_addr = desc_table[desc_index].addr;
2271 buffer_len = desc_table[desc_index].len;
2275 error = VHOST_USER_TX_FUNC_ERROR_PKT_DROP_NOMRG;
2283 cpy->
len = bytes_left;
2284 cpy->
len = (cpy->
len > buffer_len) ? buffer_len : cpy->
len;
2285 cpy->
dst = buffer_map_addr;
2289 bytes_left -= cpy->
len;
2290 buffer_len -= cpy->
len;
2291 buffer_map_addr += cpy->
len;
2292 desc_len += cpy->
len;
2336 copy_len, &map_hint)))
2339 VHOST_USER_TX_FUNC_ERROR_MMAP_FAIL, 1);
2358 if (n_left && (error == VHOST_USER_TX_FUNC_ERROR_PKT_DROP_NOBUF) && retry)
2377 if (
PREDICT_FALSE (n_left && error != VHOST_USER_TX_FUNC_ERROR_NONE))
2411 .name =
"vhost-user",
2431 struct sockaddr_un sun;
2434 f64 timeout = 3153600000.0 ;
2435 uword *event_data = 0;
2437 sockfd = socket (AF_UNIX, SOCK_STREAM, 0);
2438 sun.sun_family = AF_UNIX;
2456 if (vui->unix_server_index == ~0) {
2457 if (vui->unix_file_index == ~0)
2460 strncpy (sun.sun_path, (char *) vui->sock_filename,
2461 sizeof (sun.sun_path) - 1);
2464 if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
2465 clib_unix_warning (
"fcntl");
2467 if (connect (sockfd, (struct sockaddr *) &sun,
2468 sizeof (struct sockaddr_un)) == 0)
2471 if (fcntl(sockfd, F_SETFL, 0) < 0)
2472 clib_unix_warning (
"fcntl2");
2474 vui->sock_errno = 0;
2475 template.file_descriptor = sockfd;
2476 template.private_data =
2477 vui - vhost_user_main.vhost_user_interfaces;
2478 vui->unix_file_index = unix_file_add (&unix_main, &template);
2481 if ((sockfd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) {
2482 clib_warning(
"Critical: Could not open unix socket");
2488 vui->sock_errno = errno;
2495 socklen_t len = sizeof (error);
2496 int fd = UNIX_GET_FD(vui->unix_file_index);
2498 getsockopt (fd, SOL_SOCKET, SO_ERROR, &error, &len);
2502 DBG_SOCK (
"getsockopt returned %d", retval);
2503 vhost_user_if_disconnect (vui);
2515 .function = vhost_user_process,
2517 .name =
"vhost-user-process",
2561 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
2563 DBG_SOCK (
"Deleting vhost-user interface %s (instance %d)",
2592 struct sockaddr_un un = { };
2595 if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
2596 return VNET_API_ERROR_SYSCALL_ERROR_1;
2598 un.sun_family = AF_UNIX;
2599 strncpy ((
char *) un.sun_path, (
char *) sock_filename,
2600 sizeof (un.sun_path) - 1);
2603 unlink ((
char *) sock_filename);
2605 if (bind (fd, (
struct sockaddr *) &un,
sizeof (un)) == -1)
2607 rv = VNET_API_ERROR_SYSCALL_ERROR_2;
2611 if (listen (fd, 1) == -1)
2613 rv = VNET_API_ERROR_SYSCALL_ERROR_3;
2651 vhost_user_dev_class.index,
2670 const char *sock_filename,
2671 u64 feature_mask,
u32 * sw_if_index,
u8 operation_mode)
2677 if (server_sock_fd != -1)
2681 template.file_descriptor = server_sock_fd;
2725 f64 timeout = 3153600000.0 ;
2726 uword event_type, *event_data = 0;
2730 f64 now, poll_time_remaining;
2734 poll_time_remaining =
2743 timeout = poll_time_remaining;
2759 u32 cpu_index = vhc - vum->
cpus;
2762 next_timeout = timeout;
2787 if ((next_timeout < timeout) && (next_timeout > 0.0))
2788 timeout = next_timeout;
2794 clib_warning (
"BUG: unhandled event type %d", event_type);
2805 .name =
"vhost-user-send-interrupt-process",
2811 const char *sock_filename,
2815 u8 renumber,
u32 custom_dev_instance,
u8 * hwaddr,
2821 int server_sock_fd = -1;
2826 return VNET_API_ERROR_UNIMPLEMENTED;
2828 if (sock_filename ==
NULL || !(strlen (sock_filename) > 0))
2830 return VNET_API_ERROR_INVALID_ARGUMENT;
2846 feature_mask, &sw_if_idx, operation_mode);
2852 *sw_if_index = sw_if_idx;
2870 const char *sock_filename,
2873 u64 feature_mask,
u8 renumber,
u32 custom_dev_instance,
2879 int server_sock_fd = -1;
2885 return VNET_API_ERROR_UNIMPLEMENTED;
2888 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
2895 &server_sock_fd)) != 0)
2900 sock_filename, feature_mask, &sw_if_idx,
2923 u8 *operation_mode = va_arg (*args,
u8 *);
2928 else if (
unformat (input,
"polling"))
2942 u8 *sock_filename =
NULL;
2945 u64 feature_mask = (
u64) ~ (0ULL);
2947 u32 custom_dev_instance = ~0;
2959 if (
unformat (line_input,
"socket %s", &sock_filename))
2961 else if (
unformat (line_input,
"server"))
2963 else if (
unformat (line_input,
"feature-mask 0x%llx", &feature_mask))
2969 else if (
unformat (line_input,
"renumber %d", &custom_dev_instance))
2973 else if (
unformat (line_input,
"mode %U",
2988 is_server, &sw_if_index, feature_mask,
2989 renumber, custom_dev_instance, hw,
3012 u32 sw_if_index = ~0;
3022 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
3062 u32 *hw_if_indices = 0;
3074 for (i = 0; i <
vec_len (hw_if_indices); i++)
3092 strncpy ((
char *) vuid->
if_name, (
char *) s,
3100 *out_vuids = r_vuids;
3108 int operation_mode = va_arg (*va,
int);
3110 switch (operation_mode)
3113 s =
format (s,
"%s",
"polling");
3116 s =
format (s,
"%s",
"interrupt");
3119 s =
format (s,
"%s",
"invalid");
3133 u32 hw_if_index, *hw_if_indices = 0;
3146 struct feat_struct *feat_entry;
3148 static struct feat_struct feat_array[] = {
3149 #define _(s,b) { .str = #s, .bit = b, }, 3155 #define foreach_protocol_feature \ 3156 _(VHOST_USER_PROTOCOL_F_MQ) \ 3157 _(VHOST_USER_PROTOCOL_F_LOG_SHMFD) 3159 static struct feat_struct proto_feat_array[] = {
3160 #define _(s) { .str = #s, .bit = s}, 3171 vec_add1 (hw_if_indices, hw_if_index);
3182 if (
vec_len (hw_if_indices) == 0)
3192 for (i = 0; i <
vec_len (hw_if_indices); i++)
3197 hi->
name, hw_if_indices[i]);
3200 " features mask (0x%llx): \n" 3201 " features (0x%llx): \n",
3205 feat_entry = (
struct feat_struct *) &feat_array;
3206 while (feat_entry->str)
3208 if (vui->
features & (1ULL << feat_entry->bit))
3216 feat_entry = (
struct feat_struct *) &proto_feat_array;
3217 while (feat_entry->str)
3267 " region fd guest_phys_addr memory_size userspace_addr mmap_offset mmap_addr\n");
3269 " ====== ===== ================== ================== ================== ================== ==================\n");
3271 for (j = 0; j < vui->
nregions; j++)
3274 " %d %-5d 0x%016lx 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n",
3276 vui->
regions[j].guest_phys_addr,
3278 vui->
regions[j].userspace_addr,
3288 (q & 1) ?
"RX" :
"TX",
3292 " qsz %d last_avail_idx %d last_used_idx %d\n",
3298 " avail.flags %x avail.idx %d used.flags %x used.idx %d\n",
3313 " id addr len flags next user_addr\n");
3315 " ===== ================== ===== ====== ===== ==================\n");
3316 for (j = 0; j < vui->
vrings[q].
qsz; j++)
3320 " %-5d 0x%016lx %-5d 0x%04x %-5d 0x%016lx\n",
3395 .path =
"create vhost-user",
3396 .short_help =
"create vhost-user socket <socket-filename> [server] " 3397 "[feature-mask <hex>] [hwaddr <mac-addr>] [renumber <dev_instance>] " 3398 "[mode {interrupt | polling}]",
3417 .path =
"delete vhost-user",
3418 .short_help =
"delete vhost-user {<interface> | sw_if_index <sw_idx>}",
3557 .path =
"show vhost-user",
3558 .short_help =
"show vhost-user [<interface> [<interface> [..]]] [descriptors]",
3574 else if (
unformat (input,
"dont-dump-memory"))
3606 u32 worker_thread_index;
3618 &sw_if_index, &worker_thread_index))
3658 .path =
"vhost thread",
3659 .short_help =
"vhost thread <iface> <worker-index> [del]",
unformat_function_t unformat_vnet_hw_interface
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static clib_error_t * vhost_user_init(vlib_main_t *vm)
static void vhost_user_vring_close(vhost_user_intf_t *vui, u32 qid)
static void vhost_user_if_disconnect(vhost_user_intf_t *vui)
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
#define VRING_AVAIL_F_NO_INTERRUPT
u32 virtio_ring_flags
The device index.
virtio_net_hdr_mrg_rxbuf_t hdr
Length of the first data descriptor.
static uword random_default_seed(void)
Default random seed (unix/linux user-mode)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
unix_file_function_t * read_function
vhost_cpu_t * cpus
Per-CPU data for vhost-user.
static void vhost_user_create_ethernet(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_t *vui, u8 *hwaddress)
Create ethernet interface for vhost user interface.
#define VHOST_USER_DOWN_DISCARD_COUNT
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
u8 runtime_data[0]
Function dependent node-runtime data.
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VHOST_VRING_IDX_TX(qid)
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * vhost_user_socket_error(unix_file_t *uf)
void vhost_user_rx_trace(vhost_trace_t *t, vhost_user_intf_t *vui, u16 qid, vlib_buffer_t *b, vhost_user_vring_t *txvq)
u64 region_guest_addr_hi[VHOST_MEMORY_MAX_NREGIONS]
vnet_interface_main_t interface_main
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
static f64 vlib_time_now(vlib_main_t *vm)
#define foreach_virtio_trace_flags
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vhost_copy_t copy[VHOST_USER_COPY_ARRAY_N]
static void vhost_user_term_if(vhost_user_intf_t *vui)
Disables and reset interface structure.
#define VLIB_BUFFER_PRE_DATA_SIZE
static uword vhost_user_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
uword * pending_input_bitmap
#define VHOST_USER_EVENT_START_TIMER
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
struct _vlib_node_registration vlib_node_registration_t
static_always_inline u32 vhost_user_input_copy(vhost_user_intf_t *vui, vhost_copy_t *cpy, u16 copy_len, u32 *map_hint)
#define VHOST_USER_MSG_HDR_SZ
static clib_error_t * vhost_user_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
int vhost_user_create_if(vnet_main_t *vnm, vlib_main_t *vm, const char *sock_filename, u8 is_server, u32 *sw_if_index, u64 feature_mask, u8 renumber, u32 custom_dev_instance, u8 *hwaddr, u8 operation_mode)
static clib_error_t * vhost_thread_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * show_vhost_user_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t unformat_vnet_sw_interface
#define VNET_HW_INTERFACE_FLAG_LINK_UP
static char * vhost_user_input_func_error_strings[]
static char * vhost_user_tx_func_error_strings[]
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
vlib_main_t ** vlib_mains
format_function_t format_vnet_sw_if_index_name
vhost_trace_t * current_trace
static uword vlib_process_suspend_time_is_zero(f64 dt)
Returns TRUE if a process suspend time is less than 1us.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int vhost_user_name_renumber(vnet_hw_interface_t *hi, u32 new_dev_instance)
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
#define VHOST_VRING_F_LOG
static void vnet_device_increment_rx_packets(u32 cpu_index, u64 count)
VNET_DEVICE_CLASS(vhost_user_dev_class, static)
#define VLIB_BUFFER_NEXT_PRESENT
static u8 * format_vhost_user_interface_name(u8 *s, va_list *args)
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define vlib_prefetch_buffer_with_index(vm, bi, type)
Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header informatio...
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
vlib_combined_counter_main_t * combined_sw_if_counters
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
#define foreach_protocol_feature
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
static u8 * format_vhost_user_operation_mode(u8 *s, va_list *va)
vhost_user_tx_func_error_t
static void unmap_all_mem_regions(vhost_user_intf_t *vui)
static void vhost_user_set_interrupt_pending(vhost_user_intf_t *vui, u32 ifq)
vhost_iface_and_queue_t * rx_queues
vhost_user_input_func_error_t
#define vlib_call_init_function(vm, x)
static clib_error_t * vhost_user_socket_read(unix_file_t *uf)
static uword pointer_to_uword(const void *p)
int vhost_user_modify_if(vnet_main_t *vnm, vlib_main_t *vm, const char *sock_filename, u8 is_server, u32 sw_if_index, u64 feature_mask, u8 renumber, u32 custom_dev_instance, u8 operation_mode)
#define UNIX_GET_FD(unixfd_idx)
static int vhost_user_init_server_sock(const char *sock_filename, int *sock_fd)
Open server unix socket on specified sock_filename.
static uword vhost_user_send_interrupt_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
VLIB_DEVICE_TX_FUNCTION_MULTIARCH(vhost_user_dev_class, vhost_user_tx)
static uword unix_file_add(unix_main_t *um, unix_file_t *template)
static void vhost_user_vring_unlock(vhost_user_intf_t *vui, u32 qid)
Unlock the vring lock.
format_function_t format_vnet_sw_interface_name
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
vlib_main_t vlib_global_main
int vhost_user_delete_if(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
static void * map_user_mem(vhost_user_intf_t *vui, uword addr)
u32 random
Pseudo random iterator.
static_always_inline void vhost_user_log_dirty_pages(vhost_user_intf_t *vui, u64 addr, u64 len)
uword os_get_cpu_number(void)
#define VIRTQ_DESC_F_INDIRECT
#define clib_error_return_unix(e, args...)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
static void vhost_user_vui_init(vnet_main_t *vnm, vhost_user_intf_t *vui, int server_sock_fd, const char *sock_filename, u64 feature_mask, u32 *sw_if_index, u8 operation_mode)
#define pool_put(P, E)
Free an object E in pool P.
void vhost_user_tx_trace(vhost_trace_t *t, vhost_user_intf_t *vui, u16 qid, vlib_buffer_t *b, vhost_user_vring_t *rxvq)
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define vhost_user_log_dirty_ring(vui, vq, member)
static vlib_node_registration_t vhost_user_process_node
(constructor) VLIB_REGISTER_NODE (vhost_user_process_node)
void vhost_user_unmap_all(void)
#define vec_del1(v, i)
Delete the element at index I.
vlib_simple_counter_main_t * sw_if_counters
u32 region_mmap_fd[VHOST_MEMORY_MAX_NREGIONS]
static void vhost_user_send_call(vlib_main_t *vm, vhost_user_vring_t *vq)
u32 node_index
Node index.
vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS]
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
int vhost_user_dump_ifs(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static uword unformat_vhost_user_operation_mode(unformat_input_t *input, va_list *args)
static clib_error_t * vhost_user_exit(vlib_main_t *vm)
static void vhost_user_tx_thread_placement(vhost_user_intf_t *vui)
static void vhost_user_vring_init(vhost_user_intf_t *vui, u32 qid)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
static vlib_node_registration_t vhost_user_send_interrupt_node
(constructor) VLIB_REGISTER_NODE (vhost_user_send_interrupt_node)
u32 * show_dev_instance_by_real_dev_instance
u16 device_index
The interface queue index (Not the virtio vring idx)
vhost_user_intf_t * vhost_user_interfaces
static clib_error_t * vhost_user_kickfd_read_ready(unix_file_t *uf)
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vhost_user_log_dirty_pages_2(vhost_user_intf_t *vui, u64 addr, u64 len, u8 is_host_address)
#define vec_free(V)
Free vector's memory (no header).
static int vhost_user_vring_try_lock(vhost_user_intf_t *vui, u32 qid)
Try once to lock the vring.
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
#define clib_warning(format, args...)
#define VLIB_BUFFER_IS_TRACED
#define clib_memcpy(a, b, c)
#define VHOST_MEMORY_MAX_NREGIONS
static_always_inline void * map_guest_mem(vhost_user_intf_t *vui, uword addr, u32 *hint)
static u32 vlib_buffer_alloc_from_free_list(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
Allocate buffers from specific freelist into supplied array.
void vlib_worker_thread_barrier_sync(vlib_main_t *vm)
static uword vhost_user_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u16 first_desc_len
Runtime queue flags.
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD
#define VLIB_BUFFER_DATA_SIZE
static void vhost_user_input_rewind_buffers(vlib_main_t *vm, vhost_cpu_t *cpu, vlib_buffer_t *b_head)
#define VLIB_CLI_COMMAND(x,...)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
u32 rx_buffers[VHOST_USER_RX_BUFFERS_N]
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
#define VHOST_USER_RX_BUFFER_STARVATION
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static long get_huge_page_size(int fd)
vhost_vring_state_t state
u32 next_buffer
Next buffer for this linked-list of buffers.
clib_error_t * vhost_user_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int vhost_user_thread_placement(u32 sw_if_index, u32 worker_thread_index, u8 del)
static void clib_mem_free(void *p)
#define VIRTQ_DESC_F_NEXT
volatile u32 * vring_locks[VHOST_VRING_MAX_N]
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
#define clib_error_report(e)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
uword * thread_registrations_by_name
static u8 * format_vhost_trace(u8 *s, va_list *va)
#define VHOST_USER_RX_COPY_THRESHOLD
static void vhost_user_vring_lock(vhost_user_intf_t *vui, u32 qid)
Spin until the vring is successfully locked.
static vlib_main_t * vlib_get_main(void)
static void vhost_user_rx_thread_placement()
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void vhost_user_update_iface_state(vhost_user_intf_t *vui)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
#define foreach_vhost_user_tx_func_error
void * region_mmap_addr[VHOST_MEMORY_MAX_NREGIONS]
static clib_error_t * vhost_user_socksvr_accept_ready(unix_file_t *uf)
static clib_error_t * vhost_user_config(vlib_main_t *vm, unformat_input_t *input)
u32 input_cpu_count
total cpu count
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define VRING_USED_F_NO_NOTIFY
#define VHOST_USER_RX_BUFFERS_N
int vhost_user_intf_ready(vhost_user_intf_t *vui)
Returns whether at least one TX and one RX vring are enabled.
vhost_user_vring_t vrings[VHOST_VRING_MAX_N]
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
u32 input_cpu_first_index
first cpu index
#define VHOST_VRING_MAX_N
vlib_node_registration_t vhost_user_input_node
(constructor) VLIB_REGISTER_NODE (vhost_user_input_node)
#define DBG_SOCK(args...)
#define hash_get_mem(h, key)
u32 vhost_user_rx_discard_packet(vlib_main_t *vm, vhost_user_intf_t *vui, vhost_user_vring_t *txvq, u32 discard_max)
Try to discard packets from the tx ring (VPP RX path).
static vhost_user_main_t vhost_user_main
static void * clib_mem_alloc_aligned(uword size, uword align)
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
static u32 random_u32(u32 *seed)
32-bit random number generator
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static_always_inline void vnet_feature_start_device_input_x1(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
#define VLIB_REGISTER_NODE(x,...)
static vlib_thread_main_t * vlib_get_thread_main()
u64 region_guest_addr_lo[VHOST_MEMORY_MAX_NREGIONS]
static clib_error_t * vhost_user_callfd_read_ready(unix_file_t *uf)
static u32 vhost_user_if_input(vlib_main_t *vm, vhost_user_main_t *vum, vhost_user_intf_t *vui, u16 qid, vlib_node_runtime_t *node)
#define vec_foreach(var, vec)
Vector iterator.
#define foreach_vhost_user_input_func_error
#define CLIB_MEMORY_BARRIER()
virtio_net_hdr_mrg_rxbuf_t tx_headers[VLIB_FRAME_SIZE]
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static_always_inline u32 vhost_user_tx_copy(vhost_user_intf_t *vui, vhost_copy_t *cpy, u16 copy_len, u32 *map_hint)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define VHOST_USER_PROTOCOL_F_MQ
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 cpu_index, u32 index, u64 increment)
Increment a simple counter.
#define VHOST_USER_POLLING_MODE
clib_error_t * vhost_user_connect_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VNET_HW_INTERFACE_CLASS(vhost_interface_class, static)
#define VHOST_USER_INTERRUPT_MODE
int dont_dump_vhost_user_memory
#define VHOST_VRING_IDX_RX(qid)
static void unix_file_del(unix_main_t *um, unix_file_t *f)