Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: major functions |
| 3 | * |
| 4 | * Copyright (C) 2011, Marvell International Ltd. |
| 5 | * |
| 6 | * This software file (the "File") is distributed by Marvell International |
| 7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 |
| 8 | * (the "License"). You may use, redistribute and/or modify this File in |
| 9 | * accordance with the terms and conditions of the License, a copy of which |
| 10 | * is available by writing to the Free Software Foundation, Inc., |
| 11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the |
| 12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
| 13 | * |
| 14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE |
| 16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about |
| 17 | * this warranty disclaimer. |
| 18 | */ |
| 19 | |
| 20 | #include "main.h" |
| 21 | #include "wmm.h" |
| 22 | #include "cfg80211.h" |
| 23 | #include "11n.h" |
| 24 | |
| 25 | #define VERSION "1.0" |
| 26 | |
| 27 | const char driver_version[] = "mwifiex " VERSION " (%s) "; |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 28 | static char *cal_data_cfg; |
| 29 | module_param(cal_data_cfg, charp, 0); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 30 | |
Amitkumar Karwar | df81008 | 2013-06-04 16:19:56 -0700 | [diff] [blame] | 31 | static void scan_delay_timer_fn(unsigned long data) |
| 32 | { |
| 33 | struct mwifiex_private *priv = (struct mwifiex_private *)data; |
| 34 | struct mwifiex_adapter *adapter = priv->adapter; |
| 35 | struct cmd_ctrl_node *cmd_node, *tmp_node; |
| 36 | unsigned long flags; |
| 37 | |
| 38 | if (adapter->surprise_removed) |
| 39 | return; |
| 40 | |
| 41 | if (adapter->scan_delay_cnt == MWIFIEX_MAX_SCAN_DELAY_CNT) { |
| 42 | /* |
| 43 | * Abort scan operation by cancelling all pending scan |
| 44 | * commands |
| 45 | */ |
| 46 | spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); |
| 47 | list_for_each_entry_safe(cmd_node, tmp_node, |
| 48 | &adapter->scan_pending_q, list) { |
| 49 | list_del(&cmd_node->list); |
| 50 | mwifiex_insert_cmd_to_free_q(adapter, cmd_node); |
| 51 | } |
| 52 | spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); |
| 53 | |
| 54 | spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); |
| 55 | adapter->scan_processing = false; |
| 56 | adapter->scan_delay_cnt = 0; |
| 57 | adapter->empty_tx_q_cnt = 0; |
| 58 | spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); |
| 59 | |
| 60 | if (priv->scan_request) { |
| 61 | dev_dbg(adapter->dev, "info: aborting scan\n"); |
| 62 | cfg80211_scan_done(priv->scan_request, 1); |
| 63 | priv->scan_request = NULL; |
| 64 | } else { |
| 65 | priv->scan_aborting = false; |
| 66 | dev_dbg(adapter->dev, "info: scan already aborted\n"); |
| 67 | } |
| 68 | goto done; |
| 69 | } |
| 70 | |
| 71 | if (!atomic_read(&priv->adapter->is_tx_received)) { |
| 72 | adapter->empty_tx_q_cnt++; |
| 73 | if (adapter->empty_tx_q_cnt == MWIFIEX_MAX_EMPTY_TX_Q_CNT) { |
| 74 | /* |
| 75 | * No Tx traffic for 200msec. Get scan command from |
| 76 | * scan pending queue and put to cmd pending queue to |
| 77 | * resume scan operation |
| 78 | */ |
| 79 | adapter->scan_delay_cnt = 0; |
| 80 | adapter->empty_tx_q_cnt = 0; |
| 81 | spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); |
| 82 | cmd_node = list_first_entry(&adapter->scan_pending_q, |
| 83 | struct cmd_ctrl_node, list); |
| 84 | list_del(&cmd_node->list); |
| 85 | spin_unlock_irqrestore(&adapter->scan_pending_q_lock, |
| 86 | flags); |
| 87 | |
| 88 | mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, |
| 89 | true); |
| 90 | queue_work(adapter->workqueue, &adapter->main_work); |
| 91 | goto done; |
| 92 | } |
| 93 | } else { |
| 94 | adapter->empty_tx_q_cnt = 0; |
| 95 | } |
| 96 | |
| 97 | /* Delay scan operation further by 20msec */ |
| 98 | mod_timer(&priv->scan_delay_timer, jiffies + |
| 99 | msecs_to_jiffies(MWIFIEX_SCAN_DELAY_MSEC)); |
| 100 | adapter->scan_delay_cnt++; |
| 101 | |
| 102 | done: |
| 103 | if (atomic_read(&priv->adapter->is_tx_received)) |
| 104 | atomic_set(&priv->adapter->is_tx_received, false); |
| 105 | |
| 106 | return; |
| 107 | } |
| 108 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 109 | /* |
| 110 | * This function registers the device and performs all the necessary |
| 111 | * initializations. |
| 112 | * |
| 113 | * The following initialization operations are performed - |
| 114 | * - Allocate adapter structure |
| 115 | * - Save interface specific operations table in adapter |
| 116 | * - Call interface specific initialization routine |
| 117 | * - Allocate private structures |
| 118 | * - Set default adapter structure parameters |
| 119 | * - Initialize locks |
| 120 | * |
| 121 | * In case of any errors during inittialization, this function also ensures |
| 122 | * proper cleanup before exiting. |
| 123 | */ |
| 124 | static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, |
Amitkumar Karwar | 287546d | 2011-06-08 20:39:20 +0530 | [diff] [blame] | 125 | void **padapter) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 126 | { |
Amitkumar Karwar | 2be7859 | 2011-04-15 20:50:42 -0700 | [diff] [blame] | 127 | struct mwifiex_adapter *adapter; |
| 128 | int i; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 129 | |
| 130 | adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 131 | if (!adapter) |
Christoph Fritz | b53575e | 2011-05-08 22:50:09 +0200 | [diff] [blame] | 132 | return -ENOMEM; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 133 | |
Amitkumar Karwar | 287546d | 2011-06-08 20:39:20 +0530 | [diff] [blame] | 134 | *padapter = adapter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 135 | adapter->card = card; |
| 136 | |
| 137 | /* Save interface specific operations in adapter */ |
| 138 | memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops)); |
| 139 | |
| 140 | /* card specific initialization has been deferred until now .. */ |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 141 | if (adapter->if_ops.init_if) |
| 142 | if (adapter->if_ops.init_if(adapter)) |
| 143 | goto error; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 144 | |
| 145 | adapter->priv_num = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 146 | |
Avinash Patil | 64b05e2 | 2012-05-08 18:30:13 -0700 | [diff] [blame] | 147 | for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) { |
| 148 | /* Allocate memory for private structure */ |
| 149 | adapter->priv[i] = |
| 150 | kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL); |
| 151 | if (!adapter->priv[i]) |
| 152 | goto error; |
| 153 | |
| 154 | adapter->priv[i]->adapter = adapter; |
Avinash Patil | 64b05e2 | 2012-05-08 18:30:13 -0700 | [diff] [blame] | 155 | adapter->priv_num++; |
Amitkumar Karwar | df81008 | 2013-06-04 16:19:56 -0700 | [diff] [blame] | 156 | |
| 157 | setup_timer(&adapter->priv[i]->scan_delay_timer, |
| 158 | scan_delay_timer_fn, |
| 159 | (unsigned long)adapter->priv[i]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 160 | } |
Amitkumar Karwar | 44b815c | 2011-09-29 20:43:41 -0700 | [diff] [blame] | 161 | mwifiex_init_lock_list(adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 162 | |
| 163 | init_timer(&adapter->cmd_timer); |
| 164 | adapter->cmd_timer.function = mwifiex_cmd_timeout_func; |
| 165 | adapter->cmd_timer.data = (unsigned long) adapter; |
| 166 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 167 | return 0; |
| 168 | |
| 169 | error: |
| 170 | dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n"); |
| 171 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 172 | for (i = 0; i < adapter->priv_num; i++) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 173 | kfree(adapter->priv[i]); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 174 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 175 | kfree(adapter); |
| 176 | |
| 177 | return -1; |
| 178 | } |
| 179 | |
| 180 | /* |
| 181 | * This function unregisters the device and performs all the necessary |
| 182 | * cleanups. |
| 183 | * |
| 184 | * The following cleanup operations are performed - |
| 185 | * - Free the timers |
| 186 | * - Free beacon buffers |
| 187 | * - Free private structures |
| 188 | * - Free adapter structure |
| 189 | */ |
| 190 | static int mwifiex_unregister(struct mwifiex_adapter *adapter) |
| 191 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 192 | s32 i; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 193 | |
Amitkumar Karwar | 4cfda67 | 2013-07-22 19:17:50 -0700 | [diff] [blame] | 194 | if (adapter->if_ops.cleanup_if) |
| 195 | adapter->if_ops.cleanup_if(adapter); |
| 196 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 197 | del_timer(&adapter->cmd_timer); |
| 198 | |
| 199 | /* Free private structures */ |
| 200 | for (i = 0; i < adapter->priv_num; i++) { |
| 201 | if (adapter->priv[i]) { |
| 202 | mwifiex_free_curr_bcn(adapter->priv[i]); |
Amitkumar Karwar | 003d87c | 2013-07-22 19:17:48 -0700 | [diff] [blame] | 203 | del_timer_sync(&adapter->priv[i]->scan_delay_timer); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 204 | kfree(adapter->priv[i]); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | kfree(adapter); |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | * The main process. |
| 214 | * |
| 215 | * This function is the main procedure of the driver and handles various driver |
| 216 | * operations. It runs in a loop and provides the core functionalities. |
| 217 | * |
| 218 | * The main responsibilities of this function are - |
| 219 | * - Ensure concurrency control |
| 220 | * - Handle pending interrupts and call interrupt handlers |
| 221 | * - Wake up the card if required |
| 222 | * - Handle command responses and call response handlers |
| 223 | * - Handle events and call event handlers |
| 224 | * - Execute pending commands |
| 225 | * - Transmit pending data packets |
| 226 | */ |
| 227 | int mwifiex_main_process(struct mwifiex_adapter *adapter) |
| 228 | { |
| 229 | int ret = 0; |
| 230 | unsigned long flags; |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 231 | struct sk_buff *skb; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 232 | |
| 233 | spin_lock_irqsave(&adapter->main_proc_lock, flags); |
| 234 | |
| 235 | /* Check if already processing */ |
| 236 | if (adapter->mwifiex_processing) { |
| 237 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); |
| 238 | goto exit_main_proc; |
| 239 | } else { |
| 240 | adapter->mwifiex_processing = true; |
| 241 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); |
| 242 | } |
| 243 | process_start: |
| 244 | do { |
| 245 | if ((adapter->hw_status == MWIFIEX_HW_STATUS_CLOSING) || |
| 246 | (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY)) |
| 247 | break; |
| 248 | |
| 249 | /* Handle pending interrupt if any */ |
| 250 | if (adapter->int_status) { |
| 251 | if (adapter->hs_activated) |
| 252 | mwifiex_process_hs_config(adapter); |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 253 | if (adapter->if_ops.process_int_status) |
| 254 | adapter->if_ops.process_int_status(adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /* Need to wake up the card ? */ |
| 258 | if ((adapter->ps_state == PS_STATE_SLEEP) && |
| 259 | (adapter->pm_wakeup_card_req && |
| 260 | !adapter->pm_wakeup_fw_try) && |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 261 | (is_command_pending(adapter) || |
| 262 | !mwifiex_wmm_lists_empty(adapter))) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 263 | adapter->pm_wakeup_fw_try = true; |
| 264 | adapter->if_ops.wakeup(adapter); |
| 265 | continue; |
| 266 | } |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 267 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 268 | if (IS_CARD_RX_RCVD(adapter)) { |
| 269 | adapter->pm_wakeup_fw_try = false; |
| 270 | if (adapter->ps_state == PS_STATE_SLEEP) |
| 271 | adapter->ps_state = PS_STATE_AWAKE; |
| 272 | } else { |
| 273 | /* We have tried to wakeup the card already */ |
| 274 | if (adapter->pm_wakeup_fw_try) |
| 275 | break; |
| 276 | if (adapter->ps_state != PS_STATE_AWAKE || |
| 277 | adapter->tx_lock_flag) |
| 278 | break; |
| 279 | |
Amitkumar Karwar | f931c770 | 2012-06-20 19:58:36 -0700 | [diff] [blame] | 280 | if ((adapter->scan_processing && |
| 281 | !adapter->scan_delay_cnt) || adapter->data_sent || |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 282 | mwifiex_wmm_lists_empty(adapter)) { |
| 283 | if (adapter->cmd_sent || adapter->curr_cmd || |
| 284 | (!is_command_pending(adapter))) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 285 | break; |
| 286 | } |
| 287 | } |
| 288 | |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 289 | /* Check Rx data for USB */ |
| 290 | if (adapter->iface_type == MWIFIEX_USB) |
| 291 | while ((skb = skb_dequeue(&adapter->usb_rx_data_q))) |
| 292 | mwifiex_handle_rx_packet(adapter, skb); |
| 293 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 294 | /* Check for Cmd Resp */ |
| 295 | if (adapter->cmd_resp_received) { |
| 296 | adapter->cmd_resp_received = false; |
| 297 | mwifiex_process_cmdresp(adapter); |
| 298 | |
| 299 | /* call mwifiex back when init_fw is done */ |
| 300 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INIT_DONE) { |
| 301 | adapter->hw_status = MWIFIEX_HW_STATUS_READY; |
| 302 | mwifiex_init_fw_complete(adapter); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /* Check for event */ |
| 307 | if (adapter->event_received) { |
| 308 | adapter->event_received = false; |
| 309 | mwifiex_process_event(adapter); |
| 310 | } |
| 311 | |
| 312 | /* Check if we need to confirm Sleep Request |
| 313 | received previously */ |
| 314 | if (adapter->ps_state == PS_STATE_PRE_SLEEP) { |
| 315 | if (!adapter->cmd_sent && !adapter->curr_cmd) |
| 316 | mwifiex_check_ps_cond(adapter); |
| 317 | } |
| 318 | |
| 319 | /* * The ps_state may have been changed during processing of |
| 320 | * Sleep Request event. |
| 321 | */ |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 322 | if ((adapter->ps_state == PS_STATE_SLEEP) || |
| 323 | (adapter->ps_state == PS_STATE_PRE_SLEEP) || |
| 324 | (adapter->ps_state == PS_STATE_SLEEP_CFM) || |
| 325 | adapter->tx_lock_flag) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 326 | continue; |
| 327 | |
| 328 | if (!adapter->cmd_sent && !adapter->curr_cmd) { |
| 329 | if (mwifiex_exec_next_cmd(adapter) == -1) { |
| 330 | ret = -1; |
| 331 | break; |
| 332 | } |
| 333 | } |
| 334 | |
Amitkumar Karwar | 3249ba7 | 2012-06-06 21:12:41 -0700 | [diff] [blame] | 335 | if ((!adapter->scan_processing || adapter->scan_delay_cnt) && |
| 336 | !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 337 | mwifiex_wmm_process_tx(adapter); |
| 338 | if (adapter->hs_activated) { |
| 339 | adapter->is_hs_configured = false; |
| 340 | mwifiex_hs_activated_event |
| 341 | (mwifiex_get_priv |
| 342 | (adapter, MWIFIEX_BSS_ROLE_ANY), |
| 343 | false); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | if (adapter->delay_null_pkt && !adapter->cmd_sent && |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 348 | !adapter->curr_cmd && !is_command_pending(adapter) && |
| 349 | mwifiex_wmm_lists_empty(adapter)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 350 | if (!mwifiex_send_null_packet |
| 351 | (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), |
| 352 | MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET | |
| 353 | MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) { |
| 354 | adapter->delay_null_pkt = false; |
| 355 | adapter->ps_state = PS_STATE_SLEEP; |
| 356 | } |
| 357 | break; |
| 358 | } |
| 359 | } while (true); |
| 360 | |
| 361 | if ((adapter->int_status) || IS_CARD_RX_RCVD(adapter)) |
| 362 | goto process_start; |
| 363 | |
| 364 | spin_lock_irqsave(&adapter->main_proc_lock, flags); |
| 365 | adapter->mwifiex_processing = false; |
| 366 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); |
| 367 | |
| 368 | exit_main_proc: |
| 369 | if (adapter->hw_status == MWIFIEX_HW_STATUS_CLOSING) |
| 370 | mwifiex_shutdown_drv(adapter); |
| 371 | return ret; |
| 372 | } |
Bing Zhao | 601216e | 2012-11-05 16:59:15 -0800 | [diff] [blame] | 373 | EXPORT_SYMBOL_GPL(mwifiex_main_process); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 374 | |
| 375 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 376 | * This function frees the adapter structure. |
| 377 | * |
| 378 | * Additionally, this closes the netlink socket, frees the timers |
| 379 | * and private structures. |
| 380 | */ |
| 381 | static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) |
| 382 | { |
| 383 | if (!adapter) { |
| 384 | pr_err("%s: adapter is NULL\n", __func__); |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | mwifiex_unregister(adapter); |
| 389 | pr_debug("info: %s: free adapter\n", __func__); |
| 390 | } |
| 391 | |
| 392 | /* |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 393 | * This function cancels all works in the queue and destroys |
| 394 | * the main workqueue. |
| 395 | */ |
| 396 | static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) |
| 397 | { |
| 398 | flush_workqueue(adapter->workqueue); |
| 399 | destroy_workqueue(adapter->workqueue); |
| 400 | adapter->workqueue = NULL; |
| 401 | } |
| 402 | |
| 403 | /* |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 404 | * This function gets firmware and initializes it. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 405 | * |
| 406 | * The main initialization steps followed are - |
| 407 | * - Download the correct firmware to card |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 408 | * - Issue the init commands to firmware |
| 409 | */ |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 410 | static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 411 | { |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 412 | int ret, i; |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 413 | char fmt[64]; |
| 414 | struct mwifiex_private *priv; |
| 415 | struct mwifiex_adapter *adapter = context; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 416 | struct mwifiex_fw_image fw; |
Amitkumar Karwar | c3afd99 | 2013-07-30 17:18:15 -0700 | [diff] [blame] | 417 | struct semaphore *sem = adapter->card_sem; |
| 418 | bool init_failed = false; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 419 | |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 420 | if (!firmware) { |
| 421 | dev_err(adapter->dev, |
| 422 | "Failed to get firmware %s\n", adapter->fw_name); |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 423 | goto err_dnld_fw; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 424 | } |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 425 | |
| 426 | memset(&fw, 0, sizeof(struct mwifiex_fw_image)); |
| 427 | adapter->firmware = firmware; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 428 | fw.fw_buf = (u8 *) adapter->firmware->data; |
| 429 | fw.fw_len = adapter->firmware->size; |
| 430 | |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 431 | if (adapter->if_ops.dnld_fw) |
| 432 | ret = adapter->if_ops.dnld_fw(adapter, &fw); |
| 433 | else |
| 434 | ret = mwifiex_dnld_fw(adapter, &fw); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 435 | if (ret == -1) |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 436 | goto err_dnld_fw; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 437 | |
| 438 | dev_notice(adapter->dev, "WLAN FW is active\n"); |
| 439 | |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 440 | if (cal_data_cfg) { |
| 441 | if ((request_firmware(&adapter->cal_data, cal_data_cfg, |
| 442 | adapter->dev)) < 0) |
| 443 | dev_err(adapter->dev, |
| 444 | "Cal data request_firmware() failed\n"); |
| 445 | } |
| 446 | |
Daniel Drake | 232fde0 | 2013-07-13 10:57:10 -0400 | [diff] [blame] | 447 | /* enable host interrupt after fw dnld is successful */ |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 448 | if (adapter->if_ops.enable_int) { |
| 449 | if (adapter->if_ops.enable_int(adapter)) |
| 450 | goto err_dnld_fw; |
| 451 | } |
Daniel Drake | 232fde0 | 2013-07-13 10:57:10 -0400 | [diff] [blame] | 452 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 453 | adapter->init_wait_q_woken = false; |
| 454 | ret = mwifiex_init_fw(adapter); |
| 455 | if (ret == -1) { |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 456 | goto err_init_fw; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 457 | } else if (!ret) { |
| 458 | adapter->hw_status = MWIFIEX_HW_STATUS_READY; |
| 459 | goto done; |
| 460 | } |
| 461 | /* Wait for mwifiex_init to complete */ |
| 462 | wait_event_interruptible(adapter->init_wait_q, |
| 463 | adapter->init_wait_q_woken); |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 464 | if (adapter->hw_status != MWIFIEX_HW_STATUS_READY) |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 465 | goto err_init_fw; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 466 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 467 | priv = adapter->priv[MWIFIEX_BSS_ROLE_STA]; |
| 468 | if (mwifiex_register_cfg80211(adapter)) { |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 469 | dev_err(adapter->dev, "cannot register with cfg80211\n"); |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 470 | goto err_register_cfg80211; |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | rtnl_lock(); |
| 474 | /* Create station interface by default */ |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 475 | if (!mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 476 | NL80211_IFTYPE_STATION, NULL, NULL)) { |
| 477 | dev_err(adapter->dev, "cannot create default STA interface\n"); |
| 478 | goto err_add_intf; |
| 479 | } |
| 480 | rtnl_unlock(); |
| 481 | |
| 482 | mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); |
| 483 | dev_notice(adapter->dev, "driver_version = %s\n", fmt); |
| 484 | goto done; |
| 485 | |
| 486 | err_add_intf: |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 487 | for (i = 0; i < adapter->priv_num; i++) { |
| 488 | priv = adapter->priv[i]; |
| 489 | |
| 490 | if (!priv) |
| 491 | continue; |
| 492 | |
| 493 | if (priv->wdev && priv->netdev) |
| 494 | mwifiex_del_virtual_intf(adapter->wiphy, priv->wdev); |
| 495 | } |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 496 | rtnl_unlock(); |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 497 | err_register_cfg80211: |
| 498 | wiphy_unregister(adapter->wiphy); |
| 499 | wiphy_free(adapter->wiphy); |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 500 | err_init_fw: |
Daniel Drake | 232fde0 | 2013-07-13 10:57:10 -0400 | [diff] [blame] | 501 | if (adapter->if_ops.disable_int) |
| 502 | adapter->if_ops.disable_int(adapter); |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 503 | err_dnld_fw: |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 504 | pr_debug("info: %s: unregister device\n", __func__); |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 505 | if (adapter->if_ops.unregister_dev) |
| 506 | adapter->if_ops.unregister_dev(adapter); |
| 507 | |
| 508 | if ((adapter->hw_status == MWIFIEX_HW_STATUS_FW_READY) || |
| 509 | (adapter->hw_status == MWIFIEX_HW_STATUS_READY)) { |
| 510 | pr_debug("info: %s: shutdown mwifiex\n", __func__); |
| 511 | adapter->init_wait_q_woken = false; |
| 512 | |
| 513 | if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS) |
| 514 | wait_event_interruptible(adapter->init_wait_q, |
| 515 | adapter->init_wait_q_woken); |
| 516 | } |
| 517 | adapter->surprise_removed = true; |
| 518 | mwifiex_terminate_workqueue(adapter); |
Amitkumar Karwar | c3afd99 | 2013-07-30 17:18:15 -0700 | [diff] [blame] | 519 | init_failed = true; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 520 | done: |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 521 | if (adapter->cal_data) { |
| 522 | release_firmware(adapter->cal_data); |
| 523 | adapter->cal_data = NULL; |
| 524 | } |
Amitkumar Karwar | c3afd99 | 2013-07-30 17:18:15 -0700 | [diff] [blame] | 525 | if (adapter->firmware) { |
| 526 | release_firmware(adapter->firmware); |
| 527 | adapter->firmware = NULL; |
| 528 | } |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 529 | complete(&adapter->fw_load); |
Amitkumar Karwar | c3afd99 | 2013-07-30 17:18:15 -0700 | [diff] [blame] | 530 | if (init_failed) |
| 531 | mwifiex_free_adapter(adapter); |
| 532 | up(sem); |
Amitkumar Karwar | 59a4cc2 | 2012-04-09 20:06:57 -0700 | [diff] [blame] | 533 | return; |
| 534 | } |
| 535 | |
| 536 | /* |
| 537 | * This function initializes the hardware and gets firmware. |
| 538 | */ |
| 539 | static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter) |
| 540 | { |
| 541 | int ret; |
| 542 | |
| 543 | init_completion(&adapter->fw_load); |
| 544 | ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, |
| 545 | adapter->dev, GFP_KERNEL, adapter, |
| 546 | mwifiex_fw_dpc); |
| 547 | if (ret < 0) |
| 548 | dev_err(adapter->dev, |
| 549 | "request_firmware_nowait() returned error %d\n", ret); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 550 | return ret; |
| 551 | } |
| 552 | |
| 553 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 554 | * CFG802.11 network device handler for open. |
| 555 | * |
| 556 | * Starts the data queue. |
| 557 | */ |
| 558 | static int |
| 559 | mwifiex_open(struct net_device *dev) |
| 560 | { |
Avinash Patil | bbea3bc | 2011-12-08 20:41:05 -0800 | [diff] [blame] | 561 | netif_tx_start_all_queues(dev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | /* |
| 566 | * CFG802.11 network device handler for close. |
| 567 | */ |
| 568 | static int |
| 569 | mwifiex_close(struct net_device *dev) |
| 570 | { |
Amitkumar Karwar | f162cac | 2012-10-19 19:19:16 -0700 | [diff] [blame] | 571 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 572 | |
| 573 | if (priv->scan_request) { |
| 574 | dev_dbg(priv->adapter->dev, "aborting scan on ndo_stop\n"); |
| 575 | cfg80211_scan_done(priv->scan_request, 1); |
| 576 | priv->scan_request = NULL; |
Amitkumar Karwar | 75ab753 | 2013-05-17 17:50:20 -0700 | [diff] [blame] | 577 | priv->scan_aborting = true; |
Amitkumar Karwar | f162cac | 2012-10-19 19:19:16 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | /* |
Stone Piao | e39faa7 | 2012-09-25 20:23:32 -0700 | [diff] [blame] | 584 | * Add buffer into wmm tx queue and queue work to transmit it. |
| 585 | */ |
| 586 | int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb) |
| 587 | { |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 588 | struct netdev_queue *txq; |
| 589 | int index = mwifiex_1d_to_wmm_queue[skb->priority]; |
| 590 | |
| 591 | if (atomic_inc_return(&priv->wmm_tx_pending[index]) >= MAX_TX_PENDING) { |
| 592 | txq = netdev_get_tx_queue(priv->netdev, index); |
| 593 | if (!netif_tx_queue_stopped(txq)) { |
| 594 | netif_tx_stop_queue(txq); |
| 595 | dev_dbg(priv->adapter->dev, "stop queue: %d\n", index); |
| 596 | } |
| 597 | } |
| 598 | |
Stone Piao | e39faa7 | 2012-09-25 20:23:32 -0700 | [diff] [blame] | 599 | atomic_inc(&priv->adapter->tx_pending); |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 600 | mwifiex_wmm_add_buf_txqueue(priv, skb); |
Stone Piao | e39faa7 | 2012-09-25 20:23:32 -0700 | [diff] [blame] | 601 | |
| 602 | if (priv->adapter->scan_delay_cnt) |
| 603 | atomic_set(&priv->adapter->is_tx_received, true); |
| 604 | |
Stone Piao | e39faa7 | 2012-09-25 20:23:32 -0700 | [diff] [blame] | 605 | queue_work(priv->adapter->workqueue, &priv->adapter->main_work); |
| 606 | |
| 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 611 | * CFG802.11 network device handler for data transmission. |
| 612 | */ |
| 613 | static int |
| 614 | mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 615 | { |
| 616 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 617 | struct sk_buff *new_skb; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 618 | struct mwifiex_txinfo *tx_info; |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 619 | struct timeval tv; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 620 | |
Yogesh Ashok Powar | 9da9a3b | 2012-01-11 20:06:11 -0800 | [diff] [blame] | 621 | dev_dbg(priv->adapter->dev, "data: %lu BSS(%d-%d): Data <= kernel\n", |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 622 | jiffies, priv->bss_type, priv->bss_num); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 623 | |
| 624 | if (priv->adapter->surprise_removed) { |
Christoph Fritz | b53575e | 2011-05-08 22:50:09 +0200 | [diff] [blame] | 625 | kfree_skb(skb); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 626 | priv->stats.tx_dropped++; |
| 627 | return 0; |
| 628 | } |
| 629 | if (!skb->len || (skb->len > ETH_FRAME_LEN)) { |
| 630 | dev_err(priv->adapter->dev, "Tx: bad skb len %d\n", skb->len); |
Christoph Fritz | b53575e | 2011-05-08 22:50:09 +0200 | [diff] [blame] | 631 | kfree_skb(skb); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 632 | priv->stats.tx_dropped++; |
| 633 | return 0; |
| 634 | } |
| 635 | if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN) { |
| 636 | dev_dbg(priv->adapter->dev, |
| 637 | "data: Tx: insufficient skb headroom %d\n", |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 638 | skb_headroom(skb)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 639 | /* Insufficient skb headroom - allocate a new skb */ |
| 640 | new_skb = |
| 641 | skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN); |
| 642 | if (unlikely(!new_skb)) { |
| 643 | dev_err(priv->adapter->dev, "Tx: cannot alloca new_skb\n"); |
Christoph Fritz | b53575e | 2011-05-08 22:50:09 +0200 | [diff] [blame] | 644 | kfree_skb(skb); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 645 | priv->stats.tx_dropped++; |
| 646 | return 0; |
| 647 | } |
| 648 | kfree_skb(skb); |
| 649 | skb = new_skb; |
| 650 | dev_dbg(priv->adapter->dev, "info: new skb headroomd %d\n", |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 651 | skb_headroom(skb)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | tx_info = MWIFIEX_SKB_TXCB(skb); |
Yogesh Ashok Powar | 9da9a3b | 2012-01-11 20:06:11 -0800 | [diff] [blame] | 655 | tx_info->bss_num = priv->bss_num; |
| 656 | tx_info->bss_type = priv->bss_type; |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 657 | |
| 658 | /* Record the current time the packet was queued; used to |
| 659 | * determine the amount of time the packet was queued in |
| 660 | * the driver before it was sent to the firmware. |
| 661 | * The delay is then sent along with the packet to the |
| 662 | * firmware for aggregate delay calculation for stats and |
| 663 | * MSDU lifetime expiry. |
| 664 | */ |
| 665 | do_gettimeofday(&tv); |
| 666 | skb->tstamp = timeval_to_ktime(tv); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 667 | |
Stone Piao | e39faa7 | 2012-09-25 20:23:32 -0700 | [diff] [blame] | 668 | mwifiex_queue_tx_pkt(priv, skb); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 669 | |
| 670 | return 0; |
| 671 | } |
| 672 | |
| 673 | /* |
| 674 | * CFG802.11 network device handler for setting MAC address. |
| 675 | */ |
| 676 | static int |
| 677 | mwifiex_set_mac_address(struct net_device *dev, void *addr) |
| 678 | { |
| 679 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 680 | struct sockaddr *hw_addr = addr; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 681 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 682 | |
| 683 | memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN); |
| 684 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 685 | /* Send request to firmware */ |
| 686 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_MAC_ADDRESS, |
| 687 | HostCmd_ACT_GEN_SET, 0, NULL); |
| 688 | |
| 689 | if (!ret) |
| 690 | memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN); |
| 691 | else |
Yogesh Ashok Powar | f57c1ed | 2012-03-13 19:22:37 -0700 | [diff] [blame] | 692 | dev_err(priv->adapter->dev, |
| 693 | "set mac address failed: ret=%d\n", ret); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 694 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 695 | memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN); |
| 696 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 697 | return ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 698 | } |
| 699 | |
| 700 | /* |
| 701 | * CFG802.11 network device handler for setting multicast list. |
| 702 | */ |
| 703 | static void mwifiex_set_multicast_list(struct net_device *dev) |
| 704 | { |
| 705 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 706 | struct mwifiex_multicast_list mcast_list; |
| 707 | |
| 708 | if (dev->flags & IFF_PROMISC) { |
| 709 | mcast_list.mode = MWIFIEX_PROMISC_MODE; |
| 710 | } else if (dev->flags & IFF_ALLMULTI || |
| 711 | netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) { |
| 712 | mcast_list.mode = MWIFIEX_ALL_MULTI_MODE; |
| 713 | } else { |
| 714 | mcast_list.mode = MWIFIEX_MULTICAST_MODE; |
Daniel Drake | 6390d88 | 2013-06-14 15:24:24 -0400 | [diff] [blame] | 715 | mcast_list.num_multicast_addr = |
| 716 | mwifiex_copy_mcast_addr(&mcast_list, dev); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 717 | } |
| 718 | mwifiex_request_set_multicast_list(priv, &mcast_list); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | /* |
| 722 | * CFG802.11 network device handler for transmission timeout. |
| 723 | */ |
| 724 | static void |
| 725 | mwifiex_tx_timeout(struct net_device *dev) |
| 726 | { |
| 727 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 728 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 729 | priv->num_tx_timeout++; |
Ashok Nagarajan | 8908c7d | 2013-03-08 10:58:45 -0800 | [diff] [blame] | 730 | priv->tx_timeout_cnt++; |
| 731 | dev_err(priv->adapter->dev, |
| 732 | "%lu : Tx timeout(#%d), bss_type-num = %d-%d\n", |
| 733 | jiffies, priv->tx_timeout_cnt, priv->bss_type, priv->bss_num); |
| 734 | mwifiex_set_trans_start(dev); |
| 735 | |
| 736 | if (priv->tx_timeout_cnt > TX_TIMEOUT_THRESHOLD && |
| 737 | priv->adapter->if_ops.card_reset) { |
| 738 | dev_err(priv->adapter->dev, |
| 739 | "tx_timeout_cnt exceeds threshold. Triggering card reset!\n"); |
| 740 | priv->adapter->if_ops.card_reset(priv->adapter); |
| 741 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /* |
| 745 | * CFG802.11 network device handler for statistics retrieval. |
| 746 | */ |
| 747 | static struct net_device_stats *mwifiex_get_stats(struct net_device *dev) |
| 748 | { |
| 749 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 750 | |
| 751 | return &priv->stats; |
| 752 | } |
| 753 | |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 754 | static u16 |
| 755 | mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb) |
| 756 | { |
| 757 | skb->priority = cfg80211_classify8021d(skb); |
| 758 | return mwifiex_1d_to_wmm_queue[skb->priority]; |
| 759 | } |
| 760 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 761 | /* Network device handlers */ |
| 762 | static const struct net_device_ops mwifiex_netdev_ops = { |
| 763 | .ndo_open = mwifiex_open, |
| 764 | .ndo_stop = mwifiex_close, |
| 765 | .ndo_start_xmit = mwifiex_hard_start_xmit, |
| 766 | .ndo_set_mac_address = mwifiex_set_mac_address, |
| 767 | .ndo_tx_timeout = mwifiex_tx_timeout, |
| 768 | .ndo_get_stats = mwifiex_get_stats, |
Jiri Pirko | afc4b13 | 2011-08-16 06:29:01 +0000 | [diff] [blame] | 769 | .ndo_set_rx_mode = mwifiex_set_multicast_list, |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 770 | .ndo_select_queue = mwifiex_netdev_select_wmm_queue, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 771 | }; |
| 772 | |
| 773 | /* |
| 774 | * This function initializes the private structure parameters. |
| 775 | * |
| 776 | * The following wait queues are initialized - |
| 777 | * - IOCTL wait queue |
| 778 | * - Command wait queue |
| 779 | * - Statistics wait queue |
| 780 | * |
| 781 | * ...and the following default parameters are set - |
| 782 | * - Current key index : Set to 0 |
| 783 | * - Rate index : Set to auto |
| 784 | * - Media connected : Set to disconnected |
| 785 | * - Adhoc link sensed : Set to false |
| 786 | * - Nick name : Set to null |
| 787 | * - Number of Tx timeout : Set to 0 |
| 788 | * - Device address : Set to current address |
| 789 | * |
| 790 | * In addition, the CFG80211 work queue is also created. |
| 791 | */ |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 792 | void mwifiex_init_priv_params(struct mwifiex_private *priv, |
| 793 | struct net_device *dev) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 794 | { |
| 795 | dev->netdev_ops = &mwifiex_netdev_ops; |
Amitkumar Karwar | f16fdc9 | 2013-05-06 19:46:54 -0700 | [diff] [blame] | 796 | dev->destructor = free_netdev; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 797 | /* Initialize private structure */ |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 798 | priv->current_key_index = 0; |
| 799 | priv->media_connected = false; |
| 800 | memset(&priv->nick_name, 0, sizeof(priv->nick_name)); |
Avinash Patil | ede98bf | 2012-05-08 18:30:28 -0700 | [diff] [blame] | 801 | memset(priv->mgmt_ie, 0, |
| 802 | sizeof(struct mwifiex_ie) * MAX_MGMT_IE_INDEX); |
Avinash Patil | f31acab | 2012-05-08 18:30:29 -0700 | [diff] [blame] | 803 | priv->beacon_idx = MWIFIEX_AUTO_IDX_MASK; |
| 804 | priv->proberesp_idx = MWIFIEX_AUTO_IDX_MASK; |
| 805 | priv->assocresp_idx = MWIFIEX_AUTO_IDX_MASK; |
| 806 | priv->rsn_idx = MWIFIEX_AUTO_IDX_MASK; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 807 | priv->num_tx_timeout = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 808 | memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN); |
| 809 | } |
| 810 | |
| 811 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 812 | * This function check if command is pending. |
| 813 | */ |
| 814 | int is_command_pending(struct mwifiex_adapter *adapter) |
| 815 | { |
| 816 | unsigned long flags; |
| 817 | int is_cmd_pend_q_empty; |
| 818 | |
| 819 | spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); |
| 820 | is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q); |
| 821 | spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); |
| 822 | |
| 823 | return !is_cmd_pend_q_empty; |
| 824 | } |
| 825 | |
| 826 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 827 | * This is the main work queue function. |
| 828 | * |
| 829 | * It handles the main process, which in turn handles the complete |
| 830 | * driver operations. |
| 831 | */ |
| 832 | static void mwifiex_main_work_queue(struct work_struct *work) |
| 833 | { |
| 834 | struct mwifiex_adapter *adapter = |
| 835 | container_of(work, struct mwifiex_adapter, main_work); |
| 836 | |
| 837 | if (adapter->surprise_removed) |
| 838 | return; |
| 839 | mwifiex_main_process(adapter); |
| 840 | } |
| 841 | |
| 842 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 843 | * This function adds the card. |
| 844 | * |
| 845 | * This function follows the following major steps to set up the device - |
| 846 | * - Initialize software. This includes probing the card, registering |
| 847 | * the interface operations table, and allocating/initializing the |
| 848 | * adapter structure |
| 849 | * - Set up the netlink socket |
| 850 | * - Create and start the main work queue |
| 851 | * - Register the device |
| 852 | * - Initialize firmware and hardware |
| 853 | * - Add logical interfaces |
| 854 | */ |
| 855 | int |
| 856 | mwifiex_add_card(void *card, struct semaphore *sem, |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 857 | struct mwifiex_if_ops *if_ops, u8 iface_type) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 858 | { |
Amitkumar Karwar | 2be7859 | 2011-04-15 20:50:42 -0700 | [diff] [blame] | 859 | struct mwifiex_adapter *adapter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 860 | |
| 861 | if (down_interruptible(sem)) |
| 862 | goto exit_sem_err; |
| 863 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 864 | if (mwifiex_register(card, if_ops, (void **)&adapter)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 865 | pr_err("%s: software init failed\n", __func__); |
| 866 | goto err_init_sw; |
| 867 | } |
| 868 | |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 869 | adapter->iface_type = iface_type; |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 870 | adapter->card_sem = sem; |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 871 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 872 | adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 873 | adapter->surprise_removed = false; |
| 874 | init_waitqueue_head(&adapter->init_wait_q); |
| 875 | adapter->is_suspended = false; |
| 876 | adapter->hs_activated = false; |
| 877 | init_waitqueue_head(&adapter->hs_activate_wait_q); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 878 | adapter->cmd_wait_q_required = false; |
| 879 | init_waitqueue_head(&adapter->cmd_wait_q.wait); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 880 | adapter->cmd_wait_q.status = 0; |
Amitkumar Karwar | efaaa8b | 2011-10-12 20:28:06 -0700 | [diff] [blame] | 881 | adapter->scan_wait_q_woken = false; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 882 | |
Amitkumar Karwar | 448a71c | 2013-10-11 18:33:04 -0700 | [diff] [blame^] | 883 | adapter->workqueue = |
| 884 | alloc_workqueue("MWIFIEX_WORK_QUEUE", |
| 885 | WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 886 | if (!adapter->workqueue) |
| 887 | goto err_kmalloc; |
| 888 | |
| 889 | INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); |
| 890 | |
| 891 | /* Register the device. Fill up the private data structure with relevant |
Daniel Drake | 232fde0 | 2013-07-13 10:57:10 -0400 | [diff] [blame] | 892 | information from the card. */ |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 893 | if (adapter->if_ops.register_dev(adapter)) { |
| 894 | pr_err("%s: failed to register mwifiex device\n", __func__); |
| 895 | goto err_registerdev; |
| 896 | } |
| 897 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 898 | if (mwifiex_init_hw_fw(adapter)) { |
| 899 | pr_err("%s: firmware init failed\n", __func__); |
| 900 | goto err_init_fw; |
| 901 | } |
Amitkumar Karwar | 2be7859 | 2011-04-15 20:50:42 -0700 | [diff] [blame] | 902 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 903 | return 0; |
| 904 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 905 | err_init_fw: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 906 | pr_debug("info: %s: unregister device\n", __func__); |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 907 | if (adapter->if_ops.unregister_dev) |
| 908 | adapter->if_ops.unregister_dev(adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 909 | if ((adapter->hw_status == MWIFIEX_HW_STATUS_FW_READY) || |
| 910 | (adapter->hw_status == MWIFIEX_HW_STATUS_READY)) { |
| 911 | pr_debug("info: %s: shutdown mwifiex\n", __func__); |
| 912 | adapter->init_wait_q_woken = false; |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 913 | |
| 914 | if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 915 | wait_event_interruptible(adapter->init_wait_q, |
| 916 | adapter->init_wait_q_woken); |
| 917 | } |
Amitkumar Karwar | 6b41f94 | 2013-07-22 19:17:55 -0700 | [diff] [blame] | 918 | err_registerdev: |
| 919 | adapter->surprise_removed = true; |
| 920 | mwifiex_terminate_workqueue(adapter); |
| 921 | err_kmalloc: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 922 | mwifiex_free_adapter(adapter); |
| 923 | |
| 924 | err_init_sw: |
| 925 | up(sem); |
| 926 | |
| 927 | exit_sem_err: |
| 928 | return -1; |
| 929 | } |
| 930 | EXPORT_SYMBOL_GPL(mwifiex_add_card); |
| 931 | |
| 932 | /* |
| 933 | * This function removes the card. |
| 934 | * |
| 935 | * This function follows the following major steps to remove the device - |
| 936 | * - Stop data traffic |
| 937 | * - Shutdown firmware |
| 938 | * - Remove the logical interfaces |
| 939 | * - Terminate the work queue |
| 940 | * - Unregister the device |
| 941 | * - Free the adapter structure |
| 942 | */ |
| 943 | int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem) |
| 944 | { |
| 945 | struct mwifiex_private *priv = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 946 | int i; |
| 947 | |
| 948 | if (down_interruptible(sem)) |
| 949 | goto exit_sem_err; |
| 950 | |
| 951 | if (!adapter) |
| 952 | goto exit_remove; |
| 953 | |
Daniel Drake | 232fde0 | 2013-07-13 10:57:10 -0400 | [diff] [blame] | 954 | /* We can no longer handle interrupts once we start doing the teardown |
| 955 | * below. */ |
| 956 | if (adapter->if_ops.disable_int) |
| 957 | adapter->if_ops.disable_int(adapter); |
| 958 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 959 | adapter->surprise_removed = true; |
| 960 | |
| 961 | /* Stop data */ |
| 962 | for (i = 0; i < adapter->priv_num; i++) { |
| 963 | priv = adapter->priv[i]; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 964 | if (priv && priv->netdev) { |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 965 | mwifiex_stop_net_dev_queue(priv->netdev, adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 966 | if (netif_carrier_ok(priv->netdev)) |
| 967 | netif_carrier_off(priv->netdev); |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | dev_dbg(adapter->dev, "cmd: calling mwifiex_shutdown_drv...\n"); |
| 972 | adapter->init_wait_q_woken = false; |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 973 | |
| 974 | if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 975 | wait_event_interruptible(adapter->init_wait_q, |
| 976 | adapter->init_wait_q_woken); |
| 977 | dev_dbg(adapter->dev, "cmd: mwifiex_shutdown_drv done\n"); |
| 978 | if (atomic_read(&adapter->rx_pending) || |
| 979 | atomic_read(&adapter->tx_pending) || |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 980 | atomic_read(&adapter->cmd_pending)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 981 | dev_err(adapter->dev, "rx_pending=%d, tx_pending=%d, " |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 982 | "cmd_pending=%d\n", |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 983 | atomic_read(&adapter->rx_pending), |
| 984 | atomic_read(&adapter->tx_pending), |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 985 | atomic_read(&adapter->cmd_pending)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 986 | } |
| 987 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 988 | for (i = 0; i < adapter->priv_num; i++) { |
| 989 | priv = adapter->priv[i]; |
| 990 | |
| 991 | if (!priv) |
| 992 | continue; |
| 993 | |
| 994 | rtnl_lock(); |
Amitkumar Karwar | 2da8cbf | 2012-02-03 20:34:02 -0800 | [diff] [blame] | 995 | if (priv->wdev && priv->netdev) |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 996 | mwifiex_del_virtual_intf(adapter->wiphy, priv->wdev); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 997 | rtnl_unlock(); |
| 998 | } |
| 999 | |
Yogesh Ashok Powar | 3d82de0 | 2011-10-05 14:58:24 -0700 | [diff] [blame] | 1000 | priv = adapter->priv[0]; |
Avinash Patil | 64b05e2 | 2012-05-08 18:30:13 -0700 | [diff] [blame] | 1001 | if (!priv || !priv->wdev) |
Yogesh Ashok Powar | 3d82de0 | 2011-10-05 14:58:24 -0700 | [diff] [blame] | 1002 | goto exit_remove; |
| 1003 | |
Avinash Patil | 64b05e2 | 2012-05-08 18:30:13 -0700 | [diff] [blame] | 1004 | wiphy_unregister(priv->wdev->wiphy); |
| 1005 | wiphy_free(priv->wdev->wiphy); |
| 1006 | |
| 1007 | for (i = 0; i < adapter->priv_num; i++) { |
| 1008 | priv = adapter->priv[i]; |
| 1009 | if (priv) |
| 1010 | kfree(priv->wdev); |
Amitkumar Karwar | 2da8cbf | 2012-02-03 20:34:02 -0800 | [diff] [blame] | 1011 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1012 | |
| 1013 | mwifiex_terminate_workqueue(adapter); |
| 1014 | |
| 1015 | /* Unregister device */ |
| 1016 | dev_dbg(adapter->dev, "info: unregister device\n"); |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 1017 | if (adapter->if_ops.unregister_dev) |
| 1018 | adapter->if_ops.unregister_dev(adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1019 | /* Free adapter structure */ |
| 1020 | dev_dbg(adapter->dev, "info: free adapter\n"); |
| 1021 | mwifiex_free_adapter(adapter); |
| 1022 | |
| 1023 | exit_remove: |
| 1024 | up(sem); |
| 1025 | exit_sem_err: |
| 1026 | return 0; |
| 1027 | } |
| 1028 | EXPORT_SYMBOL_GPL(mwifiex_remove_card); |
| 1029 | |
| 1030 | /* |
| 1031 | * This function initializes the module. |
| 1032 | * |
| 1033 | * The debug FS is also initialized if configured. |
| 1034 | */ |
| 1035 | static int |
| 1036 | mwifiex_init_module(void) |
| 1037 | { |
| 1038 | #ifdef CONFIG_DEBUG_FS |
| 1039 | mwifiex_debugfs_init(); |
| 1040 | #endif |
| 1041 | return 0; |
| 1042 | } |
| 1043 | |
| 1044 | /* |
| 1045 | * This function cleans up the module. |
| 1046 | * |
| 1047 | * The debug FS is removed if available. |
| 1048 | */ |
| 1049 | static void |
| 1050 | mwifiex_cleanup_module(void) |
| 1051 | { |
| 1052 | #ifdef CONFIG_DEBUG_FS |
| 1053 | mwifiex_debugfs_remove(); |
| 1054 | #endif |
| 1055 | } |
| 1056 | |
| 1057 | module_init(mwifiex_init_module); |
| 1058 | module_exit(mwifiex_cleanup_module); |
| 1059 | |
| 1060 | MODULE_AUTHOR("Marvell International Ltd."); |
| 1061 | MODULE_DESCRIPTION("Marvell WiFi-Ex Driver version " VERSION); |
| 1062 | MODULE_VERSION(VERSION); |
| 1063 | MODULE_LICENSE("GPL v2"); |