[qca-nss-drv] Make trustsec_tx use to nss_stats.c file

Change-Id: Ie025492bd874935bb57f6ccecbdc7a82d86f3f28
Signed-off-by: Siva Sai Krishna Marthy <smarthy@codeaurora.org>
Signed-off-by: Sakthi Vignesh Radhakrishnan <sradhakr@codeaurora.org>
diff --git a/nss_trustsec_tx_stats.c b/nss_trustsec_tx_stats.c
index cf6fd5b..a44a882 100644
--- a/nss_trustsec_tx_stats.c
+++ b/nss_trustsec_tx_stats.c
@@ -19,17 +19,18 @@
 
 /*
  * nss_trustsec_tx_stats_str
- *	Trustsec TX statistics strings
+ *	Trustsec TX statistics strings.
  */
-static int8_t *nss_trustsec_tx_stats_str[NSS_TRUSTSEC_TX_STATS_MAX] = {
-	"INVALID_SRC",
-	"UNCONFIGURED_SRC",
-	"HEADROOM_NOT_ENOUGH",
+
+struct nss_stats_info nss_trustsec_tx_stats_str[NSS_TRUSTSEC_TX_STATS_MAX] = {
+	{"INVALID_SRC"		, NSS_STATS_TYPE_ERROR},
+	{"UNCONFIGURED_SRC"	, NSS_STATS_TYPE_ERROR},
+	{"HEADROOM_NOT_ENOUGH"	, NSS_STATS_TYPE_ERROR}
 };
 
 /*
  * trustsec_tx_stats
- *	Trustsec TX statistics
+ *	Trustsec TX statistics.
  */
 uint64_t trustsec_tx_stats[NSS_TRUSTSEC_TX_STATS_MAX];
 
@@ -72,16 +73,17 @@
 
 /*
  * nss_trustsec_tx_stats_read()
- *	Read trustsec_tx statiistics
+ *	Read trustsec_tx statiistics.
  */
 static ssize_t nss_trustsec_tx_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
 {
 	int32_t i;
 
 	/*
-	 * max output lines = #stats + start tag line + end tag line + three blank lines
+	 * Max output lines = #stats + few blank lines for banner printing +
+	 * Number of Extra outputlines for future reference to add new stats.
 	 */
-	uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_TRUSTSEC_TX_STATS_MAX + 3) + 5;
+	uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_TRUSTSEC_TX_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES;
 	size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
 	size_t size_wr = 0;
 	ssize_t bytes_read = 0;
@@ -100,7 +102,7 @@
 		return 0;
 	}
 
-	size_wr = scnprintf(lbuf, size_al, "trustsec_tx stats start:\n\n");
+	size_wr = nss_stats_banner(lbuf, size_wr, size_al, "trustsec_tx");
 
 	/*
 	 * Common node stats
@@ -110,21 +112,13 @@
 	/*
 	 * TrustSec TX node stats
 	 */
-	size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx node stats:\n\n");
-
 	spin_lock_bh(&nss_top_main.stats_lock);
 	for (i = 0; (i < NSS_TRUSTSEC_TX_STATS_MAX); i++) {
 		stats_shadow[i] = trustsec_tx_stats[i];
 	}
 
 	spin_unlock_bh(&nss_top_main.stats_lock);
-
-	for (i = 0; (i < NSS_TRUSTSEC_TX_STATS_MAX); i++) {
-		size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
-					"%s = %llu\n", nss_trustsec_tx_stats_str[i], stats_shadow[i]);
-	}
-
-	size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx stats end\n\n");
+	size_wr = nss_stats_print("trustsec_tx", NULL, NSS_STATS_SINGLE_CORE, NSS_STATS_SINGLE_INSTANCE, nss_trustsec_tx_stats_str, stats_shadow, NSS_TRUSTSEC_TX_STATS_MAX, lbuf, size_wr, size_al);
 	bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
 	kfree(lbuf);
 	kfree(stats_shadow);