Commit b623603b authored by Aya Levin's avatar Aya Levin Committed by Saeed Mahameed

net/mlx5e: Fix arch depending casting issue in FEC

Change type of active_fec to u32 to match the type expected by
mlx5e_get_fec_mode. Copy active_fec and configured_fec values to
unsigned long before preforming bitwise manipulations.
Take the same approach when configuring FEC over 50G link modes: copy
the policy into an unsigned long and only than preform bitwise
operations.

Fixes: 2132b71f ("net/mlx5e: Advertise globaly supported FEC modes")
Signed-off-by: default avatarAya Levin <ayal@mellanox.com>
Reviewed-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 20300aaf
...@@ -369,17 +369,19 @@ enum mlx5e_fec_supported_link_mode { ...@@ -369,17 +369,19 @@ enum mlx5e_fec_supported_link_mode {
*_policy = MLX5_GET(pplm_reg, _buf, fec_override_admin_##link); \ *_policy = MLX5_GET(pplm_reg, _buf, fec_override_admin_##link); \
} while (0) } while (0)
#define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link) \ #define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link) \
do { \ do { \
u16 *__policy = &(policy); \ unsigned long policy_long; \
bool _write = (write); \ u16 *__policy = &(policy); \
\ bool _write = (write); \
if (_write && *__policy) \ \
*__policy = find_first_bit((u_long *)__policy, \ policy_long = *__policy; \
sizeof(u16) * BITS_PER_BYTE);\ if (_write && *__policy) \
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link); \ *__policy = find_first_bit(&policy_long, \
if (!_write && *__policy) \ sizeof(policy_long) * BITS_PER_BYTE);\
*__policy = 1 << *__policy; \ MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link); \
if (!_write && *__policy) \
*__policy = 1 << *__policy; \
} while (0) } while (0)
/* get/set FEC admin field for a given speed */ /* get/set FEC admin field for a given speed */
......
...@@ -665,11 +665,12 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = { ...@@ -665,11 +665,12 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = {
static int get_fec_supported_advertised(struct mlx5_core_dev *dev, static int get_fec_supported_advertised(struct mlx5_core_dev *dev,
struct ethtool_link_ksettings *link_ksettings) struct ethtool_link_ksettings *link_ksettings)
{ {
u_long active_fec = 0; unsigned long active_fec_long;
u32 active_fec;
u32 bitn; u32 bitn;
int err; int err;
err = mlx5e_get_fec_mode(dev, (u32 *)&active_fec, NULL); err = mlx5e_get_fec_mode(dev, &active_fec, NULL);
if (err) if (err)
return (err == -EOPNOTSUPP) ? 0 : err; return (err == -EOPNOTSUPP) ? 0 : err;
...@@ -682,10 +683,11 @@ static int get_fec_supported_advertised(struct mlx5_core_dev *dev, ...@@ -682,10 +683,11 @@ static int get_fec_supported_advertised(struct mlx5_core_dev *dev,
MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1, MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1,
ETHTOOL_LINK_MODE_FEC_LLRS_BIT); ETHTOOL_LINK_MODE_FEC_LLRS_BIT);
active_fec_long = active_fec;
/* active fec is a bit set, find out which bit is set and /* active fec is a bit set, find out which bit is set and
* advertise the corresponding ethtool bit * advertise the corresponding ethtool bit
*/ */
bitn = find_first_bit(&active_fec, sizeof(u32) * BITS_PER_BYTE); bitn = find_first_bit(&active_fec_long, sizeof(active_fec_long) * BITS_PER_BYTE);
if (bitn < ARRAY_SIZE(pplm_fec_2_ethtool_linkmodes)) if (bitn < ARRAY_SIZE(pplm_fec_2_ethtool_linkmodes))
__set_bit(pplm_fec_2_ethtool_linkmodes[bitn], __set_bit(pplm_fec_2_ethtool_linkmodes[bitn],
link_ksettings->link_modes.advertising); link_ksettings->link_modes.advertising);
...@@ -1517,8 +1519,8 @@ static int mlx5e_get_fecparam(struct net_device *netdev, ...@@ -1517,8 +1519,8 @@ static int mlx5e_get_fecparam(struct net_device *netdev,
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 fec_configured = 0; u16 fec_configured;
u32 fec_active = 0; u32 fec_active;
int err; int err;
err = mlx5e_get_fec_mode(mdev, &fec_active, &fec_configured); err = mlx5e_get_fec_mode(mdev, &fec_active, &fec_configured);
...@@ -1526,14 +1528,14 @@ static int mlx5e_get_fecparam(struct net_device *netdev, ...@@ -1526,14 +1528,14 @@ static int mlx5e_get_fecparam(struct net_device *netdev,
if (err) if (err)
return err; return err;
fecparam->active_fec = pplm2ethtool_fec((u_long)fec_active, fecparam->active_fec = pplm2ethtool_fec((unsigned long)fec_active,
sizeof(u32) * BITS_PER_BYTE); sizeof(unsigned long) * BITS_PER_BYTE);
if (!fecparam->active_fec) if (!fecparam->active_fec)
return -EOPNOTSUPP; return -EOPNOTSUPP;
fecparam->fec = pplm2ethtool_fec((u_long)fec_configured, fecparam->fec = pplm2ethtool_fec((unsigned long)fec_configured,
sizeof(u16) * BITS_PER_BYTE); sizeof(unsigned long) * BITS_PER_BYTE);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment