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 3B99941C33; Tue, 7 Feb 2023 21:45:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA54D42D31; Tue, 7 Feb 2023 21:44:45 +0100 (CET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 35C4D42D1A for ; Tue, 7 Feb 2023 21:44:43 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id b5so16977893plz.5 for ; Tue, 07 Feb 2023 12:44:43 -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=Q1DWXsNg2wR34huU9WgzcuO50V8Pk290vp1Vq5MnbDXllEzf4m84Lsu8qHQ/lvD9Mh J/AveCwFvus5J2VS1RDc18R9fMaKXFZoLA7HYLNgW9YW+bB6N4zkxuWGGItLY3UwgbTL lTnV8CJERVq4Vvsw6P7LxG0H4jWLy+rjzYSRZ/O2Odu6bslSl8GeoV5UIIReFyGdtor/ 1pPV5UCjGamQfkqPvmIj9eVxp8WV+/AtZqQ1mtffmqtymKuNGovhrC0LzuPV2lREQXv4 rSZkMRV/f9hkwUgQ6ikAlwOo+T6dBZOwN8+fvOmPIM4HHoWNxI7xd8dyliDkrLeNQsZw LPfQ== 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=QCrq0Vqu1HLo9Xiy8YyTA3U82Wa/iKXrp8OEVImXPuLrY0TA3IJJ9VhWsgMfoLR8+r +yPUA1LCMtJ5pO6qZY9Gh9tymaDZTARhTyHNAEoSSigsfUJAxWanrYT5OUV5FVwvKB1J jFVxkjsjNp5TCEurhhdcv0XAN0tdLOsCa7W4P67toaqom0maXHiEALDLXw6vH1MgGJAO U8JpmWMet+s8XuSLePB/7q3JgmkPeu64jG7Tb0GCGp7s+4G9WMIt0G2hITk3V4Pthp/g OLq0NunmQemTbXEwqUX4w3HpDHNNafXyTLagKSnDKLd25x42oztoQ+Yp+ObyNBYzWSXq fHEA== X-Gm-Message-State: AO0yUKVaqmOze0AmI+6rTPxZ2QiLErQV6PpOq7CfjQGHLqzfwVRttUao QD3jzZcToIZIzjRUNlH7pycXDftZOck4BNqta3I= X-Google-Smtp-Source: AK7set8b+nkAboMTaohJwElCimzZm4JoKswWP5NPPgXVf3el9fDB3dqjt057DEnJc28ZbSWwz34m1w== X-Received: by 2002:a17:902:ecc4:b0:198:fef5:dcf1 with SMTP id a4-20020a170902ecc400b00198fef5dcf1mr5258487plh.26.1675802682197; Tue, 07 Feb 2023 12:44:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 12:44:41 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [RFC 08/13] ring: replace RTE_LOGTYPE_RING with dynamic type Date: Tue, 7 Feb 2023 12:41:46 -0800 Message-Id: <20230207204151.1503491-9-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 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