Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

igc: Add TransmissionOverrun counter

Add TransmissionOverrun as per defined by IEEE 802.1Q Bridges.
TransmissionOverrun counter shall be incremented if the implementation
detects that a frame from a given queue is still being transmitted by
the MAC when that gate-close event for that queue occurs.

This counter is utilised by the Certification conformance test to
inform the user application whether any packets are currently being
transmitted on a particular queue during a gate-close event.

Intel Discrete I225/I226 have a mechanism to not transmit a packets if
the gate open time is insufficient for the packet transmission by setting
the Strict_End bit. Thus, it is expected for this counter to be always
zero at this moment.

Inspired from enetc_taprio_stats() and enetc_taprio_queue_stats(), now
driver also report the tx_overruns counter per traffic class.

User can get this counter by using below command:
1) tc -s qdisc show dev <interface> root
2) tc -s class show dev <interface>

Test Result (Before):
class mq :1 root
Sent 1289 bytes 20 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class mq :2 root
Sent 124 bytes 2 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class mq :3 root
Sent 46028 bytes 86 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class mq :4 root
Sent 2596 bytes 14 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0

Test Result (After):
class taprio 100:1 root
Sent 8491 bytes 38 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
Transmit overruns: 0
class taprio 100:2 root
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
Transmit overruns: 0
class taprio 100:3 root
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
Transmit overruns: 0
class taprio 100:4 root
Sent 994 bytes 11 pkt (dropped 0, overlimits 0 requeues 1)
backlog 0b 0p requeues 1
Transmit overruns: 0

Signed-off-by: Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://lore.kernel.org/r/20230714201428.1718097-1-anthony.l.nguyen@intel.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Muhammad Husaini Zulkifli and committed by
Paolo Abeni
d3750076 9ffc4de5

+32 -3
+32 -3
drivers/net/ethernet/intel/igc/igc_main.c
··· 6115 6115 return 0; 6116 6116 } 6117 6117 6118 + static void igc_taprio_stats(struct net_device *dev, 6119 + struct tc_taprio_qopt_stats *stats) 6120 + { 6121 + /* When Strict_End is enabled, the tx_overruns counter 6122 + * will always be zero. 6123 + */ 6124 + stats->tx_overruns = 0; 6125 + } 6126 + 6127 + static void igc_taprio_queue_stats(struct net_device *dev, 6128 + struct tc_taprio_qopt_queue_stats *queue_stats) 6129 + { 6130 + struct tc_taprio_qopt_stats *stats = &queue_stats->stats; 6131 + 6132 + /* When Strict_End is enabled, the tx_overruns counter 6133 + * will always be zero. 6134 + */ 6135 + stats->tx_overruns = 0; 6136 + } 6137 + 6118 6138 static int igc_save_qbv_schedule(struct igc_adapter *adapter, 6119 6139 struct tc_taprio_qopt_offload *qopt) 6120 6140 { ··· 6145 6125 size_t n; 6146 6126 int i; 6147 6127 6148 - if (qopt->cmd == TAPRIO_CMD_DESTROY) 6128 + switch (qopt->cmd) { 6129 + case TAPRIO_CMD_REPLACE: 6130 + break; 6131 + case TAPRIO_CMD_DESTROY: 6149 6132 return igc_tsn_clear_schedule(adapter); 6150 - 6151 - if (qopt->cmd != TAPRIO_CMD_REPLACE) 6133 + case TAPRIO_CMD_STATS: 6134 + igc_taprio_stats(adapter->netdev, &qopt->stats); 6135 + return 0; 6136 + case TAPRIO_CMD_QUEUE_STATS: 6137 + igc_taprio_queue_stats(adapter->netdev, &qopt->queue_stats); 6138 + return 0; 6139 + default: 6152 6140 return -EOPNOTSUPP; 6141 + } 6153 6142 6154 6143 if (qopt->base_time < 0) 6155 6144 return -ERANGE;