From 941185ae65203ace089a22d8979a2a1eb7fd3262 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Fri, 27 Sep 2019 14:21:58 +0200 Subject: svs: remove api boilerplate Type: refactor Signed-off-by: Ole Troan Change-Id: I08eab052b67893cc6633d235885438e69950904b --- MAINTAINERS | 5 +++ src/plugins/svs/CMakeLists.txt | 4 -- src/plugins/svs/svs_all_api_h.h | 21 ----------- src/plugins/svs/svs_api.c | 82 +++-------------------------------------- src/plugins/svs/svs_msg_enum.h | 28 -------------- 5 files changed, 11 insertions(+), 129 deletions(-) delete mode 100644 src/plugins/svs/svs_all_api_h.h delete mode 100644 src/plugins/svs/svs_msg_enum.h diff --git a/MAINTAINERS b/MAINTAINERS index f05688e4105..75230890be5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -528,6 +528,11 @@ Cisco Discovery Protocol I: cdp F: src/plugins/cdp/ +Source VRF Select +I: svs +M: Neale Ranns +F: src/plugins/svs/ + THE REST I: misc C: Contact vpp-dev Mailing List diff --git a/src/plugins/svs/CMakeLists.txt b/src/plugins/svs/CMakeLists.txt index 7d915b4878f..f3de2114669 100644 --- a/src/plugins/svs/CMakeLists.txt +++ b/src/plugins/svs/CMakeLists.txt @@ -18,8 +18,4 @@ add_vpp_plugin(svs API_FILES svs.api - - INSTALL_HEADERS - svs_all_api_h.h - svs_msg_enum.h ) diff --git a/src/plugins/svs/svs_all_api_h.h b/src/plugins/svs/svs_all_api_h.h deleted file mode 100644 index cdec36e0e17..00000000000 --- a/src/plugins/svs/svs_all_api_h.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ - -#ifdef vl_printfun -#include -#endif - -#include diff --git a/src/plugins/svs/svs_api.c b/src/plugins/svs/svs_api.c index 39e0843e80a..654a074471d 100644 --- a/src/plugins/svs/svs_api.c +++ b/src/plugins/svs/svs_api.c @@ -27,28 +27,9 @@ #include /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#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 -#undef vl_printfun - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include +#include /** * Base message ID fot the plugin @@ -56,15 +37,6 @@ static u32 svs_base_msg_id; #include -/* List of message types that this plugin understands */ - -#define foreach_svs_plugin_api_msg \ - _(SVS_PLUGIN_GET_VERSION, svs_plugin_get_version) \ - _(SVS_TABLE_ADD_DEL, svs_table_add_del) \ - _(SVS_ROUTE_ADD_DEL, svs_route_add_del) \ - _(SVS_ENABLE_DISABLE, svs_enable_disable) \ - _(SVS_DUMP, svs_dump) - static void vl_api_svs_plugin_get_version_t_handler (vl_api_svs_plugin_get_version_t * mp) { @@ -201,56 +173,14 @@ vl_api_svs_dump_t_handler (vl_api_svs_dump_t * mp) svs_walk (svs_send_details, &ctx); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -/* Set up the API message handling tables */ -static clib_error_t * -svs_plugin_api_hookup (vlib_main_t * vm) -{ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + svs_base_msg_id), \ - #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_svs_plugin_api_msg; -#undef _ - - return 0; -} - -static void -setup_message_id_table (api_main_t * apim) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (apim, #n "_" #crc, id + svs_base_msg_id); - foreach_vl_msg_name_crc_svs; -#undef _ -} - +#include static clib_error_t * svs_api_init (vlib_main_t * vm) { - clib_error_t *error = 0; - - u8 *name = format (0, "svs_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - svs_base_msg_id = vl_msg_api_get_msg_ids ((char *) name, - VL_MSG_FIRST_AVAILABLE); - - error = svs_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (&api_main); + svs_base_msg_id = setup_message_id_table (); - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (svs_api_init); diff --git a/src/plugins/svs/svs_msg_enum.h b/src/plugins/svs/svs_msg_enum.h deleted file mode 100644 index 550fdc8eced..00000000000 --- a/src/plugins/svs/svs_msg_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_svs_msg_enum_h -#define included_svs_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif -- cgit 1.2.3-korg