[qca-nss-drv] Tx Peer Flow Control Stats

Adding Tx peer flow control related stats to WiFi Stats.
per-AC statistics for Tx enqueue, drops, dequeue will be supported

Change-Id: Ie7f520820460f03951cec57397ab51443a779ff7
Signed-off-by: Pamidipati, Vijay <vpamidip@codeaurora.org>
diff --git a/exports/nss_wifi.h b/exports/nss_wifi.h
index 445959c..8e468bf 100644
--- a/exports/nss_wifi.h
+++ b/exports/nss_wifi.h
@@ -27,6 +27,7 @@
 #define NSS_WIFI_RAWDATA_MAX_LEN  64
 #define NSS_WIFI_RX_EXT_INV_PEER_TYPE 0
 #define NSS_WIFI_RX_EXT_PKTLOG_TYPE 1
+#define NSS_WIFI_TX_NUM_TOS_TIDS 8
 
 /**
  * wifi interface request/response types
@@ -328,7 +329,16 @@
 	uint32_t rx_bytes_deliverd;		/**< number of rx bytes that NSS wifi driver could successfully process */
 	uint32_t tx_bytes_transmit_completions;	/**< number of bytes for which transmission completion received */
 	uint32_t rx_deliver_unaligned_drop_cnt;	/**< number of unaligned data packets that were dropped at wifi receive */
-
+	uint32_t tidq_enqueue_cnt[NSS_WIFI_TX_NUM_TOS_TIDS];	/**< Number of packets enqueued to  TIDQ */
+	uint32_t tidq_dequeue_cnt[NSS_WIFI_TX_NUM_TOS_TIDS];	/**< Number of packets dequeued from  TIDQ */
+	uint32_t tidq_enqueue_fail_cnt[NSS_WIFI_TX_NUM_TOS_TIDS];	/**< Enqueue fail count */
+	uint32_t tidq_ttl_expire_cnt[NSS_WIFI_TX_NUM_TOS_TIDS];	/**< Number of packets expired from  TIDQ */
+	uint32_t tidq_dequeue_req_cnt[NSS_WIFI_TX_NUM_TOS_TIDS];	/**< Dequeue reuest count from wifi fw */
+	uint32_t total_tidq_depth;	/**< Current Queue Depth */
+	uint32_t rx_htt_fetch_cnt;	/**< Total number of HTT Fetch Messages received from wifi fw */
+	uint32_t total_tidq_bypass_cnt;	/**< Total number of packets which have bypassed tidq and sent to wifi fw */
+	uint32_t global_q_full_cnt;	/**< Total number of packets dropped due to global queue full condition */
+	uint32_t tidq_full_cnt;	/**< Total number of packets dropped due to TID queue full condition */
 };
 
 /**
diff --git a/nss_core.h b/nss_core.h
index 495d0e9..b419238 100755
--- a/nss_core.h
+++ b/nss_core.h
@@ -528,6 +528,16 @@
 	NSS_STATS_WIFI_RX_BYTES_DELIVERED,		/* Number of rx bytes that NSS wifi offload path could successfully process */
 	NSS_STATS_WIFI_TX_BYTES_COMPLETED,		/* Number of bytes for which transmission completion received */
 	NSS_STATS_WIFI_RX_DELIVER_UNALIGNED_DROP_CNT,	/* Number of rx packets that dropped beacause of alignment mismatch*/
+	NSS_STATS_WIFI_TIDQ_ENQUEUE_CNT,		/* Number of packets enqueued to  TIDQ */
+	NSS_STATS_WIFI_TIDQ_DEQUEUE_CNT = NSS_STATS_WIFI_TIDQ_ENQUEUE_CNT + 8,		/* Number of packets dequeued from  TIDQ */
+	NSS_STATS_WIFI_TIDQ_ENQUEUE_FAIL_CNT = NSS_STATS_WIFI_TIDQ_DEQUEUE_CNT + 8,	/* Enqueue fail count */
+	NSS_STATS_WIFI_TIDQ_TTL_EXPIRE_CNT = NSS_STATS_WIFI_TIDQ_ENQUEUE_FAIL_CNT + 8,	/* Number of packets expired from  TIDQ */
+	NSS_STATS_WIFI_TIDQ_DEQUEUE_REQ_CNT = NSS_STATS_WIFI_TIDQ_TTL_EXPIRE_CNT + 8,	/* Dequeue reuest count from wifi fw */
+	NSS_STATS_WIFI_TOTAL_TIDQ_DEPTH = NSS_STATS_WIFI_TIDQ_DEQUEUE_REQ_CNT + 8,	/* Tidq depth */
+	NSS_STATS_WIFI_RX_HTT_FETCH_CNT,	/* Total number of HTT Fetch Messages received from wifi fw */
+	NSS_STATS_WIFI_TOTAL_TIDQ_BYPASS_CNT,	/* Total number of packets which have bypassed tidq and sent to wifi fw */
+	NSS_STATS_WIFI_GLOBAL_Q_FULL_CNT,	/* Total number of packets dropped due to global queue full condition */
+	NSS_STATS_WIFI_TIDQ_FULL_CNT,		/* Total number of packets dropped due to TID queue full condition */
 	NSS_STATS_WIFI_MAX,
 };
 
diff --git a/nss_stats.c b/nss_stats.c
index 5d971ad..be056c8 100644
--- a/nss_stats.c
+++ b/nss_stats.c
@@ -412,7 +412,52 @@
 	"RX_PKTS_DELIVERD",
 	"RX_BYTES_DELIVERED",
 	"TX_BYTES_COMPLETED",
-	"RX_DELIVER_UNALIGNED_DROP_CNT"
+	"RX_DELIVER_UNALIGNED_DROP_CNT",
+	"TIDQ_ENQUEUE_CNT_0",
+	"TIDQ_ENQUEUE_CNT_1",
+	"TIDQ_ENQUEUE_CNT_2",
+	"TIDQ_ENQUEUE_CNT_3",
+	"TIDQ_ENQUEUE_CNT_4",
+	"TIDQ_ENQUEUE_CNT_5",
+	"TIDQ_ENQUEUE_CNT_6",
+	"TIDQ_ENQUEUE_CNT_7",
+	"TIDQ_DEQUEUE_CNT_0",
+	"TIDQ_DEQUEUE_CNT_1",
+	"TIDQ_DEQUEUE_CNT_2",
+	"TIDQ_DEQUEUE_CNT_3",
+	"TIDQ_DEQUEUE_CNT_4",
+	"TIDQ_DEQUEUE_CNT_5",
+	"TIDQ_DEQUEUE_CNT_6",
+	"TIDQ_DEQUEUE_CNT_7",
+	"TIDQ_ENQUEUE_FAIL_CNT_0",
+	"TIDQ_ENQUEUE_FAIL_CNT_1",
+	"TIDQ_ENQUEUE_FAIL_CNT_2",
+	"TIDQ_ENQUEUE_FAIL_CNT_3",
+	"TIDQ_ENQUEUE_FAIL_CNT_4",
+	"TIDQ_ENQUEUE_FAIL_CNT_5",
+	"TIDQ_ENQUEUE_FAIL_CNT_6",
+	"TIDQ_ENQUEUE_FAIL_CNT_7",
+	"TIDQ_TTL_EXPIRE_CNT_0",
+	"TIDQ_TTL_EXPIRE_CNT_1",
+	"TIDQ_TTL_EXPIRE_CNT_2",
+	"TIDQ_TTL_EXPIRE_CNT_3",
+	"TIDQ_TTL_EXPIRE_CNT_4",
+	"TIDQ_TTL_EXPIRE_CNT_5",
+	"TIDQ_TTL_EXPIRE_CNT_6",
+	"TIDQ_TTL_EXPIRE_CNT_7",
+	"TIDQ_DEQUEUE_REQ_CNT_0",
+	"TIDQ_DEQUEUE_REQ_CNT_1",
+	"TIDQ_DEQUEUE_REQ_CNT_2",
+	"TIDQ_DEQUEUE_REQ_CNT_3",
+	"TIDQ_DEQUEUE_REQ_CNT_4",
+	"TIDQ_DEQUEUE_REQ_CNT_5",
+	"TIDQ_DEQUEUE_REQ_CNT_6",
+	"TIDQ_DEQUEUE_REQ_CNT_7",
+	"TOTAL_TIDQ_DEPTH",
+	"RX_HTT_FETCH_CNT",
+	"TOTAL_TIDQ_BYPASS_CNT",
+	"GLOBAL_Q_FULL_CNT",
+	"TIDQ_FULL_CNT",
 };
 
 /*
diff --git a/nss_wifi.c b/nss_wifi.c
index 9e96ae6..ea8ac36 100644
--- a/nss_wifi.c
+++ b/nss_wifi.c
@@ -25,6 +25,7 @@
 {
 	struct nss_top_instance *nss_top = nss_ctx->nss_top;
 	uint32_t radio_id = interface - NSS_WIFI_INTERFACE0;
+	uint8_t i = 0;
 
 	if (radio_id >= NSS_MAX_WIFI_RADIO_INTERFACES) {
 		nss_warning("%p: invalid interface: %d", nss_ctx, interface);
@@ -53,6 +54,20 @@
 	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TX_BYTES_COMPLETED] += stats->tx_bytes_transmit_completions;
 	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_RX_DELIVER_UNALIGNED_DROP_CNT] += stats->rx_deliver_unaligned_drop_cnt;
 
+	for (i = 0; i < NSS_WIFI_TX_NUM_TOS_TIDS; i++) {
+		nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TIDQ_ENQUEUE_CNT + i] += stats->tidq_enqueue_cnt[i];
+		nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TIDQ_DEQUEUE_CNT + i] += stats->tidq_dequeue_cnt[i];
+		nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TIDQ_ENQUEUE_FAIL_CNT + i] += stats->tidq_enqueue_fail_cnt[i];
+		nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TIDQ_TTL_EXPIRE_CNT + i] += stats->tidq_ttl_expire_cnt[i];
+		nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TIDQ_DEQUEUE_REQ_CNT + i] += stats->tidq_dequeue_req_cnt[i];
+	}
+
+	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_RX_HTT_FETCH_CNT] += stats->rx_htt_fetch_cnt;
+	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TOTAL_TIDQ_DEPTH] = stats->total_tidq_depth;
+	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TOTAL_TIDQ_BYPASS_CNT] += stats->total_tidq_bypass_cnt;
+	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_GLOBAL_Q_FULL_CNT] += stats->global_q_full_cnt;
+	nss_top->stats_wifi[radio_id][NSS_STATS_WIFI_TIDQ_FULL_CNT] += stats->tidq_full_cnt;
+
 	spin_unlock_bh(&nss_top->stats_lock);
 }