public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn•ch>
To: Tristram.Ha@microchip•com
Cc: Sergio Paracuellos <sergio.paracuellos@gmail•com>,
	Florian Fainelli <f.fainelli@gmail•com>,
	Pavel Machek <pavel@ucw•cz>,
	UNGLinuxDriver@microchip•com, netdev@vger•kernel.org
Subject: Re: [PATCH v2 net-next 2/4] net: dsa: microchip: add MIB counter reading support
Date: Wed, 20 Feb 2019 16:08:26 +0100	[thread overview]
Message-ID: <20190220150826.GI13075@lunn.ch> (raw)
In-Reply-To: <1550620623-13036-3-git-send-email-Tristram.Ha@microchip.com>

> +static void mib_monitor(struct timer_list *t)
> +{
> +	struct ksz_device *dev = from_timer(dev, t, mib_read_timer);
> +	const struct dsa_port *dp;
> +	struct net_device *netdev;
> +	struct ksz_port_mib *mib;
> +	struct ksz_port *p;
> +	int i;
> +
> +	mod_timer(&dev->mib_read_timer, jiffies + dev->mib_read_interval);
> +
> +	/* Check which port needs to read MIB counters. */
> +	for (i = 0; i < dev->mib_port_cnt; i++) {
> +		p = &dev->ports[i];
> +		if (!p->on)
> +			continue;
> +		dp = dsa_to_port(dev->ds, i);
> +		netdev = dp->slave;
> +
> +		mib = &p->mib;
> +		mutex_lock(&mib->cnt_mutex);
> +
> +		/* Read only dropped counters when link is not up. */
> +		if (netdev && netdev->phydev && !netdev->phydev->link)
> +			mib->cnt_ptr = dev->reg_mib_cnt;
> +		mutex_unlock(&mib->cnt_mutex);
> +		p->read = true;
> +	}
> +	schedule_work(&dev->mib_read);
> +}

Hi Tristram

This is much easier to understand. Thanks for making the change.

However, i suspect Florian was suggesting you use
netif_carrier_ok(netdev), not poke around inside the phydev structure.

	Andrew

  reply	other threads:[~2019-02-20 15:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 23:56 [PATCH v2 net-next 0/4] net: dsa: microchip: add MIB counters support Tristram.Ha
2019-02-19 23:57 ` [PATCH v2 net-next 1/4] net: dsa: microchip: prepare PHY for proper advertisement Tristram.Ha
2019-02-19 23:57 ` [PATCH v2 net-next 2/4] net: dsa: microchip: add MIB counter reading support Tristram.Ha
2019-02-20 15:08   ` Andrew Lunn [this message]
2019-02-20 17:22     ` Florian Fainelli
2019-02-19 23:57 ` [PATCH v2 net-next 3/4] net: dsa: microchip: get port link status Tristram.Ha
2019-02-19 23:57 ` [PATCH v2 net-next 4/4] net: dsa: microchip: remove unnecessary include headers Tristram.Ha

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=20190220150826.GI13075@lunn.ch \
    --to=andrew@lunn$(echo .)ch \
    --cc=Tristram.Ha@microchip$(echo .)com \
    --cc=UNGLinuxDriver@microchip$(echo .)com \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pavel@ucw$(echo .)cz \
    --cc=sergio.paracuellos@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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