DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFC 00/13] Replace static logtypes with static
@ 2023-02-07 20:41 Stephen Hemminger
  2023-02-07 20:41 ` [RFC 01/13] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
                   ` (22 more replies)
  0 siblings, 23 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This is a first draft and tackling the removal of static logtypes.

It starts with the easy one and goes on to the more complex ones.

It does not address the biggest effort which is the eal,
eventdev, cryptodev, and pmd log types.

Mostly this is semi-automatic conversion but some places like
hash required some additional steps.

Stephen Hemminger (13):
  doc: document intention to deprecate RTE_LOGTYPE_USER*
  gso: remove logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with local type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  hash: replace RTE_LOGTYPE_HASH with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type

 app/test/test_acl.c                           |   3 +-
 .../prog_guide/writing_efficient_code.rst     |   3 +-
 doc/guides/rel_notes/deprecation.rst          |   4 +
 lib/acl/acl.h                                 |   5 +
 lib/acl/acl_bld.c                             |  34 +-
 lib/acl/acl_gen.c                             |  19 +-
 lib/acl/rte_acl.c                             |  13 +-
 lib/acl/tb_mem.c                              |   9 +-
 lib/eal/common/eal_common_log.c               |  15 +-
 lib/eal/include/rte_log.h                     |  27 +-
 lib/efd/rte_efd.c                             | 106 +++----
 lib/fib/rte_fib.c                             |  23 +-
 lib/fib/rte_fib6.c                            |  21 +-
 lib/gso/rte_gso.c                             |   3 +-
 lib/hash/rte_cuckoo_hash.c                    |  60 ++--
 lib/hash/rte_fbk_hash.c                       |  10 +-
 lib/hash/rte_hash_crc.h                       |   6 +-
 lib/hash/rte_thash.c                          |  54 +++-
 lib/hash/rte_thash_gfni.h                     |  24 +-
 lib/hash/version.map                          |   4 +
 lib/kni/rte_kni.c                             |  63 ++--
 lib/lpm/rte_lpm.c                             |  18 +-
 lib/lpm/rte_lpm6.c                            |  25 +-
 lib/mbuf/mbuf_log.h                           |  10 +
 lib/mbuf/rte_mbuf.c                           |  20 +-
 lib/mbuf/rte_mbuf_dyn.c                       |  15 +-
 lib/mbuf/rte_mbuf_pool_ops.c                  |   5 +-
 lib/mempool/rte_mempool.c                     |  33 +-
 lib/mempool/rte_mempool_log.h                 |  10 +
 lib/mempool/rte_mempool_ops.c                 |  12 +-
 lib/power/guest_channel.c                     |  48 +--
 lib/power/power_acpi_cpufreq.c                | 118 +++----
 lib/power/power_common.c                      |  11 +-
 lib/power/power_common.h                      |   7 +-
 lib/power/power_cppc_cpufreq.c                | 129 ++++----
 lib/power/power_kvm_vm.c                      |  24 +-
 lib/power/power_pstate_cpufreq.c              | 166 +++++-----
 lib/power/rte_power.c                         |  25 +-
 lib/power/rte_power_empty_poll.c              |  36 +--
 lib/power/rte_power_intel_uncore.c            |  75 ++---
 lib/power/rte_power_pmd_mgmt.c                |  37 ++-
 lib/rib/rte_rib.c                             |  14 +-
 lib/rib/rte_rib6.c                            |  16 +-
 lib/ring/rte_ring.c                           |  31 +-
 lib/sched/rte_pie.c                           |  16 +-
 lib/sched/rte_sched.c                         | 297 +++++++-----------
 lib/sched/rte_sched_log.h                     |  11 +
 47 files changed, 915 insertions(+), 800 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 01/13] doc: document intention to deprecate RTE_LOGTYPE_USER*
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 02/13] gso: remove logtype Stephen Hemminger
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

These static log types should be deprecated in next stable
release.

Also, remove use of USER1 from example of doing mlockall.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 doc/guides/prog_guide/writing_efficient_code.rst | 3 +--
 doc/guides/rel_notes/deprecation.rst             | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/writing_efficient_code.rst b/doc/guides/prog_guide/writing_efficient_code.rst
index e6c26efdd3a3..250e06bd734f 100644
--- a/doc/guides/prog_guide/writing_efficient_code.rst
+++ b/doc/guides/prog_guide/writing_efficient_code.rst
@@ -89,8 +89,7 @@ To avoid these you could pre-load, and lock them into memory with the ``mlockall
 .. code-block:: c
 
     if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
-        RTE_LOG(NOTICE, USER1, "mlockall() failed with error \"%s\"\n",
-                strerror(errno));
+        perror("mlockall");
     }
 
 Communication Between lcores
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index ac9aa7630b61..935e68134d0e 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -136,3 +136,7 @@ Deprecation Notices
   Its removal has been postponed to let potential users report interest
   in maintaining it.
   In the absence of such interest, this library will be removed in DPDK 23.11.
+
+* rte_log: The pre-defined RTE_LOGTYPE_USER* macros are planned to be
+  deprecated starting with the 23.07 release. Applications should use the
+  dynamic log types available with RTE_LOG_REGISTER instead.
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 02/13] gso: remove logtype
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
  2023-02-07 20:41 ` [RFC 01/13] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 03/13] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Mark Kavanagh, Konstantin Ananyev

If a large packet is passed into GSO routines of unknown protocol
then library would log a message and pass it through. This is incorrect
behaviour on many levels:
  - it allows oversize packet to get passed on to NIC driver
  - no direct return is visible to applications
  - if it happens once, many more will follow and log will fill.
  - bonus it is only log message with GSO type.

The fix is to just return -EINVAL which is what this library
does in many other places when looking at headers.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 +-
 lib/eal/include/rte_log.h       | 1 -
 lib/gso/rte_gso.c               | 3 +--
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..c369154cb1ea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
+
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..97d6b26a9967 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,6 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..19c351769fcc 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
 		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -EINVAL;
 	}
 
 	if (ret < 0) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 03/13] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
  2023-02-07 20:41 ` [RFC 01/13] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
  2023-02-07 20:41 ` [RFC 02/13] gso: remove logtype Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 04/13] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index c369154cb1ea..e7ccde1c9ccd 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 97d6b26a9967..361d1ad96299 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 04/13] efd: replace RTE_LOGTYPE_EFD with local type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (2 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 03/13] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 05/13] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of global logtype with a local log type.
Do not break message formats across source lines.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   1 -
 lib/eal/include/rte_log.h       |   2 +-
 lib/efd/rte_efd.c               | 106 +++++++++++++++-----------------
 3 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index e7ccde1c9ccd..675f3d07bbe3 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 361d1ad96299..a90fa629168d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 
 /* these log types can be used in an application */
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..23316ef7300f 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -87,6 +87,11 @@ static struct rte_tailq_elem rte_efd_tailq = {
 };
 EAL_REGISTER_TAILQ(rte_efd_tailq);
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+
+#define EFD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args)
+
 /** Internal permutation array used to shuffle bins into pseudorandom groups */
 const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = {
 	{
@@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
 	if (online_cpu_socket_bitmask == 0) {
-		RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled "
-				"in the bitmask\n");
+		EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask");
 		return NULL;
 	}
 
 	if (max_num_rules == 0) {
-		RTE_LOG(ERR, EFD, "Max num rules must be higher than 0\n");
+		EFD_LOG(ERR, "Max num rules must be higher than 0");
 		return NULL;
 	}
 
@@ -554,7 +558,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te = rte_zmalloc("EFD_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, EFD, "tailq entry allocation failed\n");
+		EFD_LOG(ERR, "tailq entry allocation failed");
 		goto error_unlock_exit;
 	}
 
@@ -564,15 +568,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (table == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating EFD table management structure"
-				" on socket %u failed\n",
-				offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating EFD table management structureon socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 
 
-	RTE_LOG(DEBUG, EFD, "Allocated EFD table management structure "
-			"on socket %u\n", offline_cpu_socket);
+	EFD_LOG(DEBUG, "Allocated EFD table management structure on socket %u",
+		offline_cpu_socket);
 
 	table->max_num_rules = num_chunks * EFD_TARGET_CHUNK_MAX_NUM_RULES;
 	table->num_rules = 0;
@@ -586,17 +590,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (key_array == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating key array"
-				" on socket %u failed\n",
-				offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating key array on socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 	table->keys = key_array;
 	strlcpy(table->name, name, sizeof(table->name));
 
-	RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks,"
-			" which potentially supports %u entries\n",
-			num_chunks, table->max_num_rules);
+	EFD_LOG(DEBUG,
+		"Creating an EFD table with %u chunks, which potentially supports %u entries",
+		num_chunks, table->max_num_rules);
 
 	/* Make sure all the allocatable table pointers are NULL initially */
 	for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++)
@@ -623,19 +627,16 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 				RTE_CACHE_LINE_SIZE,
 				socket_id);
 			if (table->chunks[socket_id] == NULL) {
-				RTE_LOG(ERR, EFD,
-						"Allocating EFD online table on "
-						"socket %u failed\n",
-						socket_id);
+				EFD_LOG(ERR,
+					"Allocating EFD online table on socket %u failed",
+					socket_id);
 				goto error_unlock_exit;
 			}
-			RTE_LOG(DEBUG, EFD,
-					"Allocated EFD online table of size "
-					"%"PRIu64" bytes (%.2f MB) on socket %u\n",
-					online_table_size,
-					(float) online_table_size /
-						(1024.0F * 1024.0F),
-					socket_id);
+			EFD_LOG(DEBUG,
+				"Allocated EFD online table of size %" PRIu64 " bytes (%.2f MB) on socket %u",
+				online_table_size,
+				(float) online_table_size / (1024.0F * 1024.0F),
+				socket_id);
 		}
 	}
 
@@ -675,16 +676,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (table->offline_chunks == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating EFD offline table on socket %u "
-				"failed\n", offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating EFD offline table on socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 
-	RTE_LOG(DEBUG, EFD,
-			"Allocated EFD offline table of size %"PRIu64" bytes "
-			" (%.2f MB) on socket %u\n", offline_table_size,
-			(float) offline_table_size / (1024.0F * 1024.0F),
-			offline_cpu_socket);
+	EFD_LOG(DEBUG,
+		"Allocated EFD offline table of size %" PRIu64 " bytes  (%.2f MB) on socket %u",
+		offline_table_size,
+		(float) offline_table_size / (1024.0F * 1024.0F),
+		offline_cpu_socket);
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
@@ -695,7 +697,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules),
 			offline_cpu_socket, 0);
 	if (r == NULL) {
-		RTE_LOG(ERR, EFD, "memory allocation failed\n");
+		EFD_LOG(ERR, "ring memory allocation failed");
 		rte_efd_free(table);
 		return NULL;
 	}
@@ -1015,20 +1017,17 @@ efd_compute_update(struct rte_efd_table * const table,
 	if (found == 0) {
 		/* Key does not exist. Insert the rule into the bin/group */
 		if (unlikely(current_group->num_rules >= EFD_MAX_GROUP_NUM_RULES)) {
-			RTE_LOG(ERR, EFD,
-					"Fatal: No room remaining for insert into "
-					"chunk %u group %u bin %u\n",
-					*chunk_id,
-					current_group_id, *bin_id);
+			EFD_LOG(ERR,
+				"Fatal: No room remaining for insert into chunk %u group %u bin %u",
+				*chunk_id, current_group_id, *bin_id);
 			return RTE_EFD_UPDATE_FAILED;
 		}
 
 		if (unlikely(current_group->num_rules ==
 				(EFD_MAX_GROUP_NUM_RULES - 1))) {
-			RTE_LOG(INFO, EFD, "Warn: Insert into last "
-					"available slot in chunk %u "
-					"group %u bin %u\n", *chunk_id,
-					current_group_id, *bin_id);
+			EFD_LOG(NOTICE,
+			       "Insert into last available slot in chunk %u group %u bin %u",
+			       *chunk_id, current_group_id, *bin_id);
 			status = RTE_EFD_UPDATE_WARN_GROUP_FULL;
 		}
 
@@ -1112,14 +1111,11 @@ efd_compute_update(struct rte_efd_table * const table,
 	uint8_t choice = 0;
 	for (;;) {
 		if (current_group != new_group &&
-				new_group->num_rules + bin_size >
-					EFD_MAX_GROUP_NUM_RULES) {
-			RTE_LOG(DEBUG, EFD,
-					"Unable to move_groups to dest group "
-					"containing %u entries."
-					"bin_size:%u choice:%02x\n",
-					new_group->num_rules, bin_size,
-					choice - 1);
+		    new_group->num_rules + bin_size > EFD_MAX_GROUP_NUM_RULES) {
+			EFD_LOG(DEBUG,
+				"Unable to move_groups to dest group containing %u entries. bin_size:%u choice:%02x",
+				new_group->num_rules, bin_size,
+				choice - 1);
 			goto next_choice;
 		}
 		move_groups(*bin_id, bin_size, new_group, current_group);
@@ -1132,10 +1128,10 @@ efd_compute_update(struct rte_efd_table * const table,
 		if (!ret)
 			return status;
 
-		RTE_LOG(DEBUG, EFD,
-				"Failed to find perfect hash for group "
-				"containing %u entries. bin_size:%u choice:%02x\n",
-				new_group->num_rules, bin_size, choice - 1);
+		EFD_LOG(DEBUG,
+			"Failed to find perfect hash for group containing %u entries. bin_size:%u choice:%02x",
+			new_group->num_rules, bin_size, choice - 1);
+
 		/* Restore groups modified to their previous state */
 		revert_groups(current_group, new_group, bin_size);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 05/13] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (3 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 04/13] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 06/13] acl: replace LOGTYPE_ACL " Stephen Hemminger
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mbuf/mbuf_log.h             | 10 ++++++++++
 lib/mbuf/rte_mbuf.c             | 20 ++++++++++++--------
 lib/mbuf/rte_mbuf_dyn.c         | 15 ++++++++-------
 lib/mbuf/rte_mbuf_pool_ops.c    |  5 +++--
 6 files changed, 34 insertions(+), 19 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 675f3d07bbe3..128bfabd94e1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a90fa629168d..1f259b2abc5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..fe97f338c9b7
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mbuf_logtype;
+
+#define MBUF_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, mbuf_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..133fd3ba55be 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,8 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
@@ -227,8 +229,8 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n,
 	int ret;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
-		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
-			priv_size);
+		MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned",
+			 priv_size);
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -247,7 +249,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n,
 		mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+		MBUF_LOG(ERR, "error setting mempool handler");
 		rte_mempool_free(mp);
 		rte_errno = -ret;
 		return NULL;
@@ -293,7 +295,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	int ret;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
-		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
+		MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned",
 			priv_size);
 		rte_errno = EINVAL;
 		return NULL;
@@ -303,12 +305,12 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 		const struct rte_pktmbuf_extmem *extm = ext_mem + i;
 
 		if (!extm->elt_size || !extm->buf_len || !extm->buf_ptr) {
-			RTE_LOG(ERR, MBUF, "invalid extmem descriptor\n");
+			MBUF_LOG(ERR, "invalid extmem descriptor");
 			rte_errno = EINVAL;
 			return NULL;
 		}
 		if (data_room_size > extm->elt_size) {
-			RTE_LOG(ERR, MBUF, "ext elt_size=%u is too small\n",
+			MBUF_LOG(ERR, "ext elt_size=%u is too small",
 				priv_size);
 			rte_errno = EINVAL;
 			return NULL;
@@ -317,7 +319,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	}
 	/* Check whether enough external memory provided. */
 	if (n_elts < n) {
-		RTE_LOG(ERR, MBUF, "not enough extmem\n");
+		MBUF_LOG(ERR, "not enough extmem");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -338,7 +340,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+		MBUF_LOG(ERR, "error setting mempool handler");
 		rte_mempool_free(mp);
 		rte_errno = -ret;
 		return NULL;
@@ -936,3 +938,5 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 
 	return 0;
 }
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..ef8d6069b37a 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
@@ -116,7 +118,7 @@ init_shared_mem(void)
 		mz = rte_memzone_lookup(RTE_MBUF_DYN_MZNAME);
 	}
 	if (mz == NULL) {
-		RTE_LOG(ERR, MBUF, "Failed to get mbuf dyn shared memory\n");
+		MBUF_LOG(ERR, "Failed to get mbuf dyn shared memory");
 		return -1;
 	}
 
@@ -315,7 +317,8 @@ __rte_mbuf_dynfield_register_offset(const struct rte_mbuf_dynfield *params,
 		shm->free_space[i] = 0;
 	process_score();
 
-	RTE_LOG(DEBUG, MBUF, "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd\n",
+	MBUF_LOG(DEBUG,
+		 "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd",
 		params->name, params->size, params->align, params->flags,
 		offset);
 
@@ -489,7 +492,7 @@ __rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params,
 
 	shm->free_flags &= ~(1ULL << bitnum);
 
-	RTE_LOG(DEBUG, MBUF, "Registered dynamic flag %s (fl=0x%x) -> %u\n",
+	MBUF_LOG(DEBUG, "Registered dynamic flag %s (fl=0x%x) -> %u",
 		params->name, params->flags, bitnum);
 
 	return bitnum;
@@ -590,8 +593,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag,
 
 	offset = rte_mbuf_dynfield_register(&field_desc);
 	if (offset < 0) {
-		RTE_LOG(ERR, MBUF,
-			"Failed to register mbuf field for timestamp\n");
+		MBUF_LOG(ERR, "Failed to register mbuf field for timestamp");
 		return -1;
 	}
 	if (field_offset != NULL)
@@ -600,8 +602,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag,
 	strlcpy(flag_desc.name, flag_name, sizeof(flag_desc.name));
 	offset = rte_mbuf_dynflag_register(&flag_desc);
 	if (offset < 0) {
-		RTE_LOG(ERR, MBUF,
-			"Failed to register mbuf flag for %s timestamp\n",
+		MBUF_LOG(ERR, "Failed to register mbuf flag for %s timestamp",
 			direction);
 		return -1;
 	}
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..8ec2710dc86d 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
@@ -31,8 +33,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 		return 0;
 	}
 
-	RTE_LOG(ERR, MBUF,
-		"%s is already registered as platform mbuf pool ops\n",
+	MBUF_LOG(ERR, "%s is already registered as platform mbuf pool ops",
 		(char *)mz->addr);
 	return -EEXIST;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 06/13] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (4 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 05/13] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 07/13] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             |  3 ++-
 lib/acl/acl.h                   |  5 +++++
 lib/acl/acl_bld.c               | 34 ++++++++++++++++-----------------
 lib/acl/acl_gen.c               | 19 +++++++++---------
 lib/acl/rte_acl.c               | 13 ++++++++-----
 lib/acl/tb_mem.c                |  9 +++++++--
 lib/eal/common/eal_common_log.c |  2 --
 lib/eal/include/rte_log.h       |  4 ++--
 8 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl.h b/lib/acl/acl.h
index f5739a475cf0..1b64aa65edfe 100644
--- a/lib/acl/acl.h
+++ b/lib/acl/acl.h
@@ -9,6 +9,11 @@
 extern"C" {
 #endif /* __cplusplus */
 
+extern int acl_logtype;
+#define ACL_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, acl_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define RTE_ACL_QUAD_MAX	5
 #define RTE_ACL_QUAD_SIZE	4
 #define RTE_ACL_QUAD_SINGLE	UINT64_C(0x7f7f7f7f00000000)
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..0e29dc886c93 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -1014,8 +1014,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
 				break;
 
 			default:
-				RTE_LOG(ERR, ACL,
-					"Error in rule[%u] type - %hhu\n",
+				ACL_LOG(ERR,
+					"Error in rule[%u] type - %hhu",
 					rule->f->data.userdata,
 					rule->config->defs[n].type);
 				return NULL;
@@ -1371,7 +1371,7 @@ acl_build_tries(struct acl_build_context *context,
 
 		last = build_one_trie(context, rule_sets, n, context->node_max);
 		if (context->bld_tries[n].trie == NULL) {
-			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
+			ACL_LOG(ERR, "Build of %u-th trie failed", n);
 			return -ENOMEM;
 		}
 
@@ -1380,8 +1380,7 @@ acl_build_tries(struct acl_build_context *context,
 			break;
 
 		if (num_tries == RTE_DIM(context->tries)) {
-			RTE_LOG(ERR, ACL,
-				"Exceeded max number of tries: %u\n",
+			ACL_LOG(ERR, "Exceeded max number of tries: %u",
 				num_tries);
 			return -ENOMEM;
 		}
@@ -1406,7 +1405,7 @@ acl_build_tries(struct acl_build_context *context,
 		 */
 		last = build_one_trie(context, rule_sets, n, INT32_MAX);
 		if (context->bld_tries[n].trie == NULL || last != NULL) {
-			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
+			ACL_LOG(ERR, "Build of %u-th trie failed", n);
 			return -ENOMEM;
 		}
 
@@ -1421,10 +1420,11 @@ acl_build_log(const struct acl_build_context *ctx)
 {
 	uint32_t n;
 
-	RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n"
+	ACL_LOG(DEBUG,
+		"Build phase for ACL \"%s\":\n"
 		"node limit for tree split: %u\n"
 		"nodes created: %u\n"
-		"memory consumed: %zu\n",
+		"memory consumed: %zu",
 		ctx->acx->name,
 		ctx->node_max,
 		ctx->num_nodes,
@@ -1432,7 +1432,7 @@ acl_build_log(const struct acl_build_context *ctx)
 
 	for (n = 0; n < RTE_DIM(ctx->tries); n++) {
 		if (ctx->tries[n].count != 0)
-			RTE_LOG(DEBUG, ACL,
+			ACL_LOG(DEBUG,
 				"trie %u: number of rules: %u, indexes: %u\n",
 				n, ctx->tries[n].count,
 				ctx->tries[n].num_data_indexes);
@@ -1523,8 +1523,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
 
 	/* build phase runs out of memory. */
 	if (rc != 0) {
-		RTE_LOG(ERR, ACL,
-			"ACL context: %s, %s() failed with error code: %d\n",
+		ACL_LOG(ERR,
+			"ACL context: %s, %s() failed with error code: %d",
 			bcx->acx->name, __func__, rc);
 		return rc;
 	}
@@ -1565,9 +1565,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 
 	for (i = 0; i != cfg->num_fields; i++) {
 		if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) {
-			RTE_LOG(ERR, ACL,
-			"ACL context: %s, invalid type: %hhu for %u-th field\n",
-			ctx->name, cfg->defs[i].type, i);
+			ACL_LOG(ERR,
+				"ACL context: %s, invalid type: %hhu for %u-th field",
+				ctx->name, cfg->defs[i].type, i);
 			return -EINVAL;
 		}
 		for (j = 0;
@@ -1577,9 +1577,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 			;
 
 		if (j == RTE_DIM(field_sizes)) {
-			RTE_LOG(ERR, ACL,
-			"ACL context: %s, invalid size: %hhu for %u-th field\n",
-			ctx->name, cfg->defs[i].size, i);
+			ACL_LOG(ERR,
+				"ACL context: %s, invalid size: %hhu for %u-th field\n",
+				ctx->name, cfg->defs[i].size, i);
 			return -EINVAL;
 		}
 	}
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..8d2a5451b0d5 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -32,18 +32,19 @@ struct rte_acl_indices {
 
 static void
 acl_gen_log_stats(const struct rte_acl_ctx *ctx,
-	const struct acl_node_counters *counts,
-	const struct rte_acl_indices *indices,
-	size_t max_size)
+		  const struct acl_node_counters *counts,
+		  const struct rte_acl_indices *indices,
+		  size_t max_size)
 {
-	RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n"
+	ACL_LOG(DEBUG,
+		"Gen phase for ACL \"%s\":\n"
 		"runtime memory footprint on socket %d:\n"
 		"single nodes/bytes used: %d/%zu\n"
 		"quad nodes/vectors/bytes used: %d/%d/%zu\n"
 		"DFA nodes/group64/bytes used: %d/%d/%zu\n"
 		"match nodes/bytes used: %d/%zu\n"
 		"total: %zu bytes\n"
-		"max limit: %zu bytes\n",
+		"max limit: %zu bytes",
 		ctx->name, ctx->socket_id,
 		counts->single, counts->single * sizeof(uint64_t),
 		counts->quad, counts->quad_vectors,
@@ -470,9 +471,9 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
 		XMM_SIZE;
 
 	if (total_size > max_size) {
-		RTE_LOG(DEBUG, ACL,
+		ACL_LOG(DEBUG,
 			"Gen phase for ACL ctx \"%s\" exceeds max_size limit, "
-			"bytes required: %zu, allowed: %zu\n",
+			"bytes required: %zu, allowed: %zu",
 			ctx->name, total_size, max_size);
 		return -ERANGE;
 	}
@@ -480,8 +481,8 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
 	mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE,
 			ctx->socket_id);
 	if (mem == NULL) {
-		RTE_LOG(ERR, ACL,
-			"allocation of %zu bytes on socket %d for %s failed\n",
+		ACL_LOG(ERR,
+			"allocation of %zu bytes on socket %d for %s failed",
 			total_size, ctx->socket_id, ctx->name);
 		return -ENOMEM;
 	}
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..9cc94b6f9633 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,6 +6,7 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
 
@@ -400,15 +401,15 @@ rte_acl_create(const struct rte_acl_param *param)
 		te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
 
 		if (te == NULL) {
-			RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
+			ACL_LOG(ERR, "Cannot allocate tailq entry!");
 			goto exit;
 		}
 
 		ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id);
 
 		if (ctx == NULL) {
-			RTE_LOG(ERR, ACL,
-				"allocation of %zu bytes on socket %d for %s failed\n",
+			ACL_LOG(ERR,
+				"allocation of %zu bytes on socket %d for %s failed",
 				sz, param->socket_id, name);
 			rte_free(te);
 			goto exit;
@@ -474,8 +475,8 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules,
 			((uintptr_t)rules + i * ctx->rule_sz);
 		rc = acl_check_rule(&rv->data);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n",
-				__func__, ctx->name, i + 1);
+			ACL_LOG(ERR, "%s: rule #%u is invalid",
+				ctx->name, i + 1);
 			return rc;
 		}
 	}
@@ -544,3 +545,5 @@ rte_acl_list_dump(void)
 	}
 	rte_mcfg_tailq_read_unlock();
 }
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..a62e664e1224 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -4,6 +4,8 @@
 
 #include "tb_mem.h"
 
+#include <rte_log.h>
+
 /*
  *  Memory management routines for temporary memory.
  *  That memory is used only during build phase and is released after
@@ -15,6 +17,8 @@
  *  in the pool->fail before calling tb_alloc() for the given pool first time.
  */
 
+extern int acl_logtype;
+
 static struct tb_mem_block *
 tb_pool(struct tb_mem_pool *pool, size_t sz)
 {
@@ -25,8 +29,9 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
-			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
+		rte_log(RTE_LOG_ERR, acl_logtype,
+			"%s(%zu)\n failed, currently allocated by pool: %zu bytes\n",
+			__func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
 	}
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 128bfabd94e1..871f2c38298c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1f259b2abc5a..d707098b6359 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 07/13] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (5 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 06/13] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 08/13] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c    |   1 -
 lib/eal/include/rte_log.h          |   2 +-
 lib/power/guest_channel.c          |  48 +++++----
 lib/power/power_acpi_cpufreq.c     | 118 ++++++++++----------
 lib/power/power_common.c           |  11 +-
 lib/power/power_common.h           |   7 +-
 lib/power/power_cppc_cpufreq.c     | 129 +++++++++++-----------
 lib/power/power_kvm_vm.c           |  24 +++--
 lib/power/power_pstate_cpufreq.c   | 166 ++++++++++++++++-------------
 lib/power/rte_power.c              |  25 +++--
 lib/power/rte_power_empty_poll.c   |  36 +++----
 lib/power/rte_power_intel_uncore.c |  75 ++++++-------
 lib/power/rte_power_pmd_mgmt.c     |  37 ++++---
 13 files changed, 365 insertions(+), 314 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 871f2c38298c..7dbf1df3b979 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index d707098b6359..5b7850af4e2b 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..647ca6c3ef5d 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,11 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(guest_channel_logtype, "power.guest", INFO);
+
+#define GUEST_LOG(level, fmt, args...)				\
+	rte_log(RTE_LOG_ ## level, guest_channel_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
@@ -58,38 +62,38 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
 	int fd = -1;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 	/* check if path is already open */
 	if (global_fds[lcore_id] != -1) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is already open with fd %d\n",
+		GUEST_LOG(ERR, "Channel(%u) is already open with fd %d",
 				lcore_id, global_fds[lcore_id]);
 		return -1;
 	}
 
 	snprintf(fd_path, PATH_MAX, "%s.%u", path, lcore_id);
-	RTE_LOG(INFO, GUEST_CHANNEL, "Opening channel '%s' for lcore %u\n",
+	GUEST_LOG(INFO, "Opening channel '%s' for lcore %u",
 			fd_path, lcore_id);
 	fd = open(fd_path, O_RDWR);
 	if (fd < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Unable to to connect to '%s' with error "
-				"%s\n", fd_path, strerror(errno));
+		GUEST_LOG(ERR, "Unable to to connect to '%s' with error %s",
+			  fd_path, strerror(errno));
 		return -1;
 	}
 
 	flags = fcntl(fd, F_GETFL, 0);
 	if (flags < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Failed on fcntl get flags for file %s\n",
+		GUEST_LOG(ERR, "Failed on fcntl get flags for file %s",
 				fd_path);
 		goto error;
 	}
 
 	flags |= O_NONBLOCK;
 	if (fcntl(fd, F_SETFL, flags) < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Failed on setting non-blocking mode for "
-				"file %s", fd_path);
+		GUEST_LOG(ERR, "Failed on setting non-blocking mode for file %s",
+			  fd_path);
 		goto error;
 	}
 	/* QEMU needs a delay after connection */
@@ -102,13 +106,13 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
 	global_fds[lcore_id] = fd;
 	ret = guest_channel_send_msg(&pkt, lcore_id);
 	if (ret != 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL,
-				"Error on channel '%s' communications test: %s\n",
-				fd_path, ret > 0 ? strerror(ret) :
-				"channel not connected");
+		GUEST_LOG(ERR,
+			  "Error on channel '%s' communications test: %s",
+			  fd_path, ret > 0 ? strerror(ret) :
+			  "channel not connected");
 		goto error;
 	}
-	RTE_LOG(INFO, GUEST_CHANNEL, "Channel '%s' is now connected\n", fd_path);
+	GUEST_LOG(INFO, "Channel '%s' is now connected", fd_path);
 	return 0;
 error:
 	close(fd);
@@ -124,13 +128,13 @@ guest_channel_send_msg(struct rte_power_channel_packet *pkt,
 	void *buffer = pkt;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 
 	if (global_fds[lcore_id] < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
+		GUEST_LOG(ERR, "Channel is not connected");
 		return -1;
 	}
 	while (buffer_len > 0) {
@@ -165,13 +169,13 @@ int power_guest_channel_read_msg(void *pkt,
 		return -1;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 
 	if (global_fds[lcore_id] < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
+		GUEST_LOG(ERR, "Channel is not connected");
 		return -1;
 	}
 
@@ -180,10 +184,10 @@ int power_guest_channel_read_msg(void *pkt,
 
 	ret = poll(&fds, 1, TIMEOUT);
 	if (ret == 0) {
-		RTE_LOG(DEBUG, GUEST_CHANNEL, "Timeout occurred during poll function.\n");
+		GUEST_LOG(DEBUG, "Timeout occurred during poll function.");
 		return -1;
 	} else if (ret < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n",
+		GUEST_LOG(ERR, "Error occurred during poll function: %s",
 				strerror(errno));
 		return -1;
 	}
@@ -199,7 +203,7 @@ int power_guest_channel_read_msg(void *pkt,
 		}
 
 		if (ret == 0) {
-			RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n");
+			GUEST_LOG(ERR, "Expected more data, but connection has been closed.");
 			return -1;
 		}
 		pkt = (char *)pkt + ret;
@@ -220,7 +224,7 @@ void
 guest_channel_host_disconnect(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return;
 	}
diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c
index 6e57aca53513..3643044d9ef0 100644
--- a/lib/power/power_acpi_cpufreq.c
+++ b/lib/power/power_acpi_cpufreq.c
@@ -62,8 +62,9 @@ static int
 set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
 {
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -74,13 +75,15 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
 	POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n",
 			idx, pi->freqs[idx], pi->lcore_id);
 	if (fseek(pi->f, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-				"lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to write new frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	fflush(pi->f);
@@ -126,14 +129,14 @@ power_get_available_freqs(struct acpi_power_info *pi)
 
 	open_core_sysfs_file(&f, "r", POWER_SYSFILE_AVAIL_FREQ, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_AVAIL_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if ((ret) < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_AVAIL_FREQ);
 		goto out;
 	}
@@ -142,12 +145,13 @@ power_get_available_freqs(struct acpi_power_info *pi)
 	count = rte_strsplit(buf, sizeof(buf), freqs,
 			RTE_MAX_LCORE_FREQS, ' ');
 	if (count <= 0) {
-		RTE_LOG(ERR, POWER, "No available frequency in "
-				""POWER_SYSFILE_AVAIL_FREQ"\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "No available frequency in " POWER_SYSFILE_AVAIL_FREQ,
+			  pi->lcore_id);
 		goto out;
 	}
 	if (count >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n",
+		POWER_LOG(ERR, "Too many available frequencies : %d",
 				count);
 		goto out;
 	}
@@ -195,14 +199,14 @@ power_init_for_setting_freq(struct acpi_power_info *pi)
 
 	open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "Failed to open %s\n",
+		POWER_LOG(ERR, "Failed to open %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if ((ret) < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
@@ -236,7 +240,7 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -252,42 +256,47 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_userspace(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"userspace\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set governor of lcore %u to userspace",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -309,7 +318,7 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -324,8 +333,8 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used", lcore_id);
 		return -1;
 	}
 
@@ -335,14 +344,15 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'userspace' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'userspace' mode and been set back to the original",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -363,18 +373,18 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -386,7 +396,7 @@ uint32_t
 power_acpi_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -397,7 +407,7 @@ int
 power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -410,7 +420,7 @@ power_acpi_cpufreq_freq_down(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -428,7 +438,7 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -445,7 +455,7 @@ int
 power_acpi_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -469,7 +479,7 @@ power_acpi_cpufreq_freq_min(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -486,7 +496,7 @@ power_acpi_turbo_status(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -502,7 +512,7 @@ power_acpi_enable_turbo(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -512,16 +522,16 @@ power_acpi_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
+		POWER_LOG(ERR,
+			"Failed to enable turbo on lcore %u",
 			lcore_id);
 			return -1;
 	}
 
 	/* Max may have changed, so call to max function */
 	if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER,
-			"Failed to set frequency of lcore %u to max\n",
+		POWER_LOG(ERR,
+			"Failed to set frequency of lcore %u to max",
 			lcore_id);
 			return -1;
 	}
@@ -535,7 +545,7 @@ power_acpi_disable_turbo(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -546,8 +556,8 @@ power_acpi_disable_turbo(unsigned int lcore_id)
 	if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -562,11 +572,11 @@ int power_acpi_get_capabilities(unsigned int lcore_id,
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..3a374f6b8431 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -161,14 +161,14 @@ power_set_governor(unsigned int lcore_id, const char *new_governor,
 	open_core_sysfs_file(&f_governor, "rw+", POWER_SYSFILE_GOVERNOR,
 			lcore_id);
 	if (f_governor == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
 
 	ret = read_core_sysfs_s(f_governor, buf, sizeof(buf));
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
@@ -188,14 +188,15 @@ power_set_governor(unsigned int lcore_id, const char *new_governor,
 	/* Write the new governor */
 	ret = write_core_sysfs_s(f_governor, new_governor);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to write %s\n",
+		POWER_LOG(ERR, "Failed to write %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
 
 	ret = 0;
-	RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been "
-			"set to '%s' successfully\n", lcore_id, new_governor);
+	POWER_LOG(INFO,
+		  "Power management governor of lcore %u has been set to '%s' successfully",
+		  lcore_id, new_governor);
 out:
 	if (f_governor != NULL)
 		fclose(f_governor);
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..8e5309bbbaff 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -10,10 +10,15 @@
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+
+#define POWER_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, power_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
-		RTE_LOG(ERR, POWER, "%s: " fmt, __func__, ## args)
+	POWER_LOG(ERR, fmt, ## args)
 #else
 #define POWER_DEBUG_TRACE(fmt, args...)
 #endif
diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c
index fc9cffef91a8..7ffda90ce7a7 100644
--- a/lib/power/power_cppc_cpufreq.c
+++ b/lib/power/power_cppc_cpufreq.c
@@ -72,8 +72,9 @@ static int
 set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
 {
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -84,13 +85,15 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
 	POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n",
 			idx, pi->freqs[idx], pi->lcore_id);
 	if (fseek(pi->f, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-			"for setting frequency for lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-				"lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to write new frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	fflush(pi->f);
@@ -121,7 +124,7 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_HIGHEST_PERF,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_HIGHEST_PERF);
 		goto err;
 	}
@@ -129,7 +132,7 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_nom, "r", POWER_SYSFILE_NOMINAL_PERF,
 			pi->lcore_id);
 	if (f_nom == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_NOMINAL_PERF);
 		goto err;
 	}
@@ -137,28 +140,28 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_cmax, "r", POWER_SYSFILE_SYS_MAX,
 			pi->lcore_id);
 	if (f_cmax == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SYS_MAX);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_max, &highest_perf);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_HIGHEST_PERF);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_nom, &nominal_perf);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_NOMINAL_PERF);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_cmax, &cpuinfo_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SYS_MAX);
 		goto err;
 	}
@@ -208,7 +211,7 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_SCALING_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SCALING_MAX_FREQ);
 		goto out;
 	}
@@ -216,21 +219,21 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_SCALING_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SCALING_MIN_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_max, &scaling_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SCALING_MAX_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_min, &scaling_min_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SCALING_MIN_FREQ);
 		goto out;
 	}
@@ -248,7 +251,7 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 +
 		pi->turbo_available;
 	if (num_freqs >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available frequencies: %d",
 				num_freqs);
 		goto out;
 	}
@@ -289,14 +292,14 @@ power_init_for_setting_freq(struct cppc_power_info *pi)
 
 	open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
@@ -340,7 +343,7 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -356,42 +359,46 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_userspace(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"userspace\n", lcore_id);
+		POWER_LOG(ERR, "Cannot set governor of lcore %u to userspace",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 
 	__atomic_store_n(&(pi->state), POWER_USED, __ATOMIC_RELEASE);
 
@@ -419,7 +426,7 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -434,8 +441,9 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used",
+			  lcore_id);
 		return -1;
 	}
 
@@ -445,14 +453,15 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'userspace' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'userspace' mode and been set back to the original",
+		  lcore_id);
 	__atomic_store_n(&(pi->state), POWER_IDLE, __ATOMIC_RELEASE);
 
 	return 0;
@@ -469,18 +478,18 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -492,7 +501,7 @@ uint32_t
 power_cppc_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -503,7 +512,7 @@ int
 power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -516,7 +525,7 @@ power_cppc_cpufreq_freq_down(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -534,7 +543,7 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -551,7 +560,7 @@ int
 power_cppc_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -575,7 +584,7 @@ power_cppc_cpufreq_freq_min(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -591,7 +600,7 @@ power_cppc_turbo_status(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -606,7 +615,7 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -616,8 +625,8 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
+		POWER_LOG(ERR,
+			"Failed to enable turbo on lcore %u",
 			lcore_id);
 		return -1;
 	}
@@ -627,8 +636,8 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 	 */
 	/* Max may have changed, so call to max function */
 	if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER,
-			"Failed to set frequency of lcore %u to max\n",
+		POWER_LOG(ERR,
+			"Failed to set frequency of lcore %u to max",
 			lcore_id);
 		return -1;
 	}
@@ -642,7 +651,7 @@ power_cppc_disable_turbo(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -653,8 +662,8 @@ power_cppc_disable_turbo(unsigned int lcore_id)
 	if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -670,11 +679,11 @@ power_cppc_get_capabilities(unsigned int lcore_id,
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..74a1094ffaa0 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -24,7 +25,7 @@ int
 power_kvm_vm_init(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+		POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
@@ -45,16 +46,16 @@ power_kvm_vm_freqs(__rte_unused unsigned int lcore_id,
 		__rte_unused uint32_t *freqs,
 		__rte_unused uint32_t num)
 {
-	RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
 uint32_t
 power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id)
 {
-	RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -62,8 +63,8 @@ int
 power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id,
 		__rte_unused uint32_t index)
 {
-	RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -73,7 +74,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 	int ret;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+		POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
@@ -81,7 +82,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 	ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
 	if (ret == 0)
 		return 1;
-	RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
+	POWER_LOG(DEBUG, "Error sending message: %s",
 			ret > 0 ? strerror(ret) : "channel not connected");
 	return -1;
 }
@@ -113,7 +114,7 @@ power_kvm_vm_freq_min(unsigned int lcore_id)
 int
 power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id)
 {
-	RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
+	POWER_LOG(ERR, "rte_power_turbo_status is not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -133,6 +134,7 @@ struct rte_power_core_capabilities;
 int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,
 		__rte_unused struct rte_power_core_capabilities *caps)
 {
-	RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "rte_power_get_capabilities is not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index 52aa64510e21..c6869bbd3c59 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -81,7 +81,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	fd = open(POWER_SYSFILE_TURBO_PCT, O_RDONLY);
 
 	if (fd < 0) {
-		RTE_LOG(ERR, POWER, "Error opening '%s': %s\n", POWER_SYSFILE_TURBO_PCT,
+		POWER_LOG(ERR, "Error opening '%s': %s", POWER_SYSFILE_TURBO_PCT,
 				 strerror(errno));
 		return fd;
 	}
@@ -89,7 +89,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	ret = read(fd, val, sizeof(val));
 
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Error reading '%s': %s\n", POWER_SYSFILE_TURBO_PCT,
+		POWER_LOG(ERR, "Error reading '%s': %s", POWER_SYSFILE_TURBO_PCT,
 				 strerror(errno));
 		goto out;
 	}
@@ -97,7 +97,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	errno = 0;
 	*outVal = (uint64_t) strtol(val, &endptr, 10);
 	if (errno != 0 || (*endptr != 0 && *endptr != '\n')) {
-		RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n",
+		POWER_LOG(ERR, "Error converting str to digits, read from %s: %s",
 				 POWER_SYSFILE_TURBO_PCT, strerror(errno));
 		ret = -1;
 		goto out;
@@ -125,7 +125,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_base_max, "r", POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_base_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -133,7 +133,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_base_min, "r", POWER_SYSFILE_BASE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_base_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
@@ -141,7 +141,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_min, "rw+", POWER_SYSFILE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_MIN_FREQ);
 		goto err;
 	}
@@ -149,7 +149,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_max, "rw+", POWER_SYSFILE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_MAX_FREQ);
 		goto err;
 	}
@@ -161,7 +161,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	/* read base max ratio */
 	ret = read_core_sysfs_u32(f_base_max, &base_max_ratio);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -169,7 +169,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	/* read base min ratio */
 	ret = read_core_sysfs_u32(f_base_min, &base_min_ratio);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
@@ -178,7 +178,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	if (f_base != NULL) {
 		ret = read_core_sysfs_u32(f_base, &base_ratio);
 		if (ret < 0) {
-			RTE_LOG(ERR, POWER, "Failed to read %s\n",
+			POWER_LOG(ERR, "Failed to read %s",
 					POWER_SYSFILE_BASE_FREQ);
 			goto err;
 		}
@@ -256,8 +256,9 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	uint32_t target_freq = 0;
 
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -269,16 +270,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	 * User need change the min/max as same value.
 	 */
 	if (fseek(pi->f_cur_min, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n",
-				pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 
 	if (fseek(pi->f_cur_max, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n",
-				pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 
@@ -287,7 +288,8 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 		if (pi->turbo_enable)
 			target_freq = pi->sys_max_freq;
 		else {
-			RTE_LOG(ERR, POWER, "Turbo is off, frequency can't be scaled up more %u\n",
+			POWER_LOG(ERR,
+				  "Turbo is off, frequency can't be scaled up more %u",
 					pi->lcore_id);
 			return -1;
 		}
@@ -298,14 +300,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	if (idx  >  pi->curr_idx) {
 
 		if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
 		if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
@@ -321,14 +325,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	if (idx  <  pi->curr_idx) {
 
 		if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
 		if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
@@ -383,7 +389,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto out;
 	}
@@ -391,7 +397,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_BASE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto out;
 	}
@@ -399,14 +405,14 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	/* read base ratios */
 	ret = read_core_sysfs_u32(f_max, &sys_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_min, &sys_min_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto out;
 	}
@@ -449,7 +455,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	num_freqs = (RTE_MIN(base_max_freq, sys_max_freq) - sys_min_freq) / BUS_FREQ
 			+ 1 + pi->turbo_available;
 	if (num_freqs >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available frequencies: %d",
 				num_freqs);
 		goto out;
 	}
@@ -493,14 +499,14 @@ power_get_cur_idx(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_cur, "r", POWER_SYSFILE_CUR_FREQ,
 			pi->lcore_id);
 	if (f_cur == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_CUR_FREQ);
 		goto fail;
 	}
 
 	ret = read_core_sysfs_u32(f_cur, &sys_cur_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_CUR_FREQ);
 		goto fail;
 	}
@@ -542,7 +548,7 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceed %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceed %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -558,47 +564,52 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_performance(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"performance\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set governor of lcore %u to performance",
+			  lcore_id);
 		goto fail;
 	}
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	if (power_get_cur_idx(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get current frequency "
-				"index of lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get current frequency index of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_pstate_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max", lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -620,7 +631,7 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -636,8 +647,8 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used", lcore_id);
 		return -1;
 	}
 
@@ -649,14 +660,15 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'performance' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'performance' mode and been set back to the original",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -678,18 +690,18 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -701,7 +713,7 @@ uint32_t
 power_pstate_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -713,7 +725,7 @@ int
 power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -726,7 +738,7 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -745,7 +757,7 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -761,7 +773,7 @@ int
 power_pstate_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -786,7 +798,7 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -803,7 +815,7 @@ power_pstate_turbo_status(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -818,7 +830,7 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -828,10 +840,10 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
-			lcore_id);
-			return -1;
+		POWER_LOG(ERR,
+			  "Failed to enable turbo on lcore %u",
+			  lcore_id);
+		return -1;
 	}
 
 	return 0;
@@ -844,7 +856,7 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -855,8 +867,8 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 	if (pi->turbo_available && pi->curr_idx <= 1) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_pstate_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -872,11 +884,11 @@ int power_pstate_get_capabilities(unsigned int lcore_id,
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..23a97fa77f53 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
@@ -70,7 +71,7 @@ rte_power_set_env(enum power_management_env env)
 	rte_spinlock_lock(&global_env_cfg_lock);
 
 	if (global_default_env != PM_ENV_NOT_SET) {
-		RTE_LOG(ERR, POWER, "Power Management Environment already set.\n");
+		POWER_LOG(ERR, "Power Management Environment already set.");
 		rte_spinlock_unlock(&global_env_cfg_lock);
 		return -1;
 	}
@@ -127,7 +128,7 @@ rte_power_set_env(enum power_management_env env)
 		rte_power_freq_disable_turbo = power_cppc_disable_turbo;
 		rte_power_get_capabilities = power_cppc_get_capabilities;
 	} else {
-		RTE_LOG(ERR, POWER, "Invalid Power Management Environment(%d) set\n",
+		POWER_LOG(ERR, "Invalid Power Management Environment(%d) set",
 				env);
 		ret = -1;
 	}
@@ -172,39 +173,40 @@ rte_power_init(unsigned int lcore_id)
 	case PM_ENV_CPPC_CPUFREQ:
 		return power_cppc_cpufreq_init(lcore_id);
 	default:
-		RTE_LOG(INFO, POWER, "Env isn't set yet!\n");
+		POWER_LOG(INFO, "Env isn't set yet!");
 	}
 
 	/* Auto detect Environment */
-	RTE_LOG(INFO, POWER, "Attempting to initialise ACPI cpufreq power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management...");
 	ret = power_acpi_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise PSTAT power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise PSTAT power management...");
 	ret = power_pstate_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_PSTATE_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise CPPC power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise CPPC power management...");
 	ret = power_cppc_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_CPPC_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise VM power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise VM power management...");
 	ret = power_kvm_vm_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_KVM_VM);
 		goto out;
 	}
-	RTE_LOG(ERR, POWER, "Unable to set Power Management Environment for lcore "
-			"%u\n", lcore_id);
+	POWER_LOG(ERR,
+		  "Unable to set Power Management Environment for lcore %u",
+		  lcore_id);
 out:
 	return ret;
 }
@@ -222,9 +224,12 @@ rte_power_exit(unsigned int lcore_id)
 	case PM_ENV_CPPC_CPUFREQ:
 		return power_cppc_cpufreq_exit(lcore_id);
 	default:
-		RTE_LOG(ERR, POWER, "Environment has not been set, unable to exit gracefully\n");
+		POWER_LOG(ERR,
+			  "Environment has not been set, unable to exit gracefully");
 
 	}
 	return -1;
 
 }
+
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..da4b1ec3068a 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
@@ -75,7 +76,7 @@ enter_normal_state(struct priority_worker *poll_stats)
 	poll_stats->iter_counter = 0;
 	poll_stats->threshold_ctr = 0;
 	poll_stats->queue_state = MED_NORMAL;
-	RTE_LOG(INFO, POWER, "Set the power freq to MED\n");
+	POWER_LOG(INFO, "Set the power freq to MED");
 	set_power_freq(poll_stats->lcore_id, MED, false);
 
 	poll_stats->thresh[MED].threshold_percent = med_to_high_threshold;
@@ -213,11 +214,9 @@ update_stats(struct priority_worker *poll_stats)
 	if (s->thresh[s->cur_freq].base_edpi < cur_edpi) {
 
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "cur_edpi is too large "
-				"cur edpi %"PRId64" "
-				"base edpi %"PRId64"\n",
-				cur_edpi,
-				s->thresh[s->cur_freq].base_edpi);
+		POWER_LOG(DEBUG,
+			  "cur_edpi is too large cur edpi %"PRId64" base edpi %"PRId64,
+			  cur_edpi, s->thresh[s->cur_freq].base_edpi);
 		/* Value to make us fail need debug log*/
 		return 1000UL;
 	}
@@ -247,7 +246,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 		enum freq_val cur_freq = poll_stats->cur_freq;
 
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "cure freq is %d, edpi is %"PRIu64"\n",
+		POWER_LOG(DEBUG, "cure freq is %d, edpi is %"PRIu64"",
 				cur_freq,
 				poll_stats->thresh[cur_freq].base_edpi);
 		return;
@@ -257,12 +256,12 @@ update_stats_normal(struct priority_worker *poll_stats)
 
 	if (percent > 100) {
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "Edpi is bigger than threshold\n");
+		POWER_LOG(DEBUG, "Edpi is bigger than threshold");
 		return;
 	}
 
 	if (poll_stats->cur_freq == LOW)
-		RTE_LOG(INFO, POWER, "Purge Mode is not currently supported\n");
+		POWER_LOG(INFO, "Purge Mode is not currently supported");
 	else if (poll_stats->cur_freq == MED) {
 
 		if (percent >
@@ -272,7 +271,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 				poll_stats->threshold_ctr++;
 			else {
 				set_state(poll_stats, HGH_BUSY);
-				RTE_LOG(INFO, POWER, "MOVE to HGH\n");
+				POWER_LOG(INFO, "MOVE to HGH");
 			}
 
 		} else {
@@ -289,7 +288,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 				poll_stats->threshold_ctr++;
 			else {
 				set_state(poll_stats, MED_NORMAL);
-				RTE_LOG(INFO, POWER, "MOVE to MED\n");
+				POWER_LOG(INFO, "MOVE to MED");
 			}
 		} else {
 			/* reset */
@@ -332,17 +331,17 @@ empty_poll_training(struct priority_worker *poll_stats,
 
 		set_state(poll_stats, MED_NORMAL);
 
-		RTE_LOG(INFO, POWER, "LOW threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "LOW threshold is %"PRIu64"",
 				poll_stats->thresh[LOW].base_edpi);
 
-		RTE_LOG(INFO, POWER, "MED threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "MED threshold is %"PRIu64"",
 				poll_stats->thresh[MED].base_edpi);
 
 
-		RTE_LOG(INFO, POWER, "HIGH threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "HIGH threshold is %"PRIu64"",
 				poll_stats->thresh[HGH].base_edpi);
 
-		RTE_LOG(INFO, POWER, "Training is Complete for %d\n",
+		POWER_LOG(INFO, "Training is Complete for %d",
 				poll_stats->lcore_id);
 	}
 
@@ -414,7 +413,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 		freq_index[HGH] = freq_tlb[HGH];
 	}
 
-	RTE_LOG(INFO, POWER, "Initialize the Empty Poll\n");
+	POWER_LOG(INFO, "Initialize the Empty Poll");
 
 	/* Train for pre-defined period */
 	ep_params->max_train_iter = INTERVALS_PER_SECOND * SECONDS_TO_TRAIN_FOR;
@@ -433,7 +432,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 				avail_freqs[i],
 				NUM_FREQS);
 
-		RTE_LOG(INFO, POWER, "total avail freq is %d , lcoreid %d\n",
+		POWER_LOG(INFO, "total avail freq is %d , lcoreid %d",
 				total_avail_freqs[i],
 				i);
 
@@ -452,8 +451,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 void
 rte_power_empty_poll_stat_free(void)
 {
-
-	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
+	POWER_LOG(INFO, "Close the Empty Poll");
 
 	rte_free(ep_params);
 }
diff --git a/lib/power/rte_power_intel_uncore.c b/lib/power/rte_power_intel_uncore.c
index 3b8724385fb7..ee6412a3ed34 100644
--- a/lib/power/rte_power_intel_uncore.c
+++ b/lib/power/rte_power_intel_uncore.c
@@ -52,8 +52,9 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 	int ret;
 
 	if (idx >= MAX_UNCORE_FREQS || idx >= ui->nb_freqs) {
-		RTE_LOG(DEBUG, POWER, "Invalid uncore frequency index %u, which "
-				"should be less than %u\n", idx, ui->nb_freqs);
+		POWER_LOG(DEBUG,
+			  "Invalid uncore frequency index %u, which should be less than %u",
+			  idx, ui->nb_freqs);
 		return -1;
 	}
 
@@ -65,13 +66,13 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 	open_core_sysfs_file(&ui->f_cur_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (ui->f_cur_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		return -1;
 	}
 	ret = read_core_sysfs_u32(ui->f_cur_max, &curr_max_freq);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+		POWER_LOG(DEBUG, "Failed to read %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		fclose(ui->f_cur_max);
 		return -1;
@@ -79,14 +80,16 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 
 	/* check this value first before fprintf value to f_cur_max, so value isn't overwritten */
 	if (fprintf(ui->f_cur_min, "%u", target_uncore_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write new uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
 	if (fprintf(ui->f_cur_max, "%u", target_uncore_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write new uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
@@ -121,13 +124,13 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_base_max, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (f_base_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
 	ret = read_core_sysfs_u32(f_base_max, &base_max_freq);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+		POWER_LOG(DEBUG, "Failed to read %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -136,14 +139,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_base_min, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ,
 		ui->pkg, ui->die);
 	if (f_base_min == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
 	if (f_base_min != NULL) {
 		ret = read_core_sysfs_u32(f_base_min, &base_min_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ);
 			goto err;
 		}
@@ -153,14 +156,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_min, "rw+", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ,
 			ui->pkg, ui->die);
 	if (f_min == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ);
 		goto err;
 	}
 	if (f_min != NULL) {
 		ret = read_core_sysfs_u32(f_min, &min_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ);
 			goto err;
 		}
@@ -170,14 +173,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (f_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		goto err;
 	}
 	if (f_max != NULL) {
 		ret = read_core_sysfs_u32(f_max, &max_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 			goto err;
 		}
@@ -222,7 +225,7 @@ power_get_available_uncore_freqs(struct uncore_power_info *ui)
 
 	num_uncore_freqs = (ui->init_max_freq - ui->init_min_freq) / BUS_FREQ + 1;
 	if (num_uncore_freqs >= MAX_UNCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available uncore frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available uncore frequencies: %d",
 				num_uncore_freqs);
 		goto out;
 	}
@@ -250,7 +253,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die)
 	if (max_pkgs == 0)
 		return -1;
 	if (pkg >= max_pkgs) {
-		RTE_LOG(DEBUG, POWER, "Package number %02u can not exceed %u\n",
+		POWER_LOG(DEBUG, "Package number %02u can not exceed %u",
 				pkg, max_pkgs);
 		return -1;
 	}
@@ -259,7 +262,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die)
 	if (max_dies == 0)
 		return -1;
 	if (die >= max_dies) {
-		RTE_LOG(DEBUG, POWER, "Die number %02u can not exceed %u\n",
+		POWER_LOG(DEBUG, "Die number %02u can not exceed %u",
 				die, max_dies);
 		return -1;
 	}
@@ -282,15 +285,17 @@ rte_power_uncore_init(unsigned int pkg, unsigned int die)
 
 	/* Init for setting uncore die frequency */
 	if (power_init_for_setting_uncore_freq(ui) < 0) {
-		RTE_LOG(DEBUG, POWER, "Cannot init for setting uncore frequency for "
-				"pkg %02u die %02u\n", pkg, die);
+		POWER_LOG(DEBUG,
+			  "Cannot init for setting uncore frequency for pkg %02u die %02u",
+			  pkg, die);
 		return -1;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_uncore_freqs(ui) < 0) {
-		RTE_LOG(DEBUG, POWER, "Cannot get available uncore frequencies of "
-				"pkg %02u die %02u\n", pkg, die);
+		POWER_LOG(DEBUG,
+			  "Cannot get available uncore frequencies of pkg %02u die %02u",
+			  pkg, die);
 		return -1;
 	}
 
@@ -309,14 +314,16 @@ rte_power_uncore_exit(unsigned int pkg, unsigned int die)
 	ui = &uncore_info[pkg][die];
 
 	if (fprintf(ui->f_cur_min, "%u", ui->org_min_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write original uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
 	if (fprintf(ui->f_cur_max, "%u", ui->org_max_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write original uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
@@ -395,10 +402,8 @@ rte_power_uncore_get_num_pkgs(void)
 
 	d = opendir(INTEL_UNCORE_FREQUENCY_DIR);
 	if (d == NULL) {
-		RTE_LOG(ERR, POWER,
-		"Uncore frequency management not supported/enabled on this kernel. "
-		"Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel"
-		" >= 5.6\n");
+		POWER_LOG(ERR,
+			  "Uncore frequency management not supported/enabled on this kernel");
 		return 0;
 	}
 
@@ -427,16 +432,14 @@ rte_power_uncore_get_num_dies(unsigned int pkg)
 	if (max_pkgs == 0)
 		return 0;
 	if (pkg >= max_pkgs) {
-		RTE_LOG(DEBUG, POWER, "Invalid package number\n");
+		POWER_LOG(DEBUG, "Invalid package number");
 		return 0;
 	}
 
 	d = opendir(INTEL_UNCORE_FREQUENCY_DIR);
 	if (d == NULL) {
-		RTE_LOG(ERR, POWER,
-		"Uncore frequency management not supported/enabled on this kernel. "
-		"Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel"
-		" >= 5.6\n");
+		POWER_LOG(ERR,
+			  "Uncore frequency management not supported/enabled on this kernel");
 		return 0;
 	}
 
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index ca1840387c74..e691e754ccb0 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -146,7 +146,7 @@ get_monitor_addresses(struct pmd_core_cfg *cfg,
 
 		/* attempted out of bounds access */
 		if (i >= len) {
-			RTE_LOG(ERR, POWER, "Too many queues being monitored\n");
+			POWER_LOG(ERR, "Too many queues being monitored");
 			return -1;
 		}
 
@@ -422,7 +422,7 @@ check_scale(unsigned int lcore)
 	/* only PSTATE and ACPI modes are supported */
 	if (!rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ) &&
 	    !rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) {
-		RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes are supported\n");
+		POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes are supported");
 		return -ENOTSUP;
 	}
 	/* ensure we could initialize the power library */
@@ -432,7 +432,7 @@ check_scale(unsigned int lcore)
 	/* ensure we initialized the correct env */
 	env = rte_power_get_env();
 	if (env != PM_ENV_ACPI_CPUFREQ && env != PM_ENV_PSTATE_CPUFREQ) {
-		RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes were initialized\n");
+		POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes were initialized");
 		return -ENOTSUP;
 	}
 
@@ -448,7 +448,7 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata)
 
 	/* check if rte_power_monitor is supported */
 	if (!global_data.intrinsics_support.power_monitor) {
-		RTE_LOG(DEBUG, POWER, "Monitoring intrinsics are not supported\n");
+		POWER_LOG(DEBUG, "Monitoring intrinsics are not supported");
 		return -ENOTSUP;
 	}
 	/* check if multi-monitor is supported */
@@ -457,14 +457,14 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata)
 
 	/* if we're adding a new queue, do we support multiple queues? */
 	if (cfg->n_queues > 0 && !multimonitor_supported) {
-		RTE_LOG(DEBUG, POWER, "Monitoring multiple queues is not supported\n");
+		POWER_LOG(DEBUG, "Monitoring multiple queues is not supported");
 		return -ENOTSUP;
 	}
 
 	/* check if the device supports the necessary PMD API */
 	if (rte_eth_get_monitor_addr(qdata->portid, qdata->qid,
 			&dummy) == -ENOTSUP) {
-		RTE_LOG(DEBUG, POWER, "The device does not support rte_eth_get_monitor_addr\n");
+		POWER_LOG(DEBUG, "The device does not support rte_eth_get_monitor_addr");
 		return -ENOTSUP;
 	}
 
@@ -564,14 +564,14 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
 		clb = clb_pause;
 		break;
 	default:
-		RTE_LOG(DEBUG, POWER, "Invalid power management type\n");
+		POWER_LOG(DEBUG, "Invalid power management type");
 		ret = -EINVAL;
 		goto end;
 	}
 	/* add this queue to the list */
 	ret = queue_list_add(lcore_cfg, &qdata);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to add queue to list: %s\n",
+		POWER_LOG(DEBUG, "Failed to add queue to list: %s",
 				strerror(-ret));
 		goto end;
 	}
@@ -684,7 +684,8 @@ int
 rte_power_pmd_mgmt_set_pause_duration(unsigned int duration)
 {
 	if (duration == 0) {
-		RTE_LOG(ERR, POWER, "Pause duration must be greater than 0, value unchanged");
+		POWER_LOG(ERR,
+			  "Pause duration must be greater than 0, value unchanged");
 		return -EINVAL;
 	}
 	pause_duration = duration;
@@ -702,12 +703,13 @@ int
 rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (min > scale_freq_max[lcore]) {
-		RTE_LOG(ERR, POWER, "Invalid min frequency: Cannot be greater than max frequency");
+		POWER_LOG(ERR,
+			  "Invalid min frequency: Cannot be greater than max frequency");
 		return -EINVAL;
 	}
 	scale_freq_min[lcore] = min;
@@ -719,7 +721,7 @@ int
 rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
@@ -727,7 +729,8 @@ rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
 	if (max == 0)
 		max = UINT32_MAX;
 	if (max < scale_freq_min[lcore]) {
-		RTE_LOG(ERR, POWER, "Invalid max frequency: Cannot be less than min frequency");
+		POWER_LOG(ERR,
+			  "Invalid max frequency: Cannot be less than min frequency");
 		return -EINVAL;
 	}
 
@@ -740,12 +743,12 @@ int
 rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (scale_freq_max[lcore] == 0)
-		RTE_LOG(DEBUG, POWER, "Scaling freq min config not set. Using sysfs min freq.\n");
+		POWER_LOG(DEBUG, "Scaling freq min config not set. Using sysfs min freq.");
 
 	return scale_freq_min[lcore];
 }
@@ -754,12 +757,12 @@ int
 rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (scale_freq_max[lcore] == UINT32_MAX) {
-		RTE_LOG(DEBUG, POWER, "Scaling freq max config not set. Using sysfs max freq.\n");
+		POWER_LOG(DEBUG, "Scaling freq max config not set. Using sysfs max freq.");
 		return 0;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 08/13] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (6 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 07/13] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 09/13] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/ring/rte_ring.c             | 31 +++++++++++++++++++------------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7dbf1df3b979..04c9d43351da 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 5b7850af4e2b..a99fe383c89b 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..1b4633468a2a 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,13 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+
+#define RING_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, ring_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
@@ -52,15 +59,15 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
 
 	/* Check if element size is a multiple of 4B */
 	if (esize % 4 != 0) {
-		RTE_LOG(ERR, RING, "element size is not a multiple of 4\n");
+		RING_LOG(ERR, "element size is not a multiple of 4");
 
 		return -EINVAL;
 	}
 
 	/* count must be a power of 2 */
 	if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK )) {
-		RTE_LOG(ERR, RING,
-			"Requested number of elements is invalid, must be power of 2, and not exceed %u\n",
+		RING_LOG(ERR,
+			"Requested number of elements is invalid, must be power of 2, and not exceed %u",
 			RTE_RING_SZ_MASK);
 
 		return -EINVAL;
@@ -195,8 +202,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 
 	/* future proof flags, only allow supported values */
 	if (flags & ~RING_F_MASK) {
-		RTE_LOG(ERR, RING,
-			"Unsupported flags requested %#x\n", flags);
+		RING_LOG(ERR,
+			"Unsupported flags requested %#x", flags);
 		return -EINVAL;
 	}
 
@@ -216,8 +223,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 		r->capacity = count;
 	} else {
 		if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) {
-			RTE_LOG(ERR, RING,
-				"Requested size is invalid, must be power of 2, and not exceed the size limit %u\n",
+			RING_LOG(ERR,
+				"Requested size is invalid, must be power of 2, and not exceed the size limit %u",
 				RTE_RING_SZ_MASK);
 			return -EINVAL;
 		}
@@ -271,7 +278,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count,
 
 	te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n");
+		RING_LOG(ERR, "Cannot reserve memory for tailq");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -295,7 +302,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count,
 		TAILQ_INSERT_TAIL(ring_list, te, next);
 	} else {
 		r = NULL;
-		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
+		RING_LOG(ERR, "Cannot reserve memory");
 		rte_free(te);
 	}
 	rte_mcfg_tailq_write_unlock();
@@ -327,13 +334,13 @@ rte_ring_free(struct rte_ring *r)
 	 * therefore, there is no memzone to free.
 	 */
 	if (r->memzone == NULL) {
-		RTE_LOG(ERR, RING,
-			"Cannot free ring, not created with rte_ring_create()\n");
+		RING_LOG(ERR,
+			 "Cannot free ring, not created with rte_ring_create()");
 		return;
 	}
 
 	if (rte_memzone_free(r->memzone) != 0) {
-		RTE_LOG(ERR, RING, "Cannot free memory\n");
+		RING_LOG(ERR, "Cannot free memory");
 		return;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 09/13] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (7 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 08/13] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 10/13] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mempool/rte_mempool.c       | 33 ++++++++++++++++++---------------
 lib/mempool/rte_mempool_log.h   | 10 ++++++++++
 lib/mempool/rte_mempool_ops.c   | 12 ++++++------
 5 files changed, 35 insertions(+), 23 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 04c9d43351da..90d388192712 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a99fe383c89b..f583352ec1ea 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..911a2b4dd850 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
@@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id)
 	cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache),
 				  RTE_CACHE_LINE_SIZE, socket_id);
 	if (cache == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate mempool cache.");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	/* try to allocate tailq entry */
 	te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!");
 		goto exit_unlock;
 	}
 
@@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp,
 
 		if (free == 0) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-					obj, (const void *) mp, cookie);
+				MEMPOOL_LOG(CRIT,
+					    "obj=%p, mempool=%p, cookie=%" PRIx64,
+					    obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (put)\n");
 			}
 			hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2;
 		} else if (free == 1) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-					obj, (const void *) mp, cookie);
+				MEMPOOL_LOG(CRIT,
+					    "obj=%p, mempool=%p, cookie=%" PRIx64,
+					    obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (get)\n");
 			}
 			hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1;
 		} else if (free == 2) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 &&
 			    cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
+				MEMPOOL_LOG(CRIT,
+					"obj=%p, mempool=%p, cookie=%" PRIx64,
 					obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (audit)\n");
 			}
@@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp,
 		tlr = rte_mempool_get_trailer(obj);
 		cookie = tlr->cookie;
 		if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
-			RTE_LOG(CRIT, MEMPOOL,
-				"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-				obj, (const void *) mp, cookie);
+			MEPOOL_LOG(CRIT,
+				   "obj=%p, mempool=%p, cookie=%" PRIx64,
+				   obj, (const void *) mp, cookie);
 			rte_panic("MEMPOOL: bad trailer cookie\n");
 		}
 	}
@@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp)
 		const struct rte_mempool_cache *cache;
 		cache = &mp->local_cache[lcore_id];
 		if (cache->len > RTE_DIM(cache->objs)) {
-			RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n",
+			MEMPOOL_LOG(CRIT, "badness on cache[%u]",
 				lcore_id);
 			rte_panic("MEMPOOL: invalid cache len\n");
 		}
@@ -1429,7 +1430,7 @@ rte_mempool_event_callback_register(rte_mempool_event_callback *func,
 
 	cb = calloc(1, sizeof(*cb));
 	if (cb == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate event callback!");
 		ret = -ENOMEM;
 		goto exit;
 	}
@@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry)
 	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
 		"Returns mempool info. Parameters: pool_name");
 }
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..3d252f761408
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mempool_logtype;
+
+#define MEMPOOL_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, mempool_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..e04e75b91ba6 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
@@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
 	if (rte_mempool_ops_table.num_ops >=
 			RTE_MEMPOOL_MAX_OPS_IDX) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(ERR, MEMPOOL,
-			"Maximum number of mempool ops structs exceeded\n");
+		MEMPOOL_LOG(ERR,
+			"Maximum number of mempool ops structs exceeded");
 		return -ENOSPC;
 	}
 
 	if (h->alloc == NULL || h->enqueue == NULL ||
 			h->dequeue == NULL || h->get_count == NULL) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(ERR, MEMPOOL,
-			"Missing callback while registering mempool ops\n");
+		MEMPOOL_LOG(ERR,
+			    "Missing callback while registering mempool ops");
 		return -EINVAL;
 	}
 
 	if (strlen(h->name) >= sizeof(ops->name) - 1) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n",
-				__func__, h->name);
+		MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", h->name);
 		rte_errno = EEXIST;
 		return -EEXIST;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 10/13] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (8 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 09/13] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 11/13] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Vladimir Medvedkin, Yipeng Wang,
	Sameh Gobriel, Bruce Richardson

Split lpm and lpm6 into seperate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/fib/rte_fib.c               | 23 +++++++-----
 lib/fib/rte_fib6.c              | 21 +++++++----
 lib/hash/rte_hash_crc.c         | 63 +++++++++++++++++++++++++++++++++
 lib/lpm/rte_lpm.c               | 18 ++++++----
 lib/lpm/rte_lpm6.c              | 25 ++++++++-----
 lib/rib/rte_rib.c               | 14 +++++---
 lib/rib/rte_rib6.c              | 16 ++++++---
 9 files changed, 142 insertions(+), 41 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 90d388192712..ff250b9a6d56 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f583352ec1ea..55067efb0a84 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..7fda4263f841 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 #include <rte_tailq.h>
@@ -17,6 +18,12 @@
 
 #include "dir24_8.h"
 
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
+
+#define FIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fib_logtype,		\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
 	.name = "RTE_FIB",
@@ -167,8 +174,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 
 	rib = rte_rib_create(name, socket_id, &rib_conf);
 	if (rib == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate RIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate RIB %s", name);
 		return NULL;
 	}
 
@@ -192,8 +199,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for FIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate tailq entry for FIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -202,7 +209,7 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	fib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_fib),	RTE_CACHE_LINE_SIZE, socket_id);
 	if (fib == NULL) {
-		RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name);
+		FIB_LOG(ERR, "FIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
@@ -213,9 +220,9 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	fib->def_nh = conf->default_nh;
 	ret = init_dataplane(fib, socket_id, conf);
 	if (ret < 0) {
-		RTE_LOG(ERR, LPM,
-			"FIB dataplane struct %s memory allocation failed "
-			"with err %d\n", name, ret);
+		FIB_LOG(ERR,
+			"FIB dataplane struct %s memory allocation failed with err %d",
+			name, ret);
 		rte_errno = -ret;
 		goto free_fib;
 	}
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..d735fe81fc41 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -17,6 +18,12 @@
 
 #include "trie.h"
 
+RTE_LOG_REGISTER_SUFFIX(fib6_logtype, "fib6", INFO);
+
+#define FIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fib6_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
 	.name = "RTE_FIB6",
@@ -168,8 +175,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 
 	rib = rte_rib6_create(name, socket_id, &rib_conf);
 	if (rib == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate RIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate RIB %s", name);
 		return NULL;
 	}
 
@@ -193,8 +200,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for FIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate tailq entry for FIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -203,7 +210,7 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	fib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_fib6), RTE_CACHE_LINE_SIZE, socket_id);
 	if (fib == NULL) {
-		RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name);
+		FIB_LOG(ERR,"FIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
@@ -214,8 +221,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	fib->def_nh = conf->default_nh;
 	ret = init_dataplane(fib, socket_id, conf);
 	if (ret < 0) {
-		RTE_LOG(ERR, LPM,
-			"FIB dataplane struct %s memory allocation failed\n",
+		FIB_LOG(ERR,
+			"FIB dataplane struct %s memory allocation failed",
 			name);
 		rte_errno = -ret;
 		goto free_fib;
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..c6d0c25c0709
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+RTE_LOG_REGISTER_SUFFIX(crc_hash_logtype, "hash.crc", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, crc_hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+static inline void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		HASH_LOG(WARNING,
+			 "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		crc32_alg = CRC32_SSE42;
+	else
+		crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		HASH_LOG(WARNING,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		crc32_alg = CRC32_ARM64;
+#endif
+
+	if (crc32_alg == CRC32_SW)
+		HASH_LOG(WARNING,
+			"Unsupported CRC32 algorithm requested using CRC32_SW");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..ba3912a775a3 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -19,6 +19,12 @@
 
 #include "rte_lpm.h"
 
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
+
+#define LPM_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, lpm_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_lpm_tailq = {
@@ -189,7 +195,7 @@ rte_lpm_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("LPM_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM, "Failed to allocate tailq entry\n");
+		LPM_LOG(ERR, "Failed to allocate tailq entry");
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -198,7 +204,7 @@ rte_lpm_create(const char *name, int socket_id,
 	i_lpm = rte_zmalloc_socket(mem_name, mem_size,
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (i_lpm == NULL) {
-		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+		LPM_LOG(ERR, "LPM memory allocation failed");
 		rte_free(te);
 		rte_errno = ENOMEM;
 		goto exit;
@@ -208,7 +214,7 @@ rte_lpm_create(const char *name, int socket_id,
 			(size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (i_lpm->rules_tbl == NULL) {
-		RTE_LOG(ERR, LPM, "LPM rules_tbl memory allocation failed\n");
+		LPM_LOG(ERR, "LPM rules_tbl memory allocation failed");
 		rte_free(i_lpm);
 		i_lpm = NULL;
 		rte_free(te);
@@ -220,7 +226,7 @@ rte_lpm_create(const char *name, int socket_id,
 			(size_t)tbl8s_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (i_lpm->lpm.tbl8 == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n");
+		LPM_LOG(ERR, "LPM tbl8 memory allocation failed");
 		rte_free(i_lpm->rules_tbl);
 		rte_free(i_lpm);
 		i_lpm = NULL;
@@ -335,7 +341,7 @@ rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg)
 		params.v = cfg->v;
 		i_lpm->dq = rte_rcu_qsbr_dq_create(&params);
 		if (i_lpm->dq == NULL) {
-			RTE_LOG(ERR, LPM, "LPM defer queue creation failed\n");
+			LPM_LOG(ERR, "LPM defer queue creation failed");
 			return 1;
 		}
 	} else {
@@ -562,7 +568,7 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start)
 		status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq,
 				(void *)&tbl8_group_start);
 		if (status == 1) {
-			RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n");
+			LPM_LOG(ERR, "Failed to push QSBR FIFO");
 			return -rte_errno;
 		}
 	}
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..7701e8112ed2 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -45,6 +45,12 @@ enum valid_flag {
 	VALID
 };
 
+RTE_LOG_REGISTER_SUFFIX(lpm6_logtype, "lpm6", INFO);
+
+#define LPM_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, lpm6_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_lpm6_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_lpm6_tailq = {
@@ -279,8 +285,9 @@ rte_lpm6_create(const char *name, int socket_id,
 
 	rules_tbl = rte_hash_create(&rule_hash_tbl_params);
 	if (rules_tbl == NULL) {
-		RTE_LOG(ERR, LPM, "LPM rules hash table allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM rules hash table allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		goto fail_wo_unlock;
 	}
 
@@ -289,8 +296,9 @@ rte_lpm6_create(const char *name, int socket_id,
 			sizeof(uint32_t) * config->number_tbl8s,
 			RTE_CACHE_LINE_SIZE);
 	if (tbl8_pool == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 pool allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM tbl8 pool allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		rte_errno = ENOMEM;
 		goto fail_wo_unlock;
 	}
@@ -300,8 +308,9 @@ rte_lpm6_create(const char *name, int socket_id,
 			sizeof(struct rte_lpm_tbl8_hdr) * config->number_tbl8s,
 			RTE_CACHE_LINE_SIZE);
 	if (tbl8_hdrs == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 headers allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM tbl8 headers allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		rte_errno = ENOMEM;
 		goto fail_wo_unlock;
 	}
@@ -329,7 +338,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM, "Failed to allocate tailq entry!\n");
+		LPM_LOG(ERR, "Failed to allocate tailq entry!");
 		rte_errno = ENOMEM;
 		goto fail;
 	}
@@ -339,7 +348,7 @@ rte_lpm6_create(const char *name, int socket_id,
 			RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm == NULL) {
-		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+		LPM_LOG(ERR, "LPM memory allocation failed");
 		rte_free(te);
 		rte_errno = ENOMEM;
 		goto fail;
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..a81b4ed1cc04 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,12 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+
+#define RIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rib_logtype,		\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
@@ -412,8 +418,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 		NULL, NULL, NULL, NULL, socket_id, 0);
 
 	if (node_pool == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate mempool for RIB %s\n", name);
+		RIB_LOG(ERR, "Can not allocate mempool for RIB %s", name);
 		return NULL;
 	}
 
@@ -437,8 +442,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (unlikely(te == NULL)) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for RIB %s\n", name);
+		RIB_LOG(ERR, "Can not allocate tailq entry for RIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -447,7 +451,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib),	RTE_CACHE_LINE_SIZE, socket_id);
 	if (unlikely(rib == NULL)) {
-		RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name);
+		RIB_LOG(ERR, "RIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..39eba4d7032b 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,12 @@
 
 #include <rte_rib6.h>
 
+RTE_LOG_REGISTER_SUFFIX(rib6_logtype, "rib6", INFO);
+
+#define RIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rib6_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
@@ -481,8 +488,7 @@ rte_rib6_create(const char *name, int socket_id,
 		NULL, NULL, NULL, NULL, socket_id, 0);
 
 	if (node_pool == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate mempool for RIB6 %s\n", name);
+		RIB_LOG(ERR, "Can not allocate mempool for RIB6 %s", name);
 		return NULL;
 	}
 
@@ -506,8 +512,8 @@ rte_rib6_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0);
 	if (unlikely(te == NULL)) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for RIB6 %s\n", name);
+		RIB_LOG(ERR,
+			"Can not allocate tailq entry for RIB6 %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -516,7 +522,7 @@ rte_rib6_create(const char *name, int socket_id,
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id);
 	if (unlikely(rib == NULL)) {
-		RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name);
+		RIB_LOG(ERR, "RIB6 %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 11/13] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (9 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 10/13] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 12/13] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/kni/rte_kni.c               | 63 ++++++++++++++++++---------------
 3 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index ff250b9a6d56..b0c625a02cdf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 55067efb0a84..69d3d07252ec 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..de3aea8be7b6 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -92,15 +92,20 @@ static void kni_allocate_mbufs(struct rte_kni *kni);
 
 static volatile int kni_fd = -1;
 
+RTE_LOG_REGISTER_SUFFIX(kni_logtype, "kni", INFO);
+
+#define KNI_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, kni_logtype,	fmt,##args)
+
 /* Shall be called before any allocation happens */
 int
 rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 {
-	RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n");
+	KNI_LOG(WARNING, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n");
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
 	if (rte_eal_iova_mode() != RTE_IOVA_PA) {
-		RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n");
+		KNI_LOG(ERR, "KNI requires IOVA as PA\n");
 		return -1;
 	}
 #endif
@@ -109,7 +114,7 @@ rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 	if (kni_fd < 0) {
 		kni_fd = open("/dev/" KNI_DEVICE, O_RDWR);
 		if (kni_fd < 0) {
-			RTE_LOG(ERR, KNI,
+			KNI_LOG(ERR,
 				"Can not open /dev/%s\n", KNI_DEVICE);
 			return -1;
 		}
@@ -225,7 +230,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 
 	/* Check if KNI subsystem has been initialized */
 	if (kni_fd < 0) {
-		RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
+		KNI_LOG(ERR, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
 		return NULL;
 	}
 
@@ -233,19 +238,19 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
-		RTE_LOG(ERR, KNI, "KNI already exists\n");
+		KNI_LOG(ERR, "KNI already exists\n");
 		goto unlock;
 	}
 
 	te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n");
+		KNI_LOG(ERR, "Failed to allocate tailq entry\n");
 		goto unlock;
 	}
 
 	kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE);
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "KNI memory allocation failed\n");
+		KNI_LOG(ERR, "KNI memory allocation failed\n");
 		goto kni_fail;
 	}
 
@@ -424,7 +429,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	strlcpy(dev_info.name, kni->name, sizeof(dev_info.name));
 	if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) {
-		RTE_LOG(ERR, KNI, "Fail to release kni device\n");
+		KNI_LOG(ERR, "Fail to release kni device\n");
 		goto unlock;
 	}
 
@@ -439,7 +444,7 @@ rte_kni_release(struct rte_kni *kni)
 		usleep(1000);
 
 	if (kni_fifo_count(kni->rx_q))
-		RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n");
+		KNI_LOG(ERR, "Fail to free all Rx-q items\n");
 
 	kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q);
 	kni_free_fifo(kni->tx_q);
@@ -466,16 +471,16 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 	int ret = 0;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id);
+	KNI_LOG(INFO, "Configure mac address of %d", port_id);
 
 	ret = rte_eth_dev_default_mac_addr_set(port_id,
 					(struct rte_ether_addr *)mac_addr);
 	if (ret < 0)
-		RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n",
+		KNI_LOG(ERR, "Failed to config mac_addr for port %d\n",
 			port_id);
 
 	return ret;
@@ -488,11 +493,11 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n",
+	KNI_LOG(INFO, "Configure promiscuous mode of %d to %d\n",
 		port_id, to_on);
 
 	if (to_on)
@@ -501,7 +506,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 		ret = rte_eth_promiscuous_disable(port_id);
 
 	if (ret != 0)
-		RTE_LOG(ERR, KNI,
+		KNI_LOG(ERR,
 			"Failed to %s promiscuous mode for port %u: %s\n",
 			to_on ? "enable" : "disable", port_id,
 			rte_strerror(-ret));
@@ -516,11 +521,11 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on)
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n",
+	KNI_LOG(INFO, "Configure allmulticast mode of %d to %d\n",
 		port_id, to_on);
 
 	if (to_on)
@@ -528,7 +533,7 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on)
 	else
 		ret = rte_eth_allmulticast_disable(port_id);
 	if (ret != 0)
-		RTE_LOG(ERR, KNI,
+		KNI_LOG(ERR,
 			"Failed to %s allmulticast mode for port %u: %s\n",
 			to_on ? "enable" : "disable", port_id,
 			rte_strerror(-ret));
@@ -551,7 +556,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 		return 0; /* It is OK of can not getting the request mbuf */
 
 	if (req != kni->sync_addr) {
-		RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req);
+		KNI_LOG(ERR, "Wrong req pointer %p\n", req);
 		return -1;
 	}
 
@@ -592,7 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 					kni->ops.port_id, req->allmulti);
 		break;
 	default:
-		RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id);
+		KNI_LOG(ERR, "Unknown request id %u\n", req->req_id);
 		req->result = -EINVAL;
 		break;
 	}
@@ -603,7 +608,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 	else
 		ret = 1;
 	if (ret != 1) {
-		RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n");
+		KNI_LOG(ERR, "Fail to put the muf back to resp_q\n");
 		return -1; /* It is an error of can't putting the mbuf back */
 	}
 
@@ -679,7 +684,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
 
 	/* Check if pktmbuf pool has been configured */
 	if (kni->pktmbuf_pool == NULL) {
-		RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n");
+		KNI_LOG(ERR, "No valid mempool for allocating mbufs\n");
 		return;
 	}
 
@@ -690,7 +695,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
 		pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
 		if (unlikely(pkts[i] == NULL)) {
 			/* Out of memory */
-			RTE_LOG(ERR, KNI, "Out of memory\n");
+			KNI_LOG(ERR, "Out of memory\n");
 			break;
 		}
 		phys[i] = va2pa(pkts[i]);
@@ -757,18 +762,18 @@ rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops)
 	enum kni_ops_status req_status;
 
 	if (ops == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n");
+		KNI_LOG(ERR, "Invalid KNI request operation.\n");
 		return -1;
 	}
 
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid kni info.\n");
+		KNI_LOG(ERR, "Invalid kni info.\n");
 		return -1;
 	}
 
 	req_status = kni_check_request_register(&kni->ops);
 	if (req_status == KNI_REQ_REGISTERED) {
-		RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n");
+		KNI_LOG(ERR, "The KNI request operation has already registered.\n");
 		return -1;
 	}
 
@@ -780,7 +785,7 @@ int
 rte_kni_unregister_handlers(struct rte_kni *kni)
 {
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid kni info.\n");
+		KNI_LOG(ERR, "Invalid kni info.\n");
 		return -1;
 	}
 
@@ -806,7 +811,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 
 	fd = open(path, O_RDWR);
 	if (fd == -1) {
-		RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path);
+		KNI_LOG(ERR, "Failed to open file: %s.\n", path);
 		return -1;
 	}
 
@@ -823,7 +828,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 	new_carrier = linkup ? "1" : "0";
 	ret = write(fd, new_carrier, 1);
 	if (ret < 1) {
-		RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path);
+		KNI_LOG(ERR, "Failed to write file: %s.\n", path);
 		close(fd);
 		return -1;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 12/13] hash: replace RTE_LOGTYPE_HASH with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (10 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 11/13] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 20:41 ` [RFC 13/13] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

A little more complex here since the one hash library actually
has multiple routines in it.  Split up the logtypes for
hash and toeplitz.

The hash crc file has another issue around logging.
It is calling RTE_LOG during a constructor which is maybe
problematic because this will all run before the DPDK library
has finished initializing logging.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/hash/rte_cuckoo_hash.c      | 60 ++++++++++++++++---------------
 lib/hash/rte_fbk_hash.c         | 10 ++++--
 lib/hash/rte_hash_crc.c         | 63 ---------------------------------
 lib/hash/rte_hash_crc.h         |  6 ++--
 lib/hash/rte_thash.c            | 54 +++++++++++++++++++++-------
 lib/hash/rte_thash_gfni.h       | 24 ++++---------
 lib/hash/version.map            |  4 +++
 9 files changed, 96 insertions(+), 128 deletions(-)
 delete mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index b0c625a02cdf..97120543d808 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 69d3d07252ec..afbd67d55b45 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..b2e9cd70e91b 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -26,6 +26,12 @@
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_logtype, "hash", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 /* Mask of all flags supported by this version */
 #define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \
 				   RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \
@@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
 	if (params == NULL) {
-		RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n");
+		HASH_LOG(ERR, "rte_hash_create has no parameters");
 		return NULL;
 	}
 
@@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
 			(params->key_len == 0)) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n");
+		HASH_LOG(ERR, "rte_hash_create has invalid parameters");
 		return NULL;
 	}
 
 	if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n");
+		HASH_LOG(ERR, "rte_hash_create: unsupported extra flags");
 		return NULL;
 	}
 
@@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or "
-			"rw concurrency lock free\n");
+		HASH_LOG(ERR,
+			 "choose rw concurrency or rw concurrency lock free");
 		return NULL;
 	}
 
@@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	r = rte_ring_create_elem(ring_name, sizeof(uint32_t),
 			rte_align32pow2(num_key_slots), params->socket_id, 0);
 	if (r == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err;
 	}
 
@@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				params->socket_id, 0);
 
 		if (r_ext == NULL) {
-			RTE_LOG(ERR, HASH, "ext buckets memory allocation "
-								"failed\n");
+			HASH_LOG(ERR,
+				 "ext buckets memory allocation failed");
 			goto err;
 		}
 	}
@@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH, "tailq entry allocation failed\n");
+		HASH_LOG(ERR, "tailq entry allocation failed");
 		goto err_unlock;
 	}
 
@@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 					RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (h == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (buckets == NULL) {
-		RTE_LOG(ERR, HASH, "buckets memory allocation failed\n");
+		HASH_LOG(ERR, "buckets memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				num_buckets * sizeof(struct rte_hash_bucket),
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 		if (buckets_ext == NULL) {
-			RTE_LOG(ERR, HASH, "ext buckets memory allocation "
-							"failed\n");
+			HASH_LOG(ERR,
+				 "ext buckets memory allocation failed");
 			goto err_unlock;
 		}
 		/* Populate ext bkt ring. We reserve 0 similar to the
@@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) *
 								num_key_slots, 0);
 			if (ext_bkt_to_free == NULL) {
-				RTE_LOG(ERR, HASH, "ext bkt to free memory allocation "
-								"failed\n");
+				HASH_LOG(ERR,
+					 "ext bkt to free memory allocation failed");
 				goto err_unlock;
 			}
 		}
@@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (k == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (tbl_chng_cnt == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				sizeof(struct lcore_cache) * RTE_MAX_LCORE,
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 		if (local_free_slots == NULL) {
-			RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n");
+			HASH_LOG(ERR, "local free slots memory allocation failed");
 			goto err_unlock;
 		}
 	}
@@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h)
 		/* Reclaim all the resources */
 		rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL);
 		if (pending != 0)
-			RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n");
+			HASH_LOG(ERR, "RCU reclaim all resources failed");
 	}
 
 	memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket));
@@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n)
 	/* Return key indexes to free slot ring */
 	ret = free_slot(h, rcu_dq_entry.key_idx);
 	if (ret < 0) {
-		RTE_LOG(ERR, HASH,
-			"%s: could not enqueue free slots in global ring\n",
-				__func__);
+		HASH_LOG(ERR,
+			 "could not enqueue free slots in global ring");
 	}
 }
 
@@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 
 	hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0);
 	if (hash_rcu_cfg == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		return 1;
 	}
 
@@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 		h->dq = rte_rcu_qsbr_dq_create(&params);
 		if (h->dq == NULL) {
 			rte_free(hash_rcu_cfg);
-			RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n");
+			HASH_LOG(ERR, "HASH defer queue creation failed");
 			return 1;
 		}
 	} else {
@@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
 	int ret = free_slot(h, bkt->key_idx[i]);
 
 	if (ret < 0) {
-		RTE_LOG(ERR, HASH,
-			"%s: could not enqueue free slots in global ring\n",
-				__func__);
+		HASH_LOG(ERR,
+			 "could not enqueue free slots in global ring");
 	}
 }
 
@@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
 		} else if (h->dq)
 			/* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */
 			if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0)
-				RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n");
+				HASH_LOG(ERR, "Failed to push QSBR FIFO");
 	}
 	__hash_rw_writer_unlock(h);
 	return ret;
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..7a0e4272ffa9 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -18,6 +18,12 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, "hash.fbk", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fbk_hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
@@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n");
+		HASH_LOG(ERR, "Failed to allocate tailq entry");
 		goto exit;
 	}
 
@@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	ht = rte_zmalloc_socket(hash_name, mem_size,
 			0, params->socket_id);
 	if (ht == NULL) {
-		RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n");
+		HASH_LOG(ERR, "Failed to allocate fbk hash table");
 		rte_free(te);
 		goto exit;
 	}
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
deleted file mode 100644
index c6d0c25c0709..000000000000
--- a/lib/hash/rte_hash_crc.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
- */
-
-RTE_LOG_REGISTER_SUFFIX(crc_hash_logtype, "hash.crc", INFO);
-
-#define HASH_LOG(level, fmt, args...)			\
-	rte_log(RTE_LOG_ ## level, crc_hash_logtype,	\
-		"%s(): " fmt "\n", __func__, ##args)
-/**
- * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
- * calculation.
- *
- * @param alg
- *   An OR of following flags:
- *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
- *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
- *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
- *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
- *
- */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		HASH_LOG(WARNING,
-			 "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		HASH_LOG(WARNING,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		HASH_LOG(WARNING,
-			"Unsupported CRC32 algorithm requested using CRC32_SW");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..3bb38880c4ea 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg)
 
 #if defined RTE_ARCH_X86
 	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
 	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
 		crc32_alg = CRC32_SSE42;
@@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg)
 
 #if defined RTE_ARCH_ARM64
 	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
 		crc32_alg = CRC32_ARM64;
 #endif
 
 	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
 }
 
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..e4722201d358 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,12 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, "thash", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rte_thash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
@@ -104,6 +110,29 @@ rte_thash_gfni_supported(void)
 	return 0;
 };
 
+#ifndef RTE_THASH_GFNI_DEFINED
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	HASH_LOG(ERR, "is undefined under given arch");
+	return 0;
+}
+
+__rte_experimental
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+	int len __rte_unused, uint8_t *tuple[] __rte_unused,
+	uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	HASH_LOG(ERR, "is undefined under given arch");
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
+#endif
+
 void
 rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size)
 {
@@ -240,8 +269,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 	/* allocate tailq entry */
 	te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH,
-			"Can not allocate tailq entry for thash context %s\n",
+		HASH_LOG(ERR,
+			"Can not allocate tailq entry for thash context %s",
 			name);
 		rte_errno = ENOMEM;
 		goto exit;
@@ -249,7 +278,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 
 	ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0);
 	if (ctx == NULL) {
-		RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n",
+		HASH_LOG(ERR,
+			 "thash ctx %s memory allocation failed",
 			name);
 		rte_errno = ENOMEM;
 		goto free_te;
@@ -272,7 +302,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 		ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t),
 			RTE_CACHE_LINE_SIZE);
 		if (ctx->matrices == NULL) {
-			RTE_LOG(ERR, HASH, "Cannot allocate matrices\n");
+			HASH_LOG(ERR, "Cannot allocate matrices");
 			rte_errno = ENOMEM;
 			goto free_ctx;
 		}
@@ -387,8 +417,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
 	if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) &&
 			((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) !=
 			RTE_THASH_IGNORE_PERIOD_OVERFLOW)) {
-		RTE_LOG(ERR, HASH,
-			"Can't generate m-sequence due to period overflow\n");
+		HASH_LOG(ERR,
+			"Can't generate m-sequence due to period overflow");
 		return -ENOSPC;
 	}
 
@@ -467,9 +497,9 @@ insert_before(struct rte_thash_ctx *ctx,
 			return ret;
 		}
 	} else if ((next_ent != NULL) && (end > next_ent->offset)) {
-		RTE_LOG(ERR, HASH,
-			"Can't add helper %s due to conflict with existing"
-			" helper %s\n", ent->name, next_ent->name);
+		HASH_LOG(ERR,
+			"Can't add helper %s due to conflict with existing helper %s",
+			 ent->name, next_ent->name);
 		rte_free(ent);
 		return -ENOSPC;
 	}
@@ -516,9 +546,9 @@ insert_after(struct rte_thash_ctx *ctx,
 	int ret;
 
 	if ((next_ent != NULL) && (end > next_ent->offset)) {
-		RTE_LOG(ERR, HASH,
-			"Can't add helper %s due to conflict with existing"
-			" helper %s\n", ent->name, next_ent->name);
+		HASH_LOG(ERR,
+			 "Can't add helper %s due to conflict with existing helper %s",
+			 ent->name, next_ent->name);
 		rte_free(ent);
 		return -EEXIST;
 	}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..c3a5cf7e7b2d 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -38,13 +38,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx,
+		    int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..c30ac81307a7 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 23.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC 13/13] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (11 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 12/13] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
@ 2023-02-07 20:41 ` Stephen Hemminger
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 20:41 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   2 -
 lib/eal/include/rte_log.h       |   4 +-
 lib/sched/rte_pie.c             |  16 +-
 lib/sched/rte_sched.c           | 297 +++++++++++++-------------------
 lib/sched/rte_sched_log.h       |  11 ++
 5 files changed, 140 insertions(+), 190 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 97120543d808..212ccda0a6e8 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,8 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index afbd67d55b45..a1549b372767 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..28ed01e8f11d 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
+
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
@@ -16,7 +18,7 @@ int
 rte_pie_rt_data_init(struct rte_pie *pie)
 {
 	if (pie == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Invalid addr for pie\n", __func__);
+		SCHED_LOG(ERR, "Invalid addr for pie");
 		return -EINVAL;
 	}
 
@@ -38,26 +40,22 @@ rte_pie_config_init(struct rte_pie_config *pie_cfg,
 		return -1;
 
 	if (qdelay_ref <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for qdelay_ref\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for qdelay_ref");
 		return -EINVAL;
 	}
 
 	if (dp_update_interval <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for dp_update_interval\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for dp_update_interval");
 		return -EINVAL;
 	}
 
 	if (max_burst <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for max_burst\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for max_burst");
 		return -EINVAL;
 	}
 
 	if (tailq_th <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tailq_th\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tailq_th");
 		return -EINVAL;
 	}
 
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..fd5bd38070fa 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -6,7 +6,6 @@
 #include <string.h>
 
 #include <rte_common.h>
-#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 #include <rte_prefetch.h>
@@ -17,6 +16,7 @@
 
 #include "rte_sched.h"
 #include "rte_sched_common.h"
+#include "rte_sched_log.h"
 #include "rte_approx.h"
 
 #ifdef __INTEL_COMPILER
@@ -324,23 +324,20 @@ pipe_profile_check(struct rte_sched_pipe_params *params,
 
 	/* Pipe parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* TB rate: non-zero, not greater than port rate */
 	if (params->tb_rate == 0 ||
 		params->tb_rate > rate) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tb rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb rate");
 		return -EINVAL;
 	}
 
 	/* TB size: non-zero */
 	if (params->tb_size == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tb size\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb size");
 		return -EINVAL;
 	}
 
@@ -349,38 +346,33 @@ pipe_profile_check(struct rte_sched_pipe_params *params,
 		if ((qsize[i] == 0 && params->tc_rate[i] != 0) ||
 			(qsize[i] != 0 && (params->tc_rate[i] == 0 ||
 			params->tc_rate[i] > params->tb_rate))) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for qsize or tc_rate\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for qsize or tc_rate");
 			return -EINVAL;
 		}
 	}
 
 	if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 ||
 		qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for be traffic class rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for be traffic class rate");
 		return -EINVAL;
 	}
 
 	/* TC period: non-zero */
 	if (params->tc_period == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc period\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc period");
 		return -EINVAL;
 	}
 
 	/*  Best effort tc oversubscription weight: non-zero */
 	if (params->tc_ov_weight == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc ov weight\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc ov weight");
 		return -EINVAL;
 	}
 
 	/* Queue WRR weights: non-zero */
 	for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) {
 		if (params->wrr_weights[i] == 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for wrr weight\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for wrr weight");
 			return -EINVAL;
 		}
 	}
@@ -396,20 +388,17 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,
 
 	/* Check user parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	if (params->tb_rate == 0 || params->tb_rate > rate) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tb rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb rate");
 		return -EINVAL;
 	}
 
 	if (params->tb_size == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tb size\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb size");
 		return -EINVAL;
 	}
 
@@ -417,21 +406,18 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,
 		uint64_t tc_rate = params->tc_rate[i];
 
 		if (tc_rate == 0 || (tc_rate > params->tb_rate)) {
-			RTE_LOG(ERR, SCHED, "%s: "
-			"Incorrect value for tc rate\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for tc rate");
 			return -EINVAL;
 		}
 	}
 
 	if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect tc rate(best effort)\n", __func__);
+		SCHED_LOG(ERR, "Incorrect tc rate(best effort)");
 		return -EINVAL;
 	}
 
 	if (params->tc_period == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tc period\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc period");
 		return -EINVAL;
 	}
 
@@ -444,29 +430,25 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	uint32_t i;
 
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* socket */
 	if (params->socket < 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for socket id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for socket id");
 		return -EINVAL;
 	}
 
 	/* rate */
 	if (params->rate == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for rate");
 		return -EINVAL;
 	}
 
 	/* mtu */
 	if (params->mtu == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for mtu\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for mtu");
 		return -EINVAL;
 	}
 
@@ -474,8 +456,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	if (params->n_subports_per_port == 0 ||
 	    params->n_subports_per_port > 1u << 16 ||
 	    !rte_is_power_of_2(params->n_subports_per_port)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for number of subports\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for number of subports");
 		return -EINVAL;
 	}
 
@@ -483,8 +464,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 		params->n_subport_profiles == 0 ||
 		params->n_max_subport_profiles == 0 ||
 		params->n_subport_profiles > params->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED,
-		"%s: Incorrect value for subport profiles\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport profiles");
 		return -EINVAL;
 	}
 
@@ -495,9 +475,8 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 
 		status = subport_profile_check(p, params->rate);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-			"%s: subport profile check failed(%d)\n",
-			__func__, status);
+			SCHED_LOG(ERR, "subport profile check failed(%d)",
+				  status);
 			return -EINVAL;
 		}
 	}
@@ -505,8 +484,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	/* n_pipes_per_subport: non-zero, power of 2 */
 	if (params->n_pipes_per_subport == 0 ||
 	    !rte_is_power_of_2(params->n_pipes_per_subport)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for maximum pipes number\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for maximum pipes number");
 		return -EINVAL;
 	}
 
@@ -605,14 +583,15 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 {
 	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
 
-	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
+	SCHED_LOG(DEBUG,
+		  "Low level config for pipe profile %u:\n"
 		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n"
 		"	Traffic classes: period = %"PRIu64",\n"
 		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
 		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
 		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
 		"	Best-effort traffic class oversubscription: weight = %hhu\n"
-		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
+		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]",
 		i,
 
 		/* Token bucket */
@@ -648,35 +627,36 @@ rte_sched_port_log_subport_profile(struct rte_sched_port *port, uint32_t i)
 {
 	struct rte_sched_subport_profile *p = port->subport_profiles + i;
 
-	RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n"
-	"Token bucket: period = %"PRIu64", credits per period = %"PRIu64","
-	"size = %"PRIu64"\n"
-	"Traffic classes: period = %"PRIu64",\n"
-	"credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
-	" %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
-	" %"PRIu64", %"PRIu64", %"PRIu64"]\n",
-	i,
-
-	/* Token bucket */
-	p->tb_period,
-	p->tb_credits_per_period,
-	p->tb_size,
-
-	/* Traffic classes */
-	p->tc_period,
-	p->tc_credits_per_period[0],
-	p->tc_credits_per_period[1],
-	p->tc_credits_per_period[2],
-	p->tc_credits_per_period[3],
-	p->tc_credits_per_period[4],
-	p->tc_credits_per_period[5],
-	p->tc_credits_per_period[6],
-	p->tc_credits_per_period[7],
-	p->tc_credits_per_period[8],
-	p->tc_credits_per_period[9],
-	p->tc_credits_per_period[10],
-	p->tc_credits_per_period[11],
-	p->tc_credits_per_period[12]);
+	SCHED_LOG(DEBUG,
+		  "Low level config for subport profile %u:\n"
+		  "Token bucket: period = %"PRIu64", credits per period = %"PRIu64","
+		  "size = %"PRIu64"\n"
+		  "Traffic classes: period = %"PRIu64",\n"
+		  "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		  " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		  " %"PRIu64", %"PRIu64", %"PRIu64"]",
+		  i,
+
+		  /* Token bucket */
+		  p->tb_period,
+		  p->tb_credits_per_period,
+		  p->tb_size,
+
+		  /* Traffic classes */
+		  p->tc_period,
+		  p->tc_credits_per_period[0],
+		  p->tc_credits_per_period[1],
+		  p->tc_credits_per_period[2],
+		  p->tc_credits_per_period[3],
+		  p->tc_credits_per_period[4],
+		  p->tc_credits_per_period[5],
+		  p->tc_credits_per_period[6],
+		  p->tc_credits_per_period[7],
+		  p->tc_credits_per_period[8],
+		  p->tc_credits_per_period[9],
+		  p->tc_credits_per_period[10],
+		  p->tc_credits_per_period[11],
+		  p->tc_credits_per_period[12]);
 }
 
 static inline uint64_t
@@ -829,8 +809,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 
 	/* Check user parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
@@ -841,14 +820,13 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 		uint16_t qsize = params->qsize[i];
 
 		if (qsize != 0 && !rte_is_power_of_2(qsize)) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for qsize\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for qsize");
 			return -EINVAL;
 		}
 	}
 
 	if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED, "%s: Incorrect qsize\n", __func__);
+		SCHED_LOG(ERR, "Incorrect qsize");
 		return -EINVAL;
 	}
 
@@ -856,8 +834,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	if (params->n_pipes_per_subport_enabled == 0 ||
 		params->n_pipes_per_subport_enabled > n_max_pipes_per_subport ||
 	    !rte_is_power_of_2(params->n_pipes_per_subport_enabled)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for pipes number\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for pipes number");
 		return -EINVAL;
 	}
 
@@ -866,8 +843,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	    params->n_pipe_profiles == 0 ||
 		params->n_max_pipe_profiles == 0 ||
 		params->n_pipe_profiles > params->n_max_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for pipe profiles\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for pipe profiles");
 		return -EINVAL;
 	}
 
@@ -877,8 +853,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 
 		status = pipe_profile_check(p, rate, &params->qsize[0]);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Pipe profile check failed(%d)\n", __func__, status);
+			SCHED_LOG(ERR, "Pipe profile check failed(%d)", status);
 			return -EINVAL;
 		}
 	}
@@ -895,9 +870,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
 
 	status = rte_sched_port_check_params(port_params);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Port scheduler port params check failed (%d)\n",
-			__func__, status);
+		SCHED_LOG(ERR,
+			  "Port scheduler port params check failed (%d)",
+			  status);
 
 		return 0;
 	}
@@ -909,9 +884,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
 				port_params->n_pipes_per_subport,
 				port_params->rate);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Port scheduler subport params check failed (%d)\n",
-				__func__, status);
+			SCHED_LOG(ERR,
+				  "Port scheduler subport params check failed (%d)",
+				status);
 
 			return 0;
 		}
@@ -940,8 +915,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 
 	status = rte_sched_port_check_params(params);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Port scheduler params check failed (%d)\n",
+		SCHED_LOG(ERR, "Port scheduler params check failed (%d)\n",
 			__func__, status);
 		return NULL;
 	}
@@ -955,7 +929,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	port = rte_zmalloc_socket("qos_params", size0 + size1,
 				 RTE_CACHE_LINE_SIZE, params->socket);
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
+		SCHED_LOG(ERR, "Memory allocation fails");
 
 		return NULL;
 	}
@@ -964,7 +938,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	port->subport_profiles  = rte_zmalloc_socket("subport_profile", size2,
 					RTE_CACHE_LINE_SIZE, params->socket);
 	if (port->subport_profiles == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
+		SCHED_LOG(ERR, "Memory allocation fails");
 		rte_free(port);
 		return NULL;
 	}
@@ -1106,8 +1080,7 @@ rte_sched_red_config(struct rte_sched_port *port,
 				params->cman_params->red_params[i][j].maxp_inv) != 0) {
 				rte_sched_free_memory(port, n_subports);
 
-				RTE_LOG(NOTICE, SCHED,
-				"%s: RED configuration init fails\n", __func__);
+				SCHED_LOG(NOTICE, "RED configuration init fails");
 				return -EINVAL;
 			}
 		}
@@ -1126,8 +1099,7 @@ rte_sched_pie_config(struct rte_sched_port *port,
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
 		if (params->cman_params->pie_params[i].tailq_th > params->qsize[i]) {
-			RTE_LOG(NOTICE, SCHED,
-			"%s: PIE tailq threshold incorrect\n", __func__);
+			SCHED_LOG(NOTICE, "PIE tailq threshold incorrect");
 			return -EINVAL;
 		}
 
@@ -1138,8 +1110,7 @@ rte_sched_pie_config(struct rte_sched_port *port,
 			params->cman_params->pie_params[i].tailq_th) != 0) {
 			rte_sched_free_memory(port, n_subports);
 
-			RTE_LOG(NOTICE, SCHED,
-			"%s: PIE configuration init fails\n", __func__);
+			SCHED_LOG(NOTICE, "PIE configuration init fails");
 			return -EINVAL;
 			}
 	}
@@ -1170,14 +1141,12 @@ rte_sched_subport_tc_ov_config(struct rte_sched_port *port,
 	struct rte_sched_subport *s;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter subport id");
 		return  -EINVAL;
 	}
 
@@ -1203,22 +1172,19 @@ rte_sched_subport_config(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return 0;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (subport_profile_id >= port->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED, "%s: "
-			"Number of subport profile exceeds the max limit\n",
-			__func__);
+		SCHED_LOG(ERR,
+			  "Number of subport profile exceeds the max limit");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1233,9 +1199,9 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			port->n_pipes_per_subport,
 			port->rate);
 		if (status != 0) {
-			RTE_LOG(NOTICE, SCHED,
-				"%s: Port scheduler params check failed (%d)\n",
-				__func__, status);
+			SCHED_LOG(NOTICE,
+				  "Port scheduler params check failed (%d)",
+				  status);
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1249,8 +1215,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		s = rte_zmalloc_socket("subport_params", size0 + size1,
 			RTE_CACHE_LINE_SIZE, port->socket);
 		if (s == NULL) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Memory allocation fails\n", __func__);
+			SCHED_LOG(ERR, "Memory allocation fails");
 			ret = -ENOMEM;
 			goto out;
 		}
@@ -1281,8 +1246,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			s->cman_enabled = true;
 			status = rte_sched_cman_config(port, s, params, n_subports);
 			if (status) {
-				RTE_LOG(NOTICE, SCHED,
-					"%s: CMAN configuration fails\n", __func__);
+				SCHED_LOG(NOTICE,
+					  "CMAN configuration fails");
 				return status;
 			}
 		} else {
@@ -1329,8 +1294,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		s->bmp = rte_bitmap_init(n_subport_pipe_queues, s->bmp_array,
 					bmp_mem_size);
 		if (s->bmp == NULL) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Subport bitmap init error\n", __func__);
+			SCHED_LOG(ERR, "Subport bitmap init error");
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1399,29 +1363,25 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 	deactivate = (pipe_profile < 0);
 
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter subport id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	s = port->subports[subport_id];
 	if (pipe_id >= s->n_pipes_per_subport_enabled) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter pipe id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter pipe id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (!deactivate && profile >= s->n_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter pipe profile\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter pipe profile");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1446,9 +1406,9 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 		s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
 
 		if (s->tc_ov != tc_be_ov) {
-			RTE_LOG(DEBUG, SCHED,
-				"Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)\n",
-				subport_id, subport_tc_be_rate, s->tc_ov_rate);
+			SCHED_LOG(DEBUG,
+				  "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)",
+				  subport_id, subport_tc_be_rate, s->tc_ov_rate);
 		}
 
 		/* Reset the pipe */
@@ -1488,8 +1448,8 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 		s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
 
 		if (s->tc_ov != tc_be_ov) {
-			RTE_LOG(DEBUG, SCHED,
-				"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n",
+			SCHED_LOG(DEBUG,
+				"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)",
 				subport_id, subport_tc_be_rate, s->tc_ov_rate);
 		}
 		p->tc_ov_period_id = s->tc_ov_period_id;
@@ -1517,15 +1477,13 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 
 	/* Port */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	/* Subport id not exceeds the max limit */
 	if (subport_id > port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		return -EINVAL;
 	}
 
@@ -1533,16 +1491,14 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 
 	/* Pipe profiles exceeds the max limit */
 	if (s->n_pipe_profiles >= s->n_max_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Number of pipe profiles exceeds the max limit\n", __func__);
+		SCHED_LOG(ERR, "Number of pipe profiles exceeds the max limit");
 		return -EINVAL;
 	}
 
 	/* Pipe params */
 	status = pipe_profile_check(params, port->rate, &s->qsize[0]);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Pipe profile check failed(%d)\n", __func__, status);
+		SCHED_LOG(ERR, "Pipe profile check failed(%d)", status);
 		return -EINVAL;
 	}
 
@@ -1552,8 +1508,7 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 	/* Pipe profile should not exists */
 	for (i = 0; i < s->n_pipe_profiles; i++)
 		if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Pipe profile exists\n", __func__);
+			SCHED_LOG(ERR, "Pipe profile exists");
 			return -EINVAL;
 		}
 
@@ -1580,21 +1535,18 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 
 	/* Port */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter profile\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter profile");
 		return -EINVAL;
 	}
 
 	if (subport_profile_id == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter subport_profile_id\n",
-		__func__);
+		SCHED_LOG(ERR,
+			  "Incorrect value for parameter subport_profile_id");
 		return -EINVAL;
 	}
 
@@ -1602,16 +1554,14 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 
 	/* Subport profiles exceeds the max limit */
 	if (port->n_subport_profiles >= port->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Number of subport profiles exceeds the max limit\n",
-		 __func__);
+		SCHED_LOG(ERR,
+			  "Number of subport profiles exceeds the max limit");
 		return -EINVAL;
 	}
 
 	status = subport_profile_check(params, port->rate);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-		"%s: subport profile check failed(%d)\n", __func__, status);
+		SCHED_LOG(ERR, "subport profile check failed", status);
 		return -EINVAL;
 	}
 
@@ -1621,8 +1571,7 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 	for (i = 0; i < port->n_subport_profiles; i++)
 		if (memcmp(port->subport_profiles + i,
 		    dst, sizeof(*dst)) == 0) {
-			RTE_LOG(ERR, SCHED,
-			"%s: subport profile exists\n", __func__);
+			SCHED_LOG(ERR, "subport profile exists");
 			return -EINVAL;
 		}
 
@@ -1694,26 +1643,22 @@ rte_sched_subport_read_stats(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		return -EINVAL;
 	}
 
 	if (stats == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter stats\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter stats");
 		return -EINVAL;
 	}
 
 	if (tc_ov == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc_ov\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc_ov");
 		return -EINVAL;
 	}
 
@@ -1742,26 +1687,22 @@ rte_sched_queue_read_stats(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (queue_id >= rte_sched_port_queues_per_port(port)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for queue id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for queue id");
 		return -EINVAL;
 	}
 
 	if (stats == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter stats\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter stats");
 		return -EINVAL;
 	}
 
 	if (qlen == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter qlen\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter qlen");
 		return -EINVAL;
 	}
 	subport_qmask = port->n_pipes_per_subport_log2 + 4;
@@ -3002,3 +2943,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_SUFFIX(sched_logtype, "sched", INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..cbf577faf2cb
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_log.h>
+
+extern int sched_logtype;
+
+#define SCHED_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, sched_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 00/17] static logtype removal
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (12 preceding siblings ...)
  2023-02-07 20:41 ` [RFC 13/13] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-07 23:04 ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 01/17] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
                     ` (16 more replies)
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                   ` (8 subsequent siblings)
  22 siblings, 17 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Second draft of removing static log types.  This version also
fixes abuse of RTE_LOGTYPE_USER1 in some libraries.

May split the USER1 stuff out into seperate patch bundle
in later versions.

Still left is the big device driver usage.

Stephen Hemminger (17):
  doc: document intention to deprecate RTE_LOGTYPE_USER*
  ip_frag: use a dynamic logtype
  reorder: use a dynamic logtype
  latencystats: use dynamic logtype
  gso: remove logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with local type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  hash: replace RTE_LOGTYPE_HASH with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  port: replace RTE_LOGTYPE_PORT with dynamic type

 app/test/test_acl.c                           |   3 +-
 .../prog_guide/writing_efficient_code.rst     |   3 +-
 doc/guides/rel_notes/deprecation.rst          |   4 +
 lib/acl/acl_bld.c                             |  35 ++-
 lib/acl/acl_gen.c                             |  20 +-
 lib/acl/acl_log.h                             |  13 +
 lib/acl/rte_acl.c                             |  14 +-
 lib/acl/tb_mem.c                              |   8 +-
 lib/eal/common/eal_common_log.c               |  16 +-
 lib/eal/include/rte_log.h                     |  29 +-
 lib/efd/rte_efd.c                             | 106 +++----
 lib/fib/rte_fib.c                             |  23 +-
 lib/fib/rte_fib6.c                            |  21 +-
 lib/gso/rte_gso.c                             |   3 +-
 lib/hash/rte_cuckoo_hash.c                    |  60 ++--
 lib/hash/rte_fbk_hash.c                       |  10 +-
 lib/hash/rte_hash_crc.h                       |   6 +-
 lib/hash/rte_thash.c                          |  53 +++-
 lib/hash/rte_thash_gfni.h                     |  24 +-
 lib/hash/version.map                          |   4 +
 lib/ip_frag/ip_frag_common.h                  |  16 +-
 lib/ip_frag/ip_frag_internal.c                | 174 +++++-----
 lib/ip_frag/rte_ip_frag_common.c              |  13 +-
 lib/ip_frag/rte_ipv4_reassembly.c             |  14 +-
 lib/ip_frag/rte_ipv6_reassembly.c             |  59 ++--
 lib/kni/rte_kni.c                             |  63 ++--
 lib/latencystats/rte_latencystats.c           |  55 ++--
 lib/lpm/rte_lpm.c                             |  18 +-
 lib/lpm/rte_lpm6.c                            |  25 +-
 lib/mbuf/mbuf_log.h                           |  10 +
 lib/mbuf/rte_mbuf.c                           |  20 +-
 lib/mbuf/rte_mbuf_dyn.c                       |  15 +-
 lib/mbuf/rte_mbuf_pool_ops.c                  |   5 +-
 lib/mempool/rte_mempool.c                     |  33 +-
 lib/mempool/rte_mempool_log.h                 |  10 +
 lib/mempool/rte_mempool_ops.c                 |  12 +-
 lib/port/rte_port_ethdev.c                    |  23 +-
 lib/port/rte_port_eventdev.c                  |  23 +-
 lib/port/rte_port_fd.c                        |  28 +-
 lib/port/rte_port_frag.c                      |  21 +-
 lib/port/rte_port_kni.c                       |  22 +-
 lib/port/rte_port_ras.c                       |  17 +-
 lib/port/rte_port_ring.c                      |  22 +-
 lib/port/rte_port_sched.c                     |  16 +-
 lib/port/rte_port_source_sink.c               |  82 ++---
 lib/port/rte_port_sym_crypto.c                |  22 +-
 lib/power/guest_channel.c                     |  48 +--
 lib/power/power_acpi_cpufreq.c                | 118 +++----
 lib/power/power_common.c                      |  11 +-
 lib/power/power_common.h                      |   7 +-
 lib/power/power_cppc_cpufreq.c                | 129 ++++----
 lib/power/power_kvm_vm.c                      |  24 +-
 lib/power/power_pstate_cpufreq.c              | 166 +++++-----
 lib/power/rte_power.c                         |  25 +-
 lib/power/rte_power_empty_poll.c              |  36 +--
 lib/power/rte_power_intel_uncore.c            |  75 ++---
 lib/power/rte_power_pmd_mgmt.c                |  37 ++-
 lib/reorder/rte_reorder.c                     |  35 ++-
 lib/rib/rte_rib.c                             |  14 +-
 lib/rib/rte_rib6.c                            |  16 +-
 lib/ring/rte_ring.c                           |  31 +-
 lib/sched/rte_pie.c                           |  16 +-
 lib/sched/rte_sched.c                         | 297 +++++++-----------
 lib/sched/rte_sched_log.h                     |  11 +
 64 files changed, 1273 insertions(+), 1096 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 01/17] doc: document intention to deprecate RTE_LOGTYPE_USER*
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 02/17] ip_frag: use a dynamic logtype Stephen Hemminger
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

These static log types should be deprecated in next stable
release.

Also, remove use of USER1 from example of doing mlockall.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 doc/guides/prog_guide/writing_efficient_code.rst | 3 +--
 doc/guides/rel_notes/deprecation.rst             | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/writing_efficient_code.rst b/doc/guides/prog_guide/writing_efficient_code.rst
index e6c26efdd3a3..250e06bd734f 100644
--- a/doc/guides/prog_guide/writing_efficient_code.rst
+++ b/doc/guides/prog_guide/writing_efficient_code.rst
@@ -89,8 +89,7 @@ To avoid these you could pre-load, and lock them into memory with the ``mlockall
 .. code-block:: c
 
     if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
-        RTE_LOG(NOTICE, USER1, "mlockall() failed with error \"%s\"\n",
-                strerror(errno));
+        perror("mlockall");
     }
 
 Communication Between lcores
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index ac9aa7630b61..935e68134d0e 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -136,3 +136,7 @@ Deprecation Notices
   Its removal has been postponed to let potential users report interest
   in maintaining it.
   In the absence of such interest, this library will be removed in DPDK 23.11.
+
+* rte_log: The pre-defined RTE_LOGTYPE_USER* macros are planned to be
+  deprecated starting with the 23.07 release. Applications should use the
+  dynamic log types available with RTE_LOG_REGISTER instead.
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 02/17] ip_frag: use a dynamic logtype
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 01/17] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 03/17] reorder: " Stephen Hemminger
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Konstantin Ananyev, Thomas Monjalon, Anatoly Burakov

DPDK libraries should not be reusing RTE_LOGTYPE_USER1 in
lieu of doing proper logtype registration.

Fixes: 416707812c03 ("ip_frag: refactor reassembly code into a proper library")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ip_frag/ip_frag_common.h      |  16 ++-
 lib/ip_frag/ip_frag_internal.c    | 174 +++++++++++++++---------------
 lib/ip_frag/rte_ip_frag_common.c  |  13 +--
 lib/ip_frag/rte_ipv4_reassembly.c |  14 ++-
 lib/ip_frag/rte_ipv6_reassembly.c |  59 +++++-----
 5 files changed, 138 insertions(+), 138 deletions(-)

diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..134072f3e810 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -9,8 +9,16 @@
 #include "ip_reassembly.h"
 
 /* logging macros. */
+extern int ipfrag_logtype;
+
+#define IP_FRAG_ERR(fmt, args...) \
+	rte_log(RTE_LOG_ERR, ipfrag_logtype, \
+		"%s: " fmt "\n", __func__, ## args)
+
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
-#define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
+#define	IP_FRAG_LOG(lvl, fmt, args...)	\
+	rte_log(RTE_LOG ## lvl, ipfrag_logtype, \
+		"%s: " fmt "\n", __func__, ## args)
 #else
 #define	IP_FRAG_LOG(lvl, fmt, args...)	do {} while(0)
 #endif /* IP_FRAG_DEBUG */
@@ -111,9 +119,9 @@ ip_frag_free_immediate(struct ip_frag_pkt *fp)
 
 	for (i = 0; i < fp->last_idx; i++) {
 		if (fp->frags[i].mb != NULL) {
-			IP_FRAG_LOG(DEBUG, "%s:%d\n"
-			    "mbuf: %p, tms: %" PRIu64", key: <%" PRIx64 ", %#x>\n",
-			    __func__, __LINE__, fp->frags[i].mb, fp->start,
+			IP_FRAG_LOG(DEBUG,
+			    "mbuf: %p, tms: %" PRIu64", key: <%" PRIx64 ", %#x>",
+			    fp->frags[i].mb, fp->start,
 			    fp->key.src_dst[0], fp->key.id);
 			rte_pktmbuf_free(fp->frags[i].mb);
 			fp->frags[i].mb = NULL;
diff --git a/lib/ip_frag/ip_frag_internal.c b/lib/ip_frag/ip_frag_internal.c
index b436a4c9313b..c633216419a2 100644
--- a/lib/ip_frag/ip_frag_internal.c
+++ b/lib/ip_frag/ip_frag_internal.c
@@ -89,7 +89,7 @@ ipv6_frag_hash(const struct ip_frag_key *key, uint32_t *v1, uint32_t *v2)
 
 struct rte_mbuf *
 ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
-	struct rte_mbuf *mb, uint16_t ofs, uint16_t len, uint16_t more_frags)
+		struct rte_mbuf *mb, uint16_t ofs, uint16_t len, uint16_t more_frags)
 {
 	uint32_t idx;
 
@@ -98,15 +98,15 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
 	/* this is the first fragment. */
 	if (ofs == 0) {
 		idx = (fp->frags[IP_FIRST_FRAG_IDX].mb == NULL) ?
-				IP_FIRST_FRAG_IDX : UINT32_MAX;
+			IP_FIRST_FRAG_IDX : UINT32_MAX;
 
-	/* this is the last fragment. */
+		/* this is the last fragment. */
 	} else if (more_frags == 0) {
 		fp->total_size = ofs + len;
 		idx = (fp->frags[IP_LAST_FRAG_IDX].mb == NULL) ?
-				IP_LAST_FRAG_IDX : UINT32_MAX;
+			IP_LAST_FRAG_IDX : UINT32_MAX;
 
-	/* this is the intermediate fragment. */
+		/* this is the intermediate fragment. */
 	} else if ((idx = fp->last_idx) < RTE_DIM(fp->frags)) {
 		fp->last_idx++;
 	}
@@ -119,31 +119,31 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
 
 		/* report an error. */
 		if (fp->key.key_len == IPV4_KEYLEN)
-			IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n"
-				"ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, "
-				"total_size: %u, frag_size: %u, last_idx: %u\n"
-				"first fragment: ofs: %u, len: %u\n"
-				"last fragment: ofs: %u, len: %u\n\n",
-				__func__, __LINE__,
-				fp, fp->key.src_dst[0], fp->key.id,
-				fp->total_size, fp->frag_size, fp->last_idx,
-				fp->frags[IP_FIRST_FRAG_IDX].ofs,
-				fp->frags[IP_FIRST_FRAG_IDX].len,
-				fp->frags[IP_LAST_FRAG_IDX].ofs,
-				fp->frags[IP_LAST_FRAG_IDX].len);
+			IP_FRAG_LOG(DEBUG,
+				    "invalid fragmented packet:\n"
+				    "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, "
+				    "total_size: %u, frag_size: %u, last_idx: %u\n"
+				    "first fragment: ofs: %u, len: %u\n"
+				    "last fragment: ofs: %u, len: %u\n",
+				    fp, fp->key.src_dst[0], fp->key.id,
+				    fp->total_size, fp->frag_size, fp->last_idx,
+				    fp->frags[IP_FIRST_FRAG_IDX].ofs,
+				    fp->frags[IP_FIRST_FRAG_IDX].len,
+				    fp->frags[IP_LAST_FRAG_IDX].ofs,
+				    fp->frags[IP_LAST_FRAG_IDX].len);
 		else
-			IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n"
-				"ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, "
-				"total_size: %u, frag_size: %u, last_idx: %u\n"
-				"first fragment: ofs: %u, len: %u\n"
-				"last fragment: ofs: %u, len: %u\n\n",
-				__func__, __LINE__,
-				fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id,
-				fp->total_size, fp->frag_size, fp->last_idx,
-				fp->frags[IP_FIRST_FRAG_IDX].ofs,
-				fp->frags[IP_FIRST_FRAG_IDX].len,
-				fp->frags[IP_LAST_FRAG_IDX].ofs,
-				fp->frags[IP_LAST_FRAG_IDX].len);
+			IP_FRAG_LOG(DEBUG,
+				    "invalid fragmented packet:\n"
+				    "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, "
+				    "total_size: %u, frag_size: %u, last_idx: %u\n"
+				    "first fragment: ofs: %u, len: %u\n"
+				    "last fragment: ofs: %u, len: %u\n",
+				    fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id,
+				    fp->total_size, fp->frag_size, fp->last_idx,
+				    fp->frags[IP_FIRST_FRAG_IDX].ofs,
+				    fp->frags[IP_FIRST_FRAG_IDX].len,
+				    fp->frags[IP_LAST_FRAG_IDX].ofs,
+				    fp->frags[IP_LAST_FRAG_IDX].len);
 
 		/* free all fragments, invalidate the entry. */
 		ip_frag_free(fp, dr);
@@ -163,9 +163,9 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
 	if (likely (fp->frag_size < fp->total_size)) {
 		return mb;
 
-	/* if we collected all fragments, then try to reassemble. */
+		/* if we collected all fragments, then try to reassemble. */
 	} else if (fp->frag_size == fp->total_size &&
-			fp->frags[IP_FIRST_FRAG_IDX].mb != NULL) {
+		   fp->frags[IP_FIRST_FRAG_IDX].mb != NULL) {
 		if (fp->key.key_len == IPV4_KEYLEN)
 			mb = ipv4_frag_reassemble(fp);
 		else
@@ -177,31 +177,31 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
 
 		/* report an error. */
 		if (fp->key.key_len == IPV4_KEYLEN)
-			IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n"
-				"ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, "
-				"total_size: %u, frag_size: %u, last_idx: %u\n"
-				"first fragment: ofs: %u, len: %u\n"
-				"last fragment: ofs: %u, len: %u\n\n",
-				__func__, __LINE__,
-				fp, fp->key.src_dst[0], fp->key.id,
-				fp->total_size, fp->frag_size, fp->last_idx,
-				fp->frags[IP_FIRST_FRAG_IDX].ofs,
-				fp->frags[IP_FIRST_FRAG_IDX].len,
-				fp->frags[IP_LAST_FRAG_IDX].ofs,
-				fp->frags[IP_LAST_FRAG_IDX].len);
+			IP_FRAG_LOG(DEBUG,
+				    "invalid fragmented packet:\n"
+				    "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, "
+				    "total_size: %u, frag_size: %u, last_idx: %u\n"
+				    "first fragment: ofs: %u, len: %u\n"
+				    "last fragment: ofs: %u, len: %u\n,
+				    fp, fp->key.src_dst[0], fp->key.id,
+				    fp->total_size, fp->frag_size, fp->last_idx,
+				    fp->frags[IP_FIRST_FRAG_IDX].ofs,
+				    fp->frags[IP_FIRST_FRAG_IDX].len,
+				    fp->frags[IP_LAST_FRAG_IDX].ofs,
+				    fp->frags[IP_LAST_FRAG_IDX].len);
 		else
-			IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n"
-				"ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, "
-				"total_size: %u, frag_size: %u, last_idx: %u\n"
-				"first fragment: ofs: %u, len: %u\n"
-				"last fragment: ofs: %u, len: %u\n\n",
-				__func__, __LINE__,
-				fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id,
-				fp->total_size, fp->frag_size, fp->last_idx,
-				fp->frags[IP_FIRST_FRAG_IDX].ofs,
-				fp->frags[IP_FIRST_FRAG_IDX].len,
-				fp->frags[IP_LAST_FRAG_IDX].ofs,
-				fp->frags[IP_LAST_FRAG_IDX].len);
+			IP_FRAG_LOG(DEBUG,
+				    "invalid fragmented packet:\n"
+				    "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, "
+				    "total_size: %u, frag_size: %u, last_idx: %u\n"
+				    "first fragment: ofs: %u, len: %u\n"
+				    "last fragment: ofs: %u, len: %u\n",
+				    fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id,
+				    fp->total_size, fp->frag_size, fp->last_idx,
+				    fp->frags[IP_FIRST_FRAG_IDX].ofs,
+				    fp->frags[IP_FIRST_FRAG_IDX].len,
+				    fp->frags[IP_LAST_FRAG_IDX].ofs,
+				    fp->frags[IP_LAST_FRAG_IDX].len);
 
 		/* free associated resources. */
 		ip_frag_free(fp, dr);
@@ -282,8 +282,8 @@ ip_frag_find(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr,
 
 struct ip_frag_pkt *
 ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
-	const struct ip_frag_key *key, uint64_t tms,
-	struct ip_frag_pkt **free, struct ip_frag_pkt **stale)
+	       const struct ip_frag_key *key, uint64_t tms,
+	       struct ip_frag_pkt **free, struct ip_frag_pkt **stale)
 {
 	struct ip_frag_pkt *p1, *p2;
 	struct ip_frag_pkt *empty, *old;
@@ -310,23 +310,21 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
 
 	for (i = 0; i != assoc; i++) {
 		if (p1->key.key_len == IPV4_KEYLEN)
-			IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-					"tbl: %p, max_entries: %u, use_entries: %u\n"
-					"ipv4_frag_pkt line0: %p, index: %u from %u\n"
-			"key: <%" PRIx64 ", %#x>, start: %" PRIu64 "\n",
-					__func__, __LINE__,
-					tbl, tbl->max_entries, tbl->use_entries,
-					p1, i, assoc,
-			p1[i].key.src_dst[0], p1[i].key.id, p1[i].start);
+			IP_FRAG_LOG(DEBUG,
+				    "tbl: %p, max_entries: %u, use_entries: %u\n"
+				    "ipv4_frag_pkt line0: %p, index: %u from %u\n"
+				    "key: <%" PRIx64 ", %#x>, start: %" PRIu64,
+				    tbl, tbl->max_entries, tbl->use_entries,
+				    p1, i, assoc,
+				    p1[i].key.src_dst[0], p1[i].key.id, p1[i].start);
 		else
-			IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-					"tbl: %p, max_entries: %u, use_entries: %u\n"
-					"ipv6_frag_pkt line0: %p, index: %u from %u\n"
-			"key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 "\n",
-					__func__, __LINE__,
-					tbl, tbl->max_entries, tbl->use_entries,
-					p1, i, assoc,
-			IPv6_KEY_BYTES(p1[i].key.src_dst), p1[i].key.id, p1[i].start);
+			IP_FRAG_LOG(DEBUG,
+				    "tbl: %p, max_entries: %u, use_entries: %u\n"
+				    "ipv6_frag_pkt line0: %p, index: %u from %u\n"
+				    "key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64,
+				    tbl, tbl->max_entries, tbl->use_entries,
+				    p1, i, assoc,
+				    IPv6_KEY_BYTES(p1[i].key.src_dst), p1[i].key.id, p1[i].start);
 
 		if (ip_frag_key_cmp(key, &p1[i].key) == 0)
 			return p1 + i;
@@ -336,23 +334,21 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
 			old = (old == NULL) ? (p1 + i) : old;
 
 		if (p2->key.key_len == IPV4_KEYLEN)
-			IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-					"tbl: %p, max_entries: %u, use_entries: %u\n"
-					"ipv4_frag_pkt line1: %p, index: %u from %u\n"
-			"key: <%" PRIx64 ", %#x>, start: %" PRIu64 "\n",
-					__func__, __LINE__,
-					tbl, tbl->max_entries, tbl->use_entries,
-					p2, i, assoc,
-			p2[i].key.src_dst[0], p2[i].key.id, p2[i].start);
+			IP_FRAG_LOG(DEBUG,
+				    "tbl: %p, max_entries: %u, use_entries: %u\n"
+				    "ipv4_frag_pkt line1: %p, index: %u from %u\n"
+				    "key: <%" PRIx64 ", %#x>, start: %" PRIu64,
+				    tbl, tbl->max_entries, tbl->use_entries,
+				    p2, i, assoc,
+				    p2[i].key.src_dst[0], p2[i].key.id, p2[i].start);
 		else
-			IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-					"tbl: %p, max_entries: %u, use_entries: %u\n"
-					"ipv6_frag_pkt line1: %p, index: %u from %u\n"
-			"key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 "\n",
-					__func__, __LINE__,
-					tbl, tbl->max_entries, tbl->use_entries,
-					p2, i, assoc,
-			IPv6_KEY_BYTES(p2[i].key.src_dst), p2[i].key.id, p2[i].start);
+			IP_FRAG_LOG(DEBUG,
+				    "tbl: %p, max_entries: %u, use_entries: %u\n"
+				    "ipv6_frag_pkt line1: %p, index: %u from %u\n"
+				    "key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64,
+				    tbl, tbl->max_entries, tbl->use_entries,
+				    p2, i, assoc,
+				    IPv6_KEY_BYTES(p2[i].key.src_dst), p2[i].key.id, p2[i].start);
 
 		if (ip_frag_key_cmp(key, &p2[i].key) == 0)
 			return p2 + i;
diff --git a/lib/ip_frag/rte_ip_frag_common.c b/lib/ip_frag/rte_ip_frag_common.c
index c1de2e81b6d0..b8ca9e019c54 100644
--- a/lib/ip_frag/rte_ip_frag_common.c
+++ b/lib/ip_frag/rte_ip_frag_common.c
@@ -52,21 +52,20 @@ rte_ip_frag_table_create(uint32_t bucket_num, uint32_t bucket_entries,
 	if (rte_is_power_of_2(bucket_entries) == 0 ||
 			nb_entries > UINT32_MAX || nb_entries == 0 ||
 			nb_entries < max_entries) {
-		RTE_LOG(ERR, USER1, "%s: invalid input parameter\n", __func__);
+		IP_FRAG_ERR("invalid input parameter");
 		return NULL;
 	}
 
 	sz = sizeof (*tbl) + nb_entries * sizeof (tbl->pkt[0]);
 	if ((tbl = rte_zmalloc_socket(__func__, sz, RTE_CACHE_LINE_SIZE,
 			socket_id)) == NULL) {
-		RTE_LOG(ERR, USER1,
-			"%s: allocation of %zu bytes at socket %d failed do\n",
-			__func__, sz, socket_id);
+		IP_FRAG_ERR("allocation of %zu bytes at socket %d failed do",
+			sz, socket_id);
 		return NULL;
 	}
 
-	RTE_LOG(INFO, USER1, "%s: allocated of %zu bytes at socket %d\n",
-		__func__, sz, socket_id);
+	IP_FRAG_LOG(INFO, "allocated of %zu bytes at socket %d",
+		    sz, socket_id);
 
 	tbl->max_cycles = max_cycles;
 	tbl->max_entries = max_entries;
@@ -142,3 +141,5 @@ rte_ip_frag_table_del_expired_entries(struct rte_ip_frag_tbl *tbl,
 		} else
 			return;
 }
+
+RTE_LOG_REGISTER_DEFAULT(ipfrag_logtype, INFO);
diff --git a/lib/ip_frag/rte_ipv4_reassembly.c b/lib/ip_frag/rte_ipv4_reassembly.c
index 4a89a5f5365a..2cdbdc4ee87f 100644
--- a/lib/ip_frag/rte_ipv4_reassembly.c
+++ b/lib/ip_frag/rte_ipv4_reassembly.c
@@ -120,12 +120,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	ip_len = rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len;
 	trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len);
 
-	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
+	IP_FRAG_LOG(DEBUG,
 		"mbuf: %p, tms: %" PRIu64 ", key: <%" PRIx64 ", %#x>"
 		"ofs: %u, len: %d, padding: %d, flags: %#x\n"
 		"tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, "
-		"max_entries: %u, use_entries: %u\n\n",
-		__func__, __LINE__,
+		"max_entries: %u, use_entries: %u\n",
 		mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, trim, ip_flag,
 		tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries,
 		tbl->use_entries);
@@ -145,11 +144,10 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		return NULL;
 	}
 
-	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
+	IP_FRAG_LOG(DEBUG,
 		"tbl: %p, max_entries: %u, use_entries: %u\n"
 		"ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, start: %" PRIu64
-		", total_size: %u, frag_size: %u, last_idx: %u\n\n",
-		__func__, __LINE__,
+		", total_size: %u, frag_size: %u, last_idx: %u\n",
 		tbl, tbl->max_entries, tbl->use_entries,
 		fp, fp->key.src_dst[0], fp->key.id, fp->start,
 		fp->total_size, fp->frag_size, fp->last_idx);
@@ -159,11 +157,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	mb = ip_frag_process(fp, dr, mb, ip_ofs, ip_len, ip_flag);
 	ip_frag_inuse(tbl, fp);
 
-	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
+	IP_FRAG_LOG(DEBUG,
 		"mbuf: %p\n"
 		"tbl: %p, max_entries: %u, use_entries: %u\n"
 		"ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, start: %" PRIu64
-		", total_size: %u, frag_size: %u, last_idx: %u\n\n",
+		", total_size: %u, frag_size: %u, last_idx: %u\n",
 		__func__, __LINE__, mb,
 		tbl, tbl->max_entries, tbl->use_entries,
 		fp, fp->key.src_dst[0], fp->key.id, fp->start,
diff --git a/lib/ip_frag/rte_ipv6_reassembly.c b/lib/ip_frag/rte_ipv6_reassembly.c
index d4019e87e63a..935878cc6cdc 100644
--- a/lib/ip_frag/rte_ipv6_reassembly.c
+++ b/lib/ip_frag/rte_ipv6_reassembly.c
@@ -135,8 +135,8 @@ ipv6_frag_reassemble(struct ip_frag_pkt *fp)
 #define FRAG_OFFSET(x) (rte_cpu_to_be_16(x) >> 3)
 struct rte_mbuf *
 rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
-	struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms,
-	struct rte_ipv6_hdr *ip_hdr, struct rte_ipv6_fragment_ext *frag_hdr)
+				struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms,
+				struct rte_ipv6_hdr *ip_hdr, struct rte_ipv6_fragment_ext *frag_hdr)
 {
 	struct ip_frag_pkt *fp;
 	struct ip_frag_key key;
@@ -161,17 +161,16 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	ip_len = rte_be_to_cpu_16(ip_hdr->payload_len) - sizeof(*frag_hdr);
 	trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len);
 
-	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-		"mbuf: %p, tms: %" PRIu64
-		", key: <" IPv6_KEY_BYTES_FMT ", %#x>, "
-		"ofs: %u, len: %d, padding: %d, flags: %#x\n"
-		"tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, "
-		"max_entries: %u, use_entries: %u\n\n",
-		__func__, __LINE__,
-		mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len,
-		trim, RTE_IPV6_GET_MF(frag_hdr->frag_data),
-		tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries,
-		tbl->use_entries);
+	IP_FRAG_LOG(DEBUG,
+		    "mbuf: %p, tms: %" PRIu64
+		    ", key: <" IPv6_KEY_BYTES_FMT ", %#x>, "
+		    "ofs: %u, len: %d, padding: %d, flags: %#x\n"
+		    "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, "
+		    "max_entries: %u, use_entries: %u\n",
+		    mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len,
+		    trim, RTE_IPV6_GET_MF(frag_hdr->frag_data),
+		    tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries,
+		    tbl->use_entries);
 
 	/* check that fragment length is greater then zero. */
 	if (ip_len <= 0) {
@@ -189,30 +188,28 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		return NULL;
 	}
 
-	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-		"tbl: %p, max_entries: %u, use_entries: %u\n"
-		"ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64
-		", total_size: %u, frag_size: %u, last_idx: %u\n\n",
-		__func__, __LINE__,
-		tbl, tbl->max_entries, tbl->use_entries,
-		fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start,
-		fp->total_size, fp->frag_size, fp->last_idx);
+	IP_FRAG_LOG(DEBUG,
+		    "tbl: %p, max_entries: %u, use_entries: %u\n"
+		    "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64
+		    ", total_size: %u, frag_size: %u, last_idx: %u\n",
+		    tbl, tbl->max_entries, tbl->use_entries,
+		    fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start,
+		    fp->total_size, fp->frag_size, fp->last_idx);
 
 
 	/* process the fragmented packet. */
 	mb = ip_frag_process(fp, dr, mb, ip_ofs, ip_len,
-			MORE_FRAGS(frag_hdr->frag_data));
+			     MORE_FRAGS(frag_hdr->frag_data));
 	ip_frag_inuse(tbl, fp);
 
-	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-		"mbuf: %p\n"
-		"tbl: %p, max_entries: %u, use_entries: %u\n"
-		"ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64
-		", total_size: %u, frag_size: %u, last_idx: %u\n\n",
-		__func__, __LINE__, mb,
-		tbl, tbl->max_entries, tbl->use_entries,
-		fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start,
-		fp->total_size, fp->frag_size, fp->last_idx);
+	IP_FRAG_LOG(DEBUG,
+		    "mbuf: %p\n"
+		    "tbl: %p, max_entries: %u, use_entries: %u\n"
+		    "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64
+		    ", total_size: %u, frag_size: %u, last_idx: %u\n",
+		    mb,tbl, tbl->max_entries, tbl->use_entries,
+		    fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start,
+		    fp->total_size, fp->frag_size, fp->last_idx);
 
 	return mb;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 03/17] reorder: use a dynamic logtype
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 01/17] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 02/17] ip_frag: use a dynamic logtype Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 04/17] latencystats: use " Stephen Hemminger
                     ` (13 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, sergio.gonzalez.monroy, Reshma Pattan,
	Neil Horman, Declan Doherty, Richardson Bruce

Libraries should not be reusing RTE_LOGTYPE_USER1 instead
of doing proper logtype registration.

Fixes: b70b56032bff ("reorder: new library")
Cc: sergio.gonzalez.monroy@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/reorder/rte_reorder.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 385ee479da42..c9ae42e71783 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -27,7 +27,11 @@ EAL_REGISTER_TAILQ(rte_reorder_tailq)
 #define RTE_REORDER_NAMESIZE 32
 
 /* Macros for printing using RTE_LOG */
-#define RTE_LOGTYPE_REORDER	RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_DEFAULT(reorder_logtype, INFO);
+
+#define REORDER_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, reorder_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
 
 #define RTE_REORDER_SEQN_DYNFIELD_NAME "rte_reorder_seqn_dynfield"
 int rte_reorder_seqn_dynfield_offset = -1;
@@ -62,26 +66,25 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
 					(2 * size * sizeof(struct rte_mbuf *));
 
 	if (b == NULL) {
-		RTE_LOG(ERR, REORDER, "Invalid reorder buffer parameter:"
-					" NULL\n");
+		REORDER_LOG(ERR, "Invalid reorder buffer parameter: NULL");
 		rte_errno = EINVAL;
 		return NULL;
 	}
 	if (!rte_is_power_of_2(size)) {
-		RTE_LOG(ERR, REORDER, "Invalid reorder buffer size"
-				" - Not a power of 2\n");
+		REORDER_LOG(ERR,
+			    "Invalid reorder buffer size - Not a power of 2");
 		rte_errno = EINVAL;
 		return NULL;
 	}
 	if (name == NULL) {
-		RTE_LOG(ERR, REORDER, "Invalid reorder buffer name ptr:"
-					" NULL\n");
+		REORDER_LOG(ERR, "Invalid reorder buffer name ptr: NULL");
 		rte_errno = EINVAL;
 		return NULL;
 	}
 	if (bufsize < min_bufsize) {
-		RTE_LOG(ERR, REORDER, "Invalid reorder buffer memory size: %u, "
-			"minimum required: %u\n", bufsize, min_bufsize);
+		REORDER_LOG(ERR,
+			    "Invalid reorder buffer memory size: %u, minimum required: %u",
+			    bufsize, min_bufsize);
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -116,14 +119,13 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 
 	/* Check user arguments. */
 	if (!rte_is_power_of_2(size)) {
-		RTE_LOG(ERR, REORDER, "Invalid reorder buffer size"
-				" - Not a power of 2\n");
+		REORDER_LOG(ERR,
+			    "Invalid reorder buffer size - Not a power of 2");
 		rte_errno = EINVAL;
 		return NULL;
 	}
 	if (name == NULL) {
-		RTE_LOG(ERR, REORDER, "Invalid reorder buffer name ptr:"
-					" NULL\n");
+		REORDER_LOG(ERR, "Invalid reorder buffer name ptr: NULL");
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -131,7 +133,8 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	rte_reorder_seqn_dynfield_offset =
 		rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc);
 	if (rte_reorder_seqn_dynfield_offset < 0) {
-		RTE_LOG(ERR, REORDER, "Failed to register mbuf field for reorder sequence number\n");
+		REORDER_LOG(ERR,
+			    "Failed to register mbuf field for reorder sequence number");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -150,7 +153,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	/* allocate tailq entry */
 	te = rte_zmalloc("REORDER_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, REORDER, "Failed to allocate tailq entry\n");
+		REORDER_LOG(ERR, "Failed to allocate tailq entry");
 		rte_errno = ENOMEM;
 		b = NULL;
 		goto exit;
@@ -159,7 +162,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	/* Allocate memory to store the reorder buffer structure. */
 	b = rte_zmalloc_socket("REORDER_BUFFER", bufsize, 0, socket_id);
 	if (b == NULL) {
-		RTE_LOG(ERR, REORDER, "Memzone allocation failed\n");
+		REORDER_LOG(ERR, "Memzone allocation failed");
 		rte_errno = ENOMEM;
 		rte_free(te);
 	} else {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 04/17] latencystats: use dynamic logtype
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 03/17] reorder: " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 05/17] gso: remove logtype Stephen Hemminger
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, reshma.pattan, Remy Horton, Harry van Haaren

Libraries should not reuse RTE_LOGTYPE_USER1 for their
loggging. Instead they should register their own type.

Fixes: 5cd3cac9ed22 ("latency: added new library for latency stats")
Cc: reshma.pattan@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/latencystats/rte_latencystats.c | 55 +++++++++++++++--------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
index 8985a377db4e..3a4c47e2b34a 100644
--- a/lib/latencystats/rte_latencystats.c
+++ b/lib/latencystats/rte_latencystats.c
@@ -26,7 +26,10 @@ latencystat_cycles_per_ns(void)
 }
 
 /* Macros for printing using RTE_LOG */
-#define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_DEFAULT(latencystat_logtype, INFO);
+#define LATENCYSTATS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, latencystat_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 static uint64_t timestamp_dynflag;
 static int timestamp_dynfield_offset = -1;
@@ -95,7 +98,7 @@ rte_latencystats_update(void)
 					latency_stats_index,
 					values, NUM_LATENCY_STATS);
 	if (ret < 0)
-		RTE_LOG(INFO, LATENCY_STATS, "Failed to push the stats\n");
+		LATENCYSTATS_LOG(INFO, "Failed to push the stats");
 
 	return ret;
 }
@@ -227,8 +230,7 @@ rte_latencystats_init(uint64_t app_samp_intvl,
 	mz = rte_memzone_reserve(MZ_RTE_LATENCY_STATS, sizeof(*glob_stats),
 					rte_socket_id(), flags);
 	if (mz == NULL) {
-		RTE_LOG(ERR, LATENCY_STATS, "Cannot reserve memory: %s:%d\n",
-			__func__, __LINE__);
+		LATENCYSTATS_LOG(ERR, "Cannot reserve memory");
 		return -ENOMEM;
 	}
 
@@ -243,8 +245,7 @@ rte_latencystats_init(uint64_t app_samp_intvl,
 	latency_stats_index = rte_metrics_reg_names(ptr_strings,
 							NUM_LATENCY_STATS);
 	if (latency_stats_index < 0) {
-		RTE_LOG(DEBUG, LATENCY_STATS,
-			"Failed to register latency stats names\n");
+		LATENCYSTATS_LOG(ERR, "Failed to register latency stats names");
 		return -1;
 	}
 
@@ -252,8 +253,8 @@ rte_latencystats_init(uint64_t app_samp_intvl,
 	ret = rte_mbuf_dyn_rx_timestamp_register(&timestamp_dynfield_offset,
 			&timestamp_dynflag);
 	if (ret != 0) {
-		RTE_LOG(ERR, LATENCY_STATS,
-			"Cannot register mbuf field/flag for timestamp\n");
+		LATENCYSTATS_LOG(ERR,
+				 "Cannot register mbuf field/flag for timestamp");
 		return -rte_errno;
 	}
 
@@ -263,9 +264,9 @@ rte_latencystats_init(uint64_t app_samp_intvl,
 
 		ret = rte_eth_dev_info_get(pid, &dev_info);
 		if (ret != 0) {
-			RTE_LOG(INFO, LATENCY_STATS,
-				"Error during getting device (port %u) info: %s\n",
-				pid, strerror(-ret));
+			LATENCYSTATS_LOG(INFO,
+					 "Error during getting device (port %u) info: %s",
+					 pid, strerror(-ret));
 
 			continue;
 		}
@@ -275,18 +276,18 @@ rte_latencystats_init(uint64_t app_samp_intvl,
 			cbs->cb = rte_eth_add_first_rx_callback(pid, qid,
 					add_time_stamps, user_cb);
 			if (!cbs->cb)
-				RTE_LOG(INFO, LATENCY_STATS, "Failed to "
-					"register Rx callback for pid=%d, "
-					"qid=%d\n", pid, qid);
+				LATENCYSTATS_LOG(INFO,
+						 "Failed to register Rx callback for pid=%d, qid=%d",
+						 pid, qid);
 		}
 		for (qid = 0; qid < dev_info.nb_tx_queues; qid++) {
 			cbs = &tx_cbs[pid][qid];
 			cbs->cb =  rte_eth_add_tx_callback(pid, qid,
 					calc_latency, user_cb);
 			if (!cbs->cb)
-				RTE_LOG(INFO, LATENCY_STATS, "Failed to "
-					"register Tx callback for pid=%d, "
-					"qid=%d\n", pid, qid);
+				LATENCYSTATS_LOG(INFO,
+						 "Failed to register Tx callback for pid=%d, qid=%d",
+						 pid, qid);
 		}
 	}
 	return 0;
@@ -307,8 +308,8 @@ rte_latencystats_uninit(void)
 
 		ret = rte_eth_dev_info_get(pid, &dev_info);
 		if (ret != 0) {
-			RTE_LOG(INFO, LATENCY_STATS,
-				"Error during getting device (port %u) info: %s\n",
+			LATENCYSTATS_LOG(INFO,
+				"Error during getting device (port %u) info: %s",
 				pid, strerror(-ret));
 
 			continue;
@@ -318,17 +319,17 @@ rte_latencystats_uninit(void)
 			cbs = &rx_cbs[pid][qid];
 			ret = rte_eth_remove_rx_callback(pid, qid, cbs->cb);
 			if (ret)
-				RTE_LOG(INFO, LATENCY_STATS, "failed to "
-					"remove Rx callback for pid=%d, "
-					"qid=%d\n", pid, qid);
+				LATENCYSTATS_LOG(INFO,
+						 "failed to remove Rx callback for pid=%d, qid=%d",
+						 pid, qid);
 		}
 		for (qid = 0; qid < dev_info.nb_tx_queues; qid++) {
 			cbs = &tx_cbs[pid][qid];
 			ret = rte_eth_remove_tx_callback(pid, qid, cbs->cb);
 			if (ret)
-				RTE_LOG(INFO, LATENCY_STATS, "failed to "
-					"remove Tx callback for pid=%d, "
-					"qid=%d\n", pid, qid);
+				LATENCYSTATS_LOG(INFO,
+						 "failed to remove Tx callback for pid=%d, qid=%d",
+						 pid, qid);
 		}
 	}
 
@@ -365,8 +366,8 @@ rte_latencystats_get(struct rte_metric_value *values, uint16_t size)
 		const struct rte_memzone *mz;
 		mz = rte_memzone_lookup(MZ_RTE_LATENCY_STATS);
 		if (mz == NULL) {
-			RTE_LOG(ERR, LATENCY_STATS,
-				"Latency stats memzone not found\n");
+			LATENCYSTATS_LOG(ERR,
+					 "Latency stats memzone not found");
 			return -ENOMEM;
 		}
 		glob_stats =  mz->addr;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 05/17] gso: remove logtype
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 04/17] latencystats: use " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 06/17] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (11 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Konstantin Ananyev, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message and pass it through. This is incorrect
behaviour on many levels:
  - it allows oversize packet to get passed on to NIC driver
  - no direct return is visible to applications
  - if it happens once, many more will follow and log will fill.
  - bonus it is only log message with GSO type.

The fix is to just return -EINVAL which is what this library
does in many other places when looking at headers.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 +-
 lib/eal/include/rte_log.h       | 1 -
 lib/gso/rte_gso.c               | 3 +--
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..c369154cb1ea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
+
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..97d6b26a9967 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,6 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..19c351769fcc 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
 		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -EINVAL;
 	}
 
 	if (ret < 0) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 06/17] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 05/17] gso: remove logtype Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 07/17] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index c369154cb1ea..e7ccde1c9ccd 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 97d6b26a9967..361d1ad96299 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 07/17] efd: replace RTE_LOGTYPE_EFD with local type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 06/17] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 08/17] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of global logtype with a local log type.
Do not break message formats across source lines.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   1 -
 lib/eal/include/rte_log.h       |   2 +-
 lib/efd/rte_efd.c               | 106 +++++++++++++++-----------------
 3 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index e7ccde1c9ccd..675f3d07bbe3 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 361d1ad96299..a90fa629168d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 
 /* these log types can be used in an application */
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..23316ef7300f 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -87,6 +87,11 @@ static struct rte_tailq_elem rte_efd_tailq = {
 };
 EAL_REGISTER_TAILQ(rte_efd_tailq);
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+
+#define EFD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args)
+
 /** Internal permutation array used to shuffle bins into pseudorandom groups */
 const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = {
 	{
@@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
 	if (online_cpu_socket_bitmask == 0) {
-		RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled "
-				"in the bitmask\n");
+		EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask");
 		return NULL;
 	}
 
 	if (max_num_rules == 0) {
-		RTE_LOG(ERR, EFD, "Max num rules must be higher than 0\n");
+		EFD_LOG(ERR, "Max num rules must be higher than 0");
 		return NULL;
 	}
 
@@ -554,7 +558,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te = rte_zmalloc("EFD_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, EFD, "tailq entry allocation failed\n");
+		EFD_LOG(ERR, "tailq entry allocation failed");
 		goto error_unlock_exit;
 	}
 
@@ -564,15 +568,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (table == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating EFD table management structure"
-				" on socket %u failed\n",
-				offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating EFD table management structureon socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 
 
-	RTE_LOG(DEBUG, EFD, "Allocated EFD table management structure "
-			"on socket %u\n", offline_cpu_socket);
+	EFD_LOG(DEBUG, "Allocated EFD table management structure on socket %u",
+		offline_cpu_socket);
 
 	table->max_num_rules = num_chunks * EFD_TARGET_CHUNK_MAX_NUM_RULES;
 	table->num_rules = 0;
@@ -586,17 +590,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (key_array == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating key array"
-				" on socket %u failed\n",
-				offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating key array on socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 	table->keys = key_array;
 	strlcpy(table->name, name, sizeof(table->name));
 
-	RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks,"
-			" which potentially supports %u entries\n",
-			num_chunks, table->max_num_rules);
+	EFD_LOG(DEBUG,
+		"Creating an EFD table with %u chunks, which potentially supports %u entries",
+		num_chunks, table->max_num_rules);
 
 	/* Make sure all the allocatable table pointers are NULL initially */
 	for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++)
@@ -623,19 +627,16 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 				RTE_CACHE_LINE_SIZE,
 				socket_id);
 			if (table->chunks[socket_id] == NULL) {
-				RTE_LOG(ERR, EFD,
-						"Allocating EFD online table on "
-						"socket %u failed\n",
-						socket_id);
+				EFD_LOG(ERR,
+					"Allocating EFD online table on socket %u failed",
+					socket_id);
 				goto error_unlock_exit;
 			}
-			RTE_LOG(DEBUG, EFD,
-					"Allocated EFD online table of size "
-					"%"PRIu64" bytes (%.2f MB) on socket %u\n",
-					online_table_size,
-					(float) online_table_size /
-						(1024.0F * 1024.0F),
-					socket_id);
+			EFD_LOG(DEBUG,
+				"Allocated EFD online table of size %" PRIu64 " bytes (%.2f MB) on socket %u",
+				online_table_size,
+				(float) online_table_size / (1024.0F * 1024.0F),
+				socket_id);
 		}
 	}
 
@@ -675,16 +676,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (table->offline_chunks == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating EFD offline table on socket %u "
-				"failed\n", offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating EFD offline table on socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 
-	RTE_LOG(DEBUG, EFD,
-			"Allocated EFD offline table of size %"PRIu64" bytes "
-			" (%.2f MB) on socket %u\n", offline_table_size,
-			(float) offline_table_size / (1024.0F * 1024.0F),
-			offline_cpu_socket);
+	EFD_LOG(DEBUG,
+		"Allocated EFD offline table of size %" PRIu64 " bytes  (%.2f MB) on socket %u",
+		offline_table_size,
+		(float) offline_table_size / (1024.0F * 1024.0F),
+		offline_cpu_socket);
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
@@ -695,7 +697,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules),
 			offline_cpu_socket, 0);
 	if (r == NULL) {
-		RTE_LOG(ERR, EFD, "memory allocation failed\n");
+		EFD_LOG(ERR, "ring memory allocation failed");
 		rte_efd_free(table);
 		return NULL;
 	}
@@ -1015,20 +1017,17 @@ efd_compute_update(struct rte_efd_table * const table,
 	if (found == 0) {
 		/* Key does not exist. Insert the rule into the bin/group */
 		if (unlikely(current_group->num_rules >= EFD_MAX_GROUP_NUM_RULES)) {
-			RTE_LOG(ERR, EFD,
-					"Fatal: No room remaining for insert into "
-					"chunk %u group %u bin %u\n",
-					*chunk_id,
-					current_group_id, *bin_id);
+			EFD_LOG(ERR,
+				"Fatal: No room remaining for insert into chunk %u group %u bin %u",
+				*chunk_id, current_group_id, *bin_id);
 			return RTE_EFD_UPDATE_FAILED;
 		}
 
 		if (unlikely(current_group->num_rules ==
 				(EFD_MAX_GROUP_NUM_RULES - 1))) {
-			RTE_LOG(INFO, EFD, "Warn: Insert into last "
-					"available slot in chunk %u "
-					"group %u bin %u\n", *chunk_id,
-					current_group_id, *bin_id);
+			EFD_LOG(NOTICE,
+			       "Insert into last available slot in chunk %u group %u bin %u",
+			       *chunk_id, current_group_id, *bin_id);
 			status = RTE_EFD_UPDATE_WARN_GROUP_FULL;
 		}
 
@@ -1112,14 +1111,11 @@ efd_compute_update(struct rte_efd_table * const table,
 	uint8_t choice = 0;
 	for (;;) {
 		if (current_group != new_group &&
-				new_group->num_rules + bin_size >
-					EFD_MAX_GROUP_NUM_RULES) {
-			RTE_LOG(DEBUG, EFD,
-					"Unable to move_groups to dest group "
-					"containing %u entries."
-					"bin_size:%u choice:%02x\n",
-					new_group->num_rules, bin_size,
-					choice - 1);
+		    new_group->num_rules + bin_size > EFD_MAX_GROUP_NUM_RULES) {
+			EFD_LOG(DEBUG,
+				"Unable to move_groups to dest group containing %u entries. bin_size:%u choice:%02x",
+				new_group->num_rules, bin_size,
+				choice - 1);
 			goto next_choice;
 		}
 		move_groups(*bin_id, bin_size, new_group, current_group);
@@ -1132,10 +1128,10 @@ efd_compute_update(struct rte_efd_table * const table,
 		if (!ret)
 			return status;
 
-		RTE_LOG(DEBUG, EFD,
-				"Failed to find perfect hash for group "
-				"containing %u entries. bin_size:%u choice:%02x\n",
-				new_group->num_rules, bin_size, choice - 1);
+		EFD_LOG(DEBUG,
+			"Failed to find perfect hash for group containing %u entries. bin_size:%u choice:%02x",
+			new_group->num_rules, bin_size, choice - 1);
+
 		/* Restore groups modified to their previous state */
 		revert_groups(current_group, new_group, bin_size);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 08/17] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 07/17] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 09/17] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mbuf/mbuf_log.h             | 10 ++++++++++
 lib/mbuf/rte_mbuf.c             | 20 ++++++++++++--------
 lib/mbuf/rte_mbuf_dyn.c         | 15 ++++++++-------
 lib/mbuf/rte_mbuf_pool_ops.c    |  5 +++--
 6 files changed, 34 insertions(+), 19 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 675f3d07bbe3..128bfabd94e1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a90fa629168d..1f259b2abc5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..fe97f338c9b7
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mbuf_logtype;
+
+#define MBUF_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, mbuf_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..133fd3ba55be 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,8 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
@@ -227,8 +229,8 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n,
 	int ret;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
-		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
-			priv_size);
+		MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned",
+			 priv_size);
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -247,7 +249,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n,
 		mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+		MBUF_LOG(ERR, "error setting mempool handler");
 		rte_mempool_free(mp);
 		rte_errno = -ret;
 		return NULL;
@@ -293,7 +295,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	int ret;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
-		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
+		MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned",
 			priv_size);
 		rte_errno = EINVAL;
 		return NULL;
@@ -303,12 +305,12 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 		const struct rte_pktmbuf_extmem *extm = ext_mem + i;
 
 		if (!extm->elt_size || !extm->buf_len || !extm->buf_ptr) {
-			RTE_LOG(ERR, MBUF, "invalid extmem descriptor\n");
+			MBUF_LOG(ERR, "invalid extmem descriptor");
 			rte_errno = EINVAL;
 			return NULL;
 		}
 		if (data_room_size > extm->elt_size) {
-			RTE_LOG(ERR, MBUF, "ext elt_size=%u is too small\n",
+			MBUF_LOG(ERR, "ext elt_size=%u is too small",
 				priv_size);
 			rte_errno = EINVAL;
 			return NULL;
@@ -317,7 +319,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	}
 	/* Check whether enough external memory provided. */
 	if (n_elts < n) {
-		RTE_LOG(ERR, MBUF, "not enough extmem\n");
+		MBUF_LOG(ERR, "not enough extmem");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -338,7 +340,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+		MBUF_LOG(ERR, "error setting mempool handler");
 		rte_mempool_free(mp);
 		rte_errno = -ret;
 		return NULL;
@@ -936,3 +938,5 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 
 	return 0;
 }
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..ef8d6069b37a 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
@@ -116,7 +118,7 @@ init_shared_mem(void)
 		mz = rte_memzone_lookup(RTE_MBUF_DYN_MZNAME);
 	}
 	if (mz == NULL) {
-		RTE_LOG(ERR, MBUF, "Failed to get mbuf dyn shared memory\n");
+		MBUF_LOG(ERR, "Failed to get mbuf dyn shared memory");
 		return -1;
 	}
 
@@ -315,7 +317,8 @@ __rte_mbuf_dynfield_register_offset(const struct rte_mbuf_dynfield *params,
 		shm->free_space[i] = 0;
 	process_score();
 
-	RTE_LOG(DEBUG, MBUF, "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd\n",
+	MBUF_LOG(DEBUG,
+		 "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd",
 		params->name, params->size, params->align, params->flags,
 		offset);
 
@@ -489,7 +492,7 @@ __rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params,
 
 	shm->free_flags &= ~(1ULL << bitnum);
 
-	RTE_LOG(DEBUG, MBUF, "Registered dynamic flag %s (fl=0x%x) -> %u\n",
+	MBUF_LOG(DEBUG, "Registered dynamic flag %s (fl=0x%x) -> %u",
 		params->name, params->flags, bitnum);
 
 	return bitnum;
@@ -590,8 +593,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag,
 
 	offset = rte_mbuf_dynfield_register(&field_desc);
 	if (offset < 0) {
-		RTE_LOG(ERR, MBUF,
-			"Failed to register mbuf field for timestamp\n");
+		MBUF_LOG(ERR, "Failed to register mbuf field for timestamp");
 		return -1;
 	}
 	if (field_offset != NULL)
@@ -600,8 +602,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag,
 	strlcpy(flag_desc.name, flag_name, sizeof(flag_desc.name));
 	offset = rte_mbuf_dynflag_register(&flag_desc);
 	if (offset < 0) {
-		RTE_LOG(ERR, MBUF,
-			"Failed to register mbuf flag for %s timestamp\n",
+		MBUF_LOG(ERR, "Failed to register mbuf flag for %s timestamp",
 			direction);
 		return -1;
 	}
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..8ec2710dc86d 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
@@ -31,8 +33,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 		return 0;
 	}
 
-	RTE_LOG(ERR, MBUF,
-		"%s is already registered as platform mbuf pool ops\n",
+	MBUF_LOG(ERR, "%s is already registered as platform mbuf pool ops",
 		(char *)mz->addr);
 	return -EEXIST;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 09/17] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 08/17] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 10/17] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
                     ` (7 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             |  3 ++-
 lib/acl/acl_bld.c               | 35 +++++++++++++++++----------------
 lib/acl/acl_gen.c               | 20 ++++++++++---------
 lib/acl/acl_log.h               | 13 ++++++++++++
 lib/acl/rte_acl.c               | 14 ++++++++-----
 lib/acl/tb_mem.c                |  8 ++++++--
 lib/eal/common/eal_common_log.c |  2 --
 lib/eal/include/rte_log.h       |  4 ++--
 8 files changed, 61 insertions(+), 38 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..143564151e29 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
@@ -1014,8 +1015,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
 				break;
 
 			default:
-				RTE_LOG(ERR, ACL,
-					"Error in rule[%u] type - %hhu\n",
+				ACL_LOG(ERR,
+					"Error in rule[%u] type - %hhu",
 					rule->f->data.userdata,
 					rule->config->defs[n].type);
 				return NULL;
@@ -1371,7 +1372,7 @@ acl_build_tries(struct acl_build_context *context,
 
 		last = build_one_trie(context, rule_sets, n, context->node_max);
 		if (context->bld_tries[n].trie == NULL) {
-			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
+			ACL_LOG(ERR, "Build of %u-th trie failed", n);
 			return -ENOMEM;
 		}
 
@@ -1380,8 +1381,7 @@ acl_build_tries(struct acl_build_context *context,
 			break;
 
 		if (num_tries == RTE_DIM(context->tries)) {
-			RTE_LOG(ERR, ACL,
-				"Exceeded max number of tries: %u\n",
+			ACL_LOG(ERR, "Exceeded max number of tries: %u",
 				num_tries);
 			return -ENOMEM;
 		}
@@ -1406,7 +1406,7 @@ acl_build_tries(struct acl_build_context *context,
 		 */
 		last = build_one_trie(context, rule_sets, n, INT32_MAX);
 		if (context->bld_tries[n].trie == NULL || last != NULL) {
-			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
+			ACL_LOG(ERR, "Build of %u-th trie failed", n);
 			return -ENOMEM;
 		}
 
@@ -1421,10 +1421,11 @@ acl_build_log(const struct acl_build_context *ctx)
 {
 	uint32_t n;
 
-	RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n"
+	ACL_LOG(DEBUG,
+		"Build phase for ACL \"%s\":\n"
 		"node limit for tree split: %u\n"
 		"nodes created: %u\n"
-		"memory consumed: %zu\n",
+		"memory consumed: %zu",
 		ctx->acx->name,
 		ctx->node_max,
 		ctx->num_nodes,
@@ -1432,7 +1433,7 @@ acl_build_log(const struct acl_build_context *ctx)
 
 	for (n = 0; n < RTE_DIM(ctx->tries); n++) {
 		if (ctx->tries[n].count != 0)
-			RTE_LOG(DEBUG, ACL,
+			ACL_LOG(DEBUG,
 				"trie %u: number of rules: %u, indexes: %u\n",
 				n, ctx->tries[n].count,
 				ctx->tries[n].num_data_indexes);
@@ -1523,8 +1524,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
 
 	/* build phase runs out of memory. */
 	if (rc != 0) {
-		RTE_LOG(ERR, ACL,
-			"ACL context: %s, %s() failed with error code: %d\n",
+		ACL_LOG(ERR,
+			"ACL context: %s, %s() failed with error code: %d",
 			bcx->acx->name, __func__, rc);
 		return rc;
 	}
@@ -1565,9 +1566,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 
 	for (i = 0; i != cfg->num_fields; i++) {
 		if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) {
-			RTE_LOG(ERR, ACL,
-			"ACL context: %s, invalid type: %hhu for %u-th field\n",
-			ctx->name, cfg->defs[i].type, i);
+			ACL_LOG(ERR,
+				"ACL context: %s, invalid type: %hhu for %u-th field",
+				ctx->name, cfg->defs[i].type, i);
 			return -EINVAL;
 		}
 		for (j = 0;
@@ -1577,9 +1578,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 			;
 
 		if (j == RTE_DIM(field_sizes)) {
-			RTE_LOG(ERR, ACL,
-			"ACL context: %s, invalid size: %hhu for %u-th field\n",
-			ctx->name, cfg->defs[i].size, i);
+			ACL_LOG(ERR,
+				"ACL context: %s, invalid size: %hhu for %u-th field\n",
+				ctx->name, cfg->defs[i].size, i);
 			return -EINVAL;
 		}
 	}
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..84369b103947 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
@@ -32,18 +33,19 @@ struct rte_acl_indices {
 
 static void
 acl_gen_log_stats(const struct rte_acl_ctx *ctx,
-	const struct acl_node_counters *counts,
-	const struct rte_acl_indices *indices,
-	size_t max_size)
+		  const struct acl_node_counters *counts,
+		  const struct rte_acl_indices *indices,
+		  size_t max_size)
 {
-	RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n"
+	ACL_LOG(DEBUG,
+		"Gen phase for ACL \"%s\":\n"
 		"runtime memory footprint on socket %d:\n"
 		"single nodes/bytes used: %d/%zu\n"
 		"quad nodes/vectors/bytes used: %d/%d/%zu\n"
 		"DFA nodes/group64/bytes used: %d/%d/%zu\n"
 		"match nodes/bytes used: %d/%zu\n"
 		"total: %zu bytes\n"
-		"max limit: %zu bytes\n",
+		"max limit: %zu bytes",
 		ctx->name, ctx->socket_id,
 		counts->single, counts->single * sizeof(uint64_t),
 		counts->quad, counts->quad_vectors,
@@ -470,9 +472,9 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
 		XMM_SIZE;
 
 	if (total_size > max_size) {
-		RTE_LOG(DEBUG, ACL,
+		ACL_LOG(DEBUG,
 			"Gen phase for ACL ctx \"%s\" exceeds max_size limit, "
-			"bytes required: %zu, allowed: %zu\n",
+			"bytes required: %zu, allowed: %zu",
 			ctx->name, total_size, max_size);
 		return -ERANGE;
 	}
@@ -480,8 +482,8 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
 	mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE,
 			ctx->socket_id);
 	if (mem == NULL) {
-		RTE_LOG(ERR, ACL,
-			"allocation of %zu bytes on socket %d for %s failed\n",
+		ACL_LOG(ERR,
+			"allocation of %zu bytes on socket %d for %s failed",
 			total_size, ctx->socket_id, ctx->name);
 		return -ENOMEM;
 	}
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..4d5adf965cd2
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#ifndef	_ACL_LOG_H_
+#define	_ACL_LOG_H_
+
+extern int acl_logtype;
+#define ACL_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, acl_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+#endif /* _ACL_LOG_H_ */
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..5c8a9cd2f693 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,10 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
@@ -400,15 +402,15 @@ rte_acl_create(const struct rte_acl_param *param)
 		te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
 
 		if (te == NULL) {
-			RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
+			ACL_LOG(ERR, "Cannot allocate tailq entry!");
 			goto exit;
 		}
 
 		ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id);
 
 		if (ctx == NULL) {
-			RTE_LOG(ERR, ACL,
-				"allocation of %zu bytes on socket %d for %s failed\n",
+			ACL_LOG(ERR,
+				"allocation of %zu bytes on socket %d for %s failed",
 				sz, param->socket_id, name);
 			rte_free(te);
 			goto exit;
@@ -474,8 +476,8 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules,
 			((uintptr_t)rules + i * ctx->rule_sz);
 		rc = acl_check_rule(&rv->data);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n",
-				__func__, ctx->name, i + 1);
+			ACL_LOG(ERR, "%s: rule #%u is invalid",
+				ctx->name, i + 1);
 			return rc;
 		}
 	}
@@ -544,3 +546,5 @@ rte_acl_list_dump(void)
 	}
 	rte_mcfg_tailq_read_unlock();
 }
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..74a12159b868 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,9 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
+
+#include <rte_log.h>
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,8 +28,9 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
-			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
+		ACL_LOG(ERR,
+			"allocation size %zu failed, currently allocated by pool: %zu bytes\n",
+			sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
 	}
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 128bfabd94e1..871f2c38298c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1f259b2abc5a..d707098b6359 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 10/17] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 09/17] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 11/17] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c    |   1 -
 lib/eal/include/rte_log.h          |   2 +-
 lib/power/guest_channel.c          |  48 +++++----
 lib/power/power_acpi_cpufreq.c     | 118 ++++++++++----------
 lib/power/power_common.c           |  11 +-
 lib/power/power_common.h           |   7 +-
 lib/power/power_cppc_cpufreq.c     | 129 +++++++++++-----------
 lib/power/power_kvm_vm.c           |  24 +++--
 lib/power/power_pstate_cpufreq.c   | 166 ++++++++++++++++-------------
 lib/power/rte_power.c              |  25 +++--
 lib/power/rte_power_empty_poll.c   |  36 +++----
 lib/power/rte_power_intel_uncore.c |  75 ++++++-------
 lib/power/rte_power_pmd_mgmt.c     |  37 ++++---
 13 files changed, 365 insertions(+), 314 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 871f2c38298c..7dbf1df3b979 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index d707098b6359..5b7850af4e2b 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..0e836fc3f578 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,11 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, "power.guest", INFO);
+
+#define GUEST_LOG(level, fmt, args...)				\
+	rte_log(RTE_LOG_ ## level, guest_channel_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
@@ -58,38 +62,38 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
 	int fd = -1;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 	/* check if path is already open */
 	if (global_fds[lcore_id] != -1) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is already open with fd %d\n",
+		GUEST_LOG(ERR, "Channel(%u) is already open with fd %d",
 				lcore_id, global_fds[lcore_id]);
 		return -1;
 	}
 
 	snprintf(fd_path, PATH_MAX, "%s.%u", path, lcore_id);
-	RTE_LOG(INFO, GUEST_CHANNEL, "Opening channel '%s' for lcore %u\n",
+	GUEST_LOG(INFO, "Opening channel '%s' for lcore %u",
 			fd_path, lcore_id);
 	fd = open(fd_path, O_RDWR);
 	if (fd < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Unable to to connect to '%s' with error "
-				"%s\n", fd_path, strerror(errno));
+		GUEST_LOG(ERR, "Unable to connect to '%s' with error %s",
+			  fd_path, strerror(errno));
 		return -1;
 	}
 
 	flags = fcntl(fd, F_GETFL, 0);
 	if (flags < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Failed on fcntl get flags for file %s\n",
+		GUEST_LOG(ERR, "Failed on fcntl get flags for file %s",
 				fd_path);
 		goto error;
 	}
 
 	flags |= O_NONBLOCK;
 	if (fcntl(fd, F_SETFL, flags) < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Failed on setting non-blocking mode for "
-				"file %s", fd_path);
+		GUEST_LOG(ERR, "Failed on setting non-blocking mode for file %s",
+			  fd_path);
 		goto error;
 	}
 	/* QEMU needs a delay after connection */
@@ -102,13 +106,13 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
 	global_fds[lcore_id] = fd;
 	ret = guest_channel_send_msg(&pkt, lcore_id);
 	if (ret != 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL,
-				"Error on channel '%s' communications test: %s\n",
-				fd_path, ret > 0 ? strerror(ret) :
-				"channel not connected");
+		GUEST_LOG(ERR,
+			  "Error on channel '%s' communications test: %s",
+			  fd_path, ret > 0 ? strerror(ret) :
+			  "channel not connected");
 		goto error;
 	}
-	RTE_LOG(INFO, GUEST_CHANNEL, "Channel '%s' is now connected\n", fd_path);
+	GUEST_LOG(INFO, "Channel '%s' is now connected", fd_path);
 	return 0;
 error:
 	close(fd);
@@ -124,13 +128,13 @@ guest_channel_send_msg(struct rte_power_channel_packet *pkt,
 	void *buffer = pkt;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 
 	if (global_fds[lcore_id] < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
+		GUEST_LOG(ERR, "Channel is not connected");
 		return -1;
 	}
 	while (buffer_len > 0) {
@@ -165,13 +169,13 @@ int power_guest_channel_read_msg(void *pkt,
 		return -1;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 
 	if (global_fds[lcore_id] < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
+		GUEST_LOG(ERR, "Channel is not connected");
 		return -1;
 	}
 
@@ -180,10 +184,10 @@ int power_guest_channel_read_msg(void *pkt,
 
 	ret = poll(&fds, 1, TIMEOUT);
 	if (ret == 0) {
-		RTE_LOG(DEBUG, GUEST_CHANNEL, "Timeout occurred during poll function.\n");
+		GUEST_LOG(DEBUG, "Timeout occurred during poll function.");
 		return -1;
 	} else if (ret < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n",
+		GUEST_LOG(ERR, "Error occurred during poll function: %s",
 				strerror(errno));
 		return -1;
 	}
@@ -199,7 +203,7 @@ int power_guest_channel_read_msg(void *pkt,
 		}
 
 		if (ret == 0) {
-			RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n");
+			GUEST_LOG(ERR, "Expected more data, but connection has been closed.");
 			return -1;
 		}
 		pkt = (char *)pkt + ret;
@@ -220,7 +224,7 @@ void
 guest_channel_host_disconnect(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return;
 	}
diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c
index 6e57aca53513..3643044d9ef0 100644
--- a/lib/power/power_acpi_cpufreq.c
+++ b/lib/power/power_acpi_cpufreq.c
@@ -62,8 +62,9 @@ static int
 set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
 {
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -74,13 +75,15 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
 	POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n",
 			idx, pi->freqs[idx], pi->lcore_id);
 	if (fseek(pi->f, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-				"lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to write new frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	fflush(pi->f);
@@ -126,14 +129,14 @@ power_get_available_freqs(struct acpi_power_info *pi)
 
 	open_core_sysfs_file(&f, "r", POWER_SYSFILE_AVAIL_FREQ, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_AVAIL_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if ((ret) < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_AVAIL_FREQ);
 		goto out;
 	}
@@ -142,12 +145,13 @@ power_get_available_freqs(struct acpi_power_info *pi)
 	count = rte_strsplit(buf, sizeof(buf), freqs,
 			RTE_MAX_LCORE_FREQS, ' ');
 	if (count <= 0) {
-		RTE_LOG(ERR, POWER, "No available frequency in "
-				""POWER_SYSFILE_AVAIL_FREQ"\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "No available frequency in " POWER_SYSFILE_AVAIL_FREQ,
+			  pi->lcore_id);
 		goto out;
 	}
 	if (count >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n",
+		POWER_LOG(ERR, "Too many available frequencies : %d",
 				count);
 		goto out;
 	}
@@ -195,14 +199,14 @@ power_init_for_setting_freq(struct acpi_power_info *pi)
 
 	open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "Failed to open %s\n",
+		POWER_LOG(ERR, "Failed to open %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if ((ret) < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
@@ -236,7 +240,7 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -252,42 +256,47 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_userspace(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"userspace\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set governor of lcore %u to userspace",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -309,7 +318,7 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -324,8 +333,8 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used", lcore_id);
 		return -1;
 	}
 
@@ -335,14 +344,15 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'userspace' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'userspace' mode and been set back to the original",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -363,18 +373,18 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -386,7 +396,7 @@ uint32_t
 power_acpi_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -397,7 +407,7 @@ int
 power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -410,7 +420,7 @@ power_acpi_cpufreq_freq_down(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -428,7 +438,7 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -445,7 +455,7 @@ int
 power_acpi_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -469,7 +479,7 @@ power_acpi_cpufreq_freq_min(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -486,7 +496,7 @@ power_acpi_turbo_status(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -502,7 +512,7 @@ power_acpi_enable_turbo(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -512,16 +522,16 @@ power_acpi_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
+		POWER_LOG(ERR,
+			"Failed to enable turbo on lcore %u",
 			lcore_id);
 			return -1;
 	}
 
 	/* Max may have changed, so call to max function */
 	if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER,
-			"Failed to set frequency of lcore %u to max\n",
+		POWER_LOG(ERR,
+			"Failed to set frequency of lcore %u to max",
 			lcore_id);
 			return -1;
 	}
@@ -535,7 +545,7 @@ power_acpi_disable_turbo(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -546,8 +556,8 @@ power_acpi_disable_turbo(unsigned int lcore_id)
 	if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -562,11 +572,11 @@ int power_acpi_get_capabilities(unsigned int lcore_id,
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..3a374f6b8431 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -161,14 +161,14 @@ power_set_governor(unsigned int lcore_id, const char *new_governor,
 	open_core_sysfs_file(&f_governor, "rw+", POWER_SYSFILE_GOVERNOR,
 			lcore_id);
 	if (f_governor == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
 
 	ret = read_core_sysfs_s(f_governor, buf, sizeof(buf));
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
@@ -188,14 +188,15 @@ power_set_governor(unsigned int lcore_id, const char *new_governor,
 	/* Write the new governor */
 	ret = write_core_sysfs_s(f_governor, new_governor);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to write %s\n",
+		POWER_LOG(ERR, "Failed to write %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
 
 	ret = 0;
-	RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been "
-			"set to '%s' successfully\n", lcore_id, new_governor);
+	POWER_LOG(INFO,
+		  "Power management governor of lcore %u has been set to '%s' successfully",
+		  lcore_id, new_governor);
 out:
 	if (f_governor != NULL)
 		fclose(f_governor);
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..8e5309bbbaff 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -10,10 +10,15 @@
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+
+#define POWER_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, power_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
-		RTE_LOG(ERR, POWER, "%s: " fmt, __func__, ## args)
+	POWER_LOG(ERR, fmt, ## args)
 #else
 #define POWER_DEBUG_TRACE(fmt, args...)
 #endif
diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c
index fc9cffef91a8..7ffda90ce7a7 100644
--- a/lib/power/power_cppc_cpufreq.c
+++ b/lib/power/power_cppc_cpufreq.c
@@ -72,8 +72,9 @@ static int
 set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
 {
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -84,13 +85,15 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
 	POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n",
 			idx, pi->freqs[idx], pi->lcore_id);
 	if (fseek(pi->f, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-			"for setting frequency for lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-				"lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to write new frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	fflush(pi->f);
@@ -121,7 +124,7 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_HIGHEST_PERF,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_HIGHEST_PERF);
 		goto err;
 	}
@@ -129,7 +132,7 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_nom, "r", POWER_SYSFILE_NOMINAL_PERF,
 			pi->lcore_id);
 	if (f_nom == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_NOMINAL_PERF);
 		goto err;
 	}
@@ -137,28 +140,28 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_cmax, "r", POWER_SYSFILE_SYS_MAX,
 			pi->lcore_id);
 	if (f_cmax == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SYS_MAX);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_max, &highest_perf);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_HIGHEST_PERF);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_nom, &nominal_perf);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_NOMINAL_PERF);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_cmax, &cpuinfo_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SYS_MAX);
 		goto err;
 	}
@@ -208,7 +211,7 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_SCALING_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SCALING_MAX_FREQ);
 		goto out;
 	}
@@ -216,21 +219,21 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_SCALING_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SCALING_MIN_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_max, &scaling_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SCALING_MAX_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_min, &scaling_min_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SCALING_MIN_FREQ);
 		goto out;
 	}
@@ -248,7 +251,7 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 +
 		pi->turbo_available;
 	if (num_freqs >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available frequencies: %d",
 				num_freqs);
 		goto out;
 	}
@@ -289,14 +292,14 @@ power_init_for_setting_freq(struct cppc_power_info *pi)
 
 	open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
@@ -340,7 +343,7 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -356,42 +359,46 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_userspace(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"userspace\n", lcore_id);
+		POWER_LOG(ERR, "Cannot set governor of lcore %u to userspace",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 
 	__atomic_store_n(&(pi->state), POWER_USED, __ATOMIC_RELEASE);
 
@@ -419,7 +426,7 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -434,8 +441,9 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used",
+			  lcore_id);
 		return -1;
 	}
 
@@ -445,14 +453,15 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'userspace' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'userspace' mode and been set back to the original",
+		  lcore_id);
 	__atomic_store_n(&(pi->state), POWER_IDLE, __ATOMIC_RELEASE);
 
 	return 0;
@@ -469,18 +478,18 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -492,7 +501,7 @@ uint32_t
 power_cppc_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -503,7 +512,7 @@ int
 power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -516,7 +525,7 @@ power_cppc_cpufreq_freq_down(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -534,7 +543,7 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -551,7 +560,7 @@ int
 power_cppc_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -575,7 +584,7 @@ power_cppc_cpufreq_freq_min(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -591,7 +600,7 @@ power_cppc_turbo_status(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -606,7 +615,7 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -616,8 +625,8 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
+		POWER_LOG(ERR,
+			"Failed to enable turbo on lcore %u",
 			lcore_id);
 		return -1;
 	}
@@ -627,8 +636,8 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 	 */
 	/* Max may have changed, so call to max function */
 	if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER,
-			"Failed to set frequency of lcore %u to max\n",
+		POWER_LOG(ERR,
+			"Failed to set frequency of lcore %u to max",
 			lcore_id);
 		return -1;
 	}
@@ -642,7 +651,7 @@ power_cppc_disable_turbo(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -653,8 +662,8 @@ power_cppc_disable_turbo(unsigned int lcore_id)
 	if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -670,11 +679,11 @@ power_cppc_get_capabilities(unsigned int lcore_id,
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..74a1094ffaa0 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -24,7 +25,7 @@ int
 power_kvm_vm_init(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+		POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
@@ -45,16 +46,16 @@ power_kvm_vm_freqs(__rte_unused unsigned int lcore_id,
 		__rte_unused uint32_t *freqs,
 		__rte_unused uint32_t num)
 {
-	RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
 uint32_t
 power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id)
 {
-	RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -62,8 +63,8 @@ int
 power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id,
 		__rte_unused uint32_t index)
 {
-	RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -73,7 +74,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 	int ret;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+		POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
@@ -81,7 +82,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 	ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
 	if (ret == 0)
 		return 1;
-	RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
+	POWER_LOG(DEBUG, "Error sending message: %s",
 			ret > 0 ? strerror(ret) : "channel not connected");
 	return -1;
 }
@@ -113,7 +114,7 @@ power_kvm_vm_freq_min(unsigned int lcore_id)
 int
 power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id)
 {
-	RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
+	POWER_LOG(ERR, "rte_power_turbo_status is not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -133,6 +134,7 @@ struct rte_power_core_capabilities;
 int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,
 		__rte_unused struct rte_power_core_capabilities *caps)
 {
-	RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "rte_power_get_capabilities is not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index 52aa64510e21..c6869bbd3c59 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -81,7 +81,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	fd = open(POWER_SYSFILE_TURBO_PCT, O_RDONLY);
 
 	if (fd < 0) {
-		RTE_LOG(ERR, POWER, "Error opening '%s': %s\n", POWER_SYSFILE_TURBO_PCT,
+		POWER_LOG(ERR, "Error opening '%s': %s", POWER_SYSFILE_TURBO_PCT,
 				 strerror(errno));
 		return fd;
 	}
@@ -89,7 +89,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	ret = read(fd, val, sizeof(val));
 
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Error reading '%s': %s\n", POWER_SYSFILE_TURBO_PCT,
+		POWER_LOG(ERR, "Error reading '%s': %s", POWER_SYSFILE_TURBO_PCT,
 				 strerror(errno));
 		goto out;
 	}
@@ -97,7 +97,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	errno = 0;
 	*outVal = (uint64_t) strtol(val, &endptr, 10);
 	if (errno != 0 || (*endptr != 0 && *endptr != '\n')) {
-		RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n",
+		POWER_LOG(ERR, "Error converting str to digits, read from %s: %s",
 				 POWER_SYSFILE_TURBO_PCT, strerror(errno));
 		ret = -1;
 		goto out;
@@ -125,7 +125,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_base_max, "r", POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_base_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -133,7 +133,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_base_min, "r", POWER_SYSFILE_BASE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_base_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
@@ -141,7 +141,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_min, "rw+", POWER_SYSFILE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_MIN_FREQ);
 		goto err;
 	}
@@ -149,7 +149,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_max, "rw+", POWER_SYSFILE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_MAX_FREQ);
 		goto err;
 	}
@@ -161,7 +161,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	/* read base max ratio */
 	ret = read_core_sysfs_u32(f_base_max, &base_max_ratio);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -169,7 +169,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	/* read base min ratio */
 	ret = read_core_sysfs_u32(f_base_min, &base_min_ratio);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
@@ -178,7 +178,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	if (f_base != NULL) {
 		ret = read_core_sysfs_u32(f_base, &base_ratio);
 		if (ret < 0) {
-			RTE_LOG(ERR, POWER, "Failed to read %s\n",
+			POWER_LOG(ERR, "Failed to read %s",
 					POWER_SYSFILE_BASE_FREQ);
 			goto err;
 		}
@@ -256,8 +256,9 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	uint32_t target_freq = 0;
 
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -269,16 +270,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	 * User need change the min/max as same value.
 	 */
 	if (fseek(pi->f_cur_min, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n",
-				pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 
 	if (fseek(pi->f_cur_max, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n",
-				pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 
@@ -287,7 +288,8 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 		if (pi->turbo_enable)
 			target_freq = pi->sys_max_freq;
 		else {
-			RTE_LOG(ERR, POWER, "Turbo is off, frequency can't be scaled up more %u\n",
+			POWER_LOG(ERR,
+				  "Turbo is off, frequency can't be scaled up more %u",
 					pi->lcore_id);
 			return -1;
 		}
@@ -298,14 +300,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	if (idx  >  pi->curr_idx) {
 
 		if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
 		if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
@@ -321,14 +325,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	if (idx  <  pi->curr_idx) {
 
 		if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
 		if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
@@ -383,7 +389,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto out;
 	}
@@ -391,7 +397,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_BASE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto out;
 	}
@@ -399,14 +405,14 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	/* read base ratios */
 	ret = read_core_sysfs_u32(f_max, &sys_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_min, &sys_min_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto out;
 	}
@@ -449,7 +455,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	num_freqs = (RTE_MIN(base_max_freq, sys_max_freq) - sys_min_freq) / BUS_FREQ
 			+ 1 + pi->turbo_available;
 	if (num_freqs >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available frequencies: %d",
 				num_freqs);
 		goto out;
 	}
@@ -493,14 +499,14 @@ power_get_cur_idx(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_cur, "r", POWER_SYSFILE_CUR_FREQ,
 			pi->lcore_id);
 	if (f_cur == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_CUR_FREQ);
 		goto fail;
 	}
 
 	ret = read_core_sysfs_u32(f_cur, &sys_cur_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_CUR_FREQ);
 		goto fail;
 	}
@@ -542,7 +548,7 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceed %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceed %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -558,47 +564,52 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_performance(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"performance\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set governor of lcore %u to performance",
+			  lcore_id);
 		goto fail;
 	}
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	if (power_get_cur_idx(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get current frequency "
-				"index of lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get current frequency index of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_pstate_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max", lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -620,7 +631,7 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -636,8 +647,8 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used", lcore_id);
 		return -1;
 	}
 
@@ -649,14 +660,15 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'performance' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'performance' mode and been set back to the original",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -678,18 +690,18 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -701,7 +713,7 @@ uint32_t
 power_pstate_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -713,7 +725,7 @@ int
 power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -726,7 +738,7 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -745,7 +757,7 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -761,7 +773,7 @@ int
 power_pstate_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -786,7 +798,7 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -803,7 +815,7 @@ power_pstate_turbo_status(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -818,7 +830,7 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -828,10 +840,10 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
-			lcore_id);
-			return -1;
+		POWER_LOG(ERR,
+			  "Failed to enable turbo on lcore %u",
+			  lcore_id);
+		return -1;
 	}
 
 	return 0;
@@ -844,7 +856,7 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -855,8 +867,8 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 	if (pi->turbo_available && pi->curr_idx <= 1) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_pstate_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -872,11 +884,11 @@ int power_pstate_get_capabilities(unsigned int lcore_id,
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..23a97fa77f53 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
@@ -70,7 +71,7 @@ rte_power_set_env(enum power_management_env env)
 	rte_spinlock_lock(&global_env_cfg_lock);
 
 	if (global_default_env != PM_ENV_NOT_SET) {
-		RTE_LOG(ERR, POWER, "Power Management Environment already set.\n");
+		POWER_LOG(ERR, "Power Management Environment already set.");
 		rte_spinlock_unlock(&global_env_cfg_lock);
 		return -1;
 	}
@@ -127,7 +128,7 @@ rte_power_set_env(enum power_management_env env)
 		rte_power_freq_disable_turbo = power_cppc_disable_turbo;
 		rte_power_get_capabilities = power_cppc_get_capabilities;
 	} else {
-		RTE_LOG(ERR, POWER, "Invalid Power Management Environment(%d) set\n",
+		POWER_LOG(ERR, "Invalid Power Management Environment(%d) set",
 				env);
 		ret = -1;
 	}
@@ -172,39 +173,40 @@ rte_power_init(unsigned int lcore_id)
 	case PM_ENV_CPPC_CPUFREQ:
 		return power_cppc_cpufreq_init(lcore_id);
 	default:
-		RTE_LOG(INFO, POWER, "Env isn't set yet!\n");
+		POWER_LOG(INFO, "Env isn't set yet!");
 	}
 
 	/* Auto detect Environment */
-	RTE_LOG(INFO, POWER, "Attempting to initialise ACPI cpufreq power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management...");
 	ret = power_acpi_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise PSTAT power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise PSTAT power management...");
 	ret = power_pstate_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_PSTATE_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise CPPC power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise CPPC power management...");
 	ret = power_cppc_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_CPPC_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise VM power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise VM power management...");
 	ret = power_kvm_vm_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_KVM_VM);
 		goto out;
 	}
-	RTE_LOG(ERR, POWER, "Unable to set Power Management Environment for lcore "
-			"%u\n", lcore_id);
+	POWER_LOG(ERR,
+		  "Unable to set Power Management Environment for lcore %u",
+		  lcore_id);
 out:
 	return ret;
 }
@@ -222,9 +224,12 @@ rte_power_exit(unsigned int lcore_id)
 	case PM_ENV_CPPC_CPUFREQ:
 		return power_cppc_cpufreq_exit(lcore_id);
 	default:
-		RTE_LOG(ERR, POWER, "Environment has not been set, unable to exit gracefully\n");
+		POWER_LOG(ERR,
+			  "Environment has not been set, unable to exit gracefully");
 
 	}
 	return -1;
 
 }
+
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..da4b1ec3068a 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
@@ -75,7 +76,7 @@ enter_normal_state(struct priority_worker *poll_stats)
 	poll_stats->iter_counter = 0;
 	poll_stats->threshold_ctr = 0;
 	poll_stats->queue_state = MED_NORMAL;
-	RTE_LOG(INFO, POWER, "Set the power freq to MED\n");
+	POWER_LOG(INFO, "Set the power freq to MED");
 	set_power_freq(poll_stats->lcore_id, MED, false);
 
 	poll_stats->thresh[MED].threshold_percent = med_to_high_threshold;
@@ -213,11 +214,9 @@ update_stats(struct priority_worker *poll_stats)
 	if (s->thresh[s->cur_freq].base_edpi < cur_edpi) {
 
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "cur_edpi is too large "
-				"cur edpi %"PRId64" "
-				"base edpi %"PRId64"\n",
-				cur_edpi,
-				s->thresh[s->cur_freq].base_edpi);
+		POWER_LOG(DEBUG,
+			  "cur_edpi is too large cur edpi %"PRId64" base edpi %"PRId64,
+			  cur_edpi, s->thresh[s->cur_freq].base_edpi);
 		/* Value to make us fail need debug log*/
 		return 1000UL;
 	}
@@ -247,7 +246,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 		enum freq_val cur_freq = poll_stats->cur_freq;
 
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "cure freq is %d, edpi is %"PRIu64"\n",
+		POWER_LOG(DEBUG, "cure freq is %d, edpi is %"PRIu64"",
 				cur_freq,
 				poll_stats->thresh[cur_freq].base_edpi);
 		return;
@@ -257,12 +256,12 @@ update_stats_normal(struct priority_worker *poll_stats)
 
 	if (percent > 100) {
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "Edpi is bigger than threshold\n");
+		POWER_LOG(DEBUG, "Edpi is bigger than threshold");
 		return;
 	}
 
 	if (poll_stats->cur_freq == LOW)
-		RTE_LOG(INFO, POWER, "Purge Mode is not currently supported\n");
+		POWER_LOG(INFO, "Purge Mode is not currently supported");
 	else if (poll_stats->cur_freq == MED) {
 
 		if (percent >
@@ -272,7 +271,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 				poll_stats->threshold_ctr++;
 			else {
 				set_state(poll_stats, HGH_BUSY);
-				RTE_LOG(INFO, POWER, "MOVE to HGH\n");
+				POWER_LOG(INFO, "MOVE to HGH");
 			}
 
 		} else {
@@ -289,7 +288,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 				poll_stats->threshold_ctr++;
 			else {
 				set_state(poll_stats, MED_NORMAL);
-				RTE_LOG(INFO, POWER, "MOVE to MED\n");
+				POWER_LOG(INFO, "MOVE to MED");
 			}
 		} else {
 			/* reset */
@@ -332,17 +331,17 @@ empty_poll_training(struct priority_worker *poll_stats,
 
 		set_state(poll_stats, MED_NORMAL);
 
-		RTE_LOG(INFO, POWER, "LOW threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "LOW threshold is %"PRIu64"",
 				poll_stats->thresh[LOW].base_edpi);
 
-		RTE_LOG(INFO, POWER, "MED threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "MED threshold is %"PRIu64"",
 				poll_stats->thresh[MED].base_edpi);
 
 
-		RTE_LOG(INFO, POWER, "HIGH threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "HIGH threshold is %"PRIu64"",
 				poll_stats->thresh[HGH].base_edpi);
 
-		RTE_LOG(INFO, POWER, "Training is Complete for %d\n",
+		POWER_LOG(INFO, "Training is Complete for %d",
 				poll_stats->lcore_id);
 	}
 
@@ -414,7 +413,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 		freq_index[HGH] = freq_tlb[HGH];
 	}
 
-	RTE_LOG(INFO, POWER, "Initialize the Empty Poll\n");
+	POWER_LOG(INFO, "Initialize the Empty Poll");
 
 	/* Train for pre-defined period */
 	ep_params->max_train_iter = INTERVALS_PER_SECOND * SECONDS_TO_TRAIN_FOR;
@@ -433,7 +432,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 				avail_freqs[i],
 				NUM_FREQS);
 
-		RTE_LOG(INFO, POWER, "total avail freq is %d , lcoreid %d\n",
+		POWER_LOG(INFO, "total avail freq is %d , lcoreid %d",
 				total_avail_freqs[i],
 				i);
 
@@ -452,8 +451,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 void
 rte_power_empty_poll_stat_free(void)
 {
-
-	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
+	POWER_LOG(INFO, "Close the Empty Poll");
 
 	rte_free(ep_params);
 }
diff --git a/lib/power/rte_power_intel_uncore.c b/lib/power/rte_power_intel_uncore.c
index 3b8724385fb7..ee6412a3ed34 100644
--- a/lib/power/rte_power_intel_uncore.c
+++ b/lib/power/rte_power_intel_uncore.c
@@ -52,8 +52,9 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 	int ret;
 
 	if (idx >= MAX_UNCORE_FREQS || idx >= ui->nb_freqs) {
-		RTE_LOG(DEBUG, POWER, "Invalid uncore frequency index %u, which "
-				"should be less than %u\n", idx, ui->nb_freqs);
+		POWER_LOG(DEBUG,
+			  "Invalid uncore frequency index %u, which should be less than %u",
+			  idx, ui->nb_freqs);
 		return -1;
 	}
 
@@ -65,13 +66,13 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 	open_core_sysfs_file(&ui->f_cur_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (ui->f_cur_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		return -1;
 	}
 	ret = read_core_sysfs_u32(ui->f_cur_max, &curr_max_freq);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+		POWER_LOG(DEBUG, "Failed to read %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		fclose(ui->f_cur_max);
 		return -1;
@@ -79,14 +80,16 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 
 	/* check this value first before fprintf value to f_cur_max, so value isn't overwritten */
 	if (fprintf(ui->f_cur_min, "%u", target_uncore_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write new uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
 	if (fprintf(ui->f_cur_max, "%u", target_uncore_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write new uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
@@ -121,13 +124,13 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_base_max, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (f_base_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
 	ret = read_core_sysfs_u32(f_base_max, &base_max_freq);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+		POWER_LOG(DEBUG, "Failed to read %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -136,14 +139,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_base_min, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ,
 		ui->pkg, ui->die);
 	if (f_base_min == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
 	if (f_base_min != NULL) {
 		ret = read_core_sysfs_u32(f_base_min, &base_min_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ);
 			goto err;
 		}
@@ -153,14 +156,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_min, "rw+", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ,
 			ui->pkg, ui->die);
 	if (f_min == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ);
 		goto err;
 	}
 	if (f_min != NULL) {
 		ret = read_core_sysfs_u32(f_min, &min_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ);
 			goto err;
 		}
@@ -170,14 +173,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (f_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		goto err;
 	}
 	if (f_max != NULL) {
 		ret = read_core_sysfs_u32(f_max, &max_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 			goto err;
 		}
@@ -222,7 +225,7 @@ power_get_available_uncore_freqs(struct uncore_power_info *ui)
 
 	num_uncore_freqs = (ui->init_max_freq - ui->init_min_freq) / BUS_FREQ + 1;
 	if (num_uncore_freqs >= MAX_UNCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available uncore frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available uncore frequencies: %d",
 				num_uncore_freqs);
 		goto out;
 	}
@@ -250,7 +253,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die)
 	if (max_pkgs == 0)
 		return -1;
 	if (pkg >= max_pkgs) {
-		RTE_LOG(DEBUG, POWER, "Package number %02u can not exceed %u\n",
+		POWER_LOG(DEBUG, "Package number %02u can not exceed %u",
 				pkg, max_pkgs);
 		return -1;
 	}
@@ -259,7 +262,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die)
 	if (max_dies == 0)
 		return -1;
 	if (die >= max_dies) {
-		RTE_LOG(DEBUG, POWER, "Die number %02u can not exceed %u\n",
+		POWER_LOG(DEBUG, "Die number %02u can not exceed %u",
 				die, max_dies);
 		return -1;
 	}
@@ -282,15 +285,17 @@ rte_power_uncore_init(unsigned int pkg, unsigned int die)
 
 	/* Init for setting uncore die frequency */
 	if (power_init_for_setting_uncore_freq(ui) < 0) {
-		RTE_LOG(DEBUG, POWER, "Cannot init for setting uncore frequency for "
-				"pkg %02u die %02u\n", pkg, die);
+		POWER_LOG(DEBUG,
+			  "Cannot init for setting uncore frequency for pkg %02u die %02u",
+			  pkg, die);
 		return -1;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_uncore_freqs(ui) < 0) {
-		RTE_LOG(DEBUG, POWER, "Cannot get available uncore frequencies of "
-				"pkg %02u die %02u\n", pkg, die);
+		POWER_LOG(DEBUG,
+			  "Cannot get available uncore frequencies of pkg %02u die %02u",
+			  pkg, die);
 		return -1;
 	}
 
@@ -309,14 +314,16 @@ rte_power_uncore_exit(unsigned int pkg, unsigned int die)
 	ui = &uncore_info[pkg][die];
 
 	if (fprintf(ui->f_cur_min, "%u", ui->org_min_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write original uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
 	if (fprintf(ui->f_cur_max, "%u", ui->org_max_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write original uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
@@ -395,10 +402,8 @@ rte_power_uncore_get_num_pkgs(void)
 
 	d = opendir(INTEL_UNCORE_FREQUENCY_DIR);
 	if (d == NULL) {
-		RTE_LOG(ERR, POWER,
-		"Uncore frequency management not supported/enabled on this kernel. "
-		"Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel"
-		" >= 5.6\n");
+		POWER_LOG(ERR,
+			  "Uncore frequency management not supported/enabled on this kernel");
 		return 0;
 	}
 
@@ -427,16 +432,14 @@ rte_power_uncore_get_num_dies(unsigned int pkg)
 	if (max_pkgs == 0)
 		return 0;
 	if (pkg >= max_pkgs) {
-		RTE_LOG(DEBUG, POWER, "Invalid package number\n");
+		POWER_LOG(DEBUG, "Invalid package number");
 		return 0;
 	}
 
 	d = opendir(INTEL_UNCORE_FREQUENCY_DIR);
 	if (d == NULL) {
-		RTE_LOG(ERR, POWER,
-		"Uncore frequency management not supported/enabled on this kernel. "
-		"Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel"
-		" >= 5.6\n");
+		POWER_LOG(ERR,
+			  "Uncore frequency management not supported/enabled on this kernel");
 		return 0;
 	}
 
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index ca1840387c74..e691e754ccb0 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -146,7 +146,7 @@ get_monitor_addresses(struct pmd_core_cfg *cfg,
 
 		/* attempted out of bounds access */
 		if (i >= len) {
-			RTE_LOG(ERR, POWER, "Too many queues being monitored\n");
+			POWER_LOG(ERR, "Too many queues being monitored");
 			return -1;
 		}
 
@@ -422,7 +422,7 @@ check_scale(unsigned int lcore)
 	/* only PSTATE and ACPI modes are supported */
 	if (!rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ) &&
 	    !rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) {
-		RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes are supported\n");
+		POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes are supported");
 		return -ENOTSUP;
 	}
 	/* ensure we could initialize the power library */
@@ -432,7 +432,7 @@ check_scale(unsigned int lcore)
 	/* ensure we initialized the correct env */
 	env = rte_power_get_env();
 	if (env != PM_ENV_ACPI_CPUFREQ && env != PM_ENV_PSTATE_CPUFREQ) {
-		RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes were initialized\n");
+		POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes were initialized");
 		return -ENOTSUP;
 	}
 
@@ -448,7 +448,7 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata)
 
 	/* check if rte_power_monitor is supported */
 	if (!global_data.intrinsics_support.power_monitor) {
-		RTE_LOG(DEBUG, POWER, "Monitoring intrinsics are not supported\n");
+		POWER_LOG(DEBUG, "Monitoring intrinsics are not supported");
 		return -ENOTSUP;
 	}
 	/* check if multi-monitor is supported */
@@ -457,14 +457,14 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata)
 
 	/* if we're adding a new queue, do we support multiple queues? */
 	if (cfg->n_queues > 0 && !multimonitor_supported) {
-		RTE_LOG(DEBUG, POWER, "Monitoring multiple queues is not supported\n");
+		POWER_LOG(DEBUG, "Monitoring multiple queues is not supported");
 		return -ENOTSUP;
 	}
 
 	/* check if the device supports the necessary PMD API */
 	if (rte_eth_get_monitor_addr(qdata->portid, qdata->qid,
 			&dummy) == -ENOTSUP) {
-		RTE_LOG(DEBUG, POWER, "The device does not support rte_eth_get_monitor_addr\n");
+		POWER_LOG(DEBUG, "The device does not support rte_eth_get_monitor_addr");
 		return -ENOTSUP;
 	}
 
@@ -564,14 +564,14 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
 		clb = clb_pause;
 		break;
 	default:
-		RTE_LOG(DEBUG, POWER, "Invalid power management type\n");
+		POWER_LOG(DEBUG, "Invalid power management type");
 		ret = -EINVAL;
 		goto end;
 	}
 	/* add this queue to the list */
 	ret = queue_list_add(lcore_cfg, &qdata);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to add queue to list: %s\n",
+		POWER_LOG(DEBUG, "Failed to add queue to list: %s",
 				strerror(-ret));
 		goto end;
 	}
@@ -684,7 +684,8 @@ int
 rte_power_pmd_mgmt_set_pause_duration(unsigned int duration)
 {
 	if (duration == 0) {
-		RTE_LOG(ERR, POWER, "Pause duration must be greater than 0, value unchanged");
+		POWER_LOG(ERR,
+			  "Pause duration must be greater than 0, value unchanged");
 		return -EINVAL;
 	}
 	pause_duration = duration;
@@ -702,12 +703,13 @@ int
 rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (min > scale_freq_max[lcore]) {
-		RTE_LOG(ERR, POWER, "Invalid min frequency: Cannot be greater than max frequency");
+		POWER_LOG(ERR,
+			  "Invalid min frequency: Cannot be greater than max frequency");
 		return -EINVAL;
 	}
 	scale_freq_min[lcore] = min;
@@ -719,7 +721,7 @@ int
 rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
@@ -727,7 +729,8 @@ rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
 	if (max == 0)
 		max = UINT32_MAX;
 	if (max < scale_freq_min[lcore]) {
-		RTE_LOG(ERR, POWER, "Invalid max frequency: Cannot be less than min frequency");
+		POWER_LOG(ERR,
+			  "Invalid max frequency: Cannot be less than min frequency");
 		return -EINVAL;
 	}
 
@@ -740,12 +743,12 @@ int
 rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (scale_freq_max[lcore] == 0)
-		RTE_LOG(DEBUG, POWER, "Scaling freq min config not set. Using sysfs min freq.\n");
+		POWER_LOG(DEBUG, "Scaling freq min config not set. Using sysfs min freq.");
 
 	return scale_freq_min[lcore];
 }
@@ -754,12 +757,12 @@ int
 rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (scale_freq_max[lcore] == UINT32_MAX) {
-		RTE_LOG(DEBUG, POWER, "Scaling freq max config not set. Using sysfs max freq.\n");
+		POWER_LOG(DEBUG, "Scaling freq max config not set. Using sysfs max freq.");
 		return 0;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 11/17] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 10/17] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 12/17] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/ring/rte_ring.c             | 31 +++++++++++++++++++------------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7dbf1df3b979..04c9d43351da 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 5b7850af4e2b..a99fe383c89b 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..1b4633468a2a 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,13 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+
+#define RING_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, ring_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
@@ -52,15 +59,15 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
 
 	/* Check if element size is a multiple of 4B */
 	if (esize % 4 != 0) {
-		RTE_LOG(ERR, RING, "element size is not a multiple of 4\n");
+		RING_LOG(ERR, "element size is not a multiple of 4");
 
 		return -EINVAL;
 	}
 
 	/* count must be a power of 2 */
 	if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK )) {
-		RTE_LOG(ERR, RING,
-			"Requested number of elements is invalid, must be power of 2, and not exceed %u\n",
+		RING_LOG(ERR,
+			"Requested number of elements is invalid, must be power of 2, and not exceed %u",
 			RTE_RING_SZ_MASK);
 
 		return -EINVAL;
@@ -195,8 +202,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 
 	/* future proof flags, only allow supported values */
 	if (flags & ~RING_F_MASK) {
-		RTE_LOG(ERR, RING,
-			"Unsupported flags requested %#x\n", flags);
+		RING_LOG(ERR,
+			"Unsupported flags requested %#x", flags);
 		return -EINVAL;
 	}
 
@@ -216,8 +223,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 		r->capacity = count;
 	} else {
 		if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) {
-			RTE_LOG(ERR, RING,
-				"Requested size is invalid, must be power of 2, and not exceed the size limit %u\n",
+			RING_LOG(ERR,
+				"Requested size is invalid, must be power of 2, and not exceed the size limit %u",
 				RTE_RING_SZ_MASK);
 			return -EINVAL;
 		}
@@ -271,7 +278,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count,
 
 	te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n");
+		RING_LOG(ERR, "Cannot reserve memory for tailq");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -295,7 +302,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count,
 		TAILQ_INSERT_TAIL(ring_list, te, next);
 	} else {
 		r = NULL;
-		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
+		RING_LOG(ERR, "Cannot reserve memory");
 		rte_free(te);
 	}
 	rte_mcfg_tailq_write_unlock();
@@ -327,13 +334,13 @@ rte_ring_free(struct rte_ring *r)
 	 * therefore, there is no memzone to free.
 	 */
 	if (r->memzone == NULL) {
-		RTE_LOG(ERR, RING,
-			"Cannot free ring, not created with rte_ring_create()\n");
+		RING_LOG(ERR,
+			 "Cannot free ring, not created with rte_ring_create()");
 		return;
 	}
 
 	if (rte_memzone_free(r->memzone) != 0) {
-		RTE_LOG(ERR, RING, "Cannot free memory\n");
+		RING_LOG(ERR, "Cannot free memory");
 		return;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 12/17] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 11/17] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 13/17] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mempool/rte_mempool.c       | 33 ++++++++++++++++++---------------
 lib/mempool/rte_mempool_log.h   | 10 ++++++++++
 lib/mempool/rte_mempool_ops.c   | 12 ++++++------
 5 files changed, 35 insertions(+), 23 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 04c9d43351da..90d388192712 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a99fe383c89b..f583352ec1ea 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..911a2b4dd850 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
@@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id)
 	cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache),
 				  RTE_CACHE_LINE_SIZE, socket_id);
 	if (cache == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate mempool cache.");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	/* try to allocate tailq entry */
 	te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!");
 		goto exit_unlock;
 	}
 
@@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp,
 
 		if (free == 0) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-					obj, (const void *) mp, cookie);
+				MEMPOOL_LOG(CRIT,
+					    "obj=%p, mempool=%p, cookie=%" PRIx64,
+					    obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (put)\n");
 			}
 			hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2;
 		} else if (free == 1) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-					obj, (const void *) mp, cookie);
+				MEMPOOL_LOG(CRIT,
+					    "obj=%p, mempool=%p, cookie=%" PRIx64,
+					    obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (get)\n");
 			}
 			hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1;
 		} else if (free == 2) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 &&
 			    cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
+				MEMPOOL_LOG(CRIT,
+					"obj=%p, mempool=%p, cookie=%" PRIx64,
 					obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (audit)\n");
 			}
@@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp,
 		tlr = rte_mempool_get_trailer(obj);
 		cookie = tlr->cookie;
 		if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
-			RTE_LOG(CRIT, MEMPOOL,
-				"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-				obj, (const void *) mp, cookie);
+			MEPOOL_LOG(CRIT,
+				   "obj=%p, mempool=%p, cookie=%" PRIx64,
+				   obj, (const void *) mp, cookie);
 			rte_panic("MEMPOOL: bad trailer cookie\n");
 		}
 	}
@@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp)
 		const struct rte_mempool_cache *cache;
 		cache = &mp->local_cache[lcore_id];
 		if (cache->len > RTE_DIM(cache->objs)) {
-			RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n",
+			MEMPOOL_LOG(CRIT, "badness on cache[%u]",
 				lcore_id);
 			rte_panic("MEMPOOL: invalid cache len\n");
 		}
@@ -1429,7 +1430,7 @@ rte_mempool_event_callback_register(rte_mempool_event_callback *func,
 
 	cb = calloc(1, sizeof(*cb));
 	if (cb == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate event callback!");
 		ret = -ENOMEM;
 		goto exit;
 	}
@@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry)
 	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
 		"Returns mempool info. Parameters: pool_name");
 }
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..3d252f761408
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mempool_logtype;
+
+#define MEMPOOL_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, mempool_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..e04e75b91ba6 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
@@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
 	if (rte_mempool_ops_table.num_ops >=
 			RTE_MEMPOOL_MAX_OPS_IDX) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(ERR, MEMPOOL,
-			"Maximum number of mempool ops structs exceeded\n");
+		MEMPOOL_LOG(ERR,
+			"Maximum number of mempool ops structs exceeded");
 		return -ENOSPC;
 	}
 
 	if (h->alloc == NULL || h->enqueue == NULL ||
 			h->dequeue == NULL || h->get_count == NULL) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(ERR, MEMPOOL,
-			"Missing callback while registering mempool ops\n");
+		MEMPOOL_LOG(ERR,
+			    "Missing callback while registering mempool ops");
 		return -EINVAL;
 	}
 
 	if (strlen(h->name) >= sizeof(ops->name) - 1) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n",
-				__func__, h->name);
+		MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", h->name);
 		rte_errno = EEXIST;
 		return -EEXIST;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 13/17] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 12/17] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 14/17] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/fib/rte_fib.c               | 23 +++++++++++++++--------
 lib/fib/rte_fib6.c              | 21 ++++++++++++++-------
 lib/lpm/rte_lpm.c               | 18 ++++++++++++------
 lib/lpm/rte_lpm6.c              | 25 +++++++++++++++++--------
 lib/rib/rte_rib.c               | 14 +++++++++-----
 lib/rib/rte_rib6.c              | 16 +++++++++++-----
 8 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 90d388192712..ff250b9a6d56 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f583352ec1ea..55067efb0a84 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..7fda4263f841 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 #include <rte_tailq.h>
@@ -17,6 +18,12 @@
 
 #include "dir24_8.h"
 
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
+
+#define FIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fib_logtype,		\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
 	.name = "RTE_FIB",
@@ -167,8 +174,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 
 	rib = rte_rib_create(name, socket_id, &rib_conf);
 	if (rib == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate RIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate RIB %s", name);
 		return NULL;
 	}
 
@@ -192,8 +199,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for FIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate tailq entry for FIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -202,7 +209,7 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	fib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_fib),	RTE_CACHE_LINE_SIZE, socket_id);
 	if (fib == NULL) {
-		RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name);
+		FIB_LOG(ERR, "FIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
@@ -213,9 +220,9 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	fib->def_nh = conf->default_nh;
 	ret = init_dataplane(fib, socket_id, conf);
 	if (ret < 0) {
-		RTE_LOG(ERR, LPM,
-			"FIB dataplane struct %s memory allocation failed "
-			"with err %d\n", name, ret);
+		FIB_LOG(ERR,
+			"FIB dataplane struct %s memory allocation failed with err %d",
+			name, ret);
 		rte_errno = -ret;
 		goto free_fib;
 	}
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..b6631fc19481 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -17,6 +18,12 @@
 
 #include "trie.h"
 
+RTE_LOG_REGISTER_SUFFIX(fib6_logtype, "fib6", INFO);
+
+#define FIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fib6_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
 	.name = "RTE_FIB6",
@@ -168,8 +175,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 
 	rib = rte_rib6_create(name, socket_id, &rib_conf);
 	if (rib == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate RIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate RIB %s", name);
 		return NULL;
 	}
 
@@ -193,8 +200,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for FIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate tailq entry for FIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -203,7 +210,7 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	fib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_fib6), RTE_CACHE_LINE_SIZE, socket_id);
 	if (fib == NULL) {
-		RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name);
+		FIB_LOG(ERR, "FIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
@@ -214,8 +221,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	fib->def_nh = conf->default_nh;
 	ret = init_dataplane(fib, socket_id, conf);
 	if (ret < 0) {
-		RTE_LOG(ERR, LPM,
-			"FIB dataplane struct %s memory allocation failed\n",
+		FIB_LOG(ERR,
+			"FIB dataplane struct %s memory allocation failed",
 			name);
 		rte_errno = -ret;
 		goto free_fib;
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..ba3912a775a3 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -19,6 +19,12 @@
 
 #include "rte_lpm.h"
 
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
+
+#define LPM_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, lpm_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_lpm_tailq = {
@@ -189,7 +195,7 @@ rte_lpm_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("LPM_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM, "Failed to allocate tailq entry\n");
+		LPM_LOG(ERR, "Failed to allocate tailq entry");
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -198,7 +204,7 @@ rte_lpm_create(const char *name, int socket_id,
 	i_lpm = rte_zmalloc_socket(mem_name, mem_size,
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (i_lpm == NULL) {
-		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+		LPM_LOG(ERR, "LPM memory allocation failed");
 		rte_free(te);
 		rte_errno = ENOMEM;
 		goto exit;
@@ -208,7 +214,7 @@ rte_lpm_create(const char *name, int socket_id,
 			(size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (i_lpm->rules_tbl == NULL) {
-		RTE_LOG(ERR, LPM, "LPM rules_tbl memory allocation failed\n");
+		LPM_LOG(ERR, "LPM rules_tbl memory allocation failed");
 		rte_free(i_lpm);
 		i_lpm = NULL;
 		rte_free(te);
@@ -220,7 +226,7 @@ rte_lpm_create(const char *name, int socket_id,
 			(size_t)tbl8s_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (i_lpm->lpm.tbl8 == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n");
+		LPM_LOG(ERR, "LPM tbl8 memory allocation failed");
 		rte_free(i_lpm->rules_tbl);
 		rte_free(i_lpm);
 		i_lpm = NULL;
@@ -335,7 +341,7 @@ rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg)
 		params.v = cfg->v;
 		i_lpm->dq = rte_rcu_qsbr_dq_create(&params);
 		if (i_lpm->dq == NULL) {
-			RTE_LOG(ERR, LPM, "LPM defer queue creation failed\n");
+			LPM_LOG(ERR, "LPM defer queue creation failed");
 			return 1;
 		}
 	} else {
@@ -562,7 +568,7 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start)
 		status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq,
 				(void *)&tbl8_group_start);
 		if (status == 1) {
-			RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n");
+			LPM_LOG(ERR, "Failed to push QSBR FIFO");
 			return -rte_errno;
 		}
 	}
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..7701e8112ed2 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -45,6 +45,12 @@ enum valid_flag {
 	VALID
 };
 
+RTE_LOG_REGISTER_SUFFIX(lpm6_logtype, "lpm6", INFO);
+
+#define LPM_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, lpm6_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_lpm6_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_lpm6_tailq = {
@@ -279,8 +285,9 @@ rte_lpm6_create(const char *name, int socket_id,
 
 	rules_tbl = rte_hash_create(&rule_hash_tbl_params);
 	if (rules_tbl == NULL) {
-		RTE_LOG(ERR, LPM, "LPM rules hash table allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM rules hash table allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		goto fail_wo_unlock;
 	}
 
@@ -289,8 +296,9 @@ rte_lpm6_create(const char *name, int socket_id,
 			sizeof(uint32_t) * config->number_tbl8s,
 			RTE_CACHE_LINE_SIZE);
 	if (tbl8_pool == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 pool allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM tbl8 pool allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		rte_errno = ENOMEM;
 		goto fail_wo_unlock;
 	}
@@ -300,8 +308,9 @@ rte_lpm6_create(const char *name, int socket_id,
 			sizeof(struct rte_lpm_tbl8_hdr) * config->number_tbl8s,
 			RTE_CACHE_LINE_SIZE);
 	if (tbl8_hdrs == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 headers allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM tbl8 headers allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		rte_errno = ENOMEM;
 		goto fail_wo_unlock;
 	}
@@ -329,7 +338,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM, "Failed to allocate tailq entry!\n");
+		LPM_LOG(ERR, "Failed to allocate tailq entry!");
 		rte_errno = ENOMEM;
 		goto fail;
 	}
@@ -339,7 +348,7 @@ rte_lpm6_create(const char *name, int socket_id,
 			RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm == NULL) {
-		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+		LPM_LOG(ERR, "LPM memory allocation failed");
 		rte_free(te);
 		rte_errno = ENOMEM;
 		goto fail;
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..a81b4ed1cc04 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,12 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+
+#define RIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rib_logtype,		\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
@@ -412,8 +418,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 		NULL, NULL, NULL, NULL, socket_id, 0);
 
 	if (node_pool == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate mempool for RIB %s\n", name);
+		RIB_LOG(ERR, "Can not allocate mempool for RIB %s", name);
 		return NULL;
 	}
 
@@ -437,8 +442,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (unlikely(te == NULL)) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for RIB %s\n", name);
+		RIB_LOG(ERR, "Can not allocate tailq entry for RIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -447,7 +451,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib),	RTE_CACHE_LINE_SIZE, socket_id);
 	if (unlikely(rib == NULL)) {
-		RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name);
+		RIB_LOG(ERR, "RIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..39eba4d7032b 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,12 @@
 
 #include <rte_rib6.h>
 
+RTE_LOG_REGISTER_SUFFIX(rib6_logtype, "rib6", INFO);
+
+#define RIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rib6_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
@@ -481,8 +488,7 @@ rte_rib6_create(const char *name, int socket_id,
 		NULL, NULL, NULL, NULL, socket_id, 0);
 
 	if (node_pool == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate mempool for RIB6 %s\n", name);
+		RIB_LOG(ERR, "Can not allocate mempool for RIB6 %s", name);
 		return NULL;
 	}
 
@@ -506,8 +512,8 @@ rte_rib6_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0);
 	if (unlikely(te == NULL)) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for RIB6 %s\n", name);
+		RIB_LOG(ERR,
+			"Can not allocate tailq entry for RIB6 %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -516,7 +522,7 @@ rte_rib6_create(const char *name, int socket_id,
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id);
 	if (unlikely(rib == NULL)) {
-		RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name);
+		RIB_LOG(ERR, "RIB6 %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 14/17] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 13/17] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 15/17] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/kni/rte_kni.c               | 63 ++++++++++++++++++---------------
 3 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index ff250b9a6d56..b0c625a02cdf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 55067efb0a84..69d3d07252ec 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..baf732017a43 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -92,15 +92,20 @@ static void kni_allocate_mbufs(struct rte_kni *kni);
 
 static volatile int kni_fd = -1;
 
+RTE_LOG_REGISTER_SUFFIX(kni_logtype, "kni", INFO);
+
+#define KNI_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, kni_logtype,	fmt, ## args)
+
 /* Shall be called before any allocation happens */
 int
 rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 {
-	RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n");
+	KNI_LOG(WARNING, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n");
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
 	if (rte_eal_iova_mode() != RTE_IOVA_PA) {
-		RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n");
+		KNI_LOG(ERR, "KNI requires IOVA as PA\n");
 		return -1;
 	}
 #endif
@@ -109,7 +114,7 @@ rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 	if (kni_fd < 0) {
 		kni_fd = open("/dev/" KNI_DEVICE, O_RDWR);
 		if (kni_fd < 0) {
-			RTE_LOG(ERR, KNI,
+			KNI_LOG(ERR,
 				"Can not open /dev/%s\n", KNI_DEVICE);
 			return -1;
 		}
@@ -225,7 +230,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 
 	/* Check if KNI subsystem has been initialized */
 	if (kni_fd < 0) {
-		RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
+		KNI_LOG(ERR, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
 		return NULL;
 	}
 
@@ -233,19 +238,19 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
-		RTE_LOG(ERR, KNI, "KNI already exists\n");
+		KNI_LOG(ERR, "KNI already exists\n");
 		goto unlock;
 	}
 
 	te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n");
+		KNI_LOG(ERR, "Failed to allocate tailq entry\n");
 		goto unlock;
 	}
 
 	kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE);
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "KNI memory allocation failed\n");
+		KNI_LOG(ERR, "KNI memory allocation failed\n");
 		goto kni_fail;
 	}
 
@@ -424,7 +429,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	strlcpy(dev_info.name, kni->name, sizeof(dev_info.name));
 	if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) {
-		RTE_LOG(ERR, KNI, "Fail to release kni device\n");
+		KNI_LOG(ERR, "Fail to release kni device\n");
 		goto unlock;
 	}
 
@@ -439,7 +444,7 @@ rte_kni_release(struct rte_kni *kni)
 		usleep(1000);
 
 	if (kni_fifo_count(kni->rx_q))
-		RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n");
+		KNI_LOG(ERR, "Fail to free all Rx-q items\n");
 
 	kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q);
 	kni_free_fifo(kni->tx_q);
@@ -466,16 +471,16 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 	int ret = 0;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id);
+	KNI_LOG(INFO, "Configure mac address of %d", port_id);
 
 	ret = rte_eth_dev_default_mac_addr_set(port_id,
 					(struct rte_ether_addr *)mac_addr);
 	if (ret < 0)
-		RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n",
+		KNI_LOG(ERR, "Failed to config mac_addr for port %d\n",
 			port_id);
 
 	return ret;
@@ -488,11 +493,11 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n",
+	KNI_LOG(INFO, "Configure promiscuous mode of %d to %d\n",
 		port_id, to_on);
 
 	if (to_on)
@@ -501,7 +506,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 		ret = rte_eth_promiscuous_disable(port_id);
 
 	if (ret != 0)
-		RTE_LOG(ERR, KNI,
+		KNI_LOG(ERR,
 			"Failed to %s promiscuous mode for port %u: %s\n",
 			to_on ? "enable" : "disable", port_id,
 			rte_strerror(-ret));
@@ -516,11 +521,11 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on)
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n",
+	KNI_LOG(INFO, "Configure allmulticast mode of %d to %d\n",
 		port_id, to_on);
 
 	if (to_on)
@@ -528,7 +533,7 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on)
 	else
 		ret = rte_eth_allmulticast_disable(port_id);
 	if (ret != 0)
-		RTE_LOG(ERR, KNI,
+		KNI_LOG(ERR,
 			"Failed to %s allmulticast mode for port %u: %s\n",
 			to_on ? "enable" : "disable", port_id,
 			rte_strerror(-ret));
@@ -551,7 +556,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 		return 0; /* It is OK of can not getting the request mbuf */
 
 	if (req != kni->sync_addr) {
-		RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req);
+		KNI_LOG(ERR, "Wrong req pointer %p\n", req);
 		return -1;
 	}
 
@@ -592,7 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 					kni->ops.port_id, req->allmulti);
 		break;
 	default:
-		RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id);
+		KNI_LOG(ERR, "Unknown request id %u\n", req->req_id);
 		req->result = -EINVAL;
 		break;
 	}
@@ -603,7 +608,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 	else
 		ret = 1;
 	if (ret != 1) {
-		RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n");
+		KNI_LOG(ERR, "Fail to put the muf back to resp_q\n");
 		return -1; /* It is an error of can't putting the mbuf back */
 	}
 
@@ -679,7 +684,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
 
 	/* Check if pktmbuf pool has been configured */
 	if (kni->pktmbuf_pool == NULL) {
-		RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n");
+		KNI_LOG(ERR, "No valid mempool for allocating mbufs\n");
 		return;
 	}
 
@@ -690,7 +695,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
 		pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
 		if (unlikely(pkts[i] == NULL)) {
 			/* Out of memory */
-			RTE_LOG(ERR, KNI, "Out of memory\n");
+			KNI_LOG(ERR, "Out of memory\n");
 			break;
 		}
 		phys[i] = va2pa(pkts[i]);
@@ -757,18 +762,18 @@ rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops)
 	enum kni_ops_status req_status;
 
 	if (ops == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n");
+		KNI_LOG(ERR, "Invalid KNI request operation.\n");
 		return -1;
 	}
 
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid kni info.\n");
+		KNI_LOG(ERR, "Invalid kni info.\n");
 		return -1;
 	}
 
 	req_status = kni_check_request_register(&kni->ops);
 	if (req_status == KNI_REQ_REGISTERED) {
-		RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n");
+		KNI_LOG(ERR, "The KNI request operation has already registered.\n");
 		return -1;
 	}
 
@@ -780,7 +785,7 @@ int
 rte_kni_unregister_handlers(struct rte_kni *kni)
 {
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid kni info.\n");
+		KNI_LOG(ERR, "Invalid kni info.\n");
 		return -1;
 	}
 
@@ -806,7 +811,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 
 	fd = open(path, O_RDWR);
 	if (fd == -1) {
-		RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path);
+		KNI_LOG(ERR, "Failed to open file: %s.\n", path);
 		return -1;
 	}
 
@@ -823,7 +828,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 	new_carrier = linkup ? "1" : "0";
 	ret = write(fd, new_carrier, 1);
 	if (ret < 1) {
-		RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path);
+		KNI_LOG(ERR, "Failed to write file: %s.\n", path);
 		close(fd);
 		return -1;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 15/17] hash: replace RTE_LOGTYPE_HASH with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 14/17] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 16/17] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 17/17] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

A little more complex here since the one hash library actually
has multiple routines in it.  Split up the logtypes for
hash and toeplitz.

The hash crc file has another issue around logging.
It is calling RTE_LOG during a constructor which is maybe
problematic because this will all run before the DPDK library
has finished initializing logging.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/hash/rte_cuckoo_hash.c      | 60 ++++++++++++++++++---------------
 lib/hash/rte_fbk_hash.c         | 10 ++++--
 lib/hash/rte_hash_crc.h         |  6 ++--
 lib/hash/rte_thash.c            | 53 ++++++++++++++++++++++-------
 lib/hash/rte_thash_gfni.h       | 24 ++++---------
 lib/hash/version.map            |  4 +++
 8 files changed, 95 insertions(+), 65 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index b0c625a02cdf..97120543d808 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 69d3d07252ec..afbd67d55b45 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..607aa9c8d04c 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -26,6 +26,12 @@
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_logtype, "hash", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 /* Mask of all flags supported by this version */
 #define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \
 				   RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \
@@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
 	if (params == NULL) {
-		RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n");
+		HASH_LOG(ERR, "null parameters");
 		return NULL;
 	}
 
@@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
 			(params->key_len == 0)) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n");
+		HASH_LOG(ERR, "invalid parameters");
 		return NULL;
 	}
 
 	if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n");
+		HASH_LOG(ERR, "unsupported extra flags");
 		return NULL;
 	}
 
@@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or "
-			"rw concurrency lock free\n");
+		HASH_LOG(ERR,
+			 "choose rw concurrency or rw concurrency lock free");
 		return NULL;
 	}
 
@@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	r = rte_ring_create_elem(ring_name, sizeof(uint32_t),
 			rte_align32pow2(num_key_slots), params->socket_id, 0);
 	if (r == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err;
 	}
 
@@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				params->socket_id, 0);
 
 		if (r_ext == NULL) {
-			RTE_LOG(ERR, HASH, "ext buckets memory allocation "
-								"failed\n");
+			HASH_LOG(ERR,
+				 "ext buckets memory allocation failed");
 			goto err;
 		}
 	}
@@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH, "tailq entry allocation failed\n");
+		HASH_LOG(ERR, "tailq entry allocation failed");
 		goto err_unlock;
 	}
 
@@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 					RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (h == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (buckets == NULL) {
-		RTE_LOG(ERR, HASH, "buckets memory allocation failed\n");
+		HASH_LOG(ERR, "buckets memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				num_buckets * sizeof(struct rte_hash_bucket),
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 		if (buckets_ext == NULL) {
-			RTE_LOG(ERR, HASH, "ext buckets memory allocation "
-							"failed\n");
+			HASH_LOG(ERR,
+				 "ext buckets memory allocation failed");
 			goto err_unlock;
 		}
 		/* Populate ext bkt ring. We reserve 0 similar to the
@@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) *
 								num_key_slots, 0);
 			if (ext_bkt_to_free == NULL) {
-				RTE_LOG(ERR, HASH, "ext bkt to free memory allocation "
-								"failed\n");
+				HASH_LOG(ERR,
+					 "ext bkt to free memory allocation failed");
 				goto err_unlock;
 			}
 		}
@@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (k == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (tbl_chng_cnt == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				sizeof(struct lcore_cache) * RTE_MAX_LCORE,
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 		if (local_free_slots == NULL) {
-			RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n");
+			HASH_LOG(ERR, "local free slots memory allocation failed");
 			goto err_unlock;
 		}
 	}
@@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h)
 		/* Reclaim all the resources */
 		rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL);
 		if (pending != 0)
-			RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n");
+			HASH_LOG(ERR, "RCU reclaim all resources failed");
 	}
 
 	memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket));
@@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n)
 	/* Return key indexes to free slot ring */
 	ret = free_slot(h, rcu_dq_entry.key_idx);
 	if (ret < 0) {
-		RTE_LOG(ERR, HASH,
-			"%s: could not enqueue free slots in global ring\n",
-				__func__);
+		HASH_LOG(ERR,
+			 "could not enqueue free slots in global ring");
 	}
 }
 
@@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 
 	hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0);
 	if (hash_rcu_cfg == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		return 1;
 	}
 
@@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 		h->dq = rte_rcu_qsbr_dq_create(&params);
 		if (h->dq == NULL) {
 			rte_free(hash_rcu_cfg);
-			RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n");
+			HASH_LOG(ERR, "HASH defer queue creation failed");
 			return 1;
 		}
 	} else {
@@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
 	int ret = free_slot(h, bkt->key_idx[i]);
 
 	if (ret < 0) {
-		RTE_LOG(ERR, HASH,
-			"%s: could not enqueue free slots in global ring\n",
-				__func__);
+		HASH_LOG(ERR,
+			 "could not enqueue free slots in global ring");
 	}
 }
 
@@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
 		} else if (h->dq)
 			/* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */
 			if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0)
-				RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n");
+				HASH_LOG(ERR, "Failed to push QSBR FIFO");
 	}
 	__hash_rw_writer_unlock(h);
 	return ret;
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..7a0e4272ffa9 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -18,6 +18,12 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, "hash.fbk", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fbk_hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
@@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n");
+		HASH_LOG(ERR, "Failed to allocate tailq entry");
 		goto exit;
 	}
 
@@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	ht = rte_zmalloc_socket(hash_name, mem_size,
 			0, params->socket_id);
 	if (ht == NULL) {
-		RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n");
+		HASH_LOG(ERR, "Failed to allocate fbk hash table");
 		rte_free(te);
 		goto exit;
 	}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..3bb38880c4ea 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg)
 
 #if defined RTE_ARCH_X86
 	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
 	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
 		crc32_alg = CRC32_SSE42;
@@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg)
 
 #if defined RTE_ARCH_ARM64
 	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
 		crc32_alg = CRC32_ARM64;
 #endif
 
 	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
 }
 
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..cb94f77f1f9b 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,12 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, "thash", INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rte_thash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
@@ -104,6 +110,28 @@ rte_thash_gfni_supported(void)
 	return 0;
 };
 
+#ifndef RTE_THASH_GFNI_DEFINED
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	HASH_LOG(ERR, "is undefined under given arch");
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+	int len __rte_unused, uint8_t *tuple[] __rte_unused,
+	uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	HASH_LOG(ERR, "is undefined under given arch");
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
+#endif
+
 void
 rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size)
 {
@@ -240,8 +268,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 	/* allocate tailq entry */
 	te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH,
-			"Can not allocate tailq entry for thash context %s\n",
+		HASH_LOG(ERR,
+			"Can not allocate tailq entry for thash context %s",
 			name);
 		rte_errno = ENOMEM;
 		goto exit;
@@ -249,7 +277,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 
 	ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0);
 	if (ctx == NULL) {
-		RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n",
+		HASH_LOG(ERR,
+			 "thash ctx %s memory allocation failed",
 			name);
 		rte_errno = ENOMEM;
 		goto free_te;
@@ -272,7 +301,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 		ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t),
 			RTE_CACHE_LINE_SIZE);
 		if (ctx->matrices == NULL) {
-			RTE_LOG(ERR, HASH, "Cannot allocate matrices\n");
+			HASH_LOG(ERR, "Cannot allocate matrices");
 			rte_errno = ENOMEM;
 			goto free_ctx;
 		}
@@ -387,8 +416,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
 	if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) &&
 			((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) !=
 			RTE_THASH_IGNORE_PERIOD_OVERFLOW)) {
-		RTE_LOG(ERR, HASH,
-			"Can't generate m-sequence due to period overflow\n");
+		HASH_LOG(ERR,
+			"Can't generate m-sequence due to period overflow");
 		return -ENOSPC;
 	}
 
@@ -467,9 +496,9 @@ insert_before(struct rte_thash_ctx *ctx,
 			return ret;
 		}
 	} else if ((next_ent != NULL) && (end > next_ent->offset)) {
-		RTE_LOG(ERR, HASH,
-			"Can't add helper %s due to conflict with existing"
-			" helper %s\n", ent->name, next_ent->name);
+		HASH_LOG(ERR,
+			"Can't add helper %s due to conflict with existing helper %s",
+			 ent->name, next_ent->name);
 		rte_free(ent);
 		return -ENOSPC;
 	}
@@ -516,9 +545,9 @@ insert_after(struct rte_thash_ctx *ctx,
 	int ret;
 
 	if ((next_ent != NULL) && (end > next_ent->offset)) {
-		RTE_LOG(ERR, HASH,
-			"Can't add helper %s due to conflict with existing"
-			" helper %s\n", ent->name, next_ent->name);
+		HASH_LOG(ERR,
+			 "Can't add helper %s due to conflict with existing helper %s",
+			 ent->name, next_ent->name);
 		rte_free(ent);
 		return -EEXIST;
 	}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..c3a5cf7e7b2d 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -38,13 +38,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx,
+		    int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..c30ac81307a7 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 23.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 16/17] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 15/17] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  2023-02-07 23:04   ` [RFC v2 17/17] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   2 -
 lib/eal/include/rte_log.h       |   4 +-
 lib/sched/rte_pie.c             |  16 +-
 lib/sched/rte_sched.c           | 297 +++++++++++++-------------------
 lib/sched/rte_sched_log.h       |  11 ++
 5 files changed, 140 insertions(+), 190 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 97120543d808..212ccda0a6e8 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,8 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index afbd67d55b45..a1549b372767 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..28ed01e8f11d 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
+
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
@@ -16,7 +18,7 @@ int
 rte_pie_rt_data_init(struct rte_pie *pie)
 {
 	if (pie == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Invalid addr for pie\n", __func__);
+		SCHED_LOG(ERR, "Invalid addr for pie");
 		return -EINVAL;
 	}
 
@@ -38,26 +40,22 @@ rte_pie_config_init(struct rte_pie_config *pie_cfg,
 		return -1;
 
 	if (qdelay_ref <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for qdelay_ref\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for qdelay_ref");
 		return -EINVAL;
 	}
 
 	if (dp_update_interval <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for dp_update_interval\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for dp_update_interval");
 		return -EINVAL;
 	}
 
 	if (max_burst <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for max_burst\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for max_burst");
 		return -EINVAL;
 	}
 
 	if (tailq_th <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tailq_th\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tailq_th");
 		return -EINVAL;
 	}
 
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..fd5bd38070fa 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -6,7 +6,6 @@
 #include <string.h>
 
 #include <rte_common.h>
-#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 #include <rte_prefetch.h>
@@ -17,6 +16,7 @@
 
 #include "rte_sched.h"
 #include "rte_sched_common.h"
+#include "rte_sched_log.h"
 #include "rte_approx.h"
 
 #ifdef __INTEL_COMPILER
@@ -324,23 +324,20 @@ pipe_profile_check(struct rte_sched_pipe_params *params,
 
 	/* Pipe parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* TB rate: non-zero, not greater than port rate */
 	if (params->tb_rate == 0 ||
 		params->tb_rate > rate) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tb rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb rate");
 		return -EINVAL;
 	}
 
 	/* TB size: non-zero */
 	if (params->tb_size == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tb size\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb size");
 		return -EINVAL;
 	}
 
@@ -349,38 +346,33 @@ pipe_profile_check(struct rte_sched_pipe_params *params,
 		if ((qsize[i] == 0 && params->tc_rate[i] != 0) ||
 			(qsize[i] != 0 && (params->tc_rate[i] == 0 ||
 			params->tc_rate[i] > params->tb_rate))) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for qsize or tc_rate\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for qsize or tc_rate");
 			return -EINVAL;
 		}
 	}
 
 	if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 ||
 		qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for be traffic class rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for be traffic class rate");
 		return -EINVAL;
 	}
 
 	/* TC period: non-zero */
 	if (params->tc_period == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc period\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc period");
 		return -EINVAL;
 	}
 
 	/*  Best effort tc oversubscription weight: non-zero */
 	if (params->tc_ov_weight == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc ov weight\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc ov weight");
 		return -EINVAL;
 	}
 
 	/* Queue WRR weights: non-zero */
 	for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) {
 		if (params->wrr_weights[i] == 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for wrr weight\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for wrr weight");
 			return -EINVAL;
 		}
 	}
@@ -396,20 +388,17 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,
 
 	/* Check user parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	if (params->tb_rate == 0 || params->tb_rate > rate) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tb rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb rate");
 		return -EINVAL;
 	}
 
 	if (params->tb_size == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tb size\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb size");
 		return -EINVAL;
 	}
 
@@ -417,21 +406,18 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,
 		uint64_t tc_rate = params->tc_rate[i];
 
 		if (tc_rate == 0 || (tc_rate > params->tb_rate)) {
-			RTE_LOG(ERR, SCHED, "%s: "
-			"Incorrect value for tc rate\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for tc rate");
 			return -EINVAL;
 		}
 	}
 
 	if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect tc rate(best effort)\n", __func__);
+		SCHED_LOG(ERR, "Incorrect tc rate(best effort)");
 		return -EINVAL;
 	}
 
 	if (params->tc_period == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tc period\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc period");
 		return -EINVAL;
 	}
 
@@ -444,29 +430,25 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	uint32_t i;
 
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* socket */
 	if (params->socket < 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for socket id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for socket id");
 		return -EINVAL;
 	}
 
 	/* rate */
 	if (params->rate == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for rate");
 		return -EINVAL;
 	}
 
 	/* mtu */
 	if (params->mtu == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for mtu\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for mtu");
 		return -EINVAL;
 	}
 
@@ -474,8 +456,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	if (params->n_subports_per_port == 0 ||
 	    params->n_subports_per_port > 1u << 16 ||
 	    !rte_is_power_of_2(params->n_subports_per_port)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for number of subports\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for number of subports");
 		return -EINVAL;
 	}
 
@@ -483,8 +464,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 		params->n_subport_profiles == 0 ||
 		params->n_max_subport_profiles == 0 ||
 		params->n_subport_profiles > params->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED,
-		"%s: Incorrect value for subport profiles\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport profiles");
 		return -EINVAL;
 	}
 
@@ -495,9 +475,8 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 
 		status = subport_profile_check(p, params->rate);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-			"%s: subport profile check failed(%d)\n",
-			__func__, status);
+			SCHED_LOG(ERR, "subport profile check failed(%d)",
+				  status);
 			return -EINVAL;
 		}
 	}
@@ -505,8 +484,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	/* n_pipes_per_subport: non-zero, power of 2 */
 	if (params->n_pipes_per_subport == 0 ||
 	    !rte_is_power_of_2(params->n_pipes_per_subport)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for maximum pipes number\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for maximum pipes number");
 		return -EINVAL;
 	}
 
@@ -605,14 +583,15 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 {
 	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
 
-	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
+	SCHED_LOG(DEBUG,
+		  "Low level config for pipe profile %u:\n"
 		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n"
 		"	Traffic classes: period = %"PRIu64",\n"
 		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
 		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
 		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
 		"	Best-effort traffic class oversubscription: weight = %hhu\n"
-		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
+		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]",
 		i,
 
 		/* Token bucket */
@@ -648,35 +627,36 @@ rte_sched_port_log_subport_profile(struct rte_sched_port *port, uint32_t i)
 {
 	struct rte_sched_subport_profile *p = port->subport_profiles + i;
 
-	RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n"
-	"Token bucket: period = %"PRIu64", credits per period = %"PRIu64","
-	"size = %"PRIu64"\n"
-	"Traffic classes: period = %"PRIu64",\n"
-	"credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
-	" %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
-	" %"PRIu64", %"PRIu64", %"PRIu64"]\n",
-	i,
-
-	/* Token bucket */
-	p->tb_period,
-	p->tb_credits_per_period,
-	p->tb_size,
-
-	/* Traffic classes */
-	p->tc_period,
-	p->tc_credits_per_period[0],
-	p->tc_credits_per_period[1],
-	p->tc_credits_per_period[2],
-	p->tc_credits_per_period[3],
-	p->tc_credits_per_period[4],
-	p->tc_credits_per_period[5],
-	p->tc_credits_per_period[6],
-	p->tc_credits_per_period[7],
-	p->tc_credits_per_period[8],
-	p->tc_credits_per_period[9],
-	p->tc_credits_per_period[10],
-	p->tc_credits_per_period[11],
-	p->tc_credits_per_period[12]);
+	SCHED_LOG(DEBUG,
+		  "Low level config for subport profile %u:\n"
+		  "Token bucket: period = %"PRIu64", credits per period = %"PRIu64","
+		  "size = %"PRIu64"\n"
+		  "Traffic classes: period = %"PRIu64",\n"
+		  "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		  " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		  " %"PRIu64", %"PRIu64", %"PRIu64"]",
+		  i,
+
+		  /* Token bucket */
+		  p->tb_period,
+		  p->tb_credits_per_period,
+		  p->tb_size,
+
+		  /* Traffic classes */
+		  p->tc_period,
+		  p->tc_credits_per_period[0],
+		  p->tc_credits_per_period[1],
+		  p->tc_credits_per_period[2],
+		  p->tc_credits_per_period[3],
+		  p->tc_credits_per_period[4],
+		  p->tc_credits_per_period[5],
+		  p->tc_credits_per_period[6],
+		  p->tc_credits_per_period[7],
+		  p->tc_credits_per_period[8],
+		  p->tc_credits_per_period[9],
+		  p->tc_credits_per_period[10],
+		  p->tc_credits_per_period[11],
+		  p->tc_credits_per_period[12]);
 }
 
 static inline uint64_t
@@ -829,8 +809,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 
 	/* Check user parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
@@ -841,14 +820,13 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 		uint16_t qsize = params->qsize[i];
 
 		if (qsize != 0 && !rte_is_power_of_2(qsize)) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for qsize\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for qsize");
 			return -EINVAL;
 		}
 	}
 
 	if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED, "%s: Incorrect qsize\n", __func__);
+		SCHED_LOG(ERR, "Incorrect qsize");
 		return -EINVAL;
 	}
 
@@ -856,8 +834,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	if (params->n_pipes_per_subport_enabled == 0 ||
 		params->n_pipes_per_subport_enabled > n_max_pipes_per_subport ||
 	    !rte_is_power_of_2(params->n_pipes_per_subport_enabled)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for pipes number\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for pipes number");
 		return -EINVAL;
 	}
 
@@ -866,8 +843,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	    params->n_pipe_profiles == 0 ||
 		params->n_max_pipe_profiles == 0 ||
 		params->n_pipe_profiles > params->n_max_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for pipe profiles\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for pipe profiles");
 		return -EINVAL;
 	}
 
@@ -877,8 +853,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 
 		status = pipe_profile_check(p, rate, &params->qsize[0]);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Pipe profile check failed(%d)\n", __func__, status);
+			SCHED_LOG(ERR, "Pipe profile check failed(%d)", status);
 			return -EINVAL;
 		}
 	}
@@ -895,9 +870,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
 
 	status = rte_sched_port_check_params(port_params);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Port scheduler port params check failed (%d)\n",
-			__func__, status);
+		SCHED_LOG(ERR,
+			  "Port scheduler port params check failed (%d)",
+			  status);
 
 		return 0;
 	}
@@ -909,9 +884,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
 				port_params->n_pipes_per_subport,
 				port_params->rate);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Port scheduler subport params check failed (%d)\n",
-				__func__, status);
+			SCHED_LOG(ERR,
+				  "Port scheduler subport params check failed (%d)",
+				status);
 
 			return 0;
 		}
@@ -940,8 +915,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 
 	status = rte_sched_port_check_params(params);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Port scheduler params check failed (%d)\n",
+		SCHED_LOG(ERR, "Port scheduler params check failed (%d)\n",
 			__func__, status);
 		return NULL;
 	}
@@ -955,7 +929,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	port = rte_zmalloc_socket("qos_params", size0 + size1,
 				 RTE_CACHE_LINE_SIZE, params->socket);
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
+		SCHED_LOG(ERR, "Memory allocation fails");
 
 		return NULL;
 	}
@@ -964,7 +938,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	port->subport_profiles  = rte_zmalloc_socket("subport_profile", size2,
 					RTE_CACHE_LINE_SIZE, params->socket);
 	if (port->subport_profiles == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
+		SCHED_LOG(ERR, "Memory allocation fails");
 		rte_free(port);
 		return NULL;
 	}
@@ -1106,8 +1080,7 @@ rte_sched_red_config(struct rte_sched_port *port,
 				params->cman_params->red_params[i][j].maxp_inv) != 0) {
 				rte_sched_free_memory(port, n_subports);
 
-				RTE_LOG(NOTICE, SCHED,
-				"%s: RED configuration init fails\n", __func__);
+				SCHED_LOG(NOTICE, "RED configuration init fails");
 				return -EINVAL;
 			}
 		}
@@ -1126,8 +1099,7 @@ rte_sched_pie_config(struct rte_sched_port *port,
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
 		if (params->cman_params->pie_params[i].tailq_th > params->qsize[i]) {
-			RTE_LOG(NOTICE, SCHED,
-			"%s: PIE tailq threshold incorrect\n", __func__);
+			SCHED_LOG(NOTICE, "PIE tailq threshold incorrect");
 			return -EINVAL;
 		}
 
@@ -1138,8 +1110,7 @@ rte_sched_pie_config(struct rte_sched_port *port,
 			params->cman_params->pie_params[i].tailq_th) != 0) {
 			rte_sched_free_memory(port, n_subports);
 
-			RTE_LOG(NOTICE, SCHED,
-			"%s: PIE configuration init fails\n", __func__);
+			SCHED_LOG(NOTICE, "PIE configuration init fails");
 			return -EINVAL;
 			}
 	}
@@ -1170,14 +1141,12 @@ rte_sched_subport_tc_ov_config(struct rte_sched_port *port,
 	struct rte_sched_subport *s;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter subport id");
 		return  -EINVAL;
 	}
 
@@ -1203,22 +1172,19 @@ rte_sched_subport_config(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return 0;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (subport_profile_id >= port->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED, "%s: "
-			"Number of subport profile exceeds the max limit\n",
-			__func__);
+		SCHED_LOG(ERR,
+			  "Number of subport profile exceeds the max limit");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1233,9 +1199,9 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			port->n_pipes_per_subport,
 			port->rate);
 		if (status != 0) {
-			RTE_LOG(NOTICE, SCHED,
-				"%s: Port scheduler params check failed (%d)\n",
-				__func__, status);
+			SCHED_LOG(NOTICE,
+				  "Port scheduler params check failed (%d)",
+				  status);
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1249,8 +1215,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		s = rte_zmalloc_socket("subport_params", size0 + size1,
 			RTE_CACHE_LINE_SIZE, port->socket);
 		if (s == NULL) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Memory allocation fails\n", __func__);
+			SCHED_LOG(ERR, "Memory allocation fails");
 			ret = -ENOMEM;
 			goto out;
 		}
@@ -1281,8 +1246,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			s->cman_enabled = true;
 			status = rte_sched_cman_config(port, s, params, n_subports);
 			if (status) {
-				RTE_LOG(NOTICE, SCHED,
-					"%s: CMAN configuration fails\n", __func__);
+				SCHED_LOG(NOTICE,
+					  "CMAN configuration fails");
 				return status;
 			}
 		} else {
@@ -1329,8 +1294,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		s->bmp = rte_bitmap_init(n_subport_pipe_queues, s->bmp_array,
 					bmp_mem_size);
 		if (s->bmp == NULL) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Subport bitmap init error\n", __func__);
+			SCHED_LOG(ERR, "Subport bitmap init error");
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1399,29 +1363,25 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 	deactivate = (pipe_profile < 0);
 
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter subport id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	s = port->subports[subport_id];
 	if (pipe_id >= s->n_pipes_per_subport_enabled) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter pipe id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter pipe id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (!deactivate && profile >= s->n_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter pipe profile\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter pipe profile");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1446,9 +1406,9 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 		s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
 
 		if (s->tc_ov != tc_be_ov) {
-			RTE_LOG(DEBUG, SCHED,
-				"Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)\n",
-				subport_id, subport_tc_be_rate, s->tc_ov_rate);
+			SCHED_LOG(DEBUG,
+				  "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)",
+				  subport_id, subport_tc_be_rate, s->tc_ov_rate);
 		}
 
 		/* Reset the pipe */
@@ -1488,8 +1448,8 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 		s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
 
 		if (s->tc_ov != tc_be_ov) {
-			RTE_LOG(DEBUG, SCHED,
-				"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n",
+			SCHED_LOG(DEBUG,
+				"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)",
 				subport_id, subport_tc_be_rate, s->tc_ov_rate);
 		}
 		p->tc_ov_period_id = s->tc_ov_period_id;
@@ -1517,15 +1477,13 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 
 	/* Port */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	/* Subport id not exceeds the max limit */
 	if (subport_id > port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		return -EINVAL;
 	}
 
@@ -1533,16 +1491,14 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 
 	/* Pipe profiles exceeds the max limit */
 	if (s->n_pipe_profiles >= s->n_max_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Number of pipe profiles exceeds the max limit\n", __func__);
+		SCHED_LOG(ERR, "Number of pipe profiles exceeds the max limit");
 		return -EINVAL;
 	}
 
 	/* Pipe params */
 	status = pipe_profile_check(params, port->rate, &s->qsize[0]);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Pipe profile check failed(%d)\n", __func__, status);
+		SCHED_LOG(ERR, "Pipe profile check failed(%d)", status);
 		return -EINVAL;
 	}
 
@@ -1552,8 +1508,7 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 	/* Pipe profile should not exists */
 	for (i = 0; i < s->n_pipe_profiles; i++)
 		if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Pipe profile exists\n", __func__);
+			SCHED_LOG(ERR, "Pipe profile exists");
 			return -EINVAL;
 		}
 
@@ -1580,21 +1535,18 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 
 	/* Port */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter profile\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter profile");
 		return -EINVAL;
 	}
 
 	if (subport_profile_id == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter subport_profile_id\n",
-		__func__);
+		SCHED_LOG(ERR,
+			  "Incorrect value for parameter subport_profile_id");
 		return -EINVAL;
 	}
 
@@ -1602,16 +1554,14 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 
 	/* Subport profiles exceeds the max limit */
 	if (port->n_subport_profiles >= port->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Number of subport profiles exceeds the max limit\n",
-		 __func__);
+		SCHED_LOG(ERR,
+			  "Number of subport profiles exceeds the max limit");
 		return -EINVAL;
 	}
 
 	status = subport_profile_check(params, port->rate);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-		"%s: subport profile check failed(%d)\n", __func__, status);
+		SCHED_LOG(ERR, "subport profile check failed", status);
 		return -EINVAL;
 	}
 
@@ -1621,8 +1571,7 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 	for (i = 0; i < port->n_subport_profiles; i++)
 		if (memcmp(port->subport_profiles + i,
 		    dst, sizeof(*dst)) == 0) {
-			RTE_LOG(ERR, SCHED,
-			"%s: subport profile exists\n", __func__);
+			SCHED_LOG(ERR, "subport profile exists");
 			return -EINVAL;
 		}
 
@@ -1694,26 +1643,22 @@ rte_sched_subport_read_stats(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		return -EINVAL;
 	}
 
 	if (stats == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter stats\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter stats");
 		return -EINVAL;
 	}
 
 	if (tc_ov == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc_ov\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc_ov");
 		return -EINVAL;
 	}
 
@@ -1742,26 +1687,22 @@ rte_sched_queue_read_stats(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (queue_id >= rte_sched_port_queues_per_port(port)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for queue id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for queue id");
 		return -EINVAL;
 	}
 
 	if (stats == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter stats\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter stats");
 		return -EINVAL;
 	}
 
 	if (qlen == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter qlen\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter qlen");
 		return -EINVAL;
 	}
 	subport_qmask = port->n_pipes_per_subport_log2 + 4;
@@ -3002,3 +2943,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_SUFFIX(sched_logtype, "sched", INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..cbf577faf2cb
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_log.h>
+
+extern int sched_logtype;
+
+#define SCHED_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, sched_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [RFC v2 17/17] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-07 23:04   ` [RFC v2 16/17] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-07 23:04   ` Stephen Hemminger
  16 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-07 23:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into seperate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/port/rte_port_ethdev.c      | 23 +++++----
 lib/port/rte_port_eventdev.c    | 23 +++++----
 lib/port/rte_port_fd.c          | 28 ++++++-----
 lib/port/rte_port_frag.c        | 21 +++++----
 lib/port/rte_port_kni.c         | 22 +++++----
 lib/port/rte_port_ras.c         | 17 ++++---
 lib/port/rte_port_ring.c        | 22 +++++----
 lib/port/rte_port_sched.c       | 16 ++++---
 lib/port/rte_port_source_sink.c | 82 +++++++++++++++++++--------------
 lib/port/rte_port_sym_crypto.c  | 22 +++++----
 12 files changed, 164 insertions(+), 115 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 212ccda0a6e8..7002e267be37 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a1549b372767..ff714a703be7 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..614bdacb3cec 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -5,11 +5,16 @@
 #include <stdint.h>
 
 #include <rte_mbuf.h>
+#include <rte_log.h>
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, "port.ethdev", INFO);
+#define RTE_PORT_ETHDEV_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_ethdev_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port ETHDEV Reader
  */
@@ -43,7 +48,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -51,7 +56,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -78,7 +83,7 @@ static int
 rte_port_ethdev_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -142,7 +147,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -150,7 +155,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -257,7 +262,7 @@ static int
 rte_port_ethdev_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -323,7 +328,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -331,7 +336,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -470,7 +475,7 @@ static int
 rte_port_ethdev_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..4d0838a004c9 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,16 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, "port.eventdev", INFO);
+#define RTE_PORT_EVENTDEV_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_eventdev_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port EVENTDEV Reader
  */
@@ -45,7 +50,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -53,7 +58,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -85,7 +90,7 @@ static int
 rte_port_eventdev_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -155,7 +160,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id)
 		(conf->enq_burst_sz == 0) ||
 		(conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->enq_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -163,7 +168,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -290,7 +295,7 @@ static int
 rte_port_eventdev_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -362,7 +367,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id)
 		(conf->enq_burst_sz == 0) ||
 		(conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->enq_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -370,7 +375,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -530,7 +535,7 @@ static int
 rte_port_eventdev_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..0c059a465b3a 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,10 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, "port.fd", INFO);
+#define RTE_PORT_FD_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_fd_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port FD Reader
  */
@@ -43,19 +47,19 @@ rte_port_fd_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 	if (conf->fd < 0) {
-		RTE_LOG(ERR, PORT, "%s: Invalid file descriptor\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid file descriptor");
 		return NULL;
 	}
 	if (conf->mtu == 0) {
-		RTE_LOG(ERR, PORT, "%s: Invalid MTU\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid MTU");
 		return NULL;
 	}
 	if (conf->mempool == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Invalid mempool\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid mempool");
 		return NULL;
 	}
 
@@ -63,7 +67,7 @@ rte_port_fd_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -109,7 +113,7 @@ static int
 rte_port_fd_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -171,7 +175,7 @@ rte_port_fd_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -179,7 +183,7 @@ rte_port_fd_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -279,7 +283,7 @@ static int
 rte_port_fd_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -344,7 +348,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -352,7 +356,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -464,7 +468,7 @@ static int
 rte_port_fd_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..243ebf225770 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,11 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, "port.frag", INFO);
+#define RTE_PORT_FRAG_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_frag_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
@@ -62,25 +67,23 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter conf is NULL");
 		return NULL;
 	}
 	if (conf->ring == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter ring is NULL");
 		return NULL;
 	}
 	if (conf->mtu == 0) {
-		RTE_LOG(ERR, PORT, "%s: Parameter mtu is invalid\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter mtu is invalid");
 		return NULL;
 	}
 	if (conf->pool_direct == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter pool_direct is NULL\n",
-			__func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter pool_direct is NULL");
 		return NULL;
 	}
 	if (conf->pool_indirect == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter pool_indirect is NULL\n",
-			__func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter pool_indirect is NULL");
 		return NULL;
 	}
 
@@ -88,7 +91,7 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4)
 	port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "port is NULL");
 		return NULL;
 	}
 
@@ -232,7 +235,7 @@ static int
 rte_port_ring_reader_frag_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter port is NULL");
 		return -1;
 	}
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..ed2b5c3e4a31 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,10 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, "port.kni", INFO);
+#define RTE_PORT_KNI_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_kni_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port KNI Reader
  */
@@ -41,7 +45,7 @@ rte_port_kni_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -49,7 +53,7 @@ rte_port_kni_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -75,7 +79,7 @@ static int
 rte_port_kni_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -138,7 +142,7 @@ rte_port_kni_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -146,7 +150,7 @@ rte_port_kni_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -250,7 +254,7 @@ static int
 rte_port_kni_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -315,7 +319,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -323,7 +327,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -460,7 +464,7 @@ static int
 rte_port_kni_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..3205b1abc360 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -21,6 +21,11 @@
 #define RTE_PORT_RAS_N_ENTRIES (RTE_PORT_RAS_N_BUCKETS * RTE_PORT_RAS_N_ENTRIES_PER_BUCKET)
 #endif
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, "port.ras", INFO);
+#define RTE_PORT_RAS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_ras_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
+
 #ifdef RTE_PORT_STATS_COLLECT
 
 #define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) \
@@ -69,16 +74,16 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter conf is NULL");
 		return NULL;
 	}
 	if (conf->ring == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter ring is NULL");
 		return NULL;
 	}
 	if ((conf->tx_burst_sz == 0) ||
 	    (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PORT, "%s: Parameter tx_burst_sz is invalid\n",
+		RTE_PORT_RAS_LOG(ERR, "Parameter tx_burst_sz is invalid\n",
 			__func__);
 		return NULL;
 	}
@@ -87,7 +92,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate socket\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Failed to allocate socket");
 		return NULL;
 	}
 
@@ -103,7 +108,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
 		socket_id);
 
 	if (port->frag_tbl == NULL) {
-		RTE_LOG(ERR, PORT, "%s: rte_ip_frag_table_create failed\n",
+		RTE_PORT_RAS_LOG(ERR, "rte_ip_frag_table_create failed\n",
 			__func__);
 		rte_free(port);
 		return NULL;
@@ -282,7 +287,7 @@ rte_port_ring_writer_ras_free(void *port)
 			port;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter port is NULL");
 		return -1;
 	}
 
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..e493f63ab25e 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,10 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, "port.ring", INFO);
+#define RTE_PORT_RING_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_ring_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port RING Reader
  */
@@ -46,7 +50,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,
 		(conf->ring == NULL) ||
 		(rte_ring_is_cons_single(conf->ring) && is_multi) ||
 		(!rte_ring_is_cons_single(conf->ring) && !is_multi)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Invalid Parameters");
 		return NULL;
 	}
 
@@ -54,7 +58,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -107,7 +111,7 @@ static int
 rte_port_ring_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -174,7 +178,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,
 		(rte_ring_is_prod_single(conf->ring) && is_multi) ||
 		(!rte_ring_is_prod_single(conf->ring) && !is_multi) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Invalid Parameters");
 		return NULL;
 	}
 
@@ -182,7 +186,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -370,7 +374,7 @@ rte_port_ring_writer_free(void *port)
 	struct rte_port_ring_writer *p = port;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -443,7 +447,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,
 		(rte_ring_is_prod_single(conf->ring) && is_multi) ||
 		(!rte_ring_is_prod_single(conf->ring) && !is_multi) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Invalid Parameters");
 		return NULL;
 	}
 
@@ -451,7 +455,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -703,7 +707,7 @@ rte_port_ring_writer_nodrop_free(void *port)
 			port;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..dc590fd9c647 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,10 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, "port.sched", INFO);
+#define RTE_PORT_SCHED_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_sched_logtype,	\
+		"%s: " fmt "\n", __func__, ##args)
 /*
  * Reader
  */
@@ -40,7 +44,7 @@ rte_port_sched_reader_create(void *params, int socket_id)
 	/* Check input parameters */
 	if ((conf == NULL) ||
 	    (conf->sched == NULL)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Invalid params");
 		return NULL;
 	}
 
@@ -48,7 +52,7 @@ rte_port_sched_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -74,7 +78,7 @@ static int
 rte_port_sched_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -139,7 +143,7 @@ rte_port_sched_writer_create(void *params, int socket_id)
 	    (conf->tx_burst_sz == 0) ||
 	    (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Invalid params");
 		return NULL;
 	}
 
@@ -147,7 +151,7 @@ rte_port_sched_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -247,7 +251,7 @@ static int
 rte_port_sched_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..fbb453f22fae 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,12 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, "port.source", INFO);
+
+#define RTE_PORT_SOURCE_LOG(level, fmt, args...)	\
+	rte_log(RTE_LOG_ ## level, port_source_logtype,	\
+		"%s: " fmt "\n", __func__, ##args)
+
 /*
  * Port SOURCE
  */
@@ -49,9 +55,9 @@ struct rte_port_source {
 
 static int
 pcap_source_load(struct rte_port_source *port,
-		const char *file_name,
-		uint32_t n_bytes_per_pkt,
-		int socket_id)
+		 const char *file_name,
+		 uint32_t n_bytes_per_pkt,
+		 int socket_id)
 {
 	uint32_t n_pkts = 0;
 	uint32_t i;
@@ -64,8 +70,8 @@ pcap_source_load(struct rte_port_source *port,
 	const uint8_t *pkt;
 	uint8_t *buff = NULL;
 	uint32_t pktmbuf_maxlen = (uint32_t)
-			(rte_pktmbuf_data_room_size(port->mempool) -
-			RTE_PKTMBUF_HEADROOM);
+		(rte_pktmbuf_data_room_size(port->mempool) -
+		 RTE_PKTMBUF_HEADROOM);
 
 	if (n_bytes_per_pkt == 0)
 		max_len = pktmbuf_maxlen;
@@ -75,8 +81,9 @@ pcap_source_load(struct rte_port_source *port,
 	/* first time open, get packet number */
 	pcap_handle = pcap_open_offline(file_name, pcap_errbuf);
 	if (pcap_handle == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"'%s' for reading\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file '%s' for reading",
+				    file_name);
 		goto error_exit;
 	}
 
@@ -86,31 +93,32 @@ pcap_source_load(struct rte_port_source *port,
 	pcap_close(pcap_handle);
 
 	port->pkt_len = rte_zmalloc_socket("PCAP",
-		(sizeof(*port->pkt_len) * n_pkts), 0, socket_id);
+					   (sizeof(*port->pkt_len) * n_pkts), 0, socket_id);
 	if (port->pkt_len == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
 	pkt_len_aligns = rte_malloc("PCAP",
-		(sizeof(*pkt_len_aligns) * n_pkts), 0);
+				    (sizeof(*pkt_len_aligns) * n_pkts), 0);
 	if (pkt_len_aligns == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
 	port->pkts = rte_zmalloc_socket("PCAP",
-		(sizeof(*port->pkts) * n_pkts), 0, socket_id);
+					(sizeof(*port->pkts) * n_pkts), 0, socket_id);
 	if (port->pkts == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
 	/* open 2nd time, get pkt_len */
 	pcap_handle = pcap_open_offline(file_name, pcap_errbuf);
 	if (pcap_handle == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"'%s' for reading\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file '%s' for reading",
+				    file_name);
 		goto error_exit;
 	}
 
@@ -126,9 +134,9 @@ pcap_source_load(struct rte_port_source *port,
 
 	/* allocate a big trunk of data for pcap file load */
 	buff = rte_zmalloc_socket("PCAP",
-		total_buff_len, 0, socket_id);
+				  total_buff_len, 0, socket_id);
 	if (buff == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
@@ -137,8 +145,9 @@ pcap_source_load(struct rte_port_source *port,
 	/* open file one last time to copy the pkt content */
 	pcap_handle = pcap_open_offline(file_name, pcap_errbuf);
 	if (pcap_handle == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"'%s' for reading\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file '%s' for reading",
+				    file_name);
 		goto error_exit;
 	}
 
@@ -155,9 +164,9 @@ pcap_source_load(struct rte_port_source *port,
 
 	rte_free(pkt_len_aligns);
 
-	RTE_LOG(INFO, PORT, "Successfully load pcap file "
-		"'%s' with %u pkts\n",
-		file_name, port->n_pkts);
+	RTE_PORT_SOURCE_LOG(INFO,
+			    "Successfully load pcap file '%s' with %u pkts",
+			    file_name, port->n_pkts);
 
 	return 0;
 
@@ -180,8 +189,8 @@ pcap_source_load(struct rte_port_source *port,
 	int _ret = 0;						\
 								\
 	if (file_name) {					\
-		RTE_LOG(ERR, PORT, "Source port field "		\
-			"\"file_name\" is not NULL.\n");	\
+		RTE_PORT_SOURCE_LOG(ERR, "Source port field "	\
+			"\"file_name\" is not NULL.");		\
 		_ret = -1;					\
 	}							\
 								\
@@ -199,7 +208,7 @@ rte_port_source_create(void *params, int socket_id)
 
 	/* Check input arguments*/
 	if ((p == NULL) || (p->mempool == NULL)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
+		RTE_PORT_SOURCE_LOG(ERR, "Invalid params");
 		return NULL;
 	}
 
@@ -207,7 +216,7 @@ rte_port_source_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -332,15 +341,16 @@ pcap_sink_open(struct rte_port_sink *port,
 	/** Open a dead pcap handler for opening dumper file */
 	tx_pcap = pcap_open_dead(DLT_EN10MB, 65535);
 	if (tx_pcap == NULL) {
-		RTE_LOG(ERR, PORT, "Cannot open pcap dead handler\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Cannot open pcap dead handler");
 		return -1;
 	}
 
 	/* The dumper is created using the previous pcap_t reference */
 	pcap_dumper = pcap_dump_open(tx_pcap, file_name);
 	if (pcap_dumper == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"\"%s\" for writing\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file \"%s\" for writing",
+				    file_name);
 		return -1;
 	}
 
@@ -349,8 +359,9 @@ pcap_sink_open(struct rte_port_sink *port,
 	port->pkt_index = 0;
 	port->dump_finish = 0;
 
-	RTE_LOG(INFO, PORT, "Ready to dump packets to file \"%s\"\n",
-		file_name);
+	RTE_PORT_SOURCE_LOG(INFO,
+			    "Ready to dump packets to file \"%s\"",
+			    file_name);
 
 	return 0;
 }
@@ -402,8 +413,9 @@ pcap_sink_write_pkt(struct rte_port_sink *port, struct rte_mbuf *mbuf)
 
 	if ((port->max_pkts != 0) && (port->pkt_index >= port->max_pkts)) {
 		port->dump_finish = 1;
-		RTE_LOG(INFO, PORT, "Dumped %u packets to file\n",
-				port->pkt_index);
+		RTE_PORT_SOURCE_LOG(INFO,
+				    "Dumped %u packets to file",
+				    port->pkt_index);
 	}
 
 }
@@ -433,7 +445,7 @@ do {								\
 	int _ret = 0;						\
 								\
 	if (file_name) {					\
-		RTE_LOG(ERR, PORT, "Sink port field "		\
+		RTE_PORT_SOURCE_LOG(ERR, "Sink port field "	\
 			"\"file_name\" is not NULL.\n");	\
 		_ret = -1;					\
 	}							\
@@ -459,7 +471,7 @@ rte_port_sink_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..ee8573a3e1c4 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,10 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, "port.crypto", INFO);
+#define RTE_PORT_CRYPTO_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_crypto_logtype,	\
+		"%s: " fmt "\n", __func__, ##args)
 /*
  * Port Crypto Reader
  */
@@ -44,7 +48,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -52,7 +56,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -100,7 +104,7 @@ static int
 rte_port_sym_crypto_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -167,7 +171,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -175,7 +179,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -285,7 +289,7 @@ static int
 rte_port_sym_crypto_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -353,7 +357,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -361,7 +365,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -497,7 +501,7 @@ static int
 rte_port_sym_crypto_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 00/16] Replace use of static logtypes
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (13 preceding siblings ...)
  2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
@ 2023-02-10  1:07 ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 01/16] gso: remove logtype Stephen Hemminger
                     ` (15 more replies)
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                   ` (7 subsequent siblings)
  22 siblings, 16 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

It does not address the larger effort which is the eal,
eventdev, cryptodev, and pmd log types.

Mostly this is semi-automatic conversion but some places like
hash required some additional steps.

v2 - fix some warnings and also do table and pipeline

Stephen Hemminger (16):
  gso: remove logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with local type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  hash: replace RTE_LOGTYPE_HASH with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type

 app/test/test_acl.c                |   3 +-
 app/test/test_table_acl.c          |  50 +++--
 app/test/test_table_pipeline.c     |  40 ++--
 lib/acl/acl_bld.c                  |  35 ++--
 lib/acl/acl_gen.c                  |  20 +-
 lib/acl/acl_log.h                  |  13 ++
 lib/acl/rte_acl.c                  |  14 +-
 lib/acl/tb_mem.c                   |   8 +-
 lib/eal/common/eal_common_log.c    |  18 +-
 lib/eal/include/rte_log.h          |  33 ++--
 lib/efd/rte_efd.c                  | 106 +++++-----
 lib/fib/fib_log.h                  |  10 +
 lib/fib/rte_fib.c                  |  20 +-
 lib/fib/rte_fib6.c                 |  16 +-
 lib/gso/rte_gso.c                  |   3 +-
 lib/hash/rte_cuckoo_hash.c         |  60 +++---
 lib/hash/rte_fbk_hash.c            |  10 +-
 lib/hash/rte_hash_crc.h            |   6 +-
 lib/hash/rte_thash.c               |  53 +++--
 lib/hash/rte_thash_gfni.h          |  24 +--
 lib/hash/version.map               |   4 +
 lib/kni/rte_kni.c                  |  63 +++---
 lib/lpm/lpm_log.h                  |   9 +
 lib/lpm/rte_lpm.c                  |  15 +-
 lib/lpm/rte_lpm6.c                 |  20 +-
 lib/mbuf/mbuf_log.h                |  10 +
 lib/mbuf/rte_mbuf.c                |  20 +-
 lib/mbuf/rte_mbuf_dyn.c            |  15 +-
 lib/mbuf/rte_mbuf_pool_ops.c       |   5 +-
 lib/mempool/rte_mempool.c          |  33 ++--
 lib/mempool/rte_mempool_log.h      |  10 +
 lib/mempool/rte_mempool_ops.c      |  12 +-
 lib/pipeline/rte_pipeline.c        | 242 +++++++++--------------
 lib/port/rte_port_ethdev.c         |  23 ++-
 lib/port/rte_port_eventdev.c       |  23 ++-
 lib/port/rte_port_fd.c             |  28 +--
 lib/port/rte_port_frag.c           |  21 +-
 lib/port/rte_port_kni.c            |  22 ++-
 lib/port/rte_port_ras.c            |  19 +-
 lib/port/rte_port_ring.c           |  22 ++-
 lib/port/rte_port_sched.c          |  16 +-
 lib/port/rte_port_source_sink.c    |  82 ++++----
 lib/port/rte_port_sym_crypto.c     |  22 ++-
 lib/power/guest_channel.c          |  48 ++---
 lib/power/power_acpi_cpufreq.c     | 118 ++++++------
 lib/power/power_common.c           |  11 +-
 lib/power/power_common.h           |   7 +-
 lib/power/power_cppc_cpufreq.c     | 129 +++++++------
 lib/power/power_kvm_vm.c           |  24 +--
 lib/power/power_pstate_cpufreq.c   | 166 ++++++++--------
 lib/power/rte_power.c              |  25 ++-
 lib/power/rte_power_empty_poll.c   |  36 ++--
 lib/power/rte_power_intel_uncore.c |  75 ++++----
 lib/power/rte_power_pmd_mgmt.c     |  37 ++--
 lib/rib/rib_log.h                  |   9 +
 lib/rib/rte_rib.c                  |  12 +-
 lib/rib/rte_rib6.c                 |  12 +-
 lib/ring/rte_ring.c                |  31 +--
 lib/sched/rte_pie.c                |  16 +-
 lib/sched/rte_sched.c              | 299 ++++++++++++-----------------
 lib/sched/rte_sched_log.h          |  11 ++
 lib/table/rte_table_acl.c          |  90 ++++-----
 lib/table/rte_table_array.c        |  23 +--
 lib/table/rte_table_hash_cuckoo.c  |  30 +--
 lib/table/rte_table_hash_ext.c     |  34 ++--
 lib/table/rte_table_hash_key16.c   |  56 +++---
 lib/table/rte_table_hash_key32.c   |  62 +++---
 lib/table/rte_table_hash_key8.c    |  59 +++---
 lib/table/rte_table_hash_lru.c     |  35 ++--
 lib/table/rte_table_lpm.c          |  54 +++---
 lib/table/rte_table_lpm_ipv6.c     |  56 +++---
 lib/table/rte_table_stub.c         |   9 +-
 72 files changed, 1477 insertions(+), 1375 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 01/16] gso: remove logtype
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:47     ` fengchengwen
  2023-02-10  2:29     ` Hu, Jiayu
  2023-02-10  1:07   ` [PATCH v3 02/16] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (14 subsequent siblings)
  15 siblings, 2 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Konstantin Ananyev, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message and pass it through. This is incorrect
behaviour on many levels:
  - it allows oversize packet to get passed on to NIC driver
  - no direct return is visible to applications
  - if it happens once, many more will follow and log will fill.
  - bonus it is only log message with GSO type.

The fix is to just return -EINVAL which is what this library
does in many other places when looking at headers.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 +-
 lib/eal/include/rte_log.h       | 1 -
 lib/gso/rte_gso.c               | 3 +--
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..c369154cb1ea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
+
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..97d6b26a9967 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,6 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..19c351769fcc 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
 		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -EINVAL;
 	}
 
 	if (ret < 0) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 02/16] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 01/16] gso: remove logtype Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
                     ` (13 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index c369154cb1ea..e7ccde1c9ccd 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 97d6b26a9967..361d1ad96299 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 01/16] gso: remove logtype Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 02/16] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  2:03     ` fengchengwen
  2023-02-10  1:07   ` [PATCH v3 04/16] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
                     ` (12 subsequent siblings)
  15 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of global logtype with a local log type.
Do not break message formats across source lines.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   1 -
 lib/eal/include/rte_log.h       |   2 +-
 lib/efd/rte_efd.c               | 106 +++++++++++++++-----------------
 3 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index e7ccde1c9ccd..675f3d07bbe3 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 361d1ad96299..a90fa629168d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 
 /* these log types can be used in an application */
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..23316ef7300f 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -87,6 +87,11 @@ static struct rte_tailq_elem rte_efd_tailq = {
 };
 EAL_REGISTER_TAILQ(rte_efd_tailq);
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+
+#define EFD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args)
+
 /** Internal permutation array used to shuffle bins into pseudorandom groups */
 const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = {
 	{
@@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
 	if (online_cpu_socket_bitmask == 0) {
-		RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled "
-				"in the bitmask\n");
+		EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask");
 		return NULL;
 	}
 
 	if (max_num_rules == 0) {
-		RTE_LOG(ERR, EFD, "Max num rules must be higher than 0\n");
+		EFD_LOG(ERR, "Max num rules must be higher than 0");
 		return NULL;
 	}
 
@@ -554,7 +558,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te = rte_zmalloc("EFD_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, EFD, "tailq entry allocation failed\n");
+		EFD_LOG(ERR, "tailq entry allocation failed");
 		goto error_unlock_exit;
 	}
 
@@ -564,15 +568,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (table == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating EFD table management structure"
-				" on socket %u failed\n",
-				offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating EFD table management structureon socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 
 
-	RTE_LOG(DEBUG, EFD, "Allocated EFD table management structure "
-			"on socket %u\n", offline_cpu_socket);
+	EFD_LOG(DEBUG, "Allocated EFD table management structure on socket %u",
+		offline_cpu_socket);
 
 	table->max_num_rules = num_chunks * EFD_TARGET_CHUNK_MAX_NUM_RULES;
 	table->num_rules = 0;
@@ -586,17 +590,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (key_array == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating key array"
-				" on socket %u failed\n",
-				offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating key array on socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 	table->keys = key_array;
 	strlcpy(table->name, name, sizeof(table->name));
 
-	RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks,"
-			" which potentially supports %u entries\n",
-			num_chunks, table->max_num_rules);
+	EFD_LOG(DEBUG,
+		"Creating an EFD table with %u chunks, which potentially supports %u entries",
+		num_chunks, table->max_num_rules);
 
 	/* Make sure all the allocatable table pointers are NULL initially */
 	for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++)
@@ -623,19 +627,16 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 				RTE_CACHE_LINE_SIZE,
 				socket_id);
 			if (table->chunks[socket_id] == NULL) {
-				RTE_LOG(ERR, EFD,
-						"Allocating EFD online table on "
-						"socket %u failed\n",
-						socket_id);
+				EFD_LOG(ERR,
+					"Allocating EFD online table on socket %u failed",
+					socket_id);
 				goto error_unlock_exit;
 			}
-			RTE_LOG(DEBUG, EFD,
-					"Allocated EFD online table of size "
-					"%"PRIu64" bytes (%.2f MB) on socket %u\n",
-					online_table_size,
-					(float) online_table_size /
-						(1024.0F * 1024.0F),
-					socket_id);
+			EFD_LOG(DEBUG,
+				"Allocated EFD online table of size %" PRIu64 " bytes (%.2f MB) on socket %u",
+				online_table_size,
+				(float) online_table_size / (1024.0F * 1024.0F),
+				socket_id);
 		}
 	}
 
@@ -675,16 +676,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 			RTE_CACHE_LINE_SIZE,
 			offline_cpu_socket);
 	if (table->offline_chunks == NULL) {
-		RTE_LOG(ERR, EFD, "Allocating EFD offline table on socket %u "
-				"failed\n", offline_cpu_socket);
+		EFD_LOG(ERR,
+			"Allocating EFD offline table on socket %u failed",
+			offline_cpu_socket);
 		goto error_unlock_exit;
 	}
 
-	RTE_LOG(DEBUG, EFD,
-			"Allocated EFD offline table of size %"PRIu64" bytes "
-			" (%.2f MB) on socket %u\n", offline_table_size,
-			(float) offline_table_size / (1024.0F * 1024.0F),
-			offline_cpu_socket);
+	EFD_LOG(DEBUG,
+		"Allocated EFD offline table of size %" PRIu64 " bytes  (%.2f MB) on socket %u",
+		offline_table_size,
+		(float) offline_table_size / (1024.0F * 1024.0F),
+		offline_cpu_socket);
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
@@ -695,7 +697,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules),
 			offline_cpu_socket, 0);
 	if (r == NULL) {
-		RTE_LOG(ERR, EFD, "memory allocation failed\n");
+		EFD_LOG(ERR, "ring memory allocation failed");
 		rte_efd_free(table);
 		return NULL;
 	}
@@ -1015,20 +1017,17 @@ efd_compute_update(struct rte_efd_table * const table,
 	if (found == 0) {
 		/* Key does not exist. Insert the rule into the bin/group */
 		if (unlikely(current_group->num_rules >= EFD_MAX_GROUP_NUM_RULES)) {
-			RTE_LOG(ERR, EFD,
-					"Fatal: No room remaining for insert into "
-					"chunk %u group %u bin %u\n",
-					*chunk_id,
-					current_group_id, *bin_id);
+			EFD_LOG(ERR,
+				"Fatal: No room remaining for insert into chunk %u group %u bin %u",
+				*chunk_id, current_group_id, *bin_id);
 			return RTE_EFD_UPDATE_FAILED;
 		}
 
 		if (unlikely(current_group->num_rules ==
 				(EFD_MAX_GROUP_NUM_RULES - 1))) {
-			RTE_LOG(INFO, EFD, "Warn: Insert into last "
-					"available slot in chunk %u "
-					"group %u bin %u\n", *chunk_id,
-					current_group_id, *bin_id);
+			EFD_LOG(NOTICE,
+			       "Insert into last available slot in chunk %u group %u bin %u",
+			       *chunk_id, current_group_id, *bin_id);
 			status = RTE_EFD_UPDATE_WARN_GROUP_FULL;
 		}
 
@@ -1112,14 +1111,11 @@ efd_compute_update(struct rte_efd_table * const table,
 	uint8_t choice = 0;
 	for (;;) {
 		if (current_group != new_group &&
-				new_group->num_rules + bin_size >
-					EFD_MAX_GROUP_NUM_RULES) {
-			RTE_LOG(DEBUG, EFD,
-					"Unable to move_groups to dest group "
-					"containing %u entries."
-					"bin_size:%u choice:%02x\n",
-					new_group->num_rules, bin_size,
-					choice - 1);
+		    new_group->num_rules + bin_size > EFD_MAX_GROUP_NUM_RULES) {
+			EFD_LOG(DEBUG,
+				"Unable to move_groups to dest group containing %u entries. bin_size:%u choice:%02x",
+				new_group->num_rules, bin_size,
+				choice - 1);
 			goto next_choice;
 		}
 		move_groups(*bin_id, bin_size, new_group, current_group);
@@ -1132,10 +1128,10 @@ efd_compute_update(struct rte_efd_table * const table,
 		if (!ret)
 			return status;
 
-		RTE_LOG(DEBUG, EFD,
-				"Failed to find perfect hash for group "
-				"containing %u entries. bin_size:%u choice:%02x\n",
-				new_group->num_rules, bin_size, choice - 1);
+		EFD_LOG(DEBUG,
+			"Failed to find perfect hash for group containing %u entries. bin_size:%u choice:%02x",
+			new_group->num_rules, bin_size, choice - 1);
+
 		/* Restore groups modified to their previous state */
 		revert_groups(current_group, new_group, bin_size);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 04/16] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 05/16] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (11 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mbuf/mbuf_log.h             | 10 ++++++++++
 lib/mbuf/rte_mbuf.c             | 20 ++++++++++++--------
 lib/mbuf/rte_mbuf_dyn.c         | 15 ++++++++-------
 lib/mbuf/rte_mbuf_pool_ops.c    |  5 +++--
 6 files changed, 34 insertions(+), 19 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 675f3d07bbe3..128bfabd94e1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a90fa629168d..1f259b2abc5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..fe97f338c9b7
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mbuf_logtype;
+
+#define MBUF_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, mbuf_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..133fd3ba55be 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,8 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
@@ -227,8 +229,8 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n,
 	int ret;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
-		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
-			priv_size);
+		MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned",
+			 priv_size);
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -247,7 +249,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n,
 		mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+		MBUF_LOG(ERR, "error setting mempool handler");
 		rte_mempool_free(mp);
 		rte_errno = -ret;
 		return NULL;
@@ -293,7 +295,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	int ret;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
-		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
+		MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned",
 			priv_size);
 		rte_errno = EINVAL;
 		return NULL;
@@ -303,12 +305,12 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 		const struct rte_pktmbuf_extmem *extm = ext_mem + i;
 
 		if (!extm->elt_size || !extm->buf_len || !extm->buf_ptr) {
-			RTE_LOG(ERR, MBUF, "invalid extmem descriptor\n");
+			MBUF_LOG(ERR, "invalid extmem descriptor");
 			rte_errno = EINVAL;
 			return NULL;
 		}
 		if (data_room_size > extm->elt_size) {
-			RTE_LOG(ERR, MBUF, "ext elt_size=%u is too small\n",
+			MBUF_LOG(ERR, "ext elt_size=%u is too small",
 				priv_size);
 			rte_errno = EINVAL;
 			return NULL;
@@ -317,7 +319,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	}
 	/* Check whether enough external memory provided. */
 	if (n_elts < n) {
-		RTE_LOG(ERR, MBUF, "not enough extmem\n");
+		MBUF_LOG(ERR, "not enough extmem");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -338,7 +340,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n,
 	mp_ops_name = rte_mbuf_best_mempool_ops();
 	ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
 	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+		MBUF_LOG(ERR, "error setting mempool handler");
 		rte_mempool_free(mp);
 		rte_errno = -ret;
 		return NULL;
@@ -936,3 +938,5 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 
 	return 0;
 }
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..ef8d6069b37a 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
@@ -116,7 +118,7 @@ init_shared_mem(void)
 		mz = rte_memzone_lookup(RTE_MBUF_DYN_MZNAME);
 	}
 	if (mz == NULL) {
-		RTE_LOG(ERR, MBUF, "Failed to get mbuf dyn shared memory\n");
+		MBUF_LOG(ERR, "Failed to get mbuf dyn shared memory");
 		return -1;
 	}
 
@@ -315,7 +317,8 @@ __rte_mbuf_dynfield_register_offset(const struct rte_mbuf_dynfield *params,
 		shm->free_space[i] = 0;
 	process_score();
 
-	RTE_LOG(DEBUG, MBUF, "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd\n",
+	MBUF_LOG(DEBUG,
+		 "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd",
 		params->name, params->size, params->align, params->flags,
 		offset);
 
@@ -489,7 +492,7 @@ __rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params,
 
 	shm->free_flags &= ~(1ULL << bitnum);
 
-	RTE_LOG(DEBUG, MBUF, "Registered dynamic flag %s (fl=0x%x) -> %u\n",
+	MBUF_LOG(DEBUG, "Registered dynamic flag %s (fl=0x%x) -> %u",
 		params->name, params->flags, bitnum);
 
 	return bitnum;
@@ -590,8 +593,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag,
 
 	offset = rte_mbuf_dynfield_register(&field_desc);
 	if (offset < 0) {
-		RTE_LOG(ERR, MBUF,
-			"Failed to register mbuf field for timestamp\n");
+		MBUF_LOG(ERR, "Failed to register mbuf field for timestamp");
 		return -1;
 	}
 	if (field_offset != NULL)
@@ -600,8 +602,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag,
 	strlcpy(flag_desc.name, flag_name, sizeof(flag_desc.name));
 	offset = rte_mbuf_dynflag_register(&flag_desc);
 	if (offset < 0) {
-		RTE_LOG(ERR, MBUF,
-			"Failed to register mbuf flag for %s timestamp\n",
+		MBUF_LOG(ERR, "Failed to register mbuf flag for %s timestamp",
 			direction);
 		return -1;
 	}
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..8ec2710dc86d 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
@@ -31,8 +33,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 		return 0;
 	}
 
-	RTE_LOG(ERR, MBUF,
-		"%s is already registered as platform mbuf pool ops\n",
+	MBUF_LOG(ERR, "%s is already registered as platform mbuf pool ops",
 		(char *)mz->addr);
 	return -EEXIST;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 05/16] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 04/16] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 06/16] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
                     ` (10 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             |  3 ++-
 lib/acl/acl_bld.c               | 35 +++++++++++++++++----------------
 lib/acl/acl_gen.c               | 20 ++++++++++---------
 lib/acl/acl_log.h               | 13 ++++++++++++
 lib/acl/rte_acl.c               | 14 ++++++++-----
 lib/acl/tb_mem.c                |  8 ++++++--
 lib/eal/common/eal_common_log.c |  2 --
 lib/eal/include/rte_log.h       |  4 ++--
 8 files changed, 61 insertions(+), 38 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..143564151e29 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
@@ -1014,8 +1015,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
 				break;
 
 			default:
-				RTE_LOG(ERR, ACL,
-					"Error in rule[%u] type - %hhu\n",
+				ACL_LOG(ERR,
+					"Error in rule[%u] type - %hhu",
 					rule->f->data.userdata,
 					rule->config->defs[n].type);
 				return NULL;
@@ -1371,7 +1372,7 @@ acl_build_tries(struct acl_build_context *context,
 
 		last = build_one_trie(context, rule_sets, n, context->node_max);
 		if (context->bld_tries[n].trie == NULL) {
-			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
+			ACL_LOG(ERR, "Build of %u-th trie failed", n);
 			return -ENOMEM;
 		}
 
@@ -1380,8 +1381,7 @@ acl_build_tries(struct acl_build_context *context,
 			break;
 
 		if (num_tries == RTE_DIM(context->tries)) {
-			RTE_LOG(ERR, ACL,
-				"Exceeded max number of tries: %u\n",
+			ACL_LOG(ERR, "Exceeded max number of tries: %u",
 				num_tries);
 			return -ENOMEM;
 		}
@@ -1406,7 +1406,7 @@ acl_build_tries(struct acl_build_context *context,
 		 */
 		last = build_one_trie(context, rule_sets, n, INT32_MAX);
 		if (context->bld_tries[n].trie == NULL || last != NULL) {
-			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
+			ACL_LOG(ERR, "Build of %u-th trie failed", n);
 			return -ENOMEM;
 		}
 
@@ -1421,10 +1421,11 @@ acl_build_log(const struct acl_build_context *ctx)
 {
 	uint32_t n;
 
-	RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n"
+	ACL_LOG(DEBUG,
+		"Build phase for ACL \"%s\":\n"
 		"node limit for tree split: %u\n"
 		"nodes created: %u\n"
-		"memory consumed: %zu\n",
+		"memory consumed: %zu",
 		ctx->acx->name,
 		ctx->node_max,
 		ctx->num_nodes,
@@ -1432,7 +1433,7 @@ acl_build_log(const struct acl_build_context *ctx)
 
 	for (n = 0; n < RTE_DIM(ctx->tries); n++) {
 		if (ctx->tries[n].count != 0)
-			RTE_LOG(DEBUG, ACL,
+			ACL_LOG(DEBUG,
 				"trie %u: number of rules: %u, indexes: %u\n",
 				n, ctx->tries[n].count,
 				ctx->tries[n].num_data_indexes);
@@ -1523,8 +1524,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
 
 	/* build phase runs out of memory. */
 	if (rc != 0) {
-		RTE_LOG(ERR, ACL,
-			"ACL context: %s, %s() failed with error code: %d\n",
+		ACL_LOG(ERR,
+			"ACL context: %s, %s() failed with error code: %d",
 			bcx->acx->name, __func__, rc);
 		return rc;
 	}
@@ -1565,9 +1566,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 
 	for (i = 0; i != cfg->num_fields; i++) {
 		if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) {
-			RTE_LOG(ERR, ACL,
-			"ACL context: %s, invalid type: %hhu for %u-th field\n",
-			ctx->name, cfg->defs[i].type, i);
+			ACL_LOG(ERR,
+				"ACL context: %s, invalid type: %hhu for %u-th field",
+				ctx->name, cfg->defs[i].type, i);
 			return -EINVAL;
 		}
 		for (j = 0;
@@ -1577,9 +1578,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
 			;
 
 		if (j == RTE_DIM(field_sizes)) {
-			RTE_LOG(ERR, ACL,
-			"ACL context: %s, invalid size: %hhu for %u-th field\n",
-			ctx->name, cfg->defs[i].size, i);
+			ACL_LOG(ERR,
+				"ACL context: %s, invalid size: %hhu for %u-th field\n",
+				ctx->name, cfg->defs[i].size, i);
 			return -EINVAL;
 		}
 	}
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..84369b103947 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
@@ -32,18 +33,19 @@ struct rte_acl_indices {
 
 static void
 acl_gen_log_stats(const struct rte_acl_ctx *ctx,
-	const struct acl_node_counters *counts,
-	const struct rte_acl_indices *indices,
-	size_t max_size)
+		  const struct acl_node_counters *counts,
+		  const struct rte_acl_indices *indices,
+		  size_t max_size)
 {
-	RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n"
+	ACL_LOG(DEBUG,
+		"Gen phase for ACL \"%s\":\n"
 		"runtime memory footprint on socket %d:\n"
 		"single nodes/bytes used: %d/%zu\n"
 		"quad nodes/vectors/bytes used: %d/%d/%zu\n"
 		"DFA nodes/group64/bytes used: %d/%d/%zu\n"
 		"match nodes/bytes used: %d/%zu\n"
 		"total: %zu bytes\n"
-		"max limit: %zu bytes\n",
+		"max limit: %zu bytes",
 		ctx->name, ctx->socket_id,
 		counts->single, counts->single * sizeof(uint64_t),
 		counts->quad, counts->quad_vectors,
@@ -470,9 +472,9 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
 		XMM_SIZE;
 
 	if (total_size > max_size) {
-		RTE_LOG(DEBUG, ACL,
+		ACL_LOG(DEBUG,
 			"Gen phase for ACL ctx \"%s\" exceeds max_size limit, "
-			"bytes required: %zu, allowed: %zu\n",
+			"bytes required: %zu, allowed: %zu",
 			ctx->name, total_size, max_size);
 		return -ERANGE;
 	}
@@ -480,8 +482,8 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie,
 	mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE,
 			ctx->socket_id);
 	if (mem == NULL) {
-		RTE_LOG(ERR, ACL,
-			"allocation of %zu bytes on socket %d for %s failed\n",
+		ACL_LOG(ERR,
+			"allocation of %zu bytes on socket %d for %s failed",
 			total_size, ctx->socket_id, ctx->name);
 		return -ENOMEM;
 	}
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..4d5adf965cd2
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#ifndef	_ACL_LOG_H_
+#define	_ACL_LOG_H_
+
+extern int acl_logtype;
+#define ACL_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, acl_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+#endif /* _ACL_LOG_H_ */
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..5c8a9cd2f693 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,10 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
@@ -400,15 +402,15 @@ rte_acl_create(const struct rte_acl_param *param)
 		te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
 
 		if (te == NULL) {
-			RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
+			ACL_LOG(ERR, "Cannot allocate tailq entry!");
 			goto exit;
 		}
 
 		ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id);
 
 		if (ctx == NULL) {
-			RTE_LOG(ERR, ACL,
-				"allocation of %zu bytes on socket %d for %s failed\n",
+			ACL_LOG(ERR,
+				"allocation of %zu bytes on socket %d for %s failed",
 				sz, param->socket_id, name);
 			rte_free(te);
 			goto exit;
@@ -474,8 +476,8 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules,
 			((uintptr_t)rules + i * ctx->rule_sz);
 		rc = acl_check_rule(&rv->data);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n",
-				__func__, ctx->name, i + 1);
+			ACL_LOG(ERR, "%s: rule #%u is invalid",
+				ctx->name, i + 1);
 			return rc;
 		}
 	}
@@ -544,3 +546,5 @@ rte_acl_list_dump(void)
 	}
 	rte_mcfg_tailq_read_unlock();
 }
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..74a12159b868 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,9 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
+
+#include <rte_log.h>
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,8 +28,9 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
-			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
+		ACL_LOG(ERR,
+			"allocation size %zu failed, currently allocated by pool: %zu bytes\n",
+			sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
 	}
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 128bfabd94e1..871f2c38298c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1f259b2abc5a..d707098b6359 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 06/16] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 05/16] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 07/16] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (9 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c    |   1 -
 lib/eal/include/rte_log.h          |   2 +-
 lib/power/guest_channel.c          |  48 +++++----
 lib/power/power_acpi_cpufreq.c     | 118 ++++++++++----------
 lib/power/power_common.c           |  11 +-
 lib/power/power_common.h           |   7 +-
 lib/power/power_cppc_cpufreq.c     | 129 +++++++++++-----------
 lib/power/power_kvm_vm.c           |  24 +++--
 lib/power/power_pstate_cpufreq.c   | 166 ++++++++++++++++-------------
 lib/power/rte_power.c              |  25 +++--
 lib/power/rte_power_empty_poll.c   |  36 +++----
 lib/power/rte_power_intel_uncore.c |  75 ++++++-------
 lib/power/rte_power_pmd_mgmt.c     |  37 ++++---
 13 files changed, 365 insertions(+), 314 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 871f2c38298c..7dbf1df3b979 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index d707098b6359..5b7850af4e2b 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..ad59d60f5d94 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,11 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+
+#define GUEST_LOG(level, fmt, args...)				\
+	rte_log(RTE_LOG_ ## level, guest_channel_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
@@ -58,38 +62,38 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
 	int fd = -1;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 	/* check if path is already open */
 	if (global_fds[lcore_id] != -1) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is already open with fd %d\n",
+		GUEST_LOG(ERR, "Channel(%u) is already open with fd %d",
 				lcore_id, global_fds[lcore_id]);
 		return -1;
 	}
 
 	snprintf(fd_path, PATH_MAX, "%s.%u", path, lcore_id);
-	RTE_LOG(INFO, GUEST_CHANNEL, "Opening channel '%s' for lcore %u\n",
+	GUEST_LOG(INFO, "Opening channel '%s' for lcore %u",
 			fd_path, lcore_id);
 	fd = open(fd_path, O_RDWR);
 	if (fd < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Unable to to connect to '%s' with error "
-				"%s\n", fd_path, strerror(errno));
+		GUEST_LOG(ERR, "Unable to connect to '%s' with error %s",
+			  fd_path, strerror(errno));
 		return -1;
 	}
 
 	flags = fcntl(fd, F_GETFL, 0);
 	if (flags < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Failed on fcntl get flags for file %s\n",
+		GUEST_LOG(ERR, "Failed on fcntl get flags for file %s",
 				fd_path);
 		goto error;
 	}
 
 	flags |= O_NONBLOCK;
 	if (fcntl(fd, F_SETFL, flags) < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Failed on setting non-blocking mode for "
-				"file %s", fd_path);
+		GUEST_LOG(ERR, "Failed on setting non-blocking mode for file %s",
+			  fd_path);
 		goto error;
 	}
 	/* QEMU needs a delay after connection */
@@ -102,13 +106,13 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
 	global_fds[lcore_id] = fd;
 	ret = guest_channel_send_msg(&pkt, lcore_id);
 	if (ret != 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL,
-				"Error on channel '%s' communications test: %s\n",
-				fd_path, ret > 0 ? strerror(ret) :
-				"channel not connected");
+		GUEST_LOG(ERR,
+			  "Error on channel '%s' communications test: %s",
+			  fd_path, ret > 0 ? strerror(ret) :
+			  "channel not connected");
 		goto error;
 	}
-	RTE_LOG(INFO, GUEST_CHANNEL, "Channel '%s' is now connected\n", fd_path);
+	GUEST_LOG(INFO, "Channel '%s' is now connected", fd_path);
 	return 0;
 error:
 	close(fd);
@@ -124,13 +128,13 @@ guest_channel_send_msg(struct rte_power_channel_packet *pkt,
 	void *buffer = pkt;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 
 	if (global_fds[lcore_id] < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
+		GUEST_LOG(ERR, "Channel is not connected");
 		return -1;
 	}
 	while (buffer_len > 0) {
@@ -165,13 +169,13 @@ int power_guest_channel_read_msg(void *pkt,
 		return -1;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
 
 	if (global_fds[lcore_id] < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
+		GUEST_LOG(ERR, "Channel is not connected");
 		return -1;
 	}
 
@@ -180,10 +184,10 @@ int power_guest_channel_read_msg(void *pkt,
 
 	ret = poll(&fds, 1, TIMEOUT);
 	if (ret == 0) {
-		RTE_LOG(DEBUG, GUEST_CHANNEL, "Timeout occurred during poll function.\n");
+		GUEST_LOG(DEBUG, "Timeout occurred during poll function.");
 		return -1;
 	} else if (ret < 0) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n",
+		GUEST_LOG(ERR, "Error occurred during poll function: %s",
 				strerror(errno));
 		return -1;
 	}
@@ -199,7 +203,7 @@ int power_guest_channel_read_msg(void *pkt,
 		}
 
 		if (ret == 0) {
-			RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n");
+			GUEST_LOG(ERR, "Expected more data, but connection has been closed.");
 			return -1;
 		}
 		pkt = (char *)pkt + ret;
@@ -220,7 +224,7 @@ void
 guest_channel_host_disconnect(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
+		GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return;
 	}
diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c
index 6e57aca53513..3643044d9ef0 100644
--- a/lib/power/power_acpi_cpufreq.c
+++ b/lib/power/power_acpi_cpufreq.c
@@ -62,8 +62,9 @@ static int
 set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
 {
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -74,13 +75,15 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
 	POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n",
 			idx, pi->freqs[idx], pi->lcore_id);
 	if (fseek(pi->f, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-				"lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to write new frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	fflush(pi->f);
@@ -126,14 +129,14 @@ power_get_available_freqs(struct acpi_power_info *pi)
 
 	open_core_sysfs_file(&f, "r", POWER_SYSFILE_AVAIL_FREQ, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_AVAIL_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if ((ret) < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_AVAIL_FREQ);
 		goto out;
 	}
@@ -142,12 +145,13 @@ power_get_available_freqs(struct acpi_power_info *pi)
 	count = rte_strsplit(buf, sizeof(buf), freqs,
 			RTE_MAX_LCORE_FREQS, ' ');
 	if (count <= 0) {
-		RTE_LOG(ERR, POWER, "No available frequency in "
-				""POWER_SYSFILE_AVAIL_FREQ"\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "No available frequency in " POWER_SYSFILE_AVAIL_FREQ,
+			  pi->lcore_id);
 		goto out;
 	}
 	if (count >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n",
+		POWER_LOG(ERR, "Too many available frequencies : %d",
 				count);
 		goto out;
 	}
@@ -195,14 +199,14 @@ power_init_for_setting_freq(struct acpi_power_info *pi)
 
 	open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "Failed to open %s\n",
+		POWER_LOG(ERR, "Failed to open %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if ((ret) < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
@@ -236,7 +240,7 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -252,42 +256,47 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_userspace(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"userspace\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set governor of lcore %u to userspace",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -309,7 +318,7 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -324,8 +333,8 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used", lcore_id);
 		return -1;
 	}
 
@@ -335,14 +344,15 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'userspace' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'userspace' mode and been set back to the original",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -363,18 +373,18 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -386,7 +396,7 @@ uint32_t
 power_acpi_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -397,7 +407,7 @@ int
 power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -410,7 +420,7 @@ power_acpi_cpufreq_freq_down(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -428,7 +438,7 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -445,7 +455,7 @@ int
 power_acpi_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -469,7 +479,7 @@ power_acpi_cpufreq_freq_min(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -486,7 +496,7 @@ power_acpi_turbo_status(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -502,7 +512,7 @@ power_acpi_enable_turbo(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -512,16 +522,16 @@ power_acpi_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
+		POWER_LOG(ERR,
+			"Failed to enable turbo on lcore %u",
 			lcore_id);
 			return -1;
 	}
 
 	/* Max may have changed, so call to max function */
 	if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER,
-			"Failed to set frequency of lcore %u to max\n",
+		POWER_LOG(ERR,
+			"Failed to set frequency of lcore %u to max",
 			lcore_id);
 			return -1;
 	}
@@ -535,7 +545,7 @@ power_acpi_disable_turbo(unsigned int lcore_id)
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -546,8 +556,8 @@ power_acpi_disable_turbo(unsigned int lcore_id)
 	if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -562,11 +572,11 @@ int power_acpi_get_capabilities(unsigned int lcore_id,
 	struct acpi_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..3a374f6b8431 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -161,14 +161,14 @@ power_set_governor(unsigned int lcore_id, const char *new_governor,
 	open_core_sysfs_file(&f_governor, "rw+", POWER_SYSFILE_GOVERNOR,
 			lcore_id);
 	if (f_governor == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
 
 	ret = read_core_sysfs_s(f_governor, buf, sizeof(buf));
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
@@ -188,14 +188,15 @@ power_set_governor(unsigned int lcore_id, const char *new_governor,
 	/* Write the new governor */
 	ret = write_core_sysfs_s(f_governor, new_governor);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to write %s\n",
+		POWER_LOG(ERR, "Failed to write %s",
 				POWER_SYSFILE_GOVERNOR);
 		goto out;
 	}
 
 	ret = 0;
-	RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been "
-			"set to '%s' successfully\n", lcore_id, new_governor);
+	POWER_LOG(INFO,
+		  "Power management governor of lcore %u has been set to '%s' successfully",
+		  lcore_id, new_governor);
 out:
 	if (f_governor != NULL)
 		fclose(f_governor);
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..8e5309bbbaff 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -10,10 +10,15 @@
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+
+#define POWER_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, power_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
-		RTE_LOG(ERR, POWER, "%s: " fmt, __func__, ## args)
+	POWER_LOG(ERR, fmt, ## args)
 #else
 #define POWER_DEBUG_TRACE(fmt, args...)
 #endif
diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c
index fc9cffef91a8..7ffda90ce7a7 100644
--- a/lib/power/power_cppc_cpufreq.c
+++ b/lib/power/power_cppc_cpufreq.c
@@ -72,8 +72,9 @@ static int
 set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
 {
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -84,13 +85,15 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
 	POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n",
 			idx, pi->freqs[idx], pi->lcore_id);
 	if (fseek(pi->f, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-			"for setting frequency for lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-				"lcore %u\n", pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to write new frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 	fflush(pi->f);
@@ -121,7 +124,7 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_HIGHEST_PERF,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_HIGHEST_PERF);
 		goto err;
 	}
@@ -129,7 +132,7 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_nom, "r", POWER_SYSFILE_NOMINAL_PERF,
 			pi->lcore_id);
 	if (f_nom == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_NOMINAL_PERF);
 		goto err;
 	}
@@ -137,28 +140,28 @@ power_check_turbo(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_cmax, "r", POWER_SYSFILE_SYS_MAX,
 			pi->lcore_id);
 	if (f_cmax == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SYS_MAX);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_max, &highest_perf);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_HIGHEST_PERF);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_nom, &nominal_perf);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_NOMINAL_PERF);
 		goto err;
 	}
 
 	ret = read_core_sysfs_u32(f_cmax, &cpuinfo_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SYS_MAX);
 		goto err;
 	}
@@ -208,7 +211,7 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_SCALING_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SCALING_MAX_FREQ);
 		goto out;
 	}
@@ -216,21 +219,21 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_SCALING_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SCALING_MIN_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_max, &scaling_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SCALING_MAX_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_min, &scaling_min_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SCALING_MIN_FREQ);
 		goto out;
 	}
@@ -248,7 +251,7 @@ power_get_available_freqs(struct cppc_power_info *pi)
 	num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 +
 		pi->turbo_available;
 	if (num_freqs >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available frequencies: %d",
 				num_freqs);
 		goto out;
 	}
@@ -289,14 +292,14 @@ power_init_for_setting_freq(struct cppc_power_info *pi)
 
 	open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
 
 	ret = read_core_sysfs_s(f, buf, sizeof(buf));
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_SETSPEED);
 		goto err;
 	}
@@ -340,7 +343,7 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -356,42 +359,46 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_userspace(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"userspace\n", lcore_id);
+		POWER_LOG(ERR, "Cannot set governor of lcore %u to userspace",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 
 	__atomic_store_n(&(pi->state), POWER_USED, __ATOMIC_RELEASE);
 
@@ -419,7 +426,7 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -434,8 +441,9 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used",
+			  lcore_id);
 		return -1;
 	}
 
@@ -445,14 +453,15 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'userspace' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'userspace' mode and been set back to the original",
+		  lcore_id);
 	__atomic_store_n(&(pi->state), POWER_IDLE, __ATOMIC_RELEASE);
 
 	return 0;
@@ -469,18 +478,18 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -492,7 +501,7 @@ uint32_t
 power_cppc_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -503,7 +512,7 @@ int
 power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -516,7 +525,7 @@ power_cppc_cpufreq_freq_down(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -534,7 +543,7 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -551,7 +560,7 @@ int
 power_cppc_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -575,7 +584,7 @@ power_cppc_cpufreq_freq_min(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -591,7 +600,7 @@ power_cppc_turbo_status(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -606,7 +615,7 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -616,8 +625,8 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
+		POWER_LOG(ERR,
+			"Failed to enable turbo on lcore %u",
 			lcore_id);
 		return -1;
 	}
@@ -627,8 +636,8 @@ power_cppc_enable_turbo(unsigned int lcore_id)
 	 */
 	/* Max may have changed, so call to max function */
 	if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER,
-			"Failed to set frequency of lcore %u to max\n",
+		POWER_LOG(ERR,
+			"Failed to set frequency of lcore %u to max",
 			lcore_id);
 		return -1;
 	}
@@ -642,7 +651,7 @@ power_cppc_disable_turbo(unsigned int lcore_id)
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -653,8 +662,8 @@ power_cppc_disable_turbo(unsigned int lcore_id)
 	if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -670,11 +679,11 @@ power_cppc_get_capabilities(unsigned int lcore_id,
 	struct cppc_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..74a1094ffaa0 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -24,7 +25,7 @@ int
 power_kvm_vm_init(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+		POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
@@ -45,16 +46,16 @@ power_kvm_vm_freqs(__rte_unused unsigned int lcore_id,
 		__rte_unused uint32_t *freqs,
 		__rte_unused uint32_t num)
 {
-	RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
 uint32_t
 power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id)
 {
-	RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -62,8 +63,8 @@ int
 power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id,
 		__rte_unused uint32_t index)
 {
-	RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
-			"for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -73,7 +74,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 	int ret;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+		POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
 				lcore_id, RTE_MAX_LCORE-1);
 		return -1;
 	}
@@ -81,7 +82,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 	ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
 	if (ret == 0)
 		return 1;
-	RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
+	POWER_LOG(DEBUG, "Error sending message: %s",
 			ret > 0 ? strerror(ret) : "channel not connected");
 	return -1;
 }
@@ -113,7 +114,7 @@ power_kvm_vm_freq_min(unsigned int lcore_id)
 int
 power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id)
 {
-	RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
+	POWER_LOG(ERR, "rte_power_turbo_status is not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
 
@@ -133,6 +134,7 @@ struct rte_power_core_capabilities;
 int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,
 		__rte_unused struct rte_power_core_capabilities *caps)
 {
-	RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n");
+	POWER_LOG(ERR,
+		  "rte_power_get_capabilities is not implemented for Virtual Machine Power Management");
 	return -ENOTSUP;
 }
diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index 52aa64510e21..c6869bbd3c59 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -81,7 +81,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	fd = open(POWER_SYSFILE_TURBO_PCT, O_RDONLY);
 
 	if (fd < 0) {
-		RTE_LOG(ERR, POWER, "Error opening '%s': %s\n", POWER_SYSFILE_TURBO_PCT,
+		POWER_LOG(ERR, "Error opening '%s': %s", POWER_SYSFILE_TURBO_PCT,
 				 strerror(errno));
 		return fd;
 	}
@@ -89,7 +89,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	ret = read(fd, val, sizeof(val));
 
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Error reading '%s': %s\n", POWER_SYSFILE_TURBO_PCT,
+		POWER_LOG(ERR, "Error reading '%s': %s", POWER_SYSFILE_TURBO_PCT,
 				 strerror(errno));
 		goto out;
 	}
@@ -97,7 +97,7 @@ power_read_turbo_pct(uint64_t *outVal)
 	errno = 0;
 	*outVal = (uint64_t) strtol(val, &endptr, 10);
 	if (errno != 0 || (*endptr != 0 && *endptr != '\n')) {
-		RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n",
+		POWER_LOG(ERR, "Error converting str to digits, read from %s: %s",
 				 POWER_SYSFILE_TURBO_PCT, strerror(errno));
 		ret = -1;
 		goto out;
@@ -125,7 +125,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_base_max, "r", POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_base_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -133,7 +133,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_base_min, "r", POWER_SYSFILE_BASE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_base_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
@@ -141,7 +141,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_min, "rw+", POWER_SYSFILE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_MIN_FREQ);
 		goto err;
 	}
@@ -149,7 +149,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_max, "rw+", POWER_SYSFILE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_MAX_FREQ);
 		goto err;
 	}
@@ -161,7 +161,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	/* read base max ratio */
 	ret = read_core_sysfs_u32(f_base_max, &base_max_ratio);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -169,7 +169,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	/* read base min ratio */
 	ret = read_core_sysfs_u32(f_base_min, &base_min_ratio);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
@@ -178,7 +178,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
 	if (f_base != NULL) {
 		ret = read_core_sysfs_u32(f_base, &base_ratio);
 		if (ret < 0) {
-			RTE_LOG(ERR, POWER, "Failed to read %s\n",
+			POWER_LOG(ERR, "Failed to read %s",
 					POWER_SYSFILE_BASE_FREQ);
 			goto err;
 		}
@@ -256,8 +256,9 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	uint32_t target_freq = 0;
 
 	if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Invalid frequency index %u, which "
-				"should be less than %u\n", idx, pi->nb_freqs);
+		POWER_LOG(ERR,
+			  "Invalid frequency index %u, which should be less than %u",
+			  idx, pi->nb_freqs);
 		return -1;
 	}
 
@@ -269,16 +270,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	 * User need change the min/max as same value.
 	 */
 	if (fseek(pi->f_cur_min, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n",
-				pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 
 	if (fseek(pi->f_cur_max, 0, SEEK_SET) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 "
-				"for setting frequency for lcore %u\n",
-				pi->lcore_id);
+		POWER_LOG(ERR,
+			  "Fail to set file position indicator to 0 for setting frequency for lcore %u",
+			  pi->lcore_id);
 		return -1;
 	}
 
@@ -287,7 +288,8 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 		if (pi->turbo_enable)
 			target_freq = pi->sys_max_freq;
 		else {
-			RTE_LOG(ERR, POWER, "Turbo is off, frequency can't be scaled up more %u\n",
+			POWER_LOG(ERR,
+				  "Turbo is off, frequency can't be scaled up more %u",
 					pi->lcore_id);
 			return -1;
 		}
@@ -298,14 +300,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	if (idx  >  pi->curr_idx) {
 
 		if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
 		if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
@@ -321,14 +325,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx)
 	if (idx  <  pi->curr_idx) {
 
 		if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
 		if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) {
-			RTE_LOG(ERR, POWER, "Fail to write new frequency for "
-					"lcore %u\n", pi->lcore_id);
+			POWER_LOG(ERR,
+				  "Fail to write new frequency for lcore %u",
+				  pi->lcore_id);
 			return -1;
 		}
 
@@ -383,7 +389,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_BASE_MAX_FREQ,
 			pi->lcore_id);
 	if (f_max == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto out;
 	}
@@ -391,7 +397,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_BASE_MIN_FREQ,
 			pi->lcore_id);
 	if (f_min == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto out;
 	}
@@ -399,14 +405,14 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	/* read base ratios */
 	ret = read_core_sysfs_u32(f_max, &sys_max_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MAX_FREQ);
 		goto out;
 	}
 
 	ret = read_core_sysfs_u32(f_min, &sys_min_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_BASE_MIN_FREQ);
 		goto out;
 	}
@@ -449,7 +455,7 @@ power_get_available_freqs(struct pstate_power_info *pi)
 	num_freqs = (RTE_MIN(base_max_freq, sys_max_freq) - sys_min_freq) / BUS_FREQ
 			+ 1 + pi->turbo_available;
 	if (num_freqs >= RTE_MAX_LCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available frequencies: %d",
 				num_freqs);
 		goto out;
 	}
@@ -493,14 +499,14 @@ power_get_cur_idx(struct pstate_power_info *pi)
 	open_core_sysfs_file(&f_cur, "r", POWER_SYSFILE_CUR_FREQ,
 			pi->lcore_id);
 	if (f_cur == NULL) {
-		RTE_LOG(ERR, POWER, "failed to open %s\n",
+		POWER_LOG(ERR, "failed to open %s",
 				POWER_SYSFILE_CUR_FREQ);
 		goto fail;
 	}
 
 	ret = read_core_sysfs_u32(f_cur, &sys_cur_freq);
 	if (ret < 0) {
-		RTE_LOG(ERR, POWER, "Failed to read %s\n",
+		POWER_LOG(ERR, "Failed to read %s",
 				POWER_SYSFILE_CUR_FREQ);
 		goto fail;
 	}
@@ -542,7 +548,7 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceed %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceed %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -558,47 +564,52 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"in use\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is in use", lcore_id);
 		return -1;
 	}
 
 	pi->lcore_id = lcore_id;
 	/* Check and set the governor */
 	if (power_set_governor_performance(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
-				"performance\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set governor of lcore %u to performance",
+			  lcore_id);
 		goto fail;
 	}
 	/* Init for setting lcore frequency */
 	if (power_init_for_setting_freq(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot init for setting frequency for lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_freqs(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
-				"lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get available frequencies of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	if (power_get_cur_idx(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot get current frequency "
-				"index of lcore %u\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot get current frequency index of lcore %u",
+			  lcore_id);
 		goto fail;
 	}
 
 	/* Set freq to max by default */
 	if (power_pstate_cpufreq_freq_max(lcore_id) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
-				"to max\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set frequency of lcore %u to max", lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
-			"power management\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Initialized successfully for lcore %u power management",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -620,7 +631,7 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 	uint32_t exp_state;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
+		POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
 				lcore_id, RTE_MAX_LCORE - 1U);
 		return -1;
 	}
@@ -636,8 +647,8 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 	if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
 					POWER_ONGOING, 0,
 					__ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
-		RTE_LOG(INFO, POWER, "Power management of lcore %u is "
-				"not used\n", lcore_id);
+		POWER_LOG(INFO,
+			  "Power management of lcore %u is not used", lcore_id);
 		return -1;
 	}
 
@@ -649,14 +660,15 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
 
 	/* Set the governor back to the original */
 	if (power_set_governor_original(pi) < 0) {
-		RTE_LOG(ERR, POWER, "Cannot set the governor of %u back "
-				"to the original\n", lcore_id);
+		POWER_LOG(ERR,
+			  "Cannot set the governor of %u back to the original",
+			  lcore_id);
 		goto fail;
 	}
 
-	RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
-			"'performance' mode and been set back to the "
-			"original\n", lcore_id);
+	POWER_LOG(INFO,
+		  "Power management of lcore %u has exited from 'performance' mode and been set back to the original",
+		  lcore_id);
 	exp_state = POWER_ONGOING;
 	__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
 				    0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
@@ -678,18 +690,18 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return 0;
 	}
 
 	if (freqs == NULL) {
-		RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
+		POWER_LOG(ERR, "NULL buffer supplied");
 		return 0;
 	}
 
 	pi = &lcore_power_info[lcore_id];
 	if (num < pi->nb_freqs) {
-		RTE_LOG(ERR, POWER, "Buffer size is not enough\n");
+		POWER_LOG(ERR, "Buffer size is not enough");
 		return 0;
 	}
 	rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t));
@@ -701,7 +713,7 @@ uint32_t
 power_pstate_cpufreq_get_freq(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return RTE_POWER_INVALID_FREQ_INDEX;
 	}
 
@@ -713,7 +725,7 @@ int
 power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -726,7 +738,7 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -745,7 +757,7 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -761,7 +773,7 @@ int
 power_pstate_cpufreq_freq_max(unsigned int lcore_id)
 {
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -786,7 +798,7 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -803,7 +815,7 @@ power_pstate_turbo_status(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -818,7 +830,7 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -828,10 +840,10 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 		pi->turbo_enable = 1;
 	else {
 		pi->turbo_enable = 0;
-		RTE_LOG(ERR, POWER,
-			"Failed to enable turbo on lcore %u\n",
-			lcore_id);
-			return -1;
+		POWER_LOG(ERR,
+			  "Failed to enable turbo on lcore %u",
+			  lcore_id);
+		return -1;
 	}
 
 	return 0;
@@ -844,7 +856,7 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 
@@ -855,8 +867,8 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 	if (pi->turbo_available && pi->curr_idx <= 1) {
 		/* Try to set freq to max by default coming out of turbo */
 		if (power_pstate_cpufreq_freq_max(lcore_id) < 0) {
-			RTE_LOG(ERR, POWER,
-				"Failed to set frequency of lcore %u to max\n",
+			POWER_LOG(ERR,
+				"Failed to set frequency of lcore %u to max",
 				lcore_id);
 			return -1;
 		}
@@ -872,11 +884,11 @@ int power_pstate_get_capabilities(unsigned int lcore_id,
 	struct pstate_power_info *pi;
 
 	if (lcore_id >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+		POWER_LOG(ERR, "Invalid lcore ID");
 		return -1;
 	}
 	if (caps == NULL) {
-		RTE_LOG(ERR, POWER, "Invalid argument\n");
+		POWER_LOG(ERR, "Invalid argument");
 		return -1;
 	}
 
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..23a97fa77f53 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
@@ -70,7 +71,7 @@ rte_power_set_env(enum power_management_env env)
 	rte_spinlock_lock(&global_env_cfg_lock);
 
 	if (global_default_env != PM_ENV_NOT_SET) {
-		RTE_LOG(ERR, POWER, "Power Management Environment already set.\n");
+		POWER_LOG(ERR, "Power Management Environment already set.");
 		rte_spinlock_unlock(&global_env_cfg_lock);
 		return -1;
 	}
@@ -127,7 +128,7 @@ rte_power_set_env(enum power_management_env env)
 		rte_power_freq_disable_turbo = power_cppc_disable_turbo;
 		rte_power_get_capabilities = power_cppc_get_capabilities;
 	} else {
-		RTE_LOG(ERR, POWER, "Invalid Power Management Environment(%d) set\n",
+		POWER_LOG(ERR, "Invalid Power Management Environment(%d) set",
 				env);
 		ret = -1;
 	}
@@ -172,39 +173,40 @@ rte_power_init(unsigned int lcore_id)
 	case PM_ENV_CPPC_CPUFREQ:
 		return power_cppc_cpufreq_init(lcore_id);
 	default:
-		RTE_LOG(INFO, POWER, "Env isn't set yet!\n");
+		POWER_LOG(INFO, "Env isn't set yet!");
 	}
 
 	/* Auto detect Environment */
-	RTE_LOG(INFO, POWER, "Attempting to initialise ACPI cpufreq power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management...");
 	ret = power_acpi_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise PSTAT power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise PSTAT power management...");
 	ret = power_pstate_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_PSTATE_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise CPPC power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise CPPC power management...");
 	ret = power_cppc_cpufreq_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_CPPC_CPUFREQ);
 		goto out;
 	}
 
-	RTE_LOG(INFO, POWER, "Attempting to initialise VM power management...\n");
+	POWER_LOG(INFO, "Attempting to initialise VM power management...");
 	ret = power_kvm_vm_init(lcore_id);
 	if (ret == 0) {
 		rte_power_set_env(PM_ENV_KVM_VM);
 		goto out;
 	}
-	RTE_LOG(ERR, POWER, "Unable to set Power Management Environment for lcore "
-			"%u\n", lcore_id);
+	POWER_LOG(ERR,
+		  "Unable to set Power Management Environment for lcore %u",
+		  lcore_id);
 out:
 	return ret;
 }
@@ -222,9 +224,12 @@ rte_power_exit(unsigned int lcore_id)
 	case PM_ENV_CPPC_CPUFREQ:
 		return power_cppc_cpufreq_exit(lcore_id);
 	default:
-		RTE_LOG(ERR, POWER, "Environment has not been set, unable to exit gracefully\n");
+		POWER_LOG(ERR,
+			  "Environment has not been set, unable to exit gracefully");
 
 	}
 	return -1;
 
 }
+
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..da4b1ec3068a 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
@@ -75,7 +76,7 @@ enter_normal_state(struct priority_worker *poll_stats)
 	poll_stats->iter_counter = 0;
 	poll_stats->threshold_ctr = 0;
 	poll_stats->queue_state = MED_NORMAL;
-	RTE_LOG(INFO, POWER, "Set the power freq to MED\n");
+	POWER_LOG(INFO, "Set the power freq to MED");
 	set_power_freq(poll_stats->lcore_id, MED, false);
 
 	poll_stats->thresh[MED].threshold_percent = med_to_high_threshold;
@@ -213,11 +214,9 @@ update_stats(struct priority_worker *poll_stats)
 	if (s->thresh[s->cur_freq].base_edpi < cur_edpi) {
 
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "cur_edpi is too large "
-				"cur edpi %"PRId64" "
-				"base edpi %"PRId64"\n",
-				cur_edpi,
-				s->thresh[s->cur_freq].base_edpi);
+		POWER_LOG(DEBUG,
+			  "cur_edpi is too large cur edpi %"PRId64" base edpi %"PRId64,
+			  cur_edpi, s->thresh[s->cur_freq].base_edpi);
 		/* Value to make us fail need debug log*/
 		return 1000UL;
 	}
@@ -247,7 +246,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 		enum freq_val cur_freq = poll_stats->cur_freq;
 
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "cure freq is %d, edpi is %"PRIu64"\n",
+		POWER_LOG(DEBUG, "cure freq is %d, edpi is %"PRIu64"",
 				cur_freq,
 				poll_stats->thresh[cur_freq].base_edpi);
 		return;
@@ -257,12 +256,12 @@ update_stats_normal(struct priority_worker *poll_stats)
 
 	if (percent > 100) {
 		/* edpi mean empty poll counter difference per interval */
-		RTE_LOG(DEBUG, POWER, "Edpi is bigger than threshold\n");
+		POWER_LOG(DEBUG, "Edpi is bigger than threshold");
 		return;
 	}
 
 	if (poll_stats->cur_freq == LOW)
-		RTE_LOG(INFO, POWER, "Purge Mode is not currently supported\n");
+		POWER_LOG(INFO, "Purge Mode is not currently supported");
 	else if (poll_stats->cur_freq == MED) {
 
 		if (percent >
@@ -272,7 +271,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 				poll_stats->threshold_ctr++;
 			else {
 				set_state(poll_stats, HGH_BUSY);
-				RTE_LOG(INFO, POWER, "MOVE to HGH\n");
+				POWER_LOG(INFO, "MOVE to HGH");
 			}
 
 		} else {
@@ -289,7 +288,7 @@ update_stats_normal(struct priority_worker *poll_stats)
 				poll_stats->threshold_ctr++;
 			else {
 				set_state(poll_stats, MED_NORMAL);
-				RTE_LOG(INFO, POWER, "MOVE to MED\n");
+				POWER_LOG(INFO, "MOVE to MED");
 			}
 		} else {
 			/* reset */
@@ -332,17 +331,17 @@ empty_poll_training(struct priority_worker *poll_stats,
 
 		set_state(poll_stats, MED_NORMAL);
 
-		RTE_LOG(INFO, POWER, "LOW threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "LOW threshold is %"PRIu64"",
 				poll_stats->thresh[LOW].base_edpi);
 
-		RTE_LOG(INFO, POWER, "MED threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "MED threshold is %"PRIu64"",
 				poll_stats->thresh[MED].base_edpi);
 
 
-		RTE_LOG(INFO, POWER, "HIGH threshold is %"PRIu64"\n",
+		POWER_LOG(INFO, "HIGH threshold is %"PRIu64"",
 				poll_stats->thresh[HGH].base_edpi);
 
-		RTE_LOG(INFO, POWER, "Training is Complete for %d\n",
+		POWER_LOG(INFO, "Training is Complete for %d",
 				poll_stats->lcore_id);
 	}
 
@@ -414,7 +413,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 		freq_index[HGH] = freq_tlb[HGH];
 	}
 
-	RTE_LOG(INFO, POWER, "Initialize the Empty Poll\n");
+	POWER_LOG(INFO, "Initialize the Empty Poll");
 
 	/* Train for pre-defined period */
 	ep_params->max_train_iter = INTERVALS_PER_SECOND * SECONDS_TO_TRAIN_FOR;
@@ -433,7 +432,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 				avail_freqs[i],
 				NUM_FREQS);
 
-		RTE_LOG(INFO, POWER, "total avail freq is %d , lcoreid %d\n",
+		POWER_LOG(INFO, "total avail freq is %d , lcoreid %d",
 				total_avail_freqs[i],
 				i);
 
@@ -452,8 +451,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
 void
 rte_power_empty_poll_stat_free(void)
 {
-
-	RTE_LOG(INFO, POWER, "Close the Empty Poll\n");
+	POWER_LOG(INFO, "Close the Empty Poll");
 
 	rte_free(ep_params);
 }
diff --git a/lib/power/rte_power_intel_uncore.c b/lib/power/rte_power_intel_uncore.c
index 3b8724385fb7..ee6412a3ed34 100644
--- a/lib/power/rte_power_intel_uncore.c
+++ b/lib/power/rte_power_intel_uncore.c
@@ -52,8 +52,9 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 	int ret;
 
 	if (idx >= MAX_UNCORE_FREQS || idx >= ui->nb_freqs) {
-		RTE_LOG(DEBUG, POWER, "Invalid uncore frequency index %u, which "
-				"should be less than %u\n", idx, ui->nb_freqs);
+		POWER_LOG(DEBUG,
+			  "Invalid uncore frequency index %u, which should be less than %u",
+			  idx, ui->nb_freqs);
 		return -1;
 	}
 
@@ -65,13 +66,13 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 	open_core_sysfs_file(&ui->f_cur_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (ui->f_cur_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		return -1;
 	}
 	ret = read_core_sysfs_u32(ui->f_cur_max, &curr_max_freq);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+		POWER_LOG(DEBUG, "Failed to read %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		fclose(ui->f_cur_max);
 		return -1;
@@ -79,14 +80,16 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx)
 
 	/* check this value first before fprintf value to f_cur_max, so value isn't overwritten */
 	if (fprintf(ui->f_cur_min, "%u", target_uncore_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write new uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
 	if (fprintf(ui->f_cur_max, "%u", target_uncore_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write new uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
@@ -121,13 +124,13 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_base_max, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (f_base_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
 	ret = read_core_sysfs_u32(f_base_max, &base_max_freq);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+		POWER_LOG(DEBUG, "Failed to read %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ);
 		goto err;
 	}
@@ -136,14 +139,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_base_min, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ,
 		ui->pkg, ui->die);
 	if (f_base_min == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ);
 		goto err;
 	}
 	if (f_base_min != NULL) {
 		ret = read_core_sysfs_u32(f_base_min, &base_min_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ);
 			goto err;
 		}
@@ -153,14 +156,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_min, "rw+", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ,
 			ui->pkg, ui->die);
 	if (f_min == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ);
 		goto err;
 	}
 	if (f_min != NULL) {
 		ret = read_core_sysfs_u32(f_min, &min_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ);
 			goto err;
 		}
@@ -170,14 +173,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui)
 	open_core_sysfs_file(&f_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ,
 			ui->pkg, ui->die);
 	if (f_max == NULL) {
-		RTE_LOG(DEBUG, POWER, "failed to open %s\n",
+		POWER_LOG(DEBUG, "failed to open %s",
 				POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 		goto err;
 	}
 	if (f_max != NULL) {
 		ret = read_core_sysfs_u32(f_max, &max_freq);
 		if (ret < 0) {
-			RTE_LOG(DEBUG, POWER, "Failed to read %s\n",
+			POWER_LOG(DEBUG, "Failed to read %s",
 					POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ);
 			goto err;
 		}
@@ -222,7 +225,7 @@ power_get_available_uncore_freqs(struct uncore_power_info *ui)
 
 	num_uncore_freqs = (ui->init_max_freq - ui->init_min_freq) / BUS_FREQ + 1;
 	if (num_uncore_freqs >= MAX_UNCORE_FREQS) {
-		RTE_LOG(ERR, POWER, "Too many available uncore frequencies: %d\n",
+		POWER_LOG(ERR, "Too many available uncore frequencies: %d",
 				num_uncore_freqs);
 		goto out;
 	}
@@ -250,7 +253,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die)
 	if (max_pkgs == 0)
 		return -1;
 	if (pkg >= max_pkgs) {
-		RTE_LOG(DEBUG, POWER, "Package number %02u can not exceed %u\n",
+		POWER_LOG(DEBUG, "Package number %02u can not exceed %u",
 				pkg, max_pkgs);
 		return -1;
 	}
@@ -259,7 +262,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die)
 	if (max_dies == 0)
 		return -1;
 	if (die >= max_dies) {
-		RTE_LOG(DEBUG, POWER, "Die number %02u can not exceed %u\n",
+		POWER_LOG(DEBUG, "Die number %02u can not exceed %u",
 				die, max_dies);
 		return -1;
 	}
@@ -282,15 +285,17 @@ rte_power_uncore_init(unsigned int pkg, unsigned int die)
 
 	/* Init for setting uncore die frequency */
 	if (power_init_for_setting_uncore_freq(ui) < 0) {
-		RTE_LOG(DEBUG, POWER, "Cannot init for setting uncore frequency for "
-				"pkg %02u die %02u\n", pkg, die);
+		POWER_LOG(DEBUG,
+			  "Cannot init for setting uncore frequency for pkg %02u die %02u",
+			  pkg, die);
 		return -1;
 	}
 
 	/* Get the available frequencies */
 	if (power_get_available_uncore_freqs(ui) < 0) {
-		RTE_LOG(DEBUG, POWER, "Cannot get available uncore frequencies of "
-				"pkg %02u die %02u\n", pkg, die);
+		POWER_LOG(DEBUG,
+			  "Cannot get available uncore frequencies of pkg %02u die %02u",
+			  pkg, die);
 		return -1;
 	}
 
@@ -309,14 +314,16 @@ rte_power_uncore_exit(unsigned int pkg, unsigned int die)
 	ui = &uncore_info[pkg][die];
 
 	if (fprintf(ui->f_cur_min, "%u", ui->org_min_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write original uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
 	if (fprintf(ui->f_cur_max, "%u", ui->org_max_freq) < 0) {
-		RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for "
-				"pkg %02u die %02u\n", ui->pkg, ui->die);
+		POWER_LOG(ERR,
+			  "Fail to write original uncore frequency for pkg %02u die %02u",
+			  ui->pkg, ui->die);
 		return -1;
 	}
 
@@ -395,10 +402,8 @@ rte_power_uncore_get_num_pkgs(void)
 
 	d = opendir(INTEL_UNCORE_FREQUENCY_DIR);
 	if (d == NULL) {
-		RTE_LOG(ERR, POWER,
-		"Uncore frequency management not supported/enabled on this kernel. "
-		"Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel"
-		" >= 5.6\n");
+		POWER_LOG(ERR,
+			  "Uncore frequency management not supported/enabled on this kernel");
 		return 0;
 	}
 
@@ -427,16 +432,14 @@ rte_power_uncore_get_num_dies(unsigned int pkg)
 	if (max_pkgs == 0)
 		return 0;
 	if (pkg >= max_pkgs) {
-		RTE_LOG(DEBUG, POWER, "Invalid package number\n");
+		POWER_LOG(DEBUG, "Invalid package number");
 		return 0;
 	}
 
 	d = opendir(INTEL_UNCORE_FREQUENCY_DIR);
 	if (d == NULL) {
-		RTE_LOG(ERR, POWER,
-		"Uncore frequency management not supported/enabled on this kernel. "
-		"Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel"
-		" >= 5.6\n");
+		POWER_LOG(ERR,
+			  "Uncore frequency management not supported/enabled on this kernel");
 		return 0;
 	}
 
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index ca1840387c74..e691e754ccb0 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -146,7 +146,7 @@ get_monitor_addresses(struct pmd_core_cfg *cfg,
 
 		/* attempted out of bounds access */
 		if (i >= len) {
-			RTE_LOG(ERR, POWER, "Too many queues being monitored\n");
+			POWER_LOG(ERR, "Too many queues being monitored");
 			return -1;
 		}
 
@@ -422,7 +422,7 @@ check_scale(unsigned int lcore)
 	/* only PSTATE and ACPI modes are supported */
 	if (!rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ) &&
 	    !rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) {
-		RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes are supported\n");
+		POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes are supported");
 		return -ENOTSUP;
 	}
 	/* ensure we could initialize the power library */
@@ -432,7 +432,7 @@ check_scale(unsigned int lcore)
 	/* ensure we initialized the correct env */
 	env = rte_power_get_env();
 	if (env != PM_ENV_ACPI_CPUFREQ && env != PM_ENV_PSTATE_CPUFREQ) {
-		RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes were initialized\n");
+		POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes were initialized");
 		return -ENOTSUP;
 	}
 
@@ -448,7 +448,7 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata)
 
 	/* check if rte_power_monitor is supported */
 	if (!global_data.intrinsics_support.power_monitor) {
-		RTE_LOG(DEBUG, POWER, "Monitoring intrinsics are not supported\n");
+		POWER_LOG(DEBUG, "Monitoring intrinsics are not supported");
 		return -ENOTSUP;
 	}
 	/* check if multi-monitor is supported */
@@ -457,14 +457,14 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata)
 
 	/* if we're adding a new queue, do we support multiple queues? */
 	if (cfg->n_queues > 0 && !multimonitor_supported) {
-		RTE_LOG(DEBUG, POWER, "Monitoring multiple queues is not supported\n");
+		POWER_LOG(DEBUG, "Monitoring multiple queues is not supported");
 		return -ENOTSUP;
 	}
 
 	/* check if the device supports the necessary PMD API */
 	if (rte_eth_get_monitor_addr(qdata->portid, qdata->qid,
 			&dummy) == -ENOTSUP) {
-		RTE_LOG(DEBUG, POWER, "The device does not support rte_eth_get_monitor_addr\n");
+		POWER_LOG(DEBUG, "The device does not support rte_eth_get_monitor_addr");
 		return -ENOTSUP;
 	}
 
@@ -564,14 +564,14 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
 		clb = clb_pause;
 		break;
 	default:
-		RTE_LOG(DEBUG, POWER, "Invalid power management type\n");
+		POWER_LOG(DEBUG, "Invalid power management type");
 		ret = -EINVAL;
 		goto end;
 	}
 	/* add this queue to the list */
 	ret = queue_list_add(lcore_cfg, &qdata);
 	if (ret < 0) {
-		RTE_LOG(DEBUG, POWER, "Failed to add queue to list: %s\n",
+		POWER_LOG(DEBUG, "Failed to add queue to list: %s",
 				strerror(-ret));
 		goto end;
 	}
@@ -684,7 +684,8 @@ int
 rte_power_pmd_mgmt_set_pause_duration(unsigned int duration)
 {
 	if (duration == 0) {
-		RTE_LOG(ERR, POWER, "Pause duration must be greater than 0, value unchanged");
+		POWER_LOG(ERR,
+			  "Pause duration must be greater than 0, value unchanged");
 		return -EINVAL;
 	}
 	pause_duration = duration;
@@ -702,12 +703,13 @@ int
 rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (min > scale_freq_max[lcore]) {
-		RTE_LOG(ERR, POWER, "Invalid min frequency: Cannot be greater than max frequency");
+		POWER_LOG(ERR,
+			  "Invalid min frequency: Cannot be greater than max frequency");
 		return -EINVAL;
 	}
 	scale_freq_min[lcore] = min;
@@ -719,7 +721,7 @@ int
 rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
@@ -727,7 +729,8 @@ rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
 	if (max == 0)
 		max = UINT32_MAX;
 	if (max < scale_freq_min[lcore]) {
-		RTE_LOG(ERR, POWER, "Invalid max frequency: Cannot be less than min frequency");
+		POWER_LOG(ERR,
+			  "Invalid max frequency: Cannot be less than min frequency");
 		return -EINVAL;
 	}
 
@@ -740,12 +743,12 @@ int
 rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (scale_freq_max[lcore] == 0)
-		RTE_LOG(DEBUG, POWER, "Scaling freq min config not set. Using sysfs min freq.\n");
+		POWER_LOG(DEBUG, "Scaling freq min config not set. Using sysfs min freq.");
 
 	return scale_freq_min[lcore];
 }
@@ -754,12 +757,12 @@ int
 rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore)
 {
 	if (lcore >= RTE_MAX_LCORE) {
-		RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore);
+		POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
 		return -EINVAL;
 	}
 
 	if (scale_freq_max[lcore] == UINT32_MAX) {
-		RTE_LOG(DEBUG, POWER, "Scaling freq max config not set. Using sysfs max freq.\n");
+		POWER_LOG(DEBUG, "Scaling freq max config not set. Using sysfs max freq.");
 		return 0;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 07/16] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 06/16] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 08/16] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (8 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/ring/rte_ring.c             | 31 +++++++++++++++++++------------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7dbf1df3b979..04c9d43351da 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 5b7850af4e2b..a99fe383c89b 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..1b4633468a2a 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,13 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+
+#define RING_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, ring_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
@@ -52,15 +59,15 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
 
 	/* Check if element size is a multiple of 4B */
 	if (esize % 4 != 0) {
-		RTE_LOG(ERR, RING, "element size is not a multiple of 4\n");
+		RING_LOG(ERR, "element size is not a multiple of 4");
 
 		return -EINVAL;
 	}
 
 	/* count must be a power of 2 */
 	if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK )) {
-		RTE_LOG(ERR, RING,
-			"Requested number of elements is invalid, must be power of 2, and not exceed %u\n",
+		RING_LOG(ERR,
+			"Requested number of elements is invalid, must be power of 2, and not exceed %u",
 			RTE_RING_SZ_MASK);
 
 		return -EINVAL;
@@ -195,8 +202,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 
 	/* future proof flags, only allow supported values */
 	if (flags & ~RING_F_MASK) {
-		RTE_LOG(ERR, RING,
-			"Unsupported flags requested %#x\n", flags);
+		RING_LOG(ERR,
+			"Unsupported flags requested %#x", flags);
 		return -EINVAL;
 	}
 
@@ -216,8 +223,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 		r->capacity = count;
 	} else {
 		if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) {
-			RTE_LOG(ERR, RING,
-				"Requested size is invalid, must be power of 2, and not exceed the size limit %u\n",
+			RING_LOG(ERR,
+				"Requested size is invalid, must be power of 2, and not exceed the size limit %u",
 				RTE_RING_SZ_MASK);
 			return -EINVAL;
 		}
@@ -271,7 +278,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count,
 
 	te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n");
+		RING_LOG(ERR, "Cannot reserve memory for tailq");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -295,7 +302,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count,
 		TAILQ_INSERT_TAIL(ring_list, te, next);
 	} else {
 		r = NULL;
-		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
+		RING_LOG(ERR, "Cannot reserve memory");
 		rte_free(te);
 	}
 	rte_mcfg_tailq_write_unlock();
@@ -327,13 +334,13 @@ rte_ring_free(struct rte_ring *r)
 	 * therefore, there is no memzone to free.
 	 */
 	if (r->memzone == NULL) {
-		RTE_LOG(ERR, RING,
-			"Cannot free ring, not created with rte_ring_create()\n");
+		RING_LOG(ERR,
+			 "Cannot free ring, not created with rte_ring_create()");
 		return;
 	}
 
 	if (rte_memzone_free(r->memzone) != 0) {
-		RTE_LOG(ERR, RING, "Cannot free memory\n");
+		RING_LOG(ERR, "Cannot free memory");
 		return;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 08/16] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 07/16] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 09/16] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (7 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/mempool/rte_mempool.c       | 33 ++++++++++++++++++---------------
 lib/mempool/rte_mempool_log.h   | 10 ++++++++++
 lib/mempool/rte_mempool_ops.c   | 12 ++++++------
 5 files changed, 35 insertions(+), 23 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 04c9d43351da..90d388192712 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a99fe383c89b..f583352ec1ea 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..911a2b4dd850 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
@@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id)
 	cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache),
 				  RTE_CACHE_LINE_SIZE, socket_id);
 	if (cache == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate mempool cache.");
 		rte_errno = ENOMEM;
 		return NULL;
 	}
@@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	/* try to allocate tailq entry */
 	te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!");
 		goto exit_unlock;
 	}
 
@@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp,
 
 		if (free == 0) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-					obj, (const void *) mp, cookie);
+				MEMPOOL_LOG(CRIT,
+					    "obj=%p, mempool=%p, cookie=%" PRIx64,
+					    obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (put)\n");
 			}
 			hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2;
 		} else if (free == 1) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-					obj, (const void *) mp, cookie);
+				MEMPOOL_LOG(CRIT,
+					    "obj=%p, mempool=%p, cookie=%" PRIx64,
+					    obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (get)\n");
 			}
 			hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1;
 		} else if (free == 2) {
 			if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 &&
 			    cookie != RTE_MEMPOOL_HEADER_COOKIE2) {
-				RTE_LOG(CRIT, MEMPOOL,
-					"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
+				MEMPOOL_LOG(CRIT,
+					"obj=%p, mempool=%p, cookie=%" PRIx64,
 					obj, (const void *) mp, cookie);
 				rte_panic("MEMPOOL: bad header cookie (audit)\n");
 			}
@@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp,
 		tlr = rte_mempool_get_trailer(obj);
 		cookie = tlr->cookie;
 		if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
-			RTE_LOG(CRIT, MEMPOOL,
-				"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
-				obj, (const void *) mp, cookie);
+			MEPOOL_LOG(CRIT,
+				   "obj=%p, mempool=%p, cookie=%" PRIx64,
+				   obj, (const void *) mp, cookie);
 			rte_panic("MEMPOOL: bad trailer cookie\n");
 		}
 	}
@@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp)
 		const struct rte_mempool_cache *cache;
 		cache = &mp->local_cache[lcore_id];
 		if (cache->len > RTE_DIM(cache->objs)) {
-			RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n",
+			MEMPOOL_LOG(CRIT, "badness on cache[%u]",
 				lcore_id);
 			rte_panic("MEMPOOL: invalid cache len\n");
 		}
@@ -1429,7 +1430,7 @@ rte_mempool_event_callback_register(rte_mempool_event_callback *func,
 
 	cb = calloc(1, sizeof(*cb));
 	if (cb == NULL) {
-		RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n");
+		MEMPOOL_LOG(ERR, "Cannot allocate event callback!");
 		ret = -ENOMEM;
 		goto exit;
 	}
@@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry)
 	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
 		"Returns mempool info. Parameters: pool_name");
 }
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..3d252f761408
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation.
+ * Copyright 2014 6WIND S.A.
+ */
+
+extern int mempool_logtype;
+
+#define MEMPOOL_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, mempool_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..e04e75b91ba6 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
@@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
 	if (rte_mempool_ops_table.num_ops >=
 			RTE_MEMPOOL_MAX_OPS_IDX) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(ERR, MEMPOOL,
-			"Maximum number of mempool ops structs exceeded\n");
+		MEMPOOL_LOG(ERR,
+			"Maximum number of mempool ops structs exceeded");
 		return -ENOSPC;
 	}
 
 	if (h->alloc == NULL || h->enqueue == NULL ||
 			h->dequeue == NULL || h->get_count == NULL) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(ERR, MEMPOOL,
-			"Missing callback while registering mempool ops\n");
+		MEMPOOL_LOG(ERR,
+			    "Missing callback while registering mempool ops");
 		return -EINVAL;
 	}
 
 	if (strlen(h->name) >= sizeof(ops->name) - 1) {
 		rte_spinlock_unlock(&rte_mempool_ops_table.sl);
-		RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n",
-				__func__, h->name);
+		MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", h->name);
 		rte_errno = EEXIST;
 		return -EEXIST;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 09/16] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 08/16] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 10/16] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/fib/fib_log.h               | 10 ++++++++++
 lib/fib/rte_fib.c               | 20 ++++++++++++--------
 lib/fib/rte_fib6.c              | 16 +++++++++-------
 lib/lpm/lpm_log.h               |  9 +++++++++
 lib/lpm/rte_lpm.c               | 15 +++++++++------
 lib/lpm/rte_lpm6.c              | 20 ++++++++++++--------
 lib/rib/rib_log.h               |  9 +++++++++
 lib/rib/rte_rib.c               | 12 +++++++-----
 lib/rib/rte_rib6.c              | 12 +++++++-----
 11 files changed, 85 insertions(+), 41 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 90d388192712..ff250b9a6d56 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f583352ec1ea..55067efb0a84 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..bf2fa88c7451
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+extern int fib_logtype;
+
+#define FIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fib_logtype,		\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..aa2ba735771a 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 #include <rte_tailq.h>
@@ -15,8 +16,11 @@
 #include <rte_rib.h>
 #include <rte_fib.h>
 
+#include "fib_log.h"
 #include "dir24_8.h"
 
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
+
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
 	.name = "RTE_FIB",
@@ -167,8 +171,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 
 	rib = rte_rib_create(name, socket_id, &rib_conf);
 	if (rib == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate RIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate RIB %s", name);
 		return NULL;
 	}
 
@@ -192,8 +196,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for FIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate tailq entry for FIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -202,7 +206,7 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	fib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_fib),	RTE_CACHE_LINE_SIZE, socket_id);
 	if (fib == NULL) {
-		RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name);
+		FIB_LOG(ERR, "FIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
@@ -213,9 +217,9 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
 	fib->def_nh = conf->default_nh;
 	ret = init_dataplane(fib, socket_id, conf);
 	if (ret < 0) {
-		RTE_LOG(ERR, LPM,
-			"FIB dataplane struct %s memory allocation failed "
-			"with err %d\n", name, ret);
+		FIB_LOG(ERR,
+			"FIB dataplane struct %s memory allocation failed with err %d",
+			name, ret);
 		rte_errno = -ret;
 		goto free_fib;
 	}
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..4ce641f9dcd8 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,12 +9,14 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
+#include "fib_log.h"
 #include "trie.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
@@ -168,8 +170,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 
 	rib = rte_rib6_create(name, socket_id, &rib_conf);
 	if (rib == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate RIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate RIB %s", name);
 		return NULL;
 	}
 
@@ -193,8 +195,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for FIB %s\n", name);
+		FIB_LOG(ERR,
+			"Can not allocate tailq entry for FIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -203,7 +205,7 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	fib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_fib6), RTE_CACHE_LINE_SIZE, socket_id);
 	if (fib == NULL) {
-		RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name);
+		FIB_LOG(ERR, "FIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
@@ -214,8 +216,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
 	fib->def_nh = conf->default_nh;
 	ret = init_dataplane(fib, socket_id, conf);
 	if (ret < 0) {
-		RTE_LOG(ERR, LPM,
-			"FIB dataplane struct %s memory allocation failed\n",
+		FIB_LOG(ERR,
+			"FIB dataplane struct %s memory allocation failed",
 			name);
 		rte_errno = -ret;
 		goto free_fib;
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..b4101cfbe238
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ * Copyright(c) 2020 Arm Limited
+ */
+
+extern int lpm_logtype;
+#define LPM_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, lpm_logtype,		\
+		"%s(): " fmt "\n", __func__, ## args)
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..363058e118c0 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
@@ -189,7 +192,7 @@ rte_lpm_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("LPM_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM, "Failed to allocate tailq entry\n");
+		LPM_LOG(ERR, "Failed to allocate tailq entry");
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -198,7 +201,7 @@ rte_lpm_create(const char *name, int socket_id,
 	i_lpm = rte_zmalloc_socket(mem_name, mem_size,
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (i_lpm == NULL) {
-		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+		LPM_LOG(ERR, "LPM memory allocation failed");
 		rte_free(te);
 		rte_errno = ENOMEM;
 		goto exit;
@@ -208,7 +211,7 @@ rte_lpm_create(const char *name, int socket_id,
 			(size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (i_lpm->rules_tbl == NULL) {
-		RTE_LOG(ERR, LPM, "LPM rules_tbl memory allocation failed\n");
+		LPM_LOG(ERR, "LPM rules_tbl memory allocation failed");
 		rte_free(i_lpm);
 		i_lpm = NULL;
 		rte_free(te);
@@ -220,7 +223,7 @@ rte_lpm_create(const char *name, int socket_id,
 			(size_t)tbl8s_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (i_lpm->lpm.tbl8 == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n");
+		LPM_LOG(ERR, "LPM tbl8 memory allocation failed");
 		rte_free(i_lpm->rules_tbl);
 		rte_free(i_lpm);
 		i_lpm = NULL;
@@ -335,7 +338,7 @@ rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg)
 		params.v = cfg->v;
 		i_lpm->dq = rte_rcu_qsbr_dq_create(&params);
 		if (i_lpm->dq == NULL) {
-			RTE_LOG(ERR, LPM, "LPM defer queue creation failed\n");
+			LPM_LOG(ERR, "LPM defer queue creation failed");
 			return 1;
 		}
 	} else {
@@ -562,7 +565,7 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start)
 		status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq,
 				(void *)&tbl8_group_start);
 		if (status == 1) {
-			RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n");
+			LPM_LOG(ERR, "Failed to push QSBR FIFO");
 			return -rte_errno;
 		}
 	}
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..6c36a637322e 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
@@ -279,8 +280,9 @@ rte_lpm6_create(const char *name, int socket_id,
 
 	rules_tbl = rte_hash_create(&rule_hash_tbl_params);
 	if (rules_tbl == NULL) {
-		RTE_LOG(ERR, LPM, "LPM rules hash table allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM rules hash table allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		goto fail_wo_unlock;
 	}
 
@@ -289,8 +291,9 @@ rte_lpm6_create(const char *name, int socket_id,
 			sizeof(uint32_t) * config->number_tbl8s,
 			RTE_CACHE_LINE_SIZE);
 	if (tbl8_pool == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 pool allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM tbl8 pool allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		rte_errno = ENOMEM;
 		goto fail_wo_unlock;
 	}
@@ -300,8 +303,9 @@ rte_lpm6_create(const char *name, int socket_id,
 			sizeof(struct rte_lpm_tbl8_hdr) * config->number_tbl8s,
 			RTE_CACHE_LINE_SIZE);
 	if (tbl8_hdrs == NULL) {
-		RTE_LOG(ERR, LPM, "LPM tbl8 headers allocation failed: %s (%d)",
-				  rte_strerror(rte_errno), rte_errno);
+		LPM_LOG(ERR,
+			"LPM tbl8 headers allocation failed: %s (%d)",
+			rte_strerror(rte_errno), rte_errno);
 		rte_errno = ENOMEM;
 		goto fail_wo_unlock;
 	}
@@ -329,7 +333,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, LPM, "Failed to allocate tailq entry!\n");
+		LPM_LOG(ERR, "Failed to allocate tailq entry!");
 		rte_errno = ENOMEM;
 		goto fail;
 	}
@@ -339,7 +343,7 @@ rte_lpm6_create(const char *name, int socket_id,
 			RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm == NULL) {
-		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+		LPM_LOG(ERR, "LPM memory allocation failed");
 		rte_free(te);
 		rte_errno = ENOMEM;
 		goto fail;
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..520f4083c0a8
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+extern int rib_logtype;
+#define RIB_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rib_logtype,		\
+		"%s(): " fmt "\n", __func__, ##args)
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..c667e8cfe964 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,10 @@
 
 #include <rte_rib.h>
 
+#include "rib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
@@ -412,8 +416,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 		NULL, NULL, NULL, NULL, socket_id, 0);
 
 	if (node_pool == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate mempool for RIB %s\n", name);
+		RIB_LOG(ERR, "Can not allocate mempool for RIB %s", name);
 		return NULL;
 	}
 
@@ -437,8 +440,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0);
 	if (unlikely(te == NULL)) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for RIB %s\n", name);
+		RIB_LOG(ERR, "Can not allocate tailq entry for RIB %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -447,7 +449,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf)
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib),	RTE_CACHE_LINE_SIZE, socket_id);
 	if (unlikely(rib == NULL)) {
-		RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name);
+		RIB_LOG(ERR, "RIB %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..4e171d4208d9 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
@@ -481,8 +484,7 @@ rte_rib6_create(const char *name, int socket_id,
 		NULL, NULL, NULL, NULL, socket_id, 0);
 
 	if (node_pool == NULL) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate mempool for RIB6 %s\n", name);
+		RIB_LOG(ERR, "Can not allocate mempool for RIB6 %s", name);
 		return NULL;
 	}
 
@@ -506,8 +508,8 @@ rte_rib6_create(const char *name, int socket_id,
 	/* allocate tailq entry */
 	te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0);
 	if (unlikely(te == NULL)) {
-		RTE_LOG(ERR, LPM,
-			"Can not allocate tailq entry for RIB6 %s\n", name);
+		RIB_LOG(ERR,
+			"Can not allocate tailq entry for RIB6 %s", name);
 		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -516,7 +518,7 @@ rte_rib6_create(const char *name, int socket_id,
 	rib = rte_zmalloc_socket(mem_name,
 		sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id);
 	if (unlikely(rib == NULL)) {
-		RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name);
+		RIB_LOG(ERR, "RIB6 %s memory allocation failed", name);
 		rte_errno = ENOMEM;
 		goto free_te;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 10/16] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 09/16] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 11/16] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
                     ` (5 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/kni/rte_kni.c               | 63 ++++++++++++++++++---------------
 3 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index ff250b9a6d56..b0c625a02cdf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 55067efb0a84..69d3d07252ec 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..6645c2a239cb 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -92,15 +92,20 @@ static void kni_allocate_mbufs(struct rte_kni *kni);
 
 static volatile int kni_fd = -1;
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+
+#define KNI_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, kni_logtype,	fmt, ## args)
+
 /* Shall be called before any allocation happens */
 int
 rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 {
-	RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n");
+	KNI_LOG(WARNING, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n");
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
 	if (rte_eal_iova_mode() != RTE_IOVA_PA) {
-		RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n");
+		KNI_LOG(ERR, "KNI requires IOVA as PA\n");
 		return -1;
 	}
 #endif
@@ -109,7 +114,7 @@ rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 	if (kni_fd < 0) {
 		kni_fd = open("/dev/" KNI_DEVICE, O_RDWR);
 		if (kni_fd < 0) {
-			RTE_LOG(ERR, KNI,
+			KNI_LOG(ERR,
 				"Can not open /dev/%s\n", KNI_DEVICE);
 			return -1;
 		}
@@ -225,7 +230,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 
 	/* Check if KNI subsystem has been initialized */
 	if (kni_fd < 0) {
-		RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
+		KNI_LOG(ERR, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
 		return NULL;
 	}
 
@@ -233,19 +238,19 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
-		RTE_LOG(ERR, KNI, "KNI already exists\n");
+		KNI_LOG(ERR, "KNI already exists\n");
 		goto unlock;
 	}
 
 	te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n");
+		KNI_LOG(ERR, "Failed to allocate tailq entry\n");
 		goto unlock;
 	}
 
 	kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE);
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "KNI memory allocation failed\n");
+		KNI_LOG(ERR, "KNI memory allocation failed\n");
 		goto kni_fail;
 	}
 
@@ -424,7 +429,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	strlcpy(dev_info.name, kni->name, sizeof(dev_info.name));
 	if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) {
-		RTE_LOG(ERR, KNI, "Fail to release kni device\n");
+		KNI_LOG(ERR, "Fail to release kni device\n");
 		goto unlock;
 	}
 
@@ -439,7 +444,7 @@ rte_kni_release(struct rte_kni *kni)
 		usleep(1000);
 
 	if (kni_fifo_count(kni->rx_q))
-		RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n");
+		KNI_LOG(ERR, "Fail to free all Rx-q items\n");
 
 	kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q);
 	kni_free_fifo(kni->tx_q);
@@ -466,16 +471,16 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 	int ret = 0;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id);
+	KNI_LOG(INFO, "Configure mac address of %d", port_id);
 
 	ret = rte_eth_dev_default_mac_addr_set(port_id,
 					(struct rte_ether_addr *)mac_addr);
 	if (ret < 0)
-		RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n",
+		KNI_LOG(ERR, "Failed to config mac_addr for port %d\n",
 			port_id);
 
 	return ret;
@@ -488,11 +493,11 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n",
+	KNI_LOG(INFO, "Configure promiscuous mode of %d to %d\n",
 		port_id, to_on);
 
 	if (to_on)
@@ -501,7 +506,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 		ret = rte_eth_promiscuous_disable(port_id);
 
 	if (ret != 0)
-		RTE_LOG(ERR, KNI,
+		KNI_LOG(ERR,
 			"Failed to %s promiscuous mode for port %u: %s\n",
 			to_on ? "enable" : "disable", port_id,
 			rte_strerror(-ret));
@@ -516,11 +521,11 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on)
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+		KNI_LOG(ERR, "Invalid port id %d\n", port_id);
 		return -EINVAL;
 	}
 
-	RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n",
+	KNI_LOG(INFO, "Configure allmulticast mode of %d to %d\n",
 		port_id, to_on);
 
 	if (to_on)
@@ -528,7 +533,7 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on)
 	else
 		ret = rte_eth_allmulticast_disable(port_id);
 	if (ret != 0)
-		RTE_LOG(ERR, KNI,
+		KNI_LOG(ERR,
 			"Failed to %s allmulticast mode for port %u: %s\n",
 			to_on ? "enable" : "disable", port_id,
 			rte_strerror(-ret));
@@ -551,7 +556,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 		return 0; /* It is OK of can not getting the request mbuf */
 
 	if (req != kni->sync_addr) {
-		RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req);
+		KNI_LOG(ERR, "Wrong req pointer %p\n", req);
 		return -1;
 	}
 
@@ -592,7 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 					kni->ops.port_id, req->allmulti);
 		break;
 	default:
-		RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id);
+		KNI_LOG(ERR, "Unknown request id %u\n", req->req_id);
 		req->result = -EINVAL;
 		break;
 	}
@@ -603,7 +608,7 @@ rte_kni_handle_request(struct rte_kni *kni)
 	else
 		ret = 1;
 	if (ret != 1) {
-		RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n");
+		KNI_LOG(ERR, "Fail to put the muf back to resp_q\n");
 		return -1; /* It is an error of can't putting the mbuf back */
 	}
 
@@ -679,7 +684,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
 
 	/* Check if pktmbuf pool has been configured */
 	if (kni->pktmbuf_pool == NULL) {
-		RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n");
+		KNI_LOG(ERR, "No valid mempool for allocating mbufs\n");
 		return;
 	}
 
@@ -690,7 +695,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
 		pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
 		if (unlikely(pkts[i] == NULL)) {
 			/* Out of memory */
-			RTE_LOG(ERR, KNI, "Out of memory\n");
+			KNI_LOG(ERR, "Out of memory\n");
 			break;
 		}
 		phys[i] = va2pa(pkts[i]);
@@ -757,18 +762,18 @@ rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops)
 	enum kni_ops_status req_status;
 
 	if (ops == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n");
+		KNI_LOG(ERR, "Invalid KNI request operation.\n");
 		return -1;
 	}
 
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid kni info.\n");
+		KNI_LOG(ERR, "Invalid kni info.\n");
 		return -1;
 	}
 
 	req_status = kni_check_request_register(&kni->ops);
 	if (req_status == KNI_REQ_REGISTERED) {
-		RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n");
+		KNI_LOG(ERR, "The KNI request operation has already registered.\n");
 		return -1;
 	}
 
@@ -780,7 +785,7 @@ int
 rte_kni_unregister_handlers(struct rte_kni *kni)
 {
 	if (kni == NULL) {
-		RTE_LOG(ERR, KNI, "Invalid kni info.\n");
+		KNI_LOG(ERR, "Invalid kni info.\n");
 		return -1;
 	}
 
@@ -806,7 +811,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 
 	fd = open(path, O_RDWR);
 	if (fd == -1) {
-		RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path);
+		KNI_LOG(ERR, "Failed to open file: %s.\n", path);
 		return -1;
 	}
 
@@ -823,7 +828,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)
 	new_carrier = linkup ? "1" : "0";
 	ret = write(fd, new_carrier, 1);
 	if (ret < 1) {
-		RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path);
+		KNI_LOG(ERR, "Failed to write file: %s.\n", path);
 		close(fd);
 		return -1;
 	}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 11/16] hash: replace RTE_LOGTYPE_HASH with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 10/16] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 12/16] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (4 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

A little more complex here since the one hash library actually
has multiple routines in it.  Split up the logtypes for
hash and toeplitz.

The hash crc file has another issue around logging.
It is calling RTE_LOG during a constructor which is maybe
problematic because this will all run before the DPDK library
has finished initializing logging.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/hash/rte_cuckoo_hash.c      | 60 ++++++++++++++++++---------------
 lib/hash/rte_fbk_hash.c         | 10 ++++--
 lib/hash/rte_hash_crc.h         |  6 ++--
 lib/hash/rte_thash.c            | 53 ++++++++++++++++++++++-------
 lib/hash/rte_thash_gfni.h       | 24 ++++---------
 lib/hash/version.map            |  4 +++
 8 files changed, 95 insertions(+), 65 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index b0c625a02cdf..97120543d808 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 69d3d07252ec..afbd67d55b45 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..a5ca21b74e2a 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -26,6 +26,12 @@
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_logtype, cuckoo, INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 /* Mask of all flags supported by this version */
 #define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \
 				   RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \
@@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
 	if (params == NULL) {
-		RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n");
+		HASH_LOG(ERR, "null parameters");
 		return NULL;
 	}
 
@@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
 			(params->key_len == 0)) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n");
+		HASH_LOG(ERR, "invalid parameters");
 		return NULL;
 	}
 
 	if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n");
+		HASH_LOG(ERR, "unsupported extra flags");
 		return NULL;
 	}
 
@@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
 		rte_errno = EINVAL;
-		RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or "
-			"rw concurrency lock free\n");
+		HASH_LOG(ERR,
+			 "choose rw concurrency or rw concurrency lock free");
 		return NULL;
 	}
 
@@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	r = rte_ring_create_elem(ring_name, sizeof(uint32_t),
 			rte_align32pow2(num_key_slots), params->socket_id, 0);
 	if (r == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err;
 	}
 
@@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				params->socket_id, 0);
 
 		if (r_ext == NULL) {
-			RTE_LOG(ERR, HASH, "ext buckets memory allocation "
-								"failed\n");
+			HASH_LOG(ERR,
+				 "ext buckets memory allocation failed");
 			goto err;
 		}
 	}
@@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH, "tailq entry allocation failed\n");
+		HASH_LOG(ERR, "tailq entry allocation failed");
 		goto err_unlock;
 	}
 
@@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 					RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (h == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (buckets == NULL) {
-		RTE_LOG(ERR, HASH, "buckets memory allocation failed\n");
+		HASH_LOG(ERR, "buckets memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				num_buckets * sizeof(struct rte_hash_bucket),
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 		if (buckets_ext == NULL) {
-			RTE_LOG(ERR, HASH, "ext buckets memory allocation "
-							"failed\n");
+			HASH_LOG(ERR,
+				 "ext buckets memory allocation failed");
 			goto err_unlock;
 		}
 		/* Populate ext bkt ring. We reserve 0 similar to the
@@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) *
 								num_key_slots, 0);
 			if (ext_bkt_to_free == NULL) {
-				RTE_LOG(ERR, HASH, "ext bkt to free memory allocation "
-								"failed\n");
+				HASH_LOG(ERR,
+					 "ext bkt to free memory allocation failed");
 				goto err_unlock;
 			}
 		}
@@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (k == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (tbl_chng_cnt == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		goto err_unlock;
 	}
 
@@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 				sizeof(struct lcore_cache) * RTE_MAX_LCORE,
 				RTE_CACHE_LINE_SIZE, params->socket_id);
 		if (local_free_slots == NULL) {
-			RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n");
+			HASH_LOG(ERR, "local free slots memory allocation failed");
 			goto err_unlock;
 		}
 	}
@@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h)
 		/* Reclaim all the resources */
 		rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL);
 		if (pending != 0)
-			RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n");
+			HASH_LOG(ERR, "RCU reclaim all resources failed");
 	}
 
 	memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket));
@@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n)
 	/* Return key indexes to free slot ring */
 	ret = free_slot(h, rcu_dq_entry.key_idx);
 	if (ret < 0) {
-		RTE_LOG(ERR, HASH,
-			"%s: could not enqueue free slots in global ring\n",
-				__func__);
+		HASH_LOG(ERR,
+			 "could not enqueue free slots in global ring");
 	}
 }
 
@@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 
 	hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0);
 	if (hash_rcu_cfg == NULL) {
-		RTE_LOG(ERR, HASH, "memory allocation failed\n");
+		HASH_LOG(ERR, "memory allocation failed");
 		return 1;
 	}
 
@@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 		h->dq = rte_rcu_qsbr_dq_create(&params);
 		if (h->dq == NULL) {
 			rte_free(hash_rcu_cfg);
-			RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n");
+			HASH_LOG(ERR, "HASH defer queue creation failed");
 			return 1;
 		}
 	} else {
@@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
 	int ret = free_slot(h, bkt->key_idx[i]);
 
 	if (ret < 0) {
-		RTE_LOG(ERR, HASH,
-			"%s: could not enqueue free slots in global ring\n",
-				__func__);
+		HASH_LOG(ERR,
+			 "could not enqueue free slots in global ring");
 	}
 }
 
@@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
 		} else if (h->dq)
 			/* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */
 			if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0)
-				RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n");
+				HASH_LOG(ERR, "Failed to push QSBR FIFO");
 	}
 	__hash_rw_writer_unlock(h);
 	return ret;
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..37edb5e2c7fe 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -18,6 +18,12 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, fbk_hash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
@@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n");
+		HASH_LOG(ERR, "Failed to allocate tailq entry");
 		goto exit;
 	}
 
@@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	ht = rte_zmalloc_socket(hash_name, mem_size,
 			0, params->socket_id);
 	if (ht == NULL) {
-		RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n");
+		HASH_LOG(ERR, "Failed to allocate fbk hash table");
 		rte_free(te);
 		goto exit;
 	}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..3bb38880c4ea 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg)
 
 #if defined RTE_ARCH_X86
 	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
 	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
 		crc32_alg = CRC32_SSE42;
@@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg)
 
 #if defined RTE_ARCH_ARM64
 	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
 		crc32_alg = CRC32_ARM64;
 #endif
 
 	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
+		fprintf(stderr,
 			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
 }
 
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..fddc14e57588 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,12 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, thash, INFO);
+
+#define HASH_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, rte_thash_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
@@ -104,6 +110,28 @@ rte_thash_gfni_supported(void)
 	return 0;
 };
 
+#ifndef RTE_THASH_GFNI_DEFINED
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	HASH_LOG(ERR, "is undefined under given arch");
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+	int len __rte_unused, uint8_t *tuple[] __rte_unused,
+	uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	HASH_LOG(ERR, "is undefined under given arch");
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
+#endif
+
 void
 rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size)
 {
@@ -240,8 +268,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 	/* allocate tailq entry */
 	te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0);
 	if (te == NULL) {
-		RTE_LOG(ERR, HASH,
-			"Can not allocate tailq entry for thash context %s\n",
+		HASH_LOG(ERR,
+			"Can not allocate tailq entry for thash context %s",
 			name);
 		rte_errno = ENOMEM;
 		goto exit;
@@ -249,7 +277,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 
 	ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0);
 	if (ctx == NULL) {
-		RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n",
+		HASH_LOG(ERR,
+			 "thash ctx %s memory allocation failed",
 			name);
 		rte_errno = ENOMEM;
 		goto free_te;
@@ -272,7 +301,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
 		ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t),
 			RTE_CACHE_LINE_SIZE);
 		if (ctx->matrices == NULL) {
-			RTE_LOG(ERR, HASH, "Cannot allocate matrices\n");
+			HASH_LOG(ERR, "Cannot allocate matrices");
 			rte_errno = ENOMEM;
 			goto free_ctx;
 		}
@@ -387,8 +416,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
 	if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) &&
 			((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) !=
 			RTE_THASH_IGNORE_PERIOD_OVERFLOW)) {
-		RTE_LOG(ERR, HASH,
-			"Can't generate m-sequence due to period overflow\n");
+		HASH_LOG(ERR,
+			"Can't generate m-sequence due to period overflow");
 		return -ENOSPC;
 	}
 
@@ -467,9 +496,9 @@ insert_before(struct rte_thash_ctx *ctx,
 			return ret;
 		}
 	} else if ((next_ent != NULL) && (end > next_ent->offset)) {
-		RTE_LOG(ERR, HASH,
-			"Can't add helper %s due to conflict with existing"
-			" helper %s\n", ent->name, next_ent->name);
+		HASH_LOG(ERR,
+			"Can't add helper %s due to conflict with existing helper %s",
+			 ent->name, next_ent->name);
 		rte_free(ent);
 		return -ENOSPC;
 	}
@@ -516,9 +545,9 @@ insert_after(struct rte_thash_ctx *ctx,
 	int ret;
 
 	if ((next_ent != NULL) && (end > next_ent->offset)) {
-		RTE_LOG(ERR, HASH,
-			"Can't add helper %s due to conflict with existing"
-			" helper %s\n", ent->name, next_ent->name);
+		HASH_LOG(ERR,
+			 "Can't add helper %s due to conflict with existing helper %s",
+			 ent->name, next_ent->name);
 		rte_free(ent);
 		return -EEXIST;
 	}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..c3a5cf7e7b2d 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -38,13 +38,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx,
+		    int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..c30ac81307a7 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 23.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 12/16] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 11/16] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 13/16] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
                     ` (3 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   2 -
 lib/eal/include/rte_log.h       |   4 +-
 lib/sched/rte_pie.c             |  16 +-
 lib/sched/rte_sched.c           | 299 +++++++++++++-------------------
 lib/sched/rte_sched_log.h       |  11 ++
 5 files changed, 141 insertions(+), 191 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 97120543d808..212ccda0a6e8 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,8 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index afbd67d55b45..a1549b372767 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..28ed01e8f11d 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
+
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
@@ -16,7 +18,7 @@ int
 rte_pie_rt_data_init(struct rte_pie *pie)
 {
 	if (pie == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Invalid addr for pie\n", __func__);
+		SCHED_LOG(ERR, "Invalid addr for pie");
 		return -EINVAL;
 	}
 
@@ -38,26 +40,22 @@ rte_pie_config_init(struct rte_pie_config *pie_cfg,
 		return -1;
 
 	if (qdelay_ref <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for qdelay_ref\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for qdelay_ref");
 		return -EINVAL;
 	}
 
 	if (dp_update_interval <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for dp_update_interval\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for dp_update_interval");
 		return -EINVAL;
 	}
 
 	if (max_burst <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for max_burst\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for max_burst");
 		return -EINVAL;
 	}
 
 	if (tailq_th <= 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tailq_th\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tailq_th");
 		return -EINVAL;
 	}
 
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..b74792f72c56 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -6,7 +6,6 @@
 #include <string.h>
 
 #include <rte_common.h>
-#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 #include <rte_prefetch.h>
@@ -17,6 +16,7 @@
 
 #include "rte_sched.h"
 #include "rte_sched_common.h"
+#include "rte_sched_log.h"
 #include "rte_approx.h"
 
 #ifdef __INTEL_COMPILER
@@ -324,23 +324,20 @@ pipe_profile_check(struct rte_sched_pipe_params *params,
 
 	/* Pipe parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* TB rate: non-zero, not greater than port rate */
 	if (params->tb_rate == 0 ||
 		params->tb_rate > rate) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tb rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb rate");
 		return -EINVAL;
 	}
 
 	/* TB size: non-zero */
 	if (params->tb_size == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tb size\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb size");
 		return -EINVAL;
 	}
 
@@ -349,38 +346,33 @@ pipe_profile_check(struct rte_sched_pipe_params *params,
 		if ((qsize[i] == 0 && params->tc_rate[i] != 0) ||
 			(qsize[i] != 0 && (params->tc_rate[i] == 0 ||
 			params->tc_rate[i] > params->tb_rate))) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for qsize or tc_rate\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for qsize or tc_rate");
 			return -EINVAL;
 		}
 	}
 
 	if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 ||
 		qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for be traffic class rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for be traffic class rate");
 		return -EINVAL;
 	}
 
 	/* TC period: non-zero */
 	if (params->tc_period == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc period\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc period");
 		return -EINVAL;
 	}
 
 	/*  Best effort tc oversubscription weight: non-zero */
 	if (params->tc_ov_weight == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc ov weight\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc ov weight");
 		return -EINVAL;
 	}
 
 	/* Queue WRR weights: non-zero */
 	for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) {
 		if (params->wrr_weights[i] == 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for wrr weight\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for wrr weight");
 			return -EINVAL;
 		}
 	}
@@ -396,20 +388,17 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,
 
 	/* Check user parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	if (params->tb_rate == 0 || params->tb_rate > rate) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tb rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb rate");
 		return -EINVAL;
 	}
 
 	if (params->tb_size == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tb size\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tb size");
 		return -EINVAL;
 	}
 
@@ -417,21 +406,18 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,
 		uint64_t tc_rate = params->tc_rate[i];
 
 		if (tc_rate == 0 || (tc_rate > params->tb_rate)) {
-			RTE_LOG(ERR, SCHED, "%s: "
-			"Incorrect value for tc rate\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for tc rate");
 			return -EINVAL;
 		}
 	}
 
 	if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect tc rate(best effort)\n", __func__);
+		SCHED_LOG(ERR, "Incorrect tc rate(best effort)");
 		return -EINVAL;
 	}
 
 	if (params->tc_period == 0) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for tc period\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc period");
 		return -EINVAL;
 	}
 
@@ -444,29 +430,25 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	uint32_t i;
 
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* socket */
 	if (params->socket < 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for socket id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for socket id");
 		return -EINVAL;
 	}
 
 	/* rate */
 	if (params->rate == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for rate\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for rate");
 		return -EINVAL;
 	}
 
 	/* mtu */
 	if (params->mtu == 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for mtu\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for mtu");
 		return -EINVAL;
 	}
 
@@ -474,8 +456,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	if (params->n_subports_per_port == 0 ||
 	    params->n_subports_per_port > 1u << 16 ||
 	    !rte_is_power_of_2(params->n_subports_per_port)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for number of subports\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for number of subports");
 		return -EINVAL;
 	}
 
@@ -483,8 +464,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 		params->n_subport_profiles == 0 ||
 		params->n_max_subport_profiles == 0 ||
 		params->n_subport_profiles > params->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED,
-		"%s: Incorrect value for subport profiles\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport profiles");
 		return -EINVAL;
 	}
 
@@ -495,9 +475,8 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 
 		status = subport_profile_check(p, params->rate);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-			"%s: subport profile check failed(%d)\n",
-			__func__, status);
+			SCHED_LOG(ERR, "subport profile check failed(%d)",
+				  status);
 			return -EINVAL;
 		}
 	}
@@ -505,8 +484,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	/* n_pipes_per_subport: non-zero, power of 2 */
 	if (params->n_pipes_per_subport == 0 ||
 	    !rte_is_power_of_2(params->n_pipes_per_subport)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for maximum pipes number\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for maximum pipes number");
 		return -EINVAL;
 	}
 
@@ -605,14 +583,15 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 {
 	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
 
-	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
+	SCHED_LOG(DEBUG,
+		  "Low level config for pipe profile %u:\n"
 		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n"
 		"	Traffic classes: period = %"PRIu64",\n"
 		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
 		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
 		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
 		"	Best-effort traffic class oversubscription: weight = %hhu\n"
-		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
+		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]",
 		i,
 
 		/* Token bucket */
@@ -648,35 +627,36 @@ rte_sched_port_log_subport_profile(struct rte_sched_port *port, uint32_t i)
 {
 	struct rte_sched_subport_profile *p = port->subport_profiles + i;
 
-	RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n"
-	"Token bucket: period = %"PRIu64", credits per period = %"PRIu64","
-	"size = %"PRIu64"\n"
-	"Traffic classes: period = %"PRIu64",\n"
-	"credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
-	" %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
-	" %"PRIu64", %"PRIu64", %"PRIu64"]\n",
-	i,
-
-	/* Token bucket */
-	p->tb_period,
-	p->tb_credits_per_period,
-	p->tb_size,
-
-	/* Traffic classes */
-	p->tc_period,
-	p->tc_credits_per_period[0],
-	p->tc_credits_per_period[1],
-	p->tc_credits_per_period[2],
-	p->tc_credits_per_period[3],
-	p->tc_credits_per_period[4],
-	p->tc_credits_per_period[5],
-	p->tc_credits_per_period[6],
-	p->tc_credits_per_period[7],
-	p->tc_credits_per_period[8],
-	p->tc_credits_per_period[9],
-	p->tc_credits_per_period[10],
-	p->tc_credits_per_period[11],
-	p->tc_credits_per_period[12]);
+	SCHED_LOG(DEBUG,
+		  "Low level config for subport profile %u:\n"
+		  "Token bucket: period = %"PRIu64", credits per period = %"PRIu64","
+		  "size = %"PRIu64"\n"
+		  "Traffic classes: period = %"PRIu64",\n"
+		  "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		  " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		  " %"PRIu64", %"PRIu64", %"PRIu64"]",
+		  i,
+
+		  /* Token bucket */
+		  p->tb_period,
+		  p->tb_credits_per_period,
+		  p->tb_size,
+
+		  /* Traffic classes */
+		  p->tc_period,
+		  p->tc_credits_per_period[0],
+		  p->tc_credits_per_period[1],
+		  p->tc_credits_per_period[2],
+		  p->tc_credits_per_period[3],
+		  p->tc_credits_per_period[4],
+		  p->tc_credits_per_period[5],
+		  p->tc_credits_per_period[6],
+		  p->tc_credits_per_period[7],
+		  p->tc_credits_per_period[8],
+		  p->tc_credits_per_period[9],
+		  p->tc_credits_per_period[10],
+		  p->tc_credits_per_period[11],
+		  p->tc_credits_per_period[12]);
 }
 
 static inline uint64_t
@@ -829,8 +809,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 
 	/* Check user parameters */
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter params\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
@@ -841,14 +820,13 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 		uint16_t qsize = params->qsize[i];
 
 		if (qsize != 0 && !rte_is_power_of_2(qsize)) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Incorrect value for qsize\n", __func__);
+			SCHED_LOG(ERR, "Incorrect value for qsize");
 			return -EINVAL;
 		}
 	}
 
 	if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
-		RTE_LOG(ERR, SCHED, "%s: Incorrect qsize\n", __func__);
+		SCHED_LOG(ERR, "Incorrect qsize");
 		return -EINVAL;
 	}
 
@@ -856,8 +834,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	if (params->n_pipes_per_subport_enabled == 0 ||
 		params->n_pipes_per_subport_enabled > n_max_pipes_per_subport ||
 	    !rte_is_power_of_2(params->n_pipes_per_subport_enabled)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for pipes number\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for pipes number");
 		return -EINVAL;
 	}
 
@@ -866,8 +843,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	    params->n_pipe_profiles == 0 ||
 		params->n_max_pipe_profiles == 0 ||
 		params->n_pipe_profiles > params->n_max_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for pipe profiles\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for pipe profiles");
 		return -EINVAL;
 	}
 
@@ -877,8 +853,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 
 		status = pipe_profile_check(p, rate, &params->qsize[0]);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Pipe profile check failed(%d)\n", __func__, status);
+			SCHED_LOG(ERR, "Pipe profile check failed(%d)", status);
 			return -EINVAL;
 		}
 	}
@@ -895,9 +870,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
 
 	status = rte_sched_port_check_params(port_params);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Port scheduler port params check failed (%d)\n",
-			__func__, status);
+		SCHED_LOG(ERR,
+			  "Port scheduler port params check failed (%d)",
+			  status);
 
 		return 0;
 	}
@@ -909,9 +884,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
 				port_params->n_pipes_per_subport,
 				port_params->rate);
 		if (status != 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Port scheduler subport params check failed (%d)\n",
-				__func__, status);
+			SCHED_LOG(ERR,
+				  "Port scheduler subport params check failed (%d)",
+				status);
 
 			return 0;
 		}
@@ -940,9 +915,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 
 	status = rte_sched_port_check_params(params);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Port scheduler params check failed (%d)\n",
-			__func__, status);
+		SCHED_LOG(ERR, "Port scheduler params check failed (%d)",
+			  status);
 		return NULL;
 	}
 
@@ -955,7 +929,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	port = rte_zmalloc_socket("qos_params", size0 + size1,
 				 RTE_CACHE_LINE_SIZE, params->socket);
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
+		SCHED_LOG(ERR, "Memory allocation fails");
 
 		return NULL;
 	}
@@ -964,7 +938,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	port->subport_profiles  = rte_zmalloc_socket("subport_profile", size2,
 					RTE_CACHE_LINE_SIZE, params->socket);
 	if (port->subport_profiles == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
+		SCHED_LOG(ERR, "Memory allocation fails");
 		rte_free(port);
 		return NULL;
 	}
@@ -1106,8 +1080,7 @@ rte_sched_red_config(struct rte_sched_port *port,
 				params->cman_params->red_params[i][j].maxp_inv) != 0) {
 				rte_sched_free_memory(port, n_subports);
 
-				RTE_LOG(NOTICE, SCHED,
-				"%s: RED configuration init fails\n", __func__);
+				SCHED_LOG(NOTICE, "RED configuration init fails");
 				return -EINVAL;
 			}
 		}
@@ -1126,8 +1099,7 @@ rte_sched_pie_config(struct rte_sched_port *port,
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
 		if (params->cman_params->pie_params[i].tailq_th > params->qsize[i]) {
-			RTE_LOG(NOTICE, SCHED,
-			"%s: PIE tailq threshold incorrect\n", __func__);
+			SCHED_LOG(NOTICE, "PIE tailq threshold incorrect");
 			return -EINVAL;
 		}
 
@@ -1138,8 +1110,7 @@ rte_sched_pie_config(struct rte_sched_port *port,
 			params->cman_params->pie_params[i].tailq_th) != 0) {
 			rte_sched_free_memory(port, n_subports);
 
-			RTE_LOG(NOTICE, SCHED,
-			"%s: PIE configuration init fails\n", __func__);
+			SCHED_LOG(NOTICE, "PIE configuration init fails");
 			return -EINVAL;
 			}
 	}
@@ -1170,14 +1141,12 @@ rte_sched_subport_tc_ov_config(struct rte_sched_port *port,
 	struct rte_sched_subport *s;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter subport id");
 		return  -EINVAL;
 	}
 
@@ -1203,22 +1172,19 @@ rte_sched_subport_config(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return 0;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (subport_profile_id >= port->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED, "%s: "
-			"Number of subport profile exceeds the max limit\n",
-			__func__);
+		SCHED_LOG(ERR,
+			  "Number of subport profile exceeds the max limit");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1233,9 +1199,9 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			port->n_pipes_per_subport,
 			port->rate);
 		if (status != 0) {
-			RTE_LOG(NOTICE, SCHED,
-				"%s: Port scheduler params check failed (%d)\n",
-				__func__, status);
+			SCHED_LOG(NOTICE,
+				  "Port scheduler params check failed (%d)",
+				  status);
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1249,8 +1215,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		s = rte_zmalloc_socket("subport_params", size0 + size1,
 			RTE_CACHE_LINE_SIZE, port->socket);
 		if (s == NULL) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Memory allocation fails\n", __func__);
+			SCHED_LOG(ERR, "Memory allocation fails");
 			ret = -ENOMEM;
 			goto out;
 		}
@@ -1281,8 +1246,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			s->cman_enabled = true;
 			status = rte_sched_cman_config(port, s, params, n_subports);
 			if (status) {
-				RTE_LOG(NOTICE, SCHED,
-					"%s: CMAN configuration fails\n", __func__);
+				SCHED_LOG(NOTICE,
+					  "CMAN configuration fails");
 				return status;
 			}
 		} else {
@@ -1329,8 +1294,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		s->bmp = rte_bitmap_init(n_subport_pipe_queues, s->bmp_array,
 					bmp_mem_size);
 		if (s->bmp == NULL) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Subport bitmap init error\n", __func__);
+			SCHED_LOG(ERR, "Subport bitmap init error");
 			ret = -EINVAL;
 			goto out;
 		}
@@ -1399,29 +1363,25 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 	deactivate = (pipe_profile < 0);
 
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter subport id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	s = port->subports[subport_id];
 	if (pipe_id >= s->n_pipes_per_subport_enabled) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter pipe id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter pipe id");
 		ret = -EINVAL;
 		goto out;
 	}
 
 	if (!deactivate && profile >= s->n_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter pipe profile\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter pipe profile");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -1446,9 +1406,9 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 		s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
 
 		if (s->tc_ov != tc_be_ov) {
-			RTE_LOG(DEBUG, SCHED,
-				"Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)\n",
-				subport_id, subport_tc_be_rate, s->tc_ov_rate);
+			SCHED_LOG(DEBUG,
+				  "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)",
+				  subport_id, subport_tc_be_rate, s->tc_ov_rate);
 		}
 
 		/* Reset the pipe */
@@ -1488,8 +1448,8 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 		s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
 
 		if (s->tc_ov != tc_be_ov) {
-			RTE_LOG(DEBUG, SCHED,
-				"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n",
+			SCHED_LOG(DEBUG,
+				"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)",
 				subport_id, subport_tc_be_rate, s->tc_ov_rate);
 		}
 		p->tc_ov_period_id = s->tc_ov_period_id;
@@ -1517,15 +1477,13 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 
 	/* Port */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	/* Subport id not exceeds the max limit */
 	if (subport_id > port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		return -EINVAL;
 	}
 
@@ -1533,16 +1491,14 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 
 	/* Pipe profiles exceeds the max limit */
 	if (s->n_pipe_profiles >= s->n_max_pipe_profiles) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Number of pipe profiles exceeds the max limit\n", __func__);
+		SCHED_LOG(ERR, "Number of pipe profiles exceeds the max limit");
 		return -EINVAL;
 	}
 
 	/* Pipe params */
 	status = pipe_profile_check(params, port->rate, &s->qsize[0]);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Pipe profile check failed(%d)\n", __func__, status);
+		SCHED_LOG(ERR, "Pipe profile check failed(%d)", status);
 		return -EINVAL;
 	}
 
@@ -1552,8 +1508,7 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
 	/* Pipe profile should not exists */
 	for (i = 0; i < s->n_pipe_profiles; i++)
 		if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) {
-			RTE_LOG(ERR, SCHED,
-				"%s: Pipe profile exists\n", __func__);
+			SCHED_LOG(ERR, "Pipe profile exists");
 			return -EINVAL;
 		}
 
@@ -1580,21 +1535,18 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 
 	/* Port */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (params == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter profile\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter profile");
 		return -EINVAL;
 	}
 
 	if (subport_profile_id == NULL) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Incorrect value for parameter subport_profile_id\n",
-		__func__);
+		SCHED_LOG(ERR,
+			  "Incorrect value for parameter subport_profile_id");
 		return -EINVAL;
 	}
 
@@ -1602,16 +1554,14 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 
 	/* Subport profiles exceeds the max limit */
 	if (port->n_subport_profiles >= port->n_max_subport_profiles) {
-		RTE_LOG(ERR, SCHED, "%s: "
-		"Number of subport profiles exceeds the max limit\n",
-		 __func__);
+		SCHED_LOG(ERR,
+			  "Number of subport profiles exceeds the max limit");
 		return -EINVAL;
 	}
 
 	status = subport_profile_check(params, port->rate);
 	if (status != 0) {
-		RTE_LOG(ERR, SCHED,
-		"%s: subport profile check failed(%d)\n", __func__, status);
+		SCHED_LOG(ERR, "subport profile check failed (%d)", status);
 		return -EINVAL;
 	}
 
@@ -1621,8 +1571,7 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,
 	for (i = 0; i < port->n_subport_profiles; i++)
 		if (memcmp(port->subport_profiles + i,
 		    dst, sizeof(*dst)) == 0) {
-			RTE_LOG(ERR, SCHED,
-			"%s: subport profile exists\n", __func__);
+			SCHED_LOG(ERR, "subport profile exists");
 			return -EINVAL;
 		}
 
@@ -1694,26 +1643,22 @@ rte_sched_subport_read_stats(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (subport_id >= port->n_subports_per_port) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for subport id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for subport id");
 		return -EINVAL;
 	}
 
 	if (stats == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter stats\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter stats");
 		return -EINVAL;
 	}
 
 	if (tc_ov == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for tc_ov\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for tc_ov");
 		return -EINVAL;
 	}
 
@@ -1742,26 +1687,22 @@ rte_sched_queue_read_stats(struct rte_sched_port *port,
 
 	/* Check user parameters */
 	if (port == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter port\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter port");
 		return -EINVAL;
 	}
 
 	if (queue_id >= rte_sched_port_queues_per_port(port)) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for queue id\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for queue id");
 		return -EINVAL;
 	}
 
 	if (stats == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter stats\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter stats");
 		return -EINVAL;
 	}
 
 	if (qlen == NULL) {
-		RTE_LOG(ERR, SCHED,
-			"%s: Incorrect value for parameter qlen\n", __func__);
+		SCHED_LOG(ERR, "Incorrect value for parameter qlen");
 		return -EINVAL;
 	}
 	subport_qmask = port->n_pipes_per_subport_log2 + 4;
@@ -3002,3 +2943,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..cbf577faf2cb
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_log.h>
+
+extern int sched_logtype;
+
+#define SCHED_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, sched_logtype,	\
+		"%s(): " fmt "\n", __func__, ##args)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 13/16] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 12/16] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 14/16] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (2 subsequent siblings)
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |  1 -
 lib/eal/include/rte_log.h       |  2 +-
 lib/port/rte_port_ethdev.c      | 23 +++++----
 lib/port/rte_port_eventdev.c    | 23 +++++----
 lib/port/rte_port_fd.c          | 28 ++++++-----
 lib/port/rte_port_frag.c        | 21 +++++----
 lib/port/rte_port_kni.c         | 22 +++++----
 lib/port/rte_port_ras.c         | 19 ++++----
 lib/port/rte_port_ring.c        | 22 +++++----
 lib/port/rte_port_sched.c       | 16 ++++---
 lib/port/rte_port_source_sink.c | 82 +++++++++++++++++++--------------
 lib/port/rte_port_sym_crypto.c  | 22 +++++----
 12 files changed, 164 insertions(+), 117 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 212ccda0a6e8..7002e267be37 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index a1549b372767..ff714a703be7 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..1ce0e7b3d396 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -5,11 +5,16 @@
 #include <stdint.h>
 
 #include <rte_mbuf.h>
+#include <rte_log.h>
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_PORT_ETHDEV_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_ethdev_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port ETHDEV Reader
  */
@@ -43,7 +48,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -51,7 +56,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -78,7 +83,7 @@ static int
 rte_port_ethdev_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -142,7 +147,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -150,7 +155,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -257,7 +262,7 @@ static int
 rte_port_ethdev_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -323,7 +328,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -331,7 +336,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -470,7 +475,7 @@ static int
 rte_port_ethdev_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..9331bd9a8e52 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,16 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_PORT_EVENTDEV_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_eventdev_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port EVENTDEV Reader
  */
@@ -45,7 +50,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -53,7 +58,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -85,7 +90,7 @@ static int
 rte_port_eventdev_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -155,7 +160,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id)
 		(conf->enq_burst_sz == 0) ||
 		(conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->enq_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -163,7 +168,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -290,7 +295,7 @@ static int
 rte_port_eventdev_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -362,7 +367,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id)
 		(conf->enq_burst_sz == 0) ||
 		(conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->enq_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -370,7 +375,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -530,7 +535,7 @@ static int
 rte_port_eventdev_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..78a65d4ad582 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,10 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_PORT_FD_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_fd_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port FD Reader
  */
@@ -43,19 +47,19 @@ rte_port_fd_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 	if (conf->fd < 0) {
-		RTE_LOG(ERR, PORT, "%s: Invalid file descriptor\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid file descriptor");
 		return NULL;
 	}
 	if (conf->mtu == 0) {
-		RTE_LOG(ERR, PORT, "%s: Invalid MTU\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid MTU");
 		return NULL;
 	}
 	if (conf->mempool == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Invalid mempool\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid mempool");
 		return NULL;
 	}
 
@@ -63,7 +67,7 @@ rte_port_fd_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -109,7 +113,7 @@ static int
 rte_port_fd_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -171,7 +175,7 @@ rte_port_fd_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -179,7 +183,7 @@ rte_port_fd_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -279,7 +283,7 @@ static int
 rte_port_fd_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -344,7 +348,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -352,7 +356,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -464,7 +468,7 @@ static int
 rte_port_fd_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_FD_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..1a6d88cceb84 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,11 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_PORT_FRAG_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_frag_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
@@ -62,25 +67,23 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter conf is NULL");
 		return NULL;
 	}
 	if (conf->ring == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter ring is NULL");
 		return NULL;
 	}
 	if (conf->mtu == 0) {
-		RTE_LOG(ERR, PORT, "%s: Parameter mtu is invalid\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter mtu is invalid");
 		return NULL;
 	}
 	if (conf->pool_direct == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter pool_direct is NULL\n",
-			__func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter pool_direct is NULL");
 		return NULL;
 	}
 	if (conf->pool_indirect == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter pool_indirect is NULL\n",
-			__func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter pool_indirect is NULL");
 		return NULL;
 	}
 
@@ -88,7 +91,7 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4)
 	port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "port is NULL");
 		return NULL;
 	}
 
@@ -232,7 +235,7 @@ static int
 rte_port_ring_reader_frag_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__);
+		RTE_PORT_FRAG_LOG(ERR, "Parameter port is NULL");
 		return -1;
 	}
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..3f4d1dcb5882 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,10 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_PORT_KNI_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_kni_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port KNI Reader
  */
@@ -41,7 +45,7 @@ rte_port_kni_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -49,7 +53,7 @@ rte_port_kni_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -75,7 +79,7 @@ static int
 rte_port_kni_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -138,7 +142,7 @@ rte_port_kni_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -146,7 +150,7 @@ rte_port_kni_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -250,7 +254,7 @@ static int
 rte_port_kni_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -315,7 +319,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -323,7 +327,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -460,7 +464,7 @@ static int
 rte_port_kni_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_KNI_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..6cc1c19fc971 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -21,6 +21,11 @@
 #define RTE_PORT_RAS_N_ENTRIES (RTE_PORT_RAS_N_BUCKETS * RTE_PORT_RAS_N_ENTRIES_PER_BUCKET)
 #endif
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_PORT_RAS_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_ras_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
+
 #ifdef RTE_PORT_STATS_COLLECT
 
 #define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) \
@@ -69,17 +74,16 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter conf is NULL");
 		return NULL;
 	}
 	if (conf->ring == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter ring is NULL");
 		return NULL;
 	}
 	if ((conf->tx_burst_sz == 0) ||
 	    (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PORT, "%s: Parameter tx_burst_sz is invalid\n",
-			__func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter tx_burst_sz is invalid");
 		return NULL;
 	}
 
@@ -87,7 +91,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate socket\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Failed to allocate socket");
 		return NULL;
 	}
 
@@ -103,8 +107,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
 		socket_id);
 
 	if (port->frag_tbl == NULL) {
-		RTE_LOG(ERR, PORT, "%s: rte_ip_frag_table_create failed\n",
-			__func__);
+		RTE_PORT_RAS_LOG(ERR, "rte_ip_frag_table_create failed");
 		rte_free(port);
 		return NULL;
 	}
@@ -282,7 +285,7 @@ rte_port_ring_writer_ras_free(void *port)
 			port;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__);
+		RTE_PORT_RAS_LOG(ERR, "Parameter port is NULL");
 		return -1;
 	}
 
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..bc9cb4f72b15 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,10 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_PORT_RING_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_ring_logtype,	\
+		"%s: " fmt "\n", __func__, ## args)
 /*
  * Port RING Reader
  */
@@ -46,7 +50,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,
 		(conf->ring == NULL) ||
 		(rte_ring_is_cons_single(conf->ring) && is_multi) ||
 		(!rte_ring_is_cons_single(conf->ring) && !is_multi)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Invalid Parameters");
 		return NULL;
 	}
 
@@ -54,7 +58,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -107,7 +111,7 @@ static int
 rte_port_ring_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -174,7 +178,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,
 		(rte_ring_is_prod_single(conf->ring) && is_multi) ||
 		(!rte_ring_is_prod_single(conf->ring) && !is_multi) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Invalid Parameters");
 		return NULL;
 	}
 
@@ -182,7 +186,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -370,7 +374,7 @@ rte_port_ring_writer_free(void *port)
 	struct rte_port_ring_writer *p = port;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -443,7 +447,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,
 		(rte_ring_is_prod_single(conf->ring) && is_multi) ||
 		(!rte_ring_is_prod_single(conf->ring) && !is_multi) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Invalid Parameters");
 		return NULL;
 	}
 
@@ -451,7 +455,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -703,7 +707,7 @@ rte_port_ring_writer_nodrop_free(void *port)
 			port;
 
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_RING_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..8a421855f7e2 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,10 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_PORT_SCHED_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_sched_logtype,	\
+		"%s: " fmt "\n", __func__, ##args)
 /*
  * Reader
  */
@@ -40,7 +44,7 @@ rte_port_sched_reader_create(void *params, int socket_id)
 	/* Check input parameters */
 	if ((conf == NULL) ||
 	    (conf->sched == NULL)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Invalid params");
 		return NULL;
 	}
 
@@ -48,7 +52,7 @@ rte_port_sched_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -74,7 +78,7 @@ static int
 rte_port_sched_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -139,7 +143,7 @@ rte_port_sched_writer_create(void *params, int socket_id)
 	    (conf->tx_burst_sz == 0) ||
 	    (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Invalid params");
 		return NULL;
 	}
 
@@ -147,7 +151,7 @@ rte_port_sched_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -247,7 +251,7 @@ static int
 rte_port_sched_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_SCHED_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..80c31d6cee6a 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,12 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+
+#define RTE_PORT_SOURCE_LOG(level, fmt, args...)	\
+	rte_log(RTE_LOG_ ## level, port_source_logtype,	\
+		"%s: " fmt "\n", __func__, ##args)
+
 /*
  * Port SOURCE
  */
@@ -49,9 +55,9 @@ struct rte_port_source {
 
 static int
 pcap_source_load(struct rte_port_source *port,
-		const char *file_name,
-		uint32_t n_bytes_per_pkt,
-		int socket_id)
+		 const char *file_name,
+		 uint32_t n_bytes_per_pkt,
+		 int socket_id)
 {
 	uint32_t n_pkts = 0;
 	uint32_t i;
@@ -64,8 +70,8 @@ pcap_source_load(struct rte_port_source *port,
 	const uint8_t *pkt;
 	uint8_t *buff = NULL;
 	uint32_t pktmbuf_maxlen = (uint32_t)
-			(rte_pktmbuf_data_room_size(port->mempool) -
-			RTE_PKTMBUF_HEADROOM);
+		(rte_pktmbuf_data_room_size(port->mempool) -
+		 RTE_PKTMBUF_HEADROOM);
 
 	if (n_bytes_per_pkt == 0)
 		max_len = pktmbuf_maxlen;
@@ -75,8 +81,9 @@ pcap_source_load(struct rte_port_source *port,
 	/* first time open, get packet number */
 	pcap_handle = pcap_open_offline(file_name, pcap_errbuf);
 	if (pcap_handle == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"'%s' for reading\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file '%s' for reading",
+				    file_name);
 		goto error_exit;
 	}
 
@@ -86,31 +93,32 @@ pcap_source_load(struct rte_port_source *port,
 	pcap_close(pcap_handle);
 
 	port->pkt_len = rte_zmalloc_socket("PCAP",
-		(sizeof(*port->pkt_len) * n_pkts), 0, socket_id);
+					   (sizeof(*port->pkt_len) * n_pkts), 0, socket_id);
 	if (port->pkt_len == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
 	pkt_len_aligns = rte_malloc("PCAP",
-		(sizeof(*pkt_len_aligns) * n_pkts), 0);
+				    (sizeof(*pkt_len_aligns) * n_pkts), 0);
 	if (pkt_len_aligns == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
 	port->pkts = rte_zmalloc_socket("PCAP",
-		(sizeof(*port->pkts) * n_pkts), 0, socket_id);
+					(sizeof(*port->pkts) * n_pkts), 0, socket_id);
 	if (port->pkts == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
 	/* open 2nd time, get pkt_len */
 	pcap_handle = pcap_open_offline(file_name, pcap_errbuf);
 	if (pcap_handle == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"'%s' for reading\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file '%s' for reading",
+				    file_name);
 		goto error_exit;
 	}
 
@@ -126,9 +134,9 @@ pcap_source_load(struct rte_port_source *port,
 
 	/* allocate a big trunk of data for pcap file load */
 	buff = rte_zmalloc_socket("PCAP",
-		total_buff_len, 0, socket_id);
+				  total_buff_len, 0, socket_id);
 	if (buff == NULL) {
-		RTE_LOG(ERR, PORT, "No enough memory\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Not enough memory");
 		goto error_exit;
 	}
 
@@ -137,8 +145,9 @@ pcap_source_load(struct rte_port_source *port,
 	/* open file one last time to copy the pkt content */
 	pcap_handle = pcap_open_offline(file_name, pcap_errbuf);
 	if (pcap_handle == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"'%s' for reading\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file '%s' for reading",
+				    file_name);
 		goto error_exit;
 	}
 
@@ -155,9 +164,9 @@ pcap_source_load(struct rte_port_source *port,
 
 	rte_free(pkt_len_aligns);
 
-	RTE_LOG(INFO, PORT, "Successfully load pcap file "
-		"'%s' with %u pkts\n",
-		file_name, port->n_pkts);
+	RTE_PORT_SOURCE_LOG(INFO,
+			    "Successfully load pcap file '%s' with %u pkts",
+			    file_name, port->n_pkts);
 
 	return 0;
 
@@ -180,8 +189,8 @@ pcap_source_load(struct rte_port_source *port,
 	int _ret = 0;						\
 								\
 	if (file_name) {					\
-		RTE_LOG(ERR, PORT, "Source port field "		\
-			"\"file_name\" is not NULL.\n");	\
+		RTE_PORT_SOURCE_LOG(ERR, "Source port field "	\
+			"\"file_name\" is not NULL.");		\
 		_ret = -1;					\
 	}							\
 								\
@@ -199,7 +208,7 @@ rte_port_source_create(void *params, int socket_id)
 
 	/* Check input arguments*/
 	if ((p == NULL) || (p->mempool == NULL)) {
-		RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
+		RTE_PORT_SOURCE_LOG(ERR, "Invalid params");
 		return NULL;
 	}
 
@@ -207,7 +216,7 @@ rte_port_source_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -332,15 +341,16 @@ pcap_sink_open(struct rte_port_sink *port,
 	/** Open a dead pcap handler for opening dumper file */
 	tx_pcap = pcap_open_dead(DLT_EN10MB, 65535);
 	if (tx_pcap == NULL) {
-		RTE_LOG(ERR, PORT, "Cannot open pcap dead handler\n");
+		RTE_PORT_SOURCE_LOG(ERR, "Cannot open pcap dead handler");
 		return -1;
 	}
 
 	/* The dumper is created using the previous pcap_t reference */
 	pcap_dumper = pcap_dump_open(tx_pcap, file_name);
 	if (pcap_dumper == NULL) {
-		RTE_LOG(ERR, PORT, "Failed to open pcap file "
-			"\"%s\" for writing\n", file_name);
+		RTE_PORT_SOURCE_LOG(ERR,
+				    "Failed to open pcap file \"%s\" for writing",
+				    file_name);
 		return -1;
 	}
 
@@ -349,8 +359,9 @@ pcap_sink_open(struct rte_port_sink *port,
 	port->pkt_index = 0;
 	port->dump_finish = 0;
 
-	RTE_LOG(INFO, PORT, "Ready to dump packets to file \"%s\"\n",
-		file_name);
+	RTE_PORT_SOURCE_LOG(INFO,
+			    "Ready to dump packets to file \"%s\"",
+			    file_name);
 
 	return 0;
 }
@@ -402,8 +413,9 @@ pcap_sink_write_pkt(struct rte_port_sink *port, struct rte_mbuf *mbuf)
 
 	if ((port->max_pkts != 0) && (port->pkt_index >= port->max_pkts)) {
 		port->dump_finish = 1;
-		RTE_LOG(INFO, PORT, "Dumped %u packets to file\n",
-				port->pkt_index);
+		RTE_PORT_SOURCE_LOG(INFO,
+				    "Dumped %u packets to file",
+				    port->pkt_index);
 	}
 
 }
@@ -433,7 +445,7 @@ do {								\
 	int _ret = 0;						\
 								\
 	if (file_name) {					\
-		RTE_LOG(ERR, PORT, "Sink port field "		\
+		RTE_PORT_SOURCE_LOG(ERR, "Sink port field "	\
 			"\"file_name\" is not NULL.\n");	\
 		_ret = -1;					\
 	}							\
@@ -459,7 +471,7 @@ rte_port_sink_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..3a55a5fde6fb 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,10 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_PORT_CRYPTO_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, port_crypto_logtype,	\
+		"%s: " fmt "\n", __func__, ##args)
 /*
  * Port Crypto Reader
  */
@@ -44,7 +48,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id)
 
 	/* Check input parameters */
 	if (conf == NULL) {
-		RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "params is NULL");
 		return NULL;
 	}
 
@@ -52,7 +56,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -100,7 +104,7 @@ static int
 rte_port_sym_crypto_reader_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "port is NULL");
 		return -EINVAL;
 	}
 
@@ -167,7 +171,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -175,7 +179,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -285,7 +289,7 @@ static int
 rte_port_sym_crypto_writer_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
@@ -353,7 +357,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id)
 		(conf->tx_burst_sz == 0) ||
 		(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
 		(!rte_is_power_of_2(conf->tx_burst_sz))) {
-		RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters");
 		return NULL;
 	}
 
@@ -361,7 +365,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id)
 	port = rte_zmalloc_socket("PORT", sizeof(*port),
 		RTE_CACHE_LINE_SIZE, socket_id);
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port");
 		return NULL;
 	}
 
@@ -497,7 +501,7 @@ static int
 rte_port_sym_crypto_writer_nodrop_free(void *port)
 {
 	if (port == NULL) {
-		RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__);
+		RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL");
 		return -EINVAL;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 14/16] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 13/16] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 15/16] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 16/16] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type Stephen Hemminger
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   |  1 -
 lib/eal/include/rte_log.h         |  2 +-
 lib/table/rte_table_acl.c         | 90 +++++++++++++------------------
 lib/table/rte_table_array.c       | 23 ++++----
 lib/table/rte_table_hash_cuckoo.c | 30 ++++++-----
 lib/table/rte_table_hash_ext.c    | 34 +++++++-----
 lib/table/rte_table_hash_key16.c  | 56 ++++++++++---------
 lib/table/rte_table_hash_key32.c  | 62 ++++++++++-----------
 lib/table/rte_table_hash_key8.c   | 59 ++++++++++----------
 lib/table/rte_table_hash_lru.c    | 35 ++++++------
 lib/table/rte_table_lpm.c         | 54 +++++++++----------
 lib/table/rte_table_lpm_ipv6.c    | 56 +++++++++----------
 lib/table/rte_table_stub.c        |  9 ++--
 13 files changed, 257 insertions(+), 254 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7002e267be37..a4e718e51d12 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index ff714a703be7..af87eb42ddb3 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..87081f183862 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,11 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_acl, acl, INFO);
+#define TABLE_ACL_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, table_logtype_acl,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
@@ -65,22 +70,20 @@ rte_table_acl_create(
 
 	/* Check input parameters */
 	if (p == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid value for params\n", __func__);
+		TABLE_ACL_LOG(ERR, "Invalid value for params");
 		return NULL;
 	}
 	if (p->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid value for name\n", __func__);
+		TABLE_ACL_LOG(ERR, "Invalid value for name");
 		return NULL;
 	}
 	if (p->n_rules == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid value for n_rules\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "Invalid value for n_rules");
 		return NULL;
 	}
 	if ((p->n_rule_fields == 0) ||
 	    (p->n_rule_fields > RTE_ACL_MAX_FIELDS)) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid value for n_rule_fields\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "Invalid value for n_rule_fields");
 		return NULL;
 	}
 
@@ -98,9 +101,7 @@ rte_table_acl_create(
 	acl = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (acl == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %u bytes for ACL table\n",
-			__func__, total_size);
+		TABLE_ACL_LOG(ERR,"Cannot allocate %u bytes for ACL table", total_size);
 		return NULL;
 	}
 
@@ -140,7 +141,7 @@ rte_table_acl_free(void *table)
 
 	/* Check input parameters */
 	if (table == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -164,8 +165,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx)
 	/* Create low level ACL table */
 	ctx = rte_acl_create(&acl->acl_params);
 	if (ctx == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot create low level ACL table\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "Cannot create low level ACL table");
 		return -1;
 	}
 
@@ -176,9 +176,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx)
 			status = rte_acl_add_rules(ctx, acl->acl_rule_list[i],
 				1);
 			if (status != 0) {
-				RTE_LOG(ERR, TABLE,
-				"%s: Cannot add rule to low level ACL table\n",
-					__func__);
+				TABLE_ACL_LOG(ERR, "Cannot add rule to low level ACL table");
 				rte_acl_free(ctx);
 				return -1;
 			}
@@ -196,9 +194,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx)
 	/* Build low level ACl table */
 	status = rte_acl_build(ctx, &acl->cfg);
 	if (status != 0) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot build the low level ACL table\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "Cannot build the low level ACL table");
 		rte_acl_free(ctx);
 		return -1;
 	}
@@ -226,29 +222,27 @@ rte_table_acl_entry_add(
 
 	/* Check input parameters */
 	if (table == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (key == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 	if (entry == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "entry parameter is NULL");
 		return -EINVAL;
 	}
 	if (key_found == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "key_found parameter is NULL");
 		return -EINVAL;
 	}
 	if (entry_ptr == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entry_ptr parameter is NULL\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "entry_ptr parameter is NULL");
 		return -EINVAL;
 	}
 	if (rule->priority > RTE_ACL_MAX_PRIORITY) {
-		RTE_LOG(ERR, TABLE, "%s: Priority is too high\n", __func__);
+		TABLE_ACL_LOG(ERR, "Priority is too high");
 		return -EINVAL;
 	}
 
@@ -291,8 +285,7 @@ rte_table_acl_entry_add(
 
 	/* Return if max rules */
 	if (free_pos_valid == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Max number of rules reached\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "Max number of rules reached");
 		return -ENOSPC;
 	}
 
@@ -342,16 +335,15 @@ rte_table_acl_entry_delete(
 
 	/* Check input parameters */
 	if (table == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (key == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 	if (key_found == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "key_found parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -424,29 +416,27 @@ rte_table_acl_entry_add_bulk(
 
 	/* Check input parameters */
 	if (table == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (keys == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: keys parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "keys parameter is NULL");
 		return -EINVAL;
 	}
 	if (entries == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entries parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "entries parameter is NULL");
 		return -EINVAL;
 	}
 	if (n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: 0 rules to add\n", __func__);
+		TABLE_ACL_LOG(ERR, "0 rules to add");
 		return -EINVAL;
 	}
 	if (key_found == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "key_found parameter is NULL");
 		return -EINVAL;
 	}
 	if (entries_ptr == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entries_ptr parameter is NULL\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "entries_ptr parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -455,20 +445,18 @@ rte_table_acl_entry_add_bulk(
 		struct rte_table_acl_rule_add_params *rule;
 
 		if (keys[i] == NULL) {
-			RTE_LOG(ERR, TABLE, "%s: keys[%" PRIu32 "] parameter is NULL\n",
-					__func__, i);
+			TABLE_ACL_LOG(ERR, "keys[%" PRIu32 "] parameter is NULL\n", i);
 			return -EINVAL;
 		}
 
 		if (entries[i] == NULL) {
-			RTE_LOG(ERR, TABLE, "%s: entries[%" PRIu32 "] parameter is NULL\n",
-					__func__, i);
+			TABLE_ACL_LOG(ERR, "entries[%" PRIu32 "] parameter is NULL\n", i);
 			return -EINVAL;
 		}
 
 		rule = keys[i];
 		if (rule->priority > RTE_ACL_MAX_PRIORITY) {
-			RTE_LOG(ERR, TABLE, "%s: Priority is too high\n", __func__);
+			TABLE_ACL_LOG(ERR, "Priority is too high");
 			return -EINVAL;
 		}
 	}
@@ -604,27 +592,25 @@ rte_table_acl_entry_delete_bulk(
 
 	/* Check input parameters */
 	if (table == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (keys == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__);
+		TABLE_ACL_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 	if (n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: 0 rules to delete\n", __func__);
+		TABLE_ACL_LOG(ERR, "0 rules to delete");
 		return -EINVAL;
 	}
 	if (key_found == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n",
-			__func__);
+		TABLE_ACL_LOG(ERR, "key_found parameter is NULL");
 		return -EINVAL;
 	}
 
 	for (i = 0; i < n_keys; i++) {
 		if (keys[i] == NULL) {
-			RTE_LOG(ERR, TABLE, "%s: keys[%" PRIu32 "] parameter is NULL\n",
-					__func__, i);
+			TABLE_ACL_LOG(ERR, "keys[%" PRIu32 "] parameter is NULL", i);
 			return -EINVAL;
 		}
 	}
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..47b5a2b15b2b 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,11 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_array, array, INFO);
+#define TABLE_ARRAY_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, table_logtype_array,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
@@ -61,9 +66,7 @@ rte_table_array_create(void *params, int socket_id, uint32_t entry_size)
 	total_size = total_cl_size * RTE_CACHE_LINE_SIZE;
 	t = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id);
 	if (t == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %u bytes for array table\n",
-			__func__, total_size);
+		TABLE_ARRAY_LOG(ERR, "Cannot allocate %u bytes for array table\n", total_size);
 		return NULL;
 	}
 
@@ -83,7 +86,7 @@ rte_table_array_free(void *table)
 
 	/* Check input parameters */
 	if (t == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ARRAY_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -107,25 +110,23 @@ rte_table_array_entry_add(
 
 	/* Check input parameters */
 	if (table == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_ARRAY_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (key == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__);
+		TABLE_ARRAY_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 	if (entry == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__);
+		TABLE_ARRAY_LOG(ERR, "entry parameter is NULL");
 		return -EINVAL;
 	}
 	if (key_found == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n",
-			__func__);
+		TABLE_ARRAY_LOG(ERR, "key_found parameter is NULL");
 		return -EINVAL;
 	}
 	if (entry_ptr == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entry_ptr parameter is NULL\n",
-			__func__);
+		TABLE_ARRAY_LOG(ERR, "entry_ptr parameter is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..7b1f1575e564 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,11 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_hash, hash, INFO);
+#define TABLE_HASH_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, table_logtype_hash,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
@@ -47,27 +52,27 @@ static int
 check_params_create_hash_cuckoo(struct rte_table_hash_cuckoo_params *params)
 {
 	if (params == NULL) {
-		RTE_LOG(ERR, TABLE, "NULL Input Parameters.\n");
+		TABLE_HASH_LOG(ERR, "NULL Input Parameters.");
 		return -EINVAL;
 	}
 
 	if (params->name == NULL) {
-		RTE_LOG(ERR, TABLE, "Table name is NULL.\n");
+		TABLE_HASH_LOG(ERR, "Table name is NULL.");
 		return -EINVAL;
 	}
 
 	if (params->key_size == 0) {
-		RTE_LOG(ERR, TABLE, "Invalid key_size.\n");
+		TABLE_HASH_LOG(ERR, "Invalid key_size.");
 		return -EINVAL;
 	}
 
 	if (params->n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "Invalid n_keys.\n");
+		TABLE_HASH_LOG(ERR, "Invalid n_keys.");
 		return -EINVAL;
 	}
 
 	if (params->f_hash == NULL) {
-		RTE_LOG(ERR, TABLE, "f_hash is NULL.\n");
+		TABLE_HASH_LOG(ERR, "f_hash is NULL.");
 		return -EINVAL;
 	}
 
@@ -94,9 +99,8 @@ rte_table_hash_cuckoo_create(void *params,
 
 	t = rte_zmalloc_socket(p->name, total_size, RTE_CACHE_LINE_SIZE, socket_id);
 	if (t == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %u bytes for cuckoo hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH_LOG(ERR, "Cannot allocate %u bytes for cuckoo hash table %s",
+			       total_size, p->name);
 		return NULL;
 	}
 
@@ -114,9 +118,8 @@ rte_table_hash_cuckoo_create(void *params,
 	if (h_table == NULL) {
 		h_table = rte_hash_create(&hash_cuckoo_params);
 		if (h_table == NULL) {
-			RTE_LOG(ERR, TABLE,
-				"%s: failed to create cuckoo hash table %s\n",
-				__func__, p->name);
+			TABLE_HASH_LOG(ERR, "failed to create cuckoo hash table %s",
+				       p->name);
 			rte_free(t);
 			return NULL;
 		}
@@ -131,9 +134,8 @@ rte_table_hash_cuckoo_create(void *params,
 	t->key_offset = p->key_offset;
 	t->h_table = h_table;
 
-	RTE_LOG(INFO, TABLE,
-		"%s: Cuckoo hash table %s memory footprint is %u bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH_LOG(INFO, "Cuckoo hash table %s memory footprint is %u bytes",
+		       p->name, total_size);
 	return t;
 }
 
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..ca16328c1612 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,11 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_hash_ext, hash.ext, INFO);
+#define TABLE_HASH_EXT_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, table_logtype_hash_ext,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
@@ -128,33 +133,33 @@ check_params_create(struct rte_table_hash_params *params)
 {
 	/* name */
 	if (params->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__);
+		TABLE_HASH_EXT_LOG(ERR, "name invalid value");
 		return -EINVAL;
 	}
 
 	/* key_size */
 	if ((params->key_size < sizeof(uint64_t)) ||
 		(!rte_is_power_of_2(params->key_size))) {
-		RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__);
+		TABLE_HASH_EXT_LOG(ERR, "key_size invalid value");
 		return -EINVAL;
 	}
 
 	/* n_keys */
 	if (params->n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: n_keys invalid value\n", __func__);
+		TABLE_HASH_EXT_LOG(ERR, "n_keys invalid value");
 		return -EINVAL;
 	}
 
 	/* n_buckets */
 	if ((params->n_buckets == 0) ||
 		(!rte_is_power_of_2(params->n_buckets))) {
-		RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__);
+		TABLE_HASH_EXT_LOG(ERR, "n_buckets invalid value");
 		return -EINVAL;
 	}
 
 	/* f_hash */
 	if (params->f_hash == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: f_hash invalid value\n", __func__);
+		TABLE_HASH_EXT_LOG(ERR, "f_hash invalid value");
 		return -EINVAL;
 	}
 
@@ -211,9 +216,9 @@ rte_table_hash_ext_create(void *params, int socket_id, uint32_t entry_size)
 		key_sz + key_stack_sz + bkt_ext_stack_sz + data_sz;
 
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes"
-			" for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH_EXT_LOG(ERR,
+				   "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				   total_size, p->name);
 		return NULL;
 	}
 
@@ -222,14 +227,15 @@ rte_table_hash_ext_create(void *params, int socket_id, uint32_t entry_size)
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (t == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes"
-			" for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH_EXT_LOG(ERR,
+				   "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				   total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE, "%s (%u-byte key): Hash table %s memory "
-		"footprint is %" PRIu64 " bytes\n",
-		__func__, p->key_size, p->name, total_size);
+
+	TABLE_HASH_EXT_LOG(INFO,
+			   "(%u-byte key): Hash table %s memory footprint is %" PRIu64 " bytes",
+			   p->key_size, p->name, total_size);
 
 	/* Memory initialization */
 	t->key_size = p->key_size;
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..5501a9c5fc54 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,11 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_hash16, hash16, INFO);
+#define TABLE_HASH16_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, table_logtype_hash16,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
@@ -107,33 +112,32 @@ check_params_create(struct rte_table_hash_params *params)
 {
 	/* name */
 	if (params->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__);
+		TABLE_HASH16_LOG(ERR, "name invalid value");
 		return -EINVAL;
 	}
 
 	/* key_size */
 	if (params->key_size != KEY_SIZE) {
-		RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__);
+		TABLE_HASH16_LOG(ERR, "key_size invalid value");
 		return -EINVAL;
 	}
 
 	/* n_keys */
 	if (params->n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__);
+		TABLE_HASH16_LOG(ERR, "n_keys is zero");
 		return -EINVAL;
 	}
 
 	/* n_buckets */
 	if ((params->n_buckets == 0) ||
 		(!rte_is_power_of_2(params->n_buckets))) {
-		RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__);
+		TABLE_HASH16_LOG(ERR, "n_buckets invalid value");
 		return -EINVAL;
 	}
 
 	/* f_hash */
 	if (params->f_hash == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
-			__func__);
+		TABLE_HASH16_LOG(ERR, "f_hash function pointer is NULL");
 		return -EINVAL;
 	}
 
@@ -181,9 +185,9 @@ rte_table_hash_create_key16_lru(void *params,
 	total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size;
 
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-		"for hash table %s\n",
-		__func__, total_size, p->name);
+		TABLE_HASH16_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
 
@@ -192,14 +196,14 @@ rte_table_hash_create_key16_lru(void *params,
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-		"for hash table %s\n",
-		__func__, total_size, p->name);
+		TABLE_HASH16_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint "
-		"is %" PRIu64 " bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH16_LOG(INFO,
+			 "Hash table %s memory footprint is %" PRIu64 " bytes",
+			 p->name, total_size);
 
 	/* Memory initialization */
 	f->n_buckets = n_buckets;
@@ -236,7 +240,7 @@ rte_table_hash_free_key16_lru(void *table)
 
 	/* Check input parameters */
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_HASH16_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -391,9 +395,9 @@ rte_table_hash_create_key16_ext(void *params,
 	total_size = sizeof(struct rte_table_hash) +
 		(p->n_buckets + n_buckets_ext) * bucket_size + stack_size;
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH16_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
 
@@ -402,14 +406,14 @@ rte_table_hash_create_key16_ext(void *params,
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH16_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint "
-		"is %" PRIu64 " bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH16_LOG(INFO,
+			 "Hash table %s memory footprint is %" PRIu64 " bytes",
+			 p->name, total_size);
 
 	/* Memory initialization */
 	f->n_buckets = p->n_buckets;
@@ -446,7 +450,7 @@ rte_table_hash_free_key16_ext(void *table)
 
 	/* Check input parameters */
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_HASH16_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..d830c6b3784a 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,11 +11,16 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_logtype_hash32, hash32, INFO);
+#define TABLE_HASH32_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, table_logtype_hash32,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
-#define RTE_BUCKET_ENTRY_VALID						0x1LLU
+#define RTE_BUCKET_ENTRY_VALID				0x1LLU
 
 #ifdef RTE_TABLE_STATS_COLLECT
 
@@ -111,33 +116,32 @@ check_params_create(struct rte_table_hash_params *params)
 {
 	/* name */
 	if (params->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__);
+		TABLE_HASH32_LOG(ERR, "name invalid value");
 		return -EINVAL;
 	}
 
 	/* key_size */
 	if (params->key_size != KEY_SIZE) {
-		RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__);
+		TABLE_HASH32_LOG(ERR, "key_size invalid value");
 		return -EINVAL;
 	}
 
 	/* n_keys */
 	if (params->n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__);
+		TABLE_HASH32_LOG(ERR, "n_keys is zero");
 		return -EINVAL;
 	}
 
 	/* n_buckets */
 	if ((params->n_buckets == 0) ||
 		(!rte_is_power_of_2(params->n_buckets))) {
-		RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__);
+		TABLE_HASH32_LOG(ERR, "n_buckets invalid value");
 		return -EINVAL;
 	}
 
 	/* f_hash */
 	if (params->f_hash == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
-			__func__);
+		TABLE_HASH32_LOG(ERR, "f_hash function pointer is NULL");
 		return -EINVAL;
 	}
 
@@ -184,9 +188,9 @@ rte_table_hash_create_key32_lru(void *params,
 		KEYS_PER_BUCKET * entry_size);
 	total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size;
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH32_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
 
@@ -195,15 +199,14 @@ rte_table_hash_create_key32_lru(void *params,
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH32_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE,
-		"%s: Hash table %s memory footprint "
-		"is %" PRIu64 " bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH32_LOG(INFO,
+			 "Hash table %s memory footprint is %" PRIu64 " bytes",
+			 p->name, total_size);
 
 	/* Memory initialization */
 	f->n_buckets = n_buckets;
@@ -244,7 +247,7 @@ rte_table_hash_free_key32_lru(void *table)
 
 	/* Check input parameters */
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_HASH32_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -400,9 +403,9 @@ rte_table_hash_create_key32_ext(void *params,
 	total_size = sizeof(struct rte_table_hash) +
 		(p->n_buckets + n_buckets_ext) * bucket_size + stack_size;
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH32_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
 
@@ -411,15 +414,14 @@ rte_table_hash_create_key32_ext(void *params,
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH32_LOG(ERR,
+				 "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				 total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE,
-		"%s: Hash table %s memory footprint "
-		"is %" PRIu64" bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH32_LOG(INFO,
+			 "Hash table %s memory footprint is %" PRIu64" bytes",
+			 p->name, total_size);
 
 	/* Memory initialization */
 	f->n_buckets = p->n_buckets;
@@ -460,7 +462,7 @@ rte_table_hash_free_key32_ext(void *table)
 
 	/* Check input parameters */
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_HASH32_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..9678ee0741e5 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,12 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_logtype_hash8, hash8, INFO);
+#define TABLE_HASH8_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, table_logtype_hash8,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
@@ -101,33 +106,32 @@ check_params_create(struct rte_table_hash_params *params)
 {
 	/* name */
 	if (params->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__);
+		TABLE_HASH8_LOG(ERR, "name invalid value");
 		return -EINVAL;
 	}
 
 	/* key_size */
 	if (params->key_size != KEY_SIZE) {
-		RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__);
+		TABLE_HASH8_LOG(ERR, "key_size invalid value");
 		return -EINVAL;
 	}
 
 	/* n_keys */
 	if (params->n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__);
+		TABLE_HASH8_LOG(ERR, "n_keys is zero");
 		return -EINVAL;
 	}
 
 	/* n_buckets */
 	if ((params->n_buckets == 0) ||
 		(!rte_is_power_of_2(params->n_buckets))) {
-		RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__);
+		TABLE_HASH8_LOG(ERR, "n_buckets invalid value");
 		return -EINVAL;
 	}
 
 	/* f_hash */
 	if (params->f_hash == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
-			__func__);
+		TABLE_HASH8_LOG(ERR, "f_hash function pointer is NULL");
 		return -EINVAL;
 	}
 
@@ -173,9 +177,9 @@ rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size)
 	total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size;
 
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes"
-			" for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH8_LOG(ERR,
+				"Cannot allocate %" PRIu64 " bytes for hash table %s",
+				total_size, p->name);
 		return NULL;
 	}
 
@@ -184,15 +188,15 @@ rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size)
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes"
-			" for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH8_LOG(ERR,
+				"Cannot allocate %" PRIu64 " bytes for hash table %s",
+				total_size, p->name);
 		return NULL;
 	}
 
-	RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint "
-		"is %" PRIu64 " bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH8_LOG(INFO,
+			"Hash table %s memory footprint is %" PRIu64 " bytes",
+			p->name, total_size);
 
 	/* Memory initialization */
 	f->n_buckets = n_buckets;
@@ -226,7 +230,7 @@ rte_table_hash_free_key8_lru(void *table)
 
 	/* Check input parameters */
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_HASH8_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -377,9 +381,9 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size)
 		(p->n_buckets + n_buckets_ext) * bucket_size + stack_size;
 
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH8_LOG(ERR,
+				"Cannot allocate %" PRIu64 " bytes for hash table %s",
+				total_size, p->name);
 		return NULL;
 	}
 
@@ -388,15 +392,14 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size)
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %" PRIu64 " bytes "
-			"for hash table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH8_LOG(ERR,
+				"Cannot allocate %" PRIu64 " bytes for hash table %s",
+				total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint "
-		"is %" PRIu64 " bytes\n",
-		__func__, p->name, total_size);
+	TABLE_HASH8_LOG(INFO,
+			"Hash table %s memory footprint is %" PRIu64 " bytes",
+			p->name, total_size);
 
 	/* Memory initialization */
 	f->n_buckets = p->n_buckets;
@@ -430,7 +433,7 @@ rte_table_hash_free_key8_ext(void *table)
 
 	/* Check input parameters */
 	if (f == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_HASH8_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..9bc64f74c922 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,11 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_hash_lru, hash.lru, INFO);
+#define TABLE_HASH_LRU_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, table_logtype_hash_lru,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
@@ -105,33 +110,33 @@ check_params_create(struct rte_table_hash_params *params)
 {
 	/* name */
 	if (params->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__);
+		TABLE_HASH_LRU_LOG(ERR, "name invalid value");
 		return -EINVAL;
 	}
 
 	/* key_size */
 	if ((params->key_size < sizeof(uint64_t)) ||
 		(!rte_is_power_of_2(params->key_size))) {
-		RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__);
+		TABLE_HASH_LRU_LOG(ERR, "key_size invalid value");
 		return -EINVAL;
 	}
 
 	/* n_keys */
 	if (params->n_keys == 0) {
-		RTE_LOG(ERR, TABLE, "%s: n_keys invalid value\n", __func__);
+		TABLE_HASH_LRU_LOG(ERR, "n_keys invalid value");
 		return -EINVAL;
 	}
 
 	/* n_buckets */
 	if ((params->n_buckets == 0) ||
 		(!rte_is_power_of_2(params->n_buckets))) {
-		RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__);
+		TABLE_HASH_LRU_LOG(ERR, "n_buckets invalid value");
 		return -EINVAL;
 	}
 
 	/* f_hash */
 	if (params->f_hash == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: f_hash invalid value\n", __func__);
+		TABLE_HASH_LRU_LOG(ERR, "f_hash invalid value");
 		return -EINVAL;
 	}
 
@@ -187,10 +192,9 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size)
 		key_stack_sz + data_sz;
 
 	if (total_size > SIZE_MAX) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %" PRIu64 " bytes for hash "
-			"table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH_LRU_LOG(ERR,
+				   "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				   total_size, p->name);
 		return NULL;
 	}
 
@@ -199,15 +203,14 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size)
 		RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (t == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %" PRIu64 " bytes for hash "
-			"table %s\n",
-			__func__, total_size, p->name);
+		TABLE_HASH_LRU_LOG(ERR,
+				   "Cannot allocate %" PRIu64 " bytes for hash table %s",
+				   total_size, p->name);
 		return NULL;
 	}
-	RTE_LOG(INFO, TABLE, "%s (%u-byte key): Hash table %s memory footprint"
-		" is %" PRIu64 " bytes\n",
-		__func__, p->key_size, p->name, total_size);
+	TABLE_HASH_LRU_LOG(INFO,
+			   "(%u-byte key): Hash table %s memory footprint is %" PRIu64 " bytes",
+			   p->key_size, p->name, total_size);
 
 	/* Memory initialization */
 	t->key_size = p->key_size;
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..653e2604fd34 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,11 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_lpm, lpm, INFO);
+#define TABLE_LPM_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, table_logtype_lpm,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
@@ -59,30 +64,27 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size)
 
 	/* Check input parameters */
 	if (p == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: NULL input parameters\n", __func__);
+		TABLE_LPM_LOG(ERR, "NULL input parameters");
 		return NULL;
 	}
 	if (p->n_rules == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__);
+		TABLE_LPM_LOG(ERR, "Invalid n_rules");
 		return NULL;
 	}
 	if (p->number_tbl8s == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid number_tbl8s\n", __func__);
+		TABLE_LPM_LOG(ERR, "Invalid number_tbl8s");
 		return NULL;
 	}
 	if (p->entry_unique_size == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n",
-			__func__);
+		TABLE_LPM_LOG(ERR, "Invalid entry_unique_size");
 		return NULL;
 	}
 	if (p->entry_unique_size > entry_size) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n",
-			__func__);
+		TABLE_LPM_LOG(ERR, "Invalid entry_unique_size");
 		return NULL;
 	}
 	if (p->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Table name is NULL\n",
-			__func__);
+		TABLE_LPM_LOG(ERR, "Table name is NULL");
 		return NULL;
 	}
 	entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t));
@@ -93,9 +95,8 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size)
 	lpm = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %u bytes for LPM table\n",
-			__func__, total_size);
+		TABLE_LPM_LOG(ERR, "Cannot allocate %u bytes for LPM table",
+			      total_size);
 		return NULL;
 	}
 
@@ -107,7 +108,7 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size)
 
 	if (lpm->lpm == NULL) {
 		rte_free(lpm);
-		RTE_LOG(ERR, TABLE, "Unable to create low-level LPM table\n");
+		TABLE_LPM_LOG(ERR, "Unable to create low-level LPM table");
 		return NULL;
 	}
 
@@ -127,7 +128,7 @@ rte_table_lpm_free(void *table)
 
 	/* Check input parameters */
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_LPM_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -187,22 +188,20 @@ rte_table_lpm_entry_add(
 
 	/* Check input parameters */
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_LPM_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (ip_prefix == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n",
-			__func__);
+		TABLE_LPM_LOG(ERR, "ip_prefix parameter is NULL");
 		return -EINVAL;
 	}
 	if (entry == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__);
+		TABLE_LPM_LOG(ERR, "entry parameter is NULL");
 		return -EINVAL;
 	}
 
 	if ((ip_prefix->depth == 0) || (ip_prefix->depth > 32)) {
-		RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n",
-			__func__, ip_prefix->depth);
+		TABLE_LPM_LOG(ERR, "invalid depth (%d)", ip_prefix->depth);
 		return -EINVAL;
 	}
 
@@ -216,7 +215,7 @@ rte_table_lpm_entry_add(
 		uint8_t *nht_entry;
 
 		if (nht_find_free(lpm, &nht_pos) == 0) {
-			RTE_LOG(ERR, TABLE, "%s: NHT full\n", __func__);
+			TABLE_LPM_LOG(ERR, "NHT full");
 			return -1;
 		}
 
@@ -226,7 +225,7 @@ rte_table_lpm_entry_add(
 
 	/* Add rule to low level LPM table */
 	if (rte_lpm_add(lpm->lpm, ip_prefix->ip, ip_prefix->depth, nht_pos) < 0) {
-		RTE_LOG(ERR, TABLE, "%s: LPM rule add failed\n", __func__);
+		TABLE_LPM_LOG(ERR, "LPM rule add failed");
 		return -1;
 	}
 
@@ -253,16 +252,15 @@ rte_table_lpm_entry_delete(
 
 	/* Check input parameters */
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_LPM_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (ip_prefix == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n",
-			__func__);
+		TABLE_LPM_LOG(ERR, "ip_prefix parameter is NULL");
 		return -EINVAL;
 	}
 	if ((ip_prefix->depth == 0) || (ip_prefix->depth > 32)) {
-		RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__,
+		TABLE_LPM_LOG(ERR, "invalid depth (%d)",
 			ip_prefix->depth);
 		return -EINVAL;
 	}
@@ -271,7 +269,7 @@ rte_table_lpm_entry_delete(
 	status = rte_lpm_is_rule_present(lpm->lpm, ip_prefix->ip,
 		ip_prefix->depth, &nht_pos);
 	if (status < 0) {
-		RTE_LOG(ERR, TABLE, "%s: LPM algorithmic error\n", __func__);
+		TABLE_LPM_LOG(ERR, "LPM algorithmic error");
 		return -1;
 	}
 	if (status == 0) {
@@ -282,7 +280,7 @@ rte_table_lpm_entry_delete(
 	/* Delete rule from the low-level LPM table */
 	status = rte_lpm_delete(lpm->lpm, ip_prefix->ip, ip_prefix->depth);
 	if (status) {
-		RTE_LOG(ERR, TABLE, "%s: LPM rule delete failed\n", __func__);
+		TABLE_LPM_LOG(ERR, "LPM rule delete failed");
 		return -1;
 	}
 
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..9f87832ca8f0 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,11 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_lpm6, lpm6, INFO);
+#define TABLE_LPM6_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, table_logtype_lpm6,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
@@ -56,30 +61,27 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size)
 
 	/* Check input parameters */
 	if (p == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: NULL input parameters\n", __func__);
+		TABLE_LPM6_LOG(ERR, "NULL input parameters");
 		return NULL;
 	}
 	if (p->n_rules == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__);
+		TABLE_LPM6_LOG(ERR, "Invalid n_rules");
 		return NULL;
 	}
 	if (p->number_tbl8s == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__);
+		TABLE_LPM6_LOG(ERR, "Invalid n_rules");
 		return NULL;
 	}
 	if (p->entry_unique_size == 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "Invalid entry_unique_size");
 		return NULL;
 	}
 	if (p->entry_unique_size > entry_size) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "Invalid entry_unique_size");
 		return NULL;
 	}
 	if (p->name == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: Table name is NULL\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "Table name is NULL");
 		return NULL;
 	}
 	entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t));
@@ -90,9 +92,8 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size)
 	lpm = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %u bytes for LPM IPv6 table\n",
-			__func__, total_size);
+		TABLE_LPM6_LOG(ERR, "Cannot allocate %u bytes for LPM IPv6 table",
+			       total_size);
 		return NULL;
 	}
 
@@ -103,8 +104,7 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size)
 	lpm->lpm = rte_lpm6_create(p->name, socket_id, &lpm6_config);
 	if (lpm->lpm == NULL) {
 		rte_free(lpm);
-		RTE_LOG(ERR, TABLE,
-			"Unable to create low-level LPM IPv6 table\n");
+		TABLE_LPM6_LOG(ERR, "Unable to create low-level LPM IPv6 table\n");
 		return NULL;
 	}
 
@@ -124,7 +124,7 @@ rte_table_lpm_ipv6_free(void *table)
 
 	/* Check input parameters */
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_LPM6_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -184,21 +184,20 @@ rte_table_lpm_ipv6_entry_add(
 
 	/* Check input parameters */
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_LPM6_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (ip_prefix == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "ip_prefix parameter is NULL");
 		return -EINVAL;
 	}
 	if (entry == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__);
+		TABLE_LPM6_LOG(ERR, "entry parameter is NULL");
 		return -EINVAL;
 	}
 
 	if ((ip_prefix->depth == 0) || (ip_prefix->depth > 128)) {
-		RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__,
+		TABLE_LPM6_LOG(ERR, "invalid depth (%d)",
 			ip_prefix->depth);
 		return -EINVAL;
 	}
@@ -213,7 +212,7 @@ rte_table_lpm_ipv6_entry_add(
 		uint8_t *nht_entry;
 
 		if (nht_find_free(lpm, &nht_pos) == 0) {
-			RTE_LOG(ERR, TABLE, "%s: NHT full\n", __func__);
+			TABLE_LPM6_LOG(ERR, "NHT full");
 			return -1;
 		}
 
@@ -224,7 +223,7 @@ rte_table_lpm_ipv6_entry_add(
 	/* Add rule to low level LPM table */
 	if (rte_lpm6_add(lpm->lpm, ip_prefix->ip, ip_prefix->depth,
 		nht_pos) < 0) {
-		RTE_LOG(ERR, TABLE, "%s: LPM IPv6 rule add failed\n", __func__);
+		TABLE_LPM6_LOG(ERR, "LPM IPv6 rule add failed");
 		return -1;
 	}
 
@@ -252,16 +251,15 @@ rte_table_lpm_ipv6_entry_delete(
 
 	/* Check input parameters */
 	if (lpm == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__);
+		TABLE_LPM6_LOG(ERR, "table parameter is NULL");
 		return -EINVAL;
 	}
 	if (ip_prefix == NULL) {
-		RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "ip_prefix parameter is NULL");
 		return -EINVAL;
 	}
 	if ((ip_prefix->depth == 0) || (ip_prefix->depth > 128)) {
-		RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__,
+		TABLE_LPM6_LOG(ERR, "invalid depth (%d)",
 			ip_prefix->depth);
 		return -EINVAL;
 	}
@@ -270,8 +268,7 @@ rte_table_lpm_ipv6_entry_delete(
 	status = rte_lpm6_is_rule_present(lpm->lpm, ip_prefix->ip,
 		ip_prefix->depth, &nht_pos);
 	if (status < 0) {
-		RTE_LOG(ERR, TABLE, "%s: LPM IPv6 algorithmic error\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "LPM IPv6 algorithmic error");
 		return -1;
 	}
 	if (status == 0) {
@@ -282,8 +279,7 @@ rte_table_lpm_ipv6_entry_delete(
 	/* Delete rule from the low-level LPM table */
 	status = rte_lpm6_delete(lpm->lpm, ip_prefix->ip, ip_prefix->depth);
 	if (status) {
-		RTE_LOG(ERR, TABLE, "%s: LPM IPv6 rule delete failed\n",
-			__func__);
+		TABLE_LPM6_LOG(ERR, "LPM IPv6 rule delete failed");
 		return -1;
 	}
 
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..6ea978adfe80 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,11 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_logtype_stub, stub, INFO);
+#define TABLE_STUB_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, table_logtype_stub,	\
+		"%s(): " fmt "\n", __func__, ##args)
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
@@ -38,9 +43,7 @@ rte_table_stub_create(__rte_unused void *params,
 	stub = rte_zmalloc_socket("TABLE", size, RTE_CACHE_LINE_SIZE,
 		socket_id);
 	if (stub == NULL) {
-		RTE_LOG(ERR, TABLE,
-			"%s: Cannot allocate %u bytes for stub table\n",
-			__func__, size);
+		TABLE_STUB_LOG(ERR, "Cannot allocate %u bytes for stub table", size);
 		return NULL;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 15/16] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 14/16] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  2023-02-10  1:07   ` [PATCH v3 16/16] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type Stephen Hemminger
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v3 16/16] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-10  1:07   ` [PATCH v3 15/16] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-10  1:07   ` Stephen Hemminger
  15 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  1:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split the static global PIPELINE log type into multiple suffix
log types (by stage).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c |   1 -
 lib/eal/include/rte_log.h       |   2 +-
 lib/pipeline/rte_pipeline.c     | 242 ++++++++++++--------------------
 3 files changed, 87 insertions(+), 158 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a4e718e51d12..e4a4f7812bde 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index af87eb42ddb3..e2c11ad45c7f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..19597d4e0f1e 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,12 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+
+#define PIPELINE_LOG(level, fmt, args...)		\
+	rte_log(RTE_LOG_ ## level, pipeline_logtype,	\
+		"%s(): " fmt "\n", __func__, ## args)
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
@@ -161,23 +167,19 @@ static int
 rte_pipeline_check_params(struct rte_pipeline_params *params)
 {
 	if (params == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Incorrect value for parameter params\n", __func__);
+		PIPELINE_LOG(ERR, "Incorrect value for parameter params");
 		return -EINVAL;
 	}
 
 	/* name */
 	if (params->name == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Incorrect value for parameter name\n", __func__);
+		PIPELINE_LOG(ERR, "Incorrect value for parameter name");
 		return -EINVAL;
 	}
 
 	/* socket */
 	if (params->socket_id < 0) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Incorrect value for parameter socket_id\n",
-			__func__);
+		PIPELINE_LOG(ERR, "Incorrect value for parameter socket_id");
 		return -EINVAL;
 	}
 
@@ -193,9 +195,8 @@ rte_pipeline_create(struct rte_pipeline_params *params)
 	/* Check input parameters */
 	status = rte_pipeline_check_params(params);
 	if (status != 0) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Pipeline params check failed (%d)\n",
-			__func__, status);
+		PIPELINE_LOG(ERR, "Pipeline params check failed (%d)",
+			     status);
 		return NULL;
 	}
 
@@ -204,8 +205,7 @@ rte_pipeline_create(struct rte_pipeline_params *params)
 			RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Pipeline memory allocation failed\n", __func__);
+		PIPELINE_LOG(ERR, "Pipeline memory allocation failed");
 		return NULL;
 	}
 
@@ -233,8 +233,7 @@ rte_pipeline_free(struct rte_pipeline *p)
 
 	/* Check input parameters */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: rte_pipeline parameter is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "rte_pipeline parameter is NULL");
 		return -EINVAL;
 	}
 
@@ -275,45 +274,37 @@ rte_table_check_params(struct rte_pipeline *p,
 		uint32_t *table_id)
 {
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter is NULL");
 		return -EINVAL;
 	}
 	if (params == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: params parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "params parameter is NULL");
 		return -EINVAL;
 	}
 	if (table_id == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: table_id parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "table_id parameter is NULL");
 		return -EINVAL;
 	}
 
 	/* ops */
 	if (params->ops == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: params->ops is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "params->ops is NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_create == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_create function pointer is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_create function pointer is NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_lookup == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_lookup function pointer is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_lookup function pointer is NULL");
 		return -EINVAL;
 	}
 
 	/* De we have room for one more table? */
 	if (p->num_tables == RTE_PIPELINE_TABLE_MAX) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Incorrect value for num_tables parameter\n",
-			__func__);
+		PIPELINE_LOG(ERR, "Incorrect value for num_tables parameter");
 		return -EINVAL;
 	}
 
@@ -345,8 +336,7 @@ rte_pipeline_table_create(struct rte_pipeline *p,
 	default_entry = rte_zmalloc_socket(
 		"PIPELINE", entry_size, RTE_CACHE_LINE_SIZE, p->socket_id);
 	if (default_entry == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Failed to allocate default entry\n", __func__);
+		PIPELINE_LOG(ERR, "Failed to allocate default entry");
 		return -EINVAL;
 	}
 
@@ -355,7 +345,7 @@ rte_pipeline_table_create(struct rte_pipeline *p,
 		entry_size);
 	if (h_table == NULL) {
 		rte_free(default_entry);
-		RTE_LOG(ERR, PIPELINE, "%s: Table creation failed\n", __func__);
+		PIPELINE_LOG(ERR, "Table creation failed");
 		return -EINVAL;
 	}
 
@@ -401,20 +391,17 @@ rte_pipeline_table_default_entry_add(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (default_entry == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: default_entry parameter is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "default_entry parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: table_id %d out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table_id %d out of range", table_id);
 		return -EINVAL;
 	}
 
@@ -423,8 +410,7 @@ rte_pipeline_table_default_entry_add(struct rte_pipeline *p,
 	if ((default_entry->action == RTE_PIPELINE_ACTION_TABLE) &&
 		table->table_next_id_valid &&
 		(default_entry->table_id != table->table_next_id)) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Tree-like topologies not allowed\n", __func__);
+		PIPELINE_LOG(ERR, "Tree-like topologies not allowed");
 		return -EINVAL;
 	}
 
@@ -450,14 +436,12 @@ rte_pipeline_table_default_entry_delete(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: pipeline parameter is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "pipeline parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: table_id %d out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table_id %d out of range", table_id);
 		return -EINVAL;
 	}
 
@@ -486,41 +470,36 @@ rte_pipeline_table_entry_add(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (key == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: key parameter is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (entry == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: entry parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "entry parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: table_id %d out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table_id %d out of range", table_id);
 		return -EINVAL;
 	}
 
 	table = &p->tables[table_id];
 
 	if (table->ops.f_add == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: f_add function pointer NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "f_add function pointer NULL");
 		return -EINVAL;
 	}
 
 	if ((entry->action == RTE_PIPELINE_ACTION_TABLE) &&
 		table->table_next_id_valid &&
 		(entry->table_id != table->table_next_id)) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Tree-like topologies not allowed\n", __func__);
+		PIPELINE_LOG(ERR, "Tree-like topologies not allowed");
 		return -EINVAL;
 	}
 
@@ -546,28 +525,24 @@ rte_pipeline_table_entry_delete(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (key == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: key parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: table_id %d out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table_id %d out of range", table_id);
 		return -EINVAL;
 	}
 
 	table = &p->tables[table_id];
 
 	if (table->ops.f_delete == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_delete function pointer NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_delete function pointer NULL");
 		return -EINVAL;
 	}
 
@@ -587,33 +562,29 @@ int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (keys == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: keys parameter is NULL\n", __func__);
+		PIPELINE_LOG(ERR, "keys parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (entries == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: entries parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "entries parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: table_id %d out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table_id %d out of range", table_id);
 		return -EINVAL;
 	}
 
 	table = &p->tables[table_id];
 
 	if (table->ops.f_add_bulk == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: f_add_bulk function pointer NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "f_add_bulk function pointer NULL");
 		return -EINVAL;
 	}
 
@@ -621,8 +592,7 @@ int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p,
 		if ((entries[i]->action == RTE_PIPELINE_ACTION_TABLE) &&
 			table->table_next_id_valid &&
 			(entries[i]->table_id != table->table_next_id)) {
-			RTE_LOG(ERR, PIPELINE,
-				"%s: Tree-like topologies not allowed\n", __func__);
+			PIPELINE_LOG(ERR, "Tree-like topologies not allowed");
 			return -EINVAL;
 		}
 	}
@@ -651,28 +621,24 @@ int rte_pipeline_table_entry_delete_bulk(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (keys == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: key parameter is NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "key parameter is NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: table_id %d out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table_id %d out of range", table_id);
 		return -EINVAL;
 	}
 
 	table = &p->tables[table_id];
 
 	if (table->ops.f_delete_bulk == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_delete function pointer NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_delete function pointer NULL");
 		return -EINVAL;
 	}
 
@@ -690,51 +656,44 @@ rte_pipeline_port_in_check_params(struct rte_pipeline *p,
 		uint32_t *port_id)
 {
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 	if (params == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: params parameter NULL\n", __func__);
+		PIPELINE_LOG(ERR, "params parameter NULL");
 		return -EINVAL;
 	}
 	if (port_id == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: port_id parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "port_id parameter NULL");
 		return -EINVAL;
 	}
 
 	/* ops */
 	if (params->ops == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: params->ops parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "params->ops parameter NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_create == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_create function pointer NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_create function pointer NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_rx == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: f_rx function pointer NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "f_rx function pointer NULL");
 		return -EINVAL;
 	}
 
 	/* burst_size */
 	if ((params->burst_size == 0) ||
 		(params->burst_size > RTE_PORT_IN_BURST_SIZE_MAX)) {
-		RTE_LOG(ERR, PIPELINE, "%s: invalid value for burst_size\n",
-			__func__);
+		PIPELINE_LOG(ERR, "invalid value for burst_size");
 		return -EINVAL;
 	}
 
 	/* Do we have room for one more port? */
 	if (p->num_ports_in == RTE_PIPELINE_PORT_IN_MAX) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: invalid value for num_ports_in\n", __func__);
+		PIPELINE_LOG(ERR, "invalid value for num_ports_in");
 		return -EINVAL;
 	}
 
@@ -747,51 +706,44 @@ rte_pipeline_port_out_check_params(struct rte_pipeline *p,
 		uint32_t *port_id)
 {
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (params == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: params parameter NULL\n", __func__);
+		PIPELINE_LOG(ERR, "params parameter NULL");
 		return -EINVAL;
 	}
 
 	if (port_id == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: port_id parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "port_id parameter NULL");
 		return -EINVAL;
 	}
 
 	/* ops */
 	if (params->ops == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: params->ops parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "params->ops parameter NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_create == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_create function pointer NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_create function pointer NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_tx == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_tx function pointer NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_tx function pointer NULL");
 		return -EINVAL;
 	}
 
 	if (params->ops->f_tx_bulk == NULL) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: f_tx_bulk function pointer NULL\n", __func__);
+		PIPELINE_LOG(ERR, "f_tx_bulk function pointer NULL");
 		return -EINVAL;
 	}
 
 	/* Do we have room for one more port? */
 	if (p->num_ports_out == RTE_PIPELINE_PORT_OUT_MAX) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: invalid value for num_ports_out\n", __func__);
+		PIPELINE_LOG(ERR, "invalid value for num_ports_out");
 		return -EINVAL;
 	}
 
@@ -819,7 +771,7 @@ rte_pipeline_port_in_create(struct rte_pipeline *p,
 	/* Create the port */
 	h_port = params->ops->f_create(params->arg_create, p->socket_id);
 	if (h_port == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: Port creation failed\n", __func__);
+		PIPELINE_LOG(ERR, "Port creation failed");
 		return -EINVAL;
 	}
 
@@ -869,7 +821,7 @@ rte_pipeline_port_out_create(struct rte_pipeline *p,
 	/* Create the port */
 	h_port = params->ops->f_create(params->arg_create, p->socket_id);
 	if (h_port == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: Port creation failed\n", __func__);
+		PIPELINE_LOG(ERR, "Port creation failed");
 		return -EINVAL;
 	}
 
@@ -904,22 +856,17 @@ rte_pipeline_port_in_connect_to_table(struct rte_pipeline *p,
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (port_id >= p->num_ports_in) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: port IN ID %u is out of range\n",
-			__func__, port_id);
+		PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id);
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Table ID %u is out of range\n",
-			__func__, table_id);
+		PIPELINE_LOG(ERR, "Table ID %u is out of range", table_id);
 		return -EINVAL;
 	}
 
@@ -938,15 +885,12 @@ rte_pipeline_port_in_enable(struct rte_pipeline *p, uint32_t port_id)
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (port_id >= p->num_ports_in) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: port IN ID %u is out of range\n",
-			__func__, port_id);
+		PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id);
 		return -EINVAL;
 	}
 
@@ -985,14 +929,12 @@ rte_pipeline_port_in_disable(struct rte_pipeline *p, uint32_t port_id)
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-		__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (port_id >= p->num_ports_in) {
-		RTE_LOG(ERR, PIPELINE, "%s: port IN ID %u is out of range\n",
-			__func__, port_id);
+		PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id);
 		return -EINVAL;
 	}
 
@@ -1039,26 +981,22 @@ rte_pipeline_check(struct rte_pipeline *p)
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	/* Check that pipeline has at least one input port, one table and one
 	output port */
 	if (p->num_ports_in == 0) {
-		RTE_LOG(ERR, PIPELINE, "%s: must have at least 1 input port\n",
-			__func__);
+		PIPELINE_LOG(ERR, "must have at least 1 input port");
 		return -EINVAL;
 	}
 	if (p->num_tables == 0) {
-		RTE_LOG(ERR, PIPELINE, "%s: must have at least 1 table\n",
-			__func__);
+		PIPELINE_LOG(ERR, "must have at least 1 table");
 		return -EINVAL;
 	}
 	if (p->num_ports_out == 0) {
-		RTE_LOG(ERR, PIPELINE, "%s: must have at least 1 output port\n",
-			__func__);
+		PIPELINE_LOG(ERR, "must have at least 1 output port");
 		return -EINVAL;
 	}
 
@@ -1067,9 +1005,8 @@ rte_pipeline_check(struct rte_pipeline *p)
 		struct rte_port_in *port_in = &p->ports_in[port_in_id];
 
 		if (port_in->table_id == RTE_TABLE_INVALID) {
-			RTE_LOG(ERR, PIPELINE,
-				"%s: Port IN ID %u is not connected\n",
-				__func__, port_in_id);
+			PIPELINE_LOG(ERR, "Port IN ID %u is not connected",
+				     port_in_id);
 			return -EINVAL;
 		}
 	}
@@ -1451,8 +1388,7 @@ rte_pipeline_flush(struct rte_pipeline *p)
 
 	/* Check input arguments */
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
@@ -1504,15 +1440,12 @@ int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id,
 	int retval;
 
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (port_id >= p->num_ports_in) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: port IN ID %u is out of range\n",
-			__func__, port_id);
+		PIPELINE_LOG(ERR, "port IN ID %u is out of range", port_id);
 		return -EINVAL;
 	}
 
@@ -1541,13 +1474,12 @@ int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id,
 	int retval;
 
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", __func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (port_id >= p->num_ports_out) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: port OUT ID %u is out of range\n", __func__, port_id);
+		PIPELINE_LOG(ERR, "port OUT ID %u is out of range", port_id);
 		return -EINVAL;
 	}
 
@@ -1575,14 +1507,12 @@ int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id,
 	int retval;
 
 	if (p == NULL) {
-		RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n",
-			__func__);
+		PIPELINE_LOG(ERR, "pipeline parameter NULL");
 		return -EINVAL;
 	}
 
 	if (table_id >= p->num_tables) {
-		RTE_LOG(ERR, PIPELINE,
-				"%s: table %u is out of range\n", __func__, table_id);
+		PIPELINE_LOG(ERR, "table %u is out of range\n", table_id);
 		return -EINVAL;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v3 01/16] gso: remove logtype
  2023-02-10  1:07   ` [PATCH v3 01/16] gso: remove logtype Stephen Hemminger
@ 2023-02-10  1:47     ` fengchengwen
  2023-02-10  2:29     ` Hu, Jiayu
  1 sibling, 0 replies; 255+ messages in thread
From: fengchengwen @ 2023-02-10  1:47 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: jiayu.hu, Konstantin Ananyev, Mark Kavanagh

On 2023/2/10 9:07, Stephen Hemminger wrote:
> If a large packet is passed into GSO routines of unknown protocol
> then library would log a message and pass it through. This is incorrect
> behaviour on many levels:
>   - it allows oversize packet to get passed on to NIC driver
>   - no direct return is visible to applications
>   - if it happens once, many more will follow and log will fill.
>   - bonus it is only log message with GSO type.
> 
> The fix is to just return -EINVAL which is what this library
> does in many other places when looking at headers.

Hi Stephen,

1. this patch do two thing (remove logtype and return -EINVAL), suggest seperate them.
2. I think we should keep rte_gso_segment return 0 when unmatch:
   a. the rte_gso_segment API requirement input mbuf set right ol_flags:
       * Before calling rte_gso_segment(), applications must set proper ol_flags
       * for the packet. The GSO library uses the same macros as that of TSO.
       * For example, set RTE_MBUF_F_TX_TCP_SEG and RTE_MBUF_F_TX_IPV4 in ol_flags to segment
       * a TCP/IPv4 packet. If rte_gso_segment() succeeds, the RTE_MBUF_F_TX_TCP_SEG
       * flag is removed for all GSO segments and the input packet.
   b. the rte_gso_segment filter and process mbuf according "struct rte_gso_ctx", for one
      stream which combine with udp and vxlan-tcp, we could only segment vxlan-tcp.

Thanks.

> 
> Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
> Cc: jiayu.hu@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/eal/common/eal_common_log.c | 2 +-
>  lib/eal/include/rte_log.h       | 1 -
>  lib/gso/rte_gso.c               | 3 +--
>  3 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
> index bd7b188ceb4a..c369154cb1ea 100644
> --- a/lib/eal/common/eal_common_log.c
> +++ b/lib/eal/common/eal_common_log.c
> @@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = {
>  	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
>  	{RTE_LOGTYPE_EFD,        "lib.efd"},
>  	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
> -	{RTE_LOGTYPE_GSO,        "lib.gso"},
> +
>  	{RTE_LOGTYPE_USER1,      "user1"},
>  	{RTE_LOGTYPE_USER2,      "user2"},
>  	{RTE_LOGTYPE_USER3,      "user3"},
> diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
> index 6d2b0856a565..97d6b26a9967 100644
> --- a/lib/eal/include/rte_log.h
> +++ b/lib/eal/include/rte_log.h
> @@ -46,7 +46,6 @@ extern "C" {
>  #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
>  #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
>  #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
> -#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
>  
>  /* these log types can be used in an application */
>  #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
> diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
> index 4b59217c16ee..19c351769fcc 100644
> --- a/lib/gso/rte_gso.c
> +++ b/lib/gso/rte_gso.c
> @@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
>  				indirect_pool, pkts_out, nb_pkts_out);
>  	} else {
>  		/* unsupported packet, skip */
> -		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
> -		ret = 0;
> +		ret = -EINVAL;
>  	}
>  
>  	if (ret < 0) {
> 

^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type
  2023-02-10  1:07   ` [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
@ 2023-02-10  2:03     ` fengchengwen
  2023-02-10  2:47       ` Stephen Hemminger
  0 siblings, 1 reply; 255+ messages in thread
From: fengchengwen @ 2023-02-10  2:03 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Byron Marohn, Yipeng Wang

On 2023/2/10 9:07, Stephen Hemminger wrote:
> Replace all uses of global logtype with a local log type.
> Do not break message formats across source lines.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

...

>  };
>  EAL_REGISTER_TAILQ(rte_efd_tailq);
>  
> +RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
> +
> +#define EFD_LOG(level, fmt, args...) \
> +	rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args)
> +
>  /** Internal permutation array used to shuffle bins into pseudorandom groups */
>  const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = {
>  	{
> @@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
>  	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
>  
>  	if (online_cpu_socket_bitmask == 0) {
> -		RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled "
> -				"in the bitmask\n");
> +		EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask");

Hi Stephen,

Original output will be: EFD: At least one CPU ...
and new output will be: rte_efd_create(): At least one CPU ...

The new output don't have EFD (module or lib name), logs of the EFD module cannot be easily
filtered, althought new have function name, but will may not contains module name.

Suggest add module name in EFD_LOG:
#define EFD_LOG(level, fmt, args...) \
	rte_log(RTE_LOG_ ## level, efd_logtype, "EFD: %s(): " fmt "\n", __func__, ##args)

Thanks.

>  		return NULL;
>  	}
>  

...

^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [PATCH v3 01/16] gso: remove logtype
  2023-02-10  1:07   ` [PATCH v3 01/16] gso: remove logtype Stephen Hemminger
  2023-02-10  1:47     ` fengchengwen
@ 2023-02-10  2:29     ` Hu, Jiayu
  2023-02-10  2:46       ` Stephen Hemminger
  1 sibling, 1 reply; 255+ messages in thread
From: Hu, Jiayu @ 2023-02-10  2:29 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Konstantin Ananyev, Mark Kavanagh

Hi Stephen,

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, February 10, 2023 9:07 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Hu, Jiayu
> <jiayu.hu@intel.com>; Konstantin Ananyev
> <konstantin.v.ananyev@yandex.ru>; Mark Kavanagh
> <mark.b.kavanagh@intel.com>
> Subject: [PATCH v3 01/16] gso: remove logtype
> 
> If a large packet is passed into GSO routines of unknown protocol then library
> would log a message and pass it through. This is incorrect behaviour on many
> levels:
>   - it allows oversize packet to get passed on to NIC driver

Applications use SW GSO only if NIC segmentation is not
supported. For a burst of packets mixed with different packet
types, GSO doesn't process the packet with unsupported types,
and the oversize packets go to NIC and get dropped finally.
I presume this case frequently happen in real cases.

>   - no direct return is visible to applications
>   - if it happens once, many more will follow and log will fill.
>   - bonus it is only log message with GSO type.
> 
> The fix is to just return -EINVAL which is what this library does in many other
> places when looking at headers.
> 
> Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
> Cc: jiayu.hu@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/eal/common/eal_common_log.c | 2 +-
>  lib/eal/include/rte_log.h       | 1 -
>  lib/gso/rte_gso.c               | 3 +--
>  3 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/eal/common/eal_common_log.c
> b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..c369154cb1ea
> 100644
> --- a/lib/eal/common/eal_common_log.c
> +++ b/lib/eal/common/eal_common_log.c
> @@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = {
>  	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
>  	{RTE_LOGTYPE_EFD,        "lib.efd"},
>  	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
> -	{RTE_LOGTYPE_GSO,        "lib.gso"},
> +
>  	{RTE_LOGTYPE_USER1,      "user1"},
>  	{RTE_LOGTYPE_USER2,      "user2"},
>  	{RTE_LOGTYPE_USER3,      "user3"},
> diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index
> 6d2b0856a565..97d6b26a9967 100644
> --- a/lib/eal/include/rte_log.h
> +++ b/lib/eal/include/rte_log.h
> @@ -46,7 +46,6 @@ extern "C" {
>  #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
>  #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
>  #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
> -#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
> 
>  /* these log types can be used in an application */
>  #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
> diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index
> 4b59217c16ee..19c351769fcc 100644
> --- a/lib/gso/rte_gso.c
> +++ b/lib/gso/rte_gso.c
> @@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
>  				indirect_pool, pkts_out, nb_pkts_out);
>  	} else {
>  		/* unsupported packet, skip */
> -		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
> -		ret = 0;
> +		ret = -EINVAL;

If applications want to know that the packet is failed on SW GSO,
I think ENOTSUP is better than EINVAL, as it is not invalid input
from users.

Thanks,
Jiayu

>  	}
> 
>  	if (ret < 0) {
> --
> 2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v3 01/16] gso: remove logtype
  2023-02-10  2:29     ` Hu, Jiayu
@ 2023-02-10  2:46       ` Stephen Hemminger
  0 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  2:46 UTC (permalink / raw)
  To: Hu, Jiayu; +Cc: dev, Konstantin Ananyev, Mark Kavanagh

On Fri, 10 Feb 2023 02:29:44 +0000
"Hu, Jiayu" <jiayu.hu@intel.com> wrote:

> Hi Stephen,
> 
> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Friday, February 10, 2023 9:07 AM
> > To: dev@dpdk.org
> > Cc: Stephen Hemminger <stephen@networkplumber.org>; Hu, Jiayu
> > <jiayu.hu@intel.com>; Konstantin Ananyev
> > <konstantin.v.ananyev@yandex.ru>; Mark Kavanagh
> > <mark.b.kavanagh@intel.com>
> > Subject: [PATCH v3 01/16] gso: remove logtype
> > 
> > If a large packet is passed into GSO routines of unknown protocol then library
> > would log a message and pass it through. This is incorrect behaviour on many
> > levels:
> >   - it allows oversize packet to get passed on to NIC driver  
> 
> Applications use SW GSO only if NIC segmentation is not
> supported. For a burst of packets mixed with different packet
> types, GSO doesn't process the packet with unsupported types,
> and the oversize packets go to NIC and get dropped finally.
> I presume this case frequently happen in real cases.
> 
> >   - no direct return is visible to applications
> >   - if it happens once, many more will follow and log will fill.
> >   - bonus it is only log message with GSO type.
> > 
> > The fix is to just return -EINVAL which is what this library does in many other
> > places when looking at headers.
> > 
> > Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
> > Cc: jiayu.hu@intel.com
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  lib/eal/common/eal_common_log.c | 2 +-
> >  lib/eal/include/rte_log.h       | 1 -
> >  lib/gso/rte_gso.c               | 3 +--
> >  3 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/lib/eal/common/eal_common_log.c
> > b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..c369154cb1ea
> > 100644
> > --- a/lib/eal/common/eal_common_log.c
> > +++ b/lib/eal/common/eal_common_log.c
> > @@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = {
> >  	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
> >  	{RTE_LOGTYPE_EFD,        "lib.efd"},
> >  	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
> > -	{RTE_LOGTYPE_GSO,        "lib.gso"},
> > +
> >  	{RTE_LOGTYPE_USER1,      "user1"},
> >  	{RTE_LOGTYPE_USER2,      "user2"},
> >  	{RTE_LOGTYPE_USER3,      "user3"},
> > diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index
> > 6d2b0856a565..97d6b26a9967 100644
> > --- a/lib/eal/include/rte_log.h
> > +++ b/lib/eal/include/rte_log.h
> > @@ -46,7 +46,6 @@ extern "C" {
> >  #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
> >  #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
> >  #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
> > -#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
> > 
> >  /* these log types can be used in an application */
> >  #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
> > diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index
> > 4b59217c16ee..19c351769fcc 100644
> > --- a/lib/gso/rte_gso.c
> > +++ b/lib/gso/rte_gso.c
> > @@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
> >  				indirect_pool, pkts_out, nb_pkts_out);
> >  	} else {
> >  		/* unsupported packet, skip */
> > -		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
> > -		ret = 0;
> > +		ret = -EINVAL;  
> 
> If applications want to know that the packet is failed on SW GSO,
> I think ENOTSUP is better than EINVAL, as it is not invalid input
> from users.

Ok, just wanted to do the same thing as what would happen
earlier in the code path for cases where the arguments are incorrect.
Doing -ENOTSUP makes sense.


	



^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type
  2023-02-10  2:03     ` fengchengwen
@ 2023-02-10  2:47       ` Stephen Hemminger
  0 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-10  2:47 UTC (permalink / raw)
  To: fengchengwen; +Cc: dev, Byron Marohn, Yipeng Wang

On Fri, 10 Feb 2023 10:03:47 +0800
fengchengwen <fengchengwen@huawei.com> wrote:

> On 2023/2/10 9:07, Stephen Hemminger wrote:
> > Replace all uses of global logtype with a local log type.
> > Do not break message formats across source lines.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---  
> 
> ...
> 
> >  };
> >  EAL_REGISTER_TAILQ(rte_efd_tailq);
> >  
> > +RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
> > +
> > +#define EFD_LOG(level, fmt, args...) \
> > +	rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args)
> > +
> >  /** Internal permutation array used to shuffle bins into pseudorandom groups */
> >  const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = {
> >  	{
> > @@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
> >  	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
> >  
> >  	if (online_cpu_socket_bitmask == 0) {
> > -		RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled "
> > -				"in the bitmask\n");
> > +		EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask");  
> 
> Hi Stephen,
> 
> Original output will be: EFD: At least one CPU ...
> and new output will be: rte_efd_create(): At least one CPU ...
> 
> The new output don't have EFD (module or lib name), logs of the EFD module cannot be easily
> filtered, althought new have function name, but will may not contains module name.
> 
> Suggest add module name in EFD_LOG:
> #define EFD_LOG(level, fmt, args...) \
> 	rte_log(RTE_LOG_ ## level, efd_logtype, "EFD: %s(): " fmt "\n", __func__, ##args)

Thought that the function name was more precise that the module name.
It is what most drivers do.

^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 00/19] Replace use of static logtypes
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (14 preceding siblings ...)
  2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
@ 2023-02-13 19:55 ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 01/19] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (18 more replies)
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                   ` (6 subsequent siblings)
  22 siblings, 19 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v4 - use simpler/shorter method for setting local LOGTYPE
     split up steps of some of the changes

Stephen Hemminger (19):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++----------
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  3 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/hash/meson.build              |  9 ++++-
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  3 ++
 lib/hash/rte_hash_crc.c           | 66 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 46 +--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 46 +++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 28 +++----------
 lib/hash/version.map              |  5 +++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  3 ++
 lib/mempool/rte_mempool_log.h     |  4 ++
 lib/mempool/rte_mempool_ops.c     |  1 +
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/power/rte_power_empty_poll.c  |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 70 files changed, 363 insertions(+), 158 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 01/19] gso: don't log message on non TCP/UDP
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 02/19] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (17 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Mark Kavanagh, Konstantin Ananyev

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 02/19] eal: drop no longer used GSO logtype
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 01/19] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 03/19] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (16 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 03/19] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 01/19] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 02/19] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 04/19] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (15 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 04/19] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 03/19] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 05/19] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (14 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9cfa75bf93b0 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -28,6 +28,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 05/19] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 04/19] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 06/19] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (13 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 06/19] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 05/19] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 07/19] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
                     ` (12 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 07/19] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 06/19] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 08/19] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (11 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c  | 1 -
 lib/eal/include/rte_log.h        | 2 +-
 lib/power/guest_channel.c        | 3 ++-
 lib/power/power_common.c         | 2 ++
 lib/power/power_common.h         | 3 ++-
 lib/power/power_kvm_vm.c         | 1 +
 lib/power/rte_power.c            | 1 +
 lib/power/rte_power_empty_poll.c | 1 +
 8 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..64e3b4b46d5e 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 08/19] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 07/19] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 09/19] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (10 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 09/19] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 08/19] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 10/19] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (9 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 3 +++
 lib/mempool/rte_mempool_log.h   | 4 ++++
 lib/mempool/rte_mempool_ops.c   | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..841abe53e3b9 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,9 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..216401c9f2cd
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	mempool_logtype
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..ad7c81823ce1 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 10/19] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 09/19] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 11/19] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (8 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 11/19] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 10/19] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 12/19] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (7 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 12/19] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 11/19] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 13/19] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
                     ` (6 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..c2bd8c785fcd 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 13/19] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 12/19] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 14/19] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..9793033a8fd4 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 14/19] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 13/19] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 15/19] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 15/19] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 14/19] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 16/19] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 16/19] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 15/19] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 17/19] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamicly allocated logtype

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 17/19] hash: move rte_thash_gfni stubs out of header file
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 16/19] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 18/19] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 19/19] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 +++++++-
 lib/hash/rte_thash_gfni.c | 43 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 28 +++++--------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 59 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..7617b9d4f630
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..86208eb45ebb 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,8 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +33,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 18/19] hash: move rte_hash_set_alg out header
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 17/19] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  2023-02-13 19:55   ` [PATCH v4 19/19] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build    |  1 +
 lib/hash/rte_hash_crc.c | 63 +++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h | 46 ++----------------------------
 lib/hash/version.map    |  1 +
 4 files changed, 67 insertions(+), 44 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..c59eebccb1eb
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		crc32_alg = CRC32_SSE42;
+	else
+		crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		crc32_alg = CRC32_ARM64;
+#endif
+
+	if (crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e4acd99a0c81 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..a1d81835399c 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v4 19/19] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-13 19:55   ` [PATCH v4 18/19] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-13 19:55   ` Stephen Hemminger
  18 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-13 19:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 3 +++
 lib/hash/rte_hash_crc.c         | 3 +++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 7 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..a5026193070a 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -18,6 +18,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
index c59eebccb1eb..7c544a669f8a 100644
--- a/lib/hash/rte_hash_crc.c
+++ b/lib/hash/rte_hash_crc.c
@@ -7,6 +7,9 @@
 
 #include "rte_hash_crc.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH hash_crc_logtype
+
 /**
  * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
  * calculation.
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index 7617b9d4f630..f17ca222dc32 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -8,6 +8,9 @@
 #include <rte_log.h>
 #include <rte_thash_gfni.h>
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 00/22] Replace us of static logtypes
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (15 preceding siblings ...)
  2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
@ 2023-02-14  2:18 ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                   ` (5 subsequent siblings)
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v5 - fix use of LOGTYPE PORT and POWER in examples

v4 - use simpler/shorter method for setting local LOGTYPE
     split up steps of some of the changes

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++----------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  3 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/hash/meson.build              |  9 ++++-
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  3 ++
 lib/hash/rte_hash_crc.c           | 66 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 46 +--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 46 +++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 28 +++----------
 lib/hash/version.map              |  5 +++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  3 ++
 lib/mempool/rte_mempool_log.h     |  4 ++
 lib/mempool/rte_mempool_ops.c     |  1 +
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/power/rte_power_empty_poll.c  |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 73 files changed, 375 insertions(+), 169 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 01/22] gso: don't log message on non TCP/UDP
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Konstantin Ananyev, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 02/22] eal: drop no longer used GSO logtype
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9cfa75bf93b0 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -28,6 +28,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Don't use static static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index caf26b373e8d..8e094c1bdda5 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -52,7 +52,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2445,7 +2446,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2454,7 +2455,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2472,7 +2473,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2541,7 +2542,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2607,7 +2608,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	if (app_mode == APP_MODE_EMPTY_POLL)
 		empty_poll_setup_timer();
@@ -2626,7 +2627,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c  | 1 -
 lib/eal/include/rte_log.h        | 2 +-
 lib/power/guest_channel.c        | 3 ++-
 lib/power/power_common.c         | 2 ++
 lib/power/power_common.h         | 3 ++-
 lib/power/power_kvm_vm.c         | 1 +
 lib/power/rte_power.c            | 1 +
 lib/power/rte_power_empty_poll.c | 1 +
 8 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..64e3b4b46d5e 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 3 +++
 lib/mempool/rte_mempool_log.h   | 4 ++++
 lib/mempool/rte_mempool_ops.c   | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..841abe53e3b9 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,9 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..216401c9f2cd
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	mempool_logtype
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..ad7c81823ce1 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:18   ` [PATCH v5 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-14  2:18   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-14  2:18   ` [PATCH v5 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..c2bd8c785fcd 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, akhil.goyal, Radu Nicolau, Akhil Goyal,
	Aviad Yehezkel, Boris Pismenny, Declan Doherty

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..9793033a8fd4 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 +++++++-
 lib/hash/rte_thash_gfni.c | 43 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 28 +++++--------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 59 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..7617b9d4f630
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..86208eb45ebb 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,8 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +33,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 21/22] hash: move rte_hash_set_alg out header
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  2023-02-14  2:19   ` [PATCH v5 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build    |  1 +
 lib/hash/rte_hash_crc.c | 63 +++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h | 46 ++----------------------------
 lib/hash/version.map    |  1 +
 4 files changed, 67 insertions(+), 44 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..c59eebccb1eb
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		crc32_alg = CRC32_SSE42;
+	else
+		crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		crc32_alg = CRC32_ARM64;
+#endif
+
+	if (crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e4acd99a0c81 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..a1d81835399c 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v5 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-14  2:19   ` [PATCH v5 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-14  2:19   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14  2:19 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 3 +++
 lib/hash/rte_hash_crc.c         | 3 +++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 7 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..a5026193070a 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -18,6 +18,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
index c59eebccb1eb..7c544a669f8a 100644
--- a/lib/hash/rte_hash_crc.c
+++ b/lib/hash/rte_hash_crc.c
@@ -7,6 +7,9 @@
 
 #include "rte_hash_crc.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH hash_crc_logtype
+
 /**
  * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
  * calculation.
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index 7617b9d4f630..f17ca222dc32 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -8,6 +8,9 @@
 #include <rte_log.h>
 #include <rte_thash_gfni.h>
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 00/22] Replace use of static logtypes in libraries
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (16 preceding siblings ...)
  2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
@ 2023-02-14 22:47 ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                   ` (4 subsequent siblings)
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v6 - fix typo in kni port 

v5 - fix use of LOGTYPE PORT and POWER in examples

v4 - use simpler/shorter method for setting local LOGTYPE
     split up steps of some of the changes

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++----------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  3 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/hash/meson.build              |  9 ++++-
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  3 ++
 lib/hash/rte_hash_crc.c           | 66 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 46 +--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 46 +++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 28 +++----------
 lib/hash/version.map              |  5 +++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  3 ++
 lib/mempool/rte_mempool_log.h     |  4 ++
 lib/mempool/rte_mempool_ops.c     |  1 +
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/power/rte_power_empty_poll.c  |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 73 files changed, 375 insertions(+), 169 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 01/22] gso: don't log message on non TCP/UDP
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-15  7:26     ` Hu, Jiayu
  2023-02-14 22:47   ` [PATCH v6 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Konstantin Ananyev, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 02/22] eal: drop no longer used GSO logtype
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9cfa75bf93b0 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -28,6 +28,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Don't use static static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index caf26b373e8d..8e094c1bdda5 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -52,7 +52,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2445,7 +2446,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2454,7 +2455,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2472,7 +2473,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2541,7 +2542,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2607,7 +2608,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	if (app_mode == APP_MODE_EMPTY_POLL)
 		empty_poll_setup_timer();
@@ -2626,7 +2627,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c  | 1 -
 lib/eal/include/rte_log.h        | 2 +-
 lib/power/guest_channel.c        | 3 ++-
 lib/power/power_common.c         | 2 ++
 lib/power/power_common.h         | 3 ++-
 lib/power/power_kvm_vm.c         | 1 +
 lib/power/rte_power.c            | 1 +
 lib/power/rte_power_empty_poll.c | 1 +
 8 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..64e3b4b46d5e 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 3 +++
 lib/mempool/rte_mempool_log.h   | 4 ++++
 lib/mempool/rte_mempool_ops.c   | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..841abe53e3b9 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,9 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..216401c9f2cd
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	mempool_logtype
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..ad7c81823ce1 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..c2bd8c785fcd 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, akhil.goyal, Radu Nicolau, Akhil Goyal,
	Declan Doherty, Aviad Yehezkel, Boris Pismenny

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..d4ac08b4cff0 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYPE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 +++++++-
 lib/hash/rte_thash_gfni.c | 43 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 28 +++++--------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 59 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..7617b9d4f630
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..86208eb45ebb 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,8 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +33,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 21/22] hash: move rte_hash_set_alg out header
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  2023-02-14 22:47   ` [PATCH v6 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build    |  1 +
 lib/hash/rte_hash_crc.c | 63 +++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h | 46 ++----------------------------
 lib/hash/version.map    |  1 +
 4 files changed, 67 insertions(+), 44 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..c59eebccb1eb
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		crc32_alg = CRC32_SSE42;
+	else
+		crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		crc32_alg = CRC32_ARM64;
+#endif
+
+	if (crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e4acd99a0c81 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..a1d81835399c 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v6 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-14 22:47   ` [PATCH v6 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-14 22:47   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-14 22:47 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 3 +++
 lib/hash/rte_hash_crc.c         | 3 +++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 7 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..a5026193070a 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -18,6 +18,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
index c59eebccb1eb..7c544a669f8a 100644
--- a/lib/hash/rte_hash_crc.c
+++ b/lib/hash/rte_hash_crc.c
@@ -7,6 +7,9 @@
 
 #include "rte_hash_crc.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH hash_crc_logtype
+
 /**
  * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
  * calculation.
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index 7617b9d4f630..f17ca222dc32 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -8,6 +8,9 @@
 #include <rte_log.h>
 #include <rte_thash_gfni.h>
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [PATCH v6 01/22] gso: don't log message on non TCP/UDP
  2023-02-14 22:47   ` [PATCH v6 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-15  7:26     ` Hu, Jiayu
  2023-02-15 17:12       ` Stephen Hemminger
  0 siblings, 1 reply; 255+ messages in thread
From: Hu, Jiayu @ 2023-02-15  7:26 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Konstantin Ananyev, Mark Kavanagh



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Wednesday, February 15, 2023 6:47 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Hu, Jiayu
> <jiayu.hu@intel.com>; Konstantin Ananyev
> <konstantin.v.ananyev@yandex.ru>; Mark Kavanagh
> <mark.b.kavanagh@intel.com>
> Subject: [PATCH v6 01/22] gso: don't log message on non TCP/UDP
> 
> If a large packet is passed into GSO routines of unknown protocol then library
> would log a message.
> Better to tell the application instead of logging.
> 
> Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
> Cc: jiayu.hu@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/gso/rte_gso.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index
> 4b59217c16ee..c8e67c2d4b48 100644
> --- a/lib/gso/rte_gso.c
> +++ b/lib/gso/rte_gso.c
> @@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
>  		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
>  				indirect_pool, pkts_out, nb_pkts_out);
>  	} else {
> -		/* unsupported packet, skip */
> -		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
> -		ret = 0;
> +		ret = -ENOTSUP;	/* only UDP or TCP allowed */
> +

The function signature annotation in rte_gso.h also needs update for ENOTSUP.
In addition, will it break ABI? 

Thanks,
Jiayu
>  	}
> 
>  	if (ret < 0) {
> --
> 2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v6 01/22] gso: don't log message on non TCP/UDP
  2023-02-15  7:26     ` Hu, Jiayu
@ 2023-02-15 17:12       ` Stephen Hemminger
  0 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:12 UTC (permalink / raw)
  To: Hu, Jiayu; +Cc: dev, Konstantin Ananyev, Mark Kavanagh

On Wed, 15 Feb 2023 07:26:22 +0000
"Hu, Jiayu" <jiayu.hu@intel.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Wednesday, February 15, 2023 6:47 AM
> > To: dev@dpdk.org
> > Cc: Stephen Hemminger <stephen@networkplumber.org>; Hu, Jiayu
> > <jiayu.hu@intel.com>; Konstantin Ananyev
> > <konstantin.v.ananyev@yandex.ru>; Mark Kavanagh
> > <mark.b.kavanagh@intel.com>
> > Subject: [PATCH v6 01/22] gso: don't log message on non TCP/UDP
> > 
> > If a large packet is passed into GSO routines of unknown protocol then library
> > would log a message.
> > Better to tell the application instead of logging.
> > 
> > Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
> > Cc: jiayu.hu@intel.com
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  lib/gso/rte_gso.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index
> > 4b59217c16ee..c8e67c2d4b48 100644
> > --- a/lib/gso/rte_gso.c
> > +++ b/lib/gso/rte_gso.c
> > @@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
> >  		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
> >  				indirect_pool, pkts_out, nb_pkts_out);
> >  	} else {
> > -		/* unsupported packet, skip */
> > -		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
> > -		ret = 0;
> > +		ret = -ENOTSUP;	/* only UDP or TCP allowed */
> > +  
> 
> The function signature annotation in rte_gso.h also needs update for ENOTSUP.
> In addition, will it break ABI? 

Not really, if anybody hits this error case, nothing good would have
been happening.

^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 00/22] Replace use of static logtypes in libraries
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (17 preceding siblings ...)
  2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
@ 2023-02-15 17:23 ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                   ` (3 subsequent siblings)
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v7 - fix commit message typ
     add error to gso_segment function doc
     fix missing cpuflags.h on arm

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++----------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  3 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/gso/rte_gso.h                 |  1 +
 lib/hash/meson.build              |  9 ++++-
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  5 +++
 lib/hash/rte_hash_crc.c           | 66 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 46 +--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 46 +++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 28 +++----------
 lib/hash/version.map              |  5 +++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  3 ++
 lib/mempool/rte_mempool_log.h     |  4 ++
 lib/mempool/rte_mempool_ops.c     |  1 +
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/power/rte_power_empty_poll.c  |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 74 files changed, 378 insertions(+), 169 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/mempool/rte_mempool_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 01/22] gso: don't log message on non TCP/UDP
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-16  1:23     ` Hu, Jiayu
  2023-02-15 17:23   ` [PATCH v7 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, jiayu.hu, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Cc: jiayu.hu@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 lib/gso/rte_gso.h | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
diff --git a/lib/gso/rte_gso.h b/lib/gso/rte_gso.h
index 40922524df42..23d6980aff9f 100644
--- a/lib/gso/rte_gso.h
+++ b/lib/gso/rte_gso.h
@@ -114,6 +114,7 @@ struct rte_gso_ctx {
  *  - The number of GSO segments filled in pkts_out on success.
  *  - Return 0 if it does not need to be GSO'd.
  *  - Return -ENOMEM if run out of memory in MBUF pools.
+ *  - Return -ENOTSUP for protocols that can not be segmentd (not UDP or TCP)
  *  - Return -EINVAL for invalid parameters.
  */
 int rte_gso_segment(struct rte_mbuf *pkt,
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 02/22] eal: drop no longer used GSO logtype
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9cfa75bf93b0 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -28,6 +28,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Don't use static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index caf26b373e8d..8e094c1bdda5 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -52,7 +52,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2445,7 +2446,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2454,7 +2455,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2472,7 +2473,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2541,7 +2542,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2607,7 +2608,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	if (app_mode == APP_MODE_EMPTY_POLL)
 		empty_poll_setup_timer();
@@ -2626,7 +2627,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-22 16:34     ` Hunt, David
  2023-02-15 17:23   ` [PATCH v7 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c  | 1 -
 lib/eal/include/rte_log.h        | 2 +-
 lib/power/guest_channel.c        | 3 ++-
 lib/power/power_common.c         | 2 ++
 lib/power/power_common.h         | 3 ++-
 lib/power/power_kvm_vm.c         | 1 +
 lib/power/rte_power.c            | 1 +
 lib/power/rte_power_empty_poll.c | 1 +
 8 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
index 4a4db512474e..64e3b4b46d5e 100644
--- a/lib/power/rte_power_empty_poll.c
+++ b/lib/power/rte_power_empty_poll.c
@@ -10,6 +10,7 @@
 
 #include "rte_power.h"
 #include "rte_power_empty_poll.h"
+#include "power_common.h"
 
 #define INTERVALS_PER_SECOND 100     /* (10ms) */
 #define SECONDS_TO_TRAIN_FOR 2
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 3 +++
 lib/mempool/rte_mempool_log.h   | 4 ++++
 lib/mempool/rte_mempool_ops.c   | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 lib/mempool/rte_mempool_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 45b5df6199b0..841abe53e3b9 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -30,6 +30,9 @@
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO);
 
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h
new file mode 100644
index 000000000000..216401c9f2cd
--- /dev/null
+++ b/lib/mempool/rte_mempool_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	mempool_logtype
diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c
index 3b43edc548a0..ad7c81823ce1 100644
--- a/lib/mempool/rte_mempool_ops.c
+++ b/lib/mempool/rte_mempool_ops.c
@@ -12,6 +12,7 @@
 #include <dev_driver.h>
 
 #include "rte_mempool_trace.h"
+#include "rte_mempool_log.h"
 
 /* indirect jump table to support external memory pools. */
 struct rte_mempool_ops_table rte_mempool_ops_table = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index c91697131d3e..c2bd8c785fcd 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, akhil.goyal, Radu Nicolau, Akhil Goyal,
	Declan Doherty, Aviad Yehezkel, Boris Pismenny

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..d4ac08b4cff0 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYPE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 19:14     ` Medvedkin, Vladimir
  2023-02-15 17:23   ` [PATCH v7 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 +++++++-
 lib/hash/rte_thash_gfni.c | 43 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 28 +++++--------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 59 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..7617b9d4f630
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..86208eb45ebb 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,8 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +33,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 21/22] hash: move rte_hash_set_alg out header
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  2023-02-15 17:23   ` [PATCH v7 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build    |  1 +
 lib/hash/rte_hash_crc.c | 63 +++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h | 46 ++----------------------------
 lib/hash/version.map    |  1 +
 4 files changed, 67 insertions(+), 44 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..c59eebccb1eb
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		crc32_alg = CRC32_SSE42;
+	else
+		crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		crc32_alg = CRC32_ARM64;
+#endif
+
+	if (crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e4acd99a0c81 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..a1d81835399c 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v7 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-15 17:23   ` [PATCH v7 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-15 17:23   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-15 17:23 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 5 +++++
 lib/hash/rte_hash_crc.c         | 3 +++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 7 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..b4c4c191abdc 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 
 #include <sys/queue.h>
+
+#include <rte_cpuflags.h>
 #include <rte_eal_memconfig.h>
 #include <rte_malloc.h>
 #include <rte_common.h>
@@ -18,6 +20,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
index c59eebccb1eb..7c544a669f8a 100644
--- a/lib/hash/rte_hash_crc.c
+++ b/lib/hash/rte_hash_crc.c
@@ -7,6 +7,9 @@
 
 #include "rte_hash_crc.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH hash_crc_logtype
+
 /**
  * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
  * calculation.
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index 7617b9d4f630..f17ca222dc32 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -8,6 +8,9 @@
 #include <rte_log.h>
 #include <rte_thash_gfni.h>
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v7 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-15 17:23   ` [PATCH v7 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-15 19:14     ` Medvedkin, Vladimir
  0 siblings, 0 replies; 255+ messages in thread
From: Medvedkin, Vladimir @ 2023-02-15 19:14 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Yipeng Wang, Sameh Gobriel, Bruce Richardson

Hi Stepthen,

There is a problem with the build on a machine that supports GFNI:

../lib/hash/rte_thash_gfni.c:15:1: error: redefinition of ‘rte_thash_gfni’
    15 | rte_thash_gfni(const uint64_t *mtrx __rte_unused,
       | ^~~~~~~~~~~~~~
In file included from ../lib/hash/rte_thash_gfni.h:13,
                  from ../lib/hash/rte_thash_gfni.c:9:
../lib/hash/rte_thash_x86_gfni.h:180:1: note: previous definition of 
‘rte_thash_gfni’ was here
   180 | rte_thash_gfni(const uint64_t *m, const uint8_t *tuple, int len)
       | ^~~~~~~~~~~~~~


I believe you forgot to frame dummy functions with #ifndef 
RTE_THASH_GFNI_DEFINED


On 15/02/2023 17:23, Stephen Hemminger wrote:
> Having stubs in header file makes it harder to update
> RTE_LOG(). Also modify to only print warning once.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/hash/meson.build      |  8 +++++++-
>   lib/hash/rte_thash_gfni.c | 43 +++++++++++++++++++++++++++++++++++++++
>   lib/hash/rte_thash_gfni.h | 28 +++++--------------------
>   lib/hash/version.map      |  4 ++++
>   4 files changed, 59 insertions(+), 24 deletions(-)
>   create mode 100644 lib/hash/rte_thash_gfni.c
>
> diff --git a/lib/hash/meson.build b/lib/hash/meson.build
> index 2f757d45f9bc..e56ee8572564 100644
> --- a/lib/hash/meson.build
> +++ b/lib/hash/meson.build
> @@ -17,7 +17,13 @@ indirect_headers += files(
>           'rte_thash_x86_gfni.h',
>   )
>   
> -sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
> +sources = files(
> +    'rte_cuckoo_hash.c',
> +    'rte_fbk_hash.c',
> +    'rte_thash.c',
> +    'rte_thash_gfni.c'
> +)
> +
>   deps += ['net']
>   deps += ['ring']
>   deps += ['rcu']
> diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
> new file mode 100644
> index 000000000000..7617b9d4f630
> --- /dev/null
> +++ b/lib/hash/rte_thash_gfni.c
> @@ -0,0 +1,43 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2021 Intel Corporation
> + */
> +
> +#include <stdbool.h>
> +
> +#include <rte_compat.h>
> +#include <rte_log.h>
> +#include <rte_thash_gfni.h>
> +
> +uint32_t
> +rte_thash_gfni(const uint64_t *mtrx __rte_unused,
> +	       const uint8_t *key __rte_unused, int len __rte_unused)
> +{
> +	static bool warned;
> +
> +	if (!warned) {
> +		warned = true;
> +		RTE_LOG(ERR, HASH,
> +			"%s is undefined under given arch\n", __func__);
> +	}
> +
> +	return 0;
> +}
> +
> +void
> +rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
> +		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
> +		    uint32_t val[], uint32_t num)
> +{
> +	unsigned int i;
> +
> +	static bool warned;
> +
> +	if (!warned) {
> +		warned = true;
> +		RTE_LOG(ERR, HASH,
> +			"%s is undefined under given arch\n", __func__);
> +	}
> +
> +	for (i = 0; i < num; i++)
> +		val[i] = 0;
> +}
> diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
> index ef90faa302d1..86208eb45ebb 100644
> --- a/lib/hash/rte_thash_gfni.h
> +++ b/lib/hash/rte_thash_gfni.h
> @@ -9,13 +9,8 @@
>   extern "C" {
>   #endif
>   
> -#include <rte_compat.h>
> -#include <rte_log.h>
> -
>   #ifdef RTE_ARCH_X86
> -
>   #include <rte_thash_x86_gfni.h>
> -
>   #endif
>   
>   #ifndef RTE_THASH_GFNI_DEFINED
> @@ -38,13 +33,8 @@ extern "C" {
>    *  Calculated Toeplitz hash value.
>    */
>   __rte_experimental
> -static inline uint32_t
> -rte_thash_gfni(const uint64_t *mtrx __rte_unused,
> -	const uint8_t *key __rte_unused, int len __rte_unused)
> -{
> -	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
> -	return 0;
> -}
> +uint32_t
> +rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
>   
>   /**
>    * Bulk implementation for Toeplitz hash.
> @@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
>    *  Number of tuples to hash.
>    */
>   __rte_experimental
> -static inline void
> -rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
> -	int len __rte_unused, uint8_t *tuple[] __rte_unused,
> -	uint32_t val[], uint32_t num)
> -{
> -	unsigned int i;
> -
> -	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
> -	for (i = 0; i < num; i++)
> -		val[i] = 0;
> -}
> +void
> +rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
> +		    uint32_t val[], uint32_t num);
>   
>   #endif /* RTE_THASH_GFNI_DEFINED */
>   
> diff --git a/lib/hash/version.map b/lib/hash/version.map
> index bdcebd19c29b..f03b047b2eec 100644
> --- a/lib/hash/version.map
> +++ b/lib/hash/version.map
> @@ -51,4 +51,8 @@ EXPERIMENTAL {
>   	rte_thash_complete_matrix;
>   	rte_thash_get_gfni_matrices;
>   	rte_thash_gfni_supported;
> +
> +	# added in 22.07
> +	rte_thash_gfni;
> +	rte_thash_gfni_bulk;
>   };

-- 
Regards,
Vladimir


^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [PATCH v7 01/22] gso: don't log message on non TCP/UDP
  2023-02-15 17:23   ` [PATCH v7 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-16  1:23     ` Hu, Jiayu
  0 siblings, 0 replies; 255+ messages in thread
From: Hu, Jiayu @ 2023-02-16  1:23 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Mark Kavanagh


> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 16, 2023 1:23 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Hu, Jiayu
> <jiayu.hu@intel.com>; Mark Kavanagh <mark.b.kavanagh@intel.com>
> Subject: [PATCH v7 01/22] gso: don't log message on non TCP/UDP
> 
> If a large packet is passed into GSO routines of unknown protocol then library
> would log a message.
> Better to tell the application instead of logging.
> 
> Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
> Cc: jiayu.hu@intel.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/gso/rte_gso.c | 5 ++---
>  lib/gso/rte_gso.h | 1 +
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index
> 4b59217c16ee..c8e67c2d4b48 100644
> --- a/lib/gso/rte_gso.c
> +++ b/lib/gso/rte_gso.c
> @@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
>  		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
>  				indirect_pool, pkts_out, nb_pkts_out);
>  	} else {
> -		/* unsupported packet, skip */
> -		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
> -		ret = 0;
> +		ret = -ENOTSUP;	/* only UDP or TCP allowed */
> +
>  	}
> 
>  	if (ret < 0) {
> diff --git a/lib/gso/rte_gso.h b/lib/gso/rte_gso.h index
> 40922524df42..23d6980aff9f 100644
> --- a/lib/gso/rte_gso.h
> +++ b/lib/gso/rte_gso.h
> @@ -114,6 +114,7 @@ struct rte_gso_ctx {
>   *  - The number of GSO segments filled in pkts_out on success.
>   *  - Return 0 if it does not need to be GSO'd.
>   *  - Return -ENOMEM if run out of memory in MBUF pools.
> + *  - Return -ENOTSUP for protocols that can not be segmentd (not UDP
> + or TCP)
>   *  - Return -EINVAL for invalid parameters.
>   */
>  int rte_gso_segment(struct rte_mbuf *pkt,
> --
> 2.39.1

Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 00/22] Convert static logtypes in libraries
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (18 preceding siblings ...)
  2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
@ 2023-02-20 23:35 ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                   ` (2 subsequent siblings)
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

There are several options on how to treat the old static types:
	- leave them there
	- mark the definitions as deprecated
	- remove them
This version removes them since there is no guarantee in current
DPDK policies that says they can't be removed.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v8 - rebase and fix CI issues on Arm
     simplify the mempool logtype patch

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++----------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  4 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/gso/rte_gso.h                 |  1 +
 lib/hash/meson.build              |  9 ++++-
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  5 +++
 lib/hash/rte_hash_crc.c           | 66 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 46 +--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 46 +++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 28 +++----------
 lib/hash/version.map              |  5 +++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  2 +
 lib/mempool/rte_mempool.h         |  8 ++++
 lib/mempool/version.map           |  3 ++
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 73 files changed, 383 insertions(+), 169 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 01/22] gso: don't log message on non TCP/UDP
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiayu Hu

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 lib/gso/rte_gso.h | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
diff --git a/lib/gso/rte_gso.h b/lib/gso/rte_gso.h
index 40922524df42..23d6980aff9f 100644
--- a/lib/gso/rte_gso.h
+++ b/lib/gso/rte_gso.h
@@ -114,6 +114,7 @@ struct rte_gso_ctx {
  *  - The number of GSO segments filled in pkts_out on success.
  *  - Return 0 if it does not need to be GSO'd.
  *  - Return -ENOMEM if run out of memory in MBUF pools.
+ *  - Return -ENOTSUP for protocols that can not be segmentd (not UDP or TCP)
  *  - Return -EINVAL for invalid parameters.
  */
 int rte_gso_segment(struct rte_mbuf *pkt,
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 02/22] eal: drop no longer used GSO logtype
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-21 14:55     ` David Marchand
  2023-02-20 23:35   ` [PATCH v8 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 4 ++++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9edb11799c89 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <sys/queue.h>
 
+#include <rte_cpuflags.h>
 #include <rte_string_fns.h>
 #include <rte_log.h>
 #include <rte_eal_memconfig.h>
@@ -28,6 +29,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Don't use static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index f57c54d2b57c..76b890b76c88 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -51,7 +51,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2236,7 +2237,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2245,7 +2246,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2263,7 +2264,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2332,7 +2333,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2381,7 +2382,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	telemetry_setup_timer();
 
@@ -2397,7 +2398,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/power/guest_channel.c       | 3 ++-
 lib/power/power_common.c        | 2 ++
 lib/power/power_common.h        | 3 ++-
 lib/power/power_kvm_vm.c        | 1 +
 lib/power/rte_power.c           | 1 +
 7 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 2 ++
 lib/mempool/rte_mempool.h       | 8 ++++++++
 lib/mempool/version.map         | 3 +++
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index cf5dea2304a7..b609a94fdf9d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,8 @@
 #include "mempool_trace.h"
 #include "rte_mempool.h"
 
+RTE_LOG_REGISTER_DEFAULT(rte_mempool_logtype, INFO);
+
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_mempool_tailq = {
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 9f530db24ba1..db01acc19b02 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -43,6 +43,7 @@
 #include <rte_spinlock.h>
 #include <rte_debug.h>
 #include <rte_lcore.h>
+#include <rte_log.h>
 #include <rte_branch_prediction.h>
 #include <rte_ring.h>
 #include <rte_memcpy.h>
@@ -175,6 +176,13 @@ struct rte_mempool_objtlr {
 
 #endif
 
+
+/**
+ * @internal Logtype used for mempool related messages.
+ */
+extern int rte_mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	rte_mempool_logtype
+
 /**
  * A list of memory where objects are stored
  */
diff --git a/lib/mempool/version.map b/lib/mempool/version.map
index dff2d1cb5555..eb2c12127560 100644
--- a/lib/mempool/version.map
+++ b/lib/mempool/version.map
@@ -57,4 +57,7 @@ INTERNAL {
 	# added in 21.11
 	rte_mempool_event_callback_register;
 	rte_mempool_event_callback_unregister;
+
+	# added in 23.07
+	rte_mempool_logtype;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index 19768d8c38b0..27e98e46df7a 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, akhil.goyal

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..d4ac08b4cff0 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYPE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-20 23:35   ` [PATCH v8 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 +++++++-
 lib/hash/rte_thash_gfni.c | 43 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 28 +++++--------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 59 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..7617b9d4f630
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..86208eb45ebb 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,8 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +33,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 21/22] hash: move rte_hash_set_alg out header
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  2023-02-21 15:02     ` David Marchand
  2023-02-21 15:10     ` David Marchand
  2023-02-20 23:35   ` [PATCH v8 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 2 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build    |  1 +
 lib/hash/rte_hash_crc.c | 63 +++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h | 46 ++----------------------------
 lib/hash/version.map    |  1 +
 4 files changed, 67 insertions(+), 44 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..c59eebccb1eb
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		crc32_alg = CRC32_SSE42;
+	else
+		crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		crc32_alg = CRC32_ARM64;
+#endif
+
+	if (crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e4acd99a0c81 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..a1d81835399c 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v8 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-20 23:35   ` [PATCH v8 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-20 23:35   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 5 +++++
 lib/hash/rte_hash_crc.c         | 3 +++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 7 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..b4c4c191abdc 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 
 #include <sys/queue.h>
+
+#include <rte_cpuflags.h>
 #include <rte_eal_memconfig.h>
 #include <rte_malloc.h>
 #include <rte_common.h>
@@ -18,6 +20,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
index c59eebccb1eb..7c544a669f8a 100644
--- a/lib/hash/rte_hash_crc.c
+++ b/lib/hash/rte_hash_crc.c
@@ -7,6 +7,9 @@
 
 #include "rte_hash_crc.h"
 
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH hash_crc_logtype
+
 /**
  * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
  * calculation.
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index 7617b9d4f630..f17ca222dc32 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -8,6 +8,9 @@
 #include <rte_log.h>
 #include <rte_thash_gfni.h>
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-20 23:35   ` [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-21 14:55     ` David Marchand
  2023-02-21 17:07       ` Stephen Hemminger
  2023-03-29 23:31       ` Stephen Hemminger
  0 siblings, 2 replies; 255+ messages in thread
From: David Marchand @ 2023-02-21 14:55 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Tue, Feb 21, 2023 at 12:36 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> Replace all uses of the global logtype with a dynamic log type.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/eal/common/eal_common_log.c | 1 -
>  lib/eal/include/rte_log.h       | 2 +-
>  lib/efd/rte_efd.c               | 4 ++++
>  3 files changed, 5 insertions(+), 2 deletions(-)

[snip]

> diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
> index 686a13775742..9edb11799c89 100644
> --- a/lib/efd/rte_efd.c
> +++ b/lib/efd/rte_efd.c
> @@ -9,6 +9,7 @@
>  #include <errno.h>
>  #include <sys/queue.h>
>
> +#include <rte_cpuflags.h>
>  #include <rte_string_fns.h>
>  #include <rte_log.h>
>  #include <rte_eal_memconfig.h>

This is unrelated, isn't it?


-- 
David Marchand


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v8 21/22] hash: move rte_hash_set_alg out header
  2023-02-20 23:35   ` [PATCH v8 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-21 15:02     ` David Marchand
  2023-02-21 15:10     ` David Marchand
  1 sibling, 0 replies; 255+ messages in thread
From: David Marchand @ 2023-02-21 15:02 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Tue, Feb 21, 2023 at 12:38 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The code for setting algorithm for hash is not at all perf sensitive,
> and doing it inline has a couple of problems. First, it means that if
> multiple files include the header, then the initialization gets done
> multiple times. But also, it makes it harder to fix usage of RTE_LOG().
>
> Despite what the checking script say. This is not an ABI change, the
> previous version inlined the same code; therefore both old and new code
> will work the same.

I suppose you are referring to:
http://mails.dpdk.org/archives/test-report/2023-February/356872.html
ERROR: symbol rte_hash_crc_set_alg is added in the DPDK_23 section,
but is expected to be added in the EXPERIMENTAL section of the version
map

I agree that this is irrelevant and can be ignored in this particular case.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v8 21/22] hash: move rte_hash_set_alg out header
  2023-02-20 23:35   ` [PATCH v8 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-21 15:02     ` David Marchand
@ 2023-02-21 15:10     ` David Marchand
  1 sibling, 0 replies; 255+ messages in thread
From: David Marchand @ 2023-02-21 15:10 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Tue, Feb 21, 2023 at 12:38 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
> diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
> new file mode 100644
> index 000000000000..c59eebccb1eb
> --- /dev/null
> +++ b/lib/hash/rte_hash_crc.c
> @@ -0,0 +1,63 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2014 Intel Corporation
> + */
> +
> +#include <rte_cpuflags.h>
> +#include <rte_log.h>
> +
> +#include "rte_hash_crc.h"
> +
> +/**
> + * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
> + * calculation.
> + *
> + * @param alg
> + *   An OR of following flags:
> + *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
> + *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
> + *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
> + *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
> + *
> + */
> +void
> +rte_hash_crc_set_alg(uint8_t alg)
> +{
> +       crc32_alg = CRC32_SW;
> +
> +       if (alg == CRC32_SW)
> +               return;
> +
> +#if defined RTE_ARCH_X86
> +       if (!(alg & CRC32_SSE42_x64))
> +               RTE_LOG(WARNING, HASH,
> +                       "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
> +       if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
> +               crc32_alg = CRC32_SSE42;
> +       else
> +               crc32_alg = CRC32_SSE42_x64;
> +#endif
> +
> +#if defined RTE_ARCH_ARM64
> +       if (!(alg & CRC32_ARM64))
> +               RTE_LOG(WARNING, HASH,
> +                       "Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
> +       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
> +               crc32_alg = CRC32_ARM64;
> +#endif
> +
> +       if (crc32_alg == CRC32_SW)
> +               RTE_LOG(WARNING, HASH,
> +                       "Unsupported CRC32 algorithm requested using CRC32_SW\n");
> +}
> +
> +/* Setting the best available algorithm */
> +RTE_INIT(rte_hash_crc_init_alg)
> +{
> +#if defined(RTE_ARCH_X86)
> +       rte_hash_crc_set_alg(CRC32_SSE42_x64);
> +#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
> +       rte_hash_crc_set_alg(CRC32_ARM64);
> +#else
> +       rte_hash_crc_set_alg(CRC32_SW);
> +#endif
> +}
> diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
> index 0249ad16c5b6..e4acd99a0c81 100644
> --- a/lib/hash/rte_hash_crc.h
> +++ b/lib/hash/rte_hash_crc.h
> @@ -20,8 +20,6 @@ extern "C" {
>  #include <rte_branch_prediction.h>
>  #include <rte_common.h>
>  #include <rte_config.h>
> -#include <rte_cpuflags.h>
> -#include <rte_log.h>
>
>  #include "rte_crc_sw.h"
>
> @@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
>   *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
>   *
>   */
> -static inline void
> -rte_hash_crc_set_alg(uint8_t alg)
> -{
> -       crc32_alg = CRC32_SW;
> -
> -       if (alg == CRC32_SW)
> -               return;
> -
> -#if defined RTE_ARCH_X86
> -       if (!(alg & CRC32_SSE42_x64))
> -               RTE_LOG(WARNING, HASH,
> -                       "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
> -       if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
> -               crc32_alg = CRC32_SSE42;
> -       else
> -               crc32_alg = CRC32_SSE42_x64;
> -#endif
> -
> -#if defined RTE_ARCH_ARM64
> -       if (!(alg & CRC32_ARM64))
> -               RTE_LOG(WARNING, HASH,
> -                       "Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
> -       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
> -               crc32_alg = CRC32_ARM64;
> -#endif
> -
> -       if (crc32_alg == CRC32_SW)
> -               RTE_LOG(WARNING, HASH,
> -                       "Unsupported CRC32 algorithm requested using CRC32_SW\n");
> -}
> -
> -/* Setting the best available algorithm */
> -RTE_INIT(rte_hash_crc_init_alg)
> -{
> -#if defined(RTE_ARCH_X86)
> -       rte_hash_crc_set_alg(CRC32_SSE42_x64);
> -#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
> -       rte_hash_crc_set_alg(CRC32_ARM64);
> -#else
> -       rte_hash_crc_set_alg(CRC32_SW);
> -#endif
> -}
> +void
> +rte_hash_crc_set_alg(uint8_t alg);

There is likely something unfinished with this code move.
See test report from GHA.
http://mails.dpdk.org/archives/test-report/2023-February/356932.html

[174/3761] Compiling C object 'lib/76b5a35@@rte_hash at
sta/hash_rte_fbk_hash.c.o'.
FAILED: lib/76b5a35@@rte_hash at sta/hash_rte_fbk_hash.c.o
ccache powerpc64le-linux-gnu-gcc -Ilib/76b5a35@@rte_hash at sta -Ilib
-I../lib -Ilib/hash -I../lib/hash -I. -I../ -Iconfig -I../config
-Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include
-I../lib/eal/linux/include -Ilib/eal/ppc/include
-I../lib/eal/ppc/include -Ilib/eal/common -I../lib/eal/common
-Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs
-Ilib/telemetry/../metrics -I../lib/telemetry/../metrics
-Ilib/telemetry -I../lib/telemetry -Ilib/net -I../lib/net -Ilib/mbuf
-I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring
-Ilib/rcu -I../lib/rcu -fdiagnostics-color=always -pipe
-D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g
-include rte_config.h -Wcast-qual -Wdeprecated -Wformat
-Wformat-nonliteral -Wformat-security -Wmissing-declarations
-Wmissing-prototypes -Wnested-externs -Wold-style-definition
-Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef
-Wwrite-strings -Wno-address-of-packed-member -Wno-packed-not-aligned
-Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -mcpu=power8
-mtune=power8 -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API
-Wno-format-truncation -DRTE_LOG_DEFAULT_LOGTYPE=lib.hash -MD -MQ
'lib/76b5a35@@rte_hash at sta/hash_rte_fbk_hash.c.o' -MF
'lib/76b5a35@@rte_hash at sta/hash_rte_fbk_hash.c.o.d' -o
'lib/76b5a35@@rte_hash at sta/hash_rte_fbk_hash.c.o' -c
../lib/hash/rte_fbk_hash.c
In file included from ../lib/hash/rte_fbk_hash.h:27,
                 from ../lib/hash/rte_fbk_hash.c:21:
../lib/hash/rte_hash_crc.h:32:16: error: ‘crc32_alg’ defined but not
used [-Werror=unused-variable]
   32 | static uint8_t crc32_alg = CRC32_SW;
      |                ^~~~~~~~~
cc1: all warnings being treated as errors
[175/3761] Compiling C object 'lib/76b5a35@@rte_hash at
sta/hash_rte_cuckoo_hash.c.o'.
FAILED: lib/76b5a35@@rte_hash at sta/hash_rte_cuckoo_hash.c.o
ccache powerpc64le-linux-gnu-gcc -Ilib/76b5a35@@rte_hash at sta -Ilib
-I../lib -Ilib/hash -I../lib/hash -I. -I../ -Iconfig -I../config
-Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include
-I../lib/eal/linux/include -Ilib/eal/ppc/include
-I../lib/eal/ppc/include -Ilib/eal/common -I../lib/eal/common
-Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs
-Ilib/telemetry/../metrics -I../lib/telemetry/../metrics
-Ilib/telemetry -I../lib/telemetry -Ilib/net -I../lib/net -Ilib/mbuf
-I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring
-Ilib/rcu -I../lib/rcu -fdiagnostics-color=always -pipe
-D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g
-include rte_config.h -Wcast-qual -Wdeprecated -Wformat
-Wformat-nonliteral -Wformat-security -Wmissing-declarations
-Wmissing-prototypes -Wnested-externs -Wold-style-definition
-Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef
-Wwrite-strings -Wno-address-of-packed-member -Wno-packed-not-aligned
-Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -mcpu=power8
-mtune=power8 -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API
-Wno-format-truncation -DRTE_LOG_DEFAULT_LOGTYPE=lib.hash -MD -MQ
'lib/76b5a35@@rte_hash at sta/hash_rte_cuckoo_hash.c.o' -MF
'lib/76b5a35@@rte_hash at sta/hash_rte_cuckoo_hash.c.o.d' -o
'lib/76b5a35@@rte_hash at sta/hash_rte_cuckoo_hash.c.o' -c
../lib/hash/rte_cuckoo_hash.c
In file included from ../lib/hash/rte_cuckoo_hash.h:43,
                 from ../lib/hash/rte_cuckoo_hash.c:32:
../lib/hash/rte_hash_crc.h:32:16: error: ‘crc32_alg’ defined but not
used [-Werror=unused-variable]
   32 | static uint8_t crc32_alg = CRC32_SW;
      |                ^~~~~~~~~
cc1: all warnings being treated as errors
[176/3761] Generating ethdev.sym_chk with a meson_exe.py custom command.
ninja: build stopped: subcommand failed.
##[error]Process completed with exit code 1.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-21 14:55     ` David Marchand
@ 2023-02-21 17:07       ` Stephen Hemminger
  2023-03-29 23:31       ` Stephen Hemminger
  1 sibling, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 17:07 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

On Tue, 21 Feb 2023 15:55:29 +0100
David Marchand <david.marchand@redhat.com> wrote:

> On Tue, Feb 21, 2023 at 12:36 AM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > Replace all uses of the global logtype with a dynamic log type.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  lib/eal/common/eal_common_log.c | 1 -
> >  lib/eal/include/rte_log.h       | 2 +-
> >  lib/efd/rte_efd.c               | 4 ++++
> >  3 files changed, 5 insertions(+), 2 deletions(-)  
> 
> [snip]
> 
> > diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
> > index 686a13775742..9edb11799c89 100644
> > --- a/lib/efd/rte_efd.c
> > +++ b/lib/efd/rte_efd.c
> > @@ -9,6 +9,7 @@
> >  #include <errno.h>
> >  #include <sys/queue.h>
> >
> > +#include <rte_cpuflags.h>
> >  #include <rte_string_fns.h>
> >  #include <rte_log.h>
> >  #include <rte_eal_memconfig.h>  
> 
> This is unrelated, isn't it?

Not really, the old code worked only because it would get rte_cpuflags.h
included via rte_hash_crc.h.  When rte_hash_crc.h was fixed to not
do per-cpu setup in inline, then the cpu flags did not need to be
included there.

^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 00/22] Convert static logtypes in libraries
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (19 preceding siblings ...)
  2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
@ 2023-02-21 19:01 ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

There are several options on how to treat the old static types:
leave them there, mark as deprecated, or remove them.
This version removes them since there is no guarantee in current
DPDK policies that says they can't be removed.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v9 - fix handling of crc32 alg in lib/hash.
     make it an internal global variable.
     fix gfni stubs for case where they are not used.

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++---------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  4 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/gso/rte_gso.h                 |  1 +
 lib/hash/meson.build              |  9 +++-
 lib/hash/rte_crc_arm64.h          |  8 ++--
 lib/hash/rte_crc_x86.h            | 10 ++---
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  5 +++
 lib/hash/rte_hash_crc.c           | 68 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 48 ++--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 50 +++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 28 +++----------
 lib/hash/version.map              | 11 +++++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  2 +
 lib/mempool/rte_mempool.h         |  8 ++++
 lib/mempool/version.map           |  3 ++
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 75 files changed, 405 insertions(+), 179 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 01/22] gso: don't log message on non TCP/UDP
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiayu Hu, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 lib/gso/rte_gso.h | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
diff --git a/lib/gso/rte_gso.h b/lib/gso/rte_gso.h
index 40922524df42..23d6980aff9f 100644
--- a/lib/gso/rte_gso.h
+++ b/lib/gso/rte_gso.h
@@ -114,6 +114,7 @@ struct rte_gso_ctx {
  *  - The number of GSO segments filled in pkts_out on success.
  *  - Return 0 if it does not need to be GSO'd.
  *  - Return -ENOMEM if run out of memory in MBUF pools.
+ *  - Return -ENOTSUP for protocols that can not be segmentd (not UDP or TCP)
  *  - Return -EINVAL for invalid parameters.
  */
 int rte_gso_segment(struct rte_mbuf *pkt,
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 02/22] eal: drop no longer used GSO logtype
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 4 ++++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9edb11799c89 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <sys/queue.h>
 
+#include <rte_cpuflags.h>
 #include <rte_string_fns.h>
 #include <rte_log.h>
 #include <rte_eal_memconfig.h>
@@ -28,6 +29,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-22 16:34     ` Hunt, David
  2023-02-21 19:01   ` [PATCH v9 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Don't use static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-22 16:33     ` Hunt, David
  2023-02-21 19:01   ` [PATCH v9 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index f57c54d2b57c..76b890b76c88 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -51,7 +51,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2236,7 +2237,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2245,7 +2246,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2263,7 +2264,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2332,7 +2333,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2381,7 +2382,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	telemetry_setup_timer();
 
@@ -2397,7 +2398,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-22 16:32     ` Hunt, David
  2023-02-21 19:01   ` [PATCH v9 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/power/guest_channel.c       | 3 ++-
 lib/power/power_common.c        | 2 ++
 lib/power/power_common.h        | 3 ++-
 lib/power/power_kvm_vm.c        | 1 +
 lib/power/rte_power.c           | 1 +
 7 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 2 ++
 lib/mempool/rte_mempool.h       | 8 ++++++++
 lib/mempool/version.map         | 3 +++
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index cf5dea2304a7..b609a94fdf9d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,8 @@
 #include "mempool_trace.h"
 #include "rte_mempool.h"
 
+RTE_LOG_REGISTER_DEFAULT(rte_mempool_logtype, INFO);
+
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_mempool_tailq = {
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 9f530db24ba1..db01acc19b02 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -43,6 +43,7 @@
 #include <rte_spinlock.h>
 #include <rte_debug.h>
 #include <rte_lcore.h>
+#include <rte_log.h>
 #include <rte_branch_prediction.h>
 #include <rte_ring.h>
 #include <rte_memcpy.h>
@@ -175,6 +176,13 @@ struct rte_mempool_objtlr {
 
 #endif
 
+
+/**
+ * @internal Logtype used for mempool related messages.
+ */
+extern int rte_mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	rte_mempool_logtype
+
 /**
  * A list of memory where objects are stored
  */
diff --git a/lib/mempool/version.map b/lib/mempool/version.map
index dff2d1cb5555..eb2c12127560 100644
--- a/lib/mempool/version.map
+++ b/lib/mempool/version.map
@@ -57,4 +57,7 @@ INTERNAL {
 	# added in 21.11
 	rte_mempool_event_callback_register;
 	rte_mempool_event_callback_unregister;
+
+	# added in 23.07
+	rte_mempool_logtype;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:01   ` [PATCH v9 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-21 19:01   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-21 19:01   ` [PATCH v9 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index 19768d8c38b0..27e98e46df7a 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-22  7:37     ` [EXT] " Akhil Goyal
  2023-02-21 19:02   ` [PATCH v9 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, akhil.goyal, Radu Nicolau, Akhil Goyal,
	Boris Pismenny, Declan Doherty, Aviad Yehezkel

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..d4ac08b4cff0 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYPE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 ++++++-
 lib/hash/rte_thash_gfni.c | 47 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 28 +++++------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 63 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..eb334185725c
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+#ifndef RTE_THASH_GFNI_DEFINED
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
+
+#endif
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..86208eb45ebb 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,8 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +33,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +57,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 21/22] hash: move rte_hash_set_alg out header
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  2023-02-21 19:02   ` [PATCH v9 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Ruifeng Wang

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build     |  1 +
 lib/hash/rte_crc_arm64.h |  8 ++---
 lib/hash/rte_crc_x86.h   | 10 +++---
 lib/hash/rte_hash_crc.c  | 68 ++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h  | 48 ++--------------------------
 lib/hash/version.map     |  7 +++++
 6 files changed, 88 insertions(+), 54 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_crc_arm64.h b/lib/hash/rte_crc_arm64.h
index c9f52510871b..414fe065caa8 100644
--- a/lib/hash/rte_crc_arm64.h
+++ b/lib/hash/rte_crc_arm64.h
@@ -53,7 +53,7 @@ crc32c_arm64_u64(uint64_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u8(data, init_val);
 
 	return crc32c_1byte(data, init_val);
@@ -67,7 +67,7 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u16(data, init_val);
 
 	return crc32c_2bytes(data, init_val);
@@ -81,7 +81,7 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u32(data, init_val);
 
 	return crc32c_1word(data, init_val);
@@ -95,7 +95,7 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u64(data, init_val);
 
 	return crc32c_2words(data, init_val);
diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h
index 205bc182be77..3b865e251db2 100644
--- a/lib/hash/rte_crc_x86.h
+++ b/lib/hash/rte_crc_x86.h
@@ -67,7 +67,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 static inline uint32_t
 rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u8(data, init_val);
 
 	return crc32c_1byte(data, init_val);
@@ -81,7 +81,7 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u16(data, init_val);
 
 	return crc32c_2bytes(data, init_val);
@@ -95,7 +95,7 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u32(data, init_val);
 
 	return crc32c_1word(data, init_val);
@@ -110,11 +110,11 @@ static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
 #ifdef RTE_ARCH_X86_64
-	if (likely(crc32_alg == CRC32_SSE42_x64))
+	if (likely(rte_hash_crc32_alg == CRC32_SSE42_x64))
 		return crc32c_sse42_u64(data, init_val);
 #endif
 
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u64_mimic(data, init_val);
 
 	return crc32c_2words(data, init_val);
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..1439d8a71f6a
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH_CRC hash_crc_logtype
+
+uint8_t rte_hash_crc32_alg = CRC32_SW;
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	rte_hash_crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		rte_hash_crc32_alg = CRC32_SSE42;
+	else
+		rte_hash_crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		rte_hash_crc32_alg = CRC32_ARM64;
+#endif
+
+	if (rte_hash_crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e8145ee44204 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -31,7 +29,7 @@ extern "C" {
 #define CRC32_SSE42_x64     (CRC32_x64|CRC32_SSE42)
 #define CRC32_ARM64         (1U << 3)
 
-static uint8_t crc32_alg = CRC32_SW;
+extern uint8_t rte_hash_crc32_alg;
 
 #if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
 #include "rte_crc_arm64.h"
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..8b22aad5626b 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
@@ -56,3 +57,9 @@ EXPERIMENTAL {
 	rte_thash_gfni;
 	rte_thash_gfni_bulk;
 };
+
+INTERNAL {
+	global:
+
+	rte_hash_crc32_alg;
+};
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v9 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-21 19:02   ` [PATCH v9 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-21 19:02   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-21 19:02 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 5 +++++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 6 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..b4c4c191abdc 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 
 #include <sys/queue.h>
+
+#include <rte_cpuflags.h>
 #include <rte_eal_memconfig.h>
 #include <rte_malloc.h>
 #include <rte_common.h>
@@ -18,6 +20,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index eb334185725c..35206d575153 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -10,6 +10,9 @@
 
 #ifndef RTE_THASH_GFNI_DEFINED
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [EXT] [PATCH v9 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-21 19:02   ` [PATCH v9 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-22  7:37     ` Akhil Goyal
  0 siblings, 0 replies; 255+ messages in thread
From: Akhil Goyal @ 2023-02-22  7:37 UTC (permalink / raw)
  To: Stephen Hemminger, dev
  Cc: Radu Nicolau, Boris Pismenny, Declan Doherty, Aviad Yehezkel

> Subject: [EXT] [PATCH v9 15/22] examples/ipsecgw: replace
> RTE_LOGTYPE_PORT

Title should be
examples/ipsec-secgw: replace RTE_LOGTYPE_PORT

Acked-by: Akhil Goyal <gakhil@marvell.com>
> 
> Looks like some code got copy/paste in to the IPSEC gateway
> example from another place. Shouldn't be using RTE_LOGTYPE_PORT
> here.
> 
> Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
> Cc: akhil.goyal@nxp.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 00/22] Convert static log type values in libraries
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (20 preceding siblings ...)
  2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
@ 2023-02-22 16:07 ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

There are several options on how to treat the old static types:
leave them there, mark as deprecated, or remove them.
This version removes them since there is no guarantee in current
DPDK policies that says they can't be removed.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v10 - add necessary rte_compat.h in thash_gfni stub for arm

v9 - fix handling of crc32 alg in lib/hash.
     make it an internal global variable.
     fix gfni stubs for case where they are not used.

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++---------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  4 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/gso/rte_gso.h                 |  1 +
 lib/hash/meson.build              |  9 +++-
 lib/hash/rte_crc_arm64.h          |  8 ++--
 lib/hash/rte_crc_x86.h            | 10 ++---
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  5 +++
 lib/hash/rte_hash_crc.c           | 68 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 48 ++--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 50 +++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 29 +++----------
 lib/hash/version.map              | 11 +++++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  2 +
 lib/mempool/rte_mempool.h         |  8 ++++
 lib/mempool/version.map           |  3 ++
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 75 files changed, 406 insertions(+), 179 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 01/22] gso: don't log message on non TCP/UDP
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiayu Hu, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 lib/gso/rte_gso.h | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
diff --git a/lib/gso/rte_gso.h b/lib/gso/rte_gso.h
index 40922524df42..23d6980aff9f 100644
--- a/lib/gso/rte_gso.h
+++ b/lib/gso/rte_gso.h
@@ -114,6 +114,7 @@ struct rte_gso_ctx {
  *  - The number of GSO segments filled in pkts_out on success.
  *  - Return 0 if it does not need to be GSO'd.
  *  - Return -ENOMEM if run out of memory in MBUF pools.
+ *  - Return -ENOTSUP for protocols that can not be segmentd (not UDP or TCP)
  *  - Return -EINVAL for invalid parameters.
  */
 int rte_gso_segment(struct rte_mbuf *pkt,
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 02/22] eal: drop no longer used GSO logtype
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 4 ++++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9edb11799c89 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <sys/queue.h>
 
+#include <rte_cpuflags.h>
 #include <rte_string_fns.h>
 #include <rte_log.h>
 #include <rte_eal_memconfig.h>
@@ -28,6 +29,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:36     ` Hunt, David
  2023-02-22 16:07   ` [PATCH v10 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Don't use static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:36     ` Hunt, David
  2023-02-22 16:07   ` [PATCH v10 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index f57c54d2b57c..76b890b76c88 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -51,7 +51,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2236,7 +2237,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2245,7 +2246,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2263,7 +2264,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2332,7 +2333,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2381,7 +2382,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	telemetry_setup_timer();
 
@@ -2397,7 +2398,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:35     ` Hunt, David
  2023-02-22 16:07   ` [PATCH v10 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 1 reply; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/power/guest_channel.c       | 3 ++-
 lib/power/power_common.c        | 2 ++
 lib/power/power_common.h        | 3 ++-
 lib/power/power_kvm_vm.c        | 1 +
 lib/power/rte_power.c           | 1 +
 7 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 2 ++
 lib/mempool/rte_mempool.h       | 8 ++++++++
 lib/mempool/version.map         | 3 +++
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index cf5dea2304a7..b609a94fdf9d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,8 @@
 #include "mempool_trace.h"
 #include "rte_mempool.h"
 
+RTE_LOG_REGISTER_DEFAULT(rte_mempool_logtype, INFO);
+
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_mempool_tailq = {
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 9f530db24ba1..db01acc19b02 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -43,6 +43,7 @@
 #include <rte_spinlock.h>
 #include <rte_debug.h>
 #include <rte_lcore.h>
+#include <rte_log.h>
 #include <rte_branch_prediction.h>
 #include <rte_ring.h>
 #include <rte_memcpy.h>
@@ -175,6 +176,13 @@ struct rte_mempool_objtlr {
 
 #endif
 
+
+/**
+ * @internal Logtype used for mempool related messages.
+ */
+extern int rte_mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	rte_mempool_logtype
+
 /**
  * A list of memory where objects are stored
  */
diff --git a/lib/mempool/version.map b/lib/mempool/version.map
index dff2d1cb5555..eb2c12127560 100644
--- a/lib/mempool/version.map
+++ b/lib/mempool/version.map
@@ -57,4 +57,7 @@ INTERNAL {
 	# added in 21.11
 	rte_mempool_event_callback_register;
 	rte_mempool_event_callback_unregister;
+
+	# added in 23.07
+	rte_mempool_logtype;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index 19768d8c38b0..27e98e46df7a 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, akhil.goyal, Radu Nicolau, Akhil Goyal,
	Boris Pismenny, Aviad Yehezkel, Declan Doherty

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..d4ac08b4cff0 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYPE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:07   ` [PATCH v10 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-22 16:07   ` Stephen Hemminger
  2023-02-22 16:08   ` [PATCH v10 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-22 16:07   ` [PATCH v10 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-22 16:08   ` Stephen Hemminger
  2023-02-22 16:08   ` [PATCH v10 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-22 16:08   ` [PATCH v10 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:08 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 ++++++-
 lib/hash/rte_thash_gfni.c | 47 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 29 +++++-------------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 64 insertions(+), 24 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..eb334185725c
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+#ifndef RTE_THASH_GFNI_DEFINED
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
+
+#endif
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..6127f5533873 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,16 +9,12 @@
 extern "C" {
 #endif
 
-#include <rte_compat.h>
-#include <rte_log.h>
-
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
+#include <rte_compat.h>
 
 /**
  * Calculate Toeplitz hash.
@@ -38,13 +34,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +58,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 21/22] hash: move rte_hash_set_alg out header
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-22 16:08   ` [PATCH v10 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-22 16:08   ` Stephen Hemminger
  2023-02-22 16:08   ` [PATCH v10 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:08 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Ruifeng Wang

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build     |  1 +
 lib/hash/rte_crc_arm64.h |  8 ++---
 lib/hash/rte_crc_x86.h   | 10 +++---
 lib/hash/rte_hash_crc.c  | 68 ++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h  | 48 ++--------------------------
 lib/hash/version.map     |  7 +++++
 6 files changed, 88 insertions(+), 54 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_crc_arm64.h b/lib/hash/rte_crc_arm64.h
index c9f52510871b..414fe065caa8 100644
--- a/lib/hash/rte_crc_arm64.h
+++ b/lib/hash/rte_crc_arm64.h
@@ -53,7 +53,7 @@ crc32c_arm64_u64(uint64_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u8(data, init_val);
 
 	return crc32c_1byte(data, init_val);
@@ -67,7 +67,7 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u16(data, init_val);
 
 	return crc32c_2bytes(data, init_val);
@@ -81,7 +81,7 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u32(data, init_val);
 
 	return crc32c_1word(data, init_val);
@@ -95,7 +95,7 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u64(data, init_val);
 
 	return crc32c_2words(data, init_val);
diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h
index 205bc182be77..3b865e251db2 100644
--- a/lib/hash/rte_crc_x86.h
+++ b/lib/hash/rte_crc_x86.h
@@ -67,7 +67,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 static inline uint32_t
 rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u8(data, init_val);
 
 	return crc32c_1byte(data, init_val);
@@ -81,7 +81,7 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u16(data, init_val);
 
 	return crc32c_2bytes(data, init_val);
@@ -95,7 +95,7 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u32(data, init_val);
 
 	return crc32c_1word(data, init_val);
@@ -110,11 +110,11 @@ static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
 #ifdef RTE_ARCH_X86_64
-	if (likely(crc32_alg == CRC32_SSE42_x64))
+	if (likely(rte_hash_crc32_alg == CRC32_SSE42_x64))
 		return crc32c_sse42_u64(data, init_val);
 #endif
 
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u64_mimic(data, init_val);
 
 	return crc32c_2words(data, init_val);
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..1439d8a71f6a
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH_CRC hash_crc_logtype
+
+uint8_t rte_hash_crc32_alg = CRC32_SW;
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	rte_hash_crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		rte_hash_crc32_alg = CRC32_SSE42;
+	else
+		rte_hash_crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		rte_hash_crc32_alg = CRC32_ARM64;
+#endif
+
+	if (rte_hash_crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e8145ee44204 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -31,7 +29,7 @@ extern "C" {
 #define CRC32_SSE42_x64     (CRC32_x64|CRC32_SSE42)
 #define CRC32_ARM64         (1U << 3)
 
-static uint8_t crc32_alg = CRC32_SW;
+extern uint8_t rte_hash_crc32_alg;
 
 #if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
 #include "rte_crc_arm64.h"
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..8b22aad5626b 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
@@ -56,3 +57,9 @@ EXPERIMENTAL {
 	rte_thash_gfni;
 	rte_thash_gfni_bulk;
 };
+
+INTERNAL {
+	global:
+
+	rte_hash_crc32_alg;
+};
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v10 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-22 16:08   ` [PATCH v10 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-22 16:08   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 16:08 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 5 +++++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 6 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..b4c4c191abdc 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 
 #include <sys/queue.h>
+
+#include <rte_cpuflags.h>
 #include <rte_eal_memconfig.h>
 #include <rte_malloc.h>
 #include <rte_common.h>
@@ -18,6 +20,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index eb334185725c..35206d575153 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -10,6 +10,9 @@
 
 #ifndef RTE_THASH_GFNI_DEFINED
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v9 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-21 19:01   ` [PATCH v9 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-22 16:32     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:32 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 21/02/2023 19:01, Stephen Hemminger wrote:
> Use dynamic log type for power library.
> Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/eal/common/eal_common_log.c | 1 -
>   lib/eal/include/rte_log.h       | 2 +-
>   lib/power/guest_channel.c       | 3 ++-
>   lib/power/power_common.c        | 2 ++
>   lib/power/power_common.h        | 3 ++-
>   lib/power/power_kvm_vm.c        | 1 +
>   lib/power/rte_power.c           | 1 +
>   7 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
> index 9e853addb717..39e1e6680dea 100644
> --- a/lib/eal/common/eal_common_log.c
> +++ b/lib/eal/common/eal_common_log.c
> @@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
>   	{RTE_LOGTYPE_HASH,       "lib.hash"},
>   	{RTE_LOGTYPE_LPM,        "lib.lpm"},
>   	{RTE_LOGTYPE_KNI,        "lib.kni"},
> -	{RTE_LOGTYPE_POWER,      "lib.power"},
>   	{RTE_LOGTYPE_METER,      "lib.meter"},
>   	{RTE_LOGTYPE_SCHED,      "lib.sched"},
>   	{RTE_LOGTYPE_PORT,       "lib.port"},
> diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
> index 1408722b2c2f..7d4345acceca 100644
> --- a/lib/eal/include/rte_log.h
> +++ b/lib/eal/include/rte_log.h
> @@ -36,7 +36,7 @@ extern "C" {
>   #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
>   #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
>   				 /* was RTE_LOGTYPE_ACL */
> -#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
> +				 /* was RTE_LOGTYPE_POWER */
>   #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
>   #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
>   #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
> diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
> index 969a9e5aaa06..efc326d520ca 100644
> --- a/lib/power/guest_channel.c
> +++ b/lib/power/guest_channel.c
> @@ -17,7 +17,8 @@
>   
>   #include "guest_channel.h"
>   
> -#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
> +RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
> +#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
>   
>   /* Timeout for incoming message in milliseconds. */
>   #define TIMEOUT 10
> diff --git a/lib/power/power_common.c b/lib/power/power_common.c
> index 1e09facb863f..bf77eafa886b 100644
> --- a/lib/power/power_common.c
> +++ b/lib/power/power_common.c
> @@ -12,6 +12,8 @@
>   
>   #include "power_common.h"
>   
> +RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
> +
>   #define POWER_SYSFILE_SCALING_DRIVER   \
>   		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
>   #define POWER_SYSFILE_GOVERNOR  \
> diff --git a/lib/power/power_common.h b/lib/power/power_common.h
> index c1c713927621..63a3a443509e 100644
> --- a/lib/power/power_common.h
> +++ b/lib/power/power_common.h
> @@ -5,11 +5,12 @@
>   #ifndef _POWER_COMMON_H_
>   #define _POWER_COMMON_H_
>   
> -
>   #include <rte_common.h>
>   
>   #define RTE_POWER_INVALID_FREQ_INDEX (~0)
>   
> +extern int power_logtype;
> +#define RTE_LOGTYPE_POWER power_logtype
>   
>   #ifdef RTE_LIBRTE_POWER_DEBUG
>   #define POWER_DEBUG_TRACE(fmt, args...) \
> diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
> index 6a8109d44959..db031f43105a 100644
> --- a/lib/power/power_kvm_vm.c
> +++ b/lib/power/power_kvm_vm.c
> @@ -8,6 +8,7 @@
>   
>   #include "rte_power_guest_channel.h"
>   #include "guest_channel.h"
> +#include "power_common.h"
>   #include "power_kvm_vm.h"
>   
>   #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
> diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
> index 63a43bd8f5ae..db0e7705a9ef 100644
> --- a/lib/power/rte_power.c
> +++ b/lib/power/rte_power.c
> @@ -10,6 +10,7 @@
>   #include "rte_power.h"
>   #include "power_acpi_cpufreq.h"
>   #include "power_cppc_cpufreq.h"
> +#include "power_common.h"
>   #include "power_kvm_vm.h"
>   #include "power_pstate_cpufreq.h"


Acked-by: David Hunt <david.hunt@intel.com>


>   

^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v9 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-21 19:01   ` [PATCH v9 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-22 16:33     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:33 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 21/02/2023 19:01, Stephen Hemminger wrote:
> Convert to using a dynamic logtype for the application.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   examples/l3fwd-power/main.c | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
> index f57c54d2b57c..76b890b76c88 100644
> --- a/examples/l3fwd-power/main.c
> +++ b/examples/l3fwd-power/main.c
> @@ -51,7 +51,8 @@
>   #include "perf_core.h"
>   #include "main.h"
>   
> -#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
> +RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
> +#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
>   
>   #define MAX_PKT_BURST 32
>   
> @@ -2236,7 +2237,7 @@ init_power_library(void)
>   		/* init power management library */
>   		ret = rte_power_init(lcore_id);
>   		if (ret) {
> -			RTE_LOG(ERR, POWER,
> +			RTE_LOG(ERR, L3FWD_POWER,
>   				"Library initialization failed on core %u\n",
>   				lcore_id);
>   			return ret;
> @@ -2245,7 +2246,7 @@ init_power_library(void)
>   		env = rte_power_get_env();
>   		if (env != PM_ENV_ACPI_CPUFREQ &&
>   				env != PM_ENV_PSTATE_CPUFREQ) {
> -			RTE_LOG(ERR, POWER,
> +			RTE_LOG(ERR, L3FWD_POWER,
>   				"Only ACPI and PSTATE mode are supported\n");
>   			return -1;
>   		}
> @@ -2263,7 +2264,7 @@ deinit_power_library(void)
>   		/* deinit power management library */
>   		ret = rte_power_exit(lcore_id);
>   		if (ret) {
> -			RTE_LOG(ERR, POWER,
> +			RTE_LOG(ERR, L3FWD_POWER,
>   				"Library deinitialization failed on core %u\n",
>   				lcore_id);
>   			return ret;
> @@ -2332,7 +2333,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
>   	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
>   					values, RTE_DIM(values));
>   	if (ret < 0)
> -		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
> +		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
>   }
>   
>   static int
> @@ -2381,7 +2382,7 @@ launch_timer(unsigned int lcore_id)
>   				rte_get_main_lcore());
>   	}
>   
> -	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
> +	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
>   
>   	telemetry_setup_timer();
>   
> @@ -2397,7 +2398,7 @@ launch_timer(unsigned int lcore_id)
>   		}
>   	}
>   
> -	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
> +	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
>   
>   	return 0;
>   }

Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v9 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-21 19:01   ` [PATCH v9 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-22 16:34     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:34 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 21/02/2023 19:01, Stephen Hemminger wrote:
> Don't use static logtype in sample application.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   examples/distributor/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/distributor/main.c b/examples/distributor/main.c
> index 21304d661873..542f76cf9664 100644
> --- a/examples/distributor/main.c
> +++ b/examples/distributor/main.c
> @@ -679,7 +679,7 @@ init_power_library(void)
>   		/* init power management library */
>   		ret = rte_power_init(lcore_id);
>   		if (ret) {
> -			RTE_LOG(ERR, POWER,
> +			fprintf(stderr,
>   				"Library initialization failed on core %u\n",
>   				lcore_id);
>   			/*


Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v7 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-15 17:23   ` [PATCH v7 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-22 16:34     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:34 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 15/02/2023 17:23, Stephen Hemminger wrote:
> Use dynamic log type for power library.
> Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/eal/common/eal_common_log.c  | 1 -
>   lib/eal/include/rte_log.h        | 2 +-
>   lib/power/guest_channel.c        | 3 ++-
>   lib/power/power_common.c         | 2 ++
>   lib/power/power_common.h         | 3 ++-
>   lib/power/power_kvm_vm.c         | 1 +
>   lib/power/rte_power.c            | 1 +
>   lib/power/rte_power_empty_poll.c | 1 +
>   8 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
> index 9e853addb717..39e1e6680dea 100644
> --- a/lib/eal/common/eal_common_log.c
> +++ b/lib/eal/common/eal_common_log.c
> @@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
>   	{RTE_LOGTYPE_HASH,       "lib.hash"},
>   	{RTE_LOGTYPE_LPM,        "lib.lpm"},
>   	{RTE_LOGTYPE_KNI,        "lib.kni"},
> -	{RTE_LOGTYPE_POWER,      "lib.power"},
>   	{RTE_LOGTYPE_METER,      "lib.meter"},
>   	{RTE_LOGTYPE_SCHED,      "lib.sched"},
>   	{RTE_LOGTYPE_PORT,       "lib.port"},
> diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
> index 1408722b2c2f..7d4345acceca 100644
> --- a/lib/eal/include/rte_log.h
> +++ b/lib/eal/include/rte_log.h
> @@ -36,7 +36,7 @@ extern "C" {
>   #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
>   #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
>   				 /* was RTE_LOGTYPE_ACL */
> -#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
> +				 /* was RTE_LOGTYPE_POWER */
>   #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
>   #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
>   #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
> diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
> index 969a9e5aaa06..efc326d520ca 100644
> --- a/lib/power/guest_channel.c
> +++ b/lib/power/guest_channel.c
> @@ -17,7 +17,8 @@
>   
>   #include "guest_channel.h"
>   
> -#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
> +RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
> +#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
>   
>   /* Timeout for incoming message in milliseconds. */
>   #define TIMEOUT 10
> diff --git a/lib/power/power_common.c b/lib/power/power_common.c
> index 1e09facb863f..bf77eafa886b 100644
> --- a/lib/power/power_common.c
> +++ b/lib/power/power_common.c
> @@ -12,6 +12,8 @@
>   
>   #include "power_common.h"
>   
> +RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
> +
>   #define POWER_SYSFILE_SCALING_DRIVER   \
>   		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
>   #define POWER_SYSFILE_GOVERNOR  \
> diff --git a/lib/power/power_common.h b/lib/power/power_common.h
> index c1c713927621..63a3a443509e 100644
> --- a/lib/power/power_common.h
> +++ b/lib/power/power_common.h
> @@ -5,11 +5,12 @@
>   #ifndef _POWER_COMMON_H_
>   #define _POWER_COMMON_H_
>   
> -
>   #include <rte_common.h>
>   
>   #define RTE_POWER_INVALID_FREQ_INDEX (~0)
>   
> +extern int power_logtype;
> +#define RTE_LOGTYPE_POWER power_logtype
>   
>   #ifdef RTE_LIBRTE_POWER_DEBUG
>   #define POWER_DEBUG_TRACE(fmt, args...) \
> diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
> index 6a8109d44959..db031f43105a 100644
> --- a/lib/power/power_kvm_vm.c
> +++ b/lib/power/power_kvm_vm.c
> @@ -8,6 +8,7 @@
>   
>   #include "rte_power_guest_channel.h"
>   #include "guest_channel.h"
> +#include "power_common.h"
>   #include "power_kvm_vm.h"
>   
>   #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
> diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
> index 63a43bd8f5ae..db0e7705a9ef 100644
> --- a/lib/power/rte_power.c
> +++ b/lib/power/rte_power.c
> @@ -10,6 +10,7 @@
>   #include "rte_power.h"
>   #include "power_acpi_cpufreq.h"
>   #include "power_cppc_cpufreq.h"
> +#include "power_common.h"
>   #include "power_kvm_vm.h"
>   #include "power_pstate_cpufreq.h"
>   
> diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c
> index 4a4db512474e..64e3b4b46d5e 100644
> --- a/lib/power/rte_power_empty_poll.c
> +++ b/lib/power/rte_power_empty_poll.c
> @@ -10,6 +10,7 @@
>   
>   #include "rte_power.h"
>   #include "rte_power_empty_poll.h"
> +#include "power_common.h"
>   
>   #define INTERVALS_PER_SECOND 100     /* (10ms) */
>   #define SECONDS_TO_TRAIN_FOR 2


Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v10 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-22 16:07   ` [PATCH v10 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-22 16:35     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:35 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 22/02/2023 16:07, Stephen Hemminger wrote:
> Use dynamic log type for power library.
> Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/eal/common/eal_common_log.c | 1 -
>   lib/eal/include/rte_log.h       | 2 +-
>   lib/power/guest_channel.c       | 3 ++-
>   lib/power/power_common.c        | 2 ++
>   lib/power/power_common.h        | 3 ++-
>   lib/power/power_kvm_vm.c        | 1 +
>   lib/power/rte_power.c           | 1 +
>   7 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
> index 9e853addb717..39e1e6680dea 100644
> --- a/lib/eal/common/eal_common_log.c
> +++ b/lib/eal/common/eal_common_log.c
> @@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
>   	{RTE_LOGTYPE_HASH,       "lib.hash"},
>   	{RTE_LOGTYPE_LPM,        "lib.lpm"},
>   	{RTE_LOGTYPE_KNI,        "lib.kni"},
> -	{RTE_LOGTYPE_POWER,      "lib.power"},
>   	{RTE_LOGTYPE_METER,      "lib.meter"},
>   	{RTE_LOGTYPE_SCHED,      "lib.sched"},
>   	{RTE_LOGTYPE_PORT,       "lib.port"},
> diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
> index 1408722b2c2f..7d4345acceca 100644
> --- a/lib/eal/include/rte_log.h
> +++ b/lib/eal/include/rte_log.h
> @@ -36,7 +36,7 @@ extern "C" {
>   #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
>   #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
>   				 /* was RTE_LOGTYPE_ACL */
> -#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
> +				 /* was RTE_LOGTYPE_POWER */
>   #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
>   #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
>   #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
> diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
> index 969a9e5aaa06..efc326d520ca 100644
> --- a/lib/power/guest_channel.c
> +++ b/lib/power/guest_channel.c
> @@ -17,7 +17,8 @@
>   
>   #include "guest_channel.h"
>   
> -#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
> +RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
> +#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
>   
>   /* Timeout for incoming message in milliseconds. */
>   #define TIMEOUT 10
> diff --git a/lib/power/power_common.c b/lib/power/power_common.c
> index 1e09facb863f..bf77eafa886b 100644
> --- a/lib/power/power_common.c
> +++ b/lib/power/power_common.c
> @@ -12,6 +12,8 @@
>   
>   #include "power_common.h"
>   
> +RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
> +
>   #define POWER_SYSFILE_SCALING_DRIVER   \
>   		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
>   #define POWER_SYSFILE_GOVERNOR  \
> diff --git a/lib/power/power_common.h b/lib/power/power_common.h
> index c1c713927621..63a3a443509e 100644
> --- a/lib/power/power_common.h
> +++ b/lib/power/power_common.h
> @@ -5,11 +5,12 @@
>   #ifndef _POWER_COMMON_H_
>   #define _POWER_COMMON_H_
>   
> -
>   #include <rte_common.h>
>   
>   #define RTE_POWER_INVALID_FREQ_INDEX (~0)
>   
> +extern int power_logtype;
> +#define RTE_LOGTYPE_POWER power_logtype
>   
>   #ifdef RTE_LIBRTE_POWER_DEBUG
>   #define POWER_DEBUG_TRACE(fmt, args...) \
> diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
> index 6a8109d44959..db031f43105a 100644
> --- a/lib/power/power_kvm_vm.c
> +++ b/lib/power/power_kvm_vm.c
> @@ -8,6 +8,7 @@
>   
>   #include "rte_power_guest_channel.h"
>   #include "guest_channel.h"
> +#include "power_common.h"
>   #include "power_kvm_vm.h"
>   
>   #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
> diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
> index 63a43bd8f5ae..db0e7705a9ef 100644
> --- a/lib/power/rte_power.c
> +++ b/lib/power/rte_power.c
> @@ -10,6 +10,7 @@
>   #include "rte_power.h"
>   #include "power_acpi_cpufreq.h"
>   #include "power_cppc_cpufreq.h"
> +#include "power_common.h"
>   #include "power_kvm_vm.h"
>   #include "power_pstate_cpufreq.h"


Acked-by: David Hunt <david.hunt@intel.com>


>   

^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v10 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-22 16:07   ` [PATCH v10 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-22 16:36     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:36 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 22/02/2023 16:07, Stephen Hemminger wrote:
> Convert to using a dynamic logtype for the application.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   examples/l3fwd-power/main.c | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
> index f57c54d2b57c..76b890b76c88 100644
> --- a/examples/l3fwd-power/main.c
> +++ b/examples/l3fwd-power/main.c
> @@ -51,7 +51,8 @@
>   #include "perf_core.h"
>   #include "main.h"
>   
> -#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
> +RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
> +#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
>   
>   #define MAX_PKT_BURST 32
>   
> @@ -2236,7 +2237,7 @@ init_power_library(void)
>   		/* init power management library */
>   		ret = rte_power_init(lcore_id);
>   		if (ret) {
> -			RTE_LOG(ERR, POWER,
> +			RTE_LOG(ERR, L3FWD_POWER,
>   				"Library initialization failed on core %u\n",
>   				lcore_id);
>   			return ret;
> @@ -2245,7 +2246,7 @@ init_power_library(void)
>   		env = rte_power_get_env();
>   		if (env != PM_ENV_ACPI_CPUFREQ &&
>   				env != PM_ENV_PSTATE_CPUFREQ) {
> -			RTE_LOG(ERR, POWER,
> +			RTE_LOG(ERR, L3FWD_POWER,
>   				"Only ACPI and PSTATE mode are supported\n");
>   			return -1;
>   		}
> @@ -2263,7 +2264,7 @@ deinit_power_library(void)
>   		/* deinit power management library */
>   		ret = rte_power_exit(lcore_id);
>   		if (ret) {
> -			RTE_LOG(ERR, POWER,
> +			RTE_LOG(ERR, L3FWD_POWER,
>   				"Library deinitialization failed on core %u\n",
>   				lcore_id);
>   			return ret;
> @@ -2332,7 +2333,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
>   	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
>   					values, RTE_DIM(values));
>   	if (ret < 0)
> -		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
> +		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
>   }
>   
>   static int
> @@ -2381,7 +2382,7 @@ launch_timer(unsigned int lcore_id)
>   				rte_get_main_lcore());
>   	}
>   
> -	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
> +	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
>   
>   	telemetry_setup_timer();
>   
> @@ -2397,7 +2398,7 @@ launch_timer(unsigned int lcore_id)
>   		}
>   	}
>   
> -	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
> +	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
>   
>   	return 0;
>   }


Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v10 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-22 16:07   ` [PATCH v10 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-22 16:36     ` Hunt, David
  0 siblings, 0 replies; 255+ messages in thread
From: Hunt, David @ 2023-02-22 16:36 UTC (permalink / raw)
  To: Stephen Hemminger, dev


On 22/02/2023 16:07, Stephen Hemminger wrote:
> Don't use static logtype in sample application.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   examples/distributor/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/distributor/main.c b/examples/distributor/main.c
> index 21304d661873..542f76cf9664 100644
> --- a/examples/distributor/main.c
> +++ b/examples/distributor/main.c
> @@ -679,7 +679,7 @@ init_power_library(void)
>   		/* init power management library */
>   		ret = rte_power_init(lcore_id);
>   		if (ret) {
> -			RTE_LOG(ERR, POWER,
> +			fprintf(stderr,
>   				"Library initialization failed on core %u\n",
>   				lcore_id);
>   			/*


Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 00/22] Convert static log type values in libraries
  2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
                   ` (21 preceding siblings ...)
  2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
@ 2023-02-22 21:55 ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
                     ` (21 more replies)
  22 siblings, 22 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patchset removes the main uses of static LOGTYPE's in DPDK
libraries. It starts with the easy one and goes on to the more complex ones.

There are several options on how to treat the old static types:
leave them there, mark as deprecated, or remove them.
This version removes them since there is no guarantee in current
DPDK policies that says they can't be removed.

Note: there is one patch in this series that will get
flagged incorrectly as an ABI change.

v11 - fix include check on arm cross build

v10 - add necessary rte_compat.h in thash_gfni stub for arm

v9 - fix handling of crc32 alg in lib/hash.
     make it an internal global variable.
     fix gfni stubs for case where they are not used.

Stephen Hemminger (22):
  gso: don't log message on non TCP/UDP
  eal: drop no longer used GSO logtype
  log: drop unused RTE_LOGTYPE_TIMER
  efd: replace RTE_LOGTYPE_EFD with dynamic type
  mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  acl: replace LOGTYPE_ACL with dynamic type
  examples/power: replace use of RTE_LOGTYPE_POWER
  examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  power: replace RTE_LOGTYPE_POWER with dynamic type
  ring: replace RTE_LOGTYPE_RING with dynamic type
  mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  lpm: replace RTE_LOGTYPE_LPM with dynamic types
  kni: replace RTE_LOGTYPE_KNI with dynamic type
  sched: replace RTE_LOGTYPE_SCHED with dynamic type
  examples/ipsecgw: replace RTE_LOGTYPE_PORT
  port: replace RTE_LOGTYPE_PORT with dynamic type
  table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  app/test: remove use of RTE_LOGTYPE_PIPELINE
  pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  hash: move rte_thash_gfni stubs out of header file
  hash: move rte_hash_set_alg out header
  hash: convert RTE_LOGTYPE_HASH to dynamic type

 app/test/test_acl.c               |  3 +-
 app/test/test_table_acl.c         | 50 +++++++++++------------
 app/test/test_table_pipeline.c    | 40 +++++++++---------
 examples/distributor/main.c       |  2 +-
 examples/ipsec-secgw/sa.c         |  6 +--
 examples/l3fwd-power/main.c       | 15 +++----
 lib/acl/acl_bld.c                 |  1 +
 lib/acl/acl_gen.c                 |  1 +
 lib/acl/acl_log.h                 |  4 ++
 lib/acl/rte_acl.c                 |  4 ++
 lib/acl/tb_mem.c                  |  3 +-
 lib/eal/common/eal_common_log.c   | 17 --------
 lib/eal/include/rte_log.h         | 34 ++++++++--------
 lib/efd/rte_efd.c                 |  4 ++
 lib/fib/fib_log.h                 |  4 ++
 lib/fib/rte_fib.c                 |  3 ++
 lib/fib/rte_fib6.c                |  2 +
 lib/gso/rte_gso.c                 |  5 +--
 lib/gso/rte_gso.h                 |  1 +
 lib/hash/meson.build              |  9 +++-
 lib/hash/rte_crc_arm64.h          |  8 ++--
 lib/hash/rte_crc_x86.h            | 10 ++---
 lib/hash/rte_cuckoo_hash.c        |  5 +++
 lib/hash/rte_fbk_hash.c           |  5 +++
 lib/hash/rte_hash_crc.c           | 68 +++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h           | 48 ++--------------------
 lib/hash/rte_thash.c              |  3 ++
 lib/hash/rte_thash_gfni.c         | 50 +++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h         | 30 ++++----------
 lib/hash/version.map              | 11 +++++
 lib/kni/rte_kni.c                 |  3 ++
 lib/lpm/lpm_log.h                 |  4 ++
 lib/lpm/rte_lpm.c                 |  3 ++
 lib/lpm/rte_lpm6.c                |  1 +
 lib/mbuf/mbuf_log.h               |  4 ++
 lib/mbuf/rte_mbuf.c               |  4 ++
 lib/mbuf/rte_mbuf_dyn.c           |  2 +
 lib/mbuf/rte_mbuf_pool_ops.c      |  2 +
 lib/mempool/rte_mempool.c         |  2 +
 lib/mempool/rte_mempool.h         |  8 ++++
 lib/mempool/version.map           |  3 ++
 lib/pipeline/rte_pipeline.c       |  3 ++
 lib/port/rte_port_ethdev.c        |  3 ++
 lib/port/rte_port_eventdev.c      |  4 ++
 lib/port/rte_port_fd.c            |  3 ++
 lib/port/rte_port_frag.c          |  3 ++
 lib/port/rte_port_kni.c           |  3 ++
 lib/port/rte_port_ras.c           |  3 ++
 lib/port/rte_port_ring.c          |  3 ++
 lib/port/rte_port_sched.c         |  3 ++
 lib/port/rte_port_source_sink.c   |  3 ++
 lib/port/rte_port_sym_crypto.c    |  3 ++
 lib/power/guest_channel.c         |  3 +-
 lib/power/power_common.c          |  2 +
 lib/power/power_common.h          |  3 +-
 lib/power/power_kvm_vm.c          |  1 +
 lib/power/rte_power.c             |  1 +
 lib/rib/rib_log.h                 |  4 ++
 lib/rib/rte_rib.c                 |  3 ++
 lib/rib/rte_rib6.c                |  3 ++
 lib/ring/rte_ring.c               |  3 ++
 lib/sched/rte_pie.c               |  1 +
 lib/sched/rte_sched.c             |  5 +++
 lib/sched/rte_sched_log.h         |  4 ++
 lib/table/rte_table_acl.c         |  3 ++
 lib/table/rte_table_array.c       |  3 ++
 lib/table/rte_table_hash_cuckoo.c |  3 ++
 lib/table/rte_table_hash_ext.c    |  3 ++
 lib/table/rte_table_hash_key16.c  |  3 ++
 lib/table/rte_table_hash_key32.c  |  5 ++-
 lib/table/rte_table_hash_key8.c   |  5 ++-
 lib/table/rte_table_hash_lru.c    |  3 ++
 lib/table/rte_table_lpm.c         |  3 ++
 lib/table/rte_table_lpm_ipv6.c    |  3 ++
 lib/table/rte_table_stub.c        |  3 ++
 75 files changed, 409 insertions(+), 177 deletions(-)
 create mode 100644 lib/acl/acl_log.h
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/hash/rte_hash_crc.c
 create mode 100644 lib/hash/rte_thash_gfni.c
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/mbuf/mbuf_log.h
 create mode 100644 lib/rib/rib_log.h
 create mode 100644 lib/sched/rte_sched_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 01/22] gso: don't log message on non TCP/UDP
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiayu Hu, Mark Kavanagh

If a large packet is passed into GSO routines of unknown protocol
then library would log a message.
Better to tell the application instead of logging.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/gso/rte_gso.c | 5 ++---
 lib/gso/rte_gso.h | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c
index 4b59217c16ee..c8e67c2d4b48 100644
--- a/lib/gso/rte_gso.c
+++ b/lib/gso/rte_gso.c
@@ -80,9 +80,8 @@ rte_gso_segment(struct rte_mbuf *pkt,
 		ret = gso_udp4_segment(pkt, gso_size, direct_pool,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
-		/* unsupported packet, skip */
-		RTE_LOG(DEBUG, GSO, "Unsupported packet type\n");
-		ret = 0;
+		ret = -ENOTSUP;	/* only UDP or TCP allowed */
+
 	}
 
 	if (ret < 0) {
diff --git a/lib/gso/rte_gso.h b/lib/gso/rte_gso.h
index 40922524df42..23d6980aff9f 100644
--- a/lib/gso/rte_gso.h
+++ b/lib/gso/rte_gso.h
@@ -114,6 +114,7 @@ struct rte_gso_ctx {
  *  - The number of GSO segments filled in pkts_out on success.
  *  - Return 0 if it does not need to be GSO'd.
  *  - Return -ENOMEM if run out of memory in MBUF pools.
+ *  - Return -ENOTSUP for protocols that can not be segmentd (not UDP or TCP)
  *  - Return -EINVAL for invalid parameters.
  */
 int rte_gso_segment(struct rte_mbuf *pkt,
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 02/22] eal: drop no longer used GSO logtype
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The message that used this was replaced in previous patch.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index bd7b188ceb4a..894701e8c19c 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -368,7 +368,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
-	{RTE_LOGTYPE_GSO,        "lib.gso"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
 	{RTE_LOGTYPE_USER3,      "user3"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 6d2b0856a565..11d517806054 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -46,7 +46,7 @@ extern "C" {
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
-#define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */
+				 /* was RTE_LOGTYPE_GSO */
 
 /* these log types can be used in an application */
 #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 03/22] log: drop unused RTE_LOGTYPE_TIMER
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The timer code does not use rte_log.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 894701e8c19c..5421da008f5b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
-	{RTE_LOGTYPE_TIMER,      "lib.timer"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 11d517806054..16d6ea31583d 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -30,7 +30,7 @@ extern "C" {
 #define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
-#define RTE_LOGTYPE_TIMER      4 /**< Log related to timers. */
+				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Byron Marohn, Yipeng Wang

Replace all uses of the global logtype with a dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/efd/rte_efd.c               | 4 ++++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5421da008f5b..25bb17938cc1 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
-	{RTE_LOGTYPE_EFD,        "lib.efd"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
 	{RTE_LOGTYPE_USER2,      "user2"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 16d6ea31583d..0b39795b4d06 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -44,7 +44,7 @@ extern "C" {
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 #define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
-#define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */
+				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
 				 /* was RTE_LOGTYPE_GSO */
 
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 686a13775742..9edb11799c89 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <sys/queue.h>
 
+#include <rte_cpuflags.h>
 #include <rte_string_fns.h>
 #include <rte_log.h>
 #include <rte_eal_memconfig.h>
@@ -28,6 +29,9 @@
 #include "rte_efd_arm64.h"
 #endif
 
+RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO);
+#define RTE_LOGTYPE_EFD	efd_logtype
+
 #define EFD_KEY(key_idx, table) (table->keys + ((key_idx) * table->key_len))
 /** Hash function used to determine chunk_id and bin_id for a group */
 #define EFD_HASH(key, table) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 05/22] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz

Introduce a new dynamic logtype for mbuf related messages.
Since this is used in multiple files put one macro in mbuf_log.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mbuf/mbuf_log.h             | 4 ++++
 lib/mbuf/rte_mbuf.c             | 4 ++++
 lib/mbuf/rte_mbuf_dyn.c         | 2 ++
 lib/mbuf/rte_mbuf_pool_ops.c    | 2 ++
 6 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbuf/mbuf_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 25bb17938cc1..d4389e436913 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
-	{RTE_LOGTYPE_MBUF,       "lib.mbuf"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 0b39795b4d06..941fbe51fd30 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
-#define RTE_LOGTYPE_MBUF      16 /**< Log related to mbuf. */
+				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
 #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */
diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h
new file mode 100644
index 000000000000..d759a9a25501
--- /dev/null
+++ b/lib/mbuf/mbuf_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index cfd8062f1e6a..4a379a5185d5 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -20,6 +20,10 @@
 #include <rte_errno.h>
 #include <rte_memcpy.h>
 
+#include "mbuf_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(mbuf_logtype, INFO);
+
 /*
  * pktmbuf pool constructor, given as a callback function to
  * rte_mempool_create(), or called directly if using
diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c
index 35839e938cc5..01654db03fc8 100644
--- a/lib/mbuf/rte_mbuf_dyn.c
+++ b/lib/mbuf/rte_mbuf_dyn.c
@@ -17,6 +17,8 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include "mbuf_log.h"
+
 #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn"
 
 struct mbuf_dynfield_elt {
diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c
index 4c91f4ce8569..5318430126cb 100644
--- a/lib/mbuf/rte_mbuf_pool_ops.c
+++ b/lib/mbuf/rte_mbuf_pool_ops.c
@@ -8,6 +8,8 @@
 #include <rte_errno.h>
 #include <rte_mbuf_pool_ops.h>
 
+#include "mbuf_log.h"
+
 int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 06/22] acl: replace LOGTYPE_ACL with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

The test code should not have been using fixed log type
so just change that to stderr.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c             | 3 ++-
 lib/acl/acl_bld.c               | 1 +
 lib/acl/acl_gen.c               | 1 +
 lib/acl/acl_log.h               | 4 ++++
 lib/acl/rte_acl.c               | 4 ++++
 lib/acl/tb_mem.c                | 3 ++-
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 8 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 lib/acl/acl_log.h

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 623f34682e69..75588978a720 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,
+				"%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803bd..f38e6478315f 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -5,6 +5,7 @@
 #include <rte_acl.h>
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index e759a2ca1598..54ec485d0c58 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..b55573cbe207
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index a61c3ba188da..a29decb1f6ca 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -6,8 +6,12 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 #include <rte_tailq.h>
+#include <rte_log.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4389e436913..9e853addb717 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,14 +349,12 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MALLOC,     "lib.malloc"},
 	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 941fbe51fd30..1408722b2c2f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -27,7 +27,7 @@ extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@ extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
-#define RTE_LOGTYPE_ACL        9 /**< Log related to ACL. */
+				 /* was RTE_LOGTYPE_ACL */
 #define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 07/22] examples/power: replace use of RTE_LOGTYPE_POWER
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 08/22] examples/l3fwd-power: " Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Don't use static logtype in sample application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Hunt <david.hunt@intel.com>
---
 examples/distributor/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d661873..542f76cf9664 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -679,7 +679,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			fprintf(stderr,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			/*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 08/22] examples/l3fwd-power: replace use of RTE_LOGTYPE_POWER
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Convert to using a dynamic logtype for the application.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Hunt <david.hunt@intel.com>
---
 examples/l3fwd-power/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index f57c54d2b57c..76b890b76c88 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -51,7 +51,8 @@
 #include "perf_core.h"
 #include "main.h"
 
-#define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER(l3fwd_power_logtype, l3fwd.power, INFO);
+#define RTE_LOGTYPE_L3FWD_POWER l3fwd_power_logtype
 
 #define MAX_PKT_BURST 32
 
@@ -2236,7 +2237,7 @@ init_power_library(void)
 		/* init power management library */
 		ret = rte_power_init(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library initialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2245,7 +2246,7 @@ init_power_library(void)
 		env = rte_power_get_env();
 		if (env != PM_ENV_ACPI_CPUFREQ &&
 				env != PM_ENV_PSTATE_CPUFREQ) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Only ACPI and PSTATE mode are supported\n");
 			return -1;
 		}
@@ -2263,7 +2264,7 @@ deinit_power_library(void)
 		/* deinit power management library */
 		ret = rte_power_exit(lcore_id);
 		if (ret) {
-			RTE_LOG(ERR, POWER,
+			RTE_LOG(ERR, L3FWD_POWER,
 				"Library deinitialization failed on core %u\n",
 				lcore_id);
 			return ret;
@@ -2332,7 +2333,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
 	ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index,
 					values, RTE_DIM(values));
 	if (ret < 0)
-		RTE_LOG(WARNING, POWER, "failed to update metrics\n");
+		RTE_LOG(WARNING, L3FWD_POWER, "failed to update metrics\n");
 }
 
 static int
@@ -2381,7 +2382,7 @@ launch_timer(unsigned int lcore_id)
 				rte_get_main_lcore());
 	}
 
-	RTE_LOG(INFO, POWER, "Bring up the Timer\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Bring up the Timer\n");
 
 	telemetry_setup_timer();
 
@@ -2397,7 +2398,7 @@ launch_timer(unsigned int lcore_id)
 		}
 	}
 
-	RTE_LOG(INFO, POWER, "Timer_subsystem is done\n");
+	RTE_LOG(INFO, L3FWD_POWER, "Timer_subsystem is done\n");
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 08/22] examples/l3fwd-power: " Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Hunt

Use dynamic log type for power library.
Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Hunt <david.hunt@intel.com>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/power/guest_channel.c       | 3 ++-
 lib/power/power_common.c        | 2 ++
 lib/power/power_common.h        | 3 ++-
 lib/power/power_kvm_vm.c        | 1 +
 lib/power/rte_power.c           | 1 +
 7 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 9e853addb717..39e1e6680dea 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
-	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 1408722b2c2f..7d4345acceca 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -36,7 +36,7 @@ extern "C" {
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
-#define RTE_LOGTYPE_POWER     10 /**< Log related to power. */
+				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
 #define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c
index 969a9e5aaa06..efc326d520ca 100644
--- a/lib/power/guest_channel.c
+++ b/lib/power/guest_channel.c
@@ -17,7 +17,8 @@
 
 #include "guest_channel.h"
 
-#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
+RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, guest, INFO);
+#define RTE_LOGTYPE_GUEST_CHANNEL guest_channel_logtype
 
 /* Timeout for incoming message in milliseconds. */
 #define TIMEOUT 10
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb863f..bf77eafa886b 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -12,6 +12,8 @@
 
 #include "power_common.h"
 
+RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO);
+
 #define POWER_SYSFILE_SCALING_DRIVER   \
 		"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
 #define POWER_SYSFILE_GOVERNOR  \
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c713927621..63a3a443509e 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -5,11 +5,12 @@
 #ifndef _POWER_COMMON_H_
 #define _POWER_COMMON_H_
 
-
 #include <rte_common.h>
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
+extern int power_logtype;
+#define RTE_LOGTYPE_POWER power_logtype
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) \
diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c
index 6a8109d44959..db031f43105a 100644
--- a/lib/power/power_kvm_vm.c
+++ b/lib/power/power_kvm_vm.c
@@ -8,6 +8,7 @@
 
 #include "rte_power_guest_channel.h"
 #include "guest_channel.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 63a43bd8f5ae..db0e7705a9ef 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -10,6 +10,7 @@
 #include "rte_power.h"
 #include "power_acpi_cpufreq.h"
 #include "power_cppc_cpufreq.h"
+#include "power_common.h"
 #include "power_kvm_vm.h"
 #include "power_pstate_cpufreq.h"
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 10/22] ring: replace RTE_LOGTYPE_RING with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

The logtype for ring only used in library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/ring/rte_ring.c             | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 39e1e6680dea..5f15e312f15b 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_RING,       "lib.ring"},
 	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7d4345acceca..31a2ee2f6b6f 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -28,7 +28,7 @@ extern "C" {
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
-#define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
+				 /* was RTE_LOGTYPE_RING */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..8c5f2575d6ef 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -26,6 +26,9 @@
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
 
+RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO);
+#define RTE_LOGTYPE_RING ring_logtype
+
 TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_ring_tailq = {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Olivier Matz, Andrew Rybchenko

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/mempool/rte_mempool.c       | 2 ++
 lib/mempool/rte_mempool.h       | 8 ++++++++
 lib/mempool/version.map         | 3 +++
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 5f15e312f15b..4025d2039d55 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -349,7 +349,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
-	{RTE_LOGTYPE_MEMPOOL,    "lib.mempool"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_LPM,        "lib.lpm"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 31a2ee2f6b6f..9f86bfdd0198 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -29,7 +29,7 @@ extern "C" {
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
 				 /* was RTE_LOGTYPE_MALLOC */
 				 /* was RTE_LOGTYPE_RING */
-#define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
+				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index cf5dea2304a7..b609a94fdf9d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,8 @@
 #include "mempool_trace.h"
 #include "rte_mempool.h"
 
+RTE_LOG_REGISTER_DEFAULT(rte_mempool_logtype, INFO);
+
 TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_mempool_tailq = {
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 9f530db24ba1..db01acc19b02 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -43,6 +43,7 @@
 #include <rte_spinlock.h>
 #include <rte_debug.h>
 #include <rte_lcore.h>
+#include <rte_log.h>
 #include <rte_branch_prediction.h>
 #include <rte_ring.h>
 #include <rte_memcpy.h>
@@ -175,6 +176,13 @@ struct rte_mempool_objtlr {
 
 #endif
 
+
+/**
+ * @internal Logtype used for mempool related messages.
+ */
+extern int rte_mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	rte_mempool_logtype
+
 /**
  * A list of memory where objects are stored
  */
diff --git a/lib/mempool/version.map b/lib/mempool/version.map
index dff2d1cb5555..eb2c12127560 100644
--- a/lib/mempool/version.map
+++ b/lib/mempool/version.map
@@ -57,4 +57,7 @@ INTERNAL {
 	# added in 21.11
 	rte_mempool_event_callback_register;
 	rte_mempool_event_callback_unregister;
+
+	# added in 23.07
+	rte_mempool_logtype;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (10 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Bruce Richardson

Split lpm and lpm6 into separate log types since they
are in different files and user may want to change log
levels for IPv4 vs IPv6.

For rib and fib libraries give them own types as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/fib/fib_log.h               | 4 ++++
 lib/fib/rte_fib.c               | 3 +++
 lib/fib/rte_fib6.c              | 2 ++
 lib/lpm/lpm_log.h               | 4 ++++
 lib/lpm/rte_lpm.c               | 3 +++
 lib/lpm/rte_lpm6.c              | 1 +
 lib/rib/rib_log.h               | 4 ++++
 lib/rib/rte_rib.c               | 3 +++
 lib/rib/rte_rib6.c              | 3 +++
 11 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 lib/fib/fib_log.h
 create mode 100644 lib/lpm/lpm_log.h
 create mode 100644 lib/rib/rib_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 4025d2039d55..6e2007e6ed4f 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_LPM,        "lib.lpm"},
 	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 9f86bfdd0198..115a48bf05f5 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -33,7 +33,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
-#define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
+				 /* was RTE_LOGTYPE_LPM */
 #define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
diff --git a/lib/fib/fib_log.h b/lib/fib/fib_log.h
new file mode 100644
index 000000000000..c731c820f621
--- /dev/null
+++ b/lib/fib/fib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..5b1815881415 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -16,6 +16,9 @@
 #include <rte_fib.h>
 
 #include "dir24_8.h"
+#include "fib_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO);
 
 TAILQ_HEAD(rte_fib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib_tailq = {
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..762d195fb798 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -9,6 +9,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
@@ -16,6 +17,7 @@
 #include <rte_fib6.h>
 
 #include "trie.h"
+#include "fib_log.h"
 
 TAILQ_HEAD(rte_fib6_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_fib6_tailq = {
diff --git a/lib/lpm/lpm_log.h b/lib/lpm/lpm_log.h
new file mode 100644
index 000000000000..a0621b70a5fe
--- /dev/null
+++ b/lib/lpm/lpm_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c
index cdcd1b7f9e47..0ca82147866a 100644
--- a/lib/lpm/rte_lpm.c
+++ b/lib/lpm/rte_lpm.c
@@ -18,6 +18,9 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm.h"
+#include "lpm_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO);
 
 TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
 
diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c
index 8d21aeddb83c..873cc8bc267d 100644
--- a/lib/lpm/rte_lpm6.c
+++ b/lib/lpm/rte_lpm6.c
@@ -20,6 +20,7 @@
 #include <rte_tailq.h>
 
 #include "rte_lpm6.h"
+#include "lpm_log.h"
 
 #define RTE_LPM6_TBL24_NUM_ENTRIES        (1 << 24)
 #define RTE_LPM6_TBL8_GROUP_NUM_ENTRIES         256
diff --git a/lib/rib/rib_log.h b/lib/rib/rib_log.h
new file mode 100644
index 000000000000..f3ee513ca854
--- /dev/null
+++ b/lib/rib/rib_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..5597c8b899c8 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -15,6 +15,9 @@
 
 #include <rte_rib.h>
 
+RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO);
+#define RTE_LOGTYPE_LPM rib_logtype
+
 TAILQ_HEAD(rte_rib_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_rib_tailq = {
 	.name = "RTE_RIB",
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..917bede27d24 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -8,6 +8,7 @@
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
+#include <rte_log.h>
 #include <rte_malloc.h>
 #include <rte_mempool.h>
 #include <rte_string_fns.h>
@@ -15,6 +16,8 @@
 
 #include <rte_rib6.h>
 
+#include "rib_log.h"
+
 #define RTE_RIB_VALID_NODE	1
 #define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (11 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Even though KNI will eventually disappear, fix the
logtype now.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/kni/rte_kni.c               | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 6e2007e6ed4f..70d5bb7b1951 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_KNI,        "lib.kni"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 115a48bf05f5..dc2454a0d9de 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -34,7 +34,7 @@ extern "C" {
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 				 /* was RTE_LOGTYPE_LPM */
-#define RTE_LOGTYPE_KNI        8 /**< Log related to KNI. */
+				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
 #define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 8ab6c4715314..9c37bcabcadd 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -23,6 +23,9 @@
 #include <rte_kni_common.h>
 #include "rte_kni_fifo.h"
 
+RTE_LOG_REGISTER_DEFAULT(kni_logtype, INFO);
+#define RTE_LOGTYPE_KNI kni_logtype
+
 #define MAX_MBUF_BURST_NUM            32
 
 /* Maximum number of ring entries */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 14/22] sched: replace RTE_LOGTYPE_SCHED with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (12 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Also can remove unused RTE_LOGTYPE_METER

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 2 --
 lib/eal/include/rte_log.h       | 4 ++--
 lib/sched/rte_pie.c             | 1 +
 lib/sched/rte_sched.c           | 5 +++++
 lib/sched/rte_sched_log.h       | 4 ++++
 5 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 lib/sched/rte_sched_log.h

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 70d5bb7b1951..d4b7088b5cbb 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,8 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_METER,      "lib.meter"},
-	{RTE_LOGTYPE_SCHED,      "lib.sched"},
 	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index dc2454a0d9de..f185fcbc5a94 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -37,8 +37,8 @@ extern "C" {
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
 				 /* was RTE_LOGTYPE_POWER */
-#define RTE_LOGTYPE_METER     11 /**< Log related to QoS meter. */
-#define RTE_LOGTYPE_SCHED     12 /**< Log related to QoS port scheduler. */
+				 /* was RTE_LOGTYPE_METER */
+				 /* was RTE_LOGTYPE_SCHED */
 #define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index 947e2a059f6f..cce0ce762da8 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index 19768d8c38b0..27e98e46df7a 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -16,9 +16,12 @@
 #include <rte_reciprocal.h>
 
 #include "rte_sched.h"
+#include "rte_sched_log.h"
 #include "rte_sched_common.h"
+
 #include "rte_approx.h"
 
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:2259) /* conversion may lose significant bits */
 #endif
@@ -3002,3 +3005,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	return count;
 }
+
+RTE_LOG_REGISTER_DEFAULT(sched_logtype, INFO);
diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h
new file mode 100644
index 000000000000..fde051f49d62
--- /dev/null
+++ b/lib/sched/rte_sched_log.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (13 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, akhil.goyal, Radu Nicolau, Akhil Goyal,
	Declan Doherty, Aviad Yehezkel, Boris Pismenny

Looks like some code got copy/paste in to the IPSEC gateway
example from another place. Shouldn't be using RTE_LOGTYPE_PORT
here.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")
Cc: akhil.goyal@nxp.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ipsec-secgw/sa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 7da9444a7b8a..67327fda8dbc 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1127,7 +1127,7 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	if (inbound) {
 		if ((dev_info.rx_offload_capa &
 				RTE_ETH_RX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware RX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
@@ -1135,13 +1135,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso)
 	} else { /* outbound */
 		if ((dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_SECURITY) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TX IPSec offload is not supported\n");
 			return -EINVAL;
 		}
 		if (tso && (dev_info.tx_offload_capa &
 				RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
-			RTE_LOG(WARNING, PORT,
+			RTE_LOG(WARNING, IPSEC,
 				"hardware TCP TSO offload is not supported\n");
 			return -EINVAL;
 		}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (14 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Split up the single static RTE_LOGTYPE_PORT into separate
sub types for each component: port.ethdev, port.evendev, ...

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/port/rte_port_ethdev.c      | 3 +++
 lib/port/rte_port_eventdev.c    | 4 ++++
 lib/port/rte_port_fd.c          | 3 +++
 lib/port/rte_port_frag.c        | 3 +++
 lib/port/rte_port_kni.c         | 3 +++
 lib/port/rte_port_ras.c         | 3 +++
 lib/port/rte_port_ring.c        | 3 +++
 lib/port/rte_port_sched.c       | 3 +++
 lib/port/rte_port_source_sink.c | 3 +++
 lib/port/rte_port_sym_crypto.c  | 3 +++
 12 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d4b7088b5cbb..7f1d2c8a256d 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PORT,       "lib.port"},
 	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index f185fcbc5a94..b11aec69af78 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -39,7 +39,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_POWER */
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT      13 /**< Log related to port. */
+				 /* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c
index 0da7890261e9..6685d304a6e9 100644
--- a/lib/port/rte_port_ethdev.c
+++ b/lib/port/rte_port_ethdev.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ethdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, ethdev, INFO);
+#define RTE_LOGTYPE_PORT port_ethdev_logtype
+
 /*
  * Port ETHDEV Reader
  */
diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c
index fd7dac9a5661..04447bd7f7bc 100644
--- a/lib/port/rte_port_eventdev.c
+++ b/lib/port/rte_port_eventdev.c
@@ -5,11 +5,15 @@
 #include <string.h>
 #include <stdint.h>
 
+#include <rte_log.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 
 #include "rte_port_eventdev.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, eventdev, INFO);
+#define RTE_LOGTYPE_PORT port_eventdev_logtype
+
 /*
  * Port EVENTDEV Reader
  */
diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index 932ecd324e05..b2412e7706ee 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_fd.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, fd, INFO);
+#define RTE_LOGTYPE_PORT port_fd_logtype
+
 /*
  * Port FD Reader
  */
diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c
index e1f1892176c4..9adcbba47da1 100644
--- a/lib/port/rte_port_frag.c
+++ b/lib/port/rte_port_frag.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_frag.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, frag, INFO);
+#define RTE_LOGTYPE_PORT port_frag_logtype
+
 /* Max number of fragments per packet allowed */
 #define	RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
 
diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c
index 1c7a6cb200ea..d4ac08b4cff0 100644
--- a/lib/port/rte_port_kni.c
+++ b/lib/port/rte_port_kni.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_kni.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, kni, INFO);
+#define RTE_LOGTYPE_PORT port_kni_logtype
+
 /*
  * Port KNI Reader
  */
diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c
index e5de57da42ea..5a610b1ba5b5 100644
--- a/lib/port/rte_port_ras.c
+++ b/lib/port/rte_port_ras.c
@@ -9,6 +9,9 @@
 
 #include "rte_port_ras.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, ras, INFO);
+#define RTE_LOGTYPE_PORT port_ras_logtype
+
 #ifndef RTE_PORT_RAS_N_BUCKETS
 #define RTE_PORT_RAS_N_BUCKETS                                 4094
 #endif
diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c
index 52b2d8e557f0..32a90e836579 100644
--- a/lib/port/rte_port_ring.c
+++ b/lib/port/rte_port_ring.c
@@ -10,6 +10,9 @@
 
 #include "rte_port_ring.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, ring, INFO);
+#define RTE_LOGTYPE_PORT port_ring_logtype
+
 /*
  * Port RING Reader
  */
diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c
index 8a7d815ef323..6e0a8aba5419 100644
--- a/lib/port/rte_port_sched.c
+++ b/lib/port/rte_port_sched.c
@@ -7,6 +7,9 @@
 
 #include "rte_port_sched.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, sched, INFO);
+#define RTE_LOGTYPE_PORT port_sched_logtype
+
 /*
  * Reader
  */
diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c
index 7d73adc1e79e..e9cdadbceb8f 100644
--- a/lib/port/rte_port_source_sink.c
+++ b/lib/port/rte_port_source_sink.c
@@ -15,6 +15,9 @@
 
 #include "rte_port_source_sink.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_source_logtype, source, INFO);
+#define RTE_LOGTYPE_PORT port_source_logtype
+
 /*
  * Port SOURCE
  */
diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c
index 295984d025cb..77a2f04d65f6 100644
--- a/lib/port/rte_port_sym_crypto.c
+++ b/lib/port/rte_port_sym_crypto.c
@@ -8,6 +8,9 @@
 
 #include "rte_port_sym_crypto.h"
 
+RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, crypto, INFO);
+#define RTE_LOGTYPE_PORT port_crypto_logtype
+
 /*
  * Port Crypto Reader
  */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (15 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use logtype suffixes for various components of this library.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c   | 1 -
 lib/eal/include/rte_log.h         | 2 +-
 lib/table/rte_table_acl.c         | 3 +++
 lib/table/rte_table_array.c       | 3 +++
 lib/table/rte_table_hash_cuckoo.c | 3 +++
 lib/table/rte_table_hash_ext.c    | 3 +++
 lib/table/rte_table_hash_key16.c  | 3 +++
 lib/table/rte_table_hash_key32.c  | 5 ++++-
 lib/table/rte_table_hash_key8.c   | 5 ++++-
 lib/table/rte_table_hash_lru.c    | 3 +++
 lib/table/rte_table_lpm.c         | 3 +++
 lib/table/rte_table_lpm_ipv6.c    | 3 +++
 lib/table/rte_table_stub.c        | 3 +++
 13 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7f1d2c8a256d..d640ed3c88b9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_TABLE,      "lib.table"},
 	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index b11aec69af78..934bddff9dfa 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_METER */
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE     14 /**< Log related to table. */
+				 /* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c
index 53fd5c66adb5..f44a25a89405 100644
--- a/lib/table/rte_table_acl.c
+++ b/lib/table/rte_table_acl.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_acl.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_acl_logtype, acl, INFO);
+#define RTE_LOGTYPE_TABLE table_acl_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c
index 54a0c42f7dd2..a7849beaecd6 100644
--- a/lib/table/rte_table_array.c
+++ b/lib/table/rte_table_array.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_array.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_array_logtype, array, INFO);
+#define RTE_LOGTYPE_TABLE table_array_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c
index c77eccf52722..12db0b84142f 100644
--- a/lib/table/rte_table_hash_cuckoo.c
+++ b/lib/table/rte_table_hash_cuckoo.c
@@ -10,6 +10,9 @@
 
 #include "rte_table_hash_cuckoo.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_logtype, hash, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c
index 70ea84fa2e51..147ecdf082cb 100644
--- a/lib/table/rte_table_hash_ext.c
+++ b/lib/table/rte_table_hash_ext.c
@@ -11,6 +11,9 @@
 
 #include "rte_table_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_ext_logtype, hash.ext, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_ext_logtype
+
 #define KEYS_PER_BUCKET	4
 
 struct bucket {
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 04d7fd64bd97..09fef5f14ce7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -11,6 +11,9 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_hash16_logtype, hash16, INFO);
+#define RTE_LOGTYPE_TABLE table_hash16_logtype
+
 #define KEY_SIZE						16
 
 #define KEYS_PER_BUCKET					4
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 88d8f69c72ed..1abc459eee87 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						32
+RTE_LOG_REGISTER_SUFFIX(table_hash32_logtype, hash32, INFO);
+#define RTE_LOGTYPE_TABLE table_hash32_logtype
+
+#define KEY_SIZE					32
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 035d24276946..d4ccccbcdf9e 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -11,7 +11,10 @@
 #include "rte_table_hash.h"
 #include "rte_lru.h"
 
-#define KEY_SIZE						8
+RTE_LOG_REGISTER_SUFFIX(table_hash8_logtype, hash8, INFO);
+#define RTE_LOGTYPE_TABLE table_hash8_logtype
+
+#define KEY_SIZE					8
 
 #define KEYS_PER_BUCKET					4
 
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index c31acc11cf23..d0d2c8ba44df 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -14,6 +14,9 @@
 
 #define KEYS_PER_BUCKET	4
 
+RTE_LOG_REGISTER_SUFFIX(table_hash_lru_logtype, hash_lru, INFO);
+#define RTE_LOGTYPE_TABLE table_hash_lru_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \
diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c
index 9de9e8a20d77..4a5c4a343c77 100644
--- a/lib/table/rte_table_lpm.c
+++ b/lib/table/rte_table_lpm.c
@@ -13,6 +13,9 @@
 
 #include "rte_table_lpm.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm_logtype, lpm, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm_logtype
+
 #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        65536
 #endif
diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c
index 8fde2c012f7c..236eac4238d9 100644
--- a/lib/table/rte_table_lpm_ipv6.c
+++ b/lib/table/rte_table_lpm_ipv6.c
@@ -12,6 +12,9 @@
 
 #include "rte_table_lpm_ipv6.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_lpm6_logtype, lpm6, INFO);
+#define RTE_LOGTYPE_TABLE table_lpm6_logtype
+
 #define RTE_TABLE_LPM_MAX_NEXT_HOPS                        256
 
 #ifdef RTE_TABLE_STATS_COLLECT
diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c
index 23d0de5c79b0..e74044032f7d 100644
--- a/lib/table/rte_table_stub.c
+++ b/lib/table/rte_table_stub.c
@@ -8,6 +8,9 @@
 
 #include "rte_table_stub.h"
 
+RTE_LOG_REGISTER_SUFFIX(table_stub_logtype, stub, INFO);
+#define RTE_LOGTYPE_TABLE table_stub_logtype
+
 #ifdef RTE_TABLE_STATS_COLLECT
 
 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (16 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Instead of using static type PIPELINE for logging in test application
use stderr instead.  If not testing RTE_LOG() better to not use
it since log also goes to syslog.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index e66f06b84d0a..dff9bddfb948 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -165,7 +165,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -178,7 +178,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -190,7 +190,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -202,7 +202,7 @@ parse_cb_ipv4_rule(char *str, struct rte_table_acl_rule_add_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -254,7 +254,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRC_FIELD_IPV4].value.u32,
 		&v->field_value[SRC_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read src address/mask: %s\n",
+		fprintf(stderr, "failed to read src address/mask: %s\n",
 			in[CB_FLD_SRC_ADDR]);
 		return rc;
 	}
@@ -267,7 +267,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DST_FIELD_IPV4].value.u32,
 		&v->field_value[DST_FIELD_IPV4].mask_range.u32);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest address/mask: %s\n",
+		fprintf(stderr, "failed to read dest address/mask: %s\n",
 			in[CB_FLD_DST_ADDR]);
 		return rc;
 	}
@@ -279,7 +279,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[SRCP_FIELD_IPV4].value.u16,
 		&v->field_value[SRCP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read source port range: %s\n",
+		fprintf(stderr, "failed to read source port range: %s\n",
 			in[CB_FLD_SRC_PORT_RANGE]);
 		return rc;
 	}
@@ -291,7 +291,7 @@ parse_cb_ipv4_rule_del(char *str, struct rte_table_acl_rule_delete_params *v)
 		&v->field_value[DSTP_FIELD_IPV4].value.u16,
 		&v->field_value[DSTP_FIELD_IPV4].mask_range.u16);
 	if (rc != 0) {
-		RTE_LOG(ERR, PIPELINE, "failed to read dest port range: %s\n",
+		fprintf(stderr, "failed to read dest port range: %s\n",
 			in[CB_FLD_DST_PORT_RANGE]);
 		return rc;
 	}
@@ -346,7 +346,7 @@ setup_acl_pipeline(void)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -410,7 +410,7 @@ setup_acl_pipeline(void)
 		table_params.f_action_miss = NULL;
 		table_params.action_data_size = 0;
 
-		RTE_LOG(INFO, PIPELINE, "miss_action=%x\n",
+		printf("miss_action=%x\n",
 			table_entry_miss_action);
 
 		printf("RTE_ACL_RULE_SZ(%zu) = %zu\n", DIM(ipv4_defs),
@@ -471,9 +471,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -513,9 +512,8 @@ setup_acl_pipeline(void)
 
 			ret = parse_cb_ipv4_rule_del(line, &keys[n]);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -549,9 +547,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE,
-					"line %u: parse_cb_ipv4vlan_rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse_cb_ipv4vlan_rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -575,8 +572,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule "
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -602,8 +599,8 @@ setup_acl_pipeline(void)
 
 			ret = parser(line, &rule_params);
 			if (ret != 0) {
-				RTE_LOG(ERR, PIPELINE, "line %u: parse rule"
-					" failed, error code: %d (%s)\n",
+				fprintf(stderr,
+					"line %u: parse rule failed, error code: %d (%s)\n",
 					n, ret, strerror(-ret));
 				return ret;
 			}
@@ -667,7 +664,7 @@ test_pipeline_single_filter(int expected_count)
 
 			memcpy(rte_pktmbuf_mtod(mbuf, char *), &five_tuple,
 				sizeof(struct ipv4_5tuple));
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			printf("%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], mbuf);
 		}
@@ -702,9 +699,8 @@ test_pipeline_single_filter(int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets for ACL test, "
-			"expected %d, got %d\n",
+		fprintf(stderr,
+			"%s: Unexpected packets for ACL test, expected %d, got %d\n",
 			__func__, expected_count, tx_count);
 		goto fail;
 	}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 7adbbffbf55d..960f730cf20d 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -6,7 +6,6 @@
 
 #include <string.h>
 #include <rte_pipeline.h>
-#include <rte_log.h>
 #include <inttypes.h>
 #include <rte_hexdump.h>
 #include "test_table.h"
@@ -173,30 +172,31 @@ check_pipeline_invalid_params(void)
 
 	p = rte_pipeline_create(NULL);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: configured pipeline with null params\n",
 			__func__);
 		goto fail;
 	}
 	p = rte_pipeline_create(&pipeline_params_1);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with NULL "
-			"name\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with NULL name\n", __func__);
 		goto fail;
 	}
 
 	p = rte_pipeline_create(&pipeline_params_2);
 	if (p != NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with invalid "
-			"socket\n", __func__);
+		fprintf(stderr,
+			"%s: Configure pipeline with invalid socket\n", __func__);
 		goto fail;
 	}
 
 	if (rte_eal_has_hugepages()) {
 		p = rte_pipeline_create(&pipeline_params_3);
 		if (p != NULL) {
-			RTE_LOG(INFO, PIPELINE, "%s: Configure pipeline with "
-				"invalid socket\n", __func__);
+			fprintf(stderr,
+				"%s: Configure pipeline with invalid socket\n",
+				__func__);
 			goto fail;
 		}
 	}
@@ -224,20 +224,20 @@ setup_pipeline(int test_type)
 		.socket_id = 0,
 	};
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Setting up %s test\n",
+	fprintf(stderr, "%s: **** Setting up %s test\n",
 		__func__, pipeline_test_names[test_type]);
 
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
 
 	ret = rte_pipeline_free(p);
 	if (ret != 0) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to free pipeline\n",
+		fprintf(stderr, "%s: Failed to free pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -245,7 +245,7 @@ setup_pipeline(int test_type)
 	/* Pipeline configuration */
 	p = rte_pipeline_create(&pipeline_params);
 	if (p == NULL) {
-		RTE_LOG(INFO, PIPELINE, "%s: Failed to configure pipeline\n",
+		fprintf(stderr, "%s: Failed to configure pipeline\n",
 			__func__);
 		goto fail;
 	}
@@ -411,7 +411,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	int ret;
 	int tx_count;
 
-	RTE_LOG(INFO, PIPELINE, "%s: **** Running %s test\n",
+	fprintf(stderr, "%s: **** Running %s test\n",
 		__func__, pipeline_test_names[test_type]);
 	/* Run pipeline once */
 	for (i = 0; i < N_PORTS; i++)
@@ -420,7 +420,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 
 	ret = rte_pipeline_flush(NULL);
 	if (ret != -EINVAL) {
-		RTE_LOG(INFO, PIPELINE,
+		fprintf(stderr,
 			"%s: No pipeline flush error NULL pipeline (%d)\n",
 			__func__, ret);
 		goto fail;
@@ -445,7 +445,7 @@ test_pipeline_single_filter(int test_type, int expected_count)
 			k32 = (uint32_t *) key;
 			k32[0] = 0xadadadad >> (j % 2);
 
-			RTE_LOG(INFO, PIPELINE, "%s: Enqueue onto ring %d\n",
+			fprintf(stderr, "%s: Enqueue onto ring %d\n",
 				__func__, i);
 			rte_ring_enqueue(rings_rx[i], m);
 		}
@@ -487,9 +487,9 @@ test_pipeline_single_filter(int test_type, int expected_count)
 	}
 
 	if (tx_count != expected_count) {
-		RTE_LOG(INFO, PIPELINE,
-			"%s: Unexpected packets out for %s test, expected %d, "
-			"got %d\n", __func__, pipeline_test_names[test_type],
+		fprintf(stderr,
+			"%s: Unexpected packets out for %s test, expected %d, got %d\n",
+			__func__, pipeline_test_names[test_type],
 			expected_count, tx_count);
 		goto fail;
 	}
@@ -564,8 +564,8 @@ test_table_pipeline(void)
 	connect_miss_action_to_table = 0;
 
 	if (check_pipeline_invalid_params()) {
-		RTE_LOG(INFO, PIPELINE, "%s: Check pipeline invalid params "
-			"failed.\n", __func__);
+		fprintf(stderr, "%s: Check pipeline invalid params failed.\n",
+			__func__);
 		return -1;
 	}
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (17 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use a dynamically allocated logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/pipeline/rte_pipeline.c     | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index d640ed3c88b9..a3498d1a2faf 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
 	{RTE_LOGTYPE_HASH,       "lib.hash"},
-	{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 934bddff9dfa..7473fd53505a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_SCHED */
 				 /* was RTE_LOGTYPE_PORT */
 				 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+				 /* was RTE_LOGTYPE_PIPELINE */
 				 /* was RTE_LOGTYPE_MBUF */
 #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */
 				 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index ff86c7cf96bf..30919cd9fe30 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define RTE_TABLE_INVALID                                 UINT32_MAX
 
 #ifdef RTE_PIPELINE_STATS_COLLECT
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 20/22] hash: move rte_thash_gfni stubs out of header file
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (18 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-22 21:55   ` [PATCH v11 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Having stubs in header file makes it harder to update
RTE_LOG(). Also modify to only print warning once.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build      |  8 ++++++-
 lib/hash/rte_thash_gfni.c | 47 +++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_thash_gfni.h | 30 ++++++++-----------------
 lib/hash/version.map      |  4 ++++
 4 files changed, 67 insertions(+), 22 deletions(-)
 create mode 100644 lib/hash/rte_thash_gfni.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index 2f757d45f9bc..e56ee8572564 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -17,7 +17,13 @@ indirect_headers += files(
         'rte_thash_x86_gfni.h',
 )
 
-sources = files('rte_cuckoo_hash.c', 'rte_fbk_hash.c', 'rte_thash.c')
+sources = files(
+    'rte_cuckoo_hash.c',
+    'rte_fbk_hash.c',
+    'rte_thash.c',
+    'rte_thash_gfni.c'
+)
+
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
new file mode 100644
index 000000000000..eb334185725c
--- /dev/null
+++ b/lib/hash/rte_thash_gfni.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <stdbool.h>
+
+#include <rte_compat.h>
+#include <rte_log.h>
+#include <rte_thash_gfni.h>
+
+#ifndef RTE_THASH_GFNI_DEFINED
+
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+	       const uint8_t *key __rte_unused, int len __rte_unused)
+{
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+		    int len __rte_unused, uint8_t *tuple[] __rte_unused,
+		    uint32_t val[], uint32_t num)
+{
+	unsigned int i;
+
+	static bool warned;
+
+	if (!warned) {
+		warned = true;
+		RTE_LOG(ERR, HASH,
+			"%s is undefined under given arch\n", __func__);
+	}
+
+	for (i = 0; i < num; i++)
+		val[i] = 0;
+}
+
+#endif
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index ef90faa302d1..4fc92984077e 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -9,13 +9,14 @@
 extern "C" {
 #endif
 
+#include <stdint.h>
+
 #include <rte_compat.h>
-#include <rte_log.h>
+#include <rte_common.h>
+#include <rte_config.h>
 
 #ifdef RTE_ARCH_X86
-
 #include <rte_thash_x86_gfni.h>
-
 #endif
 
 #ifndef RTE_THASH_GFNI_DEFINED
@@ -38,13 +39,8 @@ extern "C" {
  *  Calculated Toeplitz hash value.
  */
 __rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
-	const uint8_t *key __rte_unused, int len __rte_unused)
-{
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
 
 /**
  * Bulk implementation for Toeplitz hash.
@@ -67,17 +63,9 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
  *  Number of tuples to hash.
  */
 __rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
-	int len __rte_unused, uint8_t *tuple[] __rte_unused,
-	uint32_t val[], uint32_t num)
-{
-	unsigned int i;
-
-	RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
-	for (i = 0; i < num; i++)
-		val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		    uint32_t val[], uint32_t num);
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index bdcebd19c29b..f03b047b2eec 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -51,4 +51,8 @@ EXPERIMENTAL {
 	rte_thash_complete_matrix;
 	rte_thash_get_gfni_matrices;
 	rte_thash_gfni_supported;
+
+	# added in 22.07
+	rte_thash_gfni;
+	rte_thash_gfni_bulk;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 21/22] hash: move rte_hash_set_alg out header
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (19 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  2023-02-23  7:11     ` Ruifeng Wang
  2023-02-24  9:45     ` Ruifeng Wang
  2023-02-22 21:55   ` [PATCH v11 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
  21 siblings, 2 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, Ruifeng Wang

The code for setting algorithm for hash is not at all perf sensitive,
and doing it inline has a couple of problems. First, it means that if
multiple files include the header, then the initialization gets done
multiple times. But also, it makes it harder to fix usage of RTE_LOG().

Despite what the checking script say. This is not an ABI change, the
previous version inlined the same code; therefore both old and new code
will work the same.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/meson.build     |  1 +
 lib/hash/rte_crc_arm64.h |  8 ++---
 lib/hash/rte_crc_x86.h   | 10 +++---
 lib/hash/rte_hash_crc.c  | 68 ++++++++++++++++++++++++++++++++++++++++
 lib/hash/rte_hash_crc.h  | 48 ++--------------------------
 lib/hash/version.map     |  7 +++++
 6 files changed, 88 insertions(+), 54 deletions(-)
 create mode 100644 lib/hash/rte_hash_crc.c

diff --git a/lib/hash/meson.build b/lib/hash/meson.build
index e56ee8572564..c345c6f561fc 100644
--- a/lib/hash/meson.build
+++ b/lib/hash/meson.build
@@ -19,6 +19,7 @@ indirect_headers += files(
 
 sources = files(
     'rte_cuckoo_hash.c',
+    'rte_hash_crc.c',
     'rte_fbk_hash.c',
     'rte_thash.c',
     'rte_thash_gfni.c'
diff --git a/lib/hash/rte_crc_arm64.h b/lib/hash/rte_crc_arm64.h
index c9f52510871b..414fe065caa8 100644
--- a/lib/hash/rte_crc_arm64.h
+++ b/lib/hash/rte_crc_arm64.h
@@ -53,7 +53,7 @@ crc32c_arm64_u64(uint64_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u8(data, init_val);
 
 	return crc32c_1byte(data, init_val);
@@ -67,7 +67,7 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u16(data, init_val);
 
 	return crc32c_2bytes(data, init_val);
@@ -81,7 +81,7 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u32(data, init_val);
 
 	return crc32c_1word(data, init_val);
@@ -95,7 +95,7 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_ARM64))
+	if (likely(rte_hash_crc32_alg & CRC32_ARM64))
 		return crc32c_arm64_u64(data, init_val);
 
 	return crc32c_2words(data, init_val);
diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h
index 205bc182be77..3b865e251db2 100644
--- a/lib/hash/rte_crc_x86.h
+++ b/lib/hash/rte_crc_x86.h
@@ -67,7 +67,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 static inline uint32_t
 rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u8(data, init_val);
 
 	return crc32c_1byte(data, init_val);
@@ -81,7 +81,7 @@ rte_hash_crc_1byte(uint8_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u16(data, init_val);
 
 	return crc32c_2bytes(data, init_val);
@@ -95,7 +95,7 @@ rte_hash_crc_2byte(uint16_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u32(data, init_val);
 
 	return crc32c_1word(data, init_val);
@@ -110,11 +110,11 @@ static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
 #ifdef RTE_ARCH_X86_64
-	if (likely(crc32_alg == CRC32_SSE42_x64))
+	if (likely(rte_hash_crc32_alg == CRC32_SSE42_x64))
 		return crc32c_sse42_u64(data, init_val);
 #endif
 
-	if (likely(crc32_alg & CRC32_SSE42))
+	if (likely(rte_hash_crc32_alg & CRC32_SSE42))
 		return crc32c_sse42_u64_mimic(data, init_val);
 
 	return crc32c_2words(data, init_val);
diff --git a/lib/hash/rte_hash_crc.c b/lib/hash/rte_hash_crc.c
new file mode 100644
index 000000000000..1439d8a71f6a
--- /dev/null
+++ b/lib/hash/rte_hash_crc.c
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include <rte_cpuflags.h>
+#include <rte_log.h>
+
+#include "rte_hash_crc.h"
+
+RTE_LOG_REGISTER_SUFFIX(hash_crc_logtype, crc, INFO);
+#define RTE_LOGTYPE_HASH_CRC hash_crc_logtype
+
+uint8_t rte_hash_crc32_alg = CRC32_SW;
+
+/**
+ * Allow or disallow use of SSE4.2/ARMv8 intrinsics for CRC32 hash
+ * calculation.
+ *
+ * @param alg
+ *   An OR of following flags:
+ *   - (CRC32_SW) Don't use SSE4.2/ARMv8 intrinsics (default non-[x86/ARMv8])
+ *   - (CRC32_SSE42) Use SSE4.2 intrinsics if available
+ *   - (CRC32_SSE42_x64) Use 64-bit SSE4.2 intrinsic if available (default x86)
+ *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
+ *
+ */
+void
+rte_hash_crc_set_alg(uint8_t alg)
+{
+	rte_hash_crc32_alg = CRC32_SW;
+
+	if (alg == CRC32_SW)
+		return;
+
+#if defined RTE_ARCH_X86
+	if (!(alg & CRC32_SSE42_x64))
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
+	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
+		rte_hash_crc32_alg = CRC32_SSE42;
+	else
+		rte_hash_crc32_alg = CRC32_SSE42_x64;
+#endif
+
+#if defined RTE_ARCH_ARM64
+	if (!(alg & CRC32_ARM64))
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
+		rte_hash_crc32_alg = CRC32_ARM64;
+#endif
+
+	if (rte_hash_crc32_alg == CRC32_SW)
+		RTE_LOG(WARNING, HASH_CRC,
+			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
+}
+
+/* Setting the best available algorithm */
+RTE_INIT(rte_hash_crc_init_alg)
+{
+#if defined(RTE_ARCH_X86)
+	rte_hash_crc_set_alg(CRC32_SSE42_x64);
+#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
+	rte_hash_crc_set_alg(CRC32_ARM64);
+#else
+	rte_hash_crc_set_alg(CRC32_SW);
+#endif
+}
diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h
index 0249ad16c5b6..e8145ee44204 100644
--- a/lib/hash/rte_hash_crc.h
+++ b/lib/hash/rte_hash_crc.h
@@ -20,8 +20,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
 #include <rte_config.h>
-#include <rte_cpuflags.h>
-#include <rte_log.h>
 
 #include "rte_crc_sw.h"
 
@@ -31,7 +29,7 @@ extern "C" {
 #define CRC32_SSE42_x64     (CRC32_x64|CRC32_SSE42)
 #define CRC32_ARM64         (1U << 3)
 
-static uint8_t crc32_alg = CRC32_SW;
+extern uint8_t rte_hash_crc32_alg;
 
 #if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
 #include "rte_crc_arm64.h"
@@ -53,48 +51,8 @@ static uint8_t crc32_alg = CRC32_SW;
  *   - (CRC32_ARM64) Use ARMv8 CRC intrinsic if available (default ARMv8)
  *
  */
-static inline void
-rte_hash_crc_set_alg(uint8_t alg)
-{
-	crc32_alg = CRC32_SW;
-
-	if (alg == CRC32_SW)
-		return;
-
-#if defined RTE_ARCH_X86
-	if (!(alg & CRC32_SSE42_x64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
-	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
-		crc32_alg = CRC32_SSE42;
-	else
-		crc32_alg = CRC32_SSE42_x64;
-#endif
-
-#if defined RTE_ARCH_ARM64
-	if (!(alg & CRC32_ARM64))
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
-	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
-		crc32_alg = CRC32_ARM64;
-#endif
-
-	if (crc32_alg == CRC32_SW)
-		RTE_LOG(WARNING, HASH,
-			"Unsupported CRC32 algorithm requested using CRC32_SW\n");
-}
-
-/* Setting the best available algorithm */
-RTE_INIT(rte_hash_crc_init_alg)
-{
-#if defined(RTE_ARCH_X86)
-	rte_hash_crc_set_alg(CRC32_SSE42_x64);
-#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRC32)
-	rte_hash_crc_set_alg(CRC32_ARM64);
-#else
-	rte_hash_crc_set_alg(CRC32_SW);
-#endif
-}
+void
+rte_hash_crc_set_alg(uint8_t alg);
 
 #ifdef __DOXYGEN__
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index f03b047b2eec..8b22aad5626b 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_23 {
 	rte_hash_add_key_with_hash;
 	rte_hash_add_key_with_hash_data;
 	rte_hash_count;
+	rte_hash_crc_set_alg;
 	rte_hash_create;
 	rte_hash_del_key;
 	rte_hash_del_key_with_hash;
@@ -56,3 +57,9 @@ EXPERIMENTAL {
 	rte_thash_gfni;
 	rte_thash_gfni_bulk;
 };
+
+INTERNAL {
+	global:
+
+	rte_hash_crc32_alg;
+};
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* [PATCH v11 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type
  2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
                     ` (20 preceding siblings ...)
  2023-02-22 21:55   ` [PATCH v11 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-22 21:55   ` Stephen Hemminger
  21 siblings, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-02-22 21:55 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use dynamic type for hash and add subtypes for crc and gfni.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 lib/hash/rte_cuckoo_hash.c      | 5 +++++
 lib/hash/rte_fbk_hash.c         | 5 +++++
 lib/hash/rte_thash.c            | 3 +++
 lib/hash/rte_thash_gfni.c       | 3 +++
 6 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index a3498d1a2faf..704924e822d0 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -350,7 +350,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
 	{RTE_LOGTYPE_EAL,        "lib.eal"},
 	{RTE_LOGTYPE_PMD,        "pmd"},
-	{RTE_LOGTYPE_HASH,       "lib.hash"},
 	{RTE_LOGTYPE_CRYPTODEV,  "lib.cryptodev"},
 	{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
 	{RTE_LOGTYPE_USER1,      "user1"},
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 7473fd53505a..29db07881a5a 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 				 /* was RTE_LOGTYPE_MEMPOOL */
 				 /* was RTE_LOGTYPE_TIMER */
 #define RTE_LOGTYPE_PMD        5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
+				 /* was RTE_LOGTYPE_HASH */
 				 /* was RTE_LOGTYPE_LPM */
 				 /* was RTE_LOGTYPE_KNI */
 				 /* was RTE_LOGTYPE_ACL */
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a27..e2b07bfbad71 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -24,6 +24,11 @@
 #include <rte_tailq.h>
 
 #include "rte_hash.h"
+
+/* needs to be before rte_cuckoo_hash.h */
+RTE_LOG_REGISTER_DEFAULT(hash_logtype, INFO);
+#define RTE_LOGTYPE_HASH hash_logtype
+
 #include "rte_cuckoo_hash.h"
 
 /* Mask of all flags supported by this version */
diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c
index 538b23a4030a..b4c4c191abdc 100644
--- a/lib/hash/rte_fbk_hash.c
+++ b/lib/hash/rte_fbk_hash.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 
 #include <sys/queue.h>
+
+#include <rte_cpuflags.h>
 #include <rte_eal_memconfig.h>
 #include <rte_malloc.h>
 #include <rte_common.h>
@@ -18,6 +20,9 @@
 
 #include "rte_fbk_hash.h"
 
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, fbk, INFO);
+#define RTE_LOGTYPE_HASH fbk_hash_logtype
+
 TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
 
 static struct rte_tailq_elem rte_fbk_hash_tailq = {
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d07..c1fd2e34c9d4 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -13,6 +13,9 @@
 #include <rte_log.h>
 #include <rte_malloc.h>
 
+RTE_LOG_REGISTER_SUFFIX(thash_logtype, thash, INFO);
+#define RTE_LOGTYPE_HASH thash_logtype
+
 #define THASH_NAME_LEN		64
 #define TOEPLITZ_HASH_LEN	32
 
diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index eb334185725c..35206d575153 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -10,6 +10,9 @@
 
 #ifndef RTE_THASH_GFNI_DEFINED
 
+RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
+#define RTE_LOGTYPE_HASH hash_gfni_logtype
+
 uint32_t
 rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	       const uint8_t *key __rte_unused, int len __rte_unused)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
  2023-02-22 21:55   ` [PATCH v11 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
@ 2023-02-23  7:11     ` Ruifeng Wang
  2023-02-23  7:27       ` Ruifeng Wang
  2023-02-24  9:45     ` Ruifeng Wang
  1 sibling, 1 reply; 255+ messages in thread
From: Ruifeng Wang @ 2023-02-23  7:11 UTC (permalink / raw)
  To: Stephen Hemminger, dev
  Cc: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin, nd

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 23, 2023 5:56 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Yipeng Wang <yipeng1.wang@intel.com>;
> Sameh Gobriel <sameh.gobriel@intel.com>; Bruce Richardson <bruce.richardson@intel.com>;
> Vladimir Medvedkin <vladimir.medvedkin@intel.com>; Ruifeng Wang <Ruifeng.Wang@arm.com>
> Subject: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
> 
> The code for setting algorithm for hash is not at all perf sensitive, and doing it inline
> has a couple of problems. First, it means that if multiple files include the header, then
> the initialization gets done multiple times. But also, it makes it harder to fix usage of
> RTE_LOG().
> 
> Despite what the checking script say. This is not an ABI change, the previous version
> inlined the same code; therefore both old and new code will work the same.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/hash/meson.build     |  1 +
>  lib/hash/rte_crc_arm64.h |  8 ++---
>  lib/hash/rte_crc_x86.h   | 10 +++---
>  lib/hash/rte_hash_crc.c  | 68 ++++++++++++++++++++++++++++++++++++++++
>  lib/hash/rte_hash_crc.h  | 48 ++--------------------------
>  lib/hash/version.map     |  7 +++++
>  6 files changed, 88 insertions(+), 54 deletions(-)  create mode 100644
> lib/hash/rte_hash_crc.c
> 
> diff --git a/lib/hash/meson.build b/lib/hash/meson.build index e56ee8572564..c345c6f561fc
> 100644
> --- a/lib/hash/meson.build
> +++ b/lib/hash/meson.build
> @@ -19,6 +19,7 @@ indirect_headers += files(
> 
>  sources = files(
>      'rte_cuckoo_hash.c',
> +    'rte_hash_crc.c',

I suppose this list is alphabetically ordered.

>      'rte_fbk_hash.c',
>      'rte_thash.c',
>      'rte_thash_gfni.c'
<snip>
> diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h index
> 0249ad16c5b6..e8145ee44204 100644
> --- a/lib/hash/rte_hash_crc.h
> +++ b/lib/hash/rte_hash_crc.h
> @@ -20,8 +20,6 @@ extern "C" {
>  #include <rte_branch_prediction.h>
>  #include <rte_common.h>
>  #include <rte_config.h>
> -#include <rte_cpuflags.h>

A couple of files need update with this change.
rte_cpuflags.h should be included in rte_fbk_hash.c (for ARM) and rte_efd.c.

> -#include <rte_log.h>
> 
>  #include "rte_crc_sw.h"
> 
<snip>

^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
  2023-02-23  7:11     ` Ruifeng Wang
@ 2023-02-23  7:27       ` Ruifeng Wang
  0 siblings, 0 replies; 255+ messages in thread
From: Ruifeng Wang @ 2023-02-23  7:27 UTC (permalink / raw)
  To: Stephen Hemminger, dev
  Cc: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin, nd, nd

> -----Original Message-----
> From: Ruifeng Wang
> Sent: Thursday, February 23, 2023 3:11 PM
> To: Stephen Hemminger <stephen@networkplumber.org>; dev@dpdk.org
> Cc: Yipeng Wang <yipeng1.wang@intel.com>; Sameh Gobriel <sameh.gobriel@intel.com>; Bruce
> Richardson <bruce.richardson@intel.com>; Vladimir Medvedkin <vladimir.medvedkin@intel.com>;
> nd <nd@arm.com>
> Subject: RE: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
> 
> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Thursday, February 23, 2023 5:56 AM
> > To: dev@dpdk.org
> > Cc: Stephen Hemminger <stephen@networkplumber.org>; Yipeng Wang
> > <yipeng1.wang@intel.com>; Sameh Gobriel <sameh.gobriel@intel.com>;
> > Bruce Richardson <bruce.richardson@intel.com>; Vladimir Medvedkin
> > <vladimir.medvedkin@intel.com>; Ruifeng Wang <Ruifeng.Wang@arm.com>
> > Subject: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
> >
> > The code for setting algorithm for hash is not at all perf sensitive,
> > and doing it inline has a couple of problems. First, it means that if
> > multiple files include the header, then the initialization gets done
> > multiple times. But also, it makes it harder to fix usage of RTE_LOG().
> >
> > Despite what the checking script say. This is not an ABI change, the
> > previous version inlined the same code; therefore both old and new code will work the
> same.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  lib/hash/meson.build     |  1 +
> >  lib/hash/rte_crc_arm64.h |  8 ++---
> >  lib/hash/rte_crc_x86.h   | 10 +++---
> >  lib/hash/rte_hash_crc.c  | 68
> > ++++++++++++++++++++++++++++++++++++++++
> >  lib/hash/rte_hash_crc.h  | 48 ++--------------------------
> >  lib/hash/version.map     |  7 +++++
> >  6 files changed, 88 insertions(+), 54 deletions(-)  create mode
> > 100644 lib/hash/rte_hash_crc.c
> >
> > diff --git a/lib/hash/meson.build b/lib/hash/meson.build index
> > e56ee8572564..c345c6f561fc
> > 100644
> > --- a/lib/hash/meson.build
> > +++ b/lib/hash/meson.build
> > @@ -19,6 +19,7 @@ indirect_headers += files(
> >
> >  sources = files(
> >      'rte_cuckoo_hash.c',
> > +    'rte_hash_crc.c',
> 
> I suppose this list is alphabetically ordered.
> 
> >      'rte_fbk_hash.c',
> >      'rte_thash.c',
> >      'rte_thash_gfni.c'
> <snip>
> > diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h index
> > 0249ad16c5b6..e8145ee44204 100644
> > --- a/lib/hash/rte_hash_crc.h
> > +++ b/lib/hash/rte_hash_crc.h
> > @@ -20,8 +20,6 @@ extern "C" {
> >  #include <rte_branch_prediction.h>
> >  #include <rte_common.h>
> >  #include <rte_config.h>
> > -#include <rte_cpuflags.h>
> 
> A couple of files need update with this change.
> rte_cpuflags.h should be included in rte_fbk_hash.c (for ARM) and rte_efd.c.

OK, I see the changes already there in other patches in the same series.
Please ignore this comment.
Thanks.

> 
> > -#include <rte_log.h>
> >
> >  #include "rte_crc_sw.h"
> >
> <snip>

^ permalink raw reply	[flat|nested] 255+ messages in thread

* RE: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
  2023-02-22 21:55   ` [PATCH v11 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
  2023-02-23  7:11     ` Ruifeng Wang
@ 2023-02-24  9:45     ` Ruifeng Wang
  1 sibling, 0 replies; 255+ messages in thread
From: Ruifeng Wang @ 2023-02-24  9:45 UTC (permalink / raw)
  To: Stephen Hemminger, dev
  Cc: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin, nd

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 23, 2023 5:56 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Yipeng Wang <yipeng1.wang@intel.com>;
> Sameh Gobriel <sameh.gobriel@intel.com>; Bruce Richardson <bruce.richardson@intel.com>;
> Vladimir Medvedkin <vladimir.medvedkin@intel.com>; Ruifeng Wang <Ruifeng.Wang@arm.com>
> Subject: [PATCH v11 21/22] hash: move rte_hash_set_alg out header
> 
> The code for setting algorithm for hash is not at all perf sensitive, and doing it inline
> has a couple of problems. First, it means that if multiple files include the header, then
> the initialization gets done multiple times. But also, it makes it harder to fix usage of
> RTE_LOG().
> 
> Despite what the checking script say. This is not an ABI change, the previous version
> inlined the same code; therefore both old and new code will work the same.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/hash/meson.build     |  1 +
>  lib/hash/rte_crc_arm64.h |  8 ++---
>  lib/hash/rte_crc_x86.h   | 10 +++---
>  lib/hash/rte_hash_crc.c  | 68 ++++++++++++++++++++++++++++++++++++++++
>  lib/hash/rte_hash_crc.h  | 48 ++--------------------------
>  lib/hash/version.map     |  7 +++++
>  6 files changed, 88 insertions(+), 54 deletions(-)  create mode 100644
> lib/hash/rte_hash_crc.c
> 
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>


^ permalink raw reply	[flat|nested] 255+ messages in thread

* Re: [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type
  2023-02-21 14:55     ` David Marchand
  2023-02-21 17:07       ` Stephen Hemminger
@ 2023-03-29 23:31       ` Stephen Hemminger
  1 sibling, 0 replies; 255+ messages in thread
From: Stephen Hemminger @ 2023-03-29 23:31 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

On Tue, 21 Feb 2023 15:55:29 +0100
David Marchand <david.marchand@redhat.com> wrote:

> On Tue, Feb 21, 2023 at 12:36 AM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > Replace all uses of the global logtype with a dynamic log type.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  lib/eal/common/eal_common_log.c | 1 -
> >  lib/eal/include/rte_log.h       | 2 +-
> >  lib/efd/rte_efd.c               | 4 ++++
> >  3 files changed, 5 insertions(+), 2 deletions(-)  
> 
> [snip]
> 
> > diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
> > index 686a13775742..9edb11799c89 100644
> > --- a/lib/efd/rte_efd.c
> > +++ b/lib/efd/rte_efd.c
> > @@ -9,6 +9,7 @@
> >  #include <errno.h>
> >  #include <sys/queue.h>
> >
> > +#include <rte_cpuflags.h>
> >  #include <rte_string_fns.h>
> >  #include <rte_log.h>
> >  #include <rte_eal_memconfig.h>  
> 
> This is unrelated, isn't it?

Not really, previously the hash library would cause cpuflags to be included.
But that doesn't happen now that the hash function is not inline there.


^ permalink raw reply	[flat|nested] 255+ messages in thread

end of thread, other threads:[~2023-03-29 23:31 UTC | newest]

Thread overview: 255+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 20:41 [RFC 00/13] Replace static logtypes with static Stephen Hemminger
2023-02-07 20:41 ` [RFC 01/13] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
2023-02-07 20:41 ` [RFC 02/13] gso: remove logtype Stephen Hemminger
2023-02-07 20:41 ` [RFC 03/13] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-07 20:41 ` [RFC 04/13] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
2023-02-07 20:41 ` [RFC 05/13] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
2023-02-07 20:41 ` [RFC 06/13] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-07 20:41 ` [RFC 07/13] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
2023-02-07 20:41 ` [RFC 08/13] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-07 20:41 ` [RFC 09/13] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-07 20:41 ` [RFC 10/13] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-07 20:41 ` [RFC 11/13] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-07 20:41 ` [RFC 12/13] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
2023-02-07 20:41 ` [RFC 13/13] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-07 23:04 ` [RFC v2 00/17] static logtype removal Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 01/17] doc: document intention to deprecate RTE_LOGTYPE_USER* Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 02/17] ip_frag: use a dynamic logtype Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 03/17] reorder: " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 04/17] latencystats: use " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 05/17] gso: remove logtype Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 06/17] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 07/17] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 08/17] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 09/17] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 10/17] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 11/17] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 12/17] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 13/17] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 14/17] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 15/17] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 16/17] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-07 23:04   ` [RFC v2 17/17] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
2023-02-10  1:07 ` [PATCH v3 00/16] Replace use of static logtypes Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 01/16] gso: remove logtype Stephen Hemminger
2023-02-10  1:47     ` fengchengwen
2023-02-10  2:29     ` Hu, Jiayu
2023-02-10  2:46       ` Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 02/16] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type Stephen Hemminger
2023-02-10  2:03     ` fengchengwen
2023-02-10  2:47       ` Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 04/16] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 05/16] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 06/16] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 07/16] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 08/16] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 09/16] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 10/16] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 11/16] hash: replace RTE_LOGTYPE_HASH " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 12/16] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 13/16] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 14/16] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 15/16] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-10  1:07   ` [PATCH v3 16/16] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type Stephen Hemminger
2023-02-13 19:55 ` [PATCH v4 00/19] Replace use of static logtypes Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 01/19] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 02/19] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 03/19] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 04/19] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 05/19] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 06/19] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 07/19] power: replace RTE_LOGTYPE_POWER " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 08/19] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 09/19] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 10/19] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 11/19] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 12/19] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 13/19] port: replace RTE_LOGTYPE_PORT " Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 14/19] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 15/19] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 16/19] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 17/19] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 18/19] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-13 19:55   ` [PATCH v4 19/19] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-14  2:18 ` [PATCH v5 00/22] Replace us of static logtypes Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-14  2:18   ` [PATCH v5 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-14  2:19   ` [PATCH v5 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-14 22:47 ` [PATCH v6 00/22] Replace use of static logtypes in libraries Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-15  7:26     ` Hu, Jiayu
2023-02-15 17:12       ` Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-14 22:47   ` [PATCH v6 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-15 17:23 ` [PATCH v7 00/22] Replace use of static logtypes in libraries Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-16  1:23     ` Hu, Jiayu
2023-02-15 17:23   ` [PATCH v7 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-22 16:34     ` Hunt, David
2023-02-15 17:23   ` [PATCH v7 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-15 19:14     ` Medvedkin, Vladimir
2023-02-15 17:23   ` [PATCH v7 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-15 17:23   ` [PATCH v7 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-20 23:35 ` [PATCH v8 00/22] Convert static logtypes in libraries Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-21 14:55     ` David Marchand
2023-02-21 17:07       ` Stephen Hemminger
2023-03-29 23:31       ` Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-20 23:35   ` [PATCH v8 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-21 15:02     ` David Marchand
2023-02-21 15:10     ` David Marchand
2023-02-20 23:35   ` [PATCH v8 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-21 19:01 ` [PATCH v9 00/22] Convert static logtypes in libraries Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-22 16:34     ` Hunt, David
2023-02-21 19:01   ` [PATCH v9 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-22 16:33     ` Hunt, David
2023-02-21 19:01   ` [PATCH v9 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-22 16:32     ` Hunt, David
2023-02-21 19:01   ` [PATCH v9 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-21 19:01   ` [PATCH v9 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-22  7:37     ` [EXT] " Akhil Goyal
2023-02-21 19:02   ` [PATCH v9 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-21 19:02   ` [PATCH v9 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-22 16:07 ` [PATCH v10 00/22] Convert static log type values in libraries Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-22 16:36     ` Hunt, David
2023-02-22 16:07   ` [PATCH v10 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-22 16:36     ` Hunt, David
2023-02-22 16:07   ` [PATCH v10 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-22 16:35     ` Hunt, David
2023-02-22 16:07   ` [PATCH v10 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-22 16:07   ` [PATCH v10 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-22 16:08   ` [PATCH v10 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-22 16:08   ` [PATCH v10 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-22 16:08   ` [PATCH v10 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger
2023-02-22 21:55 ` [PATCH v11 00/22] Convert static log type values in libraries Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 01/22] gso: don't log message on non TCP/UDP Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 02/22] eal: drop no longer used GSO logtype Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 03/22] log: drop unused RTE_LOGTYPE_TIMER Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 04/22] efd: replace RTE_LOGTYPE_EFD with dynamic type Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 05/22] mbuf: replace RTE_LOGTYPE_MBUF " Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 06/22] acl: replace LOGTYPE_ACL " Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 07/22] examples/power: replace use of RTE_LOGTYPE_POWER Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 08/22] examples/l3fwd-power: " Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 09/22] power: replace RTE_LOGTYPE_POWER with dynamic type Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 10/22] ring: replace RTE_LOGTYPE_RING " Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 11/22] mempool: replace RTE_LOGTYPE_MEMPOOL " Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 12/22] lpm: replace RTE_LOGTYPE_LPM with dynamic types Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 13/22] kni: replace RTE_LOGTYPE_KNI with dynamic type Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 14/22] sched: replace RTE_LOGTYPE_SCHED " Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 15/22] examples/ipsecgw: replace RTE_LOGTYPE_PORT Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 16/22] port: replace RTE_LOGTYPE_PORT with dynamic type Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 17/22] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 18/22] app/test: remove use of RTE_LOGTYPE_PIPELINE Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 19/22] pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 20/22] hash: move rte_thash_gfni stubs out of header file Stephen Hemminger
2023-02-22 21:55   ` [PATCH v11 21/22] hash: move rte_hash_set_alg out header Stephen Hemminger
2023-02-23  7:11     ` Ruifeng Wang
2023-02-23  7:27       ` Ruifeng Wang
2023-02-24  9:45     ` Ruifeng Wang
2023-02-22 21:55   ` [PATCH v11 22/22] hash: convert RTE_LOGTYPE_HASH to dynamic type Stephen Hemminger

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).