42 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 48 #define vl_api_version(n,v) static u32 api_version=(v); 59 #define REPLY_MACRO(t) \ 61 unix_shared_memory_queue_t * q = \ 62 vl_api_client_index_to_input_queue (mp->client_index); \ 66 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 67 rmp->_vl_msg_id = htons ((t)+mm->msg_id_base); \ 68 rmp->context = mp->context; \ 69 rmp->retval = htonl (rv); \ 71 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 74 #define REPLY_MACRO2(t, body) \ 76 unix_shared_memory_queue_t * q = \ 77 vl_api_client_index_to_input_queue (mp->client_index); \ 81 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 82 rmp->_vl_msg_id = htons ((t)+mm->msg_id_base); \ 83 rmp->context = mp->context; \ 84 rmp->retval = htonl (rv); \ 85 do {body;} while (0); \ 86 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 89 #define foreach_memif_plugin_api_msg \ 90 _(MEMIF_CREATE, memif_create) \ 91 _(MEMIF_DELETE, memif_delete) \ 92 _(MEMIF_DETAILS, memif_details) \ 93 _(MEMIF_DUMP, memif_dump) \ 107 static const u8 empty_hw_addr[6];
111 args.
key = clib_net_to_host_u64 (mp->
key);
133 rv = VNET_API_ERROR_INVALID_ARGUMENT;
146 if (memcmp (mp->
hw_addr, empty_hw_addr, 6) != 0)
180 if (sw_if_index == mif->sw_if_index)
182 rv = memif_delete_if (vm, mif->key);
188 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
198 u8 * interface_name,
u32 context)
208 memset (mp, 0,
sizeof (*mp));
210 mp->_vl_msg_id = htons (VL_API_MEMIF_DETAILS + mm->
msg_id_base);
218 mp->
key = clib_host_to_net_u64 (mif->
key);
254 swif = vnet_get_sw_interface (vnm, mif->sw_if_index);
256 if_name = format (if_name,
"%U%c",
257 format_vnet_sw_interface_name,
260 send_memif_details (q, mif, swif, if_name, mp->context);
261 _vec_len (if_name) = 0;
278 #define vl_msg_name_crc_list 280 #undef vl_msg_name_crc_list 285 #define _(id,n,crc) \ 286 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base); 287 foreach_vl_msg_name_crc_memif;
300 name =
format (0,
"memif_%08x%c", api_version, 0);
307 vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \ 309 vl_api_##n##_t_handler, \ 311 vl_api_##n##_t_endian, \ 312 vl_api_##n##_t_print, \ 313 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.
Delete host-interface response.
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
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.
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Dump all memory interfaces.
#define MEMIF_IF_FLAG_IS_SLAVE
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)
u16 msg_id_base
API message ID base.
#define MEMIF_DEFAULT_RING_SIZE
static void setup_message_id_table(memif_main_t *mm, api_main_t *am)
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)
void * vl_msg_api_alloc(int nbytes)
Memory interface details structure.
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
void vl_api_memif_delete_t_handler(vl_api_memif_delete_t *mp)
Message handler for memif_delete API.
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static vlib_main_t * vlib_get_main(void)
static uword is_pow2(uword x)
void vl_api_memif_details_t_handler(vl_api_memif_details_t *mp)
Message handler for memif_details API.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_memif_plugin_api_msg
#define REPLY_MACRO2(t, body)
static void send_memif_details(unix_shared_memory_queue_t *q, memif_if_t *mif, vnet_sw_interface_t *swif, u8 *interface_name, u32 context)
u16 vl_msg_api_get_msg_ids(char *name, int n)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
#define MEMIF_DEFAULT_BUFFER_SIZE