Skip to content

Commit 5b8847a

Browse files
erezshitritsmb49
authored andcommitted
net/mlx5: DR, Fix crc32 calculation to work on big-endian (BE) CPUs
BugLink: https://bugs.launchpad.net/bugs/2028979 commit 1e5daf5 upstream. When calculating crc for hash index we use the function crc32 that calculates for little-endian (LE) arch. Then we convert it to network endianness using htonl(), but it's wrong to do the conversion in BE archs since the crc32 value is already LE. The solution is to switch the bytes from the crc result for all types of arc. Fixes: 40416d8 ("net/mlx5: DR, Replace CRC32 implementation to use kernel lib") Signed-off-by: Erez Shitrit <erezsh@nvidia.com> Reviewed-by: Alex Vesker <valex@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 887770e commit 5b8847a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • drivers/net/ethernet/mellanox/mlx5/core/steering

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ static u32 dr_ste_crc32_calc(const void *input_data, size_t length)
1515
{
1616
u32 crc = crc32(0, input_data, length);
1717

18-
return (__force u32)htonl(crc);
18+
return (__force u32)((crc >> 24) & 0xff) | ((crc << 8) & 0xff0000) |
19+
((crc >> 8) & 0xff00) | ((crc << 24) & 0xff000000);
1920
}
2021

2122
bool mlx5dr_ste_supp_ttl_cs_recalc(struct mlx5dr_cmd_caps *caps)

0 commit comments

Comments
 (0)