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