[v3,03/17] net/ionic: add log

Message ID 20191209214656.27347-4-cardigliano@ntop.org (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series Introduces net/ionic PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Alfredo Cardigliano Dec. 9, 2019, 9:46 p.m. UTC
  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 | 15 +++++++++++++++
 drivers/net/ionic/ionic_logs.h   | 26 ++++++++++++++++++++++++++
 drivers/net/ionic/meson.build    |  1 +
 4 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ionic/ionic_ethdev.c
 create mode 100644 drivers/net/ionic/ionic_logs.h
  

Comments

Ferruh Yigit Dec. 10, 2019, 6:49 p.m. UTC | #1
On 12/9/2019 9:46 PM, 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>

<...>

> diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
> new file mode 100644
> index 000000000..c706588bc
> --- /dev/null
> +++ b/drivers/net/ionic/ionic_ethdev.c
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
> + * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
> + */

My understanding was code will be BSD-3 license, but it seems it has been dual
license, BSD-3-Clause OR GPL-2.0 we are doing this for the code that needs to be
shared between kernel space and userspace code, since it is not the case for
this driver not sure if it is acceptable. Cc'ing Hemant and Stephen again.
  
Ferruh Yigit Dec. 10, 2019, 6:49 p.m. UTC | #2
On 12/9/2019 9:46 PM, 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>

<...>

> @@ -0,0 +1,15 @@
> +/* 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_driver;
> +
> +RTE_INIT(ionic_init_log)
> +{
> +	ionic_logtype_driver = rte_log_register("pmd.net.ionic.driver");

Up to you, but you can go with simpler "pmd.net.ionic", not sure what additional
value the last 'driver' bit is adding.
  
Hemant Agrawal Dec. 13, 2019, 10:22 a.m. UTC | #3
Hi Ferruh,

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Wednesday, December 11, 2019 12:19 AM
> To: Alfredo Cardigliano <cardigliano@ntop.org>
> Cc: dev@dpdk.org; Stephen Hemminger <stephen@networkplumber.org>;
> Hemant Agrawal <hemant.agrawal@nxp.com>
> Subject: Re: [dpdk-dev] [PATCH v3 03/17] net/ionic: add log
> Importance: High
> 
> On 12/9/2019 9:46 PM, 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>
> 
> <...>
> 
> > diff --git a/drivers/net/ionic/ionic_ethdev.c
> > b/drivers/net/ionic/ionic_ethdev.c
> > new file mode 100644
> > index 000000000..c706588bc
> > --- /dev/null
> > +++ b/drivers/net/ionic/ionic_ethdev.c
> > @@ -0,0 +1,15 @@
> > +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
> > + * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
> > + */
> 
> My understanding was code will be BSD-3 license, but it seems it has been
> dual license, BSD-3-Clause OR GPL-2.0 we are doing this for the code that
> needs to be shared between kernel space and userspace code, since it is not
> the case for this driver not sure if it is acceptable. Cc'ing Hemant and Stephen
> again.
 [Hemant] BSD-3+GPL2 is acceptable and approved license. W.r.t DPDK this code will be used as BSD-3 licensed in DPDK userspace.
  

Patch

diff --git a/drivers/net/ionic/Makefile b/drivers/net/ionic/Makefile
index d2c2b53b3..4c1c8d129 100644
--- a/drivers/net/ionic/Makefile
+++ b/drivers/net/ionic/Makefile
@@ -33,6 +33,6 @@  endif
 #
 # 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
index 000000000..c706588bc
--- /dev/null
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -0,0 +1,15 @@ 
+/* 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_driver;
+
+RTE_INIT(ionic_init_log)
+{
+	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);
+}
diff --git a/drivers/net/ionic/ionic_logs.h b/drivers/net/ionic/ionic_logs.h
new file mode 100644
index 000000000..064b10e8e
--- /dev/null
+++ b/drivers/net/ionic/ionic_logs.h
@@ -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_driver;
+
+#define IONIC_PRINT(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
+	ionic_logtype_driver, "%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_ */
diff --git a/drivers/net/ionic/meson.build b/drivers/net/ionic/meson.build
index 5386e23ca..f5e3c36c9 100644
--- a/drivers/net/ionic/meson.build
+++ b/drivers/net/ionic/meson.build
@@ -2,5 +2,6 @@ 
 # Copyright(c) 2019 Pensando
 
 sources = files(
+	'ionic_ethdev.c'
 )