From: Vladimir Oltean <olteanv@gmail.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vivien Didelot <vivien.didelot@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
kernel@pengutronix.de, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v1 1/1] net: dsa: microchip: ksz9477: export HW stats over stats64 interface
Date: Thu, 17 Feb 2022 17:55:54 +0200 [thread overview]
Message-ID: <20220217155554.bo6gcva6h2pkryou@skbuf> (raw)
In-Reply-To: <20220217140726.248071-1-o.rempel@pengutronix.de>
On Thu, Feb 17, 2022 at 03:07:26PM +0100, Oleksij Rempel wrote:
> +static void ksz9477_get_stats64(struct dsa_switch *ds, int port,
> + struct rtnl_link_stats64 *stats)
> +{
> + struct ksz_device *dev = ds->priv;
> + struct ksz9477_stats_raw *raw;
> + struct ksz_port_mib *mib;
> + int ret;
> +
> + mib = &dev->ports[port].mib;
> + raw = (struct ksz9477_stats_raw *)mib->counters;
> +
> + mutex_lock(&mib->cnt_mutex);
The eternal problem, ndo_get_stats64 runs in atomic context,
mutex_lock() sleeps. Please test your patches with
CONFIG_DEBUG_ATOMIC_SLEEP=y.
> +
> + stats->rx_packets = raw->rx_bcast + raw->rx_mcast + raw->rx_ucast;
> + stats->tx_packets = raw->tx_bcast + raw->tx_mcast + raw->tx_ucast;
> +
> + /* HW counters are counting bytes + FCS which is not acceptable
> + * for rtnl_link_stats64 interface
> + */
> + stats->rx_bytes = raw->rx_total - stats->rx_packets * ETH_FCS_LEN;
> + stats->tx_bytes = raw->tx_total - stats->tx_packets * ETH_FCS_LEN;
> +
> + stats->rx_length_errors = raw->rx_undersize + raw->rx_fragments +
> + raw->rx_oversize;
> +
> + stats->rx_crc_errors = raw->rx_crc_err;
> + stats->rx_frame_errors = raw->rx_align_err;
> + stats->rx_dropped = raw->rx_discards;
> + stats->rx_errors = stats->rx_length_errors + stats->rx_crc_errors +
> + stats->rx_frame_errors + stats->rx_dropped;
> +
> + stats->tx_window_errors = raw->tx_late_col;
> + stats->tx_fifo_errors = raw->tx_discards;
> + stats->tx_aborted_errors = raw->tx_exc_col;
> + stats->tx_errors = stats->tx_window_errors + stats->tx_fifo_errors +
> + stats->tx_aborted_errors;
> +
> + stats->multicast = raw->rx_mcast;
> + stats->collisions = raw->tx_total_col;
> +
> + mutex_unlock(&mib->cnt_mutex);
> +}
> +
> static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
> {
> regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0);
> @@ -1365,6 +1447,7 @@ static const struct dsa_switch_ops ksz9477_switch_ops = {
> .port_mdb_del = ksz9477_port_mdb_del,
> .port_mirror_add = ksz9477_port_mirror_add,
> .port_mirror_del = ksz9477_port_mirror_del,
> + .get_stats64 = ksz9477_get_stats64,
> };
>
> static u32 ksz9477_get_port_addr(int port, int offset)
> --
> 2.30.2
>
next prev parent reply other threads:[~2022-02-17 15:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 14:07 [PATCH net-next v1 1/1] net: dsa: microchip: ksz9477: export HW stats over stats64 interface Oleksij Rempel
2022-02-17 15:55 ` Vladimir Oltean [this message]
2022-02-18 8:39 ` Oleksij Rempel
2022-02-18 10:43 ` Vladimir Oltean
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=20220217155554.bo6gcva6h2pkryou@skbuf \
--to=olteanv@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.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