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