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