blob: 9a2d2a8937f029059bd873e5d5e68f86df3310ae [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",
Jackson Bockus67fc0a82017-08-09 10:30:56 -070076 "dropped_by_rule",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +053077 "mc_create_requests",
78 "mc_update_requests",
79 "mc_create_invalid_interface",
80 "mc_destroy_requests",
81 "mc_destroy_misses",
82 "mc_flushes",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053083};
84
85/*
Selin Dag6d9b0c12014-11-04 18:27:21 -080086 * nss_stats_str_ipv4_reasm
87 * IPv4 reassembly stats strings
88 */
89static int8_t *nss_stats_str_ipv4_reasm[NSS_STATS_IPV4_REASM_MAX] = {
90 "evictions",
91 "alloc_fails",
92 "timeouts",
93};
94
95/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +053096 * nss_stats_str_ipv6
97 * IPv6 stats strings
98 */
99static int8_t *nss_stats_str_ipv6[NSS_STATS_IPV6_MAX] = {
100 "rx_pkts",
101 "rx_bytes",
102 "tx_pkts",
103 "tx_bytes",
104 "create_requests",
105 "create_collisions",
106 "create_invalid_interface",
107 "destroy_requests",
108 "destroy_misses",
109 "hash_hits",
110 "hash_reorders",
111 "flushes",
112 "evictions",
Selin Dag5d68caa2015-05-12 13:23:33 -0700113 "fragmentations",
114 "frag_fails",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530115 "mc_create_requests",
116 "mc_update_requests",
117 "mc_create_invalid_interface",
118 "mc_destroy_requests",
119 "mc_destroy_misses",
120 "mc_flushes",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530121};
122
123/*
Selin Dag60a2f5b2015-06-29 14:39:49 -0700124 * nss_stats_str_ipv6_reasm
125 * IPv6 reassembly stats strings
126 */
127static int8_t *nss_stats_str_ipv6_reasm[NSS_STATS_IPV6_REASM_MAX] = {
128 "alloc_fails",
129 "timeouts",
130 "discards",
131};
132
133/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530134 * nss_stats_str_n2h
135 * N2H stats strings
136 */
137static int8_t *nss_stats_str_n2h[NSS_STATS_N2H_MAX] = {
138 "queue_dropped",
139 "ticks",
140 "worst_ticks",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700141 "iterations",
Thomas Wu3fd8dd72014-06-11 15:57:05 -0700142 "pbuf_ocm_alloc_fails",
143 "pbuf_ocm_free_count",
144 "pbuf_ocm_total_count",
145 "pbuf_default_alloc_fails",
146 "pbuf_default_free_count",
147 "pbuf_default_total_count",
Sakthi Vignesh Radhakrishnan2a8ee962014-11-22 13:35:38 -0800148 "payload_fails",
Thomas Wu53679842015-01-22 13:37:35 -0800149 "payload_free_count",
Sakthi Vignesh Radhakrishnan2a8ee962014-11-22 13:35:38 -0800150 "h2n_control_packets",
151 "h2n_control_bytes",
152 "n2h_control_packets",
153 "n2h_control_bytes",
154 "h2n_data_packets",
155 "h2n_data_bytes",
156 "n2h_data_packets",
157 "n2h_data_bytes",
Saurabh Misra71034db2015-06-04 16:18:38 -0700158 "n2h_tot_payloads",
Guojun Jin85dfa7b2015-09-02 15:13:56 -0700159 "n2h_data_interface_invalid",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530160};
161
162/*
Thomas Wuc3e382c2014-10-29 15:35:13 -0700163 * nss_stats_str_lso_rx
164 * LSO_RX stats strings
165 */
166static int8_t *nss_stats_str_lso_rx[NSS_STATS_LSO_RX_MAX] = {
167 "tx_dropped",
168 "dropped",
169 "pbuf_alloc_fail",
170 "pbuf_reference_fail"
171};
172
173/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530174 * nss_stats_str_drv
175 * Host driver stats strings
176 */
177static int8_t *nss_stats_str_drv[NSS_STATS_DRV_MAX] = {
178 "nbuf_alloc_errors",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700179 "paged_buf_alloc_errors",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530180 "tx_queue_full[0]",
181 "tx_queue_full[1]",
182 "tx_buffers_empty",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700183 "tx_paged_buffers_empty",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530184 "tx_buffers_pkt",
185 "tx_buffers_cmd",
186 "tx_buffers_crypto",
Murat Sezginb6e1a012015-09-29 14:06:37 -0700187 "tx_buffers_reuse",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530188 "rx_buffers_empty",
189 "rx_buffers_pkt",
190 "rx_buffers_cmd_resp",
191 "rx_buffers_status_sync",
192 "rx_buffers_crypto",
Thomas Wu0acd8162014-12-07 15:43:39 -0800193 "rx_buffers_virtual",
194 "tx_skb_simple",
195 "tx_skb_nr_frags",
196 "tx_skb_fraglist",
197 "rx_skb_simple",
198 "rx_skb_nr_frags",
199 "rx_skb_fraglist",
Sundarajan Srinivasan6e0366b2015-01-20 12:10:42 -0800200 "rx_bad_desciptor",
Thomas Wu1fbf5212015-06-04 14:38:40 -0700201 "nss_skb_count",
202 "rx_chain_seg_processed",
203 "rx_frag_seg_processed"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530204};
205
206/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530207 * nss_stats_str_pppoe
208 * PPPoE stats strings
209 */
210static int8_t *nss_stats_str_pppoe[NSS_STATS_PPPOE_MAX] = {
211 "create_requests",
212 "create_failures",
213 "destroy_requests",
214 "destroy_misses"
215};
216
217/*
218 * nss_stats_str_gmac
219 * GMAC stats strings
220 */
221static int8_t *nss_stats_str_gmac[NSS_STATS_GMAC_MAX] = {
222 "ticks",
223 "worst_ticks",
224 "iterations"
225};
226
227/*
Shashank Balashankar512cb602016-08-01 17:57:42 -0700228 * nss_stats_str_edma_tx
229 */
230static int8_t *nss_stats_str_edma_tx[NSS_STATS_EDMA_TX_MAX] = {
231 "tx_err",
232 "tx_dropped",
233 "desc_cnt"
234};
235
236/*
237 * nss_stats_str_edma_rx
238 */
239static int8_t *nss_stats_str_edma_rx[NSS_STATS_EDMA_RX_MAX] = {
240 "rx_csum_err",
Shashank Balashankarcbe48992017-06-27 13:51:28 -0700241 "desc_cnt",
242 "qos_err"
Shashank Balashankar512cb602016-08-01 17:57:42 -0700243};
244
245/*
246 * nss_stats_str_edma_txcmpl
247 */
248static int8_t *nss_stats_str_edma_txcmpl[NSS_STATS_EDMA_TXCMPL_MAX] = {
249 "desc_cnt"
250};
251
252/*
253 * nss_stats_str_edma_rxfill
254 */
255static int8_t *nss_stats_str_edma_rxfill[NSS_STATS_EDMA_RXFILL_MAX] = {
256 "desc_cnt"
257};
258
259/*
260 * nss_stats_str_edma_port_type
261 */
262static int8_t *nss_stats_str_edma_port_type[NSS_EDMA_PORT_TYPE_MAX] = {
263 "physical_port",
264 "virtual_port"
265};
266
267/*
268 * nss_stats_str_edma_port_ring_map
269 */
270static int8_t *nss_stats_str_edma_port_ring_map[NSS_EDMA_PORT_RING_MAP_MAX] = {
271 "rx_ring",
272 "tx_ring"
273};
274
275/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -0700276 * nss_stats_str_edma_err_map
277 */
278static int8_t *nss_stats_str_edma_err_map[NSS_EDMA_ERR_STATS_MAX] = {
279 "axi_rd_err",
280 "axi_wr_err",
281 "rx_desc_fifo_full_err",
282 "rx_buf_size_err",
283 "tx_sram_full_err",
284 "tx_cmpl_buf_full_err",
285 "pkt_len_la64k_err",
286 "pkt_len_le33_err",
Santosh Kivati28c20042017-07-11 16:47:57 -0700287 "data_len_err",
288 "alloc_fail_cnt"
Santosh Kivatib65b68b2017-05-18 13:30:58 -0700289};
290
291/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530292 * nss_stats_str_node
293 * Interface stats strings per node
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530294 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530295static int8_t *nss_stats_str_node[NSS_STATS_NODE_MAX] = {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530296 "rx_packets",
297 "rx_bytes",
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530298 "rx_dropped",
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530299 "tx_packets",
300 "tx_bytes"
301};
302
303/*
Murat Sezgin99dab642014-08-28 14:40:34 -0700304 * nss_stats_str_eth_rx
305 * eth_rx stats strings
306 */
307static int8_t *nss_stats_str_eth_rx[NSS_STATS_ETH_RX_MAX] = {
308 "ticks",
309 "worst_ticks",
310 "iterations"
311};
312
313/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530314 * nss_stats_str_if_exception_unknown
315 * Interface stats strings for unknown exceptions
316 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530317static int8_t *nss_stats_str_if_exception_eth_rx[NSS_EXCEPTION_EVENT_ETH_RX_MAX] = {
Selin Dag2e8e48c2015-02-20 15:51:55 -0800318 "UNKNOWN_L3_PROTOCOL",
319 "ETH_HDR_MISSING",
Stephen Wangec5a85c2016-09-08 23:32:27 -0700320 "VLAN_MISSING",
321 "TRUSTSEC_HDR_MISSING"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530322};
323
324/*
325 * nss_stats_str_if_exception_ipv4
326 * Interface stats strings for ipv4 exceptions
327 */
328static int8_t *nss_stats_str_if_exception_ipv4[NSS_EXCEPTION_EVENT_IPV4_MAX] = {
329 "IPV4_ICMP_HEADER_INCOMPLETE",
330 "IPV4_ICMP_UNHANDLED_TYPE",
331 "IPV4_ICMP_IPV4_HEADER_INCOMPLETE",
332 "IPV4_ICMP_IPV4_UDP_HEADER_INCOMPLETE",
333 "IPV4_ICMP_IPV4_TCP_HEADER_INCOMPLETE",
334 "IPV4_ICMP_IPV4_UNKNOWN_PROTOCOL",
335 "IPV4_ICMP_NO_ICME",
336 "IPV4_ICMP_FLUSH_TO_HOST",
337 "IPV4_TCP_HEADER_INCOMPLETE",
338 "IPV4_TCP_NO_ICME",
339 "IPV4_TCP_IP_OPTION",
340 "IPV4_TCP_IP_FRAGMENT",
341 "IPV4_TCP_SMALL_TTL",
342 "IPV4_TCP_NEEDS_FRAGMENTATION",
343 "IPV4_TCP_FLAGS",
344 "IPV4_TCP_SEQ_EXCEEDS_RIGHT_EDGE",
345 "IPV4_TCP_SMALL_DATA_OFFS",
346 "IPV4_TCP_BAD_SACK",
347 "IPV4_TCP_BIG_DATA_OFFS",
348 "IPV4_TCP_SEQ_BEFORE_LEFT_EDGE",
349 "IPV4_TCP_ACK_EXCEEDS_RIGHT_EDGE",
350 "IPV4_TCP_ACK_BEFORE_LEFT_EDGE",
351 "IPV4_UDP_HEADER_INCOMPLETE",
352 "IPV4_UDP_NO_ICME",
353 "IPV4_UDP_IP_OPTION",
354 "IPV4_UDP_IP_FRAGMENT",
355 "IPV4_UDP_SMALL_TTL",
356 "IPV4_UDP_NEEDS_FRAGMENTATION",
357 "IPV4_WRONG_TARGET_MAC",
358 "IPV4_HEADER_INCOMPLETE",
359 "IPV4_BAD_TOTAL_LENGTH",
360 "IPV4_BAD_CHECKSUM",
361 "IPV4_NON_INITIAL_FRAGMENT",
362 "IPV4_DATAGRAM_INCOMPLETE",
363 "IPV4_OPTIONS_INCOMPLETE",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530364 "IPV4_UNKNOWN_PROTOCOL",
365 "IPV4_ESP_HEADER_INCOMPLETE",
366 "IPV4_ESP_NO_ICME",
367 "IPV4_ESP_IP_OPTION",
368 "IPV4_ESP_IP_FRAGMENT",
369 "IPV4_ESP_SMALL_TTL",
370 "IPV4_ESP_NEEDS_FRAGMENTATION",
371 "IPV4_INGRESS_VID_MISMATCH",
Thomas Wu8d6f4b22014-06-09 14:46:18 -0700372 "IPV4_INGRESS_VID_MISSING",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530373 "IPV4_6RD_NO_ICME",
374 "IPV4_6RD_IP_OPTION",
375 "IPV4_6RD_IP_FRAGMENT",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700376 "IPV4_6RD_NEEDS_FRAGMENTATION",
377 "IPV4_DSCP_MARKING_MISMATCH",
Murat Sezgin7c5956a2014-05-12 09:59:51 -0700378 "IPV4_VLAN_MARKING_MISMATCH",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800379 "IPV4_DEPRECATED",
Radha krishna Simha Jiguru00cfe562014-10-21 16:22:12 +0530380 "IPV4_GRE_HEADER_INCOMPLETE",
381 "IPV4_GRE_NO_ICME",
382 "IPV4_GRE_IP_OPTION",
383 "IPV4_GRE_IP_FRAGMENT",
384 "IPV4_GRE_SMALL_TTL",
385 "IPV4_GRE_NEEDS_FRAGMENTATION",
Shyam Sundere351f1b2015-12-17 14:11:51 +0530386 "IPV4_PPTP_GRE_SESSION_MATCH_FAIL",
387 "IPV4_PPTP_GRE_INVALID_PROTO",
388 "IPV4_PPTP_GRE_NO_CME",
389 "IPV4_PPTP_GRE_IP_OPTION",
390 "IPV4_PPTP_GRE_IP_FRAGMENT",
391 "IPV4_PPTP_GRE_SMALL_TTL",
392 "IPV4_PPTP_GRE_NEEDS_FRAGMENTATION",
393 "IPV4_DESTROY",
Selin Dag60ea2b22014-11-05 09:36:22 -0800394 "IPV4_FRAG_DF_SET",
395 "IPV4_FRAG_FAIL",
Saurabh Misra5b07cc02015-01-15 14:20:58 -0800396 "IPV4_ICMP_IPV4_UDPLITE_HEADER_INCOMPLETE",
397 "IPV4_UDPLITE_HEADER_INCOMPLETE",
398 "IPV4_UDPLITE_NO_ICME",
399 "IPV4_UDPLITE_IP_OPTION",
400 "IPV4_UDPLITE_IP_FRAGMENT",
401 "IPV4_UDPLITE_SMALL_TTL",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530402 "IPV4_UDPLITE_NEEDS_FRAGMENTATION",
403 "IPV4_MC_UDP_NO_ICME",
404 "IPV4_MC_MEM_ALLOC_FAILURE",
405 "IPV4_MC_UPDATE_FAILURE",
406 "IPV4_MC_PBUF_ALLOC_FAILURE"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530407};
408
409/*
410 * nss_stats_str_if_exception_ipv6
411 * Interface stats strings for ipv6 exceptions
412 */
413static int8_t *nss_stats_str_if_exception_ipv6[NSS_EXCEPTION_EVENT_IPV6_MAX] = {
414 "IPV6_ICMP_HEADER_INCOMPLETE",
415 "IPV6_ICMP_UNHANDLED_TYPE",
416 "IPV6_ICMP_IPV6_HEADER_INCOMPLETE",
417 "IPV6_ICMP_IPV6_UDP_HEADER_INCOMPLETE",
418 "IPV6_ICMP_IPV6_TCP_HEADER_INCOMPLETE",
419 "IPV6_ICMP_IPV6_UNKNOWN_PROTOCOL",
420 "IPV6_ICMP_NO_ICME",
421 "IPV6_ICMP_FLUSH_TO_HOST",
422 "IPV6_TCP_HEADER_INCOMPLETE",
423 "IPV6_TCP_NO_ICME",
424 "IPV6_TCP_SMALL_HOP_LIMIT",
425 "IPV6_TCP_NEEDS_FRAGMENTATION",
426 "IPV6_TCP_FLAGS",
427 "IPV6_TCP_SEQ_EXCEEDS_RIGHT_EDGE",
428 "IPV6_TCP_SMALL_DATA_OFFS",
429 "IPV6_TCP_BAD_SACK",
430 "IPV6_TCP_BIG_DATA_OFFS",
431 "IPV6_TCP_SEQ_BEFORE_LEFT_EDGE",
432 "IPV6_TCP_ACK_EXCEEDS_RIGHT_EDGE",
433 "IPV6_TCP_ACK_BEFORE_LEFT_EDGE",
434 "IPV6_UDP_HEADER_INCOMPLETE",
435 "IPV6_UDP_NO_ICME",
436 "IPV6_UDP_SMALL_HOP_LIMIT",
437 "IPV6_UDP_NEEDS_FRAGMENTATION",
438 "IPV6_WRONG_TARGET_MAC",
439 "IPV6_HEADER_INCOMPLETE",
Radha krishna Simha Jiguru59a1a1c2014-01-27 18:29:40 +0530440 "IPV6_UNKNOWN_PROTOCOL",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700441 "IPV6_INGRESS_VID_MISMATCH",
Thomas Wu8d6f4b22014-06-09 14:46:18 -0700442 "IPV6_INGRESS_VID_MISSING",
Murat Sezgin0c0561d2014-04-09 18:55:58 -0700443 "IPV6_DSCP_MARKING_MISMATCH",
444 "IPV6_VLAN_MARKING_MISMATCH",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800445 "IPV6_DEPRECATED",
Saurabh Misra5b07cc02015-01-15 14:20:58 -0800446 "IPV6_GRE_NO_ICME",
447 "IPV6_GRE_NEEDS_FRAGMENTATION",
448 "IPV6_GRE_SMALL_HOP_LIMIT",
449 "IPV6_DESTROY",
450 "IPV6_ICMP_IPV6_UDPLITE_HEADER_INCOMPLETE",
451 "IPV6_UDPLITE_HEADER_INCOMPLETE",
452 "IPV6_UDPLITE_NO_ICME",
453 "IPV6_UDPLITE_SMALL_HOP_LIMIT",
Kiran Kumar C. S. K12998002014-09-04 17:09:03 +0530454 "IPV6_UDPLITE_NEEDS_FRAGMENTATION",
455 "IPV6_MC_UDP_NO_ICME",
456 "IPV6_MC_MEM_ALLOC_FAILURE",
457 "IPV6_MC_UPDATE_FAILURE",
mandrw7125bac2016-01-14 19:36:46 +0530458 "IPV6_MC_PBUF_ALLOC_FAILURE",
459 "IPV6_ESP_HEADER_INCOMPLETE",
460 "IPV6_ESP_NO_ICME",
461 "IPV6_ESP_IP_FRAGMENT",
462 "IPV6_ESP_SMALL_HOP_LIMIT",
463 "IPV6_ESP_NEEDS_FRAGMENTATION"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530464};
465
466/*
467 * nss_stats_str_if_exception_pppoe
468 * Interface stats strings for PPPoE exceptions
469 */
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +0530470static int8_t *nss_stats_str_if_exception_pppoe[NSS_PPPOE_EXCEPTION_EVENT_MAX] = {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530471 "PPPOE_WRONG_VERSION_OR_TYPE",
472 "PPPOE_WRONG_CODE",
473 "PPPOE_HEADER_INCOMPLETE",
Murat Sezgin7c5956a2014-05-12 09:59:51 -0700474 "PPPOE_UNSUPPORTED_PPP_PROTOCOL",
Murat Sezgin49d21d12016-02-03 17:36:47 -0800475 "PPPOE_DEPRECATED"
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530476};
477
478/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530479 * nss_stats_str_wifi
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530480 * Wifi statistics strings
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530481 */
482static int8_t *nss_stats_str_wifi[NSS_STATS_WIFI_MAX] = {
483 "RX_PACKETS",
484 "RX_DROPPED",
485 "TX_PACKETS",
486 "TX_DROPPED",
487 "TX_TRANSMIT_COMPLETED",
488 "TX_MGMT_RECEIVED",
489 "TX_MGMT_TRANSMITTED",
490 "TX_MGMT_DROPPED",
491 "TX_MGMT_COMPLETED",
492 "TX_INV_PEER_ENQ_CNT",
493 "RX_INV_PEER_RCV_CNT",
494 "RX_PN_CHECK_FAILED",
495 "RX_PKTS_DELIVERD",
Radha krishna Simha Jiguru36304d12015-12-03 20:21:02 +0530496 "RX_BYTES_DELIVERED",
497 "TX_BYTES_COMPLETED",
Pamidipati, Vijay670ce7e2016-03-15 16:46:59 +0530498 "RX_DELIVER_UNALIGNED_DROP_CNT",
499 "TIDQ_ENQUEUE_CNT_0",
500 "TIDQ_ENQUEUE_CNT_1",
501 "TIDQ_ENQUEUE_CNT_2",
502 "TIDQ_ENQUEUE_CNT_3",
503 "TIDQ_ENQUEUE_CNT_4",
504 "TIDQ_ENQUEUE_CNT_5",
505 "TIDQ_ENQUEUE_CNT_6",
506 "TIDQ_ENQUEUE_CNT_7",
507 "TIDQ_DEQUEUE_CNT_0",
508 "TIDQ_DEQUEUE_CNT_1",
509 "TIDQ_DEQUEUE_CNT_2",
510 "TIDQ_DEQUEUE_CNT_3",
511 "TIDQ_DEQUEUE_CNT_4",
512 "TIDQ_DEQUEUE_CNT_5",
513 "TIDQ_DEQUEUE_CNT_6",
514 "TIDQ_DEQUEUE_CNT_7",
515 "TIDQ_ENQUEUE_FAIL_CNT_0",
516 "TIDQ_ENQUEUE_FAIL_CNT_1",
517 "TIDQ_ENQUEUE_FAIL_CNT_2",
518 "TIDQ_ENQUEUE_FAIL_CNT_3",
519 "TIDQ_ENQUEUE_FAIL_CNT_4",
520 "TIDQ_ENQUEUE_FAIL_CNT_5",
521 "TIDQ_ENQUEUE_FAIL_CNT_6",
522 "TIDQ_ENQUEUE_FAIL_CNT_7",
523 "TIDQ_TTL_EXPIRE_CNT_0",
524 "TIDQ_TTL_EXPIRE_CNT_1",
525 "TIDQ_TTL_EXPIRE_CNT_2",
526 "TIDQ_TTL_EXPIRE_CNT_3",
527 "TIDQ_TTL_EXPIRE_CNT_4",
528 "TIDQ_TTL_EXPIRE_CNT_5",
529 "TIDQ_TTL_EXPIRE_CNT_6",
530 "TIDQ_TTL_EXPIRE_CNT_7",
531 "TIDQ_DEQUEUE_REQ_CNT_0",
532 "TIDQ_DEQUEUE_REQ_CNT_1",
533 "TIDQ_DEQUEUE_REQ_CNT_2",
534 "TIDQ_DEQUEUE_REQ_CNT_3",
535 "TIDQ_DEQUEUE_REQ_CNT_4",
536 "TIDQ_DEQUEUE_REQ_CNT_5",
537 "TIDQ_DEQUEUE_REQ_CNT_6",
538 "TIDQ_DEQUEUE_REQ_CNT_7",
539 "TOTAL_TIDQ_DEPTH",
540 "RX_HTT_FETCH_CNT",
541 "TOTAL_TIDQ_BYPASS_CNT",
542 "GLOBAL_Q_FULL_CNT",
543 "TIDQ_FULL_CNT",
Bharath M Kumarcc666e92014-12-24 19:17:28 +0530544};
545
546/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530547 * nss_stats_str_wifili
548 * wifili txrx statistics
549 */
550static int8_t *nss_stats_str_wifili_txrx[NSS_STATS_WIFILI_TXRX_MAX] = {
551 "WIFILI_RX_MSDU_ERROR",
552 "WIFILI_RX_INV_PEER_RCV",
553 "WIFILI_RX_WDS_SRCPORT_EXCEPTION",
554 "WIFILI_RX_WDS_SRCPORT_EXCEPTION_FAIL",
555 "WIFILI_RX_DELIVERD",
556 "WIFILI_RX_DELIVER_DROPPED",
557 "WIFILI_RX_INTRA_BSS_UCAST",
558 "WIFILI_RX_INTRA_BSS_UCAST_FAIL",
559 "WIFILI_RX_INTRA_BSS_MCAST",
560 "WIFILI_RX_INTRA_BSS_MCAST_FAIL",
Aniruddha Paul1dc00782017-06-05 13:38:48 +0530561 "WIFILI_RX_SG_RCV_SEND",
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530562 "WIFILI_RX_SG_RCV_FAIL",
Radha krishna Simha Jiguru538a0882017-08-16 12:49:41 +0530563 "WIFILI_RX_MCAST_ECHO",
Aniruddha Paul1b170c22017-05-29 12:30:39 +0530564 "WIFILI_TX_ENQUEUE",
565 "WIFILI_TX_ENQUEUE_DROP",
566 "WIFILI_TX_DEQUEUE",
567 "WIFILI_TX_HW_ENQUEUE_FAIL",
568 "WIFILI_TX_SENT_COUNT",
569};
570
571/*
572 * nss_stats_str_wifili_tcl
573 * wifili tcl stats
574 */
575static int8_t *nss_stats_str_wifili_tcl[NSS_STATS_WIFILI_TCL_MAX] = {
576 "WIFILI_TCL_NO_HW_DESC",
577 "WIFILI_TCL_RING_FULL",
578 "WIFILI_TCL_RING_SENT",
579};
580
581/*
582 * nss_stats_str_wifili_tx_comp
583 * wifili tx comp stats
584 */
585static int8_t *nss_stats_str_wifili_tx_comp[NSS_STATS_WIFILI_TX_DESC_FREE_MAX] = {
586 "WIFILI_TX_DESC_FREE_INV_BUFSRC",
587 "WIFILI_TX_DESC_FREE_INV_COOKIE",
588 "WIFILI_TX_DESC_FREE_HW_RING_EMPTY",
589 "WIFILI_TX_DESC_FREE_REAPED",
590};
591
592/*
593 * nss_stats_str_wifili_reo
594 * wifili tx reo stats
595 */
596static int8_t *nss_stats_str_wifili_reo[NSS_STATS_WIFILI_REO_MAX] = {
597 "WIFILI_REO_ERROR",
598 "WIFILI_REO_REAPED",
599 "WIFILI_REO_INV_COOKIE",
600};
601
602/*
603 * nss_stats_str_wifili_txsw_pool
604 * wifili tx desc stats
605 */
606static int8_t *nss_stats_str_wifili_txsw_pool[NSS_STATS_WIFILI_TX_DESC_MAX] = {
607 "WIFILI_TX_DESC_IN_USE",
608 "WIFILI_TX_DESC_ALLOC_FAIL",
609 "WIFILI_TX_DESC_ALREADY_ALLOCATED",
610 "WIFILI_TX_DESC_INVALID_FREE",
611 "WIFILI_TX_DESC_FREE_SRC_FW",
612 "WIFILI_TX_DESC_FREE_COMPLETION",
613 "WIFILI_TX_DESC_NO_PB",
614};
615
616/*
617 * nss_stats_str_wifili_ext_txsw_pool
618 * wifili tx ext desc stats
619 */
620static uint8_t *nss_stats_str_wifili_ext_txsw_pool[NSS_STATS_WIFILI_EXT_TX_DESC_MAX] = {
621 "WIFILI_EXT_TX_DESC_IN_USE",
622 "WIFILI_EXT_TX_DESC_ALLOC_FAIL",
623 "WIFILI_EXT_TX_DESC_ALREADY_ALLOCATED",
624 "WIFILI_EXT_TX_DESC_INVALID_FREE",
625};
626
627/*
628 * nss_stats_str_wifili_rxdma_pool
629 * wifili rx desc stats
630 */
631static int8_t *nss_stats_str_wifili_rxdma_pool[NSS_STATS_WIFILI_RX_DESC_MAX] = {
632 "WIFILI_RX_DESC_NO_PB",
633 "WIFILI_RX_DESC_ALLOC_FAIL",
634 "WIFILI_RX_DESC_IN_USE",
635};
636
637/*
638 * nss_stats_str_wifili_rxdma_ring
639 * wifili rx dma ring stats
640 */
641static int8_t *nss_stats_str_wifili_rxdma_ring[NSS_STATS_WIFILI_RXDMA_DESC_MAX] = {
642 "WIFILI_RXDMA_HW_DESC_UNAVAILABLE",
643};
644
645/*
646 * nss_stats_str_wifili_wbm
647 * wifili wbm ring stats
648 */
649static int8_t *nss_stats_str_wifili_wbm[NSS_STATS_WIFILI_WBM_MAX] = {
650 "WIFILI_WBM_SRC_DMA",
651 "WIFILI_WBM_SRC_DMA_CODE_INV",
652 "WIFILI_WBM_SRC_REO",
653 "WIFILI_WBM_SRC_REO_CODE_NULLQ",
654 "WIFILI_WBM_SRC_REO_CODE_INV",
655 "WIFILI_WBM_SRC_INV",
656};
657
658/*
Stephen Wang9779d952015-10-28 11:39:07 -0700659 * nss_stats_str_portid
660 * PortID statistics strings
661 */
662static int8_t *nss_stats_str_portid[NSS_STATS_PORTID_MAX] = {
663 "RX_INVALID_HEADER",
664};
665
666/*
Tushar Mathurff8741b2015-12-02 20:28:59 +0530667 * nss_stats_str_dtls_session_stats
668 * DTLS statistics strings for nss session stats
669 */
670static int8_t *nss_stats_str_dtls_session_debug_stats[NSS_STATS_DTLS_SESSION_MAX] = {
671 "RX_PKTS",
672 "TX_PKTS",
673 "RX_DROPPED",
674 "RX_AUTH_DONE",
675 "TX_AUTH_DONE",
676 "RX_CIPHER_DONE",
677 "TX_CIPHER_DONE",
678 "RX_CBUF_ALLOC_FAIL",
679 "TX_CBUF_ALLOC_FAIL",
680 "TX_CENQUEUE_FAIL",
681 "RX_CENQUEUE_FAIL",
682 "TX_DROPPED_HROOM",
683 "TX_DROPPED_TROOM",
684 "TX_FORWARD_ENQUEUE_FAIL",
685 "RX_FORWARD_ENQUEUE_FAIL",
686 "RX_INVALID_VERSION",
687 "RX_INVALID_EPOCH",
688 "RX_MALFORMED",
689 "RX_CIPHER_FAIL",
690 "RX_AUTH_FAIL",
691 "RX_CAPWAP_CLASSIFY_FAIL",
692 "RX_SINGLE_REC_DGRAM",
693 "RX_MULTI_REC_DGRAM",
694 "RX_REPLAY_FAIL",
695 "RX_REPLAY_DUPLICATE",
696 "RX_REPLAY_OUT_OF_WINDOW",
697 "OUTFLOW_QUEUE_FULL",
698 "DECAP_QUEUE_FULL",
699 "PBUF_ALLOC_FAIL",
700 "PBUF_COPY_FAIL",
701 "EPOCH",
702 "TX_SEQ_HIGH",
703 "TX_SEQ_LOW",
704};
705
706/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -0700707 * nss_stats_str_gre_tunnel_session_stats
708 * GRE Tunnel statistics strings for nss session stats
709 */
710static int8_t *nss_stats_str_gre_tunnel_session_debug_stats[NSS_STATS_GRE_TUNNEL_SESSION_MAX] = {
711 "RX_PKTS",
712 "TX_PKTS",
713 "RX_DROPPED",
714 "RX_MALFORMED",
715 "RX_INVALID_PROT",
716 "DECAP_QUEUE_FULL",
717 "RX_SINGLE_REC_DGRAM",
718 "RX_INVALID_REC_DGRAM",
719 "BUFFER_ALLOC_FAIL",
720 "BUFFER_COPY_FAIL",
721 "OUTFLOW_QUEUE_FULL",
722 "TX_DROPPED_HROOM",
723 "RX_CBUFFER_ALLOC_FAIL",
724 "RX_CENQUEUE_FAIL",
725 "RX_DECRYPT_DONE",
726 "RX_FORWARD_ENQUEUE_FAIL",
727 "TX_CBUFFER_ALLOC_FAIL",
728 "TX_CENQUEUE_FAIL",
729 "TX_DROPPED_TROOM",
730 "TX_FORWARD_ENQUEUE_FAIL",
731 "TX_CIPHER_DONE",
732 "CRYPTO_NOSUPP",
Shashank Balashankar4e7879e2017-06-02 15:16:01 -0700733 "RX_DROPPED_MH_VERSION",
Thomas Wu71c5ecc2016-06-21 11:15:52 -0700734};
735
736/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +0530737 * nss_stats_str_l2tpv2_session_stats
738 * l2tpv2 statistics strings for nss session stats
739 */
740static int8_t *nss_stats_str_l2tpv2_session_debug_stats[NSS_STATS_L2TPV2_SESSION_MAX] = {
741 "RX_PPP_LCP_PKTS",
742 "RX_EXP_PKTS",
743 "ENCAP_PBUF_ALLOC_FAIL",
744 "DECAP_PBUF_ALLOC_FAIL"
745};
746
747/*
ratheesh kannotha1245c32015-11-04 16:45:43 +0530748 * nss_stats_str_map_t_instance_stats
749 * map_t statistics strings for nss session stats
750 */
751static int8_t *nss_stats_str_map_t_instance_debug_stats[NSS_STATS_MAP_T_MAX] = {
752 "MAP_T_V4_TO_V6_PBUF_EXCEPTION_PKTS",
753 "MAP_T_V4_TO_V6_PBUF_NO_MATCHING_RULE",
754 "MAP_T_V4_TO_V6_PBUF_NOT_TCP_OR_UDP",
ratheesh kannoth32b6c422016-06-05 10:08:15 +0530755 "MAP_T_V4_TO_V6_RULE_ERR_LOCAL_PSID",
ratheesh kannotha1245c32015-11-04 16:45:43 +0530756 "MAP_T_V4_TO_V6_RULE_ERR_LOCAL_IPV6",
757 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_PSID",
758 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_EA_BITS",
759 "MAP_T_V4_TO_V6_RULE_ERR_REMOTE_IPV6",
760 "MAP_T_V6_TO_V4_PBUF_EXCEPTION_PKTS",
761 "MAP_T_V6_TO_V4_PBUF_NO_MATCHING_RULE",
762 "MAP_T_V6_TO_V4_PBUF_NOT_TCP_OR_UDP",
763 "MAP_T_V6_TO_V4_RULE_ERR_LOCAL_IPV4",
764 "MAP_T_V6_TO_V4_RULE_ERR_REMOTE_IPV4"
765};
766
ratheesh kannotheb2a0a82017-05-04 09:20:17 +0530767 /*
768 * nss_stats_str_gre_base_stats
769 * GRE debug statistics strings for base types
770 */
771static int8_t *nss_stats_str_gre_base_debug_stats[NSS_STATS_GRE_BASE_DEBUG_MAX] = {
772 "GRE_BASE_RX_PACKETS",
773 "GRE_BASE_RX_DROPPED",
774 "GRE_BASE_EXP_ETH_HDR_MISSING",
775 "GRE_BASE_EXP_ETH_TYPE_NON_IP",
776 "GRE_BASE_EXP_IP_UNKNOWN_PROTOCOL",
777 "GRE_BASE_EXP_IP_HEADER_INCOMPLETE",
778 "GRE_BASE_EXP_IP_BAD_TOTAL_LENGTH",
779 "GRE_BASE_EXP_IP_BAD_CHECKSUM",
780 "GRE_BASE_EXP_IP_DATAGRAM_INCOMPLETE",
781 "GRE_BASE_EXP_IP_FRAGMENT",
782 "GRE_BASE_EXP_IP_OPTIONS_INCOMPLETE",
783 "GRE_BASE_EXP_IP_WITH_OPTIONS",
784 "GRE_BASE_EXP_IPV6_UNKNOWN_PROTOCOL",
785 "GRE_BASE_EXP_IPV6_HEADER_INCOMPLETE",
786 "GRE_BASE_EXP_GRE_UNKNOWN_SESSION",
787 "GRE_BASE_EXP_GRE_NODE_INACTIVE",
788};
789
790/*
791 * nss_stats_str_gre_session_stats
792 * GRE debug statistics strings for sessions
793 */
794static int8_t *nss_stats_str_gre_session_debug_stats[NSS_STATS_GRE_SESSION_DEBUG_MAX] = {
795 "GRE_SESSION_PBUF_ALLOC_FAIL",
796 "GRE_SESSION_DECAP_FORWARD_ENQUEUE_FAIL",
797 "GRE_SESSION_ENCAP_FORWARD_ENQUEUE_FAIL",
798 "GRE_SESSION_DECAP_TX_FORWARDED",
799 "GRE_SESSION_ENCAP_RX_RECEIVED",
800 "GRE_SESSION_ENCAP_RX_DROPPED",
801 "GRE_SESSION_ENCAP_RX_LINEAR_FAIL",
802 "GRE_SESSION_EXP_RX_KEY_ERROR",
803 "GRE_SESSION_EXP_RX_SEQ_ERROR",
804 "GRE_SESSION_EXP_RX_CS_ERROR",
805 "GRE_SESSION_EXP_RX_FLAG_MISMATCH",
806 "GRE_SESSION_EXP_RX_MALFORMED",
807 "GRE_SESSION_EXP_RX_INVALID_PROTOCOL",
808 "GRE_SESSION_EXP_RX_NO_HEADROOM",
809};
810
ratheesh kannotha1245c32015-11-04 16:45:43 +0530811/*
Amit Gupta316729b2016-08-12 12:21:15 +0530812 * nss_stats_str_ppe_conn
813 * PPE statistics strings for nss flow stats
814 */
815static int8_t *nss_stats_str_ppe_conn[NSS_STATS_PPE_CONN_MAX] = {
816 "v4 routed flows",
817 "v4 bridge flows",
818 "v4 conn create req",
819 "v4 conn create fail",
820 "v4 conn destroy req",
821 "v4 conn destroy fail",
Amit Gupta263df9c2017-05-16 20:43:07 +0530822 "v4 conn MC create req",
823 "v4 conn MC create fail",
824 "v4 conn MC update req",
825 "v4 conn MC update fail",
826 "v4 conn MC delete req",
827 "v4 conn MC delete fail",
Amit Gupta316729b2016-08-12 12:21:15 +0530828
829 "v6 routed flows",
830 "v6 bridge flows",
831 "v6 conn create req",
832 "v6 conn create fail",
833 "v6 conn destroy req",
834 "v6 conn destroy fail",
Amit Gupta263df9c2017-05-16 20:43:07 +0530835 "v6 conn MC create req",
836 "v6 conn MC create fail",
837 "v6 conn MC update req",
838 "v6 conn MC update fail",
839 "v6 conn MC delete req",
840 "v6 conn MC delete fail",
Amit Gupta316729b2016-08-12 12:21:15 +0530841
Amit Gupta263df9c2017-05-16 20:43:07 +0530842 "conn fail - vp full",
Amit Gupta316729b2016-08-12 12:21:15 +0530843 "conn fail - nexthop full",
844 "conn fail - flow full",
845 "conn fail - host full",
846 "conn fail - pub-ip full",
847 "conn fail - port not setup",
848 "conn fail - rw fifo full",
Amit Gupta263df9c2017-05-16 20:43:07 +0530849 "conn fail - flow cmd failure",
Amit Gupta316729b2016-08-12 12:21:15 +0530850 "conn fail - unknown proto",
851 "conn fail - ppe not responding",
Amit Gupta263df9c2017-05-16 20:43:07 +0530852 "conn fail - CE opaque invalid",
Thomas Wufc4d9fd2017-03-22 10:15:30 -0700853 "conn fail - fqg full"
Amit Gupta316729b2016-08-12 12:21:15 +0530854};
855
856/*
857 * nss_stats_str_ppe_l3
858 * PPE statistics strings for nss debug stats
859 */
860static int8_t *nss_stats_str_ppe_l3[NSS_STATS_PPE_L3_MAX] = {
861 "PPE L3 dbg reg 0",
862 "PPE L3 dbg reg 1",
863 "PPE L3 dbg reg 2",
864 "PPE L3 dbg reg 3",
865 "PPE L3 dbg reg 4",
866 "PPE L3 dbg reg port",
867};
868
869/*
870 * nss_stats_str_ppe_code
871 * PPE statistics strings for nss debug stats
872 */
873static int8_t *nss_stats_str_ppe_code[NSS_STATS_PPE_CODE_MAX] = {
874 "PPE CPU_CODE",
875 "PPE DROP_CODE",
876};
877
878/*
Amit Gupta79c1c202017-06-30 15:28:13 +0530879 * nss_stats_str_ppe_dc
880 * PPE statistics strings for drop code
881 */
882static int8_t *nss_stats_str_ppe_dc[NSS_STATS_PPE_DROP_CODE_MAX] = {
883 "PPE_DROP_CODE_NONE",
884 "PPE_DROP_CODE_EXP_UNKNOWN_L2_PORT",
885 "PPE_DROP_CODE_EXP_PPPOE_WRONG_VER_TYPE",
886 "PPE_DROP_CODE_EXP_PPPOE_WRONG_CODE",
887 "PPE_DROP_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",
888 "PPE_DROP_CODE_EXP_IPV4_WRONG_VER",
889 "PPE_DROP_CODE_EXP_IPV4_SMALL_IHL",
890 "PPE_DROP_CODE_EXP_IPV4_WITH_OPTION",
891 "PPE_DROP_CODE_EXP_IPV4_HDR_INCOMPLETE",
892 "PPE_DROP_CODE_EXP_IPV4_BAD_TOTAL_LEN",
893 "PPE_DROP_CODE_EXP_IPV4_DATA_INCOMPLETE",
894 "PPE_DROP_CODE_EXP_IPV4_FRAG",
895 "PPE_DROP_CODE_EXP_IPV4_PING_OF_DEATH",
896 "PPE_DROP_CODE_EXP_IPV4_SNALL_TTL",
897 "PPE_DROP_CODE_EXP_IPV4_UNK_IP_PROT",
898 "PPE_DROP_CODE_EXP_IPV4_CHECKSUM_ERR",
899 "PPE_DROP_CODE_EXP_IPV4_INV_SIP",
900 "PPE_DROP_CODE_EXP_IPV4_INV_DIP",
901 "PPE_DROP_CODE_EXP_IPV4_LAND_ATTACK",
902 "PPE_DROP_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",
903 "PPE_DROP_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER",
904 "PPE_DROP_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",
905 "PPE_DROP_CODE_EXP_IPV6_WRONG_VER",
906 "PPE_DROP_CODE_EXP_IPV6_HDR_INCOMPLETE",
907 "PPE_DROP_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",
908 "PPE_DROP_CODE_EXP_IPV6_DATA_INCOMPLETE",
909 "PPE_DROP_CODE_EXP_IPV6_WITH_EXT_HDR",
910 "PPE_DROP_CODE_EXP_IPV6_SMALL_HOP_LIMIT",
911 "PPE_DROP_CODE_EXP_IPV6_INV_SIP",
912 "PPE_DROP_CODE_EXP_IPV6_INV_DIP",
913 "PPE_DROP_CODE_EXP_IPV6_LAND_ATTACK",
914 "PPE_DROP_CODE_EXP_IPV6_FRAG",
915 "PPE_DROP_CODE_EXP_IPV6_PING_OF_DEATH",
916 "PPE_DROP_CODE_EXP_IPV6_WITH_MORE_EXT_HDR",
917 "PPE_DROP_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR",
918 "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",
919 "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER",
920 "PPE_DROP_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",
921 "PPE_DROP_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER",
922 "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",
923 "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER",
924 "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE",
925 "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER",
926 "PPE_DROP_CODE_EXP_TCP_HDR_INCOMPLETE",
927 "PPE_DROP_CODE_EXP_TCP_HDR_CROSS_BORDER",
928 "PPE_DROP_CODE_EXP_TCP_SMAE_SP_DP",
929 "PPE_DROP_CODE_EXP_TCP_SMALL_DATA_OFFSET",
930 "PPE_DROP_CODE_EXP_TCP_FLAGS_0",
931 "PPE_DROP_CODE_EXP_TCP_FLAGS_1",
932 "PPE_DROP_CODE_EXP_TCP_FLAGS_2",
933 "PPE_DROP_CODE_EXP_TCP_FLAGS_3",
934 "PPE_DROP_CODE_EXP_TCP_FLAGS_4",
935 "PPE_DROP_CODE_EXP_TCP_FLAGS_5",
936 "PPE_DROP_CODE_EXP_TCP_FLAGS_6",
937 "PPE_DROP_CODE_EXP_TCP_FLAGS_7",
938 "PPE_DROP_CODE_EXP_TCP_CHECKSUM_ERR",
939 "PPE_DROP_CODE_EXP_UDP_HDR_INCOMPLETE",
940 "PPE_DROP_CODE_EXP_UDP_HDR_CROSS_BORDER",
941 "PPE_DROP_CODE_EXP_UDP_SMAE_SP_DP",
942 "PPE_DROP_CODE_EXP_UDP_BAD_LEN",
943 "PPE_DROP_CODE_EXP_UDP_DATA_INCOMPLETE",
944 "PPE_DROP_CODE_EXP_UDP_CHECKSUM_ERR",
945 "PPE_DROP_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",
946 "PPE_DROP_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER",
947 "PPE_DROP_CODE_EXP_UDP_LITE_SMAE_SP_DP",
948 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7",
949 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG",
950 "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER",
951 "PPE_DROP_CODE_EXP_UDP_LITE_CHECKSUM_ERR",
952 "PPE_DROP_CODE_L3_MC_BRIDGE_ACTION",
953 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION",
954 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR",
955 "PPE_DROP_CODE_L3_ROUTE_ACTION",
956 "PPE_DROP_CODE_L3_NO_ROUTE_ACTION",
957 "PPE_DROP_CODE_L3_NO_ROUTE_NH_INVALID_ACTION",
958 "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_ACTION",
959 "PPE_DROP_CODE_L3_BRIDGE_ACTION",
960 "PPE_DROP_CODE_L3_FLOW_ACTION",
961 "PPE_DROP_CODE_L3_FLOW_MISS_ACTION",
962 "PPE_DROP_CODE_L2_EXP_MRU_FAIL",
963 "PPE_DROP_CODE_L2_EXP_MTU_FAIL",
964 "PPE_DROP_CODE_L3_EXP_IP_PREFIX_BC",
965 "PPE_DROP_CODE_L3_EXP_MTU_FAIL",
966 "PPE_DROP_CODE_L3_EXP_MRU_FAIL",
967 "PPE_DROP_CODE_L3_EXP_ICMP_RDT",
968 "PPE_DROP_CODE_FAKE_MAC_HEADER_ERR",
969 "PPE_DROP_CODE_L3_EXP_IP_RT_TTL_ZERO",
970 "PPE_DROP_CODE_L3_FLOW_SERVICE_CODE_LOOP",
971 "PPE_DROP_CODE_L3_FLOW_DE_ACCELEARTE",
972 "PPE_DROP_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL",
973 "PPE_DROP_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",
974 "PPE_DROP_CODE_L3_EXP_MTU_DF_FAIL",
975 "PPE_DROP_CODE_L3_EXP_PPPOE_MULTICAST",
976 "PPE_DROP_CODE_IPV4_SG_UNKNOWN",
977 "PPE_DROP_CODE_IPV6_SG_UNKNOWN",
978 "PPE_DROP_CODE_ARP_SG_UNKNOWN",
979 "PPE_DROP_CODE_ND_SG_UNKNOWN",
980 "PPE_DROP_CODE_IPV4_SG_VIO",
981 "PPE_DROP_CODE_IPV6_SG_VIO",
982 "PPE_DROP_CODE_ARP_SG_VIO",
983 "PPE_DROP_CODE_ND_SG_VIO",
984 "PPE_DROP_CODE_L2_NEW_MAC_ADDRESS",
985 "PPE_DROP_CODE_L2_HASH_COLLISION",
986 "PPE_DROP_CODE_L2_STATION_MOVE",
987 "PPE_DROP_CODE_L2_LEARN_LIMIT",
988 "PPE_DROP_CODE_L2_SA_LOOKUP_ACTION",
989 "PPE_DROP_CODE_L2_DA_LOOKUP_ACTION",
990 "PPE_DROP_CODE_APP_CTRL_ACTION",
991 "PPE_DROP_CODE_IN_VLAN_FILTER_ACTION",
992 "PPE_DROP_CODE_IN_VLAN_XLT_MISS",
993 "PPE_DROP_CODE_EG_VLAN_FILTER_DROP",
994 "PPE_DROP_CODE_ACL_PRE_ACTION",
995 "PPE_DROP_CODE_ACL_POST_ACTION",
996 "PPE_DROP_CODE_MC_BC_SA",
997 "PPE_DROP_CODE_NO_DESTINATION",
998 "PPE_DROP_CODE_STG_IN_FILTER",
999 "PPE_DROP_CODE_STG_EG_FILTER",
1000 "PPE_DROP_CODE_SOURCE_FILTER_FAIL",
1001 "PPE_DROP_CODE_TRUNK_SEL_FAIL",
1002 "PPE_DROP_CODE_TX_EN_FAIL",
1003 "PPE_DROP_CODE_VLAN_TAG_FMT",
1004 "PPE_DROP_CODE_CRC_ERR",
1005 "PPE_DROP_CODE_PAUSE_FRAME",
1006 "PPE_DROP_CODE_PROMISC",
1007 "PPE_DROP_CODE_ISOLATION",
1008 "PPE_DROP_CODE_MGMT_APP",
1009 "PPE_DROP_CODE_FAKE_L2_PROT_ERR",
1010 "PPE_DROP_CODE_POLICER",
1011};
1012
1013/*
1014 * nss_stats_str_ppe_cc
1015 * PPE statistics strings for cpu code
1016 */
1017static int8_t *nss_stats_str_ppe_cc[NSS_STATS_PPE_CPU_CODE_MAX] = {
1018 "PPE_CPU_CODE_FORWARDING",
1019 "PPE_CPU_CODE_EXP_UNKNOWN_L2_PROT",
1020 "PPE_CPU_CODE_EXP_PPPOE_WRONG_VER_TYPE",
1021 "PPE_CPU_CODE_EXP_WRONG_CODE",
1022 "PPE_CPU_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",
1023 "PPE_CPU_CODE_EXP_WRONG_VER",
1024 "PPE_CPU_CODE_EXP_SMALL_IHL",
1025 "PPE_CPU_CODE_EXP_WITH_OPTION",
1026 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1027 "PPE_CPU_CODE_EXP_IPV4_BAD_TOTAL_LEN",
1028 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1029 "PPE_CPU_CODE_IPV4_FRAG",
1030 "PPE_CPU_CODE_EXP_IPV4_PING_OF_DEATH",
1031 "PPE_CPU_CODE_EXP_SNALL_TTL",
1032 "PPE_CPU_CODE_EXP_IPV4_UNK_IP_PROT",
1033 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1034 "PPE_CPU_CODE_EXP_INV_SIP",
1035 "PPE_CPU_CODE_EXP_INV_DIP",
1036 "PPE_CPU_CODE_EXP_LAND_ATTACK",
1037 "PPE_CPU_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",
1038 "PPE_CPU_CODE_EXP_IPV4_AH_CROSS_BORDER",
1039 "PPE_CPU_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",
1040 "PPE_CPU_CODE_EXP_WRONG_VER",
1041 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1042 "PPE_CPU_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",
1043 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1044 "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR",
1045 "PPE_CPU_CODE_EXP_IPV6_SMALL_HOP_LIMIT",
1046 "PPE_CPU_CODE_EXP_INV_SIP",
1047 "PPE_CPU_CODE_EXP_INV_DIP",
1048 "PPE_CPU_CODE_EXP_LAND_ATTACK",
1049 "PPE_CPU_CODE_IPV6_FRAG",
1050 "PPE_CPU_CODE_EXP_IPV6_PING_OF_DEATH",
1051 "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR",
1052 "PPE_CPU_CODE_EXP_IPV6_UNK_NEXT_HDR",
1053 "PPE_CPU_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",
1054 "PPE_CPU_CODE_EXP_IPV6_MOBILITY_CROSS_BORDER",
1055 "PPE_CPU_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",
1056 "PPE_CPU_CODE_EXP_IPV6_AH_CROSS_BORDER",
1057 "PPE_CPU_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",
1058 "PPE_CPU_CODE_EXP_IPV6_ESP_CROSS_BORDER",
1059 "PPE_CPU_CODE_EXP_IPV6_OTHER_HDR_INCOMPLETE",
1060 "PPE_CPU_CODE_EXP_IPV6_OTHER_EXT_CROSS_BORDER",
1061 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1062 "PPE_CPU_CODE_EXP_TCP_HDR_CROSS_BORDER",
1063 "PPE_CPU_CODE_EXP_TCP_SMAE_SP_DP",
1064 "PPE_CPU_CODE_EXP_TCP_SMALL_DATA_OFFSET",
1065 "PPE_CPU_CODE_EXP_FLAGS_0",
1066 "PPE_CPU_CODE_EXP_FLAGS_1",
1067 "PPE_CPU_CODE_EXP_FLAGS_2",
1068 "PPE_CPU_CODE_EXP_FLAGS_3",
1069 "PPE_CPU_CODE_EXP_FLAGS_4",
1070 "PPE_CPU_CODE_EXP_FLAGS_5",
1071 "PPE_CPU_CODE_EXP_FLAGS_6",
1072 "PPE_CPU_CODE_EXP_FLAGS_7",
1073 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1074 "PPE_CPU_CODE_EXP_HDR_INCOMPLETE",
1075 "PPE_CPU_CODE_EXP_UDP_HDR_CROSS_BORDER",
1076 "PPE_CPU_CODE_EXP_UDP_SMAE_SP_DP",
1077 "PPE_CPU_CODE_EXP_BAD_LEN",
1078 "PPE_CPU_CODE_EXP_DATA_INCOMPLETE",
1079 "PPE_CPU_CODE_EXP_CHECKSUM_ERR",
1080 "PPE_CPU_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",
1081 "PPE_CPU_CODE_EXP_UDP_LITE_CROSS_BORDER",
1082 "PPE_CPU_CODE_EXP_UDP_LITE_SP_DP",
1083 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_COV_TO_7",
1084 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_TOO_LONG",
1085 "PPE_CPU_CODE_EXP_UDP_LITE_CSM_CROSS_BORDER",
1086 "PPE_CPU_CODE_EXP_UDP_LITE_CHECKSUM_ERR",
1087 "PPE_CPU_CODE_EXP_FAKE_L2_PROT_ERR",
1088 "PPE_CPU_CODE_EXP_FAKE_MAC_HEADER_ERR",
1089 "PPE_CPU_CODE_BITMAP_MAX",
1090 "PPE_CPU_CODE_L2_MRU_FAIL",
1091 "PPE_CPU_CODE_L2_MTU_FAIL",
1092 "PPE_CPU_CODE_L3_EXP_IP_PREFIX_BC",
1093 "PPE_CPU_CODE_L3_MTU_FAIL",
1094 "PPE_CPU_CODE_L3_MRU_FAIL",
1095 "PPE_CPU_CODE_L3_ICMP_RDT",
1096 "PPE_CPU_CODE_L3_EXP_IP_RT_TO_ME",
1097 "PPE_CPU_CODE_L3_EXP_IP_TTL_ZERO",
1098 "PPE_CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP",
1099 "PPE_CPU_CODE_L3_DE_ACCELERATE",
1100 "PPE_CPU_CODE_L3_EXP_FLOW_SRC_CHK_FAIL",
1101 "PPE_CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",
1102 "PPE_CPU_CODE_L3_EXP_MTU_DF_FAIL",
1103 "PPE_CPU_CODE_L3_PPPOE_MULTICAST",
1104 "PPE_CPU_CODE_MGMT_OFFSET",
1105 "PPE_CPU_CODE_MGMT_EAPOL",
1106 "PPE_CPU_CODE_PPPOE_DIS",
1107 "PPE_CPU_CODE_MGMT_IGMP",
1108 "PPE_CPU_CODE_ARP_REQ",
1109 "PPE_CPU_CODE_ARP_REP",
1110 "PPE_CPU_CODE_MGMT_DHCPv4",
1111 "PPE_CPU_CODE_MGMT_MLD",
1112 "PPE_CPU_CODE_MGMT_NS",
1113 "PPE_CPU_CODE_MGMT_NA",
1114 "PPE_CPU_CODE_MGMT_DHCPv6",
1115 "PPE_CPU_CODE_PTP_OFFSET",
1116 "PPE_CPU_CODE_PTP_SYNC",
1117 "PPE_CPU_CODE_FOLLOW_UP",
1118 "PPE_CPU_CODE_DELAY_REQ",
1119 "PPE_CPU_CODE_DELAY_RESP",
1120 "PPE_CPU_CODE_PDELAY_REQ",
1121 "PPE_CPU_CODE_PDELAY_RESP",
1122 "PPE_CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP",
1123 "PPE_CPU_CODE_PTP_ANNOUNCE",
1124 "PPE_CPU_CODE_PTP_MANAGEMENT",
1125 "PPE_CPU_CODE_PTP_SIGNALING",
1126 "PPE_CPU_CODE_PTP_RSV_MSG",
1127 "PPE_CPU_CODE_SG_UNKNOWN",
1128 "PPE_CPU_CODE_SG_UNKNOWN",
1129 "PPE_CPU_CODE_SG_UNKNOWN",
1130 "PPE_CPU_CODE_SG_UNKNOWN",
1131 "PPE_CPU_CODE_SG_VIO",
1132 "PPE_CPU_CODE_SG_VIO",
1133 "PPE_CPU_CODE_SG_VIO",
1134 "PPE_CPU_CODE_SG_VIO",
1135 "PPE_CPU_CODE_L3_ROUTING_IP_TO_ME",
1136 "PPE_CPU_CODE_L3_SNAT_ACTION",
1137 "PPE_CPU_CODE_L3_DNAT_ACTION",
1138 "PPE_CPU_CODE_L3_RT_ACTION",
1139 "PPE_CPU_CODE_L3_BR_ACTION",
1140 "PPE_CPU_CODE_L3_BRIDGE_ACTION",
1141 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION",
1142 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION",
1143 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION",
1144 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION",
1145 "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION",
1146 "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ACTION",
1147 "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ERROR",
1148 "PPE_CPU_CODE_ROUTE_ACTION",
1149 "PPE_CPU_CODE_L3_ROUTE_ACTION",
1150 "PPE_CPU_CODE_L3_NO_ROUTE_INVALID_ACTION",
1151 "PPE_CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION",
1152 "PPE_CPU_CODE_BRIDGE_ACTION",
1153 "PPE_CPU_CODE_FLOW_ACTION",
1154 "PPE_CPU_CODE_L3_MISS_ACTION",
1155 "PPE_CPU_CODE_L2_MAC_ADDRESS",
1156 "PPE_CPU_CODE_HASH_COLLISION",
1157 "PPE_CPU_CODE_STATION_MOVE",
1158 "PPE_CPU_CODE_LEARN_LIMIT",
1159 "PPE_CPU_CODE_L2_LOOKUP_ACTION",
1160 "PPE_CPU_CODE_L2_LOOKUP_ACTION",
1161 "PPE_CPU_CODE_CTRL_ACTION",
1162 "PPE_CPU_CODE_IN_FILTER_ACTION",
1163 "PPE_CPU_CODE_IN_XLT_MISS",
1164 "PPE_CPU_CODE_EG_FILTER_DROP",
1165 "PPE_CPU_CODE_PRE_ACTION",
1166 "PPE_CPU_CODE_POST_ACTION",
1167 "PPE_CPU_CODE_CODE_ACTION",
1168};
1169
1170/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05301171 * nss_stats_str_ppt_session_stats
1172 * PPTP statistics strings for nss session stats
1173 */
1174static int8_t *nss_stats_str_pptp_session_debug_stats[NSS_STATS_PPTP_SESSION_MAX] = {
Shyam Sundere351f1b2015-12-17 14:11:51 +05301175 "ENCAP_RX_PACKETS",
1176 "ENCAP_RX_BYTES",
1177 "ENCAP_TX_PACKETS",
1178 "ENCAP_TX_BYTES",
1179 "ENCAP_RX_DROP",
1180 "DECAP_RX_PACKETS",
1181 "DECAP_RX_BYTES",
1182 "DECAP_TX_PACKETS",
1183 "DECAP_TX_BYTES",
1184 "DECAP_RX_DROP",
1185 "ENCAP_HEADROOM_ERR",
1186 "ENCAP_SMALL_SIZE",
1187 "ENCAP_PNODE_ENQUEUE_FAIL",
1188 "DECAP_NO_SEQ_NOR_ACK",
1189 "DECAP_INVAL_GRE_FLAGS",
1190 "DECAP_INVAL_GRE_PROTO",
1191 "DECAP_WRONG_SEQ",
1192 "DECAP_INVAL_PPP_HDR",
1193 "DECAP_PPP_LCP",
1194 "DECAP_UNSUPPORTED_PPP_PROTO",
1195 "DECAP_PNODE_ENQUEUE_FAIL",
Shyam Sunder66e889d2015-11-02 15:31:20 +05301196};
1197
1198/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07001199 * nss_stats_str_trustsec_tx
1200 * Trustsec TX stats strings
1201 */
1202static int8_t *nss_stats_str_trustsec_tx[NSS_STATS_TRUSTSEC_TX_MAX] = {
1203 "INVALID_SRC",
1204 "UNCONFIGURED_SRC",
1205 "HEADROOM_NOT_ENOUGH",
1206};
1207
1208/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301209 * nss_stats_ipv4_read()
1210 * Read IPV4 stats
1211 */
1212static ssize_t nss_stats_ipv4_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1213{
1214 int32_t i;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301215 /*
1216 * max output lines = #stats + start tag line + end tag line + three blank lines
1217 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301218 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 +05301219 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1220 size_t size_wr = 0;
1221 ssize_t bytes_read = 0;
1222 uint64_t *stats_shadow;
1223
1224 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1225 if (unlikely(lbuf == NULL)) {
1226 nss_warning("Could not allocate memory for local statistics buffer");
1227 return 0;
1228 }
1229
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301230 /*
1231 * Note: The assumption here is that exception event count is larger than other statistics count for IPv4
1232 */
1233 stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV4_MAX * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301234 if (unlikely(stats_shadow == NULL)) {
1235 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301236 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301237 return 0;
1238 }
1239
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301240 size_wr = scnprintf(lbuf, size_al, "ipv4 stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301241
1242 /*
1243 * Common node stats
1244 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301245 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301246 spin_lock_bh(&nss_top_main.stats_lock);
1247 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1248 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_RX_INTERFACE][i];
1249 }
1250
1251 spin_unlock_bh(&nss_top_main.stats_lock);
1252
1253 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1254 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1255 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1256 }
1257
1258 /*
1259 * IPv4 node stats
1260 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301261 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301262
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301263 spin_lock_bh(&nss_top_main.stats_lock);
1264 for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) {
1265 stats_shadow[i] = nss_top_main.stats_ipv4[i];
1266 }
1267
1268 spin_unlock_bh(&nss_top_main.stats_lock);
1269
1270 for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) {
1271 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1272 "%s = %llu\n", nss_stats_str_ipv4[i], stats_shadow[i]);
1273 }
1274
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301275 /*
1276 * Exception stats
1277 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301278 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301279
1280 spin_lock_bh(&nss_top_main.stats_lock);
1281 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) {
1282 stats_shadow[i] = nss_top_main.stats_if_exception_ipv4[i];
1283 }
1284
1285 spin_unlock_bh(&nss_top_main.stats_lock);
1286
1287 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) {
1288 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1289 "%s = %llu\n", nss_stats_str_if_exception_ipv4[i], stats_shadow[i]);
1290 }
1291
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301292 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301293 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1294 kfree(lbuf);
1295 kfree(stats_shadow);
1296
1297 return bytes_read;
1298}
1299
1300/*
Selin Dag6d9b0c12014-11-04 18:27:21 -08001301 * nss_stats_ipv4_reasm_read()
1302 * Read IPV4 reassembly stats
1303 */
1304static ssize_t nss_stats_ipv4_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1305{
1306 int32_t i;
1307 /*
1308 * max output lines = #stats + start tag line + end tag line + three blank lines
1309 */
1310 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV4_REASM_MAX + 3) + 5;
1311 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1312 size_t size_wr = 0;
1313 ssize_t bytes_read = 0;
1314 uint64_t *stats_shadow;
1315
1316 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1317 if (unlikely(lbuf == NULL)) {
1318 nss_warning("Could not allocate memory for local statistics buffer");
1319 return 0;
1320 }
1321
1322 stats_shadow = kzalloc(NSS_STATS_IPV4_REASM_MAX * 8, GFP_KERNEL);
1323 if (unlikely(stats_shadow == NULL)) {
1324 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301325 kfree(lbuf);
Selin Dag6d9b0c12014-11-04 18:27:21 -08001326 return 0;
1327 }
1328
1329 size_wr = scnprintf(lbuf, size_al, "ipv4 reasm stats start:\n\n");
1330
1331 /*
1332 * Common node stats
1333 */
1334 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
1335 spin_lock_bh(&nss_top_main.stats_lock);
1336 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1337 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_REASM_INTERFACE][i];
1338 }
1339
1340 spin_unlock_bh(&nss_top_main.stats_lock);
1341
1342 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1343 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1344 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1345 }
1346
1347 /*
1348 * IPv4 reasm node stats
1349 */
1350 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm node stats:\n\n");
1351
1352 spin_lock_bh(&nss_top_main.stats_lock);
1353 for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) {
1354 stats_shadow[i] = nss_top_main.stats_ipv4_reasm[i];
1355 }
1356
1357 spin_unlock_bh(&nss_top_main.stats_lock);
1358
1359 for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) {
1360 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1361 "%s = %llu\n", nss_stats_str_ipv4_reasm[i], stats_shadow[i]);
1362 }
1363
1364 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm stats end\n\n");
1365 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1366 kfree(lbuf);
1367 kfree(stats_shadow);
1368
1369 return bytes_read;
1370}
1371
1372/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301373 * nss_stats_ipv6_read()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301374 * Read IPV6 stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301375 */
1376static ssize_t nss_stats_ipv6_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1377{
1378 int32_t i;
1379
1380 /*
1381 * max output lines = #stats + start tag line + end tag line + three blank lines
1382 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301383 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 +05301384 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1385 size_t size_wr = 0;
1386 ssize_t bytes_read = 0;
1387 uint64_t *stats_shadow;
1388
1389 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1390 if (unlikely(lbuf == NULL)) {
1391 nss_warning("Could not allocate memory for local statistics buffer");
1392 return 0;
1393 }
1394
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301395 /*
1396 * Note: The assumption here is that exception event count is larger than other statistics count for IPv4
1397 */
1398 stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV6_MAX * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301399 if (unlikely(stats_shadow == NULL)) {
1400 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05301401 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301402 return 0;
1403 }
1404
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301405 size_wr = scnprintf(lbuf, size_al, "ipv6 stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301406
1407 /*
1408 * Common node stats
1409 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301410 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301411 spin_lock_bh(&nss_top_main.stats_lock);
1412 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1413 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_RX_INTERFACE][i];
1414 }
1415
1416 spin_unlock_bh(&nss_top_main.stats_lock);
1417
1418 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1419 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1420 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1421 }
1422
1423 /*
1424 * IPv6 node stats
1425 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301426 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301427
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301428 spin_lock_bh(&nss_top_main.stats_lock);
1429 for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) {
1430 stats_shadow[i] = nss_top_main.stats_ipv6[i];
1431 }
1432
1433 spin_unlock_bh(&nss_top_main.stats_lock);
1434
1435 for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) {
1436 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1437 "%s = %llu\n", nss_stats_str_ipv6[i], stats_shadow[i]);
1438 }
1439
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301440 /*
1441 * Exception stats
1442 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05301443 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301444
1445 spin_lock_bh(&nss_top_main.stats_lock);
1446 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) {
1447 stats_shadow[i] = nss_top_main.stats_if_exception_ipv6[i];
1448 }
1449
1450 spin_unlock_bh(&nss_top_main.stats_lock);
1451
1452 for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) {
1453 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1454 "%s = %llu\n", nss_stats_str_if_exception_ipv6[i], stats_shadow[i]);
1455 }
1456
Aniruddha Paul1b170c22017-05-29 12:30:39 +05301457 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05301458 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1459 kfree(lbuf);
1460 kfree(stats_shadow);
1461
1462 return bytes_read;
1463}
1464
1465/*
Selin Dag60a2f5b2015-06-29 14:39:49 -07001466 * nss_stats_ipv6_reasm_read()
1467 * Read IPV6 reassembly stats
1468 */
1469static ssize_t nss_stats_ipv6_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1470{
1471 int32_t i;
1472 /*
1473 * max output lines = #stats + start tag line + end tag line + three blank lines
1474 */
1475 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV6_REASM_MAX + 3) + 5;
1476 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1477 size_t size_wr = 0;
1478 ssize_t bytes_read = 0;
1479 uint64_t *stats_shadow;
1480
1481 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1482 if (unlikely(lbuf == NULL)) {
1483 nss_warning("Could not allocate memory for local statistics buffer");
1484 return 0;
1485 }
1486
1487 stats_shadow = kzalloc(NSS_STATS_IPV6_REASM_MAX * 8, GFP_KERNEL);
1488 if (unlikely(stats_shadow == NULL)) {
1489 nss_warning("Could not allocate memory for local shadow buffer");
1490 kfree(lbuf);
1491 return 0;
1492 }
1493
1494 size_wr = scnprintf(lbuf, size_al, "ipv6 reasm stats start:\n\n");
1495
1496 /*
1497 * Common node stats
1498 */
1499 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
1500 spin_lock_bh(&nss_top_main.stats_lock);
1501 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1502 stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_REASM_INTERFACE][i];
1503 }
1504
1505 spin_unlock_bh(&nss_top_main.stats_lock);
1506
1507 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1508 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1509 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1510 }
1511
1512 /*
1513 * Ipv6 reasm node stats
1514 */
1515 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm node stats:\n\n");
1516
1517 spin_lock_bh(&nss_top_main.stats_lock);
1518 for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) {
1519 stats_shadow[i] = nss_top_main.stats_ipv6_reasm[i];
1520 }
1521
1522 spin_unlock_bh(&nss_top_main.stats_lock);
1523
1524 for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) {
1525 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1526 "%s = %llu\n", nss_stats_str_ipv6_reasm[i], stats_shadow[i]);
1527 }
1528
1529 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm stats end\n\n");
1530 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1531 kfree(lbuf);
1532 kfree(stats_shadow);
1533
1534 return bytes_read;
1535}
1536
1537/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07001538 * nss_stats_edma_port_stats_read()
1539 * Read EDMA port stats
1540 */
1541static ssize_t nss_stats_edma_port_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1542{
1543 int32_t i;
1544
1545 /*
1546 * max output lines = #stats + start tag line + end tag line + three blank lines
1547 */
1548 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + 3;
1549 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1550 size_t size_wr = 0;
1551 ssize_t bytes_read = 0;
1552 uint64_t *stats_shadow;
1553 struct nss_stats_data *data = fp->private_data;
1554
1555 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1556 if (unlikely(lbuf == NULL)) {
1557 nss_warning("Could not allocate memory for local statistics buffer");
1558 return 0;
1559 }
1560
1561 /*
1562 * Note: The assumption here is that we do not have more than 64 stats
1563 */
1564 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1565 if (unlikely(stats_shadow == NULL)) {
1566 nss_warning("Could not allocate memory for local shadow buffer");
1567 kfree(lbuf);
1568 return 0;
1569 }
1570
1571 size_wr = scnprintf(lbuf, size_al, "edma stats start:\n\n");
1572
1573 /*
1574 * Common node stats
1575 */
1576 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d stats:\n\n", data->edma_id);
1577 spin_lock_bh(&nss_top_main.stats_lock);
1578 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1579 stats_shadow[i] = nss_top_main.stats_edma.port[data->edma_id].port_stats[i];
1580 }
1581
1582 spin_unlock_bh(&nss_top_main.stats_lock);
1583
1584 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
1585 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1586 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
1587 }
1588
1589 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n\n");
1590 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1591 kfree(lbuf);
1592 kfree(stats_shadow);
1593
1594 return bytes_read;
1595}
1596
1597/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07001598 * nss_stats_edma_err_stats_read()
1599 * Read EDMA err stats
1600 */
1601static ssize_t nss_stats_edma_err_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1602{
1603 int32_t i;
1604
1605 /*
1606 * max output lines = #stats + start tag line + end tag line + three blank lines
1607 */
1608 uint32_t max_output_lines = (NSS_EDMA_ERR_STATS_MAX + 2) + 3;
1609 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1610 size_t size_wr = 0;
1611 ssize_t bytes_read = 0;
1612 uint64_t *stats_shadow;
1613
1614 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1615 if (unlikely(lbuf == NULL)) {
1616 nss_warning("Could not allocate memory for local statistics buffer");
1617 return 0;
1618 }
1619
1620 /*
1621 * Note: The assumption here is that we do not have more than 64 stats
1622 */
1623 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1624 if (unlikely(stats_shadow == NULL)) {
1625 nss_warning("Could not allocate memory for local shadow buffer");
1626 kfree(lbuf);
1627 return 0;
1628 }
1629
1630 size_wr = scnprintf(lbuf, size_al, "edma error stats start:\n\n");
1631
1632 /*
1633 * Common node stats
1634 */
1635 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma error stats:\n\n");
1636 spin_lock_bh(&nss_top_main.stats_lock);
1637
1638 for (i = 0; (i < NSS_EDMA_ERR_STATS_MAX); i++)
1639 stats_shadow[i] = nss_top_main.stats_edma.misc_err[i];
1640
1641 spin_unlock_bh(&nss_top_main.stats_lock);
1642
1643 for (i = 0; (i < NSS_EDMA_ERR_STATS_MAX); i++) {
1644 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1645 "%s = %llu\n", nss_stats_str_edma_err_map[i], stats_shadow[i]);
1646 }
1647
1648 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma error stats end\n\n");
1649 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1650 kfree(lbuf);
1651 kfree(stats_shadow);
1652
1653 return bytes_read;
1654}
1655
1656/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07001657 * nss_stats_edma_port_type_read()
1658 * Read EDMA port type
1659 */
1660static ssize_t nss_stats_edma_port_type_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1661{
Shashank Balashankar512cb602016-08-01 17:57:42 -07001662 /*
1663 * max output lines = #stats + start tag line + end tag line + three blank lines
1664 */
1665 uint32_t max_output_lines = (1 + 2) + 3;
1666 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1667 size_t size_wr = 0;
1668 ssize_t bytes_read = 0;
1669 uint64_t port_type;
1670 struct nss_stats_data *data = fp->private_data;
1671
1672 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1673 if (unlikely(lbuf == NULL)) {
1674 nss_warning("Could not allocate memory for local statistics buffer");
1675 return 0;
1676 }
1677
1678 size_wr = scnprintf(lbuf, size_al, "edma port type start:\n\n");
1679 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d type:\n\n", data->edma_id);
1680
1681 /*
1682 * Port type
1683 */
1684 spin_lock_bh(&nss_top_main.stats_lock);
1685 port_type = nss_top_main.stats_edma.port[data->edma_id].port_type;
1686 spin_unlock_bh(&nss_top_main.stats_lock);
1687
1688 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1689 "port_type = %s\n", nss_stats_str_edma_port_type[port_type]);
1690
1691 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n");
1692 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1693 kfree(lbuf);
1694
1695 return bytes_read;
1696}
1697
1698/*
1699 * nss_stats_edma_port_ring_map_read()
1700 * Read EDMA port ring map
1701 */
1702static ssize_t nss_stats_edma_port_ring_map_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1703{
1704 int32_t i;
1705
1706 /*
1707 * max output lines = #stats + start tag line + end tag line + three blank lines
1708 */
1709 uint32_t max_output_lines = (4 + 2) + 3;
1710 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1711 size_t size_wr = 0;
1712 ssize_t bytes_read = 0;
1713 uint64_t *stats_shadow;
1714 struct nss_stats_data *data = fp->private_data;
1715
1716 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1717 if (unlikely(lbuf == NULL)) {
1718 nss_warning("Could not allocate memory for local statistics buffer");
1719 return 0;
1720 }
1721
1722 /*
1723 * Note: The assumption here is that we do not have more than 64 stats
1724 */
1725 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1726 if (unlikely(stats_shadow == NULL)) {
1727 nss_warning("Could not allocate memory for local shadow buffer");
1728 kfree(lbuf);
1729 return 0;
1730 }
1731
1732 size_wr = scnprintf(lbuf, size_al, "edma port ring map start:\n\n");
1733
1734 /*
1735 * Port ring map
1736 */
1737 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d ring map:\n\n", data->edma_id);
1738 spin_lock_bh(&nss_top_main.stats_lock);
1739 for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) {
1740 stats_shadow[i] = nss_top_main.stats_edma.port[data->edma_id].port_ring_map[i];
1741 }
1742
1743 spin_unlock_bh(&nss_top_main.stats_lock);
1744
1745 for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) {
1746 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1747 "%s = %llu\n", nss_stats_str_edma_port_ring_map[i], stats_shadow[i]);
1748 }
1749
1750 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n\n");
1751 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1752 kfree(lbuf);
1753 kfree(stats_shadow);
1754
1755 return bytes_read;
1756}
1757
1758/*
1759 * nss_stats_edma_txring_read()
1760 * Read EDMA Tx ring stats
1761 */
1762static ssize_t nss_stats_edma_txring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1763{
1764 int32_t i;
1765
1766 /*
1767 * max output lines = #stats + start tag line + end tag line + three blank lines
1768 */
1769 uint32_t max_output_lines = (NSS_STATS_EDMA_TX_MAX + 2) + 3;
1770 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1771 size_t size_wr = 0;
1772 ssize_t bytes_read = 0;
1773 uint64_t *stats_shadow;
1774 struct nss_stats_data *data = fp->private_data;
1775
1776 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1777 if (unlikely(lbuf == NULL)) {
1778 nss_warning("Could not allocate memory for local statistics buffer");
1779 return 0;
1780 }
1781
1782 /*
1783 * Note: The assumption here is that we do not have more than 64 stats
1784 */
1785 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1786 if (unlikely(stats_shadow == NULL)) {
1787 nss_warning("Could not allocate memory for local shadow buffer");
1788 kfree(lbuf);
1789 return 0;
1790 }
1791
1792 size_wr = scnprintf(lbuf, size_al, "edma Tx ring stats start:\n\n");
1793
1794 /*
1795 * Tx ring stats
1796 */
1797 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx ring %d stats:\n\n", data->edma_id);
1798 spin_lock_bh(&nss_top_main.stats_lock);
1799 for (i = 0; i < NSS_STATS_EDMA_TX_MAX; i++) {
1800 stats_shadow[i] = nss_top_main.stats_edma.tx_stats[data->edma_id][i];
1801 }
1802
1803 spin_unlock_bh(&nss_top_main.stats_lock);
1804
1805 for (i = 0; i < NSS_STATS_EDMA_TX_MAX; i++) {
1806 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1807 "%s = %llu\n", nss_stats_str_edma_tx[i], stats_shadow[i]);
1808 }
1809
1810 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx ring stats end\n\n");
1811 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1812 kfree(lbuf);
1813 kfree(stats_shadow);
1814
1815 return bytes_read;
1816}
1817
1818/*
1819 * nss_stats_edma_rxring_read()
1820 * Read EDMA rxring stats
1821 */
1822static ssize_t nss_stats_edma_rxring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1823{
1824 int32_t i;
1825
1826 /*
1827 * max output lines = #stats + start tag line + end tag line + three blank lines
1828 */
1829 uint32_t max_output_lines = (NSS_STATS_EDMA_RX_MAX + 2) + 3;
1830 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1831 size_t size_wr = 0;
1832 ssize_t bytes_read = 0;
1833 uint64_t *stats_shadow;
1834 struct nss_stats_data *data = fp->private_data;
1835
1836 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1837 if (unlikely(lbuf == NULL)) {
1838 nss_warning("Could not allocate memory for local statistics buffer");
1839 return 0;
1840 }
1841
1842 /*
1843 * Note: The assumption here is that we do not have more than 64 stats
1844 */
1845 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1846 if (unlikely(stats_shadow == NULL)) {
1847 nss_warning("Could not allocate memory for local shadow buffer");
1848 kfree(lbuf);
1849 return 0;
1850 }
1851
1852 size_wr = scnprintf(lbuf, size_al, "edma Rx ring stats start:\n\n");
1853
1854 /*
1855 * RX ring stats
1856 */
1857 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx ring %d stats:\n\n", data->edma_id);
1858 spin_lock_bh(&nss_top_main.stats_lock);
1859 for (i = 0; i < NSS_STATS_EDMA_RX_MAX; i++) {
1860 stats_shadow[i] = nss_top_main.stats_edma.rx_stats[data->edma_id][i];
1861 }
1862
1863 spin_unlock_bh(&nss_top_main.stats_lock);
1864
1865 for (i = 0; i < NSS_STATS_EDMA_RX_MAX; i++) {
1866 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1867 "%s = %llu\n", nss_stats_str_edma_rx[i], stats_shadow[i]);
1868 }
1869
1870 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Rx ring stats end\n\n");
1871 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1872 kfree(lbuf);
1873 kfree(stats_shadow);
1874
1875 return bytes_read;
1876}
1877
1878/*
1879 * nss_stats_edma_txcmplring_read()
1880 * Read EDMA txcmplring stats
1881 */
1882static ssize_t nss_stats_edma_txcmplring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1883{
1884 int32_t i;
1885
1886 /*
1887 * max output lines = #stats + start tag line + end tag line + three blank lines
1888 */
1889 uint32_t max_output_lines = (NSS_STATS_EDMA_TXCMPL_MAX + 2) + 3;
1890 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1891 size_t size_wr = 0;
1892 ssize_t bytes_read = 0;
1893 uint64_t *stats_shadow;
1894 struct nss_stats_data *data = fp->private_data;
1895
1896 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1897 if (unlikely(lbuf == NULL)) {
1898 nss_warning("Could not allocate memory for local statistics buffer");
1899 return 0;
1900 }
1901
1902 /*
1903 * Note: The assumption here is that we do not have more than 64 stats
1904 */
1905 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1906 if (unlikely(stats_shadow == NULL)) {
1907 nss_warning("Could not allocate memory for local shadow buffer");
1908 kfree(lbuf);
1909 return 0;
1910 }
1911
1912 size_wr = scnprintf(lbuf, size_al, "edma Tx cmpl ring stats start:\n\n");
1913
1914 /*
1915 * Tx cmpl ring stats
1916 */
1917 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx cmpl ring %d stats:\n\n", data->edma_id);
1918 spin_lock_bh(&nss_top_main.stats_lock);
1919 for (i = 0; i < NSS_STATS_EDMA_TXCMPL_MAX; i++) {
1920 stats_shadow[i] = nss_top_main.stats_edma.txcmpl_stats[data->edma_id][i];
1921 }
1922
1923 spin_unlock_bh(&nss_top_main.stats_lock);
1924
1925 for (i = 0; i < NSS_STATS_EDMA_TXCMPL_MAX; i++) {
1926 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1927 "%s = %llu\n", nss_stats_str_edma_txcmpl[i], stats_shadow[i]);
1928 }
1929
1930 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx cmpl ring stats end\n\n");
1931 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1932 kfree(lbuf);
1933 kfree(stats_shadow);
1934
1935 return bytes_read;
1936}
1937
1938/*
1939 * nss_stats_edma_rxfillring_read()
1940 * Read EDMA rxfillring stats
1941 */
1942static ssize_t nss_stats_edma_rxfillring_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
1943{
1944 int32_t i;
1945
1946 /*
1947 * max output lines = #stats + start tag line + end tag line + three blank lines
1948 */
1949 uint32_t max_output_lines = (NSS_STATS_EDMA_RXFILL_MAX + 2) + 3;
1950 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
1951 size_t size_wr = 0;
1952 ssize_t bytes_read = 0;
1953 uint64_t *stats_shadow;
1954 struct nss_stats_data *data = fp->private_data;
1955
1956 char *lbuf = kzalloc(size_al, GFP_KERNEL);
1957 if (unlikely(lbuf == NULL)) {
1958 nss_warning("Could not allocate memory for local statistics buffer");
1959 return 0;
1960 }
1961
1962 /*
1963 * Note: The assumption here is that we do not have more than 64 stats
1964 */
1965 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
1966 if (unlikely(stats_shadow == NULL)) {
1967 nss_warning("Could not allocate memory for local shadow buffer");
1968 kfree(lbuf);
1969 return 0;
1970 }
1971
1972 size_wr = scnprintf(lbuf, size_al, "edma Rx fill ring stats start:\n\n");
1973
1974 /*
1975 * Rx fill ring stats
1976 */
1977 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx fill ring %d stats:\n\n", data->edma_id);
1978 spin_lock_bh(&nss_top_main.stats_lock);
1979 for (i = 0; i < NSS_STATS_EDMA_RXFILL_MAX; i++) {
1980 stats_shadow[i] = nss_top_main.stats_edma.rxfill_stats[data->edma_id][i];
1981 }
1982
1983 spin_unlock_bh(&nss_top_main.stats_lock);
1984
1985 for (i = 0; i < NSS_STATS_EDMA_RXFILL_MAX; i++) {
1986 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
1987 "%s = %llu\n", nss_stats_str_edma_rxfill[i], stats_shadow[i]);
1988 }
1989
1990 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Rx fill ring stats end\n\n");
1991 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
1992 kfree(lbuf);
1993 kfree(stats_shadow);
1994
1995 return bytes_read;
1996}
1997
1998/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301999 * nss_stats_eth_rx_read()
2000 * Read ETH_RX stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302001 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302002static 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 +05302003{
2004 int32_t i;
2005
2006 /*
2007 * max output lines = #stats + start tag line + end tag line + three blank lines
2008 */
Murat Sezgin99dab642014-08-28 14:40:34 -07002009 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 +05302010 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2011 size_t size_wr = 0;
2012 ssize_t bytes_read = 0;
2013 uint64_t *stats_shadow;
2014
2015 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2016 if (unlikely(lbuf == NULL)) {
2017 nss_warning("Could not allocate memory for local statistics buffer");
2018 return 0;
2019 }
2020
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302021 /*
2022 * Note: The assumption here is that we do not have more than 64 stats
2023 */
2024 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302025 if (unlikely(stats_shadow == NULL)) {
2026 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302027 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302028 return 0;
2029 }
2030
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302031 size_wr = scnprintf(lbuf, size_al, "eth_rx stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302032
2033 /*
2034 * Common node stats
2035 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302036 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302037 spin_lock_bh(&nss_top_main.stats_lock);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302038 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2039 stats_shadow[i] = nss_top_main.stats_node[NSS_ETH_RX_INTERFACE][i];
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302040 }
2041
2042 spin_unlock_bh(&nss_top_main.stats_lock);
2043
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302044 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302045 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302046 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302047 }
2048
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302049 /*
Murat Sezgin99dab642014-08-28 14:40:34 -07002050 * eth_rx node stats
2051 */
2052 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx node stats:\n\n");
2053 spin_lock_bh(&nss_top_main.stats_lock);
2054 for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) {
2055 stats_shadow[i] = nss_top_main.stats_eth_rx[i];
2056 }
2057
2058 spin_unlock_bh(&nss_top_main.stats_lock);
2059
2060 for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) {
2061 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2062 "%s = %llu\n", nss_stats_str_eth_rx[i], stats_shadow[i]);
2063 }
2064
2065 /*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302066 * Exception stats
2067 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302068 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx exception stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302069
2070 spin_lock_bh(&nss_top_main.stats_lock);
2071 for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) {
2072 stats_shadow[i] = nss_top_main.stats_if_exception_eth_rx[i];
2073 }
2074
2075 spin_unlock_bh(&nss_top_main.stats_lock);
2076
2077 for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) {
2078 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2079 "%s = %llu\n", nss_stats_str_if_exception_eth_rx[i], stats_shadow[i]);
2080 }
2081
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302082 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302083 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2084 kfree(lbuf);
2085 kfree(stats_shadow);
2086
2087 return bytes_read;
2088}
2089
2090/*
2091 * nss_stats_n2h_read()
2092 * Read N2H stats
2093 */
2094static ssize_t nss_stats_n2h_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2095{
2096 int32_t i;
2097
2098 /*
2099 * max output lines = #stats + start tag line + end tag line + three blank lines
2100 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302101 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_N2H_MAX + 3) + 5;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302102 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2103 size_t size_wr = 0;
2104 ssize_t bytes_read = 0;
2105 uint64_t *stats_shadow;
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002106 int max = NSS_STATS_N2H_MAX - NSS_STATS_NODE_MAX;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302107
2108 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2109 if (unlikely(lbuf == NULL)) {
2110 nss_warning("Could not allocate memory for local statistics buffer");
2111 return 0;
2112 }
2113
2114 stats_shadow = kzalloc(NSS_STATS_N2H_MAX * 8, GFP_KERNEL);
2115 if (unlikely(stats_shadow == NULL)) {
2116 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302117 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302118 return 0;
2119 }
2120
2121 size_wr = scnprintf(lbuf, size_al, "n2h stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302122
2123 /*
2124 * Common node stats
2125 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302126 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302127 spin_lock_bh(&nss_top_main.stats_lock);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302128 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2129 stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i];
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302130 }
2131
2132 spin_unlock_bh(&nss_top_main.stats_lock);
2133
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302134 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2135 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2136 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2137 }
2138
2139 /*
2140 * N2H node stats
2141 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302142 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302143 spin_lock_bh(&nss_top_main.stats_lock);
2144 for (i = NSS_STATS_NODE_MAX; (i < NSS_STATS_N2H_MAX); i++) {
2145 stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i];
2146 }
2147
2148 spin_unlock_bh(&nss_top_main.stats_lock);
2149
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002150 for (i = 0; i < max; i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302151 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
Murat Sezgin0c0561d2014-04-09 18:55:58 -07002152 "%s = %llu\n", nss_stats_str_n2h[i], stats_shadow[i + NSS_STATS_NODE_MAX]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302153 }
2154
2155 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h stats end\n\n");
2156 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2157 kfree(lbuf);
2158 kfree(stats_shadow);
2159
2160 return bytes_read;
2161}
2162
2163/*
Thomas Wuc3e382c2014-10-29 15:35:13 -07002164 * nss_stats_lso_rx_read()
2165 * Read LSO_RX stats
2166 */
2167static ssize_t nss_stats_lso_rx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2168{
2169 int32_t i;
2170
2171 /*
2172 * max output lines = #stats + start tag line + end tag line + three blank lines
2173 */
2174 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_LSO_RX_MAX + 3) + 5;
2175 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2176 size_t size_wr = 0;
2177 ssize_t bytes_read = 0;
2178 uint64_t *stats_shadow;
2179
2180 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2181 if (unlikely(lbuf == NULL)) {
2182 nss_warning("Could not allocate memory for local statistics buffer");
2183 return 0;
2184 }
2185
2186 stats_shadow = kzalloc(NSS_STATS_LSO_RX_MAX * 8, GFP_KERNEL);
2187 if (unlikely(stats_shadow == NULL)) {
2188 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302189 kfree(lbuf);
Thomas Wuc3e382c2014-10-29 15:35:13 -07002190 return 0;
2191 }
2192
2193 size_wr = scnprintf(lbuf, size_al, "lso_rx stats start:\n\n");
2194
2195 /*
2196 * Common node stats
2197 */
2198 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
2199 spin_lock_bh(&nss_top_main.stats_lock);
2200 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2201 stats_shadow[i] = nss_top_main.stats_node[NSS_LSO_RX_INTERFACE][i];
2202 }
2203
2204 spin_unlock_bh(&nss_top_main.stats_lock);
2205
2206 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2207 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2208 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2209 }
2210
2211 /*
2212 * lso_rx node stats
2213 */
2214 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx node stats:\n\n");
2215 spin_lock_bh(&nss_top_main.stats_lock);
2216 for (i = 0; (i < NSS_STATS_LSO_RX_MAX); i++) {
2217 stats_shadow[i] = nss_top_main.stats_lso_rx[i];
2218 }
2219
2220 spin_unlock_bh(&nss_top_main.stats_lock);
2221
2222 for (i = 0; i < NSS_STATS_LSO_RX_MAX; i++) {
2223 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2224 "%s = %llu\n", nss_stats_str_lso_rx[i], stats_shadow[i]);
2225 }
2226
2227 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx stats end\n\n");
2228 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2229 kfree(lbuf);
2230 kfree(stats_shadow);
2231
2232 return bytes_read;
2233}
2234
2235/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302236 * nss_stats_drv_read()
2237 * Read HLOS driver stats
2238 */
2239static ssize_t nss_stats_drv_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2240{
2241 int32_t i;
2242
2243 /*
2244 * max output lines = #stats + start tag line + end tag line + three blank lines
2245 */
2246 uint32_t max_output_lines = NSS_STATS_DRV_MAX + 5;
2247 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2248 size_t size_wr = 0;
2249 ssize_t bytes_read = 0;
2250 uint64_t *stats_shadow;
2251
2252 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2253 if (unlikely(lbuf == NULL)) {
2254 nss_warning("Could not allocate memory for local statistics buffer");
2255 return 0;
2256 }
2257
2258 stats_shadow = kzalloc(NSS_STATS_DRV_MAX * 8, GFP_KERNEL);
2259 if (unlikely(stats_shadow == NULL)) {
2260 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302261 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302262 return 0;
2263 }
2264
2265 size_wr = scnprintf(lbuf, size_al, "drv stats start:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302266 for (i = 0; (i < NSS_STATS_DRV_MAX); i++) {
Sundarajan Srinivasan62fee7e2015-01-22 11:13:10 -08002267 stats_shadow[i] = NSS_PKT_STATS_READ(&nss_top_main.stats_drv[i]);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302268 }
2269
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302270 for (i = 0; (i < NSS_STATS_DRV_MAX); i++) {
2271 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2272 "%s = %llu\n", nss_stats_str_drv[i], stats_shadow[i]);
2273 }
2274
2275 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ndrv stats end\n\n");
2276 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2277 kfree(lbuf);
2278 kfree(stats_shadow);
2279
2280 return bytes_read;
2281}
2282
2283/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302284 * nss_stats_pppoe_read()
2285 * Read PPPoE stats
2286 */
2287static ssize_t nss_stats_pppoe_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2288{
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302289 int32_t i, j, k;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302290
2291 /*
2292 * max output lines = #stats + start tag line + end tag line + three blank lines
2293 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302294 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_PPPOE_MAX + 3) +
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302295 ((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 +05302296 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2297 size_t size_wr = 0;
2298 ssize_t bytes_read = 0;
2299 uint64_t *stats_shadow;
2300
2301 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2302 if (unlikely(lbuf == NULL)) {
2303 nss_warning("Could not allocate memory for local statistics buffer");
2304 return 0;
2305 }
2306
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302307 stats_shadow = kzalloc(64 * 8, GFP_KERNEL);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302308 if (unlikely(stats_shadow == NULL)) {
2309 nss_warning("Could not allocate memory for local shadow buffer");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302310 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302311 return 0;
2312 }
2313
2314 size_wr = scnprintf(lbuf, size_al, "pppoe stats start:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302315
2316 /*
2317 * Common node stats
2318 */
Abhishek Rastogia1a07972014-04-01 19:43:33 +05302319 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302320 spin_lock_bh(&nss_top_main.stats_lock);
2321 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2322 stats_shadow[i] = nss_top_main.stats_node[NSS_PPPOE_RX_INTERFACE][i];
2323 }
2324
2325 spin_unlock_bh(&nss_top_main.stats_lock);
2326
2327 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
2328 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2329 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
2330 }
2331
2332 /*
2333 * PPPoE node stats
2334 */
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002335 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npppoe node stats:\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302336 spin_lock_bh(&nss_top_main.stats_lock);
2337 for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) {
2338 stats_shadow[i] = nss_top_main.stats_pppoe[i];
2339 }
2340
2341 spin_unlock_bh(&nss_top_main.stats_lock);
2342
2343 for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) {
2344 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2345 "%s = %llu\n", nss_stats_str_pppoe[i], stats_shadow[i]);
2346 }
2347
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302348 /*
2349 * Exception stats
2350 */
2351 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nException PPPoE:\n\n");
2352
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002353 for (j = 1; j <= NSS_MAX_PHYSICAL_INTERFACES; j++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302354 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nInterface %d:\n\n", j);
2355
2356 spin_lock_bh(&nss_top_main.stats_lock);
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002357 for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) {
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302358 for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) {
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002359 stats_shadow_pppoe_except[k - 1][i] = nss_top_main.stats_if_exception_pppoe[j][k][i];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302360 }
2361 }
2362
2363 spin_unlock_bh(&nss_top_main.stats_lock);
2364
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002365 for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302366 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. Session\n", k);
Ankit Dhanukaa1569ce2014-05-13 19:58:06 +05302367 for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) {
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302368 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2369 "%s = %llu\n",
2370 nss_stats_str_if_exception_pppoe[i],
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002371 stats_shadow_pppoe_except[k - 1][i]);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302372 }
2373 }
2374
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302375 }
2376
Murat Sezgin2f9241a2015-06-25 13:01:51 -07002377 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npppoe stats end\n\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302378 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2379 kfree(lbuf);
2380 kfree(stats_shadow);
2381
2382 return bytes_read;
2383}
2384
2385/*
2386 * nss_stats_gmac_read()
2387 * Read GMAC stats
2388 */
2389static ssize_t nss_stats_gmac_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2390{
2391 uint32_t i, id;
2392
2393 /*
2394 * max output lines = ((#stats + start tag + one blank) * #GMACs) + start/end tag + 3 blank
2395 */
2396 uint32_t max_output_lines = ((NSS_STATS_GMAC_MAX + 2) * NSS_MAX_PHYSICAL_INTERFACES) + 5;
2397 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2398 size_t size_wr = 0;
2399 ssize_t bytes_read = 0;
2400 uint64_t *stats_shadow;
2401
2402 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2403 if (unlikely(lbuf == NULL)) {
2404 nss_warning("Could not allocate memory for local statistics buffer");
2405 return 0;
2406 }
2407
2408 stats_shadow = kzalloc(NSS_STATS_GMAC_MAX * 8, GFP_KERNEL);
2409 if (unlikely(stats_shadow == NULL)) {
2410 nss_warning("Could not allocate memory for local shadow buffer");
Ankit Dhanuka14999992014-11-12 15:35:11 +05302411 kfree(lbuf);
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302412 return 0;
2413 }
2414
2415 size_wr = scnprintf(lbuf, size_al, "gmac stats start:\n\n");
2416
2417 for (id = 0; id < NSS_MAX_PHYSICAL_INTERFACES; id++) {
2418 spin_lock_bh(&nss_top_main.stats_lock);
2419 for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) {
2420 stats_shadow[i] = nss_top_main.stats_gmac[id][i];
2421 }
2422
2423 spin_unlock_bh(&nss_top_main.stats_lock);
2424
2425 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "GMAC ID: %d\n", id);
2426 for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) {
2427 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2428 "%s = %llu\n", nss_stats_str_gmac[i], stats_shadow[i]);
2429 }
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302430 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05302431 }
2432
2433 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngmac stats end\n\n");
2434 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2435 kfree(lbuf);
2436 kfree(stats_shadow);
2437
2438 return bytes_read;
2439}
2440
Saurabh Misra09dddeb2014-09-30 16:38:07 -07002441/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05302442 * nss_stats_wifi_read()
Stephen Wangaed46332016-12-12 17:29:03 -08002443 * Read wifi statistics
Bharath M Kumarcc666e92014-12-24 19:17:28 +05302444 */
2445static ssize_t nss_stats_wifi_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2446{
2447 uint32_t i, id;
2448
2449 /*
2450 * max output lines = ((#stats + start tag + one blank) * #WIFI RADIOs) + start/end tag + 3 blank
2451 */
2452 uint32_t max_output_lines = ((NSS_STATS_WIFI_MAX + 2) * NSS_MAX_WIFI_RADIO_INTERFACES) + 5;
2453 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2454 size_t size_wr = 0;
2455 ssize_t bytes_read = 0;
2456 uint64_t *stats_shadow;
2457
2458 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2459 if (unlikely(lbuf == NULL)) {
2460 nss_warning("Could not allocate memory for local statistics buffer");
2461 return 0;
2462 }
2463
2464 stats_shadow = kzalloc(NSS_STATS_WIFI_MAX * 8, GFP_KERNEL);
2465 if (unlikely(stats_shadow == NULL)) {
2466 nss_warning("Could not allocate memory for local shadow buffer");
2467 kfree(lbuf);
2468 return 0;
2469 }
2470
2471 size_wr = scnprintf(lbuf, size_al, "wifi stats start:\n\n");
2472
2473 for (id = 0; id < NSS_MAX_WIFI_RADIO_INTERFACES; id++) {
2474 spin_lock_bh(&nss_top_main.stats_lock);
2475 for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) {
2476 stats_shadow[i] = nss_top_main.stats_wifi[id][i];
2477 }
2478
2479 spin_unlock_bh(&nss_top_main.stats_lock);
2480
2481 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFI ID: %d\n", id);
2482 for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) {
2483 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2484 "%s = %llu\n", nss_stats_str_wifi[i], stats_shadow[i]);
2485 }
2486 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,"\n");
2487 }
2488
2489 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifi stats end\n\n");
2490 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2491 kfree(lbuf);
2492 kfree(stats_shadow);
2493
2494 return bytes_read;
2495}
2496
2497/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +05302498 * nss_stats_wifili_read()
2499 * Read wifili statistics
2500 */
2501static ssize_t nss_stats_wifili_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2502{
2503 uint32_t i, j;
2504
2505 /*
2506 * max output lines = ((#stats + eight blank lines) * #WIFILI #STATS) + start/end tag + 3 blank
2507 */
2508 uint32_t max_output_lines = (((NSS_STATS_WIFILI_MAX + 9) * NSS_WIFILI_MAX_PDEV_NUM_MSG)+
2509 NSS_STATS_WIFILI_WBM_MAX + 5);
2510 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2511 size_t size_wr = 0;
2512 ssize_t bytes_read = 0;
2513 uint64_t *stats_shadow;
2514
2515 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2516 if (unlikely(lbuf == NULL)) {
2517 nss_warning("Could not allocate memory for local statistics buffer");
2518 return 0;
2519 }
2520
2521 /*
2522 * Take max of all wifili stats
2523 *
2524 * NOTE: txrx stats is bigger of all stats
2525 */
2526 stats_shadow = kzalloc(NSS_STATS_WIFILI_TXRX_MAX * 8, GFP_KERNEL);
2527 if (unlikely(stats_shadow == NULL)) {
2528 nss_warning("Could not allocate memory for local shadow buffer");
2529 kfree(lbuf);
2530 return 0;
2531 }
2532
2533 size_wr = scnprintf(lbuf, size_al, "wifili stats start:\n\n");
2534
2535 for (i = 0; i < NSS_WIFILI_MAX_PDEV_NUM_MSG; i++) {
2536
2537 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFILI ID: %d\n", i);
2538
2539 spin_lock_bh(&nss_top_main.stats_lock);
2540 for (j = 0; (j < NSS_STATS_WIFILI_TXRX_MAX); j++) {
2541 stats_shadow[j] = nss_top_main.stats_wifili.stats_txrx[i][j];
2542 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2543 "%s = %llu\n", nss_stats_str_wifili_txrx[j], stats_shadow[j]);
2544 }
2545
2546 spin_unlock_bh(&nss_top_main.stats_lock);
2547 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2548
2549 /*
2550 * Fillinng TCL ring stats
2551 */
2552 spin_lock_bh(&nss_top_main.stats_lock);
2553 for (j = 0; (j < NSS_STATS_WIFILI_TCL_MAX); j++) {
2554 stats_shadow[j] = nss_top_main.stats_wifili.stats_tcl_ring[i][j];
2555 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2556 "%s = %llu\n", nss_stats_str_wifili_tcl[j], stats_shadow[j]);
2557 }
2558
2559 spin_unlock_bh(&nss_top_main.stats_lock);
2560 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2561
2562 /*
2563 * Fillinng TCL comp stats
2564 */
2565 spin_lock_bh(&nss_top_main.stats_lock);
2566 for (j = 0; (j < NSS_STATS_WIFILI_TX_DESC_FREE_MAX); j++) {
2567 stats_shadow[j] = nss_top_main.stats_wifili.stats_tx_comp[i][j];
2568 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2569 "%s = %llu\n", nss_stats_str_wifili_tx_comp[j], stats_shadow[j]);
2570 }
2571
2572 spin_unlock_bh(&nss_top_main.stats_lock);
2573 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2574
2575 /*
2576 * Fillinng reo ring stats
2577 */
2578 spin_lock_bh(&nss_top_main.stats_lock);
2579 for (j = 0; (j < NSS_STATS_WIFILI_REO_MAX); j++) {
2580 stats_shadow[j] = nss_top_main.stats_wifili.stats_reo[i][j];
2581 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2582 "%s = %llu\n", nss_stats_str_wifili_reo[j], stats_shadow[j]);
2583 }
2584
2585 spin_unlock_bh(&nss_top_main.stats_lock);
2586 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2587
2588 /*
2589 * Fillinng TX SW Pool
2590 */
2591 spin_lock_bh(&nss_top_main.stats_lock);
2592 for (j = 0; (j < NSS_STATS_WIFILI_TX_DESC_MAX); j++) {
2593 stats_shadow[j] = nss_top_main.stats_wifili.stats_tx_desc[i][j];
2594 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2595 "%s = %llu\n", nss_stats_str_wifili_txsw_pool[j], stats_shadow[j]);
2596 }
2597
2598 spin_unlock_bh(&nss_top_main.stats_lock);
2599 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2600
2601 /*
2602 * Fillinng TX EXt SW Pool
2603 */
2604 spin_lock_bh(&nss_top_main.stats_lock);
2605 for (j = 0; (j < NSS_STATS_WIFILI_EXT_TX_DESC_MAX); j++) {
2606 stats_shadow[j] = nss_top_main.stats_wifili.stats_ext_tx_desc[i][j];
2607 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2608 "%s = %llu\n", nss_stats_str_wifili_ext_txsw_pool[j], stats_shadow[j]);
2609 }
2610
2611 spin_unlock_bh(&nss_top_main.stats_lock);
2612 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2613
2614 /*
2615 * Fillinng rxdma pool stats
2616 */
2617 spin_lock_bh(&nss_top_main.stats_lock);
2618 for (j = 0; (j < NSS_STATS_WIFILI_RX_DESC_MAX); j++) {
2619 stats_shadow[j] = nss_top_main.stats_wifili.stats_rx_desc[i][j];
2620 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2621 "%s = %llu\n", nss_stats_str_wifili_rxdma_pool[j], stats_shadow[j]);
2622 }
2623
2624 spin_unlock_bh(&nss_top_main.stats_lock);
2625 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2626
2627 /*
2628 * Fillinng rxdma ring stats
2629 */
2630 spin_lock_bh(&nss_top_main.stats_lock);
2631 for (j = 0; (j < NSS_STATS_WIFILI_RXDMA_DESC_MAX); j++) {
2632 stats_shadow[j] = nss_top_main.stats_wifili.stats_rxdma[i][j];
2633 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2634 "%s = %llu\n", nss_stats_str_wifili_rxdma_ring[j], stats_shadow[j]);
2635 }
2636
2637 spin_unlock_bh(&nss_top_main.stats_lock);
2638 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2639
2640 }
2641
2642 /*
2643 * Fillinng wbm ring stats
2644 */
2645 spin_lock_bh(&nss_top_main.stats_lock);
2646 for (j = 0; (j < NSS_STATS_WIFILI_WBM_MAX); j++) {
2647 stats_shadow[j] = nss_top_main.stats_wifili.stats_wbm[j];
2648 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2649 "%s = %llu\n", nss_stats_str_wifili_wbm[j], stats_shadow[j]);
2650 }
2651
2652 spin_unlock_bh(&nss_top_main.stats_lock);
2653 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifili stats end\n\n");
2654
2655 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
2656 kfree(lbuf);
2657 kfree(stats_shadow);
2658
2659 return bytes_read;
2660}
2661
2662/*
Tushar Mathurff8741b2015-12-02 20:28:59 +05302663 * nss_stats_dtls_read()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07002664 * Read DTLS session statistics
Tushar Mathurff8741b2015-12-02 20:28:59 +05302665 */
2666static ssize_t nss_stats_dtls_read(struct file *fp, char __user *ubuf,
2667 size_t sz, loff_t *ppos)
2668{
2669 uint32_t max_output_lines = 2 + (NSS_MAX_DTLS_SESSIONS
2670 * (NSS_STATS_DTLS_SESSION_MAX + 2)) + 2;
2671 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2672 size_t size_wr = 0;
2673 ssize_t bytes_read = 0;
2674 struct net_device *dev;
2675 int id, i;
2676 struct nss_stats_dtls_session_debug *dtls_session_stats = NULL;
2677
2678 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2679 if (unlikely(lbuf == NULL)) {
2680 nss_warning("Could not allocate memory for local statistics buffer");
2681 return 0;
2682 }
2683
2684 dtls_session_stats = kzalloc((sizeof(struct nss_stats_dtls_session_debug)
2685 * NSS_MAX_DTLS_SESSIONS), GFP_KERNEL);
2686 if (unlikely(dtls_session_stats == NULL)) {
2687 nss_warning("Could not allocate memory for populating DTLS stats");
2688 kfree(lbuf);
2689 return 0;
2690 }
2691
2692 /*
2693 * Get all stats
2694 */
2695 nss_dtls_session_debug_stats_get(dtls_session_stats);
2696
2697 /*
2698 * Session stats
2699 */
2700 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2701 "\nDTLS session stats start:\n\n");
2702
2703 for (id = 0; id < NSS_MAX_DTLS_SESSIONS; id++) {
2704 if (!dtls_session_stats[id].valid)
2705 break;
2706
2707 dev = dev_get_by_index(&init_net, dtls_session_stats[id].if_index);
2708 if (likely(dev)) {
2709 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2710 "%d. nss interface id=%d, netdevice=%s\n",
2711 id, dtls_session_stats[id].if_num,
2712 dev->name);
2713 dev_put(dev);
2714 } else {
2715 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2716 "%d. nss interface id=%d\n", id,
2717 dtls_session_stats[id].if_num);
2718 }
2719
2720 for (i = 0; i < NSS_STATS_DTLS_SESSION_MAX; i++) {
2721 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2722 "\t%s = %llu\n",
2723 nss_stats_str_dtls_session_debug_stats[i],
2724 dtls_session_stats[id].stats[i]);
2725 }
2726
2727 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2728 }
2729
2730 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2731 "\nDTLS session stats end\n");
2732 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2733
2734 kfree(dtls_session_stats);
2735 kfree(lbuf);
2736 return bytes_read;
2737}
2738
Tushar Mathurff8741b2015-12-02 20:28:59 +05302739/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07002740 * nss_stats_gre_tunnel_read()
2741 * Read GRE Tunnel session statistics
2742 */
2743static ssize_t nss_stats_gre_tunnel_read(struct file *fp, char __user *ubuf,
2744 size_t sz, loff_t *ppos)
2745{
2746 uint32_t max_output_lines = 2 + (NSS_MAX_GRE_TUNNEL_SESSIONS
2747 * (NSS_STATS_GRE_TUNNEL_SESSION_MAX + 2)) + 2;
2748 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2749 size_t size_wr = 0;
2750 ssize_t bytes_read = 0;
2751 struct net_device *dev;
2752 int id, i;
2753 struct nss_stats_gre_tunnel_session_debug *gre_tunnel_session_stats = NULL;
2754
2755 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2756 if (unlikely(lbuf == NULL)) {
2757 nss_warning("Could not allocate memory for local statistics buffer");
2758 return 0;
2759 }
2760
2761 gre_tunnel_session_stats = kzalloc((sizeof(struct nss_stats_gre_tunnel_session_debug)
2762 * NSS_MAX_GRE_TUNNEL_SESSIONS), GFP_KERNEL);
2763 if (unlikely(gre_tunnel_session_stats == NULL)) {
2764 nss_warning("Could not allocate memory for populating GRE Tunnel stats");
2765 kfree(lbuf);
2766 return 0;
2767 }
2768
2769 /*
2770 * Get all stats
2771 */
2772 nss_gre_tunnel_session_debug_stats_get(gre_tunnel_session_stats);
2773
2774 /*
2775 * Session stats
2776 */
2777 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2778 "\nGRE Tunnel session stats start:\n\n");
2779
2780 for (id = 0; id < NSS_MAX_GRE_TUNNEL_SESSIONS; id++) {
2781 if (!gre_tunnel_session_stats[id].valid)
2782 break;
2783
2784 dev = dev_get_by_index(&init_net, gre_tunnel_session_stats[id].if_index);
2785 if (likely(dev)) {
2786 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2787 "%d. nss interface id=%d, netdevice=%s\n",
2788 id, gre_tunnel_session_stats[id].if_num,
2789 dev->name);
2790 dev_put(dev);
2791 } else {
2792 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2793 "%d. nss interface id=%d\n", id,
2794 gre_tunnel_session_stats[id].if_num);
2795 }
2796
2797 for (i = 0; i < NSS_STATS_GRE_TUNNEL_SESSION_MAX; i++) {
2798 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2799 "\t%s = %llu\n",
2800 nss_stats_str_gre_tunnel_session_debug_stats[i],
2801 gre_tunnel_session_stats[id].stats[i]);
2802 }
2803
2804 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2805 }
2806
2807 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2808 "\nGRE Tunnel session stats end\n");
2809 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2810
2811 kfree(gre_tunnel_session_stats);
2812 kfree(lbuf);
2813 return bytes_read;
2814}
2815
2816/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +05302817 * nss_stats_l2tpv2_read()
2818 * Read l2tpv2 statistics
2819 */
2820static ssize_t nss_stats_l2tpv2_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2821{
2822
2823 uint32_t max_output_lines = 2 /* header & footer for session stats */
2824 + NSS_MAX_L2TPV2_DYNAMIC_INTERFACES * (NSS_STATS_L2TPV2_SESSION_MAX + 2) /*session stats */
2825 + 2;
2826 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ;
2827 size_t size_wr = 0;
2828 ssize_t bytes_read = 0;
2829 struct net_device *dev;
2830 struct nss_stats_l2tpv2_session_debug l2tpv2_session_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES];
2831 int id, i;
2832
2833 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2834 if (unlikely(lbuf == NULL)) {
2835 nss_warning("Could not allocate memory for local statistics buffer");
2836 return 0;
2837 }
2838
2839 memset(&l2tpv2_session_stats, 0, sizeof(struct nss_stats_l2tpv2_session_debug) * NSS_MAX_L2TPV2_DYNAMIC_INTERFACES);
2840
2841 /*
2842 * Get all stats
2843 */
2844 nss_l2tpv2_session_debug_stats_get((void *)&l2tpv2_session_stats);
2845
2846 /*
2847 * Session stats
2848 */
2849 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats start:\n\n");
2850 for (id = 0; id < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; id++) {
2851
2852 if (!l2tpv2_session_stats[id].valid) {
2853 break;
2854 }
2855
2856 dev = dev_get_by_index(&init_net, l2tpv2_session_stats[id].if_index);
2857 if (likely(dev)) {
2858
2859 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
2860 l2tpv2_session_stats[id].if_num, dev->name);
2861 dev_put(dev);
2862 } else {
2863 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
2864 l2tpv2_session_stats[id].if_num);
2865 }
2866
2867 for (i = 0; i < NSS_STATS_L2TPV2_SESSION_MAX; i++) {
2868 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2869 "\t%s = %llu\n", nss_stats_str_l2tpv2_session_debug_stats[i],
2870 l2tpv2_session_stats[id].stats[i]);
2871 }
2872 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2873 }
2874
2875 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats end\n");
2876 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2877
2878 kfree(lbuf);
2879 return bytes_read;
2880}
2881
2882/*
ratheesh kannotha1245c32015-11-04 16:45:43 +05302883 * nss_stats_map_t_read()
2884 * Read map_t statistics
2885 */
2886static ssize_t nss_stats_map_t_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2887{
2888
2889 uint32_t max_output_lines = 2 /* header & footer for instance stats */
2890 + NSS_MAX_MAP_T_DYNAMIC_INTERFACES * (NSS_STATS_MAP_T_MAX + 2) /*instance stats */
2891 + 2;
2892 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2893 size_t size_wr = 0;
2894 ssize_t bytes_read = 0;
2895 struct net_device *dev;
2896 struct nss_stats_map_t_instance_debug map_t_instance_stats[NSS_MAX_MAP_T_DYNAMIC_INTERFACES];
2897 int id, i;
2898
2899 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2900 if (unlikely(!lbuf)) {
2901 nss_warning("Could not allocate memory for local statistics buffer");
2902 return 0;
2903 }
2904
2905 memset(&map_t_instance_stats, 0, sizeof(struct nss_stats_map_t_instance_debug) * NSS_MAX_MAP_T_DYNAMIC_INTERFACES);
2906
2907 /*
2908 * Get all stats
2909 */
2910 nss_map_t_instance_debug_stats_get((void *)&map_t_instance_stats);
2911
2912 /*
2913 * Session stats
2914 */
2915 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats start:\n\n");
2916 for (id = 0; id < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; id++) {
2917
2918 if (!map_t_instance_stats[id].valid) {
2919 break;
2920 }
2921
2922 dev = dev_get_by_index(&init_net, map_t_instance_stats[id].if_index);
2923 if (likely(dev)) {
2924
2925 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
2926 map_t_instance_stats[id].if_num, dev->name);
2927 dev_put(dev);
2928 } else {
2929 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
2930 map_t_instance_stats[id].if_num);
2931 }
2932
2933 for (i = 0; i < NSS_STATS_MAP_T_MAX; i++) {
2934 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2935 "\t%s = %llu\n", nss_stats_str_map_t_instance_debug_stats[i],
2936 map_t_instance_stats[id].stats[i]);
2937 }
2938 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
2939 }
2940
2941 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats end\n");
2942 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
2943
2944 kfree(lbuf);
2945 return bytes_read;
2946}
2947
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05302948 /*
2949 * nss_stats_gre_read()
2950 * Read GRE statistics
2951 */
2952static ssize_t nss_stats_gre_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
2953{
2954 uint32_t max_output_lines = 2 /* header & footer for base debug stats */
2955 + 2 /* header & footer for session debug stats */
2956 + NSS_STATS_GRE_BASE_DEBUG_MAX /* Base debug */
2957 + NSS_GRE_MAX_DEBUG_SESSION_STATS * (NSS_STATS_GRE_SESSION_DEBUG_MAX + 2) /*session stats */
2958 + 2;
2959 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
2960 size_t size_wr = 0;
2961 ssize_t bytes_read = 0;
2962 struct net_device *dev;
2963 struct nss_stats_gre_session_debug *sstats;
2964 struct nss_stats_gre_base_debug *bstats;
2965 int id, i;
2966
2967 char *lbuf = kzalloc(size_al, GFP_KERNEL);
2968 if (unlikely(!lbuf)) {
2969 nss_warning("Could not allocate memory for local statistics buffer");
2970 return 0;
2971 }
2972
2973 bstats = kzalloc(sizeof(struct nss_stats_gre_base_debug), GFP_KERNEL);
2974 if (unlikely(!bstats)) {
2975 nss_warning("Could not allocate memory for base debug statistics buffer");
2976 kfree(lbuf);
2977 return 0;
2978 }
2979
2980 sstats = kzalloc(sizeof(struct nss_stats_gre_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS, GFP_KERNEL);
2981 if (unlikely(!sstats)) {
2982 nss_warning("Could not allocate memory for base debug statistics buffer");
2983 kfree(lbuf);
2984 kfree(bstats);
2985 return 0;
2986 }
2987
2988 /*
2989 * Get all base stats
2990 */
2991 nss_gre_base_debug_stats_get((void *)bstats, sizeof(struct nss_stats_gre_base_debug));
2992 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Base stats start:\n\n");
2993 for (i = 0; i < NSS_STATS_GRE_BASE_DEBUG_MAX; i++) {
2994 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
2995 "\t%s = %llu\n", nss_stats_str_gre_base_debug_stats[i],
2996 bstats->stats[i]);
2997 }
2998
2999 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Base stats End\n\n");
3000
3001 /*
3002 * Get all session stats
3003 */
3004 nss_gre_session_debug_stats_get(sstats, sizeof(struct nss_stats_gre_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS);
3005 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Session stats start:\n\n");
3006
3007 for (id = 0; id < NSS_GRE_MAX_DEBUG_SESSION_STATS; id++) {
3008
3009 if (!((sstats + id)->valid)) {
3010 continue;
3011 }
3012
3013 dev = dev_get_by_index(&init_net, (sstats + id)->if_index);
3014 if (likely(dev)) {
3015
3016 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
3017 (sstats + id)->if_num, dev->name);
3018 dev_put(dev);
3019 } else {
3020 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
3021 (sstats + id)->if_num);
3022 }
3023
3024 for (i = 0; i < NSS_STATS_GRE_SESSION_DEBUG_MAX; i++) {
3025 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3026 "\t%s = %llu\n", nss_stats_str_gre_session_debug_stats[i],
3027 (sstats + id)->stats[i]);
3028 }
3029 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3030 }
3031
3032 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngre Session stats end\n");
3033 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3034
3035 kfree(sstats);
3036 kfree(bstats);
3037 kfree(lbuf);
3038 return bytes_read;
3039}
3040
ratheesh kannotha1245c32015-11-04 16:45:43 +05303041/*
Amit Gupta316729b2016-08-12 12:21:15 +05303042 * nss_stats_ppe_conn_read()
3043 * Read ppe connection stats
3044 */
3045static ssize_t nss_stats_ppe_conn_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3046{
3047
3048 int i;
3049 char *lbuf = NULL;
3050 size_t size_wr = 0;
3051 ssize_t bytes_read = 0;
3052 uint32_t ppe_stats[NSS_STATS_PPE_CONN_MAX];
3053 uint32_t max_output_lines = 2 /* header & footer for session stats */
3054 + NSS_STATS_PPE_CONN_MAX /* PPE flow counters */
3055 + 2;
3056 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3057
Amit Gupta316729b2016-08-12 12:21:15 +05303058 lbuf = kzalloc(size_al, GFP_KERNEL);
3059 if (unlikely(lbuf == NULL)) {
3060 nss_warning("Could not allocate memory for local statistics buffer");
3061 return 0;
3062 }
3063
3064 memset(&ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_CONN_MAX);
3065
3066 /*
3067 * Get all stats
3068 */
3069 nss_ppe_stats_conn_get(ppe_stats);
3070
3071 /*
3072 * flow stats
3073 */
3074 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters start:\n\n");
3075
3076 for (i = 0; i < NSS_STATS_PPE_CONN_MAX; i++) {
3077 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3078 "\t%s = %u\n", nss_stats_str_ppe_conn[i],
3079 ppe_stats[i]);
3080 }
3081
3082 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3083
3084 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters end\n");
3085 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3086
3087 kfree(lbuf);
3088 return bytes_read;
3089}
3090
3091/*
3092 * nss_stats_ppe_l3_read()
3093 * Read ppe L3 debug stats
3094 */
3095static ssize_t nss_stats_ppe_l3_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3096{
3097
3098 int i;
3099 char *lbuf = NULL;
3100 size_t size_wr = 0;
3101 ssize_t bytes_read = 0;
3102 uint32_t ppe_stats[NSS_STATS_PPE_L3_MAX];
3103 uint32_t max_output_lines = 2 /* header & footer for session stats */
3104 + NSS_STATS_PPE_L3_MAX /* PPE flow counters */
3105 + 2;
3106 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3107
3108 lbuf = kzalloc(size_al, GFP_KERNEL);
3109 if (unlikely(!lbuf)) {
3110 nss_warning("Could not allocate memory for local statistics buffer");
3111 return 0;
3112 }
3113
3114 memset(ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_L3_MAX);
3115
3116 /*
3117 * Get all stats
3118 */
3119 nss_ppe_stats_l3_get(ppe_stats);
3120
3121 /*
3122 * flow stats
3123 */
3124 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats start:\n\n");
3125
3126 for (i = 0; i < NSS_STATS_PPE_L3_MAX; i++) {
3127 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3128 "\t%s = 0x%x\n", nss_stats_str_ppe_l3[i],
3129 ppe_stats[i]);
3130 }
3131
3132 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3133
3134 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats end\n");
3135 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3136
3137 kfree(lbuf);
3138 return bytes_read;
3139}
3140
3141/*
3142 * nss_stats_ppe_code_read()
3143 * Read ppe CPU & DROP code
3144 */
3145static ssize_t nss_stats_ppe_code_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3146{
3147
3148 int i;
3149 char *lbuf = NULL;
3150 size_t size_wr = 0;
3151 ssize_t bytes_read = 0;
3152 uint32_t ppe_stats[NSS_STATS_PPE_CODE_MAX];
3153 uint32_t max_output_lines = 2 /* header & footer for session stats */
3154 + NSS_STATS_PPE_CODE_MAX /* PPE flow counters */
3155 + 2;
3156 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3157
3158 lbuf = kzalloc(size_al, GFP_KERNEL);
3159 if (unlikely(!lbuf)) {
3160 nss_warning("Could not allocate memory for local statistics buffer");
3161 return 0;
3162 }
3163
3164 memset(ppe_stats, 0, sizeof(uint32_t) * NSS_STATS_PPE_CODE_MAX);
3165
3166 /*
3167 * Get all stats
3168 */
3169 nss_ppe_stats_code_get(ppe_stats);
3170
3171 /*
3172 * flow stats
3173 */
3174 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats start:\n\n");
3175
3176 for (i = 0; i < NSS_STATS_PPE_CODE_MAX; i++) {
3177 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3178 "\t%s = %u\n", nss_stats_str_ppe_code[i],
3179 ppe_stats[i]);
3180 }
3181
3182 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3183
3184 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats end\n");
3185 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3186
3187 kfree(lbuf);
3188 return bytes_read;
3189}
3190
3191/*
Amit Gupta79c1c202017-06-30 15:28:13 +05303192 * nss_stats_ppe_port_dc_read()
3193 * Read PPE per port drop code stats
3194 */
3195static ssize_t nss_stats_ppe_port_dc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3196{
3197 int32_t i;
3198
3199 /*
3200 * max output lines = #stats + 2 start tag line + 2 end tag line + five blank lines
3201 */
3202 uint32_t max_output_lines = (NSS_STATS_PPE_DROP_CODE_MAX + 4) + 5;
3203 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3204 size_t size_wr = 0;
3205 ssize_t bytes_read = 0;
3206 struct nss_stats_data *data = fp->private_data;
3207 uint32_t *ppe_stats;
3208
3209 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3210 if (unlikely(lbuf == NULL)) {
3211 nss_warning("Could not allocate memory for local statistics buffer");
3212 return 0;
3213 }
3214
3215 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_DROP_CODE_MAX, GFP_KERNEL);
3216 if (unlikely(ppe_stats == NULL)) {
3217 kfree(lbuf);
3218 nss_warning("Could not allocate memory for ppe stats buffer");
3219 return 0;
3220 }
3221
3222 /*
3223 * Get drop code counters for specific port
3224 */
3225 nss_ppe_port_drop_code_get(ppe_stats, data->edma_id);
3226 size_wr = scnprintf(lbuf, size_al, "ppe no drop code stats start:\n\n");
3227 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3228 "\t%s = %u\n", nss_stats_str_ppe_dc[0],
3229 ppe_stats[0]);
3230 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe no drop code stats end\n\n");
3231
3232 /*
3233 * Drop code stats
3234 */
3235 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "ppe non-zero drop code stats start:\n\n");
3236 for (i = 1; i < NSS_STATS_PPE_DROP_CODE_MAX; i++) {
3237 /*
3238 * Print only non-zero stats.
3239 */
3240 if (!ppe_stats[i]) {
3241 continue;
3242 }
3243
3244 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3245 "\t%s = %u\n", nss_stats_str_ppe_dc[i],
3246 ppe_stats[i]);
3247 }
3248 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero drop code stats end\n\n");
3249
3250 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3251 kfree(ppe_stats);
3252 kfree(lbuf);
3253
3254 return bytes_read;
3255}
3256
3257/*
3258 * nss_stats_ppe_exception_cc_read()
3259 * Read PPE CPU code stats specific to flow exceptions
3260 */
3261static ssize_t nss_stats_ppe_exception_cc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3262{
3263 int32_t i;
3264
3265 /*
3266 * max output lines = #stats + start tag line + end tag line + three blank lines
3267 */
3268 uint32_t max_output_lines = (NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX + 2) + 3;
3269 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3270 size_t size_wr = 0;
3271 ssize_t bytes_read = 0;
3272 uint32_t *ppe_stats;
3273
3274 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3275 if (unlikely(lbuf == NULL)) {
3276 nss_warning("Could not allocate memory for local statistics buffer");
3277 return 0;
3278 }
3279
3280 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX, GFP_KERNEL);
3281 if (unlikely(ppe_stats == NULL)) {
3282 kfree(lbuf);
3283 nss_warning("Could not allocate memory for ppe stats buffer");
3284 return 0;
3285 }
3286
3287 /*
3288 * Get CPU code counters for flow specific exceptions
3289 */
3290 nss_ppe_cpu_code_exception_get(ppe_stats);
3291
3292 size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code flow-exception stats start:\n\n");
3293
3294 /*
3295 * CPU code stats
3296 */
3297 for (i = 0; i < NSS_STATS_PPE_CPU_CODE_EXCEPTION_MAX; i++) {
3298 /*
3299 * Print only non-zero stats.
3300 */
3301 if (!ppe_stats[i]) {
3302 continue;
3303 }
3304
3305 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3306 "\t%s = %u\n", nss_stats_str_ppe_cc[i],
3307 ppe_stats[i]);
3308 }
3309
3310 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code flow-exception stats end\n\n");
3311 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3312 kfree(ppe_stats);
3313 kfree(lbuf);
3314
3315 return bytes_read;
3316}
3317
3318/*
3319 * nss_stats_ppe_nonexception_cc_read()
3320 * Read PPE CPU code stats for other than flow exceptions
3321 */
3322static ssize_t nss_stats_ppe_nonexception_cc_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3323{
3324 int32_t i;
3325
3326 /*
3327 * max output lines = #stats + start tag line + end tag line + three blank lines
3328 */
3329 uint32_t max_output_lines = (NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX + 2) + 3;
3330 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3331 size_t size_wr = 0;
3332 ssize_t bytes_read = 0;
3333 uint32_t *ppe_stats;
3334
3335 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3336 if (unlikely(lbuf == NULL)) {
3337 nss_warning("Could not allocate memory for local statistics buffer");
3338 return 0;
3339 }
3340
3341 ppe_stats = kzalloc(sizeof(uint32_t) * NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX, GFP_KERNEL);
3342 if (unlikely(ppe_stats == NULL)) {
3343 kfree(lbuf);
3344 nss_warning("Could not allocate memory for ppe stats buffer");
3345 return 0;
3346 }
3347
3348 /*
3349 * Get CPU code counters for non flow exceptions
3350 */
3351 nss_ppe_cpu_code_nonexception_get(ppe_stats);
3352
3353 /*
3354 * CPU code stats
3355 */
3356 size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code non-flow exception stats start:\n\n");
3357 for (i = 0; i < NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_MAX; i++) {
3358 /*
3359 * Print only non-zero stats.
3360 */
3361 if (!ppe_stats[i]) {
3362 continue;
3363 }
3364
3365 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3366 "\t%s = %u\n", nss_stats_str_ppe_cc[i + NSS_STATS_PPE_CPU_CODE_NONEXCEPTION_START],
3367 ppe_stats[i]);
3368 }
3369
3370 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code non-flow exception stats end\n\n");
3371 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3372 kfree(ppe_stats);
3373 kfree(lbuf);
3374
3375 return bytes_read;
3376}
3377
3378/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05303379 * nss_stats_pptp_read()
3380 * Read pptp statistics
3381 */
3382static ssize_t nss_stats_pptp_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3383{
3384
3385 uint32_t max_output_lines = 2 /* header & footer for session stats */
3386 + NSS_MAX_PPTP_DYNAMIC_INTERFACES * (NSS_STATS_PPTP_SESSION_MAX + 2) /*session stats */
3387 + 2;
3388 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ;
3389 size_t size_wr = 0;
3390 ssize_t bytes_read = 0;
3391 struct net_device *dev;
3392 struct nss_stats_pptp_session_debug pptp_session_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES];
3393 int id, i;
3394
3395 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3396 if (unlikely(lbuf == NULL)) {
3397 nss_warning("Could not allocate memory for local statistics buffer");
3398 return 0;
3399 }
3400
3401 memset(&pptp_session_stats, 0, sizeof(struct nss_stats_pptp_session_debug) * NSS_MAX_PPTP_DYNAMIC_INTERFACES);
3402
3403 /*
3404 * Get all stats
3405 */
3406 nss_pptp_session_debug_stats_get((void *)&pptp_session_stats);
3407
3408 /*
3409 * Session stats
3410 */
3411 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats start:\n\n");
3412 for (id = 0; id < NSS_MAX_PPTP_DYNAMIC_INTERFACES; id++) {
3413
3414 if (!pptp_session_stats[id].valid) {
3415 break;
3416 }
3417
3418 dev = dev_get_by_index(&init_net, pptp_session_stats[id].if_index);
3419 if (likely(dev)) {
3420
3421 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id,
3422 pptp_session_stats[id].if_num, dev->name);
3423 dev_put(dev);
3424 } else {
3425 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id,
3426 pptp_session_stats[id].if_num);
3427 }
3428
3429 for (i = 0; i < NSS_STATS_PPTP_SESSION_MAX; i++) {
3430 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3431 "\t%s = %llu\n", nss_stats_str_pptp_session_debug_stats[i],
3432 pptp_session_stats[id].stats[i]);
3433 }
3434 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n");
3435 }
3436
3437 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats end\n");
3438 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr);
3439
3440 kfree(lbuf);
3441 return bytes_read;
3442}
3443
3444/*
Ankit Dhanuka14999992014-11-12 15:35:11 +05303445 * nss_stats_sjack_read()
3446 * Read SJACK stats
3447 */
3448static ssize_t nss_stats_sjack_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3449{
3450 int32_t i;
3451 /*
3452 * max output lines = #stats + start tag line + end tag line + three blank lines
3453 */
3454 uint32_t max_output_lines = NSS_STATS_NODE_MAX + 5;
3455 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3456 size_t size_wr = 0;
3457 ssize_t bytes_read = 0;
3458 uint64_t *stats_shadow;
3459
3460 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3461 if (unlikely(lbuf == NULL)) {
3462 nss_warning("Could not allocate memory for local statistics buffer");
3463 return 0;
3464 }
3465
3466 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
3467 if (unlikely(stats_shadow == NULL)) {
3468 nss_warning("Could not allocate memory for local shadow buffer");
3469 kfree(lbuf);
3470 return 0;
3471 }
3472
3473 size_wr = scnprintf(lbuf, size_al, "sjack stats start:\n\n");
3474
3475 /*
3476 * Common node stats
3477 */
3478 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
3479 spin_lock_bh(&nss_top_main.stats_lock);
3480 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3481 stats_shadow[i] = nss_top_main.stats_node[NSS_SJACK_INTERFACE][i];
3482 }
3483
3484 spin_unlock_bh(&nss_top_main.stats_lock);
3485
3486 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3487 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3488 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
3489 }
3490
3491 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nsjack stats end\n\n");
3492
3493 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3494 kfree(lbuf);
3495 kfree(stats_shadow);
3496
3497 return bytes_read;
3498}
3499
3500/*
Stephen Wang9779d952015-10-28 11:39:07 -07003501 * nss_stats_portid_read()
3502 * Read PortID stats
3503 */
3504static ssize_t nss_stats_portid_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3505{
3506 int32_t i;
3507 /*
3508 * max output lines = #stats + start tag line + end tag line + three blank lines
3509 */
3510 uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_STATS_PORTID_MAX + 5;
3511 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
3512 size_t size_wr = 0;
3513 ssize_t bytes_read = 0;
3514 uint64_t *stats_shadow;
3515
3516 char *lbuf = kzalloc(size_al, GFP_KERNEL);
3517 if (unlikely(lbuf == NULL)) {
3518 nss_warning("Could not allocate memory for local statistics buffer");
3519 return 0;
3520 }
3521
3522 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
3523 if (unlikely(stats_shadow == NULL)) {
3524 nss_warning("Could not allocate memory for local shadow buffer");
3525 kfree(lbuf);
3526 return 0;
3527 }
3528
3529 size_wr = scnprintf(lbuf, size_al, "portid stats start:\n\n");
3530
3531 /*
3532 * Common node stats
3533 */
3534 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
3535 spin_lock_bh(&nss_top_main.stats_lock);
3536 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3537 stats_shadow[i] = nss_top_main.stats_node[NSS_PORTID_INTERFACE][i];
3538 }
3539
3540 spin_unlock_bh(&nss_top_main.stats_lock);
3541
3542 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
3543 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3544 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
3545 }
3546
3547 /*
3548 * PortID node stats
3549 */
3550 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid node stats:\n\n");
3551
3552 spin_lock_bh(&nss_top_main.stats_lock);
3553 for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) {
3554 stats_shadow[i] = nss_top_main.stats_portid[i];
3555 }
3556
3557 spin_unlock_bh(&nss_top_main.stats_lock);
3558
3559 for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) {
3560 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
3561 "%s = %llu\n", nss_stats_str_portid[i], stats_shadow[i]);
3562 }
3563
3564 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid stats end\n\n");
3565
3566 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
3567 kfree(lbuf);
3568 kfree(stats_shadow);
3569
3570 return bytes_read;
3571}
3572
3573/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003574 * nss_stats_capwap_encap()
3575 * Make a row for CAPWAP encap stats.
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003576 */
3577static ssize_t nss_stats_capwap_encap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s)
3578{
Saurabh Misra3f66e872015-04-03 11:30:42 -07003579 char *header[] = { "packets", "bytes", "fragments", "drop_ref", "drop_ver", "drop_unalign",
3580 "drop_hroom", "drop_dtls", "drop_nwireless", "drop_qfull", "drop_memfail", "unknown" };
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003581 uint64_t tcnt = 0;
3582
3583 switch (i) {
3584 case 0:
3585 tcnt = s->pnode_stats.tx_packets;
3586 break;
3587 case 1:
3588 tcnt = s->pnode_stats.tx_bytes;
3589 break;
3590 case 2:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003591 tcnt = s->tx_segments;
3592 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003593 case 3:
3594 tcnt = s->tx_dropped_sg_ref;
3595 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003596 case 4:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003597 tcnt = s->tx_dropped_ver_mis;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003598 break;
3599 case 5:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003600 tcnt = s->tx_dropped_unalign;
3601 break;
3602 case 6:
3603 tcnt = s->tx_dropped_hroom;
3604 break;
3605 case 7:
3606 tcnt = s->tx_dropped_dtls;
3607 break;
3608 case 8:
3609 tcnt = s->tx_dropped_nwireless;
3610 break;
3611 case 9:
3612 tcnt = s->tx_queue_full_drops;
3613 break;
3614 case 10:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003615 tcnt = s->tx_mem_failure_drops;
3616 break;
3617 default:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003618 return 0;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003619 }
3620
Saurabh Misra3f66e872015-04-03 11:30:42 -07003621 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003622}
3623
3624/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003625 * nss_stats_capwap_decap()
3626 * Make a row for CAPWAP decap stats.
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003627 */
3628static ssize_t nss_stats_capwap_decap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s)
3629{
Saurabh Misra3f66e872015-04-03 11:30:42 -07003630 char *header[] = { "packets", "bytes", "DTLS_pkts", "fragments", "rx_dropped", "drop_oversize",
3631 "drop_frag_timeout", "drop_frag_dup", "drop_frag_gap", "drop_qfull", "drop_memfail",
3632 "drop_csum", "drop_malformed", "unknown" };
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003633 uint64_t tcnt = 0;
3634
Aniruddha Paul1b170c22017-05-29 12:30:39 +05303635 switch (i) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003636 case 0:
3637 tcnt = s->pnode_stats.rx_packets;
3638 break;
3639 case 1:
3640 tcnt = s->pnode_stats.rx_bytes;
3641 break;
3642 case 2:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003643 tcnt = s->dtls_pkts;
3644 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003645 case 3:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003646 tcnt = s->rx_segments;
3647 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003648 case 4:
3649 tcnt = s->pnode_stats.rx_dropped;
3650 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003651 case 5:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003652 tcnt = s->rx_oversize_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003653 break;
3654 case 6:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003655 tcnt = s->rx_frag_timeout_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003656 break;
3657 case 7:
3658 tcnt = s->rx_dup_frag;
3659 break;
3660 case 8:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003661 tcnt = s->rx_frag_gap_drops;
3662 break;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003663 case 9:
Saurabh Misra3f66e872015-04-03 11:30:42 -07003664 tcnt = s->rx_queue_full_drops;
3665 return (snprintf(line, len, "%s = %llu (n2h = %llu)\n", header[i], tcnt, s->rx_n2h_queue_full_drops));
3666 case 10:
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003667 tcnt = s->rx_mem_failure_drops;
3668 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003669 case 11:
3670 tcnt = s->rx_csum_drops;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003671 break;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003672 case 12:
3673 tcnt = s->rx_malformed;
3674 break;
3675 default:
3676 return 0;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003677 }
3678
Saurabh Misra3f66e872015-04-03 11:30:42 -07003679 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003680}
3681
3682/*
3683 * nss_stats_capwap_read()
3684 * Read CAPWAP stats
3685 */
3686static ssize_t nss_stats_capwap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos, uint16_t type)
3687{
3688 struct nss_stats_data *data = fp->private_data;
3689 ssize_t bytes_read = 0;
3690 struct nss_capwap_tunnel_stats stats;
3691 size_t bytes;
3692 char line[80];
Saurabh Misra3f66e872015-04-03 11:30:42 -07003693 int start;
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003694 uint32_t if_num = NSS_DYNAMIC_IF_START;
3695 uint32_t max_if_num = NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES;
3696
3697 if (data) {
3698 if_num = data->if_num;
3699 }
3700
3701 /*
3702 * If we are done accomodating all the CAPWAP tunnels.
3703 */
3704 if (if_num > max_if_num) {
3705 return 0;
3706 }
3707
3708 for (; if_num <= max_if_num; if_num++) {
3709 bool isthere;
3710
3711 if (nss_is_dynamic_interface(if_num) == false) {
3712 continue;
3713 }
3714
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003715 if (nss_dynamic_interface_get_type(nss_capwap_get_ctx(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003716 continue;
3717 }
3718
3719 /*
3720 * If CAPWAP tunnel does not exists, then isthere will be false.
3721 */
3722 isthere = nss_capwap_get_stats(if_num, &stats);
3723 if (!isthere) {
3724 continue;
3725 }
3726
Saurabh Misra3f66e872015-04-03 11:30:42 -07003727 bytes = snprintf(line, sizeof(line), "----if_num : %2d----\n", if_num);
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003728 if ((bytes_read + bytes) > sz) {
3729 break;
3730 }
3731
3732 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3733 bytes_read = -EFAULT;
3734 goto fail;
3735 }
3736 bytes_read += bytes;
3737 start = 0;
Saurabh Misra3f66e872015-04-03 11:30:42 -07003738 while (bytes_read < sz) {
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003739 if (type == 1) {
3740 bytes = nss_stats_capwap_encap(line, sizeof(line), start, &stats);
3741 } else {
3742 bytes = nss_stats_capwap_decap(line, sizeof(line), start, &stats);
3743 }
3744
Saurabh Misra3f66e872015-04-03 11:30:42 -07003745 /*
3746 * If we don't have any more lines in decap/encap.
3747 */
3748 if (bytes == 0) {
3749 break;
3750 }
3751
Saurabh Misra09dddeb2014-09-30 16:38:07 -07003752 if ((bytes_read + bytes) > sz)
3753 break;
3754
3755 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3756 bytes_read = -EFAULT;
3757 goto fail;
3758 }
3759
3760 bytes_read += bytes;
3761 start++;
3762 }
3763 }
3764
3765 if (bytes_read > 0) {
3766 *ppos = bytes_read;
3767 }
3768
3769 if (data) {
3770 data->if_num = if_num;
3771 }
3772fail:
3773 return bytes_read;
3774}
3775
3776/*
3777 * nss_stats_capwap_decap_read()
3778 * Read CAPWAP decap stats
3779 */
3780static ssize_t nss_stats_capwap_decap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3781{
3782 return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 0));
3783}
3784
3785/*
3786 * nss_stats_capwap_encap_read()
3787 * Read CAPWAP encap stats
3788 */
3789static ssize_t nss_stats_capwap_encap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3790{
3791 return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 1));
3792}
3793
3794/*
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303795 * nss_stats_gre_redir()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003796 * Make a row for GRE_REDIR stats.
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303797 */
3798static ssize_t nss_stats_gre_redir(char *line, int len, int i, struct nss_gre_redir_tunnel_stats *s)
3799{
3800 char *header[] = { "TX Packets", "TX Bytes", "TX Drops", "RX Packets", "RX Bytes", "Rx Drops" };
3801 uint64_t tcnt = 0;
3802
3803 switch (i) {
3804 case 0:
3805 tcnt = s->node_stats.tx_packets;
3806 break;
3807 case 1:
3808 tcnt = s->node_stats.tx_bytes;
3809 break;
3810 case 2:
3811 tcnt = s->tx_dropped;
3812 break;
3813 case 3:
3814 tcnt = s->node_stats.rx_packets;
3815 break;
3816 case 4:
3817 tcnt = s->node_stats.rx_bytes;
3818 break;
3819 case 5:
3820 tcnt = s->node_stats.rx_dropped;
3821 break;
3822 default:
Radha krishna Simha Jigurudf53f022015-11-09 12:31:26 +05303823 return 0;
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303824 }
3825
3826 return (snprintf(line, len, "%s = %llu\n", header[i], tcnt));
3827}
3828
3829/*
3830 * nss_stats_gre_redir_read()
Thomas Wu71c5ecc2016-06-21 11:15:52 -07003831 * READ gre_redir tunnel stats.
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05303832 */
3833static ssize_t nss_stats_gre_redir_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3834{
3835 struct nss_stats_data *data = fp->private_data;
3836 ssize_t bytes_read = 0;
3837 struct nss_gre_redir_tunnel_stats stats;
3838 size_t bytes;
3839 char line[80];
3840 int start, end;
3841 int index = 0;
3842
3843 if (data) {
3844 index = data->index;
3845 }
3846
3847 /*
3848 * If we are done accomodating all the GRE_REDIR tunnels.
3849 */
3850 if (index >= NSS_GRE_REDIR_MAX_INTERFACES) {
3851 return 0;
3852 }
3853
3854 for (; index < NSS_GRE_REDIR_MAX_INTERFACES; index++) {
3855 bool isthere;
3856
3857 /*
3858 * If gre_redir tunnel does not exists, then isthere will be false.
3859 */
3860 isthere = nss_gre_redir_get_stats(index, &stats);
3861 if (!isthere) {
3862 continue;
3863 }
3864
3865 bytes = snprintf(line, sizeof(line), "\nTunnel if_num: %2d\n", stats.if_num);
3866 if ((bytes_read + bytes) > sz) {
3867 break;
3868 }
3869
3870 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3871 bytes_read = -EFAULT;
3872 goto fail;
3873 }
3874 bytes_read += bytes;
3875 start = 0;
3876 end = 6;
3877 while (bytes_read < sz && start < end) {
3878 bytes = nss_stats_gre_redir(line, sizeof(line), start, &stats);
3879
3880 if ((bytes_read + bytes) > sz)
3881 break;
3882
3883 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3884 bytes_read = -EFAULT;
3885 goto fail;
3886 }
3887
3888 bytes_read += bytes;
3889 start++;
3890 }
3891 }
3892
3893 if (bytes_read > 0) {
3894 *ppos = bytes_read;
3895 }
3896
3897 if (data) {
3898 data->index = index;
3899 }
3900
3901fail:
3902 return bytes_read;
3903}
3904
3905/*
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003906 * nss_stats_wifi_if_read()
3907 * Read wifi_if statistics
3908 */
3909static ssize_t nss_stats_wifi_if_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
3910{
3911 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003912 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 -08003913 int32_t if_num = NSS_DYNAMIC_IF_START;
3914 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
3915 size_t bytes = 0;
3916 ssize_t bytes_read = 0;
3917 char line[80];
3918 int start, end;
3919
3920 if (data) {
3921 if_num = data->if_num;
3922 }
3923
3924 if (if_num > max_if_num) {
3925 return 0;
3926 }
3927
3928 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003929 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_WIFI)
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08003930 continue;
3931
3932 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
3933 if ((bytes_read + bytes) > sz)
3934 break;
3935
3936 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3937 bytes_read = -EFAULT;
3938 goto end;
3939 }
3940
3941 bytes_read += bytes;
3942
3943 start = 0;
3944 end = 7;
3945 while (bytes_read < sz && start < end) {
3946 bytes = nss_wifi_if_copy_stats(if_num, start, line);
3947 if (!bytes)
3948 break;
3949
3950 if ((bytes_read + bytes) > sz)
3951 break;
3952
3953 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3954 bytes_read = -EFAULT;
3955 goto end;
3956 }
3957
3958 bytes_read += bytes;
3959 start++;
3960 }
3961
3962 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
3963 if (bytes_read > (sz - bytes))
3964 break;
3965
3966 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
3967 bytes_read = -EFAULT;
3968 goto end;
3969 }
3970
3971 bytes_read += bytes;
3972 }
3973
3974 if (bytes_read > 0) {
3975 *ppos = bytes_read;
3976 }
3977
3978 if (data) {
3979 data->if_num = if_num;
3980 }
3981
3982end:
3983 return bytes_read;
3984}
3985
3986/*
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07003987 * nss_stats_virt_if_read()
3988 * Read virt_if statistics
3989 */
3990static ssize_t nss_stats_virt_if_read(struct file *fp, char __user *ubuf,
3991 size_t sz, loff_t *ppos)
3992{
3993 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08003994 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 -07003995 int32_t if_num = NSS_DYNAMIC_IF_START;
3996 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
3997 size_t bytes = 0;
3998 ssize_t bytes_read = 0;
3999 char line[80];
4000 int start, end;
4001
4002 if (data) {
4003 if_num = data->if_num;
4004 }
4005
4006 if (if_num > max_if_num) {
4007 return 0;
4008 }
4009
4010 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004011 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR)
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004012 continue;
4013
4014 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
4015 if ((bytes_read + bytes) > sz)
4016 break;
4017
4018 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4019 bytes_read = -EFAULT;
4020 goto end;
4021 }
4022
4023 bytes_read += bytes;
4024
4025 start = 0;
4026 end = 7;
4027 while (bytes_read < sz && start < end) {
4028 bytes = nss_virt_if_copy_stats(if_num, start, line);
4029 if (!bytes)
4030 break;
4031
4032 if ((bytes_read + bytes) > sz)
4033 break;
4034
4035 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4036 bytes_read = -EFAULT;
4037 goto end;
4038 }
4039
4040 bytes_read += bytes;
4041 start++;
4042 }
4043
4044 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
4045 if (bytes_read > (sz - bytes))
4046 break;
4047
4048 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4049 bytes_read = -EFAULT;
4050 goto end;
4051 }
4052
4053 bytes_read += bytes;
4054 }
4055
4056 if (bytes_read > 0) {
4057 *ppos = bytes_read;
4058 }
4059
4060 if (data) {
4061 data->if_num = if_num;
4062 }
4063
4064end:
4065 return bytes_read;
4066}
4067
4068/*
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004069 * nss_stats_tx_rx_virt_if_read()
4070 * Read tx_rx_virt_if statistics
4071 */
4072static ssize_t nss_stats_tx_rx_virt_if_read(struct file *fp, char __user *ubuf,
4073 size_t sz, loff_t *ppos)
4074{
4075 struct nss_stats_data *data = fp->private_data;
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004076 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 -07004077 int32_t if_num = NSS_DYNAMIC_IF_START;
4078 int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES;
4079 size_t bytes = 0;
4080 ssize_t bytes_read = 0;
4081 char line[80];
4082 int start, end;
4083
4084 if (data) {
4085 if_num = data->if_num;
4086 }
4087
4088 if (if_num > max_if_num) {
4089 return 0;
4090 }
4091
4092 for (; if_num < max_if_num; if_num++) {
Stephen Wange8b8d0d2017-02-24 17:05:22 -08004093 if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED)
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004094 continue;
4095
4096 bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);
4097 if ((bytes_read + bytes) > sz)
4098 break;
4099
4100 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4101 bytes_read = -EFAULT;
4102 goto end;
4103 }
4104
4105 bytes_read += bytes;
4106
4107 start = 0;
4108 end = 7;
4109 while (bytes_read < sz && start < end) {
4110 bytes = nss_tx_rx_virt_if_copy_stats(if_num, start, line);
4111 if (!bytes)
4112 break;
4113
4114 if ((bytes_read + bytes) > sz)
4115 break;
4116
4117 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4118 bytes_read = -EFAULT;
4119 goto end;
4120 }
4121
4122 bytes_read += bytes;
4123 start++;
4124 }
4125
4126 bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num);
4127 if (bytes_read > (sz - bytes))
4128 break;
4129
4130 if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) {
4131 bytes_read = -EFAULT;
4132 goto end;
4133 }
4134
4135 bytes_read += bytes;
4136 }
4137
4138 if (bytes_read > 0) {
4139 *ppos = bytes_read;
4140 }
4141
4142 if (data) {
4143 data->if_num = if_num;
4144 }
4145
4146end:
4147 return bytes_read;
4148}
4149
4150/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07004151 * nss_stats_trustsec_tx_read()
4152 * Read trustsec_tx stats
4153 */
4154static ssize_t nss_stats_trustsec_tx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
4155{
4156 int32_t i;
4157
4158 /*
4159 * max output lines = #stats + start tag line + end tag line + three blank lines
4160 */
4161 uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_TRUSTSEC_TX_MAX + 3) + 5;
4162 size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines;
4163 size_t size_wr = 0;
4164 ssize_t bytes_read = 0;
4165 uint64_t *stats_shadow;
4166
4167 char *lbuf = kzalloc(size_al, GFP_KERNEL);
4168 if (unlikely(lbuf == NULL)) {
4169 nss_warning("Could not allocate memory for local statistics buffer");
4170 return 0;
4171 }
4172
4173 stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL);
4174 if (unlikely(stats_shadow == NULL)) {
4175 nss_warning("Could not allocate memory for local shadow buffer");
4176 kfree(lbuf);
4177 return 0;
4178 }
4179
4180 size_wr = scnprintf(lbuf, size_al, "trustsec_tx stats start:\n\n");
4181
4182 /*
4183 * Common node stats
4184 */
4185 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n");
4186 spin_lock_bh(&nss_top_main.stats_lock);
4187 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
4188 stats_shadow[i] = nss_top_main.stats_node[NSS_TRUSTSEC_TX_INTERFACE][i];
4189 }
4190
4191 spin_unlock_bh(&nss_top_main.stats_lock);
4192
4193 for (i = 0; (i < NSS_STATS_NODE_MAX); i++) {
4194 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4195 "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]);
4196 }
4197
4198 /*
4199 * TrustSec TX node stats
4200 */
4201 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx node stats:\n\n");
4202
4203 spin_lock_bh(&nss_top_main.stats_lock);
4204 for (i = 0; (i < NSS_STATS_TRUSTSEC_TX_MAX); i++) {
4205 stats_shadow[i] = nss_top_main.stats_trustsec_tx[i];
4206 }
4207
4208 spin_unlock_bh(&nss_top_main.stats_lock);
4209
4210 for (i = 0; (i < NSS_STATS_TRUSTSEC_TX_MAX); i++) {
4211 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4212 "%s = %llu\n", nss_stats_str_trustsec_tx[i], stats_shadow[i]);
4213 }
4214
4215 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntrustsec tx stats end\n\n");
4216 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
4217 kfree(lbuf);
4218 kfree(stats_shadow);
4219
4220 return bytes_read;
4221}
4222
4223/*
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004224 * nss_stats_wt_read()
4225 * Reads and formats worker thread statistics and outputs them to ubuf
4226 */
4227static ssize_t nss_stats_wt_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
4228{
4229 struct nss_stats_data *data = fp->private_data;
4230 struct nss_ctx_instance *nss_ctx = data->nss_ctx;
4231 struct nss_project_irq_stats *shadow;
4232 uint32_t thread_count = nss_ctx->worker_thread_count;
4233 uint32_t irq_count = nss_ctx->irq_count;
4234
4235 /*
4236 * Three lines for each IRQ
4237 */
4238 uint32_t max_output_lines = thread_count * 3 * irq_count;
4239 size_t size_al = max_output_lines * NSS_STATS_MAX_STR_LENGTH;
4240 size_t size_wr = 0;
4241 ssize_t bytes_read = 0;
4242 char *lbuf;
4243 int i;
4244 int j;
4245
4246 lbuf = kzalloc(size_al, GFP_KERNEL);
4247 if (unlikely(!lbuf)) {
4248 nss_warning("Could not allocate memory for local statistics buffer\n");
4249 return 0;
4250 }
4251
4252 shadow = kzalloc(thread_count * irq_count * sizeof(struct nss_project_irq_stats), GFP_KERNEL);
4253 if (unlikely(!shadow)) {
4254 nss_warning("Could not allocate memory for stats shadow\n");
4255 kfree(lbuf);
4256 return 0;
4257 }
4258
4259 spin_lock_bh(&nss_top_main.stats_lock);
4260 if (unlikely(!nss_ctx->wt_stats)) {
4261 spin_unlock_bh(&nss_top_main.stats_lock);
4262 nss_warning("Worker thread statistics not allocated\n");
4263 kfree(lbuf);
4264 kfree(shadow);
4265 return 0;
4266 }
4267 for (i = 0; i < thread_count; ++i) {
4268
4269 /*
4270 * The statistics shadow is an array with thread_count * irq_count
4271 * items in it. Each item is located at the index:
4272 * (thread number) * (irq_count) + (irq number)
4273 * thus simulating a two-dimensional array.
4274 */
4275 for (j = 0; j < irq_count; ++j) {
4276 shadow[i * irq_count + j] = nss_ctx->wt_stats[i].irq_stats[j];
4277 }
4278 }
4279 spin_unlock_bh(&nss_top_main.stats_lock);
4280
4281 for (i = 0; i < thread_count; ++i) {
4282 for (j = 0; j < irq_count; ++j) {
4283 struct nss_project_irq_stats *is = &(shadow[i * irq_count + j]);
4284 if (!(is->count)) {
4285 continue;
4286 }
4287
4288 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4289 "t-%d:irq-%d callback: 0x%x, count: %llu\n",
4290 i, j, is->callback, is->count);
4291 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4292 "t-%d:irq-%d tick min: %10u avg: %10u max:%10u\n",
4293 i, j, is->ticks_min, is->ticks_avg, is->ticks_max);
4294 size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,
4295 "t-%d:irq-%d insn min: %10u avg: %10u max:%10u\n\n",
4296 i, j, is->insn_min, is->insn_avg, is->insn_max);
4297 }
4298 }
4299 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf));
4300 kfree(lbuf);
4301 kfree(shadow);
4302
4303 return bytes_read;
4304}
4305
4306/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004307 * nss_stats_open()
4308 */
4309static int nss_stats_open(struct inode *inode, struct file *filp)
4310{
4311 struct nss_stats_data *data = NULL;
4312
4313 data = kzalloc(sizeof(struct nss_stats_data), GFP_KERNEL);
4314 if (!data) {
4315 return -ENOMEM;
4316 }
4317 memset(data, 0, sizeof (struct nss_stats_data));
4318 data->if_num = NSS_DYNAMIC_IF_START;
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304319 data->index = 0;
Stephen Wangaed46332016-12-12 17:29:03 -08004320 data->edma_id = (nss_ptr_t)inode->i_private;
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004321 data->nss_ctx = (struct nss_ctx_instance *)(inode->i_private);
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004322 filp->private_data = data;
4323
4324 return 0;
4325}
4326
4327/*
4328 * nss_stats_release()
4329 */
4330static int nss_stats_release(struct inode *inode, struct file *filp)
4331{
4332 struct nss_stats_data *data = filp->private_data;
4333
4334 if (data) {
4335 kfree(data);
4336 }
4337
4338 return 0;
4339}
4340
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304341#define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \
4342static const struct file_operations nss_stats_##name##_ops = { \
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004343 .open = nss_stats_open, \
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304344 .read = nss_stats_##name##_read, \
4345 .llseek = generic_file_llseek, \
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004346 .release = nss_stats_release, \
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304347};
4348
4349/*
4350 * nss_ipv4_stats_ops
4351 */
4352NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4)
4353
4354/*
Selin Dag6d9b0c12014-11-04 18:27:21 -08004355 * ipv4_reasm_stats_ops
4356 */
4357NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4_reasm)
4358
4359/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304360 * ipv6_stats_ops
4361 */
4362NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6)
4363
4364/*
Selin Dag60a2f5b2015-06-29 14:39:49 -07004365 * ipv6_reasm_stats_ops
4366 */
4367NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6_reasm)
4368
4369/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304370 * n2h_stats_ops
4371 */
4372NSS_STATS_DECLARE_FILE_OPERATIONS(n2h)
Thomas Wuc3e382c2014-10-29 15:35:13 -07004373
4374/*
4375 * lso_rx_stats_ops
4376 */
4377NSS_STATS_DECLARE_FILE_OPERATIONS(lso_rx)
4378
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304379/*
4380 * drv_stats_ops
4381 */
4382NSS_STATS_DECLARE_FILE_OPERATIONS(drv)
4383
4384/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304385 * pppoe_stats_ops
4386 */
4387NSS_STATS_DECLARE_FILE_OPERATIONS(pppoe)
4388
4389/*
ratheesh kannoth7af985d2015-06-24 15:08:40 +05304390 * l2tpv2_stats_ops
4391 */
4392NSS_STATS_DECLARE_FILE_OPERATIONS(l2tpv2)
4393
4394/*
ratheesh kannotha1245c32015-11-04 16:45:43 +05304395 * map_t_stats_ops
4396 */
4397NSS_STATS_DECLARE_FILE_OPERATIONS(map_t)
4398
4399/*
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05304400 * gre_stats_ops
4401 */
4402NSS_STATS_DECLARE_FILE_OPERATIONS(gre)
4403
4404/*
Amit Gupta316729b2016-08-12 12:21:15 +05304405 * ppe_stats_ops
4406 */
4407NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_conn)
4408NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_l3)
4409NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_code)
Amit Gupta79c1c202017-06-30 15:28:13 +05304410NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_port_dc)
4411NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_exception_cc)
4412NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_nonexception_cc)
Amit Gupta316729b2016-08-12 12:21:15 +05304413
4414/*
Shyam Sunder66e889d2015-11-02 15:31:20 +05304415 * pptp_stats_ops
4416 */
4417NSS_STATS_DECLARE_FILE_OPERATIONS(pptp)
4418
4419/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304420 * gmac_stats_ops
4421 */
4422NSS_STATS_DECLARE_FILE_OPERATIONS(gmac)
4423
4424/*
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004425 * capwap_stats_ops
4426 */
4427NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_encap)
4428NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_decap)
4429
4430/*
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304431 * eth_rx_stats_ops
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304432 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304433NSS_STATS_DECLARE_FILE_OPERATIONS(eth_rx)
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304434
4435/*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004436 * edma_port_stats_ops
4437 */
4438NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_stats)
4439
4440/*
4441 * edma_port_type_ops
4442 */
4443NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_type)
4444
4445/*
4446 * edma_port_ring_map_ops
4447 */
4448NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_ring_map)
4449
4450/*
4451 * edma_txring_stats_ops
4452 */
4453NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txring)
4454
4455/*
4456 * edma_rxring_stats_ops
4457 */
4458NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxring)
4459
4460/*
4461 * edma_txcmplring_stats_ops
4462 */
4463NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txcmplring)
4464
4465/*
4466 * edma_rxfillring_stats_ops
4467 */
4468NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxfillring)
4469
4470/*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004471 * edma_err_stats_ops
4472 */
4473NSS_STATS_DECLARE_FILE_OPERATIONS(edma_err_stats)
4474
4475/*
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304476 * gre_redir_ops
4477 */
4478NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir)
4479
4480/*
Ankit Dhanuka14999992014-11-12 15:35:11 +05304481 * sjack_stats_ops
4482 */
4483NSS_STATS_DECLARE_FILE_OPERATIONS(sjack)
4484
Stephen Wang9779d952015-10-28 11:39:07 -07004485/*
4486 * portid_ops
4487 */
4488NSS_STATS_DECLARE_FILE_OPERATIONS(portid)
4489
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08004490NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_if)
4491
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004492NSS_STATS_DECLARE_FILE_OPERATIONS(virt_if)
4493
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004494NSS_STATS_DECLARE_FILE_OPERATIONS(tx_rx_virt_if)
4495
Ankit Dhanuka14999992014-11-12 15:35:11 +05304496/*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304497 * wifi_stats_ops
4498 */
4499NSS_STATS_DECLARE_FILE_OPERATIONS(wifi)
4500
4501/*
Tushar Mathurff8741b2015-12-02 20:28:59 +05304502 * dtls_stats_ops
4503 */
4504NSS_STATS_DECLARE_FILE_OPERATIONS(dtls)
4505
4506/*
Thomas Wu71c5ecc2016-06-21 11:15:52 -07004507 * gre_tunnel_stats_ops
4508 */
4509NSS_STATS_DECLARE_FILE_OPERATIONS(gre_tunnel)
4510
4511/*
Stephen Wangec5a85c2016-09-08 23:32:27 -07004512 * trustsec_tx_stats_ops
4513 */
4514NSS_STATS_DECLARE_FILE_OPERATIONS(trustsec_tx)
4515
4516/*
Aniruddha Paul1b170c22017-05-29 12:30:39 +05304517 * wifili_stats_ops
4518 */
4519NSS_STATS_DECLARE_FILE_OPERATIONS(wifili)
4520
4521/*
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004522 * wt_stats_ops
4523 */
4524NSS_STATS_DECLARE_FILE_OPERATIONS(wt)
4525/*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304526 * nss_stats_init()
4527 * Enable NSS statistics
4528 */
4529void nss_stats_init(void)
4530{
Shashank Balashankar512cb602016-08-01 17:57:42 -07004531 int i = 0;
4532 struct dentry *edma_d = NULL;
4533 struct dentry *edma_port_dir_d = NULL;
4534 struct dentry *edma_port_d = NULL;
4535 struct dentry *edma_port_type_d = NULL;
4536 struct dentry *edma_port_stats_d = NULL;
4537 struct dentry *edma_port_ring_map_d = NULL;
Shashank Balashankar512cb602016-08-01 17:57:42 -07004538 struct dentry *edma_rings_dir_d = NULL;
4539 struct dentry *edma_tx_dir_d = NULL;
4540 struct dentry *edma_tx_d = NULL;
4541 struct dentry *edma_rx_dir_d = NULL;
4542 struct dentry *edma_rx_d = NULL;
4543 struct dentry *edma_txcmpl_dir_d = NULL;
4544 struct dentry *edma_txcmpl_d = NULL;
4545 struct dentry *edma_rxfill_dir_d = NULL;
4546 struct dentry *edma_rxfill_d = NULL;
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004547 struct dentry *edma_err_stats_d = NULL;
Shashank Balashankar512cb602016-08-01 17:57:42 -07004548
Amit Gupta79c1c202017-06-30 15:28:13 +05304549 struct dentry *ppe_code_d = NULL;
4550 struct dentry *ppe_drop_d = NULL;
4551 struct dentry *ppe_port_dc_d = NULL;
4552 struct dentry *ppe_cpu_d = NULL;
4553 struct dentry *ppe_exception_d = NULL;
4554 struct dentry *ppe_nonexception_d = NULL;
Jackson Bockusc2a4e682017-06-23 11:59:29 -07004555 struct dentry *core_dentry = NULL;
4556 struct dentry *wt_dentry = NULL;
4557
Amit Gupta79c1c202017-06-30 15:28:13 +05304558
Shashank Balashankar512cb602016-08-01 17:57:42 -07004559 char file_name[10];
4560
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304561 /*
4562 * NSS driver entry
4563 */
4564 nss_top_main.top_dentry = debugfs_create_dir("qca-nss-drv", NULL);
4565 if (unlikely(nss_top_main.top_dentry == NULL)) {
4566 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4567
4568 /*
4569 * Non availability of debugfs directory is not a catastrophy
4570 * We can still go ahead with other initialization
4571 */
4572 return;
4573 }
4574
4575 nss_top_main.stats_dentry = debugfs_create_dir("stats", nss_top_main.top_dentry);
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304576 if (unlikely(nss_top_main.stats_dentry == NULL)) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304577 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4578
4579 /*
4580 * Non availability of debugfs directory is not a catastrophy
4581 * We can still go ahead with rest of initialization
4582 */
4583 return;
4584 }
4585
4586 /*
4587 * Create files to obtain statistics
4588 */
4589
4590 /*
4591 * ipv4_stats
4592 */
4593 nss_top_main.ipv4_dentry = debugfs_create_file("ipv4", 0400,
4594 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_ops);
4595 if (unlikely(nss_top_main.ipv4_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304596 nss_warning("Failed to create qca-nss-drv/stats/ipv4 file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304597 return;
4598 }
4599
4600 /*
Selin Dag6d9b0c12014-11-04 18:27:21 -08004601 * ipv4_reasm_stats
4602 */
4603 nss_top_main.ipv4_reasm_dentry = debugfs_create_file("ipv4_reasm", 0400,
4604 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_reasm_ops);
4605 if (unlikely(nss_top_main.ipv4_reasm_dentry == NULL)) {
4606 nss_warning("Failed to create qca-nss-drv/stats/ipv4_reasm file in debugfs");
4607 return;
4608 }
4609
4610 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304611 * ipv6_stats
4612 */
4613 nss_top_main.ipv6_dentry = debugfs_create_file("ipv6", 0400,
4614 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_ops);
4615 if (unlikely(nss_top_main.ipv6_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304616 nss_warning("Failed to create qca-nss-drv/stats/ipv6 file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304617 return;
4618 }
4619
4620 /*
Selin Dag60a2f5b2015-06-29 14:39:49 -07004621 * ipv6_reasm_stats
4622 */
4623 nss_top_main.ipv6_reasm_dentry = debugfs_create_file("ipv6_reasm", 0400,
4624 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_reasm_ops);
4625 if (unlikely(nss_top_main.ipv6_reasm_dentry == NULL)) {
4626 nss_warning("Failed to create qca-nss-drv/stats/ipv6_reasm file in debugfs");
4627 return;
4628 }
4629
4630 /*
4631 * eth_rx__stats
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304632 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304633 nss_top_main.eth_rx_dentry = debugfs_create_file("eth_rx", 0400,
4634 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_eth_rx_ops);
4635 if (unlikely(nss_top_main.eth_rx_dentry == NULL)) {
4636 nss_warning("Failed to create qca-nss-drv/stats/eth_rx file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304637 return;
4638 }
4639
4640 /*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004641 * edma stats
4642 */
4643 edma_d = debugfs_create_dir("edma", nss_top_main.stats_dentry);
4644 if (unlikely(edma_d == NULL)) {
4645 nss_warning("Failed to create qca-nss-drv/stats/edma directory in debugfs");
4646 return;
4647 }
4648
4649 /*
4650 * edma port stats
4651 */
4652 edma_port_dir_d = debugfs_create_dir("ports", edma_d);
4653 if (unlikely(edma_port_dir_d == NULL)) {
4654 nss_warning("Failed to create qca-nss-drv/stats/edma/ports directory in debugfs");
4655 return;
4656 }
4657
4658 for (i = 0; i < NSS_EDMA_NUM_PORTS_MAX; i++) {
4659 memset(file_name, 0, sizeof(file_name));
4660 snprintf(file_name, sizeof(file_name), "%d", i);
4661 edma_port_d = NULL;
4662 edma_port_stats_d = NULL;
4663 edma_port_type_d = NULL;
4664 edma_port_ring_map_d = NULL;
4665
4666 edma_port_d = debugfs_create_dir(file_name, edma_port_dir_d);
4667 if (unlikely(edma_port_d == NULL)) {
4668 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d dir in debugfs", i);
4669 return;
4670 }
4671
Stephen Wangaed46332016-12-12 17:29:03 -08004672 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 -07004673 if (unlikely(edma_port_stats_d == NULL)) {
4674 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/stats file in debugfs", i);
4675 return;
4676 }
4677
Stephen Wangaed46332016-12-12 17:29:03 -08004678 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 -07004679 if (unlikely(edma_port_type_d == NULL)) {
4680 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/type file in debugfs", i);
4681 return;
4682 }
4683
Stephen Wangaed46332016-12-12 17:29:03 -08004684 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 -07004685 if (unlikely(edma_port_ring_map_d == NULL)) {
4686 nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/ring_map file in debugfs", i);
4687 return;
4688 }
4689 }
4690
4691 /*
Santosh Kivatib65b68b2017-05-18 13:30:58 -07004692 * edma error stats
4693 */
4694 edma_err_stats_d = NULL;
4695 edma_err_stats_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_stats_edma_err_stats_ops);
4696 if (unlikely(edma_port_stats_d == NULL)) {
4697 nss_warning("Failed to create qca-nss-drv/stats/edma/%d/err_stats file in debugfs", 0);
4698 return;
4699 }
4700
4701 /*
Shashank Balashankar512cb602016-08-01 17:57:42 -07004702 * edma ring stats
4703 */
4704 edma_rings_dir_d = debugfs_create_dir("rings", edma_d);
4705 if (unlikely(edma_rings_dir_d == NULL)) {
4706 nss_warning("Failed to create qca-nss-drv/stats/edma/rings directory in debugfs");
4707 return;
4708 }
4709
4710 /*
4711 * edma tx ring stats
4712 */
4713 edma_tx_dir_d = debugfs_create_dir("tx", edma_rings_dir_d);
4714 if (unlikely(edma_tx_dir_d == NULL)) {
4715 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx directory in debugfs");
4716 return;
4717 }
4718
4719 for (i = 0; i < NSS_EDMA_NUM_TX_RING_MAX; i++) {
4720 memset(file_name, 0, sizeof(file_name));
4721 scnprintf(file_name, sizeof(file_name), "%d", i);
4722 edma_tx_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004723 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 -07004724 if (unlikely(edma_tx_d == NULL)) {
4725 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx/%d file in debugfs", i);
4726 return;
4727 }
4728 }
4729
4730 /*
4731 * edma rx ring stats
4732 */
4733 edma_rx_dir_d = debugfs_create_dir("rx", edma_rings_dir_d);
4734 if (unlikely(edma_rx_dir_d == NULL)) {
4735 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx directory in debugfs");
4736 return;
4737 }
4738
4739 for (i = 0; i < NSS_EDMA_NUM_RX_RING_MAX; i++) {
4740 memset(file_name, 0, sizeof(file_name));
4741 scnprintf(file_name, sizeof(file_name), "%d", i);
4742 edma_rx_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004743 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 -07004744 if (unlikely(edma_rx_d == NULL)) {
4745 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx/%d file in debugfs", i);
4746 return;
4747 }
4748 }
4749
4750 /*
4751 * edma tx cmpl ring stats
4752 */
4753 edma_txcmpl_dir_d = debugfs_create_dir("txcmpl", edma_rings_dir_d);
4754 if (unlikely(edma_txcmpl_dir_d == NULL)) {
4755 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl directory in debugfs");
4756 return;
4757 }
4758
4759 for (i = 0; i < NSS_EDMA_NUM_TXCMPL_RING_MAX; i++) {
4760 memset(file_name, 0, sizeof(file_name));
4761 scnprintf(file_name, sizeof(file_name), "%d", i);
4762 edma_txcmpl_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004763 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 -07004764 if (unlikely(edma_txcmpl_d == NULL)) {
4765 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl/%d file in debugfs", i);
4766 return;
4767 }
4768 }
4769
4770 /*
4771 * edma rx fill ring stats
4772 */
4773 edma_rxfill_dir_d = debugfs_create_dir("rxfill", edma_rings_dir_d);
4774 if (unlikely(edma_rxfill_dir_d == NULL)) {
4775 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill directory in debugfs");
4776 return;
4777 }
4778
4779 for (i = 0; i < NSS_EDMA_NUM_RXFILL_RING_MAX; i++) {
4780 memset(file_name, 0, sizeof(file_name));
4781 scnprintf(file_name, sizeof(file_name), "%d", i);
4782 edma_rxfill_d = NULL;
Stephen Wangaed46332016-12-12 17:29:03 -08004783 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 -07004784 if (unlikely(edma_rxfill_d == NULL)) {
4785 nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill/%d file in debugfs", i);
4786 return;
4787 }
4788 }
4789
4790 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304791 * n2h_stats
4792 */
4793 nss_top_main.n2h_dentry = debugfs_create_file("n2h", 0400,
4794 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_n2h_ops);
4795 if (unlikely(nss_top_main.n2h_dentry == NULL)) {
4796 nss_warning("Failed to create qca-nss-drv/stats/n2h directory in debugfs");
4797 return;
4798 }
4799
4800 /*
Thomas Wuc3e382c2014-10-29 15:35:13 -07004801 * lso_rx_stats
4802 */
4803 nss_top_main.lso_rx_dentry = debugfs_create_file("lso_rx", 0400,
4804 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_lso_rx_ops);
4805 if (unlikely(nss_top_main.lso_rx_dentry == NULL)) {
4806 nss_warning("Failed to create qca-nss-drv/stats/lso_rx file in debugfs");
4807 return;
4808 }
4809
4810 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304811 * drv_stats
4812 */
4813 nss_top_main.drv_dentry = debugfs_create_file("drv", 0400,
4814 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_drv_ops);
4815 if (unlikely(nss_top_main.drv_dentry == NULL)) {
4816 nss_warning("Failed to create qca-nss-drv/stats/drv directory in debugfs");
4817 return;
4818 }
4819
4820 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304821 * pppoe_stats
4822 */
4823 nss_top_main.pppoe_dentry = debugfs_create_file("pppoe", 0400,
4824 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pppoe_ops);
4825 if (unlikely(nss_top_main.pppoe_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304826 nss_warning("Failed to create qca-nss-drv/stats/pppoe file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304827 return;
4828 }
4829
4830 /*
4831 * gmac_stats
4832 */
4833 nss_top_main.gmac_dentry = debugfs_create_file("gmac", 0400,
4834 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gmac_ops);
4835 if (unlikely(nss_top_main.gmac_dentry == NULL)) {
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +05304836 nss_warning("Failed to create qca-nss-drv/stats/gmac file in debugfs");
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05304837 return;
4838 }
Saurabh Misra09dddeb2014-09-30 16:38:07 -07004839
4840 /*
4841 * CAPWAP stats.
4842 */
4843 nss_top_main.capwap_encap_dentry = debugfs_create_file("capwap_encap", 0400,
4844 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_encap_ops);
4845 if (unlikely(nss_top_main.capwap_encap_dentry == NULL)) {
4846 nss_warning("Failed to create qca-nss-drv/stats/capwap_encap file in debugfs");
4847 return;
4848 }
4849
4850 nss_top_main.capwap_decap_dentry = debugfs_create_file("capwap_decap", 0400,
4851 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_decap_ops);
4852 if (unlikely(nss_top_main.capwap_decap_dentry == NULL)) {
4853 nss_warning("Failed to create qca-nss-drv/stats/capwap_decap file in debugfs");
4854 return;
4855 }
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304856
4857 /*
4858 * GRE_REDIR stats
4859 */
4860 nss_top_main.gre_redir_dentry = debugfs_create_file("gre_redir", 0400,
Ankit Dhanuka14999992014-11-12 15:35:11 +05304861 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gre_redir_ops);
Ankit Dhanuka6228ebd2014-11-05 17:26:01 +05304862 if (unlikely(nss_top_main.gre_redir_dentry == NULL)) {
4863 nss_warning("Failed to create qca-nss-drv/stats/gre_redir file in debugfs");
4864 return;
4865 }
Ankit Dhanuka14999992014-11-12 15:35:11 +05304866
4867 /*
4868 * SJACK stats
4869 */
4870 nss_top_main.sjack_dentry = debugfs_create_file("sjack", 0400,
4871 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_sjack_ops);
4872 if (unlikely(nss_top_main.sjack_dentry == NULL)) {
4873 nss_warning("Failed to create qca-nss-drv/stats/sjack file in debugfs");
4874 return;
4875 }
Saurabh Misra96998db2014-07-10 12:15:48 -07004876
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304877 /*
Stephen Wang9779d952015-10-28 11:39:07 -07004878 * PORTID stats
4879 */
4880 nss_top_main.portid_dentry = debugfs_create_file("portid", 0400,
4881 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_portid_ops);
4882 if (unlikely(nss_top_main.portid_dentry == NULL)) {
4883 nss_warning("Failed to create qca-nss-drv/stats/portid file in debugfs");
4884 return;
4885 }
4886
4887 /*
Bharath M Kumarcc666e92014-12-24 19:17:28 +05304888 * WIFI stats
4889 */
4890 nss_top_main.wifi_dentry = debugfs_create_file("wifi", 0400,
4891 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_ops);
4892 if (unlikely(nss_top_main.wifi_dentry == NULL)) {
4893 nss_warning("Failed to create qca-nss-drv/stats/wifi file in debugfs");
4894 return;
4895 }
4896
Sundarajan Srinivasan273d9002015-03-03 15:43:16 -08004897 /*
4898 * wifi_if stats
4899 */
4900 nss_top_main.wifi_if_dentry = debugfs_create_file("wifi_if", 0400,
4901 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_if_ops);
4902 if (unlikely(nss_top_main.wifi_if_dentry == NULL)) {
4903 nss_warning("Failed to create qca-nss-drv/stats/wifi_if file in debugfs");
4904 return;
4905 }
4906
Sundarajan Srinivasanab2c8562015-06-09 16:14:10 -07004907 nss_top_main.virt_if_dentry = debugfs_create_file("virt_if", 0400,
4908 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_virt_if_ops);
4909 if (unlikely(nss_top_main.virt_if_dentry == NULL)) {
4910 nss_warning("Failed to create qca-nss-drv/stats/virt_if file in debugfs");
4911 return;
4912 }
4913
Sundarajan Srinivasancd1631b2015-06-18 01:23:30 -07004914 nss_top_main.tx_rx_virt_if_dentry = debugfs_create_file("tx_rx_virt_if", 0400,
4915 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_tx_rx_virt_if_ops);
4916 if (unlikely(nss_top_main.virt_if_dentry == NULL)) {
4917 nss_warning("Failed to create qca-nss-drv/stats/tx_rx_virt_if file in debugfs");
4918 return;
4919 }
4920
ratheesh kannoth7af985d2015-06-24 15:08:40 +05304921 /*
4922 * L2TPV2 Stats
4923 */
4924 nss_top_main.l2tpv2_dentry = debugfs_create_file("l2tpv2", 0400,
4925 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_l2tpv2_ops);
4926 if (unlikely(nss_top_main.l2tpv2_dentry == NULL)) {
4927 nss_warning("Failed to create qca-nss-drv/stats/l2tpv2 file in debugfs");
4928 return;
4929 }
Shyam Sunder66e889d2015-11-02 15:31:20 +05304930
4931 /*
ratheesh kannotha1245c32015-11-04 16:45:43 +05304932 * Map-t Stats
4933 */
4934 nss_top_main.map_t_dentry = debugfs_create_file("map_t", 0400,
4935 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_map_t_ops);
4936 if (unlikely(nss_top_main.map_t_dentry == NULL)) {
4937 nss_warning("Failed to create qca-nss-drv/stats/map_t file in debugfs");
4938 return;
4939 }
4940
4941 /*
ratheesh kannotheb2a0a82017-05-04 09:20:17 +05304942 * GRE statistics
4943 */
4944 nss_top_main.gre_dentry = debugfs_create_file("gre", 0400,
4945 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gre_ops);
4946 if (unlikely(nss_top_main.gre_dentry == NULL)) {
4947 nss_warning("Failed to create qca-nss-drv/stats/gre file in debugfs");
4948 return;
4949 }
4950
4951 /*
Amit Gupta316729b2016-08-12 12:21:15 +05304952 * PPE Stats
4953 */
4954 nss_top_main.ppe_dentry = debugfs_create_dir("ppe", nss_top_main.stats_dentry);
4955 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4956 nss_warning("Failed to create qca-nss-drv directory in debugfs");
4957 return;
4958 }
4959
4960 nss_top_main.ppe_conn_dentry = debugfs_create_file("connection", 0400,
4961 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_conn_ops);
4962 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4963 nss_warning("Failed to create qca-nss-drv/stats/ppe/connection file in debugfs");
4964 }
4965
4966 nss_top_main.ppe_l3_dentry = debugfs_create_file("l3", 0400,
4967 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_l3_ops);
4968 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4969 nss_warning("Failed to create qca-nss-drv/stats/ppe/l3 file in debugfs");
4970 }
4971
4972 nss_top_main.ppe_l3_dentry = debugfs_create_file("ppe_code", 0400,
4973 nss_top_main.ppe_dentry, &nss_top_main, &nss_stats_ppe_code_ops);
4974 if (unlikely(nss_top_main.ppe_dentry == NULL)) {
4975 nss_warning("Failed to create qca-nss-drv/stats/ppe/ppe_code file in debugfs");
4976 }
4977
4978 /*
Amit Gupta79c1c202017-06-30 15:28:13 +05304979 * ppe exception and drop code stats
4980 */
4981 ppe_code_d = debugfs_create_dir("code", nss_top_main.ppe_dentry);
4982 if (unlikely(ppe_code_d == NULL)) {
4983 nss_warning("Failed to create qca-nss-drv/stats/ppe/code directory in debugfs");
4984 return;
4985 }
4986
4987 ppe_cpu_d = debugfs_create_dir("cpu", ppe_code_d);
4988 if (unlikely(ppe_cpu_d == NULL)) {
4989 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/cpu directory in debugfs");
4990 return;
4991 }
4992
4993 ppe_exception_d = debugfs_create_file("exception", 0400, ppe_cpu_d,
4994 &nss_top_main, &nss_stats_ppe_exception_cc_ops);
4995 if (unlikely(ppe_exception_d == NULL)) {
4996 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/exception file in debugfs");
4997 return;
4998 }
4999
5000 ppe_nonexception_d = debugfs_create_file("non-exception", 0400, ppe_cpu_d,
5001 &nss_top_main, &nss_stats_ppe_nonexception_cc_ops);
5002 if (unlikely(ppe_nonexception_d == NULL)) {
5003 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/non-exception file in debugfs");
5004 return;
5005 }
5006
5007 ppe_drop_d = debugfs_create_dir("drop", ppe_code_d);
5008 if (unlikely(ppe_drop_d == NULL)) {
5009 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop directory in debugfs");
5010 return;
5011 }
5012
5013 for (i = 0; i < NSS_PPE_NUM_PHY_PORTS_MAX; i++) {
5014 if (i > 0) {
5015 memset(file_name, 0, sizeof(file_name));
5016 snprintf(file_name, sizeof(file_name), "%d", i);
5017 }
5018
5019 ppe_port_dc_d = NULL;
5020 ppe_port_dc_d = debugfs_create_file((i == 0) ? "cpu" : file_name, 0400, ppe_drop_d,
5021 (void *)(nss_ptr_t)i, &nss_stats_ppe_port_dc_ops);
5022 if (unlikely(ppe_port_dc_d == NULL)) {
5023 nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop/%d file in debugfs", i);
5024 return;
5025 }
5026 }
5027
5028 /*
Shyam Sunder66e889d2015-11-02 15:31:20 +05305029 * PPTP Stats
5030 */
5031 nss_top_main.pptp_dentry = debugfs_create_file("pptp", 0400,
5032 nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pptp_ops);
5033 if (unlikely(nss_top_main.pptp_dentry == NULL)) {
5034 nss_warning("Failed to create qca-nss-drv/stats/pptp file in debugfs");
Tushar Mathurff8741b2015-12-02 20:28:59 +05305035 }
5036
5037 /*
5038 * DTLS Stats
5039 */
5040 nss_top_main.dtls_dentry = debugfs_create_file("dtls", 0400,
5041 nss_top_main.stats_dentry,
5042 &nss_top_main,
5043 &nss_stats_dtls_ops);
5044 if (unlikely(nss_top_main.dtls_dentry == NULL)) {
5045 nss_warning("Failed to create qca-nss-drv/stats/dtls file in debugfs");
Shyam Sunder66e889d2015-11-02 15:31:20 +05305046 return;
5047 }
5048
Thomas Wu71c5ecc2016-06-21 11:15:52 -07005049 /*
5050 * GRE Tunnel Stats
5051 */
5052 nss_top_main.gre_tunnel_dentry = debugfs_create_file("gre_tunnel", 0400,
5053 nss_top_main.stats_dentry,
5054 &nss_top_main,
5055 &nss_stats_gre_tunnel_ops);
5056 if (unlikely(nss_top_main.gre_tunnel_dentry == NULL)) {
5057 nss_warning("Failed to create qca-nss-drv/stats/gre_tunnel file in debugfs");
5058 return;
5059 }
5060
Stephen Wangec5a85c2016-09-08 23:32:27 -07005061 /*
5062 * TrustSec TX Stats
5063 */
5064 nss_top_main.trustsec_tx_dentry = debugfs_create_file("trustsec_tx", 0400,
5065 nss_top_main.stats_dentry,
5066 &nss_top_main,
5067 &nss_stats_trustsec_tx_ops);
5068 if (unlikely(nss_top_main.trustsec_tx_dentry == NULL)) {
5069 nss_warning("Failed to create qca-nss-drv/stats/trustsec_tx file in debugfs");
5070 return;
5071 }
5072
Aniruddha Paul1b170c22017-05-29 12:30:39 +05305073 /*
5074 * WIFILI stats
5075 */
5076 nss_top_main.wifili_dentry = debugfs_create_file("wifili", 0400,
5077 nss_top_main.stats_dentry,
5078 &nss_top_main, &nss_stats_wifili_ops);
5079 if (unlikely(nss_top_main.wifili_dentry == NULL)) {
5080 nss_warning("Failed to create qca-nss-drv/stats/wifili file in debugfs");
5081 return;
5082 }
5083
Jackson Bockusc2a4e682017-06-23 11:59:29 -07005084 /*
5085 * Per-project stats
5086 */
5087 nss_top_main.project_dentry = debugfs_create_dir("project",
5088 nss_top_main.stats_dentry);
5089 if (unlikely(nss_top_main.project_dentry == NULL)) {
5090 nss_warning("Failed to create qca-nss-drv/stats/project directory in debugfs");
5091 return;
5092 }
5093
5094 for (i = 0; i < NSS_MAX_CORES; ++i) {
5095 memset(file_name, 0, sizeof(file_name));
5096 scnprintf(file_name, sizeof(file_name), "core%d", i);
5097 core_dentry = debugfs_create_dir(file_name,
5098 nss_top_main.project_dentry);
5099 if (unlikely(core_dentry == NULL)) {
5100 nss_warning("Failed to create qca-nss-drv/stats/project/core%d directory in debugfs", i);
5101 return;
5102 }
5103
5104 wt_dentry = debugfs_create_file("worker_threads",
5105 0400,
5106 core_dentry,
5107 &(nss_top_main.nss[i]),
5108 &nss_stats_wt_ops);
5109 if (unlikely(wt_dentry == NULL)) {
5110 nss_warning("Failed to create qca-nss-drv/stats/project/core%d/worker_threads file in debugfs", i);
5111 return;
5112 }
5113 }
5114
Saurabh Misra96998db2014-07-10 12:15:48 -07005115 nss_log_init();
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305116}
5117
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305118/*
5119 * nss_stats_clean()
5120 * Cleanup NSS statistics files
5121 */
5122void nss_stats_clean(void)
5123{
5124 /*
5125 * Remove debugfs tree
5126 */
5127 if (likely(nss_top_main.top_dentry != NULL)) {
5128 debugfs_remove_recursive(nss_top_main.top_dentry);
Stephen Wangdc8b5322015-06-27 20:11:50 -07005129 nss_top_main.top_dentry = NULL;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +05305130 }
5131}