lkml.org 
[lkml]   [2022]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next v2 1/1] net: dsa: microchip: ksz9477: export HW stats over stats64 interface
On Fri, Feb 18, 2022 at 09:55:54AM +0100, Oleksij Rempel wrote:
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 7e33ec73f803..16fade9a088b 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -111,6 +111,9 @@ static void ksz_mib_read_work(struct work_struct *work)
> port_r_cnt(dev, i);
> p->read = false;
> mutex_unlock(&mib->cnt_mutex);
> +
> + if (dev->dev_ops->r_mib_stat64)
> + dev->dev_ops->r_mib_stat64(dev, i);

Why not call dev->dev_ops->r_mib_stat64() under &mib->cnt_mutex here?
You grab the mutex in that function anyway. It's not a problem if the
&mib->stats64_lock spinlock is a sub-lock of the cnt_mutex. It's only a
problem if you're taking the mutex in the atomic path.

> }
>
> schedule_delayed_work(&dev->mib_read, dev->mib_read_interval);
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index 3db63f62f0a1..c6fa487fb006 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h
> @@ -22,6 +22,8 @@ struct ksz_port_mib {
> struct mutex cnt_mutex; /* structure access */
> u8 cnt_ptr;
> u64 *counters;
> + struct rtnl_link_stats64 stats64;
> + struct spinlock stats64_lock;
> };
>
> struct ksz_port {
> @@ -128,6 +130,7 @@ struct ksz_dev_ops {
> u64 *cnt);
> void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr,
> u64 *dropped, u64 *cnt);
> + void (*r_mib_stat64)(struct ksz_device *dev, int port);
> void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze);
> void (*port_init_cnt)(struct ksz_device *dev, int port);
> int (*shutdown)(struct ksz_device *dev);
> --
> 2.30.2
>

\
 
 \ /
  Last update: 2022-02-18 11:35    [W:0.034 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site