Radhakrishna Jiguru | 1c9b225 | 2013-08-27 23:57:48 +0530 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Murat Sezgin | 49d21d1 | 2016-02-03 17:36:47 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2016, 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" |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * Maximum string length: |
| 28 | * This should be equal to maximum string size of any stats |
| 29 | * inclusive of stats value |
| 30 | */ |
| 31 | #define NSS_STATS_MAX_STR_LENGTH 96 |
| 32 | |
Sundarajan Srinivasan | cd1631b | 2015-06-18 01:23:30 -0700 | [diff] [blame] | 33 | extern int32_t nss_tx_rx_virt_if_copy_stats(int32_t if_num, int i, char *line); |
| 34 | |
Ankit Dhanuka | a1569ce | 2014-05-13 19:58:06 +0530 | [diff] [blame] | 35 | 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] | 36 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 37 | /* |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 38 | * Private data for every file descriptor |
| 39 | */ |
| 40 | struct nss_stats_data { |
Sundarajan Srinivasan | 273d900 | 2015-03-03 15:43:16 -0800 | [diff] [blame] | 41 | uint32_t if_num; /**< Interface number for stats */ |
Ankit Dhanuka | 6228ebd | 2014-11-05 17:26:01 +0530 | [diff] [blame] | 42 | uint32_t index; /**< Index for GRE_REDIR stats */ |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 46 | * Statistics structures |
| 47 | */ |
| 48 | |
| 49 | /* |
| 50 | * nss_stats_str_ipv4 |
| 51 | * IPv4 stats strings |
| 52 | */ |
| 53 | static int8_t *nss_stats_str_ipv4[NSS_STATS_IPV4_MAX] = { |
| 54 | "rx_pkts", |
| 55 | "rx_bytes", |
| 56 | "tx_pkts", |
| 57 | "tx_bytes", |
| 58 | "create_requests", |
| 59 | "create_collisions", |
| 60 | "create_invalid_interface", |
| 61 | "destroy_requests", |
| 62 | "destroy_misses", |
| 63 | "hash_hits", |
| 64 | "hash_reorders", |
| 65 | "flushes", |
Selin Dag | 60ea2b2 | 2014-11-05 09:36:22 -0800 | [diff] [blame] | 66 | "evictions", |
Kiran Kumar C. S. K | 1299800 | 2014-09-04 17:09:03 +0530 | [diff] [blame] | 67 | "fragmentations", |
| 68 | "mc_create_requests", |
| 69 | "mc_update_requests", |
| 70 | "mc_create_invalid_interface", |
| 71 | "mc_destroy_requests", |
| 72 | "mc_destroy_misses", |
| 73 | "mc_flushes", |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /* |
Selin Dag | 6d9b0c1 | 2014-11-04 18:27:21 -0800 | [diff] [blame] | 77 | * nss_stats_str_ipv4_reasm |
| 78 | * IPv4 reassembly stats strings |
| 79 | */ |
| 80 | static int8_t *nss_stats_str_ipv4_reasm[NSS_STATS_IPV4_REASM_MAX] = { |
| 81 | "evictions", |
| 82 | "alloc_fails", |
| 83 | "timeouts", |
| 84 | }; |
| 85 | |
| 86 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 87 | * nss_stats_str_ipv6 |
| 88 | * IPv6 stats strings |
| 89 | */ |
| 90 | static int8_t *nss_stats_str_ipv6[NSS_STATS_IPV6_MAX] = { |
| 91 | "rx_pkts", |
| 92 | "rx_bytes", |
| 93 | "tx_pkts", |
| 94 | "tx_bytes", |
| 95 | "create_requests", |
| 96 | "create_collisions", |
| 97 | "create_invalid_interface", |
| 98 | "destroy_requests", |
| 99 | "destroy_misses", |
| 100 | "hash_hits", |
| 101 | "hash_reorders", |
| 102 | "flushes", |
| 103 | "evictions", |
Selin Dag | 5d68caa | 2015-05-12 13:23:33 -0700 | [diff] [blame] | 104 | "fragmentations", |
| 105 | "frag_fails", |
Kiran Kumar C. S. K | 1299800 | 2014-09-04 17:09:03 +0530 | [diff] [blame] | 106 | "mc_create_requests", |
| 107 | "mc_update_requests", |
| 108 | "mc_create_invalid_interface", |
| 109 | "mc_destroy_requests", |
| 110 | "mc_destroy_misses", |
| 111 | "mc_flushes", |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | /* |
Selin Dag | 60a2f5b | 2015-06-29 14:39:49 -0700 | [diff] [blame] | 115 | * nss_stats_str_ipv6_reasm |
| 116 | * IPv6 reassembly stats strings |
| 117 | */ |
| 118 | static int8_t *nss_stats_str_ipv6_reasm[NSS_STATS_IPV6_REASM_MAX] = { |
| 119 | "alloc_fails", |
| 120 | "timeouts", |
| 121 | "discards", |
| 122 | }; |
| 123 | |
| 124 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 125 | * nss_stats_str_n2h |
| 126 | * N2H stats strings |
| 127 | */ |
| 128 | static int8_t *nss_stats_str_n2h[NSS_STATS_N2H_MAX] = { |
| 129 | "queue_dropped", |
| 130 | "ticks", |
| 131 | "worst_ticks", |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 132 | "iterations", |
Thomas Wu | 3fd8dd7 | 2014-06-11 15:57:05 -0700 | [diff] [blame] | 133 | "pbuf_ocm_alloc_fails", |
| 134 | "pbuf_ocm_free_count", |
| 135 | "pbuf_ocm_total_count", |
| 136 | "pbuf_default_alloc_fails", |
| 137 | "pbuf_default_free_count", |
| 138 | "pbuf_default_total_count", |
Sakthi Vignesh Radhakrishnan | 2a8ee96 | 2014-11-22 13:35:38 -0800 | [diff] [blame] | 139 | "payload_fails", |
Thomas Wu | 5367984 | 2015-01-22 13:37:35 -0800 | [diff] [blame] | 140 | "payload_free_count", |
Sakthi Vignesh Radhakrishnan | 2a8ee96 | 2014-11-22 13:35:38 -0800 | [diff] [blame] | 141 | "h2n_control_packets", |
| 142 | "h2n_control_bytes", |
| 143 | "n2h_control_packets", |
| 144 | "n2h_control_bytes", |
| 145 | "h2n_data_packets", |
| 146 | "h2n_data_bytes", |
| 147 | "n2h_data_packets", |
| 148 | "n2h_data_bytes", |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 149 | "n2h_tot_payloads", |
Guojun Jin | 85dfa7b | 2015-09-02 15:13:56 -0700 | [diff] [blame] | 150 | "n2h_data_interface_invalid", |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | /* |
Thomas Wu | c3e382c | 2014-10-29 15:35:13 -0700 | [diff] [blame] | 154 | * nss_stats_str_lso_rx |
| 155 | * LSO_RX stats strings |
| 156 | */ |
| 157 | static int8_t *nss_stats_str_lso_rx[NSS_STATS_LSO_RX_MAX] = { |
| 158 | "tx_dropped", |
| 159 | "dropped", |
| 160 | "pbuf_alloc_fail", |
| 161 | "pbuf_reference_fail" |
| 162 | }; |
| 163 | |
| 164 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 165 | * nss_stats_str_drv |
| 166 | * Host driver stats strings |
| 167 | */ |
| 168 | static int8_t *nss_stats_str_drv[NSS_STATS_DRV_MAX] = { |
| 169 | "nbuf_alloc_errors", |
| 170 | "tx_queue_full[0]", |
| 171 | "tx_queue_full[1]", |
| 172 | "tx_buffers_empty", |
| 173 | "tx_buffers_pkt", |
| 174 | "tx_buffers_cmd", |
| 175 | "tx_buffers_crypto", |
| 176 | "rx_buffers_empty", |
| 177 | "rx_buffers_pkt", |
| 178 | "rx_buffers_cmd_resp", |
| 179 | "rx_buffers_status_sync", |
| 180 | "rx_buffers_crypto", |
Thomas Wu | 0acd816 | 2014-12-07 15:43:39 -0800 | [diff] [blame] | 181 | "rx_buffers_virtual", |
| 182 | "tx_skb_simple", |
| 183 | "tx_skb_nr_frags", |
| 184 | "tx_skb_fraglist", |
| 185 | "rx_skb_simple", |
| 186 | "rx_skb_nr_frags", |
| 187 | "rx_skb_fraglist", |
Sundarajan Srinivasan | 6e0366b | 2015-01-20 12:10:42 -0800 | [diff] [blame] | 188 | "rx_bad_desciptor", |
Thomas Wu | 1fbf521 | 2015-06-04 14:38:40 -0700 | [diff] [blame] | 189 | "nss_skb_count", |
| 190 | "rx_chain_seg_processed", |
| 191 | "rx_frag_seg_processed" |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 195 | * nss_stats_str_pppoe |
| 196 | * PPPoE stats strings |
| 197 | */ |
| 198 | static int8_t *nss_stats_str_pppoe[NSS_STATS_PPPOE_MAX] = { |
| 199 | "create_requests", |
| 200 | "create_failures", |
| 201 | "destroy_requests", |
| 202 | "destroy_misses" |
| 203 | }; |
| 204 | |
| 205 | /* |
| 206 | * nss_stats_str_gmac |
| 207 | * GMAC stats strings |
| 208 | */ |
| 209 | static int8_t *nss_stats_str_gmac[NSS_STATS_GMAC_MAX] = { |
| 210 | "ticks", |
| 211 | "worst_ticks", |
| 212 | "iterations" |
| 213 | }; |
| 214 | |
| 215 | /* |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 216 | * nss_stats_str_node |
| 217 | * Interface stats strings per node |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 218 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 219 | static int8_t *nss_stats_str_node[NSS_STATS_NODE_MAX] = { |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 220 | "rx_packets", |
| 221 | "rx_bytes", |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 222 | "rx_dropped", |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 223 | "tx_packets", |
| 224 | "tx_bytes" |
| 225 | }; |
| 226 | |
| 227 | /* |
Murat Sezgin | 99dab64 | 2014-08-28 14:40:34 -0700 | [diff] [blame] | 228 | * nss_stats_str_eth_rx |
| 229 | * eth_rx stats strings |
| 230 | */ |
| 231 | static int8_t *nss_stats_str_eth_rx[NSS_STATS_ETH_RX_MAX] = { |
| 232 | "ticks", |
| 233 | "worst_ticks", |
| 234 | "iterations" |
| 235 | }; |
| 236 | |
| 237 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 238 | * nss_stats_str_if_exception_unknown |
| 239 | * Interface stats strings for unknown exceptions |
| 240 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 241 | 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] | 242 | "UNKNOWN_L3_PROTOCOL", |
| 243 | "ETH_HDR_MISSING", |
| 244 | "VLAN_MISSING" |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | /* |
| 248 | * nss_stats_str_if_exception_ipv4 |
| 249 | * Interface stats strings for ipv4 exceptions |
| 250 | */ |
| 251 | static int8_t *nss_stats_str_if_exception_ipv4[NSS_EXCEPTION_EVENT_IPV4_MAX] = { |
| 252 | "IPV4_ICMP_HEADER_INCOMPLETE", |
| 253 | "IPV4_ICMP_UNHANDLED_TYPE", |
| 254 | "IPV4_ICMP_IPV4_HEADER_INCOMPLETE", |
| 255 | "IPV4_ICMP_IPV4_UDP_HEADER_INCOMPLETE", |
| 256 | "IPV4_ICMP_IPV4_TCP_HEADER_INCOMPLETE", |
| 257 | "IPV4_ICMP_IPV4_UNKNOWN_PROTOCOL", |
| 258 | "IPV4_ICMP_NO_ICME", |
| 259 | "IPV4_ICMP_FLUSH_TO_HOST", |
| 260 | "IPV4_TCP_HEADER_INCOMPLETE", |
| 261 | "IPV4_TCP_NO_ICME", |
| 262 | "IPV4_TCP_IP_OPTION", |
| 263 | "IPV4_TCP_IP_FRAGMENT", |
| 264 | "IPV4_TCP_SMALL_TTL", |
| 265 | "IPV4_TCP_NEEDS_FRAGMENTATION", |
| 266 | "IPV4_TCP_FLAGS", |
| 267 | "IPV4_TCP_SEQ_EXCEEDS_RIGHT_EDGE", |
| 268 | "IPV4_TCP_SMALL_DATA_OFFS", |
| 269 | "IPV4_TCP_BAD_SACK", |
| 270 | "IPV4_TCP_BIG_DATA_OFFS", |
| 271 | "IPV4_TCP_SEQ_BEFORE_LEFT_EDGE", |
| 272 | "IPV4_TCP_ACK_EXCEEDS_RIGHT_EDGE", |
| 273 | "IPV4_TCP_ACK_BEFORE_LEFT_EDGE", |
| 274 | "IPV4_UDP_HEADER_INCOMPLETE", |
| 275 | "IPV4_UDP_NO_ICME", |
| 276 | "IPV4_UDP_IP_OPTION", |
| 277 | "IPV4_UDP_IP_FRAGMENT", |
| 278 | "IPV4_UDP_SMALL_TTL", |
| 279 | "IPV4_UDP_NEEDS_FRAGMENTATION", |
| 280 | "IPV4_WRONG_TARGET_MAC", |
| 281 | "IPV4_HEADER_INCOMPLETE", |
| 282 | "IPV4_BAD_TOTAL_LENGTH", |
| 283 | "IPV4_BAD_CHECKSUM", |
| 284 | "IPV4_NON_INITIAL_FRAGMENT", |
| 285 | "IPV4_DATAGRAM_INCOMPLETE", |
| 286 | "IPV4_OPTIONS_INCOMPLETE", |
Radha krishna Simha Jiguru | 59a1a1c | 2014-01-27 18:29:40 +0530 | [diff] [blame] | 287 | "IPV4_UNKNOWN_PROTOCOL", |
| 288 | "IPV4_ESP_HEADER_INCOMPLETE", |
| 289 | "IPV4_ESP_NO_ICME", |
| 290 | "IPV4_ESP_IP_OPTION", |
| 291 | "IPV4_ESP_IP_FRAGMENT", |
| 292 | "IPV4_ESP_SMALL_TTL", |
| 293 | "IPV4_ESP_NEEDS_FRAGMENTATION", |
| 294 | "IPV4_INGRESS_VID_MISMATCH", |
Thomas Wu | 8d6f4b2 | 2014-06-09 14:46:18 -0700 | [diff] [blame] | 295 | "IPV4_INGRESS_VID_MISSING", |
Radha krishna Simha Jiguru | 59a1a1c | 2014-01-27 18:29:40 +0530 | [diff] [blame] | 296 | "IPV4_6RD_NO_ICME", |
| 297 | "IPV4_6RD_IP_OPTION", |
| 298 | "IPV4_6RD_IP_FRAGMENT", |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 299 | "IPV4_6RD_NEEDS_FRAGMENTATION", |
| 300 | "IPV4_DSCP_MARKING_MISMATCH", |
Murat Sezgin | 7c5956a | 2014-05-12 09:59:51 -0700 | [diff] [blame] | 301 | "IPV4_VLAN_MARKING_MISMATCH", |
Murat Sezgin | 49d21d1 | 2016-02-03 17:36:47 -0800 | [diff] [blame] | 302 | "IPV4_DEPRECATED", |
Radha krishna Simha Jiguru | 00cfe56 | 2014-10-21 16:22:12 +0530 | [diff] [blame] | 303 | "IPV4_GRE_HEADER_INCOMPLETE", |
| 304 | "IPV4_GRE_NO_ICME", |
| 305 | "IPV4_GRE_IP_OPTION", |
| 306 | "IPV4_GRE_IP_FRAGMENT", |
| 307 | "IPV4_GRE_SMALL_TTL", |
| 308 | "IPV4_GRE_NEEDS_FRAGMENTATION", |
Selin Dag | 60ea2b2 | 2014-11-05 09:36:22 -0800 | [diff] [blame] | 309 | "IPV4_FRAG_DF_SET", |
| 310 | "IPV4_FRAG_FAIL", |
Saurabh Misra | 5b07cc0 | 2015-01-15 14:20:58 -0800 | [diff] [blame] | 311 | "IPV4_DESTROY", |
| 312 | "IPV4_ICMP_IPV4_UDPLITE_HEADER_INCOMPLETE", |
| 313 | "IPV4_UDPLITE_HEADER_INCOMPLETE", |
| 314 | "IPV4_UDPLITE_NO_ICME", |
| 315 | "IPV4_UDPLITE_IP_OPTION", |
| 316 | "IPV4_UDPLITE_IP_FRAGMENT", |
| 317 | "IPV4_UDPLITE_SMALL_TTL", |
Kiran Kumar C. S. K | 1299800 | 2014-09-04 17:09:03 +0530 | [diff] [blame] | 318 | "IPV4_UDPLITE_NEEDS_FRAGMENTATION", |
| 319 | "IPV4_MC_UDP_NO_ICME", |
| 320 | "IPV4_MC_MEM_ALLOC_FAILURE", |
| 321 | "IPV4_MC_UPDATE_FAILURE", |
| 322 | "IPV4_MC_PBUF_ALLOC_FAILURE" |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | /* |
| 326 | * nss_stats_str_if_exception_ipv6 |
| 327 | * Interface stats strings for ipv6 exceptions |
| 328 | */ |
| 329 | static int8_t *nss_stats_str_if_exception_ipv6[NSS_EXCEPTION_EVENT_IPV6_MAX] = { |
| 330 | "IPV6_ICMP_HEADER_INCOMPLETE", |
| 331 | "IPV6_ICMP_UNHANDLED_TYPE", |
| 332 | "IPV6_ICMP_IPV6_HEADER_INCOMPLETE", |
| 333 | "IPV6_ICMP_IPV6_UDP_HEADER_INCOMPLETE", |
| 334 | "IPV6_ICMP_IPV6_TCP_HEADER_INCOMPLETE", |
| 335 | "IPV6_ICMP_IPV6_UNKNOWN_PROTOCOL", |
| 336 | "IPV6_ICMP_NO_ICME", |
| 337 | "IPV6_ICMP_FLUSH_TO_HOST", |
| 338 | "IPV6_TCP_HEADER_INCOMPLETE", |
| 339 | "IPV6_TCP_NO_ICME", |
| 340 | "IPV6_TCP_SMALL_HOP_LIMIT", |
| 341 | "IPV6_TCP_NEEDS_FRAGMENTATION", |
| 342 | "IPV6_TCP_FLAGS", |
| 343 | "IPV6_TCP_SEQ_EXCEEDS_RIGHT_EDGE", |
| 344 | "IPV6_TCP_SMALL_DATA_OFFS", |
| 345 | "IPV6_TCP_BAD_SACK", |
| 346 | "IPV6_TCP_BIG_DATA_OFFS", |
| 347 | "IPV6_TCP_SEQ_BEFORE_LEFT_EDGE", |
| 348 | "IPV6_TCP_ACK_EXCEEDS_RIGHT_EDGE", |
| 349 | "IPV6_TCP_ACK_BEFORE_LEFT_EDGE", |
| 350 | "IPV6_UDP_HEADER_INCOMPLETE", |
| 351 | "IPV6_UDP_NO_ICME", |
| 352 | "IPV6_UDP_SMALL_HOP_LIMIT", |
| 353 | "IPV6_UDP_NEEDS_FRAGMENTATION", |
| 354 | "IPV6_WRONG_TARGET_MAC", |
| 355 | "IPV6_HEADER_INCOMPLETE", |
Radha krishna Simha Jiguru | 59a1a1c | 2014-01-27 18:29:40 +0530 | [diff] [blame] | 356 | "IPV6_UNKNOWN_PROTOCOL", |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 357 | "IPV6_INGRESS_VID_MISMATCH", |
Thomas Wu | 8d6f4b2 | 2014-06-09 14:46:18 -0700 | [diff] [blame] | 358 | "IPV6_INGRESS_VID_MISSING", |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 359 | "IPV6_DSCP_MARKING_MISMATCH", |
| 360 | "IPV6_VLAN_MARKING_MISMATCH", |
Murat Sezgin | 49d21d1 | 2016-02-03 17:36:47 -0800 | [diff] [blame] | 361 | "IPV6_DEPRECATED", |
Saurabh Misra | 5b07cc0 | 2015-01-15 14:20:58 -0800 | [diff] [blame] | 362 | "IPV6_GRE_NO_ICME", |
| 363 | "IPV6_GRE_NEEDS_FRAGMENTATION", |
| 364 | "IPV6_GRE_SMALL_HOP_LIMIT", |
| 365 | "IPV6_DESTROY", |
| 366 | "IPV6_ICMP_IPV6_UDPLITE_HEADER_INCOMPLETE", |
| 367 | "IPV6_UDPLITE_HEADER_INCOMPLETE", |
| 368 | "IPV6_UDPLITE_NO_ICME", |
| 369 | "IPV6_UDPLITE_SMALL_HOP_LIMIT", |
Kiran Kumar C. S. K | 1299800 | 2014-09-04 17:09:03 +0530 | [diff] [blame] | 370 | "IPV6_UDPLITE_NEEDS_FRAGMENTATION", |
| 371 | "IPV6_MC_UDP_NO_ICME", |
| 372 | "IPV6_MC_MEM_ALLOC_FAILURE", |
| 373 | "IPV6_MC_UPDATE_FAILURE", |
mandrw | 7125bac | 2016-01-14 19:36:46 +0530 | [diff] [blame^] | 374 | "IPV6_MC_PBUF_ALLOC_FAILURE", |
| 375 | "IPV6_ESP_HEADER_INCOMPLETE", |
| 376 | "IPV6_ESP_NO_ICME", |
| 377 | "IPV6_ESP_IP_FRAGMENT", |
| 378 | "IPV6_ESP_SMALL_HOP_LIMIT", |
| 379 | "IPV6_ESP_NEEDS_FRAGMENTATION" |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 380 | }; |
| 381 | |
| 382 | /* |
| 383 | * nss_stats_str_if_exception_pppoe |
| 384 | * Interface stats strings for PPPoE exceptions |
| 385 | */ |
Ankit Dhanuka | a1569ce | 2014-05-13 19:58:06 +0530 | [diff] [blame] | 386 | 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] | 387 | "PPPOE_WRONG_VERSION_OR_TYPE", |
| 388 | "PPPOE_WRONG_CODE", |
| 389 | "PPPOE_HEADER_INCOMPLETE", |
Murat Sezgin | 7c5956a | 2014-05-12 09:59:51 -0700 | [diff] [blame] | 390 | "PPPOE_UNSUPPORTED_PPP_PROTOCOL", |
Murat Sezgin | 49d21d1 | 2016-02-03 17:36:47 -0800 | [diff] [blame] | 391 | "PPPOE_DEPRECATED" |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 392 | }; |
| 393 | |
| 394 | /* |
Bharath M Kumar | cc666e9 | 2014-12-24 19:17:28 +0530 | [diff] [blame] | 395 | * nss_stats_str_wifi |
| 396 | * Wifi statistics strings |
| 397 | */ |
| 398 | static int8_t *nss_stats_str_wifi[NSS_STATS_WIFI_MAX] = { |
| 399 | "RX_PACKETS", |
| 400 | "RX_DROPPED", |
| 401 | "TX_PACKETS", |
| 402 | "TX_DROPPED", |
| 403 | "TX_TRANSMIT_COMPLETED", |
| 404 | "TX_MGMT_RECEIVED", |
| 405 | "TX_MGMT_TRANSMITTED", |
| 406 | "TX_MGMT_DROPPED", |
| 407 | "TX_MGMT_COMPLETED", |
| 408 | "TX_INV_PEER_ENQ_CNT", |
| 409 | "RX_INV_PEER_RCV_CNT", |
| 410 | "RX_PN_CHECK_FAILED", |
| 411 | "RX_PKTS_DELIVERD", |
Radha krishna Simha Jiguru | 36304d1 | 2015-12-03 20:21:02 +0530 | [diff] [blame] | 412 | "RX_BYTES_DELIVERED", |
| 413 | "TX_BYTES_COMPLETED", |
Pamidipati, Vijay | b7a439f | 2016-02-01 14:14:50 +0530 | [diff] [blame] | 414 | "RX_DELIVER_UNALIGNED_DROP_CNT" |
Bharath M Kumar | cc666e9 | 2014-12-24 19:17:28 +0530 | [diff] [blame] | 415 | }; |
| 416 | |
| 417 | /* |
Stephen Wang | 9779d95 | 2015-10-28 11:39:07 -0700 | [diff] [blame] | 418 | * nss_stats_str_portid |
| 419 | * PortID statistics strings |
| 420 | */ |
| 421 | static int8_t *nss_stats_str_portid[NSS_STATS_PORTID_MAX] = { |
| 422 | "RX_INVALID_HEADER", |
| 423 | }; |
| 424 | |
| 425 | /* |
Tushar Mathur | ff8741b | 2015-12-02 20:28:59 +0530 | [diff] [blame] | 426 | * nss_stats_str_dtls_session_stats |
| 427 | * DTLS statistics strings for nss session stats |
| 428 | */ |
| 429 | static int8_t *nss_stats_str_dtls_session_debug_stats[NSS_STATS_DTLS_SESSION_MAX] = { |
| 430 | "RX_PKTS", |
| 431 | "TX_PKTS", |
| 432 | "RX_DROPPED", |
| 433 | "RX_AUTH_DONE", |
| 434 | "TX_AUTH_DONE", |
| 435 | "RX_CIPHER_DONE", |
| 436 | "TX_CIPHER_DONE", |
| 437 | "RX_CBUF_ALLOC_FAIL", |
| 438 | "TX_CBUF_ALLOC_FAIL", |
| 439 | "TX_CENQUEUE_FAIL", |
| 440 | "RX_CENQUEUE_FAIL", |
| 441 | "TX_DROPPED_HROOM", |
| 442 | "TX_DROPPED_TROOM", |
| 443 | "TX_FORWARD_ENQUEUE_FAIL", |
| 444 | "RX_FORWARD_ENQUEUE_FAIL", |
| 445 | "RX_INVALID_VERSION", |
| 446 | "RX_INVALID_EPOCH", |
| 447 | "RX_MALFORMED", |
| 448 | "RX_CIPHER_FAIL", |
| 449 | "RX_AUTH_FAIL", |
| 450 | "RX_CAPWAP_CLASSIFY_FAIL", |
| 451 | "RX_SINGLE_REC_DGRAM", |
| 452 | "RX_MULTI_REC_DGRAM", |
| 453 | "RX_REPLAY_FAIL", |
| 454 | "RX_REPLAY_DUPLICATE", |
| 455 | "RX_REPLAY_OUT_OF_WINDOW", |
| 456 | "OUTFLOW_QUEUE_FULL", |
| 457 | "DECAP_QUEUE_FULL", |
| 458 | "PBUF_ALLOC_FAIL", |
| 459 | "PBUF_COPY_FAIL", |
| 460 | "EPOCH", |
| 461 | "TX_SEQ_HIGH", |
| 462 | "TX_SEQ_LOW", |
| 463 | }; |
| 464 | |
| 465 | /* |
ratheesh kannoth | 7af985d | 2015-06-24 15:08:40 +0530 | [diff] [blame] | 466 | * nss_stats_str_l2tpv2_session_stats |
| 467 | * l2tpv2 statistics strings for nss session stats |
| 468 | */ |
| 469 | static int8_t *nss_stats_str_l2tpv2_session_debug_stats[NSS_STATS_L2TPV2_SESSION_MAX] = { |
| 470 | "RX_PPP_LCP_PKTS", |
| 471 | "RX_EXP_PKTS", |
| 472 | "ENCAP_PBUF_ALLOC_FAIL", |
| 473 | "DECAP_PBUF_ALLOC_FAIL" |
| 474 | }; |
| 475 | |
| 476 | /* |
Shyam Sunder | 66e889d | 2015-11-02 15:31:20 +0530 | [diff] [blame] | 477 | * nss_stats_str_ppt_session_stats |
| 478 | * PPTP statistics strings for nss session stats |
| 479 | */ |
| 480 | static int8_t *nss_stats_str_pptp_session_debug_stats[NSS_STATS_PPTP_SESSION_MAX] = { |
| 481 | "RX_DROPPED", |
| 482 | "TX_DROPPED", |
| 483 | "ENCAP_PBUF_ALLOC_FAIL", |
| 484 | "DECAP_PBUF_ALLOC_FAIL" |
| 485 | }; |
| 486 | |
| 487 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 488 | * nss_stats_ipv4_read() |
| 489 | * Read IPV4 stats |
| 490 | */ |
| 491 | static ssize_t nss_stats_ipv4_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 492 | { |
| 493 | int32_t i; |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 494 | /* |
| 495 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 496 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 497 | 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] | 498 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 499 | size_t size_wr = 0; |
| 500 | ssize_t bytes_read = 0; |
| 501 | uint64_t *stats_shadow; |
| 502 | |
| 503 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 504 | if (unlikely(lbuf == NULL)) { |
| 505 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 506 | return 0; |
| 507 | } |
| 508 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 509 | /* |
| 510 | * Note: The assumption here is that exception event count is larger than other statistics count for IPv4 |
| 511 | */ |
| 512 | stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV4_MAX * 8, GFP_KERNEL); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 513 | if (unlikely(stats_shadow == NULL)) { |
| 514 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 515 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 516 | return 0; |
| 517 | } |
| 518 | |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 519 | size_wr = scnprintf(lbuf, size_al, "ipv4 stats start:\n\n"); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 520 | |
| 521 | /* |
| 522 | * Common node stats |
| 523 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 524 | 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] | 525 | spin_lock_bh(&nss_top_main.stats_lock); |
| 526 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 527 | stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_RX_INTERFACE][i]; |
| 528 | } |
| 529 | |
| 530 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 531 | |
| 532 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 533 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 534 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 535 | } |
| 536 | |
| 537 | /* |
| 538 | * IPv4 node stats |
| 539 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 540 | 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] | 541 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 542 | spin_lock_bh(&nss_top_main.stats_lock); |
| 543 | for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) { |
| 544 | stats_shadow[i] = nss_top_main.stats_ipv4[i]; |
| 545 | } |
| 546 | |
| 547 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 548 | |
| 549 | for (i = 0; (i < NSS_STATS_IPV4_MAX); i++) { |
| 550 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 551 | "%s = %llu\n", nss_stats_str_ipv4[i], stats_shadow[i]); |
| 552 | } |
| 553 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 554 | /* |
| 555 | * Exception stats |
| 556 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 557 | 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] | 558 | |
| 559 | spin_lock_bh(&nss_top_main.stats_lock); |
| 560 | for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) { |
| 561 | stats_shadow[i] = nss_top_main.stats_if_exception_ipv4[i]; |
| 562 | } |
| 563 | |
| 564 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 565 | |
| 566 | for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV4_MAX); i++) { |
| 567 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 568 | "%s = %llu\n", nss_stats_str_if_exception_ipv4[i], stats_shadow[i]); |
| 569 | } |
| 570 | |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 571 | 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] | 572 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 573 | kfree(lbuf); |
| 574 | kfree(stats_shadow); |
| 575 | |
| 576 | return bytes_read; |
| 577 | } |
| 578 | |
| 579 | /* |
Selin Dag | 6d9b0c1 | 2014-11-04 18:27:21 -0800 | [diff] [blame] | 580 | * nss_stats_ipv4_reasm_read() |
| 581 | * Read IPV4 reassembly stats |
| 582 | */ |
| 583 | static ssize_t nss_stats_ipv4_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 584 | { |
| 585 | int32_t i; |
| 586 | /* |
| 587 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 588 | */ |
| 589 | uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV4_REASM_MAX + 3) + 5; |
| 590 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 591 | size_t size_wr = 0; |
| 592 | ssize_t bytes_read = 0; |
| 593 | uint64_t *stats_shadow; |
| 594 | |
| 595 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 596 | if (unlikely(lbuf == NULL)) { |
| 597 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 598 | return 0; |
| 599 | } |
| 600 | |
| 601 | stats_shadow = kzalloc(NSS_STATS_IPV4_REASM_MAX * 8, GFP_KERNEL); |
| 602 | if (unlikely(stats_shadow == NULL)) { |
| 603 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 604 | kfree(lbuf); |
Selin Dag | 6d9b0c1 | 2014-11-04 18:27:21 -0800 | [diff] [blame] | 605 | return 0; |
| 606 | } |
| 607 | |
| 608 | size_wr = scnprintf(lbuf, size_al, "ipv4 reasm stats start:\n\n"); |
| 609 | |
| 610 | /* |
| 611 | * Common node stats |
| 612 | */ |
| 613 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n"); |
| 614 | spin_lock_bh(&nss_top_main.stats_lock); |
| 615 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 616 | stats_shadow[i] = nss_top_main.stats_node[NSS_IPV4_REASM_INTERFACE][i]; |
| 617 | } |
| 618 | |
| 619 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 620 | |
| 621 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 622 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 623 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 624 | } |
| 625 | |
| 626 | /* |
| 627 | * IPv4 reasm node stats |
| 628 | */ |
| 629 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm node stats:\n\n"); |
| 630 | |
| 631 | spin_lock_bh(&nss_top_main.stats_lock); |
| 632 | for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) { |
| 633 | stats_shadow[i] = nss_top_main.stats_ipv4_reasm[i]; |
| 634 | } |
| 635 | |
| 636 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 637 | |
| 638 | for (i = 0; (i < NSS_STATS_IPV4_REASM_MAX); i++) { |
| 639 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 640 | "%s = %llu\n", nss_stats_str_ipv4_reasm[i], stats_shadow[i]); |
| 641 | } |
| 642 | |
| 643 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv4 reasm stats end\n\n"); |
| 644 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 645 | kfree(lbuf); |
| 646 | kfree(stats_shadow); |
| 647 | |
| 648 | return bytes_read; |
| 649 | } |
| 650 | |
| 651 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 652 | * nss_stats_ipv6_read() |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 653 | * Read IPV6 stats |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 654 | */ |
| 655 | static ssize_t nss_stats_ipv6_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 656 | { |
| 657 | int32_t i; |
| 658 | |
| 659 | /* |
| 660 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 661 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 662 | 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] | 663 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 664 | size_t size_wr = 0; |
| 665 | ssize_t bytes_read = 0; |
| 666 | uint64_t *stats_shadow; |
| 667 | |
| 668 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 669 | if (unlikely(lbuf == NULL)) { |
| 670 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 671 | return 0; |
| 672 | } |
| 673 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 674 | /* |
| 675 | * Note: The assumption here is that exception event count is larger than other statistics count for IPv4 |
| 676 | */ |
| 677 | stats_shadow = kzalloc(NSS_EXCEPTION_EVENT_IPV6_MAX * 8, GFP_KERNEL); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 678 | if (unlikely(stats_shadow == NULL)) { |
| 679 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 680 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 681 | return 0; |
| 682 | } |
| 683 | |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 684 | size_wr = scnprintf(lbuf, size_al, "ipv6 stats start:\n\n"); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 685 | |
| 686 | /* |
| 687 | * Common node stats |
| 688 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 689 | 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] | 690 | spin_lock_bh(&nss_top_main.stats_lock); |
| 691 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 692 | stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_RX_INTERFACE][i]; |
| 693 | } |
| 694 | |
| 695 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 696 | |
| 697 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 698 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 699 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 700 | } |
| 701 | |
| 702 | /* |
| 703 | * IPv6 node stats |
| 704 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 705 | 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] | 706 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 707 | spin_lock_bh(&nss_top_main.stats_lock); |
| 708 | for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) { |
| 709 | stats_shadow[i] = nss_top_main.stats_ipv6[i]; |
| 710 | } |
| 711 | |
| 712 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 713 | |
| 714 | for (i = 0; (i < NSS_STATS_IPV6_MAX); i++) { |
| 715 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 716 | "%s = %llu\n", nss_stats_str_ipv6[i], stats_shadow[i]); |
| 717 | } |
| 718 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 719 | /* |
| 720 | * Exception stats |
| 721 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 722 | 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] | 723 | |
| 724 | spin_lock_bh(&nss_top_main.stats_lock); |
| 725 | for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) { |
| 726 | stats_shadow[i] = nss_top_main.stats_if_exception_ipv6[i]; |
| 727 | } |
| 728 | |
| 729 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 730 | |
| 731 | for (i = 0; (i < NSS_EXCEPTION_EVENT_IPV6_MAX); i++) { |
| 732 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 733 | "%s = %llu\n", nss_stats_str_if_exception_ipv6[i], stats_shadow[i]); |
| 734 | } |
| 735 | |
| 736 | 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] | 737 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 738 | kfree(lbuf); |
| 739 | kfree(stats_shadow); |
| 740 | |
| 741 | return bytes_read; |
| 742 | } |
| 743 | |
| 744 | /* |
Selin Dag | 60a2f5b | 2015-06-29 14:39:49 -0700 | [diff] [blame] | 745 | * nss_stats_ipv6_reasm_read() |
| 746 | * Read IPV6 reassembly stats |
| 747 | */ |
| 748 | static ssize_t nss_stats_ipv6_reasm_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 749 | { |
| 750 | int32_t i; |
| 751 | /* |
| 752 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 753 | */ |
| 754 | uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_IPV6_REASM_MAX + 3) + 5; |
| 755 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 756 | size_t size_wr = 0; |
| 757 | ssize_t bytes_read = 0; |
| 758 | uint64_t *stats_shadow; |
| 759 | |
| 760 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 761 | if (unlikely(lbuf == NULL)) { |
| 762 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | stats_shadow = kzalloc(NSS_STATS_IPV6_REASM_MAX * 8, GFP_KERNEL); |
| 767 | if (unlikely(stats_shadow == NULL)) { |
| 768 | nss_warning("Could not allocate memory for local shadow buffer"); |
| 769 | kfree(lbuf); |
| 770 | return 0; |
| 771 | } |
| 772 | |
| 773 | size_wr = scnprintf(lbuf, size_al, "ipv6 reasm stats start:\n\n"); |
| 774 | |
| 775 | /* |
| 776 | * Common node stats |
| 777 | */ |
| 778 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n"); |
| 779 | spin_lock_bh(&nss_top_main.stats_lock); |
| 780 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 781 | stats_shadow[i] = nss_top_main.stats_node[NSS_IPV6_REASM_INTERFACE][i]; |
| 782 | } |
| 783 | |
| 784 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 785 | |
| 786 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 787 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 788 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 789 | } |
| 790 | |
| 791 | /* |
| 792 | * Ipv6 reasm node stats |
| 793 | */ |
| 794 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm node stats:\n\n"); |
| 795 | |
| 796 | spin_lock_bh(&nss_top_main.stats_lock); |
| 797 | for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) { |
| 798 | stats_shadow[i] = nss_top_main.stats_ipv6_reasm[i]; |
| 799 | } |
| 800 | |
| 801 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 802 | |
| 803 | for (i = 0; (i < NSS_STATS_IPV6_REASM_MAX); i++) { |
| 804 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 805 | "%s = %llu\n", nss_stats_str_ipv6_reasm[i], stats_shadow[i]); |
| 806 | } |
| 807 | |
| 808 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nipv6 reasm stats end\n\n"); |
| 809 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 810 | kfree(lbuf); |
| 811 | kfree(stats_shadow); |
| 812 | |
| 813 | return bytes_read; |
| 814 | } |
| 815 | |
| 816 | /* |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 817 | * nss_stats_eth_rx_read() |
| 818 | * Read ETH_RX stats |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 819 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 820 | 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] | 821 | { |
| 822 | int32_t i; |
| 823 | |
| 824 | /* |
| 825 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 826 | */ |
Murat Sezgin | 99dab64 | 2014-08-28 14:40:34 -0700 | [diff] [blame] | 827 | 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] | 828 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 829 | size_t size_wr = 0; |
| 830 | ssize_t bytes_read = 0; |
| 831 | uint64_t *stats_shadow; |
| 832 | |
| 833 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 834 | if (unlikely(lbuf == NULL)) { |
| 835 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 836 | return 0; |
| 837 | } |
| 838 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 839 | /* |
| 840 | * Note: The assumption here is that we do not have more than 64 stats |
| 841 | */ |
| 842 | stats_shadow = kzalloc(64 * 8, GFP_KERNEL); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 843 | if (unlikely(stats_shadow == NULL)) { |
| 844 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 845 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 846 | return 0; |
| 847 | } |
| 848 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 849 | size_wr = scnprintf(lbuf, size_al,"eth_rx stats start:\n\n"); |
| 850 | |
| 851 | /* |
| 852 | * Common node stats |
| 853 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 854 | 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] | 855 | spin_lock_bh(&nss_top_main.stats_lock); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 856 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 857 | 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] | 858 | } |
| 859 | |
| 860 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 861 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 862 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 863 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 864 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 865 | } |
| 866 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 867 | /* |
Murat Sezgin | 99dab64 | 2014-08-28 14:40:34 -0700 | [diff] [blame] | 868 | * eth_rx node stats |
| 869 | */ |
| 870 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\neth_rx node stats:\n\n"); |
| 871 | spin_lock_bh(&nss_top_main.stats_lock); |
| 872 | for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) { |
| 873 | stats_shadow[i] = nss_top_main.stats_eth_rx[i]; |
| 874 | } |
| 875 | |
| 876 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 877 | |
| 878 | for (i = 0; (i < NSS_STATS_ETH_RX_MAX); i++) { |
| 879 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 880 | "%s = %llu\n", nss_stats_str_eth_rx[i], stats_shadow[i]); |
| 881 | } |
| 882 | |
| 883 | /* |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 884 | * Exception stats |
| 885 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 886 | 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] | 887 | |
| 888 | spin_lock_bh(&nss_top_main.stats_lock); |
| 889 | for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) { |
| 890 | stats_shadow[i] = nss_top_main.stats_if_exception_eth_rx[i]; |
| 891 | } |
| 892 | |
| 893 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 894 | |
| 895 | for (i = 0; (i < NSS_EXCEPTION_EVENT_ETH_RX_MAX); i++) { |
| 896 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 897 | "%s = %llu\n", nss_stats_str_if_exception_eth_rx[i], stats_shadow[i]); |
| 898 | } |
| 899 | |
| 900 | 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] | 901 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 902 | kfree(lbuf); |
| 903 | kfree(stats_shadow); |
| 904 | |
| 905 | return bytes_read; |
| 906 | } |
| 907 | |
| 908 | /* |
| 909 | * nss_stats_n2h_read() |
| 910 | * Read N2H stats |
| 911 | */ |
| 912 | static ssize_t nss_stats_n2h_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 913 | { |
| 914 | int32_t i; |
| 915 | |
| 916 | /* |
| 917 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 918 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 919 | 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] | 920 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 921 | size_t size_wr = 0; |
| 922 | ssize_t bytes_read = 0; |
| 923 | uint64_t *stats_shadow; |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 924 | int max = NSS_STATS_N2H_MAX - NSS_STATS_NODE_MAX; |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 925 | |
| 926 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 927 | if (unlikely(lbuf == NULL)) { |
| 928 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 929 | return 0; |
| 930 | } |
| 931 | |
| 932 | stats_shadow = kzalloc(NSS_STATS_N2H_MAX * 8, GFP_KERNEL); |
| 933 | if (unlikely(stats_shadow == NULL)) { |
| 934 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 935 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 936 | return 0; |
| 937 | } |
| 938 | |
| 939 | size_wr = scnprintf(lbuf, size_al, "n2h stats start:\n\n"); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 940 | |
| 941 | /* |
| 942 | * Common node stats |
| 943 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 944 | 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] | 945 | spin_lock_bh(&nss_top_main.stats_lock); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 946 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 947 | stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i]; |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 951 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 952 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 953 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 954 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 955 | } |
| 956 | |
| 957 | /* |
| 958 | * N2H node stats |
| 959 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 960 | 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] | 961 | spin_lock_bh(&nss_top_main.stats_lock); |
| 962 | for (i = NSS_STATS_NODE_MAX; (i < NSS_STATS_N2H_MAX); i++) { |
| 963 | stats_shadow[i] = nss_top_main.nss[0].stats_n2h[i]; |
| 964 | } |
| 965 | |
| 966 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 967 | |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 968 | for (i = 0; i < max; i++) { |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 969 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 970 | "%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] | 971 | } |
| 972 | |
| 973 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nn2h stats end\n\n"); |
| 974 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 975 | kfree(lbuf); |
| 976 | kfree(stats_shadow); |
| 977 | |
| 978 | return bytes_read; |
| 979 | } |
| 980 | |
| 981 | /* |
Thomas Wu | c3e382c | 2014-10-29 15:35:13 -0700 | [diff] [blame] | 982 | * nss_stats_lso_rx_read() |
| 983 | * Read LSO_RX stats |
| 984 | */ |
| 985 | static ssize_t nss_stats_lso_rx_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 986 | { |
| 987 | int32_t i; |
| 988 | |
| 989 | /* |
| 990 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 991 | */ |
| 992 | uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + (NSS_STATS_LSO_RX_MAX + 3) + 5; |
| 993 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 994 | size_t size_wr = 0; |
| 995 | ssize_t bytes_read = 0; |
| 996 | uint64_t *stats_shadow; |
| 997 | |
| 998 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 999 | if (unlikely(lbuf == NULL)) { |
| 1000 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1001 | return 0; |
| 1002 | } |
| 1003 | |
| 1004 | stats_shadow = kzalloc(NSS_STATS_LSO_RX_MAX * 8, GFP_KERNEL); |
| 1005 | if (unlikely(stats_shadow == NULL)) { |
| 1006 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 1007 | kfree(lbuf); |
Thomas Wu | c3e382c | 2014-10-29 15:35:13 -0700 | [diff] [blame] | 1008 | return 0; |
| 1009 | } |
| 1010 | |
| 1011 | size_wr = scnprintf(lbuf, size_al, "lso_rx stats start:\n\n"); |
| 1012 | |
| 1013 | /* |
| 1014 | * Common node stats |
| 1015 | */ |
| 1016 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n"); |
| 1017 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1018 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1019 | stats_shadow[i] = nss_top_main.stats_node[NSS_LSO_RX_INTERFACE][i]; |
| 1020 | } |
| 1021 | |
| 1022 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1023 | |
| 1024 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1025 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1026 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 1027 | } |
| 1028 | |
| 1029 | /* |
| 1030 | * lso_rx node stats |
| 1031 | */ |
| 1032 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx node stats:\n\n"); |
| 1033 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1034 | for (i = 0; (i < NSS_STATS_LSO_RX_MAX); i++) { |
| 1035 | stats_shadow[i] = nss_top_main.stats_lso_rx[i]; |
| 1036 | } |
| 1037 | |
| 1038 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1039 | |
| 1040 | for (i = 0; i < NSS_STATS_LSO_RX_MAX; i++) { |
| 1041 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1042 | "%s = %llu\n", nss_stats_str_lso_rx[i], stats_shadow[i]); |
| 1043 | } |
| 1044 | |
| 1045 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nlso_rx stats end\n\n"); |
| 1046 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1047 | kfree(lbuf); |
| 1048 | kfree(stats_shadow); |
| 1049 | |
| 1050 | return bytes_read; |
| 1051 | } |
| 1052 | |
| 1053 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1054 | * nss_stats_drv_read() |
| 1055 | * Read HLOS driver stats |
| 1056 | */ |
| 1057 | static ssize_t nss_stats_drv_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1058 | { |
| 1059 | int32_t i; |
| 1060 | |
| 1061 | /* |
| 1062 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 1063 | */ |
| 1064 | uint32_t max_output_lines = NSS_STATS_DRV_MAX + 5; |
| 1065 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1066 | size_t size_wr = 0; |
| 1067 | ssize_t bytes_read = 0; |
| 1068 | uint64_t *stats_shadow; |
| 1069 | |
| 1070 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1071 | if (unlikely(lbuf == NULL)) { |
| 1072 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1073 | return 0; |
| 1074 | } |
| 1075 | |
| 1076 | stats_shadow = kzalloc(NSS_STATS_DRV_MAX * 8, GFP_KERNEL); |
| 1077 | if (unlikely(stats_shadow == NULL)) { |
| 1078 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 1079 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1080 | return 0; |
| 1081 | } |
| 1082 | |
| 1083 | size_wr = scnprintf(lbuf, size_al, "drv stats start:\n\n"); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1084 | for (i = 0; (i < NSS_STATS_DRV_MAX); i++) { |
Sundarajan Srinivasan | 62fee7e | 2015-01-22 11:13:10 -0800 | [diff] [blame] | 1085 | 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] | 1086 | } |
| 1087 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1088 | for (i = 0; (i < NSS_STATS_DRV_MAX); i++) { |
| 1089 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1090 | "%s = %llu\n", nss_stats_str_drv[i], stats_shadow[i]); |
| 1091 | } |
| 1092 | |
| 1093 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ndrv stats end\n\n"); |
| 1094 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1095 | kfree(lbuf); |
| 1096 | kfree(stats_shadow); |
| 1097 | |
| 1098 | return bytes_read; |
| 1099 | } |
| 1100 | |
| 1101 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1102 | * nss_stats_pppoe_read() |
| 1103 | * Read PPPoE stats |
| 1104 | */ |
| 1105 | static ssize_t nss_stats_pppoe_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1106 | { |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1107 | int32_t i, j, k; |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1108 | |
| 1109 | /* |
| 1110 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 1111 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1112 | 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] | 1113 | ((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] | 1114 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1115 | size_t size_wr = 0; |
| 1116 | ssize_t bytes_read = 0; |
| 1117 | uint64_t *stats_shadow; |
| 1118 | |
| 1119 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1120 | if (unlikely(lbuf == NULL)) { |
| 1121 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1122 | return 0; |
| 1123 | } |
| 1124 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1125 | stats_shadow = kzalloc(64 * 8, GFP_KERNEL); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1126 | if (unlikely(stats_shadow == NULL)) { |
| 1127 | nss_warning("Could not allocate memory for local shadow buffer"); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1128 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1129 | return 0; |
| 1130 | } |
| 1131 | |
| 1132 | size_wr = scnprintf(lbuf, size_al, "pppoe stats start:\n\n"); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1133 | |
| 1134 | /* |
| 1135 | * Common node stats |
| 1136 | */ |
Abhishek Rastogi | a1a0797 | 2014-04-01 19:43:33 +0530 | [diff] [blame] | 1137 | 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] | 1138 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1139 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1140 | stats_shadow[i] = nss_top_main.stats_node[NSS_PPPOE_RX_INTERFACE][i]; |
| 1141 | } |
| 1142 | |
| 1143 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1144 | |
| 1145 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1146 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1147 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 1148 | } |
| 1149 | |
| 1150 | /* |
| 1151 | * PPPoE node stats |
| 1152 | */ |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1153 | 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] | 1154 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1155 | for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) { |
| 1156 | stats_shadow[i] = nss_top_main.stats_pppoe[i]; |
| 1157 | } |
| 1158 | |
| 1159 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1160 | |
| 1161 | for (i = 0; (i < NSS_STATS_PPPOE_MAX); i++) { |
| 1162 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1163 | "%s = %llu\n", nss_stats_str_pppoe[i], stats_shadow[i]); |
| 1164 | } |
| 1165 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1166 | /* |
| 1167 | * Exception stats |
| 1168 | */ |
| 1169 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nException PPPoE:\n\n"); |
| 1170 | |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1171 | for (j = 1; j <= NSS_MAX_PHYSICAL_INTERFACES; j++) { |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1172 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nInterface %d:\n\n", j); |
| 1173 | |
| 1174 | spin_lock_bh(&nss_top_main.stats_lock); |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1175 | for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) { |
Ankit Dhanuka | a1569ce | 2014-05-13 19:58:06 +0530 | [diff] [blame] | 1176 | for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) { |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1177 | 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] | 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1182 | |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1183 | for (k = 1; k <= NSS_PPPOE_NUM_SESSION_PER_INTERFACE; k++) { |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1184 | 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] | 1185 | for (i = 0; (i < NSS_PPPOE_EXCEPTION_EVENT_MAX); i++) { |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1186 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1187 | "%s = %llu\n", |
| 1188 | nss_stats_str_if_exception_pppoe[i], |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1189 | stats_shadow_pppoe_except[k - 1][i]); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1190 | } |
| 1191 | } |
| 1192 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1193 | } |
| 1194 | |
Murat Sezgin | 2f9241a | 2015-06-25 13:01:51 -0700 | [diff] [blame] | 1195 | 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] | 1196 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1197 | kfree(lbuf); |
| 1198 | kfree(stats_shadow); |
| 1199 | |
| 1200 | return bytes_read; |
| 1201 | } |
| 1202 | |
| 1203 | /* |
| 1204 | * nss_stats_gmac_read() |
| 1205 | * Read GMAC stats |
| 1206 | */ |
| 1207 | static ssize_t nss_stats_gmac_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1208 | { |
| 1209 | uint32_t i, id; |
| 1210 | |
| 1211 | /* |
| 1212 | * max output lines = ((#stats + start tag + one blank) * #GMACs) + start/end tag + 3 blank |
| 1213 | */ |
| 1214 | uint32_t max_output_lines = ((NSS_STATS_GMAC_MAX + 2) * NSS_MAX_PHYSICAL_INTERFACES) + 5; |
| 1215 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1216 | size_t size_wr = 0; |
| 1217 | ssize_t bytes_read = 0; |
| 1218 | uint64_t *stats_shadow; |
| 1219 | |
| 1220 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1221 | if (unlikely(lbuf == NULL)) { |
| 1222 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1223 | return 0; |
| 1224 | } |
| 1225 | |
| 1226 | stats_shadow = kzalloc(NSS_STATS_GMAC_MAX * 8, GFP_KERNEL); |
| 1227 | if (unlikely(stats_shadow == NULL)) { |
| 1228 | nss_warning("Could not allocate memory for local shadow buffer"); |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 1229 | kfree(lbuf); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 1230 | return 0; |
| 1231 | } |
| 1232 | |
| 1233 | size_wr = scnprintf(lbuf, size_al, "gmac stats start:\n\n"); |
| 1234 | |
| 1235 | for (id = 0; id < NSS_MAX_PHYSICAL_INTERFACES; id++) { |
| 1236 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1237 | for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) { |
| 1238 | stats_shadow[i] = nss_top_main.stats_gmac[id][i]; |
| 1239 | } |
| 1240 | |
| 1241 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1242 | |
| 1243 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "GMAC ID: %d\n", id); |
| 1244 | for (i = 0; (i < NSS_STATS_GMAC_MAX); i++) { |
| 1245 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1246 | "%s = %llu\n", nss_stats_str_gmac[i], stats_shadow[i]); |
| 1247 | } |
| 1248 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,"\n"); |
| 1249 | } |
| 1250 | |
| 1251 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngmac stats end\n\n"); |
| 1252 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1253 | kfree(lbuf); |
| 1254 | kfree(stats_shadow); |
| 1255 | |
| 1256 | return bytes_read; |
| 1257 | } |
| 1258 | |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1259 | /* |
Bharath M Kumar | cc666e9 | 2014-12-24 19:17:28 +0530 | [diff] [blame] | 1260 | * nss_stats_wifi_read() |
| 1261 | * Read wifi statistics |
| 1262 | */ |
| 1263 | static ssize_t nss_stats_wifi_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1264 | { |
| 1265 | uint32_t i, id; |
| 1266 | |
| 1267 | /* |
| 1268 | * max output lines = ((#stats + start tag + one blank) * #WIFI RADIOs) + start/end tag + 3 blank |
| 1269 | */ |
| 1270 | uint32_t max_output_lines = ((NSS_STATS_WIFI_MAX + 2) * NSS_MAX_WIFI_RADIO_INTERFACES) + 5; |
| 1271 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1272 | size_t size_wr = 0; |
| 1273 | ssize_t bytes_read = 0; |
| 1274 | uint64_t *stats_shadow; |
| 1275 | |
| 1276 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1277 | if (unlikely(lbuf == NULL)) { |
| 1278 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1279 | return 0; |
| 1280 | } |
| 1281 | |
| 1282 | stats_shadow = kzalloc(NSS_STATS_WIFI_MAX * 8, GFP_KERNEL); |
| 1283 | if (unlikely(stats_shadow == NULL)) { |
| 1284 | nss_warning("Could not allocate memory for local shadow buffer"); |
| 1285 | kfree(lbuf); |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
| 1289 | size_wr = scnprintf(lbuf, size_al, "wifi stats start:\n\n"); |
| 1290 | |
| 1291 | for (id = 0; id < NSS_MAX_WIFI_RADIO_INTERFACES; id++) { |
| 1292 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1293 | for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) { |
| 1294 | stats_shadow[i] = nss_top_main.stats_wifi[id][i]; |
| 1295 | } |
| 1296 | |
| 1297 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1298 | |
| 1299 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "WIFI ID: %d\n", id); |
| 1300 | for (i = 0; (i < NSS_STATS_WIFI_MAX); i++) { |
| 1301 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1302 | "%s = %llu\n", nss_stats_str_wifi[i], stats_shadow[i]); |
| 1303 | } |
| 1304 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr,"\n"); |
| 1305 | } |
| 1306 | |
| 1307 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nwifi stats end\n\n"); |
| 1308 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1309 | kfree(lbuf); |
| 1310 | kfree(stats_shadow); |
| 1311 | |
| 1312 | return bytes_read; |
| 1313 | } |
| 1314 | |
| 1315 | /* |
Tushar Mathur | ff8741b | 2015-12-02 20:28:59 +0530 | [diff] [blame] | 1316 | * nss_stats_dtls_read() |
| 1317 | * Read DTLS session statistics |
| 1318 | */ |
| 1319 | static ssize_t nss_stats_dtls_read(struct file *fp, char __user *ubuf, |
| 1320 | size_t sz, loff_t *ppos) |
| 1321 | { |
| 1322 | uint32_t max_output_lines = 2 + (NSS_MAX_DTLS_SESSIONS |
| 1323 | * (NSS_STATS_DTLS_SESSION_MAX + 2)) + 2; |
| 1324 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1325 | size_t size_wr = 0; |
| 1326 | ssize_t bytes_read = 0; |
| 1327 | struct net_device *dev; |
| 1328 | int id, i; |
| 1329 | struct nss_stats_dtls_session_debug *dtls_session_stats = NULL; |
| 1330 | |
| 1331 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1332 | if (unlikely(lbuf == NULL)) { |
| 1333 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1334 | return 0; |
| 1335 | } |
| 1336 | |
| 1337 | dtls_session_stats = kzalloc((sizeof(struct nss_stats_dtls_session_debug) |
| 1338 | * NSS_MAX_DTLS_SESSIONS), GFP_KERNEL); |
| 1339 | if (unlikely(dtls_session_stats == NULL)) { |
| 1340 | nss_warning("Could not allocate memory for populating DTLS stats"); |
| 1341 | kfree(lbuf); |
| 1342 | return 0; |
| 1343 | } |
| 1344 | |
| 1345 | /* |
| 1346 | * Get all stats |
| 1347 | */ |
| 1348 | nss_dtls_session_debug_stats_get(dtls_session_stats); |
| 1349 | |
| 1350 | /* |
| 1351 | * Session stats |
| 1352 | */ |
| 1353 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1354 | "\nDTLS session stats start:\n\n"); |
| 1355 | |
| 1356 | for (id = 0; id < NSS_MAX_DTLS_SESSIONS; id++) { |
| 1357 | if (!dtls_session_stats[id].valid) |
| 1358 | break; |
| 1359 | |
| 1360 | dev = dev_get_by_index(&init_net, dtls_session_stats[id].if_index); |
| 1361 | if (likely(dev)) { |
| 1362 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1363 | "%d. nss interface id=%d, netdevice=%s\n", |
| 1364 | id, dtls_session_stats[id].if_num, |
| 1365 | dev->name); |
| 1366 | dev_put(dev); |
| 1367 | } else { |
| 1368 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1369 | "%d. nss interface id=%d\n", id, |
| 1370 | dtls_session_stats[id].if_num); |
| 1371 | } |
| 1372 | |
| 1373 | for (i = 0; i < NSS_STATS_DTLS_SESSION_MAX; i++) { |
| 1374 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1375 | "\t%s = %llu\n", |
| 1376 | nss_stats_str_dtls_session_debug_stats[i], |
| 1377 | dtls_session_stats[id].stats[i]); |
| 1378 | } |
| 1379 | |
| 1380 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); |
| 1381 | } |
| 1382 | |
| 1383 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1384 | "\nDTLS session stats end\n"); |
| 1385 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); |
| 1386 | |
| 1387 | kfree(dtls_session_stats); |
| 1388 | kfree(lbuf); |
| 1389 | return bytes_read; |
| 1390 | } |
| 1391 | |
| 1392 | |
| 1393 | /* |
ratheesh kannoth | 7af985d | 2015-06-24 15:08:40 +0530 | [diff] [blame] | 1394 | * nss_stats_l2tpv2_read() |
| 1395 | * Read l2tpv2 statistics |
| 1396 | */ |
| 1397 | static ssize_t nss_stats_l2tpv2_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1398 | { |
| 1399 | |
| 1400 | uint32_t max_output_lines = 2 /* header & footer for session stats */ |
| 1401 | + NSS_MAX_L2TPV2_DYNAMIC_INTERFACES * (NSS_STATS_L2TPV2_SESSION_MAX + 2) /*session stats */ |
| 1402 | + 2; |
| 1403 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ; |
| 1404 | size_t size_wr = 0; |
| 1405 | ssize_t bytes_read = 0; |
| 1406 | struct net_device *dev; |
| 1407 | struct nss_stats_l2tpv2_session_debug l2tpv2_session_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES]; |
| 1408 | int id, i; |
| 1409 | |
| 1410 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1411 | if (unlikely(lbuf == NULL)) { |
| 1412 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1413 | return 0; |
| 1414 | } |
| 1415 | |
| 1416 | memset(&l2tpv2_session_stats, 0, sizeof(struct nss_stats_l2tpv2_session_debug) * NSS_MAX_L2TPV2_DYNAMIC_INTERFACES); |
| 1417 | |
| 1418 | /* |
| 1419 | * Get all stats |
| 1420 | */ |
| 1421 | nss_l2tpv2_session_debug_stats_get((void *)&l2tpv2_session_stats); |
| 1422 | |
| 1423 | /* |
| 1424 | * Session stats |
| 1425 | */ |
| 1426 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats start:\n\n"); |
| 1427 | for (id = 0; id < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; id++) { |
| 1428 | |
| 1429 | if (!l2tpv2_session_stats[id].valid) { |
| 1430 | break; |
| 1431 | } |
| 1432 | |
| 1433 | dev = dev_get_by_index(&init_net, l2tpv2_session_stats[id].if_index); |
| 1434 | if (likely(dev)) { |
| 1435 | |
| 1436 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id, |
| 1437 | l2tpv2_session_stats[id].if_num, dev->name); |
| 1438 | dev_put(dev); |
| 1439 | } else { |
| 1440 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id, |
| 1441 | l2tpv2_session_stats[id].if_num); |
| 1442 | } |
| 1443 | |
| 1444 | for (i = 0; i < NSS_STATS_L2TPV2_SESSION_MAX; i++) { |
| 1445 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1446 | "\t%s = %llu\n", nss_stats_str_l2tpv2_session_debug_stats[i], |
| 1447 | l2tpv2_session_stats[id].stats[i]); |
| 1448 | } |
| 1449 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); |
| 1450 | } |
| 1451 | |
| 1452 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats end\n"); |
| 1453 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); |
| 1454 | |
| 1455 | kfree(lbuf); |
| 1456 | return bytes_read; |
| 1457 | } |
| 1458 | |
| 1459 | /* |
Shyam Sunder | 66e889d | 2015-11-02 15:31:20 +0530 | [diff] [blame] | 1460 | * nss_stats_pptp_read() |
| 1461 | * Read pptp statistics |
| 1462 | */ |
| 1463 | static ssize_t nss_stats_pptp_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1464 | { |
| 1465 | |
| 1466 | uint32_t max_output_lines = 2 /* header & footer for session stats */ |
| 1467 | + NSS_MAX_PPTP_DYNAMIC_INTERFACES * (NSS_STATS_PPTP_SESSION_MAX + 2) /*session stats */ |
| 1468 | + 2; |
| 1469 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines ; |
| 1470 | size_t size_wr = 0; |
| 1471 | ssize_t bytes_read = 0; |
| 1472 | struct net_device *dev; |
| 1473 | struct nss_stats_pptp_session_debug pptp_session_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES]; |
| 1474 | int id, i; |
| 1475 | |
| 1476 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1477 | if (unlikely(lbuf == NULL)) { |
| 1478 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1479 | return 0; |
| 1480 | } |
| 1481 | |
| 1482 | memset(&pptp_session_stats, 0, sizeof(struct nss_stats_pptp_session_debug) * NSS_MAX_PPTP_DYNAMIC_INTERFACES); |
| 1483 | |
| 1484 | /* |
| 1485 | * Get all stats |
| 1486 | */ |
| 1487 | nss_pptp_session_debug_stats_get((void *)&pptp_session_stats); |
| 1488 | |
| 1489 | /* |
| 1490 | * Session stats |
| 1491 | */ |
| 1492 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats start:\n\n"); |
| 1493 | for (id = 0; id < NSS_MAX_PPTP_DYNAMIC_INTERFACES; id++) { |
| 1494 | |
| 1495 | if (!pptp_session_stats[id].valid) { |
| 1496 | break; |
| 1497 | } |
| 1498 | |
| 1499 | dev = dev_get_by_index(&init_net, pptp_session_stats[id].if_index); |
| 1500 | if (likely(dev)) { |
| 1501 | |
| 1502 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id, |
| 1503 | pptp_session_stats[id].if_num, dev->name); |
| 1504 | dev_put(dev); |
| 1505 | } else { |
| 1506 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d\n", id, |
| 1507 | pptp_session_stats[id].if_num); |
| 1508 | } |
| 1509 | |
| 1510 | for (i = 0; i < NSS_STATS_PPTP_SESSION_MAX; i++) { |
| 1511 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1512 | "\t%s = %llu\n", nss_stats_str_pptp_session_debug_stats[i], |
| 1513 | pptp_session_stats[id].stats[i]); |
| 1514 | } |
| 1515 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); |
| 1516 | } |
| 1517 | |
| 1518 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats end\n"); |
| 1519 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); |
| 1520 | |
| 1521 | kfree(lbuf); |
| 1522 | return bytes_read; |
| 1523 | } |
| 1524 | |
| 1525 | /* |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 1526 | * nss_stats_sjack_read() |
| 1527 | * Read SJACK stats |
| 1528 | */ |
| 1529 | static ssize_t nss_stats_sjack_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1530 | { |
| 1531 | int32_t i; |
| 1532 | /* |
| 1533 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 1534 | */ |
| 1535 | uint32_t max_output_lines = NSS_STATS_NODE_MAX + 5; |
| 1536 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1537 | size_t size_wr = 0; |
| 1538 | ssize_t bytes_read = 0; |
| 1539 | uint64_t *stats_shadow; |
| 1540 | |
| 1541 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1542 | if (unlikely(lbuf == NULL)) { |
| 1543 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1544 | return 0; |
| 1545 | } |
| 1546 | |
| 1547 | stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL); |
| 1548 | if (unlikely(stats_shadow == NULL)) { |
| 1549 | nss_warning("Could not allocate memory for local shadow buffer"); |
| 1550 | kfree(lbuf); |
| 1551 | return 0; |
| 1552 | } |
| 1553 | |
| 1554 | size_wr = scnprintf(lbuf, size_al, "sjack stats start:\n\n"); |
| 1555 | |
| 1556 | /* |
| 1557 | * Common node stats |
| 1558 | */ |
| 1559 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n"); |
| 1560 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1561 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1562 | stats_shadow[i] = nss_top_main.stats_node[NSS_SJACK_INTERFACE][i]; |
| 1563 | } |
| 1564 | |
| 1565 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1566 | |
| 1567 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1568 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1569 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 1570 | } |
| 1571 | |
| 1572 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nsjack stats end\n\n"); |
| 1573 | |
| 1574 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1575 | kfree(lbuf); |
| 1576 | kfree(stats_shadow); |
| 1577 | |
| 1578 | return bytes_read; |
| 1579 | } |
| 1580 | |
| 1581 | /* |
Stephen Wang | 9779d95 | 2015-10-28 11:39:07 -0700 | [diff] [blame] | 1582 | * nss_stats_portid_read() |
| 1583 | * Read PortID stats |
| 1584 | */ |
| 1585 | static ssize_t nss_stats_portid_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1586 | { |
| 1587 | int32_t i; |
| 1588 | /* |
| 1589 | * max output lines = #stats + start tag line + end tag line + three blank lines |
| 1590 | */ |
| 1591 | uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_STATS_PORTID_MAX + 5; |
| 1592 | size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; |
| 1593 | size_t size_wr = 0; |
| 1594 | ssize_t bytes_read = 0; |
| 1595 | uint64_t *stats_shadow; |
| 1596 | |
| 1597 | char *lbuf = kzalloc(size_al, GFP_KERNEL); |
| 1598 | if (unlikely(lbuf == NULL)) { |
| 1599 | nss_warning("Could not allocate memory for local statistics buffer"); |
| 1600 | return 0; |
| 1601 | } |
| 1602 | |
| 1603 | stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL); |
| 1604 | if (unlikely(stats_shadow == NULL)) { |
| 1605 | nss_warning("Could not allocate memory for local shadow buffer"); |
| 1606 | kfree(lbuf); |
| 1607 | return 0; |
| 1608 | } |
| 1609 | |
| 1610 | size_wr = scnprintf(lbuf, size_al, "portid stats start:\n\n"); |
| 1611 | |
| 1612 | /* |
| 1613 | * Common node stats |
| 1614 | */ |
| 1615 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common node stats:\n\n"); |
| 1616 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1617 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1618 | stats_shadow[i] = nss_top_main.stats_node[NSS_PORTID_INTERFACE][i]; |
| 1619 | } |
| 1620 | |
| 1621 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1622 | |
| 1623 | for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { |
| 1624 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1625 | "%s = %llu\n", nss_stats_str_node[i], stats_shadow[i]); |
| 1626 | } |
| 1627 | |
| 1628 | /* |
| 1629 | * PortID node stats |
| 1630 | */ |
| 1631 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid node stats:\n\n"); |
| 1632 | |
| 1633 | spin_lock_bh(&nss_top_main.stats_lock); |
| 1634 | for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) { |
| 1635 | stats_shadow[i] = nss_top_main.stats_portid[i]; |
| 1636 | } |
| 1637 | |
| 1638 | spin_unlock_bh(&nss_top_main.stats_lock); |
| 1639 | |
| 1640 | for (i = 0; (i < NSS_STATS_PORTID_MAX); i++) { |
| 1641 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, |
| 1642 | "%s = %llu\n", nss_stats_str_portid[i], stats_shadow[i]); |
| 1643 | } |
| 1644 | |
| 1645 | size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nportid stats end\n\n"); |
| 1646 | |
| 1647 | bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); |
| 1648 | kfree(lbuf); |
| 1649 | kfree(stats_shadow); |
| 1650 | |
| 1651 | return bytes_read; |
| 1652 | } |
| 1653 | |
| 1654 | /* |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1655 | * Make a row for CAPWAP encap stats. |
| 1656 | */ |
| 1657 | static ssize_t nss_stats_capwap_encap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s) |
| 1658 | { |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1659 | char *header[] = { "packets", "bytes", "fragments", "drop_ref", "drop_ver", "drop_unalign", |
| 1660 | "drop_hroom", "drop_dtls", "drop_nwireless", "drop_qfull", "drop_memfail", "unknown" }; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1661 | uint64_t tcnt = 0; |
| 1662 | |
| 1663 | switch (i) { |
| 1664 | case 0: |
| 1665 | tcnt = s->pnode_stats.tx_packets; |
| 1666 | break; |
| 1667 | case 1: |
| 1668 | tcnt = s->pnode_stats.tx_bytes; |
| 1669 | break; |
| 1670 | case 2: |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1671 | tcnt = s->tx_segments; |
| 1672 | break; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1673 | case 3: |
| 1674 | tcnt = s->tx_dropped_sg_ref; |
| 1675 | break; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1676 | case 4: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1677 | tcnt = s->tx_dropped_ver_mis; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1678 | break; |
| 1679 | case 5: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1680 | tcnt = s->tx_dropped_unalign; |
| 1681 | break; |
| 1682 | case 6: |
| 1683 | tcnt = s->tx_dropped_hroom; |
| 1684 | break; |
| 1685 | case 7: |
| 1686 | tcnt = s->tx_dropped_dtls; |
| 1687 | break; |
| 1688 | case 8: |
| 1689 | tcnt = s->tx_dropped_nwireless; |
| 1690 | break; |
| 1691 | case 9: |
| 1692 | tcnt = s->tx_queue_full_drops; |
| 1693 | break; |
| 1694 | case 10: |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1695 | tcnt = s->tx_mem_failure_drops; |
| 1696 | break; |
| 1697 | default: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1698 | return 0; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1699 | } |
| 1700 | |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1701 | return (snprintf(line, len, "%s = %llu\n", header[i], tcnt)); |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1702 | } |
| 1703 | |
| 1704 | /* |
| 1705 | * Make a row for CAPWAP decap stats. |
| 1706 | */ |
| 1707 | static ssize_t nss_stats_capwap_decap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s) |
| 1708 | { |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1709 | char *header[] = { "packets", "bytes", "DTLS_pkts", "fragments", "rx_dropped", "drop_oversize", |
| 1710 | "drop_frag_timeout", "drop_frag_dup", "drop_frag_gap", "drop_qfull", "drop_memfail", |
| 1711 | "drop_csum", "drop_malformed", "unknown" }; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1712 | uint64_t tcnt = 0; |
| 1713 | |
| 1714 | switch(i) { |
| 1715 | case 0: |
| 1716 | tcnt = s->pnode_stats.rx_packets; |
| 1717 | break; |
| 1718 | case 1: |
| 1719 | tcnt = s->pnode_stats.rx_bytes; |
| 1720 | break; |
| 1721 | case 2: |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1722 | tcnt = s->dtls_pkts; |
| 1723 | break; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1724 | case 3: |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1725 | tcnt = s->rx_segments; |
| 1726 | break; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1727 | case 4: |
| 1728 | tcnt = s->pnode_stats.rx_dropped; |
| 1729 | break; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1730 | case 5: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1731 | tcnt = s->rx_oversize_drops; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1732 | break; |
| 1733 | case 6: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1734 | tcnt = s->rx_frag_timeout_drops; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1735 | break; |
| 1736 | case 7: |
| 1737 | tcnt = s->rx_dup_frag; |
| 1738 | break; |
| 1739 | case 8: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1740 | tcnt = s->rx_frag_gap_drops; |
| 1741 | break; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1742 | case 9: |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1743 | tcnt = s->rx_queue_full_drops; |
| 1744 | return (snprintf(line, len, "%s = %llu (n2h = %llu)\n", header[i], tcnt, s->rx_n2h_queue_full_drops)); |
| 1745 | case 10: |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1746 | tcnt = s->rx_mem_failure_drops; |
| 1747 | break; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1748 | case 11: |
| 1749 | tcnt = s->rx_csum_drops; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1750 | break; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1751 | case 12: |
| 1752 | tcnt = s->rx_malformed; |
| 1753 | break; |
| 1754 | default: |
| 1755 | return 0; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1756 | } |
| 1757 | |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1758 | return (snprintf(line, len, "%s = %llu\n", header[i], tcnt)); |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1759 | } |
| 1760 | |
| 1761 | /* |
| 1762 | * nss_stats_capwap_read() |
| 1763 | * Read CAPWAP stats |
| 1764 | */ |
| 1765 | static ssize_t nss_stats_capwap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos, uint16_t type) |
| 1766 | { |
| 1767 | struct nss_stats_data *data = fp->private_data; |
| 1768 | ssize_t bytes_read = 0; |
| 1769 | struct nss_capwap_tunnel_stats stats; |
| 1770 | size_t bytes; |
| 1771 | char line[80]; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1772 | int start; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1773 | uint32_t if_num = NSS_DYNAMIC_IF_START; |
| 1774 | uint32_t max_if_num = NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES; |
| 1775 | |
| 1776 | if (data) { |
| 1777 | if_num = data->if_num; |
| 1778 | } |
| 1779 | |
| 1780 | /* |
| 1781 | * If we are done accomodating all the CAPWAP tunnels. |
| 1782 | */ |
| 1783 | if (if_num > max_if_num) { |
| 1784 | return 0; |
| 1785 | } |
| 1786 | |
| 1787 | for (; if_num <= max_if_num; if_num++) { |
| 1788 | bool isthere; |
| 1789 | |
| 1790 | if (nss_is_dynamic_interface(if_num) == false) { |
| 1791 | continue; |
| 1792 | } |
| 1793 | |
| 1794 | if (nss_dynamic_interface_get_type(if_num) != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP) { |
| 1795 | continue; |
| 1796 | } |
| 1797 | |
| 1798 | /* |
| 1799 | * If CAPWAP tunnel does not exists, then isthere will be false. |
| 1800 | */ |
| 1801 | isthere = nss_capwap_get_stats(if_num, &stats); |
| 1802 | if (!isthere) { |
| 1803 | continue; |
| 1804 | } |
| 1805 | |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1806 | bytes = snprintf(line, sizeof(line), "----if_num : %2d----\n", if_num); |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1807 | if ((bytes_read + bytes) > sz) { |
| 1808 | break; |
| 1809 | } |
| 1810 | |
| 1811 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 1812 | bytes_read = -EFAULT; |
| 1813 | goto fail; |
| 1814 | } |
| 1815 | bytes_read += bytes; |
| 1816 | start = 0; |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1817 | while (bytes_read < sz) { |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1818 | if (type == 1) { |
| 1819 | bytes = nss_stats_capwap_encap(line, sizeof(line), start, &stats); |
| 1820 | } else { |
| 1821 | bytes = nss_stats_capwap_decap(line, sizeof(line), start, &stats); |
| 1822 | } |
| 1823 | |
Saurabh Misra | 3f66e87 | 2015-04-03 11:30:42 -0700 | [diff] [blame] | 1824 | /* |
| 1825 | * If we don't have any more lines in decap/encap. |
| 1826 | */ |
| 1827 | if (bytes == 0) { |
| 1828 | break; |
| 1829 | } |
| 1830 | |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 1831 | if ((bytes_read + bytes) > sz) |
| 1832 | break; |
| 1833 | |
| 1834 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 1835 | bytes_read = -EFAULT; |
| 1836 | goto fail; |
| 1837 | } |
| 1838 | |
| 1839 | bytes_read += bytes; |
| 1840 | start++; |
| 1841 | } |
| 1842 | } |
| 1843 | |
| 1844 | if (bytes_read > 0) { |
| 1845 | *ppos = bytes_read; |
| 1846 | } |
| 1847 | |
| 1848 | if (data) { |
| 1849 | data->if_num = if_num; |
| 1850 | } |
| 1851 | fail: |
| 1852 | return bytes_read; |
| 1853 | } |
| 1854 | |
| 1855 | /* |
| 1856 | * nss_stats_capwap_decap_read() |
| 1857 | * Read CAPWAP decap stats |
| 1858 | */ |
| 1859 | static ssize_t nss_stats_capwap_decap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1860 | { |
| 1861 | return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 0)); |
| 1862 | } |
| 1863 | |
| 1864 | /* |
| 1865 | * nss_stats_capwap_encap_read() |
| 1866 | * Read CAPWAP encap stats |
| 1867 | */ |
| 1868 | static ssize_t nss_stats_capwap_encap_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1869 | { |
| 1870 | return (nss_stats_capwap_read(fp, ubuf, sz, ppos, 1)); |
| 1871 | } |
| 1872 | |
| 1873 | /* |
Ankit Dhanuka | 6228ebd | 2014-11-05 17:26:01 +0530 | [diff] [blame] | 1874 | * nss_stats_gre_redir() |
| 1875 | * Make a row for GRE_REDIR stats. |
| 1876 | */ |
| 1877 | static ssize_t nss_stats_gre_redir(char *line, int len, int i, struct nss_gre_redir_tunnel_stats *s) |
| 1878 | { |
| 1879 | char *header[] = { "TX Packets", "TX Bytes", "TX Drops", "RX Packets", "RX Bytes", "Rx Drops" }; |
| 1880 | uint64_t tcnt = 0; |
| 1881 | |
| 1882 | switch (i) { |
| 1883 | case 0: |
| 1884 | tcnt = s->node_stats.tx_packets; |
| 1885 | break; |
| 1886 | case 1: |
| 1887 | tcnt = s->node_stats.tx_bytes; |
| 1888 | break; |
| 1889 | case 2: |
| 1890 | tcnt = s->tx_dropped; |
| 1891 | break; |
| 1892 | case 3: |
| 1893 | tcnt = s->node_stats.rx_packets; |
| 1894 | break; |
| 1895 | case 4: |
| 1896 | tcnt = s->node_stats.rx_bytes; |
| 1897 | break; |
| 1898 | case 5: |
| 1899 | tcnt = s->node_stats.rx_dropped; |
| 1900 | break; |
| 1901 | default: |
Radha krishna Simha Jiguru | df53f02 | 2015-11-09 12:31:26 +0530 | [diff] [blame] | 1902 | return 0; |
Ankit Dhanuka | 6228ebd | 2014-11-05 17:26:01 +0530 | [diff] [blame] | 1903 | } |
| 1904 | |
| 1905 | return (snprintf(line, len, "%s = %llu\n", header[i], tcnt)); |
| 1906 | } |
| 1907 | |
| 1908 | /* |
| 1909 | * nss_stats_gre_redir_read() |
| 1910 | * READ gre_redir tunnel stats. |
| 1911 | */ |
| 1912 | static ssize_t nss_stats_gre_redir_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1913 | { |
| 1914 | struct nss_stats_data *data = fp->private_data; |
| 1915 | ssize_t bytes_read = 0; |
| 1916 | struct nss_gre_redir_tunnel_stats stats; |
| 1917 | size_t bytes; |
| 1918 | char line[80]; |
| 1919 | int start, end; |
| 1920 | int index = 0; |
| 1921 | |
| 1922 | if (data) { |
| 1923 | index = data->index; |
| 1924 | } |
| 1925 | |
| 1926 | /* |
| 1927 | * If we are done accomodating all the GRE_REDIR tunnels. |
| 1928 | */ |
| 1929 | if (index >= NSS_GRE_REDIR_MAX_INTERFACES) { |
| 1930 | return 0; |
| 1931 | } |
| 1932 | |
| 1933 | for (; index < NSS_GRE_REDIR_MAX_INTERFACES; index++) { |
| 1934 | bool isthere; |
| 1935 | |
| 1936 | /* |
| 1937 | * If gre_redir tunnel does not exists, then isthere will be false. |
| 1938 | */ |
| 1939 | isthere = nss_gre_redir_get_stats(index, &stats); |
| 1940 | if (!isthere) { |
| 1941 | continue; |
| 1942 | } |
| 1943 | |
| 1944 | bytes = snprintf(line, sizeof(line), "\nTunnel if_num: %2d\n", stats.if_num); |
| 1945 | if ((bytes_read + bytes) > sz) { |
| 1946 | break; |
| 1947 | } |
| 1948 | |
| 1949 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 1950 | bytes_read = -EFAULT; |
| 1951 | goto fail; |
| 1952 | } |
| 1953 | bytes_read += bytes; |
| 1954 | start = 0; |
| 1955 | end = 6; |
| 1956 | while (bytes_read < sz && start < end) { |
| 1957 | bytes = nss_stats_gre_redir(line, sizeof(line), start, &stats); |
| 1958 | |
| 1959 | if ((bytes_read + bytes) > sz) |
| 1960 | break; |
| 1961 | |
| 1962 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 1963 | bytes_read = -EFAULT; |
| 1964 | goto fail; |
| 1965 | } |
| 1966 | |
| 1967 | bytes_read += bytes; |
| 1968 | start++; |
| 1969 | } |
| 1970 | } |
| 1971 | |
| 1972 | if (bytes_read > 0) { |
| 1973 | *ppos = bytes_read; |
| 1974 | } |
| 1975 | |
| 1976 | if (data) { |
| 1977 | data->index = index; |
| 1978 | } |
| 1979 | |
| 1980 | fail: |
| 1981 | return bytes_read; |
| 1982 | } |
| 1983 | |
| 1984 | /* |
Sundarajan Srinivasan | 273d900 | 2015-03-03 15:43:16 -0800 | [diff] [blame] | 1985 | * nss_stats_wifi_if_read() |
| 1986 | * Read wifi_if statistics |
| 1987 | */ |
| 1988 | static ssize_t nss_stats_wifi_if_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) |
| 1989 | { |
| 1990 | struct nss_stats_data *data = fp->private_data; |
| 1991 | int32_t if_num = NSS_DYNAMIC_IF_START; |
| 1992 | int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES; |
| 1993 | size_t bytes = 0; |
| 1994 | ssize_t bytes_read = 0; |
| 1995 | char line[80]; |
| 1996 | int start, end; |
| 1997 | |
| 1998 | if (data) { |
| 1999 | if_num = data->if_num; |
| 2000 | } |
| 2001 | |
| 2002 | if (if_num > max_if_num) { |
| 2003 | return 0; |
| 2004 | } |
| 2005 | |
| 2006 | for (; if_num < max_if_num; if_num++) { |
| 2007 | if (nss_dynamic_interface_get_type(if_num) != NSS_DYNAMIC_INTERFACE_TYPE_WIFI) |
| 2008 | continue; |
| 2009 | |
| 2010 | bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num); |
| 2011 | if ((bytes_read + bytes) > sz) |
| 2012 | break; |
| 2013 | |
| 2014 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2015 | bytes_read = -EFAULT; |
| 2016 | goto end; |
| 2017 | } |
| 2018 | |
| 2019 | bytes_read += bytes; |
| 2020 | |
| 2021 | start = 0; |
| 2022 | end = 7; |
| 2023 | while (bytes_read < sz && start < end) { |
| 2024 | bytes = nss_wifi_if_copy_stats(if_num, start, line); |
| 2025 | if (!bytes) |
| 2026 | break; |
| 2027 | |
| 2028 | if ((bytes_read + bytes) > sz) |
| 2029 | break; |
| 2030 | |
| 2031 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2032 | bytes_read = -EFAULT; |
| 2033 | goto end; |
| 2034 | } |
| 2035 | |
| 2036 | bytes_read += bytes; |
| 2037 | start++; |
| 2038 | } |
| 2039 | |
| 2040 | bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num); |
| 2041 | if (bytes_read > (sz - bytes)) |
| 2042 | break; |
| 2043 | |
| 2044 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2045 | bytes_read = -EFAULT; |
| 2046 | goto end; |
| 2047 | } |
| 2048 | |
| 2049 | bytes_read += bytes; |
| 2050 | } |
| 2051 | |
| 2052 | if (bytes_read > 0) { |
| 2053 | *ppos = bytes_read; |
| 2054 | } |
| 2055 | |
| 2056 | if (data) { |
| 2057 | data->if_num = if_num; |
| 2058 | } |
| 2059 | |
| 2060 | end: |
| 2061 | return bytes_read; |
| 2062 | } |
| 2063 | |
| 2064 | /* |
Sundarajan Srinivasan | ab2c856 | 2015-06-09 16:14:10 -0700 | [diff] [blame] | 2065 | * nss_stats_virt_if_read() |
| 2066 | * Read virt_if statistics |
| 2067 | */ |
| 2068 | static ssize_t nss_stats_virt_if_read(struct file *fp, char __user *ubuf, |
| 2069 | size_t sz, loff_t *ppos) |
| 2070 | { |
| 2071 | struct nss_stats_data *data = fp->private_data; |
| 2072 | int32_t if_num = NSS_DYNAMIC_IF_START; |
| 2073 | int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES; |
| 2074 | size_t bytes = 0; |
| 2075 | ssize_t bytes_read = 0; |
| 2076 | char line[80]; |
| 2077 | int start, end; |
| 2078 | |
| 2079 | if (data) { |
| 2080 | if_num = data->if_num; |
| 2081 | } |
| 2082 | |
| 2083 | if (if_num > max_if_num) { |
| 2084 | return 0; |
| 2085 | } |
| 2086 | |
| 2087 | for (; if_num < max_if_num; if_num++) { |
| 2088 | if (nss_dynamic_interface_get_type(if_num) != NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR) |
| 2089 | continue; |
| 2090 | |
| 2091 | bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num); |
| 2092 | if ((bytes_read + bytes) > sz) |
| 2093 | break; |
| 2094 | |
| 2095 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2096 | bytes_read = -EFAULT; |
| 2097 | goto end; |
| 2098 | } |
| 2099 | |
| 2100 | bytes_read += bytes; |
| 2101 | |
| 2102 | start = 0; |
| 2103 | end = 7; |
| 2104 | while (bytes_read < sz && start < end) { |
| 2105 | bytes = nss_virt_if_copy_stats(if_num, start, line); |
| 2106 | if (!bytes) |
| 2107 | break; |
| 2108 | |
| 2109 | if ((bytes_read + bytes) > sz) |
| 2110 | break; |
| 2111 | |
| 2112 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2113 | bytes_read = -EFAULT; |
| 2114 | goto end; |
| 2115 | } |
| 2116 | |
| 2117 | bytes_read += bytes; |
| 2118 | start++; |
| 2119 | } |
| 2120 | |
| 2121 | bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num); |
| 2122 | if (bytes_read > (sz - bytes)) |
| 2123 | break; |
| 2124 | |
| 2125 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2126 | bytes_read = -EFAULT; |
| 2127 | goto end; |
| 2128 | } |
| 2129 | |
| 2130 | bytes_read += bytes; |
| 2131 | } |
| 2132 | |
| 2133 | if (bytes_read > 0) { |
| 2134 | *ppos = bytes_read; |
| 2135 | } |
| 2136 | |
| 2137 | if (data) { |
| 2138 | data->if_num = if_num; |
| 2139 | } |
| 2140 | |
| 2141 | end: |
| 2142 | return bytes_read; |
| 2143 | } |
| 2144 | |
| 2145 | /* |
Sundarajan Srinivasan | cd1631b | 2015-06-18 01:23:30 -0700 | [diff] [blame] | 2146 | * nss_stats_tx_rx_virt_if_read() |
| 2147 | * Read tx_rx_virt_if statistics |
| 2148 | */ |
| 2149 | static ssize_t nss_stats_tx_rx_virt_if_read(struct file *fp, char __user *ubuf, |
| 2150 | size_t sz, loff_t *ppos) |
| 2151 | { |
| 2152 | struct nss_stats_data *data = fp->private_data; |
| 2153 | int32_t if_num = NSS_DYNAMIC_IF_START; |
| 2154 | int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES; |
| 2155 | size_t bytes = 0; |
| 2156 | ssize_t bytes_read = 0; |
| 2157 | char line[80]; |
| 2158 | int start, end; |
| 2159 | |
| 2160 | if (data) { |
| 2161 | if_num = data->if_num; |
| 2162 | } |
| 2163 | |
| 2164 | if (if_num > max_if_num) { |
| 2165 | return 0; |
| 2166 | } |
| 2167 | |
| 2168 | for (; if_num < max_if_num; if_num++) { |
| 2169 | if (nss_dynamic_interface_get_type(if_num) != NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED) |
| 2170 | continue; |
| 2171 | |
| 2172 | bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num); |
| 2173 | if ((bytes_read + bytes) > sz) |
| 2174 | break; |
| 2175 | |
| 2176 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2177 | bytes_read = -EFAULT; |
| 2178 | goto end; |
| 2179 | } |
| 2180 | |
| 2181 | bytes_read += bytes; |
| 2182 | |
| 2183 | start = 0; |
| 2184 | end = 7; |
| 2185 | while (bytes_read < sz && start < end) { |
| 2186 | bytes = nss_tx_rx_virt_if_copy_stats(if_num, start, line); |
| 2187 | if (!bytes) |
| 2188 | break; |
| 2189 | |
| 2190 | if ((bytes_read + bytes) > sz) |
| 2191 | break; |
| 2192 | |
| 2193 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2194 | bytes_read = -EFAULT; |
| 2195 | goto end; |
| 2196 | } |
| 2197 | |
| 2198 | bytes_read += bytes; |
| 2199 | start++; |
| 2200 | } |
| 2201 | |
| 2202 | bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num); |
| 2203 | if (bytes_read > (sz - bytes)) |
| 2204 | break; |
| 2205 | |
| 2206 | if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { |
| 2207 | bytes_read = -EFAULT; |
| 2208 | goto end; |
| 2209 | } |
| 2210 | |
| 2211 | bytes_read += bytes; |
| 2212 | } |
| 2213 | |
| 2214 | if (bytes_read > 0) { |
| 2215 | *ppos = bytes_read; |
| 2216 | } |
| 2217 | |
| 2218 | if (data) { |
| 2219 | data->if_num = if_num; |
| 2220 | } |
| 2221 | |
| 2222 | end: |
| 2223 | return bytes_read; |
| 2224 | } |
| 2225 | |
| 2226 | /* |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 2227 | * nss_stats_open() |
| 2228 | */ |
| 2229 | static int nss_stats_open(struct inode *inode, struct file *filp) |
| 2230 | { |
| 2231 | struct nss_stats_data *data = NULL; |
| 2232 | |
| 2233 | data = kzalloc(sizeof(struct nss_stats_data), GFP_KERNEL); |
| 2234 | if (!data) { |
| 2235 | return -ENOMEM; |
| 2236 | } |
| 2237 | memset(data, 0, sizeof (struct nss_stats_data)); |
| 2238 | data->if_num = NSS_DYNAMIC_IF_START; |
Ankit Dhanuka | 6228ebd | 2014-11-05 17:26:01 +0530 | [diff] [blame] | 2239 | data->index = 0; |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 2240 | filp->private_data = data; |
| 2241 | |
| 2242 | return 0; |
| 2243 | } |
| 2244 | |
| 2245 | /* |
| 2246 | * nss_stats_release() |
| 2247 | */ |
| 2248 | static int nss_stats_release(struct inode *inode, struct file *filp) |
| 2249 | { |
| 2250 | struct nss_stats_data *data = filp->private_data; |
| 2251 | |
| 2252 | if (data) { |
| 2253 | kfree(data); |
| 2254 | } |
| 2255 | |
| 2256 | return 0; |
| 2257 | } |
| 2258 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2259 | #define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \ |
| 2260 | static const struct file_operations nss_stats_##name##_ops = { \ |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 2261 | .open = nss_stats_open, \ |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2262 | .read = nss_stats_##name##_read, \ |
| 2263 | .llseek = generic_file_llseek, \ |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 2264 | .release = nss_stats_release, \ |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2265 | }; |
| 2266 | |
| 2267 | /* |
| 2268 | * nss_ipv4_stats_ops |
| 2269 | */ |
| 2270 | NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4) |
| 2271 | |
| 2272 | /* |
Selin Dag | 6d9b0c1 | 2014-11-04 18:27:21 -0800 | [diff] [blame] | 2273 | * ipv4_reasm_stats_ops |
| 2274 | */ |
| 2275 | NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4_reasm) |
| 2276 | |
| 2277 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2278 | * ipv6_stats_ops |
| 2279 | */ |
| 2280 | NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6) |
| 2281 | |
| 2282 | /* |
Selin Dag | 60a2f5b | 2015-06-29 14:39:49 -0700 | [diff] [blame] | 2283 | * ipv6_reasm_stats_ops |
| 2284 | */ |
| 2285 | NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6_reasm) |
| 2286 | |
| 2287 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2288 | * n2h_stats_ops |
| 2289 | */ |
| 2290 | NSS_STATS_DECLARE_FILE_OPERATIONS(n2h) |
Thomas Wu | c3e382c | 2014-10-29 15:35:13 -0700 | [diff] [blame] | 2291 | |
| 2292 | /* |
| 2293 | * lso_rx_stats_ops |
| 2294 | */ |
| 2295 | NSS_STATS_DECLARE_FILE_OPERATIONS(lso_rx) |
| 2296 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2297 | /* |
| 2298 | * drv_stats_ops |
| 2299 | */ |
| 2300 | NSS_STATS_DECLARE_FILE_OPERATIONS(drv) |
| 2301 | |
| 2302 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2303 | * pppoe_stats_ops |
| 2304 | */ |
| 2305 | NSS_STATS_DECLARE_FILE_OPERATIONS(pppoe) |
| 2306 | |
| 2307 | /* |
ratheesh kannoth | 7af985d | 2015-06-24 15:08:40 +0530 | [diff] [blame] | 2308 | * l2tpv2_stats_ops |
| 2309 | */ |
| 2310 | NSS_STATS_DECLARE_FILE_OPERATIONS(l2tpv2) |
| 2311 | |
| 2312 | /* |
Shyam Sunder | 66e889d | 2015-11-02 15:31:20 +0530 | [diff] [blame] | 2313 | * pptp_stats_ops |
| 2314 | */ |
| 2315 | NSS_STATS_DECLARE_FILE_OPERATIONS(pptp) |
| 2316 | |
| 2317 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2318 | * gmac_stats_ops |
| 2319 | */ |
| 2320 | NSS_STATS_DECLARE_FILE_OPERATIONS(gmac) |
| 2321 | |
| 2322 | /* |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 2323 | * capwap_stats_ops |
| 2324 | */ |
| 2325 | NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_encap) |
| 2326 | NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_decap) |
| 2327 | |
| 2328 | /* |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 2329 | * eth_rx_stats_ops |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2330 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 2331 | NSS_STATS_DECLARE_FILE_OPERATIONS(eth_rx) |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2332 | |
| 2333 | /* |
Ankit Dhanuka | 6228ebd | 2014-11-05 17:26:01 +0530 | [diff] [blame] | 2334 | * gre_redir_ops |
| 2335 | */ |
| 2336 | NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir) |
| 2337 | |
| 2338 | /* |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 2339 | * sjack_stats_ops |
| 2340 | */ |
| 2341 | NSS_STATS_DECLARE_FILE_OPERATIONS(sjack) |
| 2342 | |
Stephen Wang | 9779d95 | 2015-10-28 11:39:07 -0700 | [diff] [blame] | 2343 | /* |
| 2344 | * portid_ops |
| 2345 | */ |
| 2346 | NSS_STATS_DECLARE_FILE_OPERATIONS(portid) |
| 2347 | |
Sundarajan Srinivasan | 273d900 | 2015-03-03 15:43:16 -0800 | [diff] [blame] | 2348 | NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_if) |
| 2349 | |
Sundarajan Srinivasan | ab2c856 | 2015-06-09 16:14:10 -0700 | [diff] [blame] | 2350 | NSS_STATS_DECLARE_FILE_OPERATIONS(virt_if) |
| 2351 | |
Sundarajan Srinivasan | cd1631b | 2015-06-18 01:23:30 -0700 | [diff] [blame] | 2352 | NSS_STATS_DECLARE_FILE_OPERATIONS(tx_rx_virt_if) |
| 2353 | |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 2354 | /* |
Bharath M Kumar | cc666e9 | 2014-12-24 19:17:28 +0530 | [diff] [blame] | 2355 | * wifi_stats_ops |
| 2356 | */ |
| 2357 | NSS_STATS_DECLARE_FILE_OPERATIONS(wifi) |
| 2358 | |
| 2359 | /* |
Tushar Mathur | ff8741b | 2015-12-02 20:28:59 +0530 | [diff] [blame] | 2360 | * dtls_stats_ops |
| 2361 | */ |
| 2362 | NSS_STATS_DECLARE_FILE_OPERATIONS(dtls) |
| 2363 | |
| 2364 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2365 | * nss_stats_init() |
| 2366 | * Enable NSS statistics |
| 2367 | */ |
| 2368 | void nss_stats_init(void) |
| 2369 | { |
| 2370 | /* |
| 2371 | * NSS driver entry |
| 2372 | */ |
| 2373 | nss_top_main.top_dentry = debugfs_create_dir("qca-nss-drv", NULL); |
| 2374 | if (unlikely(nss_top_main.top_dentry == NULL)) { |
| 2375 | nss_warning("Failed to create qca-nss-drv directory in debugfs"); |
| 2376 | |
| 2377 | /* |
| 2378 | * Non availability of debugfs directory is not a catastrophy |
| 2379 | * We can still go ahead with other initialization |
| 2380 | */ |
| 2381 | return; |
| 2382 | } |
| 2383 | |
| 2384 | 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] | 2385 | if (unlikely(nss_top_main.stats_dentry == NULL)) { |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2386 | nss_warning("Failed to create qca-nss-drv directory in debugfs"); |
| 2387 | |
| 2388 | /* |
| 2389 | * Non availability of debugfs directory is not a catastrophy |
| 2390 | * We can still go ahead with rest of initialization |
| 2391 | */ |
| 2392 | return; |
| 2393 | } |
| 2394 | |
| 2395 | /* |
| 2396 | * Create files to obtain statistics |
| 2397 | */ |
| 2398 | |
| 2399 | /* |
| 2400 | * ipv4_stats |
| 2401 | */ |
| 2402 | nss_top_main.ipv4_dentry = debugfs_create_file("ipv4", 0400, |
| 2403 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_ops); |
| 2404 | if (unlikely(nss_top_main.ipv4_dentry == NULL)) { |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 2405 | 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] | 2406 | return; |
| 2407 | } |
| 2408 | |
| 2409 | /* |
Selin Dag | 6d9b0c1 | 2014-11-04 18:27:21 -0800 | [diff] [blame] | 2410 | * ipv4_reasm_stats |
| 2411 | */ |
| 2412 | nss_top_main.ipv4_reasm_dentry = debugfs_create_file("ipv4_reasm", 0400, |
| 2413 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv4_reasm_ops); |
| 2414 | if (unlikely(nss_top_main.ipv4_reasm_dentry == NULL)) { |
| 2415 | nss_warning("Failed to create qca-nss-drv/stats/ipv4_reasm file in debugfs"); |
| 2416 | return; |
| 2417 | } |
| 2418 | |
| 2419 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2420 | * ipv6_stats |
| 2421 | */ |
| 2422 | nss_top_main.ipv6_dentry = debugfs_create_file("ipv6", 0400, |
| 2423 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_ops); |
| 2424 | if (unlikely(nss_top_main.ipv6_dentry == NULL)) { |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 2425 | 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] | 2426 | return; |
| 2427 | } |
| 2428 | |
| 2429 | /* |
Selin Dag | 60a2f5b | 2015-06-29 14:39:49 -0700 | [diff] [blame] | 2430 | * ipv6_reasm_stats |
| 2431 | */ |
| 2432 | nss_top_main.ipv6_reasm_dentry = debugfs_create_file("ipv6_reasm", 0400, |
| 2433 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_ipv6_reasm_ops); |
| 2434 | if (unlikely(nss_top_main.ipv6_reasm_dentry == NULL)) { |
| 2435 | nss_warning("Failed to create qca-nss-drv/stats/ipv6_reasm file in debugfs"); |
| 2436 | return; |
| 2437 | } |
| 2438 | |
| 2439 | /* |
| 2440 | * eth_rx__stats |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2441 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 2442 | nss_top_main.eth_rx_dentry = debugfs_create_file("eth_rx", 0400, |
| 2443 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_eth_rx_ops); |
| 2444 | if (unlikely(nss_top_main.eth_rx_dentry == NULL)) { |
| 2445 | 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] | 2446 | return; |
| 2447 | } |
| 2448 | |
| 2449 | /* |
| 2450 | * n2h_stats |
| 2451 | */ |
| 2452 | nss_top_main.n2h_dentry = debugfs_create_file("n2h", 0400, |
| 2453 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_n2h_ops); |
| 2454 | if (unlikely(nss_top_main.n2h_dentry == NULL)) { |
| 2455 | nss_warning("Failed to create qca-nss-drv/stats/n2h directory in debugfs"); |
| 2456 | return; |
| 2457 | } |
| 2458 | |
| 2459 | /* |
Thomas Wu | c3e382c | 2014-10-29 15:35:13 -0700 | [diff] [blame] | 2460 | * lso_rx_stats |
| 2461 | */ |
| 2462 | nss_top_main.lso_rx_dentry = debugfs_create_file("lso_rx", 0400, |
| 2463 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_lso_rx_ops); |
| 2464 | if (unlikely(nss_top_main.lso_rx_dentry == NULL)) { |
| 2465 | nss_warning("Failed to create qca-nss-drv/stats/lso_rx file in debugfs"); |
| 2466 | return; |
| 2467 | } |
| 2468 | |
| 2469 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2470 | * drv_stats |
| 2471 | */ |
| 2472 | nss_top_main.drv_dentry = debugfs_create_file("drv", 0400, |
| 2473 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_drv_ops); |
| 2474 | if (unlikely(nss_top_main.drv_dentry == NULL)) { |
| 2475 | nss_warning("Failed to create qca-nss-drv/stats/drv directory in debugfs"); |
| 2476 | return; |
| 2477 | } |
| 2478 | |
| 2479 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2480 | * pppoe_stats |
| 2481 | */ |
| 2482 | nss_top_main.pppoe_dentry = debugfs_create_file("pppoe", 0400, |
| 2483 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pppoe_ops); |
| 2484 | if (unlikely(nss_top_main.pppoe_dentry == NULL)) { |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 2485 | 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] | 2486 | return; |
| 2487 | } |
| 2488 | |
| 2489 | /* |
| 2490 | * gmac_stats |
| 2491 | */ |
| 2492 | nss_top_main.gmac_dentry = debugfs_create_file("gmac", 0400, |
| 2493 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_gmac_ops); |
| 2494 | if (unlikely(nss_top_main.gmac_dentry == NULL)) { |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 2495 | 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] | 2496 | return; |
| 2497 | } |
Saurabh Misra | 09dddeb | 2014-09-30 16:38:07 -0700 | [diff] [blame] | 2498 | |
| 2499 | /* |
| 2500 | * CAPWAP stats. |
| 2501 | */ |
| 2502 | nss_top_main.capwap_encap_dentry = debugfs_create_file("capwap_encap", 0400, |
| 2503 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_encap_ops); |
| 2504 | if (unlikely(nss_top_main.capwap_encap_dentry == NULL)) { |
| 2505 | nss_warning("Failed to create qca-nss-drv/stats/capwap_encap file in debugfs"); |
| 2506 | return; |
| 2507 | } |
| 2508 | |
| 2509 | nss_top_main.capwap_decap_dentry = debugfs_create_file("capwap_decap", 0400, |
| 2510 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_capwap_decap_ops); |
| 2511 | if (unlikely(nss_top_main.capwap_decap_dentry == NULL)) { |
| 2512 | nss_warning("Failed to create qca-nss-drv/stats/capwap_decap file in debugfs"); |
| 2513 | return; |
| 2514 | } |
Ankit Dhanuka | 6228ebd | 2014-11-05 17:26:01 +0530 | [diff] [blame] | 2515 | |
| 2516 | /* |
| 2517 | * GRE_REDIR stats |
| 2518 | */ |
| 2519 | nss_top_main.gre_redir_dentry = debugfs_create_file("gre_redir", 0400, |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 2520 | 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] | 2521 | if (unlikely(nss_top_main.gre_redir_dentry == NULL)) { |
| 2522 | nss_warning("Failed to create qca-nss-drv/stats/gre_redir file in debugfs"); |
| 2523 | return; |
| 2524 | } |
Ankit Dhanuka | 1499999 | 2014-11-12 15:35:11 +0530 | [diff] [blame] | 2525 | |
| 2526 | /* |
| 2527 | * SJACK stats |
| 2528 | */ |
| 2529 | nss_top_main.sjack_dentry = debugfs_create_file("sjack", 0400, |
| 2530 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_sjack_ops); |
| 2531 | if (unlikely(nss_top_main.sjack_dentry == NULL)) { |
| 2532 | nss_warning("Failed to create qca-nss-drv/stats/sjack file in debugfs"); |
| 2533 | return; |
| 2534 | } |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 2535 | |
Bharath M Kumar | cc666e9 | 2014-12-24 19:17:28 +0530 | [diff] [blame] | 2536 | /* |
Stephen Wang | 9779d95 | 2015-10-28 11:39:07 -0700 | [diff] [blame] | 2537 | * PORTID stats |
| 2538 | */ |
| 2539 | nss_top_main.portid_dentry = debugfs_create_file("portid", 0400, |
| 2540 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_portid_ops); |
| 2541 | if (unlikely(nss_top_main.portid_dentry == NULL)) { |
| 2542 | nss_warning("Failed to create qca-nss-drv/stats/portid file in debugfs"); |
| 2543 | return; |
| 2544 | } |
| 2545 | |
| 2546 | /* |
Bharath M Kumar | cc666e9 | 2014-12-24 19:17:28 +0530 | [diff] [blame] | 2547 | * WIFI stats |
| 2548 | */ |
| 2549 | nss_top_main.wifi_dentry = debugfs_create_file("wifi", 0400, |
| 2550 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_ops); |
| 2551 | if (unlikely(nss_top_main.wifi_dentry == NULL)) { |
| 2552 | nss_warning("Failed to create qca-nss-drv/stats/wifi file in debugfs"); |
| 2553 | return; |
| 2554 | } |
| 2555 | |
Sundarajan Srinivasan | 273d900 | 2015-03-03 15:43:16 -0800 | [diff] [blame] | 2556 | /* |
| 2557 | * wifi_if stats |
| 2558 | */ |
| 2559 | nss_top_main.wifi_if_dentry = debugfs_create_file("wifi_if", 0400, |
| 2560 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_wifi_if_ops); |
| 2561 | if (unlikely(nss_top_main.wifi_if_dentry == NULL)) { |
| 2562 | nss_warning("Failed to create qca-nss-drv/stats/wifi_if file in debugfs"); |
| 2563 | return; |
| 2564 | } |
| 2565 | |
Sundarajan Srinivasan | ab2c856 | 2015-06-09 16:14:10 -0700 | [diff] [blame] | 2566 | nss_top_main.virt_if_dentry = debugfs_create_file("virt_if", 0400, |
| 2567 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_virt_if_ops); |
| 2568 | if (unlikely(nss_top_main.virt_if_dentry == NULL)) { |
| 2569 | nss_warning("Failed to create qca-nss-drv/stats/virt_if file in debugfs"); |
| 2570 | return; |
| 2571 | } |
| 2572 | |
Sundarajan Srinivasan | cd1631b | 2015-06-18 01:23:30 -0700 | [diff] [blame] | 2573 | nss_top_main.tx_rx_virt_if_dentry = debugfs_create_file("tx_rx_virt_if", 0400, |
| 2574 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_tx_rx_virt_if_ops); |
| 2575 | if (unlikely(nss_top_main.virt_if_dentry == NULL)) { |
| 2576 | nss_warning("Failed to create qca-nss-drv/stats/tx_rx_virt_if file in debugfs"); |
| 2577 | return; |
| 2578 | } |
| 2579 | |
ratheesh kannoth | 7af985d | 2015-06-24 15:08:40 +0530 | [diff] [blame] | 2580 | /* |
| 2581 | * L2TPV2 Stats |
| 2582 | */ |
| 2583 | nss_top_main.l2tpv2_dentry = debugfs_create_file("l2tpv2", 0400, |
| 2584 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_l2tpv2_ops); |
| 2585 | if (unlikely(nss_top_main.l2tpv2_dentry == NULL)) { |
| 2586 | nss_warning("Failed to create qca-nss-drv/stats/l2tpv2 file in debugfs"); |
| 2587 | return; |
| 2588 | } |
Shyam Sunder | 66e889d | 2015-11-02 15:31:20 +0530 | [diff] [blame] | 2589 | |
| 2590 | /* |
| 2591 | * PPTP Stats |
| 2592 | */ |
| 2593 | nss_top_main.pptp_dentry = debugfs_create_file("pptp", 0400, |
| 2594 | nss_top_main.stats_dentry, &nss_top_main, &nss_stats_pptp_ops); |
| 2595 | if (unlikely(nss_top_main.pptp_dentry == NULL)) { |
| 2596 | 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] | 2597 | } |
| 2598 | |
| 2599 | /* |
| 2600 | * DTLS Stats |
| 2601 | */ |
| 2602 | nss_top_main.dtls_dentry = debugfs_create_file("dtls", 0400, |
| 2603 | nss_top_main.stats_dentry, |
| 2604 | &nss_top_main, |
| 2605 | &nss_stats_dtls_ops); |
| 2606 | if (unlikely(nss_top_main.dtls_dentry == NULL)) { |
| 2607 | 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] | 2608 | return; |
| 2609 | } |
| 2610 | |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 2611 | nss_log_init(); |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2612 | } |
| 2613 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2614 | /* |
| 2615 | * nss_stats_clean() |
| 2616 | * Cleanup NSS statistics files |
| 2617 | */ |
| 2618 | void nss_stats_clean(void) |
| 2619 | { |
| 2620 | /* |
| 2621 | * Remove debugfs tree |
| 2622 | */ |
| 2623 | if (likely(nss_top_main.top_dentry != NULL)) { |
| 2624 | debugfs_remove_recursive(nss_top_main.top_dentry); |
Stephen Wang | dc8b532 | 2015-06-27 20:11:50 -0700 | [diff] [blame] | 2625 | nss_top_main.top_dentry = NULL; |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 2626 | } |
| 2627 | } |