Skip to content

Commit b623603

Browse files
ayalevin123Saeed Mahameed
authored andcommitted
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: 2132b71 ("net/mlx5e: Advertise globaly supported FEC modes") Signed-off-by: Aya Levin <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 20300aa commit b623603

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/port.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -369,17 +369,19 @@ enum mlx5e_fec_supported_link_mode {
369369
*_policy = MLX5_GET(pplm_reg, _buf, fec_override_admin_##link); \
370370
} while (0)
371371

372-
#define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link) \
373-
do { \
374-
u16 *__policy = &(policy); \
375-
bool _write = (write); \
376-
\
377-
if (_write && *__policy) \
378-
*__policy = find_first_bit((u_long *)__policy, \
379-
sizeof(u16) * BITS_PER_BYTE);\
380-
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link); \
381-
if (!_write && *__policy) \
382-
*__policy = 1 << *__policy; \
372+
#define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link) \
373+
do { \
374+
unsigned long policy_long; \
375+
u16 *__policy = &(policy); \
376+
bool _write = (write); \
377+
\
378+
policy_long = *__policy; \
379+
if (_write && *__policy) \
380+
*__policy = find_first_bit(&policy_long, \
381+
sizeof(policy_long) * BITS_PER_BYTE);\
382+
MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link); \
383+
if (!_write && *__policy) \
384+
*__policy = 1 << *__policy; \
383385
} while (0)
384386

385387
/* get/set FEC admin field for a given speed */

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,12 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = {
665665
static int get_fec_supported_advertised(struct mlx5_core_dev *dev,
666666
struct ethtool_link_ksettings *link_ksettings)
667667
{
668-
u_long active_fec = 0;
668+
unsigned long active_fec_long;
669+
u32 active_fec;
669670
u32 bitn;
670671
int err;
671672

672-
err = mlx5e_get_fec_mode(dev, (u32 *)&active_fec, NULL);
673+
err = mlx5e_get_fec_mode(dev, &active_fec, NULL);
673674
if (err)
674675
return (err == -EOPNOTSUPP) ? 0 : err;
675676

@@ -682,10 +683,11 @@ static int get_fec_supported_advertised(struct mlx5_core_dev *dev,
682683
MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1,
683684
ETHTOOL_LINK_MODE_FEC_LLRS_BIT);
684685

686+
active_fec_long = active_fec;
685687
/* active fec is a bit set, find out which bit is set and
686688
* advertise the corresponding ethtool bit
687689
*/
688-
bitn = find_first_bit(&active_fec, sizeof(u32) * BITS_PER_BYTE);
690+
bitn = find_first_bit(&active_fec_long, sizeof(active_fec_long) * BITS_PER_BYTE);
689691
if (bitn < ARRAY_SIZE(pplm_fec_2_ethtool_linkmodes))
690692
__set_bit(pplm_fec_2_ethtool_linkmodes[bitn],
691693
link_ksettings->link_modes.advertising);
@@ -1517,23 +1519,23 @@ static int mlx5e_get_fecparam(struct net_device *netdev,
15171519
{
15181520
struct mlx5e_priv *priv = netdev_priv(netdev);
15191521
struct mlx5_core_dev *mdev = priv->mdev;
1520-
u16 fec_configured = 0;
1521-
u32 fec_active = 0;
1522+
u16 fec_configured;
1523+
u32 fec_active;
15221524
int err;
15231525

15241526
err = mlx5e_get_fec_mode(mdev, &fec_active, &fec_configured);
15251527

15261528
if (err)
15271529
return err;
15281530

1529-
fecparam->active_fec = pplm2ethtool_fec((u_long)fec_active,
1530-
sizeof(u32) * BITS_PER_BYTE);
1531+
fecparam->active_fec = pplm2ethtool_fec((unsigned long)fec_active,
1532+
sizeof(unsigned long) * BITS_PER_BYTE);
15311533

15321534
if (!fecparam->active_fec)
15331535
return -EOPNOTSUPP;
15341536

1535-
fecparam->fec = pplm2ethtool_fec((u_long)fec_configured,
1536-
sizeof(u16) * BITS_PER_BYTE);
1537+
fecparam->fec = pplm2ethtool_fec((unsigned long)fec_configured,
1538+
sizeof(unsigned long) * BITS_PER_BYTE);
15371539

15381540
return 0;
15391541
}

0 commit comments

Comments
 (0)