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