FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
vhost_user.c File Reference

vHost User Device Driver. More...

+ Include dependency graph for vhost_user.c:

Go to the source code of this file.

Macros

#define foreach_protocol_feature
 

Functions

 VNET_HW_INTERFACE_CLASS (vhost_interface_class, static)
 
static long get_huge_page_size (int fd)
 
static void unmap_all_mem_regions (vhost_user_intf_t *vui)
 
static_always_inline void vhost_user_tx_thread_placement (vhost_user_intf_t *vui)
 
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 mappings. More...
 
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. More...
 
static_always_inline void vhost_user_update_iface_state (vhost_user_intf_t *vui)
 
static void vhost_user_set_interrupt_pending (vhost_user_intf_t *vui, u32 ifq)
 
static clib_error_tvhost_user_callfd_read_ready (clib_file_t *uf)
 
static_always_inline void vhost_user_thread_placement (vhost_user_intf_t *vui, u32 qid)
 
static clib_error_tvhost_user_kickfd_read_ready (clib_file_t *uf)
 
static_always_inline void vhost_user_vring_init (vhost_user_intf_t *vui, u32 qid)
 
static_always_inline void vhost_user_vring_close (vhost_user_intf_t *vui, u32 qid)
 
static_always_inline void vhost_user_if_disconnect (vhost_user_intf_t *vui)
 
static clib_error_tvhost_user_socket_read (clib_file_t *uf)
 
static clib_error_tvhost_user_socket_error (clib_file_t *uf)
 
static clib_error_tvhost_user_socksvr_accept_ready (clib_file_t *uf)
 
static clib_error_tvhost_user_init (vlib_main_t *vm)
 
static uword vhost_user_send_interrupt_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
static uword vhost_user_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
static void vhost_user_term_if (vhost_user_intf_t *vui)
 Disables and reset interface structure. More...
 
int vhost_user_delete_if (vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
 
static clib_error_tvhost_user_exit (vlib_main_t *vm)
 
static int vhost_user_init_server_sock (const char *sock_filename, int *sock_fd)
 Open server unix socket on specified sock_filename. More...
 
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. More...
 
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 enable_gso, u8 enable_packed)
 
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 enable_gso, u8 enable_packed)
 
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 enable_gso, u8 enable_packed)
 
clib_error_tvhost_user_connect_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
clib_error_tvhost_user_delete_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
int vhost_user_dump_ifs (vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
 
static u8format_vhost_user_desc (u8 *s, va_list *args)
 
static u8format_vhost_user_vring (u8 *s, va_list *args)
 
static void vhost_user_show_fds (vlib_main_t *vm, vhost_user_intf_t *vui, int q)
 
static void vhost_user_show_desc (vlib_main_t *vm, vhost_user_intf_t *vui, int q, int show_descr, int show_verbose)
 
static u8format_vhost_user_packed_desc (u8 *s, va_list *args)
 
static u8format_vhost_user_vring_packed (u8 *s, va_list *args)
 
static void vhost_user_show_desc_packed (vlib_main_t *vm, vhost_user_intf_t *vui, int q, int show_descr, int show_verbose)
 
clib_error_tshow_vhost_user_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tvhost_user_config (vlib_main_t *vm, unformat_input_t *input)
 
void vhost_user_unmap_all (void)
 

Variables

vlib_node_registration_t vhost_user_send_interrupt_node
 (constructor) VLIB_REGISTER_NODE (vhost_user_send_interrupt_node) More...
 
vhost_user_main_t vhost_user_main
 
static vlib_node_registration_t vhost_user_process_node
 (constructor) VLIB_REGISTER_NODE (vhost_user_process_node) More...
 
static vlib_cli_command_t vhost_user_connect_command
 (constructor) VLIB_CLI_COMMAND (vhost_user_connect_command) More...
 
static vlib_cli_command_t vhost_user_delete_command
 (constructor) VLIB_CLI_COMMAND (vhost_user_delete_command) More...
 
static vlib_cli_command_t show_vhost_user_command
 (constructor) VLIB_CLI_COMMAND (show_vhost_user_command) More...
 

Detailed Description

vHost User Device Driver.

This file contains the source code for vHost User interface.

Definition in file vhost_user.c.

Macro Definition Documentation

◆ foreach_protocol_feature

#define foreach_protocol_feature
Value:
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD
Definition: vhost_user.h:32
#define VHOST_USER_PROTOCOL_F_MQ
Definition: vhost_user.h:31

Function Documentation

◆ format_vhost_user_desc()

static u8* format_vhost_user_desc ( u8 s,
va_list *  args 
)
static

Definition at line 1858 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_vhost_user_packed_desc()

static u8* format_vhost_user_packed_desc ( u8 s,
va_list *  args 
)
static

Definition at line 1950 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_vhost_user_vring()

static u8* format_vhost_user_vring ( u8 s,
va_list *  args 
)
static

Definition at line 1874 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_vhost_user_vring_packed()

static u8* format_vhost_user_vring_packed ( u8 s,
va_list *  args 
)
static

Definition at line 1966 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_huge_page_size()

static long get_huge_page_size ( int  fd)
static

Definition at line 66 of file vhost_user.c.

+ Here is the caller graph for this function:

◆ show_vhost_user_command_fn()

clib_error_t* show_vhost_user_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)

Definition at line 2038 of file vhost_user.c.

+ Here is the call graph for this function:

◆ unmap_all_mem_regions()

static void unmap_all_mem_regions ( vhost_user_intf_t vui)
static

Definition at line 74 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_callfd_read_ready()

static clib_error_t* vhost_user_callfd_read_ready ( clib_file_t uf)
static

Definition at line 230 of file vhost_user.c.

+ Here is the caller graph for this function:

◆ vhost_user_config()

static clib_error_t* vhost_user_config ( vlib_main_t vm,
unformat_input_t input 
)
static

Definition at line 2473 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_connect_command_fn()

clib_error_t* vhost_user_connect_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)

Definition at line 1690 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_create_ethernet()

static void vhost_user_create_ethernet ( vnet_main_t vnm,
vlib_main_t vm,
vhost_user_intf_t vui,
u8 hwaddress 
)
static

Create ethernet interface for vhost user interface.

Definition at line 1457 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_create_if()

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  enable_gso,
u8  enable_packed 
)

Definition at line 1571 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_delete_command_fn()

clib_error_t* vhost_user_delete_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)

Definition at line 1765 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_delete_if()

int vhost_user_delete_if ( vnet_main_t vnm,
vlib_main_t vm,
u32  sw_if_index 
)

Definition at line 1335 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_dump_ifs()

int vhost_user_dump_ifs ( vnet_main_t vnm,
vlib_main_t vm,
vhost_user_intf_details_t **  out_vuids 
)

Definition at line 1812 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_exit()

static clib_error_t* vhost_user_exit ( vlib_main_t vm)
static

Definition at line 1395 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_if_disconnect()

static_always_inline void vhost_user_if_disconnect ( vhost_user_intf_t vui)

Definition at line 335 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_init()

static clib_error_t* vhost_user_init ( vlib_main_t vm)
static

Definition at line 1044 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_init_server_sock()

static int vhost_user_init_server_sock ( const char *  sock_filename,
int *  sock_fd 
)
static

Open server unix socket on specified sock_filename.

Definition at line 1417 of file vhost_user.c.

+ Here is the caller graph for this function:

◆ vhost_user_intf_ready()

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.

Definition at line 185 of file vhost_user.c.

+ Here is the caller graph for this function:

◆ vhost_user_kickfd_read_ready()

static clib_error_t* vhost_user_kickfd_read_ready ( clib_file_t uf)
static

Definition at line 253 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_modify_if()

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  enable_gso,
u8  enable_packed 
)

Definition at line 1635 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_process()

static uword vhost_user_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 1176 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_rx_thread_placement()

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 mappings.

Definition at line 161 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_send_interrupt_process()

static uword vhost_user_send_interrupt_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 1079 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_set_interrupt_pending()

static void vhost_user_set_interrupt_pending ( vhost_user_intf_t vui,
u32  ifq 
)
static

Definition at line 214 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_show_desc()

static void vhost_user_show_desc ( vlib_main_t vm,
vhost_user_intf_t vui,
int  q,
int  show_descr,
int  show_verbose 
)
static

Definition at line 1896 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_show_desc_packed()

static void vhost_user_show_desc_packed ( vlib_main_t vm,
vhost_user_intf_t vui,
int  q,
int  show_descr,
int  show_verbose 
)
static

Definition at line 1982 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_show_fds()

static void vhost_user_show_fds ( vlib_main_t vm,
vhost_user_intf_t vui,
int  q 
)
static

Definition at line 1886 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_socket_error()

static clib_error_t* vhost_user_socket_error ( clib_file_t uf)
static

Definition at line 993 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_socket_read()

static clib_error_t* vhost_user_socket_read ( clib_file_t uf)
static

Definition at line 358 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_socksvr_accept_ready()

static clib_error_t* vhost_user_socksvr_accept_ready ( clib_file_t uf)
static

Definition at line 1008 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_term_if()

static void vhost_user_term_if ( vhost_user_intf_t vui)
static

Disables and reset interface structure.

It can then be either init again, or removed from used interfaces.

Definition at line 1287 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_thread_placement()

static_always_inline void vhost_user_thread_placement ( vhost_user_intf_t vui,
u32  qid 
)

Definition at line 241 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_tx_thread_placement()

static_always_inline void vhost_user_tx_thread_placement ( vhost_user_intf_t vui)

Definition at line 120 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_unmap_all()

void vhost_user_unmap_all ( void  )

Definition at line 2497 of file vhost_user.c.

+ Here is the call graph for this function:

◆ vhost_user_update_iface_state()

static_always_inline void vhost_user_update_iface_state ( vhost_user_intf_t vui)

Definition at line 197 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_vring_close()

static_always_inline void vhost_user_vring_close ( vhost_user_intf_t vui,
u32  qid 
)

Definition at line 303 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_vring_init()

static_always_inline void vhost_user_vring_init ( vhost_user_intf_t vui,
u32  qid 
)

Definition at line 280 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vhost_user_vui_init()

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  enable_gso,
u8  enable_packed 
)
static

Definition at line 1492 of file vhost_user.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VNET_HW_INTERFACE_CLASS()

VNET_HW_INTERFACE_CLASS ( vhost_interface_class  ,
static   
)

Variable Documentation

◆ show_vhost_user_command

vlib_cli_command_t show_vhost_user_command
static
Initial value:
= {
.path = "show vhost-user",
.short_help = "show vhost-user [<interface> [<interface> [..]]] "
"[[descriptors] [verbose]]",
}
clib_error_t * show_vhost_user_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: vhost_user.c:2038

(constructor) VLIB_CLI_COMMAND (show_vhost_user_command)

Definition at line 2463 of file vhost_user.c.

◆ vhost_user_connect_command

vlib_cli_command_t vhost_user_connect_command
static
Initial value:
= {
.path = "create vhost-user",
.short_help = "create vhost-user socket <socket-filename> [server] "
"[feature-mask <hex>] [hwaddr <mac-addr>] [renumber <dev_instance>] [gso] "
"[packed]",
.is_mp_safe = 1,
}
clib_error_t * vhost_user_connect_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: vhost_user.c:1690

(constructor) VLIB_CLI_COMMAND (vhost_user_connect_command)

Definition at line 2300 of file vhost_user.c.

◆ vhost_user_delete_command

vlib_cli_command_t vhost_user_delete_command
static
Initial value:
= {
.path = "delete vhost-user",
.short_help = "delete vhost-user {<interface> | sw_if_index <sw_idx>}",
}
clib_error_t * vhost_user_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: vhost_user.c:1765

(constructor) VLIB_CLI_COMMAND (vhost_user_delete_command)

Definition at line 2323 of file vhost_user.c.

◆ vhost_user_main

vhost_user_main_t vhost_user_main
Initial value:
= {
.mtu_bytes = 1518,
}

Definition at line 56 of file vhost_user.c.

◆ vhost_user_process_node

vlib_node_registration_t vhost_user_process_node
static
Initial value:
= {
.function = vhost_user_process,
.name = "vhost-user-process",
}
static uword vhost_user_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: vhost_user.c:1176

(constructor) VLIB_REGISTER_NODE (vhost_user_process_node)

Definition at line 1275 of file vhost_user.c.

◆ vhost_user_send_interrupt_node

vlib_node_registration_t vhost_user_send_interrupt_node
Initial value:
= {
.name = "vhost-user-send-interrupt-process",
}
static uword vhost_user_send_interrupt_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: vhost_user.c:1079

(constructor) VLIB_REGISTER_NODE (vhost_user_send_interrupt_node)

Definition at line 53 of file vhost_user.c.