api: binary api cleanup
[vpp.git] / src / plugins / vmxnet3 / cli.c
index 170f9ad..e1d74e8 100644 (file)
@@ -32,23 +32,29 @@ vmxnet3_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
 {
   unformat_input_t _line_input, *line_input = &_line_input;
   vmxnet3_create_if_args_t args;
-  u32 tmp;
+  u32 size;
 
   /* Get a line of input. */
   if (!unformat_user (input, unformat_line_input, line_input))
     return 0;
 
-  memset (&args, 0, sizeof (args));
+  clib_memset (&args, 0, sizeof (args));
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat (line_input, "%U", unformat_vlib_pci_addr, &args.addr))
        ;
       else if (unformat (line_input, "elog"))
        args.enable_elog = 1;
-      else if (unformat (line_input, "rx-queue-size %u", &tmp))
-       args.rxq_size = tmp;
-      else if (unformat (line_input, "tx-queue-size %u", &tmp))
-       args.txq_size = tmp;
+      else if (unformat (line_input, "bind"))
+       args.bind = 1;
+      else if (unformat (line_input, "rx-queue-size %u", &size))
+       args.rxq_size = size;
+      else if (unformat (line_input, "tx-queue-size %u", &size))
+       args.txq_size = size;
+      else if (unformat (line_input, "num-tx-queues %u", &size))
+       args.txq_num = size;
+      else if (unformat (line_input, "num-rx-queues %u", &size))
+       args.rxq_num = size;
       else
        return clib_error_return (0, "unknown input `%U'",
                                  format_unformat_error, input);
@@ -65,7 +71,8 @@ vmxnet3_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
 VLIB_CLI_COMMAND (vmxnet3_create_command, static) = {
   .path = "create interface vmxnet3",
   .short_help = "create interface vmxnet3 <pci-address>"
-                "[rx-queue-size <size>] [tx-queue-size <size>]",
+                "[rx-queue-size <size>] [tx-queue-size <size>]"
+                "[num-tx-queues <number>] [num-rx-queues <number>] [bind]",
   .function = vmxnet3_create_command_fn,
 };
 /* *INDENT-ON* */
@@ -102,7 +109,7 @@ vmxnet3_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
     return clib_error_return (0,
                              "please specify interface name or sw_if_index");
 
-  hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+  hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
   if (hw == NULL || vmxnet3_device_class.index != hw->dev_class_index)
     return clib_error_return (0, "not a vmxnet3 interface");
 
@@ -159,7 +166,7 @@ vmxnet3_test_command_fn (vlib_main_t * vm, unformat_input_t * input,
     return clib_error_return (0,
                              "please specify interface name or sw_if_index");
 
-  hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+  hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
   if (hw == NULL || vmxnet3_device_class.index != hw->dev_class_index)
     return clib_error_return (0, "not a vmxnet3 interface");
 
@@ -203,6 +210,7 @@ show_vmxnet3 (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr,
   if (!hw_if_indices)
     return;
 
+  vlib_cli_output (vm, "LRO/TSO configured: %u", vmxm->lro_configured);
   for (i = 0; i < vec_len (hw_if_indices); i++)
     {
       hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
@@ -211,6 +219,7 @@ show_vmxnet3 (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr,
                       format_vnet_hw_if_index_name, vnm, hw_if_indices[i],
                       hw_if_indices[i]);
       vlib_cli_output (vm, "  Version: %u", vd->version);
+      vlib_cli_output (vm, "  LRO/TSO enable: %u", vd->lro_enable);
       vlib_cli_output (vm, "  PCI Address: %U", format_vlib_pci_addr,
                       &vd->pci_addr);
       vlib_cli_output (vm, "  Mac Address: %U", format_ethernet_address,
@@ -319,9 +328,9 @@ show_vmxnet3 (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr,
          }
       }
 
-      vec_foreach_index (qid, vd->rxqs)
+      vec_foreach_index (qid, vd->txqs)
       {
-       txq = vec_elt_at_index (vd->txqs, 0);
+       txq = vec_elt_at_index (vd->txqs, qid);
        vlib_cli_output (vm, "  Queue %u (TX)", qid);
        vlib_cli_output (vm, "    TX completion next index %u",
                         txq->tx_comp_ring.next);
@@ -567,14 +576,37 @@ VLIB_CLI_COMMAND (show_vmxnet3_command, static) = {
 clib_error_t *
 vmxnet3_cli_init (vlib_main_t * vm)
 {
+  vmxnet3_main_t *vmxm = &vmxnet3_main;
+
   /* initialize binary API */
   vmxnet3_plugin_api_hookup (vm);
 
+  vmxm->log_default = vlib_log_register_class ("vmxnet3", 0);
   return 0;
 }
 
 VLIB_INIT_FUNCTION (vmxnet3_cli_init);
 
+static clib_error_t *
+vmxnet3_config (vlib_main_t * vm, unformat_input_t * input)
+{
+  vmxnet3_main_t *vmxm = &vmxnet3_main;
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (input, "lro"))
+       vmxm->lro_configured = 1;
+      else
+       return clib_error_return (0, "unknown input `%U'",
+                                 format_unformat_error, input);
+    }
+
+  return 0;
+}
+
+/* vmxnet3 { ... } configuration. */
+VLIB_CONFIG_FUNCTION (vmxnet3_config, "vmxnet3");
+
 /*
  * fd.io coding-style-patch-verification: ON
  *