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 8D12241C58; Fri, 10 Feb 2023 02:08:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C36442D32; Fri, 10 Feb 2023 02:08:15 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 4726142BC9 for ; Fri, 10 Feb 2023 02:08:10 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id mi9so3717038pjb.4 for ; Thu, 09 Feb 2023 17:08:10 -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=TGI+362xtBNoVKpNbOlux/TIyZ9au9Qd1CJOZexwK04=; b=MVB1ny/eBuG0kTLB38PU7gYex/gj53ulFRuTKhjloOXHSLtjoTy6PVDqtP/qQEpgMD ADIb4DUmM7jVvrmnj/QXWo/NX6kgOVzHGv6RPfaMyZIYQSE7P2v0/JQZXjlqyExIkeiD ai7Tj55MU+ocWm3JK43YSA4lvs6UEs439XtFSU0ge01wxEd8ZT+uYIfx2lkFwknczXNx mnHdPa9YeQuwLddxc4LL2LZn5qvLGlDZtElMDiTTP66SA6rbhkqTc6MLWfVjE7RoC9dC qFmCkPNQpiy4zJ9NavKUHshDcHbIPOhJzinMNAen1ByUutnQIzFLMa1vC+rj7vWTcAKq 9P3A== 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=TGI+362xtBNoVKpNbOlux/TIyZ9au9Qd1CJOZexwK04=; b=K2/6WBwMC1dz/wa6sT3OIT/H3d28l1gtRmhHg+ZtglZqS81eFA555+Opt1Luo47zDu AYV13BscD1e2RMrfbnogylSUyGeZtcFBSGOlxnO6uBiI79TZBN4Wxm6jL6YXv6paIYwT e9l/NBh1hI5xebF4djLfvlAiES7IsSYXu+e12UvJxqYzjIM8C17NUIfCYKlZfJDGRV+B vXJV4pz2j5+KIUvfEoGSZvFIJ4NctH9FtrdqOOiH1dH6+SgGEaIK32kQIMNzzjroUwe6 EuriRa5OzYNFzMfsNffNCJz7wwgrZipvSh/klAVCKw3M5OUoa+c+kqzCflfogeVub31W gBRg== X-Gm-Message-State: AO0yUKVpV7B919bBcGjDI0IQs48hr7m++g+i4kHHO0Sg46WL8p+PLjLh HLpvKfP9zGpKN20OJmmbGG7X5tLTsvBY0G04N+k= X-Google-Smtp-Source: AK7set8KIMlrQh4z667t+qg0ESX2H8URtn+ZI8g//vnX3oG/PdKY0GGW1fj59kS/aDnMVdSky7Jjhg== X-Received: by 2002:a17:902:ec90:b0:198:dae9:5f58 with SMTP id x16-20020a170902ec9000b00198dae95f58mr7997508plg.14.1675991289350; Thu, 09 Feb 2023 17:08:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH v3 07/16] ring: replace RTE_LOGTYPE_RING with dynamic type Date: Thu, 9 Feb 2023 17:07:15 -0800 Message-Id: <20230210010724.890413-8-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 The logtype for ring only used in library. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/ring/rte_ring.c | 31 +++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 7dbf1df3b979..04c9d43351da 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,7 +349,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 5b7850af4e2b..a99fe383c89b 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -28,7 +28,7 @@ extern "C" { /* SDK log type */ #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ /* was RTE_LOGTYPE_MALLOC */ -#define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ + /* was RTE_LOGTYPE_RING */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index cddaf6b2876f..1b4633468a2a 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -26,6 +26,13 @@ #include "rte_ring.h" #include "rte_ring_elem.h" +RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO); + +#define RING_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ring_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + + TAILQ_HEAD(rte_ring_list, rte_tailq_entry); static struct rte_tailq_elem rte_ring_tailq = { @@ -52,15 +59,15 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count) /* Check if element size is a multiple of 4B */ if (esize % 4 != 0) { - RTE_LOG(ERR, RING, "element size is not a multiple of 4\n"); + RING_LOG(ERR, "element size is not a multiple of 4"); return -EINVAL; } /* count must be a power of 2 */ if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK )) { - RTE_LOG(ERR, RING, - "Requested number of elements is invalid, must be power of 2, and not exceed %u\n", + RING_LOG(ERR, + "Requested number of elements is invalid, must be power of 2, and not exceed %u", RTE_RING_SZ_MASK); return -EINVAL; @@ -195,8 +202,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, /* future proof flags, only allow supported values */ if (flags & ~RING_F_MASK) { - RTE_LOG(ERR, RING, - "Unsupported flags requested %#x\n", flags); + RING_LOG(ERR, + "Unsupported flags requested %#x", flags); return -EINVAL; } @@ -216,8 +223,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, r->capacity = count; } else { if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) { - RTE_LOG(ERR, RING, - "Requested size is invalid, must be power of 2, and not exceed the size limit %u\n", + RING_LOG(ERR, + "Requested size is invalid, must be power of 2, and not exceed the size limit %u", RTE_RING_SZ_MASK); return -EINVAL; } @@ -271,7 +278,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n"); + RING_LOG(ERR, "Cannot reserve memory for tailq"); rte_errno = ENOMEM; return NULL; } @@ -295,7 +302,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, TAILQ_INSERT_TAIL(ring_list, te, next); } else { r = NULL; - RTE_LOG(ERR, RING, "Cannot reserve memory\n"); + RING_LOG(ERR, "Cannot reserve memory"); rte_free(te); } rte_mcfg_tailq_write_unlock(); @@ -327,13 +334,13 @@ rte_ring_free(struct rte_ring *r) * therefore, there is no memzone to free. */ if (r->memzone == NULL) { - RTE_LOG(ERR, RING, - "Cannot free ring, not created with rte_ring_create()\n"); + RING_LOG(ERR, + "Cannot free ring, not created with rte_ring_create()"); return; } if (rte_memzone_free(r->memzone) != 0) { - RTE_LOG(ERR, RING, "Cannot free memory\n"); + RING_LOG(ERR, "Cannot free memory"); return; } -- 2.39.1