blob: 046c592d54589da992dc0ecdcf7b3d7bec1761ca [file] [log] [blame]
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +05301/*
2 **************************************************************************
Stephen Wanga428d0b2017-01-12 21:30:01 -08003 * Copyright (c) 2013-2017, 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"
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053029
Abhishek Rastogibc74e432013-04-02 10:28:22 +053030#include <nss_hal.h>
31
32#include <linux/module.h>
33#include <linux/platform_device.h>
wthomas442c7972013-08-05 14:28:17 -070034#include <linux/proc_fs.h>
35#include <linux/device.h>
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080036
37#if (NSS_DT_SUPPORT == 1)
Stephen Wang463f1cf2016-03-29 15:25:51 -070038#if (NSS_FABRIC_SCALING_SUPPORT == 1)
Stephen Wang8ffd17f2016-03-07 14:03:40 -080039#include <linux/fab_scaling.h>
Stephen Wang1017ad12016-03-14 10:18:06 -070040#endif
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080041#include <linux/of.h>
42#include <linux/of_net.h>
43#include <linux/of_irq.h>
44#include <linux/of_address.h>
45#include <linux/reset.h>
46#else
Abhishek Rastogibc74e432013-04-02 10:28:22 +053047#include <mach/msm_nss.h>
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080048#endif
Abhishek Rastogibc74e432013-04-02 10:28:22 +053049
wthomas442c7972013-08-05 14:28:17 -070050#include <linux/sysctl.h>
51#include <linux/regulator/consumer.h>
Thomas Wufb6a6842013-10-23 13:14:27 -070052#include <linux/clk.h>
wthomas442c7972013-08-05 14:28:17 -070053
Abhishek Rastogibc74e432013-04-02 10:28:22 +053054/*
55 * Global declarations
56 */
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +053057int nss_ctl_redirect __read_mostly = 0;
Sakthi Vignesh Radhakrishnanaf39aad2014-03-31 11:31:03 -070058int nss_ctl_debug __read_mostly = 0;
Saurabh Misra96998db2014-07-10 12:15:48 -070059int nss_ctl_logbuf __read_mostly = 0;
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -080060int nss_jumbo_mru __read_mostly = 0;
61int nss_paged_mode __read_mostly = 0;
Radha krishna Simha Jiguru28a0a252015-08-04 16:34:09 +053062int nss_skip_nw_process = 0x0;
63module_param(nss_skip_nw_process, int, S_IRUGO);
Abhishek Rastogibc74e432013-04-02 10:28:22 +053064
65/*
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053066 * PM client handle
67 */
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080068#if (NSS_PM_SUPPORT == 1)
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053069static void *pm_client;
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -080070#endif
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053071
72/*
wthomas626147f2013-09-18 13:12:40 -070073 * Handler to send NSS messages
74 */
Thomas Wufb6a6842013-10-23 13:14:27 -070075struct clk *nss_core0_clk;
Thomas Wu63bcff62017-03-20 11:44:41 -070076struct clk *nss_core1_clk;
wthomas626147f2013-09-18 13:12:40 -070077
78/*
Thomas Wucd6b35a2015-07-14 10:17:48 -070079 * Handle fabric requests - only on new kernel
80 */
81#if (NSS_DT_SUPPORT == 1)
82struct clk *nss_fab0_clk;
83struct clk *nss_fab1_clk;
Samarjeet Banerjee69731a22016-07-21 13:04:59 +053084bool nss_crypto_is_scaled = false;
Thomas Wucd6b35a2015-07-14 10:17:48 -070085#endif
86
87/*
Abhishek Rastogibc74e432013-04-02 10:28:22 +053088 * Top level nss context structure
89 */
90struct nss_top_instance nss_top_main;
wthomas442c7972013-08-05 14:28:17 -070091struct nss_cmd_buffer nss_cmd_buf;
wthomas626147f2013-09-18 13:12:40 -070092struct nss_runtime_sampling nss_runtime_samples;
93struct workqueue_struct *nss_wq;
94
95/*
96 * Work Queue to handle messages to Kernel
97 */
98nss_work_t *nss_work;
Abhishek Rastogibc74e432013-04-02 10:28:22 +053099
Arunkumar T79990cb2015-06-05 10:53:16 +0530100extern struct of_device_id nss_dt_ids[];
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530101
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530102/*
103 * nss_probe()
Arunkumar T79990cb2015-06-05 10:53:16 +0530104 * HLOS device probe callback
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530105 */
Ram Chandra Jangir6577f382016-05-31 12:16:28 +0530106static inline int nss_probe(struct platform_device *nss_dev)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530107{
Arunkumar T79990cb2015-06-05 10:53:16 +0530108 return nss_hal_probe(nss_dev);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530109}
110
111/*
112 * nss_remove()
Arunkumar T79990cb2015-06-05 10:53:16 +0530113 * HLOS device remove callback
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530114 */
Ram Chandra Jangir6577f382016-05-31 12:16:28 +0530115static inline int nss_remove(struct platform_device *nss_dev)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530116{
Arunkumar T79990cb2015-06-05 10:53:16 +0530117 return nss_hal_remove(nss_dev);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530118}
119
Stephen Wang90c67de2016-04-26 15:15:59 -0700120#if (NSS_DT_SUPPORT == 1)
121/*
122 * Platform Device ID for NSS core.
123 */
124struct of_device_id nss_dt_ids[] = {
125 { .compatible = "qcom,nss" },
126 { .compatible = "qcom,nss0" },
127 { .compatible = "qcom,nss1" },
128 {},
129};
130MODULE_DEVICE_TABLE(of, nss_dt_ids);
131#endif
132
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530133/*
134 * nss_driver
135 * Platform driver structure for NSS
136 */
137struct platform_driver nss_driver = {
138 .probe = nss_probe,
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800139 .remove = nss_remove,
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530140 .driver = {
141 .name = "qca-nss",
142 .owner = THIS_MODULE,
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800143#if (NSS_DT_SUPPORT == 1)
144 .of_match_table = of_match_ptr(nss_dt_ids),
145#endif
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530146 },
147};
148
Arunkumar T28b2d742015-06-16 22:15:58 +0530149#if (NSS_FREQ_SCALE_SUPPORT == 1)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530150/*
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530151 * nss_reset_frequency_stats_samples()
152 * Reset all frequency sampling state when auto scaling is turned off.
153 */
154static void nss_reset_frequency_stats_samples (void)
155{
156 nss_runtime_samples.buffer_index = 0;
157 nss_runtime_samples.sum = 0;
158 nss_runtime_samples.average = 0;
159 nss_runtime_samples.sample_count = 0;
160 nss_runtime_samples.message_rate_limit = 0;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530161 nss_runtime_samples.freq_scale_rate_limit_down = 0;
162}
163
164/*
wthomas626147f2013-09-18 13:12:40 -0700165 ***************************************************************************************************
Thomas Wufb6a6842013-10-23 13:14:27 -0700166 * nss_wq_function() is used to queue up requests to change NSS frequencies.
167 * The function will take care of NSS notices and also control clock.
168 * The auto rate algorithmn will queue up requests or the procfs may also queue up these requests.
wthomas626147f2013-09-18 13:12:40 -0700169 ***************************************************************************************************
170 */
171
172/*
173 * nss_wq_function()
174 * Added to Handle BH requests to kernel
175 */
176void nss_wq_function (struct work_struct *work)
177{
178 nss_work_t *my_work = (nss_work_t *)work;
Vijay Vigneshana94c2652016-06-02 12:39:35 +0530179#if (NSS_DT_SUPPORT == 1)
180 nss_crypto_pm_event_callback_t crypto_pm_cb;
Samarjeet Banerjee69731a22016-07-21 13:04:59 +0530181 bool auto_scale;
182 bool turbo;
183
c_athandfde2e912017-01-10 15:40:12 +0530184 mutex_lock(&nss_top_main.wq_lock);
Samarjeet Banerjee69731a22016-07-21 13:04:59 +0530185 /*
Samarjeet Banerjeeb126e0f2016-08-05 20:58:27 +0530186 * If crypto clock is in Turbo, disable scaling for other
187 * NSS subsystem components and retain them at turbo
Samarjeet Banerjee69731a22016-07-21 13:04:59 +0530188 */
189 if (nss_crypto_is_scaled) {
Samarjeet Banerjeeb126e0f2016-08-05 20:58:27 +0530190 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency;
c_athandfde2e912017-01-10 15:40:12 +0530191 mutex_unlock(&nss_top_main.wq_lock);
Samarjeet Banerjee69731a22016-07-21 13:04:59 +0530192 return;
193 }
Vijay Vigneshana94c2652016-06-02 12:39:35 +0530194#endif
wthomas626147f2013-09-18 13:12:40 -0700195
Guojun Jin32a3c6d2015-05-06 12:27:52 -0700196 nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 0);
Guojun Jin9d782812015-05-12 14:01:25 -0700197 if (nss_top_main.nss[NSS_CORE_1].state == NSS_CORE_STATE_INITIALIZED) {
198 nss_freq_change(&nss_top_main.nss[NSS_CORE_1], my_work->frequency, my_work->stats_enable, 0);
199 }
Thomas Wufb6a6842013-10-23 13:14:27 -0700200 clk_set_rate(nss_core0_clk, my_work->frequency);
Thomas Wu63bcff62017-03-20 11:44:41 -0700201
Guojun Jin32a3c6d2015-05-06 12:27:52 -0700202 nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 1);
Guojun Jin9d782812015-05-12 14:01:25 -0700203 if (nss_top_main.nss[NSS_CORE_1].state == NSS_CORE_STATE_INITIALIZED) {
204 nss_freq_change(&nss_top_main.nss[NSS_CORE_1], my_work->frequency, my_work->stats_enable, 1);
205 }
Thomas Wu63bcff62017-03-20 11:44:41 -0700206#if defined(NSS_HAL_IPQ807x_SUPPORT)
207 clk_set_rate(nss_core1_clk, my_work->frequency);
208#endif
wthomas626147f2013-09-18 13:12:40 -0700209
Thomas Wucd6b35a2015-07-14 10:17:48 -0700210/*
211 * If we are running NSS_PM_SUPPORT, we are on banana
212 * otherwise, we check if we are are on new kernel by checking if the
213 * fabric lookups are not NULL (success in init()))
214 */
Thomas Wu0d112192015-04-13 11:37:22 -0700215#if (NSS_PM_SUPPORT == 1)
Thomas Wucd6b35a2015-07-14 10:17:48 -0700216 if (!pm_client) {
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530217 goto out;
218 }
219
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800220 if (my_work->frequency >= NSS_FREQ_733) {
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530221 nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_TURBO);
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800222 } else if (my_work->frequency > NSS_FREQ_110) {
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530223 nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_NOMINAL);
224 } else {
225 nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_IDLE);
226 }
Thomas Wu0d112192015-04-13 11:37:22 -0700227
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530228out:
Thomas Wucd6b35a2015-07-14 10:17:48 -0700229#else
230#if (NSS_DT_SUPPORT == 1)
Stephen Wang463f1cf2016-03-29 15:25:51 -0700231#if (NSS_FABRIC_SCALING_SUPPORT == 1)
Stephen Wang8ffd17f2016-03-07 14:03:40 -0800232 scale_fabrics();
Stephen Wang1017ad12016-03-14 10:18:06 -0700233#endif
Samarjeet Banerjee69731a22016-07-21 13:04:59 +0530234 if ((nss_fab0_clk != NULL) && (nss_fab1_clk != NULL)) {
Thomas Wucd6b35a2015-07-14 10:17:48 -0700235 if (my_work->frequency >= NSS_FREQ_733) {
236 clk_set_rate(nss_fab0_clk, NSS_FABRIC0_TURBO);
237 clk_set_rate(nss_fab1_clk, NSS_FABRIC1_TURBO);
238 } else if (my_work->frequency > NSS_FREQ_110) {
239 clk_set_rate(nss_fab0_clk, NSS_FABRIC0_NOMINAL);
240 clk_set_rate(nss_fab1_clk, NSS_FABRIC1_NOMINAL);
241 } else {
242 clk_set_rate(nss_fab0_clk, NSS_FABRIC0_IDLE);
243 clk_set_rate(nss_fab1_clk, NSS_FABRIC1_IDLE);
244 }
Samarjeet Banerjeecdfc0bd2016-05-28 00:22:31 +0530245
246 /*
247 * notify crypto about the clock change
248 */
249 crypto_pm_cb = nss_top_main.crypto_pm_callback;
250 if (crypto_pm_cb) {
251 turbo = (my_work->frequency >= NSS_FREQ_733);
Samarjeet Banerjee69731a22016-07-21 13:04:59 +0530252 auto_scale = nss_cmd_buf.auto_scale;
253 nss_crypto_is_scaled = crypto_pm_cb(nss_top_main.crypto_pm_ctx, turbo, auto_scale);
Samarjeet Banerjeecdfc0bd2016-05-28 00:22:31 +0530254 }
Thomas Wucd6b35a2015-07-14 10:17:48 -0700255 }
256#endif
Thomas Wu0d112192015-04-13 11:37:22 -0700257#endif
c_athandfde2e912017-01-10 15:40:12 +0530258 mutex_unlock(&nss_top_main.wq_lock);
wthomas626147f2013-09-18 13:12:40 -0700259 kfree((void *)work);
260}
261
262/*
wthomas442c7972013-08-05 14:28:17 -0700263 * nss_current_freq_handler()
264 * Handle Userspace Frequency Change Requests
265 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700266static 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 -0700267{
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800268 int ret, i;
wthomas626147f2013-09-18 13:12:40 -0700269
270 BUG_ON(!nss_wq);
wthomas442c7972013-08-05 14:28:17 -0700271
272 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
273
Thomas Wuc151f2e2015-09-08 10:59:44 -0700274 if (!*lenp || (*ppos && !write)) {
wthomas626147f2013-09-18 13:12:40 -0700275 printk("Frequency Set to %d\n", nss_cmd_buf.current_freq);
Thomas Wuc151f2e2015-09-08 10:59:44 -0700276 *lenp = 0;
wthomasd39fa822013-08-22 16:44:23 -0700277 return ret;
wthomas442c7972013-08-05 14:28:17 -0700278 }
wthomasd39fa822013-08-22 16:44:23 -0700279
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800280 /*
281 * Check if frequency exists in frequency Table
282 */
283 i = 0;
Thomas Wu7132bd32015-05-07 15:03:06 -0700284 while (i < NSS_FREQ_MAX_SCALE) {
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800285 if (nss_runtime_samples.freq_scale[i].frequency == nss_cmd_buf.current_freq) {
286 break;
287 }
288 i++;
289 }
Thomas Wu7132bd32015-05-07 15:03:06 -0700290 if (i == NSS_FREQ_MAX_SCALE) {
Thomas Wufb6a6842013-10-23 13:14:27 -0700291 printk("Frequency not found. Please check Frequency Table\n");
Thomas Wub7683af2016-07-07 14:19:09 -0700292 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
wthomas626147f2013-09-18 13:12:40 -0700293 return ret;
wthomasd39fa822013-08-22 16:44:23 -0700294 }
295
Thomas Wub7683af2016-07-07 14:19:09 -0700296 /*
297 * Turn off Auto Scale
298 */
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800299 nss_cmd_buf.auto_scale = 0;
300 nss_runtime_samples.freq_scale_ready = 0;
Thomas Wub7683af2016-07-07 14:19:09 -0700301 nss_runtime_samples.freq_scale_index = i;
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800302
Thomas Wu7409bce2014-05-21 10:56:07 -0700303 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
wthomas626147f2013-09-18 13:12:40 -0700304 if (!nss_work) {
305 nss_info("NSS Freq WQ kmalloc fail");
306 return ret;
307 }
308 INIT_WORK((struct work_struct *)nss_work, nss_wq_function);
309 nss_work->frequency = nss_cmd_buf.current_freq;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530310 nss_work->stats_enable = 0;
311
Thomas Wub7683af2016-07-07 14:19:09 -0700312 /*
313 * Ensure we start with a fresh set of samples later
314 */
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530315 nss_reset_frequency_stats_samples();
316
wthomas626147f2013-09-18 13:12:40 -0700317 queue_work(nss_wq, (struct work_struct *)nss_work);
318
wthomas442c7972013-08-05 14:28:17 -0700319 return ret;
320}
321
322/*
323 * nss_auto_scale_handler()
324 * Enables or Disable Auto Scaling
325 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700326static 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 -0700327{
328 int ret;
329
330 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
331
Thomas Wuc151f2e2015-09-08 10:59:44 -0700332 if (!*lenp || (*ppos && !write)) {
wthomas626147f2013-09-18 13:12:40 -0700333 return ret;
334 }
335
Thomas Wufb6a6842013-10-23 13:14:27 -0700336 if (nss_cmd_buf.auto_scale != 1) {
wthomas626147f2013-09-18 13:12:40 -0700337 /*
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530338 * Is auto scaling currently enabled? If so, send the command to
339 * disable stats reporting to NSS
wthomas626147f2013-09-18 13:12:40 -0700340 */
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530341 if (nss_runtime_samples.freq_scale_ready != 0) {
342 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
Thomas Wu7409bce2014-05-21 10:56:07 -0700343 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530344 if (!nss_work) {
345 nss_info("NSS Freq WQ kmalloc fail");
346 return ret;
347 }
348 INIT_WORK((struct work_struct *)nss_work, nss_wq_function);
349 nss_work->frequency = nss_cmd_buf.current_freq;
350 nss_work->stats_enable = 0;
351 queue_work(nss_wq, (struct work_struct *)nss_work);
352 nss_runtime_samples.freq_scale_ready = 0;
353
354 /*
355 * The current samples would be stale later when scaling is
356 * enabled again, hence reset them
357 */
358 nss_reset_frequency_stats_samples();
359 }
Thomas Wufb6a6842013-10-23 13:14:27 -0700360 return ret;
wthomas626147f2013-09-18 13:12:40 -0700361 }
wthomas442c7972013-08-05 14:28:17 -0700362
Thomas Wufb6a6842013-10-23 13:14:27 -0700363 /*
364 * Auto Scaling is already being done
365 */
366 if (nss_runtime_samples.freq_scale_ready == 1) {
367 return ret;
368 }
369
370 /*
371 * Setup default values - Middle of Freq Scale Band
372 */
373 nss_runtime_samples.freq_scale_index = 1;
374 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
375
Thomas Wu7409bce2014-05-21 10:56:07 -0700376 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
Thomas Wufb6a6842013-10-23 13:14:27 -0700377 if (!nss_work) {
378 nss_info("NSS Freq WQ kmalloc fail");
379 return ret;
380 }
381 INIT_WORK((struct work_struct *)nss_work, nss_wq_function);
382 nss_work->frequency = nss_cmd_buf.current_freq;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530383 nss_work->stats_enable = 1;
Thomas Wufb6a6842013-10-23 13:14:27 -0700384 queue_work(nss_wq, (struct work_struct *)nss_work);
385
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800386 nss_cmd_buf.auto_scale = 0;
Thomas Wufb6a6842013-10-23 13:14:27 -0700387 nss_runtime_samples.freq_scale_ready = 1;
388
wthomas442c7972013-08-05 14:28:17 -0700389 return ret;
390}
391
392/*
393 * nss_get_freq_table_handler()
394 * Display Support Freq and Ex how to Change.
395 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700396static 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 -0700397{
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800398 int ret, i;
wthomas442c7972013-08-05 14:28:17 -0700399
400 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
401
Thomas Wuc151f2e2015-09-08 10:59:44 -0700402 if (write) {
403 return ret;
404 }
405
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800406 printk("Frequency Supported - ");
Thomas Wuc151f2e2015-09-08 10:59:44 -0700407
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800408 i = 0;
Thomas Wu7132bd32015-05-07 15:03:06 -0700409 while (i < NSS_FREQ_MAX_SCALE) {
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800410 printk("%dMhz ", nss_runtime_samples.freq_scale[i].frequency/1000000);
411 i++;
Thomas Wu0a0a9c92013-11-21 15:28:19 -0800412 }
Thomas Wu0e2fc4f2015-03-04 15:39:14 -0800413 printk("\n");
wthomas442c7972013-08-05 14:28:17 -0700414
Thomas Wuc151f2e2015-09-08 10:59:44 -0700415 *lenp = 0;
wthomas442c7972013-08-05 14:28:17 -0700416 return ret;
417}
418
419/*
Thomas Wu05495be2013-12-19 14:24:24 -0800420 * nss_get_average_inst_handler()
421 * Display AVG Inst Per Ms.
422 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700423static 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 -0800424{
425 int ret;
426
427 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
428
Thomas Wuc151f2e2015-09-08 10:59:44 -0700429 if (write) {
430 return ret;
Thomas Wu05495be2013-12-19 14:24:24 -0800431 }
432
Thomas Wuc151f2e2015-09-08 10:59:44 -0700433 printk("Current Inst Per Ms %x\n", nss_runtime_samples.average);
434
435 *lenp = 0;
Thomas Wu05495be2013-12-19 14:24:24 -0800436 return ret;
437}
Arunkumar T28b2d742015-06-16 22:15:58 +0530438#endif
Thomas Wu05495be2013-12-19 14:24:24 -0800439
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800440#if (NSS_FW_DBG_SUPPORT == 1)
Thomas Wu05495be2013-12-19 14:24:24 -0800441/*
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530442 * nss_debug_handler()
443 * Enable NSS debug output
444 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700445static 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 +0530446{
447 int ret;
448
449 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
450 if (!ret) {
451 if ((write) && (nss_ctl_debug != 0)) {
452 printk("Enabling NSS SPI Debug\n");
453 nss_hal_debug_enable();
454 }
455 }
456
457 return ret;
458}
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800459#endif
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530460
461/*
Thomas Wu52075f42014-02-06 16:32:42 -0800462 * nss_coredump_handler()
463 * Send Signal To Coredump NSS Cores
464 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700465static 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 -0800466{
Guojun Jin32a3c6d2015-05-06 12:27:52 -0700467 struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[NSS_CORE_0];
Thomas Wu52075f42014-02-06 16:32:42 -0800468 int ret;
469
470 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
471 if (!ret) {
Guojun Jin244ecab2017-03-16 16:04:25 -0700472 /*
473 * if nss_cmd_buf.coredump is not 0 or 1, panic will be disabled
474 * when NSS FW crashes, so OEM/ODM have a chance to use mdump
475 * to dump crash dump (coredump) and send dump to us for analysis.
476 */
477 if ((write) && (nss_ctl_debug != 0) && nss_cmd_buf.coredump == 1) {
Thomas Wu52075f42014-02-06 16:32:42 -0800478 printk("Coredumping to DDR\n");
Stephen Wang90c67de2016-04-26 15:15:59 -0700479 nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP);
Thomas Wu52075f42014-02-06 16:32:42 -0800480 }
481 }
482
483 return ret;
484}
485
486/*
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800487 * nss_jumbo_mru_handler()
488 * Sysctl to modify nss_jumbo_mru
489 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700490static 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 -0800491{
492 int ret;
493
494 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
495 if (ret) {
496 return ret;
497 }
498
499 if (write) {
500 nss_core_set_jumbo_mru(nss_jumbo_mru);
501 nss_info("jumbo_mru set to %d\n", nss_jumbo_mru);
502 }
503
504 return ret;
505}
506
507/* nss_paged_mode_handler()
508 * Sysctl to modify nss_paged_mode.
509 */
510
Stephen Wang52e6d342016-03-29 15:02:33 -0700511static 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 -0800512{
513 int ret;
514
515 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
516 if (ret) {
517 return ret;
518 }
519
520 if (write) {
521 nss_core_set_paged_mode(nss_paged_mode);
522 nss_info("paged_mode set to %d\n", nss_paged_mode);
523 }
524
525 return ret;
526}
527
Arunkumar T28b2d742015-06-16 22:15:58 +0530528#if (NSS_FREQ_SCALE_SUPPORT == 1)
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800529/*
wthomas442c7972013-08-05 14:28:17 -0700530 * sysctl-tuning infrastructure.
531 */
Stephen Wang52e6d342016-03-29 15:02:33 -0700532static struct ctl_table nss_freq_table[] = {
wthomas442c7972013-08-05 14:28:17 -0700533 {
534 .procname = "current_freq",
535 .data = &nss_cmd_buf.current_freq,
536 .maxlen = sizeof(int),
537 .mode = 0644,
538 .proc_handler = &nss_current_freq_handler,
539 },
540 {
541 .procname = "freq_table",
542 .data = &nss_cmd_buf.max_freq,
543 .maxlen = sizeof(int),
544 .mode = 0644,
545 .proc_handler = &nss_get_freq_table_handler,
546 },
547 {
548 .procname = "auto_scale",
549 .data = &nss_cmd_buf.auto_scale,
550 .maxlen = sizeof(int),
551 .mode = 0644,
552 .proc_handler = &nss_auto_scale_handler,
553 },
Thomas Wu05495be2013-12-19 14:24:24 -0800554 {
555 .procname = "inst_per_sec",
556 .data = &nss_cmd_buf.average_inst,
557 .maxlen = sizeof(int),
558 .mode = 0644,
559 .proc_handler = &nss_get_average_inst_handler,
560 },
wthomas442c7972013-08-05 14:28:17 -0700561 { }
562};
Arunkumar T28b2d742015-06-16 22:15:58 +0530563#endif
wthomas442c7972013-08-05 14:28:17 -0700564
Stephen Wang52e6d342016-03-29 15:02:33 -0700565static struct ctl_table nss_general_table[] = {
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530566 {
567 .procname = "redirect",
568 .data = &nss_ctl_redirect,
569 .maxlen = sizeof(int),
570 .mode = 0644,
Vijay Dewangan9db18752014-09-15 16:25:01 -0700571 .proc_handler = proc_dointvec,
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530572 },
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800573#if (NSS_FW_DBG_SUPPORT == 1)
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530574 {
575 .procname = "debug",
576 .data = &nss_ctl_debug,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Vijay Dewangan9db18752014-09-15 16:25:01 -0700579 .proc_handler = &nss_debug_handler,
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530580 },
Sundarajan Srinivasan758e8f42014-12-08 14:56:24 -0800581#endif
Thomas Wu52075f42014-02-06 16:32:42 -0800582 {
583 .procname = "coredump",
584 .data = &nss_cmd_buf.coredump,
585 .maxlen = sizeof(int),
586 .mode = 0644,
Vijay Dewangan9db18752014-09-15 16:25:01 -0700587 .proc_handler = &nss_coredump_handler,
Thomas Wu52075f42014-02-06 16:32:42 -0800588 },
Pamidipati, Vijayefcc4692014-05-09 14:47:38 +0530589 {
Saurabh Misra96998db2014-07-10 12:15:48 -0700590 .procname = "logbuf",
591 .data = &nss_ctl_logbuf,
592 .maxlen = sizeof(int),
593 .mode = 0644,
594 .proc_handler = &nss_logbuffer_handler,
595 },
Sundarajan Srinivasanf9c4a232014-11-18 13:25:40 -0800596 {
597 .procname = "jumbo_mru",
598 .data = &nss_jumbo_mru,
599 .maxlen = sizeof(int),
600 .mode = 0644,
601 .proc_handler = &nss_jumbo_mru_handler,
602 },
603 {
604 .procname = "paged_mode",
605 .data = &nss_paged_mode,
606 .maxlen = sizeof(int),
607 .mode = 0644,
608 .proc_handler = &nss_paged_mode_handler,
609 },
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530610 { }
611};
612
Stephen Wang52e6d342016-03-29 15:02:33 -0700613static struct ctl_table nss_clock_dir[] = {
Arunkumar T28b2d742015-06-16 22:15:58 +0530614#if (NSS_FREQ_SCALE_SUPPORT == 1)
wthomas442c7972013-08-05 14:28:17 -0700615 {
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530616 .procname = "clock",
617 .mode = 0555,
618 .child = nss_freq_table,
619 },
Arunkumar T28b2d742015-06-16 22:15:58 +0530620#endif
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530621 {
622 .procname = "general",
623 .mode = 0555,
624 .child = nss_general_table,
wthomas442c7972013-08-05 14:28:17 -0700625 },
626 { }
627};
628
Stephen Wang52e6d342016-03-29 15:02:33 -0700629static struct ctl_table nss_root_dir[] = {
wthomas442c7972013-08-05 14:28:17 -0700630 {
631 .procname = "nss",
632 .mode = 0555,
633 .child = nss_clock_dir,
634 },
635 { }
636};
637
Stephen Wang52e6d342016-03-29 15:02:33 -0700638static struct ctl_table nss_root[] = {
wthomas442c7972013-08-05 14:28:17 -0700639 {
640 .procname = "dev",
641 .mode = 0555,
642 .child = nss_root_dir,
643 },
644 { }
645};
646
647static struct ctl_table_header *nss_dev_header;
648
649/*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530650 * nss_init()
651 * Registers nss driver
652 */
653static int __init nss_init(void)
654{
Radha krishna Simha Jiguru3295b8b2017-03-12 10:54:15 +0530655#if (NSS_DT_SUPPORT == 1)
656 struct device_node *cmn = NULL;
657#endif
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530658 nss_info("Init NSS driver");
659
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800660#if (NSS_DT_SUPPORT == 1)
661 /*
Radha krishna Simha Jiguru3295b8b2017-03-12 10:54:15 +0530662 * Get reference to NSS common device node
663 */
664 cmn = of_find_node_by_name(NULL, "nss-common");
665 if (!cmn) {
666 nss_info_always("qca-nss-drv.ko is loaded for symbol link\n");
667 return 0;
668 }
669 of_node_put(cmn);
670
671 /*
Stephen Wang90c67de2016-04-26 15:15:59 -0700672 * Pick up HAL by target information
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800673 */
Stephen Wang90c67de2016-04-26 15:15:59 -0700674#if defined(NSS_HAL_IPQ806X_SUPPORT)
675 if (of_machine_is_compatible("qcom,ipq8064") || of_machine_is_compatible("qcom,ipq8062")) {
676 nss_top_main.hal_ops = &nss_hal_ipq806x_ops;
Stephen Wang5901def2016-05-09 16:21:03 -0700677 nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops;
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800678 }
Stephen Wang90c67de2016-04-26 15:15:59 -0700679#endif
Stephen Wangbe348022016-05-02 17:11:34 -0700680#if defined(NSS_HAL_IPQ807x_SUPPORT)
681 if (of_machine_is_compatible("qcom,ipq807x")) {
682 nss_top_main.hal_ops = &nss_hal_ipq807x_ops;
Stephen Wangdf8323b2016-05-09 22:51:22 -0700683 nss_top_main.data_plane_ops = &nss_data_plane_edma_ops;
Stephen Wangbe348022016-05-02 17:11:34 -0700684 }
685#endif
Stephen Wang90c67de2016-04-26 15:15:59 -0700686#if defined(NSS_HAL_FSM9010_SUPPORT)
687 if (of_machine_is_compatible("qcom,fsm9010")) {
688 nss_top_main.hal_ops = &nss_hal_fsm9010_ops;
Stephen Wang5901def2016-05-09 16:21:03 -0700689 nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops;
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;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530702
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800703#endif /* NSS_DT_SUPPORT */
Stephen Wang90c67de2016-04-26 15:15:59 -0700704 nss_top_main.nss_hal_common_init_done = false;
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800705
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530706 /*
Stephen Wangb42ddc52015-12-17 18:10:35 -0800707 * Initialize data_plane workqueue
708 */
709 if (nss_data_plane_init_delay_work()) {
710 nss_warning("Error initializing nss_data_plane_workqueue\n");
711 return -EFAULT;
712 }
713
714 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530715 * Enable spin locks
716 */
717 spin_lock_init(&(nss_top_main.lock));
718 spin_lock_init(&(nss_top_main.stats_lock));
c_athandfde2e912017-01-10 15:40:12 +0530719 mutex_init(&(nss_top_main.wq_lock));
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530720
721 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530722 * Enable NSS statistics
723 */
724 nss_stats_init();
725
726 /*
wthomas442c7972013-08-05 14:28:17 -0700727 * Register sysctl table.
728 */
729 nss_dev_header = register_sysctl_table(nss_root);
730
731 /*
Vijay Dewangan9db18752014-09-15 16:25:01 -0700732 * Registering sysctl for ipv4/6 specific config.
733 */
734 nss_ipv4_register_sysctl();
735 nss_ipv6_register_sysctl();
736
Vijay Dewanganac7efc42015-02-09 16:04:53 -0800737 /*
Stephen Wang49b474b2016-03-25 10:40:30 -0700738 * Registering sysctl for n2h specific config.
Vijay Dewanganac7efc42015-02-09 16:04:53 -0800739 */
Stephen Wang49b474b2016-03-25 10:40:30 -0700740 nss_n2h_register_sysctl();
Vijay Dewanganac7efc42015-02-09 16:04:53 -0800741
Vijay Dewangan9db18752014-09-15 16:25:01 -0700742 /*
Murat Sezgine5079aa2017-06-07 18:09:38 -0700743 * Registering sysctl for dscp2pri specific config.
744 */
745 nss_dscp2pri_register_sysctl();
746
747 /*
Jackson Bockusc2a4e682017-06-23 11:59:29 -0700748 * Register sysctl for project config
749 */
750 nss_project_register_sysctl();
751
752 /*
wthomas626147f2013-09-18 13:12:40 -0700753 * Setup Runtime Sample values
754 */
wthomas626147f2013-09-18 13:12:40 -0700755 nss_runtime_samples.freq_scale_index = 1;
756 nss_runtime_samples.freq_scale_ready = 0;
Thomas Wu9681f7e2013-11-06 13:12:57 -0800757 nss_runtime_samples.freq_scale_rate_limit_down = 0;
wthomas626147f2013-09-18 13:12:40 -0700758 nss_runtime_samples.buffer_index = 0;
759 nss_runtime_samples.sum = 0;
760 nss_runtime_samples.sample_count = 0;
761 nss_runtime_samples.average = 0;
762 nss_runtime_samples.message_rate_limit = 0;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530763 nss_runtime_samples.initialized = 0;
wthomas626147f2013-09-18 13:12:40 -0700764
Thomas Wu05495be2013-12-19 14:24:24 -0800765 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
766
wthomas626147f2013-09-18 13:12:40 -0700767 /*
768 * Initial Workqueue
769 */
770 nss_wq = create_workqueue("nss_freq_queue");
771
Thomas Wu0d112192015-04-13 11:37:22 -0700772#if (NSS_PM_SUPPORT == 1)
wthomas626147f2013-09-18 13:12:40 -0700773 /*
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530774 * Initialize NSS Bus PM module
775 */
776 nss_pm_init();
777
778 /*
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530779 * Register with Bus driver
780 */
781 pm_client = nss_pm_client_register(NSS_PM_CLIENT_NETAP);
782 if (!pm_client) {
783 nss_warning("Error registering with PM driver");
784 }
Sundarajan Srinivasan4691ba62014-11-07 11:24:07 -0800785#endif
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530786
787 /*
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +0530788 * Initialize mtu size needed as start
789 */
Stephen Wanga428d0b2017-01-12 21:30:01 -0800790 nss_top_main.prev_mtu_sz = ETH_DATA_LEN;
Radha krishna Simha Jiguru7f424d52015-02-10 19:41:01 +0530791
792 /*
Guojun Jin1cb79522015-06-22 22:34:22 -0700793 * register panic handler and timeout control
794 */
795 nss_coredump_notify_register();
796 nss_coredump_init_delay_work();
797
798 /*
Stephen Wang1f6ad492016-01-27 23:42:06 -0800799 * Init capwap
800 */
801 nss_capwap_init();
802
803 /*
Amit Gupta316729b2016-08-12 12:21:15 +0530804 * INIT ppe on supported platform
805 */
806 if (of_machine_is_compatible("qcom,ipq807x")) {
807 nss_ppe_init();
808 }
809
810 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530811 * Register platform_driver
812 */
813 return platform_driver_register(&nss_driver);
814}
815
816/*
817 * nss_cleanup()
818 * Unregisters nss driver
819 */
820static void __exit nss_cleanup(void)
821{
822 nss_info("Exit NSS driver");
wthomas442c7972013-08-05 14:28:17 -0700823
824 if (nss_dev_header)
825 unregister_sysctl_table(nss_dev_header);
826
Vijay Dewangan9db18752014-09-15 16:25:01 -0700827 /*
Vijay Dewangan488e5372014-12-29 21:40:11 -0800828 * Unregister n2h specific sysctl
829 */
Stephen Wang49b474b2016-03-25 10:40:30 -0700830 nss_n2h_unregister_sysctl();
Vijay Dewangan488e5372014-12-29 21:40:11 -0800831
832 /*
Vijay Dewangan9db18752014-09-15 16:25:01 -0700833 * Unregister ipv4/6 specific sysctl
834 */
835 nss_ipv4_unregister_sysctl();
836 nss_ipv6_unregister_sysctl();
837
Suruchi Agarwalcdcb5b42017-07-06 11:08:22 -0700838 /*
839 * Free Memory allocated for connection tables
840 */
841 nss_ipv4_free_conn_tables();
842 nss_ipv6_free_conn_tables();
843
Murat Sezgine5079aa2017-06-07 18:09:38 -0700844 nss_dscp2pri_unregister_sysctl();
Jackson Bockusc2a4e682017-06-23 11:59:29 -0700845 nss_project_unregister_sysctl();
Stephen Wangb42ddc52015-12-17 18:10:35 -0800846 nss_data_plane_destroy_delay_work();
847
Amit Gupta316729b2016-08-12 12:21:15 +0530848 /*
849 * cleanup ppe on supported platform
850 */
851 if (of_machine_is_compatible("qcom,ipq807x")) {
852 nss_ppe_free();
853 }
854
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530855 platform_driver_unregister(&nss_driver);
856}
857
858module_init(nss_init);
859module_exit(nss_cleanup);
860
861MODULE_DESCRIPTION("QCA NSS Driver");
862MODULE_AUTHOR("Qualcomm Atheros Inc");
863MODULE_LICENSE("Dual BSD/GPL");