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

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
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -371,12 +371,14 @@ enum mlx5e_fec_supported_link_mode {

#define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link)			\
	do {										\
		unsigned long policy_long;						\
		u16 *__policy = &(policy);						\
		bool _write = (write);							\
											\
		policy_long = *__policy;						\
		if (_write && *__policy)						\
			*__policy = find_first_bit((u_long *)__policy,		\
						   sizeof(u16) * BITS_PER_BYTE);\
			*__policy = find_first_bit(&policy_long,			\
						   sizeof(policy_long) * BITS_PER_BYTE);\
		MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link);		\
		if (!_write && *__policy)						\
			*__policy = 1 << *__policy;					\
+11 −9
Original line number Diff line number Diff line
@@ -665,11 +665,12 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = {
static int get_fec_supported_advertised(struct mlx5_core_dev *dev,
					struct ethtool_link_ksettings *link_ksettings)
{
	u_long active_fec = 0;
	unsigned long active_fec_long;
	u32 active_fec;
	u32 bitn;
	int err;

	err = mlx5e_get_fec_mode(dev, (u32 *)&active_fec, NULL);
	err = mlx5e_get_fec_mode(dev, &active_fec, NULL);
	if (err)
		return (err == -EOPNOTSUPP) ? 0 : err;

@@ -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,
				      ETHTOOL_LINK_MODE_FEC_LLRS_BIT);

	active_fec_long = active_fec;
	/* active fec is a bit set, find out which bit is set and
	 * 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))
		__set_bit(pplm_fec_2_ethtool_linkmodes[bitn],
			  link_ksettings->link_modes.advertising);
@@ -1517,8 +1519,8 @@ static int mlx5e_get_fecparam(struct net_device *netdev,
{
	struct mlx5e_priv *priv = netdev_priv(netdev);
	struct mlx5_core_dev *mdev = priv->mdev;
	u16 fec_configured = 0;
	u32 fec_active = 0;
	u16 fec_configured;
	u32 fec_active;
	int err;

	err = mlx5e_get_fec_mode(mdev, &fec_active, &fec_configured);
@@ -1526,14 +1528,14 @@ static int mlx5e_get_fecparam(struct net_device *netdev,
	if (err)
		return err;

	fecparam->active_fec = pplm2ethtool_fec((u_long)fec_active,
						sizeof(u32) * BITS_PER_BYTE);
	fecparam->active_fec = pplm2ethtool_fec((unsigned long)fec_active,
						sizeof(unsigned long) * BITS_PER_BYTE);

	if (!fecparam->active_fec)
		return -EOPNOTSUPP;

	fecparam->fec = pplm2ethtool_fec((u_long)fec_configured,
					 sizeof(u16) * BITS_PER_BYTE);
	fecparam->fec = pplm2ethtool_fec((unsigned long)fec_configured,
					 sizeof(unsigned long) * BITS_PER_BYTE);

	return 0;
}