From 63c0fd334e8762032580377926ac294409d3e625 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Mon, 28 Jun 2021 00:52:00 +0000 Subject: sr: do not use vnet_all_api.h .. as it is going to be removed. Type: improvement Signed-off-by: Filip Tehlar Change-Id: Id3a4a4ea1e1b7361d43735bfa5470c28fc65209f --- src/vnet/srmpls/sr_mpls_api.c | 66 +++++++++++++++++++++---------------------- src/vnet/vnet_all_api_h.h | 1 - 2 files changed, 33 insertions(+), 34 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/srmpls/sr_mpls_api.c b/src/vnet/srmpls/sr_mpls_api.c index 359d7446aab..d6216c68391 100644 --- a/src/vnet/srmpls/sr_mpls_api.c +++ b/src/vnet/srmpls/sr_mpls_api.c @@ -23,25 +23,31 @@ #include #include #include - #include -#include +#include +#include +#include + +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs +#define vl_api_version(n, v) static u32 api_version = v; +#include +#undef vl_api_version -#define vl_endianfun /* define message structures */ -#include +#define vl_endianfun +#include #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 +#include #undef vl_printfun +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +#define REPLY_MSG_ID_BASE msg_id_base #include #define foreach_vpe_api_msg \ @@ -49,6 +55,7 @@ _(SR_MPLS_POLICY_DEL, sr_mpls_policy_del) \ _(SR_MPLS_STEERING_ADD_DEL, sr_mpls_steering_add_del) \ _(SR_MPLS_POLICY_ASSIGN_ENDPOINT_COLOR, sr_mpls_policy_assign_endpoint_color) +static u16 msg_id_base; static void vl_api_sr_mpls_policy_add_t_handler (vl_api_sr_mpls_policy_add_t * mp) @@ -163,19 +170,11 @@ static void vl_api_sr_mpls_policy_assign_endpoint_color_t_handler REPLY_MACRO (VL_API_SR_MPLS_POLICY_ASSIGN_ENDPOINT_COLOR_REPLY); } -/* - * sr_mpls_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 -#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); +#define _(id, n, crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + REPLY_MSG_ID_BASE); foreach_vl_msg_name_crc_sr_mpls; #undef _ } @@ -185,13 +184,16 @@ sr_mpls_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); + u8 *name = format (0, "sr_mpls_%08x%c", api_version, 0); + REPLY_MSG_ID_BASE = + vl_msg_api_get_msg_ids ((char *) name, VL_MSG_SR_MPLS_LAST); + vec_free (name); + +#define _(N, n) \ + vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + 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 _ @@ -199,22 +201,20 @@ sr_mpls_api_hookup (vlib_main_t * vm) * Manually register the sr policy add msg, so we trace enough bytes * to capture a typical segment list */ - vl_msg_api_set_handlers (VL_API_SR_MPLS_POLICY_ADD, + vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_ADD, "sr_mpls_policy_add", vl_api_sr_mpls_policy_add_t_handler, - vl_noop_handler, - vl_api_sr_mpls_policy_add_t_endian, + vl_noop_handler, vl_api_sr_mpls_policy_add_t_endian, vl_api_sr_mpls_policy_add_t_print, 256, 1); /* * Manually register the sr policy mod msg, so we trace enough bytes * to capture a typical segment list */ - vl_msg_api_set_handlers (VL_API_SR_MPLS_POLICY_MOD, + vl_msg_api_set_handlers (REPLY_MSG_ID_BASE + VL_API_SR_MPLS_POLICY_MOD, "sr_mpls_policy_mod", vl_api_sr_mpls_policy_mod_t_handler, - vl_noop_handler, - vl_api_sr_mpls_policy_mod_t_endian, + vl_noop_handler, vl_api_sr_mpls_policy_mod_t_endian, vl_api_sr_mpls_policy_mod_t_print, 256, 1); /* diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h index 6a8ee152d92..a976447cfac 100644 --- a/src/vnet/vnet_all_api_h.h +++ b/src/vnet/vnet_all_api_h.h @@ -35,7 +35,6 @@ #include #include -#include /* * fd.io coding-style-patch-verification: ON -- cgit 1.2.3-korg