blob: ea5c2d04b6098d0291fbbf925a33e6731da58820 [file] [log] [blame]
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05301/*
2 **************************************************************************
Wayne Tand5058cb2020-01-07 14:39:16 -08003 * Copyright (c) 2013-2020, 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"
Yu Huang8c107082017-07-24 14:58:26 -070023#include "nss_n2h_stats.h"
Wayne Tand5058cb2020-01-07 14:39:16 -080024#include "nss_n2h_strings.h"
25#include "nss_drv_strings.h"
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053026
Aniruddha Paulfc578bd2019-03-18 16:59:22 +053027#define NSS_N2H_MAX_BUF_POOL_SIZE (1024 * 1024 * 20) /* 20MB */
Saurabh Misra71034db2015-06-04 16:18:38 -070028#define NSS_N2H_MIN_EMPTY_POOL_BUF_SZ 32
Aniruddha Paulfc578bd2019-03-18 16:59:22 +053029#define NSS_N2H_MAX_EMPTY_POOL_BUF_SZ 131072
Vijay Dewangan488e5372014-12-29 21:40:11 -080030#define NSS_N2H_DEFAULT_EMPTY_POOL_BUF_SZ 8192
ratheesh kannothab436af2017-07-20 08:51:07 +053031#define NSS_N2H_TX_TIMEOUT 3000 /* 3 Seconds */
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053032
Saurabh Misra71034db2015-06-04 16:18:38 -070033int nss_n2h_empty_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1};
Sachin Shashidhar475012b2017-03-13 16:56:07 -070034int nss_n2h_empty_paged_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1};
Saurabh Misra71034db2015-06-04 16:18:38 -070035int nss_n2h_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} };
Sachin Shashidhar475012b2017-03-13 16:56:07 -070036int nss_n2h_paged_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} };
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053037int nss_n2h_wifi_pool_buf_cfg __read_mostly = -1;
Stephen Wang49b474b2016-03-25 10:40:30 -070038int nss_n2h_core0_mitigation_cfg __read_mostly = 1;
39int nss_n2h_core1_mitigation_cfg __read_mostly = 1;
40int nss_n2h_core0_add_buf_pool_size __read_mostly;
41int nss_n2h_core1_add_buf_pool_size __read_mostly;
Shashank Balashankar4162f572018-08-21 13:32:34 -070042int nss_n2h_queue_limit[NSS_MAX_CORES] __read_mostly = {NSS_DEFAULT_QUEUE_LIMIT, NSS_DEFAULT_QUEUE_LIMIT};
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -080043int nss_n2h_host_bp_config[NSS_MAX_CORES] __read_mostly;
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053044
Vijay Dewangan488e5372014-12-29 21:40:11 -080045struct nss_n2h_registered_data {
46 nss_n2h_msg_callback_t n2h_callback;
47 void *app_data;
48};
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053049
Vijay Dewangan488e5372014-12-29 21:40:11 -080050static struct nss_n2h_cfg_pvt nss_n2h_nepbcfgp[NSS_MAX_CORES];
51static struct nss_n2h_registered_data nss_n2h_rd[NSS_MAX_CORES];
Vijay Dewangan634ce592015-01-07 17:21:09 -080052static struct nss_n2h_cfg_pvt nss_n2h_rcp;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +053053static struct nss_n2h_cfg_pvt nss_n2h_mitigationcp[NSS_CORE_MAX];
54static struct nss_n2h_cfg_pvt nss_n2h_bufcp[NSS_CORE_MAX];
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +053055static struct nss_n2h_cfg_pvt nss_n2h_wp;
ratheesh kannothab436af2017-07-20 08:51:07 +053056static struct nss_n2h_cfg_pvt nss_n2h_q_cfg_pvt;
Shashank Balashankar4162f572018-08-21 13:32:34 -070057static struct nss_n2h_cfg_pvt nss_n2h_q_lim_pvt;
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -080058static struct nss_n2h_cfg_pvt nss_n2h_host_bp_cfg_pvt;
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053059
60/*
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -070061 * nss_n2h_interface_handler()
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053062 * Handle NSS -> HLOS messages for N2H node
63 */
Vijay Dewangan634ce592015-01-07 17:21:09 -080064static void nss_n2h_interface_handler(struct nss_ctx_instance *nss_ctx,
65 struct nss_cmn_msg *ncm,
Arunkumar Tba9b4a02016-11-07 11:41:14 +053066 void *app_data)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053067{
68 struct nss_n2h_msg *nnm = (struct nss_n2h_msg *)ncm;
Vijay Dewangan488e5372014-12-29 21:40:11 -080069 nss_n2h_msg_callback_t cb;
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053070
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -070071 BUG_ON(ncm->interface != NSS_N2H_INTERFACE);
72
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053073 /*
74 * Is this a valid request/response packet?
75 */
76 if (nnm->cm.type >= NSS_METADATA_TYPE_N2H_MAX) {
Kyle Swensondd7b2962021-03-16 13:46:32 -060077 nss_warning("%px: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053078 return;
79 }
80
81 switch (nnm->cm.type) {
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053082 case NSS_TX_METADATA_TYPE_N2H_RPS_CFG:
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053083 nss_info("NSS N2H rps_en %d \n",nnm->msg.rps_cfg.enable);
Vijay Dewangan488e5372014-12-29 21:40:11 -080084 break;
85
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +053086 case NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG:
87 nss_info("NSS N2H mitigation_dis %d \n",nnm->msg.mitigation_cfg.enable);
88 break;
89
Vijay Dewangan488e5372014-12-29 21:40:11 -080090 case NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG:
Kyle Swensondd7b2962021-03-16 13:46:32 -060091 nss_info("%px: empty pool buf cfg response from FW", nss_ctx);
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +053092 break;
93
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +053094 case NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS:
Kyle Swensondd7b2962021-03-16 13:46:32 -060095 nss_info("%px: flush payloads cmd response from FW", nss_ctx);
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +053096 break;
97
Abhishek Rastogi84d95d02014-03-26 19:31:31 +053098 case NSS_RX_METADATA_TYPE_N2H_STATS_SYNC:
Wayne Tand5058cb2020-01-07 14:39:16 -080099 /*
100 * Update driver statistics and send statistics notifications to the registered modules.
101 */
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -0700102 nss_n2h_stats_sync(nss_ctx, &nnm->msg.stats_sync);
Wayne Tand5058cb2020-01-07 14:39:16 -0800103 nss_n2h_stats_notify(nss_ctx);
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530104 break;
105
106 default:
107 if (ncm->response != NSS_CMN_RESPONSE_ACK) {
108 /*
109 * Check response
110 */
Kyle Swensondd7b2962021-03-16 13:46:32 -0600111 nss_info("%px: Received response %d for type %d, interface %d",
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530112 nss_ctx, ncm->response, ncm->type, ncm->interface);
113 }
114 }
Vijay Dewangan488e5372014-12-29 21:40:11 -0800115
116 /*
Stephen Wang49b474b2016-03-25 10:40:30 -0700117 * Update the callback and app_data for NOTIFY messages, n2h sends all notify messages
Vijay Dewangan488e5372014-12-29 21:40:11 -0800118 * to the same callback/app_data.
119 */
Suruchi Agarwale4ad24a2018-06-11 12:03:46 +0530120 if (nnm->cm.response == NSS_CMN_RESPONSE_NOTIFY) {
Vijay Dewangan488e5372014-12-29 21:40:11 -0800121 /*
122 * Place holder for the user to create right call
Suruchi Agarwale4ad24a2018-06-11 12:03:46 +0530123 * back and app data when response is NSS_CMN_RESPONSE_NOTIFY
Vijay Dewangan488e5372014-12-29 21:40:11 -0800124 */
Stephen Wangaed46332016-12-12 17:29:03 -0800125 ncm->cb = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].n2h_callback;
126 ncm->app_data = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].app_data;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800127 }
128
129 /*
130 * Do we have a callback?
131 */
132 if (!ncm->cb) {
133 return;
134 }
135
136 /*
137 * Callback
138 */
139 cb = (nss_n2h_msg_callback_t)ncm->cb;
140 cb((void *)ncm->app_data, nnm);
141}
142
143/*
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530144 * nss_n2h_mitigation_cfg_callback()
145 * call back function for mitigation configuration
146 */
147static void nss_n2h_mitigation_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
148{
Stephen Wangaed46332016-12-12 17:29:03 -0800149 uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530150 struct nss_top_instance *nss_top = &nss_top_main;
151 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
152
153 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
154
155 /*
156 * Error, hence we are not updating the nss_n2h_mitigate_en
157 */
158 nss_n2h_mitigationcp[core_num].response = NSS_FAILURE;
159 complete(&nss_n2h_mitigationcp[core_num].complete);
160 nss_warning("core%d: MITIGATION configuration failed : %d\n", core_num, nnm->cm.error);
161 return;
162 }
163
164 nss_info("core%d: MITIGATION configuration succeeded: %d\n", core_num, nnm->cm.error);
165
166 nss_ctx->n2h_mitigate_en = nnm->msg.mitigation_cfg.enable;
167 nss_n2h_mitigationcp[core_num].response = NSS_SUCCESS;
168 complete(&nss_n2h_mitigationcp[core_num].complete);
169}
170
171/*
172 * nss_n2h_buf_cfg_callback()
173 * call back function for pbuf configuration
174 */
175static void nss_n2h_bufs_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
176{
Stephen Wangaed46332016-12-12 17:29:03 -0800177 uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +0530178 unsigned int allocated_sz;
179
180 struct nss_top_instance *nss_top = &nss_top_main;
181 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
182
183 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
184 nss_n2h_bufcp[core_num].response = NSS_FAILURE;
185 nss_warning("core%d: buf configuration failed : %d\n", core_num, nnm->cm.error);
186 goto done;
187 }
188
189 nss_info("core%d: buf configuration succeeded: %d\n", core_num, nnm->cm.error);
190
191 allocated_sz = nnm->msg.buf_pool.nss_buf_page_size * nnm->msg.buf_pool.nss_buf_num_pages;
192 nss_ctx->buf_sz_allocated += allocated_sz;
193
194 nss_n2h_bufcp[core_num].response = NSS_SUCCESS;
195
196done:
197 complete(&nss_n2h_bufcp[core_num].complete);
198}
199
200/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700201 * nss_n2h_payload_stats_callback()
202 * It gets called response to payload accounting.
Vijay Dewangan488e5372014-12-29 21:40:11 -0800203 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700204static void nss_n2h_payload_stats_callback(void *app_data,
205 struct nss_n2h_msg *nnm)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800206{
Stephen Wangaed46332016-12-12 17:29:03 -0800207 uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
Saurabh Misra71034db2015-06-04 16:18:38 -0700208
Vijay Dewangan488e5372014-12-29 21:40:11 -0800209 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
210 struct nss_n2h_empty_pool_buf *nnepbcm;
211 nnepbcm = &nnm->msg.empty_pool_buf_cfg;
212
Saurabh Misra71034db2015-06-04 16:18:38 -0700213 nss_warning("%d: core empty pool buf set failure: %d\n",
214 core_num, nnm->cm.error);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800215 nss_n2h_nepbcfgp[core_num].response = NSS_FAILURE;
216 complete(&nss_n2h_nepbcfgp[core_num].complete);
217 return;
218 }
219
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700220 if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_WATER_MARK) {
221 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size =
Saurabh Misra71034db2015-06-04 16:18:38 -0700222 ntohl(nnm->msg.payload_info.pool_size);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700223 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water =
Saurabh Misra71034db2015-06-04 16:18:38 -0700224 ntohl(nnm->msg.payload_info.low_water);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700225 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water =
Saurabh Misra71034db2015-06-04 16:18:38 -0700226 ntohl(nnm->msg.payload_info.high_water);
227 }
228
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700229 if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK) {
230 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size =
231 ntohl(nnm->msg.paged_payload_info.pool_size);
232 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water =
233 ntohl(nnm->msg.paged_payload_info.low_water);
234 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water =
235 ntohl(nnm->msg.paged_payload_info.high_water);
236 }
237
Vijay Dewangan488e5372014-12-29 21:40:11 -0800238 nss_n2h_nepbcfgp[core_num].response = NSS_SUCCESS;
239 complete(&nss_n2h_nepbcfgp[core_num].complete);
240}
241
242/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530243 * nss_n2h_set_wifi_payloads_callback()
Cemil Coskun9165c762017-12-04 14:35:24 -0800244 * call back function for response to wifi pool configuration
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530245 *
246 */
247static void nss_n2h_set_wifi_payloads_callback(void *app_data,
248 struct nss_n2h_msg *nnm)
249{
Arunkumar Tba9b4a02016-11-07 11:41:14 +0530250 struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data;
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530251 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
252
253 nss_n2h_wp.response = NSS_FAILURE;
254 complete(&nss_n2h_wp.complete);
Kyle Swensondd7b2962021-03-16 13:46:32 -0600255 nss_warning("%px: wifi pool configuration failed : %d\n", nss_ctx,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530256 nnm->cm.error);
257 return;
258 }
259
Kyle Swensondd7b2962021-03-16 13:46:32 -0600260 nss_info("%px: wifi payload configuration succeeded: %d\n", nss_ctx,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530261 nnm->cm.error);
262 nss_n2h_wp.response = NSS_SUCCESS;
Neelansh Mittalfa08fba2019-12-12 12:25:27 +0530263 nss_n2h_wp.wifi_pool = ntohl(nnm->msg.wp.payloads);
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530264 complete(&nss_n2h_wp.complete);
265}
266
267/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700268 * nss_n2h_get_payload_info()
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700269 * Gets Payload information.
Vijay Dewangan488e5372014-12-29 21:40:11 -0800270 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700271static 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 -0700272{
273 struct nss_top_instance *nss_top = &nss_top_main;
274 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
Saurabh Misra71034db2015-06-04 16:18:38 -0700275 nss_tx_status_t nss_tx_status;
276 int ret = NSS_FAILURE;
277
278 /*
279 * Note that semaphore should be already held.
280 */
281
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700282 nss_tx_status = nss_n2h_tx_msg(nss_ctx, nnm);
Saurabh Misra71034db2015-06-04 16:18:38 -0700283
284 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600285 nss_warning("%px: core %d nss_tx error errorn", nss_ctx, (int)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700286 return NSS_FAILURE;
287 }
288
289 /*
290 * Blocking call, wait till we get ACK for this msg.
291 */
292 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
293 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
294 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600295 nss_warning("%px: core %d waiting for ack timed out\n", nss_ctx, (int)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700296 return NSS_FAILURE;
297 }
298
299 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600300 nss_warning("%px: core %d response returned failure\n", nss_ctx, (int)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700301 return NSS_FAILURE;
302 }
303
304 return NSS_SUCCESS;
305}
306
307/*
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700308 * nss_n2h_get_default_payload_info()
309 * Gets the default payload information.
310 */
311static int nss_n2h_get_default_payload_info(nss_ptr_t core_num)
312{
313 struct nss_n2h_msg nnm;
314
315 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
316 NSS_TX_METADATA_TYPE_GET_WATER_MARK,
317 sizeof(struct nss_n2h_payload_info),
318 nss_n2h_payload_stats_callback,
319 (void *)core_num);
320
321 return nss_n2h_get_payload_info(core_num, &nnm,
322 &nnm.msg.payload_info);
323}
324
325/*
326 * nss_n2h_get_paged_payload_info()
327 * Gets the paged payload information.
328 */
329static int nss_n2h_get_paged_payload_info(nss_ptr_t core_num)
330{
331 struct nss_n2h_msg nnm;
332
333 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
334 NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK,
335 sizeof(struct nss_n2h_payload_info),
336 nss_n2h_payload_stats_callback,
337 (void *)core_num);
338
339 return nss_n2h_get_payload_info(core_num, &nnm,
340 &nnm.msg.paged_payload_info);
341}
342
343/*
Amit Guptaca2ea682019-01-24 17:18:46 +0530344 * nss_n2h_set_empty_buf_pool()
Saurabh Misra71034db2015-06-04 16:18:38 -0700345 * Sets empty pool buffer
346 */
Amit Guptaca2ea682019-01-24 17:18:46 +0530347static int nss_n2h_set_empty_buf_pool(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700348 void __user *buffer,
349 size_t *lenp, loff_t *ppos,
Stephen Wangaed46332016-12-12 17:29:03 -0800350 nss_ptr_t core_num, int *new_val)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800351{
352 struct nss_top_instance *nss_top = &nss_top_main;
353 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
354 struct nss_n2h_msg nnm;
355 struct nss_n2h_empty_pool_buf *nnepbcm;
356 nss_tx_status_t nss_tx_status;
357 int ret = NSS_FAILURE;
358
359 /*
360 * Acquiring semaphore
361 */
362 down(&nss_n2h_nepbcfgp[core_num].sem);
363
364 /*
365 * Take snap shot of current value
366 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700367 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size = *new_val;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800368
Saurabh Misra71034db2015-06-04 16:18:38 -0700369 if (!write) {
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700370 ret = nss_n2h_get_default_payload_info(core_num);
371 *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size;
Saurabh Misra71034db2015-06-04 16:18:38 -0700372 if (ret == NSS_FAILURE) {
373 up(&nss_n2h_nepbcfgp[core_num].sem);
374 return -EBUSY;
375 }
376
377 up(&nss_n2h_nepbcfgp[core_num].sem);
378
379 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
380 return ret;
381 }
382
Vijay Dewangan488e5372014-12-29 21:40:11 -0800383 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
Saurabh Misra71034db2015-06-04 16:18:38 -0700384 if (ret) {
Vijay Dewangan488e5372014-12-29 21:40:11 -0800385 up(&nss_n2h_nepbcfgp[core_num].sem);
386 return ret;
387 }
388
Vijay Dewangan488e5372014-12-29 21:40:11 -0800389 if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600390 nss_warning("%px: core %d setting %d < min number of buffer",
Stephen Wangaed46332016-12-12 17:29:03 -0800391 nss_ctx, (int)core_num, *new_val);
Stephen Wang06761022015-03-03 16:38:42 -0800392 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800393 }
394
Kyle Swensondd7b2962021-03-16 13:46:32 -0600395 nss_info("%px: core %d number of empty pool buffer is : %d\n",
Stephen Wangaed46332016-12-12 17:29:03 -0800396 nss_ctx, (int)core_num, *new_val);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800397
398 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
399 NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG,
400 sizeof(struct nss_n2h_empty_pool_buf),
Saurabh Misra71034db2015-06-04 16:18:38 -0700401 nss_n2h_payload_stats_callback,
Stephen Wangaed46332016-12-12 17:29:03 -0800402 (nss_ptr_t *)core_num);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800403
404 nnepbcm = &nnm.msg.empty_pool_buf_cfg;
405 nnepbcm->pool_size = htonl(*new_val);
406 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
407
408 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600409 nss_warning("%px: core %d nss_tx error empty pool buffer: %d\n",
Stephen Wangaed46332016-12-12 17:29:03 -0800410 nss_ctx, (int)core_num, *new_val);
Stephen Wang06761022015-03-03 16:38:42 -0800411 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800412 }
413
414 /*
415 * Blocking call, wait till we get ACK for this msg.
416 */
Saurabh Misra71034db2015-06-04 16:18:38 -0700417 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
418 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
Vijay Dewangan488e5372014-12-29 21:40:11 -0800419 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600420 nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num);
Stephen Wang06761022015-03-03 16:38:42 -0800421 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800422 }
423
424 /*
425 * ACK/NACK received from NSS FW
426 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
427 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
428 */
429 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
Stephen Wang06761022015-03-03 16:38:42 -0800430 goto failure;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800431 }
432
433 up(&nss_n2h_nepbcfgp[core_num].sem);
Thomas Wu651b3902015-05-12 11:21:09 -0700434 return 0;
Stephen Wang06761022015-03-03 16:38:42 -0800435
436failure:
437 /*
438 * Restore the current_value to its previous state
439 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700440 *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size;
441 up(&nss_n2h_nepbcfgp[core_num].sem);
442 return NSS_FAILURE;
443}
444
445/*
446 * nss_n2h_set_empty_paged_pool_buf()
447 * Sets empty paged pool buffer
448 */
449static int nss_n2h_set_empty_paged_pool_buf(struct ctl_table *ctl, int write,
450 void __user *buffer,
451 size_t *lenp, loff_t *ppos,
452 nss_ptr_t core_num, int *new_val)
453{
454 struct nss_top_instance *nss_top = &nss_top_main;
455 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
456 struct nss_n2h_msg nnm;
457 struct nss_n2h_empty_pool_buf *nneppbcm;
458 nss_tx_status_t nss_tx_status;
459 int ret = NSS_FAILURE;
460
461 /*
462 * Acquiring semaphore
463 */
464 down(&nss_n2h_nepbcfgp[core_num].sem);
465
466 /*
467 * Take snap shot of current value
468 */
469 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size = *new_val;
470
471 if (!write) {
472 ret = nss_n2h_get_paged_payload_info(core_num);
473 *new_val = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size;
474 if (ret == NSS_FAILURE) {
475 up(&nss_n2h_nepbcfgp[core_num].sem);
476 return -EBUSY;
477 }
478
479 up(&nss_n2h_nepbcfgp[core_num].sem);
480
481 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
482 return ret;
483 }
484
485 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
486 if (ret) {
487 up(&nss_n2h_nepbcfgp[core_num].sem);
488 return ret;
489 }
490
491 if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600492 nss_warning("%px: core %d setting %d < min number of buffer",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700493 nss_ctx, (int)core_num, *new_val);
494 goto failure;
495 }
496
Kyle Swensondd7b2962021-03-16 13:46:32 -0600497 nss_info("%px: core %d number of empty paged pool buffer is : %d\n",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700498 nss_ctx, (int)core_num, *new_val);
499
500 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
501 NSS_TX_METADATA_TYPE_N2H_EMPTY_PAGED_POOL_BUF_CFG,
502 sizeof(struct nss_n2h_empty_pool_buf),
503 nss_n2h_payload_stats_callback,
504 (nss_ptr_t *)core_num);
505
506 nneppbcm = &nnm.msg.empty_pool_buf_cfg;
507 nneppbcm->pool_size = htonl(*new_val);
508 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
509
510 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600511 nss_warning("%px: core %d nss_tx error empty paged pool buffer: %d\n",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700512 nss_ctx, (int)core_num, *new_val);
513 goto failure;
514 }
515
516 /*
517 * Blocking call, wait till we get ACK for this msg.
518 */
519 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
520 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
521 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600522 nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700523 goto failure;
524 }
525
526 /*
527 * ACK/NACK received from NSS FW
528 * If ACK: Callback function will update nss_n2h_empty_pool_buf with
529 * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input
530 */
531 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
532 goto failure;
533 }
534
535 up(&nss_n2h_nepbcfgp[core_num].sem);
536 return 0;
537
538failure:
539 /*
540 * Restore the current_value to its previous state
541 */
542 *new_val = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size;
Saurabh Misra71034db2015-06-04 16:18:38 -0700543 up(&nss_n2h_nepbcfgp[core_num].sem);
544 return NSS_FAILURE;
545}
546
547/*
548 * nss_n2h_set_water_mark()
549 * Sets water mark for N2H SOS
550 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700551static int nss_n2h_set_water_mark(struct ctl_table *ctl, int write,
Saurabh Misra71034db2015-06-04 16:18:38 -0700552 void __user *buffer,
553 size_t *lenp, loff_t *ppos,
Stephen Wangaed46332016-12-12 17:29:03 -0800554 uint32_t core_num, int *low, int *high)
Saurabh Misra71034db2015-06-04 16:18:38 -0700555{
556 struct nss_top_instance *nss_top = &nss_top_main;
557 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
558 struct nss_n2h_msg nnm;
559 struct nss_n2h_water_mark *wm;
560 nss_tx_status_t nss_tx_status;
561 int ret = NSS_FAILURE;
562
563 /*
564 * Acquiring semaphore
565 */
566 down(&nss_n2h_nepbcfgp[core_num].sem);
567
568 /*
569 * Take snap shot of current value
570 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700571 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water = *low;
572 nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water = *high;
Saurabh Misra71034db2015-06-04 16:18:38 -0700573
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700574 if (!write || *low == -1 || *high == -1) {
575 ret = nss_n2h_get_default_payload_info(core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700576 if (ret == NSS_FAILURE) {
577 up(&nss_n2h_nepbcfgp[core_num].sem);
578 return -EBUSY;
579 }
580
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700581 *low = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water;
582 *high = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water;
Saurabh Misra71034db2015-06-04 16:18:38 -0700583 }
584
585 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700586 if (!write || ret) {
Saurabh Misra71034db2015-06-04 16:18:38 -0700587 up(&nss_n2h_nepbcfgp[core_num].sem);
588 return ret;
589 }
590
Saurabh Misra71034db2015-06-04 16:18:38 -0700591 if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) ||
592 (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600593 nss_warning("%px: core %d setting %d, %d < min number of buffer",
Saurabh Misra71034db2015-06-04 16:18:38 -0700594 nss_ctx, core_num, *low, *high);
595 goto failure;
596 }
597
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530598 if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) ||
599 (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600600 nss_warning("%px: core %d setting %d, %d is > upper limit",
Saurabh Misra71034db2015-06-04 16:18:38 -0700601 nss_ctx, core_num, *low, *high);
602 goto failure;
603 }
604
605 if (*low > *high) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600606 nss_warning("%px: core %d setting low %d is more than high %d",
Saurabh Misra71034db2015-06-04 16:18:38 -0700607 nss_ctx, core_num, *low, *high);
608 goto failure;
609 }
610
Kyle Swensondd7b2962021-03-16 13:46:32 -0600611 nss_info("%px: core %d number of low : %d and high : %d\n",
Saurabh Misra71034db2015-06-04 16:18:38 -0700612 nss_ctx, core_num, *low, *high);
613
614 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
615 NSS_TX_METADATA_TYPE_SET_WATER_MARK,
616 sizeof(struct nss_n2h_water_mark),
617 nss_n2h_payload_stats_callback,
Stephen Wangaed46332016-12-12 17:29:03 -0800618 (void *)(nss_ptr_t)core_num);
Saurabh Misra71034db2015-06-04 16:18:38 -0700619
620 wm = &nnm.msg.wm;
621 wm->low_water = htonl(*low);
622 wm->high_water = htonl(*high);
623 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
624
625 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600626 nss_warning("%px: core %d nss_tx error setting : %d, %d\n",
Saurabh Misra71034db2015-06-04 16:18:38 -0700627 nss_ctx, core_num, *low, *high);
628 goto failure;
629 }
630
631 /*
632 * Blocking call, wait till we get ACK for this msg.
633 */
634 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
635 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
636 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600637 nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx,
Saurabh Misra71034db2015-06-04 16:18:38 -0700638 core_num);
639 goto failure;
640 }
641
642 /*
643 * ACK/NACK received from NSS FW
644 */
645 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response)
646 goto failure;
647
648 up(&nss_n2h_nepbcfgp[core_num].sem);
649 return NSS_SUCCESS;
650
651failure:
652 /*
653 * Restore the current_value to its previous state
654 */
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700655 *low = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water;
656 *high = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water;
657 up(&nss_n2h_nepbcfgp[core_num].sem);
658 return -EINVAL;
659}
660
661/*
662 * nss_n2h_set_paged_water_mark()
663 * Sets water mark for paged pool N2H SOS
664 */
665static int nss_n2h_set_paged_water_mark(struct ctl_table *ctl, int write,
666 void __user *buffer,
667 size_t *lenp, loff_t *ppos,
668 uint32_t core_num, int *low, int *high)
669{
670 struct nss_top_instance *nss_top = &nss_top_main;
671 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
672 struct nss_n2h_msg nnm;
673 struct nss_n2h_water_mark *pwm;
674 nss_tx_status_t nss_tx_status;
675 int ret = NSS_FAILURE;
676
677 /*
678 * Acquiring semaphore
679 */
680 down(&nss_n2h_nepbcfgp[core_num].sem);
681
682 /*
683 * Take snap shot of current value
684 */
685 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water = *low;
686 nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water = *high;
687
688 if (!write || *low == -1 || *high == -1) {
689 ret = nss_n2h_get_paged_payload_info(core_num);
690 if (ret == NSS_FAILURE) {
691 up(&nss_n2h_nepbcfgp[core_num].sem);
692 return -EBUSY;
693 }
694
695 *low = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water;
696 *high = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water;
697 }
698
699 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
700 if (!write || ret) {
701 up(&nss_n2h_nepbcfgp[core_num].sem);
702 return ret;
703 }
704
705 if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) ||
706 (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600707 nss_warning("%px: core %d setting %d, %d < min number of buffer",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700708 nss_ctx, core_num, *low, *high);
709 goto failure;
710 }
711
712 if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) ||
713 (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600714 nss_warning("%px: core %d setting %d, %d is > upper limit",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700715 nss_ctx, core_num, *low, *high);
716 goto failure;
717 }
718
719 if (*low > *high) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600720 nss_warning("%px: core %d setting low %d is more than high %d",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700721 nss_ctx, core_num, *low, *high);
722 goto failure;
723 }
724
Kyle Swensondd7b2962021-03-16 13:46:32 -0600725 nss_info("%px: core %d number of low : %d and high : %d\n",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700726 nss_ctx, core_num, *low, *high);
727
728 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
729 NSS_TX_METADATA_TYPE_SET_PAGED_WATER_MARK,
730 sizeof(struct nss_n2h_water_mark),
731 nss_n2h_payload_stats_callback,
732 (void *)(nss_ptr_t)core_num);
733
734 pwm = &nnm.msg.wm_paged;
735 pwm->low_water = htonl(*low);
736 pwm->high_water = htonl(*high);
737 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
738
739 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600740 nss_warning("%px: core %d nss_tx error setting : %d, %d\n",
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700741 nss_ctx, core_num, *low, *high);
742 goto failure;
743 }
744
745 /*
746 * Blocking call, wait till we get ACK for this msg.
747 */
748 ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
749 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
750 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600751 nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx,
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700752 core_num);
753 goto failure;
754 }
755
756 /*
757 * ACK/NACK received from NSS FW
758 */
759 if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response)
760 goto failure;
761
762 up(&nss_n2h_nepbcfgp[core_num].sem);
763 return NSS_SUCCESS;
764
765failure:
766 /*
767 * Restore the current_value to its previous state
768 */
769 *low = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water;
770 *high = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water;
Stephen Wang06761022015-03-03 16:38:42 -0800771 up(&nss_n2h_nepbcfgp[core_num].sem);
Thomas Wu651b3902015-05-12 11:21:09 -0700772 return -EINVAL;
Vijay Dewangan488e5372014-12-29 21:40:11 -0800773}
774
775/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530776 * nss_n2h_cfg_wifi_pool()
777 * Sets number of wifi payloads to adjust high water mark for N2H SoS
778 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700779static int nss_n2h_cfg_wifi_pool(struct ctl_table *ctl, int write,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530780 void __user *buffer,
781 size_t *lenp, loff_t *ppos,
782 int *payloads)
783{
784 struct nss_top_instance *nss_top = &nss_top_main;
785 struct nss_ctx_instance *nss_ctx = &nss_top->nss[0];
786 struct nss_n2h_msg nnm;
787 struct nss_n2h_wifi_payloads *wp;
788 nss_tx_status_t nss_tx_status;
789 int ret = NSS_FAILURE;
790
791 /*
792 * Acquiring semaphore
793 */
794 down(&nss_n2h_wp.sem);
795
796 if (!write) {
797 *payloads = nss_n2h_wp.wifi_pool;
798
799 up(&nss_n2h_wp.sem);
800 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
801 return ret;
802 }
803
804 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
805 if (ret) {
806 up(&nss_n2h_wp.sem);
807 return ret;
808 }
809
810 /*
811 * If payloads parameter is not set, we do
812 * nothing.
813 */
814 if (*payloads == -1)
815 goto failure;
816
817 if ((*payloads < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600818 nss_warning("%px: wifi setting %d < min number of buffer",
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530819 nss_ctx, *payloads);
820 goto failure;
821 }
822
823 if ((*payloads > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600824 nss_warning("%px: wifi setting %d > max number of buffer",
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530825 nss_ctx, *payloads);
826 goto failure;
827 }
828
Kyle Swensondd7b2962021-03-16 13:46:32 -0600829 nss_info("%px: wifi payloads : %d\n",
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530830 nss_ctx, *payloads);
831
832 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
833 NSS_TX_METADATA_TYPE_N2H_WIFI_POOL_BUF_CFG,
834 sizeof(struct nss_n2h_wifi_payloads),
835 nss_n2h_set_wifi_payloads_callback,
836 (void *)nss_ctx);
837
838 wp = &nnm.msg.wp;
839 wp->payloads = htonl(*payloads);
840 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
841
842 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600843 nss_warning("%px: wifi setting %d nss_tx error",
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530844 nss_ctx, *payloads);
845 goto failure;
846 }
847
848 /*
849 * Blocking call, wait till we get ACK for this msg.
850 */
851 ret = wait_for_completion_timeout(&nss_n2h_wp.complete,
852 msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
853 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600854 nss_warning("%px: Waiting for ack timed out\n", nss_ctx);
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530855 goto failure;
856 }
857
858 /*
859 * ACK/NACK received from NSS FW
860 */
861 if (NSS_FAILURE == nss_n2h_wp.response)
862 goto failure;
863
864 up(&nss_n2h_wp.sem);
865 return NSS_SUCCESS;
866
867failure:
868 up(&nss_n2h_wp.sem);
869 return -EINVAL;
870}
871
872/*
Vijay Dewangan488e5372014-12-29 21:40:11 -0800873 * nss_n2h_empty_pool_buf_core1_handler()
874 * Sets the number of empty buffer for core 1
875 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700876static int nss_n2h_empty_pool_buf_cfg_core1_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700877 int write, void __user *buffer,
878 size_t *lenp, loff_t *ppos)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800879{
Amit Guptaca2ea682019-01-24 17:18:46 +0530880 return nss_n2h_set_empty_buf_pool(ctl, write, buffer, lenp, ppos,
Saurabh Misra71034db2015-06-04 16:18:38 -0700881 NSS_CORE_1, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800882}
883
884/*
885 * nss_n2h_empty_pool_buf_core0_handler()
886 * Sets the number of empty buffer for core 0
887 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700888static int nss_n2h_empty_pool_buf_cfg_core0_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700889 int write, void __user *buffer,
890 size_t *lenp, loff_t *ppos)
Vijay Dewangan488e5372014-12-29 21:40:11 -0800891{
Amit Guptaca2ea682019-01-24 17:18:46 +0530892 return nss_n2h_set_empty_buf_pool(ctl, write, buffer, lenp, ppos,
Saurabh Misra71034db2015-06-04 16:18:38 -0700893 NSS_CORE_0, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]);
894}
895
896/*
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700897 * nss_n2h_empty_paged_pool_buf_cfg_core1_handler()
898 * Sets the number of empty paged buffer for core 1
899 */
900static int nss_n2h_empty_paged_pool_buf_cfg_core1_handler(struct ctl_table *ctl,
901 int write, void __user *buffer,
902 size_t *lenp, loff_t *ppos)
903{
904 return nss_n2h_set_empty_paged_pool_buf(ctl, write, buffer, lenp, ppos,
905 NSS_CORE_1, &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1]);
906}
907
908/*
909 * nss_n2h_empty_paged_pool_buf_cfg_core0_handler()
910 * Sets the number of empty paged buffer for core 0
911 */
912static int nss_n2h_empty_paged_pool_buf_cfg_core0_handler(struct ctl_table *ctl,
913 int write, void __user *buffer,
914 size_t *lenp, loff_t *ppos)
915{
916 return nss_n2h_set_empty_paged_pool_buf(ctl, write, buffer, lenp, ppos,
917 NSS_CORE_0, &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0]);
918}
919
920/*
Saurabh Misra71034db2015-06-04 16:18:38 -0700921 * nss_n2h_water_mark_core1_handler()
922 * Sets water mark for core 1
923 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700924static int nss_n2h_water_mark_core1_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700925 int write, void __user *buffer,
926 size_t *lenp, loff_t *ppos)
927{
928 return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos,
929 NSS_CORE_1, &nss_n2h_water_mark[NSS_CORE_1][0],
930 &nss_n2h_water_mark[NSS_CORE_1][1]);
931}
932
933/*
934 * nss_n2h_water_mark_core0_handler()
935 * Sets water mark for core 0
936 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700937static int nss_n2h_water_mark_core0_handler(struct ctl_table *ctl,
Saurabh Misra71034db2015-06-04 16:18:38 -0700938 int write, void __user *buffer,
939 size_t *lenp, loff_t *ppos)
940{
941 return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos,
942 NSS_CORE_0, &nss_n2h_water_mark[NSS_CORE_0][0],
943 &nss_n2h_water_mark[NSS_CORE_0][1]);
Vijay Dewangan488e5372014-12-29 21:40:11 -0800944}
945
Vijay Dewangan634ce592015-01-07 17:21:09 -0800946/*
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700947 * nss_n2h_paged_water_mark_core1_handler()
948 * Sets paged water mark for core 1
949 */
950static int nss_n2h_paged_water_mark_core1_handler(struct ctl_table *ctl,
951 int write, void __user *buffer,
952 size_t *lenp, loff_t *ppos)
953{
954 return nss_n2h_set_paged_water_mark(ctl, write, buffer, lenp, ppos,
955 NSS_CORE_1, &nss_n2h_paged_water_mark[NSS_CORE_1][0],
956 &nss_n2h_paged_water_mark[NSS_CORE_1][1]);
957}
958
Sachin Shashidhar475012b2017-03-13 16:56:07 -0700959/*
960 * nss_n2h_paged_water_mark_core0_handler()
961 * Sets paged water mark for core 0
962 */
963static int nss_n2h_paged_water_mark_core0_handler(struct ctl_table *ctl,
964 int write, void __user *buffer,
965 size_t *lenp, loff_t *ppos)
966{
967 return nss_n2h_set_paged_water_mark(ctl, write, buffer, lenp, ppos,
968 NSS_CORE_0, &nss_n2h_paged_water_mark[NSS_CORE_0][0],
969 &nss_n2h_paged_water_mark[NSS_CORE_0][1]);
970}
971
972/*
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530973 * nss_n2h_wifi_payloads_handler()
974 * Sets number of wifi payloads
975 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700976static int nss_n2h_wifi_payloads_handler(struct ctl_table *ctl,
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +0530977 int write, void __user *buffer,
978 size_t *lenp, loff_t *ppos)
979{
980 return nss_n2h_cfg_wifi_pool(ctl, write, buffer, lenp, ppos,
981 &nss_n2h_wifi_pool_buf_cfg);
982}
983
984/*
ratheesh kannothab436af2017-07-20 08:51:07 +0530985 * nss_n2h_update_queue_config_callback()
986 * Callback to handle the completion of queue config command
ratheesh kannoth024a6e82017-05-18 17:48:10 +0530987 */
ratheesh kannothab436af2017-07-20 08:51:07 +0530988static void nss_n2h_update_queue_config_callback(void *app_data, struct nss_n2h_msg *nim)
ratheesh kannoth024a6e82017-05-18 17:48:10 +0530989{
ratheesh kannothab436af2017-07-20 08:51:07 +0530990 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
991 nss_warning("n2h Error response %d\n", nim->cm.response);
992 nss_n2h_q_cfg_pvt.response = NSS_TX_FAILURE;
993 } else {
994 nss_n2h_q_cfg_pvt.response = NSS_TX_SUCCESS;
995 }
996
997 complete(&nss_n2h_q_cfg_pvt.complete);
998}
999
1000/*
1001 * nss_n2h_update_queue_config_async()
1002 * Asynchronous call to send pnode queue configuration.
1003 */
1004nss_tx_status_t nss_n2h_update_queue_config_async(struct nss_ctx_instance *nss_ctx, bool mq_en, uint16_t *qlimits)
1005{
1006
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301007 struct nss_n2h_msg nnm;
1008 struct nss_n2h_pnode_queue_config *cfg;
1009 nss_tx_status_t status;
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301010 int i;
1011
1012 if (!mq_en) {
1013 return NSS_TX_SUCCESS;
1014 }
1015
ratheesh kannoth93ba95c2017-07-13 15:52:52 +05301016 /*
1017 * MQ mode doesnot make any sense if number of priority queues in NSS
1018 * is 1
1019 */
1020 if (NSS_MAX_NUM_PRI <= 1) {
1021 return NSS_TX_SUCCESS;
1022 }
1023
ratheesh kannothab436af2017-07-20 08:51:07 +05301024 memset(&nnm, 0, sizeof(struct nss_n2h_msg));
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301025
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301026 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1027 NSS_TX_METADATA_TYPE_N2H_SET_PNODE_QUEUE_CFG,
1028 sizeof(struct nss_n2h_pnode_queue_config), NULL, 0);
1029
ratheesh kannothab436af2017-07-20 08:51:07 +05301030 cfg = &nnm.msg.pn_q_cfg;
1031
1032 /*
Cemil Coskun9165c762017-12-04 14:35:24 -08001033 * Update limits
1034 */
ratheesh kannothab436af2017-07-20 08:51:07 +05301035 for (i = 0; i < NSS_MAX_NUM_PRI; i++) {
1036 cfg->qlimits[i] = qlimits[i];
1037 }
1038 cfg->mq_en = true;
1039
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301040 status = nss_n2h_tx_msg(nss_ctx, &nnm);
1041 if (status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001042 nss_warning("%px: nss_tx error to send pnode queue config\n", nss_ctx);
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301043 return status;
1044 }
1045
1046 return NSS_TX_SUCCESS;
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301047}
ratheesh kannothab436af2017-07-20 08:51:07 +05301048EXPORT_SYMBOL(nss_n2h_update_queue_config_async);
1049
1050/*
1051 * nss_n2h_update_queue_config_sync()
1052 * Synchronous call to send pnode queue configuration.
1053 */
1054nss_tx_status_t nss_n2h_update_queue_config_sync(struct nss_ctx_instance *nss_ctx, bool mq_en, uint16_t *qlimits)
1055{
1056
1057 struct nss_n2h_msg nnm;
1058 struct nss_n2h_pnode_queue_config *cfg;
1059 nss_tx_status_t status;
1060 int ret, i;
1061
1062 if (!mq_en) {
1063 return NSS_TX_SUCCESS;
1064 }
1065
ratheesh kannoth93ba95c2017-07-13 15:52:52 +05301066 /*
1067 * MQ mode doesnot make any sense if number of priority queues in NSS
1068 * is 1
1069 */
1070 if (NSS_MAX_NUM_PRI <= 1) {
1071 return NSS_TX_SUCCESS;
1072 }
1073
ratheesh kannothab436af2017-07-20 08:51:07 +05301074 memset(&nnm, 0, sizeof(struct nss_n2h_msg));
1075
1076 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1077 NSS_TX_METADATA_TYPE_N2H_SET_PNODE_QUEUE_CFG,
1078 sizeof(struct nss_n2h_pnode_queue_config), nss_n2h_update_queue_config_callback, 0);
1079
1080 cfg = &nnm.msg.pn_q_cfg;
1081
1082 /*
Cemil Coskun9165c762017-12-04 14:35:24 -08001083 * Update limits
1084 */
ratheesh kannothab436af2017-07-20 08:51:07 +05301085 for (i = 0; i < NSS_MAX_NUM_PRI; i++) {
1086 cfg->qlimits[i] = qlimits[i];
1087 }
1088 cfg->mq_en = true;
1089
1090 down(&nss_n2h_q_cfg_pvt.sem);
1091
1092 status = nss_n2h_tx_msg(nss_ctx, &nnm);
1093
1094 if (status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001095 nss_warning("%px: n2h_tx_msg failed\n", nss_ctx);
ratheesh kannothab436af2017-07-20 08:51:07 +05301096 up(&nss_n2h_q_cfg_pvt.sem);
1097 return status;
1098 }
1099 ret = wait_for_completion_timeout(&nss_n2h_q_cfg_pvt.complete, msecs_to_jiffies(NSS_N2H_TX_TIMEOUT));
1100
1101 if (!ret) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001102 nss_warning("%px: Timeout expired for pnode queue config sync message\n", nss_ctx);
ratheesh kannothab436af2017-07-20 08:51:07 +05301103 nss_n2h_q_cfg_pvt.response = NSS_TX_FAILURE;
1104 }
1105
1106 status = nss_n2h_q_cfg_pvt.response;
1107 up(&nss_n2h_q_cfg_pvt.sem);
1108 return status;
1109}
1110EXPORT_SYMBOL(nss_n2h_update_queue_config_sync);
ratheesh kannoth024a6e82017-05-18 17:48:10 +05301111
1112/*
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301113 * nss_n2h_mitigation_cfg()
1114 * Send Message to NSS to disable MITIGATION.
1115 */
Stephen Wang49b474b2016-03-25 10:40:30 -07001116static 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 +05301117{
1118 struct nss_n2h_msg nnm;
1119 struct nss_n2h_mitigation *mitigation_cfg;
1120 nss_tx_status_t nss_tx_status;
1121 int ret;
1122
1123 nss_assert(core_num < NSS_CORE_MAX);
1124
1125 down(&nss_n2h_mitigationcp[core_num].sem);
1126 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG,
1127 sizeof(struct nss_n2h_mitigation),
1128 nss_n2h_mitigation_cfg_callback,
1129 (void *)core_num);
1130
1131 mitigation_cfg = &nnm.msg.mitigation_cfg;
1132 mitigation_cfg->enable = enable_mitigation;
1133
1134 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1135
1136 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001137 nss_warning("%px: nss_tx error setting mitigation\n", nss_ctx);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301138 goto failure;
1139 }
1140
1141 /*
1142 * Blocking call, wait till we get ACK for this msg.
1143 */
1144 ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
1145 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001146 nss_warning("%px: Waiting for ack timed out\n", nss_ctx);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301147 goto failure;
1148 }
1149
1150 /*
1151 * ACK/NACK received from NSS FW
1152 */
1153 if (NSS_FAILURE == nss_n2h_mitigationcp[core_num].response) {
1154 goto failure;
1155 }
1156
1157 up(&nss_n2h_mitigationcp[core_num].sem);
1158 return NSS_SUCCESS;
1159
1160failure:
1161 up(&nss_n2h_mitigationcp[core_num].sem);
1162 return NSS_FAILURE;
1163}
1164
1165static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool)
1166{
1167 int page_count;
1168 for (page_count = 0; page_count < buf_pool->nss_buf_num_pages; page_count++) {
Stephen Wang7df68832017-08-10 16:54:35 -07001169 kfree((void *)buf_pool->nss_buf_pool_vaddr[page_count]);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301170 }
1171}
1172
1173/*
1174 * nss_n2h_buf_cfg()
1175 * Send Message to NSS to enable pbufs.
1176 */
Stephen Wang49b474b2016-03-25 10:40:30 -07001177static nss_tx_status_t nss_n2h_buf_pool_cfg(struct nss_ctx_instance *nss_ctx,
Tallapragada4b0161b2016-07-07 21:38:34 +05301178 int buf_pool_size, nss_core_id_t core_num)
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301179{
1180 static struct nss_n2h_msg nnm;
1181 struct nss_n2h_buf_pool *buf_pool;
1182 nss_tx_status_t nss_tx_status;
1183 int ret;
1184 int page_count;
1185 int num_pages = ALIGN(buf_pool_size, PAGE_SIZE)/PAGE_SIZE;
1186
1187 nss_assert(core_num < NSS_CORE_MAX);
1188
1189 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_METADATA_TYPE_N2H_ADD_BUF_POOL,
1190 sizeof(struct nss_n2h_buf_pool),
1191 nss_n2h_bufs_cfg_callback,
1192 (void *)core_num);
1193
1194 do {
1195
1196 down(&nss_n2h_bufcp[core_num].sem);
1197
1198 buf_pool = &nnm.msg.buf_pool;
1199 buf_pool->nss_buf_page_size = PAGE_SIZE;
1200
1201 for (page_count = 0; page_count < MAX_PAGES_PER_MSG && num_pages; page_count++, num_pages--) {
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301202 void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC);
1203 if (!kern_addr) {
1204 BUG_ON(!page_count);
1205 break;
1206 }
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301207
Radha krishna Simha Jiguru60068fb2017-07-28 17:40:52 +05301208 kmemleak_not_leak(kern_addr);
Stephen Wang7df68832017-08-10 16:54:35 -07001209 buf_pool->nss_buf_pool_vaddr[page_count] = (nss_ptr_t)kern_addr;
Stephen Wangefd38512017-01-24 14:01:02 -08001210 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 +05301211 }
1212
1213 buf_pool->nss_buf_num_pages = page_count;
1214 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1215 if (nss_tx_status != NSS_TX_SUCCESS) {
1216
1217 nss_n2h_buf_pool_free(buf_pool);
Kyle Swensondd7b2962021-03-16 13:46:32 -06001218 nss_warning("%px: nss_tx error setting pbuf\n", nss_ctx);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301219 goto failure;
1220 }
1221
1222 /*
Cemil Coskun9165c762017-12-04 14:35:24 -08001223 * Blocking call, wait till we get ACK for this msg.
1224 */
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301225 ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
1226 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001227 nss_warning("%px: Waiting for ack timed out\n", nss_ctx);
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301228 goto failure;
1229 }
1230
1231 /*
1232 * ACK/NACK received from NSS FW
1233 */
1234 if (NSS_FAILURE == nss_n2h_bufcp[core_num].response) {
1235
1236 nss_n2h_buf_pool_free(buf_pool);
1237 goto failure;
1238 }
1239
1240 up(&nss_n2h_bufcp[core_num].sem);
1241 } while(num_pages);
1242
1243 return NSS_SUCCESS;
1244failure:
1245 up(&nss_n2h_bufcp[core_num].sem);
1246 return NSS_FAILURE;
1247}
1248
Stephen Wang49b474b2016-03-25 10:40:30 -07001249/*
1250 * nss_mitigation_handler()
1251 * Enable NSS MITIGATION
1252 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001253static 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 -07001254{
1255 struct nss_top_instance *nss_top = &nss_top_main;
1256 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0];
1257 int ret;
1258
1259 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1260 if (ret) {
1261 return ret;
1262 }
1263
1264 /*
1265 * It's a read operation
1266 */
1267 if (!write) {
1268 return ret;
1269 }
1270
1271 if (!nss_n2h_core0_mitigation_cfg) {
1272 printk(KERN_INFO "Disabling NSS MITIGATION\n");
1273 nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_0);
1274 return 0;
1275 }
1276 printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n");
1277 return -EINVAL;
1278}
1279
1280/*
1281 * nss_mitigation_handler()
1282 * Enable NSS MITIGATION
1283 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001284static 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 -07001285{
1286 struct nss_top_instance *nss_top = &nss_top_main;
1287 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1];
1288 int ret;
1289
1290 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1291 if (ret) {
1292 return ret;
1293 }
1294
1295 /*
1296 * It's a read operation
1297 */
1298 if (!write) {
1299 return ret;
1300 }
1301
1302 if (!nss_n2h_core1_mitigation_cfg) {
1303 printk(KERN_INFO "Disabling NSS MITIGATION\n");
1304 nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_1);
1305 return 0;
1306 }
1307 printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n");
1308 return -EINVAL;
1309}
1310
1311/*
1312 * nss_buf_handler()
1313 * Add extra NSS bufs from host memory
1314 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001315static 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 -07001316{
1317 struct nss_top_instance *nss_top = &nss_top_main;
1318 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0];
1319 int ret;
1320
1321 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1322 if (ret) {
1323 return ret;
1324 }
1325
1326 /*
1327 * It's a read operation
1328 */
1329 if (!write) {
1330 return ret;
1331 }
1332
1333 if (nss_ctx->buf_sz_allocated) {
1334 nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1335 return -EPERM;
1336 }
1337
1338 if ((nss_n2h_core0_add_buf_pool_size >= 1) && (nss_n2h_core0_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) {
1339 printk(KERN_INFO "configuring additional NSS pbufs\n");
1340 ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core0_add_buf_pool_size, NSS_CORE_0);
1341 nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1342 printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated);
1343 return ret;
1344 }
1345
1346 printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE);
1347 return -EINVAL;
1348}
1349
1350/*
1351 * nss_n2h_buf_handler()
1352 * Add extra NSS bufs from host memory
1353 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001354static 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 -07001355{
1356 struct nss_top_instance *nss_top = &nss_top_main;
1357 struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1];
1358 int ret;
1359
1360 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1361 if (ret) {
1362 return ret;
1363 }
1364
1365 /*
1366 * It's a read operation
1367 */
1368 if (!write) {
1369 return ret;
1370 }
1371
1372 if (nss_ctx->buf_sz_allocated) {
1373 nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1374 return -EPERM;
1375 }
1376
1377 if ((nss_n2h_core1_add_buf_pool_size >= 1) && (nss_n2h_core1_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) {
1378 printk(KERN_INFO "configuring additional NSS pbufs\n");
1379 ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core1_add_buf_pool_size, NSS_CORE_1);
1380 nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated;
1381 printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated);
1382 return ret;
1383 }
1384
1385 printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE);
1386 return -EINVAL;
1387}
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05301388
Shashank Balashankar4162f572018-08-21 13:32:34 -07001389/*
1390 * nss_n2h_queue_limit_callback()
1391 * Callback to handle the completion of queue limit command.
1392 */
1393static void nss_n2h_queue_limit_callback(void *app_data, struct nss_n2h_msg *nim)
1394{
1395 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
1396 nss_warning("n2h error response %d\n", nim->cm.response);
1397 }
1398
1399 nss_n2h_q_lim_pvt.response = nim->cm.response;
1400 complete(&nss_n2h_q_lim_pvt.complete);
1401}
1402
1403/*
1404 * nss_n2h_set_queue_limit_sync()
1405 * Sets the n2h queue size limit synchronously.
1406 */
1407static int nss_n2h_set_queue_limit_sync(struct ctl_table *ctl, int write, void __user *buffer,
1408 size_t *lenp, loff_t *ppos, uint32_t core_id)
1409{
1410 struct nss_top_instance *nss_top = &nss_top_main;
1411 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id];
1412 struct nss_n2h_msg nim;
1413 struct nss_n2h_queue_limit_config *nnqlc = NULL;
1414 int ret, current_val;
1415 nss_tx_status_t nss_tx_status;
1416
1417 /*
1418 * Take a snap shot of current value
1419 */
1420 current_val = nss_n2h_queue_limit[core_id];
1421
1422 /*
1423 * Write the variable with user input
1424 */
1425 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1426 if (ret || (!write)) {
1427 return ret;
1428 }
1429
1430 /*
1431 * We dont allow shortening of the queue size at run-time
1432 */
1433 if (nss_n2h_queue_limit[core_id] < current_val) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001434 nss_warning("%px: New queue limit %d less than previous value %d. Cant allow shortening\n",
Shashank Balashankar4162f572018-08-21 13:32:34 -07001435 nss_ctx, nss_n2h_queue_limit[core_id], current_val);
1436 nss_n2h_queue_limit[core_id] = current_val;
1437 return NSS_TX_FAILURE;
1438 }
1439
1440 memset(&nim, 0, sizeof(struct nss_n2h_msg));
1441 nss_n2h_msg_init(&nim, NSS_N2H_INTERFACE,
1442 NSS_TX_METADATA_TYPE_N2H_QUEUE_LIMIT_CFG,
1443 sizeof(struct nss_n2h_queue_limit_config), nss_n2h_queue_limit_callback, NULL);
1444
1445 nnqlc = &nim.msg.ql_cfg;
1446 nnqlc->qlimit = nss_n2h_queue_limit[core_id];
1447
1448 /*
1449 * Send synchronous message to firmware
1450 */
1451 down(&nss_n2h_q_lim_pvt.sem);
1452
1453 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nim);
1454 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001455 nss_warning("%px: n2h queue limit message send failed\n", nss_ctx);
Shashank Balashankar4162f572018-08-21 13:32:34 -07001456 nss_n2h_queue_limit[core_id] = current_val;
1457 up(&nss_n2h_q_lim_pvt.sem);
1458 return nss_tx_status;
1459 }
1460
1461 ret = wait_for_completion_timeout(&nss_n2h_q_lim_pvt.complete, msecs_to_jiffies(NSS_N2H_TX_TIMEOUT));
1462 if (!ret) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001463 nss_warning("%px: Timeout expired for queue limit sync message\n", nss_ctx);
Shashank Balashankar4162f572018-08-21 13:32:34 -07001464 nss_n2h_queue_limit[core_id] = current_val;
1465 up(&nss_n2h_q_lim_pvt.sem);
1466 return NSS_TX_FAILURE;
1467 }
1468
1469 /*
1470 * If setting the queue limit failed, reset the value to original value
1471 */
1472 if (nss_n2h_q_lim_pvt.response != NSS_CMN_RESPONSE_ACK) {
1473 nss_n2h_queue_limit[core_id] = current_val;
1474 }
1475
1476 up(&nss_n2h_q_lim_pvt.sem);
1477 return NSS_TX_SUCCESS;
1478}
1479
1480/*
1481 * nss_n2h_queue_limit_core0_handler()
1482 * Sets the n2h queue size limit for core0
1483 */
1484static int nss_n2h_queue_limit_core0_handler(struct ctl_table *ctl,
1485 int write, void __user *buffer,
1486 size_t *lenp, loff_t *ppos)
1487{
1488 return nss_n2h_set_queue_limit_sync(ctl, write, buffer, lenp, ppos,
1489 NSS_CORE_0);
1490}
1491
1492/*
1493 * nss_n2h_queue_limit_core1_handler()
1494 * Sets the n2h queue size limit for core1
1495 */
1496static int nss_n2h_queue_limit_core1_handler(struct ctl_table *ctl,
1497 int write, void __user *buffer,
1498 size_t *lenp, loff_t *ppos)
1499{
1500 return nss_n2h_set_queue_limit_sync(ctl, write, buffer, lenp, ppos,
1501 NSS_CORE_1);
1502}
1503
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001504/*
1505 * nss_n2h_host_bp_cfg_callback()
1506 * Callback function for back pressure configuration.
1507 */
1508static void nss_n2h_host_bp_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
1509{
1510 struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data;
1511 if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
1512 nss_n2h_host_bp_cfg_pvt.response = NSS_FAILURE;
1513 complete(&nss_n2h_host_bp_cfg_pvt.complete);
Kyle Swensondd7b2962021-03-16 13:46:32 -06001514 nss_warning("%px: n2h back pressure configuration failed : %d\n", nss_ctx, nnm->cm.error);
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001515 return;
1516 }
1517
Kyle Swensondd7b2962021-03-16 13:46:32 -06001518 nss_info("%px: n2h back pressure configuration succeeded: %d\n", nss_ctx, nnm->cm.error);
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001519 nss_n2h_host_bp_cfg_pvt.response = NSS_SUCCESS;
1520 complete(&nss_n2h_host_bp_cfg_pvt.complete);
1521}
1522
1523/*
1524 * nss_n2h_host_bp_cfg()
1525 * Send Message to n2h to enable back pressure.
1526 */
1527static nss_tx_status_t nss_n2h_host_bp_cfg_sync(struct nss_ctx_instance *nss_ctx, int enable_bp)
1528{
1529 struct nss_n2h_msg nnm;
1530 nss_tx_status_t nss_tx_status;
1531 int ret;
1532
1533 down(&nss_n2h_host_bp_cfg_pvt.sem);
1534 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_HOST_BACK_PRESSURE_CFG,
1535 sizeof(struct nss_n2h_host_back_pressure),
1536 nss_n2h_host_bp_cfg_callback,
1537 (void *)nss_ctx);
1538
1539 nnm.msg.host_bp_cfg.enable = enable_bp;
1540
1541 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1542 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001543 nss_warning("%px: nss_tx error setting back pressure\n", nss_ctx);
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001544 up(&nss_n2h_host_bp_cfg_pvt.sem);
1545 return NSS_FAILURE;
1546 }
1547
1548 /*
1549 * Blocking call, wait till we get ACK for this msg.
1550 */
1551 ret = wait_for_completion_timeout(&nss_n2h_host_bp_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
1552 if (ret == 0) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001553 nss_warning("%px: Waiting for ack timed out\n", nss_ctx);
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001554 up(&nss_n2h_host_bp_cfg_pvt.sem);
1555 return NSS_FAILURE;
1556 }
1557
1558 /*
1559 * Response received from NSS FW
1560 */
1561 if (nss_n2h_host_bp_cfg_pvt.response == NSS_FAILURE) {
1562 up(&nss_n2h_host_bp_cfg_pvt.sem);
1563 return NSS_FAILURE;
1564 }
1565
1566 up(&nss_n2h_host_bp_cfg_pvt.sem);
1567 return NSS_SUCCESS;
1568}
1569
1570/*
1571 * nss_n2h_host_bp_cfg_handler()
1572 * Enable n2h back pressure.
1573 */
1574static int nss_n2h_host_bp_cfg_handler(struct ctl_table *ctl, int write,
1575 void __user *buffer, size_t *lenp, loff_t *ppos, uint32_t core_id)
1576{
1577 struct nss_top_instance *nss_top = &nss_top_main;
1578 struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id];
1579 int ret, ret_bp, current_state;
1580 current_state = nss_n2h_host_bp_config[core_id];
1581 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1582
1583 if (ret != NSS_SUCCESS) {
1584 return ret;
1585 }
1586
1587 if (!write) {
1588 return ret;
1589 }
1590
1591 if ((nss_n2h_host_bp_config[core_id] != 0) && (nss_n2h_host_bp_config[core_id] != 1)) {
1592 nss_info_always("Invalid input value. Valid values are 0 and 1\n");
1593 nss_n2h_host_bp_config[core_id] = current_state;
1594 return ret;
1595 }
1596
1597 nss_info("Configuring n2h back pressure\n");
1598 ret_bp = nss_n2h_host_bp_cfg_sync(nss_ctx, nss_n2h_host_bp_config[core_id]);
1599
1600 if (ret_bp != NSS_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001601 nss_warning("%px: n2h back pressure config failed\n", nss_ctx);
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001602 nss_n2h_host_bp_config[core_id] = current_state;
1603 }
1604
1605 return ret_bp;
1606}
1607
1608/*
1609 * nss_n2h_host_bp_cfg_core0_handler()
1610 * Enable n2h back pressure in core 0.
1611 */
1612static int nss_n2h_host_bp_cfg_core0_handler(struct ctl_table *ctl, int write,
1613 void __user *buffer, size_t *lenp, loff_t *ppos)
1614{
1615 return nss_n2h_host_bp_cfg_handler(ctl, write, buffer, lenp, ppos, NSS_CORE_0);
1616}
1617
1618/*
1619 * nss_n2h_host_bp_cfg_core1_handler()
1620 * Enable n2h back pressure in core 1.
1621 */
1622static int nss_n2h_host_bp_cfg_core1_handler(struct ctl_table *ctl, int write,
1623 void __user *buffer, size_t *lenp, loff_t *ppos)
1624{
1625 return nss_n2h_host_bp_cfg_handler(ctl, write, buffer, lenp, ppos, NSS_CORE_1);
1626}
1627
Suman Ghosh9f7b3702018-09-21 19:51:40 +05301628static struct ctl_table nss_n2h_table_single_core[] = {
1629 {
1630 .procname = "n2h_empty_pool_buf_core0",
1631 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0],
1632 .maxlen = sizeof(int),
1633 .mode = 0644,
1634 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler,
1635 },
1636 {
1637 .procname = "n2h_empty_paged_pool_buf_core0",
1638 .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0],
1639 .maxlen = sizeof(int),
1640 .mode = 0644,
1641 .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core0_handler,
1642 },
1643 {
1644 .procname = "n2h_low_water_core0",
1645 .data = &nss_n2h_water_mark[NSS_CORE_0][0],
1646 .maxlen = sizeof(int),
1647 .mode = 0644,
1648 .proc_handler = &nss_n2h_water_mark_core0_handler,
1649 },
1650 {
1651 .procname = "n2h_high_water_core0",
1652 .data = &nss_n2h_water_mark[NSS_CORE_0][1],
1653 .maxlen = sizeof(int),
1654 .mode = 0644,
1655 .proc_handler = &nss_n2h_water_mark_core0_handler,
1656 },
1657 {
1658 .procname = "n2h_paged_low_water_core0",
1659 .data = &nss_n2h_paged_water_mark[NSS_CORE_0][0],
1660 .maxlen = sizeof(int),
1661 .mode = 0644,
1662 .proc_handler = &nss_n2h_paged_water_mark_core0_handler,
1663 },
1664 {
1665 .procname = "n2h_paged_high_water_core0",
1666 .data = &nss_n2h_paged_water_mark[NSS_CORE_0][1],
1667 .maxlen = sizeof(int),
1668 .mode = 0644,
1669 .proc_handler = &nss_n2h_paged_water_mark_core0_handler,
1670 },
1671 {
1672 .procname = "n2h_wifi_pool_buf",
1673 .data = &nss_n2h_wifi_pool_buf_cfg,
1674 .maxlen = sizeof(int),
1675 .mode = 0644,
1676 .proc_handler = &nss_n2h_wifi_payloads_handler,
1677 },
1678 {
1679 .procname = "mitigation_core0",
1680 .data = &nss_n2h_core0_mitigation_cfg,
1681 .maxlen = sizeof(int),
1682 .mode = 0644,
1683 .proc_handler = &nss_n2h_mitigationcfg_core0_handler,
1684 },
1685 {
1686 .procname = "extra_pbuf_core0",
1687 .data = &nss_n2h_core0_add_buf_pool_size,
1688 .maxlen = sizeof(int),
1689 .mode = 0644,
1690 .proc_handler = &nss_n2h_buf_cfg_core0_handler,
1691 },
1692 {
1693 .procname = "n2h_queue_limit_core0",
1694 .data = &nss_n2h_queue_limit[NSS_CORE_0],
1695 .maxlen = sizeof(int),
1696 .mode = 0644,
1697 .proc_handler = &nss_n2h_queue_limit_core0_handler,
1698 },
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001699 {
1700 .procname = "host_bp_enable0",
1701 .data = &nss_n2h_host_bp_config[NSS_CORE_0],
1702 .maxlen = sizeof(int),
1703 .mode = 0644,
1704 .proc_handler = &nss_n2h_host_bp_cfg_core0_handler,
1705 },
Suman Ghosh9f7b3702018-09-21 19:51:40 +05301706
1707 { }
1708};
1709
1710static struct ctl_table nss_n2h_table_multi_core[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001711 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001712 .procname = "n2h_empty_pool_buf_core0",
1713 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0],
1714 .maxlen = sizeof(int),
1715 .mode = 0644,
1716 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001717 },
1718 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001719 .procname = "n2h_empty_pool_buf_core1",
1720 .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1],
1721 .maxlen = sizeof(int),
1722 .mode = 0644,
1723 .proc_handler = &nss_n2h_empty_pool_buf_cfg_core1_handler,
1724 },
1725 {
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001726 .procname = "n2h_empty_paged_pool_buf_core0",
1727 .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0],
1728 .maxlen = sizeof(int),
1729 .mode = 0644,
1730 .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core0_handler,
1731 },
1732 {
1733 .procname = "n2h_empty_paged_pool_buf_core1",
1734 .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1],
1735 .maxlen = sizeof(int),
1736 .mode = 0644,
1737 .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core1_handler,
1738 },
1739
1740 {
Saurabh Misra71034db2015-06-04 16:18:38 -07001741 .procname = "n2h_low_water_core0",
1742 .data = &nss_n2h_water_mark[NSS_CORE_0][0],
1743 .maxlen = sizeof(int),
1744 .mode = 0644,
1745 .proc_handler = &nss_n2h_water_mark_core0_handler,
1746 },
1747 {
1748 .procname = "n2h_low_water_core1",
1749 .data = &nss_n2h_water_mark[NSS_CORE_1][0],
1750 .maxlen = sizeof(int),
1751 .mode = 0644,
1752 .proc_handler = &nss_n2h_water_mark_core1_handler,
1753 },
1754 {
1755 .procname = "n2h_high_water_core0",
1756 .data = &nss_n2h_water_mark[NSS_CORE_0][1],
1757 .maxlen = sizeof(int),
1758 .mode = 0644,
1759 .proc_handler = &nss_n2h_water_mark_core0_handler,
1760 },
1761 {
1762 .procname = "n2h_high_water_core1",
1763 .data = &nss_n2h_water_mark[NSS_CORE_1][1],
1764 .maxlen = sizeof(int),
1765 .mode = 0644,
1766 .proc_handler = &nss_n2h_water_mark_core1_handler,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001767 },
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301768 {
Sachin Shashidhar475012b2017-03-13 16:56:07 -07001769 .procname = "n2h_paged_low_water_core0",
1770 .data = &nss_n2h_paged_water_mark[NSS_CORE_0][0],
1771 .maxlen = sizeof(int),
1772 .mode = 0644,
1773 .proc_handler = &nss_n2h_paged_water_mark_core0_handler,
1774 },
1775 {
1776 .procname = "n2h_paged_low_water_core1",
1777 .data = &nss_n2h_paged_water_mark[NSS_CORE_1][0],
1778 .maxlen = sizeof(int),
1779 .mode = 0644,
1780 .proc_handler = &nss_n2h_paged_water_mark_core1_handler,
1781 },
1782 {
1783 .procname = "n2h_paged_high_water_core0",
1784 .data = &nss_n2h_paged_water_mark[NSS_CORE_0][1],
1785 .maxlen = sizeof(int),
1786 .mode = 0644,
1787 .proc_handler = &nss_n2h_paged_water_mark_core0_handler,
1788 },
1789 {
1790 .procname = "n2h_paged_high_water_core1",
1791 .data = &nss_n2h_paged_water_mark[NSS_CORE_1][1],
1792 .maxlen = sizeof(int),
1793 .mode = 0644,
1794 .proc_handler = &nss_n2h_paged_water_mark_core1_handler,
1795 },
1796 {
Pamidipati, Vijayee9c2972016-01-10 08:13:19 +05301797 .procname = "n2h_wifi_pool_buf",
1798 .data = &nss_n2h_wifi_pool_buf_cfg,
1799 .maxlen = sizeof(int),
1800 .mode = 0644,
1801 .proc_handler = &nss_n2h_wifi_payloads_handler,
1802 },
Stephen Wang49b474b2016-03-25 10:40:30 -07001803 {
Stephen Wang49b474b2016-03-25 10:40:30 -07001804 .procname = "mitigation_core0",
1805 .data = &nss_n2h_core0_mitigation_cfg,
1806 .maxlen = sizeof(int),
1807 .mode = 0644,
1808 .proc_handler = &nss_n2h_mitigationcfg_core0_handler,
1809 },
1810 {
1811 .procname = "mitigation_core1",
1812 .data = &nss_n2h_core1_mitigation_cfg,
1813 .maxlen = sizeof(int),
1814 .mode = 0644,
1815 .proc_handler = &nss_n2h_mitigationcfg_core1_handler,
1816 },
1817 {
1818 .procname = "extra_pbuf_core0",
1819 .data = &nss_n2h_core0_add_buf_pool_size,
1820 .maxlen = sizeof(int),
1821 .mode = 0644,
1822 .proc_handler = &nss_n2h_buf_cfg_core0_handler,
1823 },
1824 {
1825 .procname = "extra_pbuf_core1",
1826 .data = &nss_n2h_core1_add_buf_pool_size,
1827 .maxlen = sizeof(int),
1828 .mode = 0644,
1829 .proc_handler = &nss_n2h_buf_cfg_core1_handler,
1830 },
Shashank Balashankar4162f572018-08-21 13:32:34 -07001831 {
1832 .procname = "n2h_queue_limit_core0",
1833 .data = &nss_n2h_queue_limit[NSS_CORE_0],
1834 .maxlen = sizeof(int),
1835 .mode = 0644,
1836 .proc_handler = &nss_n2h_queue_limit_core0_handler,
1837 },
1838 {
1839 .procname = "n2h_queue_limit_core1",
1840 .data = &nss_n2h_queue_limit[NSS_CORE_1],
1841 .maxlen = sizeof(int),
1842 .mode = 0644,
1843 .proc_handler = &nss_n2h_queue_limit_core1_handler,
1844 },
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08001845 {
1846 .procname = "host_bp_enable0",
1847 .data = &nss_n2h_host_bp_config[NSS_CORE_0],
1848 .maxlen = sizeof(int),
1849 .mode = 0644,
1850 .proc_handler = &nss_n2h_host_bp_cfg_core0_handler,
1851 },
1852 {
1853 .procname = "host_bp_enable1",
1854 .data = &nss_n2h_host_bp_config[NSS_CORE_1],
1855 .maxlen = sizeof(int),
1856 .mode = 0644,
1857 .proc_handler = &nss_n2h_host_bp_cfg_core1_handler,
1858 },
Vijay Dewangan488e5372014-12-29 21:40:11 -08001859 { }
1860};
1861
Suman Ghosh9f7b3702018-09-21 19:51:40 +05301862/*
1863 * This table will be overwritten during single-core registration
1864 */
Stephen Wang52e6d342016-03-29 15:02:33 -07001865static struct ctl_table nss_n2h_dir[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001866 {
1867 .procname = "n2hcfg",
1868 .mode = 0555,
Suman Ghosh9f7b3702018-09-21 19:51:40 +05301869 .child = nss_n2h_table_multi_core,
Vijay Dewangan488e5372014-12-29 21:40:11 -08001870 },
1871 { }
1872};
1873
Stephen Wang52e6d342016-03-29 15:02:33 -07001874static struct ctl_table nss_n2h_root_dir[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001875 {
1876 .procname = "nss",
1877 .mode = 0555,
1878 .child = nss_n2h_dir,
1879 },
1880 { }
1881};
1882
Stephen Wang52e6d342016-03-29 15:02:33 -07001883static struct ctl_table nss_n2h_root[] = {
Vijay Dewangan488e5372014-12-29 21:40:11 -08001884 {
1885 .procname = "dev",
1886 .mode = 0555,
1887 .child = nss_n2h_root_dir,
1888 },
1889 { }
1890};
1891
1892static struct ctl_table_header *nss_n2h_header;
1893
1894/*
Amit Guptaca2ea682019-01-24 17:18:46 +05301895 * nss_n2h_cfg_empty_pool_size()
1896 * Config empty buffer pool
1897 */
1898nss_tx_status_t nss_n2h_cfg_empty_pool_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz)
1899{
1900 struct nss_n2h_msg nnm;
1901 struct nss_n2h_empty_pool_buf *nnepbcm;
1902 nss_tx_status_t nss_tx_status;
1903
1904 if (pool_sz < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001905 nss_warning("%px: setting pool size %d < min number of buffer",
Amit Guptaca2ea682019-01-24 17:18:46 +05301906 nss_ctx, pool_sz);
1907 return NSS_TX_FAILURE;
1908 }
1909
1910 if (pool_sz > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001911 nss_warning("%px: setting pool size %d > max number of buffer",
Amit Guptaca2ea682019-01-24 17:18:46 +05301912 nss_ctx, pool_sz);
1913 return NSS_TX_FAILURE;
1914 }
1915
Kyle Swensondd7b2962021-03-16 13:46:32 -06001916 nss_info("%px: update number of empty buffer pool size: %d\n",
Amit Guptaca2ea682019-01-24 17:18:46 +05301917 nss_ctx, pool_sz);
1918
1919 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1920 NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG,
1921 sizeof(struct nss_n2h_empty_pool_buf), NULL, 0);
1922
1923 nnepbcm = &nnm.msg.empty_pool_buf_cfg;
1924 nnepbcm->pool_size = htonl(pool_sz);
1925 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1926
1927 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001928 nss_warning("%px: nss_tx error empty buffer pool: %d\n", nss_ctx, pool_sz);
Amit Guptaca2ea682019-01-24 17:18:46 +05301929 return nss_tx_status;
1930 }
1931
1932 return nss_tx_status;
1933}
1934
1935/*
Amit Gupta738f97e2019-01-11 18:54:55 +05301936 * nss_n2h_paged_buf_pool_init()
1937 * Sends a command down to NSS to initialize paged buffer pool
1938 */
1939nss_tx_status_t nss_n2h_paged_buf_pool_init(struct nss_ctx_instance *nss_ctx)
1940{
1941 struct nss_n2h_msg nnm;
1942 nss_tx_status_t nss_tx_status;
1943
1944 /*
1945 * No additional information needed at this point
1946 */
1947 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1948 NSS_TX_METADATA_TYPE_N2H_PAGED_BUFFER_POOL_INIT,
1949 sizeof(struct nss_n2h_paged_buffer_pool_init),
1950 NULL,
1951 NULL);
1952
1953 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1954 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001955 nss_warning("%px: failed to send paged buf configuration init command to NSS\n",
Amit Gupta738f97e2019-01-11 18:54:55 +05301956 nss_ctx);
1957 return NSS_TX_FAILURE;
1958 }
1959
1960 return NSS_TX_SUCCESS;
1961}
1962
1963/*
Stephen Wang49b474b2016-03-25 10:40:30 -07001964 * nss_n2h_flush_payloads()
Cemil Coskun9165c762017-12-04 14:35:24 -08001965 * Sends a command down to NSS for flushing all payloads
Stephen Wang49b474b2016-03-25 10:40:30 -07001966 */
1967nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx)
1968{
1969 struct nss_n2h_msg nnm;
1970 struct nss_n2h_flush_payloads *nnflshpl;
1971 nss_tx_status_t nss_tx_status;
1972
1973 nnflshpl = &nnm.msg.flush_payloads;
1974
1975 /*
1976 * TODO: No additional information sent in message
1977 * as of now. Need to initialize message content accordingly
1978 * if needed.
1979 */
1980 nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
1981 NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS,
1982 sizeof(struct nss_n2h_flush_payloads),
1983 NULL,
1984 NULL);
1985
1986 nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
1987 if (nss_tx_status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06001988 nss_warning("%px: failed to send flush payloads command to NSS\n",
Stephen Wang49b474b2016-03-25 10:40:30 -07001989 nss_ctx);
1990
1991 return NSS_TX_FAILURE;
1992 }
1993
1994 return NSS_TX_SUCCESS;
1995}
1996
1997/*
Vijay Dewangan488e5372014-12-29 21:40:11 -08001998 * nss_n2h_msg_init()
Stephen Wang49b474b2016-03-25 10:40:30 -07001999 * Initialize n2h message.
Vijay Dewangan488e5372014-12-29 21:40:11 -08002000 */
2001void nss_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type,
Vijay Dewangan634ce592015-01-07 17:21:09 -08002002 uint32_t len, nss_n2h_msg_callback_t cb, void *app_data)
Vijay Dewangan488e5372014-12-29 21:40:11 -08002003{
2004 nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data);
2005}
2006
Vijay Dewangan488e5372014-12-29 21:40:11 -08002007/*
Vijay Dewangan488e5372014-12-29 21:40:11 -08002008 * nss_n2h_tx_msg()
Cemil Coskun9165c762017-12-04 14:35:24 -08002009 * Send messages to NSS n2h package.
Vijay Dewangan488e5372014-12-29 21:40:11 -08002010 */
2011nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm)
2012{
Vijay Dewangan488e5372014-12-29 21:40:11 -08002013 struct nss_cmn_msg *ncm = &nnm->cm;
Vijay Dewangan488e5372014-12-29 21:40:11 -08002014
2015 /*
2016 * Sanity check the message
2017 */
2018 if (ncm->interface != NSS_N2H_INTERFACE) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06002019 nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface);
Vijay Dewangan488e5372014-12-29 21:40:11 -08002020 return NSS_TX_FAILURE;
2021 }
2022
2023 if (ncm->type >= NSS_METADATA_TYPE_N2H_MAX) {
Kyle Swensondd7b2962021-03-16 13:46:32 -06002024 nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type);
Vijay Dewangan488e5372014-12-29 21:40:11 -08002025 return NSS_TX_FAILURE;
2026 }
2027
Stephen Wang3e2dbd12018-03-14 17:28:17 -07002028 return nss_core_send_cmd(nss_ctx, nnm, sizeof(*nnm), NSS_NBUF_PAYLOAD_SIZE);
Vijay Dewangan488e5372014-12-29 21:40:11 -08002029}
2030
Vijay Dewangan488e5372014-12-29 21:40:11 -08002031/*
2032 * nss_n2h_notify_register()
2033 * Register to received N2H events.
2034 *
2035 * NOTE: Do we want to pass an nss_ctx here so that we can register for n2h on any core?
2036 */
2037struct nss_ctx_instance *nss_n2h_notify_register(int core, nss_n2h_msg_callback_t cb, void *app_data)
2038{
Suman Ghosh9f7b3702018-09-21 19:51:40 +05302039 if (core >= nss_top_main.num_nss) {
Vijay Dewangan488e5372014-12-29 21:40:11 -08002040 nss_warning("Input core number %d is wrong \n", core);
2041 return NULL;
2042 }
2043 /*
2044 * TODO: We need to have a new array in support of the new API
2045 * TODO: If we use a per-context array, we would move the array into nss_ctx based.
2046 */
2047 nss_n2h_rd[core].n2h_callback = cb;
2048 nss_n2h_rd[core].app_data = app_data;
2049 return &nss_top_main.nss[core];
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302050}
2051
2052/*
2053 * nss_n2h_register_handler()
2054 */
Thomas Wu91f4bdf2017-06-09 12:03:02 -07002055void nss_n2h_register_handler(struct nss_ctx_instance *nss_ctx)
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302056{
ratheesh kannothab436af2017-07-20 08:51:07 +05302057 sema_init(&nss_n2h_q_cfg_pvt.sem, 1);
2058 init_completion(&nss_n2h_q_cfg_pvt.complete);
2059
Thomas Wu91f4bdf2017-06-09 12:03:02 -07002060 nss_core_register_handler(nss_ctx, NSS_N2H_INTERFACE, nss_n2h_interface_handler, NULL);
Yu Huang8c107082017-07-24 14:58:26 -07002061
Cemil Coskun26be6162019-06-28 15:44:48 -07002062 if (nss_ctx->id == NSS_CORE_0) {
2063 nss_n2h_stats_dentry_create();
2064 }
Wayne Tand5058cb2020-01-07 14:39:16 -08002065 nss_n2h_strings_dentry_create();
2066
2067 nss_drv_strings_dentry_create();
Stephen Wang49b474b2016-03-25 10:40:30 -07002068}
Sundarajan Srinivasanf1e57462014-09-17 15:24:01 -07002069
Stephen Wang49b474b2016-03-25 10:40:30 -07002070/*
Suman Ghosh9f7b3702018-09-21 19:51:40 +05302071 * nss_n2h_single_core_register_sysctl()
Stephen Wang49b474b2016-03-25 10:40:30 -07002072 */
Suman Ghosh9f7b3702018-09-21 19:51:40 +05302073void nss_n2h_single_core_register_sysctl(void)
2074{
2075 /*
2076 * RPS sema init
2077 */
2078 sema_init(&nss_n2h_rcp.sem, 1);
2079 init_completion(&nss_n2h_rcp.complete);
2080
2081 /*
2082 * MITIGATION sema init for core0
2083 */
2084 sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1);
2085 init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete);
2086
2087 /*
2088 * PBUF addition sema init for core0
2089 */
2090 sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1);
2091 init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete);
2092
2093 /*
2094 * Core0
2095 */
2096 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1);
2097 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete);
2098 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.pool_size =
2099 nss_n2h_empty_pool_buf_cfg[NSS_CORE_0];
2100 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.low_water =
2101 nss_n2h_water_mark[NSS_CORE_0][0];
2102 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.high_water =
2103 nss_n2h_water_mark[NSS_CORE_0][1];
2104 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.pool_size =
2105 nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0];
2106 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.low_water =
2107 nss_n2h_paged_water_mark[NSS_CORE_0][0];
2108 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.high_water =
2109 nss_n2h_paged_water_mark[NSS_CORE_0][1];
2110
2111 /*
2112 * WiFi pool buf cfg sema init
2113 */
2114 sema_init(&nss_n2h_wp.sem, 1);
2115 init_completion(&nss_n2h_wp.complete);
2116
2117 /*
2118 * N2H queue config sema init
2119 */
2120 sema_init(&nss_n2h_q_lim_pvt.sem, 1);
2121 init_completion(&nss_n2h_q_lim_pvt.complete);
2122
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08002123 /*
2124 * Back pressure config sema init
2125 */
2126 sema_init(&nss_n2h_host_bp_cfg_pvt.sem, 1);
2127 init_completion(&nss_n2h_host_bp_cfg_pvt.complete);
2128
Suman Ghosh9f7b3702018-09-21 19:51:40 +05302129 nss_n2h_notify_register(NSS_CORE_0, NULL, NULL);
2130
2131 /*
2132 * Register sysctl table.
2133 */
2134 nss_n2h_dir[0].child = nss_n2h_table_single_core;
2135 nss_n2h_header = register_sysctl_table(nss_n2h_root);
2136}
2137
2138/*
2139 * nss_n2h_multi_core_register_sysctl()
2140 */
2141void nss_n2h_multi_core_register_sysctl(void)
Stephen Wang49b474b2016-03-25 10:40:30 -07002142{
Vijay Dewangan634ce592015-01-07 17:21:09 -08002143 /*
2144 * RPS sema init
2145 */
2146 sema_init(&nss_n2h_rcp.sem, 1);
2147 init_completion(&nss_n2h_rcp.complete);
2148
Kalyan Tallapragadab50e8902015-08-06 17:00:54 +05302149 /*
2150 * MITIGATION sema init for core0
2151 */
2152 sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1);
2153 init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete);
2154
2155 /*
2156 * MITIGATION sema init for core1
2157 */
2158 sema_init(&nss_n2h_mitigationcp[NSS_CORE_1].sem, 1);
2159 init_completion(&nss_n2h_mitigationcp[NSS_CORE_1].complete);
2160
2161 /*
2162 * PBUF addition sema init for core0
2163 */
2164 sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1);
2165 init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete);
2166
2167 /*
2168 * PBUF addition sema init for core1
2169 */
2170 sema_init(&nss_n2h_bufcp[NSS_CORE_1].sem, 1);
2171 init_completion(&nss_n2h_bufcp[NSS_CORE_1].complete);
Vijay Dewangan634ce592015-01-07 17:21:09 -08002172
Stephen Wang49b474b2016-03-25 10:40:30 -07002173 /*
2174 * Core0
2175 */
2176 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1);
2177 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete);
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002178 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.pool_size =
Stephen Wang49b474b2016-03-25 10:40:30 -07002179 nss_n2h_empty_pool_buf_cfg[NSS_CORE_0];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002180 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.low_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07002181 nss_n2h_water_mark[NSS_CORE_0][0];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002182 nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.high_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07002183 nss_n2h_water_mark[NSS_CORE_0][1];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002184 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.pool_size =
2185 nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0];
2186 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.low_water =
2187 nss_n2h_paged_water_mark[NSS_CORE_0][0];
2188 nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.high_water =
2189 nss_n2h_paged_water_mark[NSS_CORE_0][1];
2190
Stephen Wang49b474b2016-03-25 10:40:30 -07002191 /*
2192 * Core1
2193 */
2194 sema_init(&nss_n2h_nepbcfgp[NSS_CORE_1].sem, 1);
2195 init_completion(&nss_n2h_nepbcfgp[NSS_CORE_1].complete);
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002196 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.pool_size =
Stephen Wang49b474b2016-03-25 10:40:30 -07002197 nss_n2h_empty_pool_buf_cfg[NSS_CORE_1];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002198 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.low_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07002199 nss_n2h_water_mark[NSS_CORE_1][0];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002200 nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.high_water =
Stephen Wang49b474b2016-03-25 10:40:30 -07002201 nss_n2h_water_mark[NSS_CORE_1][1];
Sachin Shashidhar475012b2017-03-13 16:56:07 -07002202 nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.pool_size =
2203 nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1];
2204 nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.low_water =
2205 nss_n2h_paged_water_mark[NSS_CORE_1][0];
2206 nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.high_water =
2207 nss_n2h_paged_water_mark[NSS_CORE_1][1];
2208
Stephen Wang49b474b2016-03-25 10:40:30 -07002209 /*
2210 * WiFi pool buf cfg sema init
2211 */
2212 sema_init(&nss_n2h_wp.sem, 1);
2213 init_completion(&nss_n2h_wp.complete);
2214
Shashank Balashankar4162f572018-08-21 13:32:34 -07002215 /*
2216 * N2H queue config sema init
2217 */
2218 sema_init(&nss_n2h_q_lim_pvt.sem, 1);
2219 init_completion(&nss_n2h_q_lim_pvt.complete);
2220
Sakthi Vignesh Radhakrishnanf9823102019-03-05 15:38:36 -08002221 /*
2222 * Back pressure config sema init
2223 */
2224 sema_init(&nss_n2h_host_bp_cfg_pvt.sem, 1);
2225 init_completion(&nss_n2h_host_bp_cfg_pvt.complete);
2226
Vijay Dewangan488e5372014-12-29 21:40:11 -08002227 nss_n2h_notify_register(NSS_CORE_0, NULL, NULL);
2228 nss_n2h_notify_register(NSS_CORE_1, NULL, NULL);
2229
Stephen Wang49b474b2016-03-25 10:40:30 -07002230 /*
2231 * Register sysctl table.
2232 */
2233 nss_n2h_header = register_sysctl_table(nss_n2h_root);
2234}
2235
2236/*
2237 * nss_n2h_unregister_sysctl()
2238 * Unregister sysctl specific to n2h
2239 */
2240void nss_n2h_unregister_sysctl(void)
2241{
2242 /*
2243 * Unregister sysctl table.
2244 */
2245 if (nss_n2h_header) {
2246 unregister_sysctl_table(nss_n2h_header);
2247 }
Abhishek Rastogi84d95d02014-03-26 19:31:31 +05302248}
Vijay Dewangan488e5372014-12-29 21:40:11 -08002249
2250EXPORT_SYMBOL(nss_n2h_notify_register);