netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"David Laight" <David.Laight@ACULAB.COM>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Joe Perches" <joe@perches.com>,
	"Julia Lawall" <Julia.Lawall@inria.fr>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Nicolas Palix" <nicolas.palix@imag.fr>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Matti Vaittinen" <Matti.Vaittinen@fi.rohmeurope.com>,
	linux-kernel@vger.kernel.org
Cc: Yury Norov <yury.norov@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Leon Romanovsky <leon@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam()
Date: Tue, 10 May 2022 08:47:38 -0700	[thread overview]
Message-ID: <20220510154750.212913-11-yury.norov@gmail.com> (raw)
In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com>

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


  parent reply	other threads:[~2022-05-10 15:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220510154750.212913-1-yury.norov@gmail.com>
2022-05-10 15:47 ` [PATCH 04/22] ice: use bitmap_empty() in ice_vf_has_no_qs_ena() Yury Norov
2022-05-10 15:47 ` [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight() Yury Norov
2022-05-10 21:31   ` Jakub Kicinski
2022-05-10 15:47 ` [PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS() Yury Norov
2022-05-10 15:47 ` Yury Norov [this message]
2022-05-10 15:47 ` [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq() Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220510154750.212913-11-yury.norov@gmail.com \
    --to=yury.norov@gmail.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=Julia.Lawall@inria.fr \
    --cc=Matti.Vaittinen@fi.rohmeurope.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.palix@imag.fr \
    --cc=npiggin@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=peterz@infradead.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).