19 #include <sys/ioctl.h> 46 else if (
unformat (line_input,
"elog"))
48 else if (
unformat (line_input,
"bind"))
50 else if (
unformat (line_input,
"rx-queue-size %u", &size))
52 else if (
unformat (line_input,
"tx-queue-size %u", &size))
54 else if (
unformat (line_input,
"num-tx-queues %u", &size))
56 else if (
unformat (line_input,
"num-rx-queues %u", &size))
72 .path =
"create interface vmxnet3",
73 .short_help =
"create interface vmxnet3 <pci-address>" 74 "[rx-queue-size <size>] [tx-queue-size <size>]" 75 "[num-tx-queues <number>] [num-rx-queues <number>] [bind]",
97 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
108 if (sw_if_index == ~0)
110 "please specify interface name or sw_if_index");
125 .path =
"delete interface vmxnet3",
126 .short_help =
"delete interface vmxnet3 " 127 "{<interface> | sw_if_index <sw_idx>}",
142 int enable_elog = 0, disable_elog = 0;
150 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
152 else if (
unformat (line_input,
"elog-on"))
154 else if (
unformat (line_input,
"elog-off"))
165 if (sw_if_index == ~0)
167 "please specify interface name or sw_if_index");
176 vd->
flags |= VMXNET3_DEVICE_F_ELOG;
179 vd->
flags &= ~VMXNET3_DEVICE_F_ELOG;
186 .path =
"test vmxnet3",
187 .short_help =
"test vmxnet3 <interface> | sw_if_index <sw_idx> [irq] " 188 "[elog-on] [elog-off]",
195 u8 show_one_table,
u32 which,
u8 show_one_slot,
u32 slot)
203 vmxnet3_rx_desc *rxd;
204 vmxnet3_rx_comp *rx_comp;
206 vmxnet3_tx_desc *txd;
207 vmxnet3_tx_comp *tx_comp;
214 for (i = 0; i <
vec_len (hw_if_indices); i++)
248 " ring %u size %u fill %u " 249 "consume %u produce %u", rid,
256 "slot",
"address",
"flags");
257 for (desc_idx = 0; desc_idx < rxq->
size; desc_idx++)
259 rxd = &rxq->
rx_desc[rid][desc_idx];
261 desc_idx, rxd->address, rxd->flags);
264 else if (show_one_table)
266 if (((which == VMXNET3_SHOW_RX_DESC0) && (rid == 0)) ||
267 ((which == VMXNET3_SHOW_RX_DESC1) && (rid == 1)))
271 "slot",
"address",
"flags");
274 rxd = &rxq->
rx_desc[rid][slot];
276 slot, rxd->address, rxd->flags);
279 for (desc_idx = 0; desc_idx < rxq->
size; desc_idx++)
281 rxd = &rxq->
rx_desc[rid][desc_idx];
283 desc_idx, rxd->address,
295 "slot",
"index",
"rss",
"len",
"flags");
296 for (desc_idx = 0; desc_idx < rxq->
size; desc_idx++)
298 rx_comp = &rxq->
rx_comp[desc_idx];
300 desc_idx, rx_comp->index, rx_comp->rss,
301 rx_comp->len, rx_comp->flags);
304 else if (show_one_table)
306 if (which == VMXNET3_SHOW_RX_COMP)
310 "slot",
"index",
"rss",
"len",
"flags");
315 slot, rx_comp->index, rx_comp->rss,
316 rx_comp->len, rx_comp->flags);
319 for (desc_idx = 0; desc_idx < rxq->
size; desc_idx++)
321 rx_comp = &rxq->
rx_comp[desc_idx];
323 " %5u 0x%08x %10u %10u 0x%08x",
324 desc_idx, rx_comp->index, rx_comp->rss,
325 rx_comp->len, rx_comp->flags);
346 "slot",
"address",
"flags0",
"flags1");
347 for (desc_idx = 0; desc_idx < txq->
size; desc_idx++)
351 desc_idx, txd->address, txd->flags[0],
357 "slot",
"index",
"flags");
358 for (desc_idx = 0; desc_idx < txq->
size; desc_idx++)
360 tx_comp = &txq->
tx_comp[desc_idx];
362 desc_idx, tx_comp->index, tx_comp->flags);
365 else if (show_one_table)
367 if (which == VMXNET3_SHOW_TX_DESC)
371 "slot",
"address",
"flags0",
"flags1");
376 slot, txd->address, txd->flags[0],
380 for (desc_idx = 0; desc_idx < txq->
size; desc_idx++)
384 desc_idx, txd->address, txd->flags[0],
388 else if (which == VMXNET3_SHOW_TX_COMP)
392 "slot",
"index",
"flags");
397 slot, tx_comp->index, tx_comp->flags);
400 for (desc_idx = 0; desc_idx < txq->
size; desc_idx++)
402 tx_comp = &txq->
tx_comp[desc_idx];
404 desc_idx, tx_comp->index,
421 u32 hw_if_index, *hw_if_indices = 0;
423 u8 show_descr = 0, show_one_table = 0, show_one_slot = 0;
424 u32 which = ~0, slot;
438 vec_add1 (hw_if_indices, hw_if_index);
450 which = VMXNET3_SHOW_RX_COMP;
455 if (slot >= rxq->
size)
458 "slot size must be < rx queue " 459 "size %u", rxq->
size);
465 else if (
unformat (input,
"rx-desc-0"))
468 which = VMXNET3_SHOW_RX_DESC0;
473 if (slot >= rxq->
size)
476 "slot size must be < rx queue " 477 "size %u", rxq->
size);
483 else if (
unformat (input,
"rx-desc-1"))
486 which = VMXNET3_SHOW_RX_DESC1;
491 if (slot >= rxq->
size)
494 "slot size must be < rx queue " 495 "size %u", rxq->
size);
501 else if (
unformat (input,
"tx-comp"))
504 which = VMXNET3_SHOW_TX_COMP;
509 if (slot >= txq->
size)
512 "slot size must be < tx queue " 513 "size %u", txq->
size);
519 else if (
unformat (input,
"tx-desc"))
522 which = VMXNET3_SHOW_TX_DESC;
527 if (slot >= txq->
size)
530 "slot size must be < tx queue " 531 "size %u", txq->
size);
552 if (
vec_len (hw_if_indices) == 0)
559 show_vmxnet3 (vm, hw_if_indices, show_descr, show_one_table, which,
560 show_one_slot, slot);
569 .path =
"show vmxnet3",
570 .short_help =
"show vmxnet3 [[<interface>] ([desc] | ([rx-comp] | " 571 "[rx-desc-0] | [rx-desc-1] | [tx-comp] | [tx-desc]) [<slot>])]",
unformat_function_t unformat_vnet_hw_interface
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
void vmxnet3_delete_if(vlib_main_t *vm, vmxnet3_device_t *vd)
#define vec_foreach_index(var, v)
Iterate over vector indices.
format_function_t format_vnet_hw_if_index_name
vnet_main_t * vnet_get_main(void)
vmxnet3_rx_desc * rx_desc[VMXNET3_RX_RING_SIZE]
static clib_error_t * vmxnet3_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vmxnet3_main_t vmxnet3_main
void vmxnet3_create_if(vlib_main_t *vm, vmxnet3_create_if_args_t *args)
unformat_function_t unformat_vnet_sw_interface
vlib_log_class_t log_default
u8 * format_ethernet_address(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
clib_error_t * vmxnet3_plugin_api_hookup(vlib_main_t *vm)
clib_error_t * vmxnet3_cli_init(vlib_main_t *vm)
static clib_error_t * vmxnet3_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vmxnet3_rx_comp_ring rx_comp_ring
vmxnet3_tx_comp_ring tx_comp_ring
#define VMXNET3_RX_RING_SIZE
unformat_function_t unformat_vlib_pci_addr
vmxnet3_tx_comp * tx_comp
#define VLIB_CONFIG_FUNCTION(x, n,...)
static clib_error_t * show_vmxnet3_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_free(V)
Free vector's memory (no header).
static vnet_hw_interface_t * vnet_get_sup_hw_interface_api_visible_or_null(vnet_main_t *vnm, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * vmxnet3_config(vlib_main_t *vm, unformat_input_t *input)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void show_vmxnet3(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, u8 show_one_table, u32 which, u8 show_one_slot, u32 slot)
vmxnet3_tx_desc * tx_desc
vnet_device_class_t vmxnet3_device_class
vmxnet3_rx_comp * rx_comp
vmxnet3_rx_ring rx_ring[VMXNET3_RX_RING_SIZE]
vmxnet3_device_t * devices
static clib_error_t * vmxnet3_test_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
format_function_t format_vlib_pci_addr