aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-08-10 16:22:48 -0400
committerDave Barach <openvpp@barachs.net>2018-08-11 00:07:10 +0000
commitd7a37a75625dd5f09cdb99e0de6e40b49dd9a0d0 (patch)
treee2a4c5cd4aa7b90b90cb5bd28099731bbca11017 /extras
parent7eb9d9608b5b47b95f4860b2c470411658f7cdac (diff)
emacs skeletons: add quad/single, avx2/avx512 support
Change-Id: Ib8095ad69620308d6199ab030a754ee45f92e59b Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'extras')
-rw-r--r--extras/emacs/all-skel.el2
-rw-r--r--extras/emacs/plugin-am-skel.el30
-rw-r--r--extras/emacs/plugin-node-skel.el14
-rw-r--r--extras/emacs/plugin-qsnode-skel.el236
-rw-r--r--extras/emacs/plugin-setup-skel.el45
-rw-r--r--extras/emacs/plugin.el8
6 files changed, 329 insertions, 6 deletions
diff --git a/extras/emacs/all-skel.el b/extras/emacs/all-skel.el
index 1ab20c5466d..460e88218cf 100644
--- a/extras/emacs/all-skel.el
+++ b/extras/emacs/all-skel.el
@@ -29,8 +29,10 @@
(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")
(load-file "./plugin-periodic-skel.el")
+(load-file "./plugin-setup-skel.el")
(load-file "./tunnel-c-skel.el")
(load-file "./tunnel-decap-skel.el")
(load-file "./tunnel-encap-skel.el")
diff --git a/extras/emacs/plugin-am-skel.el b/extras/emacs/plugin-am-skel.el
index 0a218e2f00e..650d27c5e0f 100644
--- a/extras/emacs/plugin-am-skel.el
+++ b/extras/emacs/plugin-am-skel.el
@@ -37,6 +37,7 @@ nil
vppapitestplugins_LTLIBRARIES += " plugin-name "_test_plugin.la
vppplugins_LTLIBRARIES += " plugin-name "_plugin.la
+" plugin-name "_plugin_la_LIBADD =
" plugin-name "_plugin_la_SOURCES = \\
" plugin-name "/node.c \\
@@ -57,5 +58,32 @@ nobase_apiinclude_HEADERS += \\
" plugin-name "/" plugin-name "_test.c \\
" plugin-name "/" plugin-name ".api.h
-# vi:syntax=automake
+if CPU_X86_64
+ " plugin-name "_multiversioning_sources = \\
+ " plugin-name "/node.c
+
+if CC_SUPPORTS_AVX2
+###############################################################
+# AVX2
+###############################################################
+lib" plugin-name "_plugin_avx2_la_SOURCES = $(" plugin-name "_multiversioning_sources)
+lib" plugin-name "_plugin_avx2_la_CFLAGS = \\
+ $(AM_CFLAGS) @CPU_AVX2_FLAGS@ \\
+ -DCLIB_MARCH_VARIANT=avx2
+noinst_LTLIBRARIES += lib" plugin-name "_plugin_avx2.la
+" plugin-name "_plugin_la_LIBADD += lib" plugin-name "_plugin_avx2.la
+endif
+
+if CC_SUPPORTS_AVX512
+###############################################################
+# AVX512
+###############################################################
+lib" plugin-name "_plugin_avx512_la_SOURCES = $(" plugin-name "_multiversioning_sources)
+lib" plugin-name "_plugin_avx512_la_CFLAGS = \\
+ $(AM_CFLAGS) @CPU_AVX512_FLAGS@ \\
+ -DCLIB_MARCH_VARIANT=avx512
+noinst_LTLIBRARIES += lib" plugin-name "_plugin_avx512.la
+" plugin-name "_plugin_la_LIBADD += lib" plugin-name "_plugin_avx512.la
+endif
+endif
")
diff --git a/extras/emacs/plugin-node-skel.el b/extras/emacs/plugin-node-skel.el
index 167519aa266..1c4b0a072b1 100644
--- a/extras/emacs/plugin-node-skel.el
+++ b/extras/emacs/plugin-node-skel.el
@@ -52,6 +52,7 @@ typedef struct
u8 new_dst_mac[6];
} " plugin-name "_trace_t;
+#ifndef CLIB_MARCH_VARIANT
static u8 *
format_mac_address (u8 * s, va_list * args)
{
@@ -74,6 +75,7 @@ static u8 * format_" plugin-name "_trace (u8 * s, va_list * args)
format_mac_address, t->new_dst_mac);
return s;
}
+#endif /* CLIB_MARCH_VARIANT */
vlib_node_registration_t " plugin-name "_node;
@@ -87,11 +89,14 @@ typedef enum {
" PLUGIN-NAME "_N_ERROR,
} " plugin-name "_error_t;
-static char * " plugin-name "_error_strings[] = {
+#ifndef CLIB_MARCH_VARIANT
+static char * " plugin-name "_error_strings[] =
+{
#define _(sym,string) string,
foreach_" plugin-name "_error
#undef _
};
+#endif /* CLIB_MARCH_VARIANT */
typedef enum
{
@@ -107,8 +112,8 @@ _(3) \\
_(4) \\
_(5)
-static uword
-" plugin-name "_node_fn (vlib_main_t * vm,
+
+VLIB_NODE_FN (" plugin-name "_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
@@ -301,9 +306,9 @@ static uword
}
/* *INDENT-OFF* */
+#ifndef CLIB_MARCH_VARIANT
VLIB_REGISTER_NODE (" plugin-name "_node) =
{
- .function = " plugin-name "_node_fn,
.name = \"" plugin-name "\",
.vector_size = sizeof (u32),
.format_trace = format_" plugin-name "_trace,
@@ -319,6 +324,7 @@ VLIB_REGISTER_NODE (" plugin-name "_node) =
[" PLUGIN-NAME "_NEXT_INTERFACE_OUTPUT] = \"interface-output\",
},
};
+#endif /* CLIB_MARCH_VARIANT */
/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: " capital-oh-en "
diff --git a/extras/emacs/plugin-qsnode-skel.el b/extras/emacs/plugin-qsnode-skel.el
new file mode 100644
index 00000000000..d3fc908bbea
--- /dev/null
+++ b/extras/emacs/plugin-qsnode-skel.el
@@ -0,0 +1,236 @@
+;;; plugin-node-skel.el - vpp engine plug-in "node.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-qsnode
+"Insert a plug-in 'node.c' skeleton "
+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>
+ * 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 <vlib/vlib.h>
+#include <vnet/vnet.h>
+#include <vnet/pg/pg.h>
+#include <vppinfra/error.h>
+#include <" plugin-name "/" plugin-name ".h>
+
+typedef struct
+{
+ u32 sw_if_index;
+ u32 next_index;
+} " plugin-name "_trace_t;
+
+#ifndef CLIB_MARCH_VARIANT
+
+/* packet trace format function */
+static u8 * format_" plugin-name "_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ " plugin-name "_trace_t * t = va_arg (*args, " plugin-name "_trace_t *);
+
+ s = format (s, \"" PLUGIN-NAME ": sw_if_index %d, next index %d\\n\",
+ t->sw_if_index, t->next_index);
+ return s;
+}
+#endif /* CLIB_MARCH_VARIANT */
+
+vlib_node_registration_t " plugin-name "_node;
+
+#define foreach_" plugin-name "_error \\
+_(SWAPPED, \"Mac swap packets processed\")
+
+typedef enum
+{
+#define _(sym,str) " PLUGIN-NAME "_ERROR_##sym,
+ foreach_" plugin-name "_error
+#undef _
+ " PLUGIN-NAME "_N_ERROR,
+} " plugin-name "_error_t;
+
+#ifndef CLIB_MARCH_VARIANT
+static char * " plugin-name "_error_strings[] =
+{
+#define _(sym,string) string,
+ foreach_" plugin-name "_error
+#undef _
+};
+#endif /* CLIB_MARCH_VARIANT */
+
+typedef enum
+{
+ " PLUGIN-NAME "_NEXT_DROP,
+ " PLUGIN-NAME "_N_NEXT,
+} " plugin-name "_next_t;
+
+always_inline uword
+"plugin-name"_inline (vlib_main_t * vm,
+ vlib_node_runtime_t * node, vlib_frame_t * frame,
+ int is_ip4, int is_trace)
+{
+ u32 n_left_from, *from;
+ vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
+ u16 nexts[VLIB_FRAME_SIZE], *next;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+
+ vlib_get_buffers (vm, from, bufs, n_left_from);
+ b = bufs;
+ next = nexts;
+
+ while (n_left_from >= 4)
+ {
+ /* Prefetch next iteration. */
+ if (PREDICT_TRUE (n_left_from >= 8))
+ {
+ vlib_prefetch_buffer_header (b[4], STORE);
+ vlib_prefetch_buffer_header (b[5], STORE);
+ vlib_prefetch_buffer_header (b[6], STORE);
+ vlib_prefetch_buffer_header (b[7], STORE);
+ CLIB_PREFETCH (b[4]->data, CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b[5]->data, CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b[6]->data, CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b[7]->data, CLIB_CACHE_LINE_BYTES, STORE);
+ }
+
+ /* $$$$ process 4x pkts right here */
+ next[0] = 0;
+ next[1] = 0;
+ next[2] = 0;
+ next[3] = 0;
+
+ if (is_trace)
+ {
+ if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ "plugin-name"_trace_t *t =
+ vlib_add_trace (vm, node, b[0], sizeof (*t));
+ t->next_index = next[0];
+ t->sw_if_index = vnet_buffer(b[0])->sw_if_index[VLIB_RX];
+ }
+ if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ "plugin-name"_trace_t *t =
+ vlib_add_trace (vm, node, b[1], sizeof (*t));
+ t->next_index = next[1];
+ t->sw_if_index = vnet_buffer(b[1])->sw_if_index[VLIB_RX];
+ }
+ if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ "plugin-name"_trace_t *t =
+ vlib_add_trace (vm, node, b[2], sizeof (*t));
+ t->next_index = next[2];
+ t->sw_if_index = vnet_buffer(b[2])->sw_if_index[VLIB_RX];
+ }
+ if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ "plugin-name"_trace_t *t =
+ vlib_add_trace (vm, node, b[3], sizeof (*t));
+ t->next_index = next[3];
+ t->sw_if_index = vnet_buffer(b[3])->sw_if_index[VLIB_RX];
+ }
+ }
+
+ b += 4;
+ next += 4;
+ n_left_from -= 4;
+ }
+
+ while (n_left_from > 0)
+ {
+
+ /* $$$$ process 1 pkt right here */
+ next[0] = 0;
+
+ if (is_trace)
+ {
+ if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ "plugin-name"_trace_t *t =
+ vlib_add_trace (vm, node, b[0], sizeof (*t));
+ t->next_index = next[0];
+ t->sw_if_index = vnet_buffer(b[0])->sw_if_index[VLIB_RX];
+ }
+ }
+
+ b += 1;
+ next += 1;
+ n_left_from -= 1;
+ }
+
+ vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
+
+ return frame->n_vectors;
+}
+
+VLIB_NODE_FN ("plugin-name"_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
+ return " plugin-name "_inline (vm, node, frame, 1 /* is_ip4 */ ,
+ 1 /* is_trace */ );
+ else
+ return " plugin-name "_inline (vm, node, frame, 1 /* is_ip4 */ ,
+ 0 /* is_trace */ );
+}
+
+/* *INDENT-OFF* */
+#ifndef CLIB_MARCH_VARIANT
+VLIB_REGISTER_NODE (" plugin-name "_node) =
+{
+ .name = \"" plugin-name "\",
+ .vector_size = sizeof (u32),
+ .format_trace = format_" plugin-name "_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+
+ .n_errors = ARRAY_LEN(" plugin-name "_error_strings),
+ .error_strings = " plugin-name "_error_strings,
+
+ .n_next_nodes = " PLUGIN-NAME "_N_NEXT,
+
+ /* edit / add dispositions here */
+ .next_nodes = {
+ [" PLUGIN-NAME "_NEXT_DROP] = \"error-drop\",
+ },
+};
+#endif /* CLIB_MARCH_VARIANT */
+/* *INDENT-ON* */
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
+")
diff --git a/extras/emacs/plugin-setup-skel.el b/extras/emacs/plugin-setup-skel.el
new file mode 100644
index 00000000000..9ff2a7b9427
--- /dev/null
+++ b/extras/emacs/plugin-setup-skel.el
@@ -0,0 +1,45 @@
+;;; plugin-setup-skel.el - debug CLI + pg setup
+;;;
+;;; 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.
+
+(require 'skeleton)
+
+(define-skeleton skel-plugin-setup
+"Insert a debug cli / pg skeleton "
+nil
+'(if (not (boundp 'plugin-name))
+ (setq plugin-name (read-string "Plugin name: ")))
+'(setq PLUGIN-NAME (upcase plugin-name))
+'(setq capital-oh-en "ON")
+"
+comment { simple debug CLI setup script w/ packet generator test vector }
+set term page off
+loop create
+set int ip address loop0 192.168.1.1/24
+set int state loop0 up
+
+comment { Packet generator script. Src MAC 00:de:ad:be:ef:01 }
+comment { Dst mac 01:ba:db:ab:be:01 ethtype 0800 }
+packet-generator new {
+ name simple
+ limit 1
+ size 128-128
+ interface loop0
+ node " plugin-name "
+ data {
+ hex 0x00deadbeef0001badbabbe010800
+ incrementing 30
+ }
+}
+")
diff --git a/extras/emacs/plugin.el b/extras/emacs/plugin.el
index bf6e123bc86..1481c66dfa8 100644
--- a/extras/emacs/plugin.el
+++ b/extras/emacs/plugin.el
@@ -19,7 +19,10 @@
(setq start-dir default-directory)
(makunbound 'plugin-name)
(makunbound 'PLUGIN-NAME)
+ (makunbound 'plugin-flavor)
(setq plugin-name (read-string "Plugin name: "))
+ (setq plugin-flavor
+ (read-string "Dispatch type [dual or qs]: "))
(setq PLUGIN-NAME (upcase plugin-name))
(find-file (concat plugin-name ".am"))
(skel-plugin-makefile-am-fragment)
@@ -38,10 +41,13 @@
(find-file (concat plugin-name "_msg_enum.h"))
(skel-plugin-msg-enum)
(find-file "node.c")
- (skel-plugin-node)
+ (if (string= plugin-flavor "qs")
+ (skel-plugin-qsnode) (skel-plugin-node))
(find-file (concat plugin-name "_test.c"))
(skel-plugin-test)
(find-file (concat plugin-name "_periodic.c"))
(skel-plugin-periodic)
+ (find-file "setup.pg")
+ (skel-plugin-setup)
(cd start-dir))))