From patchwork Fri Oct 27 11:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 133500 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 F0A8743215; Fri, 27 Oct 2023 13:02:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0E2042E16; Fri, 27 Oct 2023 13:01:45 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mails.dpdk.org (Postfix) with ESMTP id B0FFC42DE4 for ; Fri, 27 Oct 2023 13:01:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698404503; x=1729940503; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v7tOydz7c2Oi7K1r/7WRSvnD7983WFxKHsT4L58/8bk=; b=oERTwo6Ye4NyZsCmQJhH+8GWBv3Vd+Y8OhVgWfM0PWJRavF1ImEkPSIZ xZHlZdmHv4/Z1gVJYWTlfcnQgq1T1JsBj0hpxauHX3gagcxI622U9XBEh zgaeTslZow1ywotAaYTtfU/Fb5LSWSVytE0dDEJOI0p8XQoveDqJpFFoa JMOk3l67hAx2SEqO96lvMrXkcsdm4zTf+5GlraXX86T2QacgqkRqjY7Rx kXtZwDHm+3bLHu2Ho/+T52xO7UGN9l28yinC7QTKmfKqOq1aYQdPT/U+4 ZKVMxXsi9pgVy2V1T5qnDhau75c0nDeL8Hy+QS+Nffj2G131ZrLb2Tybn Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="546715" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="546715" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 04:01:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="883157876" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="883157876" Received: from silpixa00401385.ir.intel.com ([10.237.214.154]) by orsmga004.jf.intel.com with ESMTP; 27 Oct 2023 04:01:41 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, rjarry@redhat.com, Bruce Richardson Subject: [PATCH v7 8/9] buildtools/dpdk-cmdline-gen: support option strings Date: Fri, 27 Oct 2023 12:01:16 +0100 Message-Id: <20231027110117.70995-9-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231027110117.70995-1-bruce.richardson@intel.com> References: <20230802170052.955323-1-bruce.richardson@intel.com> <20231027110117.70995-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 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 | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py index c208121363..8922bb5fc3 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..42e6a54bf4 100644 --- a/doc/guides/prog_guide/cmdline.rst +++ b/doc/guides/prog_guide/cmdline.rst @@ -70,6 +70,12 @@ The format of the list file must be: * ``src_ip`` +* Variable fields, which take their values from a list of options, + have the comma-separated option list placed in braces, rather than a the type name. + For example, + + * ``<(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 +85,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