FD.io VPP  v16.06
Vector Packet Processing
vhost-user.c File Reference
+ Include dependency graph for vhost-user.c:

Go to the source code of this file.

Data Structures

struct  vhost_user_input_trace_t
 

Macros

#define VHOST_USER_DEBUG_SOCKET   0
 
#define VHOST_USER_DEBUG_VQ   0
 
#define VHOST_USER_COPY_TX_HDR   0
 
#define DBG_SOCK(args...)
 
#define DBG_VQ(args...)
 
#define foreach_vhost_user_tx_func_error
 
#define foreach_vhost_user_input_func_error
 
#define VHOST_LOG_PAGE   0x1000
 
#define vhost_user_log_dirty_ring(vui, vq, member)
 

Enumerations

enum  vhost_user_tx_func_error_t { VHOST_USER_TX_FUNC_N_ERROR }
 
enum  vhost_user_input_func_error_t { VHOST_USER_INPUT_FUNC_N_ERROR }
 
enum  { VHOST_USER_RX_NEXT_ETHERNET_INPUT, VHOST_USER_RX_NEXT_DROP, VHOST_USER_RX_N_NEXT }
 

Functions

 VNET_HW_INTERFACE_CLASS (vhost_interface_class, static)
 
static u8format_vhost_user_interface_name (u8 *s, va_list *args)
 
static int vhost_user_name_renumber (vnet_hw_interface_t *hi, u32 new_dev_instance)
 
static voidmap_guest_mem (vhost_user_intf_t *vui, u64 addr)
 
static voidmap_user_mem (vhost_user_intf_t *vui, u64 addr)
 
static long get_huge_page_size (int fd)
 
static void unmap_all_mem_regions (vhost_user_intf_t *vui)
 
static clib_error_tvhost_user_callfd_read_ready (unix_file_t *uf)
 
static void vhost_user_if_disconnect (vhost_user_intf_t *vui)
 
always_inline void vhost_user_log_dirty_pages (vhost_user_intf_t *vui, u64 addr, u64 len)
 
static clib_error_tvhost_user_socket_read (unix_file_t *uf)
 
static clib_error_tvhost_user_socket_error (unix_file_t *uf)
 
static clib_error_tvhost_user_socksvr_accept_ready (unix_file_t *uf)
 
static clib_error_tvhost_user_init (vlib_main_t *vm)
 
static clib_error_tvhost_user_exit (vlib_main_t *vm)
 
static u8format_vhost_user_input_trace (u8 *s, va_list *va)
 
void vhost_user_rx_trace (vlib_main_t *vm, vlib_node_runtime_t *node, vhost_user_intf_t *vui, i16 virtqueue)
 
static void vhost_user_send_call (vlib_main_t *vm, vhost_user_vring_t *vq)
 
static u32 vhost_user_if_input (vlib_main_t *vm, vhost_user_main_t *vum, vhost_user_intf_t *vui, vlib_node_runtime_t *node)
 
static uword vhost_user_input (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
 
static uword vhost_user_intfc_tx (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static clib_error_tvhost_user_interface_admin_up_down (vnet_main_t *vnm, u32 hw_if_index, u32 flags)
 
 VNET_DEVICE_CLASS (vhost_user_dev_class, static)
 
static uword vhost_user_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
int vhost_user_delete_if (vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
 
static int vhost_user_init_server_sock (const char *sock_filename, int *sockfd)
 
static vhost_user_intf_tvhost_user_vui_new ()
 
static void vhost_user_create_ethernet (vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_t *vui, u8 *hwaddress)
 
static void vhost_user_vui_init (vnet_main_t *vnm, vhost_user_intf_t *vui, int sockfd, const char *sock_filename, u8 is_server, u64 feature_mask, u32 *sw_if_index)
 
static void vhost_user_vui_register (vlib_main_t *vm, vhost_user_intf_t *vui)
 
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)
 
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)
 
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)
 
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_input_node
 (constructor) VLIB_REGISTER_NODE (vhost_user_input_node) More...
 
static char * vhost_user_tx_func_error_strings []
 
static char * vhost_user_input_func_error_strings []
 
static vhost_user_main_t vhost_user_main
 
vlib_node_registration_t vhost_user_process_node
 (constructor) VLIB_REGISTER_NODE (vhost_user_process_node) More...
 

Macro Definition Documentation

#define DBG_SOCK (   args...)

Definition at line 52 of file vhost-user.c.

#define DBG_VQ (   args...)

Definition at line 58 of file vhost-user.c.

#define foreach_vhost_user_input_func_error
Value:
_(NO_ERROR, "no error") \
_(NO_BUFFER, "no available buffer") \
_(MMAP_FAIL, "mmap failure") \
_(UNDERSIZED_FRAME, "undersized ethernet frame received (< 14 bytes)")

Definition at line 82 of file vhost-user.c.

#define foreach_vhost_user_tx_func_error
Value:
_(NONE, "no error") \
_(NOT_READY, "vhost user state error") \
_(PKT_DROP_NOBUF, "tx packet drops (no available descriptors)") \
_(MMAP_FAIL, "mmap failure")

Definition at line 63 of file vhost-user.c.

#define VHOST_LOG_PAGE   0x1000

Definition at line 241 of file vhost-user.c.

#define VHOST_USER_COPY_TX_HDR   0

Definition at line 47 of file vhost-user.c.

#define VHOST_USER_DEBUG_SOCKET   0

Definition at line 42 of file vhost-user.c.

#define VHOST_USER_DEBUG_VQ   0

Definition at line 43 of file vhost-user.c.

#define vhost_user_log_dirty_ring (   vui,
  vq,
  member 
)
Value:
if (PREDICT_FALSE(vq->log_used)) { \
vhost_user_log_dirty_pages(vui, vq->log_guest_addr + offsetof(vring_used_t, member), \
sizeof(vq->used->member)); \
}
always_inline void vhost_user_log_dirty_pages(vhost_user_intf_t *vui, u64 addr, u64 len)
Definition: vhost-user.c:242
#define PREDICT_FALSE(x)
Definition: clib.h:97

Definition at line 262 of file vhost-user.c.

Enumeration Type Documentation

anonymous enum
Enumerator
VHOST_USER_RX_NEXT_ETHERNET_INPUT 
VHOST_USER_RX_NEXT_DROP 
VHOST_USER_RX_N_NEXT 

Definition at line 767 of file vhost-user.c.

Enumerator
VHOST_USER_INPUT_FUNC_N_ERROR 

Definition at line 88 of file vhost-user.c.

Enumerator
VHOST_USER_TX_FUNC_N_ERROR 

Definition at line 69 of file vhost-user.c.

Function Documentation

static u8* format_vhost_user_input_trace ( u8 s,
va_list *  va 
)
static

Definition at line 782 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 109 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static long get_huge_page_size ( int  fd)
static

Definition at line 168 of file vhost-user.c.

+ Here is the caller graph for this function:

static void* map_guest_mem ( vhost_user_intf_t vui,
u64  addr 
)
inlinestatic

Definition at line 143 of file vhost-user.c.

+ Here is the caller graph for this function:

static void* map_user_mem ( vhost_user_intf_t vui,
u64  addr 
)
inlinestatic

Definition at line 156 of file vhost-user.c.

+ Here is the caller graph for this function:

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

Definition at line 1871 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unmap_all_mem_regions ( vhost_user_intf_t vui)
static

Definition at line 175 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* vhost_user_callfd_read_ready ( unix_file_t uf)
static

Definition at line 203 of file vhost-user.c.

+ Here is the caller graph for this function:

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

Definition at line 1996 of file vhost-user.c.

+ Here is the call graph for this function:

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

Definition at line 1746 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1550 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 1654 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1794 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1449 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1821 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* vhost_user_exit ( vlib_main_t vm)
static

Definition at line 759 of file vhost-user.c.

static void vhost_user_if_disconnect ( vhost_user_intf_t vui)
inlinestatic

Definition at line 211 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 vhost_user_if_input ( vlib_main_t vm,
vhost_user_main_t vum,
vhost_user_intf_t vui,
vlib_node_runtime_t node 
)
static

Definition at line 860 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* vhost_user_init ( vlib_main_t vm)
static

Definition at line 734 of file vhost-user.c.

+ Here is the call graph for this function:

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

Definition at line 1483 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uword vhost_user_input ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t f 
)
static

Definition at line 1105 of file vhost-user.c.

+ Here is the call graph for this function:

static clib_error_t* vhost_user_interface_admin_up_down ( vnet_main_t vnm,
u32  hw_if_index,
u32  flags 
)
static

Definition at line 1349 of file vhost-user.c.

+ Here is the call graph for this function:

static uword vhost_user_intfc_tx ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 1148 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vhost_user_log_dirty_pages ( vhost_user_intf_t vui,
u64  addr,
u64  len 
)

Definition at line 242 of file vhost-user.c.

+ Here is the caller graph for this function:

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 
)

Definition at line 1700 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int vhost_user_name_renumber ( vnet_hw_interface_t hi,
u32  new_dev_instance 
)
static

Definition at line 125 of file vhost-user.c.

+ Here is the caller graph for this function:

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

Definition at line 1377 of file vhost-user.c.

+ Here is the call graph for this function:

void vhost_user_rx_trace ( vlib_main_t vm,
vlib_node_runtime_t node,
vhost_user_intf_t vui,
i16  virtqueue 
)

Definition at line 813 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vhost_user_send_call ( vlib_main_t vm,
vhost_user_vring_t vq 
)
inlinestatic

Definition at line 848 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* vhost_user_socket_error ( unix_file_t uf)
static

Definition at line 674 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* vhost_user_socket_read ( unix_file_t uf)
static

Definition at line 268 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* vhost_user_socksvr_accept_ready ( unix_file_t uf)
static

Definition at line 694 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vhost_user_unmap_all ( void  )

Definition at line 2020 of file vhost-user.c.

+ Here is the call graph for this function:

static void vhost_user_vui_init ( vnet_main_t vnm,
vhost_user_intf_t vui,
int  sockfd,
const char *  sock_filename,
u8  is_server,
u64  feature_mask,
u32 sw_if_index 
)
static

Definition at line 1586 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static vhost_user_intf_t* vhost_user_vui_new ( )
static

Definition at line 1526 of file vhost-user.c.

+ Here is the caller graph for this function:

static void vhost_user_vui_register ( vlib_main_t vm,
vhost_user_intf_t vui 
)
static

Definition at line 1627 of file vhost-user.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VNET_DEVICE_CLASS ( vhost_user_dev_class  ,
static   
)

+ Here is the caller graph for this function:

VNET_HW_INTERFACE_CLASS ( vhost_interface_class  ,
static   
)

Variable Documentation

char* vhost_user_input_func_error_strings[]
static
Initial value:
= {
#define _(n,s)
}
#define foreach_vhost_user_input_func_error
Definition: vhost-user.c:82

Definition at line 95 of file vhost-user.c.

vlib_node_registration_t vhost_user_input_node
Initial value:
= {
.function = vhost_user_input,
.name = "vhost-user-input",
.state = VLIB_NODE_STATE_DISABLED,
.n_next_nodes = VHOST_USER_RX_N_NEXT,
.next_nodes = {
[VHOST_USER_RX_NEXT_DROP] = "error-drop",
[VHOST_USER_RX_NEXT_ETHERNET_INPUT] = "ethernet-input",
},
}
static uword vhost_user_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Definition: vhost-user.c:1105
static u8 * format_vhost_user_input_trace(u8 *s, va_list *va)
Definition: vhost-user.c:782
static char * vhost_user_input_func_error_strings[]
Definition: vhost-user.c:95
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:70

(constructor) VLIB_REGISTER_NODE (vhost_user_input_node)

Definition at line 61 of file vhost-user.c.

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

Definition at line 101 of file vhost-user.c.

vlib_node_registration_t vhost_user_process_node
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:1377

(constructor) VLIB_REGISTER_NODE (vhost_user_process_node)

Definition at line 1443 of file vhost-user.c.

char* vhost_user_tx_func_error_strings[]
static
Initial value:
= {
#define _(n,s)
}
#define foreach_vhost_user_tx_func_error
Definition: vhost-user.c:63

Definition at line 76 of file vhost-user.c.