[v2,03/17] net/ionic: add log
Checks
Commit Message
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 | 2 +-
drivers/net/ionic/ionic_ethdev.c | 21 +++++++++++++++++++++
drivers/net/ionic/ionic_logs.h | 32 ++++++++++++++++++++++++++++++++
drivers/net/ionic/meson.build | 1 +
4 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ionic/ionic_ethdev.c
create mode 100644 drivers/net/ionic/ionic_logs.h
Comments
On 10/15/2019 9:22 AM, Alfredo Cardigliano wrote:
> 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 | 2 +-
> drivers/net/ionic/ionic_ethdev.c | 21 +++++++++++++++++++++
> drivers/net/ionic/ionic_logs.h | 32 ++++++++++++++++++++++++++++++++
> drivers/net/ionic/meson.build | 1 +
> 4 files changed, 55 insertions(+), 1 deletion(-)
> create mode 100644 drivers/net/ionic/ionic_ethdev.c
> create mode 100644 drivers/net/ionic/ionic_logs.h
>
<...>
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0
> + * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
I will stop commenting on licenses, but that needs to be resolved for all files.
> + */
> +
> +#include "ionic_logs.h"
> +
> +int ionic_logtype_init;
> +int ionic_logtype_driver;
Why two different log types are required?
Can you please put some comments on the difference of the two log types?
<...>
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: 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_init;
> +extern int ionic_logtype_driver;
> +
> +#define ionic_init_print(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
> + ionic_logtype_init, "%s(): " fmt "\n", __func__, ##args)
> +
> +#define ionic_init_print_call() ionic_init_print(DEBUG, " >>")
We tend to define macros as all upercase, to distinguish between the functions,
not really a requirement but I think it will be good to do for consistency.
@@ -53,6 +53,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
new file mode 100644
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0
+ * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
+ */
+
+#include "ionic_logs.h"
+
+int ionic_logtype_init;
+int ionic_logtype_driver;
+
+RTE_INIT(ionic_init_log)
+{
+ ionic_logtype_init = rte_log_register("pmd.net.ionic.init");
+
+ if (ionic_logtype_init >= 0)
+ rte_log_set_level(ionic_logtype_init, RTE_LOG_NOTICE);
+
+ ionic_logtype_driver = rte_log_register("pmd.net.ionic.driver");
+
+ if (ionic_logtype_driver >= 0)
+ rte_log_set_level(ionic_logtype_driver, RTE_LOG_NOTICE);
+}
new file mode 100644
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: 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_init;
+extern int ionic_logtype_driver;
+
+#define ionic_init_print(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
+ ionic_logtype_init, "%s(): " fmt "\n", __func__, ##args)
+
+#define ionic_init_print_call() ionic_init_print(DEBUG, " >>")
+
+#ifndef IONIC_WARN_ON
+#define IONIC_WARN_ON(x) do { \
+ int ret = !!(x); \
+ if (unlikely(ret)) \
+ ionic_init_print(WARNING, "WARN_ON: \"" #x "\" at %s:%d\n", \
+ __func__, __LINE__); \
+} while (0)
+#endif
+
+#define ionic_drv_print(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
+ ionic_logtype_driver, "%s(): " fmt "\n", __func__, ## args)
+
+#define ionic_drv_print_call() ionic_drv_print(DEBUG, " >>")
+
+#endif /* _IONIC_LOGS_H_ */
@@ -4,5 +4,6 @@
version = 1
sources = files(
+ 'ionic_ethdev.c'
)