Radhakrishna Jiguru | 1c9b225 | 2013-08-27 23:57:48 +0530 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Stephen Wang | a428d0b | 2017-01-12 21:30:01 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. |
Radhakrishna Jiguru | 1c9b225 | 2013-08-27 23:57:48 +0530 | [diff] [blame] | 4 | * 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 Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * nss_init.c |
| 19 | * NSS init APIs |
| 20 | * |
| 21 | */ |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 22 | #include "nss_core.h" |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 23 | #if (NSS_PM_SUPPORT == 1) |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 24 | #include "nss_pm.h" |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 25 | #endif |
Abhishek Rastogi | 9da4747 | 2014-03-18 19:46:15 +0530 | [diff] [blame] | 26 | #include "nss_tx_rx_common.h" |
Stephen Wang | 38e89bc | 2014-11-06 11:34:45 -0800 | [diff] [blame] | 27 | #include "nss_data_plane.h" |
Stephen Wang | 1f6ad49 | 2016-01-27 23:42:06 -0800 | [diff] [blame] | 28 | #include "nss_capwap.h" |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 29 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 30 | #include <nss_hal.h> |
| 31 | |
| 32 | #include <linux/module.h> |
| 33 | #include <linux/platform_device.h> |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 34 | #include <linux/proc_fs.h> |
| 35 | #include <linux/device.h> |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 36 | |
| 37 | #if (NSS_DT_SUPPORT == 1) |
Stephen Wang | 463f1cf | 2016-03-29 15:25:51 -0700 | [diff] [blame] | 38 | #if (NSS_FABRIC_SCALING_SUPPORT == 1) |
Stephen Wang | 8ffd17f | 2016-03-07 14:03:40 -0800 | [diff] [blame] | 39 | #include <linux/fab_scaling.h> |
Stephen Wang | 1017ad1 | 2016-03-14 10:18:06 -0700 | [diff] [blame] | 40 | #endif |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 41 | #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 Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 47 | #include <mach/msm_nss.h> |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 48 | #endif |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 49 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 50 | #include <linux/sysctl.h> |
| 51 | #include <linux/regulator/consumer.h> |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 52 | #include <linux/clk.h> |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 53 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 54 | /* |
| 55 | * Global declarations |
| 56 | */ |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 57 | int nss_ctl_redirect __read_mostly = 0; |
Sakthi Vignesh Radhakrishnan | af39aad | 2014-03-31 11:31:03 -0700 | [diff] [blame] | 58 | int nss_ctl_debug __read_mostly = 0; |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 59 | int nss_ctl_logbuf __read_mostly = 0; |
Sundarajan Srinivasan | f9c4a23 | 2014-11-18 13:25:40 -0800 | [diff] [blame] | 60 | int nss_jumbo_mru __read_mostly = 0; |
| 61 | int nss_paged_mode __read_mostly = 0; |
Radha krishna Simha Jiguru | 28a0a25 | 2015-08-04 16:34:09 +0530 | [diff] [blame] | 62 | int nss_skip_nw_process = 0x0; |
| 63 | module_param(nss_skip_nw_process, int, S_IRUGO); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 64 | |
| 65 | /* |
Pamidipati, Vijay | 5d27d81 | 2013-11-22 16:48:11 +0530 | [diff] [blame] | 66 | * PM client handle |
| 67 | */ |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 68 | #if (NSS_PM_SUPPORT == 1) |
Pamidipati, Vijay | 5d27d81 | 2013-11-22 16:48:11 +0530 | [diff] [blame] | 69 | static void *pm_client; |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 70 | #endif |
Pamidipati, Vijay | 5d27d81 | 2013-11-22 16:48:11 +0530 | [diff] [blame] | 71 | |
| 72 | /* |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 73 | * Handler to send NSS messages |
| 74 | */ |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 75 | struct clk *nss_core0_clk; |
Thomas Wu | 63bcff6 | 2017-03-20 11:44:41 -0700 | [diff] [blame] | 76 | struct clk *nss_core1_clk; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 77 | |
| 78 | /* |
Thomas Wu | cd6b35a | 2015-07-14 10:17:48 -0700 | [diff] [blame] | 79 | * Handle fabric requests - only on new kernel |
| 80 | */ |
| 81 | #if (NSS_DT_SUPPORT == 1) |
| 82 | struct clk *nss_fab0_clk; |
| 83 | struct clk *nss_fab1_clk; |
| 84 | #endif |
| 85 | |
| 86 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 87 | * Top level nss context structure |
| 88 | */ |
| 89 | struct nss_top_instance nss_top_main; |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 90 | struct nss_cmd_buffer nss_cmd_buf; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 91 | struct nss_runtime_sampling nss_runtime_samples; |
| 92 | struct workqueue_struct *nss_wq; |
| 93 | |
| 94 | /* |
| 95 | * Work Queue to handle messages to Kernel |
| 96 | */ |
| 97 | nss_work_t *nss_work; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 98 | |
Arunkumar T | 79990cb | 2015-06-05 10:53:16 +0530 | [diff] [blame] | 99 | extern struct of_device_id nss_dt_ids[]; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 100 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 101 | /* |
| 102 | * nss_probe() |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 103 | * HLOS device probe callback |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 104 | */ |
Ram Chandra Jangir | 6577f38 | 2016-05-31 12:16:28 +0530 | [diff] [blame] | 105 | static inline int nss_probe(struct platform_device *nss_dev) |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 106 | { |
Arunkumar T | 79990cb | 2015-06-05 10:53:16 +0530 | [diff] [blame] | 107 | return nss_hal_probe(nss_dev); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /* |
| 111 | * nss_remove() |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 112 | * HLOS device remove callback |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 113 | */ |
Ram Chandra Jangir | 6577f38 | 2016-05-31 12:16:28 +0530 | [diff] [blame] | 114 | static inline int nss_remove(struct platform_device *nss_dev) |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 115 | { |
Arunkumar T | 79990cb | 2015-06-05 10:53:16 +0530 | [diff] [blame] | 116 | return nss_hal_remove(nss_dev); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 117 | } |
| 118 | |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 119 | #if (NSS_DT_SUPPORT == 1) |
| 120 | /* |
| 121 | * Platform Device ID for NSS core. |
| 122 | */ |
| 123 | struct of_device_id nss_dt_ids[] = { |
| 124 | { .compatible = "qcom,nss" }, |
| 125 | { .compatible = "qcom,nss0" }, |
| 126 | { .compatible = "qcom,nss1" }, |
| 127 | {}, |
| 128 | }; |
| 129 | MODULE_DEVICE_TABLE(of, nss_dt_ids); |
| 130 | #endif |
| 131 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 132 | /* |
| 133 | * nss_driver |
| 134 | * Platform driver structure for NSS |
| 135 | */ |
| 136 | struct platform_driver nss_driver = { |
| 137 | .probe = nss_probe, |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 138 | .remove = nss_remove, |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 139 | .driver = { |
| 140 | .name = "qca-nss", |
| 141 | .owner = THIS_MODULE, |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 142 | #if (NSS_DT_SUPPORT == 1) |
| 143 | .of_match_table = of_match_ptr(nss_dt_ids), |
| 144 | #endif |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 145 | }, |
| 146 | }; |
| 147 | |
Arunkumar T | 28b2d74 | 2015-06-16 22:15:58 +0530 | [diff] [blame] | 148 | #if (NSS_FREQ_SCALE_SUPPORT == 1) |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 149 | /* |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 150 | * nss_reset_frequency_stats_samples() |
| 151 | * Reset all frequency sampling state when auto scaling is turned off. |
| 152 | */ |
Thomas Wu | d6af377 | 2017-09-01 13:42:28 -0700 | [diff] [blame] | 153 | static void nss_reset_frequency_stats_samples(void) |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 154 | { |
| 155 | nss_runtime_samples.buffer_index = 0; |
| 156 | nss_runtime_samples.sum = 0; |
| 157 | nss_runtime_samples.average = 0; |
| 158 | nss_runtime_samples.sample_count = 0; |
| 159 | nss_runtime_samples.message_rate_limit = 0; |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 160 | nss_runtime_samples.freq_scale_rate_limit_down = 0; |
| 161 | } |
| 162 | |
| 163 | /* |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 164 | * nss_current_freq_handler() |
| 165 | * Handle Userspace Frequency Change Requests |
| 166 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 167 | static int nss_current_freq_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 168 | { |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 169 | int ret, i; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 170 | |
| 171 | BUG_ON(!nss_wq); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 172 | |
| 173 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 174 | |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 175 | if (!*lenp || (*ppos && !write)) { |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 176 | printk("Frequency Set to %d\n", nss_cmd_buf.current_freq); |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 177 | *lenp = 0; |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 178 | return ret; |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 179 | } |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 180 | |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 181 | /* |
| 182 | * Check if frequency exists in frequency Table |
| 183 | */ |
| 184 | i = 0; |
Thomas Wu | 7132bd3 | 2015-05-07 15:03:06 -0700 | [diff] [blame] | 185 | while (i < NSS_FREQ_MAX_SCALE) { |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 186 | if (nss_runtime_samples.freq_scale[i].frequency == nss_cmd_buf.current_freq) { |
| 187 | break; |
| 188 | } |
| 189 | i++; |
| 190 | } |
Thomas Wu | 7132bd3 | 2015-05-07 15:03:06 -0700 | [diff] [blame] | 191 | if (i == NSS_FREQ_MAX_SCALE) { |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 192 | printk("Frequency not found. Please check Frequency Table\n"); |
Thomas Wu | b7683af | 2016-07-07 14:19:09 -0700 | [diff] [blame] | 193 | nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 194 | return ret; |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Thomas Wu | b7683af | 2016-07-07 14:19:09 -0700 | [diff] [blame] | 197 | /* |
| 198 | * Turn off Auto Scale |
| 199 | */ |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 200 | nss_cmd_buf.auto_scale = 0; |
| 201 | nss_runtime_samples.freq_scale_ready = 0; |
Thomas Wu | b7683af | 2016-07-07 14:19:09 -0700 | [diff] [blame] | 202 | nss_runtime_samples.freq_scale_index = i; |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 203 | |
Thomas Wu | 7409bce | 2014-05-21 10:56:07 -0700 | [diff] [blame] | 204 | nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 205 | if (!nss_work) { |
| 206 | nss_info("NSS Freq WQ kmalloc fail"); |
| 207 | return ret; |
| 208 | } |
Thomas Wu | d6af377 | 2017-09-01 13:42:28 -0700 | [diff] [blame] | 209 | INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 210 | nss_work->frequency = nss_cmd_buf.current_freq; |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 211 | nss_work->stats_enable = 0; |
| 212 | |
Thomas Wu | b7683af | 2016-07-07 14:19:09 -0700 | [diff] [blame] | 213 | /* |
| 214 | * Ensure we start with a fresh set of samples later |
| 215 | */ |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 216 | nss_reset_frequency_stats_samples(); |
| 217 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 218 | queue_work(nss_wq, (struct work_struct *)nss_work); |
| 219 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 220 | return ret; |
| 221 | } |
| 222 | |
| 223 | /* |
| 224 | * nss_auto_scale_handler() |
| 225 | * Enables or Disable Auto Scaling |
| 226 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 227 | static int nss_auto_scale_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 228 | { |
| 229 | int ret; |
| 230 | |
| 231 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 232 | |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 233 | if (!*lenp || (*ppos && !write)) { |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 234 | return ret; |
| 235 | } |
| 236 | |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 237 | if (nss_cmd_buf.auto_scale != 1) { |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 238 | /* |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 239 | * Is auto scaling currently enabled? If so, send the command to |
| 240 | * disable stats reporting to NSS |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 241 | */ |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 242 | if (nss_runtime_samples.freq_scale_ready != 0) { |
| 243 | nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; |
Thomas Wu | 7409bce | 2014-05-21 10:56:07 -0700 | [diff] [blame] | 244 | nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 245 | if (!nss_work) { |
| 246 | nss_info("NSS Freq WQ kmalloc fail"); |
| 247 | return ret; |
| 248 | } |
Thomas Wu | d6af377 | 2017-09-01 13:42:28 -0700 | [diff] [blame] | 249 | INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 250 | nss_work->frequency = nss_cmd_buf.current_freq; |
| 251 | nss_work->stats_enable = 0; |
| 252 | queue_work(nss_wq, (struct work_struct *)nss_work); |
| 253 | nss_runtime_samples.freq_scale_ready = 0; |
| 254 | |
| 255 | /* |
| 256 | * The current samples would be stale later when scaling is |
| 257 | * enabled again, hence reset them |
| 258 | */ |
| 259 | nss_reset_frequency_stats_samples(); |
| 260 | } |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 261 | return ret; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 262 | } |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 263 | |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 264 | /* |
| 265 | * Auto Scaling is already being done |
| 266 | */ |
| 267 | if (nss_runtime_samples.freq_scale_ready == 1) { |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | /* |
| 272 | * Setup default values - Middle of Freq Scale Band |
| 273 | */ |
| 274 | nss_runtime_samples.freq_scale_index = 1; |
| 275 | nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; |
| 276 | |
Thomas Wu | 7409bce | 2014-05-21 10:56:07 -0700 | [diff] [blame] | 277 | nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 278 | if (!nss_work) { |
| 279 | nss_info("NSS Freq WQ kmalloc fail"); |
| 280 | return ret; |
| 281 | } |
Thomas Wu | d6af377 | 2017-09-01 13:42:28 -0700 | [diff] [blame] | 282 | INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 283 | nss_work->frequency = nss_cmd_buf.current_freq; |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 284 | nss_work->stats_enable = 1; |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 285 | queue_work(nss_wq, (struct work_struct *)nss_work); |
| 286 | |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 287 | nss_cmd_buf.auto_scale = 0; |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 288 | nss_runtime_samples.freq_scale_ready = 1; |
| 289 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 290 | return ret; |
| 291 | } |
| 292 | |
| 293 | /* |
| 294 | * nss_get_freq_table_handler() |
| 295 | * Display Support Freq and Ex how to Change. |
| 296 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 297 | static int nss_get_freq_table_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 298 | { |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 299 | int ret, i; |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 300 | |
| 301 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 302 | |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 303 | if (write) { |
| 304 | return ret; |
| 305 | } |
| 306 | |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 307 | printk("Frequency Supported - "); |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 308 | |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 309 | i = 0; |
Thomas Wu | 7132bd3 | 2015-05-07 15:03:06 -0700 | [diff] [blame] | 310 | while (i < NSS_FREQ_MAX_SCALE) { |
Thomas Wu | 6a48ac9 | 2017-11-03 10:48:04 -0700 | [diff] [blame] | 311 | printk("%d Hz ", nss_runtime_samples.freq_scale[i].frequency); |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 312 | i++; |
Thomas Wu | 0a0a9c9 | 2013-11-21 15:28:19 -0800 | [diff] [blame] | 313 | } |
Thomas Wu | 0e2fc4f | 2015-03-04 15:39:14 -0800 | [diff] [blame] | 314 | printk("\n"); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 315 | |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 316 | *lenp = 0; |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 317 | return ret; |
| 318 | } |
| 319 | |
| 320 | /* |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 321 | * nss_get_average_inst_handler() |
| 322 | * Display AVG Inst Per Ms. |
| 323 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 324 | static int nss_get_average_inst_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 325 | { |
| 326 | int ret; |
| 327 | |
| 328 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 329 | |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 330 | if (write) { |
| 331 | return ret; |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 332 | } |
| 333 | |
Thomas Wu | c151f2e | 2015-09-08 10:59:44 -0700 | [diff] [blame] | 334 | printk("Current Inst Per Ms %x\n", nss_runtime_samples.average); |
| 335 | |
| 336 | *lenp = 0; |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 337 | return ret; |
| 338 | } |
Arunkumar T | 28b2d74 | 2015-06-16 22:15:58 +0530 | [diff] [blame] | 339 | #endif |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 340 | |
Sundarajan Srinivasan | 758e8f4 | 2014-12-08 14:56:24 -0800 | [diff] [blame] | 341 | #if (NSS_FW_DBG_SUPPORT == 1) |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 342 | /* |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame] | 343 | * nss_debug_handler() |
| 344 | * Enable NSS debug output |
| 345 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 346 | static int nss_debug_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame] | 347 | { |
| 348 | int ret; |
| 349 | |
| 350 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 351 | if (!ret) { |
| 352 | if ((write) && (nss_ctl_debug != 0)) { |
| 353 | printk("Enabling NSS SPI Debug\n"); |
| 354 | nss_hal_debug_enable(); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | return ret; |
| 359 | } |
Sundarajan Srinivasan | 758e8f4 | 2014-12-08 14:56:24 -0800 | [diff] [blame] | 360 | #endif |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame] | 361 | |
| 362 | /* |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 363 | * nss_coredump_handler() |
| 364 | * Send Signal To Coredump NSS Cores |
| 365 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 366 | static int nss_coredump_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 367 | { |
Guojun Jin | 32a3c6d | 2015-05-06 12:27:52 -0700 | [diff] [blame] | 368 | struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[NSS_CORE_0]; |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 369 | int ret; |
| 370 | |
| 371 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 372 | if (!ret) { |
Guojun Jin | 244ecab | 2017-03-16 16:04:25 -0700 | [diff] [blame] | 373 | /* |
| 374 | * if nss_cmd_buf.coredump is not 0 or 1, panic will be disabled |
| 375 | * when NSS FW crashes, so OEM/ODM have a chance to use mdump |
| 376 | * to dump crash dump (coredump) and send dump to us for analysis. |
| 377 | */ |
| 378 | if ((write) && (nss_ctl_debug != 0) && nss_cmd_buf.coredump == 1) { |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 379 | printk("Coredumping to DDR\n"); |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 380 | nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP); |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
| 384 | return ret; |
| 385 | } |
| 386 | |
| 387 | /* |
Sundarajan Srinivasan | f9c4a23 | 2014-11-18 13:25:40 -0800 | [diff] [blame] | 388 | * nss_jumbo_mru_handler() |
| 389 | * Sysctl to modify nss_jumbo_mru |
| 390 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 391 | static int nss_jumbo_mru_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Sundarajan Srinivasan | f9c4a23 | 2014-11-18 13:25:40 -0800 | [diff] [blame] | 392 | { |
| 393 | int ret; |
| 394 | |
| 395 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 396 | if (ret) { |
| 397 | return ret; |
| 398 | } |
| 399 | |
| 400 | if (write) { |
| 401 | nss_core_set_jumbo_mru(nss_jumbo_mru); |
| 402 | nss_info("jumbo_mru set to %d\n", nss_jumbo_mru); |
| 403 | } |
| 404 | |
| 405 | return ret; |
| 406 | } |
| 407 | |
| 408 | /* nss_paged_mode_handler() |
| 409 | * Sysctl to modify nss_paged_mode. |
| 410 | */ |
| 411 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 412 | static int nss_paged_mode_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
Sundarajan Srinivasan | f9c4a23 | 2014-11-18 13:25:40 -0800 | [diff] [blame] | 413 | { |
| 414 | int ret; |
| 415 | |
| 416 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 417 | if (ret) { |
| 418 | return ret; |
| 419 | } |
| 420 | |
| 421 | if (write) { |
| 422 | nss_core_set_paged_mode(nss_paged_mode); |
| 423 | nss_info("paged_mode set to %d\n", nss_paged_mode); |
| 424 | } |
| 425 | |
| 426 | return ret; |
| 427 | } |
| 428 | |
Arunkumar T | 28b2d74 | 2015-06-16 22:15:58 +0530 | [diff] [blame] | 429 | #if (NSS_FREQ_SCALE_SUPPORT == 1) |
Sundarajan Srinivasan | f9c4a23 | 2014-11-18 13:25:40 -0800 | [diff] [blame] | 430 | /* |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 431 | * sysctl-tuning infrastructure. |
| 432 | */ |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 433 | static struct ctl_table nss_freq_table[] = { |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 434 | { |
| 435 | .procname = "current_freq", |
| 436 | .data = &nss_cmd_buf.current_freq, |
| 437 | .maxlen = sizeof(int), |
| 438 | .mode = 0644, |
| 439 | .proc_handler = &nss_current_freq_handler, |
| 440 | }, |
| 441 | { |
| 442 | .procname = "freq_table", |
| 443 | .data = &nss_cmd_buf.max_freq, |
| 444 | .maxlen = sizeof(int), |
| 445 | .mode = 0644, |
| 446 | .proc_handler = &nss_get_freq_table_handler, |
| 447 | }, |
| 448 | { |
| 449 | .procname = "auto_scale", |
| 450 | .data = &nss_cmd_buf.auto_scale, |
| 451 | .maxlen = sizeof(int), |
| 452 | .mode = 0644, |
| 453 | .proc_handler = &nss_auto_scale_handler, |
| 454 | }, |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 455 | { |
| 456 | .procname = "inst_per_sec", |
| 457 | .data = &nss_cmd_buf.average_inst, |
| 458 | .maxlen = sizeof(int), |
| 459 | .mode = 0644, |
| 460 | .proc_handler = &nss_get_average_inst_handler, |
| 461 | }, |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 462 | { } |
| 463 | }; |
Arunkumar T | 28b2d74 | 2015-06-16 22:15:58 +0530 | [diff] [blame] | 464 | #endif |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 465 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 466 | static struct ctl_table nss_general_table[] = { |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 467 | { |
| 468 | .procname = "redirect", |
| 469 | .data = &nss_ctl_redirect, |
| 470 | .maxlen = sizeof(int), |
| 471 | .mode = 0644, |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 472 | .proc_handler = proc_dointvec, |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 473 | }, |
Sundarajan Srinivasan | 758e8f4 | 2014-12-08 14:56:24 -0800 | [diff] [blame] | 474 | #if (NSS_FW_DBG_SUPPORT == 1) |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame] | 475 | { |
| 476 | .procname = "debug", |
| 477 | .data = &nss_ctl_debug, |
| 478 | .maxlen = sizeof(int), |
| 479 | .mode = 0644, |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 480 | .proc_handler = &nss_debug_handler, |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame] | 481 | }, |
Sundarajan Srinivasan | 758e8f4 | 2014-12-08 14:56:24 -0800 | [diff] [blame] | 482 | #endif |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 483 | { |
| 484 | .procname = "coredump", |
| 485 | .data = &nss_cmd_buf.coredump, |
| 486 | .maxlen = sizeof(int), |
| 487 | .mode = 0644, |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 488 | .proc_handler = &nss_coredump_handler, |
Thomas Wu | 52075f4 | 2014-02-06 16:32:42 -0800 | [diff] [blame] | 489 | }, |
Pamidipati, Vijay | efcc469 | 2014-05-09 14:47:38 +0530 | [diff] [blame] | 490 | { |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 491 | .procname = "logbuf", |
| 492 | .data = &nss_ctl_logbuf, |
| 493 | .maxlen = sizeof(int), |
| 494 | .mode = 0644, |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 495 | .proc_handler = &nss_logbuffer_handler, |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 496 | }, |
Sundarajan Srinivasan | f9c4a23 | 2014-11-18 13:25:40 -0800 | [diff] [blame] | 497 | { |
| 498 | .procname = "jumbo_mru", |
| 499 | .data = &nss_jumbo_mru, |
| 500 | .maxlen = sizeof(int), |
| 501 | .mode = 0644, |
| 502 | .proc_handler = &nss_jumbo_mru_handler, |
| 503 | }, |
| 504 | { |
| 505 | .procname = "paged_mode", |
| 506 | .data = &nss_paged_mode, |
| 507 | .maxlen = sizeof(int), |
| 508 | .mode = 0644, |
| 509 | .proc_handler = &nss_paged_mode_handler, |
| 510 | }, |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 511 | { } |
| 512 | }; |
| 513 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 514 | static struct ctl_table nss_clock_dir[] = { |
Arunkumar T | 28b2d74 | 2015-06-16 22:15:58 +0530 | [diff] [blame] | 515 | #if (NSS_FREQ_SCALE_SUPPORT == 1) |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 516 | { |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 517 | .procname = "clock", |
| 518 | .mode = 0555, |
| 519 | .child = nss_freq_table, |
| 520 | }, |
Arunkumar T | 28b2d74 | 2015-06-16 22:15:58 +0530 | [diff] [blame] | 521 | #endif |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 522 | { |
| 523 | .procname = "general", |
| 524 | .mode = 0555, |
| 525 | .child = nss_general_table, |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 526 | }, |
| 527 | { } |
| 528 | }; |
| 529 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 530 | static struct ctl_table nss_root_dir[] = { |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 531 | { |
| 532 | .procname = "nss", |
| 533 | .mode = 0555, |
| 534 | .child = nss_clock_dir, |
| 535 | }, |
| 536 | { } |
| 537 | }; |
| 538 | |
Stephen Wang | 52e6d34 | 2016-03-29 15:02:33 -0700 | [diff] [blame] | 539 | static struct ctl_table nss_root[] = { |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 540 | { |
| 541 | .procname = "dev", |
| 542 | .mode = 0555, |
| 543 | .child = nss_root_dir, |
| 544 | }, |
| 545 | { } |
| 546 | }; |
| 547 | |
| 548 | static struct ctl_table_header *nss_dev_header; |
| 549 | |
| 550 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 551 | * nss_init() |
| 552 | * Registers nss driver |
| 553 | */ |
| 554 | static int __init nss_init(void) |
| 555 | { |
Radha krishna Simha Jiguru | 3295b8b | 2017-03-12 10:54:15 +0530 | [diff] [blame] | 556 | #if (NSS_DT_SUPPORT == 1) |
| 557 | struct device_node *cmn = NULL; |
| 558 | #endif |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 559 | nss_info("Init NSS driver"); |
| 560 | |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 561 | #if (NSS_DT_SUPPORT == 1) |
| 562 | /* |
Radha krishna Simha Jiguru | 3295b8b | 2017-03-12 10:54:15 +0530 | [diff] [blame] | 563 | * Get reference to NSS common device node |
| 564 | */ |
| 565 | cmn = of_find_node_by_name(NULL, "nss-common"); |
| 566 | if (!cmn) { |
| 567 | nss_info_always("qca-nss-drv.ko is loaded for symbol link\n"); |
| 568 | return 0; |
| 569 | } |
| 570 | of_node_put(cmn); |
| 571 | |
| 572 | /* |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 573 | * Pick up HAL by target information |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 574 | */ |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 575 | #if defined(NSS_HAL_IPQ806X_SUPPORT) |
| 576 | if (of_machine_is_compatible("qcom,ipq8064") || of_machine_is_compatible("qcom,ipq8062")) { |
| 577 | nss_top_main.hal_ops = &nss_hal_ipq806x_ops; |
Stephen Wang | 5901def | 2016-05-09 16:21:03 -0700 | [diff] [blame] | 578 | nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 579 | } |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 580 | #endif |
Stephen Wang | be34802 | 2016-05-02 17:11:34 -0700 | [diff] [blame] | 581 | #if defined(NSS_HAL_IPQ807x_SUPPORT) |
| 582 | if (of_machine_is_compatible("qcom,ipq807x")) { |
| 583 | nss_top_main.hal_ops = &nss_hal_ipq807x_ops; |
Stephen Wang | df8323b | 2016-05-09 22:51:22 -0700 | [diff] [blame] | 584 | nss_top_main.data_plane_ops = &nss_data_plane_edma_ops; |
Stephen Wang | be34802 | 2016-05-02 17:11:34 -0700 | [diff] [blame] | 585 | } |
| 586 | #endif |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 587 | #if defined(NSS_HAL_FSM9010_SUPPORT) |
| 588 | if (of_machine_is_compatible("qcom,fsm9010")) { |
| 589 | nss_top_main.hal_ops = &nss_hal_fsm9010_ops; |
Stephen Wang | 5901def | 2016-05-09 16:21:03 -0700 | [diff] [blame] | 590 | nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 591 | } |
| 592 | #endif |
| 593 | if (!nss_top_main.hal_ops) { |
| 594 | nss_info_always("No supported HAL compiled on this platform\n"); |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 595 | return -EFAULT; |
| 596 | } |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 597 | #else |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 598 | /* |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 599 | * For banana, only ipq806x is supported |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 600 | */ |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 601 | nss_top_main.hal_ops = &nss_hal_ipq806x_ops; |
Stephen Wang | 5901def | 2016-05-09 16:21:03 -0700 | [diff] [blame] | 602 | nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 603 | |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 604 | #endif /* NSS_DT_SUPPORT */ |
Stephen Wang | 90c67de | 2016-04-26 15:15:59 -0700 | [diff] [blame] | 605 | nss_top_main.nss_hal_common_init_done = false; |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 606 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 607 | /* |
Stephen Wang | b42ddc5 | 2015-12-17 18:10:35 -0800 | [diff] [blame] | 608 | * Initialize data_plane workqueue |
| 609 | */ |
| 610 | if (nss_data_plane_init_delay_work()) { |
| 611 | nss_warning("Error initializing nss_data_plane_workqueue\n"); |
| 612 | return -EFAULT; |
| 613 | } |
| 614 | |
| 615 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 616 | * Enable spin locks |
| 617 | */ |
| 618 | spin_lock_init(&(nss_top_main.lock)); |
| 619 | spin_lock_init(&(nss_top_main.stats_lock)); |
c_athand | fde2e91 | 2017-01-10 15:40:12 +0530 | [diff] [blame] | 620 | mutex_init(&(nss_top_main.wq_lock)); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 621 | |
| 622 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 623 | * Enable NSS statistics |
| 624 | */ |
| 625 | nss_stats_init(); |
| 626 | |
| 627 | /* |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 628 | * Register sysctl table. |
| 629 | */ |
| 630 | nss_dev_header = register_sysctl_table(nss_root); |
| 631 | |
| 632 | /* |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 633 | * Registering sysctl for ipv4/6 specific config. |
| 634 | */ |
| 635 | nss_ipv4_register_sysctl(); |
| 636 | nss_ipv6_register_sysctl(); |
| 637 | |
Vijay Dewangan | ac7efc4 | 2015-02-09 16:04:53 -0800 | [diff] [blame] | 638 | /* |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 639 | * Registering sysctl for n2h specific config. |
Vijay Dewangan | ac7efc4 | 2015-02-09 16:04:53 -0800 | [diff] [blame] | 640 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 641 | nss_n2h_register_sysctl(); |
Vijay Dewangan | ac7efc4 | 2015-02-09 16:04:53 -0800 | [diff] [blame] | 642 | |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 643 | /* |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 644 | * Registering sysctl for rps specific config. |
| 645 | */ |
| 646 | nss_rps_register_sysctl(); |
| 647 | |
| 648 | /* |
Jackson Bockus | c2a4e68 | 2017-06-23 11:59:29 -0700 | [diff] [blame] | 649 | * Register sysctl for project config |
| 650 | */ |
| 651 | nss_project_register_sysctl(); |
| 652 | |
| 653 | /* |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 654 | * Setup Runtime Sample values |
| 655 | */ |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 656 | nss_runtime_samples.freq_scale_index = 1; |
| 657 | nss_runtime_samples.freq_scale_ready = 0; |
Thomas Wu | 9681f7e | 2013-11-06 13:12:57 -0800 | [diff] [blame] | 658 | nss_runtime_samples.freq_scale_rate_limit_down = 0; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 659 | nss_runtime_samples.buffer_index = 0; |
| 660 | nss_runtime_samples.sum = 0; |
| 661 | nss_runtime_samples.sample_count = 0; |
| 662 | nss_runtime_samples.average = 0; |
| 663 | nss_runtime_samples.message_rate_limit = 0; |
Kiran Kumar C.S.K | 69fd599 | 2014-01-06 20:58:14 +0530 | [diff] [blame] | 664 | nss_runtime_samples.initialized = 0; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 665 | |
Thomas Wu | 05495be | 2013-12-19 14:24:24 -0800 | [diff] [blame] | 666 | nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; |
| 667 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 668 | /* |
| 669 | * Initial Workqueue |
| 670 | */ |
| 671 | nss_wq = create_workqueue("nss_freq_queue"); |
| 672 | |
Thomas Wu | 0d11219 | 2015-04-13 11:37:22 -0700 | [diff] [blame] | 673 | #if (NSS_PM_SUPPORT == 1) |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 674 | /* |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 675 | * Initialize NSS Bus PM module |
| 676 | */ |
| 677 | nss_pm_init(); |
| 678 | |
| 679 | /* |
Pamidipati, Vijay | 5d27d81 | 2013-11-22 16:48:11 +0530 | [diff] [blame] | 680 | * Register with Bus driver |
| 681 | */ |
| 682 | pm_client = nss_pm_client_register(NSS_PM_CLIENT_NETAP); |
| 683 | if (!pm_client) { |
| 684 | nss_warning("Error registering with PM driver"); |
| 685 | } |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 686 | #endif |
Pamidipati, Vijay | 5d27d81 | 2013-11-22 16:48:11 +0530 | [diff] [blame] | 687 | |
| 688 | /* |
Radha krishna Simha Jiguru | 7f424d5 | 2015-02-10 19:41:01 +0530 | [diff] [blame] | 689 | * Initialize mtu size needed as start |
| 690 | */ |
Stephen Wang | a428d0b | 2017-01-12 21:30:01 -0800 | [diff] [blame] | 691 | nss_top_main.prev_mtu_sz = ETH_DATA_LEN; |
Radha krishna Simha Jiguru | 7f424d5 | 2015-02-10 19:41:01 +0530 | [diff] [blame] | 692 | |
| 693 | /* |
Guojun Jin | 1cb7952 | 2015-06-22 22:34:22 -0700 | [diff] [blame] | 694 | * register panic handler and timeout control |
| 695 | */ |
| 696 | nss_coredump_notify_register(); |
| 697 | nss_coredump_init_delay_work(); |
| 698 | |
| 699 | /* |
Stephen Wang | 1f6ad49 | 2016-01-27 23:42:06 -0800 | [diff] [blame] | 700 | * Init capwap |
| 701 | */ |
| 702 | nss_capwap_init(); |
| 703 | |
| 704 | /* |
Amit Gupta | 316729b | 2016-08-12 12:21:15 +0530 | [diff] [blame] | 705 | * INIT ppe on supported platform |
| 706 | */ |
| 707 | if (of_machine_is_compatible("qcom,ipq807x")) { |
| 708 | nss_ppe_init(); |
| 709 | } |
| 710 | |
| 711 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 712 | * Register platform_driver |
| 713 | */ |
| 714 | return platform_driver_register(&nss_driver); |
| 715 | } |
| 716 | |
| 717 | /* |
| 718 | * nss_cleanup() |
| 719 | * Unregisters nss driver |
| 720 | */ |
| 721 | static void __exit nss_cleanup(void) |
| 722 | { |
| 723 | nss_info("Exit NSS driver"); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 724 | |
| 725 | if (nss_dev_header) |
| 726 | unregister_sysctl_table(nss_dev_header); |
| 727 | |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 728 | /* |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 729 | * Unregister n2h specific sysctl |
| 730 | */ |
Stephen Wang | 49b474b | 2016-03-25 10:40:30 -0700 | [diff] [blame] | 731 | nss_n2h_unregister_sysctl(); |
Vijay Dewangan | 488e537 | 2014-12-29 21:40:11 -0800 | [diff] [blame] | 732 | |
| 733 | /* |
Cemil Coskun | 9165c76 | 2017-12-04 14:35:24 -0800 | [diff] [blame] | 734 | * Unregister rps specific sysctl |
| 735 | */ |
| 736 | nss_rps_unregister_sysctl(); |
| 737 | |
| 738 | /* |
Vijay Dewangan | 9db1875 | 2014-09-15 16:25:01 -0700 | [diff] [blame] | 739 | * Unregister ipv4/6 specific sysctl |
| 740 | */ |
| 741 | nss_ipv4_unregister_sysctl(); |
| 742 | nss_ipv6_unregister_sysctl(); |
| 743 | |
Suruchi Agarwal | cdcb5b4 | 2017-07-06 11:08:22 -0700 | [diff] [blame] | 744 | /* |
| 745 | * Free Memory allocated for connection tables |
| 746 | */ |
| 747 | nss_ipv4_free_conn_tables(); |
| 748 | nss_ipv6_free_conn_tables(); |
| 749 | |
Jackson Bockus | c2a4e68 | 2017-06-23 11:59:29 -0700 | [diff] [blame] | 750 | nss_project_unregister_sysctl(); |
Stephen Wang | b42ddc5 | 2015-12-17 18:10:35 -0800 | [diff] [blame] | 751 | nss_data_plane_destroy_delay_work(); |
| 752 | |
Amit Gupta | 316729b | 2016-08-12 12:21:15 +0530 | [diff] [blame] | 753 | /* |
| 754 | * cleanup ppe on supported platform |
| 755 | */ |
| 756 | if (of_machine_is_compatible("qcom,ipq807x")) { |
| 757 | nss_ppe_free(); |
| 758 | } |
| 759 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 760 | platform_driver_unregister(&nss_driver); |
| 761 | } |
| 762 | |
| 763 | module_init(nss_init); |
| 764 | module_exit(nss_cleanup); |
| 765 | |
| 766 | MODULE_DESCRIPTION("QCA NSS Driver"); |
| 767 | MODULE_AUTHOR("Qualcomm Atheros Inc"); |
| 768 | MODULE_LICENSE("Dual BSD/GPL"); |