hs-test: cat summary file after a failed test run
[vpp.git] / src / vnet / bonding / bond_api.c
index 4306e3c..d9287a8 100644 (file)
 #include <vnet/api_errno.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/ethernet/ethernet_types_api.h>
+#include <vnet/bonding/node.h>
 
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs            /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun           /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vnet/vnet_all_api_h.h>
-#undef vl_printfun
+#include <vnet/format_fns.h>
+#include <vnet/bonding/bond.api_enum.h>
+#include <vnet/bonding/bond.api_types.h>
 
+#define REPLY_MSG_ID_BASE msg_id_base
 #include <vlibapi/api_helper_macros.h>
-#include <vnet/bonding/node.h>
 
-#define foreach_bond_api_msg                     \
-_(BOND_CREATE, bond_create)                      \
-_(BOND_DELETE, bond_delete)                      \
-_(BOND_ENSLAVE, bond_enslave)                    \
-_(BOND_ADD_MEMBER, bond_add_member)                    \
-_(SW_INTERFACE_SET_BOND_WEIGHT, sw_interface_set_bond_weight) \
-_(BOND_DETACH_SLAVE, bond_detach_slave)          \
-_(BOND_DETACH_MEMBER, bond_detach_member)          \
-_(SW_INTERFACE_BOND_DUMP, sw_interface_bond_dump) \
-_(SW_BOND_INTERFACE_DUMP, sw_bond_interface_dump) \
-_(SW_INTERFACE_SLAVE_DUMP, sw_interface_slave_dump) \
-_(SW_MEMBER_INTERFACE_DUMP, sw_member_interface_dump)
+static u16 msg_id_base;
 
 static void
 vl_api_bond_delete_t_handler (vl_api_bond_delete_t * mp)
@@ -65,8 +43,11 @@ vl_api_bond_delete_t_handler (vl_api_bond_delete_t * mp)
   vl_api_bond_delete_reply_t *rmp;
   u32 sw_if_index = ntohl (mp->sw_if_index);
 
+  VALIDATE_SW_IF_INDEX (mp);
+
   rv = bond_delete_if (vm, sw_if_index);
 
+  BAD_SW_IF_INDEX_LABEL;
   REPLY_MACRO (VL_API_BOND_DELETE_REPLY);
 }
 
@@ -94,12 +75,41 @@ vl_api_bond_create_t_handler (vl_api_bond_create_t * mp)
 
   int rv = ap->rv;
 
-  /* *INDENT-OFF* */
   REPLY_MACRO2(VL_API_BOND_CREATE_REPLY,
   ({
     rmp->sw_if_index = ntohl (ap->sw_if_index);
   }));
-  /* *INDENT-ON* */
+}
+
+static void
+vl_api_bond_create2_t_handler (vl_api_bond_create2_t * mp)
+{
+  vlib_main_t *vm = vlib_get_main ();
+  vl_api_bond_create2_reply_t *rmp;
+  bond_create_if_args_t _a, *ap = &_a;
+
+  clib_memset (ap, 0, sizeof (*ap));
+
+  ap->id = ntohl (mp->id);
+
+  if (mp->use_custom_mac)
+    {
+      mac_address_decode (mp->mac_address, (mac_address_t *) ap->hw_addr);
+      ap->hw_addr_set = 1;
+    }
+
+  ap->mode = ntohl (mp->mode);
+  ap->lb = ntohl (mp->lb);
+  ap->numa_only = mp->numa_only;
+  ap->gso = mp->enable_gso;
+  bond_create_if (vm, ap);
+
+  int rv = ap->rv;
+
+  REPLY_MACRO2(VL_API_BOND_CREATE2_REPLY,
+  ({
+    rmp->sw_if_index = ntohl (ap->sw_if_index);
+  }));
 }
 
 static void
@@ -157,6 +167,8 @@ static void
   vl_api_sw_interface_set_bond_weight_reply_t *rmp;
   int rv = 0;
 
+  VALIDATE_SW_IF_INDEX (mp);
+
   clib_memset (ap, 0, sizeof (*ap));
 
   ap->sw_if_index = ntohl (mp->sw_if_index);
@@ -165,6 +177,7 @@ static void
   bond_set_intf_weight (vm, ap);
   rv = ap->rv;
 
+  BAD_SW_IF_INDEX_LABEL;
   REPLY_MACRO (VL_API_SW_INTERFACE_SET_BOND_WEIGHT_REPLY);
 }
 
@@ -176,12 +189,15 @@ vl_api_bond_detach_slave_t_handler (vl_api_bond_detach_slave_t * mp)
   bond_detach_member_args_t _a, *ap = &_a;
   int rv = 0;
 
+  VALIDATE_SW_IF_INDEX (mp);
+
   clib_memset (ap, 0, sizeof (*ap));
 
   ap->member = ntohl (mp->sw_if_index);
   bond_detach_member (vm, ap);
   rv = ap->rv;
 
+  BAD_SW_IF_INDEX_LABEL;
   REPLY_MACRO (VL_API_BOND_DETACH_SLAVE_REPLY);
 }
 
@@ -193,12 +209,15 @@ vl_api_bond_detach_member_t_handler (vl_api_bond_detach_member_t * mp)
   bond_detach_member_args_t _a, *ap = &_a;
   int rv = 0;
 
+  VALIDATE_SW_IF_INDEX (mp);
+
   clib_memset (ap, 0, sizeof (*ap));
 
   ap->member = ntohl (mp->sw_if_index);
   bond_detach_member (vm, ap);
   rv = ap->rv;
 
+  BAD_SW_IF_INDEX_LABEL;
   REPLY_MACRO (VL_API_BOND_DETACH_MEMBER_REPLY);
 }
 
@@ -212,7 +231,8 @@ bond_send_sw_interface_details (vpe_api_main_t * am,
 
   mp = vl_msg_api_alloc (sizeof (*mp));
   clib_memset (mp, 0, sizeof (*mp));
-  mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_BOND_DETAILS);
+  mp->_vl_msg_id =
+    htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_BOND_DETAILS);
   mp->sw_if_index = htonl (bond_if->sw_if_index);
   mp->id = htonl (bond_if->id);
   clib_memcpy (mp->interface_name, bond_if->interface_name,
@@ -263,7 +283,8 @@ bond_send_sw_bond_interface_details (vpe_api_main_t * am,
 
   mp = vl_msg_api_alloc (sizeof (*mp));
   clib_memset (mp, 0, sizeof (*mp));
-  mp->_vl_msg_id = htons (VL_API_SW_BOND_INTERFACE_DETAILS);
+  mp->_vl_msg_id =
+    htons (REPLY_MSG_ID_BASE + VL_API_SW_BOND_INTERFACE_DETAILS);
   mp->sw_if_index = htonl (bond_if->sw_if_index);
   mp->id = htonl (bond_if->id);
   clib_memcpy (mp->interface_name, bond_if->interface_name,
@@ -322,7 +343,8 @@ bond_send_sw_member_interface_details (vpe_api_main_t * am,
 
   mp = vl_msg_api_alloc (sizeof (*mp));
   clib_memset (mp, 0, sizeof (*mp));
-  mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_SLAVE_DETAILS);
+  mp->_vl_msg_id =
+    htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SLAVE_DETAILS);
   mp->sw_if_index = htonl (member_if->sw_if_index);
   clib_memcpy (mp->interface_name, member_if->interface_name,
               MIN (ARRAY_LEN (mp->interface_name) - 1,
@@ -372,7 +394,8 @@ bond_send_member_interface_details (vpe_api_main_t * am,
 
   mp = vl_msg_api_alloc (sizeof (*mp));
   clib_memset (mp, 0, sizeof (*mp));
-  mp->_vl_msg_id = htons (VL_API_SW_MEMBER_INTERFACE_DETAILS);
+  mp->_vl_msg_id =
+    htons (REPLY_MSG_ID_BASE + VL_API_SW_MEMBER_INTERFACE_DETAILS);
   mp->sw_if_index = htonl (member_if->sw_if_index);
   clib_memcpy (mp->interface_name, member_if->interface_name,
               MIN (ARRAY_LEN (mp->interface_name) - 1,
@@ -412,37 +435,14 @@ vl_api_sw_member_interface_dump_t_handler (vl_api_sw_member_interface_dump_t *
   vec_free (memberifs);
 }
 
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-bond_setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
-  foreach_vl_msg_name_crc_bond;
-#undef _
-}
-
+#include <vnet/bonding/bond.api.c>
 static clib_error_t *
 bond_api_hookup (vlib_main_t * vm)
 {
-  api_main_t *am = vlibapi_get_main ();
-
-#define _(N,n)                                                  \
-    vl_msg_api_set_handlers(VL_API_##N, #n,                     \
-                           vl_api_##n##_t_handler,              \
-                           vl_noop_handler,                     \
-                           vl_api_##n##_t_endian,               \
-                           vl_api_##n##_t_print,                \
-                           sizeof(vl_api_##n##_t), 1);
-  foreach_bond_api_msg;
-#undef _
-
   /*
    * Set up the (msg_name, crc, message-id) table
    */
-  bond_setup_message_id_table (am);
+  REPLY_MSG_ID_BASE = setup_message_id_table ();
 
   return 0;
 }