44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 50 #define vl_api_version(n,v) static u32 api_version=(v); 61 #define REPLY_MACRO(t) \ 64 vl_api_client_index_to_input_queue (mp->client_index); \ 68 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 69 rmp->_vl_msg_id = htons ((t)+mm->msg_id_base); \ 70 rmp->context = mp->context; \ 71 rmp->retval = htonl (rv); \ 73 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 76 #define REPLY_MACRO2(t, body) \ 79 vl_api_client_index_to_input_queue (mp->client_index); \ 83 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 84 rmp->_vl_msg_id = htons ((t)+mm->msg_id_base); \ 85 rmp->context = mp->context; \ 86 rmp->retval = htonl (rv); \ 87 do {body;} while (0); \ 88 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 91 #define foreach_memif_plugin_api_msg \ 92 _(MEMIF_SOCKET_FILENAME_ADD_DEL, memif_socket_filename_add_del) \ 93 _(MEMIF_CREATE, memif_create) \ 94 _(MEMIF_DELETE, memif_delete) \ 95 _(MEMIF_SOCKET_FILENAME_DUMP, memif_socket_filename_dump) \ 96 _(MEMIF_DUMP, memif_dump) \ 112 vl_api_memif_socket_filename_add_del_reply_t *rmp;
119 socket_id = clib_net_to_host_u32 (mp->
socket_id);
120 if (socket_id == 0 || socket_id == ~0)
122 rv = VNET_API_ERROR_INVALID_ARGUMENT;
141 REPLY_MACRO (VL_API_MEMIF_SOCKET_FILENAME_ADD_DEL_REPLY);
157 static const u8 empty_hw_addr[6];
161 args.
id = clib_net_to_host_u32 (mp->
id);
168 if (strlen ((
char *) mp->
secret) > 0)
203 rv = VNET_API_ERROR_INVALID_ARGUMENT;
216 if (memcmp (mp->
hw_addr, empty_hw_addr, 6) != 0)
245 vl_api_memif_delete_reply_t *rmp;
252 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
266 u8 * interface_name,
u32 context)
277 memset (mp, 0,
sizeof (*mp));
279 mp->_vl_msg_id = htons (VL_API_MEMIF_DETAILS + mm->
msg_id_base);
291 mp->
id = clib_host_to_net_u32 (mif->
id);
296 mp->
role = (mif->
flags & MEMIF_IF_FLAG_IS_SLAVE) ? 1 : 0;
327 swif = vnet_get_sw_interface (vnm, mif->sw_if_index);
329 if_name = format (if_name,
"%U%c",
330 format_vnet_sw_interface_name,
333 send_memif_details (reg, mif, swif, if_name, mp->context);
334 _vec_len (if_name) = 0;
344 u8 * socket_filename,
u32 context)
350 memset (mp, 0,
sizeof (*mp));
352 mp->_vl_msg_id = htons (VL_API_MEMIF_SOCKET_FILENAME_DETAILS
356 mp->
socket_id = clib_host_to_net_u32 (socket_id);
383 memif_socket_file_t *msf;
386 msf = pool_elt_at_index(mm->socket_files, msf_idx);
387 filename = msf->filename;
388 send_memif_socket_filename_details(reg, sock_id, filename, mp->context);
393 #define vl_msg_name_crc_list 395 #undef vl_msg_name_crc_list 400 #define _(id,n,crc) \ 401 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base); 402 foreach_vl_msg_name_crc_memif;
415 name =
format (0,
"memif_%08x%c", api_version, 0);
422 vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \ 424 vl_api_##n##_t_handler, \ 426 vl_api_##n##_t_endian, \ 427 vl_api_##n##_t_print, \ 428 sizeof(vl_api_##n##_t), 1);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vl_api_memif_dump_t_handler(vl_api_memif_dump_t *mp)
Message handler for memif_dump API.
Memory interface details structure.
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)
Create memory interface response.
Create or remove named socket file for memif interfaces.
memif_socket_file_t * socket_files
memif_log2_ring_size_t log2_ring_size
struct memif_if_t::@458 run
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
memif_interface_mode_t mode
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Dump all memory interfaces.
void * vl_msg_api_alloc(int nbytes)
static uword min_log2(uword x)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
clib_error_t * memif_plugin_api_hookup(vlib_main_t *vm)
void vl_api_memif_socket_filename_dump_t_handler(vl_api_memif_socket_filename_dump_t *mp)
Message handler for memif_socket_filename_dump API.
memif_log2_ring_size_t log2_ring_size
#define hash_foreach(key_var, value_var, h, body)
vnet_device_class_t memif_device_class
u16 msg_id_base
API message ID base.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void setup_message_id_table(memif_main_t *mm, api_main_t *am)
int memif_delete_if(vlib_main_t *vm, memif_if_t *mif)
void vl_api_memif_create_t_handler(vl_api_memif_create_t *mp)
Message handler for memif_create API.
int memif_create_if(vlib_main_t *vm, memif_create_if_args_t *args)
#define MEMIF_DEFAULT_TX_QUEUES
static void send_memif_details(vl_api_registration_t *reg, memif_if_t *mif, vnet_sw_interface_t *swif, u8 *interface_name, u32 context)
API main structure, used by both vpp and binary API clients.
An API client registration, only in vpp/vlib.
Memory interface details structure.
#define vec_free(V)
Free vector's memory (no header).
static void send_memif_socket_filename_details(vl_api_registration_t *reg, u32 socket_id, u8 *socket_filename, u32 context)
int memif_socket_filename_add_del(u8 is_add, u32 sock_id, u8 *sock_filename)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void vl_api_memif_delete_t_handler(vl_api_memif_delete_t *mp)
Message handler for memif_delete API.
#define MEMIF_DEFAULT_BUFFER_SIZE
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
#define MEMIF_DEFAULT_RX_QUEUES
Dump the table of socket ids and corresponding filenames.
static vlib_main_t * vlib_get_main(void)
static uword is_pow2(uword x)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_memif_plugin_api_msg
#define REPLY_MACRO2(t, body)
#define MEMIF_DEFAULT_RING_SIZE
uword * socket_file_index_by_sock_id
void vl_api_memif_socket_filename_add_del_t_handler(vl_api_memif_socket_filename_add_del_t *mp)
Message handler for memif_socket_filename_add_del API.
u16 vl_msg_api_get_msg_ids(const char *name, int n)