[06/18] acl: convert RTE_LOGTYPE_ACL to dynamic type

Message ID 20231205021330.260017-7-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series Convert static log types in libraries to dynamic |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Dec. 5, 2023, 2:09 a.m. UTC
  Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC.
For ACL library use a dynamic type.
The one message using RTE_LOGTYPE_MALLOC should have been
under the ACL logtype anyway.

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

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

Patch

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 8011639ddd1f..503ff0889405 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -154,7 +154,7 @@  rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx,
 	for (i = 0; i != num; i++) {
 		rc = acl_ipv4vlan_check_rule(rules + i);
 		if (rc != 0) {
-			RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n",
+			fprintf(stderr,  "%s: rule #%u is invalid\n",
 				__func__, i + 1);
 			return rc;
 		}
diff --git a/lib/acl/acl.h b/lib/acl/acl.h
index c8e4e72fabfb..baed9513cb31 100644
--- a/lib/acl/acl.h
+++ b/lib/acl/acl.h
@@ -225,6 +225,7 @@  int
 rte_acl_classify_altivec(const struct rte_acl_ctx *ctx, const uint8_t **data,
 	uint32_t *results, uint32_t num, uint32_t categories);
 
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 418751e9f4c7..eaf8770415a5 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -3,8 +3,11 @@ 
  */
 
 #include <rte_acl.h>
+#include <rte_log.h>
+
 #include "tb_mem.h"
 #include "acl.h"
+#include "acl_log.h"
 
 #define	ACL_POOL_ALIGN		8
 #define	ACL_POOL_ALLOC_MIN	0x800000
diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c
index 25e75fec3534..03a47ea231ec 100644
--- a/lib/acl/acl_gen.c
+++ b/lib/acl/acl_gen.c
@@ -4,6 +4,7 @@ 
 
 #include <rte_acl.h>
 #include "acl.h"
+#include "acl_log.h"
 
 #define	QRANGE_MIN	((uint8_t)INT8_MIN)
 
diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h
new file mode 100644
index 000000000000..6147116d8d12
--- /dev/null
+++ b/lib/acl/acl_log.h
@@ -0,0 +1,6 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+#include <rte_log.h>
+
+extern int acl_logtype;
+#define RTE_LOGTYPE_ACL	acl_logtype
diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c
index 4182006d1d1c..760c3587d4dc 100644
--- a/lib/acl/rte_acl.c
+++ b/lib/acl/rte_acl.c
@@ -8,6 +8,9 @@ 
 #include <rte_tailq.h>
 
 #include "acl.h"
+#include "acl_log.h"
+
+RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO);
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
 
diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c
index f14d7b4fa26e..6a9d96aaeda2 100644
--- a/lib/acl/tb_mem.c
+++ b/lib/acl/tb_mem.c
@@ -3,6 +3,7 @@ 
  */
 
 #include "tb_mem.h"
+#include "acl_log.h"
 
 /*
  *  Memory management routines for temporary memory.
@@ -25,7 +26,7 @@  tb_pool(struct tb_mem_pool *pool, size_t sz)
 	size = sz + pool->alignment - 1;
 	block = calloc(1, size + sizeof(*pool->block));
 	if (block == NULL) {
-		RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
+		RTE_LOG(ERR, ACL, "%s(%zu)\n failed, currently allocated "
 			"by pool: %zu bytes\n", __func__, sz, pool->alloc);
 		siglongjmp(pool->fail, -ENOMEM);
 		return NULL;
diff --git a/lib/log/log.c b/lib/log/log.c
index 0718b84dcb04..49ee89ffdd97 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -352,13 +352,11 @@  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_ACL,        "lib.acl"},
 	{RTE_LOGTYPE_POWER,      "lib.power"},
 	{RTE_LOGTYPE_METER,      "lib.meter"},
 	{RTE_LOGTYPE_SCHED,      "lib.sched"},
diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h
index bd10e32fe164..0c651f58b58e 100644
--- a/lib/log/rte_log.h
+++ b/lib/log/rte_log.h
@@ -27,7 +27,7 @@  extern "C" {
 
 /* SDK log type */
 #define RTE_LOGTYPE_EAL        0 /**< Log related to eal. */
-#define RTE_LOGTYPE_MALLOC     1 /**< Log related to malloc. */
+				 /* was RTE_LOGTYPE_MALLOC */
 #define RTE_LOGTYPE_RING       2 /**< Log related to ring. */
 #define RTE_LOGTYPE_MEMPOOL    3 /**< Log related to mempool. */
 				 /* was RTE_LOGTYPE_TIMER */
@@ -35,7 +35,7 @@  extern "C" {
 #define RTE_LOGTYPE_HASH       6 /**< Log related to hash table. */
 #define RTE_LOGTYPE_LPM        7 /**< Log related to LPM. */
 				 /* was RTE_LOGTYPE_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. */