From patchwork Mon Apr 5 19:39:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 90580 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 68125A0A02; Mon, 5 Apr 2021 21:40:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30CB0140E8F; Mon, 5 Apr 2021 21:40:04 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 715D5140E7F for ; Mon, 5 Apr 2021 21:40:02 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 1EA6B1AB4; Mon, 5 Apr 2021 15:40:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Apr 2021 15:40:01 -0400 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=8M86ZRqJouHsP qA+DZhONvETjCjzzEHdwzFkSHfiFpY=; b=FrM1+JgZhAv0jFlZQMh8/+o+IIB0t O8nB0slwG4K2JZNjwq7+jQT5Zuda1wycLImLfugnKKQNXuRLpymIhjScl3L9GVS9 MYknNXE54LTFz2uM2Xyj1P5O+b7i5tV5XSmQ2tS06J3IejnLK6FXfmP7/P+1s4Q3 GKgdxSqe7fDbHZ1eFlNROL/54E7fAy2whCrKGt81Xpdp1uNOJjAzJJmw1NPbteP5 aCGtVtAZBVJdIh4VTxNfiBmcV5cBEUHAMtaKro/hBVEJRcJMex/3Gxe/XFFQq1b0 lCYZAyFqcX+0jPnvCQWPZFHrAXx25g3muo61bbycIIOFeY8um2GL7ZNqQ== 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=8M86ZRqJouHsPqA+DZhONvETjCjzzEHdwzFkSHfiFpY=; b=kgpJ12lj vFOZZ1O7l6yhY7xCSWHWVAa51LuCBdk8bVTtFbG43KeR4z7penPwLTlRNN7U0m17 0RJpP+wENGZ2dGR2k0SnlhBNhp9YX+4v8vYSKC6xgNjbuTvOq45qdT4CHrlhzUrm Q0wwetUYEgmIT8AnvRSTBxG7/7UrNxsp2Xq27MYrdKJ/gAyqAfaeKWnnf5wY0T2/ XvBNE2Gqrga6RPyNJWos2Iv/4DbUTf/76hIF+41gvrPjcItsTvpSeJZ+nPhxDeHY DsoFzPEc1jaUFYggPdt1E3EzxdY4Q7Onx8MssqO4uHUHlBdtkbOQPiun6CQYXNpK fyv9yL0geRafdw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejvddgudegvdcutefuodetggdotefrod 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 1AB7124005C; Mon, 5 Apr 2021 15:39:59 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko Date: Mon, 5 Apr 2021 21:39:51 +0200 Message-Id: <20210405193954.1115838-2-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405193954.1115838-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210405193954.1115838-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 1/4] 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 Acked-by: Bruce Richardson Acked-by: Andrew Rybchenko Acked-by: Stephen Hemminger --- 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 Mon Apr 5 19:39:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 90579 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 F1680A0A02; Mon, 5 Apr 2021 21:40:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 13DB4140E7F; Mon, 5 Apr 2021 21:40:03 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mails.dpdk.org (Postfix) with ESMTP id 4355C140E6B for ; Mon, 5 Apr 2021 21:40:02 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id BE7115C00DA; Mon, 5 Apr 2021 15:40:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Apr 2021 15:40:01 -0400 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=+wDtPAtYgz2/a JNatSGKJxMa5shOKq3U7iMFWCEcBfk=; b=YUuWdxwjJGo5xENwwkjxOY2nbdPpm ZMxlZfuBpZwE2JNrFqd7weiq8VWhNzgWrRP98W5VA/NLsR0GVmhbdOxBUcaJWaY1 lrpdn0FBkRaip+9rllqNcgoTX8bmVmn6OpOWbyc6a169Rccu/OXkEq2O3bXJSwSE L5aT45/pQwSjzrffL4fHqKI8U0MS+R9z1UDwwxNJ4LjolTrX5BojRmX0SVCKqK2s /PUQQdOa+9BTvZWkBK8W45oeZroZdjyvlkZI8mO827s1nnRRsCqN3s3SSDyevBRQ E8c7cYSEB81OcPD4aPBO2/z7QE3gW2AmfKWbsJcCy/FGArTlLaTaxuEVw== 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=+wDtPAtYgz2/aJNatSGKJxMa5shOKq3U7iMFWCEcBfk=; b=Vx8yhyxa vLqaXaWg8ZJQvqeluPNZNTa0rx+xmAYoDn4V9TA5KzVK2Wxlx0u2p/1KLmK1tgKi 2LZ6l5Q6RHh4sVe91AtCyJ0ecbybubi1lCGyr+aORoH7jRCjxH7AF3yZojWgBwKA IfjklWmy7pip2hqu53QWCmNufuzsz6881DaiznKsmvheHOBAwig5Ga/B2F3cXGtE jgdghiT4uZtBuC8yvtMOTUjFLdnBvqmiwoby1TfJO4PPhUvdkFDuQSsTnnJi0/A0 wsBvKRjGOQE+j0Sf5S6wzybzI1HKXTcM93kdc1T8DUDywUaI/Rjtq3v95gsbNtQQ xzLCEgfH0m9vMA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejvddgudegvdcutefuodetggdotefrod 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 7E475240054; Mon, 5 Apr 2021 15:40:00 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Mon, 5 Apr 2021 21:39:52 +0200 Message-Id: <20210405193954.1115838-3-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405193954.1115838-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210405193954.1115838-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 2/4] 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 Acked-by: Bruce Richardson Acked-by: Andrew Rybchenko Acked-by: Stephen Hemminger --- 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 2951b1aca2..08a85614c9 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -2045,8 +2045,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" @@ -2076,7 +2075,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" @@ -2116,11 +2115,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 32442e5ba6..4e10d37253 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 ac27dd4274..4f36f9b1f5 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -535,7 +535,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" @@ -549,11 +554,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 68a1fd1d21..25921eecb2 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -80,15 +80,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 Mon Apr 5 19:39:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 90581 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 75E22A0A02; Mon, 5 Apr 2021 21:40:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49C5A140EA2; Mon, 5 Apr 2021 21:40:06 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mails.dpdk.org (Postfix) with ESMTP id 9F3EB140EA1 for ; Mon, 5 Apr 2021 21:40:05 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 4A76C5C00DD; Mon, 5 Apr 2021 15:40:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Apr 2021 15:40:05 -0400 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=wxdcFhmC6t5IU BjUubxA0BwG6Hnt75Jsjp/N/uMeERY=; b=tjc5c0LvSmqXa+F0l5LgX74gKx+f+ YDJUCJBXrKTIyyPtZw85iqw5oQPP1QRxJ85xH5CJ/4cayiIOx0Wr642X1NPugDzh 2ELBM0PFoblDEAufSICMPYJ/VGa/MYUv0S8BiygPj5vG2G80Di7kcU9lxRXRaHmh T8opIBYygQaHSSDnDcGNy0cPbH35jr5OKRx1H5AtGGn6oxzIAaNMgqyV87l5OvJf XDeJTVV9yXQEfs9iQutQLI6fDhPreocg+Q7Vu0inetxcnZ3DldINalNjIDjDW2lW bF7ol+ToyiOZCOgcZk0nuthjNijmyB41MaWtq0UPNosiuo+IEPZcBhuQA== 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=wxdcFhmC6t5IUBjUubxA0BwG6Hnt75Jsjp/N/uMeERY=; b=DDczXku7 QsouOzvu2sEKglSOF4WCFwccsU9ACKudhDXXdZ6wDGuON1BaTvvWg9f+/znqEMjy EwI9SPdtidfrEIadi4SHNJa/YN464WNomq7tze7DnEzON94D1HpJX9lWuQx0yT91 xfQT86ZQ+3Pw+0+PpOWSe7bjfd/3041Zjdo9FZWsCxfKAKuh8zcInqor38I73bCT 6XJh3l5Ht6A/ROLfWDQ+bxYVOXIvRDt/yzvFF0Wqoyc9veeoZy+V8Hh8637LtCNH 45No//I8v2vQsGIhZJI6+WG2v7x0EpIgB4kDWz+tddC7Ua7ClaqNBrYv50foN8TY tJq9EfrX9FkZ8Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejvddgudegvdcutefuodetggdotefrod 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 6E414240054; Mon, 5 Apr 2021 15:40:02 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Mon, 5 Apr 2021 21:39:53 +0200 Message-Id: <20210405193954.1115838-4-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405193954.1115838-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210405193954.1115838-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 3/4] 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 Acked-by: Bruce Richardson Acked-by: Andrew Rybchenko Acked-by: Stephen Hemminger --- 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 08a85614c9..1da6583d71 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -2114,7 +2114,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 4e10d37253..73229ff9c4 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 4f36f9b1f5..d3615de641 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -717,7 +717,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 25921eecb2..5bca3ace1c 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -159,7 +159,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 Mon Apr 5 19:39:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 90582 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 4EA70A0A02; Mon, 5 Apr 2021 21:40:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F744140EAC; Mon, 5 Apr 2021 21:40:10 +0200 (CEST) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by mails.dpdk.org (Postfix) with ESMTP id 83674406A3 for ; Mon, 5 Apr 2021 21:40:09 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 2D0465801F7; Mon, 5 Apr 2021 15:40:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Apr 2021 15:40:09 -0400 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=hVBaC/6u41/Lc 3R1jVPMwh//Yck4T5XsjV5FVMizXLY=; b=rHBRunxQRRmdsR83KDehHhwEc4tJm nI+8KMp9LLpoA5+zZ984MwFxX8Sni9h7YsQAuqV41WVdYlnOLBz5izxsWy5SLPN3 QJHJY4QSpmYXIGj4y0CPvZzLyMtWQpoj47CH9Ts5clcIzLS2XFzE3HA/dXERczBo uB0ir6lxRxQpSKjZVEOvCZaBzBjeXE8v3PZuIZp1HZbIkbVp/UrUxz9yJOZmQ9tA muqm75LYFqKIXSsa/2sKbIiPPXdo3HsgGAGlZrL5ywVmnYQakkSNxUj3wwFY9x4c RxjUlxfEkRaaNtpFBQ2p2L6Cd+EcwnhDLpTIxojZUiC8g2Cu5h9NoKyKA== 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=hVBaC/6u41/Lc3R1jVPMwh//Yck4T5XsjV5FVMizXLY=; b=eKiXc6Ig 5cDUu8w7Q48e79az39EasmXed2UnB1ggEDoo/P0odxGymfn6Cvr5GsjNTKKYBtiz b53kQ690oKM0Su5FHtFdGlvWZ82rtsrddj94fisFlg/dNaUHku+qsBKSCGO6P8i+ MsaNTulX5oiaArw5Yjf0OKnk5QfWemXsewhRIVAq+Q2KZcoLU+vzT3s11Y/AnTkf 1nNjzkVCSRJmV5BsQw0QvqTD9xdseO6IKJwv/l3ZJtjRHLINuG5CUb2rBlPYD5tw DDRXyIvzzJ3FohVNL9N57Cqh22H1gxqhdZjMClZrrzIzW6oLt8WhrUYRfrbVA0Pk hcFOp4Fz59OF7A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejvddgudegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr 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 8DD3B240057; Mon, 5 Apr 2021 15:40:07 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Wisam Jaddo , Bruce Richardson , Andrew Rybchenko , Reshma Pattan , Maryam Tahhan , Konstantin Ananyev , Nicolas Chautru , Declan Doherty , Ciara Power , Vladimir Medvedkin , Xiaoyun Li , Ori Kam , Bernard Iremonger Date: Mon, 5 Apr 2021 21:39:54 +0200 Message-Id: <20210405193954.1115838-5-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405193954.1115838-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210405193954.1115838-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 4/4] 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 Acked-by: Bruce Richardson Acked-by: Andrew Rybchenko --- 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 f3954c1c63..4a1d64af89 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("\nUsage: %s [EAL options] -- [testpmd options]\n\n", progname); diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 96d2e0fcec..007ae429a1 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3781,6 +3781,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 a87ccb0f0f..1f9408ebb9 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -764,6 +764,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 f18dc2eef8..73ba227fba 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");