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> 86 ssize_t map_sz = (vui->
regions[
i].memory_size +
88 page_sz - 1) & ~(page_sz - 1);
95 (
"unmap memory region %d addr 0x%lx len 0x%lx page_sz 0x%x", i,
102 clib_warning (
"failed to unmap memory region (errno %d)",
124 u32 thread_index = 0;
142 if (thread_index == 0)
145 for (thread_index = 0;
179 clib_warning (
"Warning: unable to set rx mode for interface %d, " 187 int i, found[2] = { };
193 return found[0] && found[1];
201 if (is_up != vui->
is_up)
204 is_up ?
"ready" :
"down");
231 __attribute__ ((unused))
int n;
254 __attribute__ ((unused))
int n;
282 memset (vring, 0,
sizeof (*vring));
297 if (qid == 0 || qid == 1)
320 if (vring->
errfd != -1)
322 close (vring->
errfd);
360 int fd, number_of_fds = 0;
362 vhost_user_msg_t msg;
367 struct cmsghdr *cmsg;
377 memset (&mh, 0,
sizeof (mh));
378 memset (control, 0,
sizeof (control));
384 iov[0].iov_base = (
void *) &msg;
389 mh.msg_control = control;
390 mh.msg_controllen =
sizeof (control);
398 DBG_SOCK (
"recvmsg returned error %d %s", errno, strerror (errno));
402 DBG_SOCK (
"n (%d) != VHOST_USER_MSG_HDR_SZ (%d)",
408 if (mh.msg_flags & MSG_CTRUNC)
414 cmsg = CMSG_FIRSTHDR (&mh);
416 if (cmsg && (cmsg->cmsg_len > 0) && (cmsg->cmsg_level == SOL_SOCKET) &&
417 (cmsg->cmsg_type == SCM_RIGHTS) &&
418 (cmsg->cmsg_len - CMSG_LEN (0) <=
419 VHOST_MEMORY_MAX_NREGIONS *
sizeof (
int)))
421 number_of_fds = (cmsg->cmsg_len - CMSG_LEN (0)) /
sizeof (
int);
422 clib_memcpy (fds, CMSG_DATA (cmsg), number_of_fds *
sizeof (
int));
426 if ((msg.flags & 7) != 1)
428 DBG_SOCK (
"malformed message received. closing socket");
439 DBG_SOCK (
"read failed %s", strerror (errno));
442 else if (rv != msg.size)
444 DBG_SOCK (
"message too short (read %dB should be %dB)", rv, msg.size);
453 msg.u64 = (1ULL << FEAT_VIRTIO_NET_F_MRG_RXBUF) |
454 (1ULL << FEAT_VIRTIO_NET_F_CTRL_VQ) |
455 (1ULL << FEAT_VIRTIO_F_ANY_LAYOUT) |
456 (1ULL << FEAT_VIRTIO_F_INDIRECT_DESC) |
457 (1ULL << FEAT_VHOST_F_LOG_ALL) |
458 (1ULL << FEAT_VIRTIO_NET_F_GUEST_ANNOUNCE) |
459 (1ULL << FEAT_VIRTIO_NET_F_MQ) |
460 (1ULL << FEAT_VHOST_USER_F_PROTOCOL_FEATURES) |
461 (1ULL << FEAT_VIRTIO_F_VERSION_1);
463 msg.size =
sizeof (msg.u64);
464 DBG_SOCK (
"if %d msg VHOST_USER_GET_FEATURES - reply 0x%016llx",
470 DBG_SOCK (
"could not send message response");
476 DBG_SOCK (
"if %d msg VHOST_USER_SET_FEATURES features 0x%016llx",
482 ((1 << FEAT_VIRTIO_NET_F_MRG_RXBUF) |
483 (1ULL << FEAT_VIRTIO_F_VERSION_1)))
489 (vui->
features & (1 << FEAT_VIRTIO_F_ANY_LAYOUT)) ? 1 : 0;
497 DBG_SOCK (
"if %d msg VHOST_USER_SET_MEM_TABLE nregions %d",
500 if ((msg.memory.nregions < 1) ||
501 (msg.memory.nregions > VHOST_MEMORY_MAX_NREGIONS))
503 DBG_SOCK (
"number of mem regions must be between 1 and %i",
504 VHOST_MEMORY_MAX_NREGIONS);
508 if (msg.memory.nregions != number_of_fds)
510 DBG_SOCK (
"each memory region must have FD");
516 for (i = 0; i < msg.memory.nregions; i++)
521 ssize_t map_sz = (msg.memory.regions[
i].memory_size +
522 msg.memory.regions[
i].mmap_offset +
523 page_sz - 1) & ~(page_sz - 1);
525 region_mmap_addr[
i] = mmap (0, map_sz, PROT_READ | PROT_WRITE,
526 MAP_SHARED, fds[i], 0);
527 if (region_mmap_addr[i] == MAP_FAILED)
529 clib_warning (
"failed to map memory. errno is %d", errno);
530 for (j = 0; j <
i; j++)
531 munmap (region_mmap_addr[j], map_sz);
534 DBG_SOCK (
"map memory region %d addr 0 len 0x%lx fd %d " 535 "mapped 0x%lx page_sz 0x%x", i, map_sz, fds[i],
536 region_mmap_addr[i], page_sz);
541 for (i = 0; i < msg.memory.nregions; i++)
544 sizeof (vhost_user_memory_region_t));
560 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_NUM idx %d num %d",
563 if ((msg.state.num > 32768) ||
564 (msg.state.num == 0) ||
565 ((msg.state.num - 1) & msg.state.num))
571 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_ADDR idx %d",
576 DBG_SOCK (
"invalid vring index VHOST_USER_SET_VRING_ADDR:" 581 if (msg.size < sizeof (msg.addr))
583 DBG_SOCK (
"vhost message is too short (%d < %d)",
584 msg.size, sizeof (msg.addr));
588 vring_desc_t *desc =
map_user_mem (vui, msg.addr.desc_user_addr);
589 vring_used_t *used =
map_user_mem (vui, msg.addr.used_user_addr);
590 vring_avail_t *avail =
map_user_mem (vui, msg.addr.avail_user_addr);
591 if ((desc ==
NULL) || (used ==
NULL) || (avail ==
NULL))
593 DBG_SOCK (
"failed to map user memory for hw_if_index %d",
608 if (!(vui->
features & (1 << FEAT_VHOST_USER_F_PROTOCOL_FEATURES)))
630 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_CALL %d",
633 q = (
u8) (msg.u64 & 0xFF);
646 if (number_of_fds != 1)
648 DBG_SOCK (
"More than one fd received !");
653 template.file_descriptor = fds[0];
654 template.private_data =
663 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_KICK %d",
666 q = (
u8) (msg.u64 & 0xFF);
678 if (number_of_fds != 1)
680 DBG_SOCK (
"More than one fd received !");
685 template.file_descriptor = fds[0];
686 template.private_data =
702 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_ERR %d",
705 q = (
u8) (msg.u64 & 0xFF);
712 if (number_of_fds != 1)
722 DBG_SOCK (
"if %d msg VHOST_USER_SET_VRING_BASE idx %d num %d",
732 DBG_SOCK (
"invalid vring index VHOST_USER_GET_VRING_BASE:" 745 msg.size =
sizeof (msg.state);
753 DBG_SOCK (
"if %d msg VHOST_USER_GET_VRING_BASE idx %d num %d",
759 DBG_SOCK (
"could not send message response");
772 if (msg.size != sizeof (msg.log))
775 (
"invalid msg size for VHOST_USER_SET_LOG_BASE: %d instead of %d",
776 msg.size, sizeof (msg.log));
783 (
"VHOST_USER_PROTOCOL_F_LOG_SHMFD not set but VHOST_USER_SET_LOG_BASE received");
791 (msg.log.size + msg.log.offset + page_sz - 1) & ~(page_sz - 1);
793 void *log_base_addr = mmap (0, map_sz, PROT_READ | PROT_WRITE,
797 (
"map log region addr 0 len 0x%lx off 0x%lx fd %d mapped 0x%lx",
798 map_sz, msg.log.offset, fd, log_base_addr);
800 if (log_base_addr == MAP_FAILED)
802 clib_warning (
"failed to map memory. errno is %d", errno);
813 msg.size =
sizeof (msg.u64);
818 DBG_SOCK (
"could not send message response");
831 msg.size =
sizeof (msg.u64);
833 (
"if %d msg VHOST_USER_GET_PROTOCOL_FEATURES - reply 0x%016llx",
839 DBG_SOCK (
"could not send message response");
846 (
"if %d msg VHOST_USER_SET_PROTOCOL_FEATURES features 0x%016llx",
854 msg.size =
sizeof (msg.u64);
855 DBG_SOCK (
"if %d msg VHOST_USER_GET_QUEUE_NUM - reply %d",
861 DBG_SOCK (
"could not send message response");
867 DBG_SOCK (
"if %d VHOST_USER_SET_VRING_ENABLE: %s queue %d",
868 vui->
hw_if_index, msg.state.num ?
"enable" :
"disable",
872 DBG_SOCK (
"invalid vring index VHOST_USER_SET_VRING_ENABLE:" 883 DBG_SOCK (
"unknown vhost-user message %d received. closing socket",
916 int client_fd, client_len;
917 struct sockaddr_un client;
924 client_len =
sizeof (client);
926 (
struct sockaddr *) &client,
927 (socklen_t *) & client_len);
934 DBG_SOCK (
"Close client socket for vhost interface %d, fd %d",
939 DBG_SOCK (
"New client socket for vhost interface %d, fd %d",
943 template.file_descriptor = client_fd;
987 f64 timeout = 3153600000.0 ;
988 uword event_type, *event_data = 0;
991 f64 now, poll_time_remaining;
997 poll_time_remaining =
1006 timeout = poll_time_remaining;
1027 next_timeout = timeout;
1028 for (qid = 0; qid < VHOST_VRING_MAX_N / 2; qid += 2)
1030 vhost_user_vring_t *rxvq = &vui->vrings[qid];
1031 vhost_user_vring_t *txvq = &vui->vrings[qid + 1];
1033 if (txvq->qid == -1)
1035 if (txvq->n_since_last_int)
1037 if (now >= txvq->int_deadline)
1038 vhost_user_send_call (vm, txvq);
1040 next_timeout = txvq->int_deadline - now;
1043 if (rxvq->n_since_last_int)
1045 if (now >= rxvq->int_deadline)
1046 vhost_user_send_call (vm, rxvq);
1048 next_timeout = rxvq->int_deadline - now;
1051 if ((next_timeout < timeout) && (next_timeout > 0.0))
1052 timeout = next_timeout;
1059 clib_warning (
"BUG: unhandled event type %d", event_type);
1066 timeout = 3153600000.0;
1075 .name =
"vhost-user-send-interrupt-process",
1085 struct sockaddr_un sun;
1088 f64 timeout = 3153600000.0 ;
1089 uword *event_data = 0;
1092 sun.sun_family = AF_UNIX;
1107 if (vui->unix_server_index == ~0) {
1108 if (vui->clib_file_index == ~0)
1111 ((sockfd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0))
1117 if (!vui->sock_errno || (vui->sock_errno != errno))
1120 (
"Error: Could not open unix socket for %s",
1121 vui->sock_filename);
1122 vui->sock_errno = errno;
1128 strncpy (sun.sun_path, (char *) vui->sock_filename,
1129 sizeof (sun.sun_path) - 1);
1132 if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
1133 clib_unix_warning (
"fcntl");
1135 if (connect (sockfd, (struct sockaddr *) &sun,
1136 sizeof (struct sockaddr_un)) == 0)
1139 if (fcntl(sockfd, F_SETFL, 0) < 0)
1140 clib_unix_warning (
"fcntl2");
1142 vui->sock_errno = 0;
1143 template.file_descriptor = sockfd;
1144 template.private_data =
1145 vui - vhost_user_main.vhost_user_interfaces;
1146 vui->clib_file_index = clib_file_add (&file_main, &template);
1153 vui->sock_errno = errno;
1160 socklen_t len = sizeof (error);
1161 int fd = UNIX_GET_FD(vui->clib_file_index);
1163 getsockopt (fd, SOL_SOCKET, SO_ERROR, &error, &len);
1167 DBG_SOCK (
"getsockopt returned %d", retval);
1168 vhost_user_if_disconnect (vui);
1182 .name =
"vhost-user-process",
1209 if (txvq->
qid != -1)
1215 clib_warning (
"Warning: unable to unassign interface %d, " 1249 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1251 DBG_SOCK (
"Deleting vhost-user interface %s (instance %d)",
1260 if (txvq->
qid == -1)
1306 vhost_user_delete_if (vnm, vm, vui->sw_if_index);
1322 struct sockaddr_un
un = { };
1325 if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
1326 return VNET_API_ERROR_SYSCALL_ERROR_1;
1328 un.sun_family = AF_UNIX;
1329 strncpy ((
char *) un.sun_path, (
char *) sock_filename,
1330 sizeof (un.sun_path) - 1);
1333 unlink ((
char *) sock_filename);
1335 if (bind (fd, (
struct sockaddr *) &un,
sizeof (un)) == -1)
1337 rv = VNET_API_ERROR_SYSCALL_ERROR_2;
1341 if (listen (fd, 1) == -1)
1343 rv = VNET_API_ERROR_SYSCALL_ERROR_3;
1397 const char *sock_filename,
1398 u64 feature_mask,
u32 * sw_if_index)
1407 if (server_sock_fd != -1)
1411 template.file_descriptor = server_sock_fd;
1455 const char *sock_filename,
1459 u8 renumber,
u32 custom_dev_instance,
u8 * hwaddr)
1464 int server_sock_fd = -1;
1468 if (sock_filename ==
NULL || !(strlen (sock_filename) > 0))
1470 return VNET_API_ERROR_INVALID_ARGUMENT;
1481 return VNET_API_ERROR_IF_ALREADY_EXISTS;
1500 feature_mask, &sw_if_idx);
1508 *sw_if_index = sw_if_idx;
1518 const char *sock_filename,
1521 u64 feature_mask,
u8 renumber,
u32 custom_dev_instance)
1526 int server_sock_fd = -1;
1533 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1535 if (sock_filename ==
NULL || !(strlen (sock_filename) > 0))
1536 return VNET_API_ERROR_INVALID_ARGUMENT;
1545 if (if_index && (*if_index != vui->
if_index))
1546 return VNET_API_ERROR_IF_ALREADY_EXISTS;
1551 &server_sock_fd)) != 0)
1556 sock_filename, feature_mask, &sw_if_idx);
1573 u8 *sock_filename =
NULL;
1576 u64 feature_mask = (
u64) ~ (0ULL);
1578 u32 custom_dev_instance = ~0;
1589 if (
unformat (line_input,
"socket %s", &sock_filename))
1591 else if (
unformat (line_input,
"server"))
1593 else if (
unformat (line_input,
"feature-mask 0x%llx", &feature_mask))
1599 else if (
unformat (line_input,
"renumber %d", &custom_dev_instance))
1615 is_server, &sw_if_index, feature_mask,
1616 renumber, custom_dev_instance, hw)))
1638 u32 sw_if_index = ~0;
1648 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
1688 u32 *hw_if_indices = 0;
1700 for (i = 0; i <
vec_len (hw_if_indices); i++)
1717 strncpy ((
char *) vuid->
if_name, (
char *) s,
1725 *out_vuids = r_vuids;
1739 u32 hw_if_index, *hw_if_indices = 0;
1750 struct feat_struct *feat_entry;
1752 static struct feat_struct feat_array[] = {
1753 #define _(s,b) { .str = #s, .bit = b, }, 1759 #define foreach_protocol_feature \ 1760 _(VHOST_USER_PROTOCOL_F_MQ) \ 1761 _(VHOST_USER_PROTOCOL_F_LOG_SHMFD) 1763 static struct feat_struct proto_feat_array[] = {
1764 #define _(s) { .str = #s, .bit = s}, 1782 vec_add1 (hw_if_indices, hw_if_index);
1793 if (
vec_len (hw_if_indices) == 0)
1802 vlib_cli_output (vm,
" number of rx virtqueues in interrupt mode: %d",
1805 for (i = 0; i <
vec_len (hw_if_indices); i++)
1810 hi->
name, hw_if_indices[i]);
1813 " features mask (0x%llx): \n" 1814 " features (0x%llx): \n",
1818 feat_entry = (
struct feat_struct *) &feat_array;
1819 while (feat_entry->str)
1821 if (vui->
features & (1ULL << feat_entry->bit))
1829 feat_entry = (
struct feat_struct *) &proto_feat_array;
1830 while (feat_entry->str)
1854 if (txvq->
qid == -1)
1882 " region fd guest_phys_addr memory_size userspace_addr mmap_offset mmap_addr\n");
1884 " ====== ===== ================== ================== ================== ================== ==================\n");
1886 for (j = 0; j < vui->
nregions; j++)
1889 " %d %-5d 0x%016lx 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n",
1891 vui->
regions[j].guest_phys_addr,
1893 vui->
regions[j].userspace_addr,
1903 (q & 1) ?
"RX" :
"TX",
1907 " qsz %d last_avail_idx %d last_used_idx %d\n",
1914 " avail.flags %x avail.idx %d used.flags %x used.idx %d\n",
1929 " id addr len flags next user_addr\n");
1931 " ===== ================== ===== ====== ===== ==================\n");
1936 " %-5d 0x%016lx %-5d 0x%04x %-5d 0x%016lx\n",
2015 .path =
"create vhost-user",
2016 .short_help =
"create vhost-user socket <socket-filename> [server] " 2017 "[feature-mask <hex>] [hwaddr <mac-addr>] [renumber <dev_instance>] ",
2037 .path =
"delete vhost-user",
2038 .short_help =
"delete vhost-user {<interface> | sw_if_index <sw_idx>}",
2177 .path =
"show vhost-user",
2178 .short_help =
"show vhost-user [<interface> [<interface> [..]]] [descriptors]",
2212 else if (
unformat (line_input,
"off"))
2235 .path =
"debug vhost-user",
2236 .short_help =
"debug vhost-user <on | off>",
2252 else if (
unformat (input,
"dont-dump-memory"))
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) ...
#define vec_foreach_index(var, v)
Iterate over vector indices.
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
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)
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD
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...
VNET_HW_INTERFACE_CLASS(vhost_interface_class, static)
vhost_cpu_t * cpus
Per-CPU data for vhost-user.
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
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)
u64 region_guest_addr_hi[VHOST_MEMORY_MAX_NREGIONS]
static clib_error_t * vhost_user_socksvr_accept_ready(clib_file_t *uf)
#define VHOST_VRING_MAX_N
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
static f64 vlib_time_now(vlib_main_t *vm)
static_always_inline void vhost_user_update_iface_state(vhost_user_intf_t *vui)
#define VLIB_BUFFER_PRE_DATA_SIZE
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_device_class_t vhost_user_device_class
#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)
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)
static clib_error_t * vhost_user_callfd_read_ready(clib_file_t *uf)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define VHOST_USER_EVENT_START_TIMER
static_always_inline void vhost_user_vring_init(vhost_user_intf_t *vui, u32 qid)
unformat_function_t unformat_vnet_sw_interface
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
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)
format_function_t format_vnet_sw_if_index_name
#define VHOST_USER_VRING_NOFD_MASK
static_always_inline void vhost_user_rx_thread_placement(vhost_user_intf_t *vui, u32 qid)
Unassign existing interface/queue to thread mappings and re-assign new interface/queue to thread mapp...
static uword vlib_process_suspend_time_is_zero(f64 dt)
Returns TRUE if a process suspend time is less than 10us.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_file_function_t * read_function
#define vlib_worker_thread_barrier_sync(X)
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_hw_interface_rx_mode
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#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...
static clib_error_t * vhost_user_socket_read(clib_file_t *uf)
#define UNIX_GET_FD(unixfd_idx)
static_always_inline void vhost_user_thread_placement(vhost_user_intf_t *vui, u32 qid)
static_always_inline void * map_guest_mem(vhost_user_intf_t *vui, uword addr, u32 *hint)
static_always_inline void vnet_device_input_set_interrupt_pending(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define VRING_USED_F_NO_NOTIFY
#define clib_error_return(e, args...)
clib_file_main_t file_main
static vlib_node_registration_t vhost_user_process_node
(constructor) VLIB_REGISTER_NODE (vhost_user_process_node)
#define vlib_call_init_function(vm, x)
static clib_error_t * vhost_user_kickfd_read_ready(clib_file_t *uf)
static clib_error_t * vhost_user_socket_error(clib_file_t *uf)
void vhost_user_unmap_all(void)
static_always_inline void vhost_user_tx_thread_placement(vhost_user_intf_t *vui)
#define VHOST_USER_PROTOCOL_F_MQ
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline uword vnet_get_device_input_thread_index(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
static void vhost_user_term_if(vhost_user_intf_t *vui)
Disables and reset interface structure.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static_always_inline int vhost_user_intf_ready(vhost_user_intf_t *vui)
Returns whether at least one TX and one RX vring are enabled.
u32 random
Pseudo random iterator.
uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
vlib_node_registration_t vhost_user_input_node
(constructor) VLIB_REGISTER_NODE (vhost_user_input_node)
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)
#define clib_error_return_unix(e, args...)
int vnet_hw_interface_get_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, vnet_hw_interface_rx_mode *mode)
#define pool_put(P, E)
Free an object E in pool P.
int vhost_user_delete_if(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
format_function_t format_vnet_hw_interface_rx_mode
#define VLIB_CONFIG_FUNCTION(x, n,...)
vhost_user_main_t vhost_user_main
#define VHOST_USER_MSG_HDR_SZ
u32 region_mmap_fd[VHOST_MEMORY_MAX_NREGIONS]
int vhost_user_dump_ifs(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
#define VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE
vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS]
#define VHOST_VRING_IDX_RX(qid)
u32 * show_dev_instance_by_real_dev_instance
static_always_inline void vhost_user_vring_close(vhost_user_intf_t *vui, u32 qid)
vhost_user_intf_t * vhost_user_interfaces
#define VLIB_REGISTER_NODE(x,...)
static void mhash_init_c_string(mhash_t *h, uword n_value_bytes)
#define DBG_SOCK(args...)
#define vec_free(V)
Free vector's memory (no header).
static void unmap_all_mem_regions(vhost_user_intf_t *vui)
static clib_error_t * vhost_user_config(vlib_main_t *vm, unformat_input_t *input)
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
#define VHOST_USER_EVENT_STOP_TIMER
#define clib_warning(format, args...)
static uword vhost_user_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
#define clib_memcpy(a, b, c)
clib_error_t * vhost_user_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_protocol_feature
static int vhost_user_init_server_sock(const char *sock_filename, int *sock_fd)
Open server unix socket on specified sock_filename.
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
clib_error_t * show_vhost_user_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VHOST_VRING_F_LOG
void vnet_hw_interface_assign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, uword thread_index)
static uword * mhash_get(mhash_t *h, const void *key)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
static_always_inline void vhost_user_if_disconnect(vhost_user_intf_t *vui)
static void clib_mem_free(void *p)
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)
mhash_t if_index_by_sock_name
static clib_error_t * vhost_user_exit(vlib_main_t *vm)
#define clib_error_report(e)
vlib_node_registration_t vhost_user_send_interrupt_node
(constructor) VLIB_REGISTER_NODE (vhost_user_send_interrupt_node)
static uword pointer_to_uword(const void *p)
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.
clib_error_t * debug_vhost_user_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_main_t * vlib_get_main(void)
struct _vlib_node_registration vlib_node_registration_t
void * region_mmap_addr[VHOST_MEMORY_MAX_NREGIONS]
static long get_huge_page_size(int fd)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vhost_user_vring_t vrings[VHOST_VRING_MAX_N]
static void vhost_user_set_interrupt_pending(vhost_user_intf_t *vui, u32 ifq)
#define VHOST_MEMORY_MAX_NREGIONS
clib_error_t * vhost_user_connect_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
int vnet_hw_interface_unassign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
static void * clib_mem_alloc_aligned(uword size, uword align)
static u32 random_u32(u32 *seed)
32-bit random number generator
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static vlib_thread_main_t * vlib_get_thread_main()
u64 region_guest_addr_lo[VHOST_MEMORY_MAX_NREGIONS]
#define vec_foreach(var, vec)
Vector iterator.
int vnet_hw_interface_set_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, vnet_hw_interface_rx_mode mode)
static clib_error_t * vhost_user_init(vlib_main_t *vm)
static_always_inline void * map_user_mem(vhost_user_intf_t *vui, uword addr)
#define CLIB_CACHE_LINE_BYTES
static uword vhost_user_send_interrupt_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vl_api_address_union_t un
static void vnet_hw_interface_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
int dont_dump_vhost_user_memory