[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_pppoe.c b/nss_pppoe.c
index 43a1946..18faea2 100644
--- a/nss_pppoe.c
+++ b/nss_pppoe.c
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -21,6 +21,7 @@
#include "nss_tx_rx_common.h"
#include <linux/if_pppox.h>
+#include "nss_pppoe_stats.h"
/*
* nss_pppoe_tx()
@@ -92,83 +93,6 @@
*/
/*
- * nss_pppoe_session_reset()
- * Reset PPPoE session when session is destroyed.
- */
-static void nss_pppoe_session_reset(struct nss_ctx_instance *nss_ctx, struct nss_pppoe_session_reset_msg *npsr)
-{
- uint32_t i;
- uint32_t interface = npsr->interface;
- uint32_t session_index = npsr->session_index;
-
- /*
- * Reset the PPPoE statistics for this specific session.
- */
- spin_lock_bh(&nss_ctx->nss_top->stats_lock);
- for (i = 0; i < NSS_PPPOE_EXCEPTION_EVENT_MAX; i++) {
- nss_ctx->nss_top->stats_if_exception_pppoe[interface][session_index][i] = 0;
- }
- spin_unlock_bh(&nss_ctx->nss_top->stats_lock);
-}
-
-/*
- * nss_pppoe_exception_stats_sync()
- * Handle the syncing of PPPoE exception statistics.
- */
-static void nss_pppoe_exception_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pppoe_conn_stats_sync_msg *npess)
-{
- struct nss_top_instance *nss_top = nss_ctx->nss_top;
- uint32_t index = npess->index;
- uint32_t interface_num = npess->interface_num;
- uint32_t i;
-
- spin_lock_bh(&nss_top->stats_lock);
-
- if (interface_num >= NSS_MAX_PHYSICAL_INTERFACES) {
- spin_unlock_bh(&nss_top->stats_lock);
- nss_warning("%p: Incorrect interface number %d for PPPoE exception stats", nss_ctx, interface_num);
- return;
- }
-
- /*
- * pppoe exception stats
- */
- for (i = 0; i < NSS_PPPOE_EXCEPTION_EVENT_MAX; i++) {
- nss_top->stats_if_exception_pppoe[interface_num][index][i] += npess->exception_events_pppoe[i];
- }
-
- spin_unlock_bh(&nss_top->stats_lock);
-}
-
-/*
- * nss_pppoe_node_stats_sync()
- * Handle the syncing of PPPoE node statistics.
- */
-static void nss_pppoe_node_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pppoe_node_stats_sync_msg *npess)
-{
- struct nss_top_instance *nss_top = nss_ctx->nss_top;
- int j;
-
- spin_lock_bh(&nss_top->stats_lock);
-
- nss_top->stats_node[NSS_PPPOE_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += npess->node_stats.rx_packets;
- nss_top->stats_node[NSS_PPPOE_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += npess->node_stats.rx_bytes;
- nss_top->stats_node[NSS_PPPOE_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += npess->node_stats.tx_packets;
- nss_top->stats_node[NSS_PPPOE_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += npess->node_stats.tx_bytes;
-
- for (j = 0; j < NSS_MAX_NUM_PRI; j++) {
- nss_top->stats_node[NSS_PPPOE_RX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += npess->node_stats.rx_dropped[j];
- }
-
- nss_top->stats_pppoe[NSS_STATS_PPPOE_SESSION_CREATE_REQUESTS] += npess->pppoe_session_create_requests;
- nss_top->stats_pppoe[NSS_STATS_PPPOE_SESSION_CREATE_FAILURES] += npess->pppoe_session_create_failures;
- nss_top->stats_pppoe[NSS_STATS_PPPOE_SESSION_DESTROY_REQUESTS] += npess->pppoe_session_destroy_requests;
- nss_top->stats_pppoe[NSS_STATS_PPPOE_SESSION_DESTROY_REQUESTS] += npess->pppoe_session_destroy_requests;
-
- spin_unlock_bh(&nss_top->stats_lock);
-}
-
-/*
* nss_pppoe_rx_msg_handler()
* Handle NSS -> HLOS messages for PPPoE
*/
@@ -201,13 +125,13 @@
*/
switch (nim->cm.type) {
case NSS_PPPOE_RX_NODE_STATS_SYNC:
- nss_pppoe_node_stats_sync(nss_ctx, &nim->msg.pppoe_node_stats_sync);
+ nss_pppoe_stats_node_sync(nss_ctx, &nim->msg.pppoe_node_stats_sync);
break;
case NSS_PPPOE_RX_CONN_STATS_SYNC:
- nss_pppoe_exception_stats_sync(nss_ctx, &nim->msg.pppoe_conn_stats_sync);
+ nss_pppoe_stats_exception_sync(nss_ctx, &nim->msg.pppoe_conn_stats_sync);
break;
case NSS_PPPOE_RX_SESSION_RESET:
- nss_pppoe_session_reset(nss_ctx, &nim->msg.pppoe_session_reset);
+ nss_pppoe_stats_session_reset(nss_ctx, &nim->msg.pppoe_session_reset);
break;
default:
nss_warning("%p: Received response %d for type %d, interface %d",
@@ -221,6 +145,8 @@
void nss_pppoe_register_handler(struct nss_ctx_instance *nss_ctx)
{
nss_core_register_handler(nss_ctx, NSS_PPPOE_RX_INTERFACE, nss_pppoe_rx_msg_handler, NULL);
+
+ nss_pppoe_stats_dentry_create();
}
/*