aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/emacs/all-skel.el2
-rw-r--r--extras/emacs/plugin-all-apih-skel.el43
-rw-r--r--extras/emacs/plugin-cmake-skel.el10
-rw-r--r--extras/emacs/plugin-main-skel.el76
-rw-r--r--extras/emacs/plugin-msg-enum-skel.el55
-rw-r--r--extras/emacs/plugin-test-skel.el94
-rw-r--r--extras/emacs/plugin.el7
7 files changed, 17 insertions, 270 deletions
diff --git a/extras/emacs/all-skel.el b/extras/emacs/all-skel.el
index d5f23429b00..85cc8470c1e 100644
--- a/extras/emacs/all-skel.el
+++ b/extras/emacs/all-skel.el
@@ -22,12 +22,10 @@
(load-file "./dual-loop-skel.el")
(load-file "./periodic-skel.el")
(load-file "./pipe-skel.el")
-(load-file "./plugin-all-apih-skel.el")
(load-file "./plugin-cmake-skel.el")
(load-file "./plugin-api-skel.el")
(load-file "./plugin-h-skel.el")
(load-file "./plugin-main-skel.el")
-(load-file "./plugin-msg-enum-skel.el")
(load-file "./plugin-node-skel.el")
(load-file "./plugin-qsnode-skel.el")
(load-file "./plugin-test-skel.el")
diff --git a/extras/emacs/plugin-all-apih-skel.el b/extras/emacs/plugin-all-apih-skel.el
deleted file mode 100644
index 0f073f9cbfe..00000000000
--- a/extras/emacs/plugin-all-apih-skel.el
+++ /dev/null
@@ -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>
-")
diff --git a/extras/emacs/plugin-cmake-skel.el b/extras/emacs/plugin-cmake-skel.el
index 4ea82dadf3b..1555dfd0f91 100644
--- a/extras/emacs/plugin-cmake-skel.el
+++ b/extras/emacs/plugin-cmake-skel.el
@@ -38,21 +38,17 @@ nil
add_vpp_plugin("plugin-name"
SOURCES
- " plugin-name ".c
- node.c
+ " plugin-name ".c
+ node.c
" plugin-name "_periodic.c
" plugin-name ".h
MULTIARCH_SOURCES
- node.c
+ node.c
API_FILES
" plugin-name".api
- INSTALL_HEADERS
- " plugin-name "_all_api_h.h
- " plugin-name "_msg_enum.h
-
API_TEST_SOURCES
" plugin-name "_test.c
)
diff --git a/extras/emacs/plugin-main-skel.el b/extras/emacs/plugin-main-skel.el
index 632a1329c2d..e8969c85488 100644
--- a/extras/emacs/plugin-main-skel.el
+++ b/extras/emacs/plugin-main-skel.el
@@ -49,40 +49,14 @@ nil
#include <vpp/app/version.h>
#include <stdbool.h>
-/* define message IDs */
-#include <" plugin-name "/" plugin-name "_msg_enum.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
+#include <" plugin-name "/" plugin-name ".api_enum.h>
+#include <" plugin-name "/" plugin-name ".api_types.h>
#define REPLY_MSG_ID_BASE " main-p "->msg_id_base
#include <vlibapi/api_helper_macros.h>
" 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 */
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);
}
-/* Set up the API message handling tables */
-static clib_error_t *
-" 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 _
-}
+/* API definitions */
+#include <" plugin-name "/" plugin-name ".api.c>
static clib_error_t * " plugin-name "_init (vlib_main_t * vm)
{
" plugin-name "_main_t * " main-p " = &" plugin-name "_main;
clib_error_t * error = 0;
- u8 * name;
" main-p "->vlib_main = vm;
" 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 */
- setup_message_id_table (" main-p ", &api_main);
-
- vec_free(name);
+ " main-p "->msg_id_base = setup_message_id_table ();
return error;
}
diff --git a/extras/emacs/plugin-msg-enum-skel.el b/extras/emacs/plugin-msg-enum-skel.el
deleted file mode 100644
index c44af051982..00000000000
--- a/extras/emacs/plugin-msg-enum-skel.el
+++ /dev/null
@@ -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 */
-")
diff --git a/extras/emacs/plugin-test-skel.el b/extras/emacs/plugin-test-skel.el
index 42962acf2b7..fee34bfe402 100644
--- a/extras/emacs/plugin-test-skel.el
+++ b/extras/emacs/plugin-test-skel.el
@@ -24,7 +24,7 @@ nil
'(setq capital-oh-en "ON")
'(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>
* Licensed under the Apache License, Version 2.0 (the \"License\");
@@ -45,33 +45,14 @@ nil
#include <vppinfra/error.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);
/* Declare message IDs */
-#include <" plugin-name "/" plugin-name "_msg_enum.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
-
+#include <" plugin-name "/" plugin-name ".api_enum.h>
+#include <" plugin-name "/" plugin-name ".api_types.h>
typedef struct
{
@@ -82,36 +63,6 @@ typedef struct
" 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)
{
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
*/
-#define foreach_vpe_api_msg \\
-_(" 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");
+#include <" plugin-name "/" plugin-name ".api_test.c>
/*
* fd.io coding-style-patch-verification: " capital-oh-en "
diff --git a/extras/emacs/plugin.el b/extras/emacs/plugin.el
index 4d7333c5051..42591c4b6f5 100644
--- a/extras/emacs/plugin.el
+++ b/extras/emacs/plugin.el
@@ -21,7 +21,7 @@
(makunbound 'PLUGIN-NAME)
(makunbound 'plugin-flavor)
(setq plugin-name (read-string "Plugin name: "))
- (setq plugin-flavor
+ (setq plugin-flavor
(read-string "Dispatch type [dual or qs]: "))
(setq PLUGIN-NAME (upcase plugin-name))
(setq cmd-args (concat "mkdir -p " plugin-name))
@@ -32,14 +32,10 @@
(skel-plugin-cmakelists-text-fragment)
(find-file (concat plugin-name ".api"))
(skel-plugin-api)
- (find-file (concat plugin-name "_all_api_h.h"))
- (skel-plugin-all-apih)
(find-file (concat plugin-name ".h"))
(skel-plugin-h)
(find-file (concat plugin-name ".c"))
(skel-plugin-main)
- (find-file (concat plugin-name "_msg_enum.h"))
- (skel-plugin-msg-enum)
(find-file "node.c")
(if (string= plugin-flavor "qs")
(skel-plugin-qsnode) (skel-plugin-node))
@@ -50,4 +46,3 @@
(find-file "setup.pg")
(skel-plugin-setup)
(cd start-dir))))
-