Expose more port stats to ethtool
Subsystems (3)
v3 cover Expose more port stats to ethtool
Newer hardware collects a lot more FEC statistics than older hardware; these include FEC histograms and corrected/uncorrected word and bit totals. This patchset adds plumbing to pass these through to ethtool along with another link_down_count stat that is another port-level stat. That link_down_count was already being sent to the driver by the firmware; it just wasn't used.
Brett's patch is a small unrelated improvement to devcmd handling that's still nice to have and will help enable deferred probe functionality.
---
v3:
Address issues mostly found by Sashiko:
- Fix potential return of uninitialized variable in __ionic_dev_cmd_wait()
- Fix bounds of wait in __ionic_dev_cmd_wait() to prevent function from giving up prematurely now that the wait period has changed
- Add NULL check to ionic_get_link_ext_stats(), following the example set by ionic_get_link_ksettings()
- Add missing le16_to_cpu() when copying link_down_count from firmware
v2:
- Add missing cpu_to_le64() to FEC histogram stat assignment
- Remove unused pb_stats field that's replaced by the new FEC/extra stats
- Replace ethtool ext link stat with firmware stat instead of adding the firmware stat to general ethtool statistics; remove old driver calculated stat
- Add explanation for what EAGAIN return value could be used for in commit message
Brett Creeley (1):
ionic: Small improvements in devcmd retry logic
Eric Joyner (4):
ionic: Get "link_down_count" ext link stat from firmware
ionic: Update ionic_if.h with new extra port stats structure
ionic: Report rx_bits_phy stat to ethtool
ionic: Add .get_fec_stats ethtool handler
.../ethernet/pensando/ionic/ionic_ethtool.c | 63 ++++++++++++++++++- .../net/ethernet/pensando/ionic/ionic_if.h | 36 +++-------- .../net/ethernet/pensando/ionic/ionic_lif.c | 1 - .../net/ethernet/pensando/ionic/ionic_lif.h | 1 - .../net/ethernet/pensando/ionic/ionic_main.c | 11 +++- .../net/ethernet/pensando/ionic/ionic_stats.c | 15 ++++- 6 files changed, 93 insertions(+), 34 deletions(-)
base-commit: 8c699be3dad7bba87cdda485dc099226cfc2f706
Signature · 1 line
2.17.1
PATCH v3 1/5 ionic: Small improvements in devcmd retry logic
From: Brett Creeley <[email protected]>
If the timeout time is hit when the last attempt returned EAGAIN, the driver returns -ETIMEDOUT. This causes the -EAGAIN result to be lost. Fix this by returning -EAGAIN if the timeout time is hit and the previous result matches. Another commit uses this return value to help signal that a deferred probe should be performed due to the firmware not being ready, which is why it would return EAGAIN.
Also, reduce the sleep between the write to done and doorbell registers. The msleep(1000) was initially added in an arbitrary manner. However, this long of a sleep is problematic because it reduces the number of retries when -EAGAIN is returned, which may result in the devmcd giving up early due to the timeout. Fix this by reducing the sleep to msleep(50).
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +8 -3
@@ -518,10 +518,10 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds,unsigned long start_time;unsigned long max_wait;unsigned long duration; +int err =0 ;bool fw_up;int opcode;bool done; -int err;/* Wait for dev cmd to complete, retrying if we get EAGAIN, * but don't wait any longer than max_seconds.
@@ -554,6 +554,11 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds,if (!done && !time_before (jiffies, max_wait)) {ionic_dev_cmd_clean (ionic); + +/* allow caller to manage EAGAIN from previous attempt */ +if (err ==IONIC_RC_EAGAIN ) +return -EAGAIN ; +dev_warn (ionic->dev,"DEVCMD %s (%d) timeout after %ld secs\n" ,ionic_opcode_to_str (opcode), opcode, max_seconds);return -ETIMEDOUT ;
@@ -562,13 +567,13 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, err =ionic_dev_cmd_status (&ionic->idev);if (err) {if (err ==IONIC_RC_EAGAIN && -time_before (jiffies, (max_wait -HZ ))) { +time_before (jiffies, max_wait -msecs_to_jiffies (50 ))) {dev_dbg (ionic->dev,"DEV_CMD %s (%d), %s (%d) retrying...\n" ,ionic_opcode_to_str (opcode), opcode,ionic_error_to_str (err), err);iowrite32 (0 , &idev->dev_cmd_regs->done); -msleep (1000 ); +msleep (50 );iowrite32 (1 , &idev->dev_cmd_regs->doorbell); goto try_again; }
Signature · 1 line
2.17.1
PATCH v3 2/5 ionic: Get "link_down_count" ext link stat from firmware
In reply to Eric JoynerThe number of times that link has gone down at the port level is tracked by the firmware and sent to the driver via regular DMA writes to an instance of struct ionic_port_status in the driver's memory.
This statistic was never reported in favor of a driver-derived stat, but doing it in the driver was never necessary since firmware had been reporting it the whole time. Since it would be more accurate and true to the description of the statistic to get this count at the PHY level, replace the driver-calculated statistic with the firmware one and remove the driver-calculated one entirely.
--- drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 11 +++++++++-- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 - drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 - 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +9 -2
@@ -115,9 +115,16 @@ static void ionic_get_link_ext_stats(struct net_device *netdev, struct ethtool_link_ext_stats *stats) {struct ionic_lif *lif =netdev_priv (netdev); +struct ionic *ionic = lif->ionic; + +if (!ionic->idev.port_info) { +netdev_err (netdev,"port_info not initialized\n" ); +return ; + } -if (lif->ionic->pdev->is_physfn) - stats->link_down_events = lif->link_down_count; +if (ionic->pdev->is_physfn) + stats->link_down_events = +le16_to_cpu (ionic->idev.port_info->status.link_down_count); } static int ionic_get_link_ksettings(struct net_device *netdev,
drivers/net/ethernet/pensando/ionic/ionic_lif.c +0 -1
@@ -179,7 +179,6 @@ 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 +0 -1
@@ -214,7 +214,6 @@ struct ionic_lif {bool registered;bool doorbell_wa;u16 lif_type; -unsigned int link_down_count;unsigned int nmcast;unsigned int nucast;unsigned int nvlans;
Signature · 1 line
2.17.1
PATCH v3 4/5 ionic: Report rx_bits_phy stat to ethtool
In reply to Eric JoynerThis stat contains the number of total bits that the PHY has received; it's useful for BER calculations. Add it to the ethtool stats output.
--- drivers/net/ethernet/pensando/ionic/ionic_stats.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_stats.c +14 -1
@@ -167,6 +167,7 @@ static const struct ionic_stat_desc ionic_rx_stats_desc[] = {#define IONIC_NUM_PORT_STATS ARRAY_SIZE(ionic_port_stats_desc)#define IONIC_NUM_TX_STATS ARRAY_SIZE(ionic_tx_stats_desc)#define IONIC_NUM_RX_STATS ARRAY_SIZE(ionic_rx_stats_desc) +#define IONIC_NUM_EXTRA_PORT_STATS 1#define MAX_Q (lif) ((lif)->netdev->real_num_tx_queues)
@@ -243,7 +244,7 @@ static u64 ionic_sw_stats_get_count(struct ionic_lif *lif) rx_queues +=1 ; total +=IONIC_NUM_LIF_STATS ; - total +=IONIC_NUM_PORT_STATS ; + total +=IONIC_NUM_PORT_STATS +IONIC_NUM_EXTRA_PORT_STATS ; total += tx_queues *IONIC_NUM_TX_STATS ; total += rx_queues *IONIC_NUM_RX_STATS ;
@@ -280,6 +281,8 @@ static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf)for (i =0 ; i <IONIC_NUM_PORT_STATS ; i++)ethtool_puts (buf, ionic_port_stats_desc[i].name); +/* extra port stats */ +ethtool_puts (buf,"rx_bits_phy" );for (q_num =0 ; q_num <MAX_Q (lif); q_num++)ionic_sw_stats_get_tx_strings (lif, buf, q_num);
@@ -322,6 +325,15 @@ static void ionic_sw_stats_get_rxq_values(struct ionic_lif *lif, u64 **buf, } } +static void ionic_extra_port_stats_get_values (struct ionic_lif *lif,u64 **buf) +{ +struct ionic_port_info *port_info = lif->ionic->idev.port_info; + +/* The # of stats added here == IONIC_NUM_EXTRA_PORT_STATS */ + **buf =le64_to_cpu (port_info->extra_stats.rx_bits_phy); + (*buf)++; +} +static void ionic_sw_stats_get_values (struct ionic_lif *lif,u64 **buf) {struct ionic_port_stats *port_stats;
@@ -341,6 +353,7 @@ static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf) &ionic_port_stats_desc[i]); (*buf)++; } +ionic_extra_port_stats_get_values (lif, buf);for (q_num =0 ; q_num <MAX_Q (lif); q_num++)ionic_sw_stats_get_txq_values (lif, buf, q_num);
Signature · 1 line
2.17.1
PATCH v3 5/5 ionic: Add .get_fec_stats ethtool handler
In reply to Eric JoynerSeveral FEC error statistics being collected can be reported in a dedicated ethtool callback for FEC errors, so implement the handler that does so. This includes 802.3ck FEC histogram data that some newer hardware collects.
--- .../ethernet/pensando/ionic/ionic_ethtool.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +52 -0
@@ -425,6 +425,57 @@ static int ionic_get_fecparam(struct net_device *netdev,return 0 ; } +static const struct ethtool_fec_hist_range ionic_fec_ranges[] = { + {0 ,0 }, + {1 ,1 }, + {2 ,2 }, + {3 ,3 }, + {4 ,4 }, + {5 ,5 }, + {6 ,6 }, + {7 ,7 }, + {8 ,8 }, + {9 ,9 }, + {10 ,10 }, + {11 ,11 }, + {12 ,12 }, + {13 ,13 }, + {14 ,14 }, + {15 ,15 }, + {0 ,0 }, +}; + +static void +ionic_fill_fec_hist (const struct ionic_port_extra_stats *extra_stats, +struct ethtool_fec_hist *hist) +{ +int i; + + hist->ranges = ionic_fec_ranges; +for (i =0 ; i <ETHTOOL_FEC_HIST_MAX -1 ; i++) + hist->values[i].sum = +le64_to_cpu (extra_stats->fec_codeword_error_bin[i]); +} + +static void ionic_get_fec_stats (struct net_device *netdev, +struct ethtool_fec_stats *fec_stats, +struct ethtool_fec_hist *hist) +{ +struct ionic_port_extra_stats *extra_stats; +struct ionic_lif *lif =netdev_priv (netdev); + + extra_stats = &lif->ionic->idev.port_info->extra_stats; + + fec_stats->corrected_blocks.total = +le64_to_cpu (extra_stats->rsfec_correctable_blocks); + fec_stats->uncorrectable_blocks.total = +le64_to_cpu (extra_stats->rsfec_uncorrectable_blocks); + fec_stats->corrected_bits.total = +le64_to_cpu (extra_stats->fec_corrected_bits_total); + +ionic_fill_fec_hist (extra_stats, hist); +} +static int ionic_set_fecparam (struct net_device *netdev,struct ethtool_fecparam *fec) {
@@ -1161,6 +1212,7 @@ static const struct ethtool_ops ionic_ethtool_ops = { .get_module_eeprom_by_page = ionic_get_module_eeprom_by_page, .get_pauseparam = ionic_get_pauseparam, .set_pauseparam = ionic_set_pauseparam, + .get_fec_stats = ionic_get_fec_stats, .get_fecparam = ionic_get_fecparam, .set_fecparam = ionic_set_fecparam, .get_ts_info = ionic_get_ts_info,
Signature · 1 line
2.17.1
PATCH v3 3/5 ionic: Update ionic_if.h with new extra port stats structure
In reply to Eric JoynerA new structure to report additional statistics from the firmware has been added to struct ionic_port_info. It currently only contains FEC related statistics, but new statistics collected by the firmware for the port would go in it.
This structure is located in the same area as the unused ionic_port_pb_stats structure, so this patch also removes that since it was never used in this driver.
--- .../net/ethernet/pensando/ionic/ionic_if.h | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_if.h +10 -26
@@ -2855,6 +2855,14 @@ struct ionic_mgmt_port_stats {__le64 frames_tx_pause; }; +struct ionic_port_extra_stats { +__le64 rsfec_correctable_blocks; +__le64 rsfec_uncorrectable_blocks; +__le64 fec_corrected_bits_total; +__le64 rx_bits_phy; +__le64 fec_codeword_error_bin[16 ]; +}; +enum ionic_pb_buffer_drop_stats {IONIC_BUFFER_INTRINSIC_DROP =0 ,IONIC_BUFFER_DISCARDED ,
@@ -2883,28 +2891,6 @@ enum ionic_oflow_drop_stats { IONIC_OFLOW_DROP_MAX, }; -/* struct ionic_port_pb_stats - packet buffers system stats -* uses ionic_pb_buffer_drop_stats for drop_counts[] -*/ -struct ionic_port_pb_stats { -__le64 sop_count_in; -__le64 eop_count_in; -__le64 sop_count_out; -__le64 eop_count_out; -__le64 drop_counts[IONIC_BUFFER_DROP_MAX ]; -__le64 input_queue_buffer_occupancy[IONIC_QOS_TC_MAX ]; -__le64 input_queue_port_monitor[IONIC_QOS_TC_MAX ]; -__le64 output_queue_port_monitor[IONIC_QOS_TC_MAX ]; -__le64 oflow_drop_counts[IONIC_OFLOW_DROP_MAX ]; -__le64 input_queue_good_pkts_in[IONIC_QOS_TC_MAX ]; -__le64 input_queue_good_pkts_out[IONIC_QOS_TC_MAX ]; -__le64 input_queue_err_pkts_in[IONIC_QOS_TC_MAX ]; -__le64 input_queue_fifo_depth[IONIC_QOS_TC_MAX ]; -__le64 input_queue_max_fifo_depth[IONIC_QOS_TC_MAX ]; -__le64 input_queue_peak_occupancy[IONIC_QOS_TC_MAX ]; -__le64 output_queue_buffer_occupancy[IONIC_QOS_TC_MAX ]; -}; -/** * struct ionic_port_identity - port identity structure * @version: identity structure version
@@ -2950,7 +2936,7 @@ union ionic_port_identity {* @sprom_page2: Extended Transceiver sprom, page 2 * @sprom_page17: Extended Transceiver sprom, page 17 * @rsvd: reserved byte(s) -* @pb_stats: uplink pb drop stats +* @extra_stats: Extra port statistics data */ struct ionic_port_info {union ionic_port_config config;
@@ -2968,9 +2954,7 @@ struct ionic_port_info { }; };u8 rsvd[376 ]; - -/* pb_stats must start at 2k offset */ -struct ionic_port_pb_stats pb_stats; +struct ionic_port_extra_stats extra_stats; };/*
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerRe: [PATCH net-next v3 1/5] ionic: Small improvements in devcmd retry logic
In reply to Eric JoynerQuoted 3 lines · On Tue, 12 May 2026 15:44:17 -0700 Eric Joyner wrote:
Another commit uses this return value to help
signal that a deferred probe should be performed due to the firmware not being ready, which is why it would return EAGAIN.
Where can we find that "another commit". Reading this I was expecting it to be another commit in this series, but I don't see any EAGAIN later.
Jakub Kicinski
maintainerRe: [PATCH net-next v3 2/5] ionic: Get "link_down_count" ext link stat from firmware
In reply to Eric JoynerThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
ionic: Get "link_down_count" ext link stat from firmware
This patch replaces the driver-side link_down_count counter on struct ionic_lif with a value read directly from the firmware's DMA-updated struct ionic_port_status.link_down_count, exposed via ethtool_link_ext_stats.link_down_events in ionic_get_link_ext_stats().
Quoted 5 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +0
-0
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c static void ionic_get_link_ext_stats(struct net_device *netdev, · line 123
Quoted 9 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +6
-0@@ -115,9 +115,16 @@ static void ionic_get_link_ext_stats(struct net_device *netdev, struct ethtool_link_ext_stats *stats) {struct ionic_lif *lif =netdev_priv (netdev); +struct ionic *ionic = lif->ionic; + +if (!ionic->idev.port_info) { +netdev_err (netdev,"port_info not initialized\n" ); +return ; + }
[Low]
Should this NULL check sit inside the is_physfn branch below? The port_info pointer is only dereferenced on the PF path, so a VF calling ethtool on link ext stats will now log a netdev_err even though the VF path never reads port_info.
The message is also unrate-limited and reachable from userspace via ethtool. port_info is freed and set to NULL in ionic_port_reset() and reallocated in ionic_port_init() on FW reset / FLR / PCI error recovery paths (ionic_reset_prepare()/ionic_reset_done() in ionic_bus_pci.c, and ionic_restart_lif() in ionic_lif.c), so any ethtool query during that transient window will emit a kernel log line where the previous code silently did nothing.
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c static void ionic_get_link_ext_stats(struct net_device *netdev, · line 128
Quoted 7 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +3
-2-if (lif->ionic->pdev->is_physfn) - stats->link_down_events = lif->link_down_count; +if (ionic->pdev->is_physfn) + stats->link_down_events = +le16_to_cpu (ionic->idev.port_info->status.link_down_count); }
[Medium]
The firmware-supplied link_down_count is a __le16 in struct ionic_port_status (ionic_if.h), so the value saturates at 65,535. The previous lif->link_down_count was an unsigned int (32-bit), and the ethtool field stats->link_down_events is u64 and treated as monotonic by userspace consumers (per the comment on struct ethtool_link_ext_stats in include/linux/ethtool.h).
Without driver-side rollover detection that accumulates the carry into a wider counter, after 65,536 link bounces the reported value will appear to go backward to a small number. Should the driver detect a firmware value smaller than the previously-read value and fold the delta into a 32/64-bit running tally before assigning to stats->link_down_events?
[Medium]
Does this change make link_down_events non-persistent across firmware resets? port_info lives in DMA-coherent memory that ionic_port_reset() frees and clears:
drivers/net/ethernet/pensando/ionic/ionic_main.c:ionic_port_reset() {
...
dma_free_coherent(...);
idev->port_info = NULL;
...
}and ionic_port_init() reallocates a fresh zeroed page. These are called from the FLR / PCI error recovery path (ionic_reset_prepare()/ionic_reset_done() in ionic_bus_pci.c) and from ionic_restart_lif() in ionic_lif.c, so FW-reset events that previously left the driver-resident counter untouched will now zero this stat.
The commit message does not mention this behavioral change. Should the driver snapshot the firmware value before each reset and accumulate it across reset boundaries to keep the ethtool counter monotonic?
Quoted 12 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c +0
-1@@ -179,7 +179,6 @@ 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); }
Signature · 1 line
pw-bot: cr
Jakub Kicinski
maintainerRe: [PATCH net-next v3 5/5] ionic: Add .get_fec_stats ethtool handler
In reply to Eric JoynerQuoted 2 lines · On Tue, 12 May 2026 15:44:21 -0700 Eric Joyner wrote:
This includes 802.3ck FEC histogram data that some newer hardware collects.
Ah. "Some newer hardware"? As Sashiko points out the standard stats are designed trying to avoid "does 0 mean unsupported or 0" ambiguity. You need to figure out if the device reports them and if not - don't set ranges.
Re: [PATCH net-next v3 5/5] ionic: Add .get_fec_stats ethtool handler
Quoted 11 lines · Jakub Kicinski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 2 lines · On Tue, 12 May 2026 15:44:21 -0700 Eric Joyner wrote:
This includes 802.3ck FEC histogram data that some newer hardware collects.
Ah. "Some newer hardware"? As Sashiko points out the standard stats are designed trying to avoid "does 0 mean unsupported or 0" ambiguity. You need to figure out if the device reports them and if not - don't set ranges.
Unfortunately, there's no proper/good way to do this. A stopgap measure would be to use a rough proxy measure like checking the ASIC generation; and then we can implement a better way in the firmware/driver following that.
- Eric
Jakub Kicinski
maintainerRe: [PATCH net-next v3 5/5] ionic: Add .get_fec_stats ethtool handler
Quoted 5 lines · On Fri, 15 May 2026 12:59:04 -0700 Eric Joyner wrote:
Quoted 4 lines · Jakub Kicinski
Quoted 2 lines · On Tue, 12 May 2026 15:44:21 -0700 Eric Joyner wrote:
This includes 802.3ck FEC histogram data that some newer hardware collects.
Quoted 8 lines
Quoted 4 lines
Ah. "Some newer hardware"? As Sashiko points out the standard stats are designed trying to avoid "does 0 mean unsupported or 0" ambiguity. You need to figure out if the device reports them and if not - don't set ranges.
Unfortunately, there's no proper/good way to do this. A stopgap measure would be to use a rough proxy measure like checking the ASIC generation; and then we can implement a better way in the
firmware/driverfollowing that.
The FW definitely knows, so it's a SMOC.
Could you respin just patch 2 for now, or does it suffer from the same shortcoming?
Re: [PATCH net-next v3 1/5] ionic: Small improvements in devcmd retry logic
In reply to Jakub KicinskiQuoted 11 lines · Jakub Kicinski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 3 lines · On Tue, 12 May 2026 15:44:17 -0700 Eric Joyner wrote:
Another commit uses this return value to help
signal that a deferred probe should be performed due to the firmware not being ready, which is why it would return EAGAIN.Where can we find that "another commit". Reading this I was expecting it to be another commit in this series, but I don't see any EAGAIN later.
It's in a commit in the series that's targeting net that I've posted; but I think it'll be clearer if I roll that into this series in the next rev.
- Eric
Re: [PATCH net-next v3 5/5] ionic: Add .get_fec_stats ethtool handler
In reply to Jakub KicinskiQuoted 14 lines · Jakub Kicinski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 10 lines · On Fri, 15 May 2026 12:59:04 -0700 Eric Joyner wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 2 lines · On Tue, 12 May 2026 15:44:21 -0700 Eric Joyner wrote:
This includes 802.3ck FEC histogram data that some newer hardware collects.
Ah. "Some newer hardware"? As Sashiko points out the standard stats are designed trying to avoid "does 0 mean unsupported or 0" ambiguity. You need to figure out if the device reports them and if not - don't set ranges.
Quoted 7 lines
Quoted 3 lines
Unfortunately, there's no proper/good way to do this. A stopgap measure would be to use a rough proxy measure like checking the ASIC generation; and then we can implement a better way in the
firmware/driverfollowing that.The FW definitely knows, so it's a SMOC.
Could you respin just patch 2 for now, or does it suffer from the same shortcoming?
Sorry, what I wrote should've said "there's no proper/good way to do this by only making changes in software".
You're right that the firmware knows; to that end I'm almost done changing the firmware to act similarly to how this interface distinguishes valid statistics, and have the firmware report "-1" for these new extra stats if the hardware doesn't actually collect the stat.
Does that sound good? I'm planning on rerolling this patch series with support for that.
- Eric
Jakub Kicinski
maintainerRe: [PATCH net-next v3 5/5] ionic: Add .get_fec_stats ethtool handler
Quoted 7 lines · On Mon, 18 May 2026 17:06:25 -0700 Eric Joyner wrote:
Sorry, what I wrote should've said "there's no proper/good way to do this by only making changes in software".
You're right that the firmware knows; to that end I'm almost done changing the firmware to act similarly to how this interface distinguishes valid statistics, and have the firmware report "-1" for these new extra stats if the hardware doesn't actually collect the stat.
Plumbing Linux hacks into FW is definitely not my favorite :S The way we use -1 in the kernel is a local hack which is never meant to escape the kernel.
If you want to do something similar with your FW - please make sure you add your local defines, and code which _explicitly_ interprets -1 coming out of FW to the driver is "not set". IOW don't user ETHTOOL defines or assign the FW-reported value directly to the uAPI stat.
Otherwise, if we change the hack kernel uses to distinguish "unset" values and ionic would break.
Jakub Kicinski
maintainerRe: [PATCH net-next v3 1/5] ionic: Small improvements in devcmd retry logic
In reply to Eric JoynerQuoted 9 lines · On Mon, 18 May 2026 17:01:57 -0700 Eric Joyner wrote:
Quoted 8 lines · Jakub Kicinski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 3 lines · On Tue, 12 May 2026 15:44:17 -0700 Eric Joyner wrote:
Another commit uses this return value to help
signal that a deferred probe should be performed due to the firmware not being ready, which is why it would return EAGAIN.
Quoted 6 lines
Quoted 3 lines
Where can we find that "another commit". Reading this I was expecting it to be another commit in this series, but I don't see any EAGAIN later.
It's in a commit in the series that's targeting net that I've posted; but I think it'll be clearer if I roll that into this series in the next rev.
I see. Maybe wait for it to be committed and add a git commit quote here? The hash won't change once it's in tree.
Re: [PATCH net-next v3 2/5] ionic: Get "link_down_count" ext link stat from firmware
In reply to Jakub KicinskiQuoted 5 lines · Jakub Kicinski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
Man, it's been forever since I've been able to get back to this.
Quoted 6 lines
---
[Low]
Should this NULL check sit inside theis_physfnbranch below? Theport_infopointer is only dereferenced on the PF path, so a VF calling ethtool on link ext stats will now log anetdev_erreven though the VF path never readsport_info.
Sure.
Quoted 16 lines
The message is also unrate-limited and reachable from userspace via ethtool.
port_infois freed and set to NULL inionic_port_reset()and reallocated inionic_port_init()on FW reset / FLR / PCI error recovery paths (ionic_reset_prepare()/ionic_reset_done() inionic_bus_pci.c, andionic_restart_lif()inionic_lif.c), so any ethtool query during that transient window will emit a kernel log line where the previous code silently did nothing.Quoted 7 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +3
-2-if (lif->ionic->pdev->is_physfn) - stats->link_down_events = lif->link_down_count; +if (ionic->pdev->is_physfn) + stats->link_down_events = +le16_to_cpu (ionic->idev.port_info->status.link_down_count); }
I can use netdev_err_once() here, instead? There's no "netdev_err_ratelimited()" like how there is for struct device and "dev_err_ratelimited()", interestingly. Would that be more appropriate in the future?
There's also a similar issue in ionic_get_link_ksettings() below (and maybe elsewhere?), but that can be fixed in a separate patch.
Quoted 9 lines
[Medium]
The firmware-suppliedlink_down_countis a__le16in structionic_port_status(ionic_if.h), so the value saturates at 65,535. The previouslif->link_down_countwas an unsigned int (32-bit), and the ethtool fieldstats->link_down_eventsis u64 and treated as monotonic by userspace consumers (per the comment on structethtool_link_ext_statsininclude/linux/ethtool.h).
Quoted 6 lines
Without driver-side rollover detection that accumulates the carry into a wider counter, after 65,536 link bounces the reported value will appear to go backward to a small number. Should the driver detect a firmware value smaller than the previously-read value and fold the delta into a 32/64-bit running tally before assigning to
stats->link_down_events?
Is this a big enough issue to deal with? Is link really going to go down sixty-five thousand times while the driver is loaded? I guess we could have a running tally, but that seems like more effort than this is worth.
Quoted 19 lines
[Medium]
Does this change makelink_down_eventsnon-persistent across firmware resets?port_infolives in DMA-coherent memory thationic_port_reset()frees and clears:drivers/net/ethernet/pensando/ionic/ionic_main.c:ionic_port_reset() { ... dma_free_coherent(...); idev->port_info = NULL; ... }and
ionic_port_init()reallocates a fresh zeroed page. These are called from the FLR / PCI error recovery path (ionic_reset_prepare()/ionic_reset_done() inionic_bus_pci.c) and fromionic_restart_lif()inionic_lif.c, so FW-reset events that previously left the driver-resident counter untouched will now zero this stat.
Quoted 3 lines
The commit message does not mention this behavioral change. Should the driver snapshot the firmware value before each reset and accumulate it across reset boundaries to keep the ethtool counter monotonic?
This count doesn't get reset in the firmware when the device the ionic driver binds to gets reset; the freshly zeroed page will get the count from the firmware again soon after the reset occurs.
Quoted 15 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c static void ionic_link_status_check(struct ionic_lif *lif) · line 184
Quoted 13 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c +0
-1@@ -179,7 +179,6 @@ 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); }--
pw-bot: cr
Jakub Kicinski
maintainerRe: [PATCH net-next v3 2/5] ionic: Get "link_down_count" ext link stat from firmware
Quoted 35 lines · On Tue, 9 Jun 2026 11:00:03 -0700 Eric Joyner wrote:
Quoted 5 lines · Jakub Kicinski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
Man, it's been forever since I've been able to get back to this.
Quoted 6 lines
---
[Low]
Should this NULL check sit inside theis_physfnbranch below? Theport_infopointer is only dereferenced on the PF path, so a VF calling ethtool on link ext stats will now log anetdev_erreven though the VF path never readsport_info.Sure.
Quoted 16 lines
The message is also unrate-limited and reachable from userspace via ethtool.
port_infois freed and set to NULL inionic_port_reset()and reallocated inionic_port_init()on FW reset / FLR / PCI error recovery paths (ionic_reset_prepare()/ionic_reset_done() inionic_bus_pci.c, andionic_restart_lif()inionic_lif.c), so any ethtool query during that transient window will emit a kernel log line where the previous code silently did nothing.Quoted 7 lines
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +3
-2-if (lif->ionic->pdev->is_physfn) - stats->link_down_events = lif->link_down_count; +if (ionic->pdev->is_physfn) + stats->link_down_events = +le16_to_cpu (ionic->idev.port_info->status.link_down_count); }
Quoted 6 lines
I can use
netdev_err_once()here, instead? There's no "netdev_err_ratelimited()" like how there is for struct device and "dev_err_ratelimited()", interestingly. Would that be more appropriate in the future?There's also a similar issue in
ionic_get_link_ksettings()below (and maybe elsewhere?), but that can be fixed in a separate patch.
This is a nit, up to you.
Quoted 15 lines
Quoted 8 lines
[Medium]
The firmware-suppliedlink_down_countis a__le16in structionic_port_status(ionic_if.h), so the value saturates at 65,535. The previouslif->link_down_countwas an unsigned int (32-bit), and the ethtool fieldstats->link_down_eventsis u64 and treated as monotonic by userspace consumers (per the comment on structethtool_link_ext_statsininclude/linux/ethtool.h).Quoted 6 lines
Without driver-side rollover detection that accumulates the carry into a wider counter, after 65,536 link bounces the reported value will appear to go backward to a small number. Should the driver detect a firmware value smaller than the previously-read value and fold the delta into a 32/64-bit running tally before assigning to
stats->link_down_events?
Quoted 3 lines
Is this a big enough issue to deal with? Is link really going to go down sixty-five thousand times while the driver is loaded? I guess we could have a running tally, but that seems like more effort than this is worth.
Seems unlikely indeed, but drivers routinely deal with such wrapping. It's like 5 lines of code, no?
u16 val = le16_to_cpu(...
if ((u16)stats->link_down_events > val)
stats->link_down_events += BIT(16);
stats->link_down_events &= 0xffff0000;
stats->link_down_events |= val;Quoted 18 lines
Quoted 18 lines
[Medium]
Does this change makelink_down_eventsnon-persistent across firmware resets?port_infolives in DMA-coherent memory thationic_port_reset()frees and clears:drivers/net/ethernet/pensando/ionic/ionic_main.c:ionic_port_reset() { ... dma_free_coherent(...); idev->port_info = NULL; ... }and
ionic_port_init()reallocates a fresh zeroed page. These are called from the FLR / PCI error recovery path (ionic_reset_prepare()/ionic_reset_done() inionic_bus_pci.c) and fromionic_restart_lif()inionic_lif.c, so FW-reset events that previously left the driver-resident counter untouched will now zero this stat.
Quoted 7 lines
Quoted 3 lines
The commit message does not mention this behavioral change. Should the driver snapshot the firmware value before each reset and accumulate it across reset boundaries to keep the ethtool counter monotonic?
This count doesn't get reset in the firmware when the device the ionic driver binds to gets reset; the freshly zeroed page will get the count from the firmware again soon after the reset occurs.
This is also not great, operationally. Monitoring systems may expect counters to start from 0 after boot (IIUC you're saying that unless the card goes thru a full reset we'll keep the value from previous boot).
Re: [PATCH net-next v3 2/5] ionic: Get "link_down_count" ext link stat from firmware
Quoted 15 lines · Jakub Kicinski
Quoted 3 lines
Is this a big enough issue to deal with? Is link really going to go down sixty-five thousand times while the driver is loaded? I guess we could have a running tally, but that seems like more effort than this is worth.
Seems unlikely indeed, but drivers routinely deal with such wrapping. It's like 5 lines of code, no?
u16 val = le16_to_cpu(... if ((u16)stats->link_down_events > val) stats->link_down_events += BIT(16); stats->link_down_events &= 0xffff0000; stats->link_down_events |= val;
Quoted 5 lines
This is also not great, operationally. Monitoring systems may expect counters to start from 0 after boot (IIUC you're saying that unless the card goes thru a full reset we'll keep the value from previous boot).
Yep, that is what I've observed. I now wonder if the previous solution of having the driver calculate this statistic may have been an attempt to bypass these concerns.
Maybe I should go back to the original version, and have the firmware stat just be an extra entry in "ethtool -S" for additional info?
- Eric
Re: [PATCH net-next v3 2/5] ionic: Get "link_down_count" ext link stat from firmware
Quoted 22 lines · Eric Joyner
Quoted 15 lines · Jakub Kicinski
Quoted 3 lines
Is this a big enough issue to deal with? Is link really going to go down sixty-five thousand times while the driver is loaded? I guess we could have a running tally, but that seems like more effort than this is worth.
Seems unlikely indeed, but drivers routinely deal with such wrapping. It's like 5 lines of code, no?
u16 val = le16_to_cpu(... if ((u16)stats->link_down_events > val) stats->link_down_events += BIT(16); stats->link_down_events &= 0xffff0000; stats->link_down_events |= val;Quoted 5 lines
This is also not great, operationally. Monitoring systems may expect counters to start from 0 after boot (IIUC you're saying that unless the card goes thru a full reset we'll keep the value from previous boot).
Quoted 8 lines
Yep, that is what I've observed. I now wonder if the previous solution of having the driver calculate this statistic may have been an attempt to bypass these concerns.
Maybe I should go back to the original version, and have the firmware stat just be an extra entry in "ethtool -S" for additional info?
- Eric
Or, less lazily, I could actually also read the firmware value on driver load and after a reset, and then have the driver use that as an offset when reporting the count. And then also add the wrapping handling, too, so that we're not stuck with just the 16-bit value.
The downside of having an offset in the driver though is that it won't count the link down events that happen while the driver is not loaded, which could still be useful information. So maybe I'd still want the raw firmware value being reported somewhere.
- Eric