From patchwork Tue Dec 5 14:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 134881 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 2F2014367A; Tue, 5 Dec 2023 15:51:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FF4A42E58; Tue, 5 Dec 2023 15:51:25 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 569E642E58 for ; Tue, 5 Dec 2023 15:51:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701787882; x=1733323882; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OCsFSOn3iM4pELdEM4DDLNx4PPzoa0spQ3Fn0lz2igQ=; b=UArB9gxnBKzeKbfSrdZcRZBYiRD8ObnfIEVIGVggyhAYZedovkhnmhwC C5X9u/zDRM0G3iOuoYJt+Jt4ILfyWfBLAMclFQCcK/aOfvlcYEWnMtuN9 wlK3FTxDZKd6UJ+1+HsWgjA0k441oZ3rYQbPQBSkAyDUr9F61TjHlaPOf tdM2+IYU4kdf5X77k0k912xr4v34maz2hhEC6YJnkSblUAaaTFvz67lJM qzRg2w0mJM2YovxAmWK1Ci7Q8VCo/9jr1T1UiIH9UdENFigz/Q5zinoCa jSHl3iS7wufBoDVrqBHrTFEkevevk21B5b3FrLTBUls8SwA/hN3mXsU+f g==; X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="374089947" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="374089947" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 06:51:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="1018234152" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018234152" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.152]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 06:51:20 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: skori@marvell.com, david.marchand@redhat.com, Bruce Richardson Subject: [PATCH 1/3] buildtools/dpdk-cmdline-gen: support optional parameters Date: Tue, 5 Dec 2023 14:51:07 +0000 Message-Id: <20231205145109.1000464-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231205145109.1000464-1-bruce.richardson@intel.com> References: <20231205145109.1000464-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 Sometimes a user may want to have a command which takes an optional parameter. For commands with an optional constant string, this is no issue, as it can be configured as two separate commands, e.g. start start tx_first. However, if we want to have a variable parameter on the command, we hit issues, because variable tokens do not form part of the generated command names used for function and result-struct naming. To avoid duplicate name issues, we add a special syntax to allow the user to indicate that a particular variable parameter should be included in the name. Any leading variable names starting with a "__" will be included in command naming. This then allows us to have: start start tx_first start tx_first __n without hitting any naming conflicts. Signed-off-by: Bruce Richardson Acked-by: Sunil Kumar Kori --- buildtools/dpdk-cmdline-gen.py | 9 ++++++++- doc/guides/prog_guide/cmdline.rst | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py index bf1253d949..faee4ffca7 100755 --- a/buildtools/dpdk-cmdline-gen.py +++ b/buildtools/dpdk-cmdline-gen.py @@ -40,7 +40,12 @@ def process_command(lineno, tokens, comment): name_tokens = [] for t in tokens: if t.startswith("<"): - break + # stop processing the name building at a variable token, + # UNLESS the token name starts with "__" + t_type, t_name = t[1:].split(">") + if not t_name.startswith("__"): + break + t = t_name[2:] # strip off the leading '__' name_tokens.append(t) name = "_".join(name_tokens) @@ -51,6 +56,8 @@ def process_command(lineno, tokens, comment): if t.startswith("<"): t_type, t_name = t[1:].split(">") t_val = "NULL" + if t_name.startswith("__"): + t_name = t_name[2:] else: t_type = "STRING" t_name = t diff --git a/doc/guides/prog_guide/cmdline.rst b/doc/guides/prog_guide/cmdline.rst index b804d7a328..fc32d727dc 100644 --- a/doc/guides/prog_guide/cmdline.rst +++ b/doc/guides/prog_guide/cmdline.rst @@ -155,6 +155,19 @@ To get at the results structure for each command above, the ``parsed_result`` parameter should be cast to ``struct cmd_quit_result`` or ``struct cmd_show_port_stats_result`` respectively. +.. note:: + + In some cases, the user may want to have an optional variable parameter at the end of a command. + Such a variable parameter would not normally be included in the ```` string, + leading to duplicate definition errors. + To work around this, + any variable token with a name prefixed by ``'__'`` will be included in the cmdname string, + with the prefix removed. + Using this, it is possible to have commands, such as: + ``start tx_first`` and ``start tx_first __n``, without them conflicting. + The resulting code generated will expect functions called ``cmd_start_tx_first_parsed`` + and ``cmd_start_tx_first_n_parsed`` respectively. + Integrating with the Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From patchwork Tue Dec 5 14:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 134882 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 40F0C4367A; Tue, 5 Dec 2023 15:51:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5C2842E5D; Tue, 5 Dec 2023 15:51:28 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 1D47F42E67; Tue, 5 Dec 2023 15:51:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701787887; x=1733323887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mB87Yr8bI3gEWYh6yom5zPrqVYFbbAmIkyiCru9TvYw=; b=lEmYHG6u4VZ5NbIrIOHrT/5Kp5xsOfSZkJmblK9pQ+E2PmscLW3yDrsP 8rNnJ0SPZMNoKd67Gyespz/sEf9aI93w01N0uxNGrI2OyHJql2TGtXcZl NB07bsKLQRZcu924b1md0TSio8XAIGf2bM9yr9a9S0L5jCZPXEYWiroQn u12srE6hTy3TwMF9NyKyvhNXe5nG0if89wD8PsdEY3NufZQxlisa8GdlE a7IJkKTFdreWqXka5xMputqByHPEqVcqDdYqsOt1p+fdCBlPTSXUEZL1M rHfMSxjQwVPQkMg6+7iK+f0Gt8PBXByz9gYh/q2EmB8/j4muTjEyK0Fd9 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="374089969" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="374089969" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 06:51:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="1018234168" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018234168" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.152]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 06:51:25 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: skori@marvell.com, david.marchand@redhat.com, Bruce Richardson , stable@dpdk.org Subject: [PATCH 2/3] buildtools/dpdk-cmdline-gen: fix IP address initializer Date: Tue, 5 Dec 2023 14:51:08 +0000 Message-Id: <20231205145109.1000464-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231205145109.1000464-1-bruce.richardson@intel.com> References: <20231205145109.1000464-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 IP address type should be generic for both IPv4 and IPv6 and so use the cmdline lib's TOKEN_IPADDR_INITIALIZER rather than TOKEN_IPV4_INITIALIZER. Fixes: 37666691e9ed ("buildtools: add a tool to generate cmdline boilerplate") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Acked-by: Sunil Kumar Kori --- buildtools/dpdk-cmdline-gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py index faee4ffca7..8b4f22ca24 100755 --- a/buildtools/dpdk-cmdline-gen.py +++ b/buildtools/dpdk-cmdline-gen.py @@ -79,7 +79,7 @@ def process_command(lineno, tokens, comment): result_struct.append(f"\tcmdline_ipaddr_t {t_name};") initializers.append( f"static cmdline_parse_token_ipaddr_t cmd_{name}_{t_name}_tok =\n" - f"\tTOKEN_IPV4_INITIALIZER(struct cmd_{name}_result, {t_name});" + f"\tTOKEN_IPADDR_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};") From patchwork Tue Dec 5 14:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 134883 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 594FF4367A; Tue, 5 Dec 2023 15:51:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0ABB542E66; Tue, 5 Dec 2023 15:51:32 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 69DE342E6C for ; Tue, 5 Dec 2023 15:51:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701787890; x=1733323890; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VzGkMUWknDCgMZALZwpoUeosfzY66DbU5lXtz7m+XKA=; b=RuX9/9oBSVp1+rSjB7M0YlkwUzXzPIgAWEvpJRGbYlNGXkqDdi3mxQo9 BeCdya+QaIRxsWqHOYzjfROea8QPeF9NziIY1g3o1qyCNNYBRFyYwiKut U0BJvt2nm/zYYsLklgdaMcWpwyHhhW76hptGC56QVernrKsCA7+fpeCvE IqrIp3krB46RF/ZGPPHQUA0hGTFPNMmSd6+OJRWXy6Yrp+mIENURFqQCg y/MaIjd+i9ty/H3c1vzRLU9qtVjrxQJW4cmsP/9wRuM5K9vb83eNAEm2y AL+/7izBg4gsMWGUsaG10D1WD9fX3lPGpDuaKh0ZexUOlzwS5ew9cnUWN g==; X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="374089987" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="374089987" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 06:51:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="1018234180" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018234180" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.152]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 06:51:28 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: skori@marvell.com, david.marchand@redhat.com, Bruce Richardson Subject: [PATCH 3/3] buildtools/dpdk-cmdline-gen: add explicit IPv4 and v6 types Date: Tue, 5 Dec 2023 14:51:09 +0000 Message-Id: <20231205145109.1000464-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231205145109.1000464-1-bruce.richardson@intel.com> References: <20231205145109.1000464-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 for generating cmdline lib code to just match IPv4 addresses or IPv6 addresses, rather than IP addresses in general. Signed-off-by: Bruce Richardson Acked-by: Sunil Kumar Kori --- buildtools/dpdk-cmdline-gen.py | 12 ++++++++++++ doc/guides/prog_guide/cmdline.rst | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py index 8b4f22ca24..7dadded783 100755 --- a/buildtools/dpdk-cmdline-gen.py +++ b/buildtools/dpdk-cmdline-gen.py @@ -81,6 +81,18 @@ def process_command(lineno, tokens, comment): f"static cmdline_parse_token_ipaddr_t cmd_{name}_{t_name}_tok =\n" f"\tTOKEN_IPADDR_INITIALIZER(struct cmd_{name}_result, {t_name});" ) + elif t_type in ["IPV4", "IPv4", "IPV4_ADDR"]: + result_struct.append(f"\tcmdline_ipaddr_t {t_name};") + initializers.append( + f"static cmdline_parse_token_ipaddr_t cmd_{name}_{t_name}_tok =\n" + f"\tTOKEN_IPV4_INITIALIZER(struct cmd_{name}_result, {t_name});" + ) + elif t_type in ["IPV6", "IPv6", "IPV6_ADDR"]: + result_struct.append(f"\tcmdline_ipaddr_t {t_name};") + initializers.append( + f"static cmdline_parse_token_ipaddr_t cmd_{name}_{t_name}_tok =\n" + f"\tTOKEN_IPV6_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(",","#")}"' diff --git a/doc/guides/prog_guide/cmdline.rst b/doc/guides/prog_guide/cmdline.rst index fc32d727dc..f62f17f1aa 100644 --- a/doc/guides/prog_guide/cmdline.rst +++ b/doc/guides/prog_guide/cmdline.rst @@ -70,6 +70,10 @@ The format of the list file must be: * ``src_ip`` + * ``dst_ip4`` + + * ``dst_ip6`` + * 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,