blob: 368fbeaf921a862b2811f4ef7cb3a901668bd559 [file] [log] [blame]
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +05301/*
2 **************************************************************************
Wayne Tanb45933c2020-01-06 17:19:25 -08003 * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +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 */
Abhishek Rastogibc74e432013-04-02 10:28:22 +053016
17/*
18 * nss_init.c
19 * NSS init APIs
20 *
21 */
Abhishek Rastogibc74e432013-04-02 10:28:22 +053022#include "nss_core.h"
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080023#if (NSS_PM_SUPPORT == 1)
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053024#include "nss_pm.h"
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080025#endif
Abhishek Rastogi9da47472014-03-18 19:46:15 +053026#include "nss_tx_rx_common.h"
Stephen Wang38e89bc2014-11-06 11:34:45 -080027#include "nss_data_plane.h"
Stephen Wang1f6ad492016-01-27 23:42:06 -080028#include "nss_capwap.h"
Wayne Tanb45933c2020-01-06 17:19:25 -080029#include "nss_strings.h"
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053030
Abhishek Rastogibc74e432013-04-02 10:28:22 +053031#include <nss_hal.h>
32
33#include <linux/module.h>
34#include <linux/platform_device.h>
wthomas442c7972013-08-05 14:28:17 -070035#include <linux/proc_fs.h>
36#include <linux/device.h>
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080037
38#if (NSS_DT_SUPPORT == 1)
Stephen Wang463f1cf2016-03-29 15:25:51 -070039#if (NSS_FABRIC_SCALING_SUPPORT == 1)
Stephen Wang8ffd17f2016-03-07 14:03:40 -080040#include <linux/fab_scaling.h>
Stephen Wang1017ad12016-03-14 10:18:06 -070041#endif
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080042#include <linux/of.h>
43#include <linux/of_net.h>
44#include <linux/of_irq.h>
45#include <linux/of_address.h>
46#include <linux/reset.h>
47#else
Abhishek Rastogibc74e432013-04-02 10:28:22 +053048#include <mach/msm_nss.h>
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080049#endif
Abhishek Rastogibc74e432013-04-02 10:28:22 +053050
wthomas442c7972013-08-05 14:28:17 -070051#include <linux/sysctl.h>
52#include <linux/regulator/consumer.h>
Thomas Wufb6a6842013-10-23 13:14:27 -070053#include <linux/clk.h>
wthomas442c7972013-08-05 14:28:17 -070054
Abhishek Rastogibc74e432013-04-02 10:28:22 +053055/*
56 * Global declarations
57 */
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +053058int nss_ctl_redirect __read_mostly = 0;
Sakthi Vignesh Radhakrishnanaf39aad2014-03-31 11:31:03 -070059int nss_ctl_debug __read_mostly = 0;
Saurabh Misra96998db2014-07-10 12:15:48 -070060int nss_ctl_logbuf __read_mostly = 0;
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -080061int nss_jumbo_mru __read_mostly = 0;
62int nss_paged_mode __read_mostly = 0;
Casey Chen56c13632018-09-10 17:05:03 -070063#if (NSS_SKB_REUSE_SUPPORT == 1)
64int nss_max_reuse __read_mostly = PAGE_SIZE;
65#endif
Radha krishna Simha Jiguru28a0a252015-08-04 16:34:09 +053066int nss_skip_nw_process = 0x0;
67module_param(nss_skip_nw_process, int, S_IRUGO);
Abhishek Rastogibc74e432013-04-02 10:28:22 +053068
69/*
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053070 * PM client handle
71 */
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080072#if (NSS_PM_SUPPORT == 1)
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053073static void *pm_client;
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080074#endif
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053075
76/*
wthomas626147f2013-09-18 13:12:40 -070077 * Handler to send NSS messages
78 */
Thomas Wufb6a6842013-10-23 13:14:27 -070079struct clk *nss_core0_clk;
Thomas Wu63bcff62017-03-20 11:44:41 -070080struct clk *nss_core1_clk;
wthomas626147f2013-09-18 13:12:40 -070081
82/*
Thomas Wucd6b35a2015-07-14 10:17:48 -070083 * Handle fabric requests - only on new kernel
84 */
85#if (NSS_DT_SUPPORT == 1)
86struct clk *nss_fab0_clk;
87struct clk *nss_fab1_clk;
88#endif
89
90/*
Abhishek Rastogibc74e432013-04-02 10:28:22 +053091 * Top level nss context structure
92 */
93struct nss_top_instance nss_top_main;
wthomas442c7972013-08-05 14:28:17 -070094struct nss_cmd_buffer nss_cmd_buf;
wthomas626147f2013-09-18 13:12:40 -070095struct nss_runtime_sampling nss_runtime_samples;
96struct workqueue_struct *nss_wq;
97
98/*
99 * Work Queue to handle messages to Kernel
100 */
101nss_work_t *nss_work;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530102
Arunkumar T79990cb2015-06-05 10:53:16 +0530103extern struct of_device_id nss_dt_ids[];
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530104
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530105/*
106 * nss_probe()
Cemil Coskun9165c762017-12-04 14:35:24 -0800107 * HLOS device probe callback
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530108 */
Ram Chandra Jangir6577f382016-05-31 12:16:28 +0530109static inline int nss_probe(struct platform_device *nss_dev)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530110{
Arunkumar T79990cb2015-06-05 10:53:16 +0530111 return nss_hal_probe(nss_dev);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530112}
113
114/*
115 * nss_remove()
Cemil Coskun9165c762017-12-04 14:35:24 -0800116 * HLOS device remove callback
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530117 */
Ram Chandra Jangir6577f382016-05-31 12:16:28 +0530118static inline int nss_remove(struct platform_device *nss_dev)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530119{
Arunkumar T79990cb2015-06-05 10:53:16 +0530120 return nss_hal_remove(nss_dev);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530121}
122
Stephen Wang90c67de2016-04-26 15:15:59 -0700123#if (NSS_DT_SUPPORT == 1)
124/*
125 * Platform Device ID for NSS core.
126 */
127struct of_device_id nss_dt_ids[] = {
128 { .compatible = "qcom,nss" },
129 { .compatible = "qcom,nss0" },
130 { .compatible = "qcom,nss1" },
131 {},
132};
133MODULE_DEVICE_TABLE(of, nss_dt_ids);
134#endif
135
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530136/*
137 * nss_driver
138 * Platform driver structure for NSS
139 */
140struct platform_driver nss_driver = {
141 .probe = nss_probe,
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800142 .remove = nss_remove,
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530143 .driver = {
144 .name = "qca-nss",
145 .owner = THIS_MODULE,
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800146#if (NSS_DT_SUPPORT == 1)
147 .of_match_table = of_match_ptr(nss_dt_ids),
148#endif
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530149 },
150};
151
Arunkumar T28b2d742015-06-16 22:15:58 +0530152#if (NSS_FREQ_SCALE_SUPPORT == 1)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530153/*
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530154 * nss_reset_frequency_stats_samples()
155 * Reset all frequency sampling state when auto scaling is turned off.
156 */
Thomas Wud6af3772017-09-01 13:42:28 -0700157static void nss_reset_frequency_stats_samples(void)
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530158{
159 nss_runtime_samples.buffer_index = 0;
160 nss_runtime_samples.sum = 0;
161 nss_runtime_samples.average = 0;
162 nss_runtime_samples.sample_count = 0;
163 nss_runtime_samples.message_rate_limit = 0;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530164 nss_runtime_samples.freq_scale_rate_limit_down = 0;
165}
166
167/*
wthomas442c7972013-08-05 14:28:17 -0700168 * nss_current_freq_handler()
169 * Handle Userspace Frequency Change Requests
170 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700171static int nss_current_freq_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
wthomas442c7972013-08-05 14:28:17 -0700172{
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800173 int ret, i;
wthomas626147f2013-09-18 13:12:40 -0700174
175 BUG_ON(!nss_wq);
wthomas442c7972013-08-05 14:28:17 -0700176
177 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
178
Thomas Wuc151f2e2015-09-08 10:59:44 -0700179 if (!*lenp || (*ppos && !write)) {
wthomas626147f2013-09-18 13:12:40 -0700180 printk("Frequency Set to %d\n", nss_cmd_buf.current_freq);
Thomas Wuc151f2e2015-09-08 10:59:44 -0700181 *lenp = 0;
wthomasd39fa822013-08-22 16:44:23 -0700182 return ret;
wthomas442c7972013-08-05 14:28:17 -0700183 }
wthomasd39fa822013-08-22 16:44:23 -0700184
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800185 /*
186 * Check if frequency exists in frequency Table
187 */
188 i = 0;
Thomas Wu7132bd32015-05-07 15:03:06 -0700189 while (i < NSS_FREQ_MAX_SCALE) {
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800190 if (nss_runtime_samples.freq_scale[i].frequency == nss_cmd_buf.current_freq) {
191 break;
192 }
193 i++;
194 }
Thomas Wu7132bd32015-05-07 15:03:06 -0700195 if (i == NSS_FREQ_MAX_SCALE) {
Thomas Wufb6a6842013-10-23 13:14:27 -0700196 printk("Frequency not found. Please check Frequency Table\n");
Thomas Wub7683af2016-07-07 14:19:09 -0700197 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
wthomas626147f2013-09-18 13:12:40 -0700198 return ret;
wthomasd39fa822013-08-22 16:44:23 -0700199 }
200
Thomas Wub7683af2016-07-07 14:19:09 -0700201 /*
202 * Turn off Auto Scale
203 */
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800204 nss_cmd_buf.auto_scale = 0;
205 nss_runtime_samples.freq_scale_ready = 0;
Thomas Wub7683af2016-07-07 14:19:09 -0700206 nss_runtime_samples.freq_scale_index = i;
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800207
Thomas Wu7409bce2014-05-21 10:56:07 -0700208 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
wthomas626147f2013-09-18 13:12:40 -0700209 if (!nss_work) {
210 nss_info("NSS Freq WQ kmalloc fail");
211 return ret;
212 }
Thomas Wud6af3772017-09-01 13:42:28 -0700213 INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function);
wthomas626147f2013-09-18 13:12:40 -0700214 nss_work->frequency = nss_cmd_buf.current_freq;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530215 nss_work->stats_enable = 0;
216
Thomas Wub7683af2016-07-07 14:19:09 -0700217 /*
218 * Ensure we start with a fresh set of samples later
219 */
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530220 nss_reset_frequency_stats_samples();
221
wthomas626147f2013-09-18 13:12:40 -0700222 queue_work(nss_wq, (struct work_struct *)nss_work);
223
wthomas442c7972013-08-05 14:28:17 -0700224 return ret;
225}
226
227/*
228 * nss_auto_scale_handler()
229 * Enables or Disable Auto Scaling
230 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700231static int nss_auto_scale_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
wthomas442c7972013-08-05 14:28:17 -0700232{
233 int ret;
234
235 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
236
Thomas Wuc151f2e2015-09-08 10:59:44 -0700237 if (!*lenp || (*ppos && !write)) {
wthomas626147f2013-09-18 13:12:40 -0700238 return ret;
239 }
240
Thomas Wufb6a6842013-10-23 13:14:27 -0700241 if (nss_cmd_buf.auto_scale != 1) {
wthomas626147f2013-09-18 13:12:40 -0700242 /*
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530243 * Is auto scaling currently enabled? If so, send the command to
244 * disable stats reporting to NSS
wthomas626147f2013-09-18 13:12:40 -0700245 */
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530246 if (nss_runtime_samples.freq_scale_ready != 0) {
247 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
Thomas Wu7409bce2014-05-21 10:56:07 -0700248 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530249 if (!nss_work) {
250 nss_info("NSS Freq WQ kmalloc fail");
251 return ret;
252 }
Thomas Wud6af3772017-09-01 13:42:28 -0700253 INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function);
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530254 nss_work->frequency = nss_cmd_buf.current_freq;
255 nss_work->stats_enable = 0;
256 queue_work(nss_wq, (struct work_struct *)nss_work);
257 nss_runtime_samples.freq_scale_ready = 0;
258
259 /*
260 * The current samples would be stale later when scaling is
261 * enabled again, hence reset them
262 */
263 nss_reset_frequency_stats_samples();
264 }
Thomas Wufb6a6842013-10-23 13:14:27 -0700265 return ret;
wthomas626147f2013-09-18 13:12:40 -0700266 }
wthomas442c7972013-08-05 14:28:17 -0700267
Thomas Wufb6a6842013-10-23 13:14:27 -0700268 /*
Thomas Wufb6a6842013-10-23 13:14:27 -0700269 * Setup default values - Middle of Freq Scale Band
270 */
271 nss_runtime_samples.freq_scale_index = 1;
Thomas Wubfe3ffc2019-07-19 16:09:52 -0700272 nss_runtime_samples.sample_count = 0;
273 nss_runtime_samples.initialized = 0;
Thomas Wufb6a6842013-10-23 13:14:27 -0700274 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
275
Thomas Wu7409bce2014-05-21 10:56:07 -0700276 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
Thomas Wufb6a6842013-10-23 13:14:27 -0700277 if (!nss_work) {
278 nss_info("NSS Freq WQ kmalloc fail");
279 return ret;
280 }
Thomas Wud6af3772017-09-01 13:42:28 -0700281 INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function);
Thomas Wufb6a6842013-10-23 13:14:27 -0700282 nss_work->frequency = nss_cmd_buf.current_freq;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530283 nss_work->stats_enable = 1;
Thomas Wufb6a6842013-10-23 13:14:27 -0700284 queue_work(nss_wq, (struct work_struct *)nss_work);
285
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800286 nss_cmd_buf.auto_scale = 0;
Thomas Wufb6a6842013-10-23 13:14:27 -0700287 nss_runtime_samples.freq_scale_ready = 1;
288
wthomas442c7972013-08-05 14:28:17 -0700289 return ret;
290}
291
292/*
293 * nss_get_freq_table_handler()
294 * Display Support Freq and Ex how to Change.
295 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700296static int nss_get_freq_table_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
wthomas442c7972013-08-05 14:28:17 -0700297{
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800298 int ret, i;
wthomas442c7972013-08-05 14:28:17 -0700299
300 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
301
Thomas Wuc151f2e2015-09-08 10:59:44 -0700302 if (write) {
303 return ret;
304 }
305
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800306 printk("Frequency Supported - ");
Thomas Wuc151f2e2015-09-08 10:59:44 -0700307
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800308 i = 0;
Thomas Wu7132bd32015-05-07 15:03:06 -0700309 while (i < NSS_FREQ_MAX_SCALE) {
Thomas Wu6a48ac92017-11-03 10:48:04 -0700310 printk("%d Hz ", nss_runtime_samples.freq_scale[i].frequency);
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800311 i++;
Thomas Wu0a0a9c92013-11-21 15:28:19 -0800312 }
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800313 printk("\n");
wthomas442c7972013-08-05 14:28:17 -0700314
Thomas Wuc151f2e2015-09-08 10:59:44 -0700315 *lenp = 0;
wthomas442c7972013-08-05 14:28:17 -0700316 return ret;
317}
318
319/*
Thomas Wu05495be2013-12-19 14:24:24 -0800320 * nss_get_average_inst_handler()
321 * Display AVG Inst Per Ms.
322 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700323static int nss_get_average_inst_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Thomas Wu05495be2013-12-19 14:24:24 -0800324{
325 int ret;
326
327 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
328
Thomas Wuc151f2e2015-09-08 10:59:44 -0700329 if (write) {
330 return ret;
Thomas Wu05495be2013-12-19 14:24:24 -0800331 }
332
Thomas Wuc151f2e2015-09-08 10:59:44 -0700333 printk("Current Inst Per Ms %x\n", nss_runtime_samples.average);
334
335 *lenp = 0;
Thomas Wu05495be2013-12-19 14:24:24 -0800336 return ret;
337}
Arunkumar T28b2d742015-06-16 22:15:58 +0530338#endif
Thomas Wu05495be2013-12-19 14:24:24 -0800339
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800340#if (NSS_FW_DBG_SUPPORT == 1)
Thomas Wu05495be2013-12-19 14:24:24 -0800341/*
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530342 * nss_debug_handler()
343 * Enable NSS debug output
344 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700345static int nss_debug_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530346{
347 int ret;
348
349 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
350 if (!ret) {
351 if ((write) && (nss_ctl_debug != 0)) {
352 printk("Enabling NSS SPI Debug\n");
353 nss_hal_debug_enable();
354 }
355 }
356
357 return ret;
358}
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800359#endif
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530360
361/*
Thomas Wu52075f42014-02-06 16:32:42 -0800362 * nss_coredump_handler()
363 * Send Signal To Coredump NSS Cores
364 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700365static int nss_coredump_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Thomas Wu52075f42014-02-06 16:32:42 -0800366{
Guojun Jin32a3c6d2015-05-06 12:27:52 -0700367 struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[NSS_CORE_0];
Thomas Wu52075f42014-02-06 16:32:42 -0800368 int ret;
369
370 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
371 if (!ret) {
Guojun Jin244ecab2017-03-16 16:04:25 -0700372 /*
373 * if nss_cmd_buf.coredump is not 0 or 1, panic will be disabled
374 * when NSS FW crashes, so OEM/ODM have a chance to use mdump
375 * to dump crash dump (coredump) and send dump to us for analysis.
376 */
377 if ((write) && (nss_ctl_debug != 0) && nss_cmd_buf.coredump == 1) {
Thomas Wu52075f42014-02-06 16:32:42 -0800378 printk("Coredumping to DDR\n");
Stephen Wang90c67de2016-04-26 15:15:59 -0700379 nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP);
Thomas Wu52075f42014-02-06 16:32:42 -0800380 }
381 }
382
383 return ret;
384}
385
386/*
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800387 * nss_jumbo_mru_handler()
388 * Sysctl to modify nss_jumbo_mru
389 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700390static int nss_jumbo_mru_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800391{
392 int ret;
393
394 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
395 if (ret) {
396 return ret;
397 }
398
399 if (write) {
400 nss_core_set_jumbo_mru(nss_jumbo_mru);
401 nss_info("jumbo_mru set to %d\n", nss_jumbo_mru);
402 }
403
404 return ret;
405}
406
407/* nss_paged_mode_handler()
408 * Sysctl to modify nss_paged_mode.
409 */
410
Stephen Wang52e6d342016-03-29 15:02:33 -0700411static int nss_paged_mode_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800412{
413 int ret;
414
415 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
416 if (ret) {
417 return ret;
418 }
419
420 if (write) {
421 nss_core_set_paged_mode(nss_paged_mode);
422 nss_info("paged_mode set to %d\n", nss_paged_mode);
423 }
424
425 return ret;
426}
427
Casey Chen56c13632018-09-10 17:05:03 -0700428#if (NSS_SKB_REUSE_SUPPORT == 1)
429/*
430 * nss_get_min_reuse_handler()
431 * Sysctl to get min reuse sizes
432 */
433static int nss_get_min_reuse_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
434{
435 int ret;
436 struct nss_ctx_instance *nss_ctx = NULL;
437 uint32_t core_id;
438
439 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
440 if (ret) {
441 return ret;
442 }
443
444 printk("Min SKB reuse sizes - ");
445
446 for (core_id = 0; core_id < NSS_CORE_MAX; core_id++) {
447 nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id];
448 printk("core %d: %d ", core_id, nss_core_get_min_reuse(nss_ctx));
449 }
450
451 printk("\n");
452 *lenp = 0;
453 return ret;
454}
455
456/*
457 * nss_max_reuse_handler()
458 * Sysctl to modify nss_max_reuse
459 */
460static int nss_max_reuse_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
461{
462 int ret;
463
464 nss_max_reuse = nss_core_get_max_reuse();
465 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
466 if (ret) {
467 return ret;
468 }
469
470 if (write) {
471 nss_core_set_max_reuse(nss_max_reuse);
472 nss_info("max_reuse set to %d\n", nss_max_reuse);
473 }
474
475 return ret;
476}
477
478/*
479 * sysctl-tuning for NSS driver SKB reuse
480 */
481static struct ctl_table nss_skb_reuse_table[] = {
482 {
483 .procname = "min_sizes",
484 .data = NULL,
485 .maxlen = sizeof(int),
486 .mode = 0644,
487 .proc_handler = &nss_get_min_reuse_handler,
488 },
489 {
490 .procname = "max_size",
491 .data = &nss_max_reuse,
492 .maxlen = sizeof(int),
493 .mode = 0644,
494 .proc_handler = &nss_max_reuse_handler,
495 },
496 { }
497};
498#endif
499
Arunkumar T28b2d742015-06-16 22:15:58 +0530500#if (NSS_FREQ_SCALE_SUPPORT == 1)
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800501/*
wthomas442c7972013-08-05 14:28:17 -0700502 * sysctl-tuning infrastructure.
503 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700504static struct ctl_table nss_freq_table[] = {
wthomas442c7972013-08-05 14:28:17 -0700505 {
506 .procname = "current_freq",
507 .data = &nss_cmd_buf.current_freq,
508 .maxlen = sizeof(int),
509 .mode = 0644,
510 .proc_handler = &nss_current_freq_handler,
511 },
512 {
513 .procname = "freq_table",
514 .data = &nss_cmd_buf.max_freq,
515 .maxlen = sizeof(int),
516 .mode = 0644,
517 .proc_handler = &nss_get_freq_table_handler,
518 },
519 {
520 .procname = "auto_scale",
521 .data = &nss_cmd_buf.auto_scale,
522 .maxlen = sizeof(int),
523 .mode = 0644,
524 .proc_handler = &nss_auto_scale_handler,
525 },
Thomas Wu05495be2013-12-19 14:24:24 -0800526 {
527 .procname = "inst_per_sec",
528 .data = &nss_cmd_buf.average_inst,
529 .maxlen = sizeof(int),
530 .mode = 0644,
531 .proc_handler = &nss_get_average_inst_handler,
532 },
wthomas442c7972013-08-05 14:28:17 -0700533 { }
534};
Arunkumar T28b2d742015-06-16 22:15:58 +0530535#endif
wthomas442c7972013-08-05 14:28:17 -0700536
Stephen Wang52e6d342016-03-29 15:02:33 -0700537static struct ctl_table nss_general_table[] = {
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530538 {
539 .procname = "redirect",
540 .data = &nss_ctl_redirect,
541 .maxlen = sizeof(int),
542 .mode = 0644,
Cemil Coskun9165c762017-12-04 14:35:24 -0800543 .proc_handler = proc_dointvec,
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530544 },
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800545#if (NSS_FW_DBG_SUPPORT == 1)
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530546 {
547 .procname = "debug",
548 .data = &nss_ctl_debug,
549 .maxlen = sizeof(int),
550 .mode = 0644,
Cemil Coskun9165c762017-12-04 14:35:24 -0800551 .proc_handler = &nss_debug_handler,
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530552 },
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800553#endif
Thomas Wu52075f42014-02-06 16:32:42 -0800554 {
555 .procname = "coredump",
556 .data = &nss_cmd_buf.coredump,
557 .maxlen = sizeof(int),
558 .mode = 0644,
Cemil Coskun9165c762017-12-04 14:35:24 -0800559 .proc_handler = &nss_coredump_handler,
Thomas Wu52075f42014-02-06 16:32:42 -0800560 },
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530561 {
Saurabh Misra96998db2014-07-10 12:15:48 -0700562 .procname = "logbuf",
563 .data = &nss_ctl_logbuf,
564 .maxlen = sizeof(int),
565 .mode = 0644,
Cemil Coskun9165c762017-12-04 14:35:24 -0800566 .proc_handler = &nss_logbuffer_handler,
Saurabh Misra96998db2014-07-10 12:15:48 -0700567 },
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800568 {
569 .procname = "jumbo_mru",
570 .data = &nss_jumbo_mru,
571 .maxlen = sizeof(int),
572 .mode = 0644,
573 .proc_handler = &nss_jumbo_mru_handler,
574 },
575 {
576 .procname = "paged_mode",
577 .data = &nss_paged_mode,
578 .maxlen = sizeof(int),
579 .mode = 0644,
580 .proc_handler = &nss_paged_mode_handler,
581 },
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530582 { }
583};
584
Casey Chen56c13632018-09-10 17:05:03 -0700585static struct ctl_table nss_init_dir[] = {
Arunkumar T28b2d742015-06-16 22:15:58 +0530586#if (NSS_FREQ_SCALE_SUPPORT == 1)
wthomas442c7972013-08-05 14:28:17 -0700587 {
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530588 .procname = "clock",
589 .mode = 0555,
590 .child = nss_freq_table,
591 },
Arunkumar T28b2d742015-06-16 22:15:58 +0530592#endif
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530593 {
594 .procname = "general",
595 .mode = 0555,
596 .child = nss_general_table,
wthomas442c7972013-08-05 14:28:17 -0700597 },
Casey Chen56c13632018-09-10 17:05:03 -0700598#if (NSS_SKB_REUSE_SUPPORT == 1)
599 {
600 .procname = "skb_reuse",
601 .mode = 0555,
602 .child = nss_skb_reuse_table,
603 },
604#endif
wthomas442c7972013-08-05 14:28:17 -0700605 { }
606};
607
Stephen Wang52e6d342016-03-29 15:02:33 -0700608static struct ctl_table nss_root_dir[] = {
wthomas442c7972013-08-05 14:28:17 -0700609 {
610 .procname = "nss",
611 .mode = 0555,
Casey Chen56c13632018-09-10 17:05:03 -0700612 .child = nss_init_dir,
wthomas442c7972013-08-05 14:28:17 -0700613 },
614 { }
615};
616
Stephen Wang52e6d342016-03-29 15:02:33 -0700617static struct ctl_table nss_root[] = {
wthomas442c7972013-08-05 14:28:17 -0700618 {
619 .procname = "dev",
620 .mode = 0555,
621 .child = nss_root_dir,
622 },
623 { }
624};
625
626static struct ctl_table_header *nss_dev_header;
627
628/*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530629 * nss_init()
630 * Registers nss driver
631 */
632static int __init nss_init(void)
633{
Radha krishna Simha Jiguru3295b8b2017-03-12 10:54:15 +0530634#if (NSS_DT_SUPPORT == 1)
635 struct device_node *cmn = NULL;
636#endif
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530637 nss_info("Init NSS driver");
638
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800639#if (NSS_DT_SUPPORT == 1)
640 /*
Radha krishna Simha Jiguru3295b8b2017-03-12 10:54:15 +0530641 * Get reference to NSS common device node
642 */
643 cmn = of_find_node_by_name(NULL, "nss-common");
644 if (!cmn) {
645 nss_info_always("qca-nss-drv.ko is loaded for symbol link\n");
646 return 0;
647 }
648 of_node_put(cmn);
649
650 /*
Stephen Wang90c67de2016-04-26 15:15:59 -0700651 * Pick up HAL by target information
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800652 */
Stephen Wang90c67de2016-04-26 15:15:59 -0700653#if defined(NSS_HAL_IPQ806X_SUPPORT)
654 if (of_machine_is_compatible("qcom,ipq8064") || of_machine_is_compatible("qcom,ipq8062")) {
655 nss_top_main.hal_ops = &nss_hal_ipq806x_ops;
Stephen Wang5901def2016-05-09 16:21:03 -0700656 nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops;
Suman Ghosh9f7b3702018-09-21 19:51:40 +0530657 nss_top_main.num_nss = 2;
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800658 }
Stephen Wang90c67de2016-04-26 15:15:59 -0700659#endif
Stephen Wangbe348022016-05-02 17:11:34 -0700660#if defined(NSS_HAL_IPQ807x_SUPPORT)
661 if (of_machine_is_compatible("qcom,ipq807x")) {
662 nss_top_main.hal_ops = &nss_hal_ipq807x_ops;
Stephen Wangdf8323b2016-05-09 22:51:22 -0700663 nss_top_main.data_plane_ops = &nss_data_plane_edma_ops;
Radha krishna Simha Jiguru68d0cbc2019-02-15 00:19:21 +0530664#if defined(NSS_MEM_PROFILE_LOW)
665 nss_top_main.num_nss = 1;
666#else
Suman Ghosh9f7b3702018-09-21 19:51:40 +0530667 nss_top_main.num_nss = 2;
Radha krishna Simha Jiguru68d0cbc2019-02-15 00:19:21 +0530668#endif
Stephen Wangbe348022016-05-02 17:11:34 -0700669 }
670#endif
Suman Ghosh3f940232018-08-17 20:43:03 +0530671#if defined(NSS_HAL_IPQ60XX_SUPPORT)
672 if (of_machine_is_compatible("qcom,ipq6018")) {
673 nss_top_main.hal_ops = &nss_hal_ipq60xx_ops;
674 nss_top_main.data_plane_ops = &nss_data_plane_edma_ops;
Suman Ghosh9f7b3702018-09-21 19:51:40 +0530675 nss_top_main.num_nss = 1;
Suman Ghosh3f940232018-08-17 20:43:03 +0530676 }
677#endif
Subhash Kumar Katnpally0aab4f82019-11-25 12:38:39 +0530678#if defined(NSS_HAL_IPQ50XX_SUPPORT)
679 if (of_machine_is_compatible("qcom,ipq5018")) {
680 nss_top_main.hal_ops = &nss_hal_ipq50xx_ops;
681 nss_top_main.data_plane_ops = &nss_data_plane_edma_ops;
682 nss_top_main.num_nss = 1;
683 }
684#endif
Stephen Wang90c67de2016-04-26 15:15:59 -0700685#if defined(NSS_HAL_FSM9010_SUPPORT)
686 if (of_machine_is_compatible("qcom,fsm9010")) {
687 nss_top_main.hal_ops = &nss_hal_fsm9010_ops;
Stephen Wang5901def2016-05-09 16:21:03 -0700688 nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops;
Suman Ghosh9f7b3702018-09-21 19:51:40 +0530689 nss_top_main.num_nss = 1;
Stephen Wang90c67de2016-04-26 15:15:59 -0700690 }
691#endif
692 if (!nss_top_main.hal_ops) {
693 nss_info_always("No supported HAL compiled on this platform\n");
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800694 return -EFAULT;
695 }
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800696#else
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530697 /*
Stephen Wang90c67de2016-04-26 15:15:59 -0700698 * For banana, only ipq806x is supported
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530699 */
Stephen Wang90c67de2016-04-26 15:15:59 -0700700 nss_top_main.hal_ops = &nss_hal_ipq806x_ops;
Stephen Wang5901def2016-05-09 16:21:03 -0700701 nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops;
Suman Ghosh9f7b3702018-09-21 19:51:40 +0530702 nss_top_main.num_nss = 2;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530703
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800704#endif /* NSS_DT_SUPPORT */
Stephen Wang90c67de2016-04-26 15:15:59 -0700705 nss_top_main.nss_hal_common_init_done = false;
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800706
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530707 /*
Stephen Wangb42ddc52015-12-17 18:10:35 -0800708 * Initialize data_plane workqueue
709 */
710 if (nss_data_plane_init_delay_work()) {
711 nss_warning("Error initializing nss_data_plane_workqueue\n");
712 return -EFAULT;
713 }
714
715 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530716 * Enable spin locks
717 */
718 spin_lock_init(&(nss_top_main.lock));
719 spin_lock_init(&(nss_top_main.stats_lock));
c_athandfde2e912017-01-10 15:40:12 +0530720 mutex_init(&(nss_top_main.wq_lock));
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530721
722 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530723 * Enable NSS statistics
724 */
725 nss_stats_init();
726
727 /*
Wayne Tanb45933c2020-01-06 17:19:25 -0800728 * Enable NSS statistics names.
729 */
730 nss_strings_init();
731
732 /*
wthomas442c7972013-08-05 14:28:17 -0700733 * Register sysctl table.
734 */
735 nss_dev_header = register_sysctl_table(nss_root);
736
737 /*
Vijay Dewangan9db18752014-09-15 16:25:01 -0700738 * Registering sysctl for ipv4/6 specific config.
739 */
740 nss_ipv4_register_sysctl();
741 nss_ipv6_register_sysctl();
742
Vijay Dewanganac7efc42015-02-09 16:04:53 -0800743 /*
Stephen Wang49b474b2016-03-25 10:40:30 -0700744 * Registering sysctl for n2h specific config.
Vijay Dewanganac7efc42015-02-09 16:04:53 -0800745 */
Suman Ghosh9f7b3702018-09-21 19:51:40 +0530746 if (nss_top_main.num_nss == 1) {
747 nss_n2h_single_core_register_sysctl();
748 } else {
749 nss_n2h_multi_core_register_sysctl();
750 }
Vijay Dewanganac7efc42015-02-09 16:04:53 -0800751
Vijay Dewangan9db18752014-09-15 16:25:01 -0700752 /*
Cemil Coskun9165c762017-12-04 14:35:24 -0800753 * Registering sysctl for rps specific config.
754 */
755 nss_rps_register_sysctl();
756
757 /*
Cemil Coskun497f7ec2018-07-12 14:08:53 -0700758 * Registering sysctl for c2c_tx specific config.
759 */
760 nss_c2c_tx_register_sysctl();
761
762 /*
Sakthi Vignesh Radhakrishnan150c5592019-07-02 10:17:44 -0700763 * Registering sysctl for for printing non zero stats.
764 */
765 nss_stats_register_sysctl();
766
767 /*
Jackson Bockusc2a4e682017-06-23 11:59:29 -0700768 * Register sysctl for project config
769 */
770 nss_project_register_sysctl();
771
772 /*
Amit Gupta1fe4d912019-03-19 15:57:10 +0530773 * Registering sysctl for pppoe specific config.
774 */
775 nss_pppoe_register_sysctl();
776
777 /*
wthomas626147f2013-09-18 13:12:40 -0700778 * Setup Runtime Sample values
779 */
wthomas626147f2013-09-18 13:12:40 -0700780 nss_runtime_samples.freq_scale_index = 1;
781 nss_runtime_samples.freq_scale_ready = 0;
Thomas Wu9681f7e2013-11-06 13:12:57 -0800782 nss_runtime_samples.freq_scale_rate_limit_down = 0;
wthomas626147f2013-09-18 13:12:40 -0700783 nss_runtime_samples.buffer_index = 0;
784 nss_runtime_samples.sum = 0;
785 nss_runtime_samples.sample_count = 0;
786 nss_runtime_samples.average = 0;
787 nss_runtime_samples.message_rate_limit = 0;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530788 nss_runtime_samples.initialized = 0;
wthomas626147f2013-09-18 13:12:40 -0700789
Thomas Wu05495be2013-12-19 14:24:24 -0800790 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
791
wthomas626147f2013-09-18 13:12:40 -0700792 /*
793 * Initial Workqueue
794 */
795 nss_wq = create_workqueue("nss_freq_queue");
796
Thomas Wu0d112192015-04-13 11:37:22 -0700797#if (NSS_PM_SUPPORT == 1)
wthomas626147f2013-09-18 13:12:40 -0700798 /*
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530799 * Initialize NSS Bus PM module
800 */
801 nss_pm_init();
802
803 /*
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530804 * Register with Bus driver
805 */
806 pm_client = nss_pm_client_register(NSS_PM_CLIENT_NETAP);
807 if (!pm_client) {
808 nss_warning("Error registering with PM driver");
809 }
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800810#endif
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530811
812 /*
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +0530813 * Initialize mtu size needed as start
814 */
Stephen Wanga428d0b2017-01-12 21:30:01 -0800815 nss_top_main.prev_mtu_sz = ETH_DATA_LEN;
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +0530816
817 /*
Guojun Jin1cb79522015-06-22 22:34:22 -0700818 * register panic handler and timeout control
819 */
820 nss_coredump_notify_register();
821 nss_coredump_init_delay_work();
822
823 /*
Stephen Wang1f6ad492016-01-27 23:42:06 -0800824 * Init capwap
825 */
826 nss_capwap_init();
827
828 /*
Yu Huang6b2f0be2017-10-18 16:11:49 -0700829 * Init QRFS
830 */
831 nss_qrfs_init();
832
833 /*
Cemil Coskun1c9c3922018-01-23 16:21:49 -0800834 * Init c2c_tx
835 */
836 nss_c2c_tx_init();
837
838 /*
Cemil Coskuncdcd1dd2019-01-28 13:35:31 -0800839 * Init pvxlan
840 */
841 nss_pvxlan_init();
842
843 /*
Suman Ghosh85f353a2019-06-03 14:47:32 +0530844 * Init clmap
845 */
846 nss_clmap_init();
847
848 /*
Amit Gupta316729b2016-08-12 12:21:15 +0530849 * INIT ppe on supported platform
850 */
Suman Ghosh3f940232018-08-17 20:43:03 +0530851 if (of_machine_is_compatible("qcom,ipq807x") || of_machine_is_compatible("qcom,ipq6018")) {
Amit Gupta316729b2016-08-12 12:21:15 +0530852 nss_ppe_init();
853 }
854
855 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530856 * Register platform_driver
857 */
858 return platform_driver_register(&nss_driver);
859}
860
861/*
862 * nss_cleanup()
863 * Unregisters nss driver
864 */
865static void __exit nss_cleanup(void)
866{
867 nss_info("Exit NSS driver");
wthomas442c7972013-08-05 14:28:17 -0700868
869 if (nss_dev_header)
870 unregister_sysctl_table(nss_dev_header);
871
Vijay Dewangan9db18752014-09-15 16:25:01 -0700872 /*
Vijay Dewangan488e5372014-12-29 21:40:11 -0800873 * Unregister n2h specific sysctl
874 */
Stephen Wang49b474b2016-03-25 10:40:30 -0700875 nss_n2h_unregister_sysctl();
Vijay Dewangan488e5372014-12-29 21:40:11 -0800876
877 /*
Cemil Coskun9165c762017-12-04 14:35:24 -0800878 * Unregister rps specific sysctl
879 */
880 nss_rps_unregister_sysctl();
881
882 /*
Cemil Coskun497f7ec2018-07-12 14:08:53 -0700883 * Unregister c2c_tx specific sysctl
884 */
885 nss_c2c_tx_unregister_sysctl();
886
887 /*
Amit Gupta1fe4d912019-03-19 15:57:10 +0530888 * Unregister pppoe specific sysctl
889 */
890 nss_pppoe_unregister_sysctl();
891
892 /*
Vijay Dewangan9db18752014-09-15 16:25:01 -0700893 * Unregister ipv4/6 specific sysctl
894 */
895 nss_ipv4_unregister_sysctl();
896 nss_ipv6_unregister_sysctl();
897
Suruchi Agarwalcdcb5b42017-07-06 11:08:22 -0700898 /*
899 * Free Memory allocated for connection tables
900 */
901 nss_ipv4_free_conn_tables();
902 nss_ipv6_free_conn_tables();
903
Jackson Bockusc2a4e682017-06-23 11:59:29 -0700904 nss_project_unregister_sysctl();
Stephen Wangb42ddc52015-12-17 18:10:35 -0800905 nss_data_plane_destroy_delay_work();
906
Amit Gupta316729b2016-08-12 12:21:15 +0530907 /*
908 * cleanup ppe on supported platform
909 */
Suman Ghosh3f940232018-08-17 20:43:03 +0530910 if (of_machine_is_compatible("qcom,ipq807x") || of_machine_is_compatible("qcom,ipq6018")) {
Amit Gupta316729b2016-08-12 12:21:15 +0530911 nss_ppe_free();
912 }
913
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530914 platform_driver_unregister(&nss_driver);
915}
916
917module_init(nss_init);
918module_exit(nss_cleanup);
919
920MODULE_DESCRIPTION("QCA NSS Driver");
921MODULE_AUTHOR("Qualcomm Atheros Inc");
922MODULE_LICENSE("Dual BSD/GPL");