From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E98E041C58; Fri, 10 Feb 2023 02:09:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CA1E42D9B; Fri, 10 Feb 2023 02:08:25 +0100 (CET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 534D842D3E for ; Fri, 10 Feb 2023 02:08:19 +0100 (CET) Received: by mail-pj1-f49.google.com with SMTP id pj3so3756135pjb.1 for ; Thu, 09 Feb 2023 17:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oUD4untaWq9ClN/tsZ8toVOkAn+YUUKEAaJT0knWzqU=; b=SFwBNMohg7kMH9vq3FaOBo6xnoyfVxfchNYOxIhDZWvB3hJda+1c/HjMCSD/6QMlEx SJeFjiy/Z3ahix9+I9Wtfw/09n+VjQxd2YJVVQaXjjMTwg7i0LbQKgjCqTgugzDMsIQ7 mQVhuaLqkhpatcROAOInuvkm1f9P1YYif3nW2dAnnBZ7rY7CqPa380/cpJh7u6nt5Bo6 34BZjMmBpxUVs8kWQWniRRhdAsQpJUC23yS6RBCBqrWQWbAeGO8wtD+m9K3pAC+uGDLn +lANWJzfRY+6FKg6pIBwef1/1x+5xaeKb27989m/sp4MB2bKo886nvtSTVSEQ6WXVGYm lchw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oUD4untaWq9ClN/tsZ8toVOkAn+YUUKEAaJT0knWzqU=; b=iE9Y12Gq9dbnqea/uEZt62m49m7LKJlK58nWhuvSAowa9mSEYlH7WkpaSMsHhR9wtC 0aFREnNAnwzaRabXNcfQBs63W3BJVhsURIv8RzYj8cn8Y1rli8Dgf9p2qkytckYnG1Du a+RaTn8kza9IvKMK9NWj0Pr9OVxpRoUCKuptRE039qf32o4xtAI6eFLHysfJEjix7ffS aGt5d2AZp354aDGa2+L9c0jJTThx4lcypn8XdDXQxjUHAInGdHPQzPZlpwNTuibx0Q2B CvHOLjBh+uwskqhUCC2XZlcSfJWJRuHC5S9yYhZegYl0lL6JTWXCBeH6BWkf2OCNfBXk V9sA== X-Gm-Message-State: AO0yUKVxXE4hBO0eGpdWDcyCy9/gOQRDx79x3TOlA4o3V00YS6BDHX6H eYCscP/CNmLFZ0A0EoOa9MaMv7TDGYQPk7io+XI= X-Google-Smtp-Source: AK7set9dv/mS8Cm/XCU8o8VSdsftskP7N2lywP1vEFzfEVt8gjByj1OaeWtXWG7nmXGbjhc47qu6UA== X-Received: by 2002:a17:902:f54f:b0:199:1769:48dc with SMTP id h15-20020a170902f54f00b00199176948dcmr13745806plf.65.1675991297662; Thu, 09 Feb 2023 17:08:17 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 14/16] table: convert RTE_LOGTYPE_TABLE to dynamic logtype Date: Thu, 9 Feb 2023 17:07:22 -0800 Message-Id: <20230210010724.890413-15-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use logtype suffixes for various components of this library. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/table/rte_table_acl.c | 90 +++++++++++++------------------ lib/table/rte_table_array.c | 23 ++++---- lib/table/rte_table_hash_cuckoo.c | 30 ++++++----- lib/table/rte_table_hash_ext.c | 34 +++++++----- lib/table/rte_table_hash_key16.c | 56 ++++++++++--------- lib/table/rte_table_hash_key32.c | 62 ++++++++++----------- lib/table/rte_table_hash_key8.c | 59 ++++++++++---------- lib/table/rte_table_hash_lru.c | 35 ++++++------ lib/table/rte_table_lpm.c | 54 +++++++++---------- lib/table/rte_table_lpm_ipv6.c | 56 +++++++++---------- lib/table/rte_table_stub.c | 9 ++-- 13 files changed, 257 insertions(+), 254 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 7002e267be37..a4e718e51d12 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index ff714a703be7..af87eb42ddb3 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -40,7 +40,7 @@ extern "C" { /* was RTE_LOGTYPE_METER */ /* was RTE_LOGTYPE_SCHED */ /* was RTE_LOGTYPE_PORT */ -#define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ + /* was RTE_LOGTYPE_TABLE */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ /* was RTE_LOGTYPE_MBUF */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c index 53fd5c66adb5..87081f183862 100644 --- a/lib/table/rte_table_acl.c +++ b/lib/table/rte_table_acl.c @@ -11,6 +11,11 @@ #include "rte_table_acl.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_acl, acl, INFO); +#define TABLE_ACL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_acl, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_ACL_STATS_PKTS_IN_ADD(table, val) \ @@ -65,22 +70,20 @@ rte_table_acl_create( /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for params\n", __func__); + TABLE_ACL_LOG(ERR, "Invalid value for params"); return NULL; } if (p->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for name\n", __func__); + TABLE_ACL_LOG(ERR, "Invalid value for name"); return NULL; } if (p->n_rules == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for n_rules\n", - __func__); + TABLE_ACL_LOG(ERR, "Invalid value for n_rules"); return NULL; } if ((p->n_rule_fields == 0) || (p->n_rule_fields > RTE_ACL_MAX_FIELDS)) { - RTE_LOG(ERR, TABLE, "%s: Invalid value for n_rule_fields\n", - __func__); + TABLE_ACL_LOG(ERR, "Invalid value for n_rule_fields"); return NULL; } @@ -98,9 +101,7 @@ rte_table_acl_create( acl = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (acl == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for ACL table\n", - __func__, total_size); + TABLE_ACL_LOG(ERR,"Cannot allocate %u bytes for ACL table", total_size); return NULL; } @@ -140,7 +141,7 @@ rte_table_acl_free(void *table) /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -164,8 +165,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx) /* Create low level ACL table */ ctx = rte_acl_create(&acl->acl_params); if (ctx == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot create low level ACL table\n", - __func__); + TABLE_ACL_LOG(ERR, "Cannot create low level ACL table"); return -1; } @@ -176,9 +176,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx) status = rte_acl_add_rules(ctx, acl->acl_rule_list[i], 1); if (status != 0) { - RTE_LOG(ERR, TABLE, - "%s: Cannot add rule to low level ACL table\n", - __func__); + TABLE_ACL_LOG(ERR, "Cannot add rule to low level ACL table"); rte_acl_free(ctx); return -1; } @@ -196,9 +194,7 @@ rte_table_acl_build(struct rte_table_acl *acl, struct rte_acl_ctx **acl_ctx) /* Build low level ACl table */ status = rte_acl_build(ctx, &acl->cfg); if (status != 0) { - RTE_LOG(ERR, TABLE, - "%s: Cannot build the low level ACL table\n", - __func__); + TABLE_ACL_LOG(ERR, "Cannot build the low level ACL table"); rte_acl_free(ctx); return -1; } @@ -226,29 +222,27 @@ rte_table_acl_entry_add( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } if (entry_ptr == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry_ptr parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "entry_ptr parameter is NULL"); return -EINVAL; } if (rule->priority > RTE_ACL_MAX_PRIORITY) { - RTE_LOG(ERR, TABLE, "%s: Priority is too high\n", __func__); + TABLE_ACL_LOG(ERR, "Priority is too high"); return -EINVAL; } @@ -291,8 +285,7 @@ rte_table_acl_entry_add( /* Return if max rules */ if (free_pos_valid == 0) { - RTE_LOG(ERR, TABLE, "%s: Max number of rules reached\n", - __func__); + TABLE_ACL_LOG(ERR, "Max number of rules reached"); return -ENOSPC; } @@ -342,16 +335,15 @@ rte_table_acl_entry_delete( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } @@ -424,29 +416,27 @@ rte_table_acl_entry_add_bulk( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (keys == NULL) { - RTE_LOG(ERR, TABLE, "%s: keys parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "keys parameter is NULL"); return -EINVAL; } if (entries == NULL) { - RTE_LOG(ERR, TABLE, "%s: entries parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "entries parameter is NULL"); return -EINVAL; } if (n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: 0 rules to add\n", __func__); + TABLE_ACL_LOG(ERR, "0 rules to add"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } if (entries_ptr == NULL) { - RTE_LOG(ERR, TABLE, "%s: entries_ptr parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "entries_ptr parameter is NULL"); return -EINVAL; } @@ -455,20 +445,18 @@ rte_table_acl_entry_add_bulk( struct rte_table_acl_rule_add_params *rule; if (keys[i] == NULL) { - RTE_LOG(ERR, TABLE, "%s: keys[%" PRIu32 "] parameter is NULL\n", - __func__, i); + TABLE_ACL_LOG(ERR, "keys[%" PRIu32 "] parameter is NULL\n", i); return -EINVAL; } if (entries[i] == NULL) { - RTE_LOG(ERR, TABLE, "%s: entries[%" PRIu32 "] parameter is NULL\n", - __func__, i); + TABLE_ACL_LOG(ERR, "entries[%" PRIu32 "] parameter is NULL\n", i); return -EINVAL; } rule = keys[i]; if (rule->priority > RTE_ACL_MAX_PRIORITY) { - RTE_LOG(ERR, TABLE, "%s: Priority is too high\n", __func__); + TABLE_ACL_LOG(ERR, "Priority is too high"); return -EINVAL; } } @@ -604,27 +592,25 @@ rte_table_acl_entry_delete_bulk( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (keys == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ACL_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: 0 rules to delete\n", __func__); + TABLE_ACL_LOG(ERR, "0 rules to delete"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ACL_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } for (i = 0; i < n_keys; i++) { if (keys[i] == NULL) { - RTE_LOG(ERR, TABLE, "%s: keys[%" PRIu32 "] parameter is NULL\n", - __func__, i); + TABLE_ACL_LOG(ERR, "keys[%" PRIu32 "] parameter is NULL", i); return -EINVAL; } } diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c index 54a0c42f7dd2..47b5a2b15b2b 100644 --- a/lib/table/rte_table_array.c +++ b/lib/table/rte_table_array.c @@ -11,6 +11,11 @@ #include "rte_table_array.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_array, array, INFO); +#define TABLE_ARRAY_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_array, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_ARRAY_STATS_PKTS_IN_ADD(table, val) \ @@ -61,9 +66,7 @@ rte_table_array_create(void *params, int socket_id, uint32_t entry_size) total_size = total_cl_size * RTE_CACHE_LINE_SIZE; t = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for array table\n", - __func__, total_size); + TABLE_ARRAY_LOG(ERR, "Cannot allocate %u bytes for array table\n", total_size); return NULL; } @@ -83,7 +86,7 @@ rte_table_array_free(void *table) /* Check input parameters */ if (t == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -107,25 +110,23 @@ rte_table_array_entry_add( /* Check input parameters */ if (table == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (key == NULL) { - RTE_LOG(ERR, TABLE, "%s: key parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "key parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_ARRAY_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if (key_found == NULL) { - RTE_LOG(ERR, TABLE, "%s: key_found parameter is NULL\n", - __func__); + TABLE_ARRAY_LOG(ERR, "key_found parameter is NULL"); return -EINVAL; } if (entry_ptr == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry_ptr parameter is NULL\n", - __func__); + TABLE_ARRAY_LOG(ERR, "entry_ptr parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c index c77eccf52722..7b1f1575e564 100644 --- a/lib/table/rte_table_hash_cuckoo.c +++ b/lib/table/rte_table_hash_cuckoo.c @@ -10,6 +10,11 @@ #include "rte_table_hash_cuckoo.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash, hash, INFO); +#define TABLE_HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_HASH_CUCKOO_STATS_PKTS_IN_ADD(table, val) \ @@ -47,27 +52,27 @@ static int check_params_create_hash_cuckoo(struct rte_table_hash_cuckoo_params *params) { if (params == NULL) { - RTE_LOG(ERR, TABLE, "NULL Input Parameters.\n"); + TABLE_HASH_LOG(ERR, "NULL Input Parameters."); return -EINVAL; } if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "Table name is NULL.\n"); + TABLE_HASH_LOG(ERR, "Table name is NULL."); return -EINVAL; } if (params->key_size == 0) { - RTE_LOG(ERR, TABLE, "Invalid key_size.\n"); + TABLE_HASH_LOG(ERR, "Invalid key_size."); return -EINVAL; } if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "Invalid n_keys.\n"); + TABLE_HASH_LOG(ERR, "Invalid n_keys."); return -EINVAL; } if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "f_hash is NULL.\n"); + TABLE_HASH_LOG(ERR, "f_hash is NULL."); return -EINVAL; } @@ -94,9 +99,8 @@ rte_table_hash_cuckoo_create(void *params, t = rte_zmalloc_socket(p->name, total_size, RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for cuckoo hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH_LOG(ERR, "Cannot allocate %u bytes for cuckoo hash table %s", + total_size, p->name); return NULL; } @@ -114,9 +118,8 @@ rte_table_hash_cuckoo_create(void *params, if (h_table == NULL) { h_table = rte_hash_create(&hash_cuckoo_params); if (h_table == NULL) { - RTE_LOG(ERR, TABLE, - "%s: failed to create cuckoo hash table %s\n", - __func__, p->name); + TABLE_HASH_LOG(ERR, "failed to create cuckoo hash table %s", + p->name); rte_free(t); return NULL; } @@ -131,9 +134,8 @@ rte_table_hash_cuckoo_create(void *params, t->key_offset = p->key_offset; t->h_table = h_table; - RTE_LOG(INFO, TABLE, - "%s: Cuckoo hash table %s memory footprint is %u bytes\n", - __func__, p->name, total_size); + TABLE_HASH_LOG(INFO, "Cuckoo hash table %s memory footprint is %u bytes", + p->name, total_size); return t; } diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c index 70ea84fa2e51..ca16328c1612 100644 --- a/lib/table/rte_table_hash_ext.c +++ b/lib/table/rte_table_hash_ext.c @@ -11,6 +11,11 @@ #include "rte_table_hash.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash_ext, hash.ext, INFO); +#define TABLE_HASH_EXT_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash_ext, \ + "%s(): " fmt "\n", __func__, ##args) + #define KEYS_PER_BUCKET 4 struct bucket { @@ -128,33 +133,33 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if ((params->key_size < sizeof(uint64_t)) || (!rte_is_power_of_2(params->key_size))) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "n_keys invalid value"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash invalid value\n", __func__); + TABLE_HASH_EXT_LOG(ERR, "f_hash invalid value"); return -EINVAL; } @@ -211,9 +216,9 @@ rte_table_hash_ext_create(void *params, int socket_id, uint32_t entry_size) key_sz + key_stack_sz + bkt_ext_stack_sz + data_sz; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH_EXT_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -222,14 +227,15 @@ rte_table_hash_ext_create(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH_EXT_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s (%u-byte key): Hash table %s memory " - "footprint is %" PRIu64 " bytes\n", - __func__, p->key_size, p->name, total_size); + + TABLE_HASH_EXT_LOG(INFO, + "(%u-byte key): Hash table %s memory footprint is %" PRIu64 " bytes", + p->key_size, p->name, total_size); /* Memory initialization */ t->key_size = p->key_size; diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c index 04d7fd64bd97..5501a9c5fc54 100644 --- a/lib/table/rte_table_hash_key16.c +++ b/lib/table/rte_table_hash_key16.c @@ -11,6 +11,11 @@ #include "rte_table_hash.h" #include "rte_lru.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash16, hash16, INFO); +#define TABLE_HASH16_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash16, \ + "%s(): " fmt "\n", __func__, ##args) + #define KEY_SIZE 16 #define KEYS_PER_BUCKET 4 @@ -107,33 +112,32 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH16_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if (params->key_size != KEY_SIZE) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH16_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__); + TABLE_HASH16_LOG(ERR, "n_keys is zero"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH16_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n", - __func__); + TABLE_HASH16_LOG(ERR, "f_hash function pointer is NULL"); return -EINVAL; } @@ -181,9 +185,9 @@ rte_table_hash_create_key16_lru(void *params, total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -192,14 +196,14 @@ rte_table_hash_create_key16_lru(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH16_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = n_buckets; @@ -236,7 +240,7 @@ rte_table_hash_free_key16_lru(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH16_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -391,9 +395,9 @@ rte_table_hash_create_key16_ext(void *params, total_size = sizeof(struct rte_table_hash) + (p->n_buckets + n_buckets_ext) * bucket_size + stack_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -402,14 +406,14 @@ rte_table_hash_create_key16_ext(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH16_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH16_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = p->n_buckets; @@ -446,7 +450,7 @@ rte_table_hash_free_key16_ext(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH16_LOG(ERR, "table parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c index 88d8f69c72ed..d830c6b3784a 100644 --- a/lib/table/rte_table_hash_key32.c +++ b/lib/table/rte_table_hash_key32.c @@ -11,11 +11,16 @@ #include "rte_table_hash.h" #include "rte_lru.h" -#define KEY_SIZE 32 +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash32, hash32, INFO); +#define TABLE_HASH32_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash32, \ + "%s(): " fmt "\n", __func__, ##args) + +#define KEY_SIZE 32 #define KEYS_PER_BUCKET 4 -#define RTE_BUCKET_ENTRY_VALID 0x1LLU +#define RTE_BUCKET_ENTRY_VALID 0x1LLU #ifdef RTE_TABLE_STATS_COLLECT @@ -111,33 +116,32 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH32_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if (params->key_size != KEY_SIZE) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH32_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__); + TABLE_HASH32_LOG(ERR, "n_keys is zero"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH32_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n", - __func__); + TABLE_HASH32_LOG(ERR, "f_hash function pointer is NULL"); return -EINVAL; } @@ -184,9 +188,9 @@ rte_table_hash_create_key32_lru(void *params, KEYS_PER_BUCKET * entry_size); total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -195,15 +199,14 @@ rte_table_hash_create_key32_lru(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, - "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH32_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = n_buckets; @@ -244,7 +247,7 @@ rte_table_hash_free_key32_lru(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH32_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -400,9 +403,9 @@ rte_table_hash_create_key32_ext(void *params, total_size = sizeof(struct rte_table_hash) + (p->n_buckets + n_buckets_ext) * bucket_size + stack_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -411,15 +414,14 @@ rte_table_hash_create_key32_ext(void *params, RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH32_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, - "%s: Hash table %s memory footprint " - "is %" PRIu64" bytes\n", - __func__, p->name, total_size); + TABLE_HASH32_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64" bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = p->n_buckets; @@ -460,7 +462,7 @@ rte_table_hash_free_key32_ext(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH32_LOG(ERR, "table parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c index 035d24276946..9678ee0741e5 100644 --- a/lib/table/rte_table_hash_key8.c +++ b/lib/table/rte_table_hash_key8.c @@ -11,7 +11,12 @@ #include "rte_table_hash.h" #include "rte_lru.h" -#define KEY_SIZE 8 +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash8, hash8, INFO); +#define TABLE_HASH8_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash8, \ + "%s(): " fmt "\n", __func__, ##args) + +#define KEY_SIZE 8 #define KEYS_PER_BUCKET 4 @@ -101,33 +106,32 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH8_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if (params->key_size != KEY_SIZE) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH8_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys is zero\n", __func__); + TABLE_HASH8_LOG(ERR, "n_keys is zero"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH8_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n", - __func__); + TABLE_HASH8_LOG(ERR, "f_hash function pointer is NULL"); return -EINVAL; } @@ -173,9 +177,9 @@ rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size) total_size = sizeof(struct rte_table_hash) + n_buckets * bucket_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -184,15 +188,15 @@ rte_table_hash_create_key8_lru(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes" - " for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH8_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = n_buckets; @@ -226,7 +230,7 @@ rte_table_hash_free_key8_lru(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH8_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -377,9 +381,9 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size) (p->n_buckets + n_buckets_ext) * bucket_size + stack_size; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -388,15 +392,14 @@ rte_table_hash_create_key8_ext(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (f == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %" PRIu64 " bytes " - "for hash table %s\n", - __func__, total_size, p->name); + TABLE_HASH8_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s: Hash table %s memory footprint " - "is %" PRIu64 " bytes\n", - __func__, p->name, total_size); + TABLE_HASH8_LOG(INFO, + "Hash table %s memory footprint is %" PRIu64 " bytes", + p->name, total_size); /* Memory initialization */ f->n_buckets = p->n_buckets; @@ -430,7 +433,7 @@ rte_table_hash_free_key8_ext(void *table) /* Check input parameters */ if (f == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_HASH8_LOG(ERR, "table parameter is NULL"); return -EINVAL; } diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c index c31acc11cf23..9bc64f74c922 100644 --- a/lib/table/rte_table_hash_lru.c +++ b/lib/table/rte_table_hash_lru.c @@ -14,6 +14,11 @@ #define KEYS_PER_BUCKET 4 +RTE_LOG_REGISTER_SUFFIX(table_logtype_hash_lru, hash.lru, INFO); +#define TABLE_HASH_LRU_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_hash_lru, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val) \ @@ -105,33 +110,33 @@ check_params_create(struct rte_table_hash_params *params) { /* name */ if (params->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: name invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "name invalid value"); return -EINVAL; } /* key_size */ if ((params->key_size < sizeof(uint64_t)) || (!rte_is_power_of_2(params->key_size))) { - RTE_LOG(ERR, TABLE, "%s: key_size invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "key_size invalid value"); return -EINVAL; } /* n_keys */ if (params->n_keys == 0) { - RTE_LOG(ERR, TABLE, "%s: n_keys invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "n_keys invalid value"); return -EINVAL; } /* n_buckets */ if ((params->n_buckets == 0) || (!rte_is_power_of_2(params->n_buckets))) { - RTE_LOG(ERR, TABLE, "%s: n_buckets invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "n_buckets invalid value"); return -EINVAL; } /* f_hash */ if (params->f_hash == NULL) { - RTE_LOG(ERR, TABLE, "%s: f_hash invalid value\n", __func__); + TABLE_HASH_LRU_LOG(ERR, "f_hash invalid value"); return -EINVAL; } @@ -187,10 +192,9 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size) key_stack_sz + data_sz; if (total_size > SIZE_MAX) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %" PRIu64 " bytes for hash " - "table %s\n", - __func__, total_size, p->name); + TABLE_HASH_LRU_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } @@ -199,15 +203,14 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size) RTE_CACHE_LINE_SIZE, socket_id); if (t == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %" PRIu64 " bytes for hash " - "table %s\n", - __func__, total_size, p->name); + TABLE_HASH_LRU_LOG(ERR, + "Cannot allocate %" PRIu64 " bytes for hash table %s", + total_size, p->name); return NULL; } - RTE_LOG(INFO, TABLE, "%s (%u-byte key): Hash table %s memory footprint" - " is %" PRIu64 " bytes\n", - __func__, p->key_size, p->name, total_size); + TABLE_HASH_LRU_LOG(INFO, + "(%u-byte key): Hash table %s memory footprint is %" PRIu64 " bytes", + p->key_size, p->name, total_size); /* Memory initialization */ t->key_size = p->key_size; diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c index 9de9e8a20d77..653e2604fd34 100644 --- a/lib/table/rte_table_lpm.c +++ b/lib/table/rte_table_lpm.c @@ -13,6 +13,11 @@ #include "rte_table_lpm.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_lpm, lpm, INFO); +#define TABLE_LPM_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_lpm, \ + "%s(): " fmt "\n", __func__, ##args) + #ifndef RTE_TABLE_LPM_MAX_NEXT_HOPS #define RTE_TABLE_LPM_MAX_NEXT_HOPS 65536 #endif @@ -59,30 +64,27 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size) /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, TABLE, "%s: NULL input parameters\n", __func__); + TABLE_LPM_LOG(ERR, "NULL input parameters"); return NULL; } if (p->n_rules == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__); + TABLE_LPM_LOG(ERR, "Invalid n_rules"); return NULL; } if (p->number_tbl8s == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid number_tbl8s\n", __func__); + TABLE_LPM_LOG(ERR, "Invalid number_tbl8s"); return NULL; } if (p->entry_unique_size == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->entry_unique_size > entry_size) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: Table name is NULL\n", - __func__); + TABLE_LPM_LOG(ERR, "Table name is NULL"); return NULL; } entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t)); @@ -93,9 +95,8 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size) lpm = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (lpm == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for LPM table\n", - __func__, total_size); + TABLE_LPM_LOG(ERR, "Cannot allocate %u bytes for LPM table", + total_size); return NULL; } @@ -107,7 +108,7 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size) if (lpm->lpm == NULL) { rte_free(lpm); - RTE_LOG(ERR, TABLE, "Unable to create low-level LPM table\n"); + TABLE_LPM_LOG(ERR, "Unable to create low-level LPM table"); return NULL; } @@ -127,7 +128,7 @@ rte_table_lpm_free(void *table) /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -187,22 +188,20 @@ rte_table_lpm_entry_add( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 32)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", - __func__, ip_prefix->depth); + TABLE_LPM_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -216,7 +215,7 @@ rte_table_lpm_entry_add( uint8_t *nht_entry; if (nht_find_free(lpm, &nht_pos) == 0) { - RTE_LOG(ERR, TABLE, "%s: NHT full\n", __func__); + TABLE_LPM_LOG(ERR, "NHT full"); return -1; } @@ -226,7 +225,7 @@ rte_table_lpm_entry_add( /* Add rule to low level LPM table */ if (rte_lpm_add(lpm->lpm, ip_prefix->ip, ip_prefix->depth, nht_pos) < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM rule add failed\n", __func__); + TABLE_LPM_LOG(ERR, "LPM rule add failed"); return -1; } @@ -253,16 +252,15 @@ rte_table_lpm_entry_delete( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 32)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__, + TABLE_LPM_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -271,7 +269,7 @@ rte_table_lpm_entry_delete( status = rte_lpm_is_rule_present(lpm->lpm, ip_prefix->ip, ip_prefix->depth, &nht_pos); if (status < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM algorithmic error\n", __func__); + TABLE_LPM_LOG(ERR, "LPM algorithmic error"); return -1; } if (status == 0) { @@ -282,7 +280,7 @@ rte_table_lpm_entry_delete( /* Delete rule from the low-level LPM table */ status = rte_lpm_delete(lpm->lpm, ip_prefix->ip, ip_prefix->depth); if (status) { - RTE_LOG(ERR, TABLE, "%s: LPM rule delete failed\n", __func__); + TABLE_LPM_LOG(ERR, "LPM rule delete failed"); return -1; } diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c index 8fde2c012f7c..9f87832ca8f0 100644 --- a/lib/table/rte_table_lpm_ipv6.c +++ b/lib/table/rte_table_lpm_ipv6.c @@ -12,6 +12,11 @@ #include "rte_table_lpm_ipv6.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_lpm6, lpm6, INFO); +#define TABLE_LPM6_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_lpm6, \ + "%s(): " fmt "\n", __func__, ##args) + #define RTE_TABLE_LPM_MAX_NEXT_HOPS 256 #ifdef RTE_TABLE_STATS_COLLECT @@ -56,30 +61,27 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size) /* Check input parameters */ if (p == NULL) { - RTE_LOG(ERR, TABLE, "%s: NULL input parameters\n", __func__); + TABLE_LPM6_LOG(ERR, "NULL input parameters"); return NULL; } if (p->n_rules == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__); + TABLE_LPM6_LOG(ERR, "Invalid n_rules"); return NULL; } if (p->number_tbl8s == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid n_rules\n", __func__); + TABLE_LPM6_LOG(ERR, "Invalid n_rules"); return NULL; } if (p->entry_unique_size == 0) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM6_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->entry_unique_size > entry_size) { - RTE_LOG(ERR, TABLE, "%s: Invalid entry_unique_size\n", - __func__); + TABLE_LPM6_LOG(ERR, "Invalid entry_unique_size"); return NULL; } if (p->name == NULL) { - RTE_LOG(ERR, TABLE, "%s: Table name is NULL\n", - __func__); + TABLE_LPM6_LOG(ERR, "Table name is NULL"); return NULL; } entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t)); @@ -90,9 +92,8 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size) lpm = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id); if (lpm == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for LPM IPv6 table\n", - __func__, total_size); + TABLE_LPM6_LOG(ERR, "Cannot allocate %u bytes for LPM IPv6 table", + total_size); return NULL; } @@ -103,8 +104,7 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size) lpm->lpm = rte_lpm6_create(p->name, socket_id, &lpm6_config); if (lpm->lpm == NULL) { rte_free(lpm); - RTE_LOG(ERR, TABLE, - "Unable to create low-level LPM IPv6 table\n"); + TABLE_LPM6_LOG(ERR, "Unable to create low-level LPM IPv6 table\n"); return NULL; } @@ -124,7 +124,7 @@ rte_table_lpm_ipv6_free(void *table) /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "table parameter is NULL"); return -EINVAL; } @@ -184,21 +184,20 @@ rte_table_lpm_ipv6_entry_add( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM6_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if (entry == NULL) { - RTE_LOG(ERR, TABLE, "%s: entry parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "entry parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 128)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__, + TABLE_LPM6_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -213,7 +212,7 @@ rte_table_lpm_ipv6_entry_add( uint8_t *nht_entry; if (nht_find_free(lpm, &nht_pos) == 0) { - RTE_LOG(ERR, TABLE, "%s: NHT full\n", __func__); + TABLE_LPM6_LOG(ERR, "NHT full"); return -1; } @@ -224,7 +223,7 @@ rte_table_lpm_ipv6_entry_add( /* Add rule to low level LPM table */ if (rte_lpm6_add(lpm->lpm, ip_prefix->ip, ip_prefix->depth, nht_pos) < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM IPv6 rule add failed\n", __func__); + TABLE_LPM6_LOG(ERR, "LPM IPv6 rule add failed"); return -1; } @@ -252,16 +251,15 @@ rte_table_lpm_ipv6_entry_delete( /* Check input parameters */ if (lpm == NULL) { - RTE_LOG(ERR, TABLE, "%s: table parameter is NULL\n", __func__); + TABLE_LPM6_LOG(ERR, "table parameter is NULL"); return -EINVAL; } if (ip_prefix == NULL) { - RTE_LOG(ERR, TABLE, "%s: ip_prefix parameter is NULL\n", - __func__); + TABLE_LPM6_LOG(ERR, "ip_prefix parameter is NULL"); return -EINVAL; } if ((ip_prefix->depth == 0) || (ip_prefix->depth > 128)) { - RTE_LOG(ERR, TABLE, "%s: invalid depth (%d)\n", __func__, + TABLE_LPM6_LOG(ERR, "invalid depth (%d)", ip_prefix->depth); return -EINVAL; } @@ -270,8 +268,7 @@ rte_table_lpm_ipv6_entry_delete( status = rte_lpm6_is_rule_present(lpm->lpm, ip_prefix->ip, ip_prefix->depth, &nht_pos); if (status < 0) { - RTE_LOG(ERR, TABLE, "%s: LPM IPv6 algorithmic error\n", - __func__); + TABLE_LPM6_LOG(ERR, "LPM IPv6 algorithmic error"); return -1; } if (status == 0) { @@ -282,8 +279,7 @@ rte_table_lpm_ipv6_entry_delete( /* Delete rule from the low-level LPM table */ status = rte_lpm6_delete(lpm->lpm, ip_prefix->ip, ip_prefix->depth); if (status) { - RTE_LOG(ERR, TABLE, "%s: LPM IPv6 rule delete failed\n", - __func__); + TABLE_LPM6_LOG(ERR, "LPM IPv6 rule delete failed"); return -1; } diff --git a/lib/table/rte_table_stub.c b/lib/table/rte_table_stub.c index 23d0de5c79b0..6ea978adfe80 100644 --- a/lib/table/rte_table_stub.c +++ b/lib/table/rte_table_stub.c @@ -8,6 +8,11 @@ #include "rte_table_stub.h" +RTE_LOG_REGISTER_SUFFIX(table_logtype_stub, stub, INFO); +#define TABLE_STUB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, table_logtype_stub, \ + "%s(): " fmt "\n", __func__, ##args) + #ifdef RTE_TABLE_STATS_COLLECT #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \ @@ -38,9 +43,7 @@ rte_table_stub_create(__rte_unused void *params, stub = rte_zmalloc_socket("TABLE", size, RTE_CACHE_LINE_SIZE, socket_id); if (stub == NULL) { - RTE_LOG(ERR, TABLE, - "%s: Cannot allocate %u bytes for stub table\n", - __func__, size); + TABLE_STUB_LOG(ERR, "Cannot allocate %u bytes for stub table", size); return NULL; } -- 2.39.1