[v2,1/2] common/mlx5: fix build disabling

Message ID 20221030082722.1333530-2-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix build disabling common/mlx5 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Oct. 30, 2022, 8:27 a.m. UTC
  If the dependency common/mlx5 is explicitly disabled,
but net/mlx5 is not explicitly disabled,
Meson will read the full recipe of net/mlx5
and will fail when accessing a variable from common/mlx5:
drivers/net/mlx5/meson.build:76:4: ERROR: Unknown variable "mlx5_config".

The solution is to stop parsing net/mlx5 if common/mlx5 is disabled.
The deps array must be defined before stopping, in order to automatically
disable the build of net/mlx5 and print the reason.

The same protection is applied to other mlx5 drivers,
so it will allow using the variable mlx5_config in future.

Fixes: 22681deead3e ("net/mlx5/hws: enable hardware steering")

Reported-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Tested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/compress/mlx5/meson.build | 5 +++++
 drivers/crypto/mlx5/meson.build   | 5 +++++
 drivers/net/mlx5/meson.build      | 5 +++++
 drivers/regex/mlx5/meson.build    | 5 +++++
 drivers/vdpa/mlx5/meson.build     | 5 +++++
 5 files changed, 25 insertions(+)
  

Comments

Matan Azrad Oct. 30, 2022, 9:16 a.m. UTC | #1
> If the dependency common/mlx5 is explicitly disabled, but net/mlx5 is not
> explicitly disabled, Meson will read the full recipe of net/mlx5 and will fail
> when accessing a variable from common/mlx5:
> drivers/net/mlx5/meson.build:76:4: ERROR: Unknown variable
> "mlx5_config".
> 
> The solution is to stop parsing net/mlx5 if common/mlx5 is disabled.
> The deps array must be defined before stopping, in order to automatically
> disable the build of net/mlx5 and print the reason.
> 
> The same protection is applied to other mlx5 drivers, so it will allow using the
> variable mlx5_config in future.
> 
> Fixes: 22681deead3e ("net/mlx5/hws: enable hardware steering")
> 
> Reported-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Tested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Matan Azrad <matan@nvidia.com>
  
Bruce Richardson Nov. 2, 2022, 12:10 p.m. UTC | #2
On Sun, Oct 30, 2022 at 09:27:21AM +0100, Thomas Monjalon wrote:
> If the dependency common/mlx5 is explicitly disabled,
> but net/mlx5 is not explicitly disabled,
> Meson will read the full recipe of net/mlx5
> and will fail when accessing a variable from common/mlx5:
> drivers/net/mlx5/meson.build:76:4: ERROR: Unknown variable "mlx5_config".
> 
> The solution is to stop parsing net/mlx5 if common/mlx5 is disabled.
> The deps array must be defined before stopping, in order to automatically
> disable the build of net/mlx5 and print the reason.
> 
> The same protection is applied to other mlx5 drivers,
> so it will allow using the variable mlx5_config in future.
> 
> Fixes: 22681deead3e ("net/mlx5/hws: enable hardware steering")
> 
> Reported-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Tested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  drivers/compress/mlx5/meson.build | 5 +++++
>  drivers/crypto/mlx5/meson.build   | 5 +++++
>  drivers/net/mlx5/meson.build      | 5 +++++
>  drivers/regex/mlx5/meson.build    | 5 +++++
>  drivers/vdpa/mlx5/meson.build     | 5 +++++
>  5 files changed, 25 insertions(+)
> 
> diff --git a/drivers/compress/mlx5/meson.build b/drivers/compress/mlx5/meson.build
> index 7aac329986..49ce3aff46 100644
> --- a/drivers/compress/mlx5/meson.build
> +++ b/drivers/compress/mlx5/meson.build
> @@ -9,6 +9,11 @@ endif
>  
>  fmt_name = 'mlx5_compress'
>  deps += ['common_mlx5', 'eal', 'compressdev']
> +if not ('mlx5' in common_drivers)

While this is fine as-is, I think the more usual way for checking the
presence of a component in DPDK is to check dpdk_conf. In this case the
check would be "if not dpdk_conf.has('RTE_COMMON_MLX5')". You may want to
consider using that for consistency.

/Bruce
  
Thomas Monjalon Nov. 2, 2022, 12:29 p.m. UTC | #3
02/11/2022 13:10, Bruce Richardson:
> On Sun, Oct 30, 2022 at 09:27:21AM +0100, Thomas Monjalon wrote:
> > If the dependency common/mlx5 is explicitly disabled,
> > but net/mlx5 is not explicitly disabled,
> > Meson will read the full recipe of net/mlx5
> > and will fail when accessing a variable from common/mlx5:
> > drivers/net/mlx5/meson.build:76:4: ERROR: Unknown variable "mlx5_config".
> > 
> > The solution is to stop parsing net/mlx5 if common/mlx5 is disabled.
> > The deps array must be defined before stopping, in order to automatically
> > disable the build of net/mlx5 and print the reason.
> > 
> > The same protection is applied to other mlx5 drivers,
> > so it will allow using the variable mlx5_config in future.
> > 
> > Fixes: 22681deead3e ("net/mlx5/hws: enable hardware steering")
> > 
> > Reported-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > Tested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> > ---
> >  drivers/compress/mlx5/meson.build | 5 +++++
> >  drivers/crypto/mlx5/meson.build   | 5 +++++
> >  drivers/net/mlx5/meson.build      | 5 +++++
> >  drivers/regex/mlx5/meson.build    | 5 +++++
> >  drivers/vdpa/mlx5/meson.build     | 5 +++++
> >  5 files changed, 25 insertions(+)
> > 
> > diff --git a/drivers/compress/mlx5/meson.build b/drivers/compress/mlx5/meson.build
> > index 7aac329986..49ce3aff46 100644
> > --- a/drivers/compress/mlx5/meson.build
> > +++ b/drivers/compress/mlx5/meson.build
> > @@ -9,6 +9,11 @@ endif
> >  
> >  fmt_name = 'mlx5_compress'
> >  deps += ['common_mlx5', 'eal', 'compressdev']
> > +if not ('mlx5' in common_drivers)
> 
> While this is fine as-is, I think the more usual way for checking the
> presence of a component in DPDK is to check dpdk_conf. In this case the
> check would be "if not dpdk_conf.has('RTE_COMMON_MLX5')". You may want to
> consider using that for consistency.

Yes, I've forgotten this:

	lib_name = '_'.join(['rte', class, name])
	dpdk_conf.set(lib_name.to_upper(), 1)

Then what is the usage of this?

	set_variable(class + '_drivers', enabled_drivers)
  
Bruce Richardson Nov. 2, 2022, 1:14 p.m. UTC | #4
On Wed, Nov 02, 2022 at 01:29:49PM +0100, Thomas Monjalon wrote:
> 02/11/2022 13:10, Bruce Richardson:
> > On Sun, Oct 30, 2022 at 09:27:21AM +0100, Thomas Monjalon wrote:
> > > If the dependency common/mlx5 is explicitly disabled,
> > > but net/mlx5 is not explicitly disabled,
> > > Meson will read the full recipe of net/mlx5
> > > and will fail when accessing a variable from common/mlx5:
> > > drivers/net/mlx5/meson.build:76:4: ERROR: Unknown variable "mlx5_config".
> > > 
> > > The solution is to stop parsing net/mlx5 if common/mlx5 is disabled.
> > > The deps array must be defined before stopping, in order to automatically
> > > disable the build of net/mlx5 and print the reason.
> > > 
> > > The same protection is applied to other mlx5 drivers,
> > > so it will allow using the variable mlx5_config in future.
> > > 
> > > Fixes: 22681deead3e ("net/mlx5/hws: enable hardware steering")
> > > 
> > > Reported-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > > Tested-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> > > ---
> > >  drivers/compress/mlx5/meson.build | 5 +++++
> > >  drivers/crypto/mlx5/meson.build   | 5 +++++
> > >  drivers/net/mlx5/meson.build      | 5 +++++
> > >  drivers/regex/mlx5/meson.build    | 5 +++++
> > >  drivers/vdpa/mlx5/meson.build     | 5 +++++
> > >  5 files changed, 25 insertions(+)
> > > 
> > > diff --git a/drivers/compress/mlx5/meson.build b/drivers/compress/mlx5/meson.build
> > > index 7aac329986..49ce3aff46 100644
> > > --- a/drivers/compress/mlx5/meson.build
> > > +++ b/drivers/compress/mlx5/meson.build
> > > @@ -9,6 +9,11 @@ endif
> > >  
> > >  fmt_name = 'mlx5_compress'
> > >  deps += ['common_mlx5', 'eal', 'compressdev']
> > > +if not ('mlx5' in common_drivers)
> > 
> > While this is fine as-is, I think the more usual way for checking the
> > presence of a component in DPDK is to check dpdk_conf. In this case the
> > check would be "if not dpdk_conf.has('RTE_COMMON_MLX5')". You may want to
> > consider using that for consistency.
> 
> Yes, I've forgotten this:
> 
> 	lib_name = '_'.join(['rte', class, name])
> 	dpdk_conf.set(lib_name.to_upper(), 1)
> 
> Then what is the usage of this?
> 
> 	set_variable(class + '_drivers', enabled_drivers)
> 
That is used for the summary printout at the end, so we can list the
drivers enabled.

The approach using the common_drivers works fine for this patch, so let's
keep it, since it's merged. I was just pointing out the other approach for
consistency sake.

/Bruce
  
Thomas Monjalon Nov. 2, 2022, 1:17 p.m. UTC | #5
02/11/2022 14:14, Bruce Richardson:
> On Wed, Nov 02, 2022 at 01:29:49PM +0100, Thomas Monjalon wrote:
> > 02/11/2022 13:10, Bruce Richardson:
> > > On Sun, Oct 30, 2022 at 09:27:21AM +0100, Thomas Monjalon wrote:
> > > > +if not ('mlx5' in common_drivers)
> > > 
> > > While this is fine as-is, I think the more usual way for checking the
> > > presence of a component in DPDK is to check dpdk_conf. In this case the
> > > check would be "if not dpdk_conf.has('RTE_COMMON_MLX5')". You may want to
> > > consider using that for consistency.
> > 
> > Yes, I've forgotten this:
> > 
> > 	lib_name = '_'.join(['rte', class, name])
> > 	dpdk_conf.set(lib_name.to_upper(), 1)
> > 
> > Then what is the usage of this?
> > 
> > 	set_variable(class + '_drivers', enabled_drivers)
> > 
> That is used for the summary printout at the end, so we can list the
> drivers enabled.
> 
> The approach using the common_drivers works fine for this patch, so let's
> keep it, since it's merged. I was just pointing out the other approach for
> consistency sake.

I can send a patch for consistency.
  

Patch

diff --git a/drivers/compress/mlx5/meson.build b/drivers/compress/mlx5/meson.build
index 7aac329986..49ce3aff46 100644
--- a/drivers/compress/mlx5/meson.build
+++ b/drivers/compress/mlx5/meson.build
@@ -9,6 +9,11 @@  endif
 
 fmt_name = 'mlx5_compress'
 deps += ['common_mlx5', 'eal', 'compressdev']
+if not ('mlx5' in common_drivers)
+    # avoid referencing undefined variables from common/mlx5
+    subdir_done()
+endif
+
 sources = files(
         'mlx5_compress.c',
 )
diff --git a/drivers/crypto/mlx5/meson.build b/drivers/crypto/mlx5/meson.build
index 9d9c9c00bc..7521c4c671 100644
--- a/drivers/crypto/mlx5/meson.build
+++ b/drivers/crypto/mlx5/meson.build
@@ -9,6 +9,11 @@  endif
 
 fmt_name = 'mlx5_crypto'
 deps += ['common_mlx5', 'eal', 'cryptodev']
+if not ('mlx5' in common_drivers)
+    # avoid referencing undefined variables from common/mlx5
+    subdir_done()
+endif
+
 sources = files(
         'mlx5_crypto.c',
         'mlx5_crypto_dek.c',
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index ff84448186..fa15158039 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -9,6 +9,11 @@  if not (is_linux or is_windows)
 endif
 
 deps += ['hash', 'common_mlx5']
+if not ('mlx5' in common_drivers)
+    # avoid referencing undefined variables from common/mlx5
+    subdir_done()
+endif
+
 headers = files('rte_pmd_mlx5.h')
 sources = files(
         'mlx5.c',
diff --git a/drivers/regex/mlx5/meson.build b/drivers/regex/mlx5/meson.build
index e553dcb83d..70edc5b6da 100644
--- a/drivers/regex/mlx5/meson.build
+++ b/drivers/regex/mlx5/meson.build
@@ -8,6 +8,11 @@  if not is_linux
 endif
 
 deps += ['common_mlx5', 'eal', 'regexdev']
+if not ('mlx5' in common_drivers)
+    # avoid referencing undefined variables from common/mlx5
+    subdir_done()
+endif
+
 sources = files(
         'mlx5_regex.c',
         'mlx5_rxp.c',
diff --git a/drivers/vdpa/mlx5/meson.build b/drivers/vdpa/mlx5/meson.build
index 9d8dbb1a82..54a4eac6f4 100644
--- a/drivers/vdpa/mlx5/meson.build
+++ b/drivers/vdpa/mlx5/meson.build
@@ -8,6 +8,11 @@  if not is_linux
 endif
 
 deps += ['hash', 'common_mlx5', 'vhost', 'pci', 'eal', 'sched']
+if not ('mlx5' in common_drivers)
+    # avoid referencing undefined variables from common/mlx5
+    subdir_done()
+endif
+
 sources = files(
         'mlx5_vdpa.c',
         'mlx5_vdpa_mem.c',