[3/3] buildtools/dpdk-cmdline-gen: add explicit IPv4 and v6 types

Message ID 20231205145109.1000464-4-bruce.richardson@intel.com (mailing list archive)
State Accepted
Delegated to: David Marchand
Headers
Series enhancements for dpdk-cmdline-gen script |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues

Commit Message

Bruce Richardson Dec. 5, 2023, 2:51 p.m. UTC
  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 <bruce.richardson@intel.com>
---
 buildtools/dpdk-cmdline-gen.py    | 12 ++++++++++++
 doc/guides/prog_guide/cmdline.rst |  4 ++++
 2 files changed, 16 insertions(+)
  

Comments

Sunil Kumar Kori Dec. 6, 2023, 7:42 a.m. UTC | #1
> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Tuesday, December 5, 2023 8:21 PM
> To: dev@dpdk.org
> Cc: Sunil Kumar Kori <skori@marvell.com>; david.marchand@redhat.com;
> Bruce Richardson <bruce.richardson@intel.com>
> Subject: [EXT] [PATCH 3/3] buildtools/dpdk-cmdline-gen: add explicit IPv4
> and v6 types
> 
> External Email
> 
> ----------------------------------------------------------------------
> 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 <bruce.richardson@intel.com>
> ---
>  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:
> 
>    * ``<IP>src_ip``
> 
> +  * ``<IPv4>dst_ip4``
> +
> +  * ``<IPv6>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,

Acked-by: Sunil Kumar Kori <skori@marvell.com>
> --
> 2.40.1
  

Patch

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:
 
   * ``<IP>src_ip``
 
+  * ``<IPv4>dst_ip4``
+
+  * ``<IPv6>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,