From patchwork Tue Mar 9 23:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88761 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 5327CA0567; Wed, 10 Mar 2021 00:31:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11D2A22A552; Wed, 10 Mar 2021 00:31: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 240D122A552 for ; Wed, 10 Mar 2021 00:31:39 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C569E5C0094; Tue, 9 Mar 2021 18:31:38 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 09 Mar 2021 18:31: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=23HiqCcRXJCWg GdrKNmzaCXKux7hlgxbKNyRbBYXxgg=; b=qFSzLJSVaKSNz3U5q2BmyY1/m37Bk 9vxMfa2c1Tu2vAmrThPYKmHYyuJmborUj15MEeO0S264UtXYJ0lejoi/FX/nk9YC 97ROtNb1vBtQ2ickk+C6kfGxDVCEEm0vQCK5Bpl7Tdq25GFjSWXO8Sf0YLa0Yqgp xq0AO9WdoktBYEb8ZyMULZn/t/kwSB7sdsQVmx0LVetcOn0WCsEFaoiyQvZfRtq5 RRDcN4s6L33/WwktIjwIoZ8CWUONc99qkafgeQxNvzMcRS/ZW+0pW1Bph3HsOpZd K12gjGj72bKXO+ySeB1j7lsgRI3b3V45x7lYrDz3J91ILlk4WwPwNetgQ== 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=uadVrxmy VHvzEXJ3LEVvhLO33+MKQZm9Z8cpc0dz/AEwGd7KLpd7IdxG5GW8yu+0i2dcByxy ssoIFbn0pT64v1HQZ0w2Mro84Id/iuTbMrZOiel9zAuKQKd1wzusRNVFkLurJWxY IqwOijTZpEE5KGOczQNfDQaXuD6mhFqFMHM9KFU97eKkKqNq9z2ncgqlPtsTb4Wv VZWWrQ1H8uquOZKxFQ1ggD0QjvxNbLFfqwU943ySHVj9qIvY/IAh8VnkjzOgJV51 tw1q7wq1o6hmajr1rrMuTXW/drj7x/f9bnKnBDQ974CSMI0j0/82fcOkIXXc2Qb7 OA/7LyJ/4ZrdIw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghs sehmohhnjhgrlhhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepvdehgfeivdejgedtve ehfefhteelfefgieevgfffveefjeegtdfguedthedtgeevnecukfhppeejjedrudefgedr vddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght 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 4D5F324005A; Tue, 9 Mar 2021 18:31:38 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com Date: Wed, 10 Mar 2021 00:31:05 +0100 Message-Id: <20210309233116.1934666-2-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 Tue Mar 9 23:31:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88762 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 B3A76A0567; Wed, 10 Mar 2021 00:31:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5491522A556; Wed, 10 Mar 2021 00:31:44 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id C716B22A535 for ; Wed, 10 Mar 2021 00:31:42 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 794695C0094; Tue, 9 Mar 2021 18:31:42 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 09 Mar 2021 18:31: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=zFZQ/OVIs26CT S/5cSETH6uU4SwlQijreQHjhnc3KmM=; b=sZVqnKJJduhCMvFx9nE+3iS/onHQg saw4jS10VjqTKKAMJ0zfea0ocUID/bScmRzZQuBSrHpOfsYP7MJ/frVwD2zmczUq 8qAon5nrgX25KjzHy/2YvJ0q2YJgU0bQMxwpqc2utzsqdcggPkCecUiuL3Ioe3JU ov8adLBD1zkUsj6GAejHOsmD+TAJU3j9OBpinU6Sa2RR3RnTSUnsU96sZmTjPA8D eo6tIXRbU7oDOH0yEigCplCVrEW2bniP5Cf64DQ46TsZgZmIAKdqShKUJ6KsYYcn XdIiYTXtmMOlGNPZNNM7HNVACeMc31HRXT3Tfi12E0VYtW6s09KpwLOAQ== 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=MVYeHYWb jZ76ev/2Elf2L24h5uTGD0mOJmZaq5jGgb602Pat0vA07SgWn663xGuu+RXYtWgz Wrl723b9vjkWkN5U3ilICLzLlnwB+2J27H49GlU0ZlmSDKAI9lgnEL6ncqoXxYep z0JVh11Aita7qgEPbuMsyPXSlRAvCg75XlSvLYJqxKEHCngGP8Xt/aqb+yZ3Lbo3 BdopM8X12iKzvQAKFvJn1UeqRL2uSNcXyxpXVI3+rzNjJygU3tUUtVLLPFHb8Yns UxUqe4Yt920cnApd6Idb3HzpDbCANT/GvktCobRqpKqJMkhBsJ8b13FdZnjv/bLL 1DadJT/bLlMJVA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 F1DC524005E; Tue, 9 Mar 2021 18:31:40 -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 00:31:06 +0100 Message-Id: <20210309233116.1934666-3-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 Tue Mar 9 23:31:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88763 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 E61F2A0567; Wed, 10 Mar 2021 00:32:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E94622A55B; Wed, 10 Mar 2021 00:31:45 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 3FE4222A535 for ; Wed, 10 Mar 2021 00:31:44 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id BD3F25C00CE; Tue, 9 Mar 2021 18:31:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 09 Mar 2021 18:31:43 -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=VrYxnm+0fO+PB4H6kg6GqHlNQRQXX thmnsTbhnH63UxYuaTvoUX3Pi24vFKCdQqy3IQWfx3OS/hEYSCG2EVsYn3i0d/4S RlTiOBfot4kjA+IGQVwPQ7vTB+rS2ZnrElFEFDsanQ34xkBwyGASLlKokG2ct9d2 1TVFayHUsQLmUJ4TvPwq4LrKd8y2VSwIg63F8ffq+JIuNZg9eeFPp9WDeIE9Yy1D xIPwFfgDq2IrrtCP+yTKCk6kmEkRK663W0JOauCv93Y7rSE0ahUH0k9C76kyrLo4 EfjMZyVsCrkeU0gGpG4L5LbOsWGFrEYIAmfkp7QRPkE9PqmrhJ/XWo28A== 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=vinaXw+D xh0j9VPOvgbg6BAaBJMtl95GfXoNA2XvhurhiFWHNgkm6qTOjYRRcf+vjaFIVtCP iK8A2q9nPnY0ngv1eVEdT40f6YjY9z0rgG7POPjfJHLRT/1ShE5lnugHgCV2edIh 7k2O86/yqXP0UmfK3qNHDstdGX3uqOkhZ9d433LFcRs4smOG3J/2cva9hxNLTm01 9p+Z2gpsbDzBaxGikq2PPLglTq99xGEmV/pWTTXQbfmpHMFugDXGPl3xKN9jqqn6 HA5SU4ynhnETo6mWufTFsEYoWrG3Mga3uIrbEysXYRfW9eSC0A3PF9UmsGhNkdtk 4+uSIWnzSdq/kQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 C602424005A; Tue, 9 Mar 2021 18:31:42 -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 00:31:07 +0100 Message-Id: <20210309233116.1934666-4-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 Tue Mar 9 23:31:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88764 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 11679A0567; Wed, 10 Mar 2021 00:32:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C613A22A566; Wed, 10 Mar 2021 00:31:47 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id AB11A22A55D for ; Wed, 10 Mar 2021 00:31:45 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 5DDB25C009A; Tue, 9 Mar 2021 18:31:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 09 Mar 2021 18:31: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=abEB2/vtZL7+n p7LAevGDf9oDnCLt0wbqa3xKtjKC7Y=; b=oKjXkXeIPMalysITEYPARptEgrIhE z9xaylWsis3gR/G8xRt5L8I93flPhgUPNpVAHOwb+at95UEbDLvA/9Rzq2pVa78T 6r0D3srbz0p9Cu0g2kFxiPUnEaljxq6C1+xOzv83MMp4la+G8iRsFFdUhWcmLwxS 4Q3lIgkLOlqZrhLaiKtXy52IUCr0TxBjWQOAeI7L9n3E9ll3KitjhXTWy6wIh8Pf NbM+LEZ9HUy9psBxjbihs6oSDz2rTHiOo0wNtSkTLNyl42OEGLYpI/3ZohpYq9Fx F0CpaIMiQlXgd2fsxJIU4IilgYQ9+vynWoXQtn2W9LUNS6cMLQnA2+1FA== 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=abEB2/vtZL7+np7LAevGDf9oDnCLt0wbqa3xKtjKC7Y=; b=gdvkD8GL K1Kzooh2Nd2MmiHiQqvIySOL5Qml+Dc8BJb1sHdVLWlY/IHyTnEUI6eTFP8ZZPZ1 kRPkNUVrIumdl8W5SVD0p7xDgzIg2BvP6IpD6YM1s6e/OO0STfMSDFmsDOjlXFZC YX+yPIhDvIu2iRlnGJr6RUH6bEh4FD+l9PbG9cvmHCbztRrkuOdSgYd1XF2SSTG+ mAdAW652OoKjquR2ysAIueUMo16FIZhgqRtH5QF1F2oxjzc9b/JISMV2zGcvKWIU XwTNWJB0E5527uyOHCk2uEmXmZEbloM/l6g/nvP20BfhznXCdp9Qu1AiD+4aqJLY RLG2jO5SZvPEGg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 8557B240057; Tue, 9 Mar 2021 18:31:44 -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 00:31:08 +0100 Message-Id: <20210309233116.1934666-5-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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..85364ee47a 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(int 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, int tmp) { - return rte_log_save_level(tmp, regex, NULL); + return log_save_level(tmp, 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, int priority) { - return rte_log_save_level(priority, NULL, pattern); + return log_save_level(priority, 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..c057301769 --- /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, int priority); +int eal_log_save_pattern(const char *pattern, int priority); + +#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 Tue Mar 9 23:31:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88765 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 8F761A0567; Wed, 10 Mar 2021 00:32:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CEC522A569; Wed, 10 Mar 2021 00:31:49 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id CDE3222A560 for ; Wed, 10 Mar 2021 00:31:46 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 80FCA5C0094; Tue, 9 Mar 2021 18:31:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 09 Mar 2021 18:31: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=ywZyCC55L5BjT VALckc7Kac3T0SK6uVjjahD62zVzLA=; b=mFL1HJDPJGMzOdsrwQCMjFApAVrQ0 AY8qDUpDygPXXC+AghGrue3uL+ZjYb1jcGctsinEAnvFdEf8dEMnR3lAr9rERqC6 W0NFtZ31zDwT47UgGnRd38wVlRNpW9lYzbDbtnz4U5vmlI5PDJTMXtZySfWsatWu fbyNTkL9dG4waFsI7kwBuFkKzBu+x7/2kPTiaw4skeonT6vIYnrqqvEQ/UBBNhg+ B5UaHK/9WW2uzvL2X5V82z8uEAiQyNoq3u1DFMYnpaCeUh1fWLbStGVfZm6t/obf zDZHdHPKhdOgjRdR2zLejpiNiaTIli1Ftz6r4LImJqyjs8H4c8DTQxEcg== 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=ywZyCC55L5BjTVALckc7Kac3T0SK6uVjjahD62zVzLA=; b=wBImsznO Mc1W+JRje+IMsE4Jux3h1OwFnhsyyt54sVYXhTFdG4v1bDYSIx39+ttwvVaR8VdI SOr9czOTnh9WrOfMAU1eqtI6EWcYNhlhWjUHXpfIOva0bNhJ3E6ATILZ3t8vGb6P V8XUPM57AVMBcnzLl1ZBxQ14hLqqf85B7QZZiioPysy+SgOoo1pzNQTPxDncBT7F emBOgYxZnAS8Fpi17w4ptp+xH6lCGgPIF3mHlklyljIdBYKpdc0G0jrr/0UA6R28 MBD+fYyEbKfvvtwvqYwthvlY8AGQdTkUSLyv+NV+wkxJ4SSOslydwni7YywHsYvL GH7K92YHI+XSdA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghs sehmohhnjhgrlhhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepvdehgfeivdejgedtve ehfefhteelfefgieevgfffveefjeegtdfguedthedtgeevnecukfhppeejjedrudefgedr vddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght 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 20CE524005A; Tue, 9 Mar 2021 18:31:46 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com Date: Wed, 10 Mar 2021 00:31:09 +0100 Message-Id: <20210309233116.1934666-6-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 85364ee47a..7f40c36f7e 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..febc99612a 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 Tue Mar 9 23:31:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88766 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 49C9CA0567; Wed, 10 Mar 2021 00:32:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D4D622A574; Wed, 10 Mar 2021 00:31:50 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 40E5622A562 for ; Wed, 10 Mar 2021 00:31:48 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id E88EE5C00DA; Tue, 9 Mar 2021 18:31:47 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 09 Mar 2021 18:31:47 -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=0xs2IAaTgL6HT /xMrWNsYiqDG2Orh6fzmx2zBcidIrE=; b=wpi7BeOhE6yf4peqT1PaCF2vDvZO7 rAUHn0FddzVyngifkfpoRd4XB3Kpau6nj0R9WN4vFJHJVsODyVVRN7SrKTvRzQ/B 9l0FJsvA716BLFirZ9NAlCKgeknq+6vx7jwQqdWPbHVz1GZP0+vqJVJU2aGtKFc2 bagT9VsOuNj+DECs81GjL2t76WpUI056v3QQ+jDVjEiuCqrFrcV6gKPdeG6mjRho kCiDxmq7tkn3RtrM722sSOq6FPib+OQKSs6IqTT8UoAwGXGoAyVzzroP1QWRkJzK ueso6K0PzOc9v7vJI9to77/O1CPFaKVVgNOFy4nLaWuWZktIWT6VkGiXQ== 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=0xs2IAaTgL6HT/xMrWNsYiqDG2Orh6fzmx2zBcidIrE=; b=YryC2s2X hjVsjm5LI+F2mSp+CjN3GgzHkgCQnLRGpURRJ15E9PmGu41Jxjud5qBqG03wRUZs sXO8HMMqONViTnAjx7Dpe+vL3qmuU22CJvDN+4z1zPuMtdHeAr3nwoC1BLAYB0vT 9Sidpjhc5SNBT6a3Xa9BJPnuc6MftMhpVvC6jQwRSrlNHwjOV90NNXMMieZ0fcAt gsYlu1qKjW0yCVBFSZr0Qvv747voA2LkBIiP2MMdwtYoQteM762Y5XUNLl7i4mM7 LpGxRtXZQvMZyhAoyyWI7vZuqZbhb92iEfpMpfAJjPb56UjJjDzb/S9RRvR7rdDA UiPYgsezgXtx+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghs sehmohhnjhgrlhhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepvdehgfeivdejgedtve ehfefhteelfefgieevgfffveefjeegtdfguedthedtgeevnecukfhppeejjedrudefgedr vddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght 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 8912824005B; Tue, 9 Mar 2021 18:31:47 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com Date: Wed, 10 Mar 2021 00:31:10 +0100 Message-Id: <20210309233116.1934666-7-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 febc99612a..5b9ce286ff 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 Tue Mar 9 23:31:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88767 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 A1247A0567; Wed, 10 Mar 2021 00:32:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8CB622A579; Wed, 10 Mar 2021 00:31:51 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 57C2322A527 for ; Wed, 10 Mar 2021 00:31:50 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 07F035C00ED; Tue, 9 Mar 2021 18:31:50 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 09 Mar 2021 18:31: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=98f9NPdLbDoj9 UkhgWlp16HQWDs/Bgd+2JkvbojrKYU=; b=JwJlmhyb8svJb98Vp3o4B7pzUJZtC M0WoemsS+xi4sxeBvShvk++1cNhOVnAdA2YA5cwy7fxvIaQxUbog6umk3bYWTUJb rh5YB5/KfeEpQskjIBT0U2QHBS9YSMAtXB08Ghsr0tqeiPTaAk8GA/q1uoIMWdHr YTUd73y/yiuUoCxYrOHHzbtgaI4UJ4thG3BsGnVvrJHDj17BGFAts8uUMrByo6QC bMmRy2zkTlEZjxHoOZcTwQgv4FkcSiifwX0+bHZl4YJ4omDDZrrIBxQa7B+2benD mDczBVR1tWFOOEcpEHjOCLt3ACam+7a3yylNHGvLtekN/VsLNYPgLJHIg== 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=98f9NPdLbDoj9UkhgWlp16HQWDs/Bgd+2JkvbojrKYU=; b=WzDYBq7O 2w/lfrdsPtr1ClLNEJoXDGvHikUJpEcHRQy51LWebyveGUkjdIPZvwNt6wmXdCgW UrEqMLq1zTe0tbil1ZMkhrkdt/LJRc1MYSTgtrGv567RUPTzOKtRFjSFMTikjYf5 i4mNaRLcSipEfBsjKXsBawM+j2AcDBumtEJZ/4NdTFOIHe3XinvLbowZpcQaQPwE vJWA8ubdKzdIMxLAlCFB3sg9vsbKp8mBlmvwgyWX/RZOZsL8JZLRP4S1BkDVXKxq 6sZc6kHWlzR6BYmdMA1U8QAztWjToYmt7kkcRRnOwrLtIQ4g/mwkDIXgi4krj3RG IGC4N9o2tRo2qg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 CB38524005C; Tue, 9 Mar 2021 18:31:48 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Ray Kinsella , Neil Horman Date: Wed, 10 Mar 2021 00:31:11 +0100 Message-Id: <20210309233116.1934666-8-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 7f40c36f7e..e46ae7b112 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 5b9ce286ff..6c14e788e8 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 c057301769..4ca630b0f7 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, int priority); int eal_log_save_pattern(const char *pattern, int priority); +/* + * 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 Tue Mar 9 23:31:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88768 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 238B8A0567; Wed, 10 Mar 2021 00:32:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2744022A577; Wed, 10 Mar 2021 00:31:54 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id B783322A577 for ; Wed, 10 Mar 2021 00:31:51 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 69B705C009A; Tue, 9 Mar 2021 18:31:51 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 09 Mar 2021 18:31:51 -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=Fgfo1neXw1UDf P7XX3YHJ166s5XmszJQa+uhOpXiX+g=; b=ePDDEIaiW6kKKPsOsHQthCsc8YDNj ZjThEREwVXVvSlOTGZAuM7QoRlQZeqbhdnjxhcgBEi12pZz8stgAiJR6snigmgjm dRTnDy/WrE8WjCju1K3xrZZ7o27FQAGBn2UgB0D8aE5xbsCAsh1BGPJC3ntGYRfu FEiMjLEBaPfPbo4+Oc2ctus7WIm9Vmx2eWUEKAGiq7P8iz3n0yqAVOywCU/3nZo7 5DcJ6PDAJcEd1Fe3j5BIgKJuUfBv0gdL6IPl8yzU/++IzAViHc/xNkMpR9o/fvxN 4pyvHhW6m7FKg9WPews83i9lsOGjistJRh0XzKN6IpK/G3+xYfbL8rC9w== 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=Fgfo1neXw1UDfP7XX3YHJ166s5XmszJQa+uhOpXiX+g=; b=WX9pEwI1 hsMZOFP4eq9bfdRoQfRXIr6jxeCKH9roPl1gEZt7gWlWTVmBle+LKFf5FK8cDb1Q +i7c9sRmglsUHnJf/dMhQS8uR9QkdwpY6VmXGfdbd34D4ur2dmhIV5z8w2eZMB8M +OCVFMmW3l0+UP/lduShFCe8Ujefh7cNUJEBTkzWYcQar3mN8YzvVfEXVcXwhzmZ pPi7b2xBrA5zqrnwxwr7K2+lbzRwiz3hRz/kOLRxXtZQqxrdBBDi4bLvR82C2/IP oB68anKAeZ7YiojniAjg2KbLnzqXPkpgRoVlulrBDjVvVqrGF4QvAiPle6CtWyDa +aKU5rCinhpiYg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 4AC2C24005C; Tue, 9 Mar 2021 18:31:50 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Declan Doherty , Ciara Power , Wisam Jaddo , Xiaoyun Li , Ori Kam Date: Wed, 10 Mar 2021 00:31:12 +0100 Message-Id: <20210309233116.1934666-9-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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: Ori Kam Acked-by: Wisam Jaddo --- .../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 Tue Mar 9 23:31:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88769 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 B9AB3A0567; Wed, 10 Mar 2021 00:32:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8A7F22A586; Wed, 10 Mar 2021 00:31:56 +0100 (CET) Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by mails.dpdk.org (Postfix) with ESMTP id 5B8D522A57F for ; Wed, 10 Mar 2021 00:31:54 +0100 (CET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id A15185803CD; Tue, 9 Mar 2021 18:31:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 09 Mar 2021 18:31:53 -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=z9q138BdglJgI nndfinARmV9LeG3Ecxpo8qz50GAHC0=; b=lE3T8EsxZzJIkhP4k2bGK9TvNeqvl j19Ef+c8qtEIrDYsN1gbf+UpF8jvtwkc6EAN+OBS6fF7vYSeBZRU4/eaRPLjOYN1 ufLuUgVkqlFdhWQGXUs7vkXtMb2y9Z72ob1/7IiBpkuxpQApf8Am9mqlcezQGq9x pvPXGKXexKvC6AvMtXS10y/X+WHt8jCPwp8MoSy5GLnonYz4YS8HaBCOsvA8xNka TdSJ8DnU/hvSo6ftgZvdgsSG6PlM6Px/UCXTEVbrbHDyoUJWUNGUrC7vFCtaTdhC Tgc2sOgYykSWoJKyBWEkzbN0m4+S8NBN71kOmT9Uz0rnIybY4VMPmxanA== 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=z9q138BdglJgInndfinARmV9LeG3Ecxpo8qz50GAHC0=; b=mShZB5c8 qHl6CUJuSYWgMzeBv793DrYWwFQGomSfAdmjH5lE6Vy9bSPZUgANezsa6OsEeoOe l4iO0Y0VYzNKWdz5B79LOiOg304HEx3Y6al6mVYI+YFxDMP25EZ3wBqgJtpcnXvS WVEtJ3XlTWc1xDdIacoE8Vg4ttgWHfSJtgsFwMNS/gz4W1nJKdkWQ9haPNpH+7Tq 11yObe3HtaUCA0/lGGoliZDuIJt7mPGc1911dgIAd+Mee52HKdCf4mvewZty/M+A mdX3JBwo0NcIVkUM547wVa1nvtlSkB58GUc12zoDUw4qMx08w8Zy/BAFUaF4ST9L VTpxxAZ6dLQcrg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 0A19124005D; Tue, 9 Mar 2021 18:31:51 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Reshma Pattan , Maryam Tahhan , Konstantin Ananyev , Nicolas Chautru , Declan Doherty , Ciara Power , Vladimir Medvedkin , Wisam Jaddo , Xiaoyun Li , Ori Kam , Bernard Iremonger Date: Wed, 10 Mar 2021 00:31:13 +0100 Message-Id: <20210309233116.1934666-10-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 Tue Mar 9 23:31:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 88770 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 B352DA0567; Wed, 10 Mar 2021 00:32:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 23FC222A58A; Wed, 10 Mar 2021 00:31:58 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 2598C22A580 for ; Wed, 10 Mar 2021 00:31:55 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CD3DE5C009A; Tue, 9 Mar 2021 18:31:54 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 09 Mar 2021 18:31:54 -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=0iGb1EX6bRZ4M 4k7oWO2//j0cXkeZoudMVbtxRDJaSM=; b=EtjSCh7eijSr7mNjsyiAQ/6etk4fz qhkaXSNWC6h+hgMkenv4LMvqqVgdszBZDm7hdpBOeKdbGFIWMSuh/egFQIjkg1Dz saS16V84DgWk8qObflWfGcxxv9O1bu6gqqJ0G/jSYbEQOUqZj4+aWXmEM3ewoZwv 0uj5cVdivGqoJawe6a+NNrSz5Hz0o+C7vPAeImz+OU6ZfzfO0845L2yP/C8xUJK3 OPFkUX1GBduUTf5Y3yRkgwHtBQCfaz10AbdwLmxeFfmGFlZOhHGUTsYFDITN3ZJj 6DglrOxLPGULcx8GUBuwnh92zWI4tKs3J2XJJZcRbe6joJtjX+wqRbGTQ== 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=0iGb1EX6bRZ4M4k7oWO2//j0cXkeZoudMVbtxRDJaSM=; b=Z0I2VR9c L7ubJmq3c65ow1TROr76kD9DqiyKAMSbJ/rdx5R0pg6l4mFOg90MvS6ef5/XZTV8 +Ctb31AZegHaGanH8Ms2EHcG/o9riF1nua9qYC0+82dp2AezaybX/E7/jh96P6HO KMNmqF+4DuNsOIyDaejWdIJB3AVSktfqqNXJpNP/CdKngpXqTDFcTXSTgOiy3ig4 lRp3WkIH3e0vuuAG+1Mh0n+hvBTwsU2lmyrJfU5uPL0sm7amZlrXu5BBY8y9Be3q 8OZ3NN6MsDJ0ollqj/F/SOu/o/25olYuAkGKVcIfqWAgNhRDfoKdOSSUt8DUJR5A 4pv7ZnjIvDcqEw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 4E844240057; Tue, 9 Mar 2021 18:31:54 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Ori Kam Date: Wed, 10 Mar 2021 00:31:14 +0100 Message-Id: <20210309233116.1934666-11-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 Tue Mar 9 23:31: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: 88771 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 50A87A0567; Wed, 10 Mar 2021 00:32:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63A2222A58F; Wed, 10 Mar 2021 00:32:02 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 157DF22A565 for ; Wed, 10 Mar 2021 00:32:01 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B41265C009A; Tue, 9 Mar 2021 18:32:00 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 09 Mar 2021 18:32:00 -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=h9gVufGQ3wdzAqPShesHBooOpwqWP ll8AgIL5mon0UR3KoAOxFEkgw7WyosbDHFfxWvq44O/Yw9uDNhthtgbctdlhM98K 5TKSNSnW7daLfKaQQCP7qEG9WlmXf3qZpVUb2hsg+YTCaY/aloPt9z1QF89Il+di rTiTJe/NI+2fE03nTtoNCugX2fuwLGmiS4OFakw2GYoP8zkkapU3R5MnosHz7x6J YWL6QYuU9LekZumuPP01fNPMnRqJYG6UYgefRV08yZxTeM9gWHQCI1oc8dCbMJB/ 7D/PpyJoVdkr2cJsUBt2gN+9NV5ZC0wfr9djJzKlC2nPKOEOBTkxS0W8g== 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=StVtvmrF GrgypFTLpRJg+BruSBx6S3pHOK9dclvaXbEF5Kt/C0v2TgQwrdCcXLfI7LP9JGqv kKQmUTX16G+t5Eu1Mk+aMgcuBfRL6iQ9dzZACcIdlQawne02UbjyzA82pW9VYwxq PPxcznKq5fQELHnymd5fEVq5wxtMhool4kAmDPuz4xmDdIcYsCCd6QlYsRT5AoCA Kfg+RKMyqRLtoNjngzHs2d2McyMYKLSlNTC7CRD18/o+f11H8z04uAj10wv95g8n 4iWcrhz9hpoEO26XSyqQuHkVyMwJLz9FQ2rmNyYk2Y5GotukLZhewd1e3iGXiIjC q3FpMYtf76Pz/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduiedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 3EC7524005D; Tue, 9 Mar 2021 18:32:00 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Xiaoyun Li Date: Wed, 10 Mar 2021 00:31:15 +0100 Message-Id: <20210309233116.1934666-12-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309233116.1934666-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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 Acked-by: Ajit Khaparde --- 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"); }