From patchwork Mon Oct 16 14:06:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 259 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 8A4194317F; Mon, 16 Oct 2023 16:06:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12307402CB; Mon, 16 Oct 2023 16:06:27 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 78B7D40269 for ; Mon, 16 Oct 2023 16:06:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697465185; x=1729001185; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ULtPnmkxtZBejm2EIOt2eM6wvAafXm+p0gQq/5mID1Y=; b=am/6DSfDQOHrQVcMBXIMzMem5BLPI4g21giQtVa4RvGS1jjriiz7KYPp PpxYDthXZU0dR4oyewFYmvJTScC2cM2Hsu49xs3T0u8kiRXnsit1vOTXb IT9PeJjxJTwUZkZvhW8vykje5UW6NP2JJwQmFrYtdmnstuC2nPyD0wZqR 8wQBftBOSHPwd+32PwoUakNbXqCinw5FCHPoqvc1yImH2bexrFaCo/Elm 2JF/wYHuJaJIJ3tTbmT829R8L5al7A+dFSU9AqqeRa+W/S6Di2gq8KvVe NX5sMKo+O53M0PRP0LzqoJ/TOjdC4+ldkv89rDQn37uiOQxTgJ1FpWe6r Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="385370264" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="385370264" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 07:06:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="821583844" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="821583844" Received: from silpixa00401385.ir.intel.com ([10.237.214.154]) by fmsmga008.fm.intel.com with ESMTP; 16 Oct 2023 07:06:22 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, rjarry@redhat.com, Bruce Richardson Subject: [PATCH v4 0/7] document and simplify use of cmdline Date: Mon, 16 Oct 2023 15:06:05 +0100 Message-Id: <20231016140612.664853-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230802170052.955323-1-bruce.richardson@intel.com> References: <20230802170052.955323-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The DPDK commandline library is widely used by apps and examples within DPDK, but it is not documented in our programmers guide and it requires a lot of boilerplate code definitions in order to used. We can improve this situation by creating a simple python script to automatically generate the boilerplate from a list of commands. This patchset contains a new documentation chapter on cmdline library, going through step-by-step how to add commands and create the necessary token lists and parse contexts. Following that initial doc patch, the set then contains a boilerplate-generating script, as well as a set of four patches showing its use, by converting four examples to use the script instead of having the hard-coded boilerplate. Once the script is used, adding a new command becomes as simple as adding the desired command to the .list file, and then writing the required function which will be called for that command. No other boilerplate coding is necessary. Script obviously does not cover the full range of capabilities of the commandline lib, but does cover the most used parts. The code-saving to each of the examples by auto-generating the boilerplate is significant, and probably more examples with commandlines can be converted over in future. The "cmdline" example itself, is not converted over, as it should probably remain as a simple example of direct library use without the script. V4: * Reworked script following feedback from Robin J. - formatted code with black - used multi-line strings - replaced sys.exit(1) with proper error handling - per-command function returns lists rather than printing directly - other small cleanups * Added change to CI script so the cmdline script is in PATH * Converted VDPA example to script, saving another 100 LOC V3: * Added lots of documentation * Added support for help text for each command * Cleaned up script a little so it passes pycodestyle and most flake8 checks, when line-length is set to max 100. * Removed RFC tag, as I consider this patchset stable enough for consideration in a release. V2-RFC: * Add support for IP addresses in commands * Move to buildtools directory and make installable * Convert 3 examples to use script, and eliminate their boilerplate Bruce Richardson (7): doc/prog_guide: new chapter on cmdline library buildtools: script to generate cmdline boilerplate ci: allow use of DPDK tools when building examples examples/simple_mp: auto-generate cmdline boilerplate examples/hotplug_mp: auto-generate cmdline boilerplate examples/bond: auto-generate cmdline boilerplate examples/vdpa: auto-generate cmdline boilerplate .ci/linux-build.sh | 1 + app/test/commands.c | 2 + buildtools/dpdk-cmdline-gen.py | 190 +++++++ buildtools/meson.build | 7 + doc/guides/prog_guide/cmdline.rst | 466 ++++++++++++++++++ doc/guides/prog_guide/index.rst | 1 + examples/bond/Makefile | 12 +- examples/bond/commands.list | 6 + examples/bond/main.c | 161 +----- examples/bond/main.h | 10 - examples/bond/meson.build | 8 + examples/multi_process/hotplug_mp/Makefile | 12 +- examples/multi_process/hotplug_mp/commands.c | 147 +----- examples/multi_process/hotplug_mp/commands.h | 10 - .../multi_process/hotplug_mp/commands.list | 5 + examples/multi_process/hotplug_mp/meson.build | 9 + examples/multi_process/simple_mp/Makefile | 12 +- examples/multi_process/simple_mp/meson.build | 9 + .../multi_process/simple_mp/mp_commands.c | 106 +--- .../multi_process/simple_mp/mp_commands.h | 14 - .../multi_process/simple_mp/mp_commands.list | 3 + examples/vdpa/Makefile | 12 +- examples/vdpa/commands.list | 5 + examples/vdpa/main.c | 131 +---- examples/vdpa/meson.build | 7 + 25 files changed, 796 insertions(+), 550 deletions(-) create mode 100755 buildtools/dpdk-cmdline-gen.py create mode 100644 doc/guides/prog_guide/cmdline.rst create mode 100644 examples/bond/commands.list delete mode 100644 examples/bond/main.h delete mode 100644 examples/multi_process/hotplug_mp/commands.h create mode 100644 examples/multi_process/hotplug_mp/commands.list delete mode 100644 examples/multi_process/simple_mp/mp_commands.h create mode 100644 examples/multi_process/simple_mp/mp_commands.list create mode 100644 examples/vdpa/commands.list --- 2.39.2