[1/3] net/nfp: remove usage of print statements

Message ID 20230206070549.27265-2-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series cleanup the PMD |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Chaoyong He Feb. 6, 2023, 7:05 a.m. UTC
  From: James Hershaw <james.hershaw@corigine.com>

Removal of the usage of printf() statements from the nfp PMD in favour
of appropriate RTE logging functions in compliance with the standard.

Debug messages are now logged using the appropriate RTE_LOG functions so
it is no longer necessary to print specific statements when compiled in
with the DEBUG tag, rather log these messages using the appropriate
functions regardless of whether the DEBUG tag is set or not.

Signed-off-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 71 +++++++++-------------
 drivers/net/nfp/nfpcore/nfp_cppcore.c      |  3 +-
 drivers/net/nfp/nfpcore/nfp_hwinfo.c       | 17 +++---
 drivers/net/nfp/nfpcore/nfp_mip.c          | 12 ++--
 drivers/net/nfp/nfpcore/nfp_mutex.c        | 10 ++-
 drivers/net/nfp/nfpcore/nfp_nsp.c          | 30 +++++----
 drivers/net/nfp/nfpcore/nfp_nsp_cmds.c     |  4 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c      | 16 ++---
 drivers/net/nfp/nfpcore/nfp_resource.c     |  5 +-
 drivers/net/nfp/nfpcore/nfp_rtsym.c        | 28 +++------
 10 files changed, 87 insertions(+), 109 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index 22c8bc4b14..8d7eb96da1 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
@@ -34,6 +34,7 @@ 
 #include <rte_string_fns.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 
@@ -173,23 +174,17 @@  nfp_compute_bar(const struct nfp_bar *bar, uint32_t *bar_config,
 		newcfg |= NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS(tok);
 
 		if ((offset & mask) != ((offset + size - 1) & mask)) {
-			printf("BAR%d: Won't use for Fixed mapping\n",
-				bar->index);
-			printf("\t<%#llx,%#llx>, action=%d\n",
-				(unsigned long long)offset,
-				(unsigned long long)(offset + size), act);
-			printf("\tBAR too small (0x%llx).\n",
-				(unsigned long long)mask);
+			PMD_DRV_LOG(ERR, "BAR%d: Won't use for Fixed mapping <%#llx,%#llx>, action=%d BAR too small (0x%llx)",
+				    bar->index, (unsigned long long)offset,
+				    (unsigned long long)(offset + size), act,
+				    (unsigned long long)mask);
 			return -EINVAL;
 		}
 		offset &= mask;
 
-#ifdef DEBUG
-		printf("BAR%d: Created Fixed mapping\n", bar->index);
-		printf("\t%d:%d:%d:0x%#llx-0x%#llx>\n", tgt, act, tok,
-			(unsigned long long)offset,
-			(unsigned long long)(offset + mask));
-#endif
+		PMD_DRV_LOG(DEBUG, "BAR%d: Created Fixed mapping %d:%d:%d:0x%#llx-0x%#llx>",
+			    bar->index, tgt, act, tok, (unsigned long long)offset,
+			    (unsigned long long)(offset + mask));
 
 		bitsize = 40 - 16;
 	} else {
@@ -204,33 +199,27 @@  nfp_compute_bar(const struct nfp_bar *bar, uint32_t *bar_config,
 		newcfg |= NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS(tok);
 
 		if ((offset & mask) != ((offset + size - 1) & mask)) {
-			printf("BAR%d: Won't use for bulk mapping\n",
-				bar->index);
-			printf("\t<%#llx,%#llx>\n", (unsigned long long)offset,
-				(unsigned long long)(offset + size));
-			printf("\ttarget=%d, token=%d\n", tgt, tok);
-			printf("\tBAR too small (%#llx) - (%#llx != %#llx).\n",
-				(unsigned long long)mask,
-				(unsigned long long)(offset & mask),
-				(unsigned long long)(offset + size - 1) & mask);
-
+			PMD_DRV_LOG(ERR, "BAR%d: Won't use for bulk mapping <%#llx,%#llx> target=%d, token=%d BAR too small (%#llx) - (%#llx != %#llx).",
+				    bar->index, (unsigned long long)offset,
+				    (unsigned long long)(offset + size),
+				    tgt, tok, (unsigned long long)mask,
+				    (unsigned long long)(offset & mask),
+				    (unsigned long long)(offset + size - 1) & mask);
 			return -EINVAL;
 		}
 
 		offset &= mask;
 
-#ifdef DEBUG
-		printf("BAR%d: Created bulk mapping %d:x:%d:%#llx-%#llx\n",
-			bar->index, tgt, tok, (unsigned long long)offset,
-			(unsigned long long)(offset + ~mask));
-#endif
+		PMD_DRV_LOG(DEBUG, "BAR%d: Created bulk mapping %d:x:%d:%#llx-%#llx",
+			    bar->index, tgt, tok, (unsigned long long)offset,
+			    (unsigned long long)(offset + ~mask));
 
 		bitsize = 40 - 21;
 	}
 
 	if (bar->bitsize < bitsize) {
-		printf("BAR%d: Too small for %d:%d:%d\n", bar->index, tgt, tok,
-			act);
+		PMD_DRV_LOG(ERR, "BAR%d: Too small for %d:%d:%d", bar->index,
+			    tgt, tok, act);
 		return -EINVAL;
 	}
 
@@ -263,9 +252,7 @@  nfp_bar_write(struct nfp_pcie_user *nfp, struct nfp_bar *bar,
 	*(uint32_t *)(bar->csr) = newcfg;
 
 	bar->barcfg = newcfg;
-#ifdef DEBUG
-	printf("BAR%d: updated to 0x%08x\n", bar->index, newcfg);
-#endif
+	PMD_DRV_LOG(DEBUG, "BAR%d: updated to 0x%08x", bar->index, newcfg);
 
 	return 0;
 }
@@ -535,7 +522,7 @@  nfp6000_area_read(struct nfp_cpp_area *area, void *kernel_vaddr,
 
 	/* Unaligned? Translate to an explicit access */
 	if ((priv->offset + offset) & (width - 1)) {
-		printf("aread_read unaligned!!!\n");
+		PMD_DRV_LOG(ERR, "aread_read unaligned!!!");
 		return -EINVAL;
 	}
 
@@ -702,7 +689,7 @@  nfp_acquire_secondary_process_lock(struct nfp_pcie_user *desc)
 	desc->secondary_lock = open(lockfile, O_RDWR | O_CREAT | O_NONBLOCK,
 				    0666);
 	if (desc->secondary_lock < 0) {
-		RTE_LOG(ERR, PMD, "NFP lock for secondary process failed\n");
+		PMD_DRV_LOG(ERR, "NFP lock for secondary process failed");
 		free(lockfile);
 		return desc->secondary_lock;
 	}
@@ -711,7 +698,7 @@  nfp_acquire_secondary_process_lock(struct nfp_pcie_user *desc)
 	lock.l_whence = SEEK_SET;
 	rc = fcntl(desc->secondary_lock, F_SETLK, &lock);
 	if (rc < 0) {
-		RTE_LOG(ERR, PMD, "NFP lock for secondary process failed\n");
+		PMD_DRV_LOG(ERR, "NFP lock for secondary process failed");
 		close(desc->secondary_lock);
 	}
 
@@ -725,7 +712,7 @@  nfp6000_set_model(struct rte_pci_device *dev, struct nfp_cpp *cpp)
 	uint32_t model;
 
 	if (rte_pci_read_config(dev, &model, 4, 0x2e) < 0) {
-		printf("nfp set model failed\n");
+		PMD_DRV_LOG(ERR, "nfp set model failed");
 		return -1;
 	}
 
@@ -741,7 +728,7 @@  nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp)
 	uint16_t interface;
 
 	if (rte_pci_read_config(dev, &interface, 2, 0x154) < 0) {
-		printf("nfp set interface failed\n");
+		PMD_DRV_LOG(ERR, "nfp set interface failed");
 		return -1;
 	}
 
@@ -760,14 +747,14 @@  nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp)
 
 	pos = rte_pci_find_ext_capability(dev, RTE_PCI_EXT_CAP_ID_DSN);
 	if (pos <= 0) {
-		printf("PCI_EXT_CAP_ID_DSN not found. nfp set serial failed\n");
+		PMD_DRV_LOG(ERR, "PCI_EXT_CAP_ID_DSN not found. nfp set serial failed");
 		return -1;
 	} else {
 		pos += 6;
 	}
 
 	if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {
-		printf("nfp set serial failed\n");
+		PMD_DRV_LOG(ERR, "nfp set serial failed");
 		return -1;
 	}
 
@@ -776,7 +763,7 @@  nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp)
 
 	pos += 2;
 	if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {
-		printf("nfp set serial failed\n");
+		PMD_DRV_LOG(ERR, "nfp set serial failed");
 		return -1;
 	}
 
@@ -785,7 +772,7 @@  nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp)
 
 	pos += 2;
 	if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {
-		printf("nfp set serial failed\n");
+		PMD_DRV_LOG(ERR, "nfp set serial failed");
 		return -1;
 	}
 
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index 37799af558..e1e0a143f9 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -15,6 +15,7 @@ 
 #include <ethdev_pci.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp6000/nfp_xpb.h"
@@ -701,7 +702,7 @@  nfp_cpp_read(struct nfp_cpp *cpp, uint32_t destination,
 
 	area = nfp_cpp_area_alloc_acquire(cpp, destination, address, length);
 	if (!area) {
-		printf("Area allocation/acquire failed\n");
+		PMD_DRV_LOG(ERR, "Area allocation/acquire failed");
 		return -1;
 	}
 
diff --git a/drivers/net/nfp/nfpcore/nfp_hwinfo.c b/drivers/net/nfp/nfpcore/nfp_hwinfo.c
index 9f848bde79..9b66569953 100644
--- a/drivers/net/nfp/nfpcore/nfp_hwinfo.c
+++ b/drivers/net/nfp/nfpcore/nfp_hwinfo.c
@@ -20,6 +20,7 @@ 
 #include <time.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp_resource.h"
 #include "nfp_hwinfo.h"
@@ -40,12 +41,12 @@  nfp_hwinfo_db_walk(struct nfp_hwinfo *hwinfo, uint32_t size)
 	     key = val + strlen(val) + 1) {
 		val = key + strlen(key) + 1;
 		if (val >= end) {
-			printf("Bad HWINFO - overflowing key\n");
+			PMD_DRV_LOG(ERR, "Bad HWINFO - overflowing value");
 			return -EINVAL;
 		}
 
 		if (val + strlen(val) + 1 > end) {
-			printf("Bad HWINFO - overflowing value\n");
+			PMD_DRV_LOG(ERR, "Bad HWINFO - overflowing value");
 			return -EINVAL;
 		}
 	}
@@ -59,7 +60,7 @@  nfp_hwinfo_db_validate(struct nfp_hwinfo *db, uint32_t len)
 
 	size = db->size;
 	if (size > len) {
-		printf("Unsupported hwinfo size %u > %u\n", size, len);
+		PMD_DRV_LOG(ERR, "Unsupported hwinfo size %u > %u", size, len);
 		return -EINVAL;
 	}
 
@@ -67,8 +68,8 @@  nfp_hwinfo_db_validate(struct nfp_hwinfo *db, uint32_t len)
 	new_crc = nfp_crc32_posix((char *)db, size);
 	crc = (uint32_t *)(db->start + size);
 	if (new_crc != *crc) {
-		printf("Corrupt hwinfo table (CRC mismatch)\n");
-		printf("\tcalculated 0x%x, expected 0x%x\n", new_crc, *crc);
+		PMD_DRV_LOG(ERR, "Corrupt hwinfo table (CRC mismatch) calculated 0x%x, expected 0x%x",
+			    new_crc, *crc);
 		return -EINVAL;
 	}
 
@@ -108,12 +109,12 @@  nfp_hwinfo_try_fetch(struct nfp_cpp *cpp, size_t *cpp_size)
 		goto exit_free;
 
 	header = (void *)db;
-	printf("NFP HWINFO header: %#08x\n", *(uint32_t *)header);
+	PMD_DRV_LOG(DEBUG, "NFP HWINFO header: %#08x", *(uint32_t *)header);
 	if (nfp_hwinfo_is_updating(header))
 		goto exit_free;
 
 	if (header->version != NFP_HWINFO_VERSION_2) {
-		printf("Unknown HWInfo version: 0x%08x\n",
+		PMD_DRV_LOG(DEBUG, "Unknown HWInfo version: 0x%08x",
 			header->version);
 		goto exit_free;
 	}
@@ -145,7 +146,7 @@  nfp_hwinfo_fetch(struct nfp_cpp *cpp, size_t *hwdb_size)
 
 		nanosleep(&wait, NULL);
 		if (count++ > 200) {
-			printf("NFP access error\n");
+			PMD_DRV_LOG(ERR, "NFP access error");
 			return NULL;
 		}
 	}
diff --git a/drivers/net/nfp/nfpcore/nfp_mip.c b/drivers/net/nfp/nfpcore/nfp_mip.c
index c86966df8b..d342bc4141 100644
--- a/drivers/net/nfp/nfpcore/nfp_mip.c
+++ b/drivers/net/nfp/nfpcore/nfp_mip.c
@@ -7,6 +7,7 @@ 
 #include <rte_byteorder.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_mip.h"
 #include "nfp_nffw.h"
 
@@ -43,18 +44,17 @@  nfp_mip_try_read(struct nfp_cpp *cpp, uint32_t cpp_id, uint64_t addr,
 
 	ret = nfp_cpp_read(cpp, cpp_id, addr, mip, sizeof(*mip));
 	if (ret != sizeof(*mip)) {
-		printf("Failed to read MIP data (%d, %zu)\n",
-			ret, sizeof(*mip));
+		PMD_DRV_LOG(ERR, "Failed to read MIP data (%d, %zu)", ret, sizeof(*mip));
 		return -EIO;
 	}
 	if (mip->signature != NFP_MIP_SIGNATURE) {
-		printf("Incorrect MIP signature (0x%08x)\n",
-			 rte_le_to_cpu_32(mip->signature));
+		PMD_DRV_LOG(ERR, "Incorrect MIP signature (0x%08x)",
+			    rte_le_to_cpu_32(mip->signature));
 		return -EINVAL;
 	}
 	if (mip->mip_version != NFP_MIP_VERSION) {
-		printf("Unsupported MIP version (%d)\n",
-			 rte_le_to_cpu_32(mip->mip_version));
+		PMD_DRV_LOG(ERR, "Unsupported MIP version (%d)",
+			    rte_le_to_cpu_32(mip->mip_version));
 		return -EINVAL;
 	}
 
diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c
index 318c5800d7..de9049c6a0 100644
--- a/drivers/net/nfp/nfpcore/nfp_mutex.c
+++ b/drivers/net/nfp/nfpcore/nfp_mutex.c
@@ -10,6 +10,7 @@ 
 #include <sched.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp6000/nfp6000.h"
 
 #define MUTEX_LOCKED(interface)  ((((uint32_t)(interface)) << 16) | 0x000f)
@@ -265,12 +266,9 @@  nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex)
 		if (err < 0 && errno != EBUSY)
 			return err;
 		if (time(NULL) >= warn_at) {
-			printf("Warning: waiting for NFP mutex\n");
-			printf("\tusage:%u\n", mutex->usage);
-			printf("\tdepth:%hd]\n", mutex->depth);
-			printf("\ttarget:%d\n", mutex->target);
-			printf("\taddr:%llx\n", mutex->address);
-			printf("\tkey:%08x]\n", mutex->key);
+			PMD_DRV_LOG(ERR, "Warning: waiting for NFP mutex usage:%u depth:%hd] target:%d addr:%llx key:%08x]",
+				    mutex->usage, mutex->depth, mutex->target,
+				    mutex->address, mutex->key);
 			warn_at = time(NULL) + 60;
 		}
 		sched_yield();
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 876a4017c9..22fb3407c6 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -11,6 +11,7 @@ 
 #include <rte_common.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_nsp.h"
 #include "nfp_resource.h"
 
@@ -62,7 +63,7 @@  nfp_nsp_print_extended_error(uint32_t ret_val)
 
 	for (i = 0; i < (int)ARRAY_SIZE(nsp_errors); i++)
 		if (ret_val == (uint32_t)nsp_errors[i].code)
-			printf("err msg: %s\n", nsp_errors[i].msg);
+			PMD_DRV_LOG(ERR, "err msg: %s", nsp_errors[i].msg);
 }
 
 static int
@@ -81,7 +82,7 @@  nfp_nsp_check(struct nfp_nsp *state)
 		return err;
 
 	if (FIELD_GET(NSP_STATUS_MAGIC, reg) != NSP_MAGIC) {
-		printf("Cannot detect NFP Service Processor\n");
+		PMD_DRV_LOG(ERR, "Cannot detect NFP Service Processor");
 		return -ENODEV;
 	}
 
@@ -89,13 +90,13 @@  nfp_nsp_check(struct nfp_nsp *state)
 	state->ver.minor = FIELD_GET(NSP_STATUS_MINOR, reg);
 
 	if (state->ver.major != NSP_MAJOR || state->ver.minor < NSP_MINOR) {
-		printf("Unsupported ABI %hu.%hu\n", state->ver.major,
+		PMD_DRV_LOG(ERR, "Unsupported ABI %hu.%hu", state->ver.major,
 						    state->ver.minor);
 		return -EINVAL;
 	}
 
 	if (reg & NSP_STATUS_BUSY) {
-		printf("Service processor busy!\n");
+		PMD_DRV_LOG(ERR, "Service processor busy!");
 		return -EBUSY;
 	}
 
@@ -223,7 +224,7 @@  nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
 
 	if (!FIELD_FIT(NSP_BUFFER_CPP, buff_cpp >> 8) ||
 	    !FIELD_FIT(NSP_BUFFER_ADDRESS, buff_addr)) {
-		printf("Host buffer out of reach %08x %" PRIx64 "\n",
+		PMD_DRV_LOG(ERR, "Host buffer out of reach %08x %" PRIx64,
 			buff_cpp, buff_addr);
 		return -EINVAL;
 	}
@@ -245,7 +246,7 @@  nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
 	err = nfp_nsp_wait_reg(cpp, &reg, nsp_cpp, nsp_command,
 			       NSP_COMMAND_START, 0);
 	if (err) {
-		printf("Error %d waiting for code 0x%04x to start\n",
+		PMD_DRV_LOG(ERR, "Error %d waiting for code 0x%04x to start",
 			err, code);
 		return err;
 	}
@@ -254,7 +255,7 @@  nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
 	err = nfp_nsp_wait_reg(cpp, &reg, nsp_cpp, nsp_status, NSP_STATUS_BUSY,
 			       0);
 	if (err) {
-		printf("Error %d waiting for code 0x%04x to complete\n",
+		PMD_DRV_LOG(ERR, "Error %d waiting for code 0x%04x to start",
 			err, code);
 		return err;
 	}
@@ -266,7 +267,7 @@  nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
 
 	err = FIELD_GET(NSP_STATUS_RESULT, reg);
 	if (err) {
-		printf("Result (error) code set: %d (%d) command: %d\n",
+		PMD_DRV_LOG(ERR, "Result (error) code set: %d (%d) command: %d",
 			 -err, (int)ret_val, code);
 		nfp_nsp_print_extended_error(ret_val);
 		return -err;
@@ -289,8 +290,8 @@  nfp_nsp_command_buf(struct nfp_nsp *nsp, uint16_t code, uint32_t option,
 	uint32_t cpp_id;
 
 	if (nsp->ver.minor < 13) {
-		printf("NSP: Code 0x%04x with buffer not supported\n", code);
-		printf("\t(ABI %hu.%hu)\n", nsp->ver.major, nsp->ver.minor);
+		PMD_DRV_LOG(ERR, "NSP: Code 0x%04x with buffer not supported ABI %hu.%hu)",
+			    code, nsp->ver.major, nsp->ver.minor);
 		return -EOPNOTSUPP;
 	}
 
@@ -303,11 +304,8 @@  nfp_nsp_command_buf(struct nfp_nsp *nsp, uint16_t code, uint32_t option,
 
 	max_size = RTE_MAX(in_size, out_size);
 	if (FIELD_GET(NSP_DFLT_BUFFER_SIZE_MB, reg) * SZ_1M < max_size) {
-		printf("NSP: default buffer too small for command 0x%04x\n",
-		       code);
-		printf("\t(%llu < %u)\n",
-		       FIELD_GET(NSP_DFLT_BUFFER_SIZE_MB, reg) * SZ_1M,
-		       max_size);
+		PMD_DRV_LOG(ERR, "NSP: default buffer too small for command 0x%04x (%llu < %u)",
+			    code, FIELD_GET(NSP_DFLT_BUFFER_SIZE_MB, reg) * SZ_1M, max_size);
 		return -EINVAL;
 	}
 
@@ -372,7 +370,7 @@  nfp_nsp_wait(struct nfp_nsp *state)
 		}
 	}
 	if (err)
-		printf("NSP failed to respond %d\n", err);
+		PMD_DRV_LOG(ERR, "NSP failed to respond %d", err);
 
 	return err;
 }
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c
index bfd1eddb3e..1de3d1b00f 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c
@@ -6,6 +6,7 @@ 
 #include <stdio.h>
 #include <rte_byteorder.h>
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_nsp.h"
 #include "nfp_nffw.h"
 
@@ -39,8 +40,7 @@  __nfp_nsp_identify(struct nfp_nsp *nsp)
 	memset(ni, 0, sizeof(*ni));
 	ret = nfp_nsp_read_identify(nsp, ni, sizeof(*ni));
 	if (ret < 0) {
-		printf("reading bsp version failed %d\n",
-			ret);
+		PMD_DRV_LOG(ERR, "reading bsp version failed %d", ret);
 		goto exit_free;
 	}
 
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index f8f3c372ac..eb532e5f3a 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -7,6 +7,7 @@ 
 #include <rte_common.h>
 #include <rte_byteorder.h>
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_nsp.h"
 #include "nfp6000/nfp6000.h"
 
@@ -236,7 +237,7 @@  nfp_eth_calc_port_geometry(struct nfp_eth_table *table)
 				continue;
 			if (table->ports[i].label_subport ==
 			    table->ports[j].label_subport)
-				printf("Port %d subport %d is a duplicate\n",
+				PMD_DRV_LOG(DEBUG, "Port %d subport %d is a duplicate",
 					 table->ports[i].label_port,
 					 table->ports[i].label_subport);
 
@@ -275,7 +276,7 @@  __nfp_eth_read_ports(struct nfp_nsp *nsp)
 	memset(entries, 0, NSP_ETH_TABLE_SIZE);
 	ret = nfp_nsp_read_eth_table(nsp, entries, NSP_ETH_TABLE_SIZE);
 	if (ret < 0) {
-		printf("reading port table failed %d\n", ret);
+		PMD_DRV_LOG(ERR, "reading port table failed %d", ret);
 		goto err;
 	}
 
@@ -294,7 +295,7 @@  __nfp_eth_read_ports(struct nfp_nsp *nsp)
 	 * above.
 	 */
 	if (ret && ret != cnt) {
-		printf("table entry count (%d) unmatch entries present (%d)\n",
+		PMD_DRV_LOG(ERR, "table entry count (%d) unmatch entries present (%d)",
 		       ret, cnt);
 		goto err;
 	}
@@ -372,12 +373,12 @@  nfp_eth_config_start(struct nfp_cpp *cpp, unsigned int idx)
 
 	ret = nfp_nsp_read_eth_table(nsp, entries, NSP_ETH_TABLE_SIZE);
 	if (ret < 0) {
-		printf("reading port table failed %d\n", ret);
+		PMD_DRV_LOG(ERR, "reading port table failed %d", ret);
 		goto err;
 	}
 
 	if (!(entries[idx].port & NSP_ETH_PORT_LANES_MASK)) {
-		printf("trying to set port state on disabled port %d\n", idx);
+		PMD_DRV_LOG(ERR, "trying to set port state on disabled port %d", idx);
 		goto err;
 	}
 
@@ -535,7 +536,7 @@  nfp_eth_set_bit_config(struct nfp_nsp *nsp, unsigned int raw_idx,
 	 *	 codes were initially not populated correctly.
 	 */
 	if (nfp_nsp_get_abi_ver_minor(nsp) < 17) {
-		printf("set operations not supported, please update flash\n");
+		PMD_DRV_LOG(ERR, "set operations not supported, please update flash");
 		return -EOPNOTSUPP;
 	}
 
@@ -647,8 +648,7 @@  __nfp_eth_set_speed(struct nfp_nsp *nsp, unsigned int speed)
 
 	rate = nfp_eth_speed2rate(speed);
 	if (rate == RATE_INVALID) {
-		printf("could not find matching lane rate for speed %u\n",
-			 speed);
+		PMD_DRV_LOG(ERR, "could not find matching lane rate for speed %u", speed);
 		return -EINVAL;
 	}
 
diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c
index 7b5630fd86..6a10c9b0a7 100644
--- a/drivers/net/nfp/nfpcore/nfp_resource.c
+++ b/drivers/net/nfp/nfpcore/nfp_resource.c
@@ -10,6 +10,7 @@ 
 #include <rte_string_fns.h>
 
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp_resource.h"
 #include "nfp_crc.h"
@@ -79,7 +80,7 @@  nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res)
 
 	/* Search for a matching entry */
 	if (!memcmp(name_pad, NFP_RESOURCE_TBL_NAME "\0\0\0\0\0\0\0\0", 8)) {
-		printf("Grabbing device lock not supported\n");
+		PMD_DRV_LOG(ERR, "Grabbing device lock not supported");
 		return -EOPNOTSUPP;
 	}
 	key = nfp_crc32_posix(name_pad, NFP_RESOURCE_ENTRY_NAME_SZ);
@@ -185,7 +186,7 @@  nfp_resource_acquire(struct nfp_cpp *cpp, const char *name)
 			goto err_free;
 
 		if (count++ > 1000) {
-			printf("Error: resource %s timed out\n", name);
+			PMD_DRV_LOG(ERR, "Error: resource %s timed out", name);
 			err = -EBUSY;
 			goto err_free;
 		}
diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c
index 56bbf05cd8..288a37da60 100644
--- a/drivers/net/nfp/nfpcore/nfp_rtsym.c
+++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c
@@ -11,6 +11,7 @@ 
 #include <stdio.h>
 #include <rte_byteorder.h>
 #include "nfp_cpp.h"
+#include "nfp_logs.h"
 #include "nfp_mip.h"
 #include "nfp_rtsym.h"
 #include "nfp6000/nfp6000.h"
@@ -56,11 +57,8 @@  nfp_rtsym_sw_entry_init(struct nfp_rtsym_table *cache, uint32_t strtab_size,
 	sw->size = ((uint64_t)fw->size_hi << 32) |
 		   rte_le_to_cpu_32(fw->size_lo);
 
-#ifdef DEBUG
-	printf("rtsym_entry_init\n");
-	printf("\tname=%s, addr=%" PRIx64 ", size=%" PRIu64 ",target=%d\n",
-		sw->name, sw->addr, sw->size, sw->target);
-#endif
+	PMD_INIT_LOG(DEBUG, "rtsym_entry_init name=%s, addr=%" PRIx64 ", size=%" PRIu64 ", target=%d",
+		     sw->name, sw->addr, sw->size, sw->target);
 	switch (fw->target) {
 	case SYM_TGT_LMEM:
 		sw->target = NFP_RTSYM_TARGET_LMEM;
@@ -241,10 +239,8 @@  nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int *error)
 
 	id = NFP_CPP_ISLAND_ID(sym->target, NFP_CPP_ACTION_RW, 0, sym->domain);
 
-#ifdef DEBUG
-	printf("Reading symbol %s with size %" PRIu64 " at %" PRIx64 "\n",
+	PMD_DRV_LOG(DEBUG, "Reading symbol %s with size %" PRIu64 " at %" PRIx64 "",
 		name, sym->size, sym->addr);
-#endif
 	switch (sym->size) {
 	case 4:
 		err = nfp_cpp_readl(rtbl->cpp, id, sym->addr, &val32);
@@ -254,7 +250,7 @@  nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int *error)
 		err = nfp_cpp_readq(rtbl->cpp, id, sym->addr, &val);
 		break;
 	default:
-		printf("rtsym '%s' unsupported size: %" PRId64 "\n",
+		PMD_DRV_LOG(ERR, "rtsym '%s' unsupported size: %" PRId64,
 			name, sym->size);
 		err = -EINVAL;
 		break;
@@ -279,17 +275,15 @@  nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name,
 	const struct nfp_rtsym *sym;
 	uint8_t *mem;
 
-#ifdef DEBUG
-	printf("mapping symbol %s\n", name);
-#endif
+	PMD_DRV_LOG(DEBUG, "mapping symbol %s", name);
 	sym = nfp_rtsym_lookup(rtbl, name);
 	if (!sym) {
-		printf("symbol lookup fails for %s\n", name);
+		PMD_DRV_LOG(ERR, "symbol lookup fails for %s", name);
 		return NULL;
 	}
 
 	if (sym->size < min_size) {
-		printf("Symbol %s too small (%" PRIu64 " < %u)\n", name,
+		PMD_DRV_LOG(ERR, "Symbol %s too small (%" PRIu64 " < %u)", name,
 			sym->size, min_size);
 		return NULL;
 	}
@@ -297,12 +291,10 @@  nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name,
 	mem = nfp_cpp_map_area(rtbl->cpp, sym->domain, sym->target, sym->addr,
 			       sym->size, area);
 	if (!mem) {
-		printf("Failed to map symbol %s\n", name);
+		PMD_DRV_LOG(ERR, "Failed to map symbol %s", name);
 		return NULL;
 	}
-#ifdef DEBUG
-	printf("symbol %s with address %p\n", name, mem);
-#endif
+	PMD_DRV_LOG(DEBUG, "symbol %s with address %p", name, mem);
 
 	return mem;
 }