All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Saeed Mahameed' <saeed@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Aya Levin <ayal@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: RE: [net 1/8] net/mlx5e: Fix incompatible casting
Date: Thu, 3 Jun 2021 21:02:50 +0000	[thread overview]
Message-ID: <7166b5e6ebc44198bbbec5afdcb699f5@AcuMS.aculab.com> (raw)
In-Reply-To: <20210602013723.1142650-2-saeed@kernel.org>

From: Saeed Mahameed
> Sent: 02 June 2021 02:37
> 
> Device supports setting of a single fec mode at a time, enforce this
> by bitmap_weight == 1. Input from fec command is in u32, avoid cast to
> unsigned long and use bitmap_from_arr32 to populate bitmap safely.
> 
...
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> index 8360289813f0..c4724742eef1 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> @@ -1624,12 +1624,13 @@ 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;
> 
> -	if (bitmap_weight((unsigned long *)&fecparam->fec,
> -			  ETHTOOL_FEC_LLRS_BIT + 1) > 1)
> +	bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE);
> +	if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1)
>  		return -EOPNOTSUPP;

What is wrong with:
	if (fecparam->fec & (fecparam->fec - 1))
		return -EOPNOTSUPP;

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  parent reply	other threads:[~2021-06-03 21:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  1:37 [pull request][net 0/8] mlx5 fixes 2021-06-01 Saeed Mahameed
2021-06-02  1:37 ` [net 1/8] net/mlx5e: Fix incompatible casting Saeed Mahameed
2021-06-02 17:10   ` Jakub Kicinski
2021-06-02 20:30   ` patchwork-bot+netdevbpf
2021-06-03 21:02   ` David Laight [this message]
2021-06-02  1:37 ` [net 2/8] net/mlx5e: Disable TLS offload for uplink representor Saeed Mahameed
2021-06-02  1:37 ` [net 3/8] net/mlx5: Check firmware sync reset requested is set before trying to abort it Saeed Mahameed
2021-06-02  1:37 ` [net 4/8] net/mlx5e: Check for needed capability for cvlan matching Saeed Mahameed
2021-06-02  1:37 ` [net 5/8] net/mlx5e: Fix adding encap rules to slow path Saeed Mahameed
2021-06-02  1:37 ` [net 6/8] net/mlx5e: Fix HW TS with CQE compression according to profile Saeed Mahameed
2021-06-02  1:37 ` [net 7/8] net/mlx5e: Fix conflict with HW TS and CQE compression Saeed Mahameed
2021-06-02  1:37 ` [net 8/8] net/mlx5: DR, Create multi-destination flow table with level less than 64 Saeed Mahameed

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=7166b5e6ebc44198bbbec5afdcb699f5@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=ayal@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeed@kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.