net/ionic: add log
authorAlfredo Cardigliano <cardigliano@ntop.org>
Sun, 19 Jan 2020 15:53:41 +0000 (16:53 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 20 Jan 2020 17:02:17 +0000 (18:02 +0100)
Add debug options to the config file.
Define macros used for logs and make use of config file options
to enable them.

Signed-off-by: Alfredo Cardigliano <cardigliano@ntop.org>
Reviewed-by: Shannon Nelson <snelson@pensando.io>
drivers/net/ionic/Makefile
drivers/net/ionic/ionic_ethdev.c [new file with mode: 0644]
drivers/net/ionic/ionic_logs.h [new file with mode: 0644]
drivers/net/ionic/meson.build

index 9c2f9cf..baa34b0 100644 (file)
@@ -20,6 +20,6 @@ LDLIBS += -lrte_bus_pci
 #
 # all source are stored in SRCS-y
 #
-SRCS-$(CONFIG_RTE_LIBRTE_IONIC_PMD) +=
+SRCS-$(CONFIG_RTE_LIBRTE_IONIC_PMD) += ionic_ethdev.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
new file mode 100644 (file)
index 0000000..9839903
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
+ */
+
+#include "ionic_logs.h"
+
+int ionic_logtype;
+
+RTE_INIT(ionic_init_log)
+{
+       ionic_logtype = rte_log_register("pmd.net.ionic");
+       if (ionic_logtype >= 0)
+               rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE);
+}
diff --git a/drivers/net/ionic/ionic_logs.h b/drivers/net/ionic/ionic_logs.h
new file mode 100644 (file)
index 0000000..bc10ad1
--- /dev/null
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
+ */
+
+#ifndef _IONIC_LOGS_H_
+#define _IONIC_LOGS_H_
+
+#include <rte_log.h>
+
+extern int ionic_logtype;
+
+#define IONIC_PRINT(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
+       ionic_logtype, "%s(): " fmt "\n", __func__, ##args)
+
+#define IONIC_PRINT_CALL() IONIC_PRINT(DEBUG, " >>")
+
+#ifndef IONIC_WARN_ON
+#define IONIC_WARN_ON(x) do { \
+       int ret = !!(x); \
+       if (unlikely(ret)) \
+               IONIC_PRINT(WARNING, "WARN_ON: \"" #x "\" at %s:%d\n", \
+                       __func__, __LINE__); \
+} while (0)
+#endif
+
+#endif /* _IONIC_LOGS_H_ */
index 5386e23..f5e3c36 100644 (file)
@@ -2,5 +2,6 @@
 # Copyright(c) 2019 Pensando
 
 sources = files(
+       'ionic_ethdev.c'
 )