All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net-next v1] igc: Add transmission overrun counter
@ 2023-02-08  4:45 Muhammad Husaini Zulkifli
  2023-02-15 19:23 ` Tony Nguyen
  0 siblings, 1 reply; 8+ messages in thread
From: Muhammad Husaini Zulkifli @ 2023-02-08  4:45 UTC (permalink / raw)
  To: intel-wired-lan, vinicius.gomes
  Cc: muhammad.husaini.zulkifli, anthony.l.nguyen

Add transmission overrun counter as per defined by IEEE 802.1Q Bridges.
The Intel Discrete I225/6 does not have HW counters that can determine
whether a packet is still being transmitted after the gate has been closed.
But 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. Software counters have been created for each queues in
response to the IEEE specification. Thus, we can assume that overrun
counter is always "0" when setting this bit.

User can get this counter by using below command:
"ethtool -S <interface> | grep qbv_tx_overrun"

Signed-off-by: Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com>
---
 drivers/net/ethernet/intel/igc/igc.h         | 1 +
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 4 ++++
 drivers/net/ethernet/intel/igc/igc_hw.h      | 4 ++++
 drivers/net/ethernet/intel/igc/igc_main.c    | 7 +++++++
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 6 ++++++
 5 files changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index 9db93c1f97679..a8c7a978d4335 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -99,6 +99,7 @@ struct igc_ring {
 
 	u32 start_time;
 	u32 end_time;
+	u64 qbv_tx_overrun;
 
 	/* CBS parameters */
 	bool cbs_enable;                /* indicates if CBS is enabled */
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 0e2cb00622d1a..34a893171b209 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -68,6 +68,10 @@ static const struct igc_stats igc_gstrings_stats[] = {
 	IGC_STAT("tx_lpi_counter", stats.tlpic),
 	IGC_STAT("rx_lpi_counter", stats.rlpic),
 	IGC_STAT("qbv_config_change_errors", qbv_config_change_errors),
+	IGC_STAT("qbv_tx_overrun_q0", stats.qbv_tx_overrun_q0),
+	IGC_STAT("qbv_tx_overrun_q1", stats.qbv_tx_overrun_q1),
+	IGC_STAT("qbv_tx_overrun_q2", stats.qbv_tx_overrun_q2),
+	IGC_STAT("qbv_tx_overrun_q3", stats.qbv_tx_overrun_q3),
 };
 
 #define IGC_NETDEV_STAT(_net_stat) { \
diff --git a/drivers/net/ethernet/intel/igc/igc_hw.h b/drivers/net/ethernet/intel/igc/igc_hw.h
index 88680e3d613dd..ce3ba19eef601 100644
--- a/drivers/net/ethernet/intel/igc/igc_hw.h
+++ b/drivers/net/ethernet/intel/igc/igc_hw.h
@@ -273,6 +273,10 @@ struct igc_hw_stats {
 	u64 o2bspc;
 	u64 b2ospc;
 	u64 b2ogprc;
+	u64 qbv_tx_overrun_q0;
+	u64 qbv_tx_overrun_q1;
+	u64 qbv_tx_overrun_q2;
+	u64 qbv_tx_overrun_q3;
 };
 
 struct net_device *igc_get_hw_dev(struct igc_hw *hw);
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 0cc327294dfb5..8b6cdb7d4eff2 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -4926,6 +4926,12 @@ void igc_update_stats(struct igc_adapter *adapter)
 	adapter->stats.mgptc += rd32(IGC_MGTPTC);
 	adapter->stats.mgprc += rd32(IGC_MGTPRC);
 	adapter->stats.mgpdc += rd32(IGC_MGTPDC);
+
+	/* SW overrun counter */
+	adapter->stats.qbv_tx_overrun_q0 = adapter->tx_ring[0]->qbv_tx_overrun;
+	adapter->stats.qbv_tx_overrun_q1 = adapter->tx_ring[1]->qbv_tx_overrun;
+	adapter->stats.qbv_tx_overrun_q2 = adapter->tx_ring[2]->qbv_tx_overrun;
+	adapter->stats.qbv_tx_overrun_q3 = adapter->tx_ring[3]->qbv_tx_overrun;
 }
 
 /**
@@ -6039,6 +6045,7 @@ static int igc_tsn_clear_schedule(struct igc_adapter *adapter)
 
 		ring->start_time = 0;
 		ring->end_time = NSEC_PER_SEC;
+		ring->qbv_tx_overrun = 0;
 	}
 
 	return 0;
diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c
index b38c1c7569a0b..2593a1517af0a 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -135,6 +135,12 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 		txqctl |= IGC_TXQCTL_STRICT_CYCLE |
 			IGC_TXQCTL_STRICT_END;
 
+		/* Counters will always be zero if Strict_End bit is set.
+		 * Condition to check for the IGC_TXQCTL_STRICT_END must be add
+		 * in the future if Strict_End bit is not set.
+		 */
+		ring->qbv_tx_overrun = 0;
+
 		if (ring->launchtime_enable)
 			txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT;
 
-- 
2.17.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-03-31  1:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-08  4:45 [Intel-wired-lan] [PATCH net-next v1] igc: Add transmission overrun counter Muhammad Husaini Zulkifli
2023-02-15 19:23 ` Tony Nguyen
2023-02-15 23:40   ` Zulkifli, Muhammad Husaini
2023-02-18  6:19     ` Zulkifli, Muhammad Husaini
2023-02-20 22:20       ` Jakub Kicinski
2023-02-21 23:11         ` Jesse Brandeburg
2023-02-21 23:57           ` Jesse Brandeburg
2023-03-31  1:23             ` Zulkifli, Muhammad Husaini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.