emacs: track improvements in vppapigen
Remove boilerplate which is now generated by vppapigen Type: refactor Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I36bff1a651ac48caa969ed76d963b0a733ef5532
This commit is contained in:
@ -22,12 +22,10 @@
|
|||||||
(load-file "./dual-loop-skel.el")
|
(load-file "./dual-loop-skel.el")
|
||||||
(load-file "./periodic-skel.el")
|
(load-file "./periodic-skel.el")
|
||||||
(load-file "./pipe-skel.el")
|
(load-file "./pipe-skel.el")
|
||||||
(load-file "./plugin-all-apih-skel.el")
|
|
||||||
(load-file "./plugin-cmake-skel.el")
|
(load-file "./plugin-cmake-skel.el")
|
||||||
(load-file "./plugin-api-skel.el")
|
(load-file "./plugin-api-skel.el")
|
||||||
(load-file "./plugin-h-skel.el")
|
(load-file "./plugin-h-skel.el")
|
||||||
(load-file "./plugin-main-skel.el")
|
(load-file "./plugin-main-skel.el")
|
||||||
(load-file "./plugin-msg-enum-skel.el")
|
|
||||||
(load-file "./plugin-node-skel.el")
|
(load-file "./plugin-node-skel.el")
|
||||||
(load-file "./plugin-qsnode-skel.el")
|
(load-file "./plugin-qsnode-skel.el")
|
||||||
(load-file "./plugin-test-skel.el")
|
(load-file "./plugin-test-skel.el")
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
;;; plugin-all-apih-skel.el - vpp engine plug-in "all-apih.c" skeleton
|
|
||||||
;;;
|
|
||||||
;;; Copyright (c) 2016 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.
|
|
||||||
|
|
||||||
(require 'skeleton)
|
|
||||||
|
|
||||||
(define-skeleton skel-plugin-all-apih
|
|
||||||
"Insert a plug-in 'all_api_h.h' skeleton "
|
|
||||||
nil
|
|
||||||
'(if (not (boundp 'plugin-name))
|
|
||||||
(setq plugin-name (read-string "Plugin name: ")))
|
|
||||||
'(setq PLUGIN-NAME (upcase plugin-name))
|
|
||||||
"
|
|
||||||
/*
|
|
||||||
* " plugin-name "_all_api_h.h - skeleton vpp engine plug-in api #include file
|
|
||||||
*
|
|
||||||
* Copyright (c) <current-year> <your-organization>
|
|
||||||
* 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 */
|
|
||||||
#include <" plugin-name "/" plugin-name ".api.h>
|
|
||||||
")
|
|
@ -49,10 +49,6 @@ add_vpp_plugin("plugin-name"
|
|||||||
API_FILES
|
API_FILES
|
||||||
" plugin-name".api
|
" plugin-name".api
|
||||||
|
|
||||||
INSTALL_HEADERS
|
|
||||||
" plugin-name "_all_api_h.h
|
|
||||||
" plugin-name "_msg_enum.h
|
|
||||||
|
|
||||||
API_TEST_SOURCES
|
API_TEST_SOURCES
|
||||||
" plugin-name "_test.c
|
" plugin-name "_test.c
|
||||||
)
|
)
|
||||||
|
@ -49,40 +49,14 @@ nil
|
|||||||
#include <vpp/app/version.h>
|
#include <vpp/app/version.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* define message IDs */
|
#include <" plugin-name "/" plugin-name ".api_enum.h>
|
||||||
#include <" plugin-name "/" plugin-name "_msg_enum.h>
|
#include <" plugin-name "/" plugin-name ".api_types.h>
|
||||||
|
|
||||||
/* define message structures */
|
|
||||||
#define vl_typedefs
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_typedefs
|
|
||||||
|
|
||||||
/* define generated endian-swappers */
|
|
||||||
#define vl_endianfun
|
|
||||||
#include <" plugin-name "/" plugin-name "_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 <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_printfun
|
|
||||||
|
|
||||||
/* Get the API version number */
|
|
||||||
#define vl_api_version(n,v) static u32 api_version=(v);
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_api_version
|
|
||||||
|
|
||||||
#define REPLY_MSG_ID_BASE " main-p "->msg_id_base
|
#define REPLY_MSG_ID_BASE " main-p "->msg_id_base
|
||||||
#include <vlibapi/api_helper_macros.h>
|
#include <vlibapi/api_helper_macros.h>
|
||||||
|
|
||||||
" plugin-name "_main_t " plugin-name "_main;
|
" plugin-name "_main_t " plugin-name "_main;
|
||||||
|
|
||||||
/* List of message types that this plugin understands */
|
|
||||||
|
|
||||||
#define foreach_" plugin-name "_plugin_api_msg \\
|
|
||||||
_(" PLUGIN-NAME "_ENABLE_DISABLE, " plugin-name "_enable_disable)
|
|
||||||
|
|
||||||
/* Action function shared between message handler and debug CLI */
|
/* Action function shared between message handler and debug CLI */
|
||||||
|
|
||||||
int " plugin-name "_enable_disable (" plugin-name "_main_t * " main-p ", u32 sw_if_index,
|
int " plugin-name "_enable_disable (" plugin-name "_main_t * " main-p ", u32 sw_if_index,
|
||||||
@ -186,59 +160,19 @@ static void vl_api_" plugin-name "_enable_disable_t_handler
|
|||||||
REPLY_MACRO(VL_API_" PLUGIN-NAME "_ENABLE_DISABLE_REPLY);
|
REPLY_MACRO(VL_API_" PLUGIN-NAME "_ENABLE_DISABLE_REPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the API message handling tables */
|
/* API definitions */
|
||||||
static clib_error_t *
|
#include <" plugin-name "/" plugin-name ".api.c>
|
||||||
" plugin-name "_plugin_api_hookup (vlib_main_t *vm)
|
|
||||||
{
|
|
||||||
" plugin-name "_main_t * " main-p " = &" plugin-name "_main;
|
|
||||||
#define _(N,n) \\
|
|
||||||
vl_msg_api_set_handlers((VL_API_##N + " main-p "->msg_id_base), \\
|
|
||||||
#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_" plugin-name "_plugin_api_msg;
|
|
||||||
#undef _
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define vl_msg_name_crc_list
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_msg_name_crc_list
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_message_id_table (" plugin-name "_main_t * " main-p ", api_main_t * am)
|
|
||||||
{
|
|
||||||
#define _(id,n,crc) \
|
|
||||||
vl_msg_api_add_msg_name_crc (am, #n \"_\" #crc, id + " main-p "->msg_id_base);
|
|
||||||
foreach_vl_msg_name_crc_" plugin-name" ;
|
|
||||||
#undef _
|
|
||||||
}
|
|
||||||
|
|
||||||
static clib_error_t * " plugin-name "_init (vlib_main_t * vm)
|
static clib_error_t * " plugin-name "_init (vlib_main_t * vm)
|
||||||
{
|
{
|
||||||
" plugin-name "_main_t * " main-p " = &" plugin-name "_main;
|
" plugin-name "_main_t * " main-p " = &" plugin-name "_main;
|
||||||
clib_error_t * error = 0;
|
clib_error_t * error = 0;
|
||||||
u8 * name;
|
|
||||||
|
|
||||||
" main-p "->vlib_main = vm;
|
" main-p "->vlib_main = vm;
|
||||||
" main-p "->vnet_main = vnet_get_main();
|
" main-p "->vnet_main = vnet_get_main();
|
||||||
|
|
||||||
name = format (0, \"" plugin-name "_%08x%c\", api_version, 0);
|
|
||||||
|
|
||||||
/* Ask for a correctly-sized block of API message decode slots */
|
|
||||||
" main-p "->msg_id_base = vl_msg_api_get_msg_ids
|
|
||||||
((char *) name, VL_MSG_FIRST_AVAILABLE);
|
|
||||||
|
|
||||||
error = " plugin-name "_plugin_api_hookup (vm);
|
|
||||||
|
|
||||||
/* Add our API messages to the global name_crc hash table */
|
/* Add our API messages to the global name_crc hash table */
|
||||||
setup_message_id_table (" main-p ", &api_main);
|
" main-p "->msg_id_base = setup_message_id_table ();
|
||||||
|
|
||||||
vec_free(name);
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
;;; plugin-msg-enum-skel.el - vpp engine plug-in message enum skeleton
|
|
||||||
;;;
|
|
||||||
;;; Copyright (c) 2016 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.
|
|
||||||
|
|
||||||
(require 'skeleton)
|
|
||||||
|
|
||||||
(define-skeleton skel-plugin-msg-enum
|
|
||||||
"Insert a plug-in message enumeration skeleton "
|
|
||||||
nil
|
|
||||||
'(if (not (boundp 'plugin-name))
|
|
||||||
(setq plugin-name (read-string "Plugin name: ")))
|
|
||||||
'(setq PLUGIN-NAME (upcase plugin-name))
|
|
||||||
"
|
|
||||||
/*
|
|
||||||
* " plugin-name "_msg_enum.h - skeleton vpp engine plug-in message enumeration
|
|
||||||
*
|
|
||||||
* Copyright (c) <current-year> <your-organization>
|
|
||||||
* 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_" plugin-name "_msg_enum_h
|
|
||||||
#define included_" plugin-name "_msg_enum_h
|
|
||||||
|
|
||||||
#include <vppinfra/byte_order.h>
|
|
||||||
|
|
||||||
#define vl_msg_id(n,h) n,
|
|
||||||
typedef enum {
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
/* We'll want to know how many messages IDs we need... */
|
|
||||||
VL_MSG_FIRST_AVAILABLE,
|
|
||||||
} vl_msg_id_t;
|
|
||||||
#undef vl_msg_id
|
|
||||||
|
|
||||||
#endif /* included_" plugin-name "_msg_enum_h */
|
|
||||||
")
|
|
@ -24,7 +24,7 @@ nil
|
|||||||
'(setq capital-oh-en "ON")
|
'(setq capital-oh-en "ON")
|
||||||
'(setq main-p (concat (substring plugin-name 0 1) "tmp"))
|
'(setq main-p (concat (substring plugin-name 0 1) "tmp"))
|
||||||
"/*
|
"/*
|
||||||
* " plugin-name ".c - skeleton vpp-api-test plug-in
|
* " plugin-name ".c - " plugin-name " vpp-api-test plug-in
|
||||||
*
|
*
|
||||||
* Copyright (c) <current-year> <your-organization>
|
* Copyright (c) <current-year> <your-organization>
|
||||||
* Licensed under the Apache License, Version 2.0 (the \"License\");
|
* Licensed under the Apache License, Version 2.0 (the \"License\");
|
||||||
@ -45,33 +45,14 @@ nil
|
|||||||
#include <vppinfra/error.h>
|
#include <vppinfra/error.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define __plugin_msg_base " plugin-name"_test_main.msg_id_base
|
||||||
|
#include <vlibapi/vat_helper_macros.h>
|
||||||
|
|
||||||
uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
|
uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
|
||||||
|
|
||||||
/* Declare message IDs */
|
/* Declare message IDs */
|
||||||
#include <" plugin-name "/" plugin-name "_msg_enum.h>
|
#include <" plugin-name "/" plugin-name ".api_enum.h>
|
||||||
|
#include <" plugin-name "/" plugin-name ".api_types.h>
|
||||||
/* define message structures */
|
|
||||||
#define vl_typedefs
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_typedefs
|
|
||||||
|
|
||||||
/* declare message handlers for each api */
|
|
||||||
|
|
||||||
#define vl_endianfun /* define message structures */
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_endianfun
|
|
||||||
|
|
||||||
/* instantiate all the print functions we know about */
|
|
||||||
#define vl_print(handle, ...)
|
|
||||||
#define vl_printfun
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_printfun
|
|
||||||
|
|
||||||
/* Get the API version number. */
|
|
||||||
#define vl_api_version(n,v) static u32 api_version=(v);
|
|
||||||
#include <" plugin-name "/" plugin-name "_all_api_h.h>
|
|
||||||
#undef vl_api_version
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -82,36 +63,6 @@ typedef struct
|
|||||||
|
|
||||||
" plugin-name "_test_main_t " plugin-name "_test_main;
|
" plugin-name "_test_main_t " plugin-name "_test_main;
|
||||||
|
|
||||||
#define __plugin_msg_base " plugin-name"_test_main.msg_id_base
|
|
||||||
#include <vlibapi/vat_helper_macros.h>
|
|
||||||
|
|
||||||
#define foreach_standard_reply_retval_handler \\
|
|
||||||
_(" plugin-name "_enable_disable_reply)
|
|
||||||
|
|
||||||
#define _(n) \\
|
|
||||||
static void vl_api_##n##_t_handler \\
|
|
||||||
(vl_api_##n##_t * mp) \\
|
|
||||||
{ \\
|
|
||||||
vat_main_t * vam = " plugin-name "_test_main.vat_main; \\
|
|
||||||
i32 retval = ntohl(mp->retval); \\
|
|
||||||
if (vam->async_mode) { \\
|
|
||||||
vam->async_errors += (retval < 0); \\
|
|
||||||
} else { \\
|
|
||||||
vam->retval = retval; \\
|
|
||||||
vam->result_ready = 1; \\
|
|
||||||
} \\
|
|
||||||
}
|
|
||||||
foreach_standard_reply_retval_handler;
|
|
||||||
#undef _
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Table of message reply handlers, must include boilerplate handlers
|
|
||||||
* we just generated
|
|
||||||
*/
|
|
||||||
#define foreach_vpe_api_reply_msg \\
|
|
||||||
_(" PLUGIN-NAME "_ENABLE_DISABLE_REPLY, " plugin-name "_enable_disable_reply)
|
|
||||||
|
|
||||||
|
|
||||||
static int api_" plugin-name "_enable_disable (vat_main_t * vam)
|
static int api_" plugin-name "_enable_disable (vat_main_t * vam)
|
||||||
{
|
{
|
||||||
unformat_input_t * i = vam->input;
|
unformat_input_t * i = vam->input;
|
||||||
@ -153,39 +104,10 @@ static int api_" plugin-name "_enable_disable (vat_main_t * vam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of messages that the api test plugin sends,
|
* List of messages that the " plugin-name" test plugin sends,
|
||||||
* and that the data plane plugin processes
|
* and that the data plane plugin processes
|
||||||
*/
|
*/
|
||||||
#define foreach_vpe_api_msg \\
|
#include <" plugin-name "/" plugin-name ".api_test.c>
|
||||||
_(" plugin-name "_enable_disable, \"<intfc> [disable]\")
|
|
||||||
|
|
||||||
static void " plugin-name "_api_hookup (vat_main_t *vam)
|
|
||||||
{
|
|
||||||
" plugin-name "_test_main_t * " main-p " = &" plugin-name "_test_main;
|
|
||||||
/* Hook up handlers for replies from the data plane plug-in */
|
|
||||||
#define _(N,n) \\
|
|
||||||
vl_msg_api_set_handlers((VL_API_##N + " main-p "->msg_id_base), \\
|
|
||||||
#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_reply_msg;
|
|
||||||
#undef _
|
|
||||||
|
|
||||||
/* API messages we can send */
|
|
||||||
#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
|
|
||||||
foreach_vpe_api_msg;
|
|
||||||
#undef _
|
|
||||||
|
|
||||||
/* Help strings */
|
|
||||||
#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
|
|
||||||
foreach_vpe_api_msg;
|
|
||||||
#undef _
|
|
||||||
}
|
|
||||||
|
|
||||||
VAT_PLUGIN_REGISTER(" plugin-name");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fd.io coding-style-patch-verification: " capital-oh-en "
|
* fd.io coding-style-patch-verification: " capital-oh-en "
|
||||||
|
@ -32,14 +32,10 @@
|
|||||||
(skel-plugin-cmakelists-text-fragment)
|
(skel-plugin-cmakelists-text-fragment)
|
||||||
(find-file (concat plugin-name ".api"))
|
(find-file (concat plugin-name ".api"))
|
||||||
(skel-plugin-api)
|
(skel-plugin-api)
|
||||||
(find-file (concat plugin-name "_all_api_h.h"))
|
|
||||||
(skel-plugin-all-apih)
|
|
||||||
(find-file (concat plugin-name ".h"))
|
(find-file (concat plugin-name ".h"))
|
||||||
(skel-plugin-h)
|
(skel-plugin-h)
|
||||||
(find-file (concat plugin-name ".c"))
|
(find-file (concat plugin-name ".c"))
|
||||||
(skel-plugin-main)
|
(skel-plugin-main)
|
||||||
(find-file (concat plugin-name "_msg_enum.h"))
|
|
||||||
(skel-plugin-msg-enum)
|
|
||||||
(find-file "node.c")
|
(find-file "node.c")
|
||||||
(if (string= plugin-flavor "qs")
|
(if (string= plugin-flavor "qs")
|
||||||
(skel-plugin-qsnode) (skel-plugin-node))
|
(skel-plugin-qsnode) (skel-plugin-node))
|
||||||
@ -50,4 +46,3 @@
|
|||||||
(find-file "setup.pg")
|
(find-file "setup.pg")
|
||||||
(skel-plugin-setup)
|
(skel-plugin-setup)
|
||||||
(cd start-dir))))
|
(cd start-dir))))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user