From: Florian Fainelli <f.fainelli@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>, David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next 1/2] net: dsa: mv88e6xxx: Keep ATU/VTU violation statistics
Date: Wed, 28 Mar 2018 11:17:19 -0700 [thread overview]
Message-ID: <70d16316-df99-0664-a574-18edaa3ec313@gmail.com> (raw)
In-Reply-To: <1522187980-23072-2-git-send-email-andrew@lunn.ch>
On 03/27/2018 02:59 PM, Andrew Lunn wrote:
> Count the numbers of various ATU and VTU violation statistics and
> return them as part of the ethtool -S statistics.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> drivers/net/dsa/mv88e6xxx/chip.c | 50 ++++++++++++++++++++++++++++-----
> drivers/net/dsa/mv88e6xxx/chip.h | 13 ++++++---
> drivers/net/dsa/mv88e6xxx/global1_atu.c | 12 +++++---
> drivers/net/dsa/mv88e6xxx/global1_vtu.c | 8 ++++--
> drivers/net/dsa/mv88e6xxx/serdes.c | 15 ++++++----
> drivers/net/dsa/mv88e6xxx/serdes.h | 8 +++---
> 6 files changed, 78 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 9a5d786b4885..186021f98c5d 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -723,6 +723,24 @@ static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
> STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
> }
>
> +static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
Why not const char *?
> + "atu_member_violation",
> + "atu_miss_violation",
> + "atu_full_violation",
> + "vtu_member_violation",
> + "vtu_miss_violation",
> +};
> +
> +static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
> +{
> + int i;
unsigned int i?
> +
> + for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
> + strlcpy(data + i * ETH_GSTRING_LEN,
> + mv88e6xxx_atu_vtu_stats_strings[i],
> + ETH_GSTRING_LEN);
> +}
> +
> static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
> uint8_t *data)
> {
> @@ -736,9 +754,12 @@ static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
>
> if (chip->info->ops->serdes_get_strings) {
> data += count * ETH_GSTRING_LEN;
> - chip->info->ops->serdes_get_strings(chip, port, data);
> + count = chip->info->ops->serdes_get_strings(chip, port, data);
> }
>
> + data += count * ETH_GSTRING_LEN;
> + mv88e6xxx_atu_vtu_get_strings(data);
> +
> mutex_unlock(&chip->reg_lock);
> }
>
> @@ -783,10 +804,13 @@ static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port)
> if (chip->info->ops->serdes_get_sset_count)
> serdes_count = chip->info->ops->serdes_get_sset_count(chip,
> port);
> - if (serdes_count < 0)
> + if (serdes_count < 0) {
> count = serdes_count;
> - else
> - count += serdes_count;
> + goto out;
> + }
> + count += serdes_count;
> + count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
> +
> out:
> mutex_unlock(&chip->reg_lock);
>
> @@ -841,6 +865,16 @@ static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
> 0);
> }
>
> +static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
> + uint64_t *data)
> +{
> + *data++ = chip->ports[port].atu_member_violation;
> + *data++ = chip->ports[port].atu_miss_violation;
> + *data++ = chip->ports[port].atu_full_violation;
> + *data++ = chip->ports[port].vtu_member_violation;
> + *data++ = chip->ports[port].vtu_miss_violation;
This looks fine, but I suppose you could just have an u64 pointer which
is initialized to point to atu_member_violation, and then just do
pointer arithmetics to iterate, this would avoid possibly missing that
function in case new ATU/VTU violations are handled in the future?
--
Florian
next prev parent reply other threads:[~2018-03-28 18:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 21:59 [PATCH net-next 0/2] Add ATU/VTU statistics Andrew Lunn
2018-03-27 21:59 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: Keep ATU/VTU violation statistics Andrew Lunn
2018-03-28 18:17 ` Florian Fainelli [this message]
2018-03-28 19:33 ` Andrew Lunn
2018-03-28 19:57 ` Florian Fainelli
2018-03-27 21:59 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Make VTU miss violations less spammy Andrew Lunn
2018-03-28 18:11 ` Florian Fainelli
2018-03-28 19:34 ` Andrew Lunn
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=70d16316-df99-0664-a574-18edaa3ec313@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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).