log: redefine logtype values

After the changes in commit c1b5fa94a46f
("eal: support dynamic log types"), logtype is not treated as a
bitmask, but a decimal value. Therefore, values have to be
converted.

Fixes: c1b5fa94a46f ("eal: support dynamic log types")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
This commit is contained in:
Pablo de Lara 2017-04-19 15:06:34 +01:00 committed by Thomas Monjalon
parent dde32aced7
commit 75915f1bde
2 changed files with 73 additions and 58 deletions

View File

@ -118,9 +118,9 @@ rte_set_log_type(uint32_t type, int enable)
{
if (type < RTE_LOGTYPE_FIRST_EXT_ID) {
if (enable)
rte_logs.type |= type;
rte_logs.type |= 1 << type;
else
rte_logs.type &= ~type;
rte_logs.type &= ~(1 << type);
}
if (enable)
@ -240,42 +240,57 @@ rte_log_register(const char *name)
return ret;
}
struct logtype {
uint32_t log_id;
const char *logtype;
};
static const struct logtype logtype_strings[] = {
{RTE_LOGTYPE_EAL, "eal"},
{RTE_LOGTYPE_MALLOC, "malloc"},
{RTE_LOGTYPE_RING, "ring"},
{RTE_LOGTYPE_MEMPOOL, "mempool"},
{RTE_LOGTYPE_TIMER, "timer"},
{RTE_LOGTYPE_PMD, "pmd"},
{RTE_LOGTYPE_HASH, "hash"},
{RTE_LOGTYPE_LPM, "lpm"},
{RTE_LOGTYPE_KNI, "kni"},
{RTE_LOGTYPE_ACL, "acl"},
{RTE_LOGTYPE_POWER, "power"},
{RTE_LOGTYPE_METER, "meter"},
{RTE_LOGTYPE_SCHED, "sched"},
{RTE_LOGTYPE_PORT, "port"},
{RTE_LOGTYPE_TABLE, "table"},
{RTE_LOGTYPE_PIPELINE, "pipeline"},
{RTE_LOGTYPE_MBUF, "mbuf"},
{RTE_LOGTYPE_CRYPTODEV, "cryptodev"},
{RTE_LOGTYPE_EFD, "efd"},
{RTE_LOGTYPE_EVENTDEV, "eventdev"},
{RTE_LOGTYPE_USER1, "user1"},
{RTE_LOGTYPE_USER2, "user2"},
{RTE_LOGTYPE_USER3, "user3"},
{RTE_LOGTYPE_USER4, "user4"},
{RTE_LOGTYPE_USER5, "user5"},
{RTE_LOGTYPE_USER6, "user6"},
{RTE_LOGTYPE_USER7, "user7"},
{RTE_LOGTYPE_USER8, "user8"}
};
RTE_INIT(rte_log_init);
static void
rte_log_init(void)
{
uint32_t i;
rte_logs.dynamic_types = calloc(RTE_LOGTYPE_FIRST_EXT_ID,
sizeof(struct rte_log_dynamic_type));
if (rte_logs.dynamic_types == NULL)
return;
/* register legacy log types, keep sync'd with RTE_LOGTYPE_* */
__rte_log_register("eal", 0);
__rte_log_register("malloc", 1);
__rte_log_register("ring", 2);
__rte_log_register("mempool", 3);
__rte_log_register("timer", 4);
__rte_log_register("pmd", 5);
__rte_log_register("hash", 6);
__rte_log_register("lpm", 7);
__rte_log_register("kni", 8);
__rte_log_register("acl", 9);
__rte_log_register("power", 10);
__rte_log_register("meter", 11);
__rte_log_register("sched", 12);
__rte_log_register("port", 13);
__rte_log_register("table", 14);
__rte_log_register("pipeline", 15);
__rte_log_register("mbuf", 16);
__rte_log_register("cryptodev", 17);
__rte_log_register("user1", 24);
__rte_log_register("user2", 25);
__rte_log_register("user3", 26);
__rte_log_register("user4", 27);
__rte_log_register("user5", 28);
__rte_log_register("user6", 29);
__rte_log_register("user7", 30);
__rte_log_register("user8", 31);
/* register legacy log types */
for (i = 0; i < RTE_DIM(logtype_strings); i++)
__rte_log_register(logtype_strings[i].logtype,
logtype_strings[i].log_id);
rte_logs.dynamic_types_len = RTE_LOGTYPE_FIRST_EXT_ID;
}

View File

@ -66,37 +66,37 @@ struct rte_logs {
/** Global log informations */
extern struct rte_logs rte_logs;
/* SDK log type, keep sync'd with rte_log_init() */
#define RTE_LOGTYPE_EAL 0x00000001 /**< Log related to eal. */
#define RTE_LOGTYPE_MALLOC 0x00000002 /**< Log related to malloc. */
#define RTE_LOGTYPE_RING 0x00000004 /**< Log related to ring. */
#define RTE_LOGTYPE_MEMPOOL 0x00000008 /**< Log related to mempool. */
#define RTE_LOGTYPE_TIMER 0x00000010 /**< Log related to timers. */
#define RTE_LOGTYPE_PMD 0x00000020 /**< Log related to poll mode driver. */
#define RTE_LOGTYPE_HASH 0x00000040 /**< Log related to hash table. */
#define RTE_LOGTYPE_LPM 0x00000080 /**< Log related to LPM. */
#define RTE_LOGTYPE_KNI 0x00000100 /**< Log related to KNI. */
#define RTE_LOGTYPE_ACL 0x00000200 /**< Log related to ACL. */
#define RTE_LOGTYPE_POWER 0x00000400 /**< Log related to power. */
#define RTE_LOGTYPE_METER 0x00000800 /**< Log related to QoS meter. */
#define RTE_LOGTYPE_SCHED 0x00001000 /**< Log related to QoS port scheduler. */
#define RTE_LOGTYPE_PORT 0x00002000 /**< Log related to port. */
#define RTE_LOGTYPE_TABLE 0x00004000 /**< Log related to table. */
#define RTE_LOGTYPE_PIPELINE 0x00008000 /**< Log related to pipeline. */
#define RTE_LOGTYPE_MBUF 0x00010000 /**< Log related to mbuf. */
#define RTE_LOGTYPE_CRYPTODEV 0x00020000 /**< Log related to cryptodev. */
#define RTE_LOGTYPE_EFD 0x00040000 /**< Log related to EFD. */
#define RTE_LOGTYPE_EVENTDEV 0x00080000 /**< Log related to eventdev. */
/* SDK log type */
#define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */
#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. */
#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. */
#define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */
#define RTE_LOGTYPE_ACL 9 /**< Log related to 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. */
#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. */
#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. */
/* these log types can be used in an application */
#define RTE_LOGTYPE_USER1 0x01000000 /**< User-defined log type 1. */
#define RTE_LOGTYPE_USER2 0x02000000 /**< User-defined log type 2. */
#define RTE_LOGTYPE_USER3 0x04000000 /**< User-defined log type 3. */
#define RTE_LOGTYPE_USER4 0x08000000 /**< User-defined log type 4. */
#define RTE_LOGTYPE_USER5 0x10000000 /**< User-defined log type 5. */
#define RTE_LOGTYPE_USER6 0x20000000 /**< User-defined log type 6. */
#define RTE_LOGTYPE_USER7 0x40000000 /**< User-defined log type 7. */
#define RTE_LOGTYPE_USER8 0x80000000 /**< User-defined log type 8. */
#define RTE_LOGTYPE_USER1 24 /**< User-defined log type 1. */
#define RTE_LOGTYPE_USER2 25 /**< User-defined log type 2. */
#define RTE_LOGTYPE_USER3 26 /**< User-defined log type 3. */
#define RTE_LOGTYPE_USER4 27 /**< User-defined log type 4. */
#define RTE_LOGTYPE_USER5 28 /**< User-defined log type 5. */
#define RTE_LOGTYPE_USER6 29 /**< User-defined log type 6. */
#define RTE_LOGTYPE_USER7 30 /**< User-defined log type 7. */
#define RTE_LOGTYPE_USER8 31 /**< User-defined log type 8. */
/** First identifier for extended logs */
#define RTE_LOGTYPE_FIRST_EXT_ID 32