* [dpdk-dev] [PATCH] net/mlx5: fix debug variable initialization
@ 2021-11-04 12:23 Gregory Etelson
2021-11-04 12:31 ` Ferruh Yigit
2021-11-04 13:28 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
0 siblings, 2 replies; 5+ messages in thread
From: Gregory Etelson @ 2021-11-04 12:23 UTC (permalink / raw)
To: dev, getelson, viacheslavo; +Cc: ferruh.yigit, rasland, Matan Azrad
Use `__rte_unused` macro to mask a debug variable instead of `#ifdef`.
This way, if the variable is used in a macro, it does not depend on
how the macro is expanded.
Fixes: 91f0e029ce5f ("net/mlx5: translate flex item pattern into matcher")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_flex.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c
index bdfa383c45..be0f9821ce 100644
--- a/drivers/net/mlx5/mlx5_flow_flex.c
+++ b/drivers/net/mlx5/mlx5_flow_flex.c
@@ -222,9 +222,7 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
const struct rte_flow_item *item,
bool is_inner)
{
-#ifdef RTE_LIBRTE_MLX5_DEBUG
- struct mlx5_priv *priv = dev->data->dev_private;
-#endif
+ __rte_unused struct mlx5_priv *priv = dev->data->dev_private;
const struct rte_flow_item_flex *spec, *mask;
void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
misc_parameters_4);
--
2.33.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] net/mlx5: fix debug variable initialization
2021-11-04 12:23 [dpdk-dev] [PATCH] net/mlx5: fix debug variable initialization Gregory Etelson
@ 2021-11-04 12:31 ` Ferruh Yigit
2021-11-04 13:31 ` Gregory Etelson
2021-11-04 13:28 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
1 sibling, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2021-11-04 12:31 UTC (permalink / raw)
To: Gregory Etelson, dev, viacheslavo; +Cc: rasland, Matan Azrad, Andrew Rybchenko
On 11/4/2021 12:23 PM, Gregory Etelson wrote:
> Use `__rte_unused` macro to mask a debug variable instead of `#ifdef`.
> This way, if the variable is used in a macro, it does not depend on
> how the macro is expanded.
>
> Fixes: 91f0e029ce5f ("net/mlx5: translate flex item pattern into matcher")
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---
> drivers/net/mlx5/mlx5_flow_flex.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c
> index bdfa383c45..be0f9821ce 100644
> --- a/drivers/net/mlx5/mlx5_flow_flex.c
> +++ b/drivers/net/mlx5/mlx5_flow_flex.c
> @@ -222,9 +222,7 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
> const struct rte_flow_item *item,
> bool is_inner)
> {
> -#ifdef RTE_LIBRTE_MLX5_DEBUG
> - struct mlx5_priv *priv = dev->data->dev_private;
> -#endif
> + __rte_unused struct mlx5_priv *priv = dev->data->dev_private;
Marking the variable as unused to silence compiler for some cases,
but it is indeed used, what about something like this (inspired by
sfc code):
#if defined(RTE_LIBRTE_MLX5_DEBUG) || defined(RTE_ENABLE_ASSERT)
struct mlx5_priv *priv = dev->data->dev_private;
#endif
> const struct rte_flow_item_flex *spec, *mask;
> void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
> misc_parameters_4);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH v2] net/mlx5: fix debug variable initialization
2021-11-04 12:23 [dpdk-dev] [PATCH] net/mlx5: fix debug variable initialization Gregory Etelson
2021-11-04 12:31 ` Ferruh Yigit
@ 2021-11-04 13:28 ` Gregory Etelson
2021-11-04 14:00 ` Raslan Darawsheh
1 sibling, 1 reply; 5+ messages in thread
From: Gregory Etelson @ 2021-11-04 13:28 UTC (permalink / raw)
To: dev, getelson, viacheslavo; +Cc: ferruh.yigit, rasland, Matan Azrad
MLX5_ASSERT macro expansion depends on RTE_LIBRTE_MLX5_DEBUG and
RTE_ENABLE_ASSERT.
Existing implementation ignored the RTE_ENABLE_ASSERT dependency
in the mlx5_flex_flow_translate_item() scope.
As the result, the `priv` variable was not defined.
Fixes: 91f0e029ce5f ("net/mlx5: translate flex item pattern into matcher")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_flex.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c
index bdfa383c45..64867dc9e2 100644
--- a/drivers/net/mlx5/mlx5_flow_flex.c
+++ b/drivers/net/mlx5/mlx5_flow_flex.c
@@ -222,9 +222,6 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
const struct rte_flow_item *item,
bool is_inner)
{
-#ifdef RTE_LIBRTE_MLX5_DEBUG
- struct mlx5_priv *priv = dev->data->dev_private;
-#endif
const struct rte_flow_item_flex *spec, *mask;
void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
misc_parameters_4);
@@ -237,7 +234,7 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
spec = item->spec;
mask = item->mask;
tp = (struct mlx5_flex_item *)spec->handle;
- MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
+ MLX5_ASSERT(mlx5_flex_index(dev->data->dev_private, tp) >= 0);
for (i = 0; i < tp->mapnum; i++) {
struct mlx5_flex_pattern_field *map = tp->map + i;
uint32_t id = map->reg_id;
--
2.33.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] net/mlx5: fix debug variable initialization
2021-11-04 12:31 ` Ferruh Yigit
@ 2021-11-04 13:31 ` Gregory Etelson
0 siblings, 0 replies; 5+ messages in thread
From: Gregory Etelson @ 2021-11-04 13:31 UTC (permalink / raw)
To: Ferruh Yigit, dev, Slava Ovsiienko
Cc: Raslan Darawsheh, Matan Azrad, Andrew Rybchenko
Hello Ferruh,
I posted updated patch in https://patchwork.dpdk.org/project/dpdk/patch/20211104132853.31403-1-getelson@nvidia.com/
Regards,
Gregory
>
> On 11/4/2021 12:23 PM, Gregory Etelson wrote:
> > Use `__rte_unused` macro to mask a debug
> variable instead of `#ifdef`.
> > This way, if the variable is used in a macro, it
> does not depend on
> > how the macro is expanded.
> >
> > Fixes: 91f0e029ce5f ("net/mlx5: translate flex
> item pattern into matcher")
> > Signed-off-by: Gregory Etelson
> <getelson@nvidia.com>
> > ---
> > drivers/net/mlx5/mlx5_flow_flex.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_flow_flex.c
> b/drivers/net/mlx5/mlx5_flow_flex.c
> > index bdfa383c45..be0f9821ce 100644
> > --- a/drivers/net/mlx5/mlx5_flow_flex.c
> > +++ b/drivers/net/mlx5/mlx5_flow_flex.c
> > @@ -222,9 +222,7 @@
> mlx5_flex_flow_translate_item(struct
> rte_eth_dev *dev,
> > const struct rte_flow_item
> *item,
> > bool is_inner)
> > {
> > -#ifdef RTE_LIBRTE_MLX5_DEBUG
> > - struct mlx5_priv *priv = dev->data-
> >dev_private;
> > -#endif
> > + __rte_unused struct mlx5_priv *priv =
> dev->data->dev_private;
>
> Marking the variable as unused to silence
> compiler for some cases,
> but it is indeed used, what about something like
> this (inspired by
> sfc code):
>
> #if defined(RTE_LIBRTE_MLX5_DEBUG) ||
> defined(RTE_ENABLE_ASSERT)
> struct mlx5_priv *priv = dev->data-
> >dev_private;
> #endif
>
> > const struct rte_flow_item_flex *spec,
> *mask;
> > void *misc4_m =
> MLX5_ADDR_OF(fte_match_param, matcher,
> > misc_parameters_4);
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/mlx5: fix debug variable initialization
2021-11-04 13:28 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
@ 2021-11-04 14:00 ` Raslan Darawsheh
0 siblings, 0 replies; 5+ messages in thread
From: Raslan Darawsheh @ 2021-11-04 14:00 UTC (permalink / raw)
To: Gregory Etelson, dev, Slava Ovsiienko; +Cc: ferruh.yigit, Matan Azrad
Hi,
> -----Original Message-----
> From: Gregory Etelson <getelson@nvidia.com>
> Sent: Thursday, November 4, 2021 3:29 PM
> To: dev@dpdk.org; Gregory Etelson <getelson@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> Cc: ferruh.yigit@intel.com; Raslan Darawsheh <rasland@nvidia.com>; Matan
> Azrad <matan@nvidia.com>
> Subject: [PATCH v2] net/mlx5: fix debug variable initialization
>
> MLX5_ASSERT macro expansion depends on RTE_LIBRTE_MLX5_DEBUG and
> RTE_ENABLE_ASSERT.
> Existing implementation ignored the RTE_ENABLE_ASSERT dependency in
> the mlx5_flex_flow_translate_item() scope.
> As the result, the `priv` variable was not defined.
>
> Fixes: 91f0e029ce5f ("net/mlx5: translate flex item pattern into matcher")
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Squashed into relevant commit in next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-04 14:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 12:23 [dpdk-dev] [PATCH] net/mlx5: fix debug variable initialization Gregory Etelson
2021-11-04 12:31 ` Ferruh Yigit
2021-11-04 13:31 ` Gregory Etelson
2021-11-04 13:28 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
2021-11-04 14:00 ` Raslan Darawsheh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).