mlxsw: spectrum: Do not rely on machine endianness
authorIdo Schimmel <idosch@mellanox.com>
Sun, 21 Jun 2020 08:29:17 +0000 (11:29 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Jun 2020 23:29:51 +0000 (16:29 -0700)
commitf3fe412b0a634286a6a3753c3f9ff201e6bec716
tree49bd6016b54e1d33f1469cc223240e8b15599886
parent6d61f483f148b856d47a6c96d5d84054d5a9f849
mlxsw: spectrum: Do not rely on machine endianness

The second commit cited below performed a cast of 'u32 buffsize' to
'(u16 *)' when calling mlxsw_sp_port_headroom_8x_adjust():

mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, (u16 *) &buffsize);

Colin noted that this will behave differently on big endian
architectures compared to little endian architectures.

Fix this by following Colin's suggestion and have the function accept
and return 'u32' instead of passing the current size by reference.

Fixes: da382875c616 ("mlxsw: spectrum: Extend to support Spectrum-3 ASIC")
Fixes: 60833d54d56c ("mlxsw: spectrum: Adjust headroom buffers for 8x ports")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reported-by: Colin Ian King <colin.king@canonical.com>
Suggested-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c