DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org, ferruh.yigit@intel.com
Cc: thomas@monjalon.net, Gagandeep Singh <g.singh@nxp.com>
Subject: [dpdk-dev] [PATCH v3 04/14] net/ppfe: support dynamic logging
Date: Tue,  1 Oct 2019 16:31:59 +0530	[thread overview]
Message-ID: <20191001110209.6047-5-g.singh@nxp.com> (raw)
In-Reply-To: <20191001110209.6047-1-g.singh@nxp.com>

This patch introduces logging for the ppfe PMD.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 drivers/net/ppfe/pfe_logs.h    | 31 +++++++++++++++
 drivers/net/ppfe/ppfe_ethdev.c | 69 ++++++++++++++++++++++++++++------
 2 files changed, 88 insertions(+), 12 deletions(-)
 create mode 100644 drivers/net/ppfe/pfe_logs.h

diff --git a/drivers/net/ppfe/pfe_logs.h b/drivers/net/ppfe/pfe_logs.h
new file mode 100644
index 000000000..8c6499bb8
--- /dev/null
+++ b/drivers/net/ppfe/pfe_logs.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 NXP
+ */
+
+#ifndef _PFE_LOGS_H_
+#define _PFE_LOGS_H_
+
+extern int ppfe_logtype_pmd;
+
+/* PMD related logs */
+#define PFE_PMD_LOG(level, fmt, args...) \
+	 rte_log(RTE_LOG_ ## level, ppfe_logtype_pmd, "ppfe_net: %s()" \
+		 fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() PFE_PMD_LOG(DEBUG, " >>")
+
+#define PFE_PMD_DEBUG(fmt, args...) \
+	PFE_PMD_LOG(DEBUG, fmt, ## args)
+#define PFE_PMD_ERR(fmt, args...) \
+	PFE_PMD_LOG(ERR, fmt, ## args)
+#define PFE_PMD_INFO(fmt, args...) \
+	PFE_PMD_LOG(INFO, fmt, ## args)
+
+#define PFE_PMD_WARN(fmt, args...) \
+	PFE_PMD_LOG(WARNING, fmt, ## args)
+
+/* DP Logs, toggled out at compile time if level lower than current level */
+#define PFE_DP_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, PMD, fmt, ## args)
+
+#endif /* _PFE_LOGS_H_ */
diff --git a/drivers/net/ppfe/ppfe_ethdev.c b/drivers/net/ppfe/ppfe_ethdev.c
index 1b409a134..77e3e5c30 100644
--- a/drivers/net/ppfe/ppfe_ethdev.c
+++ b/drivers/net/ppfe/ppfe_ethdev.c
@@ -7,6 +7,7 @@
 #include <rte_bus_vdev.h>
 #include <dpaa_of.h>
 
+#include "pfe_logs.h"
 #include "pfe_mod.h"
 
 #define PPFE_MAX_MACS 1 /*we can support upto 4 MACs per IF*/
@@ -23,20 +24,26 @@ static struct pfe *g_pfe;
  */
 unsigned int pfe_svr = SVR_LS1012A_REV1;
 
+int ppfe_logtype_pmd;
+
 static void
 pfe_soc_version_get(void)
 {
 	FILE *svr_file = NULL;
 	unsigned int svr_ver = 0;
 
+	PMD_INIT_FUNC_TRACE();
+
 	svr_file = fopen(PFE_SOC_ID_FILE, "r");
-	if (!svr_file)
+	if (!svr_file) {
+		PFE_PMD_ERR("Unable to open SoC device");
 		return; /* Not supported on this infra */
+	}
 
 	if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
 		pfe_svr = svr_ver;
 	else
-		printf("Unable to read SoC device");
+		PFE_PMD_ERR("Unable to read SoC device");
 
 	fclose(svr_file);
 }
@@ -51,6 +58,9 @@ pfe_eth_open_cdev(struct pfe_eth_priv_s *priv)
 
 	pfe_cdev_fd = open(PFE_CDEV_PATH, O_RDONLY);
 	if (pfe_cdev_fd < 0) {
+		PFE_PMD_WARN("Unable to open PFE device file (%s).\n",
+			     PFE_CDEV_PATH);
+		PFE_PMD_WARN("Link status update will not be available.\n");
 		priv->link_fd = PFE_CDEV_INVALID_FD;
 		return -1;
 	}
@@ -75,6 +85,8 @@ pfe_eth_close_cdev(struct pfe_eth_priv_s *priv)
 static void
 pfe_eth_exit(struct rte_eth_dev *dev, struct pfe *pfe)
 {
+	PMD_INIT_FUNC_TRACE();
+
 	/* Close the device file for link status */
 	pfe_eth_close_cdev(dev->data->dev_private);
 
@@ -110,6 +122,8 @@ pfe_eth_init(struct rte_vdev_device *vdev, struct pfe *pfe, int id)
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr",
 			ETHER_ADDR_LEN * PPFE_MAX_MACS, 0);
 	if (eth_dev->data->mac_addrs == NULL) {
+		PFE_PMD_ERR("Failed to allocate mem %d to store MAC addresses",
+			ETHER_ADDR_LEN * PPFE_MAX_MACS);
 		err = -ENOMEM;
 		goto err0;
 	}
@@ -142,8 +156,10 @@ parse_integer_arg(const char *key __rte_unused,
 	errno = 0;
 
 	i = strtol(value, &end, 10);
-	if (*end != 0 || errno != 0 || i < 0 || i > 1)
+	if (*end != 0 || errno != 0 || i < 0 || i > 1) {
+		PFE_PMD_ERR("Supported Port IDS are 0 and 1");
 		return -EINVAL;
+	}
 
 	*((uint32_t *)extra_args) = i;
 
@@ -199,10 +215,15 @@ pmd_pfe_probe(struct rte_vdev_device *vdev)
 	if (rc < 0)
 		return -EINVAL;
 
+	RTE_LOG(INFO, PMD, "Initializing pmd_pfe for %s Given gem-id %d\n",
+		name, init_params.gem_id);
+
 	if (g_pfe) {
-		if (g_pfe->nb_devs >= g_pfe->max_intf)
+		if (g_pfe->nb_devs >= g_pfe->max_intf) {
+			PFE_PMD_ERR("PPFE %d dev already created Max is %d",
+				g_pfe->nb_devs, g_pfe->max_intf);
 			return -EINVAL;
-
+		}
 		goto eth_init;
 	}
 
@@ -212,31 +233,40 @@ pmd_pfe_probe(struct rte_vdev_device *vdev)
 
 	/* Load the device-tree driver */
 	rc = of_init();
-	if (rc)
+	if (rc) {
+		PFE_PMD_ERR("of_init failed with ret: %d", rc);
 		goto err;
+	}
 
 	np = of_find_compatible_node(NULL, NULL, "fsl,pfe");
 	if (!np) {
+		PFE_PMD_ERR("Invalid device node");
 		rc = -EINVAL;
 		goto err;
 	}
 
 	addr = of_get_address(np, 0, &cbus_size, NULL);
-	if (!addr)
+	if (!addr) {
+		PFE_PMD_ERR("of_get_address cannot return qman address\n");
 		goto err;
-
+	}
 	cbus_addr = of_translate_address(np, addr);
-	if (!cbus_addr)
+	if (!cbus_addr) {
+		PFE_PMD_ERR("of_translate_address failed\n");
 		goto err;
-
+	}
 
 	addr = of_get_address(np, 1, &ddr_size, NULL);
-	if (!addr)
+	if (!addr) {
+		PFE_PMD_ERR("of_get_address cannot return qman address\n");
 		goto err;
+	}
 
 	g_pfe->ddr_phys_baseaddr = of_translate_address(np, addr);
-	if (!g_pfe->ddr_phys_baseaddr)
+	if (!g_pfe->ddr_phys_baseaddr) {
+		PFE_PMD_ERR("of_translate_address failed\n");
 		goto err;
+	}
 
 	g_pfe->ddr_size = ddr_size;
 	g_pfe->cbus_size = cbus_size;
@@ -246,6 +276,7 @@ pmd_pfe_probe(struct rte_vdev_device *vdev)
 					MAP_SHARED, fd, cbus_addr);
 	close(fd);
 	if (g_pfe->cbus_baseaddr == MAP_FAILED) {
+		PFE_PMD_ERR("Can not map cbus base");
 		rc = -EINVAL;
 		goto err;
 	}
@@ -253,15 +284,20 @@ pmd_pfe_probe(struct rte_vdev_device *vdev)
 	/* Read interface count */
 	prop = of_get_property(np, "fsl,pfe-num-interfaces", &size);
 	if (!prop) {
+		PFE_PMD_ERR("Failed to read number of interfaces");
 		rc = -ENXIO;
 		goto err_prop;
 	}
 
 	interface_count = rte_be_to_cpu_32((unsigned int)*prop);
 	if (interface_count <= 0) {
+		PFE_PMD_ERR("No ethernet interface count : %d",
+				interface_count);
 		rc = -ENXIO;
 		goto err_prop;
 	}
+	PFE_PMD_INFO("num interfaces = %d ", interface_count);
+
 	g_pfe->max_intf  = interface_count;
 	pfe_soc_version_get();
 eth_init:
@@ -299,6 +335,8 @@ pmd_pfe_remove(struct rte_vdev_device *vdev)
 	if (name == NULL)
 		return -EINVAL;
 
+	PFE_PMD_INFO("Closing eventdev sw device %s", name);
+
 	if (!g_pfe)
 		return 0;
 
@@ -320,3 +358,10 @@ struct rte_vdev_driver pmd_pfe_drv = {
 
 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PPFE_VDEV_GEM_ID_ARG "=<int> ");
+
+RTE_INIT(ppfe_pmd_init_log)
+{
+	ppfe_logtype_pmd = rte_log_register("pmd.net.ppfe");
+	if (ppfe_logtype_pmd >= 0)
+		rte_log_set_level(ppfe_logtype_pmd, RTE_LOG_NOTICE);
+}
-- 
2.17.1


  parent reply	other threads:[~2019-10-01 11:18 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 13:02 [dpdk-dev] [PATCH v1 00/13] introduces ppfe network PMD Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 01/13] common/dpaax: moving OF lib code from dpaa bus Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 02/13] net/ppfe: introduce ppfe net poll mode driver Gagandeep Singh
2019-10-28 17:18   ` Stephen Hemminger
2019-10-29  9:27     ` Ferruh Yigit
2019-11-04 11:06       ` Bruce Richardson
2019-11-05 16:02         ` Ferruh Yigit
2019-11-06  9:38           ` Bruce Richardson
2019-11-06 12:22             ` Ferruh Yigit
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 03/13] doc: add guide for ppfe net PMD Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 04/13] net/ppfe: support dynamic logging Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 05/13] net/ppfe: add HW specific macros and operations Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 06/13] net/ppfe: add MAC and host interface initialisation Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 07/13] net/ppfe: add device start stop operations Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 08/13] net/ppfe: add queue setup and release operations Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 09/13] net/ppfe: add burst enqueue and dequeue operations Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 10/13] net/ppfe: add supported packet types and basic statistics Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 11/13] net/ppfe: add MTU and MAC address set operations Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 12/13] net/ppfe: add allmulticast and promiscuous Gagandeep Singh
2019-08-26 13:02 ` [dpdk-dev] [PATCH v1 13/13] net/ppfe: add link status update Gagandeep Singh
2019-08-27  7:16 ` [dpdk-dev] [PATCH v1 00/13] introduces ppfe network PMD Gagandeep Singh
2019-08-28 11:08 ` [dpdk-dev] [PATCH v2 " Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 01/13] common/dpaax: moving OF lib code from dpaa bus Gagandeep Singh
2019-09-26 16:54     ` Ferruh Yigit
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 02/13] net/ppfe: introduce ppfe net poll mode driver Gagandeep Singh
2019-09-26 16:53     ` Ferruh Yigit
2019-10-01  7:05       ` Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 03/13] doc: add guide for ppfe net PMD Gagandeep Singh
2019-09-26 16:56     ` Ferruh Yigit
2019-09-26 18:00     ` Ferruh Yigit
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 04/13] net/ppfe: support dynamic logging Gagandeep Singh
2019-09-26 16:57     ` Ferruh Yigit
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 05/13] net/ppfe: add HW specific macros and operations Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 06/13] net/ppfe: add MAC and host interface initialisation Gagandeep Singh
2019-09-26 17:00     ` Ferruh Yigit
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 07/13] net/ppfe: add device start stop operations Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 08/13] net/ppfe: add queue setup and release operations Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 09/13] net/ppfe: add burst enqueue and dequeue operations Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 10/13] net/ppfe: add supported packet types and basic statistics Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 11/13] net/ppfe: add MTU and MAC address set operations Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 12/13] net/ppfe: add allmulticast and promiscuous Gagandeep Singh
2019-08-28 11:08   ` [dpdk-dev] [PATCH v2 13/13] net/ppfe: add link status update Gagandeep Singh
2019-09-26 17:28   ` [dpdk-dev] [PATCH v2 00/13] introduces ppfe network PMD Ferruh Yigit
2019-09-27 14:55     ` Gagandeep Singh
2019-10-01 11:01 ` [dpdk-dev] [PATCH v3 00/14] " Gagandeep Singh
2019-10-01 11:01   ` [dpdk-dev] [PATCH v3 01/14] common/dpaax: moving OF lib code from dpaa bus Gagandeep Singh
2019-10-01 11:01   ` [dpdk-dev] [PATCH v3 02/14] net/ppfe: introduce ppfe net poll mode driver Gagandeep Singh
2019-10-04 15:38     ` Ferruh Yigit
2019-10-09  6:52       ` Gagandeep Singh
2019-10-01 11:01   ` [dpdk-dev] [PATCH v3 03/14] doc: add guide for ppfe net PMD Gagandeep Singh
2019-10-04 15:41     ` Ferruh Yigit
2019-10-09  6:54       ` Gagandeep Singh
2019-10-01 11:01   ` Gagandeep Singh [this message]
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 05/14] net/ppfe: add HW specific macros and operations Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 06/14] net/ppfe: add MAC and host interface initialisation Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 07/14] net/ppfe: add device start stop operations Gagandeep Singh
2019-10-04 15:42     ` Ferruh Yigit
2019-10-09  6:54       ` Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 08/14] net/ppfe: add queue setup and release operations Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 09/14] net/ppfe: add burst enqueue and dequeue operations Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 10/14] net/ppfe: add supported packet types and basic statistics Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 11/14] net/ppfe: add MTU and MAC address set operations Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 12/14] net/ppfe: add allmulticast and promiscuous Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 13/14] net/ppfe: add link status update Gagandeep Singh
2019-10-04 15:43     ` Ferruh Yigit
2019-10-09  6:57       ` Gagandeep Singh
2019-10-01 11:02   ` [dpdk-dev] [PATCH v3 14/14] doc: add NXP PPFE PMD in release notes Gagandeep Singh
2019-10-10  6:32   ` [dpdk-dev] [PATCH v4 00/14] introduces pfe network PMD Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 01/14] common/dpaax: moving OF lib code from dpaa bus Gagandeep Singh
2019-10-10 17:01       ` Ferruh Yigit
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 02/14] net/pfe: introduce pfe net poll mode driver Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 03/14] doc: add guide for pfe net PMD Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 04/14] net/pfe: support dynamic logging Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 05/14] net/pfe: add HW specific macros and operations Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 06/14] net/pfe: add MAC and host interface initialisation Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 07/14] net/pfe: add device start stop operations Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 08/14] net/pfe: add queue setup and release operations Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 09/14] net/pfe: add burst enqueue and dequeue operations Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 10/14] net/pfe: add supported packet types and basic statistics Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 11/14] net/pfe: add MTU and MAC address set operations Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 12/14] net/pfe: add allmulticast and promiscuous Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 13/14] net/pfe: add link status update Gagandeep Singh
2019-10-10  6:32     ` [dpdk-dev] [PATCH v4 14/14] doc: add NXP PFE PMD in release notes Gagandeep Singh
2019-10-10  7:11     ` [dpdk-dev] [PATCH v4 00/14] introduces pfe network PMD Thomas Monjalon
2019-10-10 17:01       ` Ferruh Yigit
2019-10-10 17:47     ` Ferruh Yigit
2019-10-25  7:59       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191001110209.6047-5-g.singh@nxp.com \
    --to=g.singh@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).