From patchwork Wed Mar 10 13:28:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88844 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5D1D6A0567; Wed, 10 Mar 2021 14:28:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA0B222A5C4; Wed, 10 Mar 2021 14:28:35 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 01BAD22A5BC for ; Wed, 10 Mar 2021 14:28:34 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 0CE861994; Wed, 10 Mar 2021 08:28:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 10 Mar 2021 08:28:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=23HiqCcRXJCWg GdrKNmzaCXKux7hlgxbKNyRbBYXxgg=; b=j6wjraCjtbUT7T7v5jCqAWMq1EmVH OgJD0zBbPEV3Mgs/k0d9urBEiKDYdPJlciQNcaQ2sITxWmNXlo8lqygcWdg54paO 0YbQqeepukZIOd9Zltmm5cdnYGRUre0u28/G3k97LJ4gw5oQ5mFV4p4FOMmcrLAH 7A3RowHih13o8c0galZ8P80GpspWSV/otmePTWuVxjac8xTPtU2xyOL8VfzRxpP0 RaGPERICQ+MycidNRsZdvAtnlwD97w3PKXpTccJBW5k8uhXntxxMmBz/R4BcLhCi pHgmVJyK2onM1s/oCTfJ6dTWTztrJUUCshmSKEbkeRN3rGUNvk1hWMGZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=23HiqCcRXJCWgGdrKNmzaCXKux7hlgxbKNyRbBYXxgg=; b=rBIKGGmy GfkJCnZokPKOfOuDMAlsvNUXspD6bPqRcCCgE/GzxYjogVxlcA+rw2DgwsdqXQ7w lpL6elva7wwWlPQvRvDZpnOJykeZhylRTWOst+sS9DOrqQbrWhZtI7gRI0L4lksJ dAuBBUwD2aS5L5yF5JwJrIVQ1aCSKcA+ArsFf0jdWRRQ/4I3ucKEXASry6k6IeQg xitlLhFILw3ptJj/Ozvg2RixH+yMKH5kS3M8/50I6ptj1VRd5oa7721rBBt7a9Oy svF8bqmXbdMkKsDzadNKyU6Rsk0t7PBTlXugzKTKo4zp8PfhwSJ+s581pujACgHl WMjOBRdbVNh1PQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpedvhefgiedvjeegtdevhe efhfetleefgfeivefgffevfeejgedtgfeutdehtdegveenucfkphepjeejrddufeegrddv tdefrddukeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 31B22240069; Wed, 10 Mar 2021 08:28:33 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com Date: Wed, 10 Mar 2021 14:28:15 +0100 Message-Id: <20210310132825.2627851-2-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 01/11] eal: explain argv behaviour during init 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 Sender: "dev" After argument parsing done by rte_eal_init(), the remaining arguments are to be parsed by the application by progressing in the argv array. In this context, the first string represented by argv[0] is still the same program name as the original argv[0], while the next strings are the application arguments. This is because rte_eal_init() manipulates the argv array after EAL parsing, before returning to the application. This note was missing in the doxygen comment of the API. Signed-off-by: Thomas Monjalon --- lib/librte_eal/include/rte_eal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/include/rte_eal.h b/lib/librte_eal/include/rte_eal.h index eaf6469e50..0cbeedb594 100644 --- a/lib/librte_eal/include/rte_eal.h +++ b/lib/librte_eal/include/rte_eal.h @@ -76,6 +76,8 @@ int rte_eal_iopl_init(void); * @param argv * An array of strings. The contents of the array, as well as the strings * which are pointed to by the array, may be modified by this function. + * The program name pointer argv[0] is copied into the last parsed argv + * so that argv[0] is still the same after deducing the parsed arguments. * @return * - On success, the number of parsed arguments, which is greater or * equal to zero. After the call to rte_eal_init(), From patchwork Wed Mar 10 13:28:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88845 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 527BEA0567; Wed, 10 Mar 2021 14:28:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0609622A5D3; Wed, 10 Mar 2021 14:28:37 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 521BA22A5DB for ; Wed, 10 Mar 2021 14:28:36 +0100 (CET) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E13715C0158; Wed, 10 Mar 2021 08:28:35 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 10 Mar 2021 08:28:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=zFZQ/OVIs26CT S/5cSETH6uU4SwlQijreQHjhnc3KmM=; b=aK1Fg5hJGkTonH4hIGGyQtgNRUWfS bgrpwXhU+gIV+ar5/nk5dcp++LfR7iCDKFp46KCpa0DdF2vSniayeuQ+U+qOv61O dnVtUHvluDC3NjpGrg3cLHkbKaOkphlP73CkSyLlpk8puJEg4DXIoDgMgg2XYYrS IRy7k4RR4v9/5lXV6x5lF/sXSP+w9vn6B07VITNilKQgQCUzATK527w4k5srkulH 9IHazvmmGWQ9l72qsQTD9+igAQlmfg08kig3iKHJ4nTd/ZgZJLkLsqOreSmIMnTR F98L7tnCLrxSiF9IB9eWYz9c3neyRCF2RVwN7miGVBEIT4Q25UejiMb0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=zFZQ/OVIs26CTS/5cSETH6uU4SwlQijreQHjhnc3KmM=; b=oh4P9vTl NNJ8O1pAdgYjVaGz7e4LXnLvuKRSuEqaKNtSk9POXLAJH34d/k0185WaCAcCmNYp oMT8bMA2hTCEBzsmMjz5nVNjnVOQZ9S3IKtABNQEuiFfvg688/gDIWJVpq5iDbnw QK0mo1wRRU6fdU0qR2SCYnpdkHKnkMUo+5dcsuuF2I9NF3g3+H2631mjCea2U2Bu JsqxHbAGTkB2F8nNFn5l6AzqR4gYhCHCUY1m46UHLxKSu3Qhsp/CHraCiWjwFBz8 e4GC5zX9ohwlhbEbLzliAVs7fWE3GeyYJLOasm9CLXNQb/TMFnsLfjy70tBFXBBi aSMvHg86Cw1ngg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id AED9F24005B; Wed, 10 Mar 2021 08:28:34 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Wed, 10 Mar 2021 14:28:16 +0100 Message-Id: <20210310132825.2627851-3-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 02/11] eal: improve options usage text 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 Sender: "dev" The description of the EAL options was printed before the application description provided via the hook. It is better to let the application print the global syntax and describes the detail of the EAL options below. Also, some useless lines are removed, and the alignment of few options is fixed. Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_options.c | 11 +++++------ lib/librte_eal/freebsd/eal.c | 8 ++++---- lib/librte_eal/linux/eal.c | 12 ++++++------ lib/librte_eal/windows/eal.c | 10 ++++------ 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 622c7bc429..0635b0d4ce 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -2022,8 +2022,7 @@ rte_vect_set_max_simd_bitwidth(uint16_t bitwidth) void eal_common_usage(void) { - printf("[options]\n\n" - "EAL common options:\n" + printf("EAL common options:\n" " -c COREMASK Hexadecimal bitmask of cores to run on\n" " -l CORELIST List of cores to run on\n" " The argument format is [-c2][,c3[-c4],...]\n" @@ -2053,7 +2052,7 @@ eal_common_usage(void) " --"OPT_VDEV" Add a virtual device.\n" " The argument format is [,key=val,...]\n" " (ex: --vdev=net_pcap0,iface=eth2).\n" - " --"OPT_IOVA_MODE" Set IOVA mode. 'pa' for IOVA_PA\n" + " --"OPT_IOVA_MODE" Set IOVA mode. 'pa' for IOVA_PA\n" " 'va' for IOVA_VA\n" " -d LIB.so|DIR Add a driver or driver directory\n" " (can be used multiple times)\n" @@ -2092,11 +2091,11 @@ eal_common_usage(void) #endif /* !RTE_EXEC_ENV_WINDOWS */ " -v Display version information on startup\n" " -h, --help This help\n" - " --"OPT_IN_MEMORY" Operate entirely in memory. This will\n" + " --"OPT_IN_MEMORY" Operate entirely in memory. This will\n" " disable secondary process support\n" " --"OPT_BASE_VIRTADDR" Base virtual address\n" - " --"OPT_TELEMETRY" Enable telemetry support (on by default)\n" - " --"OPT_NO_TELEMETRY" Disable telemetry support\n" + " --"OPT_TELEMETRY" Enable telemetry support (on by default)\n" + " --"OPT_NO_TELEMETRY" Disable telemetry support\n" " --"OPT_FORCE_MAX_SIMD_BITWIDTH" Force the max SIMD bitwidth\n" "\nEAL options for DEBUG use only:\n" " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n" diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index afbbb1c523..f466616566 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -421,13 +421,13 @@ eal_usage(const char *prgname) { rte_usage_hook_t hook = eal_get_application_usage_hook(); - printf("\nUsage: %s ", prgname); - eal_common_usage(); - /* Allow the application to print its usage message too if hook is set */ if (hook) { - printf("===== Application Usage =====\n\n"); + /* Print application usage through EAL options parsing. */ (hook)(prgname); + printf("\n"); } + + eal_common_usage(); } static inline size_t diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index bc966150a5..7c1d296192 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -534,7 +534,12 @@ eal_usage(const char *prgname) { rte_usage_hook_t hook = eal_get_application_usage_hook(); - printf("\nUsage: %s ", prgname); + if (hook) { + /* Print application usage through EAL options parsing. */ + (hook)(prgname); + printf("\n"); + } + eal_common_usage(); printf("EAL Linux options:\n" " --"OPT_SOCKET_MEM" Memory to allocate on sockets (comma separated values)\n" @@ -548,11 +553,6 @@ eal_usage(const char *prgname) " --"OPT_SINGLE_FILE_SEGMENTS" Put all hugepage memory in single files\n" " --"OPT_MATCH_ALLOCATIONS" Free hugepages exactly as allocated\n" "\n"); - /* Allow the application to print its usage message too if hook is set */ - if (hook) { - printf("===== Application Usage =====\n\n"); - (hook)(prgname); - } } static int diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index 2fc3d6141c..ec13ac1a9f 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -79,15 +79,13 @@ eal_usage(const char *prgname) { rte_usage_hook_t hook = eal_get_application_usage_hook(); - printf("\nUsage: %s ", prgname); - eal_common_usage(); - /* Allow the application to print its usage message too - * if hook is set - */ if (hook) { - printf("===== Application Usage =====\n\n"); + /* Print application usage through EAL options parsing. */ (hook)(prgname); + printf("\n"); } + + eal_common_usage(); } /* Parse the arguments for --log-level only */ From patchwork Wed Mar 10 13:28:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88846 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73A54A0567; Wed, 10 Mar 2021 14:28:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ADF4822A5F8; Wed, 10 Mar 2021 14:28:39 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id C307D22A5F4 for ; Wed, 10 Mar 2021 14:28:37 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7520F5C015C; Wed, 10 Mar 2021 08:28:37 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 10 Mar 2021 08:28:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=sCnpyLYjKhZTk Oj9kFjQ0Bmu8o6Hqr4Fi/27SjDdmHY=; b=KaMf9Lknqxw7/d2mLDqKZdGMIw8TO XbwlTD0h30YbrrYpWbvvtBWcIyuhgrkPiyHw5adDp+L9Awws673dpQibUBgz/1Lf AKn+d4/WobQaFAJKeQ2wQ270Im0rQnxSIf22m82010oTbkE/r+zWiQ391Plj/+bI 6KioaD7UWZNoy+74xT1nZWeFd5JUbSCdhdmM+NPFNanR9jLNygS7ksqmSZlmFdo2 /H9TVdxu1JVu38hTwpAw7Kn/YzYm8XeB7eToEhMCqlRdmJA6iTO20VUbpL80O5Uf HPfF7ektnV142gHH9hifwrTgb6H7cdT6YzkV6hliK76XakQElLHlfPq9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=sCnpyLYjKhZTkOj9kFjQ0Bmu8o6Hqr4Fi/27SjDdmHY=; b=rysSLUiZ J3ZSVlLPj+zSP+guBsa9RmLuxlXXy2fanpEUkOVHW39eYm0UMSFeL5xm7GMnrBxq eUyozFFgpz+JUaPWWImgo4zunV1ir0KUlktEwuE/I4rB4XA+3k+PUba9ROZHCCqD qnr/M6Xvhp+ldN9o/zXtmi6mDGZCHGqvnr7Sn6gNFxS9rjmR6K2B0r0ISdUUgwz7 Yq+w97I4X3mSyDNSvgelryDPjPlHWeWi7Yv4HVE3oBhyik7MHN8yyzFcfl5wDBHL BHrKws4dOk7T6i6pOznaG2dqhIvwjlDa9RYcFUS+A8bSvUeRgrZZERb+MgyURb5C sQPvVP0Vm8Uh9Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 7186724005D; Wed, 10 Mar 2021 08:28:36 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Wed, 10 Mar 2021 14:28:17 +0100 Message-Id: <20210310132825.2627851-4-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 03/11] eal: use macros for help option 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 Sender: "dev" The macros OPT_HELP and OPT_HELP_NUM were not used where appropriate. Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/freebsd/eal.c | 2 +- lib/librte_eal/linux/eal.c | 2 +- lib/librte_eal/windows/eal.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 0635b0d4ce..52fedb81e5 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -2090,7 +2090,7 @@ eal_common_usage(void) " must be specified once only.\n" #endif /* !RTE_EXEC_ENV_WINDOWS */ " -v Display version information on startup\n" - " -h, --help This help\n" + " -h, --"OPT_HELP" This help\n" " --"OPT_IN_MEMORY" Operate entirely in memory. This will\n" " disable secondary process support\n" " --"OPT_BASE_VIRTADDR" Base virtual address\n" diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index f466616566..66adfca2d1 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -549,7 +549,7 @@ eal_parse_args(int argc, char **argv) } break; } - case 'h': + case OPT_HELP_NUM: eal_usage(prgname); exit(EXIT_SUCCESS); default: diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 7c1d296192..6f73616f86 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -716,7 +716,7 @@ eal_parse_args(int argc, char **argv) continue; switch (opt) { - case 'h': + case OPT_HELP_NUM: eal_usage(prgname); exit(EXIT_SUCCESS); diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index ec13ac1a9f..4dd2fc1403 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -158,7 +158,7 @@ eal_parse_args(int argc, char **argv) continue; switch (opt) { - case 'h': + case OPT_HELP_NUM: eal_usage(prgname); exit(EXIT_SUCCESS); default: From patchwork Wed Mar 10 13:28:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88847 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F32E7A0567; Wed, 10 Mar 2021 14:29:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E542C22A600; Wed, 10 Mar 2021 14:28:40 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 6D90422A601 for ; Wed, 10 Mar 2021 14:28:39 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id EC0065C0042; Wed, 10 Mar 2021 08:28:38 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 10 Mar 2021 08:28:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=gZH5x9nDmVaf+ Nrm/zQm/CMN3mzLXAVD3BQRBWBVJY8=; b=EHBi/5nnzqN6GfjSFfioq6WoAh6Ea i6Gp/v0H/XC2Fej09UGQuKHgjR/wVn1Sy1OsrZMMHio+uPFO7sJwXKKUGrX+Dj2J jJeRxWIWFUrXuL8GApFVjYwXhMQDW0xw055Qq3jgrFRQ7gWP0vhopb5Y4acTwFlm CjjWESXtZFNUxg3oJn4e6W4gSQ56sGqwMEHsU+Tf0CsTJd5QOR8GH9S6kfyuqehG u34jE5qx+bZe2TfsYH70mqtQB9InD6q9tLuW4jsISio5pomXzxKCAHowOdwzL/QH /uIuGB84UGpwYbEHvWJpNwnqZGgAUbxID5xXEC08bNiqmO2X1EPqd5hBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=gZH5x9nDmVaf+Nrm/zQm/CMN3mzLXAVD3BQRBWBVJY8=; b=hwyZSlbo 2IwXtoDjh/Z4My+1Ai4Buw+jsDUY7ohrshluHvsTYV+ciMF+1BwHwH93t43CZ7y3 jzJ+sMLJ1Lv9tXU9qDq2e/66+1Tat38oM2RbDbRUY2AS66J8GJXqk2nTepxVI3EO ulJuvLEcoJjPuMBADQpSHh/M+dIluFSldliy3yZqPu37tgAWySemSHS+ZTlAyc4V WXRRw/CPTk7IWd0ii3ws+9fo7KlUfayM2qJ0qDUS+7z3U6WMOmJWH0Wz086uuGB9 9FvGoOwerqf74cv+5miCjMefGZu/sw+Pjce1vNI7uWm7c3IHkzEiYm9ivT9YYPi3 V6AvGUw6CyJcyQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 32055240057; Wed, 10 Mar 2021 08:28:38 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Wed, 10 Mar 2021 14:28:18 +0100 Message-Id: <20210310132825.2627851-5-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 04/11] eal: move private log functions 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 Sender: "dev" Some private log functions had a wrong "rte_" prefix. All private log functions are moved from eal_private.h to the new file eal_log.h: rte_eal_log_init -> eal_log_init rte_log_save_regexp -> eal_log_save_regexp rte_log_save_pattern -> eal_log_save_pattern eal_log_set_default The static functions in the file eal_common_log.c are renamed: rte_log_save_level -> log_save_level rte_log_init -> log_init Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_log.c | 18 ++++++++------ lib/librte_eal/common/eal_common_options.c | 5 ++-- lib/librte_eal/common/eal_log.h | 27 ++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 29 ---------------------- lib/librte_eal/linux/eal.c | 3 ++- lib/librte_eal/linux/eal_log.c | 4 +-- lib/librte_eal/windows/eal.c | 3 ++- lib/librte_eal/windows/eal_log.c | 6 +++-- 8 files changed, 50 insertions(+), 45 deletions(-) create mode 100644 lib/librte_eal/common/eal_log.h diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index c5554badb2..aee7c44c6a 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -15,7 +15,7 @@ #include #include -#include "eal_private.h" +#include "eal_log.h" struct rte_log_dynamic_type { const char *name; @@ -178,8 +178,8 @@ rte_log_set_level_regexp(const char *regex, uint32_t level) * Save the type string and the loglevel for later dynamic * logtypes which may register later. */ -static int rte_log_save_level(int priority, - const char *regex, const char *pattern) +static int +log_save_level(uint32_t priority, const char *regex, const char *pattern) { struct rte_eal_opt_loglevel *opt_ll = NULL; @@ -207,9 +207,10 @@ static int rte_log_save_level(int priority, return -1; } -int rte_log_save_regexp(const char *regex, int tmp) +int +eal_log_save_regexp(const char *regex, uint32_t level) { - return rte_log_save_level(tmp, regex, NULL); + return log_save_level(level, regex, NULL); } /* set log level based on globbing pattern */ @@ -232,9 +233,10 @@ rte_log_set_level_pattern(const char *pattern, uint32_t level) return 0; } -int rte_log_save_pattern(const char *pattern, int priority) +int +eal_log_save_pattern(const char *pattern, uint32_t level) { - return rte_log_save_level(priority, NULL, pattern); + return log_save_level(level, NULL, pattern); } /* get the current loglevel for the message being processed */ @@ -376,7 +378,7 @@ static const struct logtype logtype_strings[] = { }; /* Logging should be first initializer (before drivers and bus) */ -RTE_INIT_PRIO(rte_log_init, LOG) +RTE_INIT_PRIO(log_init, LOG) { uint32_t i; diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 52fedb81e5..02374ee09e 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -41,6 +41,7 @@ #include "eal_options.h" #include "eal_filesystem.h" #include "eal_private.h" +#include "eal_log.h" #ifndef RTE_EXEC_ENV_WINDOWS #include "eal_trace.h" #endif @@ -1299,7 +1300,7 @@ eal_parse_log_level(const char *arg) regex, priority); goto fail; } - if (rte_log_save_regexp(regex, priority) < 0) + if (eal_log_save_regexp(regex, priority) < 0) goto fail; } else if (pattern) { if (rte_log_set_level_pattern(pattern, priority) < 0) { @@ -1307,7 +1308,7 @@ eal_parse_log_level(const char *arg) pattern, priority); goto fail; } - if (rte_log_save_pattern(pattern, priority) < 0) + if (eal_log_save_pattern(pattern, priority) < 0) goto fail; } else { rte_log_set_global_level(priority); diff --git a/lib/librte_eal/common/eal_log.h b/lib/librte_eal/common/eal_log.h new file mode 100644 index 0000000000..684650a17b --- /dev/null +++ b/lib/librte_eal/common/eal_log.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021 Mellanox Technologies, Ltd + */ + +#ifndef EAL_LOG_H +#define EAL_LOG_H + +#include +#include + +/* + * Initialize the default log stream. + */ +int eal_log_init(const char *id, int facility); + +/* + * Determine where log data is written when no call to rte_openlog_stream. + */ +void eal_log_set_default(FILE *default_log); + +/* + * Save a log option for later. + */ +int eal_log_save_regexp(const char *regexp, uint32_t level); +int eal_log_save_pattern(const char *pattern, uint32_t level); + +#endif /* EAL_LOG_H */ diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index b8a0d20021..e3512111d9 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -79,19 +79,6 @@ struct rte_config *rte_eal_get_configuration(void); */ int rte_eal_memzone_init(void); -/** - * Common log initialization function (private to eal). Determines - * where log data is written when no call to rte_openlog_stream is - * in effect. - * - * @param default_log - * The default log stream to be used. - * @return - * - 0 on success - * - Negative on error - */ -void eal_log_set_default(FILE *default_log); - /** * Fill configuration with number of physical and logical processors * @@ -143,22 +130,6 @@ int rte_eal_memory_init(void); */ int rte_eal_timer_init(void); -/** - * Init the default log stream - * - * This function is private to EAL. - * - * @return - * 0 on success, negative on error - */ -int rte_eal_log_init(const char *id, int facility); - -/** - * Save the log regexp for later - */ -int rte_log_save_regexp(const char *type, int priority); -int rte_log_save_pattern(const char *pattern, int priority); - /** * Init tail queues for non-EAL library structures. This is to allow * the rings, mempools, etc. lists to be shared among multiple processes diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 6f73616f86..e4feeb2b0e 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -58,6 +58,7 @@ #include "eal_hugepages.h" #include "eal_memcfg.h" #include "eal_trace.h" +#include "eal_log.h" #include "eal_options.h" #include "eal_vfio.h" #include "hotplug_mp.h" @@ -1160,7 +1161,7 @@ rte_eal_init(int argc, char **argv) #endif } - if (rte_eal_log_init(logid, internal_conf->syslog_facility) < 0) { + if (eal_log_init(logid, internal_conf->syslog_facility) < 0) { rte_eal_init_alert("Cannot init logging."); rte_errno = ENOMEM; __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED); diff --git a/lib/librte_eal/linux/eal_log.c b/lib/librte_eal/linux/eal_log.c index 43c8460bfb..1a08139eb5 100644 --- a/lib/librte_eal/linux/eal_log.c +++ b/lib/librte_eal/linux/eal_log.c @@ -17,7 +17,7 @@ #include #include -#include "eal_private.h" +#include "eal_log.h" /* * default log function @@ -46,7 +46,7 @@ static cookie_io_functions_t console_log_func = { * once memzones are available. */ int -rte_eal_log_init(const char *id, int facility) +eal_log_init(const char *id, int facility) { FILE *log_stream; diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index 4dd2fc1403..5bca3ace1c 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -22,6 +22,7 @@ #include "eal_hugepages.h" #include "eal_trace.h" +#include "eal_log.h" #include "eal_windows.h" #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) @@ -265,7 +266,7 @@ rte_eal_init(int argc, char **argv) eal_get_internal_configuration(); int ret; - rte_eal_log_init(NULL, 0); + eal_log_init(NULL, 0); eal_log_level_parse(argc, argv); diff --git a/lib/librte_eal/windows/eal_log.c b/lib/librte_eal/windows/eal_log.c index 875981f139..d4ea47f1c8 100644 --- a/lib/librte_eal/windows/eal_log.c +++ b/lib/librte_eal/windows/eal_log.c @@ -2,11 +2,13 @@ * Copyright(c) 2017-2018 Intel Corporation */ -#include "eal_private.h" +#include +#include +#include "eal_log.h" /* set the log to default function, called during eal init process. */ int -rte_eal_log_init(__rte_unused const char *id, __rte_unused int facility) +eal_log_init(__rte_unused const char *id, __rte_unused int facility) { rte_openlog_stream(stderr); From patchwork Wed Mar 10 13:28:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88848 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7C6EA0567; Wed, 10 Mar 2021 14:29:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2907E22A60B; Wed, 10 Mar 2021 14:28:42 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 68C6D22A604 for ; Wed, 10 Mar 2021 14:28:41 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 9127519A2; Wed, 10 Mar 2021 08:28:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 10 Mar 2021 08:28:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=qQwRfLaX89EWJ at23WUUmYBR6RuOFLOk5yNMj7jRo0o=; b=1E2piKik9buSabiwRAYe1zR0XuQoV rZICQ1RHCfk9xlGIoqo6PUEeow8DeiKHbx+3uVBZGdHZM1kP/3pIif8FaTRCk9Hs k3YhMv8oTIeOw2GFj/cO8lE0F/vPUg04sbBEJRba6FMiK/ohJKE1RrauH1VVQH5e f6rDWa4IztT2+PMhSb77dTaM2LPAHqBsuj7wXzQfgU9vqC6NHkwJCSkEjxV9dKK6 +op7Ruo9aG6+4Klz9m/A1n+Z0y9mO6CQC7DEdNgr258AcjAsuXiuqdWJe+kDsuxw WhSUm0YGTLH2lIjXiDgmRR7LQVe6wqC6P+mNXHfkHDL3irDJaQ76E9NHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=qQwRfLaX89EWJat23WUUmYBR6RuOFLOk5yNMj7jRo0o=; b=C4KIHdEp gLQGsCJ0i/MUfQySvlJ352AgAPBSk0B8FLv1QfAXDaR8qm1fYkhG23e66K5f/0dj h9cah/8Y7faZuDY74c9fn5MQwW1N/d+3azNSisyBdEeut5q8YA52nOIOYq1+R6fx 0T6uubmusPGH4xHxwdgHVYWhRPbpn+XubferOtR8fGR1+GbSgx1vSSB3P0IxP6jX u3TlKXYE2QFCriZcSSOHgg0x7yVN6RBCYcx22YhJKrLP4AftU+UJEwxf7a+cjgus A7KvFTBobRFBVKfd8LpcRCiEhL02Ai5C9CLByG9Qk3+G8kdBtqgFs+KSVpzlIN4x uIfWpE50g5UL6Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpedvhefgiedvjeegtdevhe efhfetleefgfeivefgffevfeejgedtgfeutdehtdegveenucfkphepjeejrddufeegrddv tdefrddukeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id D0B2524005D; Wed, 10 Mar 2021 08:28:39 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com Date: Wed, 10 Mar 2021 14:28:19 +0100 Message-Id: <20210310132825.2627851-6-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 05/11] eal: introduce maximum log level macro 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 Sender: "dev" RTE_DIM(...) and RTE_LOG_DEBUG were used to get the highest log level. For better clarity a new constant RTE_LOG_MAX is introduced and mapped to RTE_LOG_DEBUG. Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_log.c | 8 ++++---- lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/include/rte_log.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index aee7c44c6a..40cac36f89 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -140,7 +140,7 @@ rte_log_set_level(uint32_t type, uint32_t level) { if (type >= rte_logs.dynamic_types_len) return -1; - if (level > RTE_LOG_DEBUG) + if (level > RTE_LOG_MAX) return -1; rte_logs.dynamic_types[type].loglevel = level; @@ -155,7 +155,7 @@ rte_log_set_level_regexp(const char *regex, uint32_t level) regex_t r; size_t i; - if (level > RTE_LOG_DEBUG) + if (level > RTE_LOG_MAX) return -1; if (regcomp(&r, regex, 0) != 0) @@ -219,7 +219,7 @@ rte_log_set_level_pattern(const char *pattern, uint32_t level) { size_t i; - if (level > RTE_LOG_DEBUG) + if (level > RTE_LOG_MAX) return -1; for (i = 0; i < rte_logs.dynamic_types_len; i++) { @@ -323,7 +323,7 @@ rte_log_register_type_and_pick_level(const char *name, uint32_t level_def) return type; TAILQ_FOREACH(opt_ll, &opt_loglevel_list, next) { - if (opt_ll->level > RTE_LOG_DEBUG) + if (opt_ll->level > RTE_LOG_MAX) continue; if (opt_ll->pattern) { diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 02374ee09e..3675e55fc9 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1249,7 +1249,7 @@ eal_parse_log_priority(const char *level) return -1; /* look for named values, skip 0 which is not a valid level */ - for (i = 1; i < RTE_DIM(levels); i++) { + for (i = 1; i <= RTE_LOG_MAX; i++) { if (strncmp(levels[i], level, len) == 0) return i; } diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h index 173004fd71..394e8682b9 100644 --- a/lib/librte_eal/include/rte_log.h +++ b/lib/librte_eal/include/rte_log.h @@ -72,6 +72,7 @@ extern "C" { #define RTE_LOG_NOTICE 6U /**< Normal but significant condition. */ #define RTE_LOG_INFO 7U /**< Informational. */ #define RTE_LOG_DEBUG 8U /**< Debug-level messages. */ +#define RTE_LOG_MAX RTE_LOG_DEBUG /**< Most detailed log level. */ /** * Change the stream that will be used by the logging system. From patchwork Wed Mar 10 13:28:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88849 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B5E7DA0567; Wed, 10 Mar 2021 14:29:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5590722A618; Wed, 10 Mar 2021 14:28:44 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 1323122A5C2 for ; Wed, 10 Mar 2021 14:28:43 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id EF72E19D0; Wed, 10 Mar 2021 08:28:41 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 10 Mar 2021 08:28:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=PfM1Tv7mRxtRA 4D7IPXrv/zZRCj9MgP6zqEJsYDJesk=; b=DHYL/BbjHxVFGSsjZWBqZW4m93TVd 6Il/6EeFa183xI/HvtvHY8G93IlKE/2zfQQUZDjFBLMKvln/QeujF/4gtfoFBV3b bg6rjt6RWTC4LmxBNvhXQ6iSy6QA66O6QTi/FQVTyag+gQT/Fqr+/E3oBMYhY0aj qoXdIdVhEpDTs8IKrKJq8O7aHFWXYms1Ocii/U1wQcGlvWnTHfAbtYkYRSIukVf+ aeG/XXRR4mNkt8PHcdxLjTPXMAJ6Azavauaw+Vg2/zmLf2ZbDcbV+db9XHuJhFcb d6APpk8SUe/VutVz3GtRFBEXGWkA6D4QMz+o3QhYQd1Yo73soIVlA4P2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=PfM1Tv7mRxtRA4D7IPXrv/zZRCj9MgP6zqEJsYDJesk=; b=CIeWi9AW m+5sQbcYFOLT9ixr1dQr3LauR9+oCw3pI9IlC6Odu9J6sL4VzzEiL5Gc7CPA/w+3 MO/avt3kBkOtzp6svaFPedUVsjZ/gs22bJCoqX0nnZ5SCPqJShet/x7mP8EOsvKy Isj+hCDjYfpyqI7aG3wdZpg61howKg5/S/FcTtkSK84ggdusG+2G5+Vk/64GDgIR R9mWhHYpOsquzVAiziwgZjMFvmiRdtjvgJNeWXEnhcji84PCJnFTJBkEik8XtKOg n+zeK2Hlyzl0Es4b7yiqd4YkldHdCMf7I6B7HEwKdZ/gg8iSp0/1sps7QZaNXSqc HBL2OZt/ippTdA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpedvhefgiedvjeegtdevhe efhfetleefgfeivefgffevfeejgedtgfeutdehtdegveenucfkphepjeejrddufeegrddv tdefrddukeegnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 3A5C924005E; Wed, 10 Mar 2021 08:28:41 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com Date: Wed, 10 Mar 2021 14:28:20 +0100 Message-Id: <20210310132825.2627851-7-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 06/11] eal: catch invalid log level number 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 Sender: "dev" The parsing check for invalid log level was not trying to catch irrelevant numeric values. A log level 0 or too high is now a failure in options parsing so it can be caught early. Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 3675e55fc9..da0aaf831e 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1289,7 +1289,7 @@ eal_parse_log_level(const char *arg) } priority = eal_parse_log_priority(level); - if (priority < 0) { + if (priority <= 0 || priority > (int) RTE_LOG_MAX) { fprintf(stderr, "invalid log priority: %s\n", level); goto fail; } From patchwork Wed Mar 10 13:28:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88850 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 470CCA0567; Wed, 10 Mar 2021 14:29:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88D5422A61A; Wed, 10 Mar 2021 14:28:47 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 0466222A61A for ; Wed, 10 Mar 2021 14:28:46 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 0B3191994; Wed, 10 Mar 2021 08:28:44 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 10 Mar 2021 08:28:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=zKOY3L9oQwidx EzX/MMtIhHtJb7dPNPVmyiRiRt+IEQ=; b=FxTIsqn2yk1Usp3tdhR3NsxWeDQTO j6T/AwDYEUVvNuU+LDtf6DIrvseJTEYKzRtX7YW9Gs98X+tkmnvHpEsrbpIDnSNs tuBlWkG4wondDB0zwArxEAtFOb6aGedrG9NWUUDn8xILkAJHG9Go0DNkdewb6GaV QU5YeLtnNE9bpkUaTRUcKFycwNRwsd/ThHGeZKkg8rSJVdTE0ULi/ETNjEgYZZrt SUgRgEerfFkjv+3EkQmqd5nrS6b3XffzYXUZrUhgn2QV4DZ2bXP2o0MvI9oZtWCk Y3n78kSGlEBzuPxTNLAws3TZEhoxQ6ZVDs+msZPZFaz9Rdor7ASX+7xrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=zKOY3L9oQwidxEzX/MMtIhHtJb7dPNPVmyiRiRt+IEQ=; b=SC8cdLcX a5aotTrHQastpfyeU1KdjFIu0w+bbYciDcyUEzTHSEt2kONdZ59X1wP1CH6kI83m P7ZoxtJFLS4ghuWTwzAhTIHckKFihtI6lodtS0cmK5a935JPYqFXM8ze8X7LPugh hl3S738OfkXvZqh2AioYz+cPhV9tNXxvcMyDy2ErW7zj8WMqvOI5UmNc1nIDgZY8 2QHsG994cHONPB6nrv7EbjS1lCVg8pU/4ELS20hvwY9neBHsQsPhkLj8JekMm7ve TVLCMwcOdwvJ5QuegP58/aeEzfAq7D6UIK8J0ya5bFhdyvvXoBYTD4yIyQ6r1pD3 B5mWYUW4PJOsWA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id CC52F24005E; Wed, 10 Mar 2021 08:28:43 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Ray Kinsella , Neil Horman Date: Wed, 10 Mar 2021 14:28:21 +0100 Message-Id: <20210310132825.2627851-8-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 07/11] eal: add log level help 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 Sender: "dev" The option --log-level was not completely described in the usage text, and it was difficult to guess the names of the log types and levels. A new value "help" is accepted after --log-level to give more details about the syntax and listing the log types and levels. The array "levels" used for level name parsing is replaced with a (modified) existing function which was used in rte_log_dump(). The new function rte_log_list_types() is exported in the API for allowing an application to give this info to the user if not exposing the EAL option --log-level. The list of log types cannot include all drivers if not linked in the application (shared object plugin case). Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_log.c | 24 +++++++++--- lib/librte_eal/common/eal_common_options.c | 44 +++++++++++++++------- lib/librte_eal/common/eal_log.h | 5 +++ lib/librte_eal/include/rte_log.h | 11 ++++++ lib/librte_eal/version.map | 3 ++ 5 files changed, 69 insertions(+), 18 deletions(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 40cac36f89..d695b04068 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -397,12 +397,12 @@ RTE_INIT_PRIO(log_init, LOG) rte_logs.dynamic_types_len = RTE_LOGTYPE_FIRST_EXT_ID; } -static const char * -loglevel_to_string(uint32_t level) +const char * +eal_log_level2str(uint32_t level) { switch (level) { case 0: return "disabled"; - case RTE_LOG_EMERG: return "emerg"; + case RTE_LOG_EMERG: return "emergency"; case RTE_LOG_ALERT: return "alert"; case RTE_LOG_CRIT: return "critical"; case RTE_LOG_ERR: return "error"; @@ -414,6 +414,20 @@ loglevel_to_string(uint32_t level) } } +/* Dump name of each logtype, one per line. */ +void +rte_log_list_types(FILE *out, const char *prefix) +{ + size_t type; + + for (type = 0; type < rte_logs.dynamic_types_len; ++type) { + if (rte_logs.dynamic_types[type].name == NULL) + continue; + fprintf(out, "%s%s\n", + prefix, rte_logs.dynamic_types[type].name); + } +} + /* dump global level and registered log types */ void rte_log_dump(FILE *f) @@ -421,14 +435,14 @@ rte_log_dump(FILE *f) size_t i; fprintf(f, "global log level is %s\n", - loglevel_to_string(rte_log_get_global_level())); + eal_log_level2str(rte_log_get_global_level())); for (i = 0; i < rte_logs.dynamic_types_len; i++) { if (rte_logs.dynamic_types[i].name == NULL) continue; fprintf(f, "id %zu: %s, level is %s\n", i, rte_logs.dynamic_types[i].name, - loglevel_to_string(rte_logs.dynamic_types[i].loglevel)); + eal_log_level2str(rte_logs.dynamic_types[i].loglevel)); } } diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index da0aaf831e..188456e4ae 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1227,19 +1227,31 @@ eal_parse_syslog(const char *facility, struct internal_config *conf) } #endif +static void +eal_log_usage(void) +{ + unsigned int level; + + printf("Log type is a pattern matching items of this list" + " (plugins may be missing):\n"); + rte_log_list_types(stdout, "\t"); + printf("\n"); + printf("Syntax using globbing pattern: "); + printf("--"OPT_LOG_LEVEL" pattern:level\n"); + printf("Syntax using regular expression: "); + printf("--"OPT_LOG_LEVEL" regexp,level\n"); + printf("Syntax for the global level: "); + printf("--"OPT_LOG_LEVEL" level\n"); + printf("Logs are emitted if allowed by both global and specific levels.\n"); + printf("\n"); + printf("Log level can be a number or the first letters of its name:\n"); + for (level = 1; level <= RTE_LOG_MAX; level++) + printf("\t%d %s\n", level, eal_log_level2str(level)); +} + static int eal_parse_log_priority(const char *level) { - static const char * const levels[] = { - [RTE_LOG_EMERG] = "emergency", - [RTE_LOG_ALERT] = "alert", - [RTE_LOG_CRIT] = "critical", - [RTE_LOG_ERR] = "error", - [RTE_LOG_WARNING] = "warning", - [RTE_LOG_NOTICE] = "notice", - [RTE_LOG_INFO] = "info", - [RTE_LOG_DEBUG] = "debug", - }; size_t len = strlen(level); unsigned long tmp; char *end; @@ -1250,7 +1262,7 @@ eal_parse_log_priority(const char *level) /* look for named values, skip 0 which is not a valid level */ for (i = 1; i <= RTE_LOG_MAX; i++) { - if (strncmp(levels[i], level, len) == 0) + if (strncmp(eal_log_level2str(i), level, len) == 0) return i; } @@ -1274,6 +1286,11 @@ eal_parse_log_level(const char *arg) char *str, *level; int priority; + if (strcmp(arg, "help") == 0) { + eal_log_usage(); + exit(EXIT_SUCCESS); + } + str = strdup(arg); if (str == NULL) return -1; @@ -2062,9 +2079,10 @@ eal_common_usage(void) #ifndef RTE_EXEC_ENV_WINDOWS " --"OPT_SYSLOG" Set syslog facility\n" #endif - " --"OPT_LOG_LEVEL"= Set global log level\n" - " --"OPT_LOG_LEVEL"=:\n" + " --"OPT_LOG_LEVEL"= Set global log level\n" + " --"OPT_LOG_LEVEL"=:\n" " Set specific log level\n" + " --"OPT_LOG_LEVEL"=help Show log types and levels\n" #ifndef RTE_EXEC_ENV_WINDOWS " --"OPT_TRACE"=\n" " Enable trace based on regular expression trace name.\n" diff --git a/lib/librte_eal/common/eal_log.h b/lib/librte_eal/common/eal_log.h index 684650a17b..c784fa6043 100644 --- a/lib/librte_eal/common/eal_log.h +++ b/lib/librte_eal/common/eal_log.h @@ -24,4 +24,9 @@ void eal_log_set_default(FILE *default_log); int eal_log_save_regexp(const char *regexp, uint32_t level); int eal_log_save_pattern(const char *pattern, uint32_t level); +/* + * Convert log level to string. + */ +const char *eal_log_level2str(uint32_t level); + #endif /* EAL_LOG_H */ diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h index 394e8682b9..e6192892c3 100644 --- a/lib/librte_eal/include/rte_log.h +++ b/lib/librte_eal/include/rte_log.h @@ -240,6 +240,17 @@ int rte_log_register(const char *name); __rte_experimental int rte_log_register_type_and_pick_level(const char *name, uint32_t level_def); +/** + * Dump name of each logtype, one per line. + * + * @param out + * Stream where the list is sent. + * @param prefix + * String preceding each logtype in the output. + */ +__rte_experimental +void rte_log_list_types(FILE *out, const char *prefix); + /** * Dump log information. * diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index fce90a112f..6b7876a0b9 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -412,6 +412,9 @@ EXPERIMENTAL { rte_thread_tls_key_delete; rte_thread_tls_value_get; rte_thread_tls_value_set; + + # added in 21.05 + rte_log_list_types; }; INTERNAL { From patchwork Wed Mar 10 13:28:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88851 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9EEECA0567; Wed, 10 Mar 2021 14:29:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C20BA22A624; Wed, 10 Mar 2021 14:28:48 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 998A822A61A for ; Wed, 10 Mar 2021 14:28:46 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3E8955C0127; Wed, 10 Mar 2021 08:28:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 10 Mar 2021 08:28:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=86qv1mpuFyvYT P22vkWUc7lm5N5+2cyXaN7ZlU0NV4A=; b=EAQB2AfoDnnGxKlwRcFg0Q4vk3dCp 1Nmx6H/RA1M6cxglpmQQFQU628LQ4NhedbUxXHkmdf/qzaboO5zrL4Tir4iTZoY9 61Mc1yZWJFRe159G66nUzvWC/8VyQigReSJfcsSZUDQZMZe0FMXsbhzGxPxad0X7 ovDfOFhyY9GidfGJJ2cCilbCmuZOTFb74YMtxMcIquvdNV4buFxiGxRO56UUNwz9 yqoi/YN7BS9y6mI0a2gAfNk4q2cwfVc3104CIY+WKrQVUvNuUiJSeyFouRfRyC5l IARl8PH/UHoJ9AQkTligYK7zSc4UR/0XamHFF+LnUvZbvuyhqAWdIPURQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=86qv1mpuFyvYTP22vkWUc7lm5N5+2cyXaN7ZlU0NV4A=; b=sk+SGU+x oYWxl5j6QUbO1lZI3Vq5gbJ5tTLZxrhm+FyY48WUJYyUHd8bb9J2KjmSpOhiWVxw wUVVaNal8UDPhkOHV+e5GHR3aq5oT3KfPu4oay7XSIDmJmbgdTy6mVU0yOhJWXnU 1ZzNumDwYgP4/ccjwt1LglTI059LvzPG624/BIhrlW1mmCxYaPmzFUmK3gZ22gmD pGX5ri6ychtz3d715LGz6YaG+zrDV1x9K/0pQCOYNz7rDN7Ab0cp7VoN/z79EpP/ Qws/tCSfv+Xyavbc87GkL21SbGVPdprRKZwiFnYCqyGPrM5Z4E0WQuLJ068vM1v6 2VfqAug+JsJr2g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 631FC24005D; Wed, 10 Mar 2021 08:28:45 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Wisam Jaddo , Ori Kam , Declan Doherty , Ciara Power , Xiaoyun Li Date: Wed, 10 Mar 2021 14:28:22 +0100 Message-Id: <20210310132825.2627851-9-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 08/11] app: fix exit messages 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 Sender: "dev" Some applications were printing useless messages with rte_exit() after showing the help. Using exit() is enough in this case. Some applications were using a redundant printf or fprintf() before calling rte_exit(). The messages are unified in a single rte_exit(). Some rte_exit() calls were missing a line feed or returning a wrong code. Signed-off-by: Thomas Monjalon Acked-by: Wisam Jaddo Acked-by: Ori Kam --- .../comp_perf_options_parse.c | 2 +- app/test-crypto-perf/cperf_options_parsing.c | 2 +- app/test-flow-perf/main.c | 59 +++++++++---------- app/test-pmd/parameters.c | 4 +- app/test-regex/main.c | 3 +- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c index 04a8d2fbee..019eddb7bd 100644 --- a/app/test-compress-perf/comp_perf_options_parse.c +++ b/app/test-compress-perf/comp_perf_options_parse.c @@ -620,7 +620,7 @@ comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv) switch (opt) { case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; /* long options */ case 0: diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 0466f7baf8..40b6dfb648 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -983,7 +983,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) switch (opt) { case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; /* long options */ case 0: diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 99d0463456..0aef767350 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -639,7 +639,7 @@ args_parse(int argc, char **argv) case 0: if (strcmp(lgopts[opt_idx].name, "help") == 0) { usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); } if (strcmp(lgopts[opt_idx].name, "group") == 0) { @@ -647,7 +647,7 @@ args_parse(int argc, char **argv) if (n >= 0) flow_group = n; else - rte_exit(EXIT_SUCCESS, + rte_exit(EXIT_FAILURE, "flow group should be >= 0\n"); printf("group %d / ", flow_group); } @@ -667,7 +667,7 @@ args_parse(int argc, char **argv) if (n > 0) hairpin_queues_num = n; else - rte_exit(EXIT_SUCCESS, + rte_exit(EXIT_FAILURE, "Hairpin queues should be > 0\n"); flow_actions[actions_idx++] = @@ -680,7 +680,7 @@ args_parse(int argc, char **argv) if (n > 0) hairpin_queues_num = n; else - rte_exit(EXIT_SUCCESS, + rte_exit(EXIT_FAILURE, "Hairpin queues should be > 0\n"); flow_actions[actions_idx++] = @@ -704,11 +704,9 @@ args_parse(int argc, char **argv) break; } /* Reached last item with no match */ - if (i == (RTE_DIM(flow_options) - 1)) { - fprintf(stderr, "Invalid encap item: %s\n", token); - usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Invalid encap item\n"); - } + if (i == (RTE_DIM(flow_options) - 1)) + rte_exit(EXIT_FAILURE, + "Invalid encap item: %s\n", token); } token = strtok(NULL, ","); } @@ -730,11 +728,9 @@ args_parse(int argc, char **argv) break; } /* Reached last item with no match */ - if (i == (RTE_DIM(flow_options) - 1)) { - fprintf(stderr, "Invalid decap item: %s\n", token); - usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Invalid decap item\n"); - } + if (i == (RTE_DIM(flow_options) - 1)) + rte_exit(EXIT_FAILURE, + "Invalid decap item %s\n", token); } token = strtok(NULL, ","); } @@ -747,9 +743,9 @@ args_parse(int argc, char **argv) if (n >= DEFAULT_RULES_BATCH) rules_batch = n; else { - printf("\n\nrules_batch should be >= %d\n", + rte_exit(EXIT_FAILURE, + "rules_batch should be >= %d\n", DEFAULT_RULES_BATCH); - rte_exit(EXIT_SUCCESS, " "); } } if (strcmp(lgopts[opt_idx].name, @@ -758,7 +754,8 @@ args_parse(int argc, char **argv) if (n >= (int) rules_batch) rules_count = n; else { - printf("\n\nrules_count should be >= %d\n", + rte_exit(EXIT_FAILURE, + "rules_count should be >= %d\n", rules_batch); } } @@ -786,23 +783,23 @@ args_parse(int argc, char **argv) if (strcmp(lgopts[opt_idx].name, "cores") == 0) { n = atoi(optarg); if ((int) rte_lcore_count() <= n) { - printf("\nError: you need %d cores to run on multi-cores\n" + rte_exit(EXIT_FAILURE, + "Error: you need %d cores to run on multi-cores\n" "Existing cores are: %d\n", n, rte_lcore_count()); - rte_exit(EXIT_FAILURE, " "); } if (n <= RTE_MAX_LCORE && n > 0) mc_pool.cores_count = n; else { - printf("Error: cores count must be > 0 " - " and < %d\n", RTE_MAX_LCORE); - rte_exit(EXIT_FAILURE, " "); + rte_exit(EXIT_FAILURE, + "Error: cores count must be > 0 and < %d\n", + RTE_MAX_LCORE); } } break; default: - fprintf(stderr, "Invalid option: %s\n", argv[optind]); usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Invalid option\n"); + rte_exit(EXIT_FAILURE, "Invalid option: %s\n", + argv[optind]); break; } } @@ -936,7 +933,7 @@ create_meter_rule(int port_id, uint32_t counter) printf("Port %u create meter idx(%d) error(%d) message: %s\n", port_id, counter, error.type, error.message ? error.message : "(no stated reason)"); - rte_exit(EXIT_FAILURE, "error in creating meter"); + rte_exit(EXIT_FAILURE, "Error in creating meter\n"); } } @@ -949,7 +946,7 @@ destroy_meter_rule(int port_id, uint32_t counter) printf("Port %u destroy meter(%d) error(%d) message: %s\n", port_id, counter, error.type, error.message ? error.message : "(no stated reason)"); - rte_exit(EXIT_FAILURE, "Error in deleting meter rule"); + rte_exit(EXIT_FAILURE, "Error in deleting meter rule\n"); } } @@ -1097,7 +1094,7 @@ destroy_flows(int port_id, uint8_t core_id, struct rte_flow **flows_list) memset(&error, 0x33, sizeof(error)); if (rte_flow_destroy(port_id, flows_list[i], &error)) { print_flow_error(error); - rte_exit(EXIT_FAILURE, "Error in deleting flow"); + rte_exit(EXIT_FAILURE, "Error in deleting flow\n"); } /* @@ -1160,7 +1157,7 @@ insert_flows(int port_id, uint8_t core_id) flows_list = rte_zmalloc("flows_list", (sizeof(struct rte_flow *) * rules_count_per_core) + 1, 0); if (flows_list == NULL) - rte_exit(EXIT_FAILURE, "No Memory available!"); + rte_exit(EXIT_FAILURE, "No Memory available!\n"); cpu_time_used = 0; flow_index = 0; @@ -1180,7 +1177,7 @@ insert_flows(int port_id, uint8_t core_id) if (flow == NULL) { print_flow_error(error); - rte_exit(EXIT_FAILURE, "error in creating flow"); + rte_exit(EXIT_FAILURE, "Error in creating flow\n"); } flows_list[flow_index++] = flow; } @@ -1199,7 +1196,7 @@ insert_flows(int port_id, uint8_t core_id) if (!flow) { print_flow_error(error); - rte_exit(EXIT_FAILURE, "error in creating flow"); + rte_exit(EXIT_FAILURE, "Error in creating flow\n"); } flows_list[flow_index++] = flow; @@ -1517,7 +1514,7 @@ packet_per_second_stats(void) old = rte_zmalloc("old", sizeof(struct lcore_info) * RTE_MAX_LCORE, 0); if (old == NULL) - rte_exit(EXIT_FAILURE, "No Memory available!"); + rte_exit(EXIT_FAILURE, "No Memory available!\n"); memcpy(old, lcore_infos, sizeof(struct lcore_info) * RTE_MAX_LCORE); diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index c8acd5d1b7..55ecea6338 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -632,7 +632,7 @@ launch_args_parse(int argc, char** argv) case 0: /*long options */ if (!strcmp(lgopts[opt_idx].name, "help")) { usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); } #ifdef RTE_LIB_CMDLINE if (!strcmp(lgopts[opt_idx].name, "interactive")) { @@ -1369,7 +1369,7 @@ launch_args_parse(int argc, char** argv) break; case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; default: usage(argv[0]); diff --git a/app/test-regex/main.c b/app/test-regex/main.c index aea4fa6b88..7bb87bb1b8 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -154,9 +154,8 @@ args_parse(int argc, char **argv, char *rules_file, char *data_file, usage("RegEx test app"); break; default: - fprintf(stderr, "Invalid option: %s\n", argv[optind]); usage("RegEx test app"); - rte_exit(EXIT_FAILURE, "Invalid option\n"); + rte_exit(EXIT_FAILURE, "Invalid option: %s\n", argv[optind]); break; } } From patchwork Wed Mar 10 13:28:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88852 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A03BEA0567; Wed, 10 Mar 2021 14:29:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C9FF22A638; Wed, 10 Mar 2021 14:28:50 +0100 (CET) Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by mails.dpdk.org (Postfix) with ESMTP id 65B0E22A62E for ; Wed, 10 Mar 2021 14:28:49 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id B75775807A6; Wed, 10 Mar 2021 08:28:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 10 Mar 2021 08:28:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=dFV73RRtZdkwH VgBsoV2WpehcgFJYefwkmwa3E8dnfA=; b=y+m1bqA+yS0ghG/kBXZEkeE13JO3J Wx+7T+jE+9J0i+96uW1eONtHNPkWslvOMrBJGaLsh0jVHNNwPge7nx45IqAUTdl9 hsgW8GxayQAK9slvfnihpyLnckTSrqjODwKwdwadX4Q7FL790w9TYLI7GQlHGdkm UVSYnyw/whPlSP4pdaq+u6vf+jjfVee4RcgvXQUxFeB6Es/trI47/eCn0OS8ecP1 FxEJlwLHUVPxUJBtiVOpVv1jlWjiaiPUfGEH+q33O6xC98mPilHgZgg9sxn4IKG2 3xSp1C3Yf3xXIfFCqB0Y1G4Gwo6f9C3IfV1zj6f9nyj+Wiz0btZo3ZwJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=dFV73RRtZdkwHVgBsoV2WpehcgFJYefwkmwa3E8dnfA=; b=R3zK/nKX +mBNJoP48ie06it7O502Nnsf7Pq3EB42xm9jh7JLmx0OaBer9dzbDVHh7eYy7Gn3 z88YCvFKlBIqf9xpB2zM1HxylX5YYo2dmZ3w4iCOiCMuw3Hq66FWmZketAZLSLfk 17xCxY4k7ekrJb38xe1FVLa+PymflcV1yF1+mc2mj9m1KfdztzpXCV2b6iP2Rmoz HrMpiUmzjuJdhGCIZkyAhKoDdRP0bqbMdSpAixW0gQ4F0l4EM2QYU3iy6CAx3c/P Q5zBmsoMuQZaXMxAeOjoYVyrupVAbzltzGOU408P1qPUdnuMyyvxxkCjn0N2qHHj W+umQUpmyXlg9g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 2BC3824005E; Wed, 10 Mar 2021 08:28:47 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Wisam Jaddo , Reshma Pattan , Maryam Tahhan , Konstantin Ananyev , Nicolas Chautru , Declan Doherty , Ciara Power , Vladimir Medvedkin , Xiaoyun Li , Ori Kam , Bernard Iremonger Date: Wed, 10 Mar 2021 14:28:23 +0100 Message-Id: <20210310132825.2627851-10-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 09/11] app: hook in EAL usage help 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 Sender: "dev" Use rte_set_application_usage_hook() in the test applications, so the full help including EAL options can be printed in one go with the EAL option -h or --help. Signed-off-by: Thomas Monjalon Acked-by: Wisam Jaddo --- app/pdump/main.c | 2 ++ app/proc-info/main.c | 2 ++ app/test-acl/main.c | 2 ++ app/test-bbdev/main.c | 3 ++- app/test-compress-perf/comp_perf_options.h | 2 ++ app/test-compress-perf/comp_perf_options_parse.c | 8 ++++---- app/test-compress-perf/main.c | 3 ++- app/test-crypto-perf/cperf_options.h | 2 ++ app/test-crypto-perf/cperf_options_parsing.c | 8 ++++---- app/test-crypto-perf/main.c | 3 ++- app/test-fib/main.c | 8 ++++++++ app/test-flow-perf/main.c | 4 +++- app/test-pmd/parameters.c | 4 ++-- app/test-pmd/testpmd.c | 2 ++ app/test-pmd/testpmd.h | 1 + app/test-regex/main.c | 3 ++- app/test-sad/main.c | 7 +++++++ 17 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 63bbe65cd8..8641017f48 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -974,6 +974,8 @@ main(int argc, char **argv) char mp_flag[] = "--proc-type=secondary"; char *argp[argc + 2]; + rte_set_application_usage_hook(pdump_usage); + /* catch ctrl-c so we can print on exit */ signal(SIGINT, signal_handler); diff --git a/app/proc-info/main.c b/app/proc-info/main.c index b9587f7ded..e7d86bfa9d 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -1361,6 +1361,8 @@ main(int argc, char **argv) char *argp[argc + 4]; uint16_t nb_ports; + rte_set_application_usage_hook(proc_info_usage); + /* preparse app arguments */ ret = proc_info_preparse_args(argc, argv); if (ret < 0) { diff --git a/app/test-acl/main.c b/app/test-acl/main.c index 2cb2fe2579..9f95cb0fbf 100644 --- a/app/test-acl/main.c +++ b/app/test-acl/main.c @@ -1080,6 +1080,8 @@ main(int argc, char **argv) int ret; uint32_t lcore; + rte_set_application_usage_hook(print_usage); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_panic("Cannot init EAL\n"); diff --git a/app/test-bbdev/main.c b/app/test-bbdev/main.c index ff65173fdb..5960ec18b2 100644 --- a/app/test-bbdev/main.c +++ b/app/test-bbdev/main.c @@ -340,7 +340,8 @@ main(int argc, char **argv) { int ret; - /* Init EAL */ + rte_set_application_usage_hook(print_usage); + ret = rte_eal_init(argc, argv); if (ret < 0) return 1; diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h index 0b777521c5..7dd785fba1 100644 --- a/app/test-compress-perf/comp_perf_options.h +++ b/app/test-compress-perf/comp_perf_options.h @@ -73,6 +73,8 @@ struct comp_test_data { uint32_t cyclecount_delay; }; +void comp_perf_usage(const char *progname); + int comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv); diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c index 019eddb7bd..39d7fd8c69 100644 --- a/app/test-compress-perf/comp_perf_options_parse.c +++ b/app/test-compress-perf/comp_perf_options_parse.c @@ -38,8 +38,8 @@ struct name_id_map { uint32_t id; }; -static void -usage(char *progname) +void +comp_perf_usage(const char *progname) { printf("%s [EAL options] --\n" " --ptest throughput / verify / pmd-cyclecount\n" @@ -619,7 +619,7 @@ comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv) while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) { switch (opt) { case 'h': - usage(argv[0]); + comp_perf_usage(argv[0]); exit(EXIT_SUCCESS); break; /* long options */ @@ -631,7 +631,7 @@ comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv) break; default: - usage(argv[0]); + comp_perf_usage(argv[0]); return -EINVAL; } } diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c index cc9951a9b1..dcd347528e 100644 --- a/app/test-compress-perf/main.c +++ b/app/test-compress-perf/main.c @@ -323,7 +323,8 @@ main(int argc, char **argv) uint8_t cdev_id; uint32_t lcore_id; - /* Initialise DPDK EAL */ + rte_set_application_usage_hook(comp_perf_usage); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n"); diff --git a/app/test-crypto-perf/cperf_options.h b/app/test-crypto-perf/cperf_options.h index 9664a4b343..5f4a780614 100644 --- a/app/test-crypto-perf/cperf_options.h +++ b/app/test-crypto-perf/cperf_options.h @@ -153,6 +153,8 @@ struct cperf_options { uint8_t imix_distribution_count; }; +void cperf_usage(const char *progname); + void cperf_options_default(struct cperf_options *options); diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 40b6dfb648..3777bc7509 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -19,8 +19,8 @@ struct name_id_map { uint32_t id; }; -static void -usage(char *progname) +void +cperf_usage(const char *progname) { printf("%s [EAL options] --\n" " --silent: disable options dump\n" @@ -982,7 +982,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) { switch (opt) { case 'h': - usage(argv[0]); + cperf_usage(argv[0]); exit(EXIT_SUCCESS); break; /* long options */ @@ -994,7 +994,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) break; default: - usage(argv[0]); + cperf_usage(argv[0]); return -EINVAL; } } diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 49af812d8b..497c4c5226 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -519,7 +519,8 @@ main(int argc, char **argv) int ret; uint32_t lcore_id; - /* Initialise DPDK EAL */ + rte_set_application_usage_hook(cperf_usage); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n"); diff --git a/app/test-fib/main.c b/app/test-fib/main.c index b0a97b0d7e..420fe17c39 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -648,6 +648,12 @@ print_usage(void) config.prgname); } +static void +usage_hook(const char *prgname __rte_unused) +{ + print_usage(); +} + static int check_config(void) { @@ -1209,6 +1215,8 @@ main(int argc, char **argv) FILE *fl = NULL; uint8_t depth_lim; + rte_set_application_usage_hook(usage_hook); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_panic("Cannot init EAL\n"); diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 0aef767350..949a5e3e11 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -115,7 +115,7 @@ static struct multi_cores_pool mc_pool = { }; static void -usage(char *progname) +usage(const char *progname) { printf("\nusage: %s\n", progname); printf("\nControl configurations:\n"); @@ -1849,6 +1849,8 @@ main(int argc, char **argv) uint16_t port; struct rte_flow_error error; + rte_set_application_usage_hook(usage); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "EAL init failed\n"); diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 55ecea6338..7f41021d4d 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -46,8 +46,8 @@ #include "testpmd.h" -static void -usage(char* progname) +void +usage(const char *progname) { printf("usage: %s [EAL options] -- " #ifdef RTE_LIB_CMDLINE diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1a57324b1b..1a60830037 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3771,6 +3771,8 @@ main(int argc, char** argv) rte_exit(EXIT_FAILURE, "Cannot register log type"); rte_log_set_level(testpmd_logtype, RTE_LOG_DEBUG); + rte_set_application_usage_hook(usage); + diag = rte_eal_init(argc, argv); if (diag < 0) rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n", diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ce83f31f0d..37348246f8 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -763,6 +763,7 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx) unsigned int parse_item_list(char* str, const char* item_name, unsigned int max_items, unsigned int *parsed_items, int check_unique_values); +void usage(const char *progname); void launch_args_parse(int argc, char** argv); void cmdline_read_from_file(const char *filename); void prompt(void); diff --git a/app/test-regex/main.c b/app/test-regex/main.c index 7bb87bb1b8..ba09b20126 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -616,7 +616,8 @@ main(int argc, char **argv) uint32_t i; struct qps_per_lcore *qps_per_lcore; - /* Init EAL. */ + rte_set_application_usage_hook(usage); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "EAL init failed\n"); diff --git a/app/test-sad/main.c b/app/test-sad/main.c index 1024757add..14a8263f8c 100644 --- a/app/test-sad/main.c +++ b/app/test-sad/main.c @@ -149,7 +149,12 @@ print_usage(void) "[-p ]\n" "[-c ]\n", config.prgname); +} +static void +usage_hook(const char *prgname __rte_unused) +{ + print_usage(); } static int @@ -620,6 +625,8 @@ main(int argc, char **argv) struct rte_ipsec_sad_conf conf = {0}; unsigned int lcore_id; + rte_set_application_usage_hook(usage_hook); + ret = rte_eal_init(argc, argv); if (ret < 0) rte_panic("Cannot init EAL\n"); From patchwork Wed Mar 10 13:28:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88853 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3E402A0567; Wed, 10 Mar 2021 14:29:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A927B22A63B; Wed, 10 Mar 2021 14:28:52 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 9A94F22A63B for ; Wed, 10 Mar 2021 14:28:51 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A29BB19D6; Wed, 10 Mar 2021 08:28:50 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 10 Mar 2021 08:28:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=QMOTtG2wo+U9x +ONJFBG065HcSeshlSHvhqn0Rk5xPI=; b=FuYBTETnUNJmmLxKDjLWXQcQV9Zjw oDVduxxJP+CNuv4R9EaRFisjElEuowp7DmrOH66artzYFgVveUkP5mLf9UPQnoxX z/JB3PsLrbdS8Y4vHvXQg76t17xA6kMk4sA3C364KOMJ224Y7EofAUbj22LzPfpV FmWHLnwrADvRZFnRzFcf6f7OaJ5oWaHtXnaxWlgdGklbcICiBgeHXZ4jRYui+MnH QryyWBWbr9IAfMm0fYSKAiHUCbnTUHZpeyOZVY+xP8KONP2MXKfkQucFnkcOt16X y6PPyWLqh743l6G496zdOSlzLGOQW1QcETjPu5TImHcA1IWmT8ngJVR7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=QMOTtG2wo+U9x+ONJFBG065HcSeshlSHvhqn0Rk5xPI=; b=n/+Jkewx rhzAec9OR/mxcZtYylBxKUMFC8FzH052199kSMCzp2pla9erhsBgEId6T93YzyaD k60ValD9u/ebP4F8UxxK8Ixarn5rEOupjg2zz80Fp7Prmdau4GTXbp+1YAp+RDq1 DlIZ/5k/+3QwjRN6jTKyE7u/68tmxglqngJvHcbcLOysdgh6UFlqmZWD8ns1KBFg Trc6BHgUzv3cjeyg8BxO379DpdHzbme6/pc0BeBTBWLXXGCPWxc/phORyfw4wI5P DWJjwiSDIAhdql7AnNN25lmSsfkwi838N65oT1ibNTeEvhljVZ/b7vsF9Ie+Iz2R x2zLwiQznnS95A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id AEAAF24005B; Wed, 10 Mar 2021 08:28:49 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Ori Kam Date: Wed, 10 Mar 2021 14:28:24 +0100 Message-Id: <20210310132825.2627851-11-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 10/11] app/regex: fix usage text 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 Sender: "dev" The usage syntax help includes the program name which was fake. It is replaced with the real name from argv. Signed-off-by: Thomas Monjalon Acked-by: Ori Kam --- app/test-regex/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/test-regex/main.c b/app/test-regex/main.c index ba09b20126..73ba227fba 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -151,10 +151,10 @@ args_parse(int argc, char **argv, char *rules_file, char *data_file, *nb_lcores = atoi(optarg); break; case ARG_HELP: - usage("RegEx test app"); + usage(argv[0]); break; default: - usage("RegEx test app"); + usage(argv[0]); rte_exit(EXIT_FAILURE, "Invalid option: %s\n", argv[optind]); break; } From patchwork Wed Mar 10 13:28:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88854 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3463DA0567; Wed, 10 Mar 2021 14:30:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56CB622A655; Wed, 10 Mar 2021 14:28:54 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id B664E22A63E for ; Wed, 10 Mar 2021 14:28:52 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C944D19CD; Wed, 10 Mar 2021 08:28:51 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 10 Mar 2021 08:28:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=NmyGRydXBBdpM zLSAVUUvnDMemu4E8YTIbnhdfm0efM=; b=QyZqLHYITpd9UGli2jvTbAD85Cr4A ie96ZDbG4C4b2c2nmjJaDN6Qm6YoyHcplScLNQ4wndZao6omwGDBTBqhEUM+Qoea Iy+va57nXGcmZTfXygF6ta5mWjwbfTGrLKct25Bh7zNE5Ldl8QjqQRDnWi54MwEO Qrde+0WmTy2q40cFQphwTDbldiNsLccam3DLLuSiOa2o57VULfKTTkrJQJDBDoiB W6FLVH+iCzsn5HA/Pkh0R6vKU1l51dmUnBnUpcxF+GoRUG16sG/Rzw7xcVriypBG aG/UI4KCHFGx8WxFdv5OG+myH/tQ5iTaVyJ/UhtLp8ZucaTHEupCY0m5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=NmyGRydXBBdpMzLSAVUUvnDMemu4E8YTIbnhdfm0efM=; b=hGFAbgJr dDjfeeO31hUoCW2X8sqZjosZve6dWDUrY06j1VIrEV9aNgD3wF2K3ZX6rbJZhz8z 1CjQuxAf6uwj6HaPl9Mp3Hxia3oIgzxCxuCbbA0qlHbKiuhYqXB9gsglRF60mrdW N7PNWjBWuZE3LGecVL1CyiRgKSZY/dQ6zoamh8Zc/Zg4Az3DwP8BvtnnSLDZ1jqF I3SFBtnzobNvU/hPlrU8e7xTKWgzhkQLxU+rCdMR01YoiF6CXNjv+Go5TZc78RSN /DtL/vNQBXmJDmAKbJ7rv3WiQJ6cGHM/N9FKTw677XUlcAma9sNWrCF40FIcJqvJ bdTlrvUDLAPx2A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id F32AA24005E; Wed, 10 Mar 2021 08:28:50 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Xiaoyun Li Date: Wed, 10 Mar 2021 14:28:25 +0100 Message-Id: <20210310132825.2627851-12-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310132825.2627851-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210310132825.2627851-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 11/11] app/testpmd: fix usage text 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 Sender: "dev" The options help text was including an incomplete and redundant summary of the options before explaining each. The summary is dropped. The details of the option --hairpin-mode had an extra space, breaking the alignment with the next line. Signed-off-by: Thomas Monjalon --- app/test-pmd/parameters.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 7f41021d4d..efcbf1e845 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -49,29 +49,7 @@ void usage(const char *progname) { - printf("usage: %s [EAL options] -- " -#ifdef RTE_LIB_CMDLINE - "[--interactive|-i] " - "[--cmdline-file=FILENAME] " -#endif - "[--help|-h] | [--auto-start|-a] | [" - "--tx-first | --stats-period=PERIOD | " - "--coremask=COREMASK --portmask=PORTMASK --numa " - "--portlist=PORTLIST " - "--mbuf-size= | --total-num-mbufs= | " - "--nb-cores= | --nb-ports= | " -#ifdef RTE_LIB_CMDLINE - "--eth-peers-configfile= | " - "--eth-peer=X,M:M:M:M:M:M | " - "--tx-ip=SRC,DST | --tx-udp=PORT | " -#endif - "--pkt-filter-mode= |" - "--rss-ip | --rss-udp | --rss-level-inner | --rss-level-outer |" - "--rxpt= | --rxht= | --rxwt= |" - " --rxfreet= | --txpt= | --txht= | --txwt= | --txfreet= | " - "--txrst= | --tx-offloads= | | --rx-offloads= | " - "--vxlan-gpe-port= | --geneve-parsed-port= | " - "--record-core-cycles | --record-burst-stats]\n", + printf("\nUsage: %s [EAL options] -- [testpmd options]\n\n", progname); #ifdef RTE_LIB_CMDLINE printf(" --interactive: run in interactive mode.\n"); @@ -221,7 +199,7 @@ usage(const char *progname) "enabled\n"); printf(" --record-core-cycles: enable measurement of CPU cycles.\n"); printf(" --record-burst-stats: enable display of RX and TX bursts.\n"); - printf(" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " + printf(" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n" " 0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n" " 0x01 - hairpin ports loop, 0x00 - hairpin port self\n"); }