node: add logging and null node
authorNithin Dabilpuram <ndabilpuram@marvell.com>
Sat, 11 Apr 2020 14:14:14 +0000 (19:44 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 5 May 2020 21:37:43 +0000 (23:37 +0200)
Add log infra for node specific logging.
Also, add null rte_node that just ignores all the objects
directed to it.

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
14 files changed:
MAINTAINERS
app/test/meson.build
config/common_base
doc/api/doxy-api.conf.in
lib/Makefile
lib/librte_node/Makefile [new file with mode: 0644]
lib/librte_node/log.c [new file with mode: 0644]
lib/librte_node/meson.build [new file with mode: 0644]
lib/librte_node/node_private.h [new file with mode: 0644]
lib/librte_node/null.c [new file with mode: 0644]
lib/librte_node/rte_node_version.map [new file with mode: 0644]
lib/meson.build
meson.build
mk/rte.app.mk

index 29c2781..9eb1365 100644 (file)
@@ -1478,6 +1478,11 @@ M: Kiran Kumar K <kirankumark@marvell.com>
 F: lib/librte_graph/
 F: app/test/test_graph*
 
+Nodes - EXPERIMENTAL
+M: Nithin Dabilpuram <ndabilpuram@marvell.com>
+M: Pavan Nikhilesh <pbhagavatula@marvell.com>
+F: lib/librte_node/
+
 
 Test Applications
 -----------------
index ddea25c..f8ed9d8 100644 (file)
@@ -156,6 +156,7 @@ test_deps = ['acl',
        'lpm',
        'member',
        'metrics',
+       'node',
        'pipeline',
        'port',
        'rawdev',
@@ -404,13 +405,15 @@ endforeach
 test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
+link_nodes = []
 if get_option('default_library') == 'static'
        link_libs = dpdk_drivers
+       link_nodes = dpdk_graph_nodes
 endif
 
 dpdk_test = executable('dpdk-test',
        test_sources,
-       link_whole: link_libs,
+       link_whole: link_libs + link_nodes,
        dependencies: test_dep_objs,
        c_args: cflags,
        install_rpath: driver_install_path,
index a792eff..ab4776a 100644 (file)
@@ -1094,6 +1094,11 @@ CONFIG_RTE_LIBRTE_GRAPH=y
 CONFIG_RTE_GRAPH_BURST_SIZE=256
 CONFIG_RTE_LIBRTE_GRAPH_STATS=y
 
+#
+# Compile librte_node
+#
+CONFIG_RTE_LIBRTE_NODE=y
+
 #
 # Compile the test application
 #
index e3b7f54..9212212 100644 (file)
@@ -49,6 +49,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \
                           @TOPDIR@/lib/librte_mempool \
                           @TOPDIR@/lib/librte_meter \
                           @TOPDIR@/lib/librte_metrics \
+                          @TOPDIR@/lib/librte_node \
                           @TOPDIR@/lib/librte_net \
                           @TOPDIR@/lib/librte_pci \
                           @TOPDIR@/lib/librte_pdump \
index 3054f90..9d24609 100644 (file)
@@ -122,6 +122,9 @@ DEPDIRS-librte_rcu := librte_eal librte_ring
 DIRS-$(CONFIG_RTE_LIBRTE_GRAPH) += librte_graph
 DEPDIRS-librte_graph := librte_eal
 
+DIRS-$(CONFIG_RTE_LIBRTE_NODE) += librte_node
+DEPDIRS-librte_node := librte_graph librte_lpm librte_ethdev librte_mbuf
+
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUX),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
 endif
diff --git a/lib/librte_node/Makefile b/lib/librte_node/Makefile
new file mode 100644 (file)
index 0000000..5cb3235
--- /dev/null
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Marvell International Ltd.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_node.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+# Strict-aliasing rules are violated by uint8_t[] to context size casts.
+CFLAGS += -fno-strict-aliasing
+LDLIBS += -lrte_eal -lrte_graph
+
+EXPORT_MAP := rte_node_version.map
+
+# all source are stored in SRCS-y
+SRCS-$(CONFIG_RTE_LIBRTE_NODE) += null.c
+SRCS-$(CONFIG_RTE_LIBRTE_NODE) += log.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_node/log.c b/lib/librte_node/log.c
new file mode 100644 (file)
index 0000000..f035f91
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#include "node_private.h"
+
+int rte_node_logtype;
+
+RTE_INIT(rte_node_init_log)
+{
+       rte_node_logtype = rte_log_register("lib.node");
+       if (rte_node_logtype >= 0)
+               rte_log_set_level(rte_node_logtype, RTE_LOG_INFO);
+}
diff --git a/lib/librte_node/meson.build b/lib/librte_node/meson.build
new file mode 100644 (file)
index 0000000..3123be5
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2020 Marvell International Ltd.
+
+sources = files('null.c', 'log.c')
+# Strict-aliasing rules are violated by uint8_t[] to context size casts.
+cflags += '-fno-strict-aliasing'
+deps += ['graph']
diff --git a/lib/librte_node/node_private.h b/lib/librte_node/node_private.h
new file mode 100644 (file)
index 0000000..f30902a
--- /dev/null
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#ifndef __NODE_PRIVATE_H__
+#define __NODE_PRIVATE_H__
+
+#include <rte_common.h>
+#include <rte_log.h>
+
+extern int rte_node_logtype;
+#define NODE_LOG(level, node_name, ...)                                        \
+       rte_log(RTE_LOG_##level, rte_node_logtype,                             \
+               RTE_FMT("NODE %s: %s():%u " RTE_FMT_HEAD(__VA_ARGS__, ) "\n",  \
+                       node_name, __func__, __LINE__,                         \
+                       RTE_FMT_TAIL(__VA_ARGS__, )))
+
+#define node_err(node_name, ...) NODE_LOG(ERR, node_name, __VA_ARGS__)
+#define node_info(node_name, ...) NODE_LOG(INFO, node_name, __VA_ARGS__)
+#define node_dbg(node_name, ...) NODE_LOG(DEBUG, node_name, __VA_ARGS__)
+
+#endif /* __NODE_PRIVATE_H__ */
diff --git a/lib/librte_node/null.c b/lib/librte_node/null.c
new file mode 100644 (file)
index 0000000..c7cd8b6
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2020 Marvell International Ltd.
+ */
+
+#include <rte_graph.h>
+
+static uint16_t
+null(struct rte_graph *graph, struct rte_node *node, void **objs,
+       uint16_t nb_objs)
+{
+       RTE_SET_USED(node);
+       RTE_SET_USED(objs);
+       RTE_SET_USED(graph);
+
+       return nb_objs;
+}
+
+static struct rte_node_register null_node = {
+       .name = "null",
+       .process = null,
+};
+
+RTE_NODE_REGISTER(null_node);
diff --git a/lib/librte_node/rte_node_version.map b/lib/librte_node/rte_node_version.map
new file mode 100644 (file)
index 0000000..f87163b
--- /dev/null
@@ -0,0 +1,6 @@
+EXPERIMENTAL {
+       global:
+
+       rte_node_logtype;
+       local: *;
+};
index 5ac94cd..e48efb5 100644 (file)
@@ -32,7 +32,7 @@ libraries = [
        # add pkt framework libs which use other libs from above
        'port', 'table', 'pipeline',
        # flow_classify lib depends on pkt framework table lib
-       'flow_classify', 'bpf', 'graph', 'telemetry']
+       'flow_classify', 'bpf', 'graph', 'node', 'telemetry']
 
 if is_windows
        libraries = ['kvargs','eal'] # only supported libraries for windows
@@ -187,6 +187,9 @@ foreach l:libraries
 
                        dpdk_libraries = [shared_lib] + dpdk_libraries
                        dpdk_static_libraries = [static_lib] + dpdk_static_libraries
+                       if libname == 'rte_node'
+                               dpdk_graph_nodes = [static_lib]
+                       endif
                endif # sources.length() > 0
 
                set_variable('shared_rte_' + name, shared_dep)
index d365804..269ba96 100644 (file)
@@ -16,6 +16,7 @@ cc = meson.get_compiler('c')
 dpdk_conf = configuration_data()
 dpdk_libraries = []
 dpdk_static_libraries = []
+dpdk_graph_nodes = []
 dpdk_driver_classes = []
 dpdk_drivers = []
 dpdk_extra_ldflags = []
index b4c09a2..244e74d 100644 (file)
@@ -99,6 +99,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_RCU)            += -lrte_rcu
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRAPH)          += -lrte_graph
+_LDLIBS-$(CONFIG_RTE_LIBRTE_NODE)           += -lrte_node
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUX),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni