aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c313
-rw-r--r--src/vnet/devices/virtio/virtio.h1
-rw-r--r--src/vnet/devices/virtio/virtio_api.c61
-rw-r--r--src/vnet/vnet_all_api_h.h1
4 files changed, 13 insertions, 363 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 54ff05ad14e..fb2c7dab653 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1478,110 +1478,6 @@ static void vl_api_bridge_flags_reply_t_handler_json
vam->result_ready = 1;
}
-static void
-vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_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;
- }
-}
-
-static void vl_api_virtio_pci_create_reply_t_handler_json
- (vl_api_virtio_pci_create_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_virtio_pci_create_v2_reply_t_handler
- (vl_api_virtio_pci_create_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;
- }
-}
-
-static void vl_api_virtio_pci_create_v2_reply_t_handler_json
- (vl_api_virtio_pci_create_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_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_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->result_ready = 1;
- }
-}
-
-static void vl_api_virtio_pci_delete_reply_t_handler_json
- (vl_api_virtio_pci_delete_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_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)
{
@@ -1936,10 +1832,6 @@ _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
_(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
_(L2_FLAGS_REPLY, l2_flags_reply) \
_(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
-_(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
-_(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
-_(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
-_(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
_(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
_(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
@@ -3700,116 +3592,6 @@ unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
}
static int
-api_virtio_pci_create_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_virtio_pci_create_v2_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u32 pci_addr = 0;
- u64 features = (u64) ~ (0ULL);
- u32 virtio_flags = 0;
- int ret;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
- {
- random_mac = 0;
- }
- else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
- ;
- else if (unformat (i, "features 0x%llx", &features))
- ;
- else if (unformat (i, "gso-enabled"))
- virtio_flags |= VIRTIO_API_FLAG_GSO;
- else if (unformat (i, "csum-offload-enabled"))
- virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
- else if (unformat (i, "gro-coalesce"))
- virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
- else if (unformat (i, "packed"))
- virtio_flags |= VIRTIO_API_FLAG_PACKED;
- else if (unformat (i, "in-order"))
- virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
- else if (unformat (i, "buffering"))
- virtio_flags |= VIRTIO_API_FLAG_BUFFERING;
- else
- break;
- }
-
- if (pci_addr == 0)
- {
- errmsg ("pci address must be non zero. ");
- return -99;
- }
-
- /* Construct the API message */
- M (VIRTIO_PCI_CREATE_V2, mp);
-
- mp->use_random_mac = random_mac;
-
- mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
- mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
- mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
- mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
-
- mp->features = clib_host_to_net_u64 (features);
- mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
-
- if (random_mac == 0)
- clib_memcpy (mp->mac_address, mac_address, 6);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_virtio_pci_delete (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_virtio_pci_delete_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- 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 vpp interface name. ");
- return -99;
- }
-
- /* Construct the API message */
- M (VIRTIO_PCI_DELETE, mp);
-
- mp->sw_if_index = htonl (sw_if_index);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
api_ip_table_add_del (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
@@ -5966,96 +5748,6 @@ api_add_node_next (vat_main_t * vam)
return ret;
}
-static void vl_api_sw_interface_virtio_pci_details_t_handler
- (vl_api_sw_interface_virtio_pci_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- typedef union
- {
- struct
- {
- u16 domain;
- u8 bus;
- u8 slot:5;
- u8 function:3;
- };
- u32 as_u32;
- } pci_addr_t;
- pci_addr_t addr;
-
- addr.domain = ntohs (mp->pci_addr.domain);
- addr.bus = mp->pci_addr.bus;
- addr.slot = mp->pci_addr.slot;
- addr.function = mp->pci_addr.function;
-
- u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
- addr.slot, addr.function);
-
- print (vam->ofp,
- "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
- pci_addr, ntohl (mp->sw_if_index),
- ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
- format_ethernet_address, mp->mac_addr,
- clib_net_to_host_u64 (mp->features));
- vec_free (pci_addr);
-}
-
-static void vl_api_sw_interface_virtio_pci_details_t_handler_json
- (vl_api_sw_interface_virtio_pci_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- vlib_pci_addr_t pci_addr;
-
- 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);
-
- pci_addr.domain = ntohs (mp->pci_addr.domain);
- pci_addr.bus = mp->pci_addr.bus;
- pci_addr.slot = mp->pci_addr.slot;
- pci_addr.function = mp->pci_addr.function;
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
- vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
- vat_json_object_add_uint (node, "features",
- clib_net_to_host_u64 (mp->features));
- vat_json_object_add_string_copy (node, "mac_addr",
- format (0, "%U", format_ethernet_address,
- &mp->mac_addr));
-}
-
-static int
-api_sw_interface_virtio_pci_dump (vat_main_t * vam)
-{
- vl_api_sw_interface_virtio_pci_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- print (vam->ofp,
- "\n%-12s %-12s %-12s %-12s %-17s %-08s",
- "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
- "mac_addr", "features");
-
- /* Get list of tap interfaces */
- M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
static int
api_l2_fib_clear_table (vat_main_t * vam)
{
@@ -8312,11 +8004,6 @@ _(l2_flags, \
"sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
_(bridge_flags, \
"bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
-_(virtio_pci_create_v2, \
- "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order] [buffering]") \
-_(virtio_pci_delete, \
- "<vpp-if-name> | sw_if_index <id>") \
-_(sw_interface_virtio_pci_dump, "") \
_(ip_table_add_del, \
"table <n> [ipv6] [add | del]\n") \
_(ip_route_add_del, \
diff --git a/src/vnet/devices/virtio/virtio.h b/src/vnet/devices/virtio/virtio.h
index c149ce482e6..48996052e2b 100644
--- a/src/vnet/devices/virtio/virtio.h
+++ b/src/vnet/devices/virtio/virtio.h
@@ -218,6 +218,7 @@ typedef struct
vlib_log_class_t log_default;
virtio_if_t *interfaces;
+ u16 msg_id_base;
} virtio_main_t;
extern virtio_main_t virtio_main;
diff --git a/src/vnet/devices/virtio/virtio_api.c b/src/vnet/devices/virtio/virtio_api.c
index 4d0b663b3dd..11514c75c59 100644
--- a/src/vnet/devices/virtio/virtio_api.c
+++ b/src/vnet/devices/virtio/virtio_api.c
@@ -26,30 +26,13 @@
#include <vnet/devices/virtio/pci.h>
#include <vlib/pci/pci_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/virtio.api_enum.h>
+#include <vnet/devices/virtio/virtio.api_types.h>
+#define REPLY_MSG_ID_BASE virtio_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_virtio_pci_api_msg \
-_(VIRTIO_PCI_CREATE, virtio_pci_create) \
-_(VIRTIO_PCI_CREATE_V2, virtio_pci_create_v2) \
-_(VIRTIO_PCI_DELETE, virtio_pci_delete) \
-_(SW_INTERFACE_VIRTIO_PCI_DUMP, sw_interface_virtio_pci_dump)
-
/* It will be deprecated in 21.01 */
static void
vl_api_virtio_pci_create_t_handler (vl_api_virtio_pci_create_t * mp)
@@ -86,7 +69,7 @@ vl_api_virtio_pci_create_t_handler (vl_api_virtio_pci_create_t * mp)
return;;
rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = htons (VL_API_VIRTIO_PCI_CREATE_REPLY);
+ rmp->_vl_msg_id = htons (REPLY_MSG_ID_BASE + VL_API_VIRTIO_PCI_CREATE_REPLY);
rmp->context = mp->context;
rmp->retval = htonl (ap->rv);
rmp->sw_if_index = htonl (ap->sw_if_index);
@@ -148,7 +131,8 @@ vl_api_virtio_pci_create_v2_t_handler (vl_api_virtio_pci_create_v2_t * mp)
return;;
rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = htons (VL_API_VIRTIO_PCI_CREATE_V2_REPLY);
+ rmp->_vl_msg_id =
+ htons (REPLY_MSG_ID_BASE + VL_API_VIRTIO_PCI_CREATE_V2_REPLY);
rmp->context = mp->context;
rmp->retval = htonl (ap->rv);
rmp->sw_if_index = htonl (ap->sw_if_index);
@@ -187,7 +171,7 @@ reply:
return;
rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = htons (VL_API_VIRTIO_PCI_DELETE_REPLY);
+ rmp->_vl_msg_id = htons (REPLY_MSG_ID_BASE + VL_API_VIRTIO_PCI_DELETE_REPLY);
rmp->context = mp->context;
rmp->retval = htonl (rv);
@@ -204,7 +188,8 @@ virtio_pci_send_sw_interface_details (vpe_api_main_t * am,
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_VIRTIO_PCI_DETAILS);
+ mp->_vl_msg_id =
+ htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_VIRTIO_PCI_DETAILS);
pci_address_encode ((vlib_pci_addr_t *) & vif->pci_addr.as_u32,
&mp->pci_addr);
mp->sw_if_index = htonl (vif->sw_if_index);
@@ -241,37 +226,15 @@ static void
}
}
-#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_virtio;
-#undef _
-}
+#include <vnet/devices/virtio/virtio.api.c>
static clib_error_t *
virtio_pci_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_virtio_pci_api_msg;
-#undef _
-
/*
* 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 ddb64ea0030..9978181c78e 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -38,7 +38,6 @@
#include <vnet/ip/ip.api.h>
#include <vnet/session/session.api.h>
#include <vnet/srmpls/sr_mpls.api.h>
-#include <vnet/devices/virtio/virtio.api.h>
/*
* fd.io coding-style-patch-verification: ON