summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-06-21 13:45:44 +0000
committerFilip Tehlar <ftehlar@cisco.com>2021-06-22 10:04:33 +0000
commit41ff1eb5ddc493abdf9721640633a137ab638262 (patch)
tree59a55b534f8cdd8c4dbcfdbc6efd349535cda1ce /src
parent102e8a5d60728cfaa8e60733ee21c3759edabfbe (diff)
ethernet: api cleanup
Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: Iacaefbf04834f000a14f151c4b848f280ac46d63
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c111
-rw-r--r--src/vnet/ethernet/p2p_ethernet.h2
-rw-r--r--src/vnet/ethernet/p2p_ethernet_api.c57
-rw-r--r--src/vnet/vnet_all_api_h.h1
4 files changed, 8 insertions, 163 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 2907b888b2c..077a4cae5d3 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2489,8 +2489,6 @@ _(set_punt_reply) \
_(sw_interface_tag_add_del_reply) \
_(sw_interface_add_del_mac_address_reply) \
_(hw_interface_set_mtu_reply) \
-_(p2p_ethernet_add_reply) \
-_(p2p_ethernet_del_reply) \
_(tcp_configure_src_addresses_reply) \
_(session_rule_add_del_reply) \
_(ip_container_proxy_add_del_reply) \
@@ -2658,8 +2656,6 @@ _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply
_(L2_XCONNECT_DETAILS, l2_xconnect_details) \
_(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
-_(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
-_(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
@@ -10509,111 +10505,6 @@ api_hw_interface_set_mtu (vat_main_t * vam)
}
static int
-api_p2p_ethernet_add (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_p2p_ethernet_add_t *mp;
- u32 parent_if_index = ~0;
- u32 sub_id = ~0;
- u8 remote_mac[6];
- u8 mac_set = 0;
- int ret;
-
- clib_memset (remote_mac, 0, sizeof (remote_mac));
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &parent_if_index))
- ;
- else
- if (unformat
- (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
- mac_set++;
- else if (unformat (i, "sub_id %d", &sub_id))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (parent_if_index == ~0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (mac_set == 0)
- {
- errmsg ("missing remote mac address");
- return -99;
- }
- if (sub_id == ~0)
- {
- errmsg ("missing sub-interface id");
- return -99;
- }
-
- M (P2P_ETHERNET_ADD, mp);
- mp->parent_if_index = ntohl (parent_if_index);
- mp->subif_id = ntohl (sub_id);
- clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_p2p_ethernet_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_p2p_ethernet_del_t *mp;
- u32 parent_if_index = ~0;
- u8 remote_mac[6];
- u8 mac_set = 0;
- int ret;
-
- clib_memset (remote_mac, 0, sizeof (remote_mac));
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &parent_if_index))
- ;
- else
- if (unformat
- (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
- mac_set++;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (parent_if_index == ~0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (mac_set == 0)
- {
- errmsg ("missing remote mac address");
- return -99;
- }
-
- M (P2P_ETHERNET_DEL, mp);
- mp->parent_if_index = ntohl (parent_if_index);
- clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
api_tcp_configure_src_addresses (vat_main_t * vam)
{
vl_api_tcp_configure_src_addresses_t *mp;
@@ -11836,8 +11727,6 @@ _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
_(l2_xconnect_dump, "") \
_(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
_(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
-_(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
-_(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
_(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
_(sock_init_shm, "size <nnn>") \
_(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
diff --git a/src/vnet/ethernet/p2p_ethernet.h b/src/vnet/ethernet/p2p_ethernet.h
index bb1e2896bc2..78ca81a9da2 100644
--- a/src/vnet/ethernet/p2p_ethernet.h
+++ b/src/vnet/ethernet/p2p_ethernet.h
@@ -33,6 +33,8 @@ typedef struct {
/* convenience */
vlib_main_t * vlib_main;
vnet_main_t * vnet_main;
+
+ u16 msg_id_base;
} p2p_ethernet_main_t;
extern p2p_ethernet_main_t p2p_main;
diff --git a/src/vnet/ethernet/p2p_ethernet_api.c b/src/vnet/ethernet/p2p_ethernet_api.c
index 8321f8db5d3..a9a8cc0a444 100644
--- a/src/vnet/ethernet/p2p_ethernet_api.c
+++ b/src/vnet/ethernet/p2p_ethernet_api.c
@@ -19,30 +19,15 @@
#include <vnet/vnet.h>
#include <vlibmemory/api.h>
-
-#include <vnet/vnet_msg_enum.h>
#include <vnet/ethernet/p2p_ethernet.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/ethernet/p2p_ethernet.api_enum.h>
+#include <vnet/ethernet/p2p_ethernet.api_types.h>
+#define REPLY_MSG_ID_BASE p2p_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_vpe_api_msg \
-_(P2P_ETHERNET_ADD, p2p_ethernet_add) \
-_(P2P_ETHERNET_DEL, p2p_ethernet_del)
-
void
vl_api_p2p_ethernet_add_t_handler (vl_api_p2p_ethernet_add_t * mp)
{
@@ -106,44 +91,14 @@ vl_api_p2p_ethernet_del_t_handler (vl_api_p2p_ethernet_del_t * mp)
REPLY_MACRO (VL_API_P2P_ETHERNET_DEL_REPLY);
}
-/*
- * p2p_ethernet_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_p2p_ethernet;
-#undef _
-}
-
+#include <vnet/ethernet/p2p_ethernet.api.c>
static clib_error_t *
p2p_ethernet_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 _
-
/*
* 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 872729cc441..05b74f9e793 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -46,7 +46,6 @@
#include <vnet/mpls/mpls.api.h>
#include <vnet/srv6/sr.api.h>
#include <vnet/srmpls/sr_mpls.api.h>
-#include <vnet/ethernet/p2p_ethernet.api.h>
#include <vnet/tcp/tcp.api.h>
#include <vnet/ip/punt.api.h>
#include <vnet/qos/qos.api.h>