Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Stephen Wang | efd3851 | 2017-01-24 14:01:02 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +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 | */ |
| 16 | |
| 17 | /* |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 18 | * nss_n2h.c |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 19 | * NSS N2H node APIs |
| 20 | */ |
| 21 | |
| 22 | #include "nss_tx_rx_common.h" |
| 23 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 24 | #define NSS_N2H_MAX_BUF_POOL_SIZE (1024 * 1024 * 8) /* 8MB */ |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 25 | #define NSS_N2H_MIN_EMPTY_POOL_BUF_SZ 32 |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 26 | #define NSS_N2H_MAX_EMPTY_POOL_BUF_SZ 65536 |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 27 | #define NSS_N2H_DEFAULT_EMPTY_POOL_BUF_SZ 8192 |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 28 | |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 29 | int nss_n2h_empty_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1}; |
| 30 | int nss_n2h_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} }; |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 31 | int nss_n2h_wifi_pool_buf_cfg __read_mostly = -1; |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 32 | int nss_n2h_rps_config __read_mostly; |
| 33 | int nss_n2h_core0_mitigation_cfg __read_mostly = 1; |
| 34 | int nss_n2h_core1_mitigation_cfg __read_mostly = 1; |
| 35 | int nss_n2h_core0_add_buf_pool_size __read_mostly; |
| 36 | int nss_n2h_core1_add_buf_pool_size __read_mostly; |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 37 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 38 | struct nss_n2h_registered_data { |
| 39 | nss_n2h_msg_callback_t n2h_callback; |
| 40 | void *app_data; |
| 41 | }; |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 42 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 43 | static struct nss_n2h_cfg_pvt nss_n2h_nepbcfgp[NSS_MAX_CORES]; |
| 44 | static struct nss_n2h_registered_data nss_n2h_rd[NSS_MAX_CORES]; |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 45 | static struct nss_n2h_cfg_pvt nss_n2h_rcp; |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 46 | static struct nss_n2h_cfg_pvt nss_n2h_mitigationcp[NSS_CORE_MAX]; |
| 47 | static struct nss_n2h_cfg_pvt nss_n2h_bufcp[NSS_CORE_MAX]; |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 48 | static struct nss_n2h_cfg_pvt nss_n2h_wp; |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 49 | |
| 50 | /* |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 51 | * nss_n2h_stats_sync() |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 52 | * Handle the syncing of NSS statistics. |
| 53 | */ |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 54 | static void nss_n2h_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_n2h_stats_sync *nnss) |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 55 | { |
| 56 | struct nss_top_instance *nss_top = nss_ctx->nss_top; |
| 57 | |
| 58 | spin_lock_bh(&nss_top->stats_lock); |
| 59 | |
| 60 | /* |
| 61 | * common node stats |
| 62 | */ |
| 63 | nss_ctx->stats_n2h[NSS_STATS_NODE_RX_PKTS] += nnss->node_stats.rx_packets; |
| 64 | nss_ctx->stats_n2h[NSS_STATS_NODE_RX_BYTES] += nnss->node_stats.rx_bytes; |
| 65 | nss_ctx->stats_n2h[NSS_STATS_NODE_RX_DROPPED] += nnss->node_stats.rx_dropped; |
| 66 | nss_ctx->stats_n2h[NSS_STATS_NODE_TX_PKTS] += nnss->node_stats.tx_packets; |
| 67 | nss_ctx->stats_n2h[NSS_STATS_NODE_TX_BYTES] += nnss->node_stats.tx_bytes; |
| 68 | |
| 69 | /* |
| 70 | * General N2H stats |
| 71 | */ |
Murat Sezgin | 0c0561d | 2014-04-09 18:55:58 -0700 | [diff] [blame] | 72 | nss_ctx->stats_n2h[NSS_STATS_N2H_QUEUE_DROPPED] += nnss->queue_dropped; |
| 73 | nss_ctx->stats_n2h[NSS_STATS_N2H_TOTAL_TICKS] += nnss->total_ticks; |
| 74 | nss_ctx->stats_n2h[NSS_STATS_N2H_WORST_CASE_TICKS] += nnss->worst_case_ticks; |
| 75 | nss_ctx->stats_n2h[NSS_STATS_N2H_ITERATIONS] += nnss->iterations; |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 76 | |
| 77 | /* |
Thomas Wu | 3fd8dd7 | 2014-06-11 15:57:05 -0700 | [diff] [blame] | 78 | * pbuf manager ocm and default pool stats |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 79 | */ |
Thomas Wu | 3fd8dd7 | 2014-06-11 15:57:05 -0700 | [diff] [blame] | 80 | nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_ALLOC_FAILS] += nnss->pbuf_ocm_stats.pbuf_alloc_fails; |
| 81 | nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_FREE_COUNT] = nnss->pbuf_ocm_stats.pbuf_free_count; |
| 82 | nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_TOTAL_COUNT] = nnss->pbuf_ocm_stats.pbuf_total_count; |
| 83 | |
| 84 | nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_ALLOC_FAILS] += nnss->pbuf_default_stats.pbuf_alloc_fails; |
| 85 | nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_FREE_COUNT] = nnss->pbuf_default_stats.pbuf_free_count; |
| 86 | nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_TOTAL_COUNT] = nnss->pbuf_default_stats.pbuf_total_count; |
| 87 | |
| 88 | /* |
| 89 | * payload mgr stats |
| 90 | */ |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 91 | nss_ctx->stats_n2h[NSS_STATS_N2H_PAYLOAD_ALLOC_FAILS] += nnss->payload_alloc_fails; |
Thomas Wu | 5367984 | 2015-01-22 13:37:35 -0800 | [diff] [blame] | 92 | nss_ctx->stats_n2h[NSS_STATS_N2H_PAYLOAD_FREE_COUNT] = nnss->payload_free_count; |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 93 | |
Sakthi Vignesh Radhakrishnan | 2a8ee96 | 2014-11-22 13:35:38 -0800 | [diff] [blame] | 94 | /* |
| 95 | * Host <=> NSS control traffic stats |
| 96 | */ |
| 97 | nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_CONTROL_PACKETS] += nnss->h2n_ctrl_pkts; |
| 98 | nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_CONTROL_BYTES] += nnss->h2n_ctrl_bytes; |
| 99 | nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_CONTROL_PACKETS] += nnss->n2h_ctrl_pkts; |
| 100 | nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_CONTROL_BYTES] += nnss->n2h_ctrl_bytes; |
| 101 | |
| 102 | /* |
| 103 | * Host <=> NSS control data traffic stats |
| 104 | */ |
| 105 | nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_DATA_PACKETS] += nnss->h2n_data_pkts; |
| 106 | nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_DATA_BYTES] += nnss->h2n_data_bytes; |
| 107 | nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_DATA_PACKETS] += nnss->n2h_data_pkts; |
| 108 | nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_DATA_BYTES] += nnss->n2h_data_bytes; |
| 109 | |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 110 | /* |
| 111 | * Payloads related stats |
| 112 | */ |
| 113 | nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_TOT_PAYLOADS] = nnss->tot_payloads; |
| 114 | |
Guojun Jin | 85dfa7b | 2015-09-02 15:13:56 -0700 | [diff] [blame] | 115 | nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_INTERFACE_INVALID] += nnss->data_interface_invalid; |
| 116 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 117 | spin_unlock_bh(&nss_top->stats_lock); |
| 118 | } |
| 119 | |
| 120 | /* |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 121 | * nss_n2h_interface_handler() |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 122 | * Handle NSS -> HLOS messages for N2H node |
| 123 | */ |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 124 | static void nss_n2h_interface_handler(struct nss_ctx_instance *nss_ctx, |
| 125 | struct nss_cmn_msg *ncm, |
Arunkumar T | ba9b4a0 | 2016-11-07 11:41:14 +0530 | [diff] [blame] | 126 | void *app_data) |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 127 | { |
| 128 | struct nss_n2h_msg *nnm = (struct nss_n2h_msg *)ncm; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 129 | nss_n2h_msg_callback_t cb; |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 130 | |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 131 | BUG_ON(ncm->interface != NSS_N2H_INTERFACE); |
| 132 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 133 | /* |
| 134 | * Is this a valid request/response packet? |
| 135 | */ |
| 136 | if (nnm->cm.type >= NSS_METADATA_TYPE_N2H_MAX) { |
| 137 | nss_warning("%p: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type); |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | switch (nnm->cm.type) { |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 142 | case NSS_TX_METADATA_TYPE_N2H_RPS_CFG: |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 143 | nss_info("NSS N2H rps_en %d \n",nnm->msg.rps_cfg.enable); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 144 | break; |
| 145 | |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 146 | case NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG: |
| 147 | nss_info("NSS N2H mitigation_dis %d \n",nnm->msg.mitigation_cfg.enable); |
| 148 | break; |
| 149 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 150 | case NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG: |
| 151 | nss_info("%p: empty pool buf cfg response from FW", nss_ctx); |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 152 | break; |
| 153 | |
Radha krishna Simha Jiguru | 7f424d5 | 2015-02-10 19:41:01 +0530 | [diff] [blame] | 154 | case NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS: |
| 155 | nss_info("%p: flush payloads cmd response from FW", nss_ctx); |
| 156 | break; |
| 157 | |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 158 | case NSS_RX_METADATA_TYPE_N2H_STATS_SYNC: |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 159 | nss_n2h_stats_sync(nss_ctx, &nnm->msg.stats_sync); |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 160 | break; |
| 161 | |
| 162 | default: |
| 163 | if (ncm->response != NSS_CMN_RESPONSE_ACK) { |
| 164 | /* |
| 165 | * Check response |
| 166 | */ |
| 167 | nss_info("%p: Received response %d for type %d, interface %d", |
| 168 | nss_ctx, ncm->response, ncm->type, ncm->interface); |
| 169 | } |
| 170 | } |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 171 | |
| 172 | /* |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 173 | * Update the callback and app_data for NOTIFY messages, n2h sends all notify messages |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 174 | * to the same callback/app_data. |
| 175 | */ |
| 176 | if (nnm->cm.response == NSS_CMM_RESPONSE_NOTIFY) { |
| 177 | /* |
| 178 | * Place holder for the user to create right call |
| 179 | * back and app data when response is NSS_CMM_RESPONSE_NOTIFY |
| 180 | */ |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 181 | ncm->cb = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].n2h_callback; |
| 182 | ncm->app_data = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].app_data; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Do we have a callback? |
| 187 | */ |
| 188 | if (!ncm->cb) { |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | * Callback |
| 194 | */ |
| 195 | cb = (nss_n2h_msg_callback_t)ncm->cb; |
| 196 | cb((void *)ncm->app_data, nnm); |
| 197 | } |
| 198 | |
| 199 | /* |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 200 | * nss_n2h_rps_cfg_callback() |
| 201 | * call back function for rps configuration |
| 202 | */ |
| 203 | static void nss_n2h_rps_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) |
| 204 | { |
| 205 | struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)app_data; |
| 206 | if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 207 | |
| 208 | /* |
| 209 | * Error, hence we are not updating the nss_n2h_empty_pool_buf |
| 210 | * Restore the current_value to its previous state |
| 211 | */ |
| 212 | nss_n2h_rcp.response = NSS_FAILURE; |
| 213 | complete(&nss_n2h_rcp.complete); |
| 214 | nss_warning("%p: RPS configuration failed : %d\n", nss_ctx, |
| 215 | nnm->cm.error); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | nss_info("%p: RPS configuration succeeded: %d\n", nss_ctx, |
| 220 | nnm->cm.error); |
| 221 | nss_ctx->n2h_rps_en = nnm->msg.rps_cfg.enable; |
| 222 | nss_n2h_rcp.response = NSS_SUCCESS; |
| 223 | complete(&nss_n2h_rcp.complete); |
| 224 | } |
| 225 | |
| 226 | /* |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 227 | * nss_n2h_mitigation_cfg_callback() |
| 228 | * call back function for mitigation configuration |
| 229 | */ |
| 230 | static void nss_n2h_mitigation_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) |
| 231 | { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 232 | uint32_t core_num = (uint32_t)(nss_ptr_t)app_data; |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 233 | struct nss_top_instance *nss_top = &nss_top_main; |
| 234 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; |
| 235 | |
| 236 | if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 237 | |
| 238 | /* |
| 239 | * Error, hence we are not updating the nss_n2h_mitigate_en |
| 240 | */ |
| 241 | nss_n2h_mitigationcp[core_num].response = NSS_FAILURE; |
| 242 | complete(&nss_n2h_mitigationcp[core_num].complete); |
| 243 | nss_warning("core%d: MITIGATION configuration failed : %d\n", core_num, nnm->cm.error); |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | nss_info("core%d: MITIGATION configuration succeeded: %d\n", core_num, nnm->cm.error); |
| 248 | |
| 249 | nss_ctx->n2h_mitigate_en = nnm->msg.mitigation_cfg.enable; |
| 250 | nss_n2h_mitigationcp[core_num].response = NSS_SUCCESS; |
| 251 | complete(&nss_n2h_mitigationcp[core_num].complete); |
| 252 | } |
| 253 | |
| 254 | /* |
| 255 | * nss_n2h_buf_cfg_callback() |
| 256 | * call back function for pbuf configuration |
| 257 | */ |
| 258 | static void nss_n2h_bufs_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) |
| 259 | { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 260 | uint32_t core_num = (uint32_t)(nss_ptr_t)app_data; |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 261 | unsigned int allocated_sz; |
| 262 | |
| 263 | struct nss_top_instance *nss_top = &nss_top_main; |
| 264 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; |
| 265 | |
| 266 | if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 267 | nss_n2h_bufcp[core_num].response = NSS_FAILURE; |
| 268 | nss_warning("core%d: buf configuration failed : %d\n", core_num, nnm->cm.error); |
| 269 | goto done; |
| 270 | } |
| 271 | |
| 272 | nss_info("core%d: buf configuration succeeded: %d\n", core_num, nnm->cm.error); |
| 273 | |
| 274 | allocated_sz = nnm->msg.buf_pool.nss_buf_page_size * nnm->msg.buf_pool.nss_buf_num_pages; |
| 275 | nss_ctx->buf_sz_allocated += allocated_sz; |
| 276 | |
| 277 | nss_n2h_bufcp[core_num].response = NSS_SUCCESS; |
| 278 | |
| 279 | done: |
| 280 | complete(&nss_n2h_bufcp[core_num].complete); |
| 281 | } |
| 282 | |
| 283 | /* |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 284 | * nss_n2h_payload_stats_callback() |
| 285 | * It gets called response to payload accounting. |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 286 | */ |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 287 | static void nss_n2h_payload_stats_callback(void *app_data, |
| 288 | struct nss_n2h_msg *nnm) |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 289 | { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 290 | uint32_t core_num = (uint32_t)(nss_ptr_t)app_data; |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 291 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 292 | if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 293 | struct nss_n2h_empty_pool_buf *nnepbcm; |
| 294 | nnepbcm = &nnm->msg.empty_pool_buf_cfg; |
| 295 | |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 296 | nss_warning("%d: core empty pool buf set failure: %d\n", |
| 297 | core_num, nnm->cm.error); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 298 | nss_n2h_nepbcfgp[core_num].response = NSS_FAILURE; |
| 299 | complete(&nss_n2h_nepbcfgp[core_num].complete); |
| 300 | return; |
| 301 | } |
| 302 | |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 303 | if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_PAYLOAD_INFO) { |
| 304 | nss_n2h_nepbcfgp[core_num].empty_buf_pool = |
| 305 | ntohl(nnm->msg.payload_info.pool_size); |
| 306 | nss_n2h_nepbcfgp[core_num].low_water = |
| 307 | ntohl(nnm->msg.payload_info.low_water); |
| 308 | nss_n2h_nepbcfgp[core_num].high_water = |
| 309 | ntohl(nnm->msg.payload_info.high_water); |
| 310 | } |
| 311 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 312 | nss_n2h_nepbcfgp[core_num].response = NSS_SUCCESS; |
| 313 | complete(&nss_n2h_nepbcfgp[core_num].complete); |
| 314 | } |
| 315 | |
| 316 | /* |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 317 | * nss_n2h_set_wifi_payloads_callback() |
| 318 | * call back function for response to wifi pool configuration |
| 319 | * |
| 320 | */ |
| 321 | static void nss_n2h_set_wifi_payloads_callback(void *app_data, |
| 322 | struct nss_n2h_msg *nnm) |
| 323 | { |
Arunkumar T | ba9b4a0 | 2016-11-07 11:41:14 +0530 | [diff] [blame] | 324 | struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data; |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 325 | if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { |
| 326 | |
| 327 | nss_n2h_wp.response = NSS_FAILURE; |
| 328 | complete(&nss_n2h_wp.complete); |
| 329 | nss_warning("%p: wifi pool configuration failed : %d\n", nss_ctx, |
| 330 | nnm->cm.error); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | nss_info("%p: wifi payload configuration succeeded: %d\n", nss_ctx, |
| 335 | nnm->cm.error); |
| 336 | nss_n2h_wp.response = NSS_SUCCESS; |
| 337 | complete(&nss_n2h_wp.complete); |
| 338 | } |
| 339 | |
| 340 | /* |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 341 | * nss_n2h_get_payload_info() |
| 342 | * Gets Payload information |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 343 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 344 | static int nss_n2h_get_payload_info(struct ctl_table *ctl, int write, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 345 | void __user *buffer, size_t *lenp, loff_t *ppos, |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 346 | nss_ptr_t core_num) |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 347 | { |
| 348 | struct nss_top_instance *nss_top = &nss_top_main; |
| 349 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; |
| 350 | struct nss_n2h_msg nnm; |
| 351 | struct nss_n2h_payload_info *nnepbcm; |
| 352 | nss_tx_status_t nss_tx_status; |
| 353 | int ret = NSS_FAILURE; |
| 354 | |
| 355 | /* |
| 356 | * Note that semaphore should be already held. |
| 357 | */ |
| 358 | |
| 359 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 360 | NSS_TX_METADATA_TYPE_GET_PAYLOAD_INFO, |
| 361 | sizeof(struct nss_n2h_payload_info), |
| 362 | nss_n2h_payload_stats_callback, |
| 363 | (void *)core_num); |
| 364 | |
| 365 | nnepbcm = &nnm.msg.payload_info; |
| 366 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 367 | |
| 368 | if (nss_tx_status != NSS_TX_SUCCESS) { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 369 | nss_warning("%p: core %d nss_tx error errorn", nss_ctx, (int)core_num); |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 370 | return NSS_FAILURE; |
| 371 | } |
| 372 | |
| 373 | /* |
| 374 | * Blocking call, wait till we get ACK for this msg. |
| 375 | */ |
| 376 | ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, |
| 377 | msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 378 | if (ret == 0) { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 379 | nss_warning("%p: core %d waiting for ack timed out\n", nss_ctx, (int)core_num); |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 380 | return NSS_FAILURE; |
| 381 | } |
| 382 | |
| 383 | if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 384 | nss_warning("%p: core %d response returned failure\n", nss_ctx, (int)core_num); |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 385 | return NSS_FAILURE; |
| 386 | } |
| 387 | |
| 388 | return NSS_SUCCESS; |
| 389 | } |
| 390 | |
| 391 | /* |
| 392 | * nss_n2h_set_empty_pool_buf() |
| 393 | * Sets empty pool buffer |
| 394 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 395 | static int nss_n2h_set_empty_pool_buf(struct ctl_table *ctl, int write, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 396 | void __user *buffer, |
| 397 | size_t *lenp, loff_t *ppos, |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 398 | nss_ptr_t core_num, int *new_val) |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 399 | { |
| 400 | struct nss_top_instance *nss_top = &nss_top_main; |
| 401 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; |
| 402 | struct nss_n2h_msg nnm; |
| 403 | struct nss_n2h_empty_pool_buf *nnepbcm; |
| 404 | nss_tx_status_t nss_tx_status; |
| 405 | int ret = NSS_FAILURE; |
| 406 | |
| 407 | /* |
| 408 | * Acquiring semaphore |
| 409 | */ |
| 410 | down(&nss_n2h_nepbcfgp[core_num].sem); |
| 411 | |
| 412 | /* |
| 413 | * Take snap shot of current value |
| 414 | */ |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 415 | nss_n2h_nepbcfgp[core_num].empty_buf_pool = *new_val; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 416 | |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 417 | if (!write) { |
| 418 | ret = nss_n2h_get_payload_info(ctl, write, buffer, lenp, ppos, |
| 419 | core_num); |
| 420 | *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool; |
| 421 | if (ret == NSS_FAILURE) { |
| 422 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 423 | return -EBUSY; |
| 424 | } |
| 425 | |
| 426 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 427 | |
| 428 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 429 | return ret; |
| 430 | } |
| 431 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 432 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 433 | if (ret) { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 434 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 435 | return ret; |
| 436 | } |
| 437 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 438 | if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 439 | nss_warning("%p: core %d setting %d < min number of buffer", |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 440 | nss_ctx, (int)core_num, *new_val); |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 441 | goto failure; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | nss_info("%p: core %d number of empty pool buffer is : %d\n", |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 445 | nss_ctx, (int)core_num, *new_val); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 446 | |
| 447 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 448 | NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG, |
| 449 | sizeof(struct nss_n2h_empty_pool_buf), |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 450 | nss_n2h_payload_stats_callback, |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 451 | (nss_ptr_t *)core_num); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 452 | |
| 453 | nnepbcm = &nnm.msg.empty_pool_buf_cfg; |
| 454 | nnepbcm->pool_size = htonl(*new_val); |
| 455 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 456 | |
| 457 | if (nss_tx_status != NSS_TX_SUCCESS) { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 458 | nss_warning("%p: core %d nss_tx error empty pool buffer: %d\n", |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 459 | nss_ctx, (int)core_num, *new_val); |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 460 | goto failure; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | /* |
| 464 | * Blocking call, wait till we get ACK for this msg. |
| 465 | */ |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 466 | ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, |
| 467 | msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 468 | if (ret == 0) { |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 469 | nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 470 | goto failure; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | /* |
| 474 | * ACK/NACK received from NSS FW |
| 475 | * If ACK: Callback function will update nss_n2h_empty_pool_buf with |
| 476 | * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input |
| 477 | */ |
| 478 | if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) { |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 479 | goto failure; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | up(&nss_n2h_nepbcfgp[core_num].sem); |
Thomas Wu | 651b390 | 2015-05-12 11:21:09 -0700 | [diff] [blame] | 483 | return 0; |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 484 | |
| 485 | failure: |
| 486 | /* |
| 487 | * Restore the current_value to its previous state |
| 488 | */ |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 489 | *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool; |
| 490 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 491 | return NSS_FAILURE; |
| 492 | } |
| 493 | |
| 494 | /* |
| 495 | * nss_n2h_set_water_mark() |
| 496 | * Sets water mark for N2H SOS |
| 497 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 498 | static int nss_n2h_set_water_mark(struct ctl_table *ctl, int write, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 499 | void __user *buffer, |
| 500 | size_t *lenp, loff_t *ppos, |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 501 | uint32_t core_num, int *low, int *high) |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 502 | { |
| 503 | struct nss_top_instance *nss_top = &nss_top_main; |
| 504 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; |
| 505 | struct nss_n2h_msg nnm; |
| 506 | struct nss_n2h_water_mark *wm; |
| 507 | nss_tx_status_t nss_tx_status; |
| 508 | int ret = NSS_FAILURE; |
| 509 | |
| 510 | /* |
| 511 | * Acquiring semaphore |
| 512 | */ |
| 513 | down(&nss_n2h_nepbcfgp[core_num].sem); |
| 514 | |
| 515 | /* |
| 516 | * Take snap shot of current value |
| 517 | */ |
| 518 | nss_n2h_nepbcfgp[core_num].low_water = *low; |
| 519 | nss_n2h_nepbcfgp[core_num].high_water = *high; |
| 520 | |
| 521 | if (!write) { |
| 522 | ret = nss_n2h_get_payload_info(ctl, write, buffer, lenp, ppos, |
| 523 | core_num); |
| 524 | *low = nss_n2h_nepbcfgp[core_num].low_water; |
| 525 | *high = nss_n2h_nepbcfgp[core_num].high_water; |
| 526 | |
| 527 | if (ret == NSS_FAILURE) { |
| 528 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 529 | return -EBUSY; |
| 530 | } |
| 531 | |
| 532 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 533 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 534 | return ret; |
| 535 | } |
| 536 | |
| 537 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 538 | if (ret) { |
| 539 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 540 | return ret; |
| 541 | } |
| 542 | |
| 543 | /* |
| 544 | * If either low or high water mark is not set then we do |
| 545 | * nothing. |
| 546 | */ |
| 547 | if (*low == -1 || *high == -1) |
| 548 | goto failure; |
| 549 | |
| 550 | if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) || |
| 551 | (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { |
| 552 | nss_warning("%p: core %d setting %d, %d < min number of buffer", |
| 553 | nss_ctx, core_num, *low, *high); |
| 554 | goto failure; |
| 555 | } |
| 556 | |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 557 | if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) || |
| 558 | (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 559 | nss_warning("%p: core %d setting %d, %d is > upper limit", |
| 560 | nss_ctx, core_num, *low, *high); |
| 561 | goto failure; |
| 562 | } |
| 563 | |
| 564 | if (*low > *high) { |
| 565 | nss_warning("%p: core %d setting low %d is more than high %d", |
| 566 | nss_ctx, core_num, *low, *high); |
| 567 | goto failure; |
| 568 | } |
| 569 | |
| 570 | nss_info("%p: core %d number of low : %d and high : %d\n", |
| 571 | nss_ctx, core_num, *low, *high); |
| 572 | |
| 573 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 574 | NSS_TX_METADATA_TYPE_SET_WATER_MARK, |
| 575 | sizeof(struct nss_n2h_water_mark), |
| 576 | nss_n2h_payload_stats_callback, |
Stephen Wang | aed4633 | 2016-12-12 17:29:03 -0800 | [diff] [blame] | 577 | (void *)(nss_ptr_t)core_num); |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 578 | |
| 579 | wm = &nnm.msg.wm; |
| 580 | wm->low_water = htonl(*low); |
| 581 | wm->high_water = htonl(*high); |
| 582 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 583 | |
| 584 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 585 | nss_warning("%p: core %d nss_tx error setting : %d, %d\n", |
| 586 | nss_ctx, core_num, *low, *high); |
| 587 | goto failure; |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | * Blocking call, wait till we get ACK for this msg. |
| 592 | */ |
| 593 | ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, |
| 594 | msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 595 | if (ret == 0) { |
| 596 | nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, |
| 597 | core_num); |
| 598 | goto failure; |
| 599 | } |
| 600 | |
| 601 | /* |
| 602 | * ACK/NACK received from NSS FW |
| 603 | */ |
| 604 | if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) |
| 605 | goto failure; |
| 606 | |
| 607 | up(&nss_n2h_nepbcfgp[core_num].sem); |
| 608 | return NSS_SUCCESS; |
| 609 | |
| 610 | failure: |
| 611 | /* |
| 612 | * Restore the current_value to its previous state |
| 613 | */ |
| 614 | *low = nss_n2h_nepbcfgp[core_num].low_water; |
| 615 | *high = nss_n2h_nepbcfgp[core_num].high_water; |
Stephen Wang | 0676102 | 2015-03-03 16:38:42 -0800 | [diff] [blame] | 616 | up(&nss_n2h_nepbcfgp[core_num].sem); |
Thomas Wu | 651b390 | 2015-05-12 11:21:09 -0700 | [diff] [blame] | 617 | return -EINVAL; |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | /* |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 621 | * nss_n2h_cfg_wifi_pool() |
| 622 | * Sets number of wifi payloads to adjust high water mark for N2H SoS |
| 623 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 624 | static int nss_n2h_cfg_wifi_pool(struct ctl_table *ctl, int write, |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 625 | void __user *buffer, |
| 626 | size_t *lenp, loff_t *ppos, |
| 627 | int *payloads) |
| 628 | { |
| 629 | struct nss_top_instance *nss_top = &nss_top_main; |
| 630 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 631 | struct nss_n2h_msg nnm; |
| 632 | struct nss_n2h_wifi_payloads *wp; |
| 633 | nss_tx_status_t nss_tx_status; |
| 634 | int ret = NSS_FAILURE; |
| 635 | |
| 636 | /* |
| 637 | * Acquiring semaphore |
| 638 | */ |
| 639 | down(&nss_n2h_wp.sem); |
| 640 | |
| 641 | if (!write) { |
| 642 | *payloads = nss_n2h_wp.wifi_pool; |
| 643 | |
| 644 | up(&nss_n2h_wp.sem); |
| 645 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 646 | return ret; |
| 647 | } |
| 648 | |
| 649 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 650 | if (ret) { |
| 651 | up(&nss_n2h_wp.sem); |
| 652 | return ret; |
| 653 | } |
| 654 | |
| 655 | /* |
| 656 | * If payloads parameter is not set, we do |
| 657 | * nothing. |
| 658 | */ |
| 659 | if (*payloads == -1) |
| 660 | goto failure; |
| 661 | |
| 662 | if ((*payloads < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { |
| 663 | nss_warning("%p: wifi setting %d < min number of buffer", |
| 664 | nss_ctx, *payloads); |
| 665 | goto failure; |
| 666 | } |
| 667 | |
| 668 | if ((*payloads > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) { |
| 669 | nss_warning("%p: wifi setting %d > max number of buffer", |
| 670 | nss_ctx, *payloads); |
| 671 | goto failure; |
| 672 | } |
| 673 | |
| 674 | nss_info("%p: wifi payloads : %d\n", |
| 675 | nss_ctx, *payloads); |
| 676 | |
| 677 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 678 | NSS_TX_METADATA_TYPE_N2H_WIFI_POOL_BUF_CFG, |
| 679 | sizeof(struct nss_n2h_wifi_payloads), |
| 680 | nss_n2h_set_wifi_payloads_callback, |
| 681 | (void *)nss_ctx); |
| 682 | |
| 683 | wp = &nnm.msg.wp; |
| 684 | wp->payloads = htonl(*payloads); |
| 685 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 686 | |
| 687 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 688 | nss_warning("%p: wifi setting %d nss_tx error", |
| 689 | nss_ctx, *payloads); |
| 690 | goto failure; |
| 691 | } |
| 692 | |
| 693 | /* |
| 694 | * Blocking call, wait till we get ACK for this msg. |
| 695 | */ |
| 696 | ret = wait_for_completion_timeout(&nss_n2h_wp.complete, |
| 697 | msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 698 | if (ret == 0) { |
| 699 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 700 | goto failure; |
| 701 | } |
| 702 | |
| 703 | /* |
| 704 | * ACK/NACK received from NSS FW |
| 705 | */ |
| 706 | if (NSS_FAILURE == nss_n2h_wp.response) |
| 707 | goto failure; |
| 708 | |
| 709 | up(&nss_n2h_wp.sem); |
| 710 | return NSS_SUCCESS; |
| 711 | |
| 712 | failure: |
| 713 | up(&nss_n2h_wp.sem); |
| 714 | return -EINVAL; |
| 715 | } |
| 716 | |
| 717 | /* |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 718 | * nss_n2h_empty_pool_buf_core1_handler() |
| 719 | * Sets the number of empty buffer for core 1 |
| 720 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 721 | static int nss_n2h_empty_pool_buf_cfg_core1_handler(struct ctl_table *ctl, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 722 | int write, void __user *buffer, |
| 723 | size_t *lenp, loff_t *ppos) |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 724 | { |
| 725 | return nss_n2h_set_empty_pool_buf(ctl, write, buffer, lenp, ppos, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 726 | NSS_CORE_1, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | /* |
| 730 | * nss_n2h_empty_pool_buf_core0_handler() |
| 731 | * Sets the number of empty buffer for core 0 |
| 732 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 733 | static int nss_n2h_empty_pool_buf_cfg_core0_handler(struct ctl_table *ctl, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 734 | int write, void __user *buffer, |
| 735 | size_t *lenp, loff_t *ppos) |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 736 | { |
| 737 | return nss_n2h_set_empty_pool_buf(ctl, write, buffer, lenp, ppos, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 738 | NSS_CORE_0, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]); |
| 739 | } |
| 740 | |
| 741 | /* |
| 742 | * nss_n2h_water_mark_core1_handler() |
| 743 | * Sets water mark for core 1 |
| 744 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 745 | static int nss_n2h_water_mark_core1_handler(struct ctl_table *ctl, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 746 | int write, void __user *buffer, |
| 747 | size_t *lenp, loff_t *ppos) |
| 748 | { |
| 749 | return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos, |
| 750 | NSS_CORE_1, &nss_n2h_water_mark[NSS_CORE_1][0], |
| 751 | &nss_n2h_water_mark[NSS_CORE_1][1]); |
| 752 | } |
| 753 | |
| 754 | /* |
| 755 | * nss_n2h_water_mark_core0_handler() |
| 756 | * Sets water mark for core 0 |
| 757 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 758 | static int nss_n2h_water_mark_core0_handler(struct ctl_table *ctl, |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 759 | int write, void __user *buffer, |
| 760 | size_t *lenp, loff_t *ppos) |
| 761 | { |
| 762 | return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos, |
| 763 | NSS_CORE_0, &nss_n2h_water_mark[NSS_CORE_0][0], |
| 764 | &nss_n2h_water_mark[NSS_CORE_0][1]); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 765 | } |
| 766 | |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 767 | /* |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 768 | * nss_n2h_wifi_payloads_handler() |
| 769 | * Sets number of wifi payloads |
| 770 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 771 | static int nss_n2h_wifi_payloads_handler(struct ctl_table *ctl, |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 772 | int write, void __user *buffer, |
| 773 | size_t *lenp, loff_t *ppos) |
| 774 | { |
| 775 | return nss_n2h_cfg_wifi_pool(ctl, write, buffer, lenp, ppos, |
| 776 | &nss_n2h_wifi_pool_buf_cfg); |
| 777 | } |
| 778 | |
| 779 | /* |
ratheesh kannoth | 024a6e8 | 2017-05-18 17:48:10 +0530 | [diff] [blame] | 780 | * nss_n2h_update_queue_config() |
| 781 | * Updates pnode queue configuration and limits |
| 782 | */ |
| 783 | nss_tx_status_t nss_n2h_update_queue_config(int max_pri, bool mq_en, int num_pri, int *qlimits) |
| 784 | { |
| 785 | struct nss_n2h_msg nnm; |
| 786 | struct nss_n2h_pnode_queue_config *cfg; |
| 787 | nss_tx_status_t status; |
| 788 | struct nss_top_instance *nss_top = &nss_top_main; |
| 789 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 790 | int i; |
| 791 | |
| 792 | if (!mq_en) { |
| 793 | return NSS_TX_SUCCESS; |
| 794 | } |
| 795 | |
| 796 | if (num_pri <= 0) { |
| 797 | nss_warning("%p: nss_tx error in pnode queue config param", nss_ctx); |
| 798 | return NSS_TX_FAILURE_BAD_PARAM; |
| 799 | } |
| 800 | |
| 801 | if (max_pri < num_pri) { |
| 802 | nss_warning("%p: nss_tx error in pnode queue config param, maximum supported priority is %d", nss_ctx, max_pri); |
| 803 | return NSS_TX_FAILURE_BAD_PARAM; |
| 804 | } |
| 805 | |
| 806 | cfg = &nnm.msg.pn_q_cfg; |
| 807 | cfg->num_pri = num_pri; |
| 808 | for (i = 0; i < num_pri; i++) { |
| 809 | cfg->qlimits[i] = qlimits[i]; |
| 810 | } |
| 811 | cfg->mq_en = true; |
| 812 | |
| 813 | /* |
| 814 | * Create message for FW |
| 815 | */ |
| 816 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 817 | NSS_TX_METADATA_TYPE_N2H_SET_PNODE_QUEUE_CFG, |
| 818 | sizeof(struct nss_n2h_pnode_queue_config), NULL, 0); |
| 819 | |
| 820 | status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 821 | if (status != NSS_TX_SUCCESS) { |
| 822 | nss_warning("%p: nss_tx error to send pnode queue config\n", nss_ctx); |
| 823 | return status; |
| 824 | } |
| 825 | |
| 826 | return NSS_TX_SUCCESS; |
| 827 | |
| 828 | } |
| 829 | EXPORT_SYMBOL(nss_n2h_update_queue_config); |
| 830 | |
| 831 | /* |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 832 | * nss_n2h_rps_cfg() |
| 833 | * Send Message to NSS to enable RPS. |
| 834 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 835 | static nss_tx_status_t nss_n2h_rps_cfg(struct nss_ctx_instance *nss_ctx, int enable_rps) |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 836 | { |
| 837 | struct nss_n2h_msg nnm; |
| 838 | struct nss_n2h_rps *rps_cfg; |
| 839 | nss_tx_status_t nss_tx_status; |
| 840 | int ret; |
| 841 | |
| 842 | down(&nss_n2h_rcp.sem); |
| 843 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_RPS_CFG, |
| 844 | sizeof(struct nss_n2h_rps), |
| 845 | nss_n2h_rps_cfg_callback, |
| 846 | (void *)nss_ctx); |
| 847 | |
| 848 | rps_cfg = &nnm.msg.rps_cfg; |
| 849 | rps_cfg->enable = enable_rps; |
| 850 | |
| 851 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 852 | |
| 853 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 854 | nss_warning("%p: nss_tx error setting rps\n", nss_ctx); |
| 855 | |
| 856 | up(&nss_n2h_rcp.sem); |
| 857 | return NSS_FAILURE; |
| 858 | } |
| 859 | |
| 860 | /* |
| 861 | * Blocking call, wait till we get ACK for this msg. |
| 862 | */ |
| 863 | ret = wait_for_completion_timeout(&nss_n2h_rcp.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 864 | if (ret == 0) { |
| 865 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 866 | up(&nss_n2h_rcp.sem); |
| 867 | return NSS_FAILURE; |
| 868 | } |
| 869 | |
| 870 | /* |
| 871 | * ACK/NACK received from NSS FW |
| 872 | * If ACK: Callback function will update nss_n2h_empty_pool_buf with |
| 873 | * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input |
| 874 | */ |
| 875 | if (NSS_FAILURE == nss_n2h_rcp.response) { |
| 876 | up(&nss_n2h_rcp.sem); |
| 877 | return NSS_FAILURE; |
| 878 | } |
| 879 | |
| 880 | up(&nss_n2h_rcp.sem); |
| 881 | return NSS_SUCCESS; |
| 882 | } |
| 883 | |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 884 | /* |
| 885 | * nss_n2h_mitigation_cfg() |
| 886 | * Send Message to NSS to disable MITIGATION. |
| 887 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 888 | static nss_tx_status_t nss_n2h_mitigation_cfg(struct nss_ctx_instance *nss_ctx, int enable_mitigation, nss_core_id_t core_num) |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 889 | { |
| 890 | struct nss_n2h_msg nnm; |
| 891 | struct nss_n2h_mitigation *mitigation_cfg; |
| 892 | nss_tx_status_t nss_tx_status; |
| 893 | int ret; |
| 894 | |
| 895 | nss_assert(core_num < NSS_CORE_MAX); |
| 896 | |
| 897 | down(&nss_n2h_mitigationcp[core_num].sem); |
| 898 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG, |
| 899 | sizeof(struct nss_n2h_mitigation), |
| 900 | nss_n2h_mitigation_cfg_callback, |
| 901 | (void *)core_num); |
| 902 | |
| 903 | mitigation_cfg = &nnm.msg.mitigation_cfg; |
| 904 | mitigation_cfg->enable = enable_mitigation; |
| 905 | |
| 906 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 907 | |
| 908 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 909 | nss_warning("%p: nss_tx error setting mitigation\n", nss_ctx); |
| 910 | goto failure; |
| 911 | } |
| 912 | |
| 913 | /* |
| 914 | * Blocking call, wait till we get ACK for this msg. |
| 915 | */ |
| 916 | ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 917 | if (ret == 0) { |
| 918 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 919 | goto failure; |
| 920 | } |
| 921 | |
| 922 | /* |
| 923 | * ACK/NACK received from NSS FW |
| 924 | */ |
| 925 | if (NSS_FAILURE == nss_n2h_mitigationcp[core_num].response) { |
| 926 | goto failure; |
| 927 | } |
| 928 | |
| 929 | up(&nss_n2h_mitigationcp[core_num].sem); |
| 930 | return NSS_SUCCESS; |
| 931 | |
| 932 | failure: |
| 933 | up(&nss_n2h_mitigationcp[core_num].sem); |
| 934 | return NSS_FAILURE; |
| 935 | } |
| 936 | |
| 937 | static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool) |
| 938 | { |
| 939 | int page_count; |
| 940 | for (page_count = 0; page_count < buf_pool->nss_buf_num_pages; page_count++) { |
| 941 | kfree(buf_pool->nss_buf_pool_vaddr[page_count]); |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | /* |
| 946 | * nss_n2h_buf_cfg() |
| 947 | * Send Message to NSS to enable pbufs. |
| 948 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 949 | static nss_tx_status_t nss_n2h_buf_pool_cfg(struct nss_ctx_instance *nss_ctx, |
Tallapragada | 4b0161b | 2016-07-07 21:38:34 +0530 | [diff] [blame] | 950 | int buf_pool_size, nss_core_id_t core_num) |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 951 | { |
| 952 | static struct nss_n2h_msg nnm; |
| 953 | struct nss_n2h_buf_pool *buf_pool; |
| 954 | nss_tx_status_t nss_tx_status; |
| 955 | int ret; |
| 956 | int page_count; |
| 957 | int num_pages = ALIGN(buf_pool_size, PAGE_SIZE)/PAGE_SIZE; |
| 958 | |
| 959 | nss_assert(core_num < NSS_CORE_MAX); |
| 960 | |
| 961 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_METADATA_TYPE_N2H_ADD_BUF_POOL, |
| 962 | sizeof(struct nss_n2h_buf_pool), |
| 963 | nss_n2h_bufs_cfg_callback, |
| 964 | (void *)core_num); |
| 965 | |
| 966 | do { |
| 967 | |
| 968 | down(&nss_n2h_bufcp[core_num].sem); |
| 969 | |
| 970 | buf_pool = &nnm.msg.buf_pool; |
| 971 | buf_pool->nss_buf_page_size = PAGE_SIZE; |
| 972 | |
| 973 | for (page_count = 0; page_count < MAX_PAGES_PER_MSG && num_pages; page_count++, num_pages--) { |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 974 | void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC); |
| 975 | if (!kern_addr) { |
| 976 | BUG_ON(!page_count); |
| 977 | break; |
| 978 | } |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 979 | |
Radha krishna Simha Jiguru | 60068fb | 2017-07-28 17:40:52 +0530 | [diff] [blame^] | 980 | kmemleak_not_leak(kern_addr); |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 981 | buf_pool->nss_buf_pool_vaddr[page_count] = kern_addr; |
Stephen Wang | efd3851 | 2017-01-24 14:01:02 -0800 | [diff] [blame] | 982 | buf_pool->nss_buf_pool_addr[page_count] = dma_map_single(nss_ctx->dev, kern_addr, PAGE_SIZE, DMA_TO_DEVICE); |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | buf_pool->nss_buf_num_pages = page_count; |
| 986 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 987 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 988 | |
| 989 | nss_n2h_buf_pool_free(buf_pool); |
| 990 | nss_warning("%p: nss_tx error setting pbuf\n", nss_ctx); |
| 991 | goto failure; |
| 992 | } |
| 993 | |
| 994 | /* |
| 995 | * Blocking call, wait till we get ACK for this msg. |
| 996 | */ |
| 997 | ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 998 | if (ret == 0) { |
| 999 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 1000 | goto failure; |
| 1001 | } |
| 1002 | |
| 1003 | /* |
| 1004 | * ACK/NACK received from NSS FW |
| 1005 | */ |
| 1006 | if (NSS_FAILURE == nss_n2h_bufcp[core_num].response) { |
| 1007 | |
| 1008 | nss_n2h_buf_pool_free(buf_pool); |
| 1009 | goto failure; |
| 1010 | } |
| 1011 | |
| 1012 | up(&nss_n2h_bufcp[core_num].sem); |
| 1013 | } while(num_pages); |
| 1014 | |
| 1015 | return NSS_SUCCESS; |
| 1016 | failure: |
| 1017 | up(&nss_n2h_bufcp[core_num].sem); |
| 1018 | return NSS_FAILURE; |
| 1019 | } |
| 1020 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1021 | /* |
| 1022 | * nss_rps_handler() |
| 1023 | * Enable NSS RPS |
| 1024 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1025 | static int nss_n2h_rpscfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1026 | { |
| 1027 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1028 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 1029 | int ret; |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 1030 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1031 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1032 | if (!ret) { |
| 1033 | if ((write) && (nss_n2h_rps_config == 1)) { |
| 1034 | printk(KERN_INFO "Enabling NSS RPS\n"); |
| 1035 | |
| 1036 | return nss_n2h_rps_cfg(nss_ctx, 1); |
| 1037 | } |
| 1038 | |
| 1039 | if ((write) && (nss_n2h_rps_config == 0)) { |
| 1040 | printk(KERN_INFO "Runtime disabling of NSS RPS not supported\n"); |
| 1041 | return ret; |
| 1042 | } |
| 1043 | |
| 1044 | if (write) { |
| 1045 | printk(KERN_INFO "Invalid input value.Valid values are 0 and 1\n"); |
| 1046 | } |
| 1047 | |
| 1048 | } |
| 1049 | |
| 1050 | return ret; |
| 1051 | } |
| 1052 | |
| 1053 | /* |
| 1054 | * nss_mitigation_handler() |
| 1055 | * Enable NSS MITIGATION |
| 1056 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1057 | static int nss_n2h_mitigationcfg_core0_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1058 | { |
| 1059 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1060 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0]; |
| 1061 | int ret; |
| 1062 | |
| 1063 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1064 | if (ret) { |
| 1065 | return ret; |
| 1066 | } |
| 1067 | |
| 1068 | /* |
| 1069 | * It's a read operation |
| 1070 | */ |
| 1071 | if (!write) { |
| 1072 | return ret; |
| 1073 | } |
| 1074 | |
| 1075 | if (!nss_n2h_core0_mitigation_cfg) { |
| 1076 | printk(KERN_INFO "Disabling NSS MITIGATION\n"); |
| 1077 | nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_0); |
| 1078 | return 0; |
| 1079 | } |
| 1080 | printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n"); |
| 1081 | return -EINVAL; |
| 1082 | } |
| 1083 | |
| 1084 | /* |
| 1085 | * nss_mitigation_handler() |
| 1086 | * Enable NSS MITIGATION |
| 1087 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1088 | static int nss_n2h_mitigationcfg_core1_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1089 | { |
| 1090 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1091 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1]; |
| 1092 | int ret; |
| 1093 | |
| 1094 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1095 | if (ret) { |
| 1096 | return ret; |
| 1097 | } |
| 1098 | |
| 1099 | /* |
| 1100 | * It's a read operation |
| 1101 | */ |
| 1102 | if (!write) { |
| 1103 | return ret; |
| 1104 | } |
| 1105 | |
| 1106 | if (!nss_n2h_core1_mitigation_cfg) { |
| 1107 | printk(KERN_INFO "Disabling NSS MITIGATION\n"); |
| 1108 | nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_1); |
| 1109 | return 0; |
| 1110 | } |
| 1111 | printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n"); |
| 1112 | return -EINVAL; |
| 1113 | } |
| 1114 | |
| 1115 | /* |
| 1116 | * nss_buf_handler() |
| 1117 | * Add extra NSS bufs from host memory |
| 1118 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1119 | static int nss_n2h_buf_cfg_core0_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1120 | { |
| 1121 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1122 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0]; |
| 1123 | int ret; |
| 1124 | |
| 1125 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1126 | if (ret) { |
| 1127 | return ret; |
| 1128 | } |
| 1129 | |
| 1130 | /* |
| 1131 | * It's a read operation |
| 1132 | */ |
| 1133 | if (!write) { |
| 1134 | return ret; |
| 1135 | } |
| 1136 | |
| 1137 | if (nss_ctx->buf_sz_allocated) { |
| 1138 | nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1139 | return -EPERM; |
| 1140 | } |
| 1141 | |
| 1142 | if ((nss_n2h_core0_add_buf_pool_size >= 1) && (nss_n2h_core0_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) { |
| 1143 | printk(KERN_INFO "configuring additional NSS pbufs\n"); |
| 1144 | ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core0_add_buf_pool_size, NSS_CORE_0); |
| 1145 | nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1146 | printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated); |
| 1147 | return ret; |
| 1148 | } |
| 1149 | |
| 1150 | printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE); |
| 1151 | return -EINVAL; |
| 1152 | } |
| 1153 | |
| 1154 | /* |
| 1155 | * nss_n2h_buf_handler() |
| 1156 | * Add extra NSS bufs from host memory |
| 1157 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1158 | static int nss_n2h_buf_cfg_core1_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1159 | { |
| 1160 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1161 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1]; |
| 1162 | int ret; |
| 1163 | |
| 1164 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1165 | if (ret) { |
| 1166 | return ret; |
| 1167 | } |
| 1168 | |
| 1169 | /* |
| 1170 | * It's a read operation |
| 1171 | */ |
| 1172 | if (!write) { |
| 1173 | return ret; |
| 1174 | } |
| 1175 | |
| 1176 | if (nss_ctx->buf_sz_allocated) { |
| 1177 | nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1178 | return -EPERM; |
| 1179 | } |
| 1180 | |
| 1181 | if ((nss_n2h_core1_add_buf_pool_size >= 1) && (nss_n2h_core1_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) { |
| 1182 | printk(KERN_INFO "configuring additional NSS pbufs\n"); |
| 1183 | ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core1_add_buf_pool_size, NSS_CORE_1); |
| 1184 | nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1185 | printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated); |
| 1186 | return ret; |
| 1187 | } |
| 1188 | |
| 1189 | printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE); |
| 1190 | return -EINVAL; |
| 1191 | } |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 1192 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1193 | static struct ctl_table nss_n2h_table[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1194 | { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 1195 | .procname = "n2h_empty_pool_buf_core0", |
| 1196 | .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0], |
| 1197 | .maxlen = sizeof(int), |
| 1198 | .mode = 0644, |
| 1199 | .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler, |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1200 | }, |
| 1201 | { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 1202 | .procname = "n2h_empty_pool_buf_core1", |
| 1203 | .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1], |
| 1204 | .maxlen = sizeof(int), |
| 1205 | .mode = 0644, |
| 1206 | .proc_handler = &nss_n2h_empty_pool_buf_cfg_core1_handler, |
| 1207 | }, |
| 1208 | { |
| 1209 | .procname = "n2h_low_water_core0", |
| 1210 | .data = &nss_n2h_water_mark[NSS_CORE_0][0], |
| 1211 | .maxlen = sizeof(int), |
| 1212 | .mode = 0644, |
| 1213 | .proc_handler = &nss_n2h_water_mark_core0_handler, |
| 1214 | }, |
| 1215 | { |
| 1216 | .procname = "n2h_low_water_core1", |
| 1217 | .data = &nss_n2h_water_mark[NSS_CORE_1][0], |
| 1218 | .maxlen = sizeof(int), |
| 1219 | .mode = 0644, |
| 1220 | .proc_handler = &nss_n2h_water_mark_core1_handler, |
| 1221 | }, |
| 1222 | { |
| 1223 | .procname = "n2h_high_water_core0", |
| 1224 | .data = &nss_n2h_water_mark[NSS_CORE_0][1], |
| 1225 | .maxlen = sizeof(int), |
| 1226 | .mode = 0644, |
| 1227 | .proc_handler = &nss_n2h_water_mark_core0_handler, |
| 1228 | }, |
| 1229 | { |
| 1230 | .procname = "n2h_high_water_core1", |
| 1231 | .data = &nss_n2h_water_mark[NSS_CORE_1][1], |
| 1232 | .maxlen = sizeof(int), |
| 1233 | .mode = 0644, |
| 1234 | .proc_handler = &nss_n2h_water_mark_core1_handler, |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1235 | }, |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 1236 | { |
| 1237 | .procname = "n2h_wifi_pool_buf", |
| 1238 | .data = &nss_n2h_wifi_pool_buf_cfg, |
| 1239 | .maxlen = sizeof(int), |
| 1240 | .mode = 0644, |
| 1241 | .proc_handler = &nss_n2h_wifi_payloads_handler, |
| 1242 | }, |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1243 | { |
| 1244 | .procname = "rps", |
| 1245 | .data = &nss_n2h_rps_config, |
| 1246 | .maxlen = sizeof(int), |
| 1247 | .mode = 0644, |
| 1248 | .proc_handler = &nss_n2h_rpscfg_handler, |
| 1249 | }, |
| 1250 | { |
| 1251 | .procname = "mitigation_core0", |
| 1252 | .data = &nss_n2h_core0_mitigation_cfg, |
| 1253 | .maxlen = sizeof(int), |
| 1254 | .mode = 0644, |
| 1255 | .proc_handler = &nss_n2h_mitigationcfg_core0_handler, |
| 1256 | }, |
| 1257 | { |
| 1258 | .procname = "mitigation_core1", |
| 1259 | .data = &nss_n2h_core1_mitigation_cfg, |
| 1260 | .maxlen = sizeof(int), |
| 1261 | .mode = 0644, |
| 1262 | .proc_handler = &nss_n2h_mitigationcfg_core1_handler, |
| 1263 | }, |
| 1264 | { |
| 1265 | .procname = "extra_pbuf_core0", |
| 1266 | .data = &nss_n2h_core0_add_buf_pool_size, |
| 1267 | .maxlen = sizeof(int), |
| 1268 | .mode = 0644, |
| 1269 | .proc_handler = &nss_n2h_buf_cfg_core0_handler, |
| 1270 | }, |
| 1271 | { |
| 1272 | .procname = "extra_pbuf_core1", |
| 1273 | .data = &nss_n2h_core1_add_buf_pool_size, |
| 1274 | .maxlen = sizeof(int), |
| 1275 | .mode = 0644, |
| 1276 | .proc_handler = &nss_n2h_buf_cfg_core1_handler, |
| 1277 | }, |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1278 | |
| 1279 | { } |
| 1280 | }; |
| 1281 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1282 | static struct ctl_table nss_n2h_dir[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1283 | { |
| 1284 | .procname = "n2hcfg", |
| 1285 | .mode = 0555, |
| 1286 | .child = nss_n2h_table, |
| 1287 | }, |
| 1288 | { } |
| 1289 | }; |
| 1290 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1291 | static struct ctl_table nss_n2h_root_dir[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1292 | { |
| 1293 | .procname = "nss", |
| 1294 | .mode = 0555, |
| 1295 | .child = nss_n2h_dir, |
| 1296 | }, |
| 1297 | { } |
| 1298 | }; |
| 1299 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1300 | static struct ctl_table nss_n2h_root[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1301 | { |
| 1302 | .procname = "dev", |
| 1303 | .mode = 0555, |
| 1304 | .child = nss_n2h_root_dir, |
| 1305 | }, |
| 1306 | { } |
| 1307 | }; |
| 1308 | |
| 1309 | static struct ctl_table_header *nss_n2h_header; |
| 1310 | |
| 1311 | /* |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1312 | * nss_n2h_flush_payloads() |
| 1313 | * Sends a command down to NSS for flushing all payloads |
| 1314 | */ |
| 1315 | nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx) |
| 1316 | { |
| 1317 | struct nss_n2h_msg nnm; |
| 1318 | struct nss_n2h_flush_payloads *nnflshpl; |
| 1319 | nss_tx_status_t nss_tx_status; |
| 1320 | |
| 1321 | nnflshpl = &nnm.msg.flush_payloads; |
| 1322 | |
| 1323 | /* |
| 1324 | * TODO: No additional information sent in message |
| 1325 | * as of now. Need to initialize message content accordingly |
| 1326 | * if needed. |
| 1327 | */ |
| 1328 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 1329 | NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS, |
| 1330 | sizeof(struct nss_n2h_flush_payloads), |
| 1331 | NULL, |
| 1332 | NULL); |
| 1333 | |
| 1334 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 1335 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 1336 | nss_warning("%p: failed to send flush payloads command to NSS\n", |
| 1337 | nss_ctx); |
| 1338 | |
| 1339 | return NSS_TX_FAILURE; |
| 1340 | } |
| 1341 | |
| 1342 | return NSS_TX_SUCCESS; |
| 1343 | } |
| 1344 | |
| 1345 | /* |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1346 | * nss_n2h_msg_init() |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1347 | * Initialize n2h message. |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1348 | */ |
| 1349 | void nss_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type, |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 1350 | uint32_t len, nss_n2h_msg_callback_t cb, void *app_data) |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1351 | { |
| 1352 | nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); |
| 1353 | } |
| 1354 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1355 | /* |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1356 | * nss_n2h_tx_msg() |
| 1357 | * Send messages to NSS n2h pacakge |
| 1358 | */ |
| 1359 | nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm) |
| 1360 | { |
| 1361 | struct nss_n2h_msg *nnm2; |
| 1362 | struct nss_cmn_msg *ncm = &nnm->cm; |
| 1363 | struct sk_buff *nbuf; |
| 1364 | nss_tx_status_t status; |
| 1365 | |
| 1366 | NSS_VERIFY_CTX_MAGIC(nss_ctx); |
| 1367 | if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { |
| 1368 | return NSS_TX_FAILURE_NOT_READY; |
| 1369 | } |
| 1370 | |
| 1371 | /* |
| 1372 | * Sanity check the message |
| 1373 | */ |
| 1374 | if (ncm->interface != NSS_N2H_INTERFACE) { |
| 1375 | nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); |
| 1376 | return NSS_TX_FAILURE; |
| 1377 | } |
| 1378 | |
| 1379 | if (ncm->type >= NSS_METADATA_TYPE_N2H_MAX) { |
| 1380 | nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); |
| 1381 | return NSS_TX_FAILURE; |
| 1382 | } |
| 1383 | |
Suruchi Agarwal | ef8a870 | 2016-01-08 12:40:08 -0800 | [diff] [blame] | 1384 | if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_n2h_msg)) { |
| 1385 | nss_warning("%p: tx request for another interface: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1386 | return NSS_TX_FAILURE; |
| 1387 | } |
| 1388 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1389 | nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE); |
| 1390 | if (unlikely(!nbuf)) { |
Sundarajan Srinivasan | 62fee7e | 2015-01-22 11:13:10 -0800 | [diff] [blame] | 1391 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1392 | return NSS_TX_FAILURE; |
| 1393 | } |
| 1394 | |
| 1395 | /* |
| 1396 | * Copy the message to our skb. |
| 1397 | */ |
| 1398 | nnm2 = (struct nss_n2h_msg *)skb_put(nbuf, sizeof(struct nss_n2h_msg)); |
| 1399 | memcpy(nnm2, nnm, sizeof(struct nss_n2h_msg)); |
| 1400 | status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0); |
| 1401 | if (status != NSS_CORE_STATUS_SUCCESS) { |
| 1402 | dev_kfree_skb_any(nbuf); |
| 1403 | nss_info("%p: unable to enqueue 'nss frequency change' - marked as stopped\n", nss_ctx); |
| 1404 | return NSS_TX_FAILURE; |
| 1405 | } |
| 1406 | |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 1407 | nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1408 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]); |
| 1409 | return NSS_TX_SUCCESS; |
| 1410 | } |
| 1411 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1412 | /* |
| 1413 | * nss_n2h_notify_register() |
| 1414 | * Register to received N2H events. |
| 1415 | * |
| 1416 | * NOTE: Do we want to pass an nss_ctx here so that we can register for n2h on any core? |
| 1417 | */ |
| 1418 | struct nss_ctx_instance *nss_n2h_notify_register(int core, nss_n2h_msg_callback_t cb, void *app_data) |
| 1419 | { |
| 1420 | if (core >= NSS_MAX_CORES) { |
| 1421 | nss_warning("Input core number %d is wrong \n", core); |
| 1422 | return NULL; |
| 1423 | } |
| 1424 | /* |
| 1425 | * TODO: We need to have a new array in support of the new API |
| 1426 | * TODO: If we use a per-context array, we would move the array into nss_ctx based. |
| 1427 | */ |
| 1428 | nss_n2h_rd[core].n2h_callback = cb; |
| 1429 | nss_n2h_rd[core].app_data = app_data; |
| 1430 | return &nss_top_main.nss[core]; |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1431 | } |
| 1432 | |
| 1433 | /* |
| 1434 | * nss_n2h_register_handler() |
| 1435 | */ |
Thomas Wu | 91f4bdf | 2017-06-09 12:03:02 -0700 | [diff] [blame] | 1436 | void nss_n2h_register_handler(struct nss_ctx_instance *nss_ctx) |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1437 | { |
Thomas Wu | 91f4bdf | 2017-06-09 12:03:02 -0700 | [diff] [blame] | 1438 | nss_core_register_handler(nss_ctx, NSS_N2H_INTERFACE, nss_n2h_interface_handler, NULL); |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1439 | } |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 1440 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1441 | /* |
| 1442 | * nss_n2h_register_sysctl() |
| 1443 | */ |
| 1444 | void nss_n2h_register_sysctl(void) |
| 1445 | { |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 1446 | /* |
| 1447 | * RPS sema init |
| 1448 | */ |
| 1449 | sema_init(&nss_n2h_rcp.sem, 1); |
| 1450 | init_completion(&nss_n2h_rcp.complete); |
| 1451 | |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 1452 | /* |
| 1453 | * MITIGATION sema init for core0 |
| 1454 | */ |
| 1455 | sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1); |
| 1456 | init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete); |
| 1457 | |
| 1458 | /* |
| 1459 | * MITIGATION sema init for core1 |
| 1460 | */ |
| 1461 | sema_init(&nss_n2h_mitigationcp[NSS_CORE_1].sem, 1); |
| 1462 | init_completion(&nss_n2h_mitigationcp[NSS_CORE_1].complete); |
| 1463 | |
| 1464 | /* |
| 1465 | * PBUF addition sema init for core0 |
| 1466 | */ |
| 1467 | sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1); |
| 1468 | init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete); |
| 1469 | |
| 1470 | /* |
| 1471 | * PBUF addition sema init for core1 |
| 1472 | */ |
| 1473 | sema_init(&nss_n2h_bufcp[NSS_CORE_1].sem, 1); |
| 1474 | init_completion(&nss_n2h_bufcp[NSS_CORE_1].complete); |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 1475 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1476 | /* |
| 1477 | * Core0 |
| 1478 | */ |
| 1479 | sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1); |
| 1480 | init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete); |
| 1481 | nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool = |
| 1482 | nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]; |
| 1483 | nss_n2h_nepbcfgp[NSS_CORE_0].low_water = |
| 1484 | nss_n2h_water_mark[NSS_CORE_0][0]; |
| 1485 | nss_n2h_nepbcfgp[NSS_CORE_0].high_water = |
| 1486 | nss_n2h_water_mark[NSS_CORE_0][1]; |
| 1487 | |
| 1488 | /* |
| 1489 | * Core1 |
| 1490 | */ |
| 1491 | sema_init(&nss_n2h_nepbcfgp[NSS_CORE_1].sem, 1); |
| 1492 | init_completion(&nss_n2h_nepbcfgp[NSS_CORE_1].complete); |
| 1493 | nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool = |
| 1494 | nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]; |
| 1495 | nss_n2h_nepbcfgp[NSS_CORE_1].low_water = |
| 1496 | nss_n2h_water_mark[NSS_CORE_1][0]; |
| 1497 | nss_n2h_nepbcfgp[NSS_CORE_1].high_water = |
| 1498 | nss_n2h_water_mark[NSS_CORE_1][1]; |
| 1499 | |
| 1500 | /* |
| 1501 | * WiFi pool buf cfg sema init |
| 1502 | */ |
| 1503 | sema_init(&nss_n2h_wp.sem, 1); |
| 1504 | init_completion(&nss_n2h_wp.complete); |
| 1505 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1506 | nss_n2h_notify_register(NSS_CORE_0, NULL, NULL); |
| 1507 | nss_n2h_notify_register(NSS_CORE_1, NULL, NULL); |
| 1508 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1509 | /* |
| 1510 | * Register sysctl table. |
| 1511 | */ |
| 1512 | nss_n2h_header = register_sysctl_table(nss_n2h_root); |
| 1513 | } |
| 1514 | |
| 1515 | /* |
| 1516 | * nss_n2h_unregister_sysctl() |
| 1517 | * Unregister sysctl specific to n2h |
| 1518 | */ |
| 1519 | void nss_n2h_unregister_sysctl(void) |
| 1520 | { |
| 1521 | /* |
| 1522 | * Unregister sysctl table. |
| 1523 | */ |
| 1524 | if (nss_n2h_header) { |
| 1525 | unregister_sysctl_table(nss_n2h_header); |
| 1526 | } |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1527 | } |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1528 | |
| 1529 | EXPORT_SYMBOL(nss_n2h_notify_register); |