From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id 1AC35C39C for ; Mon, 3 Aug 2015 05:12:54 +0200 (CEST) Received: by pasy3 with SMTP id y3so3179467pas.2 for ; Sun, 02 Aug 2015 20:12:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=I6mUjAKMqxOkENxfsnCeOm9/ODG5YkVVDdwYFe3+rKU=; b=SpBULcugVNH/vjo1Y2XFa3ekGtgW+MmGpT+JT6GCme6YBo4Rko2L9oe9PWCkugpqnl gNdq3d2gHlMsWg2ScxsvcfAaz8KLiZJED6cfEFARIVB/pyMH3ZtEiu6ZqI4BDBuYQAgz CEMJfd6kvVQ6VOS13Koc7miY6/k1DapRBNxRmIUiSOmViOSEAXugFcdrklc9ju0xAHcQ qV+dAFrObQcUrddvZ8idzyUDshoOXGcW8QTGBGc6bc1GZqECXnhYTRPpDZEKhzBu55eR qimQrPSv81pGxgikIK/7EliF3fSZPBBobUFosKS+eydanvr1qSyKn7hVmETHvrg7Ga1J kWHQ== X-Gm-Message-State: ALoCoQl+D8HeWQVMZ3R885peTIZs18ydERUYfkf6Sxex4yyDXnjxWho/DUMOblk3fQ+Hxr0pF7sS X-Received: by 10.66.163.201 with SMTP id yk9mr30667074pab.63.1438571573319; Sun, 02 Aug 2015 20:12:53 -0700 (PDT) Received: from urahara (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ud2sm6016314pbc.57.2015.08.02.20.12.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Aug 2015 20:12:53 -0700 (PDT) Date: Sun, 2 Aug 2015 20:13:03 -0700 From: Stephen Hemminger To: Keith Wiles Message-ID: <20150802201303.7d67502c@urahara> In-Reply-To: <1438551624-14127-1-git-send-email-keith.wiles@intel.com> References: <1433635446-78275-2-git-send-email-keith.wiles@intel.com> <1438551624-14127-1-git-send-email-keith.wiles@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] log:Change magic number on RTE_LOG_LEVEL to an enum name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 03:12:54 -0000 On Sun, 2 Aug 2015 16:40:24 -0500 Keith Wiles wrote: > Config files used RTE_LOG_LEVEL=8 to set log level to DEBUG. Using > a the RTE_LOG_XXXX is easier to maintain. > > Converted the RTE_LOG_XXXX define into a enum of values with > the same names to reduce maintaining the define values. > > The change is to use an enum in place of a magic number, plus > we get the benefit of seeing the enum name in the debugger > instead of a number. > > The rte_logs was set after options parsing, defaulting to > RTE_LOG_LEVEL, and it is now initialized at RTE_LOG_LEVEL > without behavioral change. > > Signed-off-by: Keith Wiles > --- > config/common_bsdapp | 6 ++++-- > config/common_linuxapp | 6 ++++-- > lib/librte_eal/common/eal_common_log.c | 4 ++-- > lib/librte_eal/common/include/rte_log.h | 18 ++++++++++-------- > 4 files changed, 20 insertions(+), 14 deletions(-) > > diff --git a/config/common_bsdapp b/config/common_bsdapp > index 2c6eb40..b2e9462 100644 > --- a/config/common_bsdapp > +++ b/config/common_bsdapp > @@ -102,12 +102,14 @@ CONFIG_RTE_MAX_NUMA_NODES=8 > CONFIG_RTE_MAX_MEMSEG=256 > CONFIG_RTE_MAX_MEMZONE=2560 > CONFIG_RTE_MAX_TAILQ=32 > -CONFIG_RTE_LOG_LEVEL=8 > -CONFIG_RTE_LOG_HISTORY=256 > CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n > CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n > CONFIG_RTE_MALLOC_DEBUG=n > > +# RTE_LOG_XXX = DEBUG, INFO, NOTICE, WARNING or ERR > +CONFIG_RTE_LOG_LEVEL=RTE_LOG_DEBUG > +CONFIG_RTE_LOG_HISTORY=256 > + > # > # FreeBSD contiguous memory driver settings > # > diff --git a/config/common_linuxapp b/config/common_linuxapp > index bda9a63..eb0f659 100644 > --- a/config/common_linuxapp > +++ b/config/common_linuxapp > @@ -102,8 +102,6 @@ CONFIG_RTE_MAX_NUMA_NODES=8 > CONFIG_RTE_MAX_MEMSEG=256 > CONFIG_RTE_MAX_MEMZONE=2560 > CONFIG_RTE_MAX_TAILQ=32 > -CONFIG_RTE_LOG_LEVEL=8 > -CONFIG_RTE_LOG_HISTORY=256 > CONFIG_RTE_LIBEAL_USE_HPET=n > CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n > CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n > @@ -111,6 +109,10 @@ CONFIG_RTE_EAL_IGB_UIO=y > CONFIG_RTE_EAL_VFIO=y > CONFIG_RTE_MALLOC_DEBUG=n > > +# RTE_LOG_XXX = DEBUG, INFO, NOTICE, WARNING or ERR > +CONFIG_RTE_LOG_LEVEL=RTE_LOG_DEBUG > +CONFIG_RTE_LOG_HISTORY=256 > + > # > # Special configurations in PCI Config Space for high performance > # > diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c > index 1ae8de7..6ed6743 100644 > --- a/lib/librte_eal/common/eal_common_log.c > +++ b/lib/librte_eal/common/eal_common_log.c > @@ -82,7 +82,7 @@ static struct log_history_list log_history; > /* global log structure */ > struct rte_logs rte_logs = { > .type = ~0, > - .level = RTE_LOG_DEBUG, > + .level = RTE_LOG_LEVEL, > .file = NULL, > }; > > @@ -93,7 +93,7 @@ static int history_enabled = 1; > > /** > * This global structure stores some informations about the message > - * that is currently beeing processed by one lcore > + * that is currently being processed by one lcore > */ > struct log_cur_msg { > uint32_t loglevel; /**< log level - see rte_log.h */ > diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h > index 24a55cc..be75a45 100644 > --- a/lib/librte_eal/common/include/rte_log.h > +++ b/lib/librte_eal/common/include/rte_log.h > @@ -89,14 +89,16 @@ extern struct rte_logs rte_logs; > #define RTE_LOGTYPE_USER8 0x80000000 /**< User-defined log type 8. */ > > /* Can't use 0, as it gives compiler warnings */ > -#define RTE_LOG_EMERG 1U /**< System is unusable. */ > -#define RTE_LOG_ALERT 2U /**< Action must be taken immediately. */ > -#define RTE_LOG_CRIT 3U /**< Critical conditions. */ > -#define RTE_LOG_ERR 4U /**< Error conditions. */ > -#define RTE_LOG_WARNING 5U /**< Warning conditions. */ > -#define RTE_LOG_NOTICE 6U /**< Normal but significant condition. */ > -#define RTE_LOG_INFO 7U /**< Informational. */ > -#define RTE_LOG_DEBUG 8U /**< Debug-level messages. */ > +enum { > + RTE_LOG_EMERG=1, /**< System is unusable. */ > + RTE_LOG_ALERT, /**< Action must be taken immediately. */ > + RTE_LOG_CRIT, /**< Critical conditions. */ > + RTE_LOG_ERR, /**< Error conditions. */ > + RTE_LOG_WARNING, /**< Warning conditions. */ > + RTE_LOG_NOTICE, /**< Normal but significant condition. */ > + RTE_LOG_INFO, /**< Informational. */ > + RTE_LOG_DEBUG /**< Debug-level messages. */ > +}; > This is technically a source API change. There are cases where you could break build of existing code that was expecting #define's (but I doubt anyone would notice0.