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 | /* |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 780 | * nss_n2h_rps_cfg() |
| 781 | * Send Message to NSS to enable RPS. |
| 782 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 783 | 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] | 784 | { |
| 785 | struct nss_n2h_msg nnm; |
| 786 | struct nss_n2h_rps *rps_cfg; |
| 787 | nss_tx_status_t nss_tx_status; |
| 788 | int ret; |
| 789 | |
| 790 | down(&nss_n2h_rcp.sem); |
| 791 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_RPS_CFG, |
| 792 | sizeof(struct nss_n2h_rps), |
| 793 | nss_n2h_rps_cfg_callback, |
| 794 | (void *)nss_ctx); |
| 795 | |
| 796 | rps_cfg = &nnm.msg.rps_cfg; |
| 797 | rps_cfg->enable = enable_rps; |
| 798 | |
| 799 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 800 | |
| 801 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 802 | nss_warning("%p: nss_tx error setting rps\n", nss_ctx); |
| 803 | |
| 804 | up(&nss_n2h_rcp.sem); |
| 805 | return NSS_FAILURE; |
| 806 | } |
| 807 | |
| 808 | /* |
| 809 | * Blocking call, wait till we get ACK for this msg. |
| 810 | */ |
| 811 | ret = wait_for_completion_timeout(&nss_n2h_rcp.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 812 | if (ret == 0) { |
| 813 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 814 | up(&nss_n2h_rcp.sem); |
| 815 | return NSS_FAILURE; |
| 816 | } |
| 817 | |
| 818 | /* |
| 819 | * ACK/NACK received from NSS FW |
| 820 | * If ACK: Callback function will update nss_n2h_empty_pool_buf with |
| 821 | * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input |
| 822 | */ |
| 823 | if (NSS_FAILURE == nss_n2h_rcp.response) { |
| 824 | up(&nss_n2h_rcp.sem); |
| 825 | return NSS_FAILURE; |
| 826 | } |
| 827 | |
| 828 | up(&nss_n2h_rcp.sem); |
| 829 | return NSS_SUCCESS; |
| 830 | } |
| 831 | |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 832 | /* |
| 833 | * nss_n2h_mitigation_cfg() |
| 834 | * Send Message to NSS to disable MITIGATION. |
| 835 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 836 | 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] | 837 | { |
| 838 | struct nss_n2h_msg nnm; |
| 839 | struct nss_n2h_mitigation *mitigation_cfg; |
| 840 | nss_tx_status_t nss_tx_status; |
| 841 | int ret; |
| 842 | |
| 843 | nss_assert(core_num < NSS_CORE_MAX); |
| 844 | |
| 845 | down(&nss_n2h_mitigationcp[core_num].sem); |
| 846 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG, |
| 847 | sizeof(struct nss_n2h_mitigation), |
| 848 | nss_n2h_mitigation_cfg_callback, |
| 849 | (void *)core_num); |
| 850 | |
| 851 | mitigation_cfg = &nnm.msg.mitigation_cfg; |
| 852 | mitigation_cfg->enable = enable_mitigation; |
| 853 | |
| 854 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 855 | |
| 856 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 857 | nss_warning("%p: nss_tx error setting mitigation\n", nss_ctx); |
| 858 | goto failure; |
| 859 | } |
| 860 | |
| 861 | /* |
| 862 | * Blocking call, wait till we get ACK for this msg. |
| 863 | */ |
| 864 | ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 865 | if (ret == 0) { |
| 866 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 867 | goto failure; |
| 868 | } |
| 869 | |
| 870 | /* |
| 871 | * ACK/NACK received from NSS FW |
| 872 | */ |
| 873 | if (NSS_FAILURE == nss_n2h_mitigationcp[core_num].response) { |
| 874 | goto failure; |
| 875 | } |
| 876 | |
| 877 | up(&nss_n2h_mitigationcp[core_num].sem); |
| 878 | return NSS_SUCCESS; |
| 879 | |
| 880 | failure: |
| 881 | up(&nss_n2h_mitigationcp[core_num].sem); |
| 882 | return NSS_FAILURE; |
| 883 | } |
| 884 | |
| 885 | static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool) |
| 886 | { |
| 887 | int page_count; |
| 888 | for (page_count = 0; page_count < buf_pool->nss_buf_num_pages; page_count++) { |
| 889 | kfree(buf_pool->nss_buf_pool_vaddr[page_count]); |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | /* |
| 894 | * nss_n2h_buf_cfg() |
| 895 | * Send Message to NSS to enable pbufs. |
| 896 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 897 | 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] | 898 | int buf_pool_size, nss_core_id_t core_num) |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 899 | { |
| 900 | static struct nss_n2h_msg nnm; |
| 901 | struct nss_n2h_buf_pool *buf_pool; |
| 902 | nss_tx_status_t nss_tx_status; |
| 903 | int ret; |
| 904 | int page_count; |
| 905 | int num_pages = ALIGN(buf_pool_size, PAGE_SIZE)/PAGE_SIZE; |
| 906 | |
| 907 | nss_assert(core_num < NSS_CORE_MAX); |
| 908 | |
| 909 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_METADATA_TYPE_N2H_ADD_BUF_POOL, |
| 910 | sizeof(struct nss_n2h_buf_pool), |
| 911 | nss_n2h_bufs_cfg_callback, |
| 912 | (void *)core_num); |
| 913 | |
| 914 | do { |
| 915 | |
| 916 | down(&nss_n2h_bufcp[core_num].sem); |
| 917 | |
| 918 | buf_pool = &nnm.msg.buf_pool; |
| 919 | buf_pool->nss_buf_page_size = PAGE_SIZE; |
| 920 | |
| 921 | 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] | 922 | void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC); |
| 923 | if (!kern_addr) { |
| 924 | BUG_ON(!page_count); |
| 925 | break; |
| 926 | } |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 927 | |
| 928 | buf_pool->nss_buf_pool_vaddr[page_count] = kern_addr; |
Stephen Wang | efd3851 | 2017-01-24 14:01:02 -0800 | [diff] [blame] | 929 | 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] | 930 | } |
| 931 | |
| 932 | buf_pool->nss_buf_num_pages = page_count; |
| 933 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 934 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 935 | |
| 936 | nss_n2h_buf_pool_free(buf_pool); |
| 937 | nss_warning("%p: nss_tx error setting pbuf\n", nss_ctx); |
| 938 | goto failure; |
| 939 | } |
| 940 | |
| 941 | /* |
| 942 | * Blocking call, wait till we get ACK for this msg. |
| 943 | */ |
| 944 | ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); |
| 945 | if (ret == 0) { |
| 946 | nss_warning("%p: Waiting for ack timed out\n", nss_ctx); |
| 947 | goto failure; |
| 948 | } |
| 949 | |
| 950 | /* |
| 951 | * ACK/NACK received from NSS FW |
| 952 | */ |
| 953 | if (NSS_FAILURE == nss_n2h_bufcp[core_num].response) { |
| 954 | |
| 955 | nss_n2h_buf_pool_free(buf_pool); |
| 956 | goto failure; |
| 957 | } |
| 958 | |
| 959 | up(&nss_n2h_bufcp[core_num].sem); |
| 960 | } while(num_pages); |
| 961 | |
| 962 | return NSS_SUCCESS; |
| 963 | failure: |
| 964 | up(&nss_n2h_bufcp[core_num].sem); |
| 965 | return NSS_FAILURE; |
| 966 | } |
| 967 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 968 | /* |
| 969 | * nss_rps_handler() |
| 970 | * Enable NSS RPS |
| 971 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 972 | 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] | 973 | { |
| 974 | struct nss_top_instance *nss_top = &nss_top_main; |
| 975 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; |
| 976 | int ret; |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 977 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 978 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 979 | if (!ret) { |
| 980 | if ((write) && (nss_n2h_rps_config == 1)) { |
| 981 | printk(KERN_INFO "Enabling NSS RPS\n"); |
| 982 | |
| 983 | return nss_n2h_rps_cfg(nss_ctx, 1); |
| 984 | } |
| 985 | |
| 986 | if ((write) && (nss_n2h_rps_config == 0)) { |
| 987 | printk(KERN_INFO "Runtime disabling of NSS RPS not supported\n"); |
| 988 | return ret; |
| 989 | } |
| 990 | |
| 991 | if (write) { |
| 992 | printk(KERN_INFO "Invalid input value.Valid values are 0 and 1\n"); |
| 993 | } |
| 994 | |
| 995 | } |
| 996 | |
| 997 | return ret; |
| 998 | } |
| 999 | |
| 1000 | /* |
| 1001 | * nss_mitigation_handler() |
| 1002 | * Enable NSS MITIGATION |
| 1003 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1004 | 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] | 1005 | { |
| 1006 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1007 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0]; |
| 1008 | int ret; |
| 1009 | |
| 1010 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1011 | if (ret) { |
| 1012 | return ret; |
| 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | * It's a read operation |
| 1017 | */ |
| 1018 | if (!write) { |
| 1019 | return ret; |
| 1020 | } |
| 1021 | |
| 1022 | if (!nss_n2h_core0_mitigation_cfg) { |
| 1023 | printk(KERN_INFO "Disabling NSS MITIGATION\n"); |
| 1024 | nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_0); |
| 1025 | return 0; |
| 1026 | } |
| 1027 | printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n"); |
| 1028 | return -EINVAL; |
| 1029 | } |
| 1030 | |
| 1031 | /* |
| 1032 | * nss_mitigation_handler() |
| 1033 | * Enable NSS MITIGATION |
| 1034 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1035 | 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] | 1036 | { |
| 1037 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1038 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1]; |
| 1039 | int ret; |
| 1040 | |
| 1041 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1042 | if (ret) { |
| 1043 | return ret; |
| 1044 | } |
| 1045 | |
| 1046 | /* |
| 1047 | * It's a read operation |
| 1048 | */ |
| 1049 | if (!write) { |
| 1050 | return ret; |
| 1051 | } |
| 1052 | |
| 1053 | if (!nss_n2h_core1_mitigation_cfg) { |
| 1054 | printk(KERN_INFO "Disabling NSS MITIGATION\n"); |
| 1055 | nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_1); |
| 1056 | return 0; |
| 1057 | } |
| 1058 | printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n"); |
| 1059 | return -EINVAL; |
| 1060 | } |
| 1061 | |
| 1062 | /* |
| 1063 | * nss_buf_handler() |
| 1064 | * Add extra NSS bufs from host memory |
| 1065 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1066 | 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] | 1067 | { |
| 1068 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1069 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0]; |
| 1070 | int ret; |
| 1071 | |
| 1072 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1073 | if (ret) { |
| 1074 | return ret; |
| 1075 | } |
| 1076 | |
| 1077 | /* |
| 1078 | * It's a read operation |
| 1079 | */ |
| 1080 | if (!write) { |
| 1081 | return ret; |
| 1082 | } |
| 1083 | |
| 1084 | if (nss_ctx->buf_sz_allocated) { |
| 1085 | nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1086 | return -EPERM; |
| 1087 | } |
| 1088 | |
| 1089 | if ((nss_n2h_core0_add_buf_pool_size >= 1) && (nss_n2h_core0_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) { |
| 1090 | printk(KERN_INFO "configuring additional NSS pbufs\n"); |
| 1091 | ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core0_add_buf_pool_size, NSS_CORE_0); |
| 1092 | nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1093 | printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated); |
| 1094 | return ret; |
| 1095 | } |
| 1096 | |
| 1097 | printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE); |
| 1098 | return -EINVAL; |
| 1099 | } |
| 1100 | |
| 1101 | /* |
| 1102 | * nss_n2h_buf_handler() |
| 1103 | * Add extra NSS bufs from host memory |
| 1104 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1105 | 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] | 1106 | { |
| 1107 | struct nss_top_instance *nss_top = &nss_top_main; |
| 1108 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1]; |
| 1109 | int ret; |
| 1110 | |
| 1111 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 1112 | if (ret) { |
| 1113 | return ret; |
| 1114 | } |
| 1115 | |
| 1116 | /* |
| 1117 | * It's a read operation |
| 1118 | */ |
| 1119 | if (!write) { |
| 1120 | return ret; |
| 1121 | } |
| 1122 | |
| 1123 | if (nss_ctx->buf_sz_allocated) { |
| 1124 | nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1125 | return -EPERM; |
| 1126 | } |
| 1127 | |
| 1128 | if ((nss_n2h_core1_add_buf_pool_size >= 1) && (nss_n2h_core1_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) { |
| 1129 | printk(KERN_INFO "configuring additional NSS pbufs\n"); |
| 1130 | ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core1_add_buf_pool_size, NSS_CORE_1); |
| 1131 | nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated; |
| 1132 | printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated); |
| 1133 | return ret; |
| 1134 | } |
| 1135 | |
| 1136 | printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE); |
| 1137 | return -EINVAL; |
| 1138 | } |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 1139 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1140 | static struct ctl_table nss_n2h_table[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1141 | { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 1142 | .procname = "n2h_empty_pool_buf_core0", |
| 1143 | .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0], |
| 1144 | .maxlen = sizeof(int), |
| 1145 | .mode = 0644, |
| 1146 | .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler, |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1147 | }, |
| 1148 | { |
Saurabh Misra | 71034db | 2015-06-04 16:18:38 -0700 | [diff] [blame] | 1149 | .procname = "n2h_empty_pool_buf_core1", |
| 1150 | .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1], |
| 1151 | .maxlen = sizeof(int), |
| 1152 | .mode = 0644, |
| 1153 | .proc_handler = &nss_n2h_empty_pool_buf_cfg_core1_handler, |
| 1154 | }, |
| 1155 | { |
| 1156 | .procname = "n2h_low_water_core0", |
| 1157 | .data = &nss_n2h_water_mark[NSS_CORE_0][0], |
| 1158 | .maxlen = sizeof(int), |
| 1159 | .mode = 0644, |
| 1160 | .proc_handler = &nss_n2h_water_mark_core0_handler, |
| 1161 | }, |
| 1162 | { |
| 1163 | .procname = "n2h_low_water_core1", |
| 1164 | .data = &nss_n2h_water_mark[NSS_CORE_1][0], |
| 1165 | .maxlen = sizeof(int), |
| 1166 | .mode = 0644, |
| 1167 | .proc_handler = &nss_n2h_water_mark_core1_handler, |
| 1168 | }, |
| 1169 | { |
| 1170 | .procname = "n2h_high_water_core0", |
| 1171 | .data = &nss_n2h_water_mark[NSS_CORE_0][1], |
| 1172 | .maxlen = sizeof(int), |
| 1173 | .mode = 0644, |
| 1174 | .proc_handler = &nss_n2h_water_mark_core0_handler, |
| 1175 | }, |
| 1176 | { |
| 1177 | .procname = "n2h_high_water_core1", |
| 1178 | .data = &nss_n2h_water_mark[NSS_CORE_1][1], |
| 1179 | .maxlen = sizeof(int), |
| 1180 | .mode = 0644, |
| 1181 | .proc_handler = &nss_n2h_water_mark_core1_handler, |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1182 | }, |
Pamidipati, Vijay | ee9c297 | 2016-01-10 08:13:19 +0530 | [diff] [blame] | 1183 | { |
| 1184 | .procname = "n2h_wifi_pool_buf", |
| 1185 | .data = &nss_n2h_wifi_pool_buf_cfg, |
| 1186 | .maxlen = sizeof(int), |
| 1187 | .mode = 0644, |
| 1188 | .proc_handler = &nss_n2h_wifi_payloads_handler, |
| 1189 | }, |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1190 | { |
| 1191 | .procname = "rps", |
| 1192 | .data = &nss_n2h_rps_config, |
| 1193 | .maxlen = sizeof(int), |
| 1194 | .mode = 0644, |
| 1195 | .proc_handler = &nss_n2h_rpscfg_handler, |
| 1196 | }, |
| 1197 | { |
| 1198 | .procname = "mitigation_core0", |
| 1199 | .data = &nss_n2h_core0_mitigation_cfg, |
| 1200 | .maxlen = sizeof(int), |
| 1201 | .mode = 0644, |
| 1202 | .proc_handler = &nss_n2h_mitigationcfg_core0_handler, |
| 1203 | }, |
| 1204 | { |
| 1205 | .procname = "mitigation_core1", |
| 1206 | .data = &nss_n2h_core1_mitigation_cfg, |
| 1207 | .maxlen = sizeof(int), |
| 1208 | .mode = 0644, |
| 1209 | .proc_handler = &nss_n2h_mitigationcfg_core1_handler, |
| 1210 | }, |
| 1211 | { |
| 1212 | .procname = "extra_pbuf_core0", |
| 1213 | .data = &nss_n2h_core0_add_buf_pool_size, |
| 1214 | .maxlen = sizeof(int), |
| 1215 | .mode = 0644, |
| 1216 | .proc_handler = &nss_n2h_buf_cfg_core0_handler, |
| 1217 | }, |
| 1218 | { |
| 1219 | .procname = "extra_pbuf_core1", |
| 1220 | .data = &nss_n2h_core1_add_buf_pool_size, |
| 1221 | .maxlen = sizeof(int), |
| 1222 | .mode = 0644, |
| 1223 | .proc_handler = &nss_n2h_buf_cfg_core1_handler, |
| 1224 | }, |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1225 | |
| 1226 | { } |
| 1227 | }; |
| 1228 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1229 | static struct ctl_table nss_n2h_dir[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1230 | { |
| 1231 | .procname = "n2hcfg", |
| 1232 | .mode = 0555, |
| 1233 | .child = nss_n2h_table, |
| 1234 | }, |
| 1235 | { } |
| 1236 | }; |
| 1237 | |
| 1238 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1239 | static struct ctl_table nss_n2h_root_dir[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1240 | { |
| 1241 | .procname = "nss", |
| 1242 | .mode = 0555, |
| 1243 | .child = nss_n2h_dir, |
| 1244 | }, |
| 1245 | { } |
| 1246 | }; |
| 1247 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 1248 | static struct ctl_table nss_n2h_root[] = { |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1249 | { |
| 1250 | .procname = "dev", |
| 1251 | .mode = 0555, |
| 1252 | .child = nss_n2h_root_dir, |
| 1253 | }, |
| 1254 | { } |
| 1255 | }; |
| 1256 | |
| 1257 | static struct ctl_table_header *nss_n2h_header; |
| 1258 | |
| 1259 | /* |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1260 | * nss_n2h_flush_payloads() |
| 1261 | * Sends a command down to NSS for flushing all payloads |
| 1262 | */ |
| 1263 | nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx) |
| 1264 | { |
| 1265 | struct nss_n2h_msg nnm; |
| 1266 | struct nss_n2h_flush_payloads *nnflshpl; |
| 1267 | nss_tx_status_t nss_tx_status; |
| 1268 | |
| 1269 | nnflshpl = &nnm.msg.flush_payloads; |
| 1270 | |
| 1271 | /* |
| 1272 | * TODO: No additional information sent in message |
| 1273 | * as of now. Need to initialize message content accordingly |
| 1274 | * if needed. |
| 1275 | */ |
| 1276 | nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, |
| 1277 | NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS, |
| 1278 | sizeof(struct nss_n2h_flush_payloads), |
| 1279 | NULL, |
| 1280 | NULL); |
| 1281 | |
| 1282 | nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); |
| 1283 | if (nss_tx_status != NSS_TX_SUCCESS) { |
| 1284 | nss_warning("%p: failed to send flush payloads command to NSS\n", |
| 1285 | nss_ctx); |
| 1286 | |
| 1287 | return NSS_TX_FAILURE; |
| 1288 | } |
| 1289 | |
| 1290 | return NSS_TX_SUCCESS; |
| 1291 | } |
| 1292 | |
| 1293 | /* |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1294 | * nss_n2h_msg_init() |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1295 | * Initialize n2h message. |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1296 | */ |
| 1297 | 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] | 1298 | uint32_t len, nss_n2h_msg_callback_t cb, void *app_data) |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1299 | { |
| 1300 | nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); |
| 1301 | } |
| 1302 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1303 | /* |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1304 | * nss_n2h_tx_msg() |
| 1305 | * Send messages to NSS n2h pacakge |
| 1306 | */ |
| 1307 | nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm) |
| 1308 | { |
| 1309 | struct nss_n2h_msg *nnm2; |
| 1310 | struct nss_cmn_msg *ncm = &nnm->cm; |
| 1311 | struct sk_buff *nbuf; |
| 1312 | nss_tx_status_t status; |
| 1313 | |
| 1314 | NSS_VERIFY_CTX_MAGIC(nss_ctx); |
| 1315 | if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { |
| 1316 | return NSS_TX_FAILURE_NOT_READY; |
| 1317 | } |
| 1318 | |
| 1319 | /* |
| 1320 | * Sanity check the message |
| 1321 | */ |
| 1322 | if (ncm->interface != NSS_N2H_INTERFACE) { |
| 1323 | nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); |
| 1324 | return NSS_TX_FAILURE; |
| 1325 | } |
| 1326 | |
| 1327 | if (ncm->type >= NSS_METADATA_TYPE_N2H_MAX) { |
| 1328 | nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); |
| 1329 | return NSS_TX_FAILURE; |
| 1330 | } |
| 1331 | |
Suruchi Agarwal | ef8a870 | 2016-01-08 12:40:08 -0800 | [diff] [blame] | 1332 | if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_n2h_msg)) { |
| 1333 | 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] | 1334 | return NSS_TX_FAILURE; |
| 1335 | } |
| 1336 | |
| 1337 | |
| 1338 | nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE); |
| 1339 | if (unlikely(!nbuf)) { |
Sundarajan Srinivasan | 62fee7e | 2015-01-22 11:13:10 -0800 | [diff] [blame] | 1340 | 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] | 1341 | return NSS_TX_FAILURE; |
| 1342 | } |
| 1343 | |
| 1344 | /* |
| 1345 | * Copy the message to our skb. |
| 1346 | */ |
| 1347 | nnm2 = (struct nss_n2h_msg *)skb_put(nbuf, sizeof(struct nss_n2h_msg)); |
| 1348 | memcpy(nnm2, nnm, sizeof(struct nss_n2h_msg)); |
| 1349 | status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0); |
| 1350 | if (status != NSS_CORE_STATUS_SUCCESS) { |
| 1351 | dev_kfree_skb_any(nbuf); |
| 1352 | nss_info("%p: unable to enqueue 'nss frequency change' - marked as stopped\n", nss_ctx); |
| 1353 | return NSS_TX_FAILURE; |
| 1354 | } |
| 1355 | |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 1356 | nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1357 | NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]); |
| 1358 | return NSS_TX_SUCCESS; |
| 1359 | } |
| 1360 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1361 | /* |
| 1362 | * nss_n2h_notify_register() |
| 1363 | * Register to received N2H events. |
| 1364 | * |
| 1365 | * NOTE: Do we want to pass an nss_ctx here so that we can register for n2h on any core? |
| 1366 | */ |
| 1367 | struct nss_ctx_instance *nss_n2h_notify_register(int core, nss_n2h_msg_callback_t cb, void *app_data) |
| 1368 | { |
| 1369 | if (core >= NSS_MAX_CORES) { |
| 1370 | nss_warning("Input core number %d is wrong \n", core); |
| 1371 | return NULL; |
| 1372 | } |
| 1373 | /* |
| 1374 | * TODO: We need to have a new array in support of the new API |
| 1375 | * TODO: If we use a per-context array, we would move the array into nss_ctx based. |
| 1376 | */ |
| 1377 | nss_n2h_rd[core].n2h_callback = cb; |
| 1378 | nss_n2h_rd[core].app_data = app_data; |
| 1379 | return &nss_top_main.nss[core]; |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | /* |
| 1383 | * nss_n2h_register_handler() |
| 1384 | */ |
Thomas Wu | 91f4bdf | 2017-06-09 12:03:02 -0700 | [diff] [blame^] | 1385 | void nss_n2h_register_handler(struct nss_ctx_instance *nss_ctx) |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1386 | { |
Thomas Wu | 91f4bdf | 2017-06-09 12:03:02 -0700 | [diff] [blame^] | 1387 | 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] | 1388 | } |
Sundarajan Srinivasan | f1e5746 | 2014-09-17 15:24:01 -0700 | [diff] [blame] | 1389 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1390 | /* |
| 1391 | * nss_n2h_register_sysctl() |
| 1392 | */ |
| 1393 | void nss_n2h_register_sysctl(void) |
| 1394 | { |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 1395 | /* |
| 1396 | * RPS sema init |
| 1397 | */ |
| 1398 | sema_init(&nss_n2h_rcp.sem, 1); |
| 1399 | init_completion(&nss_n2h_rcp.complete); |
| 1400 | |
Kalyan Tallapragada | b50e890 | 2015-08-06 17:00:54 +0530 | [diff] [blame] | 1401 | /* |
| 1402 | * MITIGATION sema init for core0 |
| 1403 | */ |
| 1404 | sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1); |
| 1405 | init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete); |
| 1406 | |
| 1407 | /* |
| 1408 | * MITIGATION sema init for core1 |
| 1409 | */ |
| 1410 | sema_init(&nss_n2h_mitigationcp[NSS_CORE_1].sem, 1); |
| 1411 | init_completion(&nss_n2h_mitigationcp[NSS_CORE_1].complete); |
| 1412 | |
| 1413 | /* |
| 1414 | * PBUF addition sema init for core0 |
| 1415 | */ |
| 1416 | sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1); |
| 1417 | init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete); |
| 1418 | |
| 1419 | /* |
| 1420 | * PBUF addition sema init for core1 |
| 1421 | */ |
| 1422 | sema_init(&nss_n2h_bufcp[NSS_CORE_1].sem, 1); |
| 1423 | init_completion(&nss_n2h_bufcp[NSS_CORE_1].complete); |
Vijay Dewangan | 634ce59 | 2015-01-07 17:21:09 -0800 | [diff] [blame] | 1424 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1425 | /* |
| 1426 | * Core0 |
| 1427 | */ |
| 1428 | sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1); |
| 1429 | init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete); |
| 1430 | nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool = |
| 1431 | nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]; |
| 1432 | nss_n2h_nepbcfgp[NSS_CORE_0].low_water = |
| 1433 | nss_n2h_water_mark[NSS_CORE_0][0]; |
| 1434 | nss_n2h_nepbcfgp[NSS_CORE_0].high_water = |
| 1435 | nss_n2h_water_mark[NSS_CORE_0][1]; |
| 1436 | |
| 1437 | /* |
| 1438 | * Core1 |
| 1439 | */ |
| 1440 | sema_init(&nss_n2h_nepbcfgp[NSS_CORE_1].sem, 1); |
| 1441 | init_completion(&nss_n2h_nepbcfgp[NSS_CORE_1].complete); |
| 1442 | nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool = |
| 1443 | nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]; |
| 1444 | nss_n2h_nepbcfgp[NSS_CORE_1].low_water = |
| 1445 | nss_n2h_water_mark[NSS_CORE_1][0]; |
| 1446 | nss_n2h_nepbcfgp[NSS_CORE_1].high_water = |
| 1447 | nss_n2h_water_mark[NSS_CORE_1][1]; |
| 1448 | |
| 1449 | /* |
| 1450 | * WiFi pool buf cfg sema init |
| 1451 | */ |
| 1452 | sema_init(&nss_n2h_wp.sem, 1); |
| 1453 | init_completion(&nss_n2h_wp.complete); |
| 1454 | |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1455 | nss_n2h_notify_register(NSS_CORE_0, NULL, NULL); |
| 1456 | nss_n2h_notify_register(NSS_CORE_1, NULL, NULL); |
| 1457 | |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 1458 | /* |
| 1459 | * Register sysctl table. |
| 1460 | */ |
| 1461 | nss_n2h_header = register_sysctl_table(nss_n2h_root); |
| 1462 | } |
| 1463 | |
| 1464 | /* |
| 1465 | * nss_n2h_unregister_sysctl() |
| 1466 | * Unregister sysctl specific to n2h |
| 1467 | */ |
| 1468 | void nss_n2h_unregister_sysctl(void) |
| 1469 | { |
| 1470 | /* |
| 1471 | * Unregister sysctl table. |
| 1472 | */ |
| 1473 | if (nss_n2h_header) { |
| 1474 | unregister_sysctl_table(nss_n2h_header); |
| 1475 | } |
Abhishek Rastogi | 84d95d0 | 2014-03-26 19:31:31 +0530 | [diff] [blame] | 1476 | } |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 1477 | |
| 1478 | EXPORT_SYMBOL(nss_n2h_notify_register); |