ionic: add support for ethtool extended stat link_down_count
Subsystems (3)
PATCH v2 1/1 ionic: add support for ethtool extended stat link_down_count
From: Nitya Sunkad <[email protected]>
Following the example of 'commit 9a0f830f8026 ("ethtool: linkstate:
add a statistic for PHY down events")', added support for link down events.
Added 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.
---
v2: Report link_down_count only on PF, not on VF
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 10 ++++++++++ drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 + drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 + 3 files changed, 12 insertions(+)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +10 -0
@@ -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,
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -0
@@ -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); }
drivers/net/ethernet/pensando/ionic/ionic_lif.h +1 -0
@@ -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;
Signature · 1 line
2.17.1
Quoted 9 lines · Shannon Nelson
From: Nitya Sunkad <[email protected]>
Following the example of 'commit
9a0f830f8026("ethtool: linkstate:
add a statistic for PHY down events")', added support for link down events.Added callback
ionic_get_link_ext_statstoionic_ethtool.cto supportlink_down_count, a property of netdev that gets reported exclusively on physical link down events.
Commit message hasn't changed since v1, despite the comment about usage of "added" vs "add".
Quoted 18 lines
Run ethtool -I <devname> to display the device link down count.
Signed-off-by Nitya Sunkad <[email protected]>Signed-off-by Shannon Nelson <[email protected]>---
v2: Reportlink_down_countonly on PF, not on VFdrivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 10 ++++++++++ drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 + drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 + 3 files changed, 12 insertions(+)drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +0
-0
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs, · line 112
Quoted 9 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +6
-0@@ -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)
Maybe
ionic->pdev->device == PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF
from [0] would be a more reliable way to determine, whether we are dealing with a PF?
Quoted 42 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +4
-0+ 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,drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0@@ -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); }drivers/net/ethernet/pensando/ionic/ionic_lif.h +1
-0@@ -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;Signature · 1 line
2.17.1
Quoted 8 lines · Larysa Zaremba
Quoted 6 lines · Shannon Nelson
From: Nitya Sunkad <[email protected]>
Following the example of 'commit
9a0f830f8026("ethtool: linkstate:
add a statistic for PHY down events")', added support for link down events.
Quoted 6 lines
Quoted 3 lines
Added callback
ionic_get_link_ext_statstoionic_ethtool.cto supportlink_down_count, a property of netdev that gets reported exclusively on physical link down events.Commit message hasn't changed since v1, despite the comment about usage of "added" vs "add".
Sorry, missed that. Not sure this is worth another spin by itself.
Quoted 31 lines
Quoted 19 lines
Run ethtool -I <devname> to display the device link down count.
Signed-off-by Nitya Sunkad <[email protected]>Signed-off-by Shannon Nelson <[email protected]>---
v2: Reportlink_down_countonly on PF, not on VFdrivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 10 ++++++++++ drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 + drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 + 3 files changed, 12 insertions(+)drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +0
-0drivers/net/ethernet/pensando/ionic/ionic_ethtool.c static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs, · line 112
Quoted 9 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +6
-0@@ -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)Maybe
Quoted 6 lines
ionic->pdev->device==PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PFfrom [0] would be a more reliable way to determine, whether we are dealing with a PF?
Note that the indicated code was removed from later versions of that patchset and never actually made it into the driver. See commit fbb39807e9ae ('ionic: support sr-iov operations')
Also, using is_physfn will still work with no further changes if we ever add another PF device id.
Unless anyone else has a preference, I think this works fine as is.
sln
Quoted 43 lines
Quoted 43 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +4
-0+ 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,drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0@@ -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); }drivers/net/ethernet/pensando/ionic/ionic_lif.h +1
-1@@ -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; --2.17.1
Larysa Zaremba
Reviewed-byQuoted 60 lines · Shannon Nelson
Quoted 8 lines · Larysa Zaremba
Quoted 6 lines · Shannon Nelson
From: Nitya Sunkad <[email protected]>
Following the example of 'commit
9a0f830f8026("ethtool: linkstate:
add a statistic for PHY down events")', added support for link down events.Quoted 6 lines
Quoted 3 lines
Added callback
ionic_get_link_ext_statstoionic_ethtool.cto supportlink_down_count, a property of netdev that gets reported exclusively on physical link down events.Commit message hasn't changed since v1, despite the comment about usage of "added" vs "add".
Sorry, missed that. Not sure this is worth another spin by itself.
Quoted 31 lines
Quoted 19 lines
Run ethtool -I <devname> to display the device link down count.
Signed-off-by Nitya Sunkad <[email protected]>Signed-off-by Shannon Nelson <[email protected]>---
v2: Reportlink_down_countonly on PF, not on VFdrivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 10 ++++++++++ drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 + drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 + 3 files changed, 12 insertions(+)drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +0
-0drivers/net/ethernet/pensando/ionic/ionic_ethtool.c static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs, · line 112
Quoted 9 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +6
-0@@ -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)Maybe
Quoted 6 lines
ionic->pdev->device==PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PFfrom [0] would be a more reliable way to determine, whether we are dealing with a PF?
Note that the indicated code was removed from later versions of that patchset and never actually made it into the driver.
See commitfbb39807e9ae('ionic: support sr-iov operations')
Quoted 7 lines
Also, using
is_physfnwill still work with no further changes if we ever add another PF device id.Unless anyone else has a preference, I think this works fine as is.
sln
If you say so, I won't fight :)
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +4
-0+ 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,drivers/net/ethernet/pensando/ionic/ionic_lif.c +1
-0@@ -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); }drivers/net/ethernet/pensando/ionic/ionic_lif.h +1
-1@@ -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; --2.17.1
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 11 lines · On Thu, 8 Jun 2023 22:50:16 -0700 you wrote:
From: Nitya Sunkad <[email protected]>
Following the example of 'commit
9a0f830f8026("ethtool: linkstate:
add a statistic for PHY down events")', added support for link down events.Added callback
ionic_get_link_ext_statstoionic_ethtool.cto supportlink_down_count, a property of netdev that gets reported exclusively on physical link down events.[...]
Here is the summary with links:
- [v2,net-next] ionic: add support for ethtool extended stat link_down_count
https://git.kernel.org/netdev/net-next/c/132b4ebfa090
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html