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 235C4431E2; Mon, 23 Oct 2023 15:17:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6909442DE5; Mon, 23 Oct 2023 15:16:19 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id A3F6742DCA for ; Mon, 23 Oct 2023 15:16:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698066972; x=1729602972; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wkTcjP5qe1CywPmC5qijXWAQ59uXfCZti8EPPx6DQyw=; b=lx33HnCqgPUpqYfaKdqr6yH4tV6iQarsTTgjkxdea0la6tYBwpDj3Ahv wBj6zqlSm66rF4zlazM59fHxyyU+UnkEI8G+y6bEcQ+Ckt3/crHGMTuQt B8P6NYxC4p2RcXovVBx6UNgoF7EnVKRS9KW10DaHbhwx5aFeGnqcsne1j BBtV2vT4OdP0QCo3z0Rxcu8zfYNHuByH8YHkpgGrm327M+k+MSie5ITuA Ok4gKJN7a7CyewpJKZEUAJ5b/7VpBGyOqIuDcsDbuq8sDV0DfnyhJgOsU W9mPseXQkxhCmkkE/BOeMx2iD9Ntx77mPwEfTT4auWY8nuOFK/HXfZgBv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="384033713" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="384033713" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2023 06:16:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="931680677" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="931680677" Received: from silpixa00401385.ir.intel.com ([10.237.214.154]) by orsmga005.jf.intel.com with ESMTP; 23 Oct 2023 06:16:11 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson Subject: [PATCH v6 8/9] buildtools/dpdk-cmdline-gen: support option strings Date: Mon, 23 Oct 2023 14:15:51 +0100 Message-Id: <20231023131552.1024375-9-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231023131552.1024375-1-bruce.richardson@intel.com> References: <20230802170052.955323-1-bruce.richardson@intel.com> <20231023131552.1024375-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 | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py index 6cb7610de4..c4c0411c27 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 -- 2.39.2