Commit 132b4ebf authored by Nitya Sunkad's avatar Nitya Sunkad Committed by David S. Miller
Browse files

ionic: add support for ethtool extended stat link_down_count



Following the example of 'commit 9a0f830f ("ethtool: linkstate:
add a statistic for PHY down events")', added support for link down
events.

Add callback ionic_get_link_ext_stats to ionic_ethtool.c to support
link_down_count, a property of netdev that gets reported exclusively
on physical link down events.

Run ethtool -I <devname> to display the device link down count.

Signed-off-by: default avatarNitya Sunkad <nitya.sunkad@amd.com>
Signed-off-by: default avatarShannon Nelson <shannon.nelson@amd.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 72d77bad
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -104,6 +104,15 @@ static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
	memcpy_fromio(p + offset, lif->ionic->idev.dev_cmd_regs->words, size);
}

static void ionic_get_link_ext_stats(struct net_device *netdev,
				     struct ethtool_link_ext_stats *stats)
{
	struct ionic_lif *lif = netdev_priv(netdev);

	if (lif->ionic->pdev->is_physfn)
		stats->link_down_events = lif->link_down_count;
}

static int ionic_get_link_ksettings(struct net_device *netdev,
				    struct ethtool_link_ksettings *ks)
{
@@ -1074,6 +1083,7 @@ static const struct ethtool_ops ionic_ethtool_ops = {
	.get_regs_len		= ionic_get_regs_len,
	.get_regs		= ionic_get_regs,
	.get_link		= ethtool_op_get_link,
	.get_link_ext_stats	= ionic_get_link_ext_stats,
	.get_link_ksettings	= ionic_get_link_ksettings,
	.set_link_ksettings	= ionic_set_link_ksettings,
	.get_coalesce		= ionic_get_coalesce,
+1 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ static void ionic_link_status_check(struct ionic_lif *lif)
		}
	} else {
		if (netif_carrier_ok(netdev)) {
			lif->link_down_count++;
			netdev_info(netdev, "Link down\n");
			netif_carrier_off(netdev);
		}
+1 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ struct ionic_lif {
	u64 hw_features;
	bool registered;
	u16 lif_type;
	unsigned int link_down_count;
	unsigned int nmcast;
	unsigned int nucast;
	unsigned int nvlans;