blob: 1223c7d4f8a5947028b77451d3eab7b72c3179c8 [file] [log] [blame]
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301/*
2 **************************************************************************
Stephen Wangefd38512017-01-24 14:01:02 -08003 * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05304 * 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 Srinivasanf1e57462014-09-17 15:24:01 -070018 * nss_n2h.c
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053019 * NSS N2H node APIs
20 */
21
22#include "nss_tx_rx_common.h"
23
Stephen Wang49b474b2016-03-25 10:40:30 -070024#define NSS_N2H_MAX_BUF_POOL_SIZE (1024 * 1024 * 8) /* 8MB */
Saurabh Misra71034db2015-06-04 16:18:38 -070025#define NSS_N2H_MIN_EMPTY_POOL_BUF_SZ 32
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053026#define NSS_N2H_MAX_EMPTY_POOL_BUF_SZ 65536
Vijay Dewangan488e5372014-12-29 21:40:11 -080027#define NSS_N2H_DEFAULT_EMPTY_POOL_BUF_SZ 8192
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053028
Saurabh Misra71034db2015-06-04 16:18:38 -070029int nss_n2h_empty_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1};
Sachin Shashidhar475012b2017-03-13 16:56:07 -070030int nss_n2h_empty_paged_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1};
Saurabh Misra71034db2015-06-04 16:18:38 -070031int nss_n2h_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} };
Sachin Shashidhar475012b2017-03-13 16:56:07 -070032int nss_n2h_paged_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} };
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053033int nss_n2h_wifi_pool_buf_cfg __read_mostly = -1;
Stephen Wang49b474b2016-03-25 10:40:30 -070034int nss_n2h_rps_config __read_mostly;
35int nss_n2h_core0_mitigation_cfg __read_mostly = 1;
36int nss_n2h_core1_mitigation_cfg __read_mostly = 1;
37int nss_n2h_core0_add_buf_pool_size __read_mostly;
38int nss_n2h_core1_add_buf_pool_size __read_mostly;
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053039
Vijay Dewangan488e5372014-12-29 21:40:11 -080040struct nss_n2h_registered_data {
41 nss_n2h_msg_callback_t n2h_callback;
42 void *app_data;
43};
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053044
Vijay Dewangan488e5372014-12-29 21:40:11 -080045static struct nss_n2h_cfg_pvt nss_n2h_nepbcfgp[NSS_MAX_CORES];
46static struct nss_n2h_registered_data nss_n2h_rd[NSS_MAX_CORES];
Vijay Dewangan634ce592015-01-07 17:21:09 -080047static struct nss_n2h_cfg_pvt nss_n2h_rcp;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +053048static struct nss_n2h_cfg_pvt nss_n2h_mitigationcp[NSS_CORE_MAX];
49static struct nss_n2h_cfg_pvt nss_n2h_bufcp[NSS_CORE_MAX];
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053050static struct nss_n2h_cfg_pvt nss_n2h_wp;
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053051
52/*
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -070053 * nss_n2h_stats_sync()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053054 * Handle the syncing of NSS statistics.
55 */
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -070056static void nss_n2h_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_n2h_stats_sync *nnss)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053057{
58 struct nss_top_instance *nss_top = nss_ctx->nss_top;
59
60 spin_lock_bh(&nss_top->stats_lock);
61
62 /*
63 * common node stats
64 */
65 nss_ctx->stats_n2h[NSS_STATS_NODE_RX_PKTS] += nnss->node_stats.rx_packets;
66 nss_ctx->stats_n2h[NSS_STATS_NODE_RX_BYTES] += nnss->node_stats.rx_bytes;
67 nss_ctx->stats_n2h[NSS_STATS_NODE_RX_DROPPED] += nnss->node_stats.rx_dropped;
68 nss_ctx->stats_n2h[NSS_STATS_NODE_TX_PKTS] += nnss->node_stats.tx_packets;
69 nss_ctx->stats_n2h[NSS_STATS_NODE_TX_BYTES] += nnss->node_stats.tx_bytes;
70
71 /*
72 * General N2H stats
73 */
Murat Sezgin0c0561d2014-04-09 18:55:58 -070074 nss_ctx->stats_n2h[NSS_STATS_N2H_QUEUE_DROPPED] += nnss->queue_dropped;
75 nss_ctx->stats_n2h[NSS_STATS_N2H_TOTAL_TICKS] += nnss->total_ticks;
76 nss_ctx->stats_n2h[NSS_STATS_N2H_WORST_CASE_TICKS] += nnss->worst_case_ticks;
77 nss_ctx->stats_n2h[NSS_STATS_N2H_ITERATIONS] += nnss->iterations;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053078
79 /*
Thomas Wu3fd8dd72014-06-11 15:57:05 -070080 * pbuf manager ocm and default pool stats
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053081 */
Thomas Wu3fd8dd72014-06-11 15:57:05 -070082 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_ALLOC_FAILS] += nnss->pbuf_ocm_stats.pbuf_alloc_fails;
83 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_FREE_COUNT] = nnss->pbuf_ocm_stats.pbuf_free_count;
84 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_TOTAL_COUNT] = nnss->pbuf_ocm_stats.pbuf_total_count;
85
86 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_ALLOC_FAILS] += nnss->pbuf_default_stats.pbuf_alloc_fails;
87 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_FREE_COUNT] = nnss->pbuf_default_stats.pbuf_free_count;
88 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_TOTAL_COUNT] = nnss->pbuf_default_stats.pbuf_total_count;
89
90 /*
91 * payload mgr stats
92 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053093 nss_ctx->stats_n2h[NSS_STATS_N2H_PAYLOAD_ALLOC_FAILS] += nnss->payload_alloc_fails;
Thomas Wu53679842015-01-22 13:37:35 -080094 nss_ctx->stats_n2h[NSS_STATS_N2H_PAYLOAD_FREE_COUNT] = nnss->payload_free_count;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053095
Sakthi Vignesh Radhakrishnan2a8ee962014-11-22 13:35:38 -080096 /*
97 * Host <=> NSS control traffic stats
98 */
99 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_CONTROL_PACKETS] += nnss->h2n_ctrl_pkts;
100 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_CONTROL_BYTES] += nnss->h2n_ctrl_bytes;
101 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_CONTROL_PACKETS] += nnss->n2h_ctrl_pkts;
102 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_CONTROL_BYTES] += nnss->n2h_ctrl_bytes;
103
104 /*
105 * Host <=> NSS control data traffic stats
106 */
107 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_DATA_PACKETS] += nnss->h2n_data_pkts;
108 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_DATA_BYTES] += nnss->h2n_data_bytes;
109 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_DATA_PACKETS] += nnss->n2h_data_pkts;
110 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_DATA_BYTES] += nnss->n2h_data_bytes;
111
Saurabh Misra71034db2015-06-04 16:18:38 -0700112 /*
113 * Payloads related stats
114 */
115 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_TOT_PAYLOADS] = nnss->tot_payloads;
116
Guojun Jin85dfa7b2015-09-02 15:13:56 -0700117 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_INTERFACE_INVALID] += nnss->data_interface_invalid;
118
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530119 spin_unlock_bh(&nss_top->stats_lock);
120}
121
122/*
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700123 * nss_n2h_interface_handler()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530124 * Handle NSS -> HLOS messages for N2H node
125 */
Vijay Dewangan634ce592015-01-07 17:21:09 -0800126static void nss_n2h_interface_handler(struct nss_ctx_instance *nss_ctx,
127 struct nss_cmn_msg *ncm,
Arunkumar Tba9b4a02016-11-07 11:41:14 +0530128 void *app_data)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530129{
130 struct nss_n2h_msg *nnm = (struct nss_n2h_msg *)ncm;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800131 nss_n2h_msg_callback_t cb;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530132
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700133 BUG_ON(ncm->interface != NSS_N2H_INTERFACE);
134
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530135 /*
136 * Is this a valid request/response packet?
137 */
138 if (nnm->cm.type >= NSS_METADATA_TYPE_N2H_MAX) {
139 nss_warning("%p: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type);
140 return;
141 }
142
143 switch (nnm->cm.type) {
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530144 case NSS_TX_METADATA_TYPE_N2H_RPS_CFG:
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530145 nss_info("NSS N2H rps_en %d \n",nnm->msg.rps_cfg.enable);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800146 break;
147
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530148 case NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG:
149 nss_info("NSS N2H mitigation_dis %d \n",nnm->msg.mitigation_cfg.enable);
150 break;
151
Vijay Dewangan488e5372014-12-29 21:40:11 -0800152 case NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG:
153 nss_info("%p: empty pool buf cfg response from FW", nss_ctx);
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530154 break;
155
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +0530156 case NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS:
157 nss_info("%p: flush payloads cmd response from FW", nss_ctx);
158 break;
159
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530160 case NSS_RX_METADATA_TYPE_N2H_STATS_SYNC:
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700161 nss_n2h_stats_sync(nss_ctx, &nnm->msg.stats_sync);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530162 break;
163
164 default:
165 if (ncm->response != NSS_CMN_RESPONSE_ACK) {
166 /*
167 * Check response
168 */
169 nss_info("%p: Received response %d for type %d, interface %d",
170 nss_ctx, ncm->response, ncm->type, ncm->interface);
171 }
172 }
Vijay Dewangan488e5372014-12-29 21:40:11 -0800173
174 /*
Stephen Wang49b474b2016-03-25 10:40:30 -0700175 * Update the callback and app_data for NOTIFY messages, n2h sends all notify messages
Vijay Dewangan488e5372014-12-29 21:40:11 -0800176 * to the same callback/app_data.
177 */
178 if (nnm->cm.response == NSS_CMM_RESPONSE_NOTIFY) {
179 /*
180 * Place holder for the user to create right call
181 * back and app data when response is NSS_CMM_RESPONSE_NOTIFY
182 */
Stephen Wangaed46332016-12-12 17:29:03 -0800183 ncm->cb = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].n2h_callback;
184 ncm->app_data = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].app_data;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800185 }
186
187 /*
188 * Do we have a callback?
189 */
190 if (!ncm->cb) {
191 return;
192 }
193
194 /*
195 * Callback
196 */
197 cb = (nss_n2h_msg_callback_t)ncm->cb;
198 cb((void *)ncm->app_data, nnm);
199}
200
201/*
Vijay Dewangan634ce592015-01-07 17:21:09 -0800202 * nss_n2h_rps_cfg_callback()
203 * call back function for rps configuration
204 */
205static void nss_n2h_rps_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
206{
207 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)app_data;
208 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
209
210 /*
211 * Error, hence we are not updating the nss_n2h_empty_pool_buf
212 * Restore the current_value to its previous state
213 */
214 nss_n2h_rcp.response = NSS_FAILURE;
215 complete(&nss_n2h_rcp.complete);
216 nss_warning("%p: RPS configuration failed : %d\n", nss_ctx,
217 nnm->cm.error);
218 return;
219 }
220
221 nss_info("%p: RPS configuration succeeded: %d\n", nss_ctx,
222 nnm->cm.error);
223 nss_ctx->n2h_rps_en = nnm->msg.rps_cfg.enable;
224 nss_n2h_rcp.response = NSS_SUCCESS;
225 complete(&nss_n2h_rcp.complete);
226}
227
228/*
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530229 * nss_n2h_mitigation_cfg_callback()
230 * call back function for mitigation configuration
231 */
232static void nss_n2h_mitigation_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
233{
Stephen Wangaed46332016-12-12 17:29:03 -0800234 uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530235 struct nss_top_instance *nss_top = &nss_top_main;
236 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
237
238 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
239
240 /*
241 * Error, hence we are not updating the nss_n2h_mitigate_en
242 */
243 nss_n2h_mitigationcp[core_num].response = NSS_FAILURE;
244 complete(&nss_n2h_mitigationcp[core_num].complete);
245 nss_warning("core%d: MITIGATION configuration failed : %d\n", core_num, nnm->cm.error);
246 return;
247 }
248
249 nss_info("core%d: MITIGATION configuration succeeded: %d\n", core_num, nnm->cm.error);
250
251 nss_ctx->n2h_mitigate_en = nnm->msg.mitigation_cfg.enable;
252 nss_n2h_mitigationcp[core_num].response = NSS_SUCCESS;
253 complete(&nss_n2h_mitigationcp[core_num].complete);
254}
255
256/*
257 * nss_n2h_buf_cfg_callback()
258 * call back function for pbuf configuration
259 */
260static void nss_n2h_bufs_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
261{
Stephen Wangaed46332016-12-12 17:29:03 -0800262 uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530263 unsigned int allocated_sz;
264
265 struct nss_top_instance *nss_top = &nss_top_main;
266 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
267
268 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
269 nss_n2h_bufcp[core_num].response = NSS_FAILURE;
270 nss_warning("core%d: buf configuration failed : %d\n", core_num, nnm->cm.error);
271 goto done;
272 }
273
274 nss_info("core%d: buf configuration succeeded: %d\n", core_num, nnm->cm.error);
275
276 allocated_sz = nnm->msg.buf_pool.nss_buf_page_size * nnm->msg.buf_pool.nss_buf_num_pages;
277 nss_ctx->buf_sz_allocated += allocated_sz;
278
279 nss_n2h_bufcp[core_num].response = NSS_SUCCESS;
280
281done:
282 complete(&nss_n2h_bufcp[core_num].complete);
283}
284
285/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700286 * nss_n2h_payload_stats_callback()
287 * It gets called response to payload accounting.
Vijay Dewangan488e5372014-12-29 21:40:11 -0800288 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700289static void nss_n2h_payload_stats_callback(void *app_data,
290 struct nss_n2h_msg *nnm)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800291{
Stephen Wangaed46332016-12-12 17:29:03 -0800292 uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
Saurabh Misra71034db2015-06-04 16:18:38 -0700293
Vijay Dewangan488e5372014-12-29 21:40:11 -0800294 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
295 struct nss_n2h_empty_pool_buf *nnepbcm;
296 nnepbcm = &nnm->msg.empty_pool_buf_cfg;
297
Saurabh Misra71034db2015-06-04 16:18:38 -0700298 nss_warning("%d: core empty pool buf set failure: %d\n",
299 core_num, nnm->cm.error);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800300 nss_n2h_nepbcfgp[core_num].response = NSS_FAILURE;
301 complete(&nss_n2h_nepbcfgp[core_num].complete);
302 return;
303 }
304
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700305 if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_WATER_MARK) {
306 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size =
Saurabh Misra71034db2015-06-04 16:18:38 -0700307 ntohl(nnm->msg.payload_info.pool_size);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700308 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water =
Saurabh Misra71034db2015-06-04 16:18:38 -0700309 ntohl(nnm->msg.payload_info.low_water);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700310 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water =
Saurabh Misra71034db2015-06-04 16:18:38 -0700311 ntohl(nnm->msg.payload_info.high_water);
312 }
313
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700314 if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK) {
315 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size =
316 ntohl(nnm->msg.paged_payload_info.pool_size);
317 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water =
318 ntohl(nnm->msg.paged_payload_info.low_water);
319 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water =
320 ntohl(nnm->msg.paged_payload_info.high_water);
321 }
322
Vijay Dewangan488e5372014-12-29 21:40:11 -0800323 nss_n2h_nepbcfgp[core_num].response = NSS_SUCCESS;
324 complete(&nss_n2h_nepbcfgp[core_num].complete);
325}
326
327/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530328 * nss_n2h_set_wifi_payloads_callback()
329 * call back function for response to wifi pool configuration
330 *
331 */
332static void nss_n2h_set_wifi_payloads_callback(void *app_data,
333 struct nss_n2h_msg *nnm)
334{
Arunkumar Tba9b4a02016-11-07 11:41:14 +0530335 struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data;
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530336 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
337
338 nss_n2h_wp.response = NSS_FAILURE;
339 complete(&nss_n2h_wp.complete);
340 nss_warning("%p: wifi pool configuration failed : %d\n", nss_ctx,
341 nnm->cm.error);
342 return;
343 }
344
345 nss_info("%p: wifi payload configuration succeeded: %d\n", nss_ctx,
346 nnm->cm.error);
347 nss_n2h_wp.response = NSS_SUCCESS;
348 complete(&nss_n2h_wp.complete);
349}
350
351/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700352 * nss_n2h_get_payload_info()
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700353 * Gets Payload information.
Vijay Dewangan488e5372014-12-29 21:40:11 -0800354 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700355static int nss_n2h_get_payload_info(nss_ptr_t core_num, struct nss_n2h_msg *nnm, struct nss_n2h_payload_info *nnepbcm)
Saurabh Misra71034db2015-06-04 16:18:38 -0700356{
357 struct nss_top_instance *nss_top = &nss_top_main;
358 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
Saurabh Misra71034db2015-06-04 16:18:38 -0700359 nss_tx_status_t nss_tx_status;
360 int ret = NSS_FAILURE;
361
362 /*
363 * Note that semaphore should be already held.
364 */
365
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700366 nss_tx_status = nss_n2h_tx_msg(nss_ctx, nnm);
Saurabh Misra71034db2015-06-04 16:18:38 -0700367
368 if (nss_tx_status != NSS_TX_SUCCESS) {
Stephen Wangaed46332016-12-12 17:29:03 -0800369 nss_warning("%p: core %d nss_tx error errorn", nss_ctx, (int)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700370 return NSS_FAILURE;
371 }
372
373 /*
374 * Blocking call, wait till we get ACK for this msg.
375 */
376 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
377 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
378 if (ret == 0) {
Stephen Wangaed46332016-12-12 17:29:03 -0800379 nss_warning("%p: core %d waiting for ack timed out\n", nss_ctx, (int)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700380 return NSS_FAILURE;
381 }
382
383 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
Stephen Wangaed46332016-12-12 17:29:03 -0800384 nss_warning("%p: core %d response returned failure\n", nss_ctx, (int)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700385 return NSS_FAILURE;
386 }
387
388 return NSS_SUCCESS;
389}
390
391/*
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700392 * nss_n2h_get_default_payload_info()
393 * Gets the default payload information.
394 */
395static int nss_n2h_get_default_payload_info(nss_ptr_t core_num)
396{
397 struct nss_n2h_msg nnm;
398
399 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
400 NSS_TX_METADATA_TYPE_GET_WATER_MARK,
401 sizeof(struct nss_n2h_payload_info),
402 nss_n2h_payload_stats_callback,
403 (void *)core_num);
404
405 return nss_n2h_get_payload_info(core_num, &nnm,
406 &nnm.msg.payload_info);
407}
408
409/*
410 * nss_n2h_get_paged_payload_info()
411 * Gets the paged payload information.
412 */
413static int nss_n2h_get_paged_payload_info(nss_ptr_t core_num)
414{
415 struct nss_n2h_msg nnm;
416
417 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
418 NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK,
419 sizeof(struct nss_n2h_payload_info),
420 nss_n2h_payload_stats_callback,
421 (void *)core_num);
422
423 return nss_n2h_get_payload_info(core_num, &nnm,
424 &nnm.msg.paged_payload_info);
425}
426
427/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700428 * nss_n2h_set_empty_pool_buf()
429 * Sets empty pool buffer
430 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700431static int nss_n2h_set_empty_pool_buf(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700432 void __user *buffer,
433 size_t *lenp, loff_t *ppos,
Stephen Wangaed46332016-12-12 17:29:03 -0800434 nss_ptr_t core_num, int *new_val)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800435{
436 struct nss_top_instance *nss_top = &nss_top_main;
437 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
438 struct nss_n2h_msg nnm;
439 struct nss_n2h_empty_pool_buf *nnepbcm;
440 nss_tx_status_t nss_tx_status;
441 int ret = NSS_FAILURE;
442
443 /*
444 * Acquiring semaphore
445 */
446 down(&nss_n2h_nepbcfgp[core_num].sem);
447
448 /*
449 * Take snap shot of current value
450 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700451 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size = *new_val;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800452
Saurabh Misra71034db2015-06-04 16:18:38 -0700453 if (!write) {
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700454 ret = nss_n2h_get_default_payload_info(core_num);
455 *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size;
Saurabh Misra71034db2015-06-04 16:18:38 -0700456 if (ret == NSS_FAILURE) {
457 up(&nss_n2h_nepbcfgp[core_num].sem);
458 return -EBUSY;
459 }
460
461 up(&nss_n2h_nepbcfgp[core_num].sem);
462
463 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
464 return ret;
465 }
466
Vijay Dewangan488e5372014-12-29 21:40:11 -0800467 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
Saurabh Misra71034db2015-06-04 16:18:38 -0700468 if (ret) {
Vijay Dewangan488e5372014-12-29 21:40:11 -0800469 up(&nss_n2h_nepbcfgp[core_num].sem);
470 return ret;
471 }
472
Vijay Dewangan488e5372014-12-29 21:40:11 -0800473 if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700474 nss_warning("%p: core %d setting %d < min number of buffer",
Stephen Wangaed46332016-12-12 17:29:03 -0800475 nss_ctx, (int)core_num, *new_val);
Stephen Wang06761022015-03-03 16:38:42 -0800476 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800477 }
478
479 nss_info("%p: core %d number of empty pool buffer is : %d\n",
Stephen Wangaed46332016-12-12 17:29:03 -0800480 nss_ctx, (int)core_num, *new_val);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800481
482 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
483 NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG,
484 sizeof(struct nss_n2h_empty_pool_buf),
Saurabh Misra71034db2015-06-04 16:18:38 -0700485 nss_n2h_payload_stats_callback,
Stephen Wangaed46332016-12-12 17:29:03 -0800486 (nss_ptr_t *)core_num);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800487
488 nnepbcm = &nnm.msg.empty_pool_buf_cfg;
489 nnepbcm->pool_size = htonl(*new_val);
490 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
491
492 if (nss_tx_status != NSS_TX_SUCCESS) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700493 nss_warning("%p: core %d nss_tx error empty pool buffer: %d\n",
Stephen Wangaed46332016-12-12 17:29:03 -0800494 nss_ctx, (int)core_num, *new_val);
Stephen Wang06761022015-03-03 16:38:42 -0800495 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800496 }
497
498 /*
499 * Blocking call, wait till we get ACK for this msg.
500 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700501 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
502 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
Vijay Dewangan488e5372014-12-29 21:40:11 -0800503 if (ret == 0) {
Stephen Wangaed46332016-12-12 17:29:03 -0800504 nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num);
Stephen Wang06761022015-03-03 16:38:42 -0800505 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800506 }
507
508 /*
509 * ACK/NACK received from NSS FW
510 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
511 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
512 */
513 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
Stephen Wang06761022015-03-03 16:38:42 -0800514 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800515 }
516
517 up(&nss_n2h_nepbcfgp[core_num].sem);
Thomas Wu651b3902015-05-12 11:21:09 -0700518 return 0;
Stephen Wang06761022015-03-03 16:38:42 -0800519
520failure:
521 /*
522 * Restore the current_value to its previous state
523 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700524 *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size;
525 up(&nss_n2h_nepbcfgp[core_num].sem);
526 return NSS_FAILURE;
527}
528
529/*
530 * nss_n2h_set_empty_paged_pool_buf()
531 * Sets empty paged pool buffer
532 */
533static int nss_n2h_set_empty_paged_pool_buf(struct ctl_table *ctl, int write,
534 void __user *buffer,
535 size_t *lenp, loff_t *ppos,
536 nss_ptr_t core_num, int *new_val)
537{
538 struct nss_top_instance *nss_top = &nss_top_main;
539 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
540 struct nss_n2h_msg nnm;
541 struct nss_n2h_empty_pool_buf *nneppbcm;
542 nss_tx_status_t nss_tx_status;
543 int ret = NSS_FAILURE;
544
545 /*
546 * Acquiring semaphore
547 */
548 down(&nss_n2h_nepbcfgp[core_num].sem);
549
550 /*
551 * Take snap shot of current value
552 */
553 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size = *new_val;
554
555 if (!write) {
556 ret = nss_n2h_get_paged_payload_info(core_num);
557 *new_val = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size;
558 if (ret == NSS_FAILURE) {
559 up(&nss_n2h_nepbcfgp[core_num].sem);
560 return -EBUSY;
561 }
562
563 up(&nss_n2h_nepbcfgp[core_num].sem);
564
565 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
566 return ret;
567 }
568
569 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
570 if (ret) {
571 up(&nss_n2h_nepbcfgp[core_num].sem);
572 return ret;
573 }
574
575 if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
576 nss_warning("%p: core %d setting %d < min number of buffer",
577 nss_ctx, (int)core_num, *new_val);
578 goto failure;
579 }
580
581 nss_info("%p: core %d number of empty paged pool buffer is : %d\n",
582 nss_ctx, (int)core_num, *new_val);
583
584 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
585 NSS_TX_METADATA_TYPE_N2H_EMPTY_PAGED_POOL_BUF_CFG,
586 sizeof(struct nss_n2h_empty_pool_buf),
587 nss_n2h_payload_stats_callback,
588 (nss_ptr_t *)core_num);
589
590 nneppbcm = &nnm.msg.empty_pool_buf_cfg;
591 nneppbcm->pool_size = htonl(*new_val);
592 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
593
594 if (nss_tx_status != NSS_TX_SUCCESS) {
595 nss_warning("%p: core %d nss_tx error empty paged pool buffer: %d\n",
596 nss_ctx, (int)core_num, *new_val);
597 goto failure;
598 }
599
600 /*
601 * Blocking call, wait till we get ACK for this msg.
602 */
603 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
604 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
605 if (ret == 0) {
606 nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num);
607 goto failure;
608 }
609
610 /*
611 * ACK/NACK received from NSS FW
612 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
613 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
614 */
615 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
616 goto failure;
617 }
618
619 up(&nss_n2h_nepbcfgp[core_num].sem);
620 return 0;
621
622failure:
623 /*
624 * Restore the current_value to its previous state
625 */
626 *new_val = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size;
Saurabh Misra71034db2015-06-04 16:18:38 -0700627 up(&nss_n2h_nepbcfgp[core_num].sem);
628 return NSS_FAILURE;
629}
630
631/*
632 * nss_n2h_set_water_mark()
633 * Sets water mark for N2H SOS
634 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700635static int nss_n2h_set_water_mark(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700636 void __user *buffer,
637 size_t *lenp, loff_t *ppos,
Stephen Wangaed46332016-12-12 17:29:03 -0800638 uint32_t core_num, int *low, int *high)
Saurabh Misra71034db2015-06-04 16:18:38 -0700639{
640 struct nss_top_instance *nss_top = &nss_top_main;
641 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
642 struct nss_n2h_msg nnm;
643 struct nss_n2h_water_mark *wm;
644 nss_tx_status_t nss_tx_status;
645 int ret = NSS_FAILURE;
646
647 /*
648 * Acquiring semaphore
649 */
650 down(&nss_n2h_nepbcfgp[core_num].sem);
651
652 /*
653 * Take snap shot of current value
654 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700655 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water = *low;
656 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water = *high;
Saurabh Misra71034db2015-06-04 16:18:38 -0700657
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700658 if (!write || *low == -1 || *high == -1) {
659 ret = nss_n2h_get_default_payload_info(core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700660 if (ret == NSS_FAILURE) {
661 up(&nss_n2h_nepbcfgp[core_num].sem);
662 return -EBUSY;
663 }
664
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700665 *low = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water;
666 *high = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water;
Saurabh Misra71034db2015-06-04 16:18:38 -0700667 }
668
669 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700670 if (!write || ret) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700671 up(&nss_n2h_nepbcfgp[core_num].sem);
672 return ret;
673 }
674
Saurabh Misra71034db2015-06-04 16:18:38 -0700675 if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) ||
676 (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
677 nss_warning("%p: core %d setting %d, %d < min number of buffer",
678 nss_ctx, core_num, *low, *high);
679 goto failure;
680 }
681
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530682 if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) ||
683 (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700684 nss_warning("%p: core %d setting %d, %d is > upper limit",
685 nss_ctx, core_num, *low, *high);
686 goto failure;
687 }
688
689 if (*low > *high) {
690 nss_warning("%p: core %d setting low %d is more than high %d",
691 nss_ctx, core_num, *low, *high);
692 goto failure;
693 }
694
695 nss_info("%p: core %d number of low : %d and high : %d\n",
696 nss_ctx, core_num, *low, *high);
697
698 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
699 NSS_TX_METADATA_TYPE_SET_WATER_MARK,
700 sizeof(struct nss_n2h_water_mark),
701 nss_n2h_payload_stats_callback,
Stephen Wangaed46332016-12-12 17:29:03 -0800702 (void *)(nss_ptr_t)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700703
704 wm = &nnm.msg.wm;
705 wm->low_water = htonl(*low);
706 wm->high_water = htonl(*high);
707 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
708
709 if (nss_tx_status != NSS_TX_SUCCESS) {
710 nss_warning("%p: core %d nss_tx error setting : %d, %d\n",
711 nss_ctx, core_num, *low, *high);
712 goto failure;
713 }
714
715 /*
716 * Blocking call, wait till we get ACK for this msg.
717 */
718 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
719 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
720 if (ret == 0) {
721 nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx,
722 core_num);
723 goto failure;
724 }
725
726 /*
727 * ACK/NACK received from NSS FW
728 */
729 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response)
730 goto failure;
731
732 up(&nss_n2h_nepbcfgp[core_num].sem);
733 return NSS_SUCCESS;
734
735failure:
736 /*
737 * Restore the current_value to its previous state
738 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700739 *low = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water;
740 *high = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water;
741 up(&nss_n2h_nepbcfgp[core_num].sem);
742 return -EINVAL;
743}
744
745/*
746 * nss_n2h_set_paged_water_mark()
747 * Sets water mark for paged pool N2H SOS
748 */
749static int nss_n2h_set_paged_water_mark(struct ctl_table *ctl, int write,
750 void __user *buffer,
751 size_t *lenp, loff_t *ppos,
752 uint32_t core_num, int *low, int *high)
753{
754 struct nss_top_instance *nss_top = &nss_top_main;
755 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
756 struct nss_n2h_msg nnm;
757 struct nss_n2h_water_mark *pwm;
758 nss_tx_status_t nss_tx_status;
759 int ret = NSS_FAILURE;
760
761 /*
762 * Acquiring semaphore
763 */
764 down(&nss_n2h_nepbcfgp[core_num].sem);
765
766 /*
767 * Take snap shot of current value
768 */
769 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water = *low;
770 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water = *high;
771
772 if (!write || *low == -1 || *high == -1) {
773 ret = nss_n2h_get_paged_payload_info(core_num);
774 if (ret == NSS_FAILURE) {
775 up(&nss_n2h_nepbcfgp[core_num].sem);
776 return -EBUSY;
777 }
778
779 *low = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water;
780 *high = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water;
781 }
782
783 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
784 if (!write || ret) {
785 up(&nss_n2h_nepbcfgp[core_num].sem);
786 return ret;
787 }
788
789 if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) ||
790 (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
791 nss_warning("%p: core %d setting %d, %d < min number of buffer",
792 nss_ctx, core_num, *low, *high);
793 goto failure;
794 }
795
796 if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) ||
797 (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
798 nss_warning("%p: core %d setting %d, %d is > upper limit",
799 nss_ctx, core_num, *low, *high);
800 goto failure;
801 }
802
803 if (*low > *high) {
804 nss_warning("%p: core %d setting low %d is more than high %d",
805 nss_ctx, core_num, *low, *high);
806 goto failure;
807 }
808
809 nss_info("%p: core %d number of low : %d and high : %d\n",
810 nss_ctx, core_num, *low, *high);
811
812 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
813 NSS_TX_METADATA_TYPE_SET_PAGED_WATER_MARK,
814 sizeof(struct nss_n2h_water_mark),
815 nss_n2h_payload_stats_callback,
816 (void *)(nss_ptr_t)core_num);
817
818 pwm = &nnm.msg.wm_paged;
819 pwm->low_water = htonl(*low);
820 pwm->high_water = htonl(*high);
821 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
822
823 if (nss_tx_status != NSS_TX_SUCCESS) {
824 nss_warning("%p: core %d nss_tx error setting : %d, %d\n",
825 nss_ctx, core_num, *low, *high);
826 goto failure;
827 }
828
829 /*
830 * Blocking call, wait till we get ACK for this msg.
831 */
832 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
833 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
834 if (ret == 0) {
835 nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx,
836 core_num);
837 goto failure;
838 }
839
840 /*
841 * ACK/NACK received from NSS FW
842 */
843 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response)
844 goto failure;
845
846 up(&nss_n2h_nepbcfgp[core_num].sem);
847 return NSS_SUCCESS;
848
849failure:
850 /*
851 * Restore the current_value to its previous state
852 */
853 *low = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water;
854 *high = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water;
Stephen Wang06761022015-03-03 16:38:42 -0800855 up(&nss_n2h_nepbcfgp[core_num].sem);
Thomas Wu651b3902015-05-12 11:21:09 -0700856 return -EINVAL;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800857}
858
859/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530860 * nss_n2h_cfg_wifi_pool()
861 * Sets number of wifi payloads to adjust high water mark for N2H SoS
862 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700863static int nss_n2h_cfg_wifi_pool(struct ctl_table *ctl, int write,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530864 void __user *buffer,
865 size_t *lenp, loff_t *ppos,
866 int *payloads)
867{
868 struct nss_top_instance *nss_top = &nss_top_main;
869 struct nss_ctx_instance *nss_ctx = &nss_top->nss[0];
870 struct nss_n2h_msg nnm;
871 struct nss_n2h_wifi_payloads *wp;
872 nss_tx_status_t nss_tx_status;
873 int ret = NSS_FAILURE;
874
875 /*
876 * Acquiring semaphore
877 */
878 down(&nss_n2h_wp.sem);
879
880 if (!write) {
881 *payloads = nss_n2h_wp.wifi_pool;
882
883 up(&nss_n2h_wp.sem);
884 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
885 return ret;
886 }
887
888 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
889 if (ret) {
890 up(&nss_n2h_wp.sem);
891 return ret;
892 }
893
894 /*
895 * If payloads parameter is not set, we do
896 * nothing.
897 */
898 if (*payloads == -1)
899 goto failure;
900
901 if ((*payloads < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
902 nss_warning("%p: wifi setting %d < min number of buffer",
903 nss_ctx, *payloads);
904 goto failure;
905 }
906
907 if ((*payloads > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
908 nss_warning("%p: wifi setting %d > max number of buffer",
909 nss_ctx, *payloads);
910 goto failure;
911 }
912
913 nss_info("%p: wifi payloads : %d\n",
914 nss_ctx, *payloads);
915
916 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
917 NSS_TX_METADATA_TYPE_N2H_WIFI_POOL_BUF_CFG,
918 sizeof(struct nss_n2h_wifi_payloads),
919 nss_n2h_set_wifi_payloads_callback,
920 (void *)nss_ctx);
921
922 wp = &nnm.msg.wp;
923 wp->payloads = htonl(*payloads);
924 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
925
926 if (nss_tx_status != NSS_TX_SUCCESS) {
927 nss_warning("%p: wifi setting %d nss_tx error",
928 nss_ctx, *payloads);
929 goto failure;
930 }
931
932 /*
933 * Blocking call, wait till we get ACK for this msg.
934 */
935 ret = wait_for_completion_timeout(&nss_n2h_wp.complete,
936 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
937 if (ret == 0) {
938 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
939 goto failure;
940 }
941
942 /*
943 * ACK/NACK received from NSS FW
944 */
945 if (NSS_FAILURE == nss_n2h_wp.response)
946 goto failure;
947
948 up(&nss_n2h_wp.sem);
949 return NSS_SUCCESS;
950
951failure:
952 up(&nss_n2h_wp.sem);
953 return -EINVAL;
954}
955
956/*
Vijay Dewangan488e5372014-12-29 21:40:11 -0800957 * nss_n2h_empty_pool_buf_core1_handler()
958 * Sets the number of empty buffer for core 1
959 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700960static int nss_n2h_empty_pool_buf_cfg_core1_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700961 int write, void __user *buffer,
962 size_t *lenp, loff_t *ppos)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800963{
964 return nss_n2h_set_empty_pool_buf(ctl, write, buffer, lenp, ppos,
Saurabh Misra71034db2015-06-04 16:18:38 -0700965 NSS_CORE_1, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800966}
967
968/*
969 * nss_n2h_empty_pool_buf_core0_handler()
970 * Sets the number of empty buffer for core 0
971 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700972static int nss_n2h_empty_pool_buf_cfg_core0_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700973 int write, void __user *buffer,
974 size_t *lenp, loff_t *ppos)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800975{
976 return nss_n2h_set_empty_pool_buf(ctl, write, buffer, lenp, ppos,
Saurabh Misra71034db2015-06-04 16:18:38 -0700977 NSS_CORE_0, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]);
978}
979
980/*
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700981 * nss_n2h_empty_paged_pool_buf_cfg_core1_handler()
982 * Sets the number of empty paged buffer for core 1
983 */
984static int nss_n2h_empty_paged_pool_buf_cfg_core1_handler(struct ctl_table *ctl,
985 int write, void __user *buffer,
986 size_t *lenp, loff_t *ppos)
987{
988 return nss_n2h_set_empty_paged_pool_buf(ctl, write, buffer, lenp, ppos,
989 NSS_CORE_1, &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1]);
990}
991
992/*
993 * nss_n2h_empty_paged_pool_buf_cfg_core0_handler()
994 * Sets the number of empty paged buffer for core 0
995 */
996static int nss_n2h_empty_paged_pool_buf_cfg_core0_handler(struct ctl_table *ctl,
997 int write, void __user *buffer,
998 size_t *lenp, loff_t *ppos)
999{
1000 return nss_n2h_set_empty_paged_pool_buf(ctl, write, buffer, lenp, ppos,
1001 NSS_CORE_0, &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0]);
1002}
1003
1004/*
Saurabh Misra71034db2015-06-04 16:18:38 -07001005 * nss_n2h_water_mark_core1_handler()
1006 * Sets water mark for core 1
1007 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001008static int nss_n2h_water_mark_core1_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -07001009 int write, void __user *buffer,
1010 size_t *lenp, loff_t *ppos)
1011{
1012 return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos,
1013 NSS_CORE_1, &nss_n2h_water_mark[NSS_CORE_1][0],
1014 &nss_n2h_water_mark[NSS_CORE_1][1]);
1015}
1016
1017/*
1018 * nss_n2h_water_mark_core0_handler()
1019 * Sets water mark for core 0
1020 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001021static int nss_n2h_water_mark_core0_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -07001022 int write, void __user *buffer,
1023 size_t *lenp, loff_t *ppos)
1024{
1025 return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos,
1026 NSS_CORE_0, &nss_n2h_water_mark[NSS_CORE_0][0],
1027 &nss_n2h_water_mark[NSS_CORE_0][1]);
Vijay Dewangan488e5372014-12-29 21:40:11 -08001028}
1029
Vijay Dewangan634ce592015-01-07 17:21:09 -08001030/*
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001031 * nss_n2h_paged_water_mark_core1_handler()
1032 * Sets paged water mark for core 1
1033 */
1034static int nss_n2h_paged_water_mark_core1_handler(struct ctl_table *ctl,
1035 int write, void __user *buffer,
1036 size_t *lenp, loff_t *ppos)
1037{
1038 return nss_n2h_set_paged_water_mark(ctl, write, buffer, lenp, ppos,
1039 NSS_CORE_1, &nss_n2h_paged_water_mark[NSS_CORE_1][0],
1040 &nss_n2h_paged_water_mark[NSS_CORE_1][1]);
1041}
1042
1043
1044/*
1045 * nss_n2h_paged_water_mark_core0_handler()
1046 * Sets paged water mark for core 0
1047 */
1048static int nss_n2h_paged_water_mark_core0_handler(struct ctl_table *ctl,
1049 int write, void __user *buffer,
1050 size_t *lenp, loff_t *ppos)
1051{
1052 return nss_n2h_set_paged_water_mark(ctl, write, buffer, lenp, ppos,
1053 NSS_CORE_0, &nss_n2h_paged_water_mark[NSS_CORE_0][0],
1054 &nss_n2h_paged_water_mark[NSS_CORE_0][1]);
1055}
1056
1057/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301058 * nss_n2h_wifi_payloads_handler()
1059 * Sets number of wifi payloads
1060 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001061static int nss_n2h_wifi_payloads_handler(struct ctl_table *ctl,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301062 int write, void __user *buffer,
1063 size_t *lenp, loff_t *ppos)
1064{
1065 return nss_n2h_cfg_wifi_pool(ctl, write, buffer, lenp, ppos,
1066 &nss_n2h_wifi_pool_buf_cfg);
1067}
1068
1069/*
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301070 * nss_n2h_update_queue_config()
1071 * Updates pnode queue configuration and limits
1072 */
1073nss_tx_status_t nss_n2h_update_queue_config(int max_pri, bool mq_en, int num_pri, int *qlimits)
1074{
1075 struct nss_n2h_msg nnm;
1076 struct nss_n2h_pnode_queue_config *cfg;
1077 nss_tx_status_t status;
1078 struct nss_top_instance *nss_top = &nss_top_main;
1079 struct nss_ctx_instance *nss_ctx = &nss_top->nss[0];
1080 int i;
1081
1082 if (!mq_en) {
1083 return NSS_TX_SUCCESS;
1084 }
1085
1086 if (num_pri <= 0) {
1087 nss_warning("%p: nss_tx error in pnode queue config param", nss_ctx);
1088 return NSS_TX_FAILURE_BAD_PARAM;
1089 }
1090
1091 if (max_pri < num_pri) {
1092 nss_warning("%p: nss_tx error in pnode queue config param, maximum supported priority is %d", nss_ctx, max_pri);
1093 return NSS_TX_FAILURE_BAD_PARAM;
1094 }
1095
1096 cfg = &nnm.msg.pn_q_cfg;
1097 cfg->num_pri = num_pri;
1098 for (i = 0; i < num_pri; i++) {
1099 cfg->qlimits[i] = qlimits[i];
1100 }
1101 cfg->mq_en = true;
1102
1103 /*
1104 * Create message for FW
1105 */
1106 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1107 NSS_TX_METADATA_TYPE_N2H_SET_PNODE_QUEUE_CFG,
1108 sizeof(struct nss_n2h_pnode_queue_config), NULL, 0);
1109
1110 status = nss_n2h_tx_msg(nss_ctx, &nnm);
1111 if (status != NSS_TX_SUCCESS) {
1112 nss_warning("%p: nss_tx error to send pnode queue config\n", nss_ctx);
1113 return status;
1114 }
1115
1116 return NSS_TX_SUCCESS;
1117
1118}
1119EXPORT_SYMBOL(nss_n2h_update_queue_config);
1120
1121/*
Vijay Dewangan634ce592015-01-07 17:21:09 -08001122 * nss_n2h_rps_cfg()
1123 * Send Message to NSS to enable RPS.
1124 */
Stephen Wang49b474b2016-03-25 10:40:30 -07001125static nss_tx_status_t nss_n2h_rps_cfg(struct nss_ctx_instance *nss_ctx, int enable_rps)
Vijay Dewangan634ce592015-01-07 17:21:09 -08001126{
1127 struct nss_n2h_msg nnm;
1128 struct nss_n2h_rps *rps_cfg;
1129 nss_tx_status_t nss_tx_status;
1130 int ret;
1131
1132 down(&nss_n2h_rcp.sem);
1133 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_RPS_CFG,
1134 sizeof(struct nss_n2h_rps),
1135 nss_n2h_rps_cfg_callback,
1136 (void *)nss_ctx);
1137
1138 rps_cfg = &nnm.msg.rps_cfg;
1139 rps_cfg->enable = enable_rps;
1140
1141 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1142
1143 if (nss_tx_status != NSS_TX_SUCCESS) {
1144 nss_warning("%p: nss_tx error setting rps\n", nss_ctx);
1145
1146 up(&nss_n2h_rcp.sem);
1147 return NSS_FAILURE;
1148 }
1149
1150 /*
1151 * Blocking call, wait till we get ACK for this msg.
1152 */
1153 ret = wait_for_completion_timeout(&nss_n2h_rcp.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
1154 if (ret == 0) {
1155 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
1156 up(&nss_n2h_rcp.sem);
1157 return NSS_FAILURE;
1158 }
1159
1160 /*
1161 * ACK/NACK received from NSS FW
1162 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
1163 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
1164 */
1165 if (NSS_FAILURE == nss_n2h_rcp.response) {
1166 up(&nss_n2h_rcp.sem);
1167 return NSS_FAILURE;
1168 }
1169
1170 up(&nss_n2h_rcp.sem);
1171 return NSS_SUCCESS;
1172}
1173
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301174/*
1175 * nss_n2h_mitigation_cfg()
1176 * Send Message to NSS to disable MITIGATION.
1177 */
Stephen Wang49b474b2016-03-25 10:40:30 -07001178static nss_tx_status_t nss_n2h_mitigation_cfg(struct nss_ctx_instance *nss_ctx, int enable_mitigation, nss_core_id_t core_num)
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301179{
1180 struct nss_n2h_msg nnm;
1181 struct nss_n2h_mitigation *mitigation_cfg;
1182 nss_tx_status_t nss_tx_status;
1183 int ret;
1184
1185 nss_assert(core_num < NSS_CORE_MAX);
1186
1187 down(&nss_n2h_mitigationcp[core_num].sem);
1188 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG,
1189 sizeof(struct nss_n2h_mitigation),
1190 nss_n2h_mitigation_cfg_callback,
1191 (void *)core_num);
1192
1193 mitigation_cfg = &nnm.msg.mitigation_cfg;
1194 mitigation_cfg->enable = enable_mitigation;
1195
1196 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1197
1198 if (nss_tx_status != NSS_TX_SUCCESS) {
1199 nss_warning("%p: nss_tx error setting mitigation\n", nss_ctx);
1200 goto failure;
1201 }
1202
1203 /*
1204 * Blocking call, wait till we get ACK for this msg.
1205 */
1206 ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
1207 if (ret == 0) {
1208 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
1209 goto failure;
1210 }
1211
1212 /*
1213 * ACK/NACK received from NSS FW
1214 */
1215 if (NSS_FAILURE == nss_n2h_mitigationcp[core_num].response) {
1216 goto failure;
1217 }
1218
1219 up(&nss_n2h_mitigationcp[core_num].sem);
1220 return NSS_SUCCESS;
1221
1222failure:
1223 up(&nss_n2h_mitigationcp[core_num].sem);
1224 return NSS_FAILURE;
1225}
1226
1227static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool)
1228{
1229 int page_count;
1230 for (page_count = 0; page_count < buf_pool->nss_buf_num_pages; page_count++) {
1231 kfree(buf_pool->nss_buf_pool_vaddr[page_count]);
1232 }
1233}
1234
1235/*
1236 * nss_n2h_buf_cfg()
1237 * Send Message to NSS to enable pbufs.
1238 */
Stephen Wang49b474b2016-03-25 10:40:30 -07001239static nss_tx_status_t nss_n2h_buf_pool_cfg(struct nss_ctx_instance *nss_ctx,
Tallapragada4b0161b2016-07-07 21:38:34 +05301240 int buf_pool_size, nss_core_id_t core_num)
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301241{
1242 static struct nss_n2h_msg nnm;
1243 struct nss_n2h_buf_pool *buf_pool;
1244 nss_tx_status_t nss_tx_status;
1245 int ret;
1246 int page_count;
1247 int num_pages = ALIGN(buf_pool_size, PAGE_SIZE)/PAGE_SIZE;
1248
1249 nss_assert(core_num < NSS_CORE_MAX);
1250
1251 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_METADATA_TYPE_N2H_ADD_BUF_POOL,
1252 sizeof(struct nss_n2h_buf_pool),
1253 nss_n2h_bufs_cfg_callback,
1254 (void *)core_num);
1255
1256 do {
1257
1258 down(&nss_n2h_bufcp[core_num].sem);
1259
1260 buf_pool = &nnm.msg.buf_pool;
1261 buf_pool->nss_buf_page_size = PAGE_SIZE;
1262
1263 for (page_count = 0; page_count < MAX_PAGES_PER_MSG && num_pages; page_count++, num_pages--) {
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301264 void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC);
1265 if (!kern_addr) {
1266 BUG_ON(!page_count);
1267 break;
1268 }
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301269
Radha krishna Simha Jiguru60068fb2017-07-28 17:40:52 +05301270 kmemleak_not_leak(kern_addr);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301271 buf_pool->nss_buf_pool_vaddr[page_count] = kern_addr;
Stephen Wangefd38512017-01-24 14:01:02 -08001272 buf_pool->nss_buf_pool_addr[page_count] = dma_map_single(nss_ctx->dev, kern_addr, PAGE_SIZE, DMA_TO_DEVICE);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301273 }
1274
1275 buf_pool->nss_buf_num_pages = page_count;
1276 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1277 if (nss_tx_status != NSS_TX_SUCCESS) {
1278
1279 nss_n2h_buf_pool_free(buf_pool);
1280 nss_warning("%p: nss_tx error setting pbuf\n", nss_ctx);
1281 goto failure;
1282 }
1283
1284 /*
1285 * Blocking call, wait till we get ACK for this msg.
1286 */
1287 ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
1288 if (ret == 0) {
1289 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
1290 goto failure;
1291 }
1292
1293 /*
1294 * ACK/NACK received from NSS FW
1295 */
1296 if (NSS_FAILURE == nss_n2h_bufcp[core_num].response) {
1297
1298 nss_n2h_buf_pool_free(buf_pool);
1299 goto failure;
1300 }
1301
1302 up(&nss_n2h_bufcp[core_num].sem);
1303 } while(num_pages);
1304
1305 return NSS_SUCCESS;
1306failure:
1307 up(&nss_n2h_bufcp[core_num].sem);
1308 return NSS_FAILURE;
1309}
1310
Stephen Wang49b474b2016-03-25 10:40:30 -07001311/*
1312 * nss_rps_handler()
1313 * Enable NSS RPS
1314 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001315static int nss_n2h_rpscfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Stephen Wang49b474b2016-03-25 10:40:30 -07001316{
1317 struct nss_top_instance *nss_top = &nss_top_main;
1318 struct nss_ctx_instance *nss_ctx = &nss_top->nss[0];
1319 int ret;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301320
Stephen Wang49b474b2016-03-25 10:40:30 -07001321 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1322 if (!ret) {
1323 if ((write) && (nss_n2h_rps_config == 1)) {
1324 printk(KERN_INFO "Enabling NSS RPS\n");
1325
1326 return nss_n2h_rps_cfg(nss_ctx, 1);
1327 }
1328
1329 if ((write) && (nss_n2h_rps_config == 0)) {
1330 printk(KERN_INFO "Runtime disabling of NSS RPS not supported\n");
1331 return ret;
1332 }
1333
1334 if (write) {
1335 printk(KERN_INFO "Invalid input value.Valid values are 0 and 1\n");
1336 }
1337
1338 }
1339
1340 return ret;
1341}
1342
1343/*
1344 * nss_mitigation_handler()
1345 * Enable NSS MITIGATION
1346 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001347static int nss_n2h_mitigationcfg_core0_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Stephen Wang49b474b2016-03-25 10:40:30 -07001348{
1349 struct nss_top_instance *nss_top = &nss_top_main;
1350 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0];
1351 int ret;
1352
1353 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1354 if (ret) {
1355 return ret;
1356 }
1357
1358 /*
1359 * It's a read operation
1360 */
1361 if (!write) {
1362 return ret;
1363 }
1364
1365 if (!nss_n2h_core0_mitigation_cfg) {
1366 printk(KERN_INFO "Disabling NSS MITIGATION\n");
1367 nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_0);
1368 return 0;
1369 }
1370 printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n");
1371 return -EINVAL;
1372}
1373
1374/*
1375 * nss_mitigation_handler()
1376 * Enable NSS MITIGATION
1377 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001378static int nss_n2h_mitigationcfg_core1_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Stephen Wang49b474b2016-03-25 10:40:30 -07001379{
1380 struct nss_top_instance *nss_top = &nss_top_main;
1381 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1];
1382 int ret;
1383
1384 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1385 if (ret) {
1386 return ret;
1387 }
1388
1389 /*
1390 * It's a read operation
1391 */
1392 if (!write) {
1393 return ret;
1394 }
1395
1396 if (!nss_n2h_core1_mitigation_cfg) {
1397 printk(KERN_INFO "Disabling NSS MITIGATION\n");
1398 nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_1);
1399 return 0;
1400 }
1401 printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n");
1402 return -EINVAL;
1403}
1404
1405/*
1406 * nss_buf_handler()
1407 * Add extra NSS bufs from host memory
1408 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001409static int nss_n2h_buf_cfg_core0_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Stephen Wang49b474b2016-03-25 10:40:30 -07001410{
1411 struct nss_top_instance *nss_top = &nss_top_main;
1412 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0];
1413 int ret;
1414
1415 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1416 if (ret) {
1417 return ret;
1418 }
1419
1420 /*
1421 * It's a read operation
1422 */
1423 if (!write) {
1424 return ret;
1425 }
1426
1427 if (nss_ctx->buf_sz_allocated) {
1428 nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1429 return -EPERM;
1430 }
1431
1432 if ((nss_n2h_core0_add_buf_pool_size >= 1) && (nss_n2h_core0_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) {
1433 printk(KERN_INFO "configuring additional NSS pbufs\n");
1434 ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core0_add_buf_pool_size, NSS_CORE_0);
1435 nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1436 printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated);
1437 return ret;
1438 }
1439
1440 printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE);
1441 return -EINVAL;
1442}
1443
1444/*
1445 * nss_n2h_buf_handler()
1446 * Add extra NSS bufs from host memory
1447 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001448static int nss_n2h_buf_cfg_core1_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Stephen Wang49b474b2016-03-25 10:40:30 -07001449{
1450 struct nss_top_instance *nss_top = &nss_top_main;
1451 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1];
1452 int ret;
1453
1454 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1455 if (ret) {
1456 return ret;
1457 }
1458
1459 /*
1460 * It's a read operation
1461 */
1462 if (!write) {
1463 return ret;
1464 }
1465
1466 if (nss_ctx->buf_sz_allocated) {
1467 nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1468 return -EPERM;
1469 }
1470
1471 if ((nss_n2h_core1_add_buf_pool_size >= 1) && (nss_n2h_core1_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) {
1472 printk(KERN_INFO "configuring additional NSS pbufs\n");
1473 ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core1_add_buf_pool_size, NSS_CORE_1);
1474 nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1475 printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated);
1476 return ret;
1477 }
1478
1479 printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE);
1480 return -EINVAL;
1481}
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301482
Stephen Wang52e6d342016-03-29 15:02:33 -07001483static struct ctl_table nss_n2h_table[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001484 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001485 .procname = "n2h_empty_pool_buf_core0",
1486 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0],
1487 .maxlen = sizeof(int),
1488 .mode = 0644,
1489 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001490 },
1491 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001492 .procname = "n2h_empty_pool_buf_core1",
1493 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1],
1494 .maxlen = sizeof(int),
1495 .mode = 0644,
1496 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core1_handler,
1497 },
1498 {
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001499 .procname = "n2h_empty_paged_pool_buf_core0",
1500 .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0],
1501 .maxlen = sizeof(int),
1502 .mode = 0644,
1503 .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core0_handler,
1504 },
1505 {
1506 .procname = "n2h_empty_paged_pool_buf_core1",
1507 .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1],
1508 .maxlen = sizeof(int),
1509 .mode = 0644,
1510 .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core1_handler,
1511 },
1512
1513 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001514 .procname = "n2h_low_water_core0",
1515 .data = &nss_n2h_water_mark[NSS_CORE_0][0],
1516 .maxlen = sizeof(int),
1517 .mode = 0644,
1518 .proc_handler = &nss_n2h_water_mark_core0_handler,
1519 },
1520 {
1521 .procname = "n2h_low_water_core1",
1522 .data = &nss_n2h_water_mark[NSS_CORE_1][0],
1523 .maxlen = sizeof(int),
1524 .mode = 0644,
1525 .proc_handler = &nss_n2h_water_mark_core1_handler,
1526 },
1527 {
1528 .procname = "n2h_high_water_core0",
1529 .data = &nss_n2h_water_mark[NSS_CORE_0][1],
1530 .maxlen = sizeof(int),
1531 .mode = 0644,
1532 .proc_handler = &nss_n2h_water_mark_core0_handler,
1533 },
1534 {
1535 .procname = "n2h_high_water_core1",
1536 .data = &nss_n2h_water_mark[NSS_CORE_1][1],
1537 .maxlen = sizeof(int),
1538 .mode = 0644,
1539 .proc_handler = &nss_n2h_water_mark_core1_handler,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001540 },
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301541 {
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001542 .procname = "n2h_paged_low_water_core0",
1543 .data = &nss_n2h_paged_water_mark[NSS_CORE_0][0],
1544 .maxlen = sizeof(int),
1545 .mode = 0644,
1546 .proc_handler = &nss_n2h_paged_water_mark_core0_handler,
1547 },
1548 {
1549 .procname = "n2h_paged_low_water_core1",
1550 .data = &nss_n2h_paged_water_mark[NSS_CORE_1][0],
1551 .maxlen = sizeof(int),
1552 .mode = 0644,
1553 .proc_handler = &nss_n2h_paged_water_mark_core1_handler,
1554 },
1555 {
1556 .procname = "n2h_paged_high_water_core0",
1557 .data = &nss_n2h_paged_water_mark[NSS_CORE_0][1],
1558 .maxlen = sizeof(int),
1559 .mode = 0644,
1560 .proc_handler = &nss_n2h_paged_water_mark_core0_handler,
1561 },
1562 {
1563 .procname = "n2h_paged_high_water_core1",
1564 .data = &nss_n2h_paged_water_mark[NSS_CORE_1][1],
1565 .maxlen = sizeof(int),
1566 .mode = 0644,
1567 .proc_handler = &nss_n2h_paged_water_mark_core1_handler,
1568 },
1569 {
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301570 .procname = "n2h_wifi_pool_buf",
1571 .data = &nss_n2h_wifi_pool_buf_cfg,
1572 .maxlen = sizeof(int),
1573 .mode = 0644,
1574 .proc_handler = &nss_n2h_wifi_payloads_handler,
1575 },
Stephen Wang49b474b2016-03-25 10:40:30 -07001576 {
1577 .procname = "rps",
1578 .data = &nss_n2h_rps_config,
1579 .maxlen = sizeof(int),
1580 .mode = 0644,
1581 .proc_handler = &nss_n2h_rpscfg_handler,
1582 },
1583 {
1584 .procname = "mitigation_core0",
1585 .data = &nss_n2h_core0_mitigation_cfg,
1586 .maxlen = sizeof(int),
1587 .mode = 0644,
1588 .proc_handler = &nss_n2h_mitigationcfg_core0_handler,
1589 },
1590 {
1591 .procname = "mitigation_core1",
1592 .data = &nss_n2h_core1_mitigation_cfg,
1593 .maxlen = sizeof(int),
1594 .mode = 0644,
1595 .proc_handler = &nss_n2h_mitigationcfg_core1_handler,
1596 },
1597 {
1598 .procname = "extra_pbuf_core0",
1599 .data = &nss_n2h_core0_add_buf_pool_size,
1600 .maxlen = sizeof(int),
1601 .mode = 0644,
1602 .proc_handler = &nss_n2h_buf_cfg_core0_handler,
1603 },
1604 {
1605 .procname = "extra_pbuf_core1",
1606 .data = &nss_n2h_core1_add_buf_pool_size,
1607 .maxlen = sizeof(int),
1608 .mode = 0644,
1609 .proc_handler = &nss_n2h_buf_cfg_core1_handler,
1610 },
Vijay Dewangan488e5372014-12-29 21:40:11 -08001611
1612 { }
1613};
1614
Stephen Wang52e6d342016-03-29 15:02:33 -07001615static struct ctl_table nss_n2h_dir[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001616 {
1617 .procname = "n2hcfg",
1618 .mode = 0555,
1619 .child = nss_n2h_table,
1620 },
1621 { }
1622};
1623
Stephen Wang52e6d342016-03-29 15:02:33 -07001624static struct ctl_table nss_n2h_root_dir[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001625 {
1626 .procname = "nss",
1627 .mode = 0555,
1628 .child = nss_n2h_dir,
1629 },
1630 { }
1631};
1632
Stephen Wang52e6d342016-03-29 15:02:33 -07001633static struct ctl_table nss_n2h_root[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001634 {
1635 .procname = "dev",
1636 .mode = 0555,
1637 .child = nss_n2h_root_dir,
1638 },
1639 { }
1640};
1641
1642static struct ctl_table_header *nss_n2h_header;
1643
1644/*
Stephen Wang49b474b2016-03-25 10:40:30 -07001645 * nss_n2h_flush_payloads()
1646 * Sends a command down to NSS for flushing all payloads
1647 */
1648nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx)
1649{
1650 struct nss_n2h_msg nnm;
1651 struct nss_n2h_flush_payloads *nnflshpl;
1652 nss_tx_status_t nss_tx_status;
1653
1654 nnflshpl = &nnm.msg.flush_payloads;
1655
1656 /*
1657 * TODO: No additional information sent in message
1658 * as of now. Need to initialize message content accordingly
1659 * if needed.
1660 */
1661 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1662 NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS,
1663 sizeof(struct nss_n2h_flush_payloads),
1664 NULL,
1665 NULL);
1666
1667 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1668 if (nss_tx_status != NSS_TX_SUCCESS) {
1669 nss_warning("%p: failed to send flush payloads command to NSS\n",
1670 nss_ctx);
1671
1672 return NSS_TX_FAILURE;
1673 }
1674
1675 return NSS_TX_SUCCESS;
1676}
1677
1678/*
Vijay Dewangan488e5372014-12-29 21:40:11 -08001679 * nss_n2h_msg_init()
Stephen Wang49b474b2016-03-25 10:40:30 -07001680 * Initialize n2h message.
Vijay Dewangan488e5372014-12-29 21:40:11 -08001681 */
1682void nss_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type,
Vijay Dewangan634ce592015-01-07 17:21:09 -08001683 uint32_t len, nss_n2h_msg_callback_t cb, void *app_data)
Vijay Dewangan488e5372014-12-29 21:40:11 -08001684{
1685 nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data);
1686}
1687
Vijay Dewangan488e5372014-12-29 21:40:11 -08001688/*
Vijay Dewangan488e5372014-12-29 21:40:11 -08001689 * nss_n2h_tx_msg()
1690 * Send messages to NSS n2h pacakge
1691 */
1692nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm)
1693{
1694 struct nss_n2h_msg *nnm2;
1695 struct nss_cmn_msg *ncm = &nnm->cm;
1696 struct sk_buff *nbuf;
1697 nss_tx_status_t status;
1698
1699 NSS_VERIFY_CTX_MAGIC(nss_ctx);
1700 if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
1701 return NSS_TX_FAILURE_NOT_READY;
1702 }
1703
1704 /*
1705 * Sanity check the message
1706 */
1707 if (ncm->interface != NSS_N2H_INTERFACE) {
1708 nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface);
1709 return NSS_TX_FAILURE;
1710 }
1711
1712 if (ncm->type >= NSS_METADATA_TYPE_N2H_MAX) {
1713 nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type);
1714 return NSS_TX_FAILURE;
1715 }
1716
Suruchi Agarwalef8a8702016-01-08 12:40:08 -08001717 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_n2h_msg)) {
1718 nss_warning("%p: tx request for another interface: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
Vijay Dewangan488e5372014-12-29 21:40:11 -08001719 return NSS_TX_FAILURE;
1720 }
1721
Vijay Dewangan488e5372014-12-29 21:40:11 -08001722 nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE);
1723 if (unlikely(!nbuf)) {
Sundarajan Srinivasan62fee7e2015-01-22 11:13:10 -08001724 NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]);
Vijay Dewangan488e5372014-12-29 21:40:11 -08001725 return NSS_TX_FAILURE;
1726 }
1727
1728 /*
1729 * Copy the message to our skb.
1730 */
1731 nnm2 = (struct nss_n2h_msg *)skb_put(nbuf, sizeof(struct nss_n2h_msg));
1732 memcpy(nnm2, nnm, sizeof(struct nss_n2h_msg));
1733 status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0);
1734 if (status != NSS_CORE_STATUS_SUCCESS) {
1735 dev_kfree_skb_any(nbuf);
1736 nss_info("%p: unable to enqueue 'nss frequency change' - marked as stopped\n", nss_ctx);
1737 return NSS_TX_FAILURE;
1738 }
1739
Stephen Wang90c67de2016-04-26 15:15:59 -07001740 nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE);
Vijay Dewangan488e5372014-12-29 21:40:11 -08001741 NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]);
1742 return NSS_TX_SUCCESS;
1743}
1744
Vijay Dewangan488e5372014-12-29 21:40:11 -08001745/*
1746 * nss_n2h_notify_register()
1747 * Register to received N2H events.
1748 *
1749 * NOTE: Do we want to pass an nss_ctx here so that we can register for n2h on any core?
1750 */
1751struct nss_ctx_instance *nss_n2h_notify_register(int core, nss_n2h_msg_callback_t cb, void *app_data)
1752{
1753 if (core >= NSS_MAX_CORES) {
1754 nss_warning("Input core number %d is wrong \n", core);
1755 return NULL;
1756 }
1757 /*
1758 * TODO: We need to have a new array in support of the new API
1759 * TODO: If we use a per-context array, we would move the array into nss_ctx based.
1760 */
1761 nss_n2h_rd[core].n2h_callback = cb;
1762 nss_n2h_rd[core].app_data = app_data;
1763 return &nss_top_main.nss[core];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301764}
1765
1766/*
1767 * nss_n2h_register_handler()
1768 */
Thomas Wu91f4bdf2017-06-09 12:03:02 -07001769void nss_n2h_register_handler(struct nss_ctx_instance *nss_ctx)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301770{
Thomas Wu91f4bdf2017-06-09 12:03:02 -07001771 nss_core_register_handler(nss_ctx, NSS_N2H_INTERFACE, nss_n2h_interface_handler, NULL);
Stephen Wang49b474b2016-03-25 10:40:30 -07001772}
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -07001773
Stephen Wang49b474b2016-03-25 10:40:30 -07001774/*
1775 * nss_n2h_register_sysctl()
1776 */
1777void nss_n2h_register_sysctl(void)
1778{
Vijay Dewangan634ce592015-01-07 17:21:09 -08001779 /*
1780 * RPS sema init
1781 */
1782 sema_init(&nss_n2h_rcp.sem, 1);
1783 init_completion(&nss_n2h_rcp.complete);
1784
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301785 /*
1786 * MITIGATION sema init for core0
1787 */
1788 sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1);
1789 init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete);
1790
1791 /*
1792 * MITIGATION sema init for core1
1793 */
1794 sema_init(&nss_n2h_mitigationcp[NSS_CORE_1].sem, 1);
1795 init_completion(&nss_n2h_mitigationcp[NSS_CORE_1].complete);
1796
1797 /*
1798 * PBUF addition sema init for core0
1799 */
1800 sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1);
1801 init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete);
1802
1803 /*
1804 * PBUF addition sema init for core1
1805 */
1806 sema_init(&nss_n2h_bufcp[NSS_CORE_1].sem, 1);
1807 init_completion(&nss_n2h_bufcp[NSS_CORE_1].complete);
Vijay Dewangan634ce592015-01-07 17:21:09 -08001808
Stephen Wang49b474b2016-03-25 10:40:30 -07001809 /*
1810 * Core0
1811 */
1812 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1);
1813 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete);
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001814 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.pool_size =
Stephen Wang49b474b2016-03-25 10:40:30 -07001815 nss_n2h_empty_pool_buf_cfg[NSS_CORE_0];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001816 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.low_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07001817 nss_n2h_water_mark[NSS_CORE_0][0];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001818 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.high_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07001819 nss_n2h_water_mark[NSS_CORE_0][1];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001820 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.pool_size =
1821 nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0];
1822 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.low_water =
1823 nss_n2h_paged_water_mark[NSS_CORE_0][0];
1824 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.high_water =
1825 nss_n2h_paged_water_mark[NSS_CORE_0][1];
1826
Stephen Wang49b474b2016-03-25 10:40:30 -07001827
1828 /*
1829 * Core1
1830 */
1831 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_1].sem, 1);
1832 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_1].complete);
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001833 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.pool_size =
Stephen Wang49b474b2016-03-25 10:40:30 -07001834 nss_n2h_empty_pool_buf_cfg[NSS_CORE_1];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001835 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.low_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07001836 nss_n2h_water_mark[NSS_CORE_1][0];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001837 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.high_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07001838 nss_n2h_water_mark[NSS_CORE_1][1];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001839 nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.pool_size =
1840 nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1];
1841 nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.low_water =
1842 nss_n2h_paged_water_mark[NSS_CORE_1][0];
1843 nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.high_water =
1844 nss_n2h_paged_water_mark[NSS_CORE_1][1];
1845
Stephen Wang49b474b2016-03-25 10:40:30 -07001846
1847 /*
1848 * WiFi pool buf cfg sema init
1849 */
1850 sema_init(&nss_n2h_wp.sem, 1);
1851 init_completion(&nss_n2h_wp.complete);
1852
Vijay Dewangan488e5372014-12-29 21:40:11 -08001853 nss_n2h_notify_register(NSS_CORE_0, NULL, NULL);
1854 nss_n2h_notify_register(NSS_CORE_1, NULL, NULL);
1855
Stephen Wang49b474b2016-03-25 10:40:30 -07001856 /*
1857 * Register sysctl table.
1858 */
1859 nss_n2h_header = register_sysctl_table(nss_n2h_root);
1860}
1861
1862/*
1863 * nss_n2h_unregister_sysctl()
1864 * Unregister sysctl specific to n2h
1865 */
1866void nss_n2h_unregister_sysctl(void)
1867{
1868 /*
1869 * Unregister sysctl table.
1870 */
1871 if (nss_n2h_header) {
1872 unregister_sysctl_table(nss_n2h_header);
1873 }
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301874}
Vijay Dewangan488e5372014-12-29 21:40:11 -08001875
1876EXPORT_SYMBOL(nss_n2h_notify_register);