public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Jerry Ray <jerry.ray@microchip.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3] dsa: lan9303: Add 3 ethtool stats
Date: Mon, 28 Nov 2022 23:05:15 +0200	[thread overview]
Message-ID: <20221128210515.kqvdshlh3phmdpxx@skbuf> (raw)
In-Reply-To: <20221128205521.32116-1-jerry.ray@microchip.com>

On Mon, Nov 28, 2022 at 02:55:21PM -0600, Jerry Ray wrote:
>  static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port,
>  				      uint64_t *data)
>  {
>  	struct lan9303 *chip = ds->priv;
> -	unsigned int u;
> +	unsigned int i, u;
>  
>  	for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
>  		u32 reg;
>  		int ret;
>  
> -		ret = lan9303_read_switch_port(
> -			chip, port, lan9303_mib[u].offset, &reg);
> -
> +		/* Read Port-based MIB stats. */
> +		ret = lan9303_read_switch_port(chip, port,
> +					       lan9303_mib[u].offset,
> +					       &reg);

Speaking of unrelated changes...

>  		if (ret)
>  			dev_warn(chip->dev, "Reading status port %d reg %u failed\n",
>  				 port, lan9303_mib[u].offset);

...If lan9303_read_switch_port() fails, should we copy kernel stack
uninitialized memory (reg) to user space?

>  		data[u] = reg;
>  	}
> +	for (i = 0; i < ARRAY_SIZE(lan9303_switch_mib); i++) {
> +		u32 reg;
> +		int ret;
> +
> +		/* Read Switch stats indexed by port. */
> +		ret = lan9303_read_switch_reg(chip,
> +					      (lan9303_switch_mib[i].offset +
> +					       port), &reg);
> +		if (ret)
> +			dev_warn(chip->dev, "Reading status port %d reg %u failed\n",
> +				 port, lan9303_switch_mib[i].offset);

Because the same, existing pattern is also used for new code here.

> +		data[i + u] = reg;
> +	}
>  }
>  
>  static int lan9303_get_sset_count(struct dsa_switch *ds, int port, int sset)
> @@ -1017,7 +1061,7 @@ static int lan9303_get_sset_count(struct dsa_switch *ds, int port, int sset)
>  	if (sset != ETH_SS_STATS)
>  		return 0;
>  
> -	return ARRAY_SIZE(lan9303_mib);
> +	return ARRAY_SIZE(lan9303_mib) + ARRAY_SIZE(lan9303_switch_mib);
>  }
>  
>  static int lan9303_phy_read(struct dsa_switch *ds, int phy, int regnum)
> -- 
> 2.17.1
> 

  reply	other threads:[~2022-11-28 21:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 20:55 [PATCH net-next v3] dsa: lan9303: Add 3 ethtool stats Jerry Ray
2022-11-28 21:05 ` Vladimir Oltean [this message]
2022-11-30 15:57   ` Jerry.Ray
2022-11-30 16:00     ` Andrew Lunn
2022-11-28 23:21 ` Jakub Kicinski
2022-11-30 15:51   ` Jerry.Ray
2022-11-30 16:52     ` Jakub Kicinski
2022-11-30 18:12       ` Jerry.Ray
2022-11-30 18:50         ` Vladimir Oltean
2022-12-01 15:56           ` Jerry.Ray

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=20221128210515.kqvdshlh3phmdpxx@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=jerry.ray@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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