[RFC,3/6] common/mlx5: change mlx5 class enum values as bits

Message ID 20200610171728.89-4-parav@mellanox.com (mailing list archive)
State Superseded, archived
Headers
Series Improve mlx5 PMD common driver framework for multiple classes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Parav Pandit June 10, 2020, 5:17 p.m. UTC
  mlx5 PCI Device supports multiple classes of devices such as net, vdpa,
and/or regex.
To support these multiple classes, change mlx5_class to a
bitmap values so that if users asks to enable multiple of them, all
supported classes can be returned by mlx5_class_supported().

Signed-off-by: Parav Pandit <parav@mellanox.com>
---
 drivers/common/mlx5/mlx5_common.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Gaëtan Rivet June 15, 2020, 7:55 p.m. UTC | #1
On 10/06/20 17:17 +0000, Parav Pandit wrote:
> mlx5 PCI Device supports multiple classes of devices such as net, vdpa,
> and/or regex.
> To support these multiple classes, change mlx5_class to a
> bitmap values so that if users asks to enable multiple of them, all
> supported classes can be returned by mlx5_class_supported().
> 
> Signed-off-by: Parav Pandit <parav@mellanox.com>
> ---
>  drivers/common/mlx5/mlx5_common.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
> index 1d59873c8..9fdbd341d 100644
> --- a/drivers/common/mlx5/mlx5_common.h
> +++ b/drivers/common/mlx5/mlx5_common.h
> @@ -13,6 +13,7 @@
>  #include <rte_log.h>
>  #include <rte_kvargs.h>
>  #include <rte_devargs.h>
> +#include <rte_bits.h>
>  
>  #include "mlx5_prm.h"
>  
> @@ -203,8 +204,8 @@ int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr);
>  
>  enum mlx5_class {
>  	MLX5_CLASS_INVALID,
> -	MLX5_CLASS_NET,
> -	MLX5_CLASS_VDPA,
> +	MLX5_CLASS_NET = RTE_BIT(0),
> +	MLX5_CLASS_VDPA = RTE_BIT(1),
>  };
>  
>  __rte_internal
> -- 
> 2.25.4
> 

Well, I should have read further after all :)

You should merge this commit with the previous one, accompanying the
class getter API change.

I am not sure if an enum width is fixed however. I think it is
implementation defined. If so, using a define would be better.
  
Parav Pandit June 18, 2020, 9:29 a.m. UTC | #2
> From: Gaëtan Rivet <grive@u256.net>
> Sent: Tuesday, June 16, 2020 1:25 AM
> 
> On 10/06/20 17:17 +0000, Parav Pandit wrote:
> > mlx5 PCI Device supports multiple classes of devices such as net,
> > vdpa, and/or regex.
> > To support these multiple classes, change mlx5_class to a bitmap
> > values so that if users asks to enable multiple of them, all supported
> > classes can be returned by mlx5_class_supported().
> >
> > Signed-off-by: Parav Pandit <parav@mellanox.com>
> > ---
> >  drivers/common/mlx5/mlx5_common.h | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/common/mlx5/mlx5_common.h
> > b/drivers/common/mlx5/mlx5_common.h
> > index 1d59873c8..9fdbd341d 100644
> > --- a/drivers/common/mlx5/mlx5_common.h
> > +++ b/drivers/common/mlx5/mlx5_common.h
> > @@ -13,6 +13,7 @@
> >  #include <rte_log.h>
> >  #include <rte_kvargs.h>
> >  #include <rte_devargs.h>
> > +#include <rte_bits.h>
> >
> >  #include "mlx5_prm.h"
> >
> > @@ -203,8 +204,8 @@ int mlx5_dev_to_pci_addr(const char *dev_path,
> > struct rte_pci_addr *pci_addr);
> >
> >  enum mlx5_class {
> >  	MLX5_CLASS_INVALID,
> > -	MLX5_CLASS_NET,
> > -	MLX5_CLASS_VDPA,
> > +	MLX5_CLASS_NET = RTE_BIT(0),
> > +	MLX5_CLASS_VDPA = RTE_BIT(1),
> >  };
> >
> >  __rte_internal
> > --
> > 2.25.4
> >
> 
> Well, I should have read further after all :)
> 
No problem. :-)

> You should merge this commit with the previous one, accompanying the
> class getter API change.
> 
Ok. Usually two changes in two different patches. But its ok to merge.

> I am not sure if an enum width is fixed however. I think it is
> implementation defined. If so, using a define would be better.
Will change to #define.
  

Patch

diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index 1d59873c8..9fdbd341d 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -13,6 +13,7 @@ 
 #include <rte_log.h>
 #include <rte_kvargs.h>
 #include <rte_devargs.h>
+#include <rte_bits.h>
 
 #include "mlx5_prm.h"
 
@@ -203,8 +204,8 @@  int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr);
 
 enum mlx5_class {
 	MLX5_CLASS_INVALID,
-	MLX5_CLASS_NET,
-	MLX5_CLASS_VDPA,
+	MLX5_CLASS_NET = RTE_BIT(0),
+	MLX5_CLASS_VDPA = RTE_BIT(1),
 };
 
 __rte_internal