[PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mlx5e_set_fecparam() used bitmap API to handle fecparam->fec. This is a
bad practice because ->fec is not a bitmap - it's an u32 mask.

The code wants to prevent user from passing ->fec with many modes
enables. For this purpose it's better to use MANY_BITS() macro, which
allows to avoid converting u32 to bitmap.

CC: David S. Miller <davem@xxxxxxxxxxxxx>
CC: Eric Dumazet <edumazet@xxxxxxxxxx>
CC: Jakub Kicinski <kuba@xxxxxxxxxx>
CC: Leon Romanovsky <leon@xxxxxxxxxx>
CC: Paolo Abeni <pabeni@xxxxxxxxxx>
CC: Saeed Mahameed <saeedm@xxxxxxxxxx>
CC: netdev@xxxxxxxxxxxxxxx
CC: linux-rdma@xxxxxxxxxxxxxxx
CC: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 6e80585d731f..316cb72c4cc8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1664,13 +1664,11 @@ static int mlx5e_set_fecparam(struct net_device *netdev,
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 	struct mlx5_core_dev *mdev = priv->mdev;
-	unsigned long fec_bitmap;
 	u16 fec_policy = 0;
 	int mode;
 	int err;
 
-	bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE);
-	if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1)
+	if (MANY_BITS(fecparam->fec))
 		return -EOPNOTSUPP;
 
 	for (mode = 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) {
-- 
2.32.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux