blob: ff31b0468cff63b8bfd5ffda67a08ecaee868aef [file] [log] [blame]
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301/*
2 **************************************************************************
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05303 * Copyright (c) 2013-2016, 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};
30int nss_n2h_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} };
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053031int nss_n2h_wifi_pool_buf_cfg __read_mostly = -1;
Stephen Wang49b474b2016-03-25 10:40:30 -070032int nss_n2h_rps_config __read_mostly;
33int nss_n2h_core0_mitigation_cfg __read_mostly = 1;
34int nss_n2h_core1_mitigation_cfg __read_mostly = 1;
35int nss_n2h_core0_add_buf_pool_size __read_mostly;
36int nss_n2h_core1_add_buf_pool_size __read_mostly;
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053037
Vijay Dewangan488e5372014-12-29 21:40:11 -080038struct nss_n2h_registered_data {
39 nss_n2h_msg_callback_t n2h_callback;
40 void *app_data;
41};
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053042
Vijay Dewangan488e5372014-12-29 21:40:11 -080043static struct nss_n2h_cfg_pvt nss_n2h_nepbcfgp[NSS_MAX_CORES];
44static struct nss_n2h_registered_data nss_n2h_rd[NSS_MAX_CORES];
Vijay Dewangan634ce592015-01-07 17:21:09 -080045static struct nss_n2h_cfg_pvt nss_n2h_rcp;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +053046static struct nss_n2h_cfg_pvt nss_n2h_mitigationcp[NSS_CORE_MAX];
47static struct nss_n2h_cfg_pvt nss_n2h_bufcp[NSS_CORE_MAX];
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053048static struct nss_n2h_cfg_pvt nss_n2h_wp;
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053049
50/*
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -070051 * nss_n2h_stats_sync()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053052 * Handle the syncing of NSS statistics.
53 */
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -070054static void nss_n2h_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_n2h_stats_sync *nnss)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053055{
56 struct nss_top_instance *nss_top = nss_ctx->nss_top;
57
58 spin_lock_bh(&nss_top->stats_lock);
59
60 /*
61 * common node stats
62 */
63 nss_ctx->stats_n2h[NSS_STATS_NODE_RX_PKTS] += nnss->node_stats.rx_packets;
64 nss_ctx->stats_n2h[NSS_STATS_NODE_RX_BYTES] += nnss->node_stats.rx_bytes;
65 nss_ctx->stats_n2h[NSS_STATS_NODE_RX_DROPPED] += nnss->node_stats.rx_dropped;
66 nss_ctx->stats_n2h[NSS_STATS_NODE_TX_PKTS] += nnss->node_stats.tx_packets;
67 nss_ctx->stats_n2h[NSS_STATS_NODE_TX_BYTES] += nnss->node_stats.tx_bytes;
68
69 /*
70 * General N2H stats
71 */
Murat Sezgin0c0561d2014-04-09 18:55:58 -070072 nss_ctx->stats_n2h[NSS_STATS_N2H_QUEUE_DROPPED] += nnss->queue_dropped;
73 nss_ctx->stats_n2h[NSS_STATS_N2H_TOTAL_TICKS] += nnss->total_ticks;
74 nss_ctx->stats_n2h[NSS_STATS_N2H_WORST_CASE_TICKS] += nnss->worst_case_ticks;
75 nss_ctx->stats_n2h[NSS_STATS_N2H_ITERATIONS] += nnss->iterations;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053076
77 /*
Thomas Wu3fd8dd72014-06-11 15:57:05 -070078 * pbuf manager ocm and default pool stats
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053079 */
Thomas Wu3fd8dd72014-06-11 15:57:05 -070080 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_ALLOC_FAILS] += nnss->pbuf_ocm_stats.pbuf_alloc_fails;
81 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_FREE_COUNT] = nnss->pbuf_ocm_stats.pbuf_free_count;
82 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_OCM_TOTAL_COUNT] = nnss->pbuf_ocm_stats.pbuf_total_count;
83
84 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_ALLOC_FAILS] += nnss->pbuf_default_stats.pbuf_alloc_fails;
85 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_FREE_COUNT] = nnss->pbuf_default_stats.pbuf_free_count;
86 nss_ctx->stats_n2h[NSS_STATS_N2H_PBUF_DEFAULT_TOTAL_COUNT] = nnss->pbuf_default_stats.pbuf_total_count;
87
88 /*
89 * payload mgr stats
90 */
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053091 nss_ctx->stats_n2h[NSS_STATS_N2H_PAYLOAD_ALLOC_FAILS] += nnss->payload_alloc_fails;
Thomas Wu53679842015-01-22 13:37:35 -080092 nss_ctx->stats_n2h[NSS_STATS_N2H_PAYLOAD_FREE_COUNT] = nnss->payload_free_count;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053093
Sakthi Vignesh Radhakrishnan2a8ee962014-11-22 13:35:38 -080094 /*
95 * Host <=> NSS control traffic stats
96 */
97 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_CONTROL_PACKETS] += nnss->h2n_ctrl_pkts;
98 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_CONTROL_BYTES] += nnss->h2n_ctrl_bytes;
99 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_CONTROL_PACKETS] += nnss->n2h_ctrl_pkts;
100 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_CONTROL_BYTES] += nnss->n2h_ctrl_bytes;
101
102 /*
103 * Host <=> NSS control data traffic stats
104 */
105 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_DATA_PACKETS] += nnss->h2n_data_pkts;
106 nss_ctx->stats_n2h[NSS_STATS_N2H_H2N_DATA_BYTES] += nnss->h2n_data_bytes;
107 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_DATA_PACKETS] += nnss->n2h_data_pkts;
108 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_DATA_BYTES] += nnss->n2h_data_bytes;
109
Saurabh Misra71034db2015-06-04 16:18:38 -0700110 /*
111 * Payloads related stats
112 */
113 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_TOT_PAYLOADS] = nnss->tot_payloads;
114
Guojun Jin85dfa7b2015-09-02 15:13:56 -0700115 nss_ctx->stats_n2h[NSS_STATS_N2H_N2H_INTERFACE_INVALID] += nnss->data_interface_invalid;
116
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530117 spin_unlock_bh(&nss_top->stats_lock);
118}
119
120/*
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700121 * nss_n2h_interface_handler()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530122 * Handle NSS -> HLOS messages for N2H node
123 */
Vijay Dewangan634ce592015-01-07 17:21:09 -0800124static void nss_n2h_interface_handler(struct nss_ctx_instance *nss_ctx,
125 struct nss_cmn_msg *ncm,
126 __attribute__((unused))void *app_data)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530127{
128 struct nss_n2h_msg *nnm = (struct nss_n2h_msg *)ncm;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800129 nss_n2h_msg_callback_t cb;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530130
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700131 BUG_ON(ncm->interface != NSS_N2H_INTERFACE);
132
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530133 /*
134 * Is this a valid request/response packet?
135 */
136 if (nnm->cm.type >= NSS_METADATA_TYPE_N2H_MAX) {
137 nss_warning("%p: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type);
138 return;
139 }
140
141 switch (nnm->cm.type) {
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530142 case NSS_TX_METADATA_TYPE_N2H_RPS_CFG:
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530143 nss_info("NSS N2H rps_en %d \n",nnm->msg.rps_cfg.enable);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800144 break;
145
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530146 case NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG:
147 nss_info("NSS N2H mitigation_dis %d \n",nnm->msg.mitigation_cfg.enable);
148 break;
149
Vijay Dewangan488e5372014-12-29 21:40:11 -0800150 case NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG:
151 nss_info("%p: empty pool buf cfg response from FW", nss_ctx);
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530152 break;
153
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +0530154 case NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS:
155 nss_info("%p: flush payloads cmd response from FW", nss_ctx);
156 break;
157
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530158 case NSS_RX_METADATA_TYPE_N2H_STATS_SYNC:
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700159 nss_n2h_stats_sync(nss_ctx, &nnm->msg.stats_sync);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530160 break;
161
162 default:
163 if (ncm->response != NSS_CMN_RESPONSE_ACK) {
164 /*
165 * Check response
166 */
167 nss_info("%p: Received response %d for type %d, interface %d",
168 nss_ctx, ncm->response, ncm->type, ncm->interface);
169 }
170 }
Vijay Dewangan488e5372014-12-29 21:40:11 -0800171
172 /*
Stephen Wang49b474b2016-03-25 10:40:30 -0700173 * Update the callback and app_data for NOTIFY messages, n2h sends all notify messages
Vijay Dewangan488e5372014-12-29 21:40:11 -0800174 * to the same callback/app_data.
175 */
176 if (nnm->cm.response == NSS_CMM_RESPONSE_NOTIFY) {
177 /*
178 * Place holder for the user to create right call
179 * back and app data when response is NSS_CMM_RESPONSE_NOTIFY
180 */
181 ncm->cb = (uint32_t)nss_n2h_rd[nss_ctx->id].n2h_callback;
182 ncm->app_data = (uint32_t)nss_n2h_rd[nss_ctx->id].app_data;
183 }
184
185 /*
186 * Do we have a callback?
187 */
188 if (!ncm->cb) {
189 return;
190 }
191
192 /*
193 * Callback
194 */
195 cb = (nss_n2h_msg_callback_t)ncm->cb;
196 cb((void *)ncm->app_data, nnm);
197}
198
199/*
Vijay Dewangan634ce592015-01-07 17:21:09 -0800200 * nss_n2h_rps_cfg_callback()
201 * call back function for rps configuration
202 */
203static void nss_n2h_rps_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
204{
205 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)app_data;
206 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
207
208 /*
209 * Error, hence we are not updating the nss_n2h_empty_pool_buf
210 * Restore the current_value to its previous state
211 */
212 nss_n2h_rcp.response = NSS_FAILURE;
213 complete(&nss_n2h_rcp.complete);
214 nss_warning("%p: RPS configuration failed : %d\n", nss_ctx,
215 nnm->cm.error);
216 return;
217 }
218
219 nss_info("%p: RPS configuration succeeded: %d\n", nss_ctx,
220 nnm->cm.error);
221 nss_ctx->n2h_rps_en = nnm->msg.rps_cfg.enable;
222 nss_n2h_rcp.response = NSS_SUCCESS;
223 complete(&nss_n2h_rcp.complete);
224}
225
226/*
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530227 * nss_n2h_mitigation_cfg_callback()
228 * call back function for mitigation configuration
229 */
230static void nss_n2h_mitigation_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
231{
232 int core_num = (int)app_data;
233 struct nss_top_instance *nss_top = &nss_top_main;
234 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
235
236 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
237
238 /*
239 * Error, hence we are not updating the nss_n2h_mitigate_en
240 */
241 nss_n2h_mitigationcp[core_num].response = NSS_FAILURE;
242 complete(&nss_n2h_mitigationcp[core_num].complete);
243 nss_warning("core%d: MITIGATION configuration failed : %d\n", core_num, nnm->cm.error);
244 return;
245 }
246
247 nss_info("core%d: MITIGATION configuration succeeded: %d\n", core_num, nnm->cm.error);
248
249 nss_ctx->n2h_mitigate_en = nnm->msg.mitigation_cfg.enable;
250 nss_n2h_mitigationcp[core_num].response = NSS_SUCCESS;
251 complete(&nss_n2h_mitigationcp[core_num].complete);
252}
253
254/*
255 * nss_n2h_buf_cfg_callback()
256 * call back function for pbuf configuration
257 */
258static void nss_n2h_bufs_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
259{
260 int core_num = (int)app_data;
261 unsigned int allocated_sz;
262
263 struct nss_top_instance *nss_top = &nss_top_main;
264 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
265
266 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
267 nss_n2h_bufcp[core_num].response = NSS_FAILURE;
268 nss_warning("core%d: buf configuration failed : %d\n", core_num, nnm->cm.error);
269 goto done;
270 }
271
272 nss_info("core%d: buf configuration succeeded: %d\n", core_num, nnm->cm.error);
273
274 allocated_sz = nnm->msg.buf_pool.nss_buf_page_size * nnm->msg.buf_pool.nss_buf_num_pages;
275 nss_ctx->buf_sz_allocated += allocated_sz;
276
277 nss_n2h_bufcp[core_num].response = NSS_SUCCESS;
278
279done:
280 complete(&nss_n2h_bufcp[core_num].complete);
281}
282
283/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700284 * nss_n2h_payload_stats_callback()
285 * It gets called response to payload accounting.
Vijay Dewangan488e5372014-12-29 21:40:11 -0800286 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700287static void nss_n2h_payload_stats_callback(void *app_data,
288 struct nss_n2h_msg *nnm)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800289{
290 int core_num = (int)app_data;
Saurabh Misra71034db2015-06-04 16:18:38 -0700291
Vijay Dewangan488e5372014-12-29 21:40:11 -0800292 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
293 struct nss_n2h_empty_pool_buf *nnepbcm;
294 nnepbcm = &nnm->msg.empty_pool_buf_cfg;
295
Saurabh Misra71034db2015-06-04 16:18:38 -0700296 nss_warning("%d: core empty pool buf set failure: %d\n",
297 core_num, nnm->cm.error);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800298 nss_n2h_nepbcfgp[core_num].response = NSS_FAILURE;
299 complete(&nss_n2h_nepbcfgp[core_num].complete);
300 return;
301 }
302
Saurabh Misra71034db2015-06-04 16:18:38 -0700303 if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_PAYLOAD_INFO) {
304 nss_n2h_nepbcfgp[core_num].empty_buf_pool =
305 ntohl(nnm->msg.payload_info.pool_size);
306 nss_n2h_nepbcfgp[core_num].low_water =
307 ntohl(nnm->msg.payload_info.low_water);
308 nss_n2h_nepbcfgp[core_num].high_water =
309 ntohl(nnm->msg.payload_info.high_water);
310 }
311
Vijay Dewangan488e5372014-12-29 21:40:11 -0800312 nss_n2h_nepbcfgp[core_num].response = NSS_SUCCESS;
313 complete(&nss_n2h_nepbcfgp[core_num].complete);
314}
315
316/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530317 * nss_n2h_set_wifi_payloads_callback()
318 * call back function for response to wifi pool configuration
319 *
320 */
321static void nss_n2h_set_wifi_payloads_callback(void *app_data,
322 struct nss_n2h_msg *nnm)
323{
324 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)app_data;
325 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
326
327 nss_n2h_wp.response = NSS_FAILURE;
328 complete(&nss_n2h_wp.complete);
329 nss_warning("%p: wifi pool configuration failed : %d\n", nss_ctx,
330 nnm->cm.error);
331 return;
332 }
333
334 nss_info("%p: wifi payload configuration succeeded: %d\n", nss_ctx,
335 nnm->cm.error);
336 nss_n2h_wp.response = NSS_SUCCESS;
337 complete(&nss_n2h_wp.complete);
338}
339
340/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700341 * nss_n2h_get_payload_info()
342 * Gets Payload information
Vijay Dewangan488e5372014-12-29 21:40:11 -0800343 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700344static int nss_n2h_get_payload_info(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700345 void __user *buffer, size_t *lenp, loff_t *ppos,
346 int core_num)
347{
348 struct nss_top_instance *nss_top = &nss_top_main;
349 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
350 struct nss_n2h_msg nnm;
351 struct nss_n2h_payload_info *nnepbcm;
352 nss_tx_status_t nss_tx_status;
353 int ret = NSS_FAILURE;
354
355 /*
356 * Note that semaphore should be already held.
357 */
358
359 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
360 NSS_TX_METADATA_TYPE_GET_PAYLOAD_INFO,
361 sizeof(struct nss_n2h_payload_info),
362 nss_n2h_payload_stats_callback,
363 (void *)core_num);
364
365 nnepbcm = &nnm.msg.payload_info;
366 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
367
368 if (nss_tx_status != NSS_TX_SUCCESS) {
369 nss_warning("%p: core %d nss_tx error errorn",
370 nss_ctx, core_num);
371 return NSS_FAILURE;
372 }
373
374 /*
375 * Blocking call, wait till we get ACK for this msg.
376 */
377 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
378 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
379 if (ret == 0) {
380 nss_warning("%p: core %d waiting for ack timed out\n", nss_ctx,
381 core_num);
382 return NSS_FAILURE;
383 }
384
385 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
386 nss_warning("%p: core %d response returned failure\n", nss_ctx,
387 core_num);
388 return NSS_FAILURE;
389 }
390
391 return NSS_SUCCESS;
392}
393
394/*
395 * nss_n2h_set_empty_pool_buf()
396 * Sets empty pool buffer
397 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700398static int nss_n2h_set_empty_pool_buf(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700399 void __user *buffer,
400 size_t *lenp, loff_t *ppos,
401 int core_num, int *new_val)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800402{
403 struct nss_top_instance *nss_top = &nss_top_main;
404 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
405 struct nss_n2h_msg nnm;
406 struct nss_n2h_empty_pool_buf *nnepbcm;
407 nss_tx_status_t nss_tx_status;
408 int ret = NSS_FAILURE;
409
410 /*
411 * Acquiring semaphore
412 */
413 down(&nss_n2h_nepbcfgp[core_num].sem);
414
415 /*
416 * Take snap shot of current value
417 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700418 nss_n2h_nepbcfgp[core_num].empty_buf_pool = *new_val;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800419
Saurabh Misra71034db2015-06-04 16:18:38 -0700420 if (!write) {
421 ret = nss_n2h_get_payload_info(ctl, write, buffer, lenp, ppos,
422 core_num);
423 *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool;
424 if (ret == NSS_FAILURE) {
425 up(&nss_n2h_nepbcfgp[core_num].sem);
426 return -EBUSY;
427 }
428
429 up(&nss_n2h_nepbcfgp[core_num].sem);
430
431 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
432 return ret;
433 }
434
Vijay Dewangan488e5372014-12-29 21:40:11 -0800435 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
Saurabh Misra71034db2015-06-04 16:18:38 -0700436 if (ret) {
Vijay Dewangan488e5372014-12-29 21:40:11 -0800437 up(&nss_n2h_nepbcfgp[core_num].sem);
438 return ret;
439 }
440
Vijay Dewangan488e5372014-12-29 21:40:11 -0800441 if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700442 nss_warning("%p: core %d setting %d < min number of buffer",
Vijay Dewangan488e5372014-12-29 21:40:11 -0800443 nss_ctx, core_num, *new_val);
Stephen Wang06761022015-03-03 16:38:42 -0800444 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800445 }
446
447 nss_info("%p: core %d number of empty pool buffer is : %d\n",
448 nss_ctx, core_num, *new_val);
449
450 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
451 NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG,
452 sizeof(struct nss_n2h_empty_pool_buf),
Saurabh Misra71034db2015-06-04 16:18:38 -0700453 nss_n2h_payload_stats_callback,
Vijay Dewangan488e5372014-12-29 21:40:11 -0800454 (void *)core_num);
455
456 nnepbcm = &nnm.msg.empty_pool_buf_cfg;
457 nnepbcm->pool_size = htonl(*new_val);
458 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
459
460 if (nss_tx_status != NSS_TX_SUCCESS) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700461 nss_warning("%p: core %d nss_tx error empty pool buffer: %d\n",
Vijay Dewangan488e5372014-12-29 21:40:11 -0800462 nss_ctx, core_num, *new_val);
Stephen Wang06761022015-03-03 16:38:42 -0800463 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800464 }
465
466 /*
467 * Blocking call, wait till we get ACK for this msg.
468 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700469 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
470 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
Vijay Dewangan488e5372014-12-29 21:40:11 -0800471 if (ret == 0) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700472 nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx,
473 core_num);
Stephen Wang06761022015-03-03 16:38:42 -0800474 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800475 }
476
477 /*
478 * ACK/NACK received from NSS FW
479 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
480 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
481 */
482 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
Stephen Wang06761022015-03-03 16:38:42 -0800483 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800484 }
485
486 up(&nss_n2h_nepbcfgp[core_num].sem);
Thomas Wu651b3902015-05-12 11:21:09 -0700487 return 0;
Stephen Wang06761022015-03-03 16:38:42 -0800488
489failure:
490 /*
491 * Restore the current_value to its previous state
492 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700493 *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool;
494 up(&nss_n2h_nepbcfgp[core_num].sem);
495 return NSS_FAILURE;
496}
497
498/*
499 * nss_n2h_set_water_mark()
500 * Sets water mark for N2H SOS
501 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700502static int nss_n2h_set_water_mark(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700503 void __user *buffer,
504 size_t *lenp, loff_t *ppos,
505 int core_num, int *low, int *high)
506{
507 struct nss_top_instance *nss_top = &nss_top_main;
508 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
509 struct nss_n2h_msg nnm;
510 struct nss_n2h_water_mark *wm;
511 nss_tx_status_t nss_tx_status;
512 int ret = NSS_FAILURE;
513
514 /*
515 * Acquiring semaphore
516 */
517 down(&nss_n2h_nepbcfgp[core_num].sem);
518
519 /*
520 * Take snap shot of current value
521 */
522 nss_n2h_nepbcfgp[core_num].low_water = *low;
523 nss_n2h_nepbcfgp[core_num].high_water = *high;
524
525 if (!write) {
526 ret = nss_n2h_get_payload_info(ctl, write, buffer, lenp, ppos,
527 core_num);
528 *low = nss_n2h_nepbcfgp[core_num].low_water;
529 *high = nss_n2h_nepbcfgp[core_num].high_water;
530
531 if (ret == NSS_FAILURE) {
532 up(&nss_n2h_nepbcfgp[core_num].sem);
533 return -EBUSY;
534 }
535
536 up(&nss_n2h_nepbcfgp[core_num].sem);
537 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
538 return ret;
539 }
540
541 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
542 if (ret) {
543 up(&nss_n2h_nepbcfgp[core_num].sem);
544 return ret;
545 }
546
547 /*
548 * If either low or high water mark is not set then we do
549 * nothing.
550 */
551 if (*low == -1 || *high == -1)
552 goto failure;
553
554 if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) ||
555 (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
556 nss_warning("%p: core %d setting %d, %d < min number of buffer",
557 nss_ctx, core_num, *low, *high);
558 goto failure;
559 }
560
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530561 if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) ||
562 (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700563 nss_warning("%p: core %d setting %d, %d is > upper limit",
564 nss_ctx, core_num, *low, *high);
565 goto failure;
566 }
567
568 if (*low > *high) {
569 nss_warning("%p: core %d setting low %d is more than high %d",
570 nss_ctx, core_num, *low, *high);
571 goto failure;
572 }
573
574 nss_info("%p: core %d number of low : %d and high : %d\n",
575 nss_ctx, core_num, *low, *high);
576
577 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
578 NSS_TX_METADATA_TYPE_SET_WATER_MARK,
579 sizeof(struct nss_n2h_water_mark),
580 nss_n2h_payload_stats_callback,
581 (void *)core_num);
582
583 wm = &nnm.msg.wm;
584 wm->low_water = htonl(*low);
585 wm->high_water = htonl(*high);
586 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
587
588 if (nss_tx_status != NSS_TX_SUCCESS) {
589 nss_warning("%p: core %d nss_tx error setting : %d, %d\n",
590 nss_ctx, core_num, *low, *high);
591 goto failure;
592 }
593
594 /*
595 * Blocking call, wait till we get ACK for this msg.
596 */
597 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
598 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
599 if (ret == 0) {
600 nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx,
601 core_num);
602 goto failure;
603 }
604
605 /*
606 * ACK/NACK received from NSS FW
607 */
608 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response)
609 goto failure;
610
611 up(&nss_n2h_nepbcfgp[core_num].sem);
612 return NSS_SUCCESS;
613
614failure:
615 /*
616 * Restore the current_value to its previous state
617 */
618 *low = nss_n2h_nepbcfgp[core_num].low_water;
619 *high = nss_n2h_nepbcfgp[core_num].high_water;
Stephen Wang06761022015-03-03 16:38:42 -0800620 up(&nss_n2h_nepbcfgp[core_num].sem);
Thomas Wu651b3902015-05-12 11:21:09 -0700621 return -EINVAL;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800622}
623
624/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530625 * nss_n2h_cfg_wifi_pool()
626 * Sets number of wifi payloads to adjust high water mark for N2H SoS
627 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700628static int nss_n2h_cfg_wifi_pool(struct ctl_table *ctl, int write,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530629 void __user *buffer,
630 size_t *lenp, loff_t *ppos,
631 int *payloads)
632{
633 struct nss_top_instance *nss_top = &nss_top_main;
634 struct nss_ctx_instance *nss_ctx = &nss_top->nss[0];
635 struct nss_n2h_msg nnm;
636 struct nss_n2h_wifi_payloads *wp;
637 nss_tx_status_t nss_tx_status;
638 int ret = NSS_FAILURE;
639
640 /*
641 * Acquiring semaphore
642 */
643 down(&nss_n2h_wp.sem);
644
645 if (!write) {
646 *payloads = nss_n2h_wp.wifi_pool;
647
648 up(&nss_n2h_wp.sem);
649 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
650 return ret;
651 }
652
653 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
654 if (ret) {
655 up(&nss_n2h_wp.sem);
656 return ret;
657 }
658
659 /*
660 * If payloads parameter is not set, we do
661 * nothing.
662 */
663 if (*payloads == -1)
664 goto failure;
665
666 if ((*payloads < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
667 nss_warning("%p: wifi setting %d < min number of buffer",
668 nss_ctx, *payloads);
669 goto failure;
670 }
671
672 if ((*payloads > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
673 nss_warning("%p: wifi setting %d > max number of buffer",
674 nss_ctx, *payloads);
675 goto failure;
676 }
677
678 nss_info("%p: wifi payloads : %d\n",
679 nss_ctx, *payloads);
680
681 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
682 NSS_TX_METADATA_TYPE_N2H_WIFI_POOL_BUF_CFG,
683 sizeof(struct nss_n2h_wifi_payloads),
684 nss_n2h_set_wifi_payloads_callback,
685 (void *)nss_ctx);
686
687 wp = &nnm.msg.wp;
688 wp->payloads = htonl(*payloads);
689 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
690
691 if (nss_tx_status != NSS_TX_SUCCESS) {
692 nss_warning("%p: wifi setting %d nss_tx error",
693 nss_ctx, *payloads);
694 goto failure;
695 }
696
697 /*
698 * Blocking call, wait till we get ACK for this msg.
699 */
700 ret = wait_for_completion_timeout(&nss_n2h_wp.complete,
701 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
702 if (ret == 0) {
703 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
704 goto failure;
705 }
706
707 /*
708 * ACK/NACK received from NSS FW
709 */
710 if (NSS_FAILURE == nss_n2h_wp.response)
711 goto failure;
712
713 up(&nss_n2h_wp.sem);
714 return NSS_SUCCESS;
715
716failure:
717 up(&nss_n2h_wp.sem);
718 return -EINVAL;
719}
720
721/*
Vijay Dewangan488e5372014-12-29 21:40:11 -0800722 * nss_n2h_empty_pool_buf_core1_handler()
723 * Sets the number of empty buffer for core 1
724 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700725static int nss_n2h_empty_pool_buf_cfg_core1_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700726 int write, void __user *buffer,
727 size_t *lenp, loff_t *ppos)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800728{
729 return nss_n2h_set_empty_pool_buf(ctl, write, buffer, lenp, ppos,
Saurabh Misra71034db2015-06-04 16:18:38 -0700730 NSS_CORE_1, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800731}
732
733/*
734 * nss_n2h_empty_pool_buf_core0_handler()
735 * Sets the number of empty buffer for core 0
736 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700737static int nss_n2h_empty_pool_buf_cfg_core0_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700738 int write, void __user *buffer,
739 size_t *lenp, loff_t *ppos)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800740{
741 return nss_n2h_set_empty_pool_buf(ctl, write, buffer, lenp, ppos,
Saurabh Misra71034db2015-06-04 16:18:38 -0700742 NSS_CORE_0, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]);
743}
744
745/*
746 * nss_n2h_water_mark_core1_handler()
747 * Sets water mark for core 1
748 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700749static int nss_n2h_water_mark_core1_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700750 int write, void __user *buffer,
751 size_t *lenp, loff_t *ppos)
752{
753 return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos,
754 NSS_CORE_1, &nss_n2h_water_mark[NSS_CORE_1][0],
755 &nss_n2h_water_mark[NSS_CORE_1][1]);
756}
757
758/*
759 * nss_n2h_water_mark_core0_handler()
760 * Sets water mark for core 0
761 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700762static int nss_n2h_water_mark_core0_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700763 int write, void __user *buffer,
764 size_t *lenp, loff_t *ppos)
765{
766 return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos,
767 NSS_CORE_0, &nss_n2h_water_mark[NSS_CORE_0][0],
768 &nss_n2h_water_mark[NSS_CORE_0][1]);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800769}
770
Vijay Dewangan634ce592015-01-07 17:21:09 -0800771/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530772 * nss_n2h_wifi_payloads_handler()
773 * Sets number of wifi payloads
774 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700775static int nss_n2h_wifi_payloads_handler(struct ctl_table *ctl,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530776 int write, void __user *buffer,
777 size_t *lenp, loff_t *ppos)
778{
779 return nss_n2h_cfg_wifi_pool(ctl, write, buffer, lenp, ppos,
780 &nss_n2h_wifi_pool_buf_cfg);
781}
782
783/*
Vijay Dewangan634ce592015-01-07 17:21:09 -0800784 * nss_n2h_rps_cfg()
785 * Send Message to NSS to enable RPS.
786 */
Stephen Wang49b474b2016-03-25 10:40:30 -0700787static nss_tx_status_t nss_n2h_rps_cfg(struct nss_ctx_instance *nss_ctx, int enable_rps)
Vijay Dewangan634ce592015-01-07 17:21:09 -0800788{
789 struct nss_n2h_msg nnm;
790 struct nss_n2h_rps *rps_cfg;
791 nss_tx_status_t nss_tx_status;
792 int ret;
793
794 down(&nss_n2h_rcp.sem);
795 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_RPS_CFG,
796 sizeof(struct nss_n2h_rps),
797 nss_n2h_rps_cfg_callback,
798 (void *)nss_ctx);
799
800 rps_cfg = &nnm.msg.rps_cfg;
801 rps_cfg->enable = enable_rps;
802
803 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
804
805 if (nss_tx_status != NSS_TX_SUCCESS) {
806 nss_warning("%p: nss_tx error setting rps\n", nss_ctx);
807
808 up(&nss_n2h_rcp.sem);
809 return NSS_FAILURE;
810 }
811
812 /*
813 * Blocking call, wait till we get ACK for this msg.
814 */
815 ret = wait_for_completion_timeout(&nss_n2h_rcp.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
816 if (ret == 0) {
817 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
818 up(&nss_n2h_rcp.sem);
819 return NSS_FAILURE;
820 }
821
822 /*
823 * ACK/NACK received from NSS FW
824 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
825 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
826 */
827 if (NSS_FAILURE == nss_n2h_rcp.response) {
828 up(&nss_n2h_rcp.sem);
829 return NSS_FAILURE;
830 }
831
832 up(&nss_n2h_rcp.sem);
833 return NSS_SUCCESS;
834}
835
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530836/*
837 * nss_n2h_mitigation_cfg()
838 * Send Message to NSS to disable MITIGATION.
839 */
Stephen Wang49b474b2016-03-25 10:40:30 -0700840static 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 +0530841{
842 struct nss_n2h_msg nnm;
843 struct nss_n2h_mitigation *mitigation_cfg;
844 nss_tx_status_t nss_tx_status;
845 int ret;
846
847 nss_assert(core_num < NSS_CORE_MAX);
848
849 down(&nss_n2h_mitigationcp[core_num].sem);
850 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG,
851 sizeof(struct nss_n2h_mitigation),
852 nss_n2h_mitigation_cfg_callback,
853 (void *)core_num);
854
855 mitigation_cfg = &nnm.msg.mitigation_cfg;
856 mitigation_cfg->enable = enable_mitigation;
857
858 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
859
860 if (nss_tx_status != NSS_TX_SUCCESS) {
861 nss_warning("%p: nss_tx error setting mitigation\n", nss_ctx);
862 goto failure;
863 }
864
865 /*
866 * Blocking call, wait till we get ACK for this msg.
867 */
868 ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
869 if (ret == 0) {
870 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
871 goto failure;
872 }
873
874 /*
875 * ACK/NACK received from NSS FW
876 */
877 if (NSS_FAILURE == nss_n2h_mitigationcp[core_num].response) {
878 goto failure;
879 }
880
881 up(&nss_n2h_mitigationcp[core_num].sem);
882 return NSS_SUCCESS;
883
884failure:
885 up(&nss_n2h_mitigationcp[core_num].sem);
886 return NSS_FAILURE;
887}
888
889static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool)
890{
891 int page_count;
892 for (page_count = 0; page_count < buf_pool->nss_buf_num_pages; page_count++) {
893 kfree(buf_pool->nss_buf_pool_vaddr[page_count]);
894 }
895}
896
897/*
898 * nss_n2h_buf_cfg()
899 * Send Message to NSS to enable pbufs.
900 */
Stephen Wang49b474b2016-03-25 10:40:30 -0700901static nss_tx_status_t nss_n2h_buf_pool_cfg(struct nss_ctx_instance *nss_ctx,
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530902 int buf_pool_size, nss_core_id_t core_num)
903{
904 static struct nss_n2h_msg nnm;
905 struct nss_n2h_buf_pool *buf_pool;
906 nss_tx_status_t nss_tx_status;
907 int ret;
908 int page_count;
909 int num_pages = ALIGN(buf_pool_size, PAGE_SIZE)/PAGE_SIZE;
910
911 nss_assert(core_num < NSS_CORE_MAX);
912
913 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_METADATA_TYPE_N2H_ADD_BUF_POOL,
914 sizeof(struct nss_n2h_buf_pool),
915 nss_n2h_bufs_cfg_callback,
916 (void *)core_num);
917
918 do {
919
920 down(&nss_n2h_bufcp[core_num].sem);
921
922 buf_pool = &nnm.msg.buf_pool;
923 buf_pool->nss_buf_page_size = PAGE_SIZE;
924
925 for (page_count = 0; page_count < MAX_PAGES_PER_MSG && num_pages; page_count++, num_pages--) {
926
927 void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC);
928 if (!kern_addr) {
929 BUG_ON(!page_count);
930 break;
931 }
932 BUG_ON((long unsigned int)kern_addr % PAGE_SIZE);
933
934 buf_pool->nss_buf_pool_vaddr[page_count] = kern_addr;
935 buf_pool->nss_buf_pool_addr[page_count] = dma_map_single(NULL, kern_addr, PAGE_SIZE, DMA_TO_DEVICE);
936 }
937
938 buf_pool->nss_buf_num_pages = page_count;
939 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
940 if (nss_tx_status != NSS_TX_SUCCESS) {
941
942 nss_n2h_buf_pool_free(buf_pool);
943 nss_warning("%p: nss_tx error setting pbuf\n", nss_ctx);
944 goto failure;
945 }
946
947 /*
948 * Blocking call, wait till we get ACK for this msg.
949 */
950 ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
951 if (ret == 0) {
952 nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
953 goto failure;
954 }
955
956 /*
957 * ACK/NACK received from NSS FW
958 */
959 if (NSS_FAILURE == nss_n2h_bufcp[core_num].response) {
960
961 nss_n2h_buf_pool_free(buf_pool);
962 goto failure;
963 }
964
965 up(&nss_n2h_bufcp[core_num].sem);
966 } while(num_pages);
967
968 return NSS_SUCCESS;
969failure:
970 up(&nss_n2h_bufcp[core_num].sem);
971 return NSS_FAILURE;
972}
973
Stephen Wang49b474b2016-03-25 10:40:30 -0700974/*
975 * nss_rps_handler()
976 * Enable NSS RPS
977 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700978static 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 -0700979{
980 struct nss_top_instance *nss_top = &nss_top_main;
981 struct nss_ctx_instance *nss_ctx = &nss_top->nss[0];
982 int ret;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530983
Stephen Wang49b474b2016-03-25 10:40:30 -0700984 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
985 if (!ret) {
986 if ((write) && (nss_n2h_rps_config == 1)) {
987 printk(KERN_INFO "Enabling NSS RPS\n");
988
989 return nss_n2h_rps_cfg(nss_ctx, 1);
990 }
991
992 if ((write) && (nss_n2h_rps_config == 0)) {
993 printk(KERN_INFO "Runtime disabling of NSS RPS not supported\n");
994 return ret;
995 }
996
997 if (write) {
998 printk(KERN_INFO "Invalid input value.Valid values are 0 and 1\n");
999 }
1000
1001 }
1002
1003 return ret;
1004}
1005
1006/*
1007 * nss_mitigation_handler()
1008 * Enable NSS MITIGATION
1009 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001010static 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 -07001011{
1012 struct nss_top_instance *nss_top = &nss_top_main;
1013 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0];
1014 int ret;
1015
1016 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1017 if (ret) {
1018 return ret;
1019 }
1020
1021 /*
1022 * It's a read operation
1023 */
1024 if (!write) {
1025 return ret;
1026 }
1027
1028 if (!nss_n2h_core0_mitigation_cfg) {
1029 printk(KERN_INFO "Disabling NSS MITIGATION\n");
1030 nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_0);
1031 return 0;
1032 }
1033 printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n");
1034 return -EINVAL;
1035}
1036
1037/*
1038 * nss_mitigation_handler()
1039 * Enable NSS MITIGATION
1040 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001041static 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 -07001042{
1043 struct nss_top_instance *nss_top = &nss_top_main;
1044 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1];
1045 int ret;
1046
1047 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1048 if (ret) {
1049 return ret;
1050 }
1051
1052 /*
1053 * It's a read operation
1054 */
1055 if (!write) {
1056 return ret;
1057 }
1058
1059 if (!nss_n2h_core1_mitigation_cfg) {
1060 printk(KERN_INFO "Disabling NSS MITIGATION\n");
1061 nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_1);
1062 return 0;
1063 }
1064 printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n");
1065 return -EINVAL;
1066}
1067
1068/*
1069 * nss_buf_handler()
1070 * Add extra NSS bufs from host memory
1071 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001072static 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 -07001073{
1074 struct nss_top_instance *nss_top = &nss_top_main;
1075 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0];
1076 int ret;
1077
1078 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1079 if (ret) {
1080 return ret;
1081 }
1082
1083 /*
1084 * It's a read operation
1085 */
1086 if (!write) {
1087 return ret;
1088 }
1089
1090 if (nss_ctx->buf_sz_allocated) {
1091 nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1092 return -EPERM;
1093 }
1094
1095 if ((nss_n2h_core0_add_buf_pool_size >= 1) && (nss_n2h_core0_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) {
1096 printk(KERN_INFO "configuring additional NSS pbufs\n");
1097 ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core0_add_buf_pool_size, NSS_CORE_0);
1098 nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1099 printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated);
1100 return ret;
1101 }
1102
1103 printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE);
1104 return -EINVAL;
1105}
1106
1107/*
1108 * nss_n2h_buf_handler()
1109 * Add extra NSS bufs from host memory
1110 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001111static 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 -07001112{
1113 struct nss_top_instance *nss_top = &nss_top_main;
1114 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1];
1115 int ret;
1116
1117 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1118 if (ret) {
1119 return ret;
1120 }
1121
1122 /*
1123 * It's a read operation
1124 */
1125 if (!write) {
1126 return ret;
1127 }
1128
1129 if (nss_ctx->buf_sz_allocated) {
1130 nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1131 return -EPERM;
1132 }
1133
1134 if ((nss_n2h_core1_add_buf_pool_size >= 1) && (nss_n2h_core1_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) {
1135 printk(KERN_INFO "configuring additional NSS pbufs\n");
1136 ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core1_add_buf_pool_size, NSS_CORE_1);
1137 nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1138 printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated);
1139 return ret;
1140 }
1141
1142 printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE);
1143 return -EINVAL;
1144}
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301145
Stephen Wang52e6d342016-03-29 15:02:33 -07001146static struct ctl_table nss_n2h_table[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001147 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001148 .procname = "n2h_empty_pool_buf_core0",
1149 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0],
1150 .maxlen = sizeof(int),
1151 .mode = 0644,
1152 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001153 },
1154 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001155 .procname = "n2h_empty_pool_buf_core1",
1156 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1],
1157 .maxlen = sizeof(int),
1158 .mode = 0644,
1159 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core1_handler,
1160 },
1161 {
1162 .procname = "n2h_low_water_core0",
1163 .data = &nss_n2h_water_mark[NSS_CORE_0][0],
1164 .maxlen = sizeof(int),
1165 .mode = 0644,
1166 .proc_handler = &nss_n2h_water_mark_core0_handler,
1167 },
1168 {
1169 .procname = "n2h_low_water_core1",
1170 .data = &nss_n2h_water_mark[NSS_CORE_1][0],
1171 .maxlen = sizeof(int),
1172 .mode = 0644,
1173 .proc_handler = &nss_n2h_water_mark_core1_handler,
1174 },
1175 {
1176 .procname = "n2h_high_water_core0",
1177 .data = &nss_n2h_water_mark[NSS_CORE_0][1],
1178 .maxlen = sizeof(int),
1179 .mode = 0644,
1180 .proc_handler = &nss_n2h_water_mark_core0_handler,
1181 },
1182 {
1183 .procname = "n2h_high_water_core1",
1184 .data = &nss_n2h_water_mark[NSS_CORE_1][1],
1185 .maxlen = sizeof(int),
1186 .mode = 0644,
1187 .proc_handler = &nss_n2h_water_mark_core1_handler,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001188 },
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301189 {
1190 .procname = "n2h_wifi_pool_buf",
1191 .data = &nss_n2h_wifi_pool_buf_cfg,
1192 .maxlen = sizeof(int),
1193 .mode = 0644,
1194 .proc_handler = &nss_n2h_wifi_payloads_handler,
1195 },
Stephen Wang49b474b2016-03-25 10:40:30 -07001196 {
1197 .procname = "rps",
1198 .data = &nss_n2h_rps_config,
1199 .maxlen = sizeof(int),
1200 .mode = 0644,
1201 .proc_handler = &nss_n2h_rpscfg_handler,
1202 },
1203 {
1204 .procname = "mitigation_core0",
1205 .data = &nss_n2h_core0_mitigation_cfg,
1206 .maxlen = sizeof(int),
1207 .mode = 0644,
1208 .proc_handler = &nss_n2h_mitigationcfg_core0_handler,
1209 },
1210 {
1211 .procname = "mitigation_core1",
1212 .data = &nss_n2h_core1_mitigation_cfg,
1213 .maxlen = sizeof(int),
1214 .mode = 0644,
1215 .proc_handler = &nss_n2h_mitigationcfg_core1_handler,
1216 },
1217 {
1218 .procname = "extra_pbuf_core0",
1219 .data = &nss_n2h_core0_add_buf_pool_size,
1220 .maxlen = sizeof(int),
1221 .mode = 0644,
1222 .proc_handler = &nss_n2h_buf_cfg_core0_handler,
1223 },
1224 {
1225 .procname = "extra_pbuf_core1",
1226 .data = &nss_n2h_core1_add_buf_pool_size,
1227 .maxlen = sizeof(int),
1228 .mode = 0644,
1229 .proc_handler = &nss_n2h_buf_cfg_core1_handler,
1230 },
Vijay Dewangan488e5372014-12-29 21:40:11 -08001231
1232 { }
1233};
1234
Stephen Wang52e6d342016-03-29 15:02:33 -07001235static struct ctl_table nss_n2h_dir[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001236 {
1237 .procname = "n2hcfg",
1238 .mode = 0555,
1239 .child = nss_n2h_table,
1240 },
1241 { }
1242};
1243
1244
Stephen Wang52e6d342016-03-29 15:02:33 -07001245static struct ctl_table nss_n2h_root_dir[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001246 {
1247 .procname = "nss",
1248 .mode = 0555,
1249 .child = nss_n2h_dir,
1250 },
1251 { }
1252};
1253
Stephen Wang52e6d342016-03-29 15:02:33 -07001254static struct ctl_table nss_n2h_root[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001255 {
1256 .procname = "dev",
1257 .mode = 0555,
1258 .child = nss_n2h_root_dir,
1259 },
1260 { }
1261};
1262
1263static struct ctl_table_header *nss_n2h_header;
1264
1265/*
Stephen Wang49b474b2016-03-25 10:40:30 -07001266 * nss_n2h_flush_payloads()
1267 * Sends a command down to NSS for flushing all payloads
1268 */
1269nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx)
1270{
1271 struct nss_n2h_msg nnm;
1272 struct nss_n2h_flush_payloads *nnflshpl;
1273 nss_tx_status_t nss_tx_status;
1274
1275 nnflshpl = &nnm.msg.flush_payloads;
1276
1277 /*
1278 * TODO: No additional information sent in message
1279 * as of now. Need to initialize message content accordingly
1280 * if needed.
1281 */
1282 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1283 NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS,
1284 sizeof(struct nss_n2h_flush_payloads),
1285 NULL,
1286 NULL);
1287
1288 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1289 if (nss_tx_status != NSS_TX_SUCCESS) {
1290 nss_warning("%p: failed to send flush payloads command to NSS\n",
1291 nss_ctx);
1292
1293 return NSS_TX_FAILURE;
1294 }
1295
1296 return NSS_TX_SUCCESS;
1297}
1298
1299/*
Vijay Dewangan488e5372014-12-29 21:40:11 -08001300 * nss_n2h_msg_init()
Stephen Wang49b474b2016-03-25 10:40:30 -07001301 * Initialize n2h message.
Vijay Dewangan488e5372014-12-29 21:40:11 -08001302 */
1303void nss_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type,
Vijay Dewangan634ce592015-01-07 17:21:09 -08001304 uint32_t len, nss_n2h_msg_callback_t cb, void *app_data)
Vijay Dewangan488e5372014-12-29 21:40:11 -08001305{
1306 nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data);
1307}
1308
Vijay Dewangan488e5372014-12-29 21:40:11 -08001309/*
Vijay Dewangan488e5372014-12-29 21:40:11 -08001310 * nss_n2h_tx_msg()
1311 * Send messages to NSS n2h pacakge
1312 */
1313nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm)
1314{
1315 struct nss_n2h_msg *nnm2;
1316 struct nss_cmn_msg *ncm = &nnm->cm;
1317 struct sk_buff *nbuf;
1318 nss_tx_status_t status;
1319
1320 NSS_VERIFY_CTX_MAGIC(nss_ctx);
1321 if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
1322 return NSS_TX_FAILURE_NOT_READY;
1323 }
1324
1325 /*
1326 * Sanity check the message
1327 */
1328 if (ncm->interface != NSS_N2H_INTERFACE) {
1329 nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface);
1330 return NSS_TX_FAILURE;
1331 }
1332
1333 if (ncm->type >= NSS_METADATA_TYPE_N2H_MAX) {
1334 nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type);
1335 return NSS_TX_FAILURE;
1336 }
1337
Suruchi Agarwalef8a8702016-01-08 12:40:08 -08001338 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_n2h_msg)) {
1339 nss_warning("%p: tx request for another interface: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
Vijay Dewangan488e5372014-12-29 21:40:11 -08001340 return NSS_TX_FAILURE;
1341 }
1342
1343
1344 nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE);
1345 if (unlikely(!nbuf)) {
Sundarajan Srinivasan62fee7e2015-01-22 11:13:10 -08001346 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 -08001347 return NSS_TX_FAILURE;
1348 }
1349
1350 /*
1351 * Copy the message to our skb.
1352 */
1353 nnm2 = (struct nss_n2h_msg *)skb_put(nbuf, sizeof(struct nss_n2h_msg));
1354 memcpy(nnm2, nnm, sizeof(struct nss_n2h_msg));
1355 status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0);
1356 if (status != NSS_CORE_STATUS_SUCCESS) {
1357 dev_kfree_skb_any(nbuf);
1358 nss_info("%p: unable to enqueue 'nss frequency change' - marked as stopped\n", nss_ctx);
1359 return NSS_TX_FAILURE;
1360 }
1361
1362 nss_hal_send_interrupt(nss_ctx->nmap,
1363 nss_ctx->h2n_desc_rings[NSS_IF_CMD_QUEUE].desc_ring.int_bit,
1364 NSS_REGS_H2N_INTR_STATUS_DATA_COMMAND_QUEUE);
1365 NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]);
1366 return NSS_TX_SUCCESS;
1367}
1368
Vijay Dewangan488e5372014-12-29 21:40:11 -08001369/*
1370 * nss_n2h_notify_register()
1371 * Register to received N2H events.
1372 *
1373 * NOTE: Do we want to pass an nss_ctx here so that we can register for n2h on any core?
1374 */
1375struct nss_ctx_instance *nss_n2h_notify_register(int core, nss_n2h_msg_callback_t cb, void *app_data)
1376{
1377 if (core >= NSS_MAX_CORES) {
1378 nss_warning("Input core number %d is wrong \n", core);
1379 return NULL;
1380 }
1381 /*
1382 * TODO: We need to have a new array in support of the new API
1383 * TODO: If we use a per-context array, we would move the array into nss_ctx based.
1384 */
1385 nss_n2h_rd[core].n2h_callback = cb;
1386 nss_n2h_rd[core].app_data = app_data;
1387 return &nss_top_main.nss[core];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301388}
1389
1390/*
1391 * nss_n2h_register_handler()
1392 */
1393void nss_n2h_register_handler()
1394{
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -07001395 nss_core_register_handler(NSS_N2H_INTERFACE, nss_n2h_interface_handler, NULL);
Stephen Wang49b474b2016-03-25 10:40:30 -07001396}
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -07001397
Stephen Wang49b474b2016-03-25 10:40:30 -07001398/*
1399 * nss_n2h_register_sysctl()
1400 */
1401void nss_n2h_register_sysctl(void)
1402{
Vijay Dewangan634ce592015-01-07 17:21:09 -08001403 /*
1404 * RPS sema init
1405 */
1406 sema_init(&nss_n2h_rcp.sem, 1);
1407 init_completion(&nss_n2h_rcp.complete);
1408
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301409 /*
1410 * MITIGATION sema init for core0
1411 */
1412 sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1);
1413 init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete);
1414
1415 /*
1416 * MITIGATION sema init for core1
1417 */
1418 sema_init(&nss_n2h_mitigationcp[NSS_CORE_1].sem, 1);
1419 init_completion(&nss_n2h_mitigationcp[NSS_CORE_1].complete);
1420
1421 /*
1422 * PBUF addition sema init for core0
1423 */
1424 sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1);
1425 init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete);
1426
1427 /*
1428 * PBUF addition sema init for core1
1429 */
1430 sema_init(&nss_n2h_bufcp[NSS_CORE_1].sem, 1);
1431 init_completion(&nss_n2h_bufcp[NSS_CORE_1].complete);
Vijay Dewangan634ce592015-01-07 17:21:09 -08001432
Stephen Wang49b474b2016-03-25 10:40:30 -07001433 /*
1434 * Core0
1435 */
1436 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1);
1437 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete);
1438 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool =
1439 nss_n2h_empty_pool_buf_cfg[NSS_CORE_0];
1440 nss_n2h_nepbcfgp[NSS_CORE_0].low_water =
1441 nss_n2h_water_mark[NSS_CORE_0][0];
1442 nss_n2h_nepbcfgp[NSS_CORE_0].high_water =
1443 nss_n2h_water_mark[NSS_CORE_0][1];
1444
1445 /*
1446 * Core1
1447 */
1448 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_1].sem, 1);
1449 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_1].complete);
1450 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool =
1451 nss_n2h_empty_pool_buf_cfg[NSS_CORE_1];
1452 nss_n2h_nepbcfgp[NSS_CORE_1].low_water =
1453 nss_n2h_water_mark[NSS_CORE_1][0];
1454 nss_n2h_nepbcfgp[NSS_CORE_1].high_water =
1455 nss_n2h_water_mark[NSS_CORE_1][1];
1456
1457 /*
1458 * WiFi pool buf cfg sema init
1459 */
1460 sema_init(&nss_n2h_wp.sem, 1);
1461 init_completion(&nss_n2h_wp.complete);
1462
Vijay Dewangan488e5372014-12-29 21:40:11 -08001463 nss_n2h_notify_register(NSS_CORE_0, NULL, NULL);
1464 nss_n2h_notify_register(NSS_CORE_1, NULL, NULL);
1465
Stephen Wang49b474b2016-03-25 10:40:30 -07001466 /*
1467 * Register sysctl table.
1468 */
1469 nss_n2h_header = register_sysctl_table(nss_n2h_root);
1470}
1471
1472/*
1473 * nss_n2h_unregister_sysctl()
1474 * Unregister sysctl specific to n2h
1475 */
1476void nss_n2h_unregister_sysctl(void)
1477{
1478 /*
1479 * Unregister sysctl table.
1480 */
1481 if (nss_n2h_header) {
1482 unregister_sysctl_table(nss_n2h_header);
1483 }
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301484}
Vijay Dewangan488e5372014-12-29 21:40:11 -08001485
1486EXPORT_SYMBOL(nss_n2h_notify_register);