summaryrefslogtreecommitdiffstats
path: root/build-root/emacs-lisp
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-02-10 11:57:46 -0500
committerDave Barach <dave@barachs.net>2017-02-10 15:05:19 -0500
commitfed79e83910459ed700615d2a5a24024f835a66c (patch)
tree6244c857d9858a73d41a66779a9ed0070c053305 /build-root/emacs-lisp
parentb91017a30b3a2034c47008e7bcfe7bda49fe7c57 (diff)
Update plugin templates
Disguise the string "fd.io coding-style blah blah blah" to avoid spurious checkstyle failures on the emacs lisp code. DGMS. Change-Id: I6b88d9588dff7d67c6e509052ae4f32529684de7 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'build-root/emacs-lisp')
-rw-r--r--build-root/emacs-lisp/plugin-main-skel.el78
-rw-r--r--build-root/emacs-lisp/plugin-node-skel.el24
-rw-r--r--build-root/emacs-lisp/plugin-test-skel.el122
3 files changed, 106 insertions, 118 deletions
diff --git a/build-root/emacs-lisp/plugin-main-skel.el b/build-root/emacs-lisp/plugin-main-skel.el
index 90b98949e83..46615c311c7 100644
--- a/build-root/emacs-lisp/plugin-main-skel.el
+++ b/build-root/emacs-lisp/plugin-main-skel.el
@@ -21,8 +21,8 @@ nil
'(if (not (boundp 'plugin-name))
(setq plugin-name (read-string "Plugin name: ")))
'(setq PLUGIN-NAME (upcase plugin-name))
-"
-/*
+'(setq capital-oh-en "ON")
+"/*
* " plugin-name ".c - skeleton vpp engine plug-in
*
* Copyright (c) <current-year> <your-organization>
@@ -46,6 +46,7 @@ nil
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
+#include <vpp/app/version.h>
/* define message IDs */
#include <" plugin-name "/" plugin-name "_msg_enum.h>
@@ -100,27 +101,6 @@ do { \\
#define foreach_" plugin-name "_plugin_api_msg \\
_(" PLUGIN-NAME "_ENABLE_DISABLE, " plugin-name "_enable_disable)
-/*
- * This routine exists to convince the vlib plugin framework that
- * we haven't accidentally copied a random .dll into the plugin directory.
- *
- * Also collects global variable pointers passed from the vpp engine
- */
-
-clib_error_t *
-vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h,
- int from_early_init)
-{
- " plugin-name "_main_t * sm = &" plugin-name "_main;
- clib_error_t * error = 0;
-
- sm->vlib_main = vm;
- sm->vnet_main = h->vnet_main;
- sm->ethernet_main = h->ethernet_main;
-
- return error;
-}
-
/* Action function shared between message handler and debug CLI */
int " plugin-name "_enable_disable (" plugin-name "_main_t * sm, u32 sw_if_index,
@@ -156,14 +136,15 @@ static clib_error_t *
int rv;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
- if (unformat (input, \"disable\"))
- enable_disable = 0;
- else if (unformat (input, \"%U\", unformat_vnet_sw_interface,
- sm->vnet_main, &sw_if_index))
- ;
- else
- break;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, \"disable\"))
+ enable_disable = 0;
+ else if (unformat (input, \"%U\", unformat_vnet_sw_interface,
+ sm->vnet_main, &sw_if_index))
+ ;
+ else
+ break;
}
if (sw_if_index == ~0)
@@ -171,7 +152,8 @@ static clib_error_t *
rv = " plugin-name "_enable_disable (sm, sw_if_index, enable_disable);
- switch(rv) {
+ switch(rv)
+ {
case 0:
break;
@@ -187,16 +169,19 @@ static clib_error_t *
default:
return clib_error_return (0, \"" plugin-name "_enable_disable returned %d\",
rv);
- }
+ }
return 0;
}
-VLIB_CLI_COMMAND (" plugin-name "_enable_disable_command, static) = {
- .path = \"" plugin-name " enable-disable\",
- .short_help =
- \"" plugin-name " enable-disable <interface-name> [disable]\",
- .function = " plugin-name "_enable_disable_command_fn,
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (" plugin-name "_enable_disable_command, static) =
+{
+ .path = \"" plugin-name " enable-disable\",
+ .short_help =
+ \"" plugin-name " enable-disable <interface-name> [disable]\",
+ .function = " plugin-name "_enable_disable_command_fn,
};
+/* *INDENT-ON* */
/* API message handler */
static void vl_api_" plugin-name "_enable_disable_t_handler
@@ -268,11 +253,28 @@ static clib_error_t * " plugin-name "_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (" plugin-name "_init);
+/* *INDENT-OFF* */
VNET_FEATURE_INIT (" plugin-name ", static) =
{
.arc_name = \"device-input\",
.node_name = \"" plugin-name "\",
.runs_before = VNET_FEATURES (\"ethernet-input\"),
};
+/* *INDENT-ON */
+
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () =
+{
+ .version = VPP_BUILD_VER,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
")
diff --git a/build-root/emacs-lisp/plugin-node-skel.el b/build-root/emacs-lisp/plugin-node-skel.el
index ee745c35326..167519aa266 100644
--- a/build-root/emacs-lisp/plugin-node-skel.el
+++ b/build-root/emacs-lisp/plugin-node-skel.el
@@ -21,8 +21,8 @@ nil
'(if (not (boundp 'plugin-name))
(setq plugin-name (read-string "Plugin name: ")))
'(setq PLUGIN-NAME (upcase plugin-name))
-"
-/*
+'(setq capital-oh-en "ON")
+"/*
* node.c - skeleton vpp engine plug-in dual-loop node skeleton
*
* Copyright (c) <current-year> <your-organization>
@@ -44,7 +44,8 @@ nil
#include <vppinfra/error.h>
#include <" plugin-name "/" plugin-name ".h>
-typedef struct {
+typedef struct
+{
u32 next_index;
u32 sw_if_index;
u8 new_src_mac[6];
@@ -92,7 +93,8 @@ static char * " plugin-name "_error_strings[] = {
#undef _
};
-typedef enum {
+typedef enum
+{
" PLUGIN-NAME "_NEXT_INTERFACE_OUTPUT,
" PLUGIN-NAME "_N_NEXT,
} " plugin-name "_next_t;
@@ -187,8 +189,6 @@ static uword
foreach_mac_address_offset;
#undef _
-
-
sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
@@ -300,7 +300,9 @@ static uword
return frame->n_vectors;
}
-VLIB_REGISTER_NODE (" plugin-name "_node) = {
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (" plugin-name "_node) =
+{
.function = " plugin-name "_node_fn,
.name = \"" plugin-name "\",
.vector_size = sizeof (u32),
@@ -317,4 +319,12 @@ VLIB_REGISTER_NODE (" plugin-name "_node) = {
[" PLUGIN-NAME "_NEXT_INTERFACE_OUTPUT] = \"interface-output\",
},
};
+/* *INDENT-ON* */
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
")
diff --git a/build-root/emacs-lisp/plugin-test-skel.el b/build-root/emacs-lisp/plugin-test-skel.el
index b546747f522..2f8121a8226 100644
--- a/build-root/emacs-lisp/plugin-test-skel.el
+++ b/build-root/emacs-lisp/plugin-test-skel.el
@@ -21,8 +21,8 @@ nil
'(if (not (boundp 'plugin-name))
(setq plugin-name (read-string "Plugin name: ")))
'(setq PLUGIN-NAME (upcase plugin-name))
-"
-/*
+'(setq capital-oh-en "ON")
+"/*
* " plugin-name ".c - skeleton vpp-api-test plug-in
*
* Copyright (c) <current-year> <your-organization>
@@ -72,14 +72,18 @@ uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
#undef vl_api_version
-typedef struct {
- /* API message ID base */
- u16 msg_id_base;
- vat_main_t *vat_main;
+typedef struct
+{
+ /* API message ID base */
+ u16 msg_id_base;
+ vat_main_t *vat_main;
} " plugin-name "_test_main_t;
" 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)
@@ -107,79 +111,44 @@ foreach_standard_reply_retval_handler;
_(" PLUGIN-NAME "_ENABLE_DISABLE_REPLY, " plugin-name "_enable_disable_reply)
-/* M: construct, but don't yet send a message */
-
-#define M(T, mp) \\
-do { \\
- vam->result_ready = 0; \\
- mp = vl_msg_api_alloc(sizeof(*mp)); \\
- memset (mp, 0, sizeof (*mp)); \\
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \\
- mp->client_index = vam->my_client_index; \\
-} while(0);
-
-#define M2(T, mp, n) \\
-do { \\
- vam->result_ready = 0; \\
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \\
- memset (mp, 0, sizeof (*mp)); \\
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \\
- mp->client_index = vam->my_client_index; \\
-} while(0);
-
-/* S: send a message */
-#define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \\
-do { \\
- f64 timeout = vat_time_now (vam) + 1.0; \\
- \\
- while (vat_time_now (vam) < timeout) { \\
- if (vam->result_ready == 1) { \\
- return (vam->retval); \\
- } \\
- } \\
- return -99; \\
-} while(0);
-
static int api_" plugin-name "_enable_disable (vat_main_t * vam)
{
- " plugin-name "_test_main_t * sm = &" plugin-name "_test_main;
- unformat_input_t * i = vam->input;
- int enable_disable = 1;
- u32 sw_if_index = ~0;
- vl_api_" plugin-name "_enable_disable_t * mp;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
- if (unformat (i, \"%U\", unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, \"sw_if_index %d\", &sw_if_index))
- ;
- else if (unformat (i, \"disable\"))
- enable_disable = 0;
- else
- break;
+ unformat_input_t * i = vam->input;
+ int enable_disable = 1;
+ u32 sw_if_index = ~0;
+ vl_api_" plugin-name "_enable_disable_t * mp;
+ int ret;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, \"%U\", unformat_sw_if_index, vam, &sw_if_index))
+ ;
+ else if (unformat (i, \"sw_if_index %d\", &sw_if_index))
+ ;
+ else if (unformat (i, \"disable\"))
+ enable_disable = 0;
+ else
+ break;
}
-
- if (sw_if_index == ~0) {
- errmsg (\"missing interface name / explicit sw_if_index number \\n\");
- return -99;
+
+ if (sw_if_index == ~0)
+ {
+ errmsg (\"missing interface name / explicit sw_if_index number \\n\");
+ return -99;
}
-
- /* Construct the API message */
- M(" PLUGIN-NAME "_ENABLE_DISABLE, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable_disable = enable_disable;
+
+ /* Construct the API message */
+ M(" PLUGIN-NAME "_ENABLE_DISABLE, mp);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->enable_disable = enable_disable;
- /* send it... */
- S(mp);
+ /* send it... */
+ S(mp);
- /* Wait for a reply... */
- W (ret);
- return ret;
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
}
/*
@@ -233,4 +202,11 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
return 0;
}
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
")
="mi">64); } static inline void clib_mov128blocks (u8 * dst, const u8 * src, size_t n) { __m256i ymm0, ymm1, ymm2, ymm3; while (n >= 128) { ymm0 = _mm256_loadu_si256 ((const __m256i *) ((const u8 *) src + 0 * 32)); n -= 128; ymm1 = _mm256_loadu_si256 ((const __m256i *) ((const u8 *) src + 1 * 32)); ymm2 = _mm256_loadu_si256 ((const __m256i *) ((const u8 *) src + 2 * 32)); ymm3 = _mm256_loadu_si256 ((const __m256i *) ((const u8 *) src + 3 * 32)); src = (const u8 *) src + 128; _mm256_storeu_si256 ((__m256i *) ((u8 *) dst + 0 * 32), ymm0); _mm256_storeu_si256 ((__m256i *) ((u8 *) dst + 1 * 32), ymm1); _mm256_storeu_si256 ((__m256i *) ((u8 *) dst + 2 * 32), ymm2); _mm256_storeu_si256 ((__m256i *) ((u8 *) dst + 3 * 32), ymm3); dst = (u8 *) dst + 128; } } static inline void * clib_memcpy (void *dst, const void *src, size_t n) { uword dstu = (uword) dst; uword srcu = (uword) src; void *ret = dst; size_t dstofss; size_t bits; /** * Copy less than 16 bytes */ if (n < 16) { if (n & 0x01) { *(u8 *) dstu = *(const u8 *) srcu; srcu = (uword) ((const u8 *) srcu + 1); dstu = (uword) ((u8 *) dstu + 1); } if (n & 0x02) { *(u16 *) dstu = *(const u16 *) srcu; srcu = (uword) ((const u16 *) srcu + 1); dstu = (uword) ((u16 *) dstu + 1); } if (n & 0x04) { *(u32 *) dstu = *(const u32 *) srcu; srcu = (uword) ((const u32 *) srcu + 1); dstu = (uword) ((u32 *) dstu + 1); } if (n & 0x08) { *(u64 *) dstu = *(const u64 *) srcu; } return ret; } /** * Fast way when copy size doesn't exceed 512 bytes */ if (n <= 32) { clib_mov16 ((u8 *) dst, (const u8 *) src); clib_mov16 ((u8 *) dst - 16 + n, (const u8 *) src - 16 + n); return ret; } if (n <= 48) { clib_mov16 ((u8 *) dst, (const u8 *) src); clib_mov16 ((u8 *) dst + 16, (const u8 *) src + 16); clib_mov16 ((u8 *) dst - 16 + n, (const u8 *) src - 16 + n); return ret; } if (n <= 64) { clib_mov32 ((u8 *) dst, (const u8 *) src); clib_mov32 ((u8 *) dst - 32 + n, (const u8 *) src - 32 + n); return ret; } if (n <= 256) { if (n >= 128) { n -= 128; clib_mov128 ((u8 *) dst, (const u8 *) src); src = (const u8 *) src + 128; dst = (u8 *) dst + 128; } COPY_BLOCK_128_BACK31: if (n >= 64) { n -= 64; clib_mov64 ((u8 *) dst, (const u8 *) src); src = (const u8 *) src + 64; dst = (u8 *) dst + 64; } if (n > 32) { clib_mov32 ((u8 *) dst, (const u8 *) src); clib_mov32 ((u8 *) dst - 32 + n, (const u8 *) src - 32 + n); return ret; } if (n > 0) { clib_mov32 ((u8 *) dst - 32 + n, (const u8 *) src - 32 + n); } return ret; } /** * Make store aligned when copy size exceeds 256 bytes */ dstofss = (uword) dst & 0x1F; if (dstofss > 0) { dstofss = 32 - dstofss; n -= dstofss; clib_mov32 ((u8 *) dst, (const u8 *) src); src = (const u8 *) src + dstofss; dst = (u8 *) dst + dstofss; } /** * Copy 128-byte blocks. */ clib_mov128blocks ((u8 *) dst, (const u8 *) src, n); bits = n; n = n & 127; bits -= n; src = (const u8 *) src + bits; dst = (u8 *) dst + bits; /** * Copy whatever left */ goto COPY_BLOCK_128_BACK31; } #endif /* included_clib_mamcpy_avx2_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */