net/mlx5e: Enforce setting of a single FEC mode
authorAya Levin <ayal@mellanox.com>
Tue, 11 Feb 2020 22:32:49 +0000 (14:32 -0800)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 19 Feb 2020 03:17:30 +0000 (19:17 -0800)
Ethtool command allow setting of several FEC modes in a single set
command. The driver can only set a single FEC mode at a time. With this
patch driver will reply not-supported on setting several FEC modes.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

index d674cb6798950a8ca186756e8d2d09ce8a2e1b67..d1664ff1772b647b1023e6d826bda0cb32775223 100644 (file)
@@ -1541,6 +1541,10 @@ static int mlx5e_set_fecparam(struct net_device *netdev,
        int mode;
        int err;
 
+       if (bitmap_weight((unsigned long *)&fecparam->fec,
+                         ETHTOOL_FEC_BASER_BIT + 1) > 1)
+               return -EOPNOTSUPP;
+
        for (mode = 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) {
                if (!(pplm_fec_2_ethtool[mode] & fecparam->fec))
                        continue;