Message ID | 20200506114028.20688-2-frank.heimes@canonical.com |
---|---|
State | New |
Headers | show |
Series | net/mlx5e: Fix endianness handling in pedit mask (LP: 1872726) | expand |
On 06.05.20 13:40, frank.heimes@canonical.com wrote: > From: Sebastian Hense <sebastian.hense1@ibm.com> > > BugLink: https://bugs.launchpad.net/bugs/1872726 > > The mask value is provided as 64 bit and has to be casted in > either 32 or 16 bit. On big endian systems the wrong half was > casted which resulted in an all zero mask. > > Fixes: 2b64beba0251 ("net/mlx5e: Support header re-write of partial fields in TC pedit offload") > > Signed-off-by: Sebastian Hense <sebastian.hense1@ibm.com> > Reviewed-by: Roi Dayan <roid@mellanox.com> > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> > (backported from commit 404402abd5f90aa90a134eb9604b1750c1941529) > Signed-off-by: Frank Heimes <frank.heimes@canonical.com> Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> > --- > drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > index ec117e441425..a8817ded2959 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > @@ -2424,10 +2424,11 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs, > field_bsize = f->size * BITS_PER_BYTE; > > if (field_bsize == 32) { > - mask_be32 = *(__be32 *)&mask; > + mask_be32 = (__be32)mask; > mask = (__force unsigned long)cpu_to_le32(be32_to_cpu(mask_be32)); > } else if (field_bsize == 16) { > - mask_be16 = *(__be16 *)&mask; > + mask_be32 = (__be32)mask; > + mask_be16 = *(__be16 *)&mask_be32; > mask = (__force unsigned long)cpu_to_le16(be16_to_cpu(mask_be16)); > } > >
On 13.05.20 12:05, Kleber Souza wrote: > On 06.05.20 13:40, frank.heimes@canonical.com wrote: >> From: Sebastian Hense <sebastian.hense1@ibm.com> >> >> BugLink: https://bugs.launchpad.net/bugs/1872726 Hi Frank, I also forgot a comment about this one as well :-). Can you please set the 'linux -> Focal' nomination to 'In Progress'? 'Fix Committed' should be set by the kernel team when the patch is applied only. Thanks, Kleber >> >> The mask value is provided as 64 bit and has to be casted in >> either 32 or 16 bit. On big endian systems the wrong half was >> casted which resulted in an all zero mask. >> >> Fixes: 2b64beba0251 ("net/mlx5e: Support header re-write of partial fields in TC pedit offload") >> >> Signed-off-by: Sebastian Hense <sebastian.hense1@ibm.com> >> Reviewed-by: Roi Dayan <roid@mellanox.com> >> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> >> (backported from commit 404402abd5f90aa90a134eb9604b1750c1941529) >> Signed-off-by: Frank Heimes <frank.heimes@canonical.com> > > Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> > >> --- >> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c >> index ec117e441425..a8817ded2959 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c >> @@ -2424,10 +2424,11 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs, >> field_bsize = f->size * BITS_PER_BYTE; >> >> if (field_bsize == 32) { >> - mask_be32 = *(__be32 *)&mask; >> + mask_be32 = (__be32)mask; >> mask = (__force unsigned long)cpu_to_le32(be32_to_cpu(mask_be32)); >> } else if (field_bsize == 16) { >> - mask_be16 = *(__be16 *)&mask; >> + mask_be32 = (__be32)mask; >> + mask_be16 = *(__be16 *)&mask_be32; >> mask = (__force unsigned long)cpu_to_le16(be16_to_cpu(mask_be16)); >> } >> >> >
Acked-by: Sultan Alsawaf <sultan.alsawaf@canonical.com> On Wed, May 06, 2020 at 01:40:28PM +0200, frank.heimes@canonical.com wrote: > From: Sebastian Hense <sebastian.hense1@ibm.com> > > BugLink: https://bugs.launchpad.net/bugs/1872726 > > The mask value is provided as 64 bit and has to be casted in > either 32 or 16 bit. On big endian systems the wrong half was > casted which resulted in an all zero mask. > > Fixes: 2b64beba0251 ("net/mlx5e: Support header re-write of partial fields in TC pedit offload") > > Signed-off-by: Sebastian Hense <sebastian.hense1@ibm.com> > Reviewed-by: Roi Dayan <roid@mellanox.com> > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> > (backported from commit 404402abd5f90aa90a134eb9604b1750c1941529) > Signed-off-by: Frank Heimes <frank.heimes@canonical.com> > --- > drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > index ec117e441425..a8817ded2959 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > @@ -2424,10 +2424,11 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs, > field_bsize = f->size * BITS_PER_BYTE; > > if (field_bsize == 32) { > - mask_be32 = *(__be32 *)&mask; > + mask_be32 = (__be32)mask; > mask = (__force unsigned long)cpu_to_le32(be32_to_cpu(mask_be32)); > } else if (field_bsize == 16) { > - mask_be16 = *(__be16 *)&mask; > + mask_be32 = (__be32)mask; > + mask_be16 = *(__be16 *)&mask_be32; > mask = (__force unsigned long)cpu_to_le16(be16_to_cpu(mask_be16)); > } > > -- > 2.25.1 > > > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index ec117e441425..a8817ded2959 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2424,10 +2424,11 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs, field_bsize = f->size * BITS_PER_BYTE; if (field_bsize == 32) { - mask_be32 = *(__be32 *)&mask; + mask_be32 = (__be32)mask; mask = (__force unsigned long)cpu_to_le32(be32_to_cpu(mask_be32)); } else if (field_bsize == 16) { - mask_be16 = *(__be16 *)&mask; + mask_be32 = (__be32)mask; + mask_be16 = *(__be16 *)&mask_be32; mask = (__force unsigned long)cpu_to_le16(be16_to_cpu(mask_be16)); }