summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-22 12:18:17 +0000
committerOle Tr�an <otroan@employees.org>2021-06-22 19:54:55 +0000
commit4f348df8cfcec6378ad0593a5bde527f2cbd9482 (patch)
treeab67a8be01f885f1399591f9d60342be76652e37
parentce74c6f016dafd234431bbf561632b107fc11d06 (diff)
virtio: api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I047310b8c9fcc51dcfb187710ff59b7895abe217
-rw-r--r--src/vat/api_format.c564
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c63
-rw-r--r--src/vnet/vnet_all_api_h.h1
3 files changed, 22 insertions, 606 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index c296a5b58a0..86b247eb2da 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1618,76 +1618,6 @@ static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
vam->result_ready = 1;
}
-static void vl_api_create_vhost_user_if_reply_t_handler
- (vl_api_create_vhost_user_if_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
- vam->regenerate_interface_table = 1;
-}
-
-static void vl_api_create_vhost_user_if_reply_t_handler_json
- (vl_api_create_vhost_user_if_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_create_vhost_user_if_v2_reply_t_handler
- (vl_api_create_vhost_user_if_v2_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
- vam->regenerate_interface_table = 1;
-}
-
-static void vl_api_create_vhost_user_if_v2_reply_t_handler_json
- (vl_api_create_vhost_user_if_v2_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
static void vl_api_ip_address_details_t_handler
(vl_api_ip_address_details_t * mp)
{
@@ -1965,9 +1895,6 @@ _(l2_patch_add_del_reply) \
_(l2_fib_clear_table_reply) \
_(l2_interface_efp_filter_reply) \
_(l2_interface_vlan_tag_rewrite_reply) \
-_(modify_vhost_user_if_reply) \
-_(modify_vhost_user_if_v2_reply) \
-_(delete_vhost_user_if_reply) \
_(want_l2_macs_events_reply) \
_(delete_loopback_reply) \
_(bd_ip_mac_add_del_reply) \
@@ -2079,12 +2006,6 @@ _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
_(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
_(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
_(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
-_(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
-_(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
-_(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
-_(CREATE_VHOST_USER_IF_V2_REPLY, create_vhost_user_if_v2_reply) \
-_(MODIFY_VHOST_USER_IF_V2_REPLY, modify_vhost_user_if_v2_reply) \
-_(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
_(SHOW_VERSION_REPLY, show_version_reply) \
_(SHOW_THREADS_REPLY, show_threads_reply) \
_(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
@@ -6668,447 +6589,7 @@ api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
}
static int
-api_create_vhost_user_if (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_create_vhost_user_if_t *mp;
- u8 *file_name;
- u8 is_server = 0;
- u8 file_name_set = 0;
- u32 custom_dev_instance = ~0;
- u8 hwaddr[6];
- u8 use_custom_mac = 0;
- u8 disable_mrg_rxbuf = 0;
- u8 disable_indirect_desc = 0;
- u8 *tag = 0;
- u8 enable_gso = 0;
- u8 enable_packed = 0;
- int ret;
-
- /* Shut up coverity */
- clib_memset (hwaddr, 0, sizeof (hwaddr));
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "socket %s", &file_name))
- {
- file_name_set = 1;
- }
- else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
- ;
- else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
- use_custom_mac = 1;
- else if (unformat (i, "server"))
- is_server = 1;
- else if (unformat (i, "disable_mrg_rxbuf"))
- disable_mrg_rxbuf = 1;
- else if (unformat (i, "disable_indirect_desc"))
- disable_indirect_desc = 1;
- else if (unformat (i, "gso"))
- enable_gso = 1;
- else if (unformat (i, "packed"))
- enable_packed = 1;
- else if (unformat (i, "tag %s", &tag))
- ;
- else
- break;
- }
-
- if (file_name_set == 0)
- {
- errmsg ("missing socket file name");
- return -99;
- }
-
- if (vec_len (file_name) > 255)
- {
- errmsg ("socket file name too long");
- return -99;
- }
- vec_add1 (file_name, 0);
-
- M (CREATE_VHOST_USER_IF, mp);
-
- mp->is_server = is_server;
- mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
- mp->disable_indirect_desc = disable_indirect_desc;
- mp->enable_gso = enable_gso;
- mp->enable_packed = enable_packed;
- mp->custom_dev_instance = ntohl (custom_dev_instance);
- clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
- vec_free (file_name);
- if (custom_dev_instance != ~0)
- mp->renumber = 1;
-
- mp->use_custom_mac = use_custom_mac;
- clib_memcpy (mp->mac_address, hwaddr, 6);
- if (tag)
- strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
- vec_free (tag);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_modify_vhost_user_if (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_modify_vhost_user_if_t *mp;
- u8 *file_name;
- u8 is_server = 0;
- u8 file_name_set = 0;
- u32 custom_dev_instance = ~0;
- u8 sw_if_index_set = 0;
- u32 sw_if_index = (u32) ~ 0;
- u8 enable_gso = 0;
- u8 enable_packed = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "socket %s", &file_name))
- {
- file_name_set = 1;
- }
- else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
- ;
- else if (unformat (i, "server"))
- is_server = 1;
- else if (unformat (i, "gso"))
- enable_gso = 1;
- else if (unformat (i, "packed"))
- enable_packed = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing sw_if_index or interface name");
- return -99;
- }
-
- if (file_name_set == 0)
- {
- errmsg ("missing socket file name");
- return -99;
- }
-
- if (vec_len (file_name) > 255)
- {
- errmsg ("socket file name too long");
- return -99;
- }
- vec_add1 (file_name, 0);
-
- M (MODIFY_VHOST_USER_IF, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_server = is_server;
- mp->enable_gso = enable_gso;
- mp->enable_packed = enable_packed;
- mp->custom_dev_instance = ntohl (custom_dev_instance);
- clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
- vec_free (file_name);
- if (custom_dev_instance != ~0)
- mp->renumber = 1;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_create_vhost_user_if_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_create_vhost_user_if_v2_t *mp;
- u8 *file_name;
- u8 is_server = 0;
- u8 file_name_set = 0;
- u32 custom_dev_instance = ~0;
- u8 hwaddr[6];
- u8 use_custom_mac = 0;
- u8 disable_mrg_rxbuf = 0;
- u8 disable_indirect_desc = 0;
- u8 *tag = 0;
- u8 enable_gso = 0;
- u8 enable_packed = 0;
- u8 enable_event_idx = 0;
- int ret;
-
- /* Shut up coverity */
- clib_memset (hwaddr, 0, sizeof (hwaddr));
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "socket %s", &file_name))
- {
- file_name_set = 1;
- }
- else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
- ;
- else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
- use_custom_mac = 1;
- else if (unformat (i, "server"))
- is_server = 1;
- else if (unformat (i, "disable_mrg_rxbuf"))
- disable_mrg_rxbuf = 1;
- else if (unformat (i, "disable_indirect_desc"))
- disable_indirect_desc = 1;
- else if (unformat (i, "gso"))
- enable_gso = 1;
- else if (unformat (i, "packed"))
- enable_packed = 1;
- else if (unformat (i, "event-idx"))
- enable_event_idx = 1;
- else if (unformat (i, "tag %s", &tag))
- ;
- else
- break;
- }
-
- if (file_name_set == 0)
- {
- errmsg ("missing socket file name");
- return -99;
- }
-
- if (vec_len (file_name) > 255)
- {
- errmsg ("socket file name too long");
- return -99;
- }
- vec_add1 (file_name, 0);
-
- M (CREATE_VHOST_USER_IF_V2, mp);
-
- mp->is_server = is_server;
- mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
- mp->disable_indirect_desc = disable_indirect_desc;
- mp->enable_gso = enable_gso;
- mp->enable_packed = enable_packed;
- mp->enable_event_idx = enable_event_idx;
- mp->custom_dev_instance = ntohl (custom_dev_instance);
- clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
- vec_free (file_name);
- if (custom_dev_instance != ~0)
- mp->renumber = 1;
-
- mp->use_custom_mac = use_custom_mac;
- clib_memcpy (mp->mac_address, hwaddr, 6);
- if (tag)
- strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
- vec_free (tag);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_modify_vhost_user_if_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_modify_vhost_user_if_v2_t *mp;
- u8 *file_name;
- u8 is_server = 0;
- u8 file_name_set = 0;
- u32 custom_dev_instance = ~0;
- u8 sw_if_index_set = 0;
- u32 sw_if_index = (u32) ~ 0;
- u8 enable_gso = 0;
- u8 enable_packed = 0;
- u8 enable_event_idx = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "socket %s", &file_name))
- {
- file_name_set = 1;
- }
- else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
- ;
- else if (unformat (i, "server"))
- is_server = 1;
- else if (unformat (i, "gso"))
- enable_gso = 1;
- else if (unformat (i, "packed"))
- enable_packed = 1;
- else if (unformat (i, "event-idx"))
- enable_event_idx = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing sw_if_index or interface name");
- return -99;
- }
-
- if (file_name_set == 0)
- {
- errmsg ("missing socket file name");
- return -99;
- }
-
- if (vec_len (file_name) > 255)
- {
- errmsg ("socket file name too long");
- return -99;
- }
- vec_add1 (file_name, 0);
-
- M (MODIFY_VHOST_USER_IF_V2, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_server = is_server;
- mp->enable_gso = enable_gso;
- mp->enable_packed = enable_packed;
- mp->enable_event_idx = enable_event_idx;
- mp->custom_dev_instance = ntohl (custom_dev_instance);
- clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
- vec_free (file_name);
- if (custom_dev_instance != ~0)
- mp->renumber = 1;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_delete_vhost_user_if (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_delete_vhost_user_if_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing sw_if_index or interface name");
- return -99;
- }
-
-
- M (DELETE_VHOST_USER_IF, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static void vl_api_sw_interface_vhost_user_details_t_handler
- (vl_api_sw_interface_vhost_user_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u64 features;
-
- features =
- clib_net_to_host_u32 (mp->features_first_32) | ((u64)
- clib_net_to_host_u32
- (mp->features_last_32) <<
- 32);
-
- print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %16llx %6d %7d %s",
- (char *) mp->interface_name, ntohl (mp->sw_if_index),
- ntohl (mp->virtio_net_hdr_sz), features, mp->is_server,
- ntohl (mp->num_regions), (char *) mp->sock_filename);
- print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
-}
-
-static void vl_api_sw_interface_vhost_user_details_t_handler_json
- (vl_api_sw_interface_vhost_user_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_string_copy (node, "interface_name",
- mp->interface_name);
- vat_json_object_add_uint (node, "virtio_net_hdr_sz",
- ntohl (mp->virtio_net_hdr_sz));
- vat_json_object_add_uint (node, "features_first_32",
- clib_net_to_host_u32 (mp->features_first_32));
- vat_json_object_add_uint (node, "features_last_32",
- clib_net_to_host_u32 (mp->features_last_32));
- vat_json_object_add_uint (node, "is_server", mp->is_server);
- vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
- vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
- vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
-}
-
-static int
-api_sw_interface_vhost_user_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_vhost_user_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
- u32 sw_if_index = ~0;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else
- break;
- }
-
- print (vam->ofp, "Interface name idx hdr_sz features "
- "server regions filename");
-
- /* Get list of vhost-user interfaces */
- M (SW_INTERFACE_VHOST_USER_DUMP, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_show_version (vat_main_t * vam)
+api_show_version (vat_main_t *vam)
{
vl_api_show_version_t *mp;
int ret;
@@ -7120,20 +6601,19 @@ api_show_version (vat_main_t * vam)
return ret;
}
-static void vl_api_l2_fib_table_details_t_handler
- (vl_api_l2_fib_table_details_t * mp)
+static void
+vl_api_l2_fib_table_details_t_handler (vl_api_l2_fib_table_details_t *mp)
{
vat_main_t *vam = &vat_main;
- print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
- " %d %d %d",
+ print (vam->ofp,
+ "%3" PRIu32 " %U %3" PRIu32 " %d %d %d",
ntohl (mp->bd_id), format_ethernet_address, mp->mac,
- ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
- mp->bvi_mac);
+ ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac, mp->bvi_mac);
}
-static void vl_api_l2_fib_table_details_t_handler_json
- (vl_api_l2_fib_table_details_t * mp)
+static void
+vl_api_l2_fib_table_details_t_handler_json (vl_api_l2_fib_table_details_t *mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t *node = NULL;
@@ -7155,7 +6635,7 @@ static void vl_api_l2_fib_table_details_t_handler_json
}
static int
-api_l2_fib_table_dump (vat_main_t * vam)
+api_l2_fib_table_dump (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_l2_fib_table_dump_t *mp;
@@ -7195,9 +6675,8 @@ api_l2_fib_table_dump (vat_main_t * vam)
return ret;
}
-
static int
-api_interface_name_renumber (vat_main_t * vam)
+api_interface_name_renumber (vat_main_t *vam)
{
unformat_input_t *line_input = vam->input;
vl_api_interface_name_renumber_t *mp;
@@ -7242,7 +6721,7 @@ api_interface_name_renumber (vat_main_t * vam)
}
static int
-api_want_l2_macs_events (vat_main_t * vam)
+api_want_l2_macs_events (vat_main_t *vam)
{
unformat_input_t *line_input = vam->input;
vl_api_want_l2_macs_events_t *mp;
@@ -7278,7 +6757,7 @@ api_want_l2_macs_events (vat_main_t * vam)
}
static int
-api_ip_address_dump (vat_main_t * vam)
+api_ip_address_dump (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_ip_address_dump_t *mp;
@@ -7293,8 +6772,7 @@ api_ip_address_dump (vat_main_t * vam)
{
if (unformat (i, "sw_if_index %d", &sw_if_index))
sw_if_index_set = 1;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
sw_if_index_set = 1;
else if (unformat (i, "ipv4"))
ipv4_set = 1;
@@ -9713,22 +9191,6 @@ _(l2_interface_vlan_tag_rewrite, \
"<intfc> | sw_if_index <nn> \n" \
"[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
"[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
-_(create_vhost_user_if, \
- "socket <filename> [server] [renumber <dev_instance>] " \
- "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
- "[mac <mac_address>] [packed]") \
-_(modify_vhost_user_if, \
- "<intfc> | sw_if_index <nn> socket <filename>\n" \
- "[server] [renumber <dev_instance>] [gso] [packed]") \
-_(create_vhost_user_if_v2, \
- "socket <filename> [server] [renumber <dev_instance>] " \
- "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
- "[mac <mac_address>] [packed] [event-idx]") \
-_(modify_vhost_user_if_v2, \
- "<intfc> | sw_if_index <nn> socket <filename>\n" \
- "[server] [renumber <dev_instance>] [gso] [packed] [event-idx]")\
-_(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
-_(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
_(show_version, "") \
_(show_threads, "") \
_(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index 86656883bd8..df6768d4cde 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -27,31 +27,14 @@
#include <vnet/ethernet/ethernet_types_api.h>
#include <vnet/devices/virtio/virtio_types_api.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/devices/virtio/vhost_user.api_enum.h>
+#include <vnet/devices/virtio/vhost_user.api_types.h>
+#define REPLY_MSG_ID_BASE msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_vpe_api_msg \
-_(CREATE_VHOST_USER_IF, create_vhost_user_if) \
-_(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
-_(CREATE_VHOST_USER_IF_V2, create_vhost_user_if_v2) \
-_(MODIFY_VHOST_USER_IF_V2, modify_vhost_user_if_v2) \
-_(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
-_(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump)
+static u16 msg_id_base;
static void
vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
@@ -286,7 +269,8 @@ send_sw_interface_vhost_user_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
+ mp->_vl_msg_id =
+ ntohs (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
mp->sw_if_index = ntohl (vui->sw_if_index);
mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz);
virtio_features_encode (vui->features, (u32 *) & mp->features_first_32,
@@ -339,40 +323,11 @@ static void
vec_free (ifaces);
}
-/*
- * vhost-user_api_hookup
- * Add vpe's API message handlers to the table.
- * vlib has already mapped shared memory and
- * added the client registration handlers.
- * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
- */
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-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_vhost_user;
-#undef _
-}
-
+#include <vnet/devices/virtio/vhost_user.api.c>
static clib_error_t *
vhost_user_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_vpe_api_msg;
-#undef _
-
/* Mark CREATE_VHOST_USER_IF as mp safe */
am->is_mp_safe[VL_API_CREATE_VHOST_USER_IF] = 1;
am->is_mp_safe[VL_API_CREATE_VHOST_USER_IF_V2] = 1;
@@ -380,7 +335,7 @@ vhost_user_api_hookup (vlib_main_t * vm)
/*
* Set up the (msg_name, crc, message-id) table
*/
- setup_message_id_table (am);
+ REPLY_MSG_ID_BASE = setup_message_id_table ();
return 0;
}
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index 0e1cdd6fa28..4e54b443ac4 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -33,7 +33,6 @@
#include <vnet/format_fns.h>
#endif
-#include <vnet/devices/virtio/vhost_user.api.h>
#include <vnet/interface.api.h>
#include <vnet/l2/l2.api.h>
#include <vnet/span/span.api.h>