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 CC7D541C33; Tue, 7 Feb 2023 21:44:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3837942BD9; Tue, 7 Feb 2023 21:44:41 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 1FB80410F6 for ; Tue, 7 Feb 2023 21:44:39 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id h15so9598697plk.12 for ; Tue, 07 Feb 2023 12:44:39 -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=XC9Z/WZcbYJRMRfGGnRbWvLq8XyY7AHTqG0rf0Z88tw=; b=YxA+EexxueVSTiypwd1dxyBZtT85ZWr8BYhSOcUPYwKrMECVkC69+UvLmG01A6ZRXm SUsaLtPDZ6DiHPnPSD4/+02SbLCWE44CxGpY7M/hhde6aa1ZHJctoamGBY0nxGI4G+Xv xutw4cwGWdXQOxO/dPTILgQ5hV8hc3HRpL14dLieFBXVUEVT/fkQeBiM1UWhrjpK2EPY e9Ch17AZvukeOnt9JlMaopevnOp1GLI7S4QDGFT/RiNwd6PDk+gLeBXjMHQN+Y3xVQFF 9lrhplAAxSADUd2kNdbRqnO94SBQvvVTW2qWNCs2/NtbBM9BOZh3nAzmlXVQcy9lxa5d H6xw== 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=XC9Z/WZcbYJRMRfGGnRbWvLq8XyY7AHTqG0rf0Z88tw=; b=YxksG4eEgoV709QlN1Ng+vE4VfylspLvB1ZH4ykU2gi2TXlvKkTWXyiZPWDEKZKGul JSVQiE3ebS0ftLcskS21Dhv0JeJtdyOpCPtCMRUp3dBbBwBs0SYXccoeBqeg64/TWMQb fgkcZQ/N+JaJVnrlTMce+G1uxmG/PGQZWvD3wFNC0rSAqj8ufNgNkvHG8kbXRM4MKdOU ASl8lHwNDmJE7Q1VoOWC51kUC7uMW6B3S6t4Y9zSL+hVogYvMaBDIf+7MMcUbuNHW8E6 ea92wcVNAUtJkEp3UywOgNkYjc9L4DnAS+7mEJIU/ExJKivXQ1v8L218dZfnNY0kj/0+ b0nQ== X-Gm-Message-State: AO0yUKUgW0bbxztcuVMM1evpu2Z4f8vtfMIv9g+YDb/WFrg7qOwd5l9M F53RWSU+aEO60Ji5gwZcGmLLp9GflTmjfD1oU+8= X-Google-Smtp-Source: AK7set/rZy5CuRoxat0h/qQTQC/TjTfSiuTcIa/8KRqBz4zaKOZbD4fx9ebKrIBJLAoehCmb5UV6jQ== X-Received: by 2002:a05:6a20:1449:b0:be:b137:9d2d with SMTP id a9-20020a056a20144900b000beb1379d2dmr5441911pzi.58.1675802677925; Tue, 07 Feb 2023 12:44:37 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jk24-20020a170903331800b00194ab9a4febsm4725562plb.74.2023.02.07.12.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 12:44:37 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Byron Marohn , Yipeng Wang Subject: [RFC 04/13] efd: replace RTE_LOGTYPE_EFD with local type Date: Tue, 7 Feb 2023 12:41:42 -0800 Message-Id: <20230207204151.1503491-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207204151.1503491-1-stephen@networkplumber.org> References: <20230207204151.1503491-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 Replace all uses of global logtype with a local log type. Do not break message formats across source lines. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/efd/rte_efd.c | 106 +++++++++++++++----------------- 3 files changed, 52 insertions(+), 57 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index e7ccde1c9ccd..675f3d07bbe3 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_MBUF, "lib.mbuf"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, - {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, {RTE_LOGTYPE_USER1, "user1"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 361d1ad96299..a90fa629168d 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -44,7 +44,7 @@ extern "C" { #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ #define RTE_LOGTYPE_MBUF 16 /**< Log related to mbuf. */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ -#define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */ + /* was RTE_LOGTYPE_EFD */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ /* these log types can be used in an application */ diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c index 686a13775742..23316ef7300f 100644 --- a/lib/efd/rte_efd.c +++ b/lib/efd/rte_efd.c @@ -87,6 +87,11 @@ static struct rte_tailq_elem rte_efd_tailq = { }; EAL_REGISTER_TAILQ(rte_efd_tailq); +RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO); + +#define EFD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args) + /** Internal permutation array used to shuffle bins into pseudorandom groups */ const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = { { @@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); if (online_cpu_socket_bitmask == 0) { - RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled " - "in the bitmask\n"); + EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask"); return NULL; } if (max_num_rules == 0) { - RTE_LOG(ERR, EFD, "Max num rules must be higher than 0\n"); + EFD_LOG(ERR, "Max num rules must be higher than 0"); return NULL; } @@ -554,7 +558,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, te = rte_zmalloc("EFD_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, EFD, "tailq entry allocation failed\n"); + EFD_LOG(ERR, "tailq entry allocation failed"); goto error_unlock_exit; } @@ -564,15 +568,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (table == NULL) { - RTE_LOG(ERR, EFD, "Allocating EFD table management structure" - " on socket %u failed\n", - offline_cpu_socket); + EFD_LOG(ERR, + "Allocating EFD table management structureon socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, "Allocated EFD table management structure " - "on socket %u\n", offline_cpu_socket); + EFD_LOG(DEBUG, "Allocated EFD table management structure on socket %u", + offline_cpu_socket); table->max_num_rules = num_chunks * EFD_TARGET_CHUNK_MAX_NUM_RULES; table->num_rules = 0; @@ -586,17 +590,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (key_array == NULL) { - RTE_LOG(ERR, EFD, "Allocating key array" - " on socket %u failed\n", - offline_cpu_socket); + EFD_LOG(ERR, + "Allocating key array on socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } table->keys = key_array; strlcpy(table->name, name, sizeof(table->name)); - RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks," - " which potentially supports %u entries\n", - num_chunks, table->max_num_rules); + EFD_LOG(DEBUG, + "Creating an EFD table with %u chunks, which potentially supports %u entries", + num_chunks, table->max_num_rules); /* Make sure all the allocatable table pointers are NULL initially */ for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++) @@ -623,19 +627,16 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, socket_id); if (table->chunks[socket_id] == NULL) { - RTE_LOG(ERR, EFD, - "Allocating EFD online table on " - "socket %u failed\n", - socket_id); + EFD_LOG(ERR, + "Allocating EFD online table on socket %u failed", + socket_id); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, - "Allocated EFD online table of size " - "%"PRIu64" bytes (%.2f MB) on socket %u\n", - online_table_size, - (float) online_table_size / - (1024.0F * 1024.0F), - socket_id); + EFD_LOG(DEBUG, + "Allocated EFD online table of size %" PRIu64 " bytes (%.2f MB) on socket %u", + online_table_size, + (float) online_table_size / (1024.0F * 1024.0F), + socket_id); } } @@ -675,16 +676,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (table->offline_chunks == NULL) { - RTE_LOG(ERR, EFD, "Allocating EFD offline table on socket %u " - "failed\n", offline_cpu_socket); + EFD_LOG(ERR, + "Allocating EFD offline table on socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, - "Allocated EFD offline table of size %"PRIu64" bytes " - " (%.2f MB) on socket %u\n", offline_table_size, - (float) offline_table_size / (1024.0F * 1024.0F), - offline_cpu_socket); + EFD_LOG(DEBUG, + "Allocated EFD offline table of size %" PRIu64 " bytes (%.2f MB) on socket %u", + offline_table_size, + (float) offline_table_size / (1024.0F * 1024.0F), + offline_cpu_socket); te->data = (void *) table; TAILQ_INSERT_TAIL(efd_list, te, next); @@ -695,7 +697,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules), offline_cpu_socket, 0); if (r == NULL) { - RTE_LOG(ERR, EFD, "memory allocation failed\n"); + EFD_LOG(ERR, "ring memory allocation failed"); rte_efd_free(table); return NULL; } @@ -1015,20 +1017,17 @@ efd_compute_update(struct rte_efd_table * const table, if (found == 0) { /* Key does not exist. Insert the rule into the bin/group */ if (unlikely(current_group->num_rules >= EFD_MAX_GROUP_NUM_RULES)) { - RTE_LOG(ERR, EFD, - "Fatal: No room remaining for insert into " - "chunk %u group %u bin %u\n", - *chunk_id, - current_group_id, *bin_id); + EFD_LOG(ERR, + "Fatal: No room remaining for insert into chunk %u group %u bin %u", + *chunk_id, current_group_id, *bin_id); return RTE_EFD_UPDATE_FAILED; } if (unlikely(current_group->num_rules == (EFD_MAX_GROUP_NUM_RULES - 1))) { - RTE_LOG(INFO, EFD, "Warn: Insert into last " - "available slot in chunk %u " - "group %u bin %u\n", *chunk_id, - current_group_id, *bin_id); + EFD_LOG(NOTICE, + "Insert into last available slot in chunk %u group %u bin %u", + *chunk_id, current_group_id, *bin_id); status = RTE_EFD_UPDATE_WARN_GROUP_FULL; } @@ -1112,14 +1111,11 @@ efd_compute_update(struct rte_efd_table * const table, uint8_t choice = 0; for (;;) { if (current_group != new_group && - new_group->num_rules + bin_size > - EFD_MAX_GROUP_NUM_RULES) { - RTE_LOG(DEBUG, EFD, - "Unable to move_groups to dest group " - "containing %u entries." - "bin_size:%u choice:%02x\n", - new_group->num_rules, bin_size, - choice - 1); + new_group->num_rules + bin_size > EFD_MAX_GROUP_NUM_RULES) { + EFD_LOG(DEBUG, + "Unable to move_groups to dest group containing %u entries. bin_size:%u choice:%02x", + new_group->num_rules, bin_size, + choice - 1); goto next_choice; } move_groups(*bin_id, bin_size, new_group, current_group); @@ -1132,10 +1128,10 @@ efd_compute_update(struct rte_efd_table * const table, if (!ret) return status; - RTE_LOG(DEBUG, EFD, - "Failed to find perfect hash for group " - "containing %u entries. bin_size:%u choice:%02x\n", - new_group->num_rules, bin_size, choice - 1); + EFD_LOG(DEBUG, + "Failed to find perfect hash for group containing %u entries. bin_size:%u choice:%02x", + new_group->num_rules, bin_size, choice - 1); + /* Restore groups modified to their previous state */ revert_groups(current_group, new_group, bin_size); -- 2.39.1