lkml.org 
[lkml]   [2022]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam()
    Date
    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@davemloft.net>
    CC: Eric Dumazet <edumazet@google.com>
    CC: Jakub Kicinski <kuba@kernel.org>
    CC: Leon Romanovsky <leon@kernel.org>
    CC: Paolo Abeni <pabeni@redhat.com>
    CC: Saeed Mahameed <saeedm@nvidia.com>
    CC: netdev@vger.kernel.org
    CC: linux-rdma@vger.kernel.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    ---
    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
    \
     
     \ /
      Last update: 2022-05-10 17:56    [W:4.355 / U:0.168 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site