netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Shannon Nelson <snelson@pensando.io>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org
Subject: Re: [PATCH net-next 6/6] ionic: useful names for booleans
Date: Wed, 04 Nov 2020 17:21:44 -0800	[thread overview]
Message-ID: <fd2d2c3ec2fd7a34c9c74098d85da9f06f47821f.camel@kernel.org> (raw)
In-Reply-To: <20201104223354.63856-7-snelson@pensando.io>

On Wed, 2020-11-04 at 14:33 -0800, Shannon Nelson wrote:
> With a few more uses of true and false in function calls, we
> need to give them some useful names so we can tell from the
> calling point what we're doing.
> 

Aha! The root cause of the issue is passing booleans to functions in
first place, it is usually a bad idea that could lead to complication
and overloading the design for no reason, please see my suggestion in
the previous patch maybe you can apply the same approach on some of the
booleans below.


> Signed-off-by: Shannon Nelson <snelson@pensando.io>
> ---
>  drivers/net/ethernet/pensando/ionic/ionic_lif.c | 16 ++++++++-------
> -
>  drivers/net/ethernet/pensando/ionic/ionic_lif.h |  8 ++++++++
>  2 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> index a58bb572b23b..a0d2989a0d8d 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> @@ -1074,22 +1074,22 @@ static int ionic_lif_addr(struct ionic_lif
> *lif, const u8 *addr, bool add,
>  
>  static int ionic_addr_add(struct net_device *netdev, const u8 *addr)
>  {
> -	return ionic_lif_addr(netdev_priv(netdev), addr, true, true);
> +	return ionic_lif_addr(netdev_priv(netdev), addr, ADD_ADDR,
> CAN_SLEEP);
>  }
>  
>  static int ionic_ndo_addr_add(struct net_device *netdev, const u8
> *addr)
>  {
> -	return ionic_lif_addr(netdev_priv(netdev), addr, true, false);
> +	return ionic_lif_addr(netdev_priv(netdev), addr, ADD_ADDR,
> CAN_NOT_SLEEP);
>  }
>  
>  static int ionic_addr_del(struct net_device *netdev, const u8 *addr)
>  {
> -	return ionic_lif_addr(netdev_priv(netdev), addr, false, true);
> +	return ionic_lif_addr(netdev_priv(netdev), addr, DEL_ADDR,
> CAN_SLEEP);
>  }
>  
>  static int ionic_ndo_addr_del(struct net_device *netdev, const u8
> *addr)
>  {
> -	return ionic_lif_addr(netdev_priv(netdev), addr, false, false);
> +	return ionic_lif_addr(netdev_priv(netdev), addr, DEL_ADDR,
> CAN_NOT_SLEEP);
>  }
>  
>  static void ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int
> rx_mode)
> @@ -1214,7 +1214,7 @@ static void ionic_set_rx_mode(struct net_device
> *netdev, bool from_ndo)
>  
>  static void ionic_ndo_set_rx_mode(struct net_device *netdev)
>  {
> -	ionic_set_rx_mode(netdev, true);
> +	ionic_set_rx_mode(netdev, FROM_NDO);
>  }
>  
>  static __le64 ionic_netdev_features_to_nic(netdev_features_t
> features)
> @@ -1805,7 +1805,7 @@ static int ionic_txrx_init(struct ionic_lif
> *lif)
>  	if (lif->netdev->features & NETIF_F_RXHASH)
>  		ionic_lif_rss_init(lif);
>  
> -	ionic_set_rx_mode(lif->netdev, false);
> +	ionic_set_rx_mode(lif->netdev, NOT_FROM_NDO);
>  
>  	return 0;
>  
> @@ -2813,7 +2813,7 @@ static int ionic_station_set(struct ionic_lif
> *lif)
>  		 */
>  		if (!ether_addr_equal(ctx.comp.lif_getattr.mac,
>  				      netdev->dev_addr))
> -			ionic_lif_addr(lif, netdev->dev_addr, true,
> true);
> +			ionic_lif_addr(lif, netdev->dev_addr, ADD_ADDR,
> CAN_SLEEP);
>  	} else {
>  		/* Update the netdev mac with the device's mac */
>  		memcpy(addr.sa_data, ctx.comp.lif_getattr.mac, netdev-
> >addr_len);
> @@ -2830,7 +2830,7 @@ static int ionic_station_set(struct ionic_lif
> *lif)
>  
>  	netdev_dbg(lif->netdev, "adding station MAC addr %pM\n",
>  		   netdev->dev_addr);
> -	ionic_lif_addr(lif, netdev->dev_addr, true, true);
> +	ionic_lif_addr(lif, netdev->dev_addr, ADD_ADDR, CAN_SLEEP);
>  
>  	return 0;
>  }
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h
> b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
> index 0224dfd24b8a..493de679b498 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
> @@ -13,6 +13,14 @@
>  
>  #define IONIC_MAX_NUM_NAPI_CNTR		(NAPI_POLL_WEIGHT + 1)
>  #define IONIC_MAX_NUM_SG_CNTR		(IONIC_TX_MAX_SG_ELEMS
> + 1)
> +
> +#define ADD_ADDR	true
> +#define DEL_ADDR	false
> +#define CAN_SLEEP	true
> +#define CAN_NOT_SLEEP	false
> +#define FROM_NDO	true
> +#define NOT_FROM_NDO	false
> +
>  #define IONIC_RX_COPYBREAK_DEFAULT	256
>  #define IONIC_TX_BUDGET_DEFAULT		256
>  


  reply	other threads:[~2020-11-05  1:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 22:33 [PATCH net-next 0/6] ionic updates Shannon Nelson
2020-11-04 22:33 ` [PATCH net-next 1/6] ionic: start queues before announcing link up Shannon Nelson
2020-11-04 22:33 ` [PATCH net-next 2/6] ionic: check for link after netdev registration Shannon Nelson
2020-11-04 22:33 ` [PATCH net-next 3/6] ionic: add lif quiesce Shannon Nelson
2020-11-05  0:50   ` Saeed Mahameed
2020-11-05 18:49     ` Shannon Nelson
2020-11-04 22:33 ` [PATCH net-next 4/6] ionic: batch rx buffer refilling Shannon Nelson
2020-11-05  1:08   ` Saeed Mahameed
2020-11-05 18:49     ` Shannon Nelson
2020-11-04 22:33 ` [PATCH net-next 5/6] ionic: use mc sync for multicast filters Shannon Nelson
2020-11-05  1:18   ` Saeed Mahameed
2020-11-05 18:50     ` Shannon Nelson
2020-11-04 22:33 ` [PATCH net-next 6/6] ionic: useful names for booleans Shannon Nelson
2020-11-05  1:21   ` Saeed Mahameed [this message]
2020-11-05 18:50     ` Shannon Nelson

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=fd2d2c3ec2fd7a34c9c74098d85da9f06f47821f.camel@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=snelson@pensando.io \
    /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).