aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples/sample-plugin/sample
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-09-12 12:12:36 +0200
committerDave Barach <openvpp@barachs.net>2018-09-12 17:04:36 +0000
commit0fa900e482451d05449501c1422bfa7c47eec661 (patch)
treec9f17a9fa246221aec040d334ef0ae52143768b5 /src/examples/sample-plugin/sample
parent79dcbc74cd417f4caf41bc398ccba94cab7d656b (diff)
cmake: create cmake VPP module, update sample-plugin so it uses it
Change-Id: I32e91ba8e55797ffe169f98b09bdb42caa5c7de2 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/examples/sample-plugin/sample')
-rw-r--r--src/examples/sample-plugin/sample/CMakeLists.txt32
-rw-r--r--src/examples/sample-plugin/sample/node.c20
2 files changed, 39 insertions, 13 deletions
diff --git a/src/examples/sample-plugin/sample/CMakeLists.txt b/src/examples/sample-plugin/sample/CMakeLists.txt
new file mode 100644
index 00000000000..f2fc1434492
--- /dev/null
+++ b/src/examples/sample-plugin/sample/CMakeLists.txt
@@ -0,0 +1,32 @@
+# 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_directories(${CMAKE_SOURCE_DIR})
+
+# for generated API headers:
+include_directories(${CMAKE_BINARY_DIR})
+
+add_vpp_plugin(sample
+ SOURCES
+ node.c
+ sample.c
+
+ MULTIARCH_SOURCES
+ node.c
+
+ API_FILES
+ sample.api
+
+ API_TEST_SOURCES
+ sample_test.c
+)
diff --git a/src/examples/sample-plugin/sample/node.c b/src/examples/sample-plugin/sample/node.c
index 7f34be56168..009968b6099 100644
--- a/src/examples/sample-plugin/sample/node.c
+++ b/src/examples/sample-plugin/sample/node.c
@@ -45,7 +45,7 @@ format_sample_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t sample_node;
+extern vlib_node_registration_t sample_node;
#define foreach_sample_error \
_(SWAPPED, "Mac swap packets processed")
@@ -87,9 +87,8 @@ _(3) \
_(4) \
_(5)
-static uword
-sample_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (sample_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
sample_next_t next_index;
@@ -285,9 +284,8 @@ sample_node_fn (vlib_main_t * vm,
* Node costs about 17 clocks/pkt at a vector size of 26
*/
#ifdef VERSION_2
-static uword
-sample_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (sample_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
sample_next_t next_index;
@@ -475,9 +473,8 @@ sample_node_fn (vlib_main_t * vm,
/* This would normally be a stack local, but since it's a constant... */
static const u16 nexts[VLIB_FRAME_SIZE] = { 0 };
-static uword
-sample_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (sample_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from;
u32 pkts_swapped = 0;
@@ -605,7 +602,6 @@ sample_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (sample_node) =
{
- .function = sample_node_fn,
.name = "sample",
.vector_size = sizeof (u32),
.format_trace = format_sample_trace,
@@ -623,8 +619,6 @@ VLIB_REGISTER_NODE (sample_node) =
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (sample_node, sample_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*