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 D906741C34; Wed, 8 Feb 2023 00:05:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3924F42D3E; Wed, 8 Feb 2023 00:05:15 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 35C7E42D39 for ; Wed, 8 Feb 2023 00:05:13 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id c10-20020a17090a1d0a00b0022e63a94799so372038pjd.2 for ; Tue, 07 Feb 2023 15:05:13 -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=qvwzapTcuZqBaC2c59y5lWyW/p7KpRhoxl1W09jOILgBQMky5PQ+IderW/RGMJz7QN hNH2NQ7XOTb0hdrL1wEAEwjLnKDhv+gZJyAiqwMOUrQNb4UkaD1jn/A6TIcOnvy00LjN rurWW8puYFeeLdkd0rlLbsatTfHDijdtjiEV61EREZjaKLVwLzrj200pHKJ2K+rjSYJ1 Xv8DLvcmkUi5VcfNOm/lwTEdiEzPq67PupAL3NLM9wMrAayLmNR7yyiGRJHkm6HCUwRT NtnpGB3NHuGODWCOo8LgqEBclMKPMde6llI2rBwwsp3f39QHctzuRlACHWoUoj75Q580 iR+A== 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=nG6tJ3eG/kOJ6on3YihM7wvdlQgAOrqI+bpVLDdr+KeioR0AgxIDOnAPe/sOywV0uR c75G05k5s6X/I6BXQakJehBCXnfSY8BYEGTppcfDrbXc1kR5jztcUn0Bp6wY446Z57XV 6Ayqf1xDOqtkkRZZyJfL3P7PHCMf76N31apC2L6v79LNnl4mw++NUQpzmQawDa+E/Ao5 rKHdLQY64OjC5twtqjvxo70/atBj75zZNfBjV4ClgrUo2nkST/17ZtU5qfxsxNyV2i2N RviZRh/39bWwjS46Xl75wuXWHRkvt2DWZE6oiJa81pYkMMRlqFfZeq1J3OHfTHqq50Lx JBzw== X-Gm-Message-State: AO0yUKW2D0ugmHIrN7f/0tBxqtr6pSFfD4BI9xULTXx7kxqgenvAMJPY kJ0EIUdNLRGK2zcRku8lZg4zGcsRdgCCo9SVzdA= X-Google-Smtp-Source: AK7set9dEZ39NxY0Cu+n8kqjXMI4REE3Vnj40fzCcaAH9neG33SV8ZDA3Thf0cksmZrFtT48/AIbew== X-Received: by 2002:a17:90b:1a8c:b0:22c:9078:178 with SMTP id ng12-20020a17090b1a8c00b0022c90780178mr5899977pjb.27.1675811112075; Tue, 07 Feb 2023 15:05:12 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:11 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Byron Marohn , Yipeng Wang Subject: [RFC v2 07/17] efd: replace RTE_LOGTYPE_EFD with local type Date: Tue, 7 Feb 2023 15:04:28 -0800 Message-Id: <20230207230438.1617331-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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