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