Skip to contentSkip to conversation

Replace static logtypes with static

RFC Superseded Stephen Hemminger 8 participants 255 messages Feb 7, 2023 – Mar 29, 2023 Arm/Amlogic Meson SoC support Page 1 of 3

lore
Share & tools
lore
#0 lore raw

cover Replace static logtypes with static

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
Signature · 1 line
2.39.1
#1 lore raw

RFC 1/13 doc: document intention to deprecate RTE_LOGTYPE_USER*

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

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

---
 doc/guides/prog_guide/writing_efficient_code.rst | 3 +--
 doc/guides/rel_notes/deprecation.rst             | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)
doc/guides/prog_guide/writing_efficient_code.rst +1 -2
index e6c26efdd3a3..250e06bd734f 100644
@@ -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
doc/guides/rel_notes/deprecation.rst +4 -0
index ac9aa7630b61..935e68134d0e 100644
@@ -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.
Signature · 1 line
2.39.1
#2 lore raw

RFC 2/13 gso: remove logtype

In reply to Stephen Hemminger

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")
---
 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(-)
lib/eal/common/eal_common_log.c +1 -1
index bd7b188ceb4a..c369154cb1ea 100644
@@ -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"},
lib/eal/include/rte_log.h +0 -1
index 6d2b0856a565..97d6b26a9967 100644
@@ -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. */
lib/gso/rte_gso.c +1 -2
index 4b59217c16ee..19c351769fcc 100644
@@ -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) {
Signature · 1 line
2.39.1
#3 lore raw

RFC 3/13 log: drop unused RTE_LOGTYPE_TIMER

In reply to 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(-)
lib/eal/common/eal_common_log.c +0 -1
index c369154cb1ea..e7ccde1c9ccd 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 97d6b26a9967..361d1ad96299 100644
@@ -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. */
Signature · 1 line
2.39.1
#4 lore raw

RFC 4/13 efd: replace RTE_LOGTYPE_EFD with local type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index e7ccde1c9ccd..675f3d07bbe3 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 361d1ad96299..a90fa629168d 100644
@@ -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 */
lib/efd/rte_efd.c +51 -55

195 lines not on this page · raw message

Signature · 1 line
2.39.1
#5 lore raw

RFC 5/13 mbuf: replace RTE_LOGTYPE_MBUF with dynamic type

In reply to 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

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 675f3d07bbe3..128bfabd94e1 100644
@@ -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"},
 
lib/eal/include/rte_log.h +1 -1
index a90fa629168d..1f259b2abc5a 100644
@@ -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. */
lib/mbuf/mbuf_log.h new file +10 -0
new file mode 100644
index 000000000000..fe97f338c9b7
@@ -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)
lib/mbuf/rte_mbuf.c +12 -8
index cfd8062f1e6a..133fd3ba55be 100644
@@ -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);
lib/mbuf/rte_mbuf_dyn.c +8 -7
index 35839e938cc5..ef8d6069b37a 100644
@@ -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;
 	}
lib/mbuf/rte_mbuf_pool_ops.c +3 -2
index 4c91f4ce8569..8ec2710dc86d 100644
@@ -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;
 }
Signature · 1 line
2.39.1
#6 lore raw

RFC 6/13 acl: replace LOGTYPE_ACL with dynamic type

In reply to 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.

---
 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(-)
app/test/test_acl.c +2 -1
index 623f34682e69..75588978a720 100644
@@ -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;
 		}
lib/acl/acl.h +5 -0
index f5739a475cf0..1b64aa65edfe 100644
@@ -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)
lib/acl/acl_bld.c +17 -17
index 2816632803bd..0e29dc886c93 100644
@@ -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;
 		}
 	}
lib/acl/acl_gen.c +10 -9
index e759a2ca1598..8d2a5451b0d5 100644
@@ -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;
 	}
lib/acl/rte_acl.c +8 -5
index a61c3ba188da..9cc94b6f9633 100644
@@ -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);
lib/acl/tb_mem.c +7 -2
index f14d7b4fa26e..a62e664e1224 100644
@@ -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;
 	}
lib/eal/common/eal_common_log.c +0 -2
index 128bfabd94e1..871f2c38298c 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index 1f259b2abc5a..d707098b6359 100644
@@ -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. */
Signature · 1 line
2.39.1
#7 lore raw

RFC 7/13 power: replace RTE_LOGTYPE_POWER with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 871f2c38298c..7dbf1df3b979 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index d707098b6359..5b7850af4e2b 100644
@@ -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. */
lib/power/guest_channel.c +26 -22

134 lines not on this page · raw message

lib/power/power_acpi_cpufreq.c +64 -54

319 lines not on this page · raw message

lib/power/power_common.c +6 -5
index 1e09facb863f..3a374f6b8431 100644
@@ -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);
lib/power/power_common.h +6 -1
index c1c713927621..8e5309bbbaff 100644
@@ -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
lib/power/power_cppc_cpufreq.c +69 -60

375 lines not on this page · raw message

lib/power/power_kvm_vm.c +13 -11
index 6a8109d44959..74a1094ffaa0 100644
@@ -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;
 }
lib/power/power_pstate_cpufreq.c +89 -77

460 lines not on this page · raw message

lib/power/rte_power.c +15 -10
index 63a43bd8f5ae..23a97fa77f53 100644
@@ -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);
lib/power/rte_power_empty_poll.c +17 -19
index 4a4db512474e..da4b1ec3068a 100644
@@ -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);
 }
lib/power/rte_power_intel_uncore.c +39 -36

205 lines not on this page · raw message

lib/power/rte_power_pmd_mgmt.c +20 -17
index ca1840387c74..e691e754ccb0 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#8 lore raw

RFC 8/13 ring: replace RTE_LOGTYPE_RING with dynamic type

In reply to Stephen Hemminger

The logtype for ring only used in library.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 7dbf1df3b979..04c9d43351da 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 5b7850af4e2b..a99fe383c89b 100644
@@ -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. */
lib/ring/rte_ring.c +19 -12
index cddaf6b2876f..1b4633468a2a 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#9 lore raw

RFC 9/13 mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type

In reply to Stephen Hemminger

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 04c9d43351da..90d388192712 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index a99fe383c89b..f583352ec1ea 100644
@@ -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. */
lib/mempool/rte_mempool.c +18 -15
index 45b5df6199b0..911a2b4dd850 100644
@@ -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);
lib/mempool/rte_mempool_log.h new file +10 -0
new file mode 100644
index 000000000000..3d252f761408
@@ -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)
lib/mempool/rte_mempool_ops.c +6 -6
index 3b43edc548a0..e04e75b91ba6 100644
@@ -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;
 	}
Signature · 1 line
2.39.1
#10 lore raw

RFC 10/13 lpm: replace RTE_LOGTYPE_LPM with dynamic types

In reply to Stephen Hemminger

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.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 90d388192712..ff250b9a6d56 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index f583352ec1ea..55067efb0a84 100644
@@ -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 */
lib/fib/rte_fib.c +15 -8
index 8af4c4091908..7fda4263f841 100644
@@ -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;
 	}
lib/fib/rte_fib6.c +14 -7
index 4b8e22b142b9..d735fe81fc41 100644
@@ -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;
lib/hash/rte_hash_crc.c new file +63 -0

63 lines not on this page · raw message

lib/lpm/rte_lpm.c +12 -6
index cdcd1b7f9e47..ba3912a775a3 100644
@@ -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;
 		}
 	}
lib/lpm/rte_lpm6.c +17 -8
index 8d21aeddb83c..7701e8112ed2 100644
@@ -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;
lib/rib/rte_rib.c +9 -5
index b0794edf66f5..a81b4ed1cc04 100644
@@ -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;
 	}
lib/rib/rte_rib6.c +11 -5
index 19e4ff97c479..39eba4d7032b 100644
@@ -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;
 	}
Signature · 1 line
2.39.1
#11 lore raw

RFC 11/13 kni: replace RTE_LOGTYPE_KNI with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index ff250b9a6d56..b0c625a02cdf 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 55067efb0a84..69d3d07252ec 100644
@@ -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. */
lib/kni/rte_kni.c +34 -29

222 lines not on this page · raw message

Signature · 1 line
2.39.1
#12 lore raw

RFC 12/13 hash: replace RTE_LOGTYPE_HASH with dynamic type

In reply to Stephen Hemminger

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.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index b0c625a02cdf..97120543d808 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 69d3d07252ec..afbd67d55b45 100644
@@ -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 */
lib/hash/rte_cuckoo_hash.c +32 -28

185 lines not on this page · raw message

lib/hash/rte_fbk_hash.c +8 -2
index 538b23a4030a..7a0e4272ffa9 100644
@@ -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;
 	}
lib/hash/rte_hash_crc.c deleted +0 -63

63 lines not on this page · raw message

lib/hash/rte_hash_crc.h +3 -3
index 0249ad16c5b6..3bb38880c4ea 100644
@@ -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");
 }
 
lib/hash/rte_thash.c +42 -12

102 lines not on this page · raw message

lib/hash/rte_thash_gfni.h +6 -18
index ef90faa302d1..c3a5cf7e7b2d 100644
@@ -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 */
 
lib/hash/version.map +4 -0
index bdcebd19c29b..c30ac81307a7 100644
@@ -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;
 };
Signature · 1 line
2.39.1
#13 lore raw

RFC 13/13 sched: replace RTE_LOGTYPE_SCHED with dynamic type

In reply to Stephen Hemminger

Also can remove unused RTE_LOGTYPE_METER

---
 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
lib/eal/common/eal_common_log.c +0 -2
index 97120543d808..212ccda0a6e8 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index afbd67d55b45..a1549b372767 100644
@@ -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. */
lib/sched/rte_pie.c +7 -9
index 947e2a059f6f..28ed01e8f11d 100644
@@ -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;
 	}
 
lib/sched/rte_sched.c +120 -177

710 lines not on this page · raw message

lib/sched/rte_sched_log.h new file +11 -0
new file mode 100644
index 000000000000..cbf577faf2cb
@@ -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)
Signature · 1 line
2.39.1
#14 lore raw

v2 cover static logtype removal

In reply to 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
Signature · 1 line
2.39.1
#15 lore raw

RFC v2 1/17 doc: document intention to deprecate RTE_LOGTYPE_USER*

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

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

---
 doc/guides/prog_guide/writing_efficient_code.rst | 3 +--
 doc/guides/rel_notes/deprecation.rst             | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)
doc/guides/prog_guide/writing_efficient_code.rst +1 -2
index e6c26efdd3a3..250e06bd734f 100644
@@ -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
doc/guides/rel_notes/deprecation.rst +4 -0
index ac9aa7630b61..935e68134d0e 100644
@@ -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.
Signature · 1 line
2.39.1
#16 lore raw

RFC v2 2/17 ip_frag: use a dynamic logtype

In reply to Stephen Hemminger

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")
---
 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(-)
lib/ip_frag/ip_frag_common.h +12 -4
index 9c0dbdeb6eb9..134072f3e810 100644
@@ -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;
lib/ip_frag/ip_frag_internal.c +85 -89

232 lines not on this page · raw message

lib/ip_frag/rte_ip_frag_common.c +7 -6
index c1de2e81b6d0..b8ca9e019c54 100644
@@ -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);
lib/ip_frag/rte_ipv4_reassembly.c +6 -8
index 4a89a5f5365a..2cdbdc4ee87f 100644
@@ -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,
lib/ip_frag/rte_ipv6_reassembly.c +28 -31

83 lines not on this page · raw message

Signature · 1 line
2.39.1
#17 lore raw

RFC v2 3/17 reorder: use a dynamic logtype

In reply to Stephen Hemminger

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

Fixes b70b56032bff ("reorder: new library")
---
 lib/reorder/rte_reorder.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)
lib/reorder/rte_reorder.c +19 -16
index 385ee479da42..c9ae42e71783 100644
@@ -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 {
Signature · 1 line
2.39.1
#18 lore raw

RFC v2 4/17 latencystats: use dynamic logtype

In reply to Stephen Hemminger

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")
---
 lib/latencystats/rte_latencystats.c | 55 +++++++++++++++--------------
 1 file changed, 28 insertions(+), 27 deletions(-)
lib/latencystats/rte_latencystats.c +28 -27
index 8985a377db4e..3a4c47e2b34a 100644
@@ -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;
Signature · 1 line
2.39.1
#19 lore raw

RFC v2 5/17 gso: remove logtype

In reply to Stephen Hemminger

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")
---
 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(-)
lib/eal/common/eal_common_log.c +1 -1
index bd7b188ceb4a..c369154cb1ea 100644
@@ -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"},
lib/eal/include/rte_log.h +0 -1
index 6d2b0856a565..97d6b26a9967 100644
@@ -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. */
lib/gso/rte_gso.c +1 -2
index 4b59217c16ee..19c351769fcc 100644
@@ -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) {
Signature · 1 line
2.39.1
#20 lore raw

RFC v2 6/17 log: drop unused RTE_LOGTYPE_TIMER

In reply to 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(-)
lib/eal/common/eal_common_log.c +0 -1
index c369154cb1ea..e7ccde1c9ccd 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 97d6b26a9967..361d1ad96299 100644
@@ -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. */
Signature · 1 line
2.39.1
#21 lore raw

RFC v2 7/17 efd: replace RTE_LOGTYPE_EFD with local type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index e7ccde1c9ccd..675f3d07bbe3 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 361d1ad96299..a90fa629168d 100644
@@ -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 */
lib/efd/rte_efd.c +51 -55

195 lines not on this page · raw message

Signature · 1 line
2.39.1
#22 lore raw

RFC v2 8/17 mbuf: replace RTE_LOGTYPE_MBUF with dynamic type

In reply to 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

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 675f3d07bbe3..128bfabd94e1 100644
@@ -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"},
 
lib/eal/include/rte_log.h +1 -1
index a90fa629168d..1f259b2abc5a 100644
@@ -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. */
lib/mbuf/mbuf_log.h new file +10 -0
new file mode 100644
index 000000000000..fe97f338c9b7
@@ -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)
lib/mbuf/rte_mbuf.c +12 -8
index cfd8062f1e6a..133fd3ba55be 100644
@@ -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);
lib/mbuf/rte_mbuf_dyn.c +8 -7
index 35839e938cc5..ef8d6069b37a 100644
@@ -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;
 	}
lib/mbuf/rte_mbuf_pool_ops.c +3 -2
index 4c91f4ce8569..8ec2710dc86d 100644
@@ -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;
 }
Signature · 1 line
2.39.1
#23 lore raw

RFC v2 9/17 acl: replace LOGTYPE_ACL with dynamic type

In reply to 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.

---
 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
app/test/test_acl.c +2 -1
index 623f34682e69..75588978a720 100644
@@ -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;
 		}
lib/acl/acl_bld.c +18 -17
index 2816632803bd..143564151e29 100644
@@ -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;
 		}
 	}
lib/acl/acl_gen.c +11 -9
index e759a2ca1598..84369b103947 100644
@@ -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;
 	}
lib/acl/acl_log.h new file +13 -0
new file mode 100644
index 000000000000..4d5adf965cd2
@@ -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_ */
lib/acl/rte_acl.c +9 -5
index a61c3ba188da..5c8a9cd2f693 100644
@@ -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);
lib/acl/tb_mem.c +6 -2
index f14d7b4fa26e..74a12159b868 100644
@@ -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;
 	}
lib/eal/common/eal_common_log.c +0 -2
index 128bfabd94e1..871f2c38298c 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index 1f259b2abc5a..d707098b6359 100644
@@ -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. */
Signature · 1 line
2.39.1
#24 lore raw

RFC v2 10/17 power: replace RTE_LOGTYPE_POWER with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 871f2c38298c..7dbf1df3b979 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index d707098b6359..5b7850af4e2b 100644
@@ -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. */
lib/power/guest_channel.c +26 -22

134 lines not on this page · raw message

lib/power/power_acpi_cpufreq.c +64 -54

319 lines not on this page · raw message

lib/power/power_common.c +6 -5
index 1e09facb863f..3a374f6b8431 100644
@@ -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);
lib/power/power_common.h +6 -1
index c1c713927621..8e5309bbbaff 100644
@@ -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
lib/power/power_cppc_cpufreq.c +69 -60

375 lines not on this page · raw message

lib/power/power_kvm_vm.c +13 -11
index 6a8109d44959..74a1094ffaa0 100644
@@ -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;
 }
lib/power/power_pstate_cpufreq.c +89 -77

460 lines not on this page · raw message

lib/power/rte_power.c +15 -10
index 63a43bd8f5ae..23a97fa77f53 100644
@@ -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);
lib/power/rte_power_empty_poll.c +17 -19
index 4a4db512474e..da4b1ec3068a 100644
@@ -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);
 }
lib/power/rte_power_intel_uncore.c +39 -36

205 lines not on this page · raw message

lib/power/rte_power_pmd_mgmt.c +20 -17
index ca1840387c74..e691e754ccb0 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#25 lore raw

RFC v2 11/17 ring: replace RTE_LOGTYPE_RING with dynamic type

In reply to Stephen Hemminger

The logtype for ring only used in library.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 7dbf1df3b979..04c9d43351da 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 5b7850af4e2b..a99fe383c89b 100644
@@ -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. */
lib/ring/rte_ring.c +19 -12
index cddaf6b2876f..1b4633468a2a 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#26 lore raw

RFC v2 12/17 mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type

In reply to Stephen Hemminger

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 04c9d43351da..90d388192712 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index a99fe383c89b..f583352ec1ea 100644
@@ -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. */
lib/mempool/rte_mempool.c +18 -15
index 45b5df6199b0..911a2b4dd850 100644
@@ -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);
lib/mempool/rte_mempool_log.h new file +10 -0
new file mode 100644
index 000000000000..3d252f761408
@@ -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)
lib/mempool/rte_mempool_ops.c +6 -6
index 3b43edc548a0..e04e75b91ba6 100644
@@ -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;
 	}
Signature · 1 line
2.39.1
#27 lore raw

RFC v2 13/17 lpm: replace RTE_LOGTYPE_LPM with dynamic types

In reply to 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.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 90d388192712..ff250b9a6d56 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index f583352ec1ea..55067efb0a84 100644
@@ -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 */
lib/fib/rte_fib.c +15 -8
index 8af4c4091908..7fda4263f841 100644
@@ -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;
 	}
lib/fib/rte_fib6.c +14 -7
index 4b8e22b142b9..b6631fc19481 100644
@@ -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;
lib/lpm/rte_lpm.c +12 -6
index cdcd1b7f9e47..ba3912a775a3 100644
@@ -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;
 		}
 	}
lib/lpm/rte_lpm6.c +17 -8
index 8d21aeddb83c..7701e8112ed2 100644
@@ -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;
lib/rib/rte_rib.c +9 -5
index b0794edf66f5..a81b4ed1cc04 100644
@@ -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;
 	}
lib/rib/rte_rib6.c +11 -5
index 19e4ff97c479..39eba4d7032b 100644
@@ -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;
 	}
Signature · 1 line
2.39.1
#28 lore raw

RFC v2 14/17 kni: replace RTE_LOGTYPE_KNI with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index ff250b9a6d56..b0c625a02cdf 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 55067efb0a84..69d3d07252ec 100644
@@ -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. */
lib/kni/rte_kni.c +34 -29

222 lines not on this page · raw message

Signature · 1 line
2.39.1
#29 lore raw

RFC v2 15/17 hash: replace RTE_LOGTYPE_HASH with dynamic type

In reply to Stephen Hemminger

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.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index b0c625a02cdf..97120543d808 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 69d3d07252ec..afbd67d55b45 100644
@@ -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 */
lib/hash/rte_cuckoo_hash.c +32 -28

185 lines not on this page · raw message

lib/hash/rte_fbk_hash.c +8 -2
index 538b23a4030a..7a0e4272ffa9 100644
@@ -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;
 	}
lib/hash/rte_hash_crc.h +3 -3
index 0249ad16c5b6..3bb38880c4ea 100644
@@ -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");
 }
 
lib/hash/rte_thash.c +41 -12

101 lines not on this page · raw message

lib/hash/rte_thash_gfni.h +6 -18
index ef90faa302d1..c3a5cf7e7b2d 100644
@@ -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 */
 
lib/hash/version.map +4 -0
index bdcebd19c29b..c30ac81307a7 100644
@@ -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;
 };
Signature · 1 line
2.39.1
#30 lore raw

RFC v2 16/17 sched: replace RTE_LOGTYPE_SCHED with dynamic type

In reply to Stephen Hemminger

Also can remove unused RTE_LOGTYPE_METER

---
 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
lib/eal/common/eal_common_log.c +0 -2
index 97120543d808..212ccda0a6e8 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index afbd67d55b45..a1549b372767 100644
@@ -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. */
lib/sched/rte_pie.c +7 -9
index 947e2a059f6f..28ed01e8f11d 100644
@@ -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;
 	}
 
lib/sched/rte_sched.c +120 -177

710 lines not on this page · raw message

lib/sched/rte_sched_log.h new file +11 -0
new file mode 100644
index 000000000000..cbf577faf2cb
@@ -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)
Signature · 1 line
2.39.1
#31 lore raw

RFC v2 17/17 port: replace RTE_LOGTYPE_PORT with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 212ccda0a6e8..7002e267be37 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index a1549b372767..ff714a703be7 100644
@@ -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 */
lib/port/rte_port_ethdev.c +14 -9
index 0da7890261e9..614bdacb3cec 100644
@@ -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;
 	}
 
lib/port/rte_port_eventdev.c +14 -9
index fd7dac9a5661..4d0838a004c9 100644
@@ -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;
 	}
 
lib/port/rte_port_fd.c +16 -12
index 932ecd324e05..0c059a465b3a 100644
@@ -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;
 	}
 
lib/port/rte_port_frag.c +12 -9
index e1f1892176c4..243ebf225770 100644
@@ -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;
 	}
 
lib/port/rte_port_kni.c +13 -9
index 1c7a6cb200ea..ed2b5c3e4a31 100644
@@ -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;
 	}
 
lib/port/rte_port_ras.c +11 -6
index e5de57da42ea..3205b1abc360 100644
@@ -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;
 	}
 
lib/port/rte_port_ring.c +13 -9
index 52b2d8e557f0..e493f63ab25e 100644
@@ -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;
 	}
 
lib/port/rte_port_sched.c +10 -6
index 8a7d815ef323..dc590fd9c647 100644
@@ -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;
 	}
 
lib/port/rte_port_source_sink.c +47 -35

202 lines not on this page · raw message

lib/port/rte_port_sym_crypto.c +13 -9
index 295984d025cb..ee8573a3e1c4 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#32 lore raw

v3 cover Replace use of static logtypes

In reply to 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
Signature · 1 line
2.39.1
#33 lore raw

PATCH v3 1/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
- 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")
---
 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(-)
lib/eal/common/eal_common_log.c +1 -1
index bd7b188ceb4a..c369154cb1ea 100644
@@ -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"},
lib/eal/include/rte_log.h +0 -1
index 6d2b0856a565..97d6b26a9967 100644
@@ -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. */
lib/gso/rte_gso.c +1 -2
index 4b59217c16ee..19c351769fcc 100644
@@ -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) {
Signature · 1 line
2.39.1
#34 lore raw

Re: [PATCH v3 01/16] gso: remove logtype

Quoted 10 lines · Stephen Hemminger

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.

Quoted 50 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")
---
 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(-)
lib/eal/common/eal_common_log.c +1 -1
index bd7b188ceb4a..c369154cb1ea 100644
@@ -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"},
lib/eal/include/rte_log.h +0 -1
index 6d2b0856a565..97d6b26a9967 100644
@@ -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. */
lib/gso/rte_gso.c +1 -2
index 4b59217c16ee..19c351769fcc 100644
@@ -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) {
#35 lore raw

RE: [PATCH v3 01/16] gso: remove logtype

In reply to Stephen Hemminger

Hi Stephen,

Quoted 10 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, February 10, 2023 9:07 AM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Hu, Jiayu <[email protected]>; Konstantin Ananyev <[email protected]>; Mark Kavanagh <[email protected]>
Subject: [PATCH v3 01/16] gso: remove logtype

Quoted 4 lines

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.

Quoted 47 lines

- 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")
---
 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(-)
(quoted diff) +0 -0

b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..c369154cb1ea 100644

lib/eal/common/eal_common_log.c +1 -1
@@ -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"},
lib/eal/include/rte_log.h index renamed from lib/eal/include/rte_log.h +0 -0

6d2b0856a565..97d6b26a9967 100644

lib/eal/include/rte_log.h +0 -1
@@ -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. */
lib/gso/rte_gso.c index renamed from lib/gso/rte_gso.c +0 -0

4b59217c16ee..19c351769fcc 100644

lib/gso/rte_gso.c rte_gso_segment(struct rte_mbuf *pkt, · line 84

Quoted 6 lines
lib/gso/rte_gso.c +1 -2
@@ -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

Quoted 5 lines
lib/gso/rte_gso.c +0 -1
 	}
 
 	if (ret < 0) {
--

2.39.1

#36 lore raw

Re: [PATCH v3 01/16] gso: remove logtype

Quoted 72 lines · Jiayu

Hi Stephen,

Quoted 10 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, February 10, 2023 9:07 AM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Hu, Jiayu <[email protected]>; Konstantin Ananyev <[email protected]>; Mark Kavanagh <[email protected]>
Subject: [PATCH v3 01/16] gso: remove logtype

Quoted 4 lines

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.

Quoted 49 lines

- 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")
---
 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(-)
(quoted diff) +0 -0

b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..c369154cb1ea 100644

lib/eal/common/eal_common_log.c +1 -1
@@ -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"},
lib/eal/include/rte_log.h index renamed from lib/eal/include/rte_log.h +0 -0

6d2b0856a565..97d6b26a9967 100644

lib/eal/include/rte_log.h +0 -1
@@ -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. */
lib/gso/rte_gso.c index renamed from lib/gso/rte_gso.c +0 -0

4b59217c16ee..19c351769fcc 100644

lib/gso/rte_gso.c +0 -0
@@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt,
 				indirect_pool, pkts_out, nb_pkts_out);
 	} else {
Quoted 8 lines

lib/gso/rte_gso.c rte_gso_segment(struct rte_mbuf *pkt, · line 84

Quoted 4 lines
lib/gso/rte_gso.c +1 -2
 		/* 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.

#37 lore raw

PATCH v3 2/16 log: drop unused RTE_LOGTYPE_TIMER

In reply to 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(-)
lib/eal/common/eal_common_log.c +0 -1
index c369154cb1ea..e7ccde1c9ccd 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 97d6b26a9967..361d1ad96299 100644
@@ -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. */
Signature · 1 line
2.39.1
#38 lore raw

PATCH v3 3/16 efd: replace RTE_LOGTYPE_EFD with local type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index e7ccde1c9ccd..675f3d07bbe3 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 361d1ad96299..a90fa629168d 100644
@@ -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 */
lib/efd/rte_efd.c +51 -55

195 lines not on this page · raw message

Signature · 1 line
2.39.1
#39 lore raw

Re: [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type

Quoted 5 lines · Stephen Hemminger

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

---

...

Quoted 12 lines

};
EAL_REGISTER_TAILQ(rte_efd_tailq);

lib/efd/rte_efd.c +5 -0
+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] = {
 	{

lib/efd/rte_efd.c rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, · line 517

Quoted 6 lines
lib/efd/rte_efd.c +1 -2
@@ -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.

Quoted 3 lines
lib/efd/rte_efd.c +0 -0
 		return NULL;
 	}
 

...

#40 lore raw

Re: [PATCH v3 03/16] efd: replace RTE_LOGTYPE_EFD with local type

Quoted 33 lines · On Fri, 10 Feb 2023 10:03:47 +0800 fengchengwen <[email protected]> wrote:
Quoted 5 lines · Stephen Hemminger

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

---

...

Quoted 12 lines

};
EAL_REGISTER_TAILQ(rte_efd_tailq);

lib/efd/rte_efd.c +5 -0
+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] = {
 	{

lib/efd/rte_efd.c rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, · line 517

Quoted 6 lines
lib/efd/rte_efd.c +1 -2
@@ -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 ...

Quoted 6 lines

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.

#41 lore raw

PATCH v3 4/16 mbuf: replace RTE_LOGTYPE_MBUF with dynamic type

In reply to 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

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 675f3d07bbe3..128bfabd94e1 100644
@@ -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"},
 
lib/eal/include/rte_log.h +1 -1
index a90fa629168d..1f259b2abc5a 100644
@@ -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. */
lib/mbuf/mbuf_log.h new file +10 -0
new file mode 100644
index 000000000000..fe97f338c9b7
@@ -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)
lib/mbuf/rte_mbuf.c +12 -8
index cfd8062f1e6a..133fd3ba55be 100644
@@ -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);
lib/mbuf/rte_mbuf_dyn.c +8 -7
index 35839e938cc5..ef8d6069b37a 100644
@@ -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;
 	}
lib/mbuf/rte_mbuf_pool_ops.c +3 -2
index 4c91f4ce8569..8ec2710dc86d 100644
@@ -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;
 }
Signature · 1 line
2.39.1
#42 lore raw

PATCH v3 5/16 acl: replace LOGTYPE_ACL with dynamic type

In reply to 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.

---
 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
app/test/test_acl.c +2 -1
index 623f34682e69..75588978a720 100644
@@ -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;
 		}
lib/acl/acl_bld.c +18 -17
index 2816632803bd..143564151e29 100644
@@ -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;
 		}
 	}
lib/acl/acl_gen.c +11 -9
index e759a2ca1598..84369b103947 100644
@@ -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;
 	}
lib/acl/acl_log.h new file +13 -0
new file mode 100644
index 000000000000..4d5adf965cd2
@@ -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_ */
lib/acl/rte_acl.c +9 -5
index a61c3ba188da..5c8a9cd2f693 100644
@@ -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);
lib/acl/tb_mem.c +6 -2
index f14d7b4fa26e..74a12159b868 100644
@@ -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;
 	}
lib/eal/common/eal_common_log.c +0 -2
index 128bfabd94e1..871f2c38298c 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index 1f259b2abc5a..d707098b6359 100644
@@ -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. */
Signature · 1 line
2.39.1
#43 lore raw

PATCH v3 6/16 power: replace RTE_LOGTYPE_POWER with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 871f2c38298c..7dbf1df3b979 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index d707098b6359..5b7850af4e2b 100644
@@ -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. */
lib/power/guest_channel.c +26 -22

134 lines not on this page · raw message

lib/power/power_acpi_cpufreq.c +64 -54

319 lines not on this page · raw message

lib/power/power_common.c +6 -5
index 1e09facb863f..3a374f6b8431 100644
@@ -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);
lib/power/power_common.h +6 -1
index c1c713927621..8e5309bbbaff 100644
@@ -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
lib/power/power_cppc_cpufreq.c +69 -60

375 lines not on this page · raw message

lib/power/power_kvm_vm.c +13 -11
index 6a8109d44959..74a1094ffaa0 100644
@@ -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;
 }
lib/power/power_pstate_cpufreq.c +89 -77

460 lines not on this page · raw message

lib/power/rte_power.c +15 -10
index 63a43bd8f5ae..23a97fa77f53 100644
@@ -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);
lib/power/rte_power_empty_poll.c +17 -19
index 4a4db512474e..da4b1ec3068a 100644
@@ -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);
 }
lib/power/rte_power_intel_uncore.c +39 -36

205 lines not on this page · raw message

lib/power/rte_power_pmd_mgmt.c +20 -17
index ca1840387c74..e691e754ccb0 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#44 lore raw

PATCH v3 7/16 ring: replace RTE_LOGTYPE_RING with dynamic type

In reply to Stephen Hemminger

The logtype for ring only used in library.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 7dbf1df3b979..04c9d43351da 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 5b7850af4e2b..a99fe383c89b 100644
@@ -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. */
lib/ring/rte_ring.c +19 -12
index cddaf6b2876f..1b4633468a2a 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#45 lore raw

PATCH v3 8/16 mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type

In reply to Stephen Hemminger

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 04c9d43351da..90d388192712 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index a99fe383c89b..f583352ec1ea 100644
@@ -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. */
lib/mempool/rte_mempool.c +18 -15
index 45b5df6199b0..911a2b4dd850 100644
@@ -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);
lib/mempool/rte_mempool_log.h new file +10 -0
new file mode 100644
index 000000000000..3d252f761408
@@ -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)
lib/mempool/rte_mempool_ops.c +6 -6
index 3b43edc548a0..e04e75b91ba6 100644
@@ -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;
 	}
Signature · 1 line
2.39.1
#46 lore raw

PATCH v3 9/16 lpm: replace RTE_LOGTYPE_LPM with dynamic types

In reply to 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.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 90d388192712..ff250b9a6d56 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index f583352ec1ea..55067efb0a84 100644
@@ -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 */
lib/fib/fib_log.h new file +10 -0
new file mode 100644
index 000000000000..bf2fa88c7451
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Vladimir Medvedkin <[email protected]>
+ * 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)
lib/fib/rte_fib.c +12 -8
index 8af4c4091908..aa2ba735771a 100644
@@ -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;
 	}
lib/fib/rte_fib6.c +9 -7
index 4b8e22b142b9..4ce641f9dcd8 100644
@@ -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;
lib/lpm/lpm_log.h new file +9 -0
new file mode 100644
index 000000000000..b4101cfbe238
@@ -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)
lib/lpm/rte_lpm.c +9 -6
index cdcd1b7f9e47..363058e118c0 100644
@@ -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;
 		}
 	}
lib/lpm/rte_lpm6.c +12 -8
index 8d21aeddb83c..6c36a637322e 100644
@@ -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;
lib/rib/rib_log.h new file +9 -0
new file mode 100644
index 000000000000..520f4083c0a8
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Vladimir Medvedkin <[email protected]>
+ * 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)
lib/rib/rte_rib.c +7 -5
index b0794edf66f5..c667e8cfe964 100644
@@ -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;
 	}
lib/rib/rte_rib6.c +7 -5
index 19e4ff97c479..4e171d4208d9 100644
@@ -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;
 	}
Signature · 1 line
2.39.1
#47 lore raw

PATCH v3 10/16 kni: replace RTE_LOGTYPE_KNI with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index ff250b9a6d56..b0c625a02cdf 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 55067efb0a84..69d3d07252ec 100644
@@ -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. */
lib/kni/rte_kni.c +34 -29

222 lines not on this page · raw message

Signature · 1 line
2.39.1
#48 lore raw

PATCH v3 11/16 hash: replace RTE_LOGTYPE_HASH with dynamic type

In reply to Stephen Hemminger

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.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index b0c625a02cdf..97120543d808 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 69d3d07252ec..afbd67d55b45 100644
@@ -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 */
lib/hash/rte_cuckoo_hash.c +32 -28

185 lines not on this page · raw message

lib/hash/rte_fbk_hash.c +8 -2
index 538b23a4030a..37edb5e2c7fe 100644
@@ -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;
 	}
lib/hash/rte_hash_crc.h +3 -3
index 0249ad16c5b6..3bb38880c4ea 100644
@@ -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");
 }
 
lib/hash/rte_thash.c +41 -12

101 lines not on this page · raw message

lib/hash/rte_thash_gfni.h +6 -18
index ef90faa302d1..c3a5cf7e7b2d 100644
@@ -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 */
 
lib/hash/version.map +4 -0
index bdcebd19c29b..c30ac81307a7 100644
@@ -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;
 };
Signature · 1 line
2.39.1
#49 lore raw

PATCH v3 12/16 sched: replace RTE_LOGTYPE_SCHED with dynamic type

In reply to Stephen Hemminger

Also can remove unused RTE_LOGTYPE_METER

---
 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
lib/eal/common/eal_common_log.c +0 -2
index 97120543d808..212ccda0a6e8 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index afbd67d55b45..a1549b372767 100644
@@ -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. */
lib/sched/rte_pie.c +7 -9
index 947e2a059f6f..28ed01e8f11d 100644
@@ -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;
 	}
 
lib/sched/rte_sched.c +121 -178

712 lines not on this page · raw message

lib/sched/rte_sched_log.h new file +11 -0
new file mode 100644
index 000000000000..cbf577faf2cb
@@ -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)
Signature · 1 line
2.39.1
#50 lore raw

PATCH v3 13/16 port: replace RTE_LOGTYPE_PORT with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 212ccda0a6e8..7002e267be37 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index a1549b372767..ff714a703be7 100644
@@ -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 */
lib/port/rte_port_ethdev.c +14 -9
index 0da7890261e9..1ce0e7b3d396 100644
@@ -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;
 	}
 
lib/port/rte_port_eventdev.c +14 -9
index fd7dac9a5661..9331bd9a8e52 100644
@@ -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;
 	}
 
lib/port/rte_port_fd.c +16 -12
index 932ecd324e05..78a65d4ad582 100644
@@ -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;
 	}
 
lib/port/rte_port_frag.c +12 -9
index e1f1892176c4..1a6d88cceb84 100644
@@ -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;
 	}
 
lib/port/rte_port_kni.c +13 -9
index 1c7a6cb200ea..3f4d1dcb5882 100644
@@ -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;
 	}
 
lib/port/rte_port_ras.c +11 -8
index e5de57da42ea..6cc1c19fc971 100644
@@ -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;
 	}
 
lib/port/rte_port_ring.c +13 -9
index 52b2d8e557f0..bc9cb4f72b15 100644
@@ -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;
 	}
 
lib/port/rte_port_sched.c +10 -6
index 8a7d815ef323..8a421855f7e2 100644
@@ -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;
 	}
 
lib/port/rte_port_source_sink.c +47 -35

202 lines not on this page · raw message

lib/port/rte_port_sym_crypto.c +13 -9
index 295984d025cb..3a55a5fde6fb 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#51 lore raw

PATCH v3 14/16 table: convert RTE_LOGTYPE_TABLE to dynamic logtype

In reply to Stephen Hemminger

Use logtype suffixes for various components of this library.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 7002e267be37..a4e718e51d12 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index ff714a703be7..af87eb42ddb3 100644
@@ -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. */
lib/table/rte_table_acl.c +38 -52

237 lines not on this page · raw message

lib/table/rte_table_array.c +12 -11
index 54a0c42f7dd2..47b5a2b15b2b 100644
@@ -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;
 	}
 
lib/table/rte_table_hash_cuckoo.c +16 -14
index c77eccf52722..7b1f1575e564 100644
@@ -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;
 }
 
lib/table/rte_table_hash_ext.c +20 -14
index 70ea84fa2e51..ca16328c1612 100644
@@ -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;
lib/table/rte_table_hash_key16.c +30 -26

129 lines not on this page · raw message

lib/table/rte_table_hash_key32.c +32 -30

138 lines not on this page · raw message

lib/table/rte_table_hash_key8.c +31 -28

133 lines not on this page · raw message

lib/table/rte_table_hash_lru.c +19 -16
index c31acc11cf23..9bc64f74c922 100644
@@ -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;
lib/table/rte_table_lpm.c +26 -28

151 lines not on this page · raw message

lib/table/rte_table_lpm_ipv6.c +26 -30

153 lines not on this page · raw message

lib/table/rte_table_stub.c +6 -3
index 23d0de5c79b0..6ea978adfe80 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#52 lore raw

PATCH v3 15/16 app/test: remove use of RTE_LOGTYPE_PIPELINE

In reply to 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.

---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)
app/test/test_table_acl.c +23 -27
index e66f06b84d0a..dff9bddfb948 100644
@@ -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;
 	}
app/test/test_table_pipeline.c +20 -20
index 7adbbffbf55d..960f730cf20d 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#53 lore raw

PATCH v3 16/16 pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic log type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index a4e718e51d12..e4a4f7812bde 100644
@@ -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"},
 
lib/eal/include/rte_log.h +1 -1
index af87eb42ddb3..e2c11ad45c7f 100644
@@ -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 */
lib/pipeline/rte_pipeline.c +86 -156

632 lines not on this page · raw message

Signature · 1 line
2.39.1
#54 lore raw

v4 cover Replace use of static logtypes

In reply to 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
Signature · 1 line
2.39.1
#55 lore raw

PATCH v4 1/19 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")
---
 lib/gso/rte_gso.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/gso/rte_gso.c +2 -3
index 4b59217c16ee..c8e67c2d4b48 100644
@@ -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) {
Signature · 1 line
2.39.1
#56 lore raw

PATCH v4 2/19 eal: drop no longer used GSO logtype

In reply to Stephen Hemminger

The message that used this was replaced in previous patch.

---
 lib/eal/common/eal_common_log.c | 1 -
 lib/eal/include/rte_log.h       | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
lib/eal/common/eal_common_log.c +0 -1
index bd7b188ceb4a..894701e8c19c 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 6d2b0856a565..11d517806054 100644
@@ -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. */
Signature · 1 line
2.39.1
#57 lore raw

PATCH v4 3/19 log: drop unused RTE_LOGTYPE_TIMER

In reply to 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 894701e8c19c..5421da008f5b 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 11d517806054..16d6ea31583d 100644
@@ -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. */
Signature · 1 line
2.39.1
#58 lore raw

PATCH v4 4/19 efd: replace RTE_LOGTYPE_EFD with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 5421da008f5b..25bb17938cc1 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 16d6ea31583d..0b39795b4d06 100644
@@ -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 */
 
lib/efd/rte_efd.c +3 -0
index 686a13775742..9cfa75bf93b0 100644
@@ -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) \
Signature · 1 line
2.39.1
#59 lore raw

PATCH v4 5/19 mbuf: replace RTE_LOGTYPE_MBUF with dynamic type

In reply to 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

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 25bb17938cc1..d4389e436913 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 0b39795b4d06..941fbe51fd30 100644
@@ -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. */
lib/mbuf/mbuf_log.h new file +4 -0
new file mode 100644
index 000000000000..d759a9a25501
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mbuf_logtype;
+#define RTE_LOGTYPE_MBUF	mbuf_logtype
lib/mbuf/rte_mbuf.c +4 -0
index cfd8062f1e6a..4a379a5185d5 100644
@@ -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
lib/mbuf/rte_mbuf_dyn.c +2 -0
index 35839e938cc5..01654db03fc8 100644
@@ -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 {
lib/mbuf/rte_mbuf_pool_ops.c +2 -0
index 4c91f4ce8569..5318430126cb 100644
@@ -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)
 {
Signature · 1 line
2.39.1
#60 lore raw

PATCH v4 6/19 acl: replace LOGTYPE_ACL with dynamic type

In reply to 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.

---
 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
app/test/test_acl.c +2 -1
index 623f34682e69..75588978a720 100644
@@ -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;
 		}
lib/acl/acl_bld.c +1 -0
index 2816632803bd..f38e6478315f 100644
@@ -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
lib/acl/acl_gen.c +1 -0
index e759a2ca1598..54ec485d0c58 100644
@@ -4,6 +4,7 @@
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
lib/acl/acl_log.h new file +4 -0
new file mode 100644
index 000000000000..b55573cbe207
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
lib/acl/rte_acl.c +4 -0
index a61c3ba188da..a29decb1f6ca 100644
@@ -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);
 
lib/acl/tb_mem.c +2 -1
index f14d7b4fa26e..6a9d96aaeda2 100644
@@ -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;
lib/eal/common/eal_common_log.c +0 -2
index d4389e436913..9e853addb717 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index 941fbe51fd30..1408722b2c2f 100644
@@ -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. */
Signature · 1 line
2.39.1
#61 lore raw

PATCH v4 7/19 power: replace RTE_LOGTYPE_POWER with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 9e853addb717..39e1e6680dea 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 1408722b2c2f..7d4345acceca 100644
@@ -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. */
lib/power/guest_channel.c +2 -1
index 969a9e5aaa06..efc326d520ca 100644
@@ -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
lib/power/power_common.c +2 -0
index 1e09facb863f..bf77eafa886b 100644
@@ -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  \
lib/power/power_common.h +2 -1
index c1c713927621..63a3a443509e 100644
@@ -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...) \
lib/power/power_kvm_vm.c +1 -0
index 6a8109d44959..db031f43105a 100644
@@ -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"
lib/power/rte_power.c +1 -0
index 63a43bd8f5ae..db0e7705a9ef 100644
@@ -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"
 
lib/power/rte_power_empty_poll.c +1 -0
index 4a4db512474e..64e3b4b46d5e 100644
@@ -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
Signature · 1 line
2.39.1
#62 lore raw

PATCH v4 8/19 ring: replace RTE_LOGTYPE_RING with dynamic type

In reply to Stephen Hemminger

The logtype for ring only used in library.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 39e1e6680dea..5f15e312f15b 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 7d4345acceca..31a2ee2f6b6f 100644
@@ -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. */
lib/ring/rte_ring.c +3 -0
index cddaf6b2876f..8c5f2575d6ef 100644
@@ -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 = {
Signature · 1 line
2.39.1
#63 lore raw

PATCH v4 9/19 mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type

In reply to Stephen Hemminger

Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 5f15e312f15b..4025d2039d55 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 31a2ee2f6b6f..9f86bfdd0198 100644
@@ -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. */
lib/mempool/rte_mempool.c +3 -0
index 45b5df6199b0..841abe53e3b9 100644
@@ -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);
 
lib/mempool/rte_mempool_log.h new file +4 -0
new file mode 100644
index 000000000000..216401c9f2cd
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int mempool_logtype;
+#define RTE_LOGTYPE_MEMPOOL	mempool_logtype
lib/mempool/rte_mempool_ops.c +1 -0
index 3b43edc548a0..ad7c81823ce1 100644
@@ -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 = {
Signature · 1 line
2.39.1
#64 lore raw

PATCH v4 10/19 lpm: replace RTE_LOGTYPE_LPM with dynamic types

In reply to 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.

---
 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
lib/eal/common/eal_common_log.c +0 -1
index 4025d2039d55..6e2007e6ed4f 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 9f86bfdd0198..115a48bf05f5 100644
@@ -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 */
lib/fib/fib_log.h new file +4 -0
new file mode 100644
index 000000000000..c731c820f621
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int fib_logtype;
+#define RTE_LOGTYPE_LPM fib_logtype
lib/fib/rte_fib.c +3 -0
index 8af4c4091908..5b1815881415 100644
@@ -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 = {
lib/fib/rte_fib6.c +2 -0
index 4b8e22b142b9..762d195fb798 100644
@@ -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 = {
lib/lpm/lpm_log.h new file +4 -0
new file mode 100644
index 000000000000..a0621b70a5fe
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int lpm_logtype;
+#define RTE_LOGTYPE_LPM lpm_logtype
lib/lpm/rte_lpm.c +3 -0
index cdcd1b7f9e47..0ca82147866a 100644
@@ -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);
 
lib/lpm/rte_lpm6.c +1 -0
index 8d21aeddb83c..873cc8bc267d 100644
@@ -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
lib/rib/rib_log.h new file +4 -0
new file mode 100644
index 000000000000..f3ee513ca854
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int rib_logtype;
+#define RTE_LOGTYPE_LPM rib_logtype
lib/rib/rte_rib.c +3 -0
index b0794edf66f5..5597c8b899c8 100644
@@ -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",
lib/rib/rte_rib6.c +3 -0
index 19e4ff97c479..917bede27d24 100644
@@ -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. */
Signature · 1 line
2.39.1
#65 lore raw

PATCH v4 11/19 kni: replace RTE_LOGTYPE_KNI with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 6e2007e6ed4f..70d5bb7b1951 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 115a48bf05f5..dc2454a0d9de 100644
@@ -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. */
lib/kni/rte_kni.c +3 -0
index 8ab6c4715314..9c37bcabcadd 100644
@@ -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 */
Signature · 1 line
2.39.1
#66 lore raw

PATCH v4 12/19 sched: replace RTE_LOGTYPE_SCHED with dynamic type

In reply to Stephen Hemminger

Also can remove unused RTE_LOGTYPE_METER

---
 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
lib/eal/common/eal_common_log.c +0 -2
index 70d5bb7b1951..d4b7088b5cbb 100644
@@ -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"},
lib/eal/include/rte_log.h +2 -2
index dc2454a0d9de..f185fcbc5a94 100644
@@ -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. */
lib/sched/rte_pie.c +1 -0
index 947e2a059f6f..cce0ce762da8 100644
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rte_sched_log.h"
 #include "rte_pie.h"
 
 #ifdef __INTEL_COMPILER
lib/sched/rte_sched.c +5 -0
index c91697131d3e..c2bd8c785fcd 100644
@@ -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);
lib/sched/rte_sched_log.h new file +4 -0
new file mode 100644
index 000000000000..fde051f49d62
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+extern int sched_logtype;
+#define RTE_LOGTYPE_SCHED sched_logtype
Signature · 1 line
2.39.1
#67 lore raw

PATCH v4 13/19 port: replace RTE_LOGTYPE_PORT with dynamic type

In reply to Stephen Hemminger

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

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index d4b7088b5cbb..7f1d2c8a256d 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index f185fcbc5a94..b11aec69af78 100644
@@ -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 */
lib/port/rte_port_ethdev.c +3 -0
index 0da7890261e9..6685d304a6e9 100644
@@ -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
  */
lib/port/rte_port_eventdev.c +4 -0
index fd7dac9a5661..04447bd7f7bc 100644
@@ -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
  */
lib/port/rte_port_fd.c +3 -0
index 932ecd324e05..b2412e7706ee 100644
@@ -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
  */
lib/port/rte_port_frag.c +3 -0
index e1f1892176c4..9adcbba47da1 100644
@@ -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
 
lib/port/rte_port_kni.c +3 -0
index 1c7a6cb200ea..9793033a8fd4 100644
@@ -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
  */
lib/port/rte_port_ras.c +3 -0
index e5de57da42ea..5a610b1ba5b5 100644
@@ -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
lib/port/rte_port_ring.c +3 -0
index 52b2d8e557f0..32a90e836579 100644
@@ -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
  */
lib/port/rte_port_sched.c +3 -0
index 8a7d815ef323..6e0a8aba5419 100644
@@ -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
  */
lib/port/rte_port_source_sink.c +3 -0
index 7d73adc1e79e..e9cdadbceb8f 100644
@@ -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
  */
lib/port/rte_port_sym_crypto.c +3 -0
index 295984d025cb..77a2f04d65f6 100644
@@ -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
  */
Signature · 1 line
2.39.1
#68 lore raw

PATCH v4 14/19 table: convert RTE_LOGTYPE_TABLE to dynamic logtype

In reply to Stephen Hemminger

Use logtype suffixes for various components of this library.

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index 7f1d2c8a256d..d640ed3c88b9 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index b11aec69af78..934bddff9dfa 100644
@@ -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. */
lib/table/rte_table_acl.c +3 -0
index 53fd5c66adb5..f44a25a89405 100644
@@ -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) \
lib/table/rte_table_array.c +3 -0
index 54a0c42f7dd2..a7849beaecd6 100644
@@ -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) \
lib/table/rte_table_hash_cuckoo.c +3 -0
index c77eccf52722..12db0b84142f 100644
@@ -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) \
lib/table/rte_table_hash_ext.c +3 -0
index 70ea84fa2e51..147ecdf082cb 100644
@@ -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 {
lib/table/rte_table_hash_key16.c +3 -0
index 04d7fd64bd97..09fef5f14ce7 100644
@@ -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
lib/table/rte_table_hash_key32.c +4 -1
index 88d8f69c72ed..1abc459eee87 100644
@@ -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
 
lib/table/rte_table_hash_key8.c +4 -1
index 035d24276946..d4ccccbcdf9e 100644
@@ -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
 
lib/table/rte_table_hash_lru.c +3 -0
index c31acc11cf23..d0d2c8ba44df 100644
@@ -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) \
lib/table/rte_table_lpm.c +3 -0
index 9de9e8a20d77..4a5c4a343c77 100644
@@ -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
lib/table/rte_table_lpm_ipv6.c +3 -0
index 8fde2c012f7c..236eac4238d9 100644
@@ -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
lib/table/rte_table_stub.c +3 -0
index 23d0de5c79b0..e74044032f7d 100644
@@ -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) \
Signature · 1 line
2.39.1
#69 lore raw

PATCH v4 15/19 app/test: remove use of RTE_LOGTYPE_PIPELINE

In reply to 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.

---
 app/test/test_table_acl.c      | 50 ++++++++++++++++------------------
 app/test/test_table_pipeline.c | 40 +++++++++++++--------------
 2 files changed, 43 insertions(+), 47 deletions(-)
app/test/test_table_acl.c +23 -27
index e66f06b84d0a..dff9bddfb948 100644
@@ -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;
 	}
app/test/test_table_pipeline.c +20 -20
index 7adbbffbf55d..960f730cf20d 100644
@@ -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;
 	}
 
Signature · 1 line
2.39.1
#70 lore raw

PATCH v4 16/19 pipeline: replace RTE_LOGTYPE_PIPELINE with dynamic type

In reply to Stephen Hemminger

Use a dynamicly allocated logtype

---
 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(-)
lib/eal/common/eal_common_log.c +0 -1
index d640ed3c88b9..a3498d1a2faf 100644
@@ -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"},
lib/eal/include/rte_log.h +1 -1
index 934bddff9dfa..7473fd53505a 100644
@@ -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 */
lib/pipeline/rte_pipeline.c +3 -0
index ff86c7cf96bf..30919cd9fe30 100644
@@ -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
Signature · 1 line
2.39.1
#71 lore raw

PATCH v4 17/19 hash: move rte_thash_gfni stubs out of header file

In reply to Stephen Hemminger

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

---
 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
lib/hash/meson.build +7 -1
index 2f757d45f9bc..e56ee8572564 100644
@@ -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']
lib/hash/rte_thash_gfni.c new file +43 -0

43 lines not on this page · raw message

lib/hash/rte_thash_gfni.h +5 -23
index ef90faa302d1..86208eb45ebb 100644
@@ -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 */
 
lib/hash/version.map +4 -0
index bdcebd19c29b..f03b047b2eec 100644
@@ -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;
 };
Signature · 1 line
2.39.1