blob: d8adebcedfe4ebc225c3f16bccc26e35a5f17c4a [file] [log] [blame]
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +05301/*
2 **************************************************************************
Stephen Wangaed46332016-12-12 17:29:03 -08003 * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +05304 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053016
17/*
18 * nss_stats.c
19 * NSS stats APIs
20 *
21 */
22
23#include "nss_core.h"
Tushar Mathurff8741b2015-12-02 20:28:59 +053024#include "nss_dtls_stats.h"
Thomas Wu71c5ecc2016-06-21 11:15:52 -070025#include "nss_gre_tunnel_stats.h"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053026
27/*
28 * Maximum string length:
29 * This should be equal to maximum string size of any stats
30 * inclusive of stats value
31 */
32#define NSS_STATS_MAX_STR_LENGTH 96
Aniruddha Paul1b170c22017-05-29 12:30:39 +053033#define NSS_STATS_WIFILI_MAX (NSS_STATS_WIFILI_TXRX_MAX + NSS_STATS_WIFILI_TCL_MAX + \
34 NSS_STATS_WIFILI_TX_DESC_FREE_MAX + NSS_STATS_WIFILI_REO_MAX + \
35 NSS_STATS_WIFILI_TX_DESC_MAX + NSS_STATS_WIFILI_EXT_TX_DESC_MAX + \
36 NSS_STATS_WIFILI_RX_DESC_MAX + NSS_STATS_WIFILI_RXDMA_DESC_MAX)
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053037
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -070038extern int32_t nss_tx_rx_virt_if_copy_stats(int32_t if_num, int i, char *line);
39
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +053040uint64_t stats_shadow_pppoe_except[NSS_PPPOE_NUM_SESSION_PER_INTERFACE][NSS_PPPOE_EXCEPTION_EVENT_MAX];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053041
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053042/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -070043 * Private data for every file descriptor
44 */
45struct nss_stats_data {
Jackson Bockusc2a4e682017-06-23 11:59:29 -070046 uint32_t if_num; /* Interface number for stats */
47 uint32_t index; /* Index for GRE_REDIR stats */
48 uint32_t edma_id; /* EDMA port ID or ring ID */
49 struct nss_ctx_instance *nss_ctx;
50 /* The core for project stats */
Saurabh Misra09dddeb2014-09-30 16:38:07 -070051};
52
53/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053054 * Statistics structures
55 */
56
57/*
58 * nss_stats_str_ipv4
59 * IPv4 stats strings
60 */
61static int8_t *nss_stats_str_ipv4[NSS_STATS_IPV4_MAX] = {
62 "rx_pkts",
63 "rx_bytes",
64 "tx_pkts",
65 "tx_bytes",
66 "create_requests",
67 "create_collisions",
68 "create_invalid_interface",
69 "destroy_requests",
70 "destroy_misses",
71 "hash_hits",
72 "hash_reorders",
73 "flushes",
Selin Dag60ea2b22014-11-05 09:36:22 -080074 "evictions",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +053075 "fragmentations",
76 "mc_create_requests",
77 "mc_update_requests",
78 "mc_create_invalid_interface",
79 "mc_destroy_requests",
80 "mc_destroy_misses",
81 "mc_flushes",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053082};
83
84/*
Selin Dag6d9b0c12014-11-04 18:27:21 -080085 * nss_stats_str_ipv4_reasm
86 * IPv4 reassembly stats strings
87 */
88static int8_t *nss_stats_str_ipv4_reasm[NSS_STATS_IPV4_REASM_MAX] = {
89 "evictions",
90 "alloc_fails",
91 "timeouts",
92};
93
94/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053095 * nss_stats_str_ipv6
96 * IPv6 stats strings
97 */
98static int8_t *nss_stats_str_ipv6[NSS_STATS_IPV6_MAX] = {
99 "rx_pkts",
100 "rx_bytes",
101 "tx_pkts",
102 "tx_bytes",
103 "create_requests",
104 "create_collisions",
105 "create_invalid_interface",
106 "destroy_requests",
107 "destroy_misses",
108 "hash_hits",
109 "hash_reorders",
110 "flushes",
111 "evictions",
Selin Dag5d68caa2015-05-12 13:23:33 -0700112 "fragmentations",
113 "frag_fails",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530114 "mc_create_requests",
115 "mc_update_requests",
116 "mc_create_invalid_interface",
117 "mc_destroy_requests",
118 "mc_destroy_misses",
119 "mc_flushes",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530120};
121
122/*
Selin Dag60a2f5b2015-06-29 14:39:49 -0700123 * nss_stats_str_ipv6_reasm
124 * IPv6 reassembly stats strings
125 */
126static int8_t *nss_stats_str_ipv6_reasm[NSS_STATS_IPV6_REASM_MAX] = {
127 "alloc_fails",
128 "timeouts",
129 "discards",
130};
131
132/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530133 * nss_stats_str_n2h
134 * N2H stats strings
135 */
136static int8_t *nss_stats_str_n2h[NSS_STATS_N2H_MAX] = {
137 "queue_dropped",
138 "ticks",
139 "worst_ticks",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700140 "iterations",
Thomas Wu3fd8dd72014-06-11 15:57:05 -0700141 "pbuf_ocm_alloc_fails",
142 "pbuf_ocm_free_count",
143 "pbuf_ocm_total_count",
144 "pbuf_default_alloc_fails",
145 "pbuf_default_free_count",
146 "pbuf_default_total_count",
Sakthi Vignesh Radhakrishnan2a8ee962014-11-22 13:35:38 -0800147 "payload_fails",
Thomas Wu53679842015-01-22 13:37:35 -0800148 "payload_free_count",
Sakthi Vignesh Radhakrishnan2a8ee962014-11-22 13:35:38 -0800149 "h2n_control_packets",
150 "h2n_control_bytes",
151 "n2h_control_packets",
152 "n2h_control_bytes",
153 "h2n_data_packets",
154 "h2n_data_bytes",
155 "n2h_data_packets",
156 "n2h_data_bytes",
Saurabh Misra71034db2015-06-04 16:18:38 -0700157 "n2h_tot_payloads",
Guojun Jin85dfa7b2015-09-02 15:13:56 -0700158 "n2h_data_interface_invalid",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530159};
160
161/*
Thomas Wuc3e382c2014-10-29 15:35:13 -0700162 * nss_stats_str_lso_rx
163 * LSO_RX stats strings
164 */
165static int8_t *nss_stats_str_lso_rx[NSS_STATS_LSO_RX_MAX] = {
166 "tx_dropped",
167 "dropped",
168 "pbuf_alloc_fail",
169 "pbuf_reference_fail"
170};
171
172/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530173 * nss_stats_str_drv
174 * Host driver stats strings
175 */
176static int8_t *nss_stats_str_drv[NSS_STATS_DRV_MAX] = {
177 "nbuf_alloc_errors",
178 "tx_queue_full[0]",
179 "tx_queue_full[1]",
180 "tx_buffers_empty",
181 "tx_buffers_pkt",
182 "tx_buffers_cmd",
183 "tx_buffers_crypto",
Murat Sezginb6e1a012015-09-29 14:06:37 -0700184 "tx_buffers_reuse",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530185 "rx_buffers_empty",
186 "rx_buffers_pkt",
187 "rx_buffers_cmd_resp",
188 "rx_buffers_status_sync",
189 "rx_buffers_crypto",
Thomas Wu0acd8162014-12-07 15:43:39 -0800190 "rx_buffers_virtual",
191 "tx_skb_simple",
192 "tx_skb_nr_frags",
193 "tx_skb_fraglist",
194 "rx_skb_simple",
195 "rx_skb_nr_frags",
196 "rx_skb_fraglist",
Sundarajan Srinivasan6e0366b2015-01-20 12:10:42 -0800197 "rx_bad_desciptor",
Thomas Wu1fbf5212015-06-04 14:38:40 -0700198 "nss_skb_count",
199 "rx_chain_seg_processed",
200 "rx_frag_seg_processed"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530201};
202
203/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530204 * nss_stats_str_pppoe
205 * PPPoE stats strings
206 */
207static int8_t *nss_stats_str_pppoe[NSS_STATS_PPPOE_MAX] = {
208 "create_requests",
209 "create_failures",
210 "destroy_requests",
211 "destroy_misses"
212};
213
214/*
215 * nss_stats_str_gmac
216 * GMAC stats strings
217 */
218static int8_t *nss_stats_str_gmac[NSS_STATS_GMAC_MAX] = {
219 "ticks",
220 "worst_ticks",
221 "iterations"
222};
223
224/*
Shashank Balashankar512cb602016-08-01 17:57:42 -0700225 * nss_stats_str_edma_tx
226 */
227static int8_t *nss_stats_str_edma_tx[NSS_STATS_EDMA_TX_MAX] = {
228 "tx_err",
229 "tx_dropped",
230 "desc_cnt"
231};
232
233/*
234 * nss_stats_str_edma_rx
235 */
236static int8_t *nss_stats_str_edma_rx[NSS_STATS_EDMA_RX_MAX] = {
237 "rx_csum_err",
Shashank Balashankarcbe48992017-06-27 13:51:28 -0700238 "desc_cnt",
239 "qos_err"
Shashank Balashankar512cb602016-08-01 17:57:42 -0700240};
241
242/*
243 * nss_stats_str_edma_txcmpl
244 */
245static int8_t *nss_stats_str_edma_txcmpl[NSS_STATS_EDMA_TXCMPL_MAX] = {
246 "desc_cnt"
247};
248
249/*
250 * nss_stats_str_edma_rxfill
251 */
252static int8_t *nss_stats_str_edma_rxfill[NSS_STATS_EDMA_RXFILL_MAX] = {
253 "desc_cnt"
254};
255
256/*
257 * nss_stats_str_edma_port_type
258 */
259static int8_t *nss_stats_str_edma_port_type[NSS_EDMA_PORT_TYPE_MAX] = {
260 "physical_port",
261 "virtual_port"
262};
263
264/*
265 * nss_stats_str_edma_port_ring_map
266 */
267static int8_t *nss_stats_str_edma_port_ring_map[NSS_EDMA_PORT_RING_MAP_MAX] = {
268 "rx_ring",
269 "tx_ring"
270};
271
272/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -0700273 * nss_stats_str_edma_err_map
274 */
275static int8_t *nss_stats_str_edma_err_map[NSS_EDMA_ERR_STATS_MAX] = {
276 "axi_rd_err",
277 "axi_wr_err",
278 "rx_desc_fifo_full_err",
279 "rx_buf_size_err",
280 "tx_sram_full_err",
281 "tx_cmpl_buf_full_err",
282 "pkt_len_la64k_err",
283 "pkt_len_le33_err",
Santosh Kivati28c20042017-07-11 16:47:57 -0700284 "data_len_err",
285 "alloc_fail_cnt"
Santosh Kivatib65b68b2017-05-18 13:30:58 -0700286};
287
288/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530289 * nss_stats_str_node
290 * Interface stats strings per node
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530291 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530292static int8_t *nss_stats_str_node[NSS_STATS_NODE_MAX] = {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530293 "rx_packets",
294 "rx_bytes",
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530295 "rx_dropped",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530296 "tx_packets",
297 "tx_bytes"
298};
299
300/*
Murat Sezgin99dab642014-08-28 14:40:34 -0700301 * nss_stats_str_eth_rx
302 * eth_rx stats strings
303 */
304static int8_t *nss_stats_str_eth_rx[NSS_STATS_ETH_RX_MAX] = {
305 "ticks",
306 "worst_ticks",
307 "iterations"
308};
309
310/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530311 * nss_stats_str_if_exception_unknown
312 * Interface stats strings for unknown exceptions
313 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530314static int8_t *nss_stats_str_if_exception_eth_rx[NSS_EXCEPTION_EVENT_ETH_RX_MAX] = {
Selin Dag2e8e48c2015-02-20 15:51:55 -0800315 "UNKNOWN_L3_PROTOCOL",
316 "ETH_HDR_MISSING",
Stephen Wangec5a85c2016-09-08 23:32:27 -0700317 "VLAN_MISSING",
318 "TRUSTSEC_HDR_MISSING"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530319};
320
321/*
322 * nss_stats_str_if_exception_ipv4
323 * Interface stats strings for ipv4 exceptions
324 */
325static int8_t *nss_stats_str_if_exception_ipv4[NSS_EXCEPTION_EVENT_IPV4_MAX] = {
326 "IPV4_ICMP_HEADER_INCOMPLETE",
327 "IPV4_ICMP_UNHANDLED_TYPE",
328 "IPV4_ICMP_IPV4_HEADER_INCOMPLETE",
329 "IPV4_ICMP_IPV4_UDP_HEADER_INCOMPLETE",
330 "IPV4_ICMP_IPV4_TCP_HEADER_INCOMPLETE",
331 "IPV4_ICMP_IPV4_UNKNOWN_PROTOCOL",
332 "IPV4_ICMP_NO_ICME",
333 "IPV4_ICMP_FLUSH_TO_HOST",
334 "IPV4_TCP_HEADER_INCOMPLETE",
335 "IPV4_TCP_NO_ICME",
336 "IPV4_TCP_IP_OPTION",
337 "IPV4_TCP_IP_FRAGMENT",
338 "IPV4_TCP_SMALL_TTL",
339 "IPV4_TCP_NEEDS_FRAGMENTATION",
340 "IPV4_TCP_FLAGS",
341 "IPV4_TCP_SEQ_EXCEEDS_RIGHT_EDGE",
342 "IPV4_TCP_SMALL_DATA_OFFS",
343 "IPV4_TCP_BAD_SACK",
344 "IPV4_TCP_BIG_DATA_OFFS",
345 "IPV4_TCP_SEQ_BEFORE_LEFT_EDGE",
346 "IPV4_TCP_ACK_EXCEEDS_RIGHT_EDGE",
347 "IPV4_TCP_ACK_BEFORE_LEFT_EDGE",
348 "IPV4_UDP_HEADER_INCOMPLETE",
349 "IPV4_UDP_NO_ICME",
350 "IPV4_UDP_IP_OPTION",
351 "IPV4_UDP_IP_FRAGMENT",
352 "IPV4_UDP_SMALL_TTL",
353 "IPV4_UDP_NEEDS_FRAGMENTATION",
354 "IPV4_WRONG_TARGET_MAC",
355 "IPV4_HEADER_INCOMPLETE",
356 "IPV4_BAD_TOTAL_LENGTH",
357 "IPV4_BAD_CHECKSUM",
358 "IPV4_NON_INITIAL_FRAGMENT",
359 "IPV4_DATAGRAM_INCOMPLETE",
360 "IPV4_OPTIONS_INCOMPLETE",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530361 "IPV4_UNKNOWN_PROTOCOL",
362 "IPV4_ESP_HEADER_INCOMPLETE",
363 "IPV4_ESP_NO_ICME",
364 "IPV4_ESP_IP_OPTION",
365 "IPV4_ESP_IP_FRAGMENT",
366 "IPV4_ESP_SMALL_TTL",
367 "IPV4_ESP_NEEDS_FRAGMENTATION",
368 "IPV4_INGRESS_VID_MISMATCH",
Thomas Wu8d6f4b22014-06-09 14:46:18 -0700369 "IPV4_INGRESS_VID_MISSING",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530370 "IPV4_6RD_NO_ICME",
371 "IPV4_6RD_IP_OPTION",
372 "IPV4_6RD_IP_FRAGMENT",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700373 "IPV4_6RD_NEEDS_FRAGMENTATION",
374 "IPV4_DSCP_MARKING_MISMATCH",
Murat Sezgin7c5956a2014-05-12 09:59:51 -0700375 "IPV4_VLAN_MARKING_MISMATCH",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800376 "IPV4_DEPRECATED",
Radha krishna Simha Jiguru00cfe562014-10-21 16:22:12 +0530377 "IPV4_GRE_HEADER_INCOMPLETE",
378 "IPV4_GRE_NO_ICME",
379 "IPV4_GRE_IP_OPTION",
380 "IPV4_GRE_IP_FRAGMENT",
381 "IPV4_GRE_SMALL_TTL",
382 "IPV4_GRE_NEEDS_FRAGMENTATION",
Shyam Sundere351f1b2015-12-17 14:11:51 +0530383 "IPV4_PPTP_GRE_SESSION_MATCH_FAIL",
384 "IPV4_PPTP_GRE_INVALID_PROTO",
385 "IPV4_PPTP_GRE_NO_CME",
386 "IPV4_PPTP_GRE_IP_OPTION",
387 "IPV4_PPTP_GRE_IP_FRAGMENT",
388 "IPV4_PPTP_GRE_SMALL_TTL",
389 "IPV4_PPTP_GRE_NEEDS_FRAGMENTATION",
390 "IPV4_DESTROY",
Selin Dag60ea2b22014-11-05 09:36:22 -0800391 "IPV4_FRAG_DF_SET",
392 "IPV4_FRAG_FAIL",
Saurabh Misra5b07cc02015-01-15 14:20:58 -0800393 "IPV4_ICMP_IPV4_UDPLITE_HEADER_INCOMPLETE",
394 "IPV4_UDPLITE_HEADER_INCOMPLETE",
395 "IPV4_UDPLITE_NO_ICME",
396 "IPV4_UDPLITE_IP_OPTION",
397 "IPV4_UDPLITE_IP_FRAGMENT",
398 "IPV4_UDPLITE_SMALL_TTL",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530399 "IPV4_UDPLITE_NEEDS_FRAGMENTATION",
400 "IPV4_MC_UDP_NO_ICME",
401 "IPV4_MC_MEM_ALLOC_FAILURE",
402 "IPV4_MC_UPDATE_FAILURE",
403 "IPV4_MC_PBUF_ALLOC_FAILURE"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530404};
405
406/*
407 * nss_stats_str_if_exception_ipv6
408 * Interface stats strings for ipv6 exceptions
409 */
410static int8_t *nss_stats_str_if_exception_ipv6[NSS_EXCEPTION_EVENT_IPV6_MAX] = {
411 "IPV6_ICMP_HEADER_INCOMPLETE",
412 "IPV6_ICMP_UNHANDLED_TYPE",
413 "IPV6_ICMP_IPV6_HEADER_INCOMPLETE",
414 "IPV6_ICMP_IPV6_UDP_HEADER_INCOMPLETE",
415 "IPV6_ICMP_IPV6_TCP_HEADER_INCOMPLETE",
416 "IPV6_ICMP_IPV6_UNKNOWN_PROTOCOL",
417 "IPV6_ICMP_NO_ICME",
418 "IPV6_ICMP_FLUSH_TO_HOST",
419 "IPV6_TCP_HEADER_INCOMPLETE",
420 "IPV6_TCP_NO_ICME",
421 "IPV6_TCP_SMALL_HOP_LIMIT",
422 "IPV6_TCP_NEEDS_FRAGMENTATION",
423 "IPV6_TCP_FLAGS",
424 "IPV6_TCP_SEQ_EXCEEDS_RIGHT_EDGE",
425 "IPV6_TCP_SMALL_DATA_OFFS",
426 "IPV6_TCP_BAD_SACK",
427 "IPV6_TCP_BIG_DATA_OFFS",
428 "IPV6_TCP_SEQ_BEFORE_LEFT_EDGE",
429 "IPV6_TCP_ACK_EXCEEDS_RIGHT_EDGE",
430 "IPV6_TCP_ACK_BEFORE_LEFT_EDGE",
431 "IPV6_UDP_HEADER_INCOMPLETE",
432 "IPV6_UDP_NO_ICME",
433 "IPV6_UDP_SMALL_HOP_LIMIT",
434 "IPV6_UDP_NEEDS_FRAGMENTATION",
435 "IPV6_WRONG_TARGET_MAC",
436 "IPV6_HEADER_INCOMPLETE",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530437 "IPV6_UNKNOWN_PROTOCOL",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700438 "IPV6_INGRESS_VID_MISMATCH",
Thomas Wu8d6f4b22014-06-09 14:46:18 -0700439 "IPV6_INGRESS_VID_MISSING",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700440 "IPV6_DSCP_MARKING_MISMATCH",
441 "IPV6_VLAN_MARKING_MISMATCH",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800442 "IPV6_DEPRECATED",
Saurabh Misra5b07cc02015-01-15 14:20:58 -0800443 "IPV6_GRE_NO_ICME",
444 "IPV6_GRE_NEEDS_FRAGMENTATION",
445 "IPV6_GRE_SMALL_HOP_LIMIT",
446 "IPV6_DESTROY",
447 "IPV6_ICMP_IPV6_UDPLITE_HEADER_INCOMPLETE",
448 "IPV6_UDPLITE_HEADER_INCOMPLETE",
449 "IPV6_UDPLITE_NO_ICME",
450 "IPV6_UDPLITE_SMALL_HOP_LIMIT",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530451 "IPV6_UDPLITE_NEEDS_FRAGMENTATION",
452 "IPV6_MC_UDP_NO_ICME",
453 "IPV6_MC_MEM_ALLOC_FAILURE",
454 "IPV6_MC_UPDATE_FAILURE",
mandrw7125bac2016-01-14 19:36:46 +0530455 "IPV6_MC_PBUF_ALLOC_FAILURE",
456 "IPV6_ESP_HEADER_INCOMPLETE",
457 "IPV6_ESP_NO_ICME",
458 "IPV6_ESP_IP_FRAGMENT",
459 "IPV6_ESP_SMALL_HOP_LIMIT",
460 "IPV6_ESP_NEEDS_FRAGMENTATION"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530461};
462
463/*
464 * nss_stats_str_if_exception_pppoe
465 * Interface stats strings for PPPoE exceptions
466 */
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +0530467static int8_t *nss_stats_str_if_exception_pppoe[NSS_PPPOE_EXCEPTION_EVENT_MAX] = {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530468 "PPPOE_WRONG_VERSION_OR_TYPE",
469 "PPPOE_WRONG_CODE",
470 "PPPOE_HEADER_INCOMPLETE",
Murat Sezgin7c5956a2014-05-12 09:59:51 -0700471 "PPPOE_UNSUPPORTED_PPP_PROTOCOL",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800472 "PPPOE_DEPRECATED"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530473};
474
475/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530476 * nss_stats_str_wifi
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530477 * Wifi statistics strings
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530478 */
479static int8_t *nss_stats_str_wifi[NSS_STATS_WIFI_MAX] = {
480 "RX_PACKETS",
481 "RX_DROPPED",
482 "TX_PACKETS",
483 "TX_DROPPED",
484 "TX_TRANSMIT_COMPLETED",
485 "TX_MGMT_RECEIVED",
486 "TX_MGMT_TRANSMITTED",
487 "TX_MGMT_DROPPED",
488 "TX_MGMT_COMPLETED",
489 "TX_INV_PEER_ENQ_CNT",
490 "RX_INV_PEER_RCV_CNT",
491 "RX_PN_CHECK_FAILED",
492 "RX_PKTS_DELIVERD",
Radha krishna Simha Jiguru36304d12015-12-03 20:21:02 +0530493 "RX_BYTES_DELIVERED",
494 "TX_BYTES_COMPLETED",
Pamidipati, Vijay670ce7e2016-03-15 16:46:59 +0530495 "RX_DELIVER_UNALIGNED_DROP_CNT",
496 "TIDQ_ENQUEUE_CNT_0",
497 "TIDQ_ENQUEUE_CNT_1",
498 "TIDQ_ENQUEUE_CNT_2",
499 "TIDQ_ENQUEUE_CNT_3",
500 "TIDQ_ENQUEUE_CNT_4",
501 "TIDQ_ENQUEUE_CNT_5",
502 "TIDQ_ENQUEUE_CNT_6",
503 "TIDQ_ENQUEUE_CNT_7",
504 "TIDQ_DEQUEUE_CNT_0",
505 "TIDQ_DEQUEUE_CNT_1",
506 "TIDQ_DEQUEUE_CNT_2",
507 "TIDQ_DEQUEUE_CNT_3",
508 "TIDQ_DEQUEUE_CNT_4",
509 "TIDQ_DEQUEUE_CNT_5",
510 "TIDQ_DEQUEUE_CNT_6",
511 "TIDQ_DEQUEUE_CNT_7",
512 "TIDQ_ENQUEUE_FAIL_CNT_0",
513 "TIDQ_ENQUEUE_FAIL_CNT_1",
514 "TIDQ_ENQUEUE_FAIL_CNT_2",
515 "TIDQ_ENQUEUE_FAIL_CNT_3",
516 "TIDQ_ENQUEUE_FAIL_CNT_4",
517 "TIDQ_ENQUEUE_FAIL_CNT_5",
518 "TIDQ_ENQUEUE_FAIL_CNT_6",
519 "TIDQ_ENQUEUE_FAIL_CNT_7",
520 "TIDQ_TTL_EXPIRE_CNT_0",
521 "TIDQ_TTL_EXPIRE_CNT_1",
522 "TIDQ_TTL_EXPIRE_CNT_2",
523 "TIDQ_TTL_EXPIRE_CNT_3",
524 "TIDQ_TTL_EXPIRE_CNT_4",
525 "TIDQ_TTL_EXPIRE_CNT_5",
526 "TIDQ_TTL_EXPIRE_CNT_6",
527 "TIDQ_TTL_EXPIRE_CNT_7",
528 "TIDQ_DEQUEUE_REQ_CNT_0",
529 "TIDQ_DEQUEUE_REQ_CNT_1",
530 "TIDQ_DEQUEUE_REQ_CNT_2",
531 "TIDQ_DEQUEUE_REQ_CNT_3",
532 "TIDQ_DEQUEUE_REQ_CNT_4",
533 "TIDQ_DEQUEUE_REQ_CNT_5",
534 "TIDQ_DEQUEUE_REQ_CNT_6",
535 "TIDQ_DEQUEUE_REQ_CNT_7",
536 "TOTAL_TIDQ_DEPTH",
537 "RX_HTT_FETCH_CNT",
538 "TOTAL_TIDQ_BYPASS_CNT",
539 "GLOBAL_Q_FULL_CNT",
540 "TIDQ_FULL_CNT",
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530541};
542
543/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530544 * nss_stats_str_wifili
545 * wifili txrx statistics
546 */
547static int8_t *nss_stats_str_wifili_txrx[NSS_STATS_WIFILI_TXRX_MAX] = {
548 "WIFILI_RX_MSDU_ERROR",
549 "WIFILI_RX_INV_PEER_RCV",
550 "WIFILI_RX_WDS_SRCPORT_EXCEPTION",
551 "WIFILI_RX_WDS_SRCPORT_EXCEPTION_FAIL",
552 "WIFILI_RX_DELIVERD",
553 "WIFILI_RX_DELIVER_DROPPED",
554 "WIFILI_RX_INTRA_BSS_UCAST",
555 "WIFILI_RX_INTRA_BSS_UCAST_FAIL",
556 "WIFILI_RX_INTRA_BSS_MCAST",
557 "WIFILI_RX_INTRA_BSS_MCAST_FAIL",
Aniruddha Paul1dc00782017-06-05 13:38:48 +0530558 "WIFILI_RX_SG_RCV_SEND",
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530559 "WIFILI_RX_SG_RCV_FAIL",
560 "WIFILI_TX_ENQUEUE",
561 "WIFILI_TX_ENQUEUE_DROP",
562 "WIFILI_TX_DEQUEUE",
563 "WIFILI_TX_HW_ENQUEUE_FAIL",
564 "WIFILI_TX_SENT_COUNT",
565};
566
567/*
568 * nss_stats_str_wifili_tcl
569 * wifili tcl stats
570 */
571static int8_t *nss_stats_str_wifili_tcl[NSS_STATS_WIFILI_TCL_MAX] = {
572 "WIFILI_TCL_NO_HW_DESC",
573 "WIFILI_TCL_RING_FULL",
574 "WIFILI_TCL_RING_SENT",
575};
576
577/*
578 * nss_stats_str_wifili_tx_comp
579 * wifili tx comp stats
580 */
581static int8_t *nss_stats_str_wifili_tx_comp[NSS_STATS_WIFILI_TX_DESC_FREE_MAX] = {
582 "WIFILI_TX_DESC_FREE_INV_BUFSRC",
583 "WIFILI_TX_DESC_FREE_INV_COOKIE",
584 "WIFILI_TX_DESC_FREE_HW_RING_EMPTY",
585 "WIFILI_TX_DESC_FREE_REAPED",
586};
587
588/*
589 * nss_stats_str_wifili_reo
590 * wifili tx reo stats
591 */
592static int8_t *nss_stats_str_wifili_reo[NSS_STATS_WIFILI_REO_MAX] = {
593 "WIFILI_REO_ERROR",
594 "WIFILI_REO_REAPED",
595 "WIFILI_REO_INV_COOKIE",
596};
597
598/*
599 * nss_stats_str_wifili_txsw_pool
600 * wifili tx desc stats
601 */
602static int8_t *nss_stats_str_wifili_txsw_pool[NSS_STATS_WIFILI_TX_DESC_MAX] = {
603 "WIFILI_TX_DESC_IN_USE",
604 "WIFILI_TX_DESC_ALLOC_FAIL",
605 "WIFILI_TX_DESC_ALREADY_ALLOCATED",
606 "WIFILI_TX_DESC_INVALID_FREE",
607 "WIFILI_TX_DESC_FREE_SRC_FW",
608 "WIFILI_TX_DESC_FREE_COMPLETION",
609 "WIFILI_TX_DESC_NO_PB",
610};
611
612/*
613 * nss_stats_str_wifili_ext_txsw_pool
614 * wifili tx ext desc stats
615 */
616static uint8_t *nss_stats_str_wifili_ext_txsw_pool[NSS_STATS_WIFILI_EXT_TX_DESC_MAX] = {
617 "WIFILI_EXT_TX_DESC_IN_USE",
618 "WIFILI_EXT_TX_DESC_ALLOC_FAIL",
619 "WIFILI_EXT_TX_DESC_ALREADY_ALLOCATED",
620 "WIFILI_EXT_TX_DESC_INVALID_FREE",
621};
622
623/*
624 * nss_stats_str_wifili_rxdma_pool
625 * wifili rx desc stats
626 */
627static int8_t *nss_stats_str_wifili_rxdma_pool[NSS_STATS_WIFILI_RX_DESC_MAX] = {
628 "WIFILI_RX_DESC_NO_PB",
629 "WIFILI_RX_DESC_ALLOC_FAIL",
630 "WIFILI_RX_DESC_IN_USE",
631};
632
633/*
634 * nss_stats_str_wifili_rxdma_ring
635 * wifili rx dma ring stats
636 */
637static int8_t *nss_stats_str_wifili_rxdma_ring[NSS_STATS_WIFILI_RXDMA_DESC_MAX] = {
638 "WIFILI_RXDMA_HW_DESC_UNAVAILABLE",
639};
640
641/*
642 * nss_stats_str_wifili_wbm
643 * wifili wbm ring stats
644 */
645static int8_t *nss_stats_str_wifili_wbm[NSS_STATS_WIFILI_WBM_MAX] = {
646 "WIFILI_WBM_SRC_DMA",
647 "WIFILI_WBM_SRC_DMA_CODE_INV",
648 "WIFILI_WBM_SRC_REO",
649 "WIFILI_WBM_SRC_REO_CODE_NULLQ",
650 "WIFILI_WBM_SRC_REO_CODE_INV",
651 "WIFILI_WBM_SRC_INV",
652};
653
654/*
Stephen Wang9779d952015-10-28 11:39:07 -0700655 * nss_stats_str_portid
656 * PortID statistics strings
657 */
658static int8_t *nss_stats_str_portid[NSS_STATS_PORTID_MAX] = {
659 "RX_INVALID_HEADER",
660};
661
662/*
Tushar Mathurff8741b2015-12-02 20:28:59 +0530663 * nss_stats_str_dtls_session_stats
664 * DTLS statistics strings for nss session stats
665 */
666static int8_t *nss_stats_str_dtls_session_debug_stats[NSS_STATS_DTLS_SESSION_MAX] = {
667 "RX_PKTS",
668 "TX_PKTS",
669 "RX_DROPPED",
670 "RX_AUTH_DONE",
671 "TX_AUTH_DONE",
672 "RX_CIPHER_DONE",
673 "TX_CIPHER_DONE",
674 "RX_CBUF_ALLOC_FAIL",
675 "TX_CBUF_ALLOC_FAIL",
676 "TX_CENQUEUE_FAIL",
677 "RX_CENQUEUE_FAIL",
678 "TX_DROPPED_HROOM",
679 "TX_DROPPED_TROOM",
680 "TX_FORWARD_ENQUEUE_FAIL",
681 "RX_FORWARD_ENQUEUE_FAIL",
682 "RX_INVALID_VERSION",
683 "RX_INVALID_EPOCH",
684 "RX_MALFORMED",
685 "RX_CIPHER_FAIL",
686 "RX_AUTH_FAIL",
687 "RX_CAPWAP_CLASSIFY_FAIL",
688 "RX_SINGLE_REC_DGRAM",
689 "RX_MULTI_REC_DGRAM",
690 "RX_REPLAY_FAIL",
691 "RX_REPLAY_DUPLICATE",
692 "RX_REPLAY_OUT_OF_WINDOW",
693 "OUTFLOW_QUEUE_FULL",
694 "DECAP_QUEUE_FULL",
695 "PBUF_ALLOC_FAIL",
696 "PBUF_COPY_FAIL",
697 "EPOCH",
698 "TX_SEQ_HIGH",
699 "TX_SEQ_LOW",
700};
701
702/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -0700703 * nss_stats_str_gre_tunnel_session_stats
704 * GRE Tunnel statistics strings for nss session stats
705 */
706static int8_t *nss_stats_str_gre_tunnel_session_debug_stats[NSS_STATS_GRE_TUNNEL_SESSION_MAX] = {
707 "RX_PKTS",
708 "TX_PKTS",
709 "RX_DROPPED",
710 "RX_MALFORMED",
711 "RX_INVALID_PROT",
712 "DECAP_QUEUE_FULL",
713 "RX_SINGLE_REC_DGRAM",
714 "RX_INVALID_REC_DGRAM",
715 "BUFFER_ALLOC_FAIL",
716 "BUFFER_COPY_FAIL",
717 "OUTFLOW_QUEUE_FULL",
718 "TX_DROPPED_HROOM",
719 "RX_CBUFFER_ALLOC_FAIL",
720 "RX_CENQUEUE_FAIL",
721 "RX_DECRYPT_DONE",
722 "RX_FORWARD_ENQUEUE_FAIL",
723 "TX_CBUFFER_ALLOC_FAIL",
724 "TX_CENQUEUE_FAIL",
725 "TX_DROPPED_TROOM",
726 "TX_FORWARD_ENQUEUE_FAIL",
727 "TX_CIPHER_DONE",
728 "CRYPTO_NOSUPP",
Shashank Balashankar4e7879e2017-06-02 15:16:01 -0700729 "RX_DROPPED_MH_VERSION",
Thomas Wu71c5ecc2016-06-21 11:15:52 -0700730};
731
732/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +0530733 * nss_stats_str_l2tpv2_session_stats
734 * l2tpv2 statistics strings for nss session stats
735 */
736static int8_t *nss_stats_str_l2tpv2_session_debug_stats[NSS_STATS_L2TPV2_SESSION_MAX] = {
737 "RX_PPP_LCP_PKTS",
738 "RX_EXP_PKTS",
739 "ENCAP_PBUF_ALLOC_FAIL",
740 "DECAP_PBUF_ALLOC_FAIL"
741};
742
743/*
ratheesh kannotha1245c32015-11-04 16:45:43 +0530744 * nss_stats_str_map_t_instance_stats
745 * map_t statistics strings for nss session stats
746 */
747static int8_t *nss_stats_str_map_t_instance_debug_stats[NSS_STATS_MAP_T_MAX] = {
748 "MAP_T_V4_TO_V6_PBUF_EXCEPTION_PKTS",
749 "MAP_T_V4_TO_V6_PBUF_NO_MATCHING_RULE",
750 "MAP_T_V4_TO_V6_PBUF_NOT_TCP_OR_UDP",
ratheesh kannoth32b6c422016-06-05 10:08:15 +0530751 "MAP_T_V4_TO_V6_RULE_ERR_LOCAL_PSID",
ratheesh kannotha1245c32015-11-04 16:45:43 +0530752 "MAP_T_V4_TO_V6_RULE_ERR_LOCAL_IPV6",
753 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_PSID",
754 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_EA_BITS",
755 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_IPV6",
756 "MAP_T_V6_TO_V4_PBUF_EXCEPTION_PKTS",
757 "MAP_T_V6_TO_V4_PBUF_NO_MATCHING_RULE",
758 "MAP_T_V6_TO_V4_PBUF_NOT_TCP_OR_UDP",
759 "MAP_T_V6_TO_V4_RULE_ERR_LOCAL_IPV4",
760 "MAP_T_V6_TO_V4_RULE_ERR_REMOTE_IPV4"
761};
762
ratheesh kannotheb2a0a82017-05-04 09:20:17 +0530763 /*
764 * nss_stats_str_gre_base_stats
765 * GRE debug statistics strings for base types
766 */
767static int8_t *nss_stats_str_gre_base_debug_stats[NSS_STATS_GRE_BASE_DEBUG_MAX] = {
768 "GRE_BASE_RX_PACKETS",
769 "GRE_BASE_RX_DROPPED",
770 "GRE_BASE_EXP_ETH_HDR_MISSING",
771 "GRE_BASE_EXP_ETH_TYPE_NON_IP",
772 "GRE_BASE_EXP_IP_UNKNOWN_PROTOCOL",
773 "GRE_BASE_EXP_IP_HEADER_INCOMPLETE",
774 "GRE_BASE_EXP_IP_BAD_TOTAL_LENGTH",
775 "GRE_BASE_EXP_IP_BAD_CHECKSUM",
776 "GRE_BASE_EXP_IP_DATAGRAM_INCOMPLETE",
777 "GRE_BASE_EXP_IP_FRAGMENT",
778 "GRE_BASE_EXP_IP_OPTIONS_INCOMPLETE",
779 "GRE_BASE_EXP_IP_WITH_OPTIONS",
780 "GRE_BASE_EXP_IPV6_UNKNOWN_PROTOCOL",
781 "GRE_BASE_EXP_IPV6_HEADER_INCOMPLETE",
782 "GRE_BASE_EXP_GRE_UNKNOWN_SESSION",
783 "GRE_BASE_EXP_GRE_NODE_INACTIVE",
784};
785
786/*
787 * nss_stats_str_gre_session_stats
788 * GRE debug statistics strings for sessions
789 */
790static int8_t *nss_stats_str_gre_session_debug_stats[NSS_STATS_GRE_SESSION_DEBUG_MAX] = {
791 "GRE_SESSION_PBUF_ALLOC_FAIL",
792 "GRE_SESSION_DECAP_FORWARD_ENQUEUE_FAIL",
793 "GRE_SESSION_ENCAP_FORWARD_ENQUEUE_FAIL",
794 "GRE_SESSION_DECAP_TX_FORWARDED",
795 "GRE_SESSION_ENCAP_RX_RECEIVED",
796 "GRE_SESSION_ENCAP_RX_DROPPED",
797 "GRE_SESSION_ENCAP_RX_LINEAR_FAIL",
798 "GRE_SESSION_EXP_RX_KEY_ERROR",
799 "GRE_SESSION_EXP_RX_SEQ_ERROR",
800 "GRE_SESSION_EXP_RX_CS_ERROR",
801 "GRE_SESSION_EXP_RX_FLAG_MISMATCH",
802 "GRE_SESSION_EXP_RX_MALFORMED",
803 "GRE_SESSION_EXP_RX_INVALID_PROTOCOL",
804 "GRE_SESSION_EXP_RX_NO_HEADROOM",
805};
806
ratheesh kannotha1245c32015-11-04 16:45:43 +0530807/*
Amit Gupta316729b2016-08-12 12:21:15 +0530808 * nss_stats_str_ppe_conn
809 * PPE statistics strings for nss flow stats
810 */
811static int8_t *nss_stats_str_ppe_conn[NSS_STATS_PPE_CONN_MAX] = {
812 "v4 routed flows",
813 "v4 bridge flows",
814 "v4 conn create req",
815 "v4 conn create fail",
816 "v4 conn destroy req",
817 "v4 conn destroy fail",
Amit Gupta263df9c2017-05-16 20:43:07 +0530818 "v4 conn MC create req",
819 "v4 conn MC create fail",
820 "v4 conn MC update req",
821 "v4 conn MC update fail",
822 "v4 conn MC delete req",
823 "v4 conn MC delete fail",
Amit Gupta316729b2016-08-12 12:21:15 +0530824
825 "v6 routed flows",
826 "v6 bridge flows",
827 "v6 conn create req",
828 "v6 conn create fail",
829 "v6 conn destroy req",
830 "v6 conn destroy fail",
Amit Gupta263df9c2017-05-16 20:43:07 +0530831 "v6 conn MC create req",
832 "v6 conn MC create fail",
833 "v6 conn MC update req",
834 "v6 conn MC update fail",
835 "v6 conn MC delete req",
836 "v6 conn MC delete fail",
Amit Gupta316729b2016-08-12 12:21:15 +0530837
Amit Gupta263df9c2017-05-16 20:43:07 +0530838 "conn fail - vp full",
Amit Gupta316729b2016-08-12 12:21:15 +0530839 "conn fail - nexthop full",
840 "conn fail - flow full",
841 "conn fail - host full",
842 "conn fail - pub-ip full",
843 "conn fail - port not setup",
844 "conn fail - rw fifo full",
Amit Gupta263df9c2017-05-16 20:43:07 +0530845 "conn fail - flow cmd failure",
Amit Gupta316729b2016-08-12 12:21:15 +0530846 "conn fail - unknown proto",
847 "conn fail - ppe not responding",
Amit Gupta263df9c2017-05-16 20:43:07 +0530848 "conn fail - CE opaque invalid",
Thomas Wufc4d9fd2017-03-22 10:15:30 -0700849 "conn fail - fqg full"
Amit Gupta316729b2016-08-12 12:21:15 +0530850};
851
852/*
853 * nss_stats_str_ppe_l3
854 * PPE statistics strings for nss debug stats
855 */
856static int8_t *nss_stats_str_ppe_l3[NSS_STATS_PPE_L3_MAX] = {
857 "PPE L3 dbg reg 0",
858 "PPE L3 dbg reg 1",
859 "PPE L3 dbg reg 2",
860 "PPE L3 dbg reg 3",
861 "PPE L3 dbg reg 4",
862 "PPE L3 dbg reg port",
863};
864
865/*
866 * nss_stats_str_ppe_code
867 * PPE statistics strings for nss debug stats
868 */
869static int8_t *nss_stats_str_ppe_code[NSS_STATS_PPE_CODE_MAX] = {
870 "PPE CPU_CODE",
871 "PPE DROP_CODE",
872};
873
874/*
Amit Gupta79c1c202017-06-30 15:28:13 +0530875 * nss_stats_str_ppe_dc
876 * PPE statistics strings for drop code
877 */
878static int8_t *nss_stats_str_ppe_dc[NSS_STATS_PPE_DROP_CODE_MAX] = {
879 "PPE_DROP_CODE_NONE",
880 "PPE_DROP_CODE_EXP_UNKNOWN_L2_PORT",
881 "PPE_DROP_CODE_EXP_PPPOE_WRONG_VER_TYPE",
882 "PPE_DROP_CODE_EXP_PPPOE_WRONG_CODE",
883 "PPE_DROP_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",
884 "PPE_DROP_CODE_EXP_IPV4_WRONG_VER",
885 "PPE_DROP_CODE_EXP_IPV4_SMALL_IHL",
886 "PPE_DROP_CODE_EXP_IPV4_WITH_OPTION",
887 "PPE_DROP_CODE_EXP_IPV4_HDR_INCOMPLETE",
888 "PPE_DROP_CODE_EXP_IPV4_BAD_TOTAL_LEN",
889 "PPE_DROP_CODE_EXP_IPV4_DATA_INCOMPLETE",
890 "PPE_DROP_CODE_EXP_IPV4_FRAG",
891 "PPE_DROP_CODE_EXP_IPV4_PING_OF_DEATH",
892 "PPE_DROP_CODE_EXP_IPV4_SNALL_TTL",
893 "PPE_DROP_CODE_EXP_IPV4_UNK_IP_PROT",
894 "PPE_DROP_CODE_EXP_IPV4_CHECKSUM_ERR",
895 "PPE_DROP_CODE_EXP_IPV4_INV_SIP",
896 "PPE_DROP_CODE_EXP_IPV4_INV_DIP",
897 "PPE_DROP_CODE_EXP_IPV4_LAND_ATTACK",
898 "PPE_DROP_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",
899 "PPE_DROP_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER",
900 "PPE_DROP_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",
901 "PPE_DROP_CODE_EXP_IPV6_WRONG_VER",
902 "PPE_DROP_CODE_EXP_IPV6_HDR_INCOMPLETE",
903 "PPE_DROP_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",
904 "PPE_DROP_CODE_EXP_IPV6_DATA_INCOMPLETE",
905 "PPE_DROP_CODE_EXP_IPV6_WITH_EXT_HDR",
906 "PPE_DROP_CODE_EXP_IPV6_SMALL_HOP_LIMIT",
907 "PPE_DROP_CODE_EXP_IPV6_INV_SIP",
908 "PPE_DROP_CODE_EXP_IPV6_INV_DIP",
909 "PPE_DROP_CODE_EXP_IPV6_LAND_ATTACK",
910 "PPE_DROP_CODE_EXP_IPV6_FRAG",
911 "PPE_DROP_CODE_EXP_IPV6_PING_OF_DEATH",
912 "PPE_DROP_CODE_EXP_IPV6_WITH_MORE_EXT_HDR",
913 "PPE_DROP_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR",
914 "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",
915 "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER",
916 "PPE_DROP_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",
917 "PPE_DROP_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER",
918 "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",
919 "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER",
920 "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE",
921 "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER",
922 "PPE_DROP_CODE_EXP_TCP_HDR_INCOMPLETE",
923 "PPE_DROP_CODE_EXP_TCP_HDR_CROSS_BORDER",
924 "PPE_DROP_CODE_EXP_TCP_SMAE_SP_DP",
925 "PPE_DROP_CODE_EXP_TCP_SMALL_DATA_OFFSET",
926 "PPE_DROP_CODE_EXP_TCP_FLAGS_0",
927 "PPE_DROP_CODE_EXP_TCP_FLAGS_1",
928 "PPE_DROP_CODE_EXP_TCP_FLAGS_2",
929 "PPE_DROP_CODE_EXP_TCP_FLAGS_3",
930 "PPE_DROP_CODE_EXP_TCP_FLAGS_4",
931 "PPE_DROP_CODE_EXP_TCP_FLAGS_5",
932 "PPE_DROP_CODE_EXP_TCP_FLAGS_6",
933 "PPE_DROP_CODE_EXP_TCP_FLAGS_7",
934 "PPE_DROP_CODE_EXP_TCP_CHECKSUM_ERR",
935 "PPE_DROP_CODE_EXP_UDP_HDR_INCOMPLETE",
936 "PPE_DROP_CODE_EXP_UDP_HDR_CROSS_BORDER",
937 "PPE_DROP_CODE_EXP_UDP_SMAE_SP_DP",
938 "PPE_DROP_CODE_EXP_UDP_BAD_LEN",
939 "PPE_DROP_CODE_EXP_UDP_DATA_INCOMPLETE",
940 "PPE_DROP_CODE_EXP_UDP_CHECKSUM_ERR",
941 "PPE_DROP_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",
942 "PPE_DROP_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER",
943 "PPE_DROP_CODE_EXP_UDP_LITE_SMAE_SP_DP",
944 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7",
945 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG",
946 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER",
947 "PPE_DROP_CODE_EXP_UDP_LITE_CHECKSUM_ERR",
948 "PPE_DROP_CODE_L3_MC_BRIDGE_ACTION",
949 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION",
950 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR",
951 "PPE_DROP_CODE_L3_ROUTE_ACTION",
952 "PPE_DROP_CODE_L3_NO_ROUTE_ACTION",
953 "PPE_DROP_CODE_L3_NO_ROUTE_NH_INVALID_ACTION",
954 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_ACTION",
955 "PPE_DROP_CODE_L3_BRIDGE_ACTION",
956 "PPE_DROP_CODE_L3_FLOW_ACTION",
957 "PPE_DROP_CODE_L3_FLOW_MISS_ACTION",
958 "PPE_DROP_CODE_L2_EXP_MRU_FAIL",
959 "PPE_DROP_CODE_L2_EXP_MTU_FAIL",
960 "PPE_DROP_CODE_L3_EXP_IP_PREFIX_BC",
961 "PPE_DROP_CODE_L3_EXP_MTU_FAIL",
962 "PPE_DROP_CODE_L3_EXP_MRU_FAIL",
963 "PPE_DROP_CODE_L3_EXP_ICMP_RDT",
964 "PPE_DROP_CODE_FAKE_MAC_HEADER_ERR",
965 "PPE_DROP_CODE_L3_EXP_IP_RT_TTL_ZERO",
966 "PPE_DROP_CODE_L3_FLOW_SERVICE_CODE_LOOP",
967 "PPE_DROP_CODE_L3_FLOW_DE_ACCELEARTE",
968 "PPE_DROP_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL",
969 "PPE_DROP_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",
970 "PPE_DROP_CODE_L3_EXP_MTU_DF_FAIL",
971 "PPE_DROP_CODE_L3_EXP_PPPOE_MULTICAST",
972 "PPE_DROP_CODE_IPV4_SG_UNKNOWN",
973 "PPE_DROP_CODE_IPV6_SG_UNKNOWN",
974 "PPE_DROP_CODE_ARP_SG_UNKNOWN",
975 "PPE_DROP_CODE_ND_SG_UNKNOWN",
976 "PPE_DROP_CODE_IPV4_SG_VIO",
977 "PPE_DROP_CODE_IPV6_SG_VIO",
978 "PPE_DROP_CODE_ARP_SG_VIO",
979 "PPE_DROP_CODE_ND_SG_VIO",
980 "PPE_DROP_CODE_L2_NEW_MAC_ADDRESS",
981 "PPE_DROP_CODE_L2_HASH_COLLISION",
982 "PPE_DROP_CODE_L2_STATION_MOVE",
983 "PPE_DROP_CODE_L2_LEARN_LIMIT",
984 "PPE_DROP_CODE_L2_SA_LOOKUP_ACTION",
985 "PPE_DROP_CODE_L2_DA_LOOKUP_ACTION",
986 "PPE_DROP_CODE_APP_CTRL_ACTION",
987 "PPE_DROP_CODE_IN_VLAN_FILTER_ACTION",
988 "PPE_DROP_CODE_IN_VLAN_XLT_MISS",
989 "PPE_DROP_CODE_EG_VLAN_FILTER_DROP",
990 "PPE_DROP_CODE_ACL_PRE_ACTION",
991 "PPE_DROP_CODE_ACL_POST_ACTION",
992 "PPE_DROP_CODE_MC_BC_SA",
993 "PPE_DROP_CODE_NO_DESTINATION",
994 "PPE_DROP_CODE_STG_IN_FILTER",
995 "PPE_DROP_CODE_STG_EG_FILTER",
996 "PPE_DROP_CODE_SOURCE_FILTER_FAIL",
997 "PPE_DROP_CODE_TRUNK_SEL_FAIL",
998 "PPE_DROP_CODE_TX_EN_FAIL",
999 "PPE_DROP_CODE_VLAN_TAG_FMT",
1000 "PPE_DROP_CODE_CRC_ERR",
1001 "PPE_DROP_CODE_PAUSE_FRAME",
1002 "PPE_DROP_CODE_PROMISC",
1003 "PPE_DROP_CODE_ISOLATION",
1004 "PPE_DROP_CODE_MGMT_APP",
1005 "PPE_DROP_CODE_FAKE_L2_PROT_ERR",
1006 "PPE_DROP_CODE_POLICER",
1007};
1008
1009/*
1010 * nss_stats_str_ppe_cc
1011 * PPE statistics strings for cpu code
1012 */
1013static int8_t *nss_stats_str_ppe_cc[NSS_STATS_PPE_CPU_CODE_MAX] = {
1014 "PPE_CPU_CODE_FORWARDING",
1015 "PPE_CPU_CODE_EXP_UNKNOWN_L2_PROT",
1016 "PPE_CPU_CODE_EXP_PPPOE_WRONG_VER_TYPE",
1017 "PPE_CPU_CODE_EXP_WRONG_CODE",
1018 "PPE_CPU_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",
1019 "PPE_CPU_CODE_EXP_WRONG_VER",
1020 "PPE_CPU_CODE_EXP_SMALL_IHL",
1021 "PPE_CPU_CODE_EXP_WITH_OPTION",
1022 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1023 "PPE_CPU_CODE_EXP_IPV4_BAD_TOTAL_LEN",
1024 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1025 "PPE_CPU_CODE_IPV4_FRAG",
1026 "PPE_CPU_CODE_EXP_IPV4_PING_OF_DEATH",
1027 "PPE_CPU_CODE_EXP_SNALL_TTL",
1028 "PPE_CPU_CODE_EXP_IPV4_UNK_IP_PROT",
1029 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1030 "PPE_CPU_CODE_EXP_INV_SIP",
1031 "PPE_CPU_CODE_EXP_INV_DIP",
1032 "PPE_CPU_CODE_EXP_LAND_ATTACK",
1033 "PPE_CPU_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",
1034 "PPE_CPU_CODE_EXP_IPV4_AH_CROSS_BORDER",
1035 "PPE_CPU_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",
1036 "PPE_CPU_CODE_EXP_WRONG_VER",
1037 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1038 "PPE_CPU_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",
1039 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1040 "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR",
1041 "PPE_CPU_CODE_EXP_IPV6_SMALL_HOP_LIMIT",
1042 "PPE_CPU_CODE_EXP_INV_SIP",
1043 "PPE_CPU_CODE_EXP_INV_DIP",
1044 "PPE_CPU_CODE_EXP_LAND_ATTACK",
1045 "PPE_CPU_CODE_IPV6_FRAG",
1046 "PPE_CPU_CODE_EXP_IPV6_PING_OF_DEATH",
1047 "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR",
1048 "PPE_CPU_CODE_EXP_IPV6_UNK_NEXT_HDR",
1049 "PPE_CPU_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",
1050 "PPE_CPU_CODE_EXP_IPV6_MOBILITY_CROSS_BORDER",
1051 "PPE_CPU_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",
1052 "PPE_CPU_CODE_EXP_IPV6_AH_CROSS_BORDER",
1053 "PPE_CPU_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",
1054 "PPE_CPU_CODE_EXP_IPV6_ESP_CROSS_BORDER",
1055 "PPE_CPU_CODE_EXP_IPV6_OTHER_HDR_INCOMPLETE",
1056 "PPE_CPU_CODE_EXP_IPV6_OTHER_EXT_CROSS_BORDER",
1057 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1058 "PPE_CPU_CODE_EXP_TCP_HDR_CROSS_BORDER",
1059 "PPE_CPU_CODE_EXP_TCP_SMAE_SP_DP",
1060 "PPE_CPU_CODE_EXP_TCP_SMALL_DATA_OFFSET",
1061 "PPE_CPU_CODE_EXP_FLAGS_0",
1062 "PPE_CPU_CODE_EXP_FLAGS_1",
1063 "PPE_CPU_CODE_EXP_FLAGS_2",
1064 "PPE_CPU_CODE_EXP_FLAGS_3",
1065 "PPE_CPU_CODE_EXP_FLAGS_4",
1066 "PPE_CPU_CODE_EXP_FLAGS_5",
1067 "PPE_CPU_CODE_EXP_FLAGS_6",
1068 "PPE_CPU_CODE_EXP_FLAGS_7",
1069 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1070 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1071 "PPE_CPU_CODE_EXP_UDP_HDR_CROSS_BORDER",
1072 "PPE_CPU_CODE_EXP_UDP_SMAE_SP_DP",
1073 "PPE_CPU_CODE_EXP_BAD_LEN",
1074 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1075 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1076 "PPE_CPU_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",
1077 "PPE_CPU_CODE_EXP_UDP_LITE_CROSS_BORDER",
1078 "PPE_CPU_CODE_EXP_UDP_LITE_SP_DP",
1079 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_COV_TO_7",
1080 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_TOO_LONG",
1081 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_CROSS_BORDER",
1082 "PPE_CPU_CODE_EXP_UDP_LITE_CHECKSUM_ERR",
1083 "PPE_CPU_CODE_EXP_FAKE_L2_PROT_ERR",
1084 "PPE_CPU_CODE_EXP_FAKE_MAC_HEADER_ERR",
1085 "PPE_CPU_CODE_BITMAP_MAX",
1086 "PPE_CPU_CODE_L2_MRU_FAIL",
1087 "PPE_CPU_CODE_L2_MTU_FAIL",
1088 "PPE_CPU_CODE_L3_EXP_IP_PREFIX_BC",
1089 "PPE_CPU_CODE_L3_MTU_FAIL",
1090 "PPE_CPU_CODE_L3_MRU_FAIL",
1091 "PPE_CPU_CODE_L3_ICMP_RDT",
1092 "PPE_CPU_CODE_L3_EXP_IP_RT_TO_ME",
1093 "PPE_CPU_CODE_L3_EXP_IP_TTL_ZERO",
1094 "PPE_CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP",
1095 "PPE_CPU_CODE_L3_DE_ACCELERATE",
1096 "PPE_CPU_CODE_L3_EXP_FLOW_SRC_CHK_FAIL",
1097 "PPE_CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",
1098 "PPE_CPU_CODE_L3_EXP_MTU_DF_FAIL",
1099 "PPE_CPU_CODE_L3_PPPOE_MULTICAST",
1100 "PPE_CPU_CODE_MGMT_OFFSET",
1101 "PPE_CPU_CODE_MGMT_EAPOL",
1102 "PPE_CPU_CODE_PPPOE_DIS",
1103 "PPE_CPU_CODE_MGMT_IGMP",
1104 "PPE_CPU_CODE_ARP_REQ",
1105 "PPE_CPU_CODE_ARP_REP",
1106 "PPE_CPU_CODE_MGMT_DHCPv4",
1107 "PPE_CPU_CODE_MGMT_MLD",
1108 "PPE_CPU_CODE_MGMT_NS",
1109 "PPE_CPU_CODE_MGMT_NA",
1110 "PPE_CPU_CODE_MGMT_DHCPv6",
1111 "PPE_CPU_CODE_PTP_OFFSET",
1112 "PPE_CPU_CODE_PTP_SYNC",
1113 "PPE_CPU_CODE_FOLLOW_UP",
1114 "PPE_CPU_CODE_DELAY_REQ",
1115 "PPE_CPU_CODE_DELAY_RESP",
1116 "PPE_CPU_CODE_PDELAY_REQ",
1117 "PPE_CPU_CODE_PDELAY_RESP",
1118 "PPE_CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP",
1119 "PPE_CPU_CODE_PTP_ANNOUNCE",
1120 "PPE_CPU_CODE_PTP_MANAGEMENT",
1121 "PPE_CPU_CODE_PTP_SIGNALING",
1122 "PPE_CPU_CODE_PTP_RSV_MSG",
1123 "PPE_CPU_CODE_SG_UNKNOWN",
1124 "PPE_CPU_CODE_SG_UNKNOWN",
1125 "PPE_CPU_CODE_SG_UNKNOWN",
1126 "PPE_CPU_CODE_SG_UNKNOWN",
1127 "PPE_CPU_CODE_SG_VIO",
1128 "PPE_CPU_CODE_SG_VIO",
1129 "PPE_CPU_CODE_SG_VIO",
1130 "PPE_CPU_CODE_SG_VIO",
1131 "PPE_CPU_CODE_L3_ROUTING_IP_TO_ME",
1132 "PPE_CPU_CODE_L3_SNAT_ACTION",
1133 "PPE_CPU_CODE_L3_DNAT_ACTION",
1134 "PPE_CPU_CODE_L3_RT_ACTION",
1135 "PPE_CPU_CODE_L3_BR_ACTION",
1136 "PPE_CPU_CODE_L3_BRIDGE_ACTION",
1137 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION",
1138 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION",
1139 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION",
1140 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION",
1141 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION",
1142 "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ACTION",
1143 "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ERROR",
1144 "PPE_CPU_CODE_ROUTE_ACTION",
1145 "PPE_CPU_CODE_L3_ROUTE_ACTION",
1146 "PPE_CPU_CODE_L3_NO_ROUTE_INVALID_ACTION",
1147 "PPE_CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION",
1148 "PPE_CPU_CODE_BRIDGE_ACTION",
1149 "PPE_CPU_CODE_FLOW_ACTION",
1150 "PPE_CPU_CODE_L3_MISS_ACTION",
1151 "PPE_CPU_CODE_L2_MAC_ADDRESS",
1152 "PPE_CPU_CODE_HASH_COLLISION",
1153 "PPE_CPU_CODE_STATION_MOVE",
1154 "PPE_CPU_CODE_LEARN_LIMIT",
1155 "PPE_CPU_CODE_L2_LOOKUP_ACTION",
1156 "PPE_CPU_CODE_L2_LOOKUP_ACTION",
1157 "PPE_CPU_CODE_CTRL_ACTION",
1158 "PPE_CPU_CODE_IN_FILTER_ACTION",
1159 "PPE_CPU_CODE_IN_XLT_MISS",
1160 "PPE_CPU_CODE_EG_FILTER_DROP",
1161 "PPE_CPU_CODE_PRE_ACTION",
1162 "PPE_CPU_CODE_POST_ACTION",
1163 "PPE_CPU_CODE_CODE_ACTION",
1164};
1165
1166/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05301167 * nss_stats_str_ppt_session_stats
1168 * PPTP statistics strings for nss session stats
1169 */
1170static int8_t *nss_stats_str_pptp_session_debug_stats[NSS_STATS_PPTP_SESSION_MAX] = {
Shyam Sundere351f1b2015-12-17 14:11:51 +05301171 "ENCAP_RX_PACKETS",
1172 "ENCAP_RX_BYTES",
1173 "ENCAP_TX_PACKETS",
1174 "ENCAP_TX_BYTES",
1175 "ENCAP_RX_DROP",
1176 "DECAP_RX_PACKETS",
1177 "DECAP_RX_BYTES",
1178 "DECAP_TX_PACKETS",
1179 "DECAP_TX_BYTES",
1180 "DECAP_RX_DROP",
1181 "ENCAP_HEADROOM_ERR",
1182 "ENCAP_SMALL_SIZE",
1183 "ENCAP_PNODE_ENQUEUE_FAIL",
1184 "DECAP_NO_SEQ_NOR_ACK",
1185 "DECAP_INVAL_GRE_FLAGS",
1186 "DECAP_INVAL_GRE_PROTO",
1187 "DECAP_WRONG_SEQ",
1188 "DECAP_INVAL_PPP_HDR",
1189 "DECAP_PPP_LCP",
1190 "DECAP_UNSUPPORTED_PPP_PROTO",
1191 "DECAP_PNODE_ENQUEUE_FAIL",
Shyam Sunder66e889d2015-11-02 15:31:20 +05301192};
1193
1194/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07001195 * nss_stats_str_trustsec_tx
1196 * Trustsec TX stats strings
1197 */
1198static int8_t *nss_stats_str_trustsec_tx[NSS_STATS_TRUSTSEC_TX_MAX] = {
1199 "INVALID_SRC",
1200 "UNCONFIGURED_SRC",
1201 "HEADROOM_NOT_ENOUGH",
1202};
1203
1204/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301205 * nss_stats_ipv4_read()
1206 * Read IPV4 stats
1207 */
1208static ssize_t nss_stats_ipv4_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1209{
1210 int32_t i;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301211 /*
1212 * max output lines = #stats + start tag line + end tag line + three blank lines
1213 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301214 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV4_MAX + 3) + (NSS_EXCEPTION_EVENT_IPV4_MAX + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301215 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1216 size_t size_wr = 0;
1217 ssize_t bytes_read = 0;
1218 uint64_t *stats_shadow;
1219
1220 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1221 if (unlikely(lbuf == NULL)) {
1222 nss_warning("Could not allocate memory for local statistics buffer");
1223 return 0;
1224 }
1225
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301226 /*
1227 * Note: The assumption here is that exception event count is larger than other statistics count for IPv4
1228 */
1229 stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV4_MAX * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301230 if (unlikely(stats_shadow == NULL)) {
1231 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301232 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301233 return 0;
1234 }
1235
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301236 size_wr = scnprintf(lbuf, size_al, "ipv4 stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301237
1238 /*
1239 * Common node stats
1240 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301241 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301242 spin_lock_bh(&nss_top_main.stats_lock);
1243 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1244 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_RX_INTERFACE][i];
1245 }
1246
1247 spin_unlock_bh(&nss_top_main.stats_lock);
1248
1249 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1250 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1251 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1252 }
1253
1254 /*
1255 * IPv4 node stats
1256 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301257 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301258
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301259 spin_lock_bh(&nss_top_main.stats_lock);
1260 for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) {
1261 stats_shadow[i] = nss_top_main.stats_ipv4[i];
1262 }
1263
1264 spin_unlock_bh(&nss_top_main.stats_lock);
1265
1266 for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) {
1267 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1268 "%s = %llu\n", nss_stats_str_ipv4[i], stats_shadow[i]);
1269 }
1270
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301271 /*
1272 * Exception stats
1273 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301274 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301275
1276 spin_lock_bh(&nss_top_main.stats_lock);
1277 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) {
1278 stats_shadow[i] = nss_top_main.stats_if_exception_ipv4[i];
1279 }
1280
1281 spin_unlock_bh(&nss_top_main.stats_lock);
1282
1283 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) {
1284 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1285 "%s = %llu\n", nss_stats_str_if_exception_ipv4[i], stats_shadow[i]);
1286 }
1287
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301288 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301289 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1290 kfree(lbuf);
1291 kfree(stats_shadow);
1292
1293 return bytes_read;
1294}
1295
1296/*
Selin Dag6d9b0c12014-11-04 18:27:21 -08001297 * nss_stats_ipv4_reasm_read()
1298 * Read IPV4 reassembly stats
1299 */
1300static ssize_t nss_stats_ipv4_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1301{
1302 int32_t i;
1303 /*
1304 * max output lines = #stats + start tag line + end tag line + three blank lines
1305 */
1306 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV4_REASM_MAX + 3) + 5;
1307 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1308 size_t size_wr = 0;
1309 ssize_t bytes_read = 0;
1310 uint64_t *stats_shadow;
1311
1312 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1313 if (unlikely(lbuf == NULL)) {
1314 nss_warning("Could not allocate memory for local statistics buffer");
1315 return 0;
1316 }
1317
1318 stats_shadow = kzalloc(NSS_STATS_IPV4_REASM_MAX * 8, GFP_KERNEL);
1319 if (unlikely(stats_shadow == NULL)) {
1320 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301321 kfree(lbuf);
Selin Dag6d9b0c12014-11-04 18:27:21 -08001322 return 0;
1323 }
1324
1325 size_wr = scnprintf(lbuf, size_al, "ipv4 reasm stats start:\n\n");
1326
1327 /*
1328 * Common node stats
1329 */
1330 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
1331 spin_lock_bh(&nss_top_main.stats_lock);
1332 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1333 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_REASM_INTERFACE][i];
1334 }
1335
1336 spin_unlock_bh(&nss_top_main.stats_lock);
1337
1338 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1339 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1340 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1341 }
1342
1343 /*
1344 * IPv4 reasm node stats
1345 */
1346 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm node stats:\n\n");
1347
1348 spin_lock_bh(&nss_top_main.stats_lock);
1349 for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) {
1350 stats_shadow[i] = nss_top_main.stats_ipv4_reasm[i];
1351 }
1352
1353 spin_unlock_bh(&nss_top_main.stats_lock);
1354
1355 for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) {
1356 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1357 "%s = %llu\n", nss_stats_str_ipv4_reasm[i], stats_shadow[i]);
1358 }
1359
1360 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm stats end\n\n");
1361 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1362 kfree(lbuf);
1363 kfree(stats_shadow);
1364
1365 return bytes_read;
1366}
1367
1368/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301369 * nss_stats_ipv6_read()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301370 * Read IPV6 stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301371 */
1372static ssize_t nss_stats_ipv6_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1373{
1374 int32_t i;
1375
1376 /*
1377 * max output lines = #stats + start tag line + end tag line + three blank lines
1378 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301379 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV6_MAX + 3) + (NSS_EXCEPTION_EVENT_IPV6_MAX + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301380 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1381 size_t size_wr = 0;
1382 ssize_t bytes_read = 0;
1383 uint64_t *stats_shadow;
1384
1385 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1386 if (unlikely(lbuf == NULL)) {
1387 nss_warning("Could not allocate memory for local statistics buffer");
1388 return 0;
1389 }
1390
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301391 /*
1392 * Note: The assumption here is that exception event count is larger than other statistics count for IPv4
1393 */
1394 stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV6_MAX * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301395 if (unlikely(stats_shadow == NULL)) {
1396 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301397 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301398 return 0;
1399 }
1400
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301401 size_wr = scnprintf(lbuf, size_al, "ipv6 stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301402
1403 /*
1404 * Common node stats
1405 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301406 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301407 spin_lock_bh(&nss_top_main.stats_lock);
1408 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1409 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_RX_INTERFACE][i];
1410 }
1411
1412 spin_unlock_bh(&nss_top_main.stats_lock);
1413
1414 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1415 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1416 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1417 }
1418
1419 /*
1420 * IPv6 node stats
1421 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301422 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301423
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301424 spin_lock_bh(&nss_top_main.stats_lock);
1425 for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) {
1426 stats_shadow[i] = nss_top_main.stats_ipv6[i];
1427 }
1428
1429 spin_unlock_bh(&nss_top_main.stats_lock);
1430
1431 for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) {
1432 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1433 "%s = %llu\n", nss_stats_str_ipv6[i], stats_shadow[i]);
1434 }
1435
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301436 /*
1437 * Exception stats
1438 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301439 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301440
1441 spin_lock_bh(&nss_top_main.stats_lock);
1442 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) {
1443 stats_shadow[i] = nss_top_main.stats_if_exception_ipv6[i];
1444 }
1445
1446 spin_unlock_bh(&nss_top_main.stats_lock);
1447
1448 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) {
1449 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1450 "%s = %llu\n", nss_stats_str_if_exception_ipv6[i], stats_shadow[i]);
1451 }
1452
Aniruddha Paul1b170c22017-05-29 12:30:39 +05301453 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301454 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1455 kfree(lbuf);
1456 kfree(stats_shadow);
1457
1458 return bytes_read;
1459}
1460
1461/*
Selin Dag60a2f5b2015-06-29 14:39:49 -07001462 * nss_stats_ipv6_reasm_read()
1463 * Read IPV6 reassembly stats
1464 */
1465static ssize_t nss_stats_ipv6_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1466{
1467 int32_t i;
1468 /*
1469 * max output lines = #stats + start tag line + end tag line + three blank lines
1470 */
1471 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV6_REASM_MAX + 3) + 5;
1472 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1473 size_t size_wr = 0;
1474 ssize_t bytes_read = 0;
1475 uint64_t *stats_shadow;
1476
1477 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1478 if (unlikely(lbuf == NULL)) {
1479 nss_warning("Could not allocate memory for local statistics buffer");
1480 return 0;
1481 }
1482
1483 stats_shadow = kzalloc(NSS_STATS_IPV6_REASM_MAX * 8, GFP_KERNEL);
1484 if (unlikely(stats_shadow == NULL)) {
1485 nss_warning("Could not allocate memory for local shadow buffer");
1486 kfree(lbuf);
1487 return 0;
1488 }
1489
1490 size_wr = scnprintf(lbuf, size_al, "ipv6 reasm stats start:\n\n");
1491
1492 /*
1493 * Common node stats
1494 */
1495 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
1496 spin_lock_bh(&nss_top_main.stats_lock);
1497 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1498 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_REASM_INTERFACE][i];
1499 }
1500
1501 spin_unlock_bh(&nss_top_main.stats_lock);
1502
1503 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1504 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1505 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1506 }
1507
1508 /*
1509 * Ipv6 reasm node stats
1510 */
1511 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm node stats:\n\n");
1512
1513 spin_lock_bh(&nss_top_main.stats_lock);
1514 for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) {
1515 stats_shadow[i] = nss_top_main.stats_ipv6_reasm[i];
1516 }
1517
1518 spin_unlock_bh(&nss_top_main.stats_lock);
1519
1520 for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) {
1521 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1522 "%s = %llu\n", nss_stats_str_ipv6_reasm[i], stats_shadow[i]);
1523 }
1524
1525 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm stats end\n\n");
1526 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1527 kfree(lbuf);
1528 kfree(stats_shadow);
1529
1530 return bytes_read;
1531}
1532
1533/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07001534 * nss_stats_edma_port_stats_read()
1535 * Read EDMA port stats
1536 */
1537static ssize_t nss_stats_edma_port_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1538{
1539 int32_t i;
1540
1541 /*
1542 * max output lines = #stats + start tag line + end tag line + three blank lines
1543 */
1544 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + 3;
1545 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1546 size_t size_wr = 0;
1547 ssize_t bytes_read = 0;
1548 uint64_t *stats_shadow;
1549 struct nss_stats_data *data = fp->private_data;
1550
1551 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1552 if (unlikely(lbuf == NULL)) {
1553 nss_warning("Could not allocate memory for local statistics buffer");
1554 return 0;
1555 }
1556
1557 /*
1558 * Note: The assumption here is that we do not have more than 64 stats
1559 */
1560 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1561 if (unlikely(stats_shadow == NULL)) {
1562 nss_warning("Could not allocate memory for local shadow buffer");
1563 kfree(lbuf);
1564 return 0;
1565 }
1566
1567 size_wr = scnprintf(lbuf, size_al, "edma stats start:\n\n");
1568
1569 /*
1570 * Common node stats
1571 */
1572 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d stats:\n\n", data->edma_id);
1573 spin_lock_bh(&nss_top_main.stats_lock);
1574 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1575 stats_shadow[i] = nss_top_main.stats_edma.port[data->edma_id].port_stats[i];
1576 }
1577
1578 spin_unlock_bh(&nss_top_main.stats_lock);
1579
1580 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1581 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1582 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1583 }
1584
1585 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n\n");
1586 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1587 kfree(lbuf);
1588 kfree(stats_shadow);
1589
1590 return bytes_read;
1591}
1592
1593/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07001594 * nss_stats_edma_err_stats_read()
1595 * Read EDMA err stats
1596 */
1597static ssize_t nss_stats_edma_err_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1598{
1599 int32_t i;
1600
1601 /*
1602 * max output lines = #stats + start tag line + end tag line + three blank lines
1603 */
1604 uint32_t max_output_lines = (NSS_EDMA_ERR_STATS_MAX + 2) + 3;
1605 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1606 size_t size_wr = 0;
1607 ssize_t bytes_read = 0;
1608 uint64_t *stats_shadow;
1609
1610 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1611 if (unlikely(lbuf == NULL)) {
1612 nss_warning("Could not allocate memory for local statistics buffer");
1613 return 0;
1614 }
1615
1616 /*
1617 * Note: The assumption here is that we do not have more than 64 stats
1618 */
1619 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1620 if (unlikely(stats_shadow == NULL)) {
1621 nss_warning("Could not allocate memory for local shadow buffer");
1622 kfree(lbuf);
1623 return 0;
1624 }
1625
1626 size_wr = scnprintf(lbuf, size_al, "edma error stats start:\n\n");
1627
1628 /*
1629 * Common node stats
1630 */
1631 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma error stats:\n\n");
1632 spin_lock_bh(&nss_top_main.stats_lock);
1633
1634 for (i = 0; (i < NSS_EDMA_ERR_STATS_MAX); i++)
1635 stats_shadow[i] = nss_top_main.stats_edma.misc_err[i];
1636
1637 spin_unlock_bh(&nss_top_main.stats_lock);
1638
1639 for (i = 0; (i < NSS_EDMA_ERR_STATS_MAX); i++) {
1640 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1641 "%s = %llu\n", nss_stats_str_edma_err_map[i], stats_shadow[i]);
1642 }
1643
1644 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma error stats end\n\n");
1645 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1646 kfree(lbuf);
1647 kfree(stats_shadow);
1648
1649 return bytes_read;
1650}
1651
1652/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07001653 * nss_stats_edma_port_type_read()
1654 * Read EDMA port type
1655 */
1656static ssize_t nss_stats_edma_port_type_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1657{
Shashank Balashankar512cb602016-08-01 17:57:42 -07001658 /*
1659 * max output lines = #stats + start tag line + end tag line + three blank lines
1660 */
1661 uint32_t max_output_lines = (1 + 2) + 3;
1662 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1663 size_t size_wr = 0;
1664 ssize_t bytes_read = 0;
1665 uint64_t port_type;
1666 struct nss_stats_data *data = fp->private_data;
1667
1668 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1669 if (unlikely(lbuf == NULL)) {
1670 nss_warning("Could not allocate memory for local statistics buffer");
1671 return 0;
1672 }
1673
1674 size_wr = scnprintf(lbuf, size_al, "edma port type start:\n\n");
1675 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d type:\n\n", data->edma_id);
1676
1677 /*
1678 * Port type
1679 */
1680 spin_lock_bh(&nss_top_main.stats_lock);
1681 port_type = nss_top_main.stats_edma.port[data->edma_id].port_type;
1682 spin_unlock_bh(&nss_top_main.stats_lock);
1683
1684 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1685 "port_type = %s\n", nss_stats_str_edma_port_type[port_type]);
1686
1687 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n");
1688 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1689 kfree(lbuf);
1690
1691 return bytes_read;
1692}
1693
1694/*
1695 * nss_stats_edma_port_ring_map_read()
1696 * Read EDMA port ring map
1697 */
1698static ssize_t nss_stats_edma_port_ring_map_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1699{
1700 int32_t i;
1701
1702 /*
1703 * max output lines = #stats + start tag line + end tag line + three blank lines
1704 */
1705 uint32_t max_output_lines = (4 + 2) + 3;
1706 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1707 size_t size_wr = 0;
1708 ssize_t bytes_read = 0;
1709 uint64_t *stats_shadow;
1710 struct nss_stats_data *data = fp->private_data;
1711
1712 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1713 if (unlikely(lbuf == NULL)) {
1714 nss_warning("Could not allocate memory for local statistics buffer");
1715 return 0;
1716 }
1717
1718 /*
1719 * Note: The assumption here is that we do not have more than 64 stats
1720 */
1721 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1722 if (unlikely(stats_shadow == NULL)) {
1723 nss_warning("Could not allocate memory for local shadow buffer");
1724 kfree(lbuf);
1725 return 0;
1726 }
1727
1728 size_wr = scnprintf(lbuf, size_al, "edma port ring map start:\n\n");
1729
1730 /*
1731 * Port ring map
1732 */
1733 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d ring map:\n\n", data->edma_id);
1734 spin_lock_bh(&nss_top_main.stats_lock);
1735 for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) {
1736 stats_shadow[i] = nss_top_main.stats_edma.port[data->edma_id].port_ring_map[i];
1737 }
1738
1739 spin_unlock_bh(&nss_top_main.stats_lock);
1740
1741 for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) {
1742 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1743 "%s = %llu\n", nss_stats_str_edma_port_ring_map[i], stats_shadow[i]);
1744 }
1745
1746 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n\n");
1747 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1748 kfree(lbuf);
1749 kfree(stats_shadow);
1750
1751 return bytes_read;
1752}
1753
1754/*
1755 * nss_stats_edma_txring_read()
1756 * Read EDMA Tx ring stats
1757 */
1758static ssize_t nss_stats_edma_txring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1759{
1760 int32_t i;
1761
1762 /*
1763 * max output lines = #stats + start tag line + end tag line + three blank lines
1764 */
1765 uint32_t max_output_lines = (NSS_STATS_EDMA_TX_MAX + 2) + 3;
1766 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1767 size_t size_wr = 0;
1768 ssize_t bytes_read = 0;
1769 uint64_t *stats_shadow;
1770 struct nss_stats_data *data = fp->private_data;
1771
1772 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1773 if (unlikely(lbuf == NULL)) {
1774 nss_warning("Could not allocate memory for local statistics buffer");
1775 return 0;
1776 }
1777
1778 /*
1779 * Note: The assumption here is that we do not have more than 64 stats
1780 */
1781 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1782 if (unlikely(stats_shadow == NULL)) {
1783 nss_warning("Could not allocate memory for local shadow buffer");
1784 kfree(lbuf);
1785 return 0;
1786 }
1787
1788 size_wr = scnprintf(lbuf, size_al, "edma Tx ring stats start:\n\n");
1789
1790 /*
1791 * Tx ring stats
1792 */
1793 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx ring %d stats:\n\n", data->edma_id);
1794 spin_lock_bh(&nss_top_main.stats_lock);
1795 for (i = 0; i < NSS_STATS_EDMA_TX_MAX; i++) {
1796 stats_shadow[i] = nss_top_main.stats_edma.tx_stats[data->edma_id][i];
1797 }
1798
1799 spin_unlock_bh(&nss_top_main.stats_lock);
1800
1801 for (i = 0; i < NSS_STATS_EDMA_TX_MAX; i++) {
1802 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1803 "%s = %llu\n", nss_stats_str_edma_tx[i], stats_shadow[i]);
1804 }
1805
1806 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx ring stats end\n\n");
1807 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1808 kfree(lbuf);
1809 kfree(stats_shadow);
1810
1811 return bytes_read;
1812}
1813
1814/*
1815 * nss_stats_edma_rxring_read()
1816 * Read EDMA rxring stats
1817 */
1818static ssize_t nss_stats_edma_rxring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1819{
1820 int32_t i;
1821
1822 /*
1823 * max output lines = #stats + start tag line + end tag line + three blank lines
1824 */
1825 uint32_t max_output_lines = (NSS_STATS_EDMA_RX_MAX + 2) + 3;
1826 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1827 size_t size_wr = 0;
1828 ssize_t bytes_read = 0;
1829 uint64_t *stats_shadow;
1830 struct nss_stats_data *data = fp->private_data;
1831
1832 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1833 if (unlikely(lbuf == NULL)) {
1834 nss_warning("Could not allocate memory for local statistics buffer");
1835 return 0;
1836 }
1837
1838 /*
1839 * Note: The assumption here is that we do not have more than 64 stats
1840 */
1841 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1842 if (unlikely(stats_shadow == NULL)) {
1843 nss_warning("Could not allocate memory for local shadow buffer");
1844 kfree(lbuf);
1845 return 0;
1846 }
1847
1848 size_wr = scnprintf(lbuf, size_al, "edma Rx ring stats start:\n\n");
1849
1850 /*
1851 * RX ring stats
1852 */
1853 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx ring %d stats:\n\n", data->edma_id);
1854 spin_lock_bh(&nss_top_main.stats_lock);
1855 for (i = 0; i < NSS_STATS_EDMA_RX_MAX; i++) {
1856 stats_shadow[i] = nss_top_main.stats_edma.rx_stats[data->edma_id][i];
1857 }
1858
1859 spin_unlock_bh(&nss_top_main.stats_lock);
1860
1861 for (i = 0; i < NSS_STATS_EDMA_RX_MAX; i++) {
1862 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1863 "%s = %llu\n", nss_stats_str_edma_rx[i], stats_shadow[i]);
1864 }
1865
1866 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Rx ring stats end\n\n");
1867 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1868 kfree(lbuf);
1869 kfree(stats_shadow);
1870
1871 return bytes_read;
1872}
1873
1874/*
1875 * nss_stats_edma_txcmplring_read()
1876 * Read EDMA txcmplring stats
1877 */
1878static ssize_t nss_stats_edma_txcmplring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1879{
1880 int32_t i;
1881
1882 /*
1883 * max output lines = #stats + start tag line + end tag line + three blank lines
1884 */
1885 uint32_t max_output_lines = (NSS_STATS_EDMA_TXCMPL_MAX + 2) + 3;
1886 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1887 size_t size_wr = 0;
1888 ssize_t bytes_read = 0;
1889 uint64_t *stats_shadow;
1890 struct nss_stats_data *data = fp->private_data;
1891
1892 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1893 if (unlikely(lbuf == NULL)) {
1894 nss_warning("Could not allocate memory for local statistics buffer");
1895 return 0;
1896 }
1897
1898 /*
1899 * Note: The assumption here is that we do not have more than 64 stats
1900 */
1901 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1902 if (unlikely(stats_shadow == NULL)) {
1903 nss_warning("Could not allocate memory for local shadow buffer");
1904 kfree(lbuf);
1905 return 0;
1906 }
1907
1908 size_wr = scnprintf(lbuf, size_al, "edma Tx cmpl ring stats start:\n\n");
1909
1910 /*
1911 * Tx cmpl ring stats
1912 */
1913 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx cmpl ring %d stats:\n\n", data->edma_id);
1914 spin_lock_bh(&nss_top_main.stats_lock);
1915 for (i = 0; i < NSS_STATS_EDMA_TXCMPL_MAX; i++) {
1916 stats_shadow[i] = nss_top_main.stats_edma.txcmpl_stats[data->edma_id][i];
1917 }
1918
1919 spin_unlock_bh(&nss_top_main.stats_lock);
1920
1921 for (i = 0; i < NSS_STATS_EDMA_TXCMPL_MAX; i++) {
1922 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1923 "%s = %llu\n", nss_stats_str_edma_txcmpl[i], stats_shadow[i]);
1924 }
1925
1926 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx cmpl ring stats end\n\n");
1927 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1928 kfree(lbuf);
1929 kfree(stats_shadow);
1930
1931 return bytes_read;
1932}
1933
1934/*
1935 * nss_stats_edma_rxfillring_read()
1936 * Read EDMA rxfillring stats
1937 */
1938static ssize_t nss_stats_edma_rxfillring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1939{
1940 int32_t i;
1941
1942 /*
1943 * max output lines = #stats + start tag line + end tag line + three blank lines
1944 */
1945 uint32_t max_output_lines = (NSS_STATS_EDMA_RXFILL_MAX + 2) + 3;
1946 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1947 size_t size_wr = 0;
1948 ssize_t bytes_read = 0;
1949 uint64_t *stats_shadow;
1950 struct nss_stats_data *data = fp->private_data;
1951
1952 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1953 if (unlikely(lbuf == NULL)) {
1954 nss_warning("Could not allocate memory for local statistics buffer");
1955 return 0;
1956 }
1957
1958 /*
1959 * Note: The assumption here is that we do not have more than 64 stats
1960 */
1961 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1962 if (unlikely(stats_shadow == NULL)) {
1963 nss_warning("Could not allocate memory for local shadow buffer");
1964 kfree(lbuf);
1965 return 0;
1966 }
1967
1968 size_wr = scnprintf(lbuf, size_al, "edma Rx fill ring stats start:\n\n");
1969
1970 /*
1971 * Rx fill ring stats
1972 */
1973 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx fill ring %d stats:\n\n", data->edma_id);
1974 spin_lock_bh(&nss_top_main.stats_lock);
1975 for (i = 0; i < NSS_STATS_EDMA_RXFILL_MAX; i++) {
1976 stats_shadow[i] = nss_top_main.stats_edma.rxfill_stats[data->edma_id][i];
1977 }
1978
1979 spin_unlock_bh(&nss_top_main.stats_lock);
1980
1981 for (i = 0; i < NSS_STATS_EDMA_RXFILL_MAX; i++) {
1982 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1983 "%s = %llu\n", nss_stats_str_edma_rxfill[i], stats_shadow[i]);
1984 }
1985
1986 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Rx fill ring stats end\n\n");
1987 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1988 kfree(lbuf);
1989 kfree(stats_shadow);
1990
1991 return bytes_read;
1992}
1993
1994/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301995 * nss_stats_eth_rx_read()
1996 * Read ETH_RX stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301997 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301998static ssize_t nss_stats_eth_rx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301999{
2000 int32_t i;
2001
2002 /*
2003 * max output lines = #stats + start tag line + end tag line + three blank lines
2004 */
Murat Sezgin99dab642014-08-28 14:40:34 -07002005 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_ETH_RX_MAX + 3) + (NSS_EXCEPTION_EVENT_ETH_RX_MAX + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302006 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2007 size_t size_wr = 0;
2008 ssize_t bytes_read = 0;
2009 uint64_t *stats_shadow;
2010
2011 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2012 if (unlikely(lbuf == NULL)) {
2013 nss_warning("Could not allocate memory for local statistics buffer");
2014 return 0;
2015 }
2016
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302017 /*
2018 * Note: The assumption here is that we do not have more than 64 stats
2019 */
2020 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302021 if (unlikely(stats_shadow == NULL)) {
2022 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302023 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302024 return 0;
2025 }
2026
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302027 size_wr = scnprintf(lbuf, size_al, "eth_rx stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302028
2029 /*
2030 * Common node stats
2031 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302032 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302033 spin_lock_bh(&nss_top_main.stats_lock);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302034 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2035 stats_shadow[i] = nss_top_main.stats_node[NSS_ETH_RX_INTERFACE][i];
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302036 }
2037
2038 spin_unlock_bh(&nss_top_main.stats_lock);
2039
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302040 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302041 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302042 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302043 }
2044
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302045 /*
Murat Sezgin99dab642014-08-28 14:40:34 -07002046 * eth_rx node stats
2047 */
2048 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx node stats:\n\n");
2049 spin_lock_bh(&nss_top_main.stats_lock);
2050 for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) {
2051 stats_shadow[i] = nss_top_main.stats_eth_rx[i];
2052 }
2053
2054 spin_unlock_bh(&nss_top_main.stats_lock);
2055
2056 for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) {
2057 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2058 "%s = %llu\n", nss_stats_str_eth_rx[i], stats_shadow[i]);
2059 }
2060
2061 /*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302062 * Exception stats
2063 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302064 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302065
2066 spin_lock_bh(&nss_top_main.stats_lock);
2067 for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) {
2068 stats_shadow[i] = nss_top_main.stats_if_exception_eth_rx[i];
2069 }
2070
2071 spin_unlock_bh(&nss_top_main.stats_lock);
2072
2073 for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) {
2074 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2075 "%s = %llu\n", nss_stats_str_if_exception_eth_rx[i], stats_shadow[i]);
2076 }
2077
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302078 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302079 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2080 kfree(lbuf);
2081 kfree(stats_shadow);
2082
2083 return bytes_read;
2084}
2085
2086/*
2087 * nss_stats_n2h_read()
2088 * Read N2H stats
2089 */
2090static ssize_t nss_stats_n2h_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2091{
2092 int32_t i;
2093
2094 /*
2095 * max output lines = #stats + start tag line + end tag line + three blank lines
2096 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302097 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_N2H_MAX + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302098 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2099 size_t size_wr = 0;
2100 ssize_t bytes_read = 0;
2101 uint64_t *stats_shadow;
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002102 int max = NSS_STATS_N2H_MAX - NSS_STATS_NODE_MAX;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302103
2104 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2105 if (unlikely(lbuf == NULL)) {
2106 nss_warning("Could not allocate memory for local statistics buffer");
2107 return 0;
2108 }
2109
2110 stats_shadow = kzalloc(NSS_STATS_N2H_MAX * 8, GFP_KERNEL);
2111 if (unlikely(stats_shadow == NULL)) {
2112 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302113 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302114 return 0;
2115 }
2116
2117 size_wr = scnprintf(lbuf, size_al, "n2h stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302118
2119 /*
2120 * Common node stats
2121 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302122 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302123 spin_lock_bh(&nss_top_main.stats_lock);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302124 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2125 stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i];
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302126 }
2127
2128 spin_unlock_bh(&nss_top_main.stats_lock);
2129
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302130 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2131 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2132 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2133 }
2134
2135 /*
2136 * N2H node stats
2137 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302138 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302139 spin_lock_bh(&nss_top_main.stats_lock);
2140 for (i = NSS_STATS_NODE_MAX; (i < NSS_STATS_N2H_MAX); i++) {
2141 stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i];
2142 }
2143
2144 spin_unlock_bh(&nss_top_main.stats_lock);
2145
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002146 for (i = 0; i < max; i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302147 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002148 "%s = %llu\n", nss_stats_str_n2h[i], stats_shadow[i + NSS_STATS_NODE_MAX]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302149 }
2150
2151 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h stats end\n\n");
2152 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2153 kfree(lbuf);
2154 kfree(stats_shadow);
2155
2156 return bytes_read;
2157}
2158
2159/*
Thomas Wuc3e382c2014-10-29 15:35:13 -07002160 * nss_stats_lso_rx_read()
2161 * Read LSO_RX stats
2162 */
2163static ssize_t nss_stats_lso_rx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2164{
2165 int32_t i;
2166
2167 /*
2168 * max output lines = #stats + start tag line + end tag line + three blank lines
2169 */
2170 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_LSO_RX_MAX + 3) + 5;
2171 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2172 size_t size_wr = 0;
2173 ssize_t bytes_read = 0;
2174 uint64_t *stats_shadow;
2175
2176 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2177 if (unlikely(lbuf == NULL)) {
2178 nss_warning("Could not allocate memory for local statistics buffer");
2179 return 0;
2180 }
2181
2182 stats_shadow = kzalloc(NSS_STATS_LSO_RX_MAX * 8, GFP_KERNEL);
2183 if (unlikely(stats_shadow == NULL)) {
2184 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302185 kfree(lbuf);
Thomas Wuc3e382c2014-10-29 15:35:13 -07002186 return 0;
2187 }
2188
2189 size_wr = scnprintf(lbuf, size_al, "lso_rx stats start:\n\n");
2190
2191 /*
2192 * Common node stats
2193 */
2194 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
2195 spin_lock_bh(&nss_top_main.stats_lock);
2196 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2197 stats_shadow[i] = nss_top_main.stats_node[NSS_LSO_RX_INTERFACE][i];
2198 }
2199
2200 spin_unlock_bh(&nss_top_main.stats_lock);
2201
2202 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2203 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2204 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2205 }
2206
2207 /*
2208 * lso_rx node stats
2209 */
2210 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx node stats:\n\n");
2211 spin_lock_bh(&nss_top_main.stats_lock);
2212 for (i = 0; (i < NSS_STATS_LSO_RX_MAX); i++) {
2213 stats_shadow[i] = nss_top_main.stats_lso_rx[i];
2214 }
2215
2216 spin_unlock_bh(&nss_top_main.stats_lock);
2217
2218 for (i = 0; i < NSS_STATS_LSO_RX_MAX; i++) {
2219 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2220 "%s = %llu\n", nss_stats_str_lso_rx[i], stats_shadow[i]);
2221 }
2222
2223 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx stats end\n\n");
2224 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2225 kfree(lbuf);
2226 kfree(stats_shadow);
2227
2228 return bytes_read;
2229}
2230
2231/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302232 * nss_stats_drv_read()
2233 * Read HLOS driver stats
2234 */
2235static ssize_t nss_stats_drv_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2236{
2237 int32_t i;
2238
2239 /*
2240 * max output lines = #stats + start tag line + end tag line + three blank lines
2241 */
2242 uint32_t max_output_lines = NSS_STATS_DRV_MAX + 5;
2243 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2244 size_t size_wr = 0;
2245 ssize_t bytes_read = 0;
2246 uint64_t *stats_shadow;
2247
2248 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2249 if (unlikely(lbuf == NULL)) {
2250 nss_warning("Could not allocate memory for local statistics buffer");
2251 return 0;
2252 }
2253
2254 stats_shadow = kzalloc(NSS_STATS_DRV_MAX * 8, GFP_KERNEL);
2255 if (unlikely(stats_shadow == NULL)) {
2256 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302257 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302258 return 0;
2259 }
2260
2261 size_wr = scnprintf(lbuf, size_al, "drv stats start:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302262 for (i = 0; (i < NSS_STATS_DRV_MAX); i++) {
Sundarajan Srinivasan62fee7e2015-01-22 11:13:10 -08002263 stats_shadow[i] = NSS_PKT_STATS_READ(&nss_top_main.stats_drv[i]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302264 }
2265
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302266 for (i = 0; (i < NSS_STATS_DRV_MAX); i++) {
2267 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2268 "%s = %llu\n", nss_stats_str_drv[i], stats_shadow[i]);
2269 }
2270
2271 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ndrv stats end\n\n");
2272 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2273 kfree(lbuf);
2274 kfree(stats_shadow);
2275
2276 return bytes_read;
2277}
2278
2279/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302280 * nss_stats_pppoe_read()
2281 * Read PPPoE stats
2282 */
2283static ssize_t nss_stats_pppoe_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2284{
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302285 int32_t i, j, k;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302286
2287 /*
2288 * max output lines = #stats + start tag line + end tag line + three blank lines
2289 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302290 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_PPPOE_MAX + 3) +
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302291 ((NSS_MAX_PHYSICAL_INTERFACES * NSS_PPPOE_NUM_SESSION_PER_INTERFACE * (NSS_PPPOE_EXCEPTION_EVENT_MAX + 5)) + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302292 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2293 size_t size_wr = 0;
2294 ssize_t bytes_read = 0;
2295 uint64_t *stats_shadow;
2296
2297 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2298 if (unlikely(lbuf == NULL)) {
2299 nss_warning("Could not allocate memory for local statistics buffer");
2300 return 0;
2301 }
2302
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302303 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302304 if (unlikely(stats_shadow == NULL)) {
2305 nss_warning("Could not allocate memory for local shadow buffer");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302306 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302307 return 0;
2308 }
2309
2310 size_wr = scnprintf(lbuf, size_al, "pppoe stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302311
2312 /*
2313 * Common node stats
2314 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302315 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302316 spin_lock_bh(&nss_top_main.stats_lock);
2317 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2318 stats_shadow[i] = nss_top_main.stats_node[NSS_PPPOE_RX_INTERFACE][i];
2319 }
2320
2321 spin_unlock_bh(&nss_top_main.stats_lock);
2322
2323 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2324 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2325 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2326 }
2327
2328 /*
2329 * PPPoE node stats
2330 */
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002331 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npppoe node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302332 spin_lock_bh(&nss_top_main.stats_lock);
2333 for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) {
2334 stats_shadow[i] = nss_top_main.stats_pppoe[i];
2335 }
2336
2337 spin_unlock_bh(&nss_top_main.stats_lock);
2338
2339 for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) {
2340 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2341 "%s = %llu\n", nss_stats_str_pppoe[i], stats_shadow[i]);
2342 }
2343
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302344 /*
2345 * Exception stats
2346 */
2347 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nException PPPoE:\n\n");
2348
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002349 for (j = 1; j <= NSS_MAX_PHYSICAL_INTERFACES; j++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302350 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nInterface %d:\n\n", j);
2351
2352 spin_lock_bh(&nss_top_main.stats_lock);
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002353 for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) {
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302354 for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) {
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002355 stats_shadow_pppoe_except[k - 1][i] = nss_top_main.stats_if_exception_pppoe[j][k][i];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302356 }
2357 }
2358
2359 spin_unlock_bh(&nss_top_main.stats_lock);
2360
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002361 for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302362 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. Session\n", k);
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302363 for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302364 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2365 "%s = %llu\n",
2366 nss_stats_str_if_exception_pppoe[i],
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002367 stats_shadow_pppoe_except[k - 1][i]);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302368 }
2369 }
2370
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302371 }
2372
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002373 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npppoe stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302374 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2375 kfree(lbuf);
2376 kfree(stats_shadow);
2377
2378 return bytes_read;
2379}
2380
2381/*
2382 * nss_stats_gmac_read()
2383 * Read GMAC stats
2384 */
2385static ssize_t nss_stats_gmac_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2386{
2387 uint32_t i, id;
2388
2389 /*
2390 * max output lines = ((#stats + start tag + one blank) * #GMACs) + start/end tag + 3 blank
2391 */
2392 uint32_t max_output_lines = ((NSS_STATS_GMAC_MAX + 2) * NSS_MAX_PHYSICAL_INTERFACES) + 5;
2393 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2394 size_t size_wr = 0;
2395 ssize_t bytes_read = 0;
2396 uint64_t *stats_shadow;
2397
2398 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2399 if (unlikely(lbuf == NULL)) {
2400 nss_warning("Could not allocate memory for local statistics buffer");
2401 return 0;
2402 }
2403
2404 stats_shadow = kzalloc(NSS_STATS_GMAC_MAX * 8, GFP_KERNEL);
2405 if (unlikely(stats_shadow == NULL)) {
2406 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302407 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302408 return 0;
2409 }
2410
2411 size_wr = scnprintf(lbuf, size_al, "gmac stats start:\n\n");
2412
2413 for (id = 0; id < NSS_MAX_PHYSICAL_INTERFACES; id++) {
2414 spin_lock_bh(&nss_top_main.stats_lock);
2415 for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) {
2416 stats_shadow[i] = nss_top_main.stats_gmac[id][i];
2417 }
2418
2419 spin_unlock_bh(&nss_top_main.stats_lock);
2420
2421 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "GMAC ID: %d\n", id);
2422 for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) {
2423 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2424 "%s = %llu\n", nss_stats_str_gmac[i], stats_shadow[i]);
2425 }
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302426 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302427 }
2428
2429 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngmac stats end\n\n");
2430 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2431 kfree(lbuf);
2432 kfree(stats_shadow);
2433
2434 return bytes_read;
2435}
2436
Saurabh Misra09dddeb2014-09-30 16:38:07 -07002437/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05302438 * nss_stats_wifi_read()
Stephen Wangaed46332016-12-12 17:29:03 -08002439 * Read wifi statistics
Bharath M Kumarcc666e92014-12-24 19:17:28 +05302440 */
2441static ssize_t nss_stats_wifi_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2442{
2443 uint32_t i, id;
2444
2445 /*
2446 * max output lines = ((#stats + start tag + one blank) * #WIFI RADIOs) + start/end tag + 3 blank
2447 */
2448 uint32_t max_output_lines = ((NSS_STATS_WIFI_MAX + 2) * NSS_MAX_WIFI_RADIO_INTERFACES) + 5;
2449 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2450 size_t size_wr = 0;
2451 ssize_t bytes_read = 0;
2452 uint64_t *stats_shadow;
2453
2454 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2455 if (unlikely(lbuf == NULL)) {
2456 nss_warning("Could not allocate memory for local statistics buffer");
2457 return 0;
2458 }
2459
2460 stats_shadow = kzalloc(NSS_STATS_WIFI_MAX * 8, GFP_KERNEL);
2461 if (unlikely(stats_shadow == NULL)) {
2462 nss_warning("Could not allocate memory for local shadow buffer");
2463 kfree(lbuf);
2464 return 0;
2465 }
2466
2467 size_wr = scnprintf(lbuf, size_al, "wifi stats start:\n\n");
2468
2469 for (id = 0; id < NSS_MAX_WIFI_RADIO_INTERFACES; id++) {
2470 spin_lock_bh(&nss_top_main.stats_lock);
2471 for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) {
2472 stats_shadow[i] = nss_top_main.stats_wifi[id][i];
2473 }
2474
2475 spin_unlock_bh(&nss_top_main.stats_lock);
2476
2477 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFI ID: %d\n", id);
2478 for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) {
2479 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2480 "%s = %llu\n", nss_stats_str_wifi[i], stats_shadow[i]);
2481 }
2482 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,"\n");
2483 }
2484
2485 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifi stats end\n\n");
2486 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2487 kfree(lbuf);
2488 kfree(stats_shadow);
2489
2490 return bytes_read;
2491}
2492
2493/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302494 * nss_stats_wifili_read()
2495 * Read wifili statistics
2496 */
2497static ssize_t nss_stats_wifili_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2498{
2499 uint32_t i, j;
2500
2501 /*
2502 * max output lines = ((#stats + eight blank lines) * #WIFILI #STATS) + start/end tag + 3 blank
2503 */
2504 uint32_t max_output_lines = (((NSS_STATS_WIFILI_MAX + 9) * NSS_WIFILI_MAX_PDEV_NUM_MSG)+
2505 NSS_STATS_WIFILI_WBM_MAX + 5);
2506 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2507 size_t size_wr = 0;
2508 ssize_t bytes_read = 0;
2509 uint64_t *stats_shadow;
2510
2511 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2512 if (unlikely(lbuf == NULL)) {
2513 nss_warning("Could not allocate memory for local statistics buffer");
2514 return 0;
2515 }
2516
2517 /*
2518 * Take max of all wifili stats
2519 *
2520 * NOTE: txrx stats is bigger of all stats
2521 */
2522 stats_shadow = kzalloc(NSS_STATS_WIFILI_TXRX_MAX * 8, GFP_KERNEL);
2523 if (unlikely(stats_shadow == NULL)) {
2524 nss_warning("Could not allocate memory for local shadow buffer");
2525 kfree(lbuf);
2526 return 0;
2527 }
2528
2529 size_wr = scnprintf(lbuf, size_al, "wifili stats start:\n\n");
2530
2531 for (i = 0; i < NSS_WIFILI_MAX_PDEV_NUM_MSG; i++) {
2532
2533 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFILI ID: %d\n", i);
2534
2535 spin_lock_bh(&nss_top_main.stats_lock);
2536 for (j = 0; (j < NSS_STATS_WIFILI_TXRX_MAX); j++) {
2537 stats_shadow[j] = nss_top_main.stats_wifili.stats_txrx[i][j];
2538 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2539 "%s = %llu\n", nss_stats_str_wifili_txrx[j], stats_shadow[j]);
2540 }
2541
2542 spin_unlock_bh(&nss_top_main.stats_lock);
2543 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2544
2545 /*
2546 * Fillinng TCL ring stats
2547 */
2548 spin_lock_bh(&nss_top_main.stats_lock);
2549 for (j = 0; (j < NSS_STATS_WIFILI_TCL_MAX); j++) {
2550 stats_shadow[j] = nss_top_main.stats_wifili.stats_tcl_ring[i][j];
2551 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2552 "%s = %llu\n", nss_stats_str_wifili_tcl[j], stats_shadow[j]);
2553 }
2554
2555 spin_unlock_bh(&nss_top_main.stats_lock);
2556 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2557
2558 /*
2559 * Fillinng TCL comp stats
2560 */
2561 spin_lock_bh(&nss_top_main.stats_lock);
2562 for (j = 0; (j < NSS_STATS_WIFILI_TX_DESC_FREE_MAX); j++) {
2563 stats_shadow[j] = nss_top_main.stats_wifili.stats_tx_comp[i][j];
2564 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2565 "%s = %llu\n", nss_stats_str_wifili_tx_comp[j], stats_shadow[j]);
2566 }
2567
2568 spin_unlock_bh(&nss_top_main.stats_lock);
2569 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2570
2571 /*
2572 * Fillinng reo ring stats
2573 */
2574 spin_lock_bh(&nss_top_main.stats_lock);
2575 for (j = 0; (j < NSS_STATS_WIFILI_REO_MAX); j++) {
2576 stats_shadow[j] = nss_top_main.stats_wifili.stats_reo[i][j];
2577 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2578 "%s = %llu\n", nss_stats_str_wifili_reo[j], stats_shadow[j]);
2579 }
2580
2581 spin_unlock_bh(&nss_top_main.stats_lock);
2582 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2583
2584 /*
2585 * Fillinng TX SW Pool
2586 */
2587 spin_lock_bh(&nss_top_main.stats_lock);
2588 for (j = 0; (j < NSS_STATS_WIFILI_TX_DESC_MAX); j++) {
2589 stats_shadow[j] = nss_top_main.stats_wifili.stats_tx_desc[i][j];
2590 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2591 "%s = %llu\n", nss_stats_str_wifili_txsw_pool[j], stats_shadow[j]);
2592 }
2593
2594 spin_unlock_bh(&nss_top_main.stats_lock);
2595 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2596
2597 /*
2598 * Fillinng TX EXt SW Pool
2599 */
2600 spin_lock_bh(&nss_top_main.stats_lock);
2601 for (j = 0; (j < NSS_STATS_WIFILI_EXT_TX_DESC_MAX); j++) {
2602 stats_shadow[j] = nss_top_main.stats_wifili.stats_ext_tx_desc[i][j];
2603 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2604 "%s = %llu\n", nss_stats_str_wifili_ext_txsw_pool[j], stats_shadow[j]);
2605 }
2606
2607 spin_unlock_bh(&nss_top_main.stats_lock);
2608 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2609
2610 /*
2611 * Fillinng rxdma pool stats
2612 */
2613 spin_lock_bh(&nss_top_main.stats_lock);
2614 for (j = 0; (j < NSS_STATS_WIFILI_RX_DESC_MAX); j++) {
2615 stats_shadow[j] = nss_top_main.stats_wifili.stats_rx_desc[i][j];
2616 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2617 "%s = %llu\n", nss_stats_str_wifili_rxdma_pool[j], stats_shadow[j]);
2618 }
2619
2620 spin_unlock_bh(&nss_top_main.stats_lock);
2621 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2622
2623 /*
2624 * Fillinng rxdma ring stats
2625 */
2626 spin_lock_bh(&nss_top_main.stats_lock);
2627 for (j = 0; (j < NSS_STATS_WIFILI_RXDMA_DESC_MAX); j++) {
2628 stats_shadow[j] = nss_top_main.stats_wifili.stats_rxdma[i][j];
2629 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2630 "%s = %llu\n", nss_stats_str_wifili_rxdma_ring[j], stats_shadow[j]);
2631 }
2632
2633 spin_unlock_bh(&nss_top_main.stats_lock);
2634 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2635
2636 }
2637
2638 /*
2639 * Fillinng wbm ring stats
2640 */
2641 spin_lock_bh(&nss_top_main.stats_lock);
2642 for (j = 0; (j < NSS_STATS_WIFILI_WBM_MAX); j++) {
2643 stats_shadow[j] = nss_top_main.stats_wifili.stats_wbm[j];
2644 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2645 "%s = %llu\n", nss_stats_str_wifili_wbm[j], stats_shadow[j]);
2646 }
2647
2648 spin_unlock_bh(&nss_top_main.stats_lock);
2649 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifili stats end\n\n");
2650
2651 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2652 kfree(lbuf);
2653 kfree(stats_shadow);
2654
2655 return bytes_read;
2656}
2657
2658/*
Tushar Mathurff8741b2015-12-02 20:28:59 +05302659 * nss_stats_dtls_read()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07002660 * Read DTLS session statistics
Tushar Mathurff8741b2015-12-02 20:28:59 +05302661 */
2662static ssize_t nss_stats_dtls_read(struct file *fp, char __user *ubuf,
2663 size_t sz, loff_t *ppos)
2664{
2665 uint32_t max_output_lines = 2 + (NSS_MAX_DTLS_SESSIONS
2666 * (NSS_STATS_DTLS_SESSION_MAX + 2)) + 2;
2667 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2668 size_t size_wr = 0;
2669 ssize_t bytes_read = 0;
2670 struct net_device *dev;
2671 int id, i;
2672 struct nss_stats_dtls_session_debug *dtls_session_stats = NULL;
2673
2674 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2675 if (unlikely(lbuf == NULL)) {
2676 nss_warning("Could not allocate memory for local statistics buffer");
2677 return 0;
2678 }
2679
2680 dtls_session_stats = kzalloc((sizeof(struct nss_stats_dtls_session_debug)
2681 * NSS_MAX_DTLS_SESSIONS), GFP_KERNEL);
2682 if (unlikely(dtls_session_stats == NULL)) {
2683 nss_warning("Could not allocate memory for populating DTLS stats");
2684 kfree(lbuf);
2685 return 0;
2686 }
2687
2688 /*
2689 * Get all stats
2690 */
2691 nss_dtls_session_debug_stats_get(dtls_session_stats);
2692
2693 /*
2694 * Session stats
2695 */
2696 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2697 "\nDTLS session stats start:\n\n");
2698
2699 for (id = 0; id < NSS_MAX_DTLS_SESSIONS; id++) {
2700 if (!dtls_session_stats[id].valid)
2701 break;
2702
2703 dev = dev_get_by_index(&init_net, dtls_session_stats[id].if_index);
2704 if (likely(dev)) {
2705 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2706 "%d. nss interface id=%d, netdevice=%s\n",
2707 id, dtls_session_stats[id].if_num,
2708 dev->name);
2709 dev_put(dev);
2710 } else {
2711 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2712 "%d. nss interface id=%d\n", id,
2713 dtls_session_stats[id].if_num);
2714 }
2715
2716 for (i = 0; i < NSS_STATS_DTLS_SESSION_MAX; i++) {
2717 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2718 "\t%s = %llu\n",
2719 nss_stats_str_dtls_session_debug_stats[i],
2720 dtls_session_stats[id].stats[i]);
2721 }
2722
2723 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2724 }
2725
2726 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2727 "\nDTLS session stats end\n");
2728 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2729
2730 kfree(dtls_session_stats);
2731 kfree(lbuf);
2732 return bytes_read;
2733}
2734
Tushar Mathurff8741b2015-12-02 20:28:59 +05302735/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07002736 * nss_stats_gre_tunnel_read()
2737 * Read GRE Tunnel session statistics
2738 */
2739static ssize_t nss_stats_gre_tunnel_read(struct file *fp, char __user *ubuf,
2740 size_t sz, loff_t *ppos)
2741{
2742 uint32_t max_output_lines = 2 + (NSS_MAX_GRE_TUNNEL_SESSIONS
2743 * (NSS_STATS_GRE_TUNNEL_SESSION_MAX + 2)) + 2;
2744 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2745 size_t size_wr = 0;
2746 ssize_t bytes_read = 0;
2747 struct net_device *dev;
2748 int id, i;
2749 struct nss_stats_gre_tunnel_session_debug *gre_tunnel_session_stats = NULL;
2750
2751 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2752 if (unlikely(lbuf == NULL)) {
2753 nss_warning("Could not allocate memory for local statistics buffer");
2754 return 0;
2755 }
2756
2757 gre_tunnel_session_stats = kzalloc((sizeof(struct nss_stats_gre_tunnel_session_debug)
2758 * NSS_MAX_GRE_TUNNEL_SESSIONS), GFP_KERNEL);
2759 if (unlikely(gre_tunnel_session_stats == NULL)) {
2760 nss_warning("Could not allocate memory for populating GRE Tunnel stats");
2761 kfree(lbuf);
2762 return 0;
2763 }
2764
2765 /*
2766 * Get all stats
2767 */
2768 nss_gre_tunnel_session_debug_stats_get(gre_tunnel_session_stats);
2769
2770 /*
2771 * Session stats
2772 */
2773 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2774 "\nGRE Tunnel session stats start:\n\n");
2775
2776 for (id = 0; id < NSS_MAX_GRE_TUNNEL_SESSIONS; id++) {
2777 if (!gre_tunnel_session_stats[id].valid)
2778 break;
2779
2780 dev = dev_get_by_index(&init_net, gre_tunnel_session_stats[id].if_index);
2781 if (likely(dev)) {
2782 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2783 "%d. nss interface id=%d, netdevice=%s\n",
2784 id, gre_tunnel_session_stats[id].if_num,
2785 dev->name);
2786 dev_put(dev);
2787 } else {
2788 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2789 "%d. nss interface id=%d\n", id,
2790 gre_tunnel_session_stats[id].if_num);
2791 }
2792
2793 for (i = 0; i < NSS_STATS_GRE_TUNNEL_SESSION_MAX; i++) {
2794 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2795 "\t%s = %llu\n",
2796 nss_stats_str_gre_tunnel_session_debug_stats[i],
2797 gre_tunnel_session_stats[id].stats[i]);
2798 }
2799
2800 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2801 }
2802
2803 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2804 "\nGRE Tunnel session stats end\n");
2805 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2806
2807 kfree(gre_tunnel_session_stats);
2808 kfree(lbuf);
2809 return bytes_read;
2810}
2811
2812/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +05302813 * nss_stats_l2tpv2_read()
2814 * Read l2tpv2 statistics
2815 */
2816static ssize_t nss_stats_l2tpv2_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2817{
2818
2819 uint32_t max_output_lines = 2 /* header & footer for session stats */
2820 + NSS_MAX_L2TPV2_DYNAMIC_INTERFACES * (NSS_STATS_L2TPV2_SESSION_MAX + 2) /*session stats */
2821 + 2;
2822 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ;
2823 size_t size_wr = 0;
2824 ssize_t bytes_read = 0;
2825 struct net_device *dev;
2826 struct nss_stats_l2tpv2_session_debug l2tpv2_session_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES];
2827 int id, i;
2828
2829 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2830 if (unlikely(lbuf == NULL)) {
2831 nss_warning("Could not allocate memory for local statistics buffer");
2832 return 0;
2833 }
2834
2835 memset(&l2tpv2_session_stats, 0, sizeof(struct nss_stats_l2tpv2_session_debug) * NSS_MAX_L2TPV2_DYNAMIC_INTERFACES);
2836
2837 /*
2838 * Get all stats
2839 */
2840 nss_l2tpv2_session_debug_stats_get((void *)&l2tpv2_session_stats);
2841
2842 /*
2843 * Session stats
2844 */
2845 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats start:\n\n");
2846 for (id = 0; id < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; id++) {
2847
2848 if (!l2tpv2_session_stats[id].valid) {
2849 break;
2850 }
2851
2852 dev = dev_get_by_index(&init_net, l2tpv2_session_stats[id].if_index);
2853 if (likely(dev)) {
2854
2855 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
2856 l2tpv2_session_stats[id].if_num, dev->name);
2857 dev_put(dev);
2858 } else {
2859 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
2860 l2tpv2_session_stats[id].if_num);
2861 }
2862
2863 for (i = 0; i < NSS_STATS_L2TPV2_SESSION_MAX; i++) {
2864 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2865 "\t%s = %llu\n", nss_stats_str_l2tpv2_session_debug_stats[i],
2866 l2tpv2_session_stats[id].stats[i]);
2867 }
2868 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2869 }
2870
2871 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats end\n");
2872 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2873
2874 kfree(lbuf);
2875 return bytes_read;
2876}
2877
2878/*
ratheesh kannotha1245c32015-11-04 16:45:43 +05302879 * nss_stats_map_t_read()
2880 * Read map_t statistics
2881 */
2882static ssize_t nss_stats_map_t_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2883{
2884
2885 uint32_t max_output_lines = 2 /* header & footer for instance stats */
2886 + NSS_MAX_MAP_T_DYNAMIC_INTERFACES * (NSS_STATS_MAP_T_MAX + 2) /*instance stats */
2887 + 2;
2888 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2889 size_t size_wr = 0;
2890 ssize_t bytes_read = 0;
2891 struct net_device *dev;
2892 struct nss_stats_map_t_instance_debug map_t_instance_stats[NSS_MAX_MAP_T_DYNAMIC_INTERFACES];
2893 int id, i;
2894
2895 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2896 if (unlikely(!lbuf)) {
2897 nss_warning("Could not allocate memory for local statistics buffer");
2898 return 0;
2899 }
2900
2901 memset(&map_t_instance_stats, 0, sizeof(struct nss_stats_map_t_instance_debug) * NSS_MAX_MAP_T_DYNAMIC_INTERFACES);
2902
2903 /*
2904 * Get all stats
2905 */
2906 nss_map_t_instance_debug_stats_get((void *)&map_t_instance_stats);
2907
2908 /*
2909 * Session stats
2910 */
2911 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats start:\n\n");
2912 for (id = 0; id < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; id++) {
2913
2914 if (!map_t_instance_stats[id].valid) {
2915 break;
2916 }
2917
2918 dev = dev_get_by_index(&init_net, map_t_instance_stats[id].if_index);
2919 if (likely(dev)) {
2920
2921 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
2922 map_t_instance_stats[id].if_num, dev->name);
2923 dev_put(dev);
2924 } else {
2925 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
2926 map_t_instance_stats[id].if_num);
2927 }
2928
2929 for (i = 0; i < NSS_STATS_MAP_T_MAX; i++) {
2930 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2931 "\t%s = %llu\n", nss_stats_str_map_t_instance_debug_stats[i],
2932 map_t_instance_stats[id].stats[i]);
2933 }
2934 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2935 }
2936
2937 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats end\n");
2938 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2939
2940 kfree(lbuf);
2941 return bytes_read;
2942}
2943
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05302944 /*
2945 * nss_stats_gre_read()
2946 * Read GRE statistics
2947 */
2948static ssize_t nss_stats_gre_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2949{
2950 uint32_t max_output_lines = 2 /* header & footer for base debug stats */
2951 + 2 /* header & footer for session debug stats */
2952 + NSS_STATS_GRE_BASE_DEBUG_MAX /* Base debug */
2953 + NSS_GRE_MAX_DEBUG_SESSION_STATS * (NSS_STATS_GRE_SESSION_DEBUG_MAX + 2) /*session stats */
2954 + 2;
2955 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2956 size_t size_wr = 0;
2957 ssize_t bytes_read = 0;
2958 struct net_device *dev;
2959 struct nss_stats_gre_session_debug *sstats;
2960 struct nss_stats_gre_base_debug *bstats;
2961 int id, i;
2962
2963 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2964 if (unlikely(!lbuf)) {
2965 nss_warning("Could not allocate memory for local statistics buffer");
2966 return 0;
2967 }
2968
2969 bstats = kzalloc(sizeof(struct nss_stats_gre_base_debug), GFP_KERNEL);
2970 if (unlikely(!bstats)) {
2971 nss_warning("Could not allocate memory for base debug statistics buffer");
2972 kfree(lbuf);
2973 return 0;
2974 }
2975
2976 sstats = kzalloc(sizeof(struct nss_stats_gre_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS, GFP_KERNEL);
2977 if (unlikely(!sstats)) {
2978 nss_warning("Could not allocate memory for base debug statistics buffer");
2979 kfree(lbuf);
2980 kfree(bstats);
2981 return 0;
2982 }
2983
2984 /*
2985 * Get all base stats
2986 */
2987 nss_gre_base_debug_stats_get((void *)bstats, sizeof(struct nss_stats_gre_base_debug));
2988 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Base stats start:\n\n");
2989 for (i = 0; i < NSS_STATS_GRE_BASE_DEBUG_MAX; i++) {
2990 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2991 "\t%s = %llu\n", nss_stats_str_gre_base_debug_stats[i],
2992 bstats->stats[i]);
2993 }
2994
2995 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Base stats End\n\n");
2996
2997 /*
2998 * Get all session stats
2999 */
3000 nss_gre_session_debug_stats_get(sstats, sizeof(struct nss_stats_gre_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS);
3001 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Session stats start:\n\n");
3002
3003 for (id = 0; id < NSS_GRE_MAX_DEBUG_SESSION_STATS; id++) {
3004
3005 if (!((sstats + id)->valid)) {
3006 continue;
3007 }
3008
3009 dev = dev_get_by_index(&init_net, (sstats + id)->if_index);
3010 if (likely(dev)) {
3011
3012 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
3013 (sstats + id)->if_num, dev->name);
3014 dev_put(dev);
3015 } else {
3016 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
3017 (sstats + id)->if_num);
3018 }
3019
3020 for (i = 0; i < NSS_STATS_GRE_SESSION_DEBUG_MAX; i++) {
3021 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3022 "\t%s = %llu\n", nss_stats_str_gre_session_debug_stats[i],
3023 (sstats + id)->stats[i]);
3024 }
3025 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3026 }
3027
3028 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Session stats end\n");
3029 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3030
3031 kfree(sstats);
3032 kfree(bstats);
3033 kfree(lbuf);
3034 return bytes_read;
3035}
3036
ratheesh kannotha1245c32015-11-04 16:45:43 +05303037/*
Amit Gupta316729b2016-08-12 12:21:15 +05303038 * nss_stats_ppe_conn_read()
3039 * Read ppe connection stats
3040 */
3041static ssize_t nss_stats_ppe_conn_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3042{
3043
3044 int i;
3045 char *lbuf = NULL;
3046 size_t size_wr = 0;
3047 ssize_t bytes_read = 0;
3048 uint32_t ppe_stats[NSS_STATS_PPE_CONN_MAX];
3049 uint32_t max_output_lines = 2 /* header & footer for session stats */
3050 + NSS_STATS_PPE_CONN_MAX /* PPE flow counters */
3051 + 2;
3052 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3053
Amit Gupta316729b2016-08-12 12:21:15 +05303054 lbuf = kzalloc(size_al, GFP_KERNEL);
3055 if (unlikely(lbuf == NULL)) {
3056 nss_warning("Could not allocate memory for local statistics buffer");
3057 return 0;
3058 }
3059
3060 memset(&ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_CONN_MAX);
3061
3062 /*
3063 * Get all stats
3064 */
3065 nss_ppe_stats_conn_get(ppe_stats);
3066
3067 /*
3068 * flow stats
3069 */
3070 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters start:\n\n");
3071
3072 for (i = 0; i < NSS_STATS_PPE_CONN_MAX; i++) {
3073 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3074 "\t%s = %u\n", nss_stats_str_ppe_conn[i],
3075 ppe_stats[i]);
3076 }
3077
3078 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3079
3080 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters end\n");
3081 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3082
3083 kfree(lbuf);
3084 return bytes_read;
3085}
3086
3087/*
3088 * nss_stats_ppe_l3_read()
3089 * Read ppe L3 debug stats
3090 */
3091static ssize_t nss_stats_ppe_l3_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3092{
3093
3094 int i;
3095 char *lbuf = NULL;
3096 size_t size_wr = 0;
3097 ssize_t bytes_read = 0;
3098 uint32_t ppe_stats[NSS_STATS_PPE_L3_MAX];
3099 uint32_t max_output_lines = 2 /* header & footer for session stats */
3100 + NSS_STATS_PPE_L3_MAX /* PPE flow counters */
3101 + 2;
3102 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3103
3104 lbuf = kzalloc(size_al, GFP_KERNEL);
3105 if (unlikely(!lbuf)) {
3106 nss_warning("Could not allocate memory for local statistics buffer");
3107 return 0;
3108 }
3109
3110 memset(ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_L3_MAX);
3111
3112 /*
3113 * Get all stats
3114 */
3115 nss_ppe_stats_l3_get(ppe_stats);
3116
3117 /*
3118 * flow stats
3119 */
3120 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats start:\n\n");
3121
3122 for (i = 0; i < NSS_STATS_PPE_L3_MAX; i++) {
3123 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3124 "\t%s = 0x%x\n", nss_stats_str_ppe_l3[i],
3125 ppe_stats[i]);
3126 }
3127
3128 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3129
3130 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats end\n");
3131 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3132
3133 kfree(lbuf);
3134 return bytes_read;
3135}
3136
3137/*
3138 * nss_stats_ppe_code_read()
3139 * Read ppe CPU & DROP code
3140 */
3141static ssize_t nss_stats_ppe_code_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3142{
3143
3144 int i;
3145 char *lbuf = NULL;
3146 size_t size_wr = 0;
3147 ssize_t bytes_read = 0;
3148 uint32_t ppe_stats[NSS_STATS_PPE_CODE_MAX];
3149 uint32_t max_output_lines = 2 /* header & footer for session stats */
3150 + NSS_STATS_PPE_CODE_MAX /* PPE flow counters */
3151 + 2;
3152 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3153
3154 lbuf = kzalloc(size_al, GFP_KERNEL);
3155 if (unlikely(!lbuf)) {
3156 nss_warning("Could not allocate memory for local statistics buffer");
3157 return 0;
3158 }
3159
3160 memset(ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_CODE_MAX);
3161
3162 /*
3163 * Get all stats
3164 */
3165 nss_ppe_stats_code_get(ppe_stats);
3166
3167 /*
3168 * flow stats
3169 */
3170 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats start:\n\n");
3171
3172 for (i = 0; i < NSS_STATS_PPE_CODE_MAX; i++) {
3173 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3174 "\t%s = %u\n", nss_stats_str_ppe_code[i],
3175 ppe_stats[i]);
3176 }
3177
3178 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3179
3180 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats end\n");
3181 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3182
3183 kfree(lbuf);
3184 return bytes_read;
3185}
3186
3187/*
Amit Gupta79c1c202017-06-30 15:28:13 +05303188 * nss_stats_ppe_port_dc_read()
3189 * Read PPE per port drop code stats
3190 */
3191static ssize_t nss_stats_ppe_port_dc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3192{
3193 int32_t i;
3194
3195 /*
3196 * max output lines = #stats + 2 start tag line + 2 end tag line + five blank lines
3197 */
3198 uint32_t max_output_lines = (NSS_STATS_PPE_DROP_CODE_MAX + 4) + 5;
3199 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3200 size_t size_wr = 0;
3201 ssize_t bytes_read = 0;
3202 struct nss_stats_data *data = fp->private_data;
3203 uint32_t *ppe_stats;
3204
3205 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3206 if (unlikely(lbuf == NULL)) {
3207 nss_warning("Could not allocate memory for local statistics buffer");
3208 return 0;
3209 }
3210
3211 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_DROP_CODE_MAX, GFP_KERNEL);
3212 if (unlikely(ppe_stats == NULL)) {
3213 kfree(lbuf);
3214 nss_warning("Could not allocate memory for ppe stats buffer");
3215 return 0;
3216 }
3217
3218 /*
3219 * Get drop code counters for specific port
3220 */
3221 nss_ppe_port_drop_code_get(ppe_stats, data->edma_id);
3222 size_wr = scnprintf(lbuf, size_al, "ppe no drop code stats start:\n\n");
3223 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3224 "\t%s = %u\n", nss_stats_str_ppe_dc[0],
3225 ppe_stats[0]);
3226 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe no drop code stats end\n\n");
3227
3228 /*
3229 * Drop code stats
3230 */
3231 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "ppe non-zero drop code stats start:\n\n");
3232 for (i = 1; i < NSS_STATS_PPE_DROP_CODE_MAX; i++) {
3233 /*
3234 * Print only non-zero stats.
3235 */
3236 if (!ppe_stats[i]) {
3237 continue;
3238 }
3239
3240 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3241 "\t%s = %u\n", nss_stats_str_ppe_dc[i],
3242 ppe_stats[i]);
3243 }
3244 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero drop code stats end\n\n");
3245
3246 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3247 kfree(ppe_stats);
3248 kfree(lbuf);
3249
3250 return bytes_read;
3251}
3252
3253/*
3254 * nss_stats_ppe_exception_cc_read()
3255 * Read PPE CPU code stats specific to flow exceptions
3256 */
3257static ssize_t nss_stats_ppe_exception_cc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3258{
3259 int32_t i;
3260
3261 /*
3262 * max output lines = #stats + start tag line + end tag line + three blank lines
3263 */
3264 uint32_t max_output_lines = (NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX + 2) + 3;
3265 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3266 size_t size_wr = 0;
3267 ssize_t bytes_read = 0;
3268 uint32_t *ppe_stats;
3269
3270 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3271 if (unlikely(lbuf == NULL)) {
3272 nss_warning("Could not allocate memory for local statistics buffer");
3273 return 0;
3274 }
3275
3276 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX, GFP_KERNEL);
3277 if (unlikely(ppe_stats == NULL)) {
3278 kfree(lbuf);
3279 nss_warning("Could not allocate memory for ppe stats buffer");
3280 return 0;
3281 }
3282
3283 /*
3284 * Get CPU code counters for flow specific exceptions
3285 */
3286 nss_ppe_cpu_code_exception_get(ppe_stats);
3287
3288 size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code flow-exception stats start:\n\n");
3289
3290 /*
3291 * CPU code stats
3292 */
3293 for (i = 0; i < NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX; i++) {
3294 /*
3295 * Print only non-zero stats.
3296 */
3297 if (!ppe_stats[i]) {
3298 continue;
3299 }
3300
3301 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3302 "\t%s = %u\n", nss_stats_str_ppe_cc[i],
3303 ppe_stats[i]);
3304 }
3305
3306 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code flow-exception stats end\n\n");
3307 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3308 kfree(ppe_stats);
3309 kfree(lbuf);
3310
3311 return bytes_read;
3312}
3313
3314/*
3315 * nss_stats_ppe_nonexception_cc_read()
3316 * Read PPE CPU code stats for other than flow exceptions
3317 */
3318static ssize_t nss_stats_ppe_nonexception_cc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3319{
3320 int32_t i;
3321
3322 /*
3323 * max output lines = #stats + start tag line + end tag line + three blank lines
3324 */
3325 uint32_t max_output_lines = (NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX + 2) + 3;
3326 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3327 size_t size_wr = 0;
3328 ssize_t bytes_read = 0;
3329 uint32_t *ppe_stats;
3330
3331 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3332 if (unlikely(lbuf == NULL)) {
3333 nss_warning("Could not allocate memory for local statistics buffer");
3334 return 0;
3335 }
3336
3337 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX, GFP_KERNEL);
3338 if (unlikely(ppe_stats == NULL)) {
3339 kfree(lbuf);
3340 nss_warning("Could not allocate memory for ppe stats buffer");
3341 return 0;
3342 }
3343
3344 /*
3345 * Get CPU code counters for non flow exceptions
3346 */
3347 nss_ppe_cpu_code_nonexception_get(ppe_stats);
3348
3349 /*
3350 * CPU code stats
3351 */
3352 size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code non-flow exception stats start:\n\n");
3353 for (i = 0; i < NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX; i++) {
3354 /*
3355 * Print only non-zero stats.
3356 */
3357 if (!ppe_stats[i]) {
3358 continue;
3359 }
3360
3361 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3362 "\t%s = %u\n", nss_stats_str_ppe_cc[i + NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_START],
3363 ppe_stats[i]);
3364 }
3365
3366 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code non-flow exception stats end\n\n");
3367 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3368 kfree(ppe_stats);
3369 kfree(lbuf);
3370
3371 return bytes_read;
3372}
3373
3374/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05303375 * nss_stats_pptp_read()
3376 * Read pptp statistics
3377 */
3378static ssize_t nss_stats_pptp_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3379{
3380
3381 uint32_t max_output_lines = 2 /* header & footer for session stats */
3382 + NSS_MAX_PPTP_DYNAMIC_INTERFACES * (NSS_STATS_PPTP_SESSION_MAX + 2) /*session stats */
3383 + 2;
3384 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ;
3385 size_t size_wr = 0;
3386 ssize_t bytes_read = 0;
3387 struct net_device *dev;
3388 struct nss_stats_pptp_session_debug pptp_session_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES];
3389 int id, i;
3390
3391 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3392 if (unlikely(lbuf == NULL)) {
3393 nss_warning("Could not allocate memory for local statistics buffer");
3394 return 0;
3395 }
3396
3397 memset(&pptp_session_stats, 0, sizeof(struct nss_stats_pptp_session_debug) * NSS_MAX_PPTP_DYNAMIC_INTERFACES);
3398
3399 /*
3400 * Get all stats
3401 */
3402 nss_pptp_session_debug_stats_get((void *)&pptp_session_stats);
3403
3404 /*
3405 * Session stats
3406 */
3407 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats start:\n\n");
3408 for (id = 0; id < NSS_MAX_PPTP_DYNAMIC_INTERFACES; id++) {
3409
3410 if (!pptp_session_stats[id].valid) {
3411 break;
3412 }
3413
3414 dev = dev_get_by_index(&init_net, pptp_session_stats[id].if_index);
3415 if (likely(dev)) {
3416
3417 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
3418 pptp_session_stats[id].if_num, dev->name);
3419 dev_put(dev);
3420 } else {
3421 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
3422 pptp_session_stats[id].if_num);
3423 }
3424
3425 for (i = 0; i < NSS_STATS_PPTP_SESSION_MAX; i++) {
3426 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3427 "\t%s = %llu\n", nss_stats_str_pptp_session_debug_stats[i],
3428 pptp_session_stats[id].stats[i]);
3429 }
3430 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3431 }
3432
3433 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats end\n");
3434 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3435
3436 kfree(lbuf);
3437 return bytes_read;
3438}
3439
3440/*
Ankit Dhanuka14999992014-11-12 15:35:11 +05303441 * nss_stats_sjack_read()
3442 * Read SJACK stats
3443 */
3444static ssize_t nss_stats_sjack_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3445{
3446 int32_t i;
3447 /*
3448 * max output lines = #stats + start tag line + end tag line + three blank lines
3449 */
3450 uint32_t max_output_lines = NSS_STATS_NODE_MAX + 5;
3451 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3452 size_t size_wr = 0;
3453 ssize_t bytes_read = 0;
3454 uint64_t *stats_shadow;
3455
3456 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3457 if (unlikely(lbuf == NULL)) {
3458 nss_warning("Could not allocate memory for local statistics buffer");
3459 return 0;
3460 }
3461
3462 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
3463 if (unlikely(stats_shadow == NULL)) {
3464 nss_warning("Could not allocate memory for local shadow buffer");
3465 kfree(lbuf);
3466 return 0;
3467 }
3468
3469 size_wr = scnprintf(lbuf, size_al, "sjack stats start:\n\n");
3470
3471 /*
3472 * Common node stats
3473 */
3474 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
3475 spin_lock_bh(&nss_top_main.stats_lock);
3476 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3477 stats_shadow[i] = nss_top_main.stats_node[NSS_SJACK_INTERFACE][i];
3478 }
3479
3480 spin_unlock_bh(&nss_top_main.stats_lock);
3481
3482 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3483 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3484 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
3485 }
3486
3487 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nsjack stats end\n\n");
3488
3489 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3490 kfree(lbuf);
3491 kfree(stats_shadow);
3492
3493 return bytes_read;
3494}
3495
3496/*
Stephen Wang9779d952015-10-28 11:39:07 -07003497 * nss_stats_portid_read()
3498 * Read PortID stats
3499 */
3500static ssize_t nss_stats_portid_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3501{
3502 int32_t i;
3503 /*
3504 * max output lines = #stats + start tag line + end tag line + three blank lines
3505 */
3506 uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_STATS_PORTID_MAX + 5;
3507 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3508 size_t size_wr = 0;
3509 ssize_t bytes_read = 0;
3510 uint64_t *stats_shadow;
3511
3512 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3513 if (unlikely(lbuf == NULL)) {
3514 nss_warning("Could not allocate memory for local statistics buffer");
3515 return 0;
3516 }
3517
3518 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
3519 if (unlikely(stats_shadow == NULL)) {
3520 nss_warning("Could not allocate memory for local shadow buffer");
3521 kfree(lbuf);
3522 return 0;
3523 }
3524
3525 size_wr = scnprintf(lbuf, size_al, "portid stats start:\n\n");
3526
3527 /*
3528 * Common node stats
3529 */
3530 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
3531 spin_lock_bh(&nss_top_main.stats_lock);
3532 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3533 stats_shadow[i] = nss_top_main.stats_node[NSS_PORTID_INTERFACE][i];
3534 }
3535
3536 spin_unlock_bh(&nss_top_main.stats_lock);
3537
3538 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3539 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3540 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
3541 }
3542
3543 /*
3544 * PortID node stats
3545 */
3546 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid node stats:\n\n");
3547
3548 spin_lock_bh(&nss_top_main.stats_lock);
3549 for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) {
3550 stats_shadow[i] = nss_top_main.stats_portid[i];
3551 }
3552
3553 spin_unlock_bh(&nss_top_main.stats_lock);
3554
3555 for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) {
3556 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3557 "%s = %llu\n", nss_stats_str_portid[i], stats_shadow[i]);
3558 }
3559
3560 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid stats end\n\n");
3561
3562 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3563 kfree(lbuf);
3564 kfree(stats_shadow);
3565
3566 return bytes_read;
3567}
3568
3569/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003570 * nss_stats_capwap_encap()
3571 * Make a row for CAPWAP encap stats.
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003572 */
3573static ssize_t nss_stats_capwap_encap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s)
3574{
Saurabh Misra3f66e872015-04-03 11:30:42 -07003575 char *header[] = { "packets", "bytes", "fragments", "drop_ref", "drop_ver", "drop_unalign",
3576 "drop_hroom", "drop_dtls", "drop_nwireless", "drop_qfull", "drop_memfail", "unknown" };
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003577 uint64_t tcnt = 0;
3578
3579 switch (i) {
3580 case 0:
3581 tcnt = s->pnode_stats.tx_packets;
3582 break;
3583 case 1:
3584 tcnt = s->pnode_stats.tx_bytes;
3585 break;
3586 case 2:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003587 tcnt = s->tx_segments;
3588 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003589 case 3:
3590 tcnt = s->tx_dropped_sg_ref;
3591 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003592 case 4:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003593 tcnt = s->tx_dropped_ver_mis;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003594 break;
3595 case 5:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003596 tcnt = s->tx_dropped_unalign;
3597 break;
3598 case 6:
3599 tcnt = s->tx_dropped_hroom;
3600 break;
3601 case 7:
3602 tcnt = s->tx_dropped_dtls;
3603 break;
3604 case 8:
3605 tcnt = s->tx_dropped_nwireless;
3606 break;
3607 case 9:
3608 tcnt = s->tx_queue_full_drops;
3609 break;
3610 case 10:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003611 tcnt = s->tx_mem_failure_drops;
3612 break;
3613 default:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003614 return 0;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003615 }
3616
Saurabh Misra3f66e872015-04-03 11:30:42 -07003617 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003618}
3619
3620/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003621 * nss_stats_capwap_decap()
3622 * Make a row for CAPWAP decap stats.
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003623 */
3624static ssize_t nss_stats_capwap_decap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s)
3625{
Saurabh Misra3f66e872015-04-03 11:30:42 -07003626 char *header[] = { "packets", "bytes", "DTLS_pkts", "fragments", "rx_dropped", "drop_oversize",
3627 "drop_frag_timeout", "drop_frag_dup", "drop_frag_gap", "drop_qfull", "drop_memfail",
3628 "drop_csum", "drop_malformed", "unknown" };
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003629 uint64_t tcnt = 0;
3630
Aniruddha Paul1b170c22017-05-29 12:30:39 +05303631 switch (i) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003632 case 0:
3633 tcnt = s->pnode_stats.rx_packets;
3634 break;
3635 case 1:
3636 tcnt = s->pnode_stats.rx_bytes;
3637 break;
3638 case 2:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003639 tcnt = s->dtls_pkts;
3640 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003641 case 3:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003642 tcnt = s->rx_segments;
3643 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003644 case 4:
3645 tcnt = s->pnode_stats.rx_dropped;
3646 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003647 case 5:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003648 tcnt = s->rx_oversize_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003649 break;
3650 case 6:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003651 tcnt = s->rx_frag_timeout_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003652 break;
3653 case 7:
3654 tcnt = s->rx_dup_frag;
3655 break;
3656 case 8:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003657 tcnt = s->rx_frag_gap_drops;
3658 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003659 case 9:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003660 tcnt = s->rx_queue_full_drops;
3661 return (snprintf(line, len, "%s = %llu (n2h = %llu)\n", header[i], tcnt, s->rx_n2h_queue_full_drops));
3662 case 10:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003663 tcnt = s->rx_mem_failure_drops;
3664 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003665 case 11:
3666 tcnt = s->rx_csum_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003667 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003668 case 12:
3669 tcnt = s->rx_malformed;
3670 break;
3671 default:
3672 return 0;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003673 }
3674
Saurabh Misra3f66e872015-04-03 11:30:42 -07003675 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003676}
3677
3678/*
3679 * nss_stats_capwap_read()
3680 * Read CAPWAP stats
3681 */
3682static ssize_t nss_stats_capwap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos, uint16_t type)
3683{
3684 struct nss_stats_data *data = fp->private_data;
3685 ssize_t bytes_read = 0;
3686 struct nss_capwap_tunnel_stats stats;
3687 size_t bytes;
3688 char line[80];
Saurabh Misra3f66e872015-04-03 11:30:42 -07003689 int start;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003690 uint32_t if_num = NSS_DYNAMIC_IF_START;
3691 uint32_t max_if_num = NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES;
3692
3693 if (data) {
3694 if_num = data->if_num;
3695 }
3696
3697 /*
3698 * If we are done accomodating all the CAPWAP tunnels.
3699 */
3700 if (if_num > max_if_num) {
3701 return 0;
3702 }
3703
3704 for (; if_num <= max_if_num; if_num++) {
3705 bool isthere;
3706
3707 if (nss_is_dynamic_interface(if_num) == false) {
3708 continue;
3709 }
3710
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003711 if (nss_dynamic_interface_get_type(nss_capwap_get_ctx(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003712 continue;
3713 }
3714
3715 /*
3716 * If CAPWAP tunnel does not exists, then isthere will be false.
3717 */
3718 isthere = nss_capwap_get_stats(if_num, &stats);
3719 if (!isthere) {
3720 continue;
3721 }
3722
Saurabh Misra3f66e872015-04-03 11:30:42 -07003723 bytes = snprintf(line, sizeof(line), "----if_num : %2d----\n", if_num);
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003724 if ((bytes_read + bytes) > sz) {
3725 break;
3726 }
3727
3728 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3729 bytes_read = -EFAULT;
3730 goto fail;
3731 }
3732 bytes_read += bytes;
3733 start = 0;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003734 while (bytes_read < sz) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003735 if (type == 1) {
3736 bytes = nss_stats_capwap_encap(line, sizeof(line), start, &stats);
3737 } else {
3738 bytes = nss_stats_capwap_decap(line, sizeof(line), start, &stats);
3739 }
3740
Saurabh Misra3f66e872015-04-03 11:30:42 -07003741 /*
3742 * If we don't have any more lines in decap/encap.
3743 */
3744 if (bytes == 0) {
3745 break;
3746 }
3747
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003748 if ((bytes_read + bytes) > sz)
3749 break;
3750
3751 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3752 bytes_read = -EFAULT;
3753 goto fail;
3754 }
3755
3756 bytes_read += bytes;
3757 start++;
3758 }
3759 }
3760
3761 if (bytes_read > 0) {
3762 *ppos = bytes_read;
3763 }
3764
3765 if (data) {
3766 data->if_num = if_num;
3767 }
3768fail:
3769 return bytes_read;
3770}
3771
3772/*
3773 * nss_stats_capwap_decap_read()
3774 * Read CAPWAP decap stats
3775 */
3776static ssize_t nss_stats_capwap_decap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3777{
3778 return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 0));
3779}
3780
3781/*
3782 * nss_stats_capwap_encap_read()
3783 * Read CAPWAP encap stats
3784 */
3785static ssize_t nss_stats_capwap_encap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3786{
3787 return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 1));
3788}
3789
3790/*
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303791 * nss_stats_gre_redir()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003792 * Make a row for GRE_REDIR stats.
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303793 */
3794static ssize_t nss_stats_gre_redir(char *line, int len, int i, struct nss_gre_redir_tunnel_stats *s)
3795{
3796 char *header[] = { "TX Packets", "TX Bytes", "TX Drops", "RX Packets", "RX Bytes", "Rx Drops" };
3797 uint64_t tcnt = 0;
3798
3799 switch (i) {
3800 case 0:
3801 tcnt = s->node_stats.tx_packets;
3802 break;
3803 case 1:
3804 tcnt = s->node_stats.tx_bytes;
3805 break;
3806 case 2:
3807 tcnt = s->tx_dropped;
3808 break;
3809 case 3:
3810 tcnt = s->node_stats.rx_packets;
3811 break;
3812 case 4:
3813 tcnt = s->node_stats.rx_bytes;
3814 break;
3815 case 5:
3816 tcnt = s->node_stats.rx_dropped;
3817 break;
3818 default:
Radha krishna Simha Jigurudf53f022015-11-09 12:31:26 +05303819 return 0;
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303820 }
3821
3822 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
3823}
3824
3825/*
3826 * nss_stats_gre_redir_read()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003827 * READ gre_redir tunnel stats.
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303828 */
3829static ssize_t nss_stats_gre_redir_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3830{
3831 struct nss_stats_data *data = fp->private_data;
3832 ssize_t bytes_read = 0;
3833 struct nss_gre_redir_tunnel_stats stats;
3834 size_t bytes;
3835 char line[80];
3836 int start, end;
3837 int index = 0;
3838
3839 if (data) {
3840 index = data->index;
3841 }
3842
3843 /*
3844 * If we are done accomodating all the GRE_REDIR tunnels.
3845 */
3846 if (index >= NSS_GRE_REDIR_MAX_INTERFACES) {
3847 return 0;
3848 }
3849
3850 for (; index < NSS_GRE_REDIR_MAX_INTERFACES; index++) {
3851 bool isthere;
3852
3853 /*
3854 * If gre_redir tunnel does not exists, then isthere will be false.
3855 */
3856 isthere = nss_gre_redir_get_stats(index, &stats);
3857 if (!isthere) {
3858 continue;
3859 }
3860
3861 bytes = snprintf(line, sizeof(line), "\nTunnel if_num: %2d\n", stats.if_num);
3862 if ((bytes_read + bytes) > sz) {
3863 break;
3864 }
3865
3866 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3867 bytes_read = -EFAULT;
3868 goto fail;
3869 }
3870 bytes_read += bytes;
3871 start = 0;
3872 end = 6;
3873 while (bytes_read < sz && start < end) {
3874 bytes = nss_stats_gre_redir(line, sizeof(line), start, &stats);
3875
3876 if ((bytes_read + bytes) > sz)
3877 break;
3878
3879 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3880 bytes_read = -EFAULT;
3881 goto fail;
3882 }
3883
3884 bytes_read += bytes;
3885 start++;
3886 }
3887 }
3888
3889 if (bytes_read > 0) {
3890 *ppos = bytes_read;
3891 }
3892
3893 if (data) {
3894 data->index = index;
3895 }
3896
3897fail:
3898 return bytes_read;
3899}
3900
3901/*
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003902 * nss_stats_wifi_if_read()
3903 * Read wifi_if statistics
3904 */
3905static ssize_t nss_stats_wifi_if_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3906{
3907 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003908 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id];
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003909 int32_t if_num = NSS_DYNAMIC_IF_START;
3910 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
3911 size_t bytes = 0;
3912 ssize_t bytes_read = 0;
3913 char line[80];
3914 int start, end;
3915
3916 if (data) {
3917 if_num = data->if_num;
3918 }
3919
3920 if (if_num > max_if_num) {
3921 return 0;
3922 }
3923
3924 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003925 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_WIFI)
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003926 continue;
3927
3928 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
3929 if ((bytes_read + bytes) > sz)
3930 break;
3931
3932 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3933 bytes_read = -EFAULT;
3934 goto end;
3935 }
3936
3937 bytes_read += bytes;
3938
3939 start = 0;
3940 end = 7;
3941 while (bytes_read < sz && start < end) {
3942 bytes = nss_wifi_if_copy_stats(if_num, start, line);
3943 if (!bytes)
3944 break;
3945
3946 if ((bytes_read + bytes) > sz)
3947 break;
3948
3949 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3950 bytes_read = -EFAULT;
3951 goto end;
3952 }
3953
3954 bytes_read += bytes;
3955 start++;
3956 }
3957
3958 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
3959 if (bytes_read > (sz - bytes))
3960 break;
3961
3962 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3963 bytes_read = -EFAULT;
3964 goto end;
3965 }
3966
3967 bytes_read += bytes;
3968 }
3969
3970 if (bytes_read > 0) {
3971 *ppos = bytes_read;
3972 }
3973
3974 if (data) {
3975 data->if_num = if_num;
3976 }
3977
3978end:
3979 return bytes_read;
3980}
3981
3982/*
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07003983 * nss_stats_virt_if_read()
3984 * Read virt_if statistics
3985 */
3986static ssize_t nss_stats_virt_if_read(struct file *fp, char __user *ubuf,
3987 size_t sz, loff_t *ppos)
3988{
3989 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003990 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id];
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07003991 int32_t if_num = NSS_DYNAMIC_IF_START;
3992 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
3993 size_t bytes = 0;
3994 ssize_t bytes_read = 0;
3995 char line[80];
3996 int start, end;
3997
3998 if (data) {
3999 if_num = data->if_num;
4000 }
4001
4002 if (if_num > max_if_num) {
4003 return 0;
4004 }
4005
4006 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004007 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR)
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004008 continue;
4009
4010 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
4011 if ((bytes_read + bytes) > sz)
4012 break;
4013
4014 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4015 bytes_read = -EFAULT;
4016 goto end;
4017 }
4018
4019 bytes_read += bytes;
4020
4021 start = 0;
4022 end = 7;
4023 while (bytes_read < sz && start < end) {
4024 bytes = nss_virt_if_copy_stats(if_num, start, line);
4025 if (!bytes)
4026 break;
4027
4028 if ((bytes_read + bytes) > sz)
4029 break;
4030
4031 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4032 bytes_read = -EFAULT;
4033 goto end;
4034 }
4035
4036 bytes_read += bytes;
4037 start++;
4038 }
4039
4040 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
4041 if (bytes_read > (sz - bytes))
4042 break;
4043
4044 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4045 bytes_read = -EFAULT;
4046 goto end;
4047 }
4048
4049 bytes_read += bytes;
4050 }
4051
4052 if (bytes_read > 0) {
4053 *ppos = bytes_read;
4054 }
4055
4056 if (data) {
4057 data->if_num = if_num;
4058 }
4059
4060end:
4061 return bytes_read;
4062}
4063
4064/*
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004065 * nss_stats_tx_rx_virt_if_read()
4066 * Read tx_rx_virt_if statistics
4067 */
4068static ssize_t nss_stats_tx_rx_virt_if_read(struct file *fp, char __user *ubuf,
4069 size_t sz, loff_t *ppos)
4070{
4071 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004072 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id];
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004073 int32_t if_num = NSS_DYNAMIC_IF_START;
4074 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
4075 size_t bytes = 0;
4076 ssize_t bytes_read = 0;
4077 char line[80];
4078 int start, end;
4079
4080 if (data) {
4081 if_num = data->if_num;
4082 }
4083
4084 if (if_num > max_if_num) {
4085 return 0;
4086 }
4087
4088 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004089 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED)
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004090 continue;
4091
4092 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
4093 if ((bytes_read + bytes) > sz)
4094 break;
4095
4096 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4097 bytes_read = -EFAULT;
4098 goto end;
4099 }
4100
4101 bytes_read += bytes;
4102
4103 start = 0;
4104 end = 7;
4105 while (bytes_read < sz && start < end) {
4106 bytes = nss_tx_rx_virt_if_copy_stats(if_num, start, line);
4107 if (!bytes)
4108 break;
4109
4110 if ((bytes_read + bytes) > sz)
4111 break;
4112
4113 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4114 bytes_read = -EFAULT;
4115 goto end;
4116 }
4117
4118 bytes_read += bytes;
4119 start++;
4120 }
4121
4122 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
4123 if (bytes_read > (sz - bytes))
4124 break;
4125
4126 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4127 bytes_read = -EFAULT;
4128 goto end;
4129 }
4130
4131 bytes_read += bytes;
4132 }
4133
4134 if (bytes_read > 0) {
4135 *ppos = bytes_read;
4136 }
4137
4138 if (data) {
4139 data->if_num = if_num;
4140 }
4141
4142end:
4143 return bytes_read;
4144}
4145
4146/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07004147 * nss_stats_trustsec_tx_read()
4148 * Read trustsec_tx stats
4149 */
4150static ssize_t nss_stats_trustsec_tx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
4151{
4152 int32_t i;
4153
4154 /*
4155 * max output lines = #stats + start tag line + end tag line + three blank lines
4156 */
4157 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_TRUSTSEC_TX_MAX + 3) + 5;
4158 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
4159 size_t size_wr = 0;
4160 ssize_t bytes_read = 0;
4161 uint64_t *stats_shadow;
4162
4163 char *lbuf = kzalloc(size_al, GFP_KERNEL);
4164 if (unlikely(lbuf == NULL)) {
4165 nss_warning("Could not allocate memory for local statistics buffer");
4166 return 0;
4167 }
4168
4169 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
4170 if (unlikely(stats_shadow == NULL)) {
4171 nss_warning("Could not allocate memory for local shadow buffer");
4172 kfree(lbuf);
4173 return 0;
4174 }
4175
4176 size_wr = scnprintf(lbuf, size_al, "trustsec_tx stats start:\n\n");
4177
4178 /*
4179 * Common node stats
4180 */
4181 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
4182 spin_lock_bh(&nss_top_main.stats_lock);
4183 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
4184 stats_shadow[i] = nss_top_main.stats_node[NSS_TRUSTSEC_TX_INTERFACE][i];
4185 }
4186
4187 spin_unlock_bh(&nss_top_main.stats_lock);
4188
4189 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
4190 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4191 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
4192 }
4193
4194 /*
4195 * TrustSec TX node stats
4196 */
4197 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx node stats:\n\n");
4198
4199 spin_lock_bh(&nss_top_main.stats_lock);
4200 for (i = 0; (i < NSS_STATS_TRUSTSEC_TX_MAX); i++) {
4201 stats_shadow[i] = nss_top_main.stats_trustsec_tx[i];
4202 }
4203
4204 spin_unlock_bh(&nss_top_main.stats_lock);
4205
4206 for (i = 0; (i < NSS_STATS_TRUSTSEC_TX_MAX); i++) {
4207 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4208 "%s = %llu\n", nss_stats_str_trustsec_tx[i], stats_shadow[i]);
4209 }
4210
4211 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx stats end\n\n");
4212 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
4213 kfree(lbuf);
4214 kfree(stats_shadow);
4215
4216 return bytes_read;
4217}
4218
4219/*
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004220 * nss_stats_wt_read()
4221 * Reads and formats worker thread statistics and outputs them to ubuf
4222 */
4223static ssize_t nss_stats_wt_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
4224{
4225 struct nss_stats_data *data = fp->private_data;
4226 struct nss_ctx_instance *nss_ctx = data->nss_ctx;
4227 struct nss_project_irq_stats *shadow;
4228 uint32_t thread_count = nss_ctx->worker_thread_count;
4229 uint32_t irq_count = nss_ctx->irq_count;
4230
4231 /*
4232 * Three lines for each IRQ
4233 */
4234 uint32_t max_output_lines = thread_count * 3 * irq_count;
4235 size_t size_al = max_output_lines * NSS_STATS_MAX_STR_LENGTH;
4236 size_t size_wr = 0;
4237 ssize_t bytes_read = 0;
4238 char *lbuf;
4239 int i;
4240 int j;
4241
4242 lbuf = kzalloc(size_al, GFP_KERNEL);
4243 if (unlikely(!lbuf)) {
4244 nss_warning("Could not allocate memory for local statistics buffer\n");
4245 return 0;
4246 }
4247
4248 shadow = kzalloc(thread_count * irq_count * sizeof(struct nss_project_irq_stats), GFP_KERNEL);
4249 if (unlikely(!shadow)) {
4250 nss_warning("Could not allocate memory for stats shadow\n");
4251 kfree(lbuf);
4252 return 0;
4253 }
4254
4255 spin_lock_bh(&nss_top_main.stats_lock);
4256 if (unlikely(!nss_ctx->wt_stats)) {
4257 spin_unlock_bh(&nss_top_main.stats_lock);
4258 nss_warning("Worker thread statistics not allocated\n");
4259 kfree(lbuf);
4260 kfree(shadow);
4261 return 0;
4262 }
4263 for (i = 0; i < thread_count; ++i) {
4264
4265 /*
4266 * The statistics shadow is an array with thread_count * irq_count
4267 * items in it. Each item is located at the index:
4268 * (thread number) * (irq_count) + (irq number)
4269 * thus simulating a two-dimensional array.
4270 */
4271 for (j = 0; j < irq_count; ++j) {
4272 shadow[i * irq_count + j] = nss_ctx->wt_stats[i].irq_stats[j];
4273 }
4274 }
4275 spin_unlock_bh(&nss_top_main.stats_lock);
4276
4277 for (i = 0; i < thread_count; ++i) {
4278 for (j = 0; j < irq_count; ++j) {
4279 struct nss_project_irq_stats *is = &(shadow[i * irq_count + j]);
4280 if (!(is->count)) {
4281 continue;
4282 }
4283
4284 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4285 "t-%d:irq-%d callback: 0x%x, count: %llu\n",
4286 i, j, is->callback, is->count);
4287 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4288 "t-%d:irq-%d tick min: %10u avg: %10u max:%10u\n",
4289 i, j, is->ticks_min, is->ticks_avg, is->ticks_max);
4290 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4291 "t-%d:irq-%d insn min: %10u avg: %10u max:%10u\n\n",
4292 i, j, is->insn_min, is->insn_avg, is->insn_max);
4293 }
4294 }
4295 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
4296 kfree(lbuf);
4297 kfree(shadow);
4298
4299 return bytes_read;
4300}
4301
4302/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004303 * nss_stats_open()
4304 */
4305static int nss_stats_open(struct inode *inode, struct file *filp)
4306{
4307 struct nss_stats_data *data = NULL;
4308
4309 data = kzalloc(sizeof(struct nss_stats_data), GFP_KERNEL);
4310 if (!data) {
4311 return -ENOMEM;
4312 }
4313 memset(data, 0, sizeof (struct nss_stats_data));
4314 data->if_num = NSS_DYNAMIC_IF_START;
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304315 data->index = 0;
Stephen Wangaed46332016-12-12 17:29:03 -08004316 data->edma_id = (nss_ptr_t)inode->i_private;
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004317 data->nss_ctx = (struct nss_ctx_instance *)(inode->i_private);
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004318 filp->private_data = data;
4319
4320 return 0;
4321}
4322
4323/*
4324 * nss_stats_release()
4325 */
4326static int nss_stats_release(struct inode *inode, struct file *filp)
4327{
4328 struct nss_stats_data *data = filp->private_data;
4329
4330 if (data) {
4331 kfree(data);
4332 }
4333
4334 return 0;
4335}
4336
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304337#define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \
4338static const struct file_operations nss_stats_##name##_ops = { \
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004339 .open = nss_stats_open, \
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304340 .read = nss_stats_##name##_read, \
4341 .llseek = generic_file_llseek, \
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004342 .release = nss_stats_release, \
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304343};
4344
4345/*
4346 * nss_ipv4_stats_ops
4347 */
4348NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4)
4349
4350/*
Selin Dag6d9b0c12014-11-04 18:27:21 -08004351 * ipv4_reasm_stats_ops
4352 */
4353NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4_reasm)
4354
4355/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304356 * ipv6_stats_ops
4357 */
4358NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6)
4359
4360/*
Selin Dag60a2f5b2015-06-29 14:39:49 -07004361 * ipv6_reasm_stats_ops
4362 */
4363NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6_reasm)
4364
4365/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304366 * n2h_stats_ops
4367 */
4368NSS_STATS_DECLARE_FILE_OPERATIONS(n2h)
Thomas Wuc3e382c2014-10-29 15:35:13 -07004369
4370/*
4371 * lso_rx_stats_ops
4372 */
4373NSS_STATS_DECLARE_FILE_OPERATIONS(lso_rx)
4374
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304375/*
4376 * drv_stats_ops
4377 */
4378NSS_STATS_DECLARE_FILE_OPERATIONS(drv)
4379
4380/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304381 * pppoe_stats_ops
4382 */
4383NSS_STATS_DECLARE_FILE_OPERATIONS(pppoe)
4384
4385/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +05304386 * l2tpv2_stats_ops
4387 */
4388NSS_STATS_DECLARE_FILE_OPERATIONS(l2tpv2)
4389
4390/*
ratheesh kannotha1245c32015-11-04 16:45:43 +05304391 * map_t_stats_ops
4392 */
4393NSS_STATS_DECLARE_FILE_OPERATIONS(map_t)
4394
4395/*
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05304396 * gre_stats_ops
4397 */
4398NSS_STATS_DECLARE_FILE_OPERATIONS(gre)
4399
4400/*
Amit Gupta316729b2016-08-12 12:21:15 +05304401 * ppe_stats_ops
4402 */
4403NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_conn)
4404NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_l3)
4405NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_code)
Amit Gupta79c1c202017-06-30 15:28:13 +05304406NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_port_dc)
4407NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_exception_cc)
4408NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_nonexception_cc)
Amit Gupta316729b2016-08-12 12:21:15 +05304409
4410/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05304411 * pptp_stats_ops
4412 */
4413NSS_STATS_DECLARE_FILE_OPERATIONS(pptp)
4414
4415/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304416 * gmac_stats_ops
4417 */
4418NSS_STATS_DECLARE_FILE_OPERATIONS(gmac)
4419
4420/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004421 * capwap_stats_ops
4422 */
4423NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_encap)
4424NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_decap)
4425
4426/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304427 * eth_rx_stats_ops
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304428 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304429NSS_STATS_DECLARE_FILE_OPERATIONS(eth_rx)
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304430
4431/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004432 * edma_port_stats_ops
4433 */
4434NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_stats)
4435
4436/*
4437 * edma_port_type_ops
4438 */
4439NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_type)
4440
4441/*
4442 * edma_port_ring_map_ops
4443 */
4444NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_ring_map)
4445
4446/*
4447 * edma_txring_stats_ops
4448 */
4449NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txring)
4450
4451/*
4452 * edma_rxring_stats_ops
4453 */
4454NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxring)
4455
4456/*
4457 * edma_txcmplring_stats_ops
4458 */
4459NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txcmplring)
4460
4461/*
4462 * edma_rxfillring_stats_ops
4463 */
4464NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxfillring)
4465
4466/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004467 * edma_err_stats_ops
4468 */
4469NSS_STATS_DECLARE_FILE_OPERATIONS(edma_err_stats)
4470
4471/*
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304472 * gre_redir_ops
4473 */
4474NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir)
4475
4476/*
Ankit Dhanuka14999992014-11-12 15:35:11 +05304477 * sjack_stats_ops
4478 */
4479NSS_STATS_DECLARE_FILE_OPERATIONS(sjack)
4480
Stephen Wang9779d952015-10-28 11:39:07 -07004481/*
4482 * portid_ops
4483 */
4484NSS_STATS_DECLARE_FILE_OPERATIONS(portid)
4485
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08004486NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_if)
4487
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004488NSS_STATS_DECLARE_FILE_OPERATIONS(virt_if)
4489
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004490NSS_STATS_DECLARE_FILE_OPERATIONS(tx_rx_virt_if)
4491
Ankit Dhanuka14999992014-11-12 15:35:11 +05304492/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304493 * wifi_stats_ops
4494 */
4495NSS_STATS_DECLARE_FILE_OPERATIONS(wifi)
4496
4497/*
Tushar Mathurff8741b2015-12-02 20:28:59 +05304498 * dtls_stats_ops
4499 */
4500NSS_STATS_DECLARE_FILE_OPERATIONS(dtls)
4501
4502/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07004503 * gre_tunnel_stats_ops
4504 */
4505NSS_STATS_DECLARE_FILE_OPERATIONS(gre_tunnel)
4506
4507/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07004508 * trustsec_tx_stats_ops
4509 */
4510NSS_STATS_DECLARE_FILE_OPERATIONS(trustsec_tx)
4511
4512/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +05304513 * wifili_stats_ops
4514 */
4515NSS_STATS_DECLARE_FILE_OPERATIONS(wifili)
4516
4517/*
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004518 * wt_stats_ops
4519 */
4520NSS_STATS_DECLARE_FILE_OPERATIONS(wt)
4521/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304522 * nss_stats_init()
4523 * Enable NSS statistics
4524 */
4525void nss_stats_init(void)
4526{
Shashank Balashankar512cb602016-08-01 17:57:42 -07004527 int i = 0;
4528 struct dentry *edma_d = NULL;
4529 struct dentry *edma_port_dir_d = NULL;
4530 struct dentry *edma_port_d = NULL;
4531 struct dentry *edma_port_type_d = NULL;
4532 struct dentry *edma_port_stats_d = NULL;
4533 struct dentry *edma_port_ring_map_d = NULL;
Shashank Balashankar512cb602016-08-01 17:57:42 -07004534 struct dentry *edma_rings_dir_d = NULL;
4535 struct dentry *edma_tx_dir_d = NULL;
4536 struct dentry *edma_tx_d = NULL;
4537 struct dentry *edma_rx_dir_d = NULL;
4538 struct dentry *edma_rx_d = NULL;
4539 struct dentry *edma_txcmpl_dir_d = NULL;
4540 struct dentry *edma_txcmpl_d = NULL;
4541 struct dentry *edma_rxfill_dir_d = NULL;
4542 struct dentry *edma_rxfill_d = NULL;
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004543 struct dentry *edma_err_stats_d = NULL;
Shashank Balashankar512cb602016-08-01 17:57:42 -07004544
Amit Gupta79c1c202017-06-30 15:28:13 +05304545 struct dentry *ppe_code_d = NULL;
4546 struct dentry *ppe_drop_d = NULL;
4547 struct dentry *ppe_port_dc_d = NULL;
4548 struct dentry *ppe_cpu_d = NULL;
4549 struct dentry *ppe_exception_d = NULL;
4550 struct dentry *ppe_nonexception_d = NULL;
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004551 struct dentry *core_dentry = NULL;
4552 struct dentry *wt_dentry = NULL;
4553
Amit Gupta79c1c202017-06-30 15:28:13 +05304554
Shashank Balashankar512cb602016-08-01 17:57:42 -07004555 char file_name[10];
4556
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304557 /*
4558 * NSS driver entry
4559 */
4560 nss_top_main.top_dentry = debugfs_create_dir("qca-nss-drv", NULL);
4561 if (unlikely(nss_top_main.top_dentry == NULL)) {
4562 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4563
4564 /*
4565 * Non availability of debugfs directory is not a catastrophy
4566 * We can still go ahead with other initialization
4567 */
4568 return;
4569 }
4570
4571 nss_top_main.stats_dentry = debugfs_create_dir("stats", nss_top_main.top_dentry);
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304572 if (unlikely(nss_top_main.stats_dentry == NULL)) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304573 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4574
4575 /*
4576 * Non availability of debugfs directory is not a catastrophy
4577 * We can still go ahead with rest of initialization
4578 */
4579 return;
4580 }
4581
4582 /*
4583 * Create files to obtain statistics
4584 */
4585
4586 /*
4587 * ipv4_stats
4588 */
4589 nss_top_main.ipv4_dentry = debugfs_create_file("ipv4", 0400,
4590 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_ops);
4591 if (unlikely(nss_top_main.ipv4_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304592 nss_warning("Failed to create qca-nss-drv/stats/ipv4 file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304593 return;
4594 }
4595
4596 /*
Selin Dag6d9b0c12014-11-04 18:27:21 -08004597 * ipv4_reasm_stats
4598 */
4599 nss_top_main.ipv4_reasm_dentry = debugfs_create_file("ipv4_reasm", 0400,
4600 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_reasm_ops);
4601 if (unlikely(nss_top_main.ipv4_reasm_dentry == NULL)) {
4602 nss_warning("Failed to create qca-nss-drv/stats/ipv4_reasm file in debugfs");
4603 return;
4604 }
4605
4606 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304607 * ipv6_stats
4608 */
4609 nss_top_main.ipv6_dentry = debugfs_create_file("ipv6", 0400,
4610 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_ops);
4611 if (unlikely(nss_top_main.ipv6_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304612 nss_warning("Failed to create qca-nss-drv/stats/ipv6 file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304613 return;
4614 }
4615
4616 /*
Selin Dag60a2f5b2015-06-29 14:39:49 -07004617 * ipv6_reasm_stats
4618 */
4619 nss_top_main.ipv6_reasm_dentry = debugfs_create_file("ipv6_reasm", 0400,
4620 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_reasm_ops);
4621 if (unlikely(nss_top_main.ipv6_reasm_dentry == NULL)) {
4622 nss_warning("Failed to create qca-nss-drv/stats/ipv6_reasm file in debugfs");
4623 return;
4624 }
4625
4626 /*
4627 * eth_rx__stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304628 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304629 nss_top_main.eth_rx_dentry = debugfs_create_file("eth_rx", 0400,
4630 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_eth_rx_ops);
4631 if (unlikely(nss_top_main.eth_rx_dentry == NULL)) {
4632 nss_warning("Failed to create qca-nss-drv/stats/eth_rx file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304633 return;
4634 }
4635
4636 /*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004637 * edma stats
4638 */
4639 edma_d = debugfs_create_dir("edma", nss_top_main.stats_dentry);
4640 if (unlikely(edma_d == NULL)) {
4641 nss_warning("Failed to create qca-nss-drv/stats/edma directory in debugfs");
4642 return;
4643 }
4644
4645 /*
4646 * edma port stats
4647 */
4648 edma_port_dir_d = debugfs_create_dir("ports", edma_d);
4649 if (unlikely(edma_port_dir_d == NULL)) {
4650 nss_warning("Failed to create qca-nss-drv/stats/edma/ports directory in debugfs");
4651 return;
4652 }
4653
4654 for (i = 0; i < NSS_EDMA_NUM_PORTS_MAX; i++) {
4655 memset(file_name, 0, sizeof(file_name));
4656 snprintf(file_name, sizeof(file_name), "%d", i);
4657 edma_port_d = NULL;
4658 edma_port_stats_d = NULL;
4659 edma_port_type_d = NULL;
4660 edma_port_ring_map_d = NULL;
4661
4662 edma_port_d = debugfs_create_dir(file_name, edma_port_dir_d);
4663 if (unlikely(edma_port_d == NULL)) {
4664 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d dir in debugfs", i);
4665 return;
4666 }
4667
Stephen Wangaed46332016-12-12 17:29:03 -08004668 edma_port_stats_d = debugfs_create_file("stats", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_stats_edma_port_stats_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004669 if (unlikely(edma_port_stats_d == NULL)) {
4670 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/stats file in debugfs", i);
4671 return;
4672 }
4673
Stephen Wangaed46332016-12-12 17:29:03 -08004674 edma_port_type_d = debugfs_create_file("type", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_stats_edma_port_type_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004675 if (unlikely(edma_port_type_d == NULL)) {
4676 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/type file in debugfs", i);
4677 return;
4678 }
4679
Stephen Wangaed46332016-12-12 17:29:03 -08004680 edma_port_ring_map_d = debugfs_create_file("ring_map", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_stats_edma_port_ring_map_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004681 if (unlikely(edma_port_ring_map_d == NULL)) {
4682 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/ring_map file in debugfs", i);
4683 return;
4684 }
4685 }
4686
4687 /*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004688 * edma error stats
4689 */
4690 edma_err_stats_d = NULL;
4691 edma_err_stats_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_stats_edma_err_stats_ops);
4692 if (unlikely(edma_port_stats_d == NULL)) {
4693 nss_warning("Failed to create qca-nss-drv/stats/edma/%d/err_stats file in debugfs", 0);
4694 return;
4695 }
4696
4697 /*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004698 * edma ring stats
4699 */
4700 edma_rings_dir_d = debugfs_create_dir("rings", edma_d);
4701 if (unlikely(edma_rings_dir_d == NULL)) {
4702 nss_warning("Failed to create qca-nss-drv/stats/edma/rings directory in debugfs");
4703 return;
4704 }
4705
4706 /*
4707 * edma tx ring stats
4708 */
4709 edma_tx_dir_d = debugfs_create_dir("tx", edma_rings_dir_d);
4710 if (unlikely(edma_tx_dir_d == NULL)) {
4711 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx directory in debugfs");
4712 return;
4713 }
4714
4715 for (i = 0; i < NSS_EDMA_NUM_TX_RING_MAX; i++) {
4716 memset(file_name, 0, sizeof(file_name));
4717 scnprintf(file_name, sizeof(file_name), "%d", i);
4718 edma_tx_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004719 edma_tx_d = debugfs_create_file(file_name, 0400, edma_tx_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_txring_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004720 if (unlikely(edma_tx_d == NULL)) {
4721 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx/%d file in debugfs", i);
4722 return;
4723 }
4724 }
4725
4726 /*
4727 * edma rx ring stats
4728 */
4729 edma_rx_dir_d = debugfs_create_dir("rx", edma_rings_dir_d);
4730 if (unlikely(edma_rx_dir_d == NULL)) {
4731 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx directory in debugfs");
4732 return;
4733 }
4734
4735 for (i = 0; i < NSS_EDMA_NUM_RX_RING_MAX; i++) {
4736 memset(file_name, 0, sizeof(file_name));
4737 scnprintf(file_name, sizeof(file_name), "%d", i);
4738 edma_rx_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004739 edma_rx_d = debugfs_create_file(file_name, 0400, edma_rx_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_rxring_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004740 if (unlikely(edma_rx_d == NULL)) {
4741 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx/%d file in debugfs", i);
4742 return;
4743 }
4744 }
4745
4746 /*
4747 * edma tx cmpl ring stats
4748 */
4749 edma_txcmpl_dir_d = debugfs_create_dir("txcmpl", edma_rings_dir_d);
4750 if (unlikely(edma_txcmpl_dir_d == NULL)) {
4751 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl directory in debugfs");
4752 return;
4753 }
4754
4755 for (i = 0; i < NSS_EDMA_NUM_TXCMPL_RING_MAX; i++) {
4756 memset(file_name, 0, sizeof(file_name));
4757 scnprintf(file_name, sizeof(file_name), "%d", i);
4758 edma_txcmpl_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004759 edma_txcmpl_d = debugfs_create_file(file_name, 0400, edma_txcmpl_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_txcmplring_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004760 if (unlikely(edma_txcmpl_d == NULL)) {
4761 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl/%d file in debugfs", i);
4762 return;
4763 }
4764 }
4765
4766 /*
4767 * edma rx fill ring stats
4768 */
4769 edma_rxfill_dir_d = debugfs_create_dir("rxfill", edma_rings_dir_d);
4770 if (unlikely(edma_rxfill_dir_d == NULL)) {
4771 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill directory in debugfs");
4772 return;
4773 }
4774
4775 for (i = 0; i < NSS_EDMA_NUM_RXFILL_RING_MAX; i++) {
4776 memset(file_name, 0, sizeof(file_name));
4777 scnprintf(file_name, sizeof(file_name), "%d", i);
4778 edma_rxfill_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004779 edma_rxfill_d = debugfs_create_file(file_name, 0400, edma_rxfill_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_rxfillring_ops);
Shashank Balashankar512cb602016-08-01 17:57:42 -07004780 if (unlikely(edma_rxfill_d == NULL)) {
4781 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill/%d file in debugfs", i);
4782 return;
4783 }
4784 }
4785
4786 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304787 * n2h_stats
4788 */
4789 nss_top_main.n2h_dentry = debugfs_create_file("n2h", 0400,
4790 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_n2h_ops);
4791 if (unlikely(nss_top_main.n2h_dentry == NULL)) {
4792 nss_warning("Failed to create qca-nss-drv/stats/n2h directory in debugfs");
4793 return;
4794 }
4795
4796 /*
Thomas Wuc3e382c2014-10-29 15:35:13 -07004797 * lso_rx_stats
4798 */
4799 nss_top_main.lso_rx_dentry = debugfs_create_file("lso_rx", 0400,
4800 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_lso_rx_ops);
4801 if (unlikely(nss_top_main.lso_rx_dentry == NULL)) {
4802 nss_warning("Failed to create qca-nss-drv/stats/lso_rx file in debugfs");
4803 return;
4804 }
4805
4806 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304807 * drv_stats
4808 */
4809 nss_top_main.drv_dentry = debugfs_create_file("drv", 0400,
4810 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_drv_ops);
4811 if (unlikely(nss_top_main.drv_dentry == NULL)) {
4812 nss_warning("Failed to create qca-nss-drv/stats/drv directory in debugfs");
4813 return;
4814 }
4815
4816 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304817 * pppoe_stats
4818 */
4819 nss_top_main.pppoe_dentry = debugfs_create_file("pppoe", 0400,
4820 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pppoe_ops);
4821 if (unlikely(nss_top_main.pppoe_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304822 nss_warning("Failed to create qca-nss-drv/stats/pppoe file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304823 return;
4824 }
4825
4826 /*
4827 * gmac_stats
4828 */
4829 nss_top_main.gmac_dentry = debugfs_create_file("gmac", 0400,
4830 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gmac_ops);
4831 if (unlikely(nss_top_main.gmac_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304832 nss_warning("Failed to create qca-nss-drv/stats/gmac file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304833 return;
4834 }
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004835
4836 /*
4837 * CAPWAP stats.
4838 */
4839 nss_top_main.capwap_encap_dentry = debugfs_create_file("capwap_encap", 0400,
4840 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_encap_ops);
4841 if (unlikely(nss_top_main.capwap_encap_dentry == NULL)) {
4842 nss_warning("Failed to create qca-nss-drv/stats/capwap_encap file in debugfs");
4843 return;
4844 }
4845
4846 nss_top_main.capwap_decap_dentry = debugfs_create_file("capwap_decap", 0400,
4847 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_decap_ops);
4848 if (unlikely(nss_top_main.capwap_decap_dentry == NULL)) {
4849 nss_warning("Failed to create qca-nss-drv/stats/capwap_decap file in debugfs");
4850 return;
4851 }
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304852
4853 /*
4854 * GRE_REDIR stats
4855 */
4856 nss_top_main.gre_redir_dentry = debugfs_create_file("gre_redir", 0400,
Ankit Dhanuka14999992014-11-12 15:35:11 +05304857 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gre_redir_ops);
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304858 if (unlikely(nss_top_main.gre_redir_dentry == NULL)) {
4859 nss_warning("Failed to create qca-nss-drv/stats/gre_redir file in debugfs");
4860 return;
4861 }
Ankit Dhanuka14999992014-11-12 15:35:11 +05304862
4863 /*
4864 * SJACK stats
4865 */
4866 nss_top_main.sjack_dentry = debugfs_create_file("sjack", 0400,
4867 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_sjack_ops);
4868 if (unlikely(nss_top_main.sjack_dentry == NULL)) {
4869 nss_warning("Failed to create qca-nss-drv/stats/sjack file in debugfs");
4870 return;
4871 }
Saurabh Misra96998db2014-07-10 12:15:48 -07004872
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304873 /*
Stephen Wang9779d952015-10-28 11:39:07 -07004874 * PORTID stats
4875 */
4876 nss_top_main.portid_dentry = debugfs_create_file("portid", 0400,
4877 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_portid_ops);
4878 if (unlikely(nss_top_main.portid_dentry == NULL)) {
4879 nss_warning("Failed to create qca-nss-drv/stats/portid file in debugfs");
4880 return;
4881 }
4882
4883 /*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304884 * WIFI stats
4885 */
4886 nss_top_main.wifi_dentry = debugfs_create_file("wifi", 0400,
4887 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_ops);
4888 if (unlikely(nss_top_main.wifi_dentry == NULL)) {
4889 nss_warning("Failed to create qca-nss-drv/stats/wifi file in debugfs");
4890 return;
4891 }
4892
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08004893 /*
4894 * wifi_if stats
4895 */
4896 nss_top_main.wifi_if_dentry = debugfs_create_file("wifi_if", 0400,
4897 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_if_ops);
4898 if (unlikely(nss_top_main.wifi_if_dentry == NULL)) {
4899 nss_warning("Failed to create qca-nss-drv/stats/wifi_if file in debugfs");
4900 return;
4901 }
4902
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004903 nss_top_main.virt_if_dentry = debugfs_create_file("virt_if", 0400,
4904 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_virt_if_ops);
4905 if (unlikely(nss_top_main.virt_if_dentry == NULL)) {
4906 nss_warning("Failed to create qca-nss-drv/stats/virt_if file in debugfs");
4907 return;
4908 }
4909
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004910 nss_top_main.tx_rx_virt_if_dentry = debugfs_create_file("tx_rx_virt_if", 0400,
4911 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_tx_rx_virt_if_ops);
4912 if (unlikely(nss_top_main.virt_if_dentry == NULL)) {
4913 nss_warning("Failed to create qca-nss-drv/stats/tx_rx_virt_if file in debugfs");
4914 return;
4915 }
4916
ratheesh kannoth7af985d2015-06-24 15:08:40 +05304917 /*
4918 * L2TPV2 Stats
4919 */
4920 nss_top_main.l2tpv2_dentry = debugfs_create_file("l2tpv2", 0400,
4921 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_l2tpv2_ops);
4922 if (unlikely(nss_top_main.l2tpv2_dentry == NULL)) {
4923 nss_warning("Failed to create qca-nss-drv/stats/l2tpv2 file in debugfs");
4924 return;
4925 }
Shyam Sunder66e889d2015-11-02 15:31:20 +05304926
4927 /*
ratheesh kannotha1245c32015-11-04 16:45:43 +05304928 * Map-t Stats
4929 */
4930 nss_top_main.map_t_dentry = debugfs_create_file("map_t", 0400,
4931 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_map_t_ops);
4932 if (unlikely(nss_top_main.map_t_dentry == NULL)) {
4933 nss_warning("Failed to create qca-nss-drv/stats/map_t file in debugfs");
4934 return;
4935 }
4936
4937 /*
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05304938 * GRE statistics
4939 */
4940 nss_top_main.gre_dentry = debugfs_create_file("gre", 0400,
4941 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gre_ops);
4942 if (unlikely(nss_top_main.gre_dentry == NULL)) {
4943 nss_warning("Failed to create qca-nss-drv/stats/gre file in debugfs");
4944 return;
4945 }
4946
4947 /*
Amit Gupta316729b2016-08-12 12:21:15 +05304948 * PPE Stats
4949 */
4950 nss_top_main.ppe_dentry = debugfs_create_dir("ppe", nss_top_main.stats_dentry);
4951 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4952 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4953 return;
4954 }
4955
4956 nss_top_main.ppe_conn_dentry = debugfs_create_file("connection", 0400,
4957 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_conn_ops);
4958 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4959 nss_warning("Failed to create qca-nss-drv/stats/ppe/connection file in debugfs");
4960 }
4961
4962 nss_top_main.ppe_l3_dentry = debugfs_create_file("l3", 0400,
4963 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_l3_ops);
4964 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4965 nss_warning("Failed to create qca-nss-drv/stats/ppe/l3 file in debugfs");
4966 }
4967
4968 nss_top_main.ppe_l3_dentry = debugfs_create_file("ppe_code", 0400,
4969 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_code_ops);
4970 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4971 nss_warning("Failed to create qca-nss-drv/stats/ppe/ppe_code file in debugfs");
4972 }
4973
4974 /*
Amit Gupta79c1c202017-06-30 15:28:13 +05304975 * ppe exception and drop code stats
4976 */
4977 ppe_code_d = debugfs_create_dir("code", nss_top_main.ppe_dentry);
4978 if (unlikely(ppe_code_d == NULL)) {
4979 nss_warning("Failed to create qca-nss-drv/stats/ppe/code directory in debugfs");
4980 return;
4981 }
4982
4983 ppe_cpu_d = debugfs_create_dir("cpu", ppe_code_d);
4984 if (unlikely(ppe_cpu_d == NULL)) {
4985 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/cpu directory in debugfs");
4986 return;
4987 }
4988
4989 ppe_exception_d = debugfs_create_file("exception", 0400, ppe_cpu_d,
4990 &nss_top_main, &nss_stats_ppe_exception_cc_ops);
4991 if (unlikely(ppe_exception_d == NULL)) {
4992 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/exception file in debugfs");
4993 return;
4994 }
4995
4996 ppe_nonexception_d = debugfs_create_file("non-exception", 0400, ppe_cpu_d,
4997 &nss_top_main, &nss_stats_ppe_nonexception_cc_ops);
4998 if (unlikely(ppe_nonexception_d == NULL)) {
4999 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/non-exception file in debugfs");
5000 return;
5001 }
5002
5003 ppe_drop_d = debugfs_create_dir("drop", ppe_code_d);
5004 if (unlikely(ppe_drop_d == NULL)) {
5005 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop directory in debugfs");
5006 return;
5007 }
5008
5009 for (i = 0; i < NSS_PPE_NUM_PHY_PORTS_MAX; i++) {
5010 if (i > 0) {
5011 memset(file_name, 0, sizeof(file_name));
5012 snprintf(file_name, sizeof(file_name), "%d", i);
5013 }
5014
5015 ppe_port_dc_d = NULL;
5016 ppe_port_dc_d = debugfs_create_file((i == 0) ? "cpu" : file_name, 0400, ppe_drop_d,
5017 (void *)(nss_ptr_t)i, &nss_stats_ppe_port_dc_ops);
5018 if (unlikely(ppe_port_dc_d == NULL)) {
5019 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop/%d file in debugfs", i);
5020 return;
5021 }
5022 }
5023
5024 /*
Shyam Sunder66e889d2015-11-02 15:31:20 +05305025 * PPTP Stats
5026 */
5027 nss_top_main.pptp_dentry = debugfs_create_file("pptp", 0400,
5028 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pptp_ops);
5029 if (unlikely(nss_top_main.pptp_dentry == NULL)) {
5030 nss_warning("Failed to create qca-nss-drv/stats/pptp file in debugfs");
Tushar Mathurff8741b2015-12-02 20:28:59 +05305031 }
5032
5033 /*
5034 * DTLS Stats
5035 */
5036 nss_top_main.dtls_dentry = debugfs_create_file("dtls", 0400,
5037 nss_top_main.stats_dentry,
5038 &nss_top_main,
5039 &nss_stats_dtls_ops);
5040 if (unlikely(nss_top_main.dtls_dentry == NULL)) {
5041 nss_warning("Failed to create qca-nss-drv/stats/dtls file in debugfs");
Shyam Sunder66e889d2015-11-02 15:31:20 +05305042 return;
5043 }
5044
Thomas Wu71c5ecc2016-06-21 11:15:52 -07005045 /*
5046 * GRE Tunnel Stats
5047 */
5048 nss_top_main.gre_tunnel_dentry = debugfs_create_file("gre_tunnel", 0400,
5049 nss_top_main.stats_dentry,
5050 &nss_top_main,
5051 &nss_stats_gre_tunnel_ops);
5052 if (unlikely(nss_top_main.gre_tunnel_dentry == NULL)) {
5053 nss_warning("Failed to create qca-nss-drv/stats/gre_tunnel file in debugfs");
5054 return;
5055 }
5056
Stephen Wangec5a85c2016-09-08 23:32:27 -07005057 /*
5058 * TrustSec TX Stats
5059 */
5060 nss_top_main.trustsec_tx_dentry = debugfs_create_file("trustsec_tx", 0400,
5061 nss_top_main.stats_dentry,
5062 &nss_top_main,
5063 &nss_stats_trustsec_tx_ops);
5064 if (unlikely(nss_top_main.trustsec_tx_dentry == NULL)) {
5065 nss_warning("Failed to create qca-nss-drv/stats/trustsec_tx file in debugfs");
5066 return;
5067 }
5068
Aniruddha Paul1b170c22017-05-29 12:30:39 +05305069 /*
5070 * WIFILI stats
5071 */
5072 nss_top_main.wifili_dentry = debugfs_create_file("wifili", 0400,
5073 nss_top_main.stats_dentry,
5074 &nss_top_main, &nss_stats_wifili_ops);
5075 if (unlikely(nss_top_main.wifili_dentry == NULL)) {
5076 nss_warning("Failed to create qca-nss-drv/stats/wifili file in debugfs");
5077 return;
5078 }
5079
Jackson Bockusc2a4e682017-06-23 11:59:29 -07005080 /*
5081 * Per-project stats
5082 */
5083 nss_top_main.project_dentry = debugfs_create_dir("project",
5084 nss_top_main.stats_dentry);
5085 if (unlikely(nss_top_main.project_dentry == NULL)) {
5086 nss_warning("Failed to create qca-nss-drv/stats/project directory in debugfs");
5087 return;
5088 }
5089
5090 for (i = 0; i < NSS_MAX_CORES; ++i) {
5091 memset(file_name, 0, sizeof(file_name));
5092 scnprintf(file_name, sizeof(file_name), "core%d", i);
5093 core_dentry = debugfs_create_dir(file_name,
5094 nss_top_main.project_dentry);
5095 if (unlikely(core_dentry == NULL)) {
5096 nss_warning("Failed to create qca-nss-drv/stats/project/core%d directory in debugfs", i);
5097 return;
5098 }
5099
5100 wt_dentry = debugfs_create_file("worker_threads",
5101 0400,
5102 core_dentry,
5103 &(nss_top_main.nss[i]),
5104 &nss_stats_wt_ops);
5105 if (unlikely(wt_dentry == NULL)) {
5106 nss_warning("Failed to create qca-nss-drv/stats/project/core%d/worker_threads file in debugfs", i);
5107 return;
5108 }
5109 }
5110
Saurabh Misra96998db2014-07-10 12:15:48 -07005111 nss_log_init();
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305112}
5113
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305114/*
5115 * nss_stats_clean()
5116 * Cleanup NSS statistics files
5117 */
5118void nss_stats_clean(void)
5119{
5120 /*
5121 * Remove debugfs tree
5122 */
5123 if (likely(nss_top_main.top_dentry != NULL)) {
5124 debugfs_remove_recursive(nss_top_main.top_dentry);
Stephen Wangdc8b5322015-06-27 20:11:50 -07005125 nss_top_main.top_dentry = NULL;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305126 }
5127}