* [PATCH] net/mlx5: fix metadata endianness in modify field action
@ 2021-11-29 12:32 Viacheslav Ovsiienko
2021-12-06 8:56 ` Raslan Darawsheh
2021-12-07 13:44 ` Ferruh Yigit
0 siblings, 2 replies; 9+ messages in thread
From: Viacheslav Ovsiienko @ 2021-11-29 12:32 UTC (permalink / raw)
To: dev; +Cc: matan, rasland, stable
As modify field action immediate source parameter the metadata
should follow the CPU endianness (according to SET_META action
structure format), and mlx5 PMD wrongly handled the immediate
parameter metadata buffer as big-endian, resulting in wrong
metadata set action with incorrect endianness.
Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
Cc: stable@dpdk.org
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 4834c752d9..1c6cae8779 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1465,7 +1465,7 @@ static void
mlx5_flow_field_id_to_modify_info
(const struct rte_flow_action_modify_data *data,
struct field_modify_info *info, uint32_t *mask,
- uint32_t width, uint32_t *shift, struct rte_eth_dev *dev,
+ uint32_t width, struct rte_eth_dev *dev,
const struct rte_flow_attr *attr, struct rte_flow_error *error)
{
struct mlx5_priv *priv = dev->data->dev_private;
@@ -1820,16 +1820,11 @@ mlx5_flow_field_id_to_modify_info
{
uint32_t meta_mask = priv->sh->dv_meta_mask;
uint32_t meta_count = __builtin_popcount(meta_mask);
- uint32_t msk_c0 =
- rte_cpu_to_be_32(priv->sh->dv_regc0_mask);
- uint32_t shl_c0 = rte_bsf32(msk_c0);
int reg = flow_dv_get_metadata_reg(dev, attr, error);
if (reg < 0)
return;
MLX5_ASSERT(reg != REG_NON);
MLX5_ASSERT((unsigned int)reg < RTE_DIM(reg_to_field));
- if (reg == REG_C_0)
- *shift = shl_c0;
info[idx] = (struct field_modify_info){4, 0,
reg_to_field[reg]};
if (mask)
@@ -1881,29 +1876,33 @@ flow_dv_convert_action_modify_field
struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS] = {
{0, 0, 0} };
uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0};
- uint32_t type;
- uint32_t shift = 0;
+ uint32_t type, meta = 0;
if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
conf->src.field == RTE_FLOW_FIELD_VALUE) {
type = MLX5_MODIFICATION_TYPE_SET;
/** For SET fill the destination field (field) first. */
mlx5_flow_field_id_to_modify_info(&conf->dst, field, mask,
- conf->width, &shift, dev,
+ conf->width, dev,
attr, error);
item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ?
(void *)(uintptr_t)conf->src.pvalue :
(void *)(uintptr_t)&conf->src.value;
+ if (conf->dst.field == RTE_FLOW_FIELD_META) {
+ meta = *(const unaligned_uint32_t *)item.spec;
+ meta = rte_cpu_to_be_32(meta);
+ item.spec = &meta;
+ }
} else {
type = MLX5_MODIFICATION_TYPE_COPY;
/** For COPY fill the destination field (dcopy) without mask. */
mlx5_flow_field_id_to_modify_info(&conf->dst, dcopy, NULL,
- conf->width, &shift, dev,
+ conf->width, dev,
attr, error);
/** Then construct the source field (field) with mask. */
mlx5_flow_field_id_to_modify_info(&conf->src, field, mask,
- conf->width, &shift,
- dev, attr, error);
+ conf->width, dev,
+ attr, error);
}
item.mask = &mask;
return flow_dv_convert_modify_action(&item,
--
2.18.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] net/mlx5: fix metadata endianness in modify field action
2021-11-29 12:32 [PATCH] net/mlx5: fix metadata endianness in modify field action Viacheslav Ovsiienko
@ 2021-12-06 8:56 ` Raslan Darawsheh
2021-12-07 13:44 ` Ferruh Yigit
1 sibling, 0 replies; 9+ messages in thread
From: Raslan Darawsheh @ 2021-12-06 8:56 UTC (permalink / raw)
To: Slava Ovsiienko, dev; +Cc: Matan Azrad, stable
Hi,
> -----Original Message-----
> From: Slava Ovsiienko <viacheslavo@nvidia.com>
> Sent: Monday, November 29, 2021 2:33 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] net/mlx5: fix metadata endianness in modify field action
>
> As modify field action immediate source parameter the metadata
> should follow the CPU endianness (according to SET_META action
> structure format), and mlx5 PMD wrongly handled the immediate
> parameter metadata buffer as big-endian, resulting in wrong
> metadata set action with incorrect endianness.
>
> Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
> Cc: stable@dpdk.org
>
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/mlx5: fix metadata endianness in modify field action
2021-11-29 12:32 [PATCH] net/mlx5: fix metadata endianness in modify field action Viacheslav Ovsiienko
2021-12-06 8:56 ` Raslan Darawsheh
@ 2021-12-07 13:44 ` Ferruh Yigit
2021-12-16 9:50 ` Slava Ovsiienko
1 sibling, 1 reply; 9+ messages in thread
From: Ferruh Yigit @ 2021-12-07 13:44 UTC (permalink / raw)
To: Viacheslav Ovsiienko, dev; +Cc: matan, rasland, stable
On 11/29/2021 12:32 PM, Viacheslav Ovsiienko wrote:
> As modify field action immediate source parameter the metadata
> should follow the CPU endianness (according to SET_META action
> structure format), and mlx5 PMD wrongly handled the immediate
> parameter metadata buffer as big-endian, resulting in wrong
> metadata set action with incorrect endianness.
>
> Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
> Cc: stable@dpdk.org
>
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
> drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
> index 4834c752d9..1c6cae8779 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -1465,7 +1465,7 @@ static void
> mlx5_flow_field_id_to_modify_info
> (const struct rte_flow_action_modify_data *data,
> struct field_modify_info *info, uint32_t *mask,
> - uint32_t width, uint32_t *shift, struct rte_eth_dev *dev,
> + uint32_t width, struct rte_eth_dev *dev,
Hi Viacheslav,
Is removing (unused) 'shift' variable related to the problem mentioned
in the commit log?
Only below "meta = rte_cpu_to_be_32(meta);" change block seems fixing
the issue and rest is cleanup, if that is the case can you please split
the patch?
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] net/mlx5: fix metadata endianness in modify field action
2021-12-07 13:44 ` Ferruh Yigit
@ 2021-12-16 9:50 ` Slava Ovsiienko
2021-12-17 12:59 ` Ferruh Yigit
0 siblings, 1 reply; 9+ messages in thread
From: Slava Ovsiienko @ 2021-12-16 9:50 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: Matan Azrad, Raslan Darawsheh, stable
Hi, Ferruh
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Tuesday, December 7, 2021 15:45
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; stable@dpdk.org
> Subject: Re: [PATCH] net/mlx5: fix metadata endianness in modify field action
>
> On 11/29/2021 12:32 PM, Viacheslav Ovsiienko wrote:
> > As modify field action immediate source parameter the metadata should
> > follow the CPU endianness (according to SET_META action structure
> > format), and mlx5 PMD wrongly handled the immediate parameter
> metadata
> > buffer as big-endian, resulting in wrong metadata set action with
> > incorrect endianness.
> >
> > Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> > ---
> > drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++------------
> > 1 file changed, 11 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> > b/drivers/net/mlx5/mlx5_flow_dv.c index 4834c752d9..1c6cae8779 100644
> > --- a/drivers/net/mlx5/mlx5_flow_dv.c
> > +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> > @@ -1465,7 +1465,7 @@ static void
> > mlx5_flow_field_id_to_modify_info
> > (const struct rte_flow_action_modify_data *data,
> > struct field_modify_info *info, uint32_t *mask,
> > - uint32_t width, uint32_t *shift, struct rte_eth_dev *dev,
> > + uint32_t width, struct rte_eth_dev *dev,
>
> Hi Viacheslav,
>
> Is removing (unused) 'shift' variable related to the problem mentioned in the
> commit log?
Related indirectly to metadata, but not directly to the issue.
"shift" is unused leftover after changing immediate value format.
And this patch just provides collateral cleanup. Do you think we should
separate into dedicated cleanup patch? Or mention this cleanup in commit
message?
With best regards,
Slava
>
> Only below "meta = rte_cpu_to_be_32(meta);" change block seems fixing the
> issue and rest is cleanup, if that is the case can you please split the patch?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/mlx5: fix metadata endianness in modify field action
2021-12-16 9:50 ` Slava Ovsiienko
@ 2021-12-17 12:59 ` Ferruh Yigit
2022-02-03 8:46 ` [PATCH v2 1/2] " Viacheslav Ovsiienko
0 siblings, 1 reply; 9+ messages in thread
From: Ferruh Yigit @ 2021-12-17 12:59 UTC (permalink / raw)
To: Slava Ovsiienko, dev; +Cc: Matan Azrad, Raslan Darawsheh, stable
On 12/16/2021 9:50 AM, Slava Ovsiienko wrote:
> Hi, Ferruh
>
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@intel.com>
>> Sent: Tuesday, December 7, 2021 15:45
>> To: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org
>> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
>> <rasland@nvidia.com>; stable@dpdk.org
>> Subject: Re: [PATCH] net/mlx5: fix metadata endianness in modify field action
>>
>> On 11/29/2021 12:32 PM, Viacheslav Ovsiienko wrote:
>>> As modify field action immediate source parameter the metadata should
>>> follow the CPU endianness (according to SET_META action structure
>>> format), and mlx5 PMD wrongly handled the immediate parameter
>> metadata
>>> buffer as big-endian, resulting in wrong metadata set action with
>>> incorrect endianness.
>>>
>>> Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
>>> ---
>>> drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++------------
>>> 1 file changed, 11 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
>>> b/drivers/net/mlx5/mlx5_flow_dv.c index 4834c752d9..1c6cae8779 100644
>>> --- a/drivers/net/mlx5/mlx5_flow_dv.c
>>> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
>>> @@ -1465,7 +1465,7 @@ static void
>>> mlx5_flow_field_id_to_modify_info
>>> (const struct rte_flow_action_modify_data *data,
>>> struct field_modify_info *info, uint32_t *mask,
>>> - uint32_t width, uint32_t *shift, struct rte_eth_dev *dev,
>>> + uint32_t width, struct rte_eth_dev *dev,
>>
>> Hi Viacheslav,
>>
>> Is removing (unused) 'shift' variable related to the problem mentioned in the
>> commit log?
> Related indirectly to metadata, but not directly to the issue.
> "shift" is unused leftover after changing immediate value format.
> And this patch just provides collateral cleanup. Do you think we should
> separate into dedicated cleanup patch? Or mention this cleanup in commit
> message?
>
if not directly related I think better to split on its own patch, this
makes it more clear to possible future references to the patches.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field action
2021-12-17 12:59 ` Ferruh Yigit
@ 2022-02-03 8:46 ` Viacheslav Ovsiienko
2022-02-03 8:46 ` [PATCH v2 2/2] net/mlx5: remove unused metadata shift parameter Viacheslav Ovsiienko
2022-02-09 8:50 ` [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field action Raslan Darawsheh
0 siblings, 2 replies; 9+ messages in thread
From: Viacheslav Ovsiienko @ 2022-02-03 8:46 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, matan, rasland, stable
As modify field action immediate source parameter the metadata
should follow the CPU endianness (according to SET_META action
structure format), and mlx5 PMD wrongly handled the immediate
parameter metadata buffer as big-endian, resulting in wrong
metadata set action with incorrect endianness.
Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
Cc: stable@dpdk.org
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index af90a7fd0a..10ef2af06a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1867,7 +1867,7 @@ flow_dv_convert_action_modify_field
struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS] = {
{0, 0, 0} };
uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0};
- uint32_t type;
+ uint32_t type, meta = 0;
uint32_t shift = 0;
if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
@@ -1880,6 +1880,11 @@ flow_dv_convert_action_modify_field
item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ?
(void *)(uintptr_t)conf->src.pvalue :
(void *)(uintptr_t)&conf->src.value;
+ if (conf->dst.field == RTE_FLOW_FIELD_META) {
+ meta = *(const unaligned_uint32_t *)item.spec;
+ meta = rte_cpu_to_be_32(meta);
+ item.spec = &meta;
+ }
} else {
type = MLX5_MODIFICATION_TYPE_COPY;
/** For COPY fill the destination field (dcopy) without mask. */
--
2.18.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] net/mlx5: remove unused metadata shift parameter
2022-02-03 8:46 ` [PATCH v2 1/2] " Viacheslav Ovsiienko
@ 2022-02-03 8:46 ` Viacheslav Ovsiienko
2022-02-08 10:48 ` Ferruh Yigit
2022-02-09 8:50 ` [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field action Raslan Darawsheh
1 sibling, 1 reply; 9+ messages in thread
From: Viacheslav Ovsiienko @ 2022-02-03 8:46 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, matan, rasland
Due to updated modify field actionimmediate value buffer
pattern [1] the implicit shift for the metadata is not
needed anymore and should be removed.
[1] commit 40c8fb1fd3b3 ("net/mlx5: update modify field action")
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 10ef2af06a..ef9c66eddf 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1451,7 +1451,7 @@ static void
mlx5_flow_field_id_to_modify_info
(const struct rte_flow_action_modify_data *data,
struct field_modify_info *info, uint32_t *mask,
- uint32_t width, uint32_t *shift, struct rte_eth_dev *dev,
+ uint32_t width, struct rte_eth_dev *dev,
const struct rte_flow_attr *attr, struct rte_flow_error *error)
{
struct mlx5_priv *priv = dev->data->dev_private;
@@ -1806,16 +1806,11 @@ mlx5_flow_field_id_to_modify_info
{
uint32_t meta_mask = priv->sh->dv_meta_mask;
uint32_t meta_count = __builtin_popcount(meta_mask);
- uint32_t msk_c0 =
- rte_cpu_to_be_32(priv->sh->dv_regc0_mask);
- uint32_t shl_c0 = rte_bsf32(msk_c0);
int reg = flow_dv_get_metadata_reg(dev, attr, error);
if (reg < 0)
return;
MLX5_ASSERT(reg != REG_NON);
MLX5_ASSERT((unsigned int)reg < RTE_DIM(reg_to_field));
- if (reg == REG_C_0)
- *shift = shl_c0;
info[idx] = (struct field_modify_info){4, 0,
reg_to_field[reg]};
if (mask)
@@ -1868,14 +1863,13 @@ flow_dv_convert_action_modify_field
{0, 0, 0} };
uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0};
uint32_t type, meta = 0;
- uint32_t shift = 0;
if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
conf->src.field == RTE_FLOW_FIELD_VALUE) {
type = MLX5_MODIFICATION_TYPE_SET;
/** For SET fill the destination field (field) first. */
mlx5_flow_field_id_to_modify_info(&conf->dst, field, mask,
- conf->width, &shift, dev,
+ conf->width, dev,
attr, error);
item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ?
(void *)(uintptr_t)conf->src.pvalue :
@@ -1889,12 +1883,12 @@ flow_dv_convert_action_modify_field
type = MLX5_MODIFICATION_TYPE_COPY;
/** For COPY fill the destination field (dcopy) without mask. */
mlx5_flow_field_id_to_modify_info(&conf->dst, dcopy, NULL,
- conf->width, &shift, dev,
+ conf->width, dev,
attr, error);
/** Then construct the source field (field) with mask. */
mlx5_flow_field_id_to_modify_info(&conf->src, field, mask,
- conf->width, &shift,
- dev, attr, error);
+ conf->width, dev,
+ attr, error);
}
item.mask = &mask;
return flow_dv_convert_modify_action(&item,
--
2.18.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field action
2022-02-03 8:46 ` [PATCH v2 1/2] " Viacheslav Ovsiienko
2022-02-03 8:46 ` [PATCH v2 2/2] net/mlx5: remove unused metadata shift parameter Viacheslav Ovsiienko
@ 2022-02-09 8:50 ` Raslan Darawsheh
1 sibling, 0 replies; 9+ messages in thread
From: Raslan Darawsheh @ 2022-02-09 8:50 UTC (permalink / raw)
To: Slava Ovsiienko, dev; +Cc: ferruh.yigit, Matan Azrad, stable
Hi,
> -----Original Message-----
> From: Slava Ovsiienko <viacheslavo@nvidia.com>
> Sent: Thursday, February 3, 2022 10:47 AM
> To: dev@dpdk.org
> Cc: ferruh.yigit@intel.com; Matan Azrad <matan@nvidia.com>; Raslan
> Darawsheh <rasland@nvidia.com>; stable@dpdk.org
> Subject: [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field
> action
>
> As modify field action immediate source parameter the metadata should
> follow the CPU endianness (according to SET_META action structure format),
> and mlx5 PMD wrongly handled the immediate parameter metadata buffer
> as big-endian, resulting in wrong metadata set action with incorrect
> endianness.
>
> Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
> Cc: stable@dpdk.org
>
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-02-09 8:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 12:32 [PATCH] net/mlx5: fix metadata endianness in modify field action Viacheslav Ovsiienko
2021-12-06 8:56 ` Raslan Darawsheh
2021-12-07 13:44 ` Ferruh Yigit
2021-12-16 9:50 ` Slava Ovsiienko
2021-12-17 12:59 ` Ferruh Yigit
2022-02-03 8:46 ` [PATCH v2 1/2] " Viacheslav Ovsiienko
2022-02-03 8:46 ` [PATCH v2 2/2] net/mlx5: remove unused metadata shift parameter Viacheslav Ovsiienko
2022-02-08 10:48 ` Ferruh Yigit
2022-02-09 8:50 ` [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field action 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).