summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-22 12:03:55 +0000
committerOle Tr�an <otroan@employees.org>2021-06-22 14:12:29 +0000
commit3808ec06c4c6a860cab7c6293e8b1be93f002b21 (patch)
treec018d2c644898f7672402fc5105cb52101842bf3
parente2fc003f46f70659045e563368db73eeca9a9647 (diff)
devices: tapv2 api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I0a2c1cbbe798ddf9d08da78bf0b458a0f54fa13a
-rw-r--r--src/vat/api_format.c403
-rw-r--r--src/vnet/devices/tap/tapv2_api.c61
-rw-r--r--src/vnet/vnet_all_api_h.h1
3 files changed, 12 insertions, 453 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 8df56aee474..e92eee3bab8 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1508,74 +1508,6 @@ static void vl_api_bridge_flags_reply_t_handler_json
}
static void
-vl_api_tap_create_v2_reply_t_handler (vl_api_tap_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_tap_create_v2_reply_t_handler_json
- (vl_api_tap_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_tap_delete_v2_reply_t_handler (vl_api_tap_delete_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->result_ready = 1;
- }
-}
-
-static void vl_api_tap_delete_v2_reply_t_handler_json
- (vl_api_tap_delete_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_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
mp)
{
@@ -2152,9 +2084,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) \
-_(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
-_(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
-_(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
_(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) \
@@ -3967,248 +3896,6 @@ api_bd_ip_mac_dump (vat_main_t * vam)
return ret;
}
-static int
-api_tap_create_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_tap_create_v2_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u32 id = ~0;
- u32 num_rx_queues = 0;
- u8 *host_if_name = 0;
- u8 host_if_name_set = 0;
- u8 *host_ns = 0;
- u8 host_ns_set = 0;
- u8 host_mac_addr[6];
- u8 host_mac_addr_set = 0;
- u8 *host_bridge = 0;
- u8 host_bridge_set = 0;
- u8 host_ip4_prefix_set = 0;
- u8 host_ip6_prefix_set = 0;
- ip4_address_t host_ip4_addr;
- ip4_address_t host_ip4_gw;
- u8 host_ip4_gw_set = 0;
- u32 host_ip4_prefix_len = 0;
- ip6_address_t host_ip6_addr;
- ip6_address_t host_ip6_gw;
- u8 host_ip6_gw_set = 0;
- u32 host_ip6_prefix_len = 0;
- u32 host_mtu_size = 0;
- u8 host_mtu_set = 0;
- u32 tap_flags = 0;
- int ret;
- u32 rx_ring_sz = 0, tx_ring_sz = 0;
-
- 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, "id %u", &id))
- ;
- else
- if (unformat
- (i, "hw-addr %U", unformat_ethernet_address, mac_address))
- random_mac = 0;
- else if (unformat (i, "host-if-name %s", &host_if_name))
- host_if_name_set = 1;
- else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
- ;
- else if (unformat (i, "host-ns %s", &host_ns))
- host_ns_set = 1;
- else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
- host_mac_addr))
- host_mac_addr_set = 1;
- else if (unformat (i, "host-bridge %s", &host_bridge))
- host_bridge_set = 1;
- else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
- &host_ip4_addr, &host_ip4_prefix_len))
- host_ip4_prefix_set = 1;
- else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
- &host_ip6_addr, &host_ip6_prefix_len))
- host_ip6_prefix_set = 1;
- else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
- &host_ip4_gw))
- host_ip4_gw_set = 1;
- else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
- &host_ip6_gw))
- host_ip6_gw_set = 1;
- else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
- ;
- else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
- ;
- else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
- host_mtu_set = 1;
- else if (unformat (i, "no-gso"))
- tap_flags &= ~TAP_API_FLAG_GSO;
- else if (unformat (i, "gso"))
- tap_flags |= TAP_API_FLAG_GSO;
- else if (unformat (i, "csum-offload"))
- tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
- else if (unformat (i, "persist"))
- tap_flags |= TAP_API_FLAG_PERSIST;
- else if (unformat (i, "attach"))
- tap_flags |= TAP_API_FLAG_ATTACH;
- else if (unformat (i, "tun"))
- tap_flags |= TAP_API_FLAG_TUN;
- else if (unformat (i, "gro-coalesce"))
- tap_flags |= TAP_API_FLAG_GRO_COALESCE;
- else if (unformat (i, "packed"))
- tap_flags |= TAP_API_FLAG_PACKED;
- else if (unformat (i, "in-order"))
- tap_flags |= TAP_API_FLAG_IN_ORDER;
- else
- break;
- }
-
- if (vec_len (host_if_name) > 63)
- {
- errmsg ("tap name too long. ");
- return -99;
- }
- if (vec_len (host_ns) > 63)
- {
- errmsg ("host name space too long. ");
- return -99;
- }
- if (vec_len (host_bridge) > 63)
- {
- errmsg ("host bridge name too long. ");
- return -99;
- }
- if (host_ip4_prefix_len > 32)
- {
- errmsg ("host ip4 prefix length not valid. ");
- return -99;
- }
- if (host_ip6_prefix_len > 128)
- {
- errmsg ("host ip6 prefix length not valid. ");
- return -99;
- }
- if (!is_pow2 (rx_ring_sz))
- {
- errmsg ("rx ring size must be power of 2. ");
- return -99;
- }
- if (rx_ring_sz > 32768)
- {
- errmsg ("rx ring size must be 32768 or lower. ");
- return -99;
- }
- if (!is_pow2 (tx_ring_sz))
- {
- errmsg ("tx ring size must be power of 2. ");
- return -99;
- }
- if (tx_ring_sz > 32768)
- {
- errmsg ("tx ring size must be 32768 or lower. ");
- return -99;
- }
- if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
- {
- errmsg ("host MTU size must be in between 64 and 65355. ");
- return -99;
- }
-
- /* Construct the API message */
- M (TAP_CREATE_V2, mp);
-
- mp->id = ntohl (id);
- mp->use_random_mac = random_mac;
- mp->num_rx_queues = (u8) num_rx_queues;
- mp->tx_ring_sz = ntohs (tx_ring_sz);
- mp->rx_ring_sz = ntohs (rx_ring_sz);
- mp->host_mtu_set = host_mtu_set;
- mp->host_mtu_size = ntohl (host_mtu_size);
- mp->host_mac_addr_set = host_mac_addr_set;
- mp->host_ip4_prefix_set = host_ip4_prefix_set;
- mp->host_ip6_prefix_set = host_ip6_prefix_set;
- mp->host_ip4_gw_set = host_ip4_gw_set;
- mp->host_ip6_gw_set = host_ip6_gw_set;
- mp->tap_flags = ntohl (tap_flags);
- mp->host_namespace_set = host_ns_set;
- mp->host_if_name_set = host_if_name_set;
- mp->host_bridge_set = host_bridge_set;
-
- if (random_mac == 0)
- clib_memcpy (mp->mac_address, mac_address, 6);
- if (host_mac_addr_set)
- clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
- if (host_if_name_set)
- clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
- if (host_ns_set)
- clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
- if (host_bridge_set)
- clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
- if (host_ip4_prefix_set)
- {
- clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
- mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
- }
- if (host_ip6_prefix_set)
- {
- clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
- mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
- }
- if (host_ip4_gw_set)
- clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
- if (host_ip6_gw_set)
- clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
-
- vec_free (host_ns);
- vec_free (host_if_name);
- vec_free (host_bridge);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_tap_delete_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_tap_delete_v2_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 (TAP_DELETE_V2, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
uword
unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
{
@@ -6803,91 +6490,6 @@ api_add_node_next (vat_main_t * vam)
return ret;
}
-static void vl_api_sw_interface_tap_v2_details_t_handler
- (vl_api_sw_interface_tap_v2_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- u8 *ip4 =
- format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
- mp->host_ip4_prefix.len);
- u8 *ip6 =
- format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
- mp->host_ip6_prefix.len);
-
- print (vam->ofp,
- "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
- mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
- ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
- format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
- mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
-
- vec_free (ip4);
- vec_free (ip6);
-}
-
-static void vl_api_sw_interface_tap_v2_details_t_handler_json
- (vl_api_sw_interface_tap_v2_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, "id", ntohl (mp->id));
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
- vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
- 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_string_copy (node, "host_mac_addr",
- format (0, "%U", format_ethernet_address,
- &mp->host_mac_addr));
- vat_json_object_add_string_copy (node, "host_namespace",
- mp->host_namespace);
- vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
- vat_json_object_add_string_copy (node, "host_ip4_addr",
- format (0, "%U/%d", format_ip4_address,
- mp->host_ip4_prefix.address,
- mp->host_ip4_prefix.len));
- vat_json_object_add_string_copy (node, "host_ip6_prefix",
- format (0, "%U/%d", format_ip6_address,
- mp->host_ip6_prefix.address,
- mp->host_ip6_prefix.len));
-
-}
-
-static int
-api_sw_interface_tap_v2_dump (vat_main_t * vam)
-{
- vl_api_sw_interface_tap_v2_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- print (vam->ofp,
- "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
- "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
- "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
- "host_ip6_addr");
-
- /* Get list of tap interfaces */
- M (SW_INTERFACE_TAP_V2_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
static void vl_api_sw_interface_virtio_pci_details_t_handler
(vl_api_sw_interface_virtio_pci_details_t * mp)
{
@@ -10323,11 +9925,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") \
-_(tap_create_v2, \
- "id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload | gro-coalesce] [persist] [attach] [tun] [packed] [in-order]") \
-_(tap_delete_v2, \
- "<vpp-if-name> | sw_if_index <id>") \
-_(sw_interface_tap_v2_dump, "") \
_(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, \
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index ac38128daf8..08dca0dc92b 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -24,33 +24,18 @@
#include <vnet/api_errno.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/ip/ip.h>
-
#include <vnet/ethernet/ethernet_types_api.h>
#include <vnet/ip/ip_types_api.h>
+#include <vnet/devices/tap/tap.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/tap/tapv2.api_enum.h>
+#include <vnet/devices/tap/tapv2.api_types.h>
+#define REPLY_MSG_ID_BASE msg_id_base
#include <vlibapi/api_helper_macros.h>
-#include <vnet/devices/tap/tap.h>
-#define foreach_tapv2_api_msg \
-_(TAP_CREATE_V2, tap_create_v2) \
-_(TAP_DELETE_V2, tap_delete_v2) \
-_(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump)
+static u16 msg_id_base;
static void
vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
@@ -158,7 +143,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
}
rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_TAP_CREATE_V2_REPLY);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_TAP_CREATE_V2_REPLY);
rmp->context = mp->context;
rmp->retval = ntohl (ap->rv);
rmp->sw_if_index = ntohl (ap->sw_if_index);
@@ -189,7 +174,7 @@ vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp)
rv = tap_delete_if (vm, sw_if_index);
rmp = vl_msg_api_alloc (sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_V2_REPLY);
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_TAP_DELETE_V2_REPLY);
rmp->context = mp->context;
rmp->retval = ntohl (rv);
@@ -207,7 +192,8 @@ tap_send_sw_interface_details (vpe_api_main_t * am,
vl_api_sw_interface_tap_v2_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_TAP_V2_DETAILS);
+ mp->_vl_msg_id =
+ htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_TAP_V2_DETAILS);
mp->id = htonl (tap_if->id);
mp->sw_if_index = htonl (tap_if->sw_if_index);
mp->tap_flags = htonl (tap_if->tap_flags);
@@ -273,37 +259,14 @@ vl_api_sw_interface_tap_v2_dump_t_handler (vl_api_sw_interface_tap_v2_dump_t *
vec_free (tapifs);
}
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-tap_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_tapv2;
-#undef _
-}
-
+#include <vnet/devices/tap/tapv2.api.c>
static clib_error_t *
tapv2_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_tapv2_api_msg;
-#undef _
-
/*
* Set up the (msg_name, crc, message-id) table
*/
- tap_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 6f24ef457ac..d0b6135e48f 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -35,7 +35,6 @@
#include <vnet/devices/af_packet/af_packet.api.h>
#include <vnet/devices/virtio/vhost_user.api.h>
-#include <vnet/devices/tap/tapv2.api.h>
#include <vnet/interface.api.h>
#include <vnet/l2/l2.api.h>
#include <vnet/span/span.api.h>