From 99d02dc47ab746f7881963422637c293c45f0f78 Mon Sep 17 00:00:00 2001
From: Amit Kumar <amit.kumar@iopsys.eu>
Date: Mon, 4 Mar 2024 16:20:48 +0530
Subject: [PATCH] linux: pause frame stats increment

---
 ethernet.h              | 1 +
 linux/linux/linux_eth.c | 6 +++++-
 linux/mtk/mtk_eth.c     | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ethernet.h b/ethernet.h
index b08fded..02163ea 100644
--- a/ethernet.h
+++ b/ethernet.h
@@ -72,6 +72,7 @@ struct eth_rmon_stats {
 		uint64_t packets_256to511bytes;
 		uint64_t packets_512to1023bytes;
 		uint64_t packets_1024to1518bytes;
+		uint64_t pause_packets;
 	} tx, rx;
 };
 
diff --git a/linux/linux/linux_eth.c b/linux/linux/linux_eth.c
index 942d03d..5d27550 100644
--- a/linux/linux/linux_eth.c
+++ b/linux/linux/linux_eth.c
@@ -39,6 +39,8 @@ typedef enum {
     iow_tx_fraglist_nr_frags_packets,
     iow_tx_tso_packets,
     iow_tx_tso_drop_packets,
+    iow_tx_gso_packets,
+    iow_tx_gso_dropped_packets,
     iow_rx_frame,
     iow_rx_bytes,
     iow_rx_bytes_g,
@@ -315,7 +317,7 @@ int linux_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
         ret = -1;
 
     rmon->tx.packets = (uint64_t)g_linux_stats->data[iow_tx_packets];
-    rmon->tx.bytes = (uint64_t)g_linux_stats->data[iow_tx_bytes];
+    rmon->tx.bytes = (uint64_t)g_linux_stats->data[iow_tx_byte];
     rmon->tx.crc_err_packets = 0;
 /* These two counters are marked zero because they dont
  * hold much relevancy to Customer
@@ -328,6 +330,7 @@ int linux_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
     rmon->tx.packets_256to511bytes = (uint64_t)g_linux_stats->data[iow_tx_pkt256to511];
     rmon->tx.packets_512to1023bytes = (uint64_t)g_linux_stats->data[iow_tx_pkt512to1023];
     rmon->tx.packets_1024to1518bytes = (uint64_t)g_linux_stats->data[iow_tx_pkt1024tomax];
+    rmon->tx.pause_packets = (uint64_t)g_linux_stats->data[iow_tx_pause];
 
     rmon->rx.bytes = (uint64_t)g_linux_stats->data[iow_rx_byte];
     rmon->rx.packets = (uint64_t)g_linux_stats->data[iow_rx_packets];
@@ -338,6 +341,7 @@ int linux_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
     rmon->rx.over_sz_packets = (uint64_t)g_linux_stats->data[iow_rx_oversize];
     rmon->rx.packets_64bytes = (uint64_t)g_linux_stats->data[iow_rx_pkt64];
     rmon->rx.packets_65to127bytes = (uint64_t)g_linux_stats->data[iow_rx_pkt65to127];
+    rmon->rx.pause_packets = (uint64_t)g_linux_stats->data[iow_rx_pause];
 
     free(g_linux_stats);
 
diff --git a/linux/mtk/mtk_eth.c b/linux/mtk/mtk_eth.c
index 0f32fad..abed7ec 100644
--- a/linux/mtk/mtk_eth.c
+++ b/linux/mtk/mtk_eth.c
@@ -214,6 +214,7 @@ int mtk_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
     rmon->tx.packets_256to511bytes = g_mtk_stat.data[iow_TxPktSz256To511];
     rmon->tx.packets_512to1023bytes = g_mtk_stat.data[iow_TxPktSz512To1023];
     rmon->tx.packets_1024to1518bytes = g_mtk_stat.data[iow_Tx1024ToMax];
+    rmon->tx.pause_packets = g_mtk_stat.data[iow_TxPause];
 
     rmon->rx.bytes = g_mtk_stat.data[iow_RxBytes];
     rmon->rx.packets = g_mtk_stat.data[iow_rx_packets];
@@ -228,6 +229,7 @@ int mtk_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
     rmon->rx.packets_256to511bytes = g_mtk_stat.data[iow_RxPktSz256To511];
     rmon->rx.packets_512to1023bytes = g_mtk_stat.data[iow_RxPktSz512To1023];
     rmon->rx.packets_1024to1518bytes = g_mtk_stat.data[iow_RxPktSz1024ToMax];
+    rmon->tx.pause_packets = g_mtk_stat.data[iow_RxPause];
 
     return ret;
 }
-- 
GitLab