[qca-nss-drv] Break up statistics implementation
Break up the centralized statistics implementation to be subsystem based
statistics implementation.
Change-Id: Ibc14d88f391e816d3d6284a57ea6676f2842ac70
Signed-off-by: Yu Huang <yuhuang@codeaurora.org>
diff --git a/nss_wifili.c b/nss_wifili.c
index 3070e87..abb40a3 100644
--- a/nss_wifili.c
+++ b/nss_wifili.c
@@ -15,6 +15,7 @@
*/
#include "nss_tx_rx_common.h"
+#include "nss_wifili_stats.h"
#define NSS_WIFILI_TX_TIMEOUT 1000 /* Millisecond to jiffies*/
@@ -31,174 +32,6 @@
} wifili_pvt;
/*
- * nss_wifili_stats_sync()
- * Handle the syncing of WIFI stats.
- */
-static void nss_wifili_stats_sync(struct nss_ctx_instance *nss_ctx,
- struct nss_wifili_stats_sync_msg *wlsoc_stats, uint16_t interface)
-{
- struct nss_top_instance *nss_top = nss_ctx->nss_top;
- struct nss_wifili_stats *stats = &nss_top->stats_wifili;
- struct nss_wifili_device_stats *devstats = &wlsoc_stats->stats;
- uint32_t index;
-
- spin_lock_bh(&nss_top->stats_lock);
-
- for (index = 0; index < NSS_WIFILI_MAX_PDEV_NUM_MSG; index++) {
- /*
- * Rx stats
- */
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_MSDU_ERROR] +=
- devstats->rx_data_stats[index].rx_msdu_err;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_INV_PEER_RCV] +=
- (devstats->rx_data_stats[index].rx_inv_peer +
- devstats->rx_data_stats[index].rx_scatter_inv_peer);
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_WDS_SRCPORT_EXCEPTION] +=
- devstats->rx_data_stats[index].rx_wds_learn_send;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_WDS_SRCPORT_EXCEPTION_FAIL] +=
- devstats->rx_data_stats[index].rx_wds_learn_send_fail;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_DELIVERD] +=
- devstats->rx_data_stats[index].rx_deliver_cnt;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_DELIVER_DROPPED] +=
- devstats->rx_data_stats[index].rx_deliver_cnt_fail;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_INTRA_BSS_UCAST] +=
- devstats->rx_data_stats[index].rx_intra_bss_ucast_send;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_INTRA_BSS_UCAST_FAIL] +=
- devstats->rx_data_stats[index].rx_intra_bss_ucast_send_fail;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_INTRA_BSS_MCAST] +=
- devstats->rx_data_stats[index].rx_intra_bss_mcast_send;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_INTRA_BSS_MCAST_FAIL] +=
- devstats->rx_data_stats[index].rx_intra_bss_mcast_send_fail;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_SG_RCV_SEND] +=
- devstats->rx_data_stats[index].rx_sg_recv_send;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_SG_RCV_FAIL] +=
- devstats->rx_data_stats[index].rx_sg_recv_fail;
- stats->stats_txrx[index][NSS_STATS_WIFILI_RX_MCAST_ECHO] +=
- devstats->rx_data_stats[index].rx_me_pkts;
-
- /*
- * Tx stats
- */
- stats->stats_txrx[index][NSS_STATS_WIFILI_TX_ENQUEUE] +=
- devstats->tx_data_stats[index].tx_enqueue_cnt;
- stats->stats_txrx[index][NSS_STATS_WIFILI_TX_ENQUEUE_DROP] +=
- devstats->tx_data_stats[index].tx_enqueue_dropped;
- stats->stats_txrx[index][NSS_STATS_WIFILI_TX_DEQUEUE] +=
- devstats->tx_data_stats[index].tx_dequeue_cnt;
- stats->stats_txrx[index][NSS_STATS_WIFILI_TX_HW_ENQUEUE_FAIL] +=
- devstats->tx_data_stats[index].tx_send_fail_cnt;
- stats->stats_txrx[index][NSS_STATS_WIFILI_TX_SENT_COUNT] +=
- devstats->tx_data_stats[index].tx_processed_pkt;
- }
-
- /*
- * update the tcl ring stats
- */
- for (index = 0; index < NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG; index++) {
- stats->stats_tcl_ring[index][NSS_STATS_WIFILI_TCL_NO_HW_DESC] +=
- devstats->tcl_stats[index].tcl_no_hw_desc;
- stats->stats_tcl_ring[index][NSS_STATS_WIFILI_TCL_RING_FULL] +=
- devstats->tcl_stats[index].tcl_ring_full;
- stats->stats_tcl_ring[index][NSS_STATS_WIFILI_TCL_RING_SENT] +=
- devstats->tcl_stats[index].tcl_ring_sent;
- }
-
- /*
- * update the tcl comp stats
- */
- for (index = 0; index < NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG; index++) {
- stats->stats_tx_comp[index][NSS_STATS_WIFILI_TX_DESC_FREE_INV_BUFSRC] +=
- devstats->txcomp_stats[index].invalid_bufsrc;
- stats->stats_tx_comp[index][NSS_STATS_WIFILI_TX_DESC_FREE_INV_COOKIE] +=
- devstats->txcomp_stats[index].invalid_cookie;
- stats->stats_tx_comp[index][NSS_STATS_WIFILI_TX_DESC_FREE_HW_RING_EMPTY] +=
- devstats->txcomp_stats[index].hw_ring_empty;
- stats->stats_tx_comp[index][NSS_STATS_WIFILI_TX_DESC_FREE_REAPED] +=
- devstats->txcomp_stats[index].ring_reaped;
- }
-
- /*
- * update reo ring stats
- */
- for (index = 0; index < NSS_WIFILI_MAX_REO_DATA_RINGS_MSG; index++) {
- stats->stats_reo[index][NSS_STATS_WIFILI_REO_ERROR] +=
- devstats->rxreo_stats[index].ring_error;
- stats->stats_reo[index][NSS_STATS_WIFILI_REO_REAPED] +=
- devstats->rxreo_stats[index].ring_reaped;
- stats->stats_reo[index][NSS_STATS_WIFILI_REO_INV_COOKIE] +=
- devstats->rxreo_stats[index].invalid_cookie;
- }
-
- /*
- * update tx sw pool
- */
- for (index = 0; index < NSS_WIFILI_MAX_TXDESC_POOLS_MSG; index++) {
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_IN_USE] =
- devstats->tx_sw_pool_stats[index].desc_alloc;
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_ALLOC_FAIL] +=
- devstats->tx_sw_pool_stats[index].desc_alloc_fail;
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_ALREADY_ALLOCATED] +=
- devstats->tx_sw_pool_stats[index].desc_already_allocated;
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_INVALID_FREE] +=
- devstats->tx_sw_pool_stats[index].desc_invalid_free;
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_FREE_SRC_FW] +=
- devstats->tx_sw_pool_stats[index].tx_rel_src_fw;
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_FREE_COMPLETION] +=
- devstats->tx_sw_pool_stats[index].tx_rel_tx_desc;
- stats->stats_tx_desc[index][NSS_STATS_WIFILI_TX_DESC_NO_PB] +=
- devstats->tx_sw_pool_stats[index].tx_rel_no_pb;
- }
-
- /*
- * update ext tx desc pool stats
- */
- for (index = 0; index < NSS_WIFILI_MAX_TX_EXT_DESC_POOLS_MSG; index++) {
- stats->stats_ext_tx_desc[index][NSS_STATS_WIFILI_EXT_TX_DESC_IN_USE] =
- devstats->tx_ext_sw_pool_stats[index].desc_alloc;
- stats->stats_ext_tx_desc[index][NSS_STATS_WIFILI_EXT_TX_DESC_ALLOC_FAIL] +=
- devstats->tx_ext_sw_pool_stats[index].desc_alloc_fail;
- stats->stats_ext_tx_desc[index][NSS_STATS_WIFILI_EXT_TX_DESC_ALREADY_ALLOCATED] +=
- devstats->tx_ext_sw_pool_stats[index].desc_already_allocated;
- stats->stats_ext_tx_desc[index][NSS_STATS_WIFILI_EXT_TX_DESC_INVALID_FREE] +=
- devstats->tx_ext_sw_pool_stats[index].desc_invalid_free;
- }
-
- /*
- * update rx desc pool stats
- */
- for (index = 0; index < NSS_WIFILI_MAX_PDEV_NUM_MSG; index++) {
- stats->stats_rx_desc[index][NSS_STATS_WIFILI_RX_DESC_NO_PB] +=
- devstats->rx_sw_pool_stats[index].rx_no_pb;
- stats->stats_rx_desc[index][NSS_STATS_WIFILI_RX_DESC_ALLOC_FAIL] +=
- devstats->rx_sw_pool_stats[index].desc_alloc_fail;
- stats->stats_rx_desc[index][NSS_STATS_WIFILI_RX_DESC_IN_USE] =
- devstats->rx_sw_pool_stats[index].desc_alloc;
- }
-
- /*
- * update rx dma ring stats
- */
- for (index = 0; index < NSS_WIFILI_MAX_PDEV_NUM_MSG; index++) {
- stats->stats_rxdma[index][NSS_STATS_WIFILI_RXDMA_DESC_UNAVAILABLE] +=
- devstats->rxdma_stats[index].rx_hw_desc_unavailable;
- stats->stats_rxdma[index][NSS_STATS_WIFILI_RXDMA_BUF_REPLENISHED] +=
- devstats->rxdma_stats[index].rx_buf_replenished;
- }
-
- /*
- * update wbm ring stats
- */
- stats->stats_wbm[NSS_STATS_WIFILI_WBM_SRC_DMA] += devstats->rxwbm_stats.err_src_rxdma;
- stats->stats_wbm[NSS_STATS_WIFILI_WBM_SRC_DMA_CODE_INV] += devstats->rxwbm_stats.err_src_rxdma_code_inv;
- stats->stats_wbm[NSS_STATS_WIFILI_WBM_SRC_REO] += devstats->rxwbm_stats.err_src_reo;
- stats->stats_wbm[NSS_STATS_WIFILI_WBM_SRC_REO_CODE_NULLQ] += devstats->rxwbm_stats.err_src_reo_code_nullq;
- stats->stats_wbm[NSS_STATS_WIFILI_WBM_SRC_REO_CODE_INV] += devstats->rxwbm_stats.err_src_reo_code_inv;
- stats->stats_wbm[NSS_STATS_WIFILI_WBM_SRC_INV] += devstats->rxwbm_stats.err_src_invalid;
- spin_unlock_bh(&nss_top->stats_lock);
- return;
-}
-
-/*
* nss_wifili_handler()
* Handle NSS -> HLOS messages for wifi
*/
@@ -521,6 +354,8 @@
nss_info("nss_wifili_register_handler");
nss_core_register_handler(nss_ctx, NSS_WIFILI_INTERFACE, nss_wifili_handler, NULL);
+ nss_wifili_stats_dentry_create();
+
sema_init(&wifili_pvt.sem, 1);
init_completion(&wifili_pvt.complete);
}