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 C0AD341C34; Wed, 8 Feb 2023 00:06:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DD2642D5F; Wed, 8 Feb 2023 00:05:20 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id B2C1942D56 for ; Wed, 8 Feb 2023 00:05:17 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id ge21-20020a17090b0e1500b002308aac5b5eso345711pjb.4 for ; Tue, 07 Feb 2023 15:05:17 -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=sRgNBZMQXOSp5I+WWgSeo5hk292AWpiZs5bMgRaDRrvb+NuWpSIiXdlyJDKxdcvFeH hgn47fSoH1t0ECn5LpD4Bgkmz8fv2+BxQZFkTALw10Qc8CgDzv0vOZXsUESOeYhx8nWP OSAk98SVEzRkdLIiMMRvpOTNErtxf1m4wQuWcoXNV96v3riB9ra2ONEv4COnK+ngdHwV oONm+2/2Gp+XlxIowQNrc9aLXDe1v6TPLPO/fU6O9OLpUfeNS19Tu7vVcDgoGKdwvVgG eTqqHQncFAY0dVDADCcg+1TJ3xAu1zc3Drx+seRz8oQXjZDXpuGWf1kaQSRyBkcjPx/I TBIQ== 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=V5eaVx0NyfupuIIhTe4W0muPouS39x5Ar7Qkv8CpJE7ukou+Jcb6KFV+hs5Zf0Dga5 raA/S4pYZNPIpqiTeY9jcpYjiUGJ/RLJnxxO3yANa8OEUPTiX5tTcIgvdyKPLv2KM1L4 aINXPaBjeErRjyo63ZQaNbMTMkvPkZd2lkHhzfAgjY8Egdy/XNAC7I1vEOCPOT1x7TAq pnGToJVS1iMuf0e8cRz00lpwqztB1u9Al5vuZLJNLw/XllEs92rLtcfXXj5bhfH8mkNP nggxJCqKo5rwH7ft9ei/RAFzAbHHLiHU/2Ww4kJCMGaKbW8p0gF/KcKCxNNu8CEwg8O2 1UAA== X-Gm-Message-State: AO0yUKVoLRIZJicRcoBXnF0RC6rfqawVKHEu4tCKhFBtdT1SoA20qxBL KOb/GO8x6aRASKJyA7LEmXL/QiJ/34+CnxzX5V4= X-Google-Smtp-Source: AK7set+aES/601rvoOIJjnhqIjpN0OEAFaMDoc+rP+vjKz4KH+gJ7CfaTnzPaF+RBY6uOUW2bbR0mg== X-Received: by 2002:a17:90a:313:b0:230:c87e:2b2d with SMTP id 19-20020a17090a031300b00230c87e2b2dmr5639302pje.40.1675811116614; Tue, 07 Feb 2023 15:05:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [RFC v2 11/17] ring: replace RTE_LOGTYPE_RING with dynamic type Date: Tue, 7 Feb 2023 15:04:32 -0800 Message-Id: <20230207230438.1617331-12-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 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