From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA0534318A; Tue, 17 Oct 2023 14:14:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B86742DD5; Tue, 17 Oct 2023 14:13:43 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 3D3E142DD1 for ; Tue, 17 Oct 2023 14:13:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697544821; x=1729080821; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nrh2QEcPYXHy5z6ZMIMwAZa6NQVMVm+y1GmBaMLNH8w=; b=QN1vDoRjhdQwAGBagYL4IIFopFSyunEfZA2asEVRm3t8LXFX0DG/hNKz DOUXkAJNemiLZbNLsX4CJs1ax2UE32KfQQTQ0gcllr7k6brUxAIHk9zDW zosVPNk4s8XM5ruTngyJ7zv9SnI9/j7+egjOQ4pPowojVcMmIuK3X7s9g qFGBrZRMsrQVP4r32rucO/mr+aAXPAlXAzKVLmzymVhm8LaSMY5GWKqtB QDYFwZi/paMdD8v35bsAVJo2fwBa3oCexty59rncA877YGyUt+uMPQipG yE6rKXk9bZaVgT1F+wsrUvVuysmkocQd1bfXX8yu7F9pj5nASwHf0xF8D A==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="449984835" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="449984835" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 05:13:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="4068982" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.41]) by fmviesa001.fm.intel.com with ESMTP; 17 Oct 2023 05:13:45 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, rjarry@redhat.com, Bruce Richardson Subject: [PATCH v5 8/9] buildtools/dpdk-cmdline-gen: support option strings Date: Tue, 17 Oct 2023 13:13:17 +0100 Message-Id: <20231017121318.146007-9-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017121318.146007-1-bruce.richardson@intel.com> References: <20230802170052.955323-1-bruce.richardson@intel.com> <20231017121318.146007-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Add support to the commandline generator for option strings, where there are only a limited number of acceptable values to be passed as a parameter. Signed-off-by: Bruce Richardson --- buildtools/dpdk-cmdline-gen.py | 7 +++++++ doc/guides/prog_guide/cmdline.rst | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py index 6cb7610de4..fe74194121 100755 --- a/buildtools/dpdk-cmdline-gen.py +++ b/buildtools/dpdk-cmdline-gen.py @@ -73,6 +73,13 @@ def process_command(lineno, tokens, comment): f"cmdline_parse_token_ipaddr_t cmd_{name}_{t_name}_tok =\n" + f"\tTOKEN_IPV4_INITIALIZER(struct cmd_{name}_result, {t_name});" ) + elif t_type.startswith("|") and t_type.endswith("|"): + result_struct.append(f"\tcmdline_fixed_string_t {t_name};") + t_val = f'"{t_type[1:-1].replace("|","#")}"' + initializers.append( + f"static cmdline_parse_token_string_t cmd_{name}_{t_name}_tok =\n" + + f"\tTOKEN_STRING_INITIALIZER(struct cmd_{name}_result, {t_name}, {t_val});" + ) else: raise TypeError(f"Error line {lineno + 1}: unknown token type '{t_type}'") token_list.append(f"cmd_{name}_{t_name}_tok") diff --git a/doc/guides/prog_guide/cmdline.rst b/doc/guides/prog_guide/cmdline.rst index 0b96b770e2..1268eca911 100644 --- a/doc/guides/prog_guide/cmdline.rst +++ b/doc/guides/prog_guide/cmdline.rst @@ -62,7 +62,8 @@ The format of the list file must be: * One command per line -* Variable fields are prefixed by the type-name in angle-brackets, for example: +* Variable fields are prefixed by the type-name, or "|"-delimited option-list, in angle-brackets. + For example: * ``message`` @@ -70,6 +71,8 @@ The format of the list file must be: * ``src_ip`` + * ``<|rx|tx|rxtx|>mode`` + * The help text for a command is given in the form of a comment on the same line as the command An example list file, with a variety of (unrelated) commands, is shown below:: @@ -79,6 +82,7 @@ An example list file, with a variety of (unrelated) commands, is shown below:: add x y # add x and y echo message # print message to screen add socket path # add unix socket with the given path + set mode <|rx|tx|>rxtx # set Rx-only or Tx-only mode quit # close the application Running the Generator Script -- 2.39.2