blob: f0343a80ba0b3ab5d8f46241a83e0a2b1075b2e5 [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",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700178 "paged_buf_alloc_errors",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530179 "tx_queue_full[0]",
180 "tx_queue_full[1]",
181 "tx_buffers_empty",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700182 "tx_paged_buffers_empty",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530183 "tx_buffers_pkt",
184 "tx_buffers_cmd",
185 "tx_buffers_crypto",
Murat Sezginb6e1a012015-09-29 14:06:37 -0700186 "tx_buffers_reuse",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530187 "rx_buffers_empty",
188 "rx_buffers_pkt",
189 "rx_buffers_cmd_resp",
190 "rx_buffers_status_sync",
191 "rx_buffers_crypto",
Thomas Wu0acd8162014-12-07 15:43:39 -0800192 "rx_buffers_virtual",
193 "tx_skb_simple",
194 "tx_skb_nr_frags",
195 "tx_skb_fraglist",
196 "rx_skb_simple",
197 "rx_skb_nr_frags",
198 "rx_skb_fraglist",
Sundarajan Srinivasan6e0366b2015-01-20 12:10:42 -0800199 "rx_bad_desciptor",
Thomas Wu1fbf5212015-06-04 14:38:40 -0700200 "nss_skb_count",
201 "rx_chain_seg_processed",
202 "rx_frag_seg_processed"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530203};
204
205/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530206 * nss_stats_str_pppoe
207 * PPPoE stats strings
208 */
209static int8_t *nss_stats_str_pppoe[NSS_STATS_PPPOE_MAX] = {
210 "create_requests",
211 "create_failures",
212 "destroy_requests",
213 "destroy_misses"
214};
215
216/*
217 * nss_stats_str_gmac
218 * GMAC stats strings
219 */
220static int8_t *nss_stats_str_gmac[NSS_STATS_GMAC_MAX] = {
221 "ticks",
222 "worst_ticks",
223 "iterations"
224};
225
226/*
Shashank Balashankar512cb602016-08-01 17:57:42 -0700227 * nss_stats_str_edma_tx
228 */
229static int8_t *nss_stats_str_edma_tx[NSS_STATS_EDMA_TX_MAX] = {
230 "tx_err",
231 "tx_dropped",
232 "desc_cnt"
233};
234
235/*
236 * nss_stats_str_edma_rx
237 */
238static int8_t *nss_stats_str_edma_rx[NSS_STATS_EDMA_RX_MAX] = {
239 "rx_csum_err",
Shashank Balashankarcbe48992017-06-27 13:51:28 -0700240 "desc_cnt",
241 "qos_err"
Shashank Balashankar512cb602016-08-01 17:57:42 -0700242};
243
244/*
245 * nss_stats_str_edma_txcmpl
246 */
247static int8_t *nss_stats_str_edma_txcmpl[NSS_STATS_EDMA_TXCMPL_MAX] = {
248 "desc_cnt"
249};
250
251/*
252 * nss_stats_str_edma_rxfill
253 */
254static int8_t *nss_stats_str_edma_rxfill[NSS_STATS_EDMA_RXFILL_MAX] = {
255 "desc_cnt"
256};
257
258/*
259 * nss_stats_str_edma_port_type
260 */
261static int8_t *nss_stats_str_edma_port_type[NSS_EDMA_PORT_TYPE_MAX] = {
262 "physical_port",
263 "virtual_port"
264};
265
266/*
267 * nss_stats_str_edma_port_ring_map
268 */
269static int8_t *nss_stats_str_edma_port_ring_map[NSS_EDMA_PORT_RING_MAP_MAX] = {
270 "rx_ring",
271 "tx_ring"
272};
273
274/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -0700275 * nss_stats_str_edma_err_map
276 */
277static int8_t *nss_stats_str_edma_err_map[NSS_EDMA_ERR_STATS_MAX] = {
278 "axi_rd_err",
279 "axi_wr_err",
280 "rx_desc_fifo_full_err",
281 "rx_buf_size_err",
282 "tx_sram_full_err",
283 "tx_cmpl_buf_full_err",
284 "pkt_len_la64k_err",
285 "pkt_len_le33_err",
Santosh Kivati28c20042017-07-11 16:47:57 -0700286 "data_len_err",
287 "alloc_fail_cnt"
Santosh Kivatib65b68b2017-05-18 13:30:58 -0700288};
289
290/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530291 * nss_stats_str_node
292 * Interface stats strings per node
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530293 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530294static int8_t *nss_stats_str_node[NSS_STATS_NODE_MAX] = {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530295 "rx_packets",
296 "rx_bytes",
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530297 "rx_dropped",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530298 "tx_packets",
299 "tx_bytes"
300};
301
302/*
Murat Sezgin99dab642014-08-28 14:40:34 -0700303 * nss_stats_str_eth_rx
304 * eth_rx stats strings
305 */
306static int8_t *nss_stats_str_eth_rx[NSS_STATS_ETH_RX_MAX] = {
307 "ticks",
308 "worst_ticks",
309 "iterations"
310};
311
312/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530313 * nss_stats_str_if_exception_unknown
314 * Interface stats strings for unknown exceptions
315 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530316static int8_t *nss_stats_str_if_exception_eth_rx[NSS_EXCEPTION_EVENT_ETH_RX_MAX] = {
Selin Dag2e8e48c2015-02-20 15:51:55 -0800317 "UNKNOWN_L3_PROTOCOL",
318 "ETH_HDR_MISSING",
Stephen Wangec5a85c2016-09-08 23:32:27 -0700319 "VLAN_MISSING",
320 "TRUSTSEC_HDR_MISSING"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530321};
322
323/*
324 * nss_stats_str_if_exception_ipv4
325 * Interface stats strings for ipv4 exceptions
326 */
327static int8_t *nss_stats_str_if_exception_ipv4[NSS_EXCEPTION_EVENT_IPV4_MAX] = {
328 "IPV4_ICMP_HEADER_INCOMPLETE",
329 "IPV4_ICMP_UNHANDLED_TYPE",
330 "IPV4_ICMP_IPV4_HEADER_INCOMPLETE",
331 "IPV4_ICMP_IPV4_UDP_HEADER_INCOMPLETE",
332 "IPV4_ICMP_IPV4_TCP_HEADER_INCOMPLETE",
333 "IPV4_ICMP_IPV4_UNKNOWN_PROTOCOL",
334 "IPV4_ICMP_NO_ICME",
335 "IPV4_ICMP_FLUSH_TO_HOST",
336 "IPV4_TCP_HEADER_INCOMPLETE",
337 "IPV4_TCP_NO_ICME",
338 "IPV4_TCP_IP_OPTION",
339 "IPV4_TCP_IP_FRAGMENT",
340 "IPV4_TCP_SMALL_TTL",
341 "IPV4_TCP_NEEDS_FRAGMENTATION",
342 "IPV4_TCP_FLAGS",
343 "IPV4_TCP_SEQ_EXCEEDS_RIGHT_EDGE",
344 "IPV4_TCP_SMALL_DATA_OFFS",
345 "IPV4_TCP_BAD_SACK",
346 "IPV4_TCP_BIG_DATA_OFFS",
347 "IPV4_TCP_SEQ_BEFORE_LEFT_EDGE",
348 "IPV4_TCP_ACK_EXCEEDS_RIGHT_EDGE",
349 "IPV4_TCP_ACK_BEFORE_LEFT_EDGE",
350 "IPV4_UDP_HEADER_INCOMPLETE",
351 "IPV4_UDP_NO_ICME",
352 "IPV4_UDP_IP_OPTION",
353 "IPV4_UDP_IP_FRAGMENT",
354 "IPV4_UDP_SMALL_TTL",
355 "IPV4_UDP_NEEDS_FRAGMENTATION",
356 "IPV4_WRONG_TARGET_MAC",
357 "IPV4_HEADER_INCOMPLETE",
358 "IPV4_BAD_TOTAL_LENGTH",
359 "IPV4_BAD_CHECKSUM",
360 "IPV4_NON_INITIAL_FRAGMENT",
361 "IPV4_DATAGRAM_INCOMPLETE",
362 "IPV4_OPTIONS_INCOMPLETE",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530363 "IPV4_UNKNOWN_PROTOCOL",
364 "IPV4_ESP_HEADER_INCOMPLETE",
365 "IPV4_ESP_NO_ICME",
366 "IPV4_ESP_IP_OPTION",
367 "IPV4_ESP_IP_FRAGMENT",
368 "IPV4_ESP_SMALL_TTL",
369 "IPV4_ESP_NEEDS_FRAGMENTATION",
370 "IPV4_INGRESS_VID_MISMATCH",
Thomas Wu8d6f4b22014-06-09 14:46:18 -0700371 "IPV4_INGRESS_VID_MISSING",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530372 "IPV4_6RD_NO_ICME",
373 "IPV4_6RD_IP_OPTION",
374 "IPV4_6RD_IP_FRAGMENT",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700375 "IPV4_6RD_NEEDS_FRAGMENTATION",
376 "IPV4_DSCP_MARKING_MISMATCH",
Murat Sezgin7c5956a2014-05-12 09:59:51 -0700377 "IPV4_VLAN_MARKING_MISMATCH",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800378 "IPV4_DEPRECATED",
Radha krishna Simha Jiguru00cfe562014-10-21 16:22:12 +0530379 "IPV4_GRE_HEADER_INCOMPLETE",
380 "IPV4_GRE_NO_ICME",
381 "IPV4_GRE_IP_OPTION",
382 "IPV4_GRE_IP_FRAGMENT",
383 "IPV4_GRE_SMALL_TTL",
384 "IPV4_GRE_NEEDS_FRAGMENTATION",
Shyam Sundere351f1b2015-12-17 14:11:51 +0530385 "IPV4_PPTP_GRE_SESSION_MATCH_FAIL",
386 "IPV4_PPTP_GRE_INVALID_PROTO",
387 "IPV4_PPTP_GRE_NO_CME",
388 "IPV4_PPTP_GRE_IP_OPTION",
389 "IPV4_PPTP_GRE_IP_FRAGMENT",
390 "IPV4_PPTP_GRE_SMALL_TTL",
391 "IPV4_PPTP_GRE_NEEDS_FRAGMENTATION",
392 "IPV4_DESTROY",
Selin Dag60ea2b22014-11-05 09:36:22 -0800393 "IPV4_FRAG_DF_SET",
394 "IPV4_FRAG_FAIL",
Saurabh Misra5b07cc02015-01-15 14:20:58 -0800395 "IPV4_ICMP_IPV4_UDPLITE_HEADER_INCOMPLETE",
396 "IPV4_UDPLITE_HEADER_INCOMPLETE",
397 "IPV4_UDPLITE_NO_ICME",
398 "IPV4_UDPLITE_IP_OPTION",
399 "IPV4_UDPLITE_IP_FRAGMENT",
400 "IPV4_UDPLITE_SMALL_TTL",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530401 "IPV4_UDPLITE_NEEDS_FRAGMENTATION",
402 "IPV4_MC_UDP_NO_ICME",
403 "IPV4_MC_MEM_ALLOC_FAILURE",
404 "IPV4_MC_UPDATE_FAILURE",
405 "IPV4_MC_PBUF_ALLOC_FAILURE"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530406};
407
408/*
409 * nss_stats_str_if_exception_ipv6
410 * Interface stats strings for ipv6 exceptions
411 */
412static int8_t *nss_stats_str_if_exception_ipv6[NSS_EXCEPTION_EVENT_IPV6_MAX] = {
413 "IPV6_ICMP_HEADER_INCOMPLETE",
414 "IPV6_ICMP_UNHANDLED_TYPE",
415 "IPV6_ICMP_IPV6_HEADER_INCOMPLETE",
416 "IPV6_ICMP_IPV6_UDP_HEADER_INCOMPLETE",
417 "IPV6_ICMP_IPV6_TCP_HEADER_INCOMPLETE",
418 "IPV6_ICMP_IPV6_UNKNOWN_PROTOCOL",
419 "IPV6_ICMP_NO_ICME",
420 "IPV6_ICMP_FLUSH_TO_HOST",
421 "IPV6_TCP_HEADER_INCOMPLETE",
422 "IPV6_TCP_NO_ICME",
423 "IPV6_TCP_SMALL_HOP_LIMIT",
424 "IPV6_TCP_NEEDS_FRAGMENTATION",
425 "IPV6_TCP_FLAGS",
426 "IPV6_TCP_SEQ_EXCEEDS_RIGHT_EDGE",
427 "IPV6_TCP_SMALL_DATA_OFFS",
428 "IPV6_TCP_BAD_SACK",
429 "IPV6_TCP_BIG_DATA_OFFS",
430 "IPV6_TCP_SEQ_BEFORE_LEFT_EDGE",
431 "IPV6_TCP_ACK_EXCEEDS_RIGHT_EDGE",
432 "IPV6_TCP_ACK_BEFORE_LEFT_EDGE",
433 "IPV6_UDP_HEADER_INCOMPLETE",
434 "IPV6_UDP_NO_ICME",
435 "IPV6_UDP_SMALL_HOP_LIMIT",
436 "IPV6_UDP_NEEDS_FRAGMENTATION",
437 "IPV6_WRONG_TARGET_MAC",
438 "IPV6_HEADER_INCOMPLETE",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530439 "IPV6_UNKNOWN_PROTOCOL",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700440 "IPV6_INGRESS_VID_MISMATCH",
Thomas Wu8d6f4b22014-06-09 14:46:18 -0700441 "IPV6_INGRESS_VID_MISSING",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700442 "IPV6_DSCP_MARKING_MISMATCH",
443 "IPV6_VLAN_MARKING_MISMATCH",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800444 "IPV6_DEPRECATED",
Saurabh Misra5b07cc02015-01-15 14:20:58 -0800445 "IPV6_GRE_NO_ICME",
446 "IPV6_GRE_NEEDS_FRAGMENTATION",
447 "IPV6_GRE_SMALL_HOP_LIMIT",
448 "IPV6_DESTROY",
449 "IPV6_ICMP_IPV6_UDPLITE_HEADER_INCOMPLETE",
450 "IPV6_UDPLITE_HEADER_INCOMPLETE",
451 "IPV6_UDPLITE_NO_ICME",
452 "IPV6_UDPLITE_SMALL_HOP_LIMIT",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530453 "IPV6_UDPLITE_NEEDS_FRAGMENTATION",
454 "IPV6_MC_UDP_NO_ICME",
455 "IPV6_MC_MEM_ALLOC_FAILURE",
456 "IPV6_MC_UPDATE_FAILURE",
mandrw7125bac2016-01-14 19:36:46 +0530457 "IPV6_MC_PBUF_ALLOC_FAILURE",
458 "IPV6_ESP_HEADER_INCOMPLETE",
459 "IPV6_ESP_NO_ICME",
460 "IPV6_ESP_IP_FRAGMENT",
461 "IPV6_ESP_SMALL_HOP_LIMIT",
462 "IPV6_ESP_NEEDS_FRAGMENTATION"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530463};
464
465/*
466 * nss_stats_str_if_exception_pppoe
467 * Interface stats strings for PPPoE exceptions
468 */
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +0530469static int8_t *nss_stats_str_if_exception_pppoe[NSS_PPPOE_EXCEPTION_EVENT_MAX] = {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530470 "PPPOE_WRONG_VERSION_OR_TYPE",
471 "PPPOE_WRONG_CODE",
472 "PPPOE_HEADER_INCOMPLETE",
Murat Sezgin7c5956a2014-05-12 09:59:51 -0700473 "PPPOE_UNSUPPORTED_PPP_PROTOCOL",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800474 "PPPOE_DEPRECATED"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530475};
476
477/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530478 * nss_stats_str_wifi
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530479 * Wifi statistics strings
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530480 */
481static int8_t *nss_stats_str_wifi[NSS_STATS_WIFI_MAX] = {
482 "RX_PACKETS",
483 "RX_DROPPED",
484 "TX_PACKETS",
485 "TX_DROPPED",
486 "TX_TRANSMIT_COMPLETED",
487 "TX_MGMT_RECEIVED",
488 "TX_MGMT_TRANSMITTED",
489 "TX_MGMT_DROPPED",
490 "TX_MGMT_COMPLETED",
491 "TX_INV_PEER_ENQ_CNT",
492 "RX_INV_PEER_RCV_CNT",
493 "RX_PN_CHECK_FAILED",
494 "RX_PKTS_DELIVERD",
Radha krishna Simha Jiguru36304d12015-12-03 20:21:02 +0530495 "RX_BYTES_DELIVERED",
496 "TX_BYTES_COMPLETED",
Pamidipati, Vijay670ce7e2016-03-15 16:46:59 +0530497 "RX_DELIVER_UNALIGNED_DROP_CNT",
498 "TIDQ_ENQUEUE_CNT_0",
499 "TIDQ_ENQUEUE_CNT_1",
500 "TIDQ_ENQUEUE_CNT_2",
501 "TIDQ_ENQUEUE_CNT_3",
502 "TIDQ_ENQUEUE_CNT_4",
503 "TIDQ_ENQUEUE_CNT_5",
504 "TIDQ_ENQUEUE_CNT_6",
505 "TIDQ_ENQUEUE_CNT_7",
506 "TIDQ_DEQUEUE_CNT_0",
507 "TIDQ_DEQUEUE_CNT_1",
508 "TIDQ_DEQUEUE_CNT_2",
509 "TIDQ_DEQUEUE_CNT_3",
510 "TIDQ_DEQUEUE_CNT_4",
511 "TIDQ_DEQUEUE_CNT_5",
512 "TIDQ_DEQUEUE_CNT_6",
513 "TIDQ_DEQUEUE_CNT_7",
514 "TIDQ_ENQUEUE_FAIL_CNT_0",
515 "TIDQ_ENQUEUE_FAIL_CNT_1",
516 "TIDQ_ENQUEUE_FAIL_CNT_2",
517 "TIDQ_ENQUEUE_FAIL_CNT_3",
518 "TIDQ_ENQUEUE_FAIL_CNT_4",
519 "TIDQ_ENQUEUE_FAIL_CNT_5",
520 "TIDQ_ENQUEUE_FAIL_CNT_6",
521 "TIDQ_ENQUEUE_FAIL_CNT_7",
522 "TIDQ_TTL_EXPIRE_CNT_0",
523 "TIDQ_TTL_EXPIRE_CNT_1",
524 "TIDQ_TTL_EXPIRE_CNT_2",
525 "TIDQ_TTL_EXPIRE_CNT_3",
526 "TIDQ_TTL_EXPIRE_CNT_4",
527 "TIDQ_TTL_EXPIRE_CNT_5",
528 "TIDQ_TTL_EXPIRE_CNT_6",
529 "TIDQ_TTL_EXPIRE_CNT_7",
530 "TIDQ_DEQUEUE_REQ_CNT_0",
531 "TIDQ_DEQUEUE_REQ_CNT_1",
532 "TIDQ_DEQUEUE_REQ_CNT_2",
533 "TIDQ_DEQUEUE_REQ_CNT_3",
534 "TIDQ_DEQUEUE_REQ_CNT_4",
535 "TIDQ_DEQUEUE_REQ_CNT_5",
536 "TIDQ_DEQUEUE_REQ_CNT_6",
537 "TIDQ_DEQUEUE_REQ_CNT_7",
538 "TOTAL_TIDQ_DEPTH",
539 "RX_HTT_FETCH_CNT",
540 "TOTAL_TIDQ_BYPASS_CNT",
541 "GLOBAL_Q_FULL_CNT",
542 "TIDQ_FULL_CNT",
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530543};
544
545/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530546 * nss_stats_str_wifili
547 * wifili txrx statistics
548 */
549static int8_t *nss_stats_str_wifili_txrx[NSS_STATS_WIFILI_TXRX_MAX] = {
550 "WIFILI_RX_MSDU_ERROR",
551 "WIFILI_RX_INV_PEER_RCV",
552 "WIFILI_RX_WDS_SRCPORT_EXCEPTION",
553 "WIFILI_RX_WDS_SRCPORT_EXCEPTION_FAIL",
554 "WIFILI_RX_DELIVERD",
555 "WIFILI_RX_DELIVER_DROPPED",
556 "WIFILI_RX_INTRA_BSS_UCAST",
557 "WIFILI_RX_INTRA_BSS_UCAST_FAIL",
558 "WIFILI_RX_INTRA_BSS_MCAST",
559 "WIFILI_RX_INTRA_BSS_MCAST_FAIL",
Aniruddha Paul1dc00782017-06-05 13:38:48 +0530560 "WIFILI_RX_SG_RCV_SEND",
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530561 "WIFILI_RX_SG_RCV_FAIL",
562 "WIFILI_TX_ENQUEUE",
563 "WIFILI_TX_ENQUEUE_DROP",
564 "WIFILI_TX_DEQUEUE",
565 "WIFILI_TX_HW_ENQUEUE_FAIL",
566 "WIFILI_TX_SENT_COUNT",
567};
568
569/*
570 * nss_stats_str_wifili_tcl
571 * wifili tcl stats
572 */
573static int8_t *nss_stats_str_wifili_tcl[NSS_STATS_WIFILI_TCL_MAX] = {
574 "WIFILI_TCL_NO_HW_DESC",
575 "WIFILI_TCL_RING_FULL",
576 "WIFILI_TCL_RING_SENT",
577};
578
579/*
580 * nss_stats_str_wifili_tx_comp
581 * wifili tx comp stats
582 */
583static int8_t *nss_stats_str_wifili_tx_comp[NSS_STATS_WIFILI_TX_DESC_FREE_MAX] = {
584 "WIFILI_TX_DESC_FREE_INV_BUFSRC",
585 "WIFILI_TX_DESC_FREE_INV_COOKIE",
586 "WIFILI_TX_DESC_FREE_HW_RING_EMPTY",
587 "WIFILI_TX_DESC_FREE_REAPED",
588};
589
590/*
591 * nss_stats_str_wifili_reo
592 * wifili tx reo stats
593 */
594static int8_t *nss_stats_str_wifili_reo[NSS_STATS_WIFILI_REO_MAX] = {
595 "WIFILI_REO_ERROR",
596 "WIFILI_REO_REAPED",
597 "WIFILI_REO_INV_COOKIE",
598};
599
600/*
601 * nss_stats_str_wifili_txsw_pool
602 * wifili tx desc stats
603 */
604static int8_t *nss_stats_str_wifili_txsw_pool[NSS_STATS_WIFILI_TX_DESC_MAX] = {
605 "WIFILI_TX_DESC_IN_USE",
606 "WIFILI_TX_DESC_ALLOC_FAIL",
607 "WIFILI_TX_DESC_ALREADY_ALLOCATED",
608 "WIFILI_TX_DESC_INVALID_FREE",
609 "WIFILI_TX_DESC_FREE_SRC_FW",
610 "WIFILI_TX_DESC_FREE_COMPLETION",
611 "WIFILI_TX_DESC_NO_PB",
612};
613
614/*
615 * nss_stats_str_wifili_ext_txsw_pool
616 * wifili tx ext desc stats
617 */
618static uint8_t *nss_stats_str_wifili_ext_txsw_pool[NSS_STATS_WIFILI_EXT_TX_DESC_MAX] = {
619 "WIFILI_EXT_TX_DESC_IN_USE",
620 "WIFILI_EXT_TX_DESC_ALLOC_FAIL",
621 "WIFILI_EXT_TX_DESC_ALREADY_ALLOCATED",
622 "WIFILI_EXT_TX_DESC_INVALID_FREE",
623};
624
625/*
626 * nss_stats_str_wifili_rxdma_pool
627 * wifili rx desc stats
628 */
629static int8_t *nss_stats_str_wifili_rxdma_pool[NSS_STATS_WIFILI_RX_DESC_MAX] = {
630 "WIFILI_RX_DESC_NO_PB",
631 "WIFILI_RX_DESC_ALLOC_FAIL",
632 "WIFILI_RX_DESC_IN_USE",
633};
634
635/*
636 * nss_stats_str_wifili_rxdma_ring
637 * wifili rx dma ring stats
638 */
639static int8_t *nss_stats_str_wifili_rxdma_ring[NSS_STATS_WIFILI_RXDMA_DESC_MAX] = {
640 "WIFILI_RXDMA_HW_DESC_UNAVAILABLE",
641};
642
643/*
644 * nss_stats_str_wifili_wbm
645 * wifili wbm ring stats
646 */
647static int8_t *nss_stats_str_wifili_wbm[NSS_STATS_WIFILI_WBM_MAX] = {
648 "WIFILI_WBM_SRC_DMA",
649 "WIFILI_WBM_SRC_DMA_CODE_INV",
650 "WIFILI_WBM_SRC_REO",
651 "WIFILI_WBM_SRC_REO_CODE_NULLQ",
652 "WIFILI_WBM_SRC_REO_CODE_INV",
653 "WIFILI_WBM_SRC_INV",
654};
655
656/*
Stephen Wang9779d952015-10-28 11:39:07 -0700657 * nss_stats_str_portid
658 * PortID statistics strings
659 */
660static int8_t *nss_stats_str_portid[NSS_STATS_PORTID_MAX] = {
661 "RX_INVALID_HEADER",
662};
663
664/*
Tushar Mathurff8741b2015-12-02 20:28:59 +0530665 * nss_stats_str_dtls_session_stats
666 * DTLS statistics strings for nss session stats
667 */
668static int8_t *nss_stats_str_dtls_session_debug_stats[NSS_STATS_DTLS_SESSION_MAX] = {
669 "RX_PKTS",
670 "TX_PKTS",
671 "RX_DROPPED",
672 "RX_AUTH_DONE",
673 "TX_AUTH_DONE",
674 "RX_CIPHER_DONE",
675 "TX_CIPHER_DONE",
676 "RX_CBUF_ALLOC_FAIL",
677 "TX_CBUF_ALLOC_FAIL",
678 "TX_CENQUEUE_FAIL",
679 "RX_CENQUEUE_FAIL",
680 "TX_DROPPED_HROOM",
681 "TX_DROPPED_TROOM",
682 "TX_FORWARD_ENQUEUE_FAIL",
683 "RX_FORWARD_ENQUEUE_FAIL",
684 "RX_INVALID_VERSION",
685 "RX_INVALID_EPOCH",
686 "RX_MALFORMED",
687 "RX_CIPHER_FAIL",
688 "RX_AUTH_FAIL",
689 "RX_CAPWAP_CLASSIFY_FAIL",
690 "RX_SINGLE_REC_DGRAM",
691 "RX_MULTI_REC_DGRAM",
692 "RX_REPLAY_FAIL",
693 "RX_REPLAY_DUPLICATE",
694 "RX_REPLAY_OUT_OF_WINDOW",
695 "OUTFLOW_QUEUE_FULL",
696 "DECAP_QUEUE_FULL",
697 "PBUF_ALLOC_FAIL",
698 "PBUF_COPY_FAIL",
699 "EPOCH",
700 "TX_SEQ_HIGH",
701 "TX_SEQ_LOW",
702};
703
704/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -0700705 * nss_stats_str_gre_tunnel_session_stats
706 * GRE Tunnel statistics strings for nss session stats
707 */
708static int8_t *nss_stats_str_gre_tunnel_session_debug_stats[NSS_STATS_GRE_TUNNEL_SESSION_MAX] = {
709 "RX_PKTS",
710 "TX_PKTS",
711 "RX_DROPPED",
712 "RX_MALFORMED",
713 "RX_INVALID_PROT",
714 "DECAP_QUEUE_FULL",
715 "RX_SINGLE_REC_DGRAM",
716 "RX_INVALID_REC_DGRAM",
717 "BUFFER_ALLOC_FAIL",
718 "BUFFER_COPY_FAIL",
719 "OUTFLOW_QUEUE_FULL",
720 "TX_DROPPED_HROOM",
721 "RX_CBUFFER_ALLOC_FAIL",
722 "RX_CENQUEUE_FAIL",
723 "RX_DECRYPT_DONE",
724 "RX_FORWARD_ENQUEUE_FAIL",
725 "TX_CBUFFER_ALLOC_FAIL",
726 "TX_CENQUEUE_FAIL",
727 "TX_DROPPED_TROOM",
728 "TX_FORWARD_ENQUEUE_FAIL",
729 "TX_CIPHER_DONE",
730 "CRYPTO_NOSUPP",
Shashank Balashankar4e7879e2017-06-02 15:16:01 -0700731 "RX_DROPPED_MH_VERSION",
Thomas Wu71c5ecc2016-06-21 11:15:52 -0700732};
733
734/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +0530735 * nss_stats_str_l2tpv2_session_stats
736 * l2tpv2 statistics strings for nss session stats
737 */
738static int8_t *nss_stats_str_l2tpv2_session_debug_stats[NSS_STATS_L2TPV2_SESSION_MAX] = {
739 "RX_PPP_LCP_PKTS",
740 "RX_EXP_PKTS",
741 "ENCAP_PBUF_ALLOC_FAIL",
742 "DECAP_PBUF_ALLOC_FAIL"
743};
744
745/*
ratheesh kannotha1245c32015-11-04 16:45:43 +0530746 * nss_stats_str_map_t_instance_stats
747 * map_t statistics strings for nss session stats
748 */
749static int8_t *nss_stats_str_map_t_instance_debug_stats[NSS_STATS_MAP_T_MAX] = {
750 "MAP_T_V4_TO_V6_PBUF_EXCEPTION_PKTS",
751 "MAP_T_V4_TO_V6_PBUF_NO_MATCHING_RULE",
752 "MAP_T_V4_TO_V6_PBUF_NOT_TCP_OR_UDP",
ratheesh kannoth32b6c422016-06-05 10:08:15 +0530753 "MAP_T_V4_TO_V6_RULE_ERR_LOCAL_PSID",
ratheesh kannotha1245c32015-11-04 16:45:43 +0530754 "MAP_T_V4_TO_V6_RULE_ERR_LOCAL_IPV6",
755 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_PSID",
756 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_EA_BITS",
757 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_IPV6",
758 "MAP_T_V6_TO_V4_PBUF_EXCEPTION_PKTS",
759 "MAP_T_V6_TO_V4_PBUF_NO_MATCHING_RULE",
760 "MAP_T_V6_TO_V4_PBUF_NOT_TCP_OR_UDP",
761 "MAP_T_V6_TO_V4_RULE_ERR_LOCAL_IPV4",
762 "MAP_T_V6_TO_V4_RULE_ERR_REMOTE_IPV4"
763};
764
ratheesh kannotheb2a0a82017-05-04 09:20:17 +0530765 /*
766 * nss_stats_str_gre_base_stats
767 * GRE debug statistics strings for base types
768 */
769static int8_t *nss_stats_str_gre_base_debug_stats[NSS_STATS_GRE_BASE_DEBUG_MAX] = {
770 "GRE_BASE_RX_PACKETS",
771 "GRE_BASE_RX_DROPPED",
772 "GRE_BASE_EXP_ETH_HDR_MISSING",
773 "GRE_BASE_EXP_ETH_TYPE_NON_IP",
774 "GRE_BASE_EXP_IP_UNKNOWN_PROTOCOL",
775 "GRE_BASE_EXP_IP_HEADER_INCOMPLETE",
776 "GRE_BASE_EXP_IP_BAD_TOTAL_LENGTH",
777 "GRE_BASE_EXP_IP_BAD_CHECKSUM",
778 "GRE_BASE_EXP_IP_DATAGRAM_INCOMPLETE",
779 "GRE_BASE_EXP_IP_FRAGMENT",
780 "GRE_BASE_EXP_IP_OPTIONS_INCOMPLETE",
781 "GRE_BASE_EXP_IP_WITH_OPTIONS",
782 "GRE_BASE_EXP_IPV6_UNKNOWN_PROTOCOL",
783 "GRE_BASE_EXP_IPV6_HEADER_INCOMPLETE",
784 "GRE_BASE_EXP_GRE_UNKNOWN_SESSION",
785 "GRE_BASE_EXP_GRE_NODE_INACTIVE",
786};
787
788/*
789 * nss_stats_str_gre_session_stats
790 * GRE debug statistics strings for sessions
791 */
792static int8_t *nss_stats_str_gre_session_debug_stats[NSS_STATS_GRE_SESSION_DEBUG_MAX] = {
793 "GRE_SESSION_PBUF_ALLOC_FAIL",
794 "GRE_SESSION_DECAP_FORWARD_ENQUEUE_FAIL",
795 "GRE_SESSION_ENCAP_FORWARD_ENQUEUE_FAIL",
796 "GRE_SESSION_DECAP_TX_FORWARDED",
797 "GRE_SESSION_ENCAP_RX_RECEIVED",
798 "GRE_SESSION_ENCAP_RX_DROPPED",
799 "GRE_SESSION_ENCAP_RX_LINEAR_FAIL",
800 "GRE_SESSION_EXP_RX_KEY_ERROR",
801 "GRE_SESSION_EXP_RX_SEQ_ERROR",
802 "GRE_SESSION_EXP_RX_CS_ERROR",
803 "GRE_SESSION_EXP_RX_FLAG_MISMATCH",
804 "GRE_SESSION_EXP_RX_MALFORMED",
805 "GRE_SESSION_EXP_RX_INVALID_PROTOCOL",
806 "GRE_SESSION_EXP_RX_NO_HEADROOM",
807};
808
ratheesh kannotha1245c32015-11-04 16:45:43 +0530809/*
Amit Gupta316729b2016-08-12 12:21:15 +0530810 * nss_stats_str_ppe_conn
811 * PPE statistics strings for nss flow stats
812 */
813static int8_t *nss_stats_str_ppe_conn[NSS_STATS_PPE_CONN_MAX] = {
814 "v4 routed flows",
815 "v4 bridge flows",
816 "v4 conn create req",
817 "v4 conn create fail",
818 "v4 conn destroy req",
819 "v4 conn destroy fail",
Amit Gupta263df9c2017-05-16 20:43:07 +0530820 "v4 conn MC create req",
821 "v4 conn MC create fail",
822 "v4 conn MC update req",
823 "v4 conn MC update fail",
824 "v4 conn MC delete req",
825 "v4 conn MC delete fail",
Amit Gupta316729b2016-08-12 12:21:15 +0530826
827 "v6 routed flows",
828 "v6 bridge flows",
829 "v6 conn create req",
830 "v6 conn create fail",
831 "v6 conn destroy req",
832 "v6 conn destroy fail",
Amit Gupta263df9c2017-05-16 20:43:07 +0530833 "v6 conn MC create req",
834 "v6 conn MC create fail",
835 "v6 conn MC update req",
836 "v6 conn MC update fail",
837 "v6 conn MC delete req",
838 "v6 conn MC delete fail",
Amit Gupta316729b2016-08-12 12:21:15 +0530839
Amit Gupta263df9c2017-05-16 20:43:07 +0530840 "conn fail - vp full",
Amit Gupta316729b2016-08-12 12:21:15 +0530841 "conn fail - nexthop full",
842 "conn fail - flow full",
843 "conn fail - host full",
844 "conn fail - pub-ip full",
845 "conn fail - port not setup",
846 "conn fail - rw fifo full",
Amit Gupta263df9c2017-05-16 20:43:07 +0530847 "conn fail - flow cmd failure",
Amit Gupta316729b2016-08-12 12:21:15 +0530848 "conn fail - unknown proto",
849 "conn fail - ppe not responding",
Amit Gupta263df9c2017-05-16 20:43:07 +0530850 "conn fail - CE opaque invalid",
Thomas Wufc4d9fd2017-03-22 10:15:30 -0700851 "conn fail - fqg full"
Amit Gupta316729b2016-08-12 12:21:15 +0530852};
853
854/*
855 * nss_stats_str_ppe_l3
856 * PPE statistics strings for nss debug stats
857 */
858static int8_t *nss_stats_str_ppe_l3[NSS_STATS_PPE_L3_MAX] = {
859 "PPE L3 dbg reg 0",
860 "PPE L3 dbg reg 1",
861 "PPE L3 dbg reg 2",
862 "PPE L3 dbg reg 3",
863 "PPE L3 dbg reg 4",
864 "PPE L3 dbg reg port",
865};
866
867/*
868 * nss_stats_str_ppe_code
869 * PPE statistics strings for nss debug stats
870 */
871static int8_t *nss_stats_str_ppe_code[NSS_STATS_PPE_CODE_MAX] = {
872 "PPE CPU_CODE",
873 "PPE DROP_CODE",
874};
875
876/*
Amit Gupta79c1c202017-06-30 15:28:13 +0530877 * nss_stats_str_ppe_dc
878 * PPE statistics strings for drop code
879 */
880static int8_t *nss_stats_str_ppe_dc[NSS_STATS_PPE_DROP_CODE_MAX] = {
881 "PPE_DROP_CODE_NONE",
882 "PPE_DROP_CODE_EXP_UNKNOWN_L2_PORT",
883 "PPE_DROP_CODE_EXP_PPPOE_WRONG_VER_TYPE",
884 "PPE_DROP_CODE_EXP_PPPOE_WRONG_CODE",
885 "PPE_DROP_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",
886 "PPE_DROP_CODE_EXP_IPV4_WRONG_VER",
887 "PPE_DROP_CODE_EXP_IPV4_SMALL_IHL",
888 "PPE_DROP_CODE_EXP_IPV4_WITH_OPTION",
889 "PPE_DROP_CODE_EXP_IPV4_HDR_INCOMPLETE",
890 "PPE_DROP_CODE_EXP_IPV4_BAD_TOTAL_LEN",
891 "PPE_DROP_CODE_EXP_IPV4_DATA_INCOMPLETE",
892 "PPE_DROP_CODE_EXP_IPV4_FRAG",
893 "PPE_DROP_CODE_EXP_IPV4_PING_OF_DEATH",
894 "PPE_DROP_CODE_EXP_IPV4_SNALL_TTL",
895 "PPE_DROP_CODE_EXP_IPV4_UNK_IP_PROT",
896 "PPE_DROP_CODE_EXP_IPV4_CHECKSUM_ERR",
897 "PPE_DROP_CODE_EXP_IPV4_INV_SIP",
898 "PPE_DROP_CODE_EXP_IPV4_INV_DIP",
899 "PPE_DROP_CODE_EXP_IPV4_LAND_ATTACK",
900 "PPE_DROP_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",
901 "PPE_DROP_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER",
902 "PPE_DROP_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",
903 "PPE_DROP_CODE_EXP_IPV6_WRONG_VER",
904 "PPE_DROP_CODE_EXP_IPV6_HDR_INCOMPLETE",
905 "PPE_DROP_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",
906 "PPE_DROP_CODE_EXP_IPV6_DATA_INCOMPLETE",
907 "PPE_DROP_CODE_EXP_IPV6_WITH_EXT_HDR",
908 "PPE_DROP_CODE_EXP_IPV6_SMALL_HOP_LIMIT",
909 "PPE_DROP_CODE_EXP_IPV6_INV_SIP",
910 "PPE_DROP_CODE_EXP_IPV6_INV_DIP",
911 "PPE_DROP_CODE_EXP_IPV6_LAND_ATTACK",
912 "PPE_DROP_CODE_EXP_IPV6_FRAG",
913 "PPE_DROP_CODE_EXP_IPV6_PING_OF_DEATH",
914 "PPE_DROP_CODE_EXP_IPV6_WITH_MORE_EXT_HDR",
915 "PPE_DROP_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR",
916 "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",
917 "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER",
918 "PPE_DROP_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",
919 "PPE_DROP_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER",
920 "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",
921 "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER",
922 "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE",
923 "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER",
924 "PPE_DROP_CODE_EXP_TCP_HDR_INCOMPLETE",
925 "PPE_DROP_CODE_EXP_TCP_HDR_CROSS_BORDER",
926 "PPE_DROP_CODE_EXP_TCP_SMAE_SP_DP",
927 "PPE_DROP_CODE_EXP_TCP_SMALL_DATA_OFFSET",
928 "PPE_DROP_CODE_EXP_TCP_FLAGS_0",
929 "PPE_DROP_CODE_EXP_TCP_FLAGS_1",
930 "PPE_DROP_CODE_EXP_TCP_FLAGS_2",
931 "PPE_DROP_CODE_EXP_TCP_FLAGS_3",
932 "PPE_DROP_CODE_EXP_TCP_FLAGS_4",
933 "PPE_DROP_CODE_EXP_TCP_FLAGS_5",
934 "PPE_DROP_CODE_EXP_TCP_FLAGS_6",
935 "PPE_DROP_CODE_EXP_TCP_FLAGS_7",
936 "PPE_DROP_CODE_EXP_TCP_CHECKSUM_ERR",
937 "PPE_DROP_CODE_EXP_UDP_HDR_INCOMPLETE",
938 "PPE_DROP_CODE_EXP_UDP_HDR_CROSS_BORDER",
939 "PPE_DROP_CODE_EXP_UDP_SMAE_SP_DP",
940 "PPE_DROP_CODE_EXP_UDP_BAD_LEN",
941 "PPE_DROP_CODE_EXP_UDP_DATA_INCOMPLETE",
942 "PPE_DROP_CODE_EXP_UDP_CHECKSUM_ERR",
943 "PPE_DROP_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",
944 "PPE_DROP_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER",
945 "PPE_DROP_CODE_EXP_UDP_LITE_SMAE_SP_DP",
946 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7",
947 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG",
948 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER",
949 "PPE_DROP_CODE_EXP_UDP_LITE_CHECKSUM_ERR",
950 "PPE_DROP_CODE_L3_MC_BRIDGE_ACTION",
951 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION",
952 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR",
953 "PPE_DROP_CODE_L3_ROUTE_ACTION",
954 "PPE_DROP_CODE_L3_NO_ROUTE_ACTION",
955 "PPE_DROP_CODE_L3_NO_ROUTE_NH_INVALID_ACTION",
956 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_ACTION",
957 "PPE_DROP_CODE_L3_BRIDGE_ACTION",
958 "PPE_DROP_CODE_L3_FLOW_ACTION",
959 "PPE_DROP_CODE_L3_FLOW_MISS_ACTION",
960 "PPE_DROP_CODE_L2_EXP_MRU_FAIL",
961 "PPE_DROP_CODE_L2_EXP_MTU_FAIL",
962 "PPE_DROP_CODE_L3_EXP_IP_PREFIX_BC",
963 "PPE_DROP_CODE_L3_EXP_MTU_FAIL",
964 "PPE_DROP_CODE_L3_EXP_MRU_FAIL",
965 "PPE_DROP_CODE_L3_EXP_ICMP_RDT",
966 "PPE_DROP_CODE_FAKE_MAC_HEADER_ERR",
967 "PPE_DROP_CODE_L3_EXP_IP_RT_TTL_ZERO",
968 "PPE_DROP_CODE_L3_FLOW_SERVICE_CODE_LOOP",
969 "PPE_DROP_CODE_L3_FLOW_DE_ACCELEARTE",
970 "PPE_DROP_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL",
971 "PPE_DROP_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",
972 "PPE_DROP_CODE_L3_EXP_MTU_DF_FAIL",
973 "PPE_DROP_CODE_L3_EXP_PPPOE_MULTICAST",
974 "PPE_DROP_CODE_IPV4_SG_UNKNOWN",
975 "PPE_DROP_CODE_IPV6_SG_UNKNOWN",
976 "PPE_DROP_CODE_ARP_SG_UNKNOWN",
977 "PPE_DROP_CODE_ND_SG_UNKNOWN",
978 "PPE_DROP_CODE_IPV4_SG_VIO",
979 "PPE_DROP_CODE_IPV6_SG_VIO",
980 "PPE_DROP_CODE_ARP_SG_VIO",
981 "PPE_DROP_CODE_ND_SG_VIO",
982 "PPE_DROP_CODE_L2_NEW_MAC_ADDRESS",
983 "PPE_DROP_CODE_L2_HASH_COLLISION",
984 "PPE_DROP_CODE_L2_STATION_MOVE",
985 "PPE_DROP_CODE_L2_LEARN_LIMIT",
986 "PPE_DROP_CODE_L2_SA_LOOKUP_ACTION",
987 "PPE_DROP_CODE_L2_DA_LOOKUP_ACTION",
988 "PPE_DROP_CODE_APP_CTRL_ACTION",
989 "PPE_DROP_CODE_IN_VLAN_FILTER_ACTION",
990 "PPE_DROP_CODE_IN_VLAN_XLT_MISS",
991 "PPE_DROP_CODE_EG_VLAN_FILTER_DROP",
992 "PPE_DROP_CODE_ACL_PRE_ACTION",
993 "PPE_DROP_CODE_ACL_POST_ACTION",
994 "PPE_DROP_CODE_MC_BC_SA",
995 "PPE_DROP_CODE_NO_DESTINATION",
996 "PPE_DROP_CODE_STG_IN_FILTER",
997 "PPE_DROP_CODE_STG_EG_FILTER",
998 "PPE_DROP_CODE_SOURCE_FILTER_FAIL",
999 "PPE_DROP_CODE_TRUNK_SEL_FAIL",
1000 "PPE_DROP_CODE_TX_EN_FAIL",
1001 "PPE_DROP_CODE_VLAN_TAG_FMT",
1002 "PPE_DROP_CODE_CRC_ERR",
1003 "PPE_DROP_CODE_PAUSE_FRAME",
1004 "PPE_DROP_CODE_PROMISC",
1005 "PPE_DROP_CODE_ISOLATION",
1006 "PPE_DROP_CODE_MGMT_APP",
1007 "PPE_DROP_CODE_FAKE_L2_PROT_ERR",
1008 "PPE_DROP_CODE_POLICER",
1009};
1010
1011/*
1012 * nss_stats_str_ppe_cc
1013 * PPE statistics strings for cpu code
1014 */
1015static int8_t *nss_stats_str_ppe_cc[NSS_STATS_PPE_CPU_CODE_MAX] = {
1016 "PPE_CPU_CODE_FORWARDING",
1017 "PPE_CPU_CODE_EXP_UNKNOWN_L2_PROT",
1018 "PPE_CPU_CODE_EXP_PPPOE_WRONG_VER_TYPE",
1019 "PPE_CPU_CODE_EXP_WRONG_CODE",
1020 "PPE_CPU_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",
1021 "PPE_CPU_CODE_EXP_WRONG_VER",
1022 "PPE_CPU_CODE_EXP_SMALL_IHL",
1023 "PPE_CPU_CODE_EXP_WITH_OPTION",
1024 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1025 "PPE_CPU_CODE_EXP_IPV4_BAD_TOTAL_LEN",
1026 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1027 "PPE_CPU_CODE_IPV4_FRAG",
1028 "PPE_CPU_CODE_EXP_IPV4_PING_OF_DEATH",
1029 "PPE_CPU_CODE_EXP_SNALL_TTL",
1030 "PPE_CPU_CODE_EXP_IPV4_UNK_IP_PROT",
1031 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1032 "PPE_CPU_CODE_EXP_INV_SIP",
1033 "PPE_CPU_CODE_EXP_INV_DIP",
1034 "PPE_CPU_CODE_EXP_LAND_ATTACK",
1035 "PPE_CPU_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",
1036 "PPE_CPU_CODE_EXP_IPV4_AH_CROSS_BORDER",
1037 "PPE_CPU_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",
1038 "PPE_CPU_CODE_EXP_WRONG_VER",
1039 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1040 "PPE_CPU_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",
1041 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1042 "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR",
1043 "PPE_CPU_CODE_EXP_IPV6_SMALL_HOP_LIMIT",
1044 "PPE_CPU_CODE_EXP_INV_SIP",
1045 "PPE_CPU_CODE_EXP_INV_DIP",
1046 "PPE_CPU_CODE_EXP_LAND_ATTACK",
1047 "PPE_CPU_CODE_IPV6_FRAG",
1048 "PPE_CPU_CODE_EXP_IPV6_PING_OF_DEATH",
1049 "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR",
1050 "PPE_CPU_CODE_EXP_IPV6_UNK_NEXT_HDR",
1051 "PPE_CPU_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",
1052 "PPE_CPU_CODE_EXP_IPV6_MOBILITY_CROSS_BORDER",
1053 "PPE_CPU_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",
1054 "PPE_CPU_CODE_EXP_IPV6_AH_CROSS_BORDER",
1055 "PPE_CPU_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",
1056 "PPE_CPU_CODE_EXP_IPV6_ESP_CROSS_BORDER",
1057 "PPE_CPU_CODE_EXP_IPV6_OTHER_HDR_INCOMPLETE",
1058 "PPE_CPU_CODE_EXP_IPV6_OTHER_EXT_CROSS_BORDER",
1059 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1060 "PPE_CPU_CODE_EXP_TCP_HDR_CROSS_BORDER",
1061 "PPE_CPU_CODE_EXP_TCP_SMAE_SP_DP",
1062 "PPE_CPU_CODE_EXP_TCP_SMALL_DATA_OFFSET",
1063 "PPE_CPU_CODE_EXP_FLAGS_0",
1064 "PPE_CPU_CODE_EXP_FLAGS_1",
1065 "PPE_CPU_CODE_EXP_FLAGS_2",
1066 "PPE_CPU_CODE_EXP_FLAGS_3",
1067 "PPE_CPU_CODE_EXP_FLAGS_4",
1068 "PPE_CPU_CODE_EXP_FLAGS_5",
1069 "PPE_CPU_CODE_EXP_FLAGS_6",
1070 "PPE_CPU_CODE_EXP_FLAGS_7",
1071 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1072 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1073 "PPE_CPU_CODE_EXP_UDP_HDR_CROSS_BORDER",
1074 "PPE_CPU_CODE_EXP_UDP_SMAE_SP_DP",
1075 "PPE_CPU_CODE_EXP_BAD_LEN",
1076 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1077 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1078 "PPE_CPU_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",
1079 "PPE_CPU_CODE_EXP_UDP_LITE_CROSS_BORDER",
1080 "PPE_CPU_CODE_EXP_UDP_LITE_SP_DP",
1081 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_COV_TO_7",
1082 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_TOO_LONG",
1083 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_CROSS_BORDER",
1084 "PPE_CPU_CODE_EXP_UDP_LITE_CHECKSUM_ERR",
1085 "PPE_CPU_CODE_EXP_FAKE_L2_PROT_ERR",
1086 "PPE_CPU_CODE_EXP_FAKE_MAC_HEADER_ERR",
1087 "PPE_CPU_CODE_BITMAP_MAX",
1088 "PPE_CPU_CODE_L2_MRU_FAIL",
1089 "PPE_CPU_CODE_L2_MTU_FAIL",
1090 "PPE_CPU_CODE_L3_EXP_IP_PREFIX_BC",
1091 "PPE_CPU_CODE_L3_MTU_FAIL",
1092 "PPE_CPU_CODE_L3_MRU_FAIL",
1093 "PPE_CPU_CODE_L3_ICMP_RDT",
1094 "PPE_CPU_CODE_L3_EXP_IP_RT_TO_ME",
1095 "PPE_CPU_CODE_L3_EXP_IP_TTL_ZERO",
1096 "PPE_CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP",
1097 "PPE_CPU_CODE_L3_DE_ACCELERATE",
1098 "PPE_CPU_CODE_L3_EXP_FLOW_SRC_CHK_FAIL",
1099 "PPE_CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",
1100 "PPE_CPU_CODE_L3_EXP_MTU_DF_FAIL",
1101 "PPE_CPU_CODE_L3_PPPOE_MULTICAST",
1102 "PPE_CPU_CODE_MGMT_OFFSET",
1103 "PPE_CPU_CODE_MGMT_EAPOL",
1104 "PPE_CPU_CODE_PPPOE_DIS",
1105 "PPE_CPU_CODE_MGMT_IGMP",
1106 "PPE_CPU_CODE_ARP_REQ",
1107 "PPE_CPU_CODE_ARP_REP",
1108 "PPE_CPU_CODE_MGMT_DHCPv4",
1109 "PPE_CPU_CODE_MGMT_MLD",
1110 "PPE_CPU_CODE_MGMT_NS",
1111 "PPE_CPU_CODE_MGMT_NA",
1112 "PPE_CPU_CODE_MGMT_DHCPv6",
1113 "PPE_CPU_CODE_PTP_OFFSET",
1114 "PPE_CPU_CODE_PTP_SYNC",
1115 "PPE_CPU_CODE_FOLLOW_UP",
1116 "PPE_CPU_CODE_DELAY_REQ",
1117 "PPE_CPU_CODE_DELAY_RESP",
1118 "PPE_CPU_CODE_PDELAY_REQ",
1119 "PPE_CPU_CODE_PDELAY_RESP",
1120 "PPE_CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP",
1121 "PPE_CPU_CODE_PTP_ANNOUNCE",
1122 "PPE_CPU_CODE_PTP_MANAGEMENT",
1123 "PPE_CPU_CODE_PTP_SIGNALING",
1124 "PPE_CPU_CODE_PTP_RSV_MSG",
1125 "PPE_CPU_CODE_SG_UNKNOWN",
1126 "PPE_CPU_CODE_SG_UNKNOWN",
1127 "PPE_CPU_CODE_SG_UNKNOWN",
1128 "PPE_CPU_CODE_SG_UNKNOWN",
1129 "PPE_CPU_CODE_SG_VIO",
1130 "PPE_CPU_CODE_SG_VIO",
1131 "PPE_CPU_CODE_SG_VIO",
1132 "PPE_CPU_CODE_SG_VIO",
1133 "PPE_CPU_CODE_L3_ROUTING_IP_TO_ME",
1134 "PPE_CPU_CODE_L3_SNAT_ACTION",
1135 "PPE_CPU_CODE_L3_DNAT_ACTION",
1136 "PPE_CPU_CODE_L3_RT_ACTION",
1137 "PPE_CPU_CODE_L3_BR_ACTION",
1138 "PPE_CPU_CODE_L3_BRIDGE_ACTION",
1139 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION",
1140 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION",
1141 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION",
1142 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION",
1143 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION",
1144 "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ACTION",
1145 "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ERROR",
1146 "PPE_CPU_CODE_ROUTE_ACTION",
1147 "PPE_CPU_CODE_L3_ROUTE_ACTION",
1148 "PPE_CPU_CODE_L3_NO_ROUTE_INVALID_ACTION",
1149 "PPE_CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION",
1150 "PPE_CPU_CODE_BRIDGE_ACTION",
1151 "PPE_CPU_CODE_FLOW_ACTION",
1152 "PPE_CPU_CODE_L3_MISS_ACTION",
1153 "PPE_CPU_CODE_L2_MAC_ADDRESS",
1154 "PPE_CPU_CODE_HASH_COLLISION",
1155 "PPE_CPU_CODE_STATION_MOVE",
1156 "PPE_CPU_CODE_LEARN_LIMIT",
1157 "PPE_CPU_CODE_L2_LOOKUP_ACTION",
1158 "PPE_CPU_CODE_L2_LOOKUP_ACTION",
1159 "PPE_CPU_CODE_CTRL_ACTION",
1160 "PPE_CPU_CODE_IN_FILTER_ACTION",
1161 "PPE_CPU_CODE_IN_XLT_MISS",
1162 "PPE_CPU_CODE_EG_FILTER_DROP",
1163 "PPE_CPU_CODE_PRE_ACTION",
1164 "PPE_CPU_CODE_POST_ACTION",
1165 "PPE_CPU_CODE_CODE_ACTION",
1166};
1167
1168/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05301169 * nss_stats_str_ppt_session_stats
1170 * PPTP statistics strings for nss session stats
1171 */
1172static int8_t *nss_stats_str_pptp_session_debug_stats[NSS_STATS_PPTP_SESSION_MAX] = {
Shyam Sundere351f1b2015-12-17 14:11:51 +05301173 "ENCAP_RX_PACKETS",
1174 "ENCAP_RX_BYTES",
1175 "ENCAP_TX_PACKETS",
1176 "ENCAP_TX_BYTES",
1177 "ENCAP_RX_DROP",
1178 "DECAP_RX_PACKETS",
1179 "DECAP_RX_BYTES",
1180 "DECAP_TX_PACKETS",
1181 "DECAP_TX_BYTES",
1182 "DECAP_RX_DROP",
1183 "ENCAP_HEADROOM_ERR",
1184 "ENCAP_SMALL_SIZE",
1185 "ENCAP_PNODE_ENQUEUE_FAIL",
1186 "DECAP_NO_SEQ_NOR_ACK",
1187 "DECAP_INVAL_GRE_FLAGS",
1188 "DECAP_INVAL_GRE_PROTO",
1189 "DECAP_WRONG_SEQ",
1190 "DECAP_INVAL_PPP_HDR",
1191 "DECAP_PPP_LCP",
1192 "DECAP_UNSUPPORTED_PPP_PROTO",
1193 "DECAP_PNODE_ENQUEUE_FAIL",
Shyam Sunder66e889d2015-11-02 15:31:20 +05301194};
1195
1196/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07001197 * nss_stats_str_trustsec_tx
1198 * Trustsec TX stats strings
1199 */
1200static int8_t *nss_stats_str_trustsec_tx[NSS_STATS_TRUSTSEC_TX_MAX] = {
1201 "INVALID_SRC",
1202 "UNCONFIGURED_SRC",
1203 "HEADROOM_NOT_ENOUGH",
1204};
1205
1206/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301207 * nss_stats_ipv4_read()
1208 * Read IPV4 stats
1209 */
1210static ssize_t nss_stats_ipv4_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1211{
1212 int32_t i;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301213 /*
1214 * max output lines = #stats + start tag line + end tag line + three blank lines
1215 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301216 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 +05301217 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1218 size_t size_wr = 0;
1219 ssize_t bytes_read = 0;
1220 uint64_t *stats_shadow;
1221
1222 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1223 if (unlikely(lbuf == NULL)) {
1224 nss_warning("Could not allocate memory for local statistics buffer");
1225 return 0;
1226 }
1227
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301228 /*
1229 * Note: The assumption here is that exception event count is larger than other statistics count for IPv4
1230 */
1231 stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV4_MAX * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301232 if (unlikely(stats_shadow == NULL)) {
1233 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301234 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301235 return 0;
1236 }
1237
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301238 size_wr = scnprintf(lbuf, size_al, "ipv4 stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301239
1240 /*
1241 * Common node stats
1242 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301243 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301244 spin_lock_bh(&nss_top_main.stats_lock);
1245 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1246 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_RX_INTERFACE][i];
1247 }
1248
1249 spin_unlock_bh(&nss_top_main.stats_lock);
1250
1251 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1252 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1253 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1254 }
1255
1256 /*
1257 * IPv4 node stats
1258 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301259 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301260
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301261 spin_lock_bh(&nss_top_main.stats_lock);
1262 for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) {
1263 stats_shadow[i] = nss_top_main.stats_ipv4[i];
1264 }
1265
1266 spin_unlock_bh(&nss_top_main.stats_lock);
1267
1268 for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) {
1269 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1270 "%s = %llu\n", nss_stats_str_ipv4[i], stats_shadow[i]);
1271 }
1272
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301273 /*
1274 * Exception stats
1275 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301276 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301277
1278 spin_lock_bh(&nss_top_main.stats_lock);
1279 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) {
1280 stats_shadow[i] = nss_top_main.stats_if_exception_ipv4[i];
1281 }
1282
1283 spin_unlock_bh(&nss_top_main.stats_lock);
1284
1285 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) {
1286 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1287 "%s = %llu\n", nss_stats_str_if_exception_ipv4[i], stats_shadow[i]);
1288 }
1289
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301290 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301291 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1292 kfree(lbuf);
1293 kfree(stats_shadow);
1294
1295 return bytes_read;
1296}
1297
1298/*
Selin Dag6d9b0c12014-11-04 18:27:21 -08001299 * nss_stats_ipv4_reasm_read()
1300 * Read IPV4 reassembly stats
1301 */
1302static ssize_t nss_stats_ipv4_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1303{
1304 int32_t i;
1305 /*
1306 * max output lines = #stats + start tag line + end tag line + three blank lines
1307 */
1308 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV4_REASM_MAX + 3) + 5;
1309 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1310 size_t size_wr = 0;
1311 ssize_t bytes_read = 0;
1312 uint64_t *stats_shadow;
1313
1314 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1315 if (unlikely(lbuf == NULL)) {
1316 nss_warning("Could not allocate memory for local statistics buffer");
1317 return 0;
1318 }
1319
1320 stats_shadow = kzalloc(NSS_STATS_IPV4_REASM_MAX * 8, GFP_KERNEL);
1321 if (unlikely(stats_shadow == NULL)) {
1322 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301323 kfree(lbuf);
Selin Dag6d9b0c12014-11-04 18:27:21 -08001324 return 0;
1325 }
1326
1327 size_wr = scnprintf(lbuf, size_al, "ipv4 reasm stats start:\n\n");
1328
1329 /*
1330 * Common node stats
1331 */
1332 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
1333 spin_lock_bh(&nss_top_main.stats_lock);
1334 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1335 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_REASM_INTERFACE][i];
1336 }
1337
1338 spin_unlock_bh(&nss_top_main.stats_lock);
1339
1340 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1341 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1342 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1343 }
1344
1345 /*
1346 * IPv4 reasm node stats
1347 */
1348 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm node stats:\n\n");
1349
1350 spin_lock_bh(&nss_top_main.stats_lock);
1351 for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) {
1352 stats_shadow[i] = nss_top_main.stats_ipv4_reasm[i];
1353 }
1354
1355 spin_unlock_bh(&nss_top_main.stats_lock);
1356
1357 for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) {
1358 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1359 "%s = %llu\n", nss_stats_str_ipv4_reasm[i], stats_shadow[i]);
1360 }
1361
1362 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm stats end\n\n");
1363 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1364 kfree(lbuf);
1365 kfree(stats_shadow);
1366
1367 return bytes_read;
1368}
1369
1370/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301371 * nss_stats_ipv6_read()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301372 * Read IPV6 stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301373 */
1374static ssize_t nss_stats_ipv6_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1375{
1376 int32_t i;
1377
1378 /*
1379 * max output lines = #stats + start tag line + end tag line + three blank lines
1380 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301381 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 +05301382 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1383 size_t size_wr = 0;
1384 ssize_t bytes_read = 0;
1385 uint64_t *stats_shadow;
1386
1387 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1388 if (unlikely(lbuf == NULL)) {
1389 nss_warning("Could not allocate memory for local statistics buffer");
1390 return 0;
1391 }
1392
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301393 /*
1394 * Note: The assumption here is that exception event count is larger than other statistics count for IPv4
1395 */
1396 stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV6_MAX * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301397 if (unlikely(stats_shadow == NULL)) {
1398 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301399 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301400 return 0;
1401 }
1402
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301403 size_wr = scnprintf(lbuf, size_al, "ipv6 stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301404
1405 /*
1406 * Common node stats
1407 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301408 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301409 spin_lock_bh(&nss_top_main.stats_lock);
1410 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1411 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_RX_INTERFACE][i];
1412 }
1413
1414 spin_unlock_bh(&nss_top_main.stats_lock);
1415
1416 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1417 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1418 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1419 }
1420
1421 /*
1422 * IPv6 node stats
1423 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301424 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301425
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301426 spin_lock_bh(&nss_top_main.stats_lock);
1427 for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) {
1428 stats_shadow[i] = nss_top_main.stats_ipv6[i];
1429 }
1430
1431 spin_unlock_bh(&nss_top_main.stats_lock);
1432
1433 for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) {
1434 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1435 "%s = %llu\n", nss_stats_str_ipv6[i], stats_shadow[i]);
1436 }
1437
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301438 /*
1439 * Exception stats
1440 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301441 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301442
1443 spin_lock_bh(&nss_top_main.stats_lock);
1444 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) {
1445 stats_shadow[i] = nss_top_main.stats_if_exception_ipv6[i];
1446 }
1447
1448 spin_unlock_bh(&nss_top_main.stats_lock);
1449
1450 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) {
1451 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1452 "%s = %llu\n", nss_stats_str_if_exception_ipv6[i], stats_shadow[i]);
1453 }
1454
Aniruddha Paul1b170c22017-05-29 12:30:39 +05301455 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301456 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1457 kfree(lbuf);
1458 kfree(stats_shadow);
1459
1460 return bytes_read;
1461}
1462
1463/*
Selin Dag60a2f5b2015-06-29 14:39:49 -07001464 * nss_stats_ipv6_reasm_read()
1465 * Read IPV6 reassembly stats
1466 */
1467static ssize_t nss_stats_ipv6_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1468{
1469 int32_t i;
1470 /*
1471 * max output lines = #stats + start tag line + end tag line + three blank lines
1472 */
1473 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV6_REASM_MAX + 3) + 5;
1474 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1475 size_t size_wr = 0;
1476 ssize_t bytes_read = 0;
1477 uint64_t *stats_shadow;
1478
1479 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1480 if (unlikely(lbuf == NULL)) {
1481 nss_warning("Could not allocate memory for local statistics buffer");
1482 return 0;
1483 }
1484
1485 stats_shadow = kzalloc(NSS_STATS_IPV6_REASM_MAX * 8, GFP_KERNEL);
1486 if (unlikely(stats_shadow == NULL)) {
1487 nss_warning("Could not allocate memory for local shadow buffer");
1488 kfree(lbuf);
1489 return 0;
1490 }
1491
1492 size_wr = scnprintf(lbuf, size_al, "ipv6 reasm stats start:\n\n");
1493
1494 /*
1495 * Common node stats
1496 */
1497 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
1498 spin_lock_bh(&nss_top_main.stats_lock);
1499 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1500 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_REASM_INTERFACE][i];
1501 }
1502
1503 spin_unlock_bh(&nss_top_main.stats_lock);
1504
1505 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1506 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1507 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1508 }
1509
1510 /*
1511 * Ipv6 reasm node stats
1512 */
1513 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm node stats:\n\n");
1514
1515 spin_lock_bh(&nss_top_main.stats_lock);
1516 for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) {
1517 stats_shadow[i] = nss_top_main.stats_ipv6_reasm[i];
1518 }
1519
1520 spin_unlock_bh(&nss_top_main.stats_lock);
1521
1522 for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) {
1523 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1524 "%s = %llu\n", nss_stats_str_ipv6_reasm[i], stats_shadow[i]);
1525 }
1526
1527 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm stats end\n\n");
1528 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1529 kfree(lbuf);
1530 kfree(stats_shadow);
1531
1532 return bytes_read;
1533}
1534
1535/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07001536 * nss_stats_edma_port_stats_read()
1537 * Read EDMA port stats
1538 */
1539static ssize_t nss_stats_edma_port_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1540{
1541 int32_t i;
1542
1543 /*
1544 * max output lines = #stats + start tag line + end tag line + three blank lines
1545 */
1546 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + 3;
1547 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1548 size_t size_wr = 0;
1549 ssize_t bytes_read = 0;
1550 uint64_t *stats_shadow;
1551 struct nss_stats_data *data = fp->private_data;
1552
1553 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1554 if (unlikely(lbuf == NULL)) {
1555 nss_warning("Could not allocate memory for local statistics buffer");
1556 return 0;
1557 }
1558
1559 /*
1560 * Note: The assumption here is that we do not have more than 64 stats
1561 */
1562 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1563 if (unlikely(stats_shadow == NULL)) {
1564 nss_warning("Could not allocate memory for local shadow buffer");
1565 kfree(lbuf);
1566 return 0;
1567 }
1568
1569 size_wr = scnprintf(lbuf, size_al, "edma stats start:\n\n");
1570
1571 /*
1572 * Common node stats
1573 */
1574 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d stats:\n\n", data->edma_id);
1575 spin_lock_bh(&nss_top_main.stats_lock);
1576 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1577 stats_shadow[i] = nss_top_main.stats_edma.port[data->edma_id].port_stats[i];
1578 }
1579
1580 spin_unlock_bh(&nss_top_main.stats_lock);
1581
1582 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1583 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1584 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1585 }
1586
1587 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n\n");
1588 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1589 kfree(lbuf);
1590 kfree(stats_shadow);
1591
1592 return bytes_read;
1593}
1594
1595/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07001596 * nss_stats_edma_err_stats_read()
1597 * Read EDMA err stats
1598 */
1599static ssize_t nss_stats_edma_err_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1600{
1601 int32_t i;
1602
1603 /*
1604 * max output lines = #stats + start tag line + end tag line + three blank lines
1605 */
1606 uint32_t max_output_lines = (NSS_EDMA_ERR_STATS_MAX + 2) + 3;
1607 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1608 size_t size_wr = 0;
1609 ssize_t bytes_read = 0;
1610 uint64_t *stats_shadow;
1611
1612 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1613 if (unlikely(lbuf == NULL)) {
1614 nss_warning("Could not allocate memory for local statistics buffer");
1615 return 0;
1616 }
1617
1618 /*
1619 * Note: The assumption here is that we do not have more than 64 stats
1620 */
1621 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1622 if (unlikely(stats_shadow == NULL)) {
1623 nss_warning("Could not allocate memory for local shadow buffer");
1624 kfree(lbuf);
1625 return 0;
1626 }
1627
1628 size_wr = scnprintf(lbuf, size_al, "edma error stats start:\n\n");
1629
1630 /*
1631 * Common node stats
1632 */
1633 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma error stats:\n\n");
1634 spin_lock_bh(&nss_top_main.stats_lock);
1635
1636 for (i = 0; (i < NSS_EDMA_ERR_STATS_MAX); i++)
1637 stats_shadow[i] = nss_top_main.stats_edma.misc_err[i];
1638
1639 spin_unlock_bh(&nss_top_main.stats_lock);
1640
1641 for (i = 0; (i < NSS_EDMA_ERR_STATS_MAX); i++) {
1642 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1643 "%s = %llu\n", nss_stats_str_edma_err_map[i], stats_shadow[i]);
1644 }
1645
1646 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma error stats end\n\n");
1647 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1648 kfree(lbuf);
1649 kfree(stats_shadow);
1650
1651 return bytes_read;
1652}
1653
1654/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07001655 * nss_stats_edma_port_type_read()
1656 * Read EDMA port type
1657 */
1658static ssize_t nss_stats_edma_port_type_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1659{
Shashank Balashankar512cb602016-08-01 17:57:42 -07001660 /*
1661 * max output lines = #stats + start tag line + end tag line + three blank lines
1662 */
1663 uint32_t max_output_lines = (1 + 2) + 3;
1664 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1665 size_t size_wr = 0;
1666 ssize_t bytes_read = 0;
1667 uint64_t port_type;
1668 struct nss_stats_data *data = fp->private_data;
1669
1670 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1671 if (unlikely(lbuf == NULL)) {
1672 nss_warning("Could not allocate memory for local statistics buffer");
1673 return 0;
1674 }
1675
1676 size_wr = scnprintf(lbuf, size_al, "edma port type start:\n\n");
1677 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d type:\n\n", data->edma_id);
1678
1679 /*
1680 * Port type
1681 */
1682 spin_lock_bh(&nss_top_main.stats_lock);
1683 port_type = nss_top_main.stats_edma.port[data->edma_id].port_type;
1684 spin_unlock_bh(&nss_top_main.stats_lock);
1685
1686 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1687 "port_type = %s\n", nss_stats_str_edma_port_type[port_type]);
1688
1689 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n");
1690 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1691 kfree(lbuf);
1692
1693 return bytes_read;
1694}
1695
1696/*
1697 * nss_stats_edma_port_ring_map_read()
1698 * Read EDMA port ring map
1699 */
1700static ssize_t nss_stats_edma_port_ring_map_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1701{
1702 int32_t i;
1703
1704 /*
1705 * max output lines = #stats + start tag line + end tag line + three blank lines
1706 */
1707 uint32_t max_output_lines = (4 + 2) + 3;
1708 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1709 size_t size_wr = 0;
1710 ssize_t bytes_read = 0;
1711 uint64_t *stats_shadow;
1712 struct nss_stats_data *data = fp->private_data;
1713
1714 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1715 if (unlikely(lbuf == NULL)) {
1716 nss_warning("Could not allocate memory for local statistics buffer");
1717 return 0;
1718 }
1719
1720 /*
1721 * Note: The assumption here is that we do not have more than 64 stats
1722 */
1723 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1724 if (unlikely(stats_shadow == NULL)) {
1725 nss_warning("Could not allocate memory for local shadow buffer");
1726 kfree(lbuf);
1727 return 0;
1728 }
1729
1730 size_wr = scnprintf(lbuf, size_al, "edma port ring map start:\n\n");
1731
1732 /*
1733 * Port ring map
1734 */
1735 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d ring map:\n\n", data->edma_id);
1736 spin_lock_bh(&nss_top_main.stats_lock);
1737 for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) {
1738 stats_shadow[i] = nss_top_main.stats_edma.port[data->edma_id].port_ring_map[i];
1739 }
1740
1741 spin_unlock_bh(&nss_top_main.stats_lock);
1742
1743 for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) {
1744 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1745 "%s = %llu\n", nss_stats_str_edma_port_ring_map[i], stats_shadow[i]);
1746 }
1747
1748 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n\n");
1749 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1750 kfree(lbuf);
1751 kfree(stats_shadow);
1752
1753 return bytes_read;
1754}
1755
1756/*
1757 * nss_stats_edma_txring_read()
1758 * Read EDMA Tx ring stats
1759 */
1760static ssize_t nss_stats_edma_txring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1761{
1762 int32_t i;
1763
1764 /*
1765 * max output lines = #stats + start tag line + end tag line + three blank lines
1766 */
1767 uint32_t max_output_lines = (NSS_STATS_EDMA_TX_MAX + 2) + 3;
1768 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1769 size_t size_wr = 0;
1770 ssize_t bytes_read = 0;
1771 uint64_t *stats_shadow;
1772 struct nss_stats_data *data = fp->private_data;
1773
1774 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1775 if (unlikely(lbuf == NULL)) {
1776 nss_warning("Could not allocate memory for local statistics buffer");
1777 return 0;
1778 }
1779
1780 /*
1781 * Note: The assumption here is that we do not have more than 64 stats
1782 */
1783 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1784 if (unlikely(stats_shadow == NULL)) {
1785 nss_warning("Could not allocate memory for local shadow buffer");
1786 kfree(lbuf);
1787 return 0;
1788 }
1789
1790 size_wr = scnprintf(lbuf, size_al, "edma Tx ring stats start:\n\n");
1791
1792 /*
1793 * Tx ring stats
1794 */
1795 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx ring %d stats:\n\n", data->edma_id);
1796 spin_lock_bh(&nss_top_main.stats_lock);
1797 for (i = 0; i < NSS_STATS_EDMA_TX_MAX; i++) {
1798 stats_shadow[i] = nss_top_main.stats_edma.tx_stats[data->edma_id][i];
1799 }
1800
1801 spin_unlock_bh(&nss_top_main.stats_lock);
1802
1803 for (i = 0; i < NSS_STATS_EDMA_TX_MAX; i++) {
1804 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1805 "%s = %llu\n", nss_stats_str_edma_tx[i], stats_shadow[i]);
1806 }
1807
1808 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx ring stats end\n\n");
1809 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1810 kfree(lbuf);
1811 kfree(stats_shadow);
1812
1813 return bytes_read;
1814}
1815
1816/*
1817 * nss_stats_edma_rxring_read()
1818 * Read EDMA rxring stats
1819 */
1820static ssize_t nss_stats_edma_rxring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1821{
1822 int32_t i;
1823
1824 /*
1825 * max output lines = #stats + start tag line + end tag line + three blank lines
1826 */
1827 uint32_t max_output_lines = (NSS_STATS_EDMA_RX_MAX + 2) + 3;
1828 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1829 size_t size_wr = 0;
1830 ssize_t bytes_read = 0;
1831 uint64_t *stats_shadow;
1832 struct nss_stats_data *data = fp->private_data;
1833
1834 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1835 if (unlikely(lbuf == NULL)) {
1836 nss_warning("Could not allocate memory for local statistics buffer");
1837 return 0;
1838 }
1839
1840 /*
1841 * Note: The assumption here is that we do not have more than 64 stats
1842 */
1843 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1844 if (unlikely(stats_shadow == NULL)) {
1845 nss_warning("Could not allocate memory for local shadow buffer");
1846 kfree(lbuf);
1847 return 0;
1848 }
1849
1850 size_wr = scnprintf(lbuf, size_al, "edma Rx ring stats start:\n\n");
1851
1852 /*
1853 * RX ring stats
1854 */
1855 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx ring %d stats:\n\n", data->edma_id);
1856 spin_lock_bh(&nss_top_main.stats_lock);
1857 for (i = 0; i < NSS_STATS_EDMA_RX_MAX; i++) {
1858 stats_shadow[i] = nss_top_main.stats_edma.rx_stats[data->edma_id][i];
1859 }
1860
1861 spin_unlock_bh(&nss_top_main.stats_lock);
1862
1863 for (i = 0; i < NSS_STATS_EDMA_RX_MAX; i++) {
1864 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1865 "%s = %llu\n", nss_stats_str_edma_rx[i], stats_shadow[i]);
1866 }
1867
1868 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Rx ring stats end\n\n");
1869 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1870 kfree(lbuf);
1871 kfree(stats_shadow);
1872
1873 return bytes_read;
1874}
1875
1876/*
1877 * nss_stats_edma_txcmplring_read()
1878 * Read EDMA txcmplring stats
1879 */
1880static ssize_t nss_stats_edma_txcmplring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1881{
1882 int32_t i;
1883
1884 /*
1885 * max output lines = #stats + start tag line + end tag line + three blank lines
1886 */
1887 uint32_t max_output_lines = (NSS_STATS_EDMA_TXCMPL_MAX + 2) + 3;
1888 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1889 size_t size_wr = 0;
1890 ssize_t bytes_read = 0;
1891 uint64_t *stats_shadow;
1892 struct nss_stats_data *data = fp->private_data;
1893
1894 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1895 if (unlikely(lbuf == NULL)) {
1896 nss_warning("Could not allocate memory for local statistics buffer");
1897 return 0;
1898 }
1899
1900 /*
1901 * Note: The assumption here is that we do not have more than 64 stats
1902 */
1903 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1904 if (unlikely(stats_shadow == NULL)) {
1905 nss_warning("Could not allocate memory for local shadow buffer");
1906 kfree(lbuf);
1907 return 0;
1908 }
1909
1910 size_wr = scnprintf(lbuf, size_al, "edma Tx cmpl ring stats start:\n\n");
1911
1912 /*
1913 * Tx cmpl ring stats
1914 */
1915 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx cmpl ring %d stats:\n\n", data->edma_id);
1916 spin_lock_bh(&nss_top_main.stats_lock);
1917 for (i = 0; i < NSS_STATS_EDMA_TXCMPL_MAX; i++) {
1918 stats_shadow[i] = nss_top_main.stats_edma.txcmpl_stats[data->edma_id][i];
1919 }
1920
1921 spin_unlock_bh(&nss_top_main.stats_lock);
1922
1923 for (i = 0; i < NSS_STATS_EDMA_TXCMPL_MAX; i++) {
1924 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1925 "%s = %llu\n", nss_stats_str_edma_txcmpl[i], stats_shadow[i]);
1926 }
1927
1928 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx cmpl ring stats end\n\n");
1929 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1930 kfree(lbuf);
1931 kfree(stats_shadow);
1932
1933 return bytes_read;
1934}
1935
1936/*
1937 * nss_stats_edma_rxfillring_read()
1938 * Read EDMA rxfillring stats
1939 */
1940static ssize_t nss_stats_edma_rxfillring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1941{
1942 int32_t i;
1943
1944 /*
1945 * max output lines = #stats + start tag line + end tag line + three blank lines
1946 */
1947 uint32_t max_output_lines = (NSS_STATS_EDMA_RXFILL_MAX + 2) + 3;
1948 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1949 size_t size_wr = 0;
1950 ssize_t bytes_read = 0;
1951 uint64_t *stats_shadow;
1952 struct nss_stats_data *data = fp->private_data;
1953
1954 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1955 if (unlikely(lbuf == NULL)) {
1956 nss_warning("Could not allocate memory for local statistics buffer");
1957 return 0;
1958 }
1959
1960 /*
1961 * Note: The assumption here is that we do not have more than 64 stats
1962 */
1963 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1964 if (unlikely(stats_shadow == NULL)) {
1965 nss_warning("Could not allocate memory for local shadow buffer");
1966 kfree(lbuf);
1967 return 0;
1968 }
1969
1970 size_wr = scnprintf(lbuf, size_al, "edma Rx fill ring stats start:\n\n");
1971
1972 /*
1973 * Rx fill ring stats
1974 */
1975 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx fill ring %d stats:\n\n", data->edma_id);
1976 spin_lock_bh(&nss_top_main.stats_lock);
1977 for (i = 0; i < NSS_STATS_EDMA_RXFILL_MAX; i++) {
1978 stats_shadow[i] = nss_top_main.stats_edma.rxfill_stats[data->edma_id][i];
1979 }
1980
1981 spin_unlock_bh(&nss_top_main.stats_lock);
1982
1983 for (i = 0; i < NSS_STATS_EDMA_RXFILL_MAX; i++) {
1984 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1985 "%s = %llu\n", nss_stats_str_edma_rxfill[i], stats_shadow[i]);
1986 }
1987
1988 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Rx fill ring stats end\n\n");
1989 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1990 kfree(lbuf);
1991 kfree(stats_shadow);
1992
1993 return bytes_read;
1994}
1995
1996/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301997 * nss_stats_eth_rx_read()
1998 * Read ETH_RX stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301999 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302000static 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 +05302001{
2002 int32_t i;
2003
2004 /*
2005 * max output lines = #stats + start tag line + end tag line + three blank lines
2006 */
Murat Sezgin99dab642014-08-28 14:40:34 -07002007 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 +05302008 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2009 size_t size_wr = 0;
2010 ssize_t bytes_read = 0;
2011 uint64_t *stats_shadow;
2012
2013 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2014 if (unlikely(lbuf == NULL)) {
2015 nss_warning("Could not allocate memory for local statistics buffer");
2016 return 0;
2017 }
2018
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302019 /*
2020 * Note: The assumption here is that we do not have more than 64 stats
2021 */
2022 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302023 if (unlikely(stats_shadow == NULL)) {
2024 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302025 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302026 return 0;
2027 }
2028
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302029 size_wr = scnprintf(lbuf, size_al, "eth_rx stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302030
2031 /*
2032 * Common node stats
2033 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302034 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302035 spin_lock_bh(&nss_top_main.stats_lock);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302036 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2037 stats_shadow[i] = nss_top_main.stats_node[NSS_ETH_RX_INTERFACE][i];
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302038 }
2039
2040 spin_unlock_bh(&nss_top_main.stats_lock);
2041
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302042 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302043 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302044 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302045 }
2046
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302047 /*
Murat Sezgin99dab642014-08-28 14:40:34 -07002048 * eth_rx node stats
2049 */
2050 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx node stats:\n\n");
2051 spin_lock_bh(&nss_top_main.stats_lock);
2052 for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) {
2053 stats_shadow[i] = nss_top_main.stats_eth_rx[i];
2054 }
2055
2056 spin_unlock_bh(&nss_top_main.stats_lock);
2057
2058 for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) {
2059 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2060 "%s = %llu\n", nss_stats_str_eth_rx[i], stats_shadow[i]);
2061 }
2062
2063 /*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302064 * Exception stats
2065 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302066 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302067
2068 spin_lock_bh(&nss_top_main.stats_lock);
2069 for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) {
2070 stats_shadow[i] = nss_top_main.stats_if_exception_eth_rx[i];
2071 }
2072
2073 spin_unlock_bh(&nss_top_main.stats_lock);
2074
2075 for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) {
2076 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2077 "%s = %llu\n", nss_stats_str_if_exception_eth_rx[i], stats_shadow[i]);
2078 }
2079
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302080 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302081 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2082 kfree(lbuf);
2083 kfree(stats_shadow);
2084
2085 return bytes_read;
2086}
2087
2088/*
2089 * nss_stats_n2h_read()
2090 * Read N2H stats
2091 */
2092static ssize_t nss_stats_n2h_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2093{
2094 int32_t i;
2095
2096 /*
2097 * max output lines = #stats + start tag line + end tag line + three blank lines
2098 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302099 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_N2H_MAX + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302100 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2101 size_t size_wr = 0;
2102 ssize_t bytes_read = 0;
2103 uint64_t *stats_shadow;
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002104 int max = NSS_STATS_N2H_MAX - NSS_STATS_NODE_MAX;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302105
2106 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2107 if (unlikely(lbuf == NULL)) {
2108 nss_warning("Could not allocate memory for local statistics buffer");
2109 return 0;
2110 }
2111
2112 stats_shadow = kzalloc(NSS_STATS_N2H_MAX * 8, GFP_KERNEL);
2113 if (unlikely(stats_shadow == NULL)) {
2114 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302115 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302116 return 0;
2117 }
2118
2119 size_wr = scnprintf(lbuf, size_al, "n2h stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302120
2121 /*
2122 * Common node stats
2123 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302124 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302125 spin_lock_bh(&nss_top_main.stats_lock);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302126 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2127 stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i];
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302128 }
2129
2130 spin_unlock_bh(&nss_top_main.stats_lock);
2131
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302132 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2133 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2134 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2135 }
2136
2137 /*
2138 * N2H node stats
2139 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302140 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302141 spin_lock_bh(&nss_top_main.stats_lock);
2142 for (i = NSS_STATS_NODE_MAX; (i < NSS_STATS_N2H_MAX); i++) {
2143 stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i];
2144 }
2145
2146 spin_unlock_bh(&nss_top_main.stats_lock);
2147
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002148 for (i = 0; i < max; i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302149 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002150 "%s = %llu\n", nss_stats_str_n2h[i], stats_shadow[i + NSS_STATS_NODE_MAX]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302151 }
2152
2153 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h stats end\n\n");
2154 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2155 kfree(lbuf);
2156 kfree(stats_shadow);
2157
2158 return bytes_read;
2159}
2160
2161/*
Thomas Wuc3e382c2014-10-29 15:35:13 -07002162 * nss_stats_lso_rx_read()
2163 * Read LSO_RX stats
2164 */
2165static ssize_t nss_stats_lso_rx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2166{
2167 int32_t i;
2168
2169 /*
2170 * max output lines = #stats + start tag line + end tag line + three blank lines
2171 */
2172 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_LSO_RX_MAX + 3) + 5;
2173 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2174 size_t size_wr = 0;
2175 ssize_t bytes_read = 0;
2176 uint64_t *stats_shadow;
2177
2178 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2179 if (unlikely(lbuf == NULL)) {
2180 nss_warning("Could not allocate memory for local statistics buffer");
2181 return 0;
2182 }
2183
2184 stats_shadow = kzalloc(NSS_STATS_LSO_RX_MAX * 8, GFP_KERNEL);
2185 if (unlikely(stats_shadow == NULL)) {
2186 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302187 kfree(lbuf);
Thomas Wuc3e382c2014-10-29 15:35:13 -07002188 return 0;
2189 }
2190
2191 size_wr = scnprintf(lbuf, size_al, "lso_rx stats start:\n\n");
2192
2193 /*
2194 * Common node stats
2195 */
2196 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
2197 spin_lock_bh(&nss_top_main.stats_lock);
2198 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2199 stats_shadow[i] = nss_top_main.stats_node[NSS_LSO_RX_INTERFACE][i];
2200 }
2201
2202 spin_unlock_bh(&nss_top_main.stats_lock);
2203
2204 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2205 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2206 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2207 }
2208
2209 /*
2210 * lso_rx node stats
2211 */
2212 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx node stats:\n\n");
2213 spin_lock_bh(&nss_top_main.stats_lock);
2214 for (i = 0; (i < NSS_STATS_LSO_RX_MAX); i++) {
2215 stats_shadow[i] = nss_top_main.stats_lso_rx[i];
2216 }
2217
2218 spin_unlock_bh(&nss_top_main.stats_lock);
2219
2220 for (i = 0; i < NSS_STATS_LSO_RX_MAX; i++) {
2221 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2222 "%s = %llu\n", nss_stats_str_lso_rx[i], stats_shadow[i]);
2223 }
2224
2225 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx stats end\n\n");
2226 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2227 kfree(lbuf);
2228 kfree(stats_shadow);
2229
2230 return bytes_read;
2231}
2232
2233/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302234 * nss_stats_drv_read()
2235 * Read HLOS driver stats
2236 */
2237static ssize_t nss_stats_drv_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2238{
2239 int32_t i;
2240
2241 /*
2242 * max output lines = #stats + start tag line + end tag line + three blank lines
2243 */
2244 uint32_t max_output_lines = NSS_STATS_DRV_MAX + 5;
2245 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2246 size_t size_wr = 0;
2247 ssize_t bytes_read = 0;
2248 uint64_t *stats_shadow;
2249
2250 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2251 if (unlikely(lbuf == NULL)) {
2252 nss_warning("Could not allocate memory for local statistics buffer");
2253 return 0;
2254 }
2255
2256 stats_shadow = kzalloc(NSS_STATS_DRV_MAX * 8, GFP_KERNEL);
2257 if (unlikely(stats_shadow == NULL)) {
2258 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302259 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302260 return 0;
2261 }
2262
2263 size_wr = scnprintf(lbuf, size_al, "drv stats start:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302264 for (i = 0; (i < NSS_STATS_DRV_MAX); i++) {
Sundarajan Srinivasan62fee7e2015-01-22 11:13:10 -08002265 stats_shadow[i] = NSS_PKT_STATS_READ(&nss_top_main.stats_drv[i]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302266 }
2267
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302268 for (i = 0; (i < NSS_STATS_DRV_MAX); i++) {
2269 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2270 "%s = %llu\n", nss_stats_str_drv[i], stats_shadow[i]);
2271 }
2272
2273 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ndrv stats end\n\n");
2274 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2275 kfree(lbuf);
2276 kfree(stats_shadow);
2277
2278 return bytes_read;
2279}
2280
2281/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302282 * nss_stats_pppoe_read()
2283 * Read PPPoE stats
2284 */
2285static ssize_t nss_stats_pppoe_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2286{
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302287 int32_t i, j, k;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302288
2289 /*
2290 * max output lines = #stats + start tag line + end tag line + three blank lines
2291 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302292 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_PPPOE_MAX + 3) +
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302293 ((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 +05302294 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2295 size_t size_wr = 0;
2296 ssize_t bytes_read = 0;
2297 uint64_t *stats_shadow;
2298
2299 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2300 if (unlikely(lbuf == NULL)) {
2301 nss_warning("Could not allocate memory for local statistics buffer");
2302 return 0;
2303 }
2304
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302305 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302306 if (unlikely(stats_shadow == NULL)) {
2307 nss_warning("Could not allocate memory for local shadow buffer");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302308 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302309 return 0;
2310 }
2311
2312 size_wr = scnprintf(lbuf, size_al, "pppoe stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302313
2314 /*
2315 * Common node stats
2316 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302317 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302318 spin_lock_bh(&nss_top_main.stats_lock);
2319 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2320 stats_shadow[i] = nss_top_main.stats_node[NSS_PPPOE_RX_INTERFACE][i];
2321 }
2322
2323 spin_unlock_bh(&nss_top_main.stats_lock);
2324
2325 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2326 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2327 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2328 }
2329
2330 /*
2331 * PPPoE node stats
2332 */
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002333 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npppoe node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302334 spin_lock_bh(&nss_top_main.stats_lock);
2335 for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) {
2336 stats_shadow[i] = nss_top_main.stats_pppoe[i];
2337 }
2338
2339 spin_unlock_bh(&nss_top_main.stats_lock);
2340
2341 for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) {
2342 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2343 "%s = %llu\n", nss_stats_str_pppoe[i], stats_shadow[i]);
2344 }
2345
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302346 /*
2347 * Exception stats
2348 */
2349 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nException PPPoE:\n\n");
2350
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002351 for (j = 1; j <= NSS_MAX_PHYSICAL_INTERFACES; j++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302352 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nInterface %d:\n\n", j);
2353
2354 spin_lock_bh(&nss_top_main.stats_lock);
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002355 for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) {
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302356 for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) {
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002357 stats_shadow_pppoe_except[k - 1][i] = nss_top_main.stats_if_exception_pppoe[j][k][i];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302358 }
2359 }
2360
2361 spin_unlock_bh(&nss_top_main.stats_lock);
2362
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002363 for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302364 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. Session\n", k);
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302365 for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302366 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2367 "%s = %llu\n",
2368 nss_stats_str_if_exception_pppoe[i],
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002369 stats_shadow_pppoe_except[k - 1][i]);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302370 }
2371 }
2372
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302373 }
2374
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002375 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npppoe stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302376 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2377 kfree(lbuf);
2378 kfree(stats_shadow);
2379
2380 return bytes_read;
2381}
2382
2383/*
2384 * nss_stats_gmac_read()
2385 * Read GMAC stats
2386 */
2387static ssize_t nss_stats_gmac_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2388{
2389 uint32_t i, id;
2390
2391 /*
2392 * max output lines = ((#stats + start tag + one blank) * #GMACs) + start/end tag + 3 blank
2393 */
2394 uint32_t max_output_lines = ((NSS_STATS_GMAC_MAX + 2) * NSS_MAX_PHYSICAL_INTERFACES) + 5;
2395 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2396 size_t size_wr = 0;
2397 ssize_t bytes_read = 0;
2398 uint64_t *stats_shadow;
2399
2400 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2401 if (unlikely(lbuf == NULL)) {
2402 nss_warning("Could not allocate memory for local statistics buffer");
2403 return 0;
2404 }
2405
2406 stats_shadow = kzalloc(NSS_STATS_GMAC_MAX * 8, GFP_KERNEL);
2407 if (unlikely(stats_shadow == NULL)) {
2408 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302409 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302410 return 0;
2411 }
2412
2413 size_wr = scnprintf(lbuf, size_al, "gmac stats start:\n\n");
2414
2415 for (id = 0; id < NSS_MAX_PHYSICAL_INTERFACES; id++) {
2416 spin_lock_bh(&nss_top_main.stats_lock);
2417 for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) {
2418 stats_shadow[i] = nss_top_main.stats_gmac[id][i];
2419 }
2420
2421 spin_unlock_bh(&nss_top_main.stats_lock);
2422
2423 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "GMAC ID: %d\n", id);
2424 for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) {
2425 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2426 "%s = %llu\n", nss_stats_str_gmac[i], stats_shadow[i]);
2427 }
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302428 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302429 }
2430
2431 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngmac stats end\n\n");
2432 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2433 kfree(lbuf);
2434 kfree(stats_shadow);
2435
2436 return bytes_read;
2437}
2438
Saurabh Misra09dddeb2014-09-30 16:38:07 -07002439/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05302440 * nss_stats_wifi_read()
Stephen Wangaed46332016-12-12 17:29:03 -08002441 * Read wifi statistics
Bharath M Kumarcc666e92014-12-24 19:17:28 +05302442 */
2443static ssize_t nss_stats_wifi_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2444{
2445 uint32_t i, id;
2446
2447 /*
2448 * max output lines = ((#stats + start tag + one blank) * #WIFI RADIOs) + start/end tag + 3 blank
2449 */
2450 uint32_t max_output_lines = ((NSS_STATS_WIFI_MAX + 2) * NSS_MAX_WIFI_RADIO_INTERFACES) + 5;
2451 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2452 size_t size_wr = 0;
2453 ssize_t bytes_read = 0;
2454 uint64_t *stats_shadow;
2455
2456 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2457 if (unlikely(lbuf == NULL)) {
2458 nss_warning("Could not allocate memory for local statistics buffer");
2459 return 0;
2460 }
2461
2462 stats_shadow = kzalloc(NSS_STATS_WIFI_MAX * 8, GFP_KERNEL);
2463 if (unlikely(stats_shadow == NULL)) {
2464 nss_warning("Could not allocate memory for local shadow buffer");
2465 kfree(lbuf);
2466 return 0;
2467 }
2468
2469 size_wr = scnprintf(lbuf, size_al, "wifi stats start:\n\n");
2470
2471 for (id = 0; id < NSS_MAX_WIFI_RADIO_INTERFACES; id++) {
2472 spin_lock_bh(&nss_top_main.stats_lock);
2473 for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) {
2474 stats_shadow[i] = nss_top_main.stats_wifi[id][i];
2475 }
2476
2477 spin_unlock_bh(&nss_top_main.stats_lock);
2478
2479 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFI ID: %d\n", id);
2480 for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) {
2481 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2482 "%s = %llu\n", nss_stats_str_wifi[i], stats_shadow[i]);
2483 }
2484 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,"\n");
2485 }
2486
2487 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifi stats end\n\n");
2488 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2489 kfree(lbuf);
2490 kfree(stats_shadow);
2491
2492 return bytes_read;
2493}
2494
2495/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302496 * nss_stats_wifili_read()
2497 * Read wifili statistics
2498 */
2499static ssize_t nss_stats_wifili_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2500{
2501 uint32_t i, j;
2502
2503 /*
2504 * max output lines = ((#stats + eight blank lines) * #WIFILI #STATS) + start/end tag + 3 blank
2505 */
2506 uint32_t max_output_lines = (((NSS_STATS_WIFILI_MAX + 9) * NSS_WIFILI_MAX_PDEV_NUM_MSG)+
2507 NSS_STATS_WIFILI_WBM_MAX + 5);
2508 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2509 size_t size_wr = 0;
2510 ssize_t bytes_read = 0;
2511 uint64_t *stats_shadow;
2512
2513 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2514 if (unlikely(lbuf == NULL)) {
2515 nss_warning("Could not allocate memory for local statistics buffer");
2516 return 0;
2517 }
2518
2519 /*
2520 * Take max of all wifili stats
2521 *
2522 * NOTE: txrx stats is bigger of all stats
2523 */
2524 stats_shadow = kzalloc(NSS_STATS_WIFILI_TXRX_MAX * 8, GFP_KERNEL);
2525 if (unlikely(stats_shadow == NULL)) {
2526 nss_warning("Could not allocate memory for local shadow buffer");
2527 kfree(lbuf);
2528 return 0;
2529 }
2530
2531 size_wr = scnprintf(lbuf, size_al, "wifili stats start:\n\n");
2532
2533 for (i = 0; i < NSS_WIFILI_MAX_PDEV_NUM_MSG; i++) {
2534
2535 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFILI ID: %d\n", i);
2536
2537 spin_lock_bh(&nss_top_main.stats_lock);
2538 for (j = 0; (j < NSS_STATS_WIFILI_TXRX_MAX); j++) {
2539 stats_shadow[j] = nss_top_main.stats_wifili.stats_txrx[i][j];
2540 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2541 "%s = %llu\n", nss_stats_str_wifili_txrx[j], stats_shadow[j]);
2542 }
2543
2544 spin_unlock_bh(&nss_top_main.stats_lock);
2545 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2546
2547 /*
2548 * Fillinng TCL ring stats
2549 */
2550 spin_lock_bh(&nss_top_main.stats_lock);
2551 for (j = 0; (j < NSS_STATS_WIFILI_TCL_MAX); j++) {
2552 stats_shadow[j] = nss_top_main.stats_wifili.stats_tcl_ring[i][j];
2553 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2554 "%s = %llu\n", nss_stats_str_wifili_tcl[j], stats_shadow[j]);
2555 }
2556
2557 spin_unlock_bh(&nss_top_main.stats_lock);
2558 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2559
2560 /*
2561 * Fillinng TCL comp stats
2562 */
2563 spin_lock_bh(&nss_top_main.stats_lock);
2564 for (j = 0; (j < NSS_STATS_WIFILI_TX_DESC_FREE_MAX); j++) {
2565 stats_shadow[j] = nss_top_main.stats_wifili.stats_tx_comp[i][j];
2566 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2567 "%s = %llu\n", nss_stats_str_wifili_tx_comp[j], stats_shadow[j]);
2568 }
2569
2570 spin_unlock_bh(&nss_top_main.stats_lock);
2571 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2572
2573 /*
2574 * Fillinng reo ring stats
2575 */
2576 spin_lock_bh(&nss_top_main.stats_lock);
2577 for (j = 0; (j < NSS_STATS_WIFILI_REO_MAX); j++) {
2578 stats_shadow[j] = nss_top_main.stats_wifili.stats_reo[i][j];
2579 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2580 "%s = %llu\n", nss_stats_str_wifili_reo[j], stats_shadow[j]);
2581 }
2582
2583 spin_unlock_bh(&nss_top_main.stats_lock);
2584 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2585
2586 /*
2587 * Fillinng TX SW Pool
2588 */
2589 spin_lock_bh(&nss_top_main.stats_lock);
2590 for (j = 0; (j < NSS_STATS_WIFILI_TX_DESC_MAX); j++) {
2591 stats_shadow[j] = nss_top_main.stats_wifili.stats_tx_desc[i][j];
2592 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2593 "%s = %llu\n", nss_stats_str_wifili_txsw_pool[j], stats_shadow[j]);
2594 }
2595
2596 spin_unlock_bh(&nss_top_main.stats_lock);
2597 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2598
2599 /*
2600 * Fillinng TX EXt SW Pool
2601 */
2602 spin_lock_bh(&nss_top_main.stats_lock);
2603 for (j = 0; (j < NSS_STATS_WIFILI_EXT_TX_DESC_MAX); j++) {
2604 stats_shadow[j] = nss_top_main.stats_wifili.stats_ext_tx_desc[i][j];
2605 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2606 "%s = %llu\n", nss_stats_str_wifili_ext_txsw_pool[j], stats_shadow[j]);
2607 }
2608
2609 spin_unlock_bh(&nss_top_main.stats_lock);
2610 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2611
2612 /*
2613 * Fillinng rxdma pool stats
2614 */
2615 spin_lock_bh(&nss_top_main.stats_lock);
2616 for (j = 0; (j < NSS_STATS_WIFILI_RX_DESC_MAX); j++) {
2617 stats_shadow[j] = nss_top_main.stats_wifili.stats_rx_desc[i][j];
2618 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2619 "%s = %llu\n", nss_stats_str_wifili_rxdma_pool[j], stats_shadow[j]);
2620 }
2621
2622 spin_unlock_bh(&nss_top_main.stats_lock);
2623 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2624
2625 /*
2626 * Fillinng rxdma ring stats
2627 */
2628 spin_lock_bh(&nss_top_main.stats_lock);
2629 for (j = 0; (j < NSS_STATS_WIFILI_RXDMA_DESC_MAX); j++) {
2630 stats_shadow[j] = nss_top_main.stats_wifili.stats_rxdma[i][j];
2631 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2632 "%s = %llu\n", nss_stats_str_wifili_rxdma_ring[j], stats_shadow[j]);
2633 }
2634
2635 spin_unlock_bh(&nss_top_main.stats_lock);
2636 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2637
2638 }
2639
2640 /*
2641 * Fillinng wbm ring stats
2642 */
2643 spin_lock_bh(&nss_top_main.stats_lock);
2644 for (j = 0; (j < NSS_STATS_WIFILI_WBM_MAX); j++) {
2645 stats_shadow[j] = nss_top_main.stats_wifili.stats_wbm[j];
2646 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2647 "%s = %llu\n", nss_stats_str_wifili_wbm[j], stats_shadow[j]);
2648 }
2649
2650 spin_unlock_bh(&nss_top_main.stats_lock);
2651 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifili stats end\n\n");
2652
2653 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2654 kfree(lbuf);
2655 kfree(stats_shadow);
2656
2657 return bytes_read;
2658}
2659
2660/*
Tushar Mathurff8741b2015-12-02 20:28:59 +05302661 * nss_stats_dtls_read()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07002662 * Read DTLS session statistics
Tushar Mathurff8741b2015-12-02 20:28:59 +05302663 */
2664static ssize_t nss_stats_dtls_read(struct file *fp, char __user *ubuf,
2665 size_t sz, loff_t *ppos)
2666{
2667 uint32_t max_output_lines = 2 + (NSS_MAX_DTLS_SESSIONS
2668 * (NSS_STATS_DTLS_SESSION_MAX + 2)) + 2;
2669 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2670 size_t size_wr = 0;
2671 ssize_t bytes_read = 0;
2672 struct net_device *dev;
2673 int id, i;
2674 struct nss_stats_dtls_session_debug *dtls_session_stats = NULL;
2675
2676 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2677 if (unlikely(lbuf == NULL)) {
2678 nss_warning("Could not allocate memory for local statistics buffer");
2679 return 0;
2680 }
2681
2682 dtls_session_stats = kzalloc((sizeof(struct nss_stats_dtls_session_debug)
2683 * NSS_MAX_DTLS_SESSIONS), GFP_KERNEL);
2684 if (unlikely(dtls_session_stats == NULL)) {
2685 nss_warning("Could not allocate memory for populating DTLS stats");
2686 kfree(lbuf);
2687 return 0;
2688 }
2689
2690 /*
2691 * Get all stats
2692 */
2693 nss_dtls_session_debug_stats_get(dtls_session_stats);
2694
2695 /*
2696 * Session stats
2697 */
2698 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2699 "\nDTLS session stats start:\n\n");
2700
2701 for (id = 0; id < NSS_MAX_DTLS_SESSIONS; id++) {
2702 if (!dtls_session_stats[id].valid)
2703 break;
2704
2705 dev = dev_get_by_index(&init_net, dtls_session_stats[id].if_index);
2706 if (likely(dev)) {
2707 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2708 "%d. nss interface id=%d, netdevice=%s\n",
2709 id, dtls_session_stats[id].if_num,
2710 dev->name);
2711 dev_put(dev);
2712 } else {
2713 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2714 "%d. nss interface id=%d\n", id,
2715 dtls_session_stats[id].if_num);
2716 }
2717
2718 for (i = 0; i < NSS_STATS_DTLS_SESSION_MAX; i++) {
2719 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2720 "\t%s = %llu\n",
2721 nss_stats_str_dtls_session_debug_stats[i],
2722 dtls_session_stats[id].stats[i]);
2723 }
2724
2725 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2726 }
2727
2728 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2729 "\nDTLS session stats end\n");
2730 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2731
2732 kfree(dtls_session_stats);
2733 kfree(lbuf);
2734 return bytes_read;
2735}
2736
Tushar Mathurff8741b2015-12-02 20:28:59 +05302737/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07002738 * nss_stats_gre_tunnel_read()
2739 * Read GRE Tunnel session statistics
2740 */
2741static ssize_t nss_stats_gre_tunnel_read(struct file *fp, char __user *ubuf,
2742 size_t sz, loff_t *ppos)
2743{
2744 uint32_t max_output_lines = 2 + (NSS_MAX_GRE_TUNNEL_SESSIONS
2745 * (NSS_STATS_GRE_TUNNEL_SESSION_MAX + 2)) + 2;
2746 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2747 size_t size_wr = 0;
2748 ssize_t bytes_read = 0;
2749 struct net_device *dev;
2750 int id, i;
2751 struct nss_stats_gre_tunnel_session_debug *gre_tunnel_session_stats = NULL;
2752
2753 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2754 if (unlikely(lbuf == NULL)) {
2755 nss_warning("Could not allocate memory for local statistics buffer");
2756 return 0;
2757 }
2758
2759 gre_tunnel_session_stats = kzalloc((sizeof(struct nss_stats_gre_tunnel_session_debug)
2760 * NSS_MAX_GRE_TUNNEL_SESSIONS), GFP_KERNEL);
2761 if (unlikely(gre_tunnel_session_stats == NULL)) {
2762 nss_warning("Could not allocate memory for populating GRE Tunnel stats");
2763 kfree(lbuf);
2764 return 0;
2765 }
2766
2767 /*
2768 * Get all stats
2769 */
2770 nss_gre_tunnel_session_debug_stats_get(gre_tunnel_session_stats);
2771
2772 /*
2773 * Session stats
2774 */
2775 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2776 "\nGRE Tunnel session stats start:\n\n");
2777
2778 for (id = 0; id < NSS_MAX_GRE_TUNNEL_SESSIONS; id++) {
2779 if (!gre_tunnel_session_stats[id].valid)
2780 break;
2781
2782 dev = dev_get_by_index(&init_net, gre_tunnel_session_stats[id].if_index);
2783 if (likely(dev)) {
2784 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2785 "%d. nss interface id=%d, netdevice=%s\n",
2786 id, gre_tunnel_session_stats[id].if_num,
2787 dev->name);
2788 dev_put(dev);
2789 } else {
2790 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2791 "%d. nss interface id=%d\n", id,
2792 gre_tunnel_session_stats[id].if_num);
2793 }
2794
2795 for (i = 0; i < NSS_STATS_GRE_TUNNEL_SESSION_MAX; i++) {
2796 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2797 "\t%s = %llu\n",
2798 nss_stats_str_gre_tunnel_session_debug_stats[i],
2799 gre_tunnel_session_stats[id].stats[i]);
2800 }
2801
2802 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2803 }
2804
2805 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2806 "\nGRE Tunnel session stats end\n");
2807 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2808
2809 kfree(gre_tunnel_session_stats);
2810 kfree(lbuf);
2811 return bytes_read;
2812}
2813
2814/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +05302815 * nss_stats_l2tpv2_read()
2816 * Read l2tpv2 statistics
2817 */
2818static ssize_t nss_stats_l2tpv2_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2819{
2820
2821 uint32_t max_output_lines = 2 /* header & footer for session stats */
2822 + NSS_MAX_L2TPV2_DYNAMIC_INTERFACES * (NSS_STATS_L2TPV2_SESSION_MAX + 2) /*session stats */
2823 + 2;
2824 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ;
2825 size_t size_wr = 0;
2826 ssize_t bytes_read = 0;
2827 struct net_device *dev;
2828 struct nss_stats_l2tpv2_session_debug l2tpv2_session_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES];
2829 int id, i;
2830
2831 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2832 if (unlikely(lbuf == NULL)) {
2833 nss_warning("Could not allocate memory for local statistics buffer");
2834 return 0;
2835 }
2836
2837 memset(&l2tpv2_session_stats, 0, sizeof(struct nss_stats_l2tpv2_session_debug) * NSS_MAX_L2TPV2_DYNAMIC_INTERFACES);
2838
2839 /*
2840 * Get all stats
2841 */
2842 nss_l2tpv2_session_debug_stats_get((void *)&l2tpv2_session_stats);
2843
2844 /*
2845 * Session stats
2846 */
2847 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats start:\n\n");
2848 for (id = 0; id < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; id++) {
2849
2850 if (!l2tpv2_session_stats[id].valid) {
2851 break;
2852 }
2853
2854 dev = dev_get_by_index(&init_net, l2tpv2_session_stats[id].if_index);
2855 if (likely(dev)) {
2856
2857 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
2858 l2tpv2_session_stats[id].if_num, dev->name);
2859 dev_put(dev);
2860 } else {
2861 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
2862 l2tpv2_session_stats[id].if_num);
2863 }
2864
2865 for (i = 0; i < NSS_STATS_L2TPV2_SESSION_MAX; i++) {
2866 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2867 "\t%s = %llu\n", nss_stats_str_l2tpv2_session_debug_stats[i],
2868 l2tpv2_session_stats[id].stats[i]);
2869 }
2870 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2871 }
2872
2873 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats end\n");
2874 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2875
2876 kfree(lbuf);
2877 return bytes_read;
2878}
2879
2880/*
ratheesh kannotha1245c32015-11-04 16:45:43 +05302881 * nss_stats_map_t_read()
2882 * Read map_t statistics
2883 */
2884static ssize_t nss_stats_map_t_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2885{
2886
2887 uint32_t max_output_lines = 2 /* header & footer for instance stats */
2888 + NSS_MAX_MAP_T_DYNAMIC_INTERFACES * (NSS_STATS_MAP_T_MAX + 2) /*instance stats */
2889 + 2;
2890 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2891 size_t size_wr = 0;
2892 ssize_t bytes_read = 0;
2893 struct net_device *dev;
2894 struct nss_stats_map_t_instance_debug map_t_instance_stats[NSS_MAX_MAP_T_DYNAMIC_INTERFACES];
2895 int id, i;
2896
2897 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2898 if (unlikely(!lbuf)) {
2899 nss_warning("Could not allocate memory for local statistics buffer");
2900 return 0;
2901 }
2902
2903 memset(&map_t_instance_stats, 0, sizeof(struct nss_stats_map_t_instance_debug) * NSS_MAX_MAP_T_DYNAMIC_INTERFACES);
2904
2905 /*
2906 * Get all stats
2907 */
2908 nss_map_t_instance_debug_stats_get((void *)&map_t_instance_stats);
2909
2910 /*
2911 * Session stats
2912 */
2913 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats start:\n\n");
2914 for (id = 0; id < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; id++) {
2915
2916 if (!map_t_instance_stats[id].valid) {
2917 break;
2918 }
2919
2920 dev = dev_get_by_index(&init_net, map_t_instance_stats[id].if_index);
2921 if (likely(dev)) {
2922
2923 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
2924 map_t_instance_stats[id].if_num, dev->name);
2925 dev_put(dev);
2926 } else {
2927 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
2928 map_t_instance_stats[id].if_num);
2929 }
2930
2931 for (i = 0; i < NSS_STATS_MAP_T_MAX; i++) {
2932 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2933 "\t%s = %llu\n", nss_stats_str_map_t_instance_debug_stats[i],
2934 map_t_instance_stats[id].stats[i]);
2935 }
2936 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2937 }
2938
2939 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats end\n");
2940 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2941
2942 kfree(lbuf);
2943 return bytes_read;
2944}
2945
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05302946 /*
2947 * nss_stats_gre_read()
2948 * Read GRE statistics
2949 */
2950static ssize_t nss_stats_gre_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2951{
2952 uint32_t max_output_lines = 2 /* header & footer for base debug stats */
2953 + 2 /* header & footer for session debug stats */
2954 + NSS_STATS_GRE_BASE_DEBUG_MAX /* Base debug */
2955 + NSS_GRE_MAX_DEBUG_SESSION_STATS * (NSS_STATS_GRE_SESSION_DEBUG_MAX + 2) /*session stats */
2956 + 2;
2957 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2958 size_t size_wr = 0;
2959 ssize_t bytes_read = 0;
2960 struct net_device *dev;
2961 struct nss_stats_gre_session_debug *sstats;
2962 struct nss_stats_gre_base_debug *bstats;
2963 int id, i;
2964
2965 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2966 if (unlikely(!lbuf)) {
2967 nss_warning("Could not allocate memory for local statistics buffer");
2968 return 0;
2969 }
2970
2971 bstats = kzalloc(sizeof(struct nss_stats_gre_base_debug), GFP_KERNEL);
2972 if (unlikely(!bstats)) {
2973 nss_warning("Could not allocate memory for base debug statistics buffer");
2974 kfree(lbuf);
2975 return 0;
2976 }
2977
2978 sstats = kzalloc(sizeof(struct nss_stats_gre_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS, GFP_KERNEL);
2979 if (unlikely(!sstats)) {
2980 nss_warning("Could not allocate memory for base debug statistics buffer");
2981 kfree(lbuf);
2982 kfree(bstats);
2983 return 0;
2984 }
2985
2986 /*
2987 * Get all base stats
2988 */
2989 nss_gre_base_debug_stats_get((void *)bstats, sizeof(struct nss_stats_gre_base_debug));
2990 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Base stats start:\n\n");
2991 for (i = 0; i < NSS_STATS_GRE_BASE_DEBUG_MAX; i++) {
2992 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2993 "\t%s = %llu\n", nss_stats_str_gre_base_debug_stats[i],
2994 bstats->stats[i]);
2995 }
2996
2997 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Base stats End\n\n");
2998
2999 /*
3000 * Get all session stats
3001 */
3002 nss_gre_session_debug_stats_get(sstats, sizeof(struct nss_stats_gre_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS);
3003 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Session stats start:\n\n");
3004
3005 for (id = 0; id < NSS_GRE_MAX_DEBUG_SESSION_STATS; id++) {
3006
3007 if (!((sstats + id)->valid)) {
3008 continue;
3009 }
3010
3011 dev = dev_get_by_index(&init_net, (sstats + id)->if_index);
3012 if (likely(dev)) {
3013
3014 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
3015 (sstats + id)->if_num, dev->name);
3016 dev_put(dev);
3017 } else {
3018 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
3019 (sstats + id)->if_num);
3020 }
3021
3022 for (i = 0; i < NSS_STATS_GRE_SESSION_DEBUG_MAX; i++) {
3023 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3024 "\t%s = %llu\n", nss_stats_str_gre_session_debug_stats[i],
3025 (sstats + id)->stats[i]);
3026 }
3027 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3028 }
3029
3030 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Session stats end\n");
3031 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3032
3033 kfree(sstats);
3034 kfree(bstats);
3035 kfree(lbuf);
3036 return bytes_read;
3037}
3038
ratheesh kannotha1245c32015-11-04 16:45:43 +05303039/*
Amit Gupta316729b2016-08-12 12:21:15 +05303040 * nss_stats_ppe_conn_read()
3041 * Read ppe connection stats
3042 */
3043static ssize_t nss_stats_ppe_conn_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3044{
3045
3046 int i;
3047 char *lbuf = NULL;
3048 size_t size_wr = 0;
3049 ssize_t bytes_read = 0;
3050 uint32_t ppe_stats[NSS_STATS_PPE_CONN_MAX];
3051 uint32_t max_output_lines = 2 /* header & footer for session stats */
3052 + NSS_STATS_PPE_CONN_MAX /* PPE flow counters */
3053 + 2;
3054 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3055
Amit Gupta316729b2016-08-12 12:21:15 +05303056 lbuf = kzalloc(size_al, GFP_KERNEL);
3057 if (unlikely(lbuf == NULL)) {
3058 nss_warning("Could not allocate memory for local statistics buffer");
3059 return 0;
3060 }
3061
3062 memset(&ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_CONN_MAX);
3063
3064 /*
3065 * Get all stats
3066 */
3067 nss_ppe_stats_conn_get(ppe_stats);
3068
3069 /*
3070 * flow stats
3071 */
3072 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters start:\n\n");
3073
3074 for (i = 0; i < NSS_STATS_PPE_CONN_MAX; i++) {
3075 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3076 "\t%s = %u\n", nss_stats_str_ppe_conn[i],
3077 ppe_stats[i]);
3078 }
3079
3080 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3081
3082 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters end\n");
3083 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3084
3085 kfree(lbuf);
3086 return bytes_read;
3087}
3088
3089/*
3090 * nss_stats_ppe_l3_read()
3091 * Read ppe L3 debug stats
3092 */
3093static ssize_t nss_stats_ppe_l3_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3094{
3095
3096 int i;
3097 char *lbuf = NULL;
3098 size_t size_wr = 0;
3099 ssize_t bytes_read = 0;
3100 uint32_t ppe_stats[NSS_STATS_PPE_L3_MAX];
3101 uint32_t max_output_lines = 2 /* header & footer for session stats */
3102 + NSS_STATS_PPE_L3_MAX /* PPE flow counters */
3103 + 2;
3104 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3105
3106 lbuf = kzalloc(size_al, GFP_KERNEL);
3107 if (unlikely(!lbuf)) {
3108 nss_warning("Could not allocate memory for local statistics buffer");
3109 return 0;
3110 }
3111
3112 memset(ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_L3_MAX);
3113
3114 /*
3115 * Get all stats
3116 */
3117 nss_ppe_stats_l3_get(ppe_stats);
3118
3119 /*
3120 * flow stats
3121 */
3122 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats start:\n\n");
3123
3124 for (i = 0; i < NSS_STATS_PPE_L3_MAX; i++) {
3125 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3126 "\t%s = 0x%x\n", nss_stats_str_ppe_l3[i],
3127 ppe_stats[i]);
3128 }
3129
3130 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3131
3132 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats end\n");
3133 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3134
3135 kfree(lbuf);
3136 return bytes_read;
3137}
3138
3139/*
3140 * nss_stats_ppe_code_read()
3141 * Read ppe CPU & DROP code
3142 */
3143static ssize_t nss_stats_ppe_code_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3144{
3145
3146 int i;
3147 char *lbuf = NULL;
3148 size_t size_wr = 0;
3149 ssize_t bytes_read = 0;
3150 uint32_t ppe_stats[NSS_STATS_PPE_CODE_MAX];
3151 uint32_t max_output_lines = 2 /* header & footer for session stats */
3152 + NSS_STATS_PPE_CODE_MAX /* PPE flow counters */
3153 + 2;
3154 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3155
3156 lbuf = kzalloc(size_al, GFP_KERNEL);
3157 if (unlikely(!lbuf)) {
3158 nss_warning("Could not allocate memory for local statistics buffer");
3159 return 0;
3160 }
3161
3162 memset(ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_CODE_MAX);
3163
3164 /*
3165 * Get all stats
3166 */
3167 nss_ppe_stats_code_get(ppe_stats);
3168
3169 /*
3170 * flow stats
3171 */
3172 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats start:\n\n");
3173
3174 for (i = 0; i < NSS_STATS_PPE_CODE_MAX; i++) {
3175 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3176 "\t%s = %u\n", nss_stats_str_ppe_code[i],
3177 ppe_stats[i]);
3178 }
3179
3180 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3181
3182 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats end\n");
3183 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3184
3185 kfree(lbuf);
3186 return bytes_read;
3187}
3188
3189/*
Amit Gupta79c1c202017-06-30 15:28:13 +05303190 * nss_stats_ppe_port_dc_read()
3191 * Read PPE per port drop code stats
3192 */
3193static ssize_t nss_stats_ppe_port_dc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3194{
3195 int32_t i;
3196
3197 /*
3198 * max output lines = #stats + 2 start tag line + 2 end tag line + five blank lines
3199 */
3200 uint32_t max_output_lines = (NSS_STATS_PPE_DROP_CODE_MAX + 4) + 5;
3201 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3202 size_t size_wr = 0;
3203 ssize_t bytes_read = 0;
3204 struct nss_stats_data *data = fp->private_data;
3205 uint32_t *ppe_stats;
3206
3207 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3208 if (unlikely(lbuf == NULL)) {
3209 nss_warning("Could not allocate memory for local statistics buffer");
3210 return 0;
3211 }
3212
3213 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_DROP_CODE_MAX, GFP_KERNEL);
3214 if (unlikely(ppe_stats == NULL)) {
3215 kfree(lbuf);
3216 nss_warning("Could not allocate memory for ppe stats buffer");
3217 return 0;
3218 }
3219
3220 /*
3221 * Get drop code counters for specific port
3222 */
3223 nss_ppe_port_drop_code_get(ppe_stats, data->edma_id);
3224 size_wr = scnprintf(lbuf, size_al, "ppe no drop code stats start:\n\n");
3225 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3226 "\t%s = %u\n", nss_stats_str_ppe_dc[0],
3227 ppe_stats[0]);
3228 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe no drop code stats end\n\n");
3229
3230 /*
3231 * Drop code stats
3232 */
3233 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "ppe non-zero drop code stats start:\n\n");
3234 for (i = 1; i < NSS_STATS_PPE_DROP_CODE_MAX; i++) {
3235 /*
3236 * Print only non-zero stats.
3237 */
3238 if (!ppe_stats[i]) {
3239 continue;
3240 }
3241
3242 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3243 "\t%s = %u\n", nss_stats_str_ppe_dc[i],
3244 ppe_stats[i]);
3245 }
3246 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero drop code stats end\n\n");
3247
3248 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3249 kfree(ppe_stats);
3250 kfree(lbuf);
3251
3252 return bytes_read;
3253}
3254
3255/*
3256 * nss_stats_ppe_exception_cc_read()
3257 * Read PPE CPU code stats specific to flow exceptions
3258 */
3259static ssize_t nss_stats_ppe_exception_cc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3260{
3261 int32_t i;
3262
3263 /*
3264 * max output lines = #stats + start tag line + end tag line + three blank lines
3265 */
3266 uint32_t max_output_lines = (NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX + 2) + 3;
3267 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3268 size_t size_wr = 0;
3269 ssize_t bytes_read = 0;
3270 uint32_t *ppe_stats;
3271
3272 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3273 if (unlikely(lbuf == NULL)) {
3274 nss_warning("Could not allocate memory for local statistics buffer");
3275 return 0;
3276 }
3277
3278 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX, GFP_KERNEL);
3279 if (unlikely(ppe_stats == NULL)) {
3280 kfree(lbuf);
3281 nss_warning("Could not allocate memory for ppe stats buffer");
3282 return 0;
3283 }
3284
3285 /*
3286 * Get CPU code counters for flow specific exceptions
3287 */
3288 nss_ppe_cpu_code_exception_get(ppe_stats);
3289
3290 size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code flow-exception stats start:\n\n");
3291
3292 /*
3293 * CPU code stats
3294 */
3295 for (i = 0; i < NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX; i++) {
3296 /*
3297 * Print only non-zero stats.
3298 */
3299 if (!ppe_stats[i]) {
3300 continue;
3301 }
3302
3303 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3304 "\t%s = %u\n", nss_stats_str_ppe_cc[i],
3305 ppe_stats[i]);
3306 }
3307
3308 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code flow-exception stats end\n\n");
3309 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3310 kfree(ppe_stats);
3311 kfree(lbuf);
3312
3313 return bytes_read;
3314}
3315
3316/*
3317 * nss_stats_ppe_nonexception_cc_read()
3318 * Read PPE CPU code stats for other than flow exceptions
3319 */
3320static ssize_t nss_stats_ppe_nonexception_cc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3321{
3322 int32_t i;
3323
3324 /*
3325 * max output lines = #stats + start tag line + end tag line + three blank lines
3326 */
3327 uint32_t max_output_lines = (NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX + 2) + 3;
3328 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3329 size_t size_wr = 0;
3330 ssize_t bytes_read = 0;
3331 uint32_t *ppe_stats;
3332
3333 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3334 if (unlikely(lbuf == NULL)) {
3335 nss_warning("Could not allocate memory for local statistics buffer");
3336 return 0;
3337 }
3338
3339 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX, GFP_KERNEL);
3340 if (unlikely(ppe_stats == NULL)) {
3341 kfree(lbuf);
3342 nss_warning("Could not allocate memory for ppe stats buffer");
3343 return 0;
3344 }
3345
3346 /*
3347 * Get CPU code counters for non flow exceptions
3348 */
3349 nss_ppe_cpu_code_nonexception_get(ppe_stats);
3350
3351 /*
3352 * CPU code stats
3353 */
3354 size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code non-flow exception stats start:\n\n");
3355 for (i = 0; i < NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX; i++) {
3356 /*
3357 * Print only non-zero stats.
3358 */
3359 if (!ppe_stats[i]) {
3360 continue;
3361 }
3362
3363 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3364 "\t%s = %u\n", nss_stats_str_ppe_cc[i + NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_START],
3365 ppe_stats[i]);
3366 }
3367
3368 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code non-flow exception stats end\n\n");
3369 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3370 kfree(ppe_stats);
3371 kfree(lbuf);
3372
3373 return bytes_read;
3374}
3375
3376/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05303377 * nss_stats_pptp_read()
3378 * Read pptp statistics
3379 */
3380static ssize_t nss_stats_pptp_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3381{
3382
3383 uint32_t max_output_lines = 2 /* header & footer for session stats */
3384 + NSS_MAX_PPTP_DYNAMIC_INTERFACES * (NSS_STATS_PPTP_SESSION_MAX + 2) /*session stats */
3385 + 2;
3386 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ;
3387 size_t size_wr = 0;
3388 ssize_t bytes_read = 0;
3389 struct net_device *dev;
3390 struct nss_stats_pptp_session_debug pptp_session_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES];
3391 int id, i;
3392
3393 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3394 if (unlikely(lbuf == NULL)) {
3395 nss_warning("Could not allocate memory for local statistics buffer");
3396 return 0;
3397 }
3398
3399 memset(&pptp_session_stats, 0, sizeof(struct nss_stats_pptp_session_debug) * NSS_MAX_PPTP_DYNAMIC_INTERFACES);
3400
3401 /*
3402 * Get all stats
3403 */
3404 nss_pptp_session_debug_stats_get((void *)&pptp_session_stats);
3405
3406 /*
3407 * Session stats
3408 */
3409 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats start:\n\n");
3410 for (id = 0; id < NSS_MAX_PPTP_DYNAMIC_INTERFACES; id++) {
3411
3412 if (!pptp_session_stats[id].valid) {
3413 break;
3414 }
3415
3416 dev = dev_get_by_index(&init_net, pptp_session_stats[id].if_index);
3417 if (likely(dev)) {
3418
3419 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
3420 pptp_session_stats[id].if_num, dev->name);
3421 dev_put(dev);
3422 } else {
3423 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
3424 pptp_session_stats[id].if_num);
3425 }
3426
3427 for (i = 0; i < NSS_STATS_PPTP_SESSION_MAX; i++) {
3428 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3429 "\t%s = %llu\n", nss_stats_str_pptp_session_debug_stats[i],
3430 pptp_session_stats[id].stats[i]);
3431 }
3432 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3433 }
3434
3435 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats end\n");
3436 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3437
3438 kfree(lbuf);
3439 return bytes_read;
3440}
3441
3442/*
Ankit Dhanuka14999992014-11-12 15:35:11 +05303443 * nss_stats_sjack_read()
3444 * Read SJACK stats
3445 */
3446static ssize_t nss_stats_sjack_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3447{
3448 int32_t i;
3449 /*
3450 * max output lines = #stats + start tag line + end tag line + three blank lines
3451 */
3452 uint32_t max_output_lines = NSS_STATS_NODE_MAX + 5;
3453 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3454 size_t size_wr = 0;
3455 ssize_t bytes_read = 0;
3456 uint64_t *stats_shadow;
3457
3458 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3459 if (unlikely(lbuf == NULL)) {
3460 nss_warning("Could not allocate memory for local statistics buffer");
3461 return 0;
3462 }
3463
3464 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
3465 if (unlikely(stats_shadow == NULL)) {
3466 nss_warning("Could not allocate memory for local shadow buffer");
3467 kfree(lbuf);
3468 return 0;
3469 }
3470
3471 size_wr = scnprintf(lbuf, size_al, "sjack stats start:\n\n");
3472
3473 /*
3474 * Common node stats
3475 */
3476 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
3477 spin_lock_bh(&nss_top_main.stats_lock);
3478 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3479 stats_shadow[i] = nss_top_main.stats_node[NSS_SJACK_INTERFACE][i];
3480 }
3481
3482 spin_unlock_bh(&nss_top_main.stats_lock);
3483
3484 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3485 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3486 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
3487 }
3488
3489 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nsjack stats end\n\n");
3490
3491 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3492 kfree(lbuf);
3493 kfree(stats_shadow);
3494
3495 return bytes_read;
3496}
3497
3498/*
Stephen Wang9779d952015-10-28 11:39:07 -07003499 * nss_stats_portid_read()
3500 * Read PortID stats
3501 */
3502static ssize_t nss_stats_portid_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3503{
3504 int32_t i;
3505 /*
3506 * max output lines = #stats + start tag line + end tag line + three blank lines
3507 */
3508 uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_STATS_PORTID_MAX + 5;
3509 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3510 size_t size_wr = 0;
3511 ssize_t bytes_read = 0;
3512 uint64_t *stats_shadow;
3513
3514 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3515 if (unlikely(lbuf == NULL)) {
3516 nss_warning("Could not allocate memory for local statistics buffer");
3517 return 0;
3518 }
3519
3520 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
3521 if (unlikely(stats_shadow == NULL)) {
3522 nss_warning("Could not allocate memory for local shadow buffer");
3523 kfree(lbuf);
3524 return 0;
3525 }
3526
3527 size_wr = scnprintf(lbuf, size_al, "portid stats start:\n\n");
3528
3529 /*
3530 * Common node stats
3531 */
3532 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
3533 spin_lock_bh(&nss_top_main.stats_lock);
3534 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3535 stats_shadow[i] = nss_top_main.stats_node[NSS_PORTID_INTERFACE][i];
3536 }
3537
3538 spin_unlock_bh(&nss_top_main.stats_lock);
3539
3540 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3541 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3542 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
3543 }
3544
3545 /*
3546 * PortID node stats
3547 */
3548 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid node stats:\n\n");
3549
3550 spin_lock_bh(&nss_top_main.stats_lock);
3551 for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) {
3552 stats_shadow[i] = nss_top_main.stats_portid[i];
3553 }
3554
3555 spin_unlock_bh(&nss_top_main.stats_lock);
3556
3557 for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) {
3558 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3559 "%s = %llu\n", nss_stats_str_portid[i], stats_shadow[i]);
3560 }
3561
3562 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid stats end\n\n");
3563
3564 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3565 kfree(lbuf);
3566 kfree(stats_shadow);
3567
3568 return bytes_read;
3569}
3570
3571/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003572 * nss_stats_capwap_encap()
3573 * Make a row for CAPWAP encap stats.
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003574 */
3575static ssize_t nss_stats_capwap_encap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s)
3576{
Saurabh Misra3f66e872015-04-03 11:30:42 -07003577 char *header[] = { "packets", "bytes", "fragments", "drop_ref", "drop_ver", "drop_unalign",
3578 "drop_hroom", "drop_dtls", "drop_nwireless", "drop_qfull", "drop_memfail", "unknown" };
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003579 uint64_t tcnt = 0;
3580
3581 switch (i) {
3582 case 0:
3583 tcnt = s->pnode_stats.tx_packets;
3584 break;
3585 case 1:
3586 tcnt = s->pnode_stats.tx_bytes;
3587 break;
3588 case 2:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003589 tcnt = s->tx_segments;
3590 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003591 case 3:
3592 tcnt = s->tx_dropped_sg_ref;
3593 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003594 case 4:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003595 tcnt = s->tx_dropped_ver_mis;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003596 break;
3597 case 5:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003598 tcnt = s->tx_dropped_unalign;
3599 break;
3600 case 6:
3601 tcnt = s->tx_dropped_hroom;
3602 break;
3603 case 7:
3604 tcnt = s->tx_dropped_dtls;
3605 break;
3606 case 8:
3607 tcnt = s->tx_dropped_nwireless;
3608 break;
3609 case 9:
3610 tcnt = s->tx_queue_full_drops;
3611 break;
3612 case 10:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003613 tcnt = s->tx_mem_failure_drops;
3614 break;
3615 default:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003616 return 0;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003617 }
3618
Saurabh Misra3f66e872015-04-03 11:30:42 -07003619 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003620}
3621
3622/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003623 * nss_stats_capwap_decap()
3624 * Make a row for CAPWAP decap stats.
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003625 */
3626static ssize_t nss_stats_capwap_decap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s)
3627{
Saurabh Misra3f66e872015-04-03 11:30:42 -07003628 char *header[] = { "packets", "bytes", "DTLS_pkts", "fragments", "rx_dropped", "drop_oversize",
3629 "drop_frag_timeout", "drop_frag_dup", "drop_frag_gap", "drop_qfull", "drop_memfail",
3630 "drop_csum", "drop_malformed", "unknown" };
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003631 uint64_t tcnt = 0;
3632
Aniruddha Paul1b170c22017-05-29 12:30:39 +05303633 switch (i) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003634 case 0:
3635 tcnt = s->pnode_stats.rx_packets;
3636 break;
3637 case 1:
3638 tcnt = s->pnode_stats.rx_bytes;
3639 break;
3640 case 2:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003641 tcnt = s->dtls_pkts;
3642 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003643 case 3:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003644 tcnt = s->rx_segments;
3645 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003646 case 4:
3647 tcnt = s->pnode_stats.rx_dropped;
3648 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003649 case 5:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003650 tcnt = s->rx_oversize_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003651 break;
3652 case 6:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003653 tcnt = s->rx_frag_timeout_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003654 break;
3655 case 7:
3656 tcnt = s->rx_dup_frag;
3657 break;
3658 case 8:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003659 tcnt = s->rx_frag_gap_drops;
3660 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003661 case 9:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003662 tcnt = s->rx_queue_full_drops;
3663 return (snprintf(line, len, "%s = %llu (n2h = %llu)\n", header[i], tcnt, s->rx_n2h_queue_full_drops));
3664 case 10:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003665 tcnt = s->rx_mem_failure_drops;
3666 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003667 case 11:
3668 tcnt = s->rx_csum_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003669 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003670 case 12:
3671 tcnt = s->rx_malformed;
3672 break;
3673 default:
3674 return 0;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003675 }
3676
Saurabh Misra3f66e872015-04-03 11:30:42 -07003677 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003678}
3679
3680/*
3681 * nss_stats_capwap_read()
3682 * Read CAPWAP stats
3683 */
3684static ssize_t nss_stats_capwap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos, uint16_t type)
3685{
3686 struct nss_stats_data *data = fp->private_data;
3687 ssize_t bytes_read = 0;
3688 struct nss_capwap_tunnel_stats stats;
3689 size_t bytes;
3690 char line[80];
Saurabh Misra3f66e872015-04-03 11:30:42 -07003691 int start;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003692 uint32_t if_num = NSS_DYNAMIC_IF_START;
3693 uint32_t max_if_num = NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES;
3694
3695 if (data) {
3696 if_num = data->if_num;
3697 }
3698
3699 /*
3700 * If we are done accomodating all the CAPWAP tunnels.
3701 */
3702 if (if_num > max_if_num) {
3703 return 0;
3704 }
3705
3706 for (; if_num <= max_if_num; if_num++) {
3707 bool isthere;
3708
3709 if (nss_is_dynamic_interface(if_num) == false) {
3710 continue;
3711 }
3712
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003713 if (nss_dynamic_interface_get_type(nss_capwap_get_ctx(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003714 continue;
3715 }
3716
3717 /*
3718 * If CAPWAP tunnel does not exists, then isthere will be false.
3719 */
3720 isthere = nss_capwap_get_stats(if_num, &stats);
3721 if (!isthere) {
3722 continue;
3723 }
3724
Saurabh Misra3f66e872015-04-03 11:30:42 -07003725 bytes = snprintf(line, sizeof(line), "----if_num : %2d----\n", if_num);
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003726 if ((bytes_read + bytes) > sz) {
3727 break;
3728 }
3729
3730 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3731 bytes_read = -EFAULT;
3732 goto fail;
3733 }
3734 bytes_read += bytes;
3735 start = 0;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003736 while (bytes_read < sz) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003737 if (type == 1) {
3738 bytes = nss_stats_capwap_encap(line, sizeof(line), start, &stats);
3739 } else {
3740 bytes = nss_stats_capwap_decap(line, sizeof(line), start, &stats);
3741 }
3742
Saurabh Misra3f66e872015-04-03 11:30:42 -07003743 /*
3744 * If we don't have any more lines in decap/encap.
3745 */
3746 if (bytes == 0) {
3747 break;
3748 }
3749
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003750 if ((bytes_read + bytes) > sz)
3751 break;
3752
3753 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3754 bytes_read = -EFAULT;
3755 goto fail;
3756 }
3757
3758 bytes_read += bytes;
3759 start++;
3760 }
3761 }
3762
3763 if (bytes_read > 0) {
3764 *ppos = bytes_read;
3765 }
3766
3767 if (data) {
3768 data->if_num = if_num;
3769 }
3770fail:
3771 return bytes_read;
3772}
3773
3774/*
3775 * nss_stats_capwap_decap_read()
3776 * Read CAPWAP decap stats
3777 */
3778static ssize_t nss_stats_capwap_decap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3779{
3780 return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 0));
3781}
3782
3783/*
3784 * nss_stats_capwap_encap_read()
3785 * Read CAPWAP encap stats
3786 */
3787static ssize_t nss_stats_capwap_encap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3788{
3789 return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 1));
3790}
3791
3792/*
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303793 * nss_stats_gre_redir()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003794 * Make a row for GRE_REDIR stats.
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303795 */
3796static ssize_t nss_stats_gre_redir(char *line, int len, int i, struct nss_gre_redir_tunnel_stats *s)
3797{
3798 char *header[] = { "TX Packets", "TX Bytes", "TX Drops", "RX Packets", "RX Bytes", "Rx Drops" };
3799 uint64_t tcnt = 0;
3800
3801 switch (i) {
3802 case 0:
3803 tcnt = s->node_stats.tx_packets;
3804 break;
3805 case 1:
3806 tcnt = s->node_stats.tx_bytes;
3807 break;
3808 case 2:
3809 tcnt = s->tx_dropped;
3810 break;
3811 case 3:
3812 tcnt = s->node_stats.rx_packets;
3813 break;
3814 case 4:
3815 tcnt = s->node_stats.rx_bytes;
3816 break;
3817 case 5:
3818 tcnt = s->node_stats.rx_dropped;
3819 break;
3820 default:
Radha krishna Simha Jigurudf53f022015-11-09 12:31:26 +05303821 return 0;
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303822 }
3823
3824 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
3825}
3826
3827/*
3828 * nss_stats_gre_redir_read()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003829 * READ gre_redir tunnel stats.
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303830 */
3831static ssize_t nss_stats_gre_redir_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3832{
3833 struct nss_stats_data *data = fp->private_data;
3834 ssize_t bytes_read = 0;
3835 struct nss_gre_redir_tunnel_stats stats;
3836 size_t bytes;
3837 char line[80];
3838 int start, end;
3839 int index = 0;
3840
3841 if (data) {
3842 index = data->index;
3843 }
3844
3845 /*
3846 * If we are done accomodating all the GRE_REDIR tunnels.
3847 */
3848 if (index >= NSS_GRE_REDIR_MAX_INTERFACES) {
3849 return 0;
3850 }
3851
3852 for (; index < NSS_GRE_REDIR_MAX_INTERFACES; index++) {
3853 bool isthere;
3854
3855 /*
3856 * If gre_redir tunnel does not exists, then isthere will be false.
3857 */
3858 isthere = nss_gre_redir_get_stats(index, &stats);
3859 if (!isthere) {
3860 continue;
3861 }
3862
3863 bytes = snprintf(line, sizeof(line), "\nTunnel if_num: %2d\n", stats.if_num);
3864 if ((bytes_read + bytes) > sz) {
3865 break;
3866 }
3867
3868 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3869 bytes_read = -EFAULT;
3870 goto fail;
3871 }
3872 bytes_read += bytes;
3873 start = 0;
3874 end = 6;
3875 while (bytes_read < sz && start < end) {
3876 bytes = nss_stats_gre_redir(line, sizeof(line), start, &stats);
3877
3878 if ((bytes_read + bytes) > sz)
3879 break;
3880
3881 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3882 bytes_read = -EFAULT;
3883 goto fail;
3884 }
3885
3886 bytes_read += bytes;
3887 start++;
3888 }
3889 }
3890
3891 if (bytes_read > 0) {
3892 *ppos = bytes_read;
3893 }
3894
3895 if (data) {
3896 data->index = index;
3897 }
3898
3899fail:
3900 return bytes_read;
3901}
3902
3903/*
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003904 * nss_stats_wifi_if_read()
3905 * Read wifi_if statistics
3906 */
3907static ssize_t nss_stats_wifi_if_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3908{
3909 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003910 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 -08003911 int32_t if_num = NSS_DYNAMIC_IF_START;
3912 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
3913 size_t bytes = 0;
3914 ssize_t bytes_read = 0;
3915 char line[80];
3916 int start, end;
3917
3918 if (data) {
3919 if_num = data->if_num;
3920 }
3921
3922 if (if_num > max_if_num) {
3923 return 0;
3924 }
3925
3926 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003927 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_WIFI)
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003928 continue;
3929
3930 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
3931 if ((bytes_read + bytes) > sz)
3932 break;
3933
3934 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3935 bytes_read = -EFAULT;
3936 goto end;
3937 }
3938
3939 bytes_read += bytes;
3940
3941 start = 0;
3942 end = 7;
3943 while (bytes_read < sz && start < end) {
3944 bytes = nss_wifi_if_copy_stats(if_num, start, line);
3945 if (!bytes)
3946 break;
3947
3948 if ((bytes_read + bytes) > sz)
3949 break;
3950
3951 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3952 bytes_read = -EFAULT;
3953 goto end;
3954 }
3955
3956 bytes_read += bytes;
3957 start++;
3958 }
3959
3960 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
3961 if (bytes_read > (sz - bytes))
3962 break;
3963
3964 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3965 bytes_read = -EFAULT;
3966 goto end;
3967 }
3968
3969 bytes_read += bytes;
3970 }
3971
3972 if (bytes_read > 0) {
3973 *ppos = bytes_read;
3974 }
3975
3976 if (data) {
3977 data->if_num = if_num;
3978 }
3979
3980end:
3981 return bytes_read;
3982}
3983
3984/*
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07003985 * nss_stats_virt_if_read()
3986 * Read virt_if statistics
3987 */
3988static ssize_t nss_stats_virt_if_read(struct file *fp, char __user *ubuf,
3989 size_t sz, loff_t *ppos)
3990{
3991 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003992 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 -07003993 int32_t if_num = NSS_DYNAMIC_IF_START;
3994 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
3995 size_t bytes = 0;
3996 ssize_t bytes_read = 0;
3997 char line[80];
3998 int start, end;
3999
4000 if (data) {
4001 if_num = data->if_num;
4002 }
4003
4004 if (if_num > max_if_num) {
4005 return 0;
4006 }
4007
4008 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004009 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR)
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004010 continue;
4011
4012 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
4013 if ((bytes_read + bytes) > sz)
4014 break;
4015
4016 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4017 bytes_read = -EFAULT;
4018 goto end;
4019 }
4020
4021 bytes_read += bytes;
4022
4023 start = 0;
4024 end = 7;
4025 while (bytes_read < sz && start < end) {
4026 bytes = nss_virt_if_copy_stats(if_num, start, line);
4027 if (!bytes)
4028 break;
4029
4030 if ((bytes_read + bytes) > sz)
4031 break;
4032
4033 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4034 bytes_read = -EFAULT;
4035 goto end;
4036 }
4037
4038 bytes_read += bytes;
4039 start++;
4040 }
4041
4042 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
4043 if (bytes_read > (sz - bytes))
4044 break;
4045
4046 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4047 bytes_read = -EFAULT;
4048 goto end;
4049 }
4050
4051 bytes_read += bytes;
4052 }
4053
4054 if (bytes_read > 0) {
4055 *ppos = bytes_read;
4056 }
4057
4058 if (data) {
4059 data->if_num = if_num;
4060 }
4061
4062end:
4063 return bytes_read;
4064}
4065
4066/*
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004067 * nss_stats_tx_rx_virt_if_read()
4068 * Read tx_rx_virt_if statistics
4069 */
4070static ssize_t nss_stats_tx_rx_virt_if_read(struct file *fp, char __user *ubuf,
4071 size_t sz, loff_t *ppos)
4072{
4073 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004074 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 -07004075 int32_t if_num = NSS_DYNAMIC_IF_START;
4076 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
4077 size_t bytes = 0;
4078 ssize_t bytes_read = 0;
4079 char line[80];
4080 int start, end;
4081
4082 if (data) {
4083 if_num = data->if_num;
4084 }
4085
4086 if (if_num > max_if_num) {
4087 return 0;
4088 }
4089
4090 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004091 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED)
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004092 continue;
4093
4094 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
4095 if ((bytes_read + bytes) > sz)
4096 break;
4097
4098 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4099 bytes_read = -EFAULT;
4100 goto end;
4101 }
4102
4103 bytes_read += bytes;
4104
4105 start = 0;
4106 end = 7;
4107 while (bytes_read < sz && start < end) {
4108 bytes = nss_tx_rx_virt_if_copy_stats(if_num, start, line);
4109 if (!bytes)
4110 break;
4111
4112 if ((bytes_read + bytes) > sz)
4113 break;
4114
4115 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4116 bytes_read = -EFAULT;
4117 goto end;
4118 }
4119
4120 bytes_read += bytes;
4121 start++;
4122 }
4123
4124 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
4125 if (bytes_read > (sz - bytes))
4126 break;
4127
4128 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4129 bytes_read = -EFAULT;
4130 goto end;
4131 }
4132
4133 bytes_read += bytes;
4134 }
4135
4136 if (bytes_read > 0) {
4137 *ppos = bytes_read;
4138 }
4139
4140 if (data) {
4141 data->if_num = if_num;
4142 }
4143
4144end:
4145 return bytes_read;
4146}
4147
4148/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07004149 * nss_stats_trustsec_tx_read()
4150 * Read trustsec_tx stats
4151 */
4152static ssize_t nss_stats_trustsec_tx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
4153{
4154 int32_t i;
4155
4156 /*
4157 * max output lines = #stats + start tag line + end tag line + three blank lines
4158 */
4159 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_TRUSTSEC_TX_MAX + 3) + 5;
4160 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
4161 size_t size_wr = 0;
4162 ssize_t bytes_read = 0;
4163 uint64_t *stats_shadow;
4164
4165 char *lbuf = kzalloc(size_al, GFP_KERNEL);
4166 if (unlikely(lbuf == NULL)) {
4167 nss_warning("Could not allocate memory for local statistics buffer");
4168 return 0;
4169 }
4170
4171 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
4172 if (unlikely(stats_shadow == NULL)) {
4173 nss_warning("Could not allocate memory for local shadow buffer");
4174 kfree(lbuf);
4175 return 0;
4176 }
4177
4178 size_wr = scnprintf(lbuf, size_al, "trustsec_tx stats start:\n\n");
4179
4180 /*
4181 * Common node stats
4182 */
4183 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
4184 spin_lock_bh(&nss_top_main.stats_lock);
4185 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
4186 stats_shadow[i] = nss_top_main.stats_node[NSS_TRUSTSEC_TX_INTERFACE][i];
4187 }
4188
4189 spin_unlock_bh(&nss_top_main.stats_lock);
4190
4191 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
4192 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4193 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
4194 }
4195
4196 /*
4197 * TrustSec TX node stats
4198 */
4199 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx node stats:\n\n");
4200
4201 spin_lock_bh(&nss_top_main.stats_lock);
4202 for (i = 0; (i < NSS_STATS_TRUSTSEC_TX_MAX); i++) {
4203 stats_shadow[i] = nss_top_main.stats_trustsec_tx[i];
4204 }
4205
4206 spin_unlock_bh(&nss_top_main.stats_lock);
4207
4208 for (i = 0; (i < NSS_STATS_TRUSTSEC_TX_MAX); i++) {
4209 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4210 "%s = %llu\n", nss_stats_str_trustsec_tx[i], stats_shadow[i]);
4211 }
4212
4213 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx stats end\n\n");
4214 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
4215 kfree(lbuf);
4216 kfree(stats_shadow);
4217
4218 return bytes_read;
4219}
4220
4221/*
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004222 * nss_stats_wt_read()
4223 * Reads and formats worker thread statistics and outputs them to ubuf
4224 */
4225static ssize_t nss_stats_wt_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
4226{
4227 struct nss_stats_data *data = fp->private_data;
4228 struct nss_ctx_instance *nss_ctx = data->nss_ctx;
4229 struct nss_project_irq_stats *shadow;
4230 uint32_t thread_count = nss_ctx->worker_thread_count;
4231 uint32_t irq_count = nss_ctx->irq_count;
4232
4233 /*
4234 * Three lines for each IRQ
4235 */
4236 uint32_t max_output_lines = thread_count * 3 * irq_count;
4237 size_t size_al = max_output_lines * NSS_STATS_MAX_STR_LENGTH;
4238 size_t size_wr = 0;
4239 ssize_t bytes_read = 0;
4240 char *lbuf;
4241 int i;
4242 int j;
4243
4244 lbuf = kzalloc(size_al, GFP_KERNEL);
4245 if (unlikely(!lbuf)) {
4246 nss_warning("Could not allocate memory for local statistics buffer\n");
4247 return 0;
4248 }
4249
4250 shadow = kzalloc(thread_count * irq_count * sizeof(struct nss_project_irq_stats), GFP_KERNEL);
4251 if (unlikely(!shadow)) {
4252 nss_warning("Could not allocate memory for stats shadow\n");
4253 kfree(lbuf);
4254 return 0;
4255 }
4256
4257 spin_lock_bh(&nss_top_main.stats_lock);
4258 if (unlikely(!nss_ctx->wt_stats)) {
4259 spin_unlock_bh(&nss_top_main.stats_lock);
4260 nss_warning("Worker thread statistics not allocated\n");
4261 kfree(lbuf);
4262 kfree(shadow);
4263 return 0;
4264 }
4265 for (i = 0; i < thread_count; ++i) {
4266
4267 /*
4268 * The statistics shadow is an array with thread_count * irq_count
4269 * items in it. Each item is located at the index:
4270 * (thread number) * (irq_count) + (irq number)
4271 * thus simulating a two-dimensional array.
4272 */
4273 for (j = 0; j < irq_count; ++j) {
4274 shadow[i * irq_count + j] = nss_ctx->wt_stats[i].irq_stats[j];
4275 }
4276 }
4277 spin_unlock_bh(&nss_top_main.stats_lock);
4278
4279 for (i = 0; i < thread_count; ++i) {
4280 for (j = 0; j < irq_count; ++j) {
4281 struct nss_project_irq_stats *is = &(shadow[i * irq_count + j]);
4282 if (!(is->count)) {
4283 continue;
4284 }
4285
4286 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4287 "t-%d:irq-%d callback: 0x%x, count: %llu\n",
4288 i, j, is->callback, is->count);
4289 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4290 "t-%d:irq-%d tick min: %10u avg: %10u max:%10u\n",
4291 i, j, is->ticks_min, is->ticks_avg, is->ticks_max);
4292 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4293 "t-%d:irq-%d insn min: %10u avg: %10u max:%10u\n\n",
4294 i, j, is->insn_min, is->insn_avg, is->insn_max);
4295 }
4296 }
4297 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
4298 kfree(lbuf);
4299 kfree(shadow);
4300
4301 return bytes_read;
4302}
4303
4304/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004305 * nss_stats_open()
4306 */
4307static int nss_stats_open(struct inode *inode, struct file *filp)
4308{
4309 struct nss_stats_data *data = NULL;
4310
4311 data = kzalloc(sizeof(struct nss_stats_data), GFP_KERNEL);
4312 if (!data) {
4313 return -ENOMEM;
4314 }
4315 memset(data, 0, sizeof (struct nss_stats_data));
4316 data->if_num = NSS_DYNAMIC_IF_START;
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304317 data->index = 0;
Stephen Wangaed46332016-12-12 17:29:03 -08004318 data->edma_id = (nss_ptr_t)inode->i_private;
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004319 data->nss_ctx = (struct nss_ctx_instance *)(inode->i_private);
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004320 filp->private_data = data;
4321
4322 return 0;
4323}
4324
4325/*
4326 * nss_stats_release()
4327 */
4328static int nss_stats_release(struct inode *inode, struct file *filp)
4329{
4330 struct nss_stats_data *data = filp->private_data;
4331
4332 if (data) {
4333 kfree(data);
4334 }
4335
4336 return 0;
4337}
4338
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304339#define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \
4340static const struct file_operations nss_stats_##name##_ops = { \
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004341 .open = nss_stats_open, \
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304342 .read = nss_stats_##name##_read, \
4343 .llseek = generic_file_llseek, \
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004344 .release = nss_stats_release, \
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304345};
4346
4347/*
4348 * nss_ipv4_stats_ops
4349 */
4350NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4)
4351
4352/*
Selin Dag6d9b0c12014-11-04 18:27:21 -08004353 * ipv4_reasm_stats_ops
4354 */
4355NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4_reasm)
4356
4357/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304358 * ipv6_stats_ops
4359 */
4360NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6)
4361
4362/*
Selin Dag60a2f5b2015-06-29 14:39:49 -07004363 * ipv6_reasm_stats_ops
4364 */
4365NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6_reasm)
4366
4367/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304368 * n2h_stats_ops
4369 */
4370NSS_STATS_DECLARE_FILE_OPERATIONS(n2h)
Thomas Wuc3e382c2014-10-29 15:35:13 -07004371
4372/*
4373 * lso_rx_stats_ops
4374 */
4375NSS_STATS_DECLARE_FILE_OPERATIONS(lso_rx)
4376
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304377/*
4378 * drv_stats_ops
4379 */
4380NSS_STATS_DECLARE_FILE_OPERATIONS(drv)
4381
4382/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304383 * pppoe_stats_ops
4384 */
4385NSS_STATS_DECLARE_FILE_OPERATIONS(pppoe)
4386
4387/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +05304388 * l2tpv2_stats_ops
4389 */
4390NSS_STATS_DECLARE_FILE_OPERATIONS(l2tpv2)
4391
4392/*
ratheesh kannotha1245c32015-11-04 16:45:43 +05304393 * map_t_stats_ops
4394 */
4395NSS_STATS_DECLARE_FILE_OPERATIONS(map_t)
4396
4397/*
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05304398 * gre_stats_ops
4399 */
4400NSS_STATS_DECLARE_FILE_OPERATIONS(gre)
4401
4402/*
Amit Gupta316729b2016-08-12 12:21:15 +05304403 * ppe_stats_ops
4404 */
4405NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_conn)
4406NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_l3)
4407NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_code)
Amit Gupta79c1c202017-06-30 15:28:13 +05304408NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_port_dc)
4409NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_exception_cc)
4410NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_nonexception_cc)
Amit Gupta316729b2016-08-12 12:21:15 +05304411
4412/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05304413 * pptp_stats_ops
4414 */
4415NSS_STATS_DECLARE_FILE_OPERATIONS(pptp)
4416
4417/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304418 * gmac_stats_ops
4419 */
4420NSS_STATS_DECLARE_FILE_OPERATIONS(gmac)
4421
4422/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004423 * capwap_stats_ops
4424 */
4425NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_encap)
4426NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_decap)
4427
4428/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304429 * eth_rx_stats_ops
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304430 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304431NSS_STATS_DECLARE_FILE_OPERATIONS(eth_rx)
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304432
4433/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004434 * edma_port_stats_ops
4435 */
4436NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_stats)
4437
4438/*
4439 * edma_port_type_ops
4440 */
4441NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_type)
4442
4443/*
4444 * edma_port_ring_map_ops
4445 */
4446NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_ring_map)
4447
4448/*
4449 * edma_txring_stats_ops
4450 */
4451NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txring)
4452
4453/*
4454 * edma_rxring_stats_ops
4455 */
4456NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxring)
4457
4458/*
4459 * edma_txcmplring_stats_ops
4460 */
4461NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txcmplring)
4462
4463/*
4464 * edma_rxfillring_stats_ops
4465 */
4466NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxfillring)
4467
4468/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004469 * edma_err_stats_ops
4470 */
4471NSS_STATS_DECLARE_FILE_OPERATIONS(edma_err_stats)
4472
4473/*
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304474 * gre_redir_ops
4475 */
4476NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir)
4477
4478/*
Ankit Dhanuka14999992014-11-12 15:35:11 +05304479 * sjack_stats_ops
4480 */
4481NSS_STATS_DECLARE_FILE_OPERATIONS(sjack)
4482
Stephen Wang9779d952015-10-28 11:39:07 -07004483/*
4484 * portid_ops
4485 */
4486NSS_STATS_DECLARE_FILE_OPERATIONS(portid)
4487
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08004488NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_if)
4489
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004490NSS_STATS_DECLARE_FILE_OPERATIONS(virt_if)
4491
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004492NSS_STATS_DECLARE_FILE_OPERATIONS(tx_rx_virt_if)
4493
Ankit Dhanuka14999992014-11-12 15:35:11 +05304494/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304495 * wifi_stats_ops
4496 */
4497NSS_STATS_DECLARE_FILE_OPERATIONS(wifi)
4498
4499/*
Tushar Mathurff8741b2015-12-02 20:28:59 +05304500 * dtls_stats_ops
4501 */
4502NSS_STATS_DECLARE_FILE_OPERATIONS(dtls)
4503
4504/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07004505 * gre_tunnel_stats_ops
4506 */
4507NSS_STATS_DECLARE_FILE_OPERATIONS(gre_tunnel)
4508
4509/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07004510 * trustsec_tx_stats_ops
4511 */
4512NSS_STATS_DECLARE_FILE_OPERATIONS(trustsec_tx)
4513
4514/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +05304515 * wifili_stats_ops
4516 */
4517NSS_STATS_DECLARE_FILE_OPERATIONS(wifili)
4518
4519/*
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004520 * wt_stats_ops
4521 */
4522NSS_STATS_DECLARE_FILE_OPERATIONS(wt)
4523/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304524 * nss_stats_init()
4525 * Enable NSS statistics
4526 */
4527void nss_stats_init(void)
4528{
Shashank Balashankar512cb602016-08-01 17:57:42 -07004529 int i = 0;
4530 struct dentry *edma_d = NULL;
4531 struct dentry *edma_port_dir_d = NULL;
4532 struct dentry *edma_port_d = NULL;
4533 struct dentry *edma_port_type_d = NULL;
4534 struct dentry *edma_port_stats_d = NULL;
4535 struct dentry *edma_port_ring_map_d = NULL;
Shashank Balashankar512cb602016-08-01 17:57:42 -07004536 struct dentry *edma_rings_dir_d = NULL;
4537 struct dentry *edma_tx_dir_d = NULL;
4538 struct dentry *edma_tx_d = NULL;
4539 struct dentry *edma_rx_dir_d = NULL;
4540 struct dentry *edma_rx_d = NULL;
4541 struct dentry *edma_txcmpl_dir_d = NULL;
4542 struct dentry *edma_txcmpl_d = NULL;
4543 struct dentry *edma_rxfill_dir_d = NULL;
4544 struct dentry *edma_rxfill_d = NULL;
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004545 struct dentry *edma_err_stats_d = NULL;
Shashank Balashankar512cb602016-08-01 17:57:42 -07004546
Amit Gupta79c1c202017-06-30 15:28:13 +05304547 struct dentry *ppe_code_d = NULL;
4548 struct dentry *ppe_drop_d = NULL;
4549 struct dentry *ppe_port_dc_d = NULL;
4550 struct dentry *ppe_cpu_d = NULL;
4551 struct dentry *ppe_exception_d = NULL;
4552 struct dentry *ppe_nonexception_d = NULL;
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004553 struct dentry *core_dentry = NULL;
4554 struct dentry *wt_dentry = NULL;
4555
Amit Gupta79c1c202017-06-30 15:28:13 +05304556
Shashank Balashankar512cb602016-08-01 17:57:42 -07004557 char file_name[10];
4558
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304559 /*
4560 * NSS driver entry
4561 */
4562 nss_top_main.top_dentry = debugfs_create_dir("qca-nss-drv", NULL);
4563 if (unlikely(nss_top_main.top_dentry == NULL)) {
4564 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4565
4566 /*
4567 * Non availability of debugfs directory is not a catastrophy
4568 * We can still go ahead with other initialization
4569 */
4570 return;
4571 }
4572
4573 nss_top_main.stats_dentry = debugfs_create_dir("stats", nss_top_main.top_dentry);
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304574 if (unlikely(nss_top_main.stats_dentry == NULL)) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304575 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4576
4577 /*
4578 * Non availability of debugfs directory is not a catastrophy
4579 * We can still go ahead with rest of initialization
4580 */
4581 return;
4582 }
4583
4584 /*
4585 * Create files to obtain statistics
4586 */
4587
4588 /*
4589 * ipv4_stats
4590 */
4591 nss_top_main.ipv4_dentry = debugfs_create_file("ipv4", 0400,
4592 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_ops);
4593 if (unlikely(nss_top_main.ipv4_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304594 nss_warning("Failed to create qca-nss-drv/stats/ipv4 file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304595 return;
4596 }
4597
4598 /*
Selin Dag6d9b0c12014-11-04 18:27:21 -08004599 * ipv4_reasm_stats
4600 */
4601 nss_top_main.ipv4_reasm_dentry = debugfs_create_file("ipv4_reasm", 0400,
4602 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_reasm_ops);
4603 if (unlikely(nss_top_main.ipv4_reasm_dentry == NULL)) {
4604 nss_warning("Failed to create qca-nss-drv/stats/ipv4_reasm file in debugfs");
4605 return;
4606 }
4607
4608 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304609 * ipv6_stats
4610 */
4611 nss_top_main.ipv6_dentry = debugfs_create_file("ipv6", 0400,
4612 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_ops);
4613 if (unlikely(nss_top_main.ipv6_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304614 nss_warning("Failed to create qca-nss-drv/stats/ipv6 file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304615 return;
4616 }
4617
4618 /*
Selin Dag60a2f5b2015-06-29 14:39:49 -07004619 * ipv6_reasm_stats
4620 */
4621 nss_top_main.ipv6_reasm_dentry = debugfs_create_file("ipv6_reasm", 0400,
4622 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_reasm_ops);
4623 if (unlikely(nss_top_main.ipv6_reasm_dentry == NULL)) {
4624 nss_warning("Failed to create qca-nss-drv/stats/ipv6_reasm file in debugfs");
4625 return;
4626 }
4627
4628 /*
4629 * eth_rx__stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304630 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304631 nss_top_main.eth_rx_dentry = debugfs_create_file("eth_rx", 0400,
4632 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_eth_rx_ops);
4633 if (unlikely(nss_top_main.eth_rx_dentry == NULL)) {
4634 nss_warning("Failed to create qca-nss-drv/stats/eth_rx file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304635 return;
4636 }
4637
4638 /*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004639 * edma stats
4640 */
4641 edma_d = debugfs_create_dir("edma", nss_top_main.stats_dentry);
4642 if (unlikely(edma_d == NULL)) {
4643 nss_warning("Failed to create qca-nss-drv/stats/edma directory in debugfs");
4644 return;
4645 }
4646
4647 /*
4648 * edma port stats
4649 */
4650 edma_port_dir_d = debugfs_create_dir("ports", edma_d);
4651 if (unlikely(edma_port_dir_d == NULL)) {
4652 nss_warning("Failed to create qca-nss-drv/stats/edma/ports directory in debugfs");
4653 return;
4654 }
4655
4656 for (i = 0; i < NSS_EDMA_NUM_PORTS_MAX; i++) {
4657 memset(file_name, 0, sizeof(file_name));
4658 snprintf(file_name, sizeof(file_name), "%d", i);
4659 edma_port_d = NULL;
4660 edma_port_stats_d = NULL;
4661 edma_port_type_d = NULL;
4662 edma_port_ring_map_d = NULL;
4663
4664 edma_port_d = debugfs_create_dir(file_name, edma_port_dir_d);
4665 if (unlikely(edma_port_d == NULL)) {
4666 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d dir in debugfs", i);
4667 return;
4668 }
4669
Stephen Wangaed46332016-12-12 17:29:03 -08004670 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 -07004671 if (unlikely(edma_port_stats_d == NULL)) {
4672 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/stats file in debugfs", i);
4673 return;
4674 }
4675
Stephen Wangaed46332016-12-12 17:29:03 -08004676 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 -07004677 if (unlikely(edma_port_type_d == NULL)) {
4678 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/type file in debugfs", i);
4679 return;
4680 }
4681
Stephen Wangaed46332016-12-12 17:29:03 -08004682 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 -07004683 if (unlikely(edma_port_ring_map_d == NULL)) {
4684 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/ring_map file in debugfs", i);
4685 return;
4686 }
4687 }
4688
4689 /*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004690 * edma error stats
4691 */
4692 edma_err_stats_d = NULL;
4693 edma_err_stats_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_stats_edma_err_stats_ops);
4694 if (unlikely(edma_port_stats_d == NULL)) {
4695 nss_warning("Failed to create qca-nss-drv/stats/edma/%d/err_stats file in debugfs", 0);
4696 return;
4697 }
4698
4699 /*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004700 * edma ring stats
4701 */
4702 edma_rings_dir_d = debugfs_create_dir("rings", edma_d);
4703 if (unlikely(edma_rings_dir_d == NULL)) {
4704 nss_warning("Failed to create qca-nss-drv/stats/edma/rings directory in debugfs");
4705 return;
4706 }
4707
4708 /*
4709 * edma tx ring stats
4710 */
4711 edma_tx_dir_d = debugfs_create_dir("tx", edma_rings_dir_d);
4712 if (unlikely(edma_tx_dir_d == NULL)) {
4713 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx directory in debugfs");
4714 return;
4715 }
4716
4717 for (i = 0; i < NSS_EDMA_NUM_TX_RING_MAX; i++) {
4718 memset(file_name, 0, sizeof(file_name));
4719 scnprintf(file_name, sizeof(file_name), "%d", i);
4720 edma_tx_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004721 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 -07004722 if (unlikely(edma_tx_d == NULL)) {
4723 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx/%d file in debugfs", i);
4724 return;
4725 }
4726 }
4727
4728 /*
4729 * edma rx ring stats
4730 */
4731 edma_rx_dir_d = debugfs_create_dir("rx", edma_rings_dir_d);
4732 if (unlikely(edma_rx_dir_d == NULL)) {
4733 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx directory in debugfs");
4734 return;
4735 }
4736
4737 for (i = 0; i < NSS_EDMA_NUM_RX_RING_MAX; i++) {
4738 memset(file_name, 0, sizeof(file_name));
4739 scnprintf(file_name, sizeof(file_name), "%d", i);
4740 edma_rx_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004741 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 -07004742 if (unlikely(edma_rx_d == NULL)) {
4743 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx/%d file in debugfs", i);
4744 return;
4745 }
4746 }
4747
4748 /*
4749 * edma tx cmpl ring stats
4750 */
4751 edma_txcmpl_dir_d = debugfs_create_dir("txcmpl", edma_rings_dir_d);
4752 if (unlikely(edma_txcmpl_dir_d == NULL)) {
4753 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl directory in debugfs");
4754 return;
4755 }
4756
4757 for (i = 0; i < NSS_EDMA_NUM_TXCMPL_RING_MAX; i++) {
4758 memset(file_name, 0, sizeof(file_name));
4759 scnprintf(file_name, sizeof(file_name), "%d", i);
4760 edma_txcmpl_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004761 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 -07004762 if (unlikely(edma_txcmpl_d == NULL)) {
4763 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl/%d file in debugfs", i);
4764 return;
4765 }
4766 }
4767
4768 /*
4769 * edma rx fill ring stats
4770 */
4771 edma_rxfill_dir_d = debugfs_create_dir("rxfill", edma_rings_dir_d);
4772 if (unlikely(edma_rxfill_dir_d == NULL)) {
4773 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill directory in debugfs");
4774 return;
4775 }
4776
4777 for (i = 0; i < NSS_EDMA_NUM_RXFILL_RING_MAX; i++) {
4778 memset(file_name, 0, sizeof(file_name));
4779 scnprintf(file_name, sizeof(file_name), "%d", i);
4780 edma_rxfill_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004781 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 -07004782 if (unlikely(edma_rxfill_d == NULL)) {
4783 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill/%d file in debugfs", i);
4784 return;
4785 }
4786 }
4787
4788 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304789 * n2h_stats
4790 */
4791 nss_top_main.n2h_dentry = debugfs_create_file("n2h", 0400,
4792 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_n2h_ops);
4793 if (unlikely(nss_top_main.n2h_dentry == NULL)) {
4794 nss_warning("Failed to create qca-nss-drv/stats/n2h directory in debugfs");
4795 return;
4796 }
4797
4798 /*
Thomas Wuc3e382c2014-10-29 15:35:13 -07004799 * lso_rx_stats
4800 */
4801 nss_top_main.lso_rx_dentry = debugfs_create_file("lso_rx", 0400,
4802 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_lso_rx_ops);
4803 if (unlikely(nss_top_main.lso_rx_dentry == NULL)) {
4804 nss_warning("Failed to create qca-nss-drv/stats/lso_rx file in debugfs");
4805 return;
4806 }
4807
4808 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304809 * drv_stats
4810 */
4811 nss_top_main.drv_dentry = debugfs_create_file("drv", 0400,
4812 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_drv_ops);
4813 if (unlikely(nss_top_main.drv_dentry == NULL)) {
4814 nss_warning("Failed to create qca-nss-drv/stats/drv directory in debugfs");
4815 return;
4816 }
4817
4818 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304819 * pppoe_stats
4820 */
4821 nss_top_main.pppoe_dentry = debugfs_create_file("pppoe", 0400,
4822 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pppoe_ops);
4823 if (unlikely(nss_top_main.pppoe_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304824 nss_warning("Failed to create qca-nss-drv/stats/pppoe file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304825 return;
4826 }
4827
4828 /*
4829 * gmac_stats
4830 */
4831 nss_top_main.gmac_dentry = debugfs_create_file("gmac", 0400,
4832 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gmac_ops);
4833 if (unlikely(nss_top_main.gmac_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304834 nss_warning("Failed to create qca-nss-drv/stats/gmac file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304835 return;
4836 }
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004837
4838 /*
4839 * CAPWAP stats.
4840 */
4841 nss_top_main.capwap_encap_dentry = debugfs_create_file("capwap_encap", 0400,
4842 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_encap_ops);
4843 if (unlikely(nss_top_main.capwap_encap_dentry == NULL)) {
4844 nss_warning("Failed to create qca-nss-drv/stats/capwap_encap file in debugfs");
4845 return;
4846 }
4847
4848 nss_top_main.capwap_decap_dentry = debugfs_create_file("capwap_decap", 0400,
4849 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_decap_ops);
4850 if (unlikely(nss_top_main.capwap_decap_dentry == NULL)) {
4851 nss_warning("Failed to create qca-nss-drv/stats/capwap_decap file in debugfs");
4852 return;
4853 }
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304854
4855 /*
4856 * GRE_REDIR stats
4857 */
4858 nss_top_main.gre_redir_dentry = debugfs_create_file("gre_redir", 0400,
Ankit Dhanuka14999992014-11-12 15:35:11 +05304859 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gre_redir_ops);
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304860 if (unlikely(nss_top_main.gre_redir_dentry == NULL)) {
4861 nss_warning("Failed to create qca-nss-drv/stats/gre_redir file in debugfs");
4862 return;
4863 }
Ankit Dhanuka14999992014-11-12 15:35:11 +05304864
4865 /*
4866 * SJACK stats
4867 */
4868 nss_top_main.sjack_dentry = debugfs_create_file("sjack", 0400,
4869 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_sjack_ops);
4870 if (unlikely(nss_top_main.sjack_dentry == NULL)) {
4871 nss_warning("Failed to create qca-nss-drv/stats/sjack file in debugfs");
4872 return;
4873 }
Saurabh Misra96998db2014-07-10 12:15:48 -07004874
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304875 /*
Stephen Wang9779d952015-10-28 11:39:07 -07004876 * PORTID stats
4877 */
4878 nss_top_main.portid_dentry = debugfs_create_file("portid", 0400,
4879 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_portid_ops);
4880 if (unlikely(nss_top_main.portid_dentry == NULL)) {
4881 nss_warning("Failed to create qca-nss-drv/stats/portid file in debugfs");
4882 return;
4883 }
4884
4885 /*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304886 * WIFI stats
4887 */
4888 nss_top_main.wifi_dentry = debugfs_create_file("wifi", 0400,
4889 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_ops);
4890 if (unlikely(nss_top_main.wifi_dentry == NULL)) {
4891 nss_warning("Failed to create qca-nss-drv/stats/wifi file in debugfs");
4892 return;
4893 }
4894
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08004895 /*
4896 * wifi_if stats
4897 */
4898 nss_top_main.wifi_if_dentry = debugfs_create_file("wifi_if", 0400,
4899 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_if_ops);
4900 if (unlikely(nss_top_main.wifi_if_dentry == NULL)) {
4901 nss_warning("Failed to create qca-nss-drv/stats/wifi_if file in debugfs");
4902 return;
4903 }
4904
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004905 nss_top_main.virt_if_dentry = debugfs_create_file("virt_if", 0400,
4906 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_virt_if_ops);
4907 if (unlikely(nss_top_main.virt_if_dentry == NULL)) {
4908 nss_warning("Failed to create qca-nss-drv/stats/virt_if file in debugfs");
4909 return;
4910 }
4911
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004912 nss_top_main.tx_rx_virt_if_dentry = debugfs_create_file("tx_rx_virt_if", 0400,
4913 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_tx_rx_virt_if_ops);
4914 if (unlikely(nss_top_main.virt_if_dentry == NULL)) {
4915 nss_warning("Failed to create qca-nss-drv/stats/tx_rx_virt_if file in debugfs");
4916 return;
4917 }
4918
ratheesh kannoth7af985d2015-06-24 15:08:40 +05304919 /*
4920 * L2TPV2 Stats
4921 */
4922 nss_top_main.l2tpv2_dentry = debugfs_create_file("l2tpv2", 0400,
4923 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_l2tpv2_ops);
4924 if (unlikely(nss_top_main.l2tpv2_dentry == NULL)) {
4925 nss_warning("Failed to create qca-nss-drv/stats/l2tpv2 file in debugfs");
4926 return;
4927 }
Shyam Sunder66e889d2015-11-02 15:31:20 +05304928
4929 /*
ratheesh kannotha1245c32015-11-04 16:45:43 +05304930 * Map-t Stats
4931 */
4932 nss_top_main.map_t_dentry = debugfs_create_file("map_t", 0400,
4933 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_map_t_ops);
4934 if (unlikely(nss_top_main.map_t_dentry == NULL)) {
4935 nss_warning("Failed to create qca-nss-drv/stats/map_t file in debugfs");
4936 return;
4937 }
4938
4939 /*
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05304940 * GRE statistics
4941 */
4942 nss_top_main.gre_dentry = debugfs_create_file("gre", 0400,
4943 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gre_ops);
4944 if (unlikely(nss_top_main.gre_dentry == NULL)) {
4945 nss_warning("Failed to create qca-nss-drv/stats/gre file in debugfs");
4946 return;
4947 }
4948
4949 /*
Amit Gupta316729b2016-08-12 12:21:15 +05304950 * PPE Stats
4951 */
4952 nss_top_main.ppe_dentry = debugfs_create_dir("ppe", nss_top_main.stats_dentry);
4953 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4954 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4955 return;
4956 }
4957
4958 nss_top_main.ppe_conn_dentry = debugfs_create_file("connection", 0400,
4959 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_conn_ops);
4960 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4961 nss_warning("Failed to create qca-nss-drv/stats/ppe/connection file in debugfs");
4962 }
4963
4964 nss_top_main.ppe_l3_dentry = debugfs_create_file("l3", 0400,
4965 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_l3_ops);
4966 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4967 nss_warning("Failed to create qca-nss-drv/stats/ppe/l3 file in debugfs");
4968 }
4969
4970 nss_top_main.ppe_l3_dentry = debugfs_create_file("ppe_code", 0400,
4971 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_code_ops);
4972 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4973 nss_warning("Failed to create qca-nss-drv/stats/ppe/ppe_code file in debugfs");
4974 }
4975
4976 /*
Amit Gupta79c1c202017-06-30 15:28:13 +05304977 * ppe exception and drop code stats
4978 */
4979 ppe_code_d = debugfs_create_dir("code", nss_top_main.ppe_dentry);
4980 if (unlikely(ppe_code_d == NULL)) {
4981 nss_warning("Failed to create qca-nss-drv/stats/ppe/code directory in debugfs");
4982 return;
4983 }
4984
4985 ppe_cpu_d = debugfs_create_dir("cpu", ppe_code_d);
4986 if (unlikely(ppe_cpu_d == NULL)) {
4987 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/cpu directory in debugfs");
4988 return;
4989 }
4990
4991 ppe_exception_d = debugfs_create_file("exception", 0400, ppe_cpu_d,
4992 &nss_top_main, &nss_stats_ppe_exception_cc_ops);
4993 if (unlikely(ppe_exception_d == NULL)) {
4994 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/exception file in debugfs");
4995 return;
4996 }
4997
4998 ppe_nonexception_d = debugfs_create_file("non-exception", 0400, ppe_cpu_d,
4999 &nss_top_main, &nss_stats_ppe_nonexception_cc_ops);
5000 if (unlikely(ppe_nonexception_d == NULL)) {
5001 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/non-exception file in debugfs");
5002 return;
5003 }
5004
5005 ppe_drop_d = debugfs_create_dir("drop", ppe_code_d);
5006 if (unlikely(ppe_drop_d == NULL)) {
5007 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop directory in debugfs");
5008 return;
5009 }
5010
5011 for (i = 0; i < NSS_PPE_NUM_PHY_PORTS_MAX; i++) {
5012 if (i > 0) {
5013 memset(file_name, 0, sizeof(file_name));
5014 snprintf(file_name, sizeof(file_name), "%d", i);
5015 }
5016
5017 ppe_port_dc_d = NULL;
5018 ppe_port_dc_d = debugfs_create_file((i == 0) ? "cpu" : file_name, 0400, ppe_drop_d,
5019 (void *)(nss_ptr_t)i, &nss_stats_ppe_port_dc_ops);
5020 if (unlikely(ppe_port_dc_d == NULL)) {
5021 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop/%d file in debugfs", i);
5022 return;
5023 }
5024 }
5025
5026 /*
Shyam Sunder66e889d2015-11-02 15:31:20 +05305027 * PPTP Stats
5028 */
5029 nss_top_main.pptp_dentry = debugfs_create_file("pptp", 0400,
5030 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pptp_ops);
5031 if (unlikely(nss_top_main.pptp_dentry == NULL)) {
5032 nss_warning("Failed to create qca-nss-drv/stats/pptp file in debugfs");
Tushar Mathurff8741b2015-12-02 20:28:59 +05305033 }
5034
5035 /*
5036 * DTLS Stats
5037 */
5038 nss_top_main.dtls_dentry = debugfs_create_file("dtls", 0400,
5039 nss_top_main.stats_dentry,
5040 &nss_top_main,
5041 &nss_stats_dtls_ops);
5042 if (unlikely(nss_top_main.dtls_dentry == NULL)) {
5043 nss_warning("Failed to create qca-nss-drv/stats/dtls file in debugfs");
Shyam Sunder66e889d2015-11-02 15:31:20 +05305044 return;
5045 }
5046
Thomas Wu71c5ecc2016-06-21 11:15:52 -07005047 /*
5048 * GRE Tunnel Stats
5049 */
5050 nss_top_main.gre_tunnel_dentry = debugfs_create_file("gre_tunnel", 0400,
5051 nss_top_main.stats_dentry,
5052 &nss_top_main,
5053 &nss_stats_gre_tunnel_ops);
5054 if (unlikely(nss_top_main.gre_tunnel_dentry == NULL)) {
5055 nss_warning("Failed to create qca-nss-drv/stats/gre_tunnel file in debugfs");
5056 return;
5057 }
5058
Stephen Wangec5a85c2016-09-08 23:32:27 -07005059 /*
5060 * TrustSec TX Stats
5061 */
5062 nss_top_main.trustsec_tx_dentry = debugfs_create_file("trustsec_tx", 0400,
5063 nss_top_main.stats_dentry,
5064 &nss_top_main,
5065 &nss_stats_trustsec_tx_ops);
5066 if (unlikely(nss_top_main.trustsec_tx_dentry == NULL)) {
5067 nss_warning("Failed to create qca-nss-drv/stats/trustsec_tx file in debugfs");
5068 return;
5069 }
5070
Aniruddha Paul1b170c22017-05-29 12:30:39 +05305071 /*
5072 * WIFILI stats
5073 */
5074 nss_top_main.wifili_dentry = debugfs_create_file("wifili", 0400,
5075 nss_top_main.stats_dentry,
5076 &nss_top_main, &nss_stats_wifili_ops);
5077 if (unlikely(nss_top_main.wifili_dentry == NULL)) {
5078 nss_warning("Failed to create qca-nss-drv/stats/wifili file in debugfs");
5079 return;
5080 }
5081
Jackson Bockusc2a4e682017-06-23 11:59:29 -07005082 /*
5083 * Per-project stats
5084 */
5085 nss_top_main.project_dentry = debugfs_create_dir("project",
5086 nss_top_main.stats_dentry);
5087 if (unlikely(nss_top_main.project_dentry == NULL)) {
5088 nss_warning("Failed to create qca-nss-drv/stats/project directory in debugfs");
5089 return;
5090 }
5091
5092 for (i = 0; i < NSS_MAX_CORES; ++i) {
5093 memset(file_name, 0, sizeof(file_name));
5094 scnprintf(file_name, sizeof(file_name), "core%d", i);
5095 core_dentry = debugfs_create_dir(file_name,
5096 nss_top_main.project_dentry);
5097 if (unlikely(core_dentry == NULL)) {
5098 nss_warning("Failed to create qca-nss-drv/stats/project/core%d directory in debugfs", i);
5099 return;
5100 }
5101
5102 wt_dentry = debugfs_create_file("worker_threads",
5103 0400,
5104 core_dentry,
5105 &(nss_top_main.nss[i]),
5106 &nss_stats_wt_ops);
5107 if (unlikely(wt_dentry == NULL)) {
5108 nss_warning("Failed to create qca-nss-drv/stats/project/core%d/worker_threads file in debugfs", i);
5109 return;
5110 }
5111 }
5112
Saurabh Misra96998db2014-07-10 12:15:48 -07005113 nss_log_init();
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305114}
5115
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305116/*
5117 * nss_stats_clean()
5118 * Cleanup NSS statistics files
5119 */
5120void nss_stats_clean(void)
5121{
5122 /*
5123 * Remove debugfs tree
5124 */
5125 if (likely(nss_top_main.top_dentry != NULL)) {
5126 debugfs_remove_recursive(nss_top_main.top_dentry);
Stephen Wangdc8b5322015-06-27 20:11:50 -07005127 nss_top_main.top_dentry = NULL;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305128 }
5129}