main.c 48.5 KB
Newer Older
1 2 3
/*
 * Marvell Wireless LAN device driver: major functions
 *
X
Xinming Hu 已提交
4
 * Copyright (C) 2011-2014, Marvell International Ltd.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * This software file (the "File") is distributed by Marvell International
 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
 * (the "License").  You may use, redistribute and/or modify this File in
 * accordance with the terms and conditions of the License, a copy of which
 * is available by writing to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 *
 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
 * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
 * this warranty disclaimer.
 */

#include "main.h"
#include "wmm.h"
#include "cfg80211.h"
#include "11n.h"

#define VERSION	"1.0"
26
#define MFG_FIRMWARE	"mwifiex_mfg.bin"
27

28 29 30 31
static unsigned int debug_mask = MWIFIEX_DEFAULT_DEBUG_MASK;
module_param(debug_mask, uint, 0);
MODULE_PARM_DESC(debug_mask, "bitmap for debug flags");

32
const char driver_version[] = "mwifiex " VERSION " (%s) ";
33 34
static char *cal_data_cfg;
module_param(cal_data_cfg, charp, 0);
35

36 37 38 39 40
static unsigned short driver_mode;
module_param(driver_mode, ushort, 0);
MODULE_PARM_DESC(driver_mode,
		 "station=0x1(default), ap-sta=0x3, station-p2p=0x5, ap-sta-p2p=0x7");

41 42 43 44
bool mfg_mode;
module_param(mfg_mode, bool, 0);
MODULE_PARM_DESC(mfg_mode, "manufacturing mode enable:1, disable:0");

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*
 * This function registers the device and performs all the necessary
 * initializations.
 *
 * The following initialization operations are performed -
 *      - Allocate adapter structure
 *      - Save interface specific operations table in adapter
 *      - Call interface specific initialization routine
 *      - Allocate private structures
 *      - Set default adapter structure parameters
 *      - Initialize locks
 *
 * In case of any errors during inittialization, this function also ensures
 * proper cleanup before exiting.
 */
static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
61
			    void **padapter)
62
{
63 64
	struct mwifiex_adapter *adapter;
	int i;
65 66 67

	adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
	if (!adapter)
68
		return -ENOMEM;
69

70
	*padapter = adapter;
71 72 73 74
	adapter->card = card;

	/* Save interface specific operations in adapter */
	memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops));
75
	adapter->debug_mask = debug_mask;
76 77

	/* card specific initialization has been deferred until now .. */
78 79 80
	if (adapter->if_ops.init_if)
		if (adapter->if_ops.init_if(adapter))
			goto error;
81 82 83

	adapter->priv_num = 0;

84 85 86 87 88 89
	for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) {
		/* Allocate memory for private structure */
		adapter->priv[i] =
			kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL);
		if (!adapter->priv[i])
			goto error;
90

91 92 93
		adapter->priv[i]->adapter = adapter;
		adapter->priv_num++;
	}
94
	mwifiex_init_lock_list(adapter);
95

J
Julia Lawall 已提交
96 97
	setup_timer(&adapter->cmd_timer, mwifiex_cmd_timeout_func,
		    (unsigned long)adapter);
98 99 100 101

	return 0;

error:
102 103
	mwifiex_dbg(adapter, ERROR,
		    "info: leave mwifiex_register with error\n");
104

105
	for (i = 0; i < adapter->priv_num; i++)
106
		kfree(adapter->priv[i]);
107

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
	kfree(adapter);

	return -1;
}

/*
 * This function unregisters the device and performs all the necessary
 * cleanups.
 *
 * The following cleanup operations are performed -
 *      - Free the timers
 *      - Free beacon buffers
 *      - Free private structures
 *      - Free adapter structure
 */
static int mwifiex_unregister(struct mwifiex_adapter *adapter)
{
125
	s32 i;
126

127 128 129
	if (adapter->if_ops.cleanup_if)
		adapter->if_ops.cleanup_if(adapter);

130
	del_timer_sync(&adapter->cmd_timer);
131 132 133 134 135 136 137 138 139

	/* Free private structures */
	for (i = 0; i < adapter->priv_num; i++) {
		if (adapter->priv[i]) {
			mwifiex_free_curr_bcn(adapter->priv[i]);
			kfree(adapter->priv[i]);
		}
	}

140 141 142 143 144 145 146
	if (adapter->nd_info) {
		for (i = 0 ; i < adapter->nd_info->n_matches ; i++)
			kfree(adapter->nd_info->matches[i]);
		kfree(adapter->nd_info);
		adapter->nd_info = NULL;
	}

147 148
	kfree(adapter->regd);

149
	vfree(adapter->chan_stats);
150 151 152 153
	kfree(adapter);
	return 0;
}

154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
void mwifiex_queue_main_work(struct mwifiex_adapter *adapter)
{
	unsigned long flags;

	spin_lock_irqsave(&adapter->main_proc_lock, flags);
	if (adapter->mwifiex_processing) {
		adapter->more_task_flag = true;
		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
	} else {
		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
		queue_work(adapter->workqueue, &adapter->main_work);
	}
}
EXPORT_SYMBOL_GPL(mwifiex_queue_main_work);

static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter)
{
	unsigned long flags;

	spin_lock_irqsave(&adapter->rx_proc_lock, flags);
	if (adapter->rx_processing) {
		spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
	} else {
		spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
		queue_work(adapter->rx_workqueue, &adapter->rx_work);
	}
}

182 183 184 185
static int mwifiex_process_rx(struct mwifiex_adapter *adapter)
{
	unsigned long flags;
	struct sk_buff *skb;
186
	struct mwifiex_rxinfo *rx_info;
187 188 189 190 191 192 193 194 195 196 197 198 199

	spin_lock_irqsave(&adapter->rx_proc_lock, flags);
	if (adapter->rx_processing || adapter->rx_locked) {
		spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
		goto exit_rx_proc;
	} else {
		adapter->rx_processing = true;
		spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
	}

	/* Check for Rx data */
	while ((skb = skb_dequeue(&adapter->rx_data_q))) {
		atomic_dec(&adapter->rx_pending);
200 201
		if ((adapter->delay_main_work ||
		     adapter->iface_type == MWIFIEX_USB) &&
202
		    (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) {
203 204
			if (adapter->if_ops.submit_rem_rx_urbs)
				adapter->if_ops.submit_rem_rx_urbs(adapter);
205
			adapter->delay_main_work = false;
206
			mwifiex_queue_main_work(adapter);
207
		}
208 209 210 211 212 213 214
		rx_info = MWIFIEX_SKB_RXCB(skb);
		if (rx_info->buf_type == MWIFIEX_TYPE_AGGR_DATA) {
			if (adapter->if_ops.deaggr_pkt)
				adapter->if_ops.deaggr_pkt(adapter, skb);
			dev_kfree_skb_any(skb);
		} else {
			mwifiex_handle_rx_packet(adapter, skb);
215 216 217 218 219 220 221 222 223 224
		}
	}
	spin_lock_irqsave(&adapter->rx_proc_lock, flags);
	adapter->rx_processing = false;
	spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);

exit_rx_proc:
	return 0;
}

225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
/*
 * The main process.
 *
 * This function is the main procedure of the driver and handles various driver
 * operations. It runs in a loop and provides the core functionalities.
 *
 * The main responsibilities of this function are -
 *      - Ensure concurrency control
 *      - Handle pending interrupts and call interrupt handlers
 *      - Wake up the card if required
 *      - Handle command responses and call response handlers
 *      - Handle events and call event handlers
 *      - Execute pending commands
 *      - Transmit pending data packets
 */
int mwifiex_main_process(struct mwifiex_adapter *adapter)
{
	int ret = 0;
	unsigned long flags;

	spin_lock_irqsave(&adapter->main_proc_lock, flags);

	/* Check if already processing */
248
	if (adapter->mwifiex_processing || adapter->main_locked) {
249
		adapter->more_task_flag = true;
250
		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
251
		return 0;
252 253
	} else {
		adapter->mwifiex_processing = true;
254
		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
255 256 257
	}
process_start:
	do {
258
		if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY)
259 260
			break;

261 262 263 264 265 266
		/* For non-USB interfaces, If we process interrupts first, it
		 * would increase RX pending even further. Avoid this by
		 * checking if rx_pending has crossed high threshold and
		 * schedule rx work queue and then process interrupts.
		 * For USB interface, there are no interrupts. We already have
		 * HIGH_RX_PENDING check in usb.c
267
		 */
268 269
		if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING &&
		    adapter->iface_type != MWIFIEX_USB) {
270
			adapter->delay_main_work = true;
271
			mwifiex_queue_rx_work(adapter);
272 273 274
			break;
		}

275 276 277 278
		/* Handle pending interrupt if any */
		if (adapter->int_status) {
			if (adapter->hs_activated)
				mwifiex_process_hs_config(adapter);
279 280
			if (adapter->if_ops.process_int_status)
				adapter->if_ops.process_int_status(adapter);
281 282
		}

283
		if (adapter->rx_work_enabled && adapter->data_received)
284
			mwifiex_queue_rx_work(adapter);
285

286 287 288 289
		/* Need to wake up the card ? */
		if ((adapter->ps_state == PS_STATE_SLEEP) &&
		    (adapter->pm_wakeup_card_req &&
		     !adapter->pm_wakeup_fw_try) &&
290
		    (is_command_pending(adapter) ||
291
		     !skb_queue_empty(&adapter->tx_data_q) ||
292
		     !mwifiex_bypass_txlist_empty(adapter) ||
293
		     !mwifiex_wmm_lists_empty(adapter))) {
294
			adapter->pm_wakeup_fw_try = true;
295
			mod_timer(&adapter->wakeup_timer, jiffies + (HZ*3));
296 297 298
			adapter->if_ops.wakeup(adapter);
			continue;
		}
299

300
		if (IS_CARD_RX_RCVD(adapter)) {
301
			adapter->data_received = false;
302
			adapter->pm_wakeup_fw_try = false;
303
			del_timer(&adapter->wakeup_timer);
304 305 306 307 308 309
			if (adapter->ps_state == PS_STATE_SLEEP)
				adapter->ps_state = PS_STATE_AWAKE;
		} else {
			/* We have tried to wakeup the card already */
			if (adapter->pm_wakeup_fw_try)
				break;
310 311 312
			if (adapter->ps_state == PS_STATE_PRE_SLEEP)
				mwifiex_check_ps_cond(adapter);

313
			if (adapter->ps_state != PS_STATE_AWAKE)
314
				break;
315 316 317 318 319 320 321
			if (adapter->tx_lock_flag) {
				if (adapter->iface_type == MWIFIEX_USB) {
					if (!adapter->usb_mc_setup)
						break;
				} else
					break;
			}
322

323 324
			if ((!adapter->scan_chan_gap_enabled &&
			     adapter->scan_processing) || adapter->data_sent ||
325 326 327
			     mwifiex_is_tdls_chan_switching
			     (mwifiex_get_priv(adapter,
					       MWIFIEX_BSS_ROLE_STA)) ||
328
			    (mwifiex_wmm_lists_empty(adapter) &&
329
			     mwifiex_bypass_txlist_empty(adapter) &&
330
			     skb_queue_empty(&adapter->tx_data_q))) {
331
				if (adapter->cmd_sent || adapter->curr_cmd ||
332 333 334
					!mwifiex_is_send_cmd_allowed
						(mwifiex_get_priv(adapter,
						MWIFIEX_BSS_ROLE_STA)) ||
335
				    (!is_command_pending(adapter)))
336 337 338 339
					break;
			}
		}

340 341 342 343 344 345
		/* Check for event */
		if (adapter->event_received) {
			adapter->event_received = false;
			mwifiex_process_event(adapter);
		}

346 347 348 349 350 351 352 353 354 355 356 357 358 359
		/* Check for Cmd Resp */
		if (adapter->cmd_resp_received) {
			adapter->cmd_resp_received = false;
			mwifiex_process_cmdresp(adapter);

			/* call mwifiex back when init_fw is done */
			if (adapter->hw_status == MWIFIEX_HW_STATUS_INIT_DONE) {
				adapter->hw_status = MWIFIEX_HW_STATUS_READY;
				mwifiex_init_fw_complete(adapter);
			}
		}

		/* Check if we need to confirm Sleep Request
		   received previously */
360 361
		if (adapter->ps_state == PS_STATE_PRE_SLEEP)
			mwifiex_check_ps_cond(adapter);
362 363 364 365

		/* * The ps_state may have been changed during processing of
		 * Sleep Request event.
		 */
366 367
		if ((adapter->ps_state == PS_STATE_SLEEP) ||
		    (adapter->ps_state == PS_STATE_PRE_SLEEP) ||
368
		    (adapter->ps_state == PS_STATE_SLEEP_CFM)) {
369
			continue;
370
		}
371

372 373 374 375 376 377 378 379
		if (adapter->tx_lock_flag) {
			if (adapter->iface_type == MWIFIEX_USB) {
				if (!adapter->usb_mc_setup)
					continue;
			} else
				continue;
		}

380 381 382
		if (!adapter->cmd_sent && !adapter->curr_cmd &&
		    mwifiex_is_send_cmd_allowed
		    (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) {
383 384 385 386 387 388
			if (mwifiex_exec_next_cmd(adapter) == -1) {
				ret = -1;
				break;
			}
		}

389 390 391 392 393 394 395
		/** If USB Multi channel setup ongoing,
		 *  wait for ready to tx data.
		 */
		if (adapter->iface_type == MWIFIEX_USB &&
		    adapter->usb_mc_setup)
			continue;

396 397 398 399 400 401 402 403 404 405 406 407 408 409
		if ((adapter->scan_chan_gap_enabled ||
		     !adapter->scan_processing) &&
		    !adapter->data_sent &&
		    !skb_queue_empty(&adapter->tx_data_q)) {
			mwifiex_process_tx_queue(adapter);
			if (adapter->hs_activated) {
				adapter->is_hs_configured = false;
				mwifiex_hs_activated_event
					(mwifiex_get_priv
					(adapter, MWIFIEX_BSS_ROLE_ANY),
					false);
			}
		}

410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
		if ((adapter->scan_chan_gap_enabled ||
		     !adapter->scan_processing) &&
		    !adapter->data_sent &&
		    !mwifiex_bypass_txlist_empty(adapter) &&
		    !mwifiex_is_tdls_chan_switching
			(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) {
			mwifiex_process_bypass_tx(adapter);
			if (adapter->hs_activated) {
				adapter->is_hs_configured = false;
				mwifiex_hs_activated_event
					(mwifiex_get_priv
					 (adapter, MWIFIEX_BSS_ROLE_ANY),
					 false);
			}
		}

426
		if ((adapter->scan_chan_gap_enabled ||
427
		     !adapter->scan_processing) &&
428 429 430
		    !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter) &&
		    !mwifiex_is_tdls_chan_switching
			(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) {
431 432 433 434 435 436 437 438 439 440 441
			mwifiex_wmm_process_tx(adapter);
			if (adapter->hs_activated) {
				adapter->is_hs_configured = false;
				mwifiex_hs_activated_event
					(mwifiex_get_priv
					 (adapter, MWIFIEX_BSS_ROLE_ANY),
					 false);
			}
		}

		if (adapter->delay_null_pkt && !adapter->cmd_sent &&
442
		    !adapter->curr_cmd && !is_command_pending(adapter) &&
443
		    (mwifiex_wmm_lists_empty(adapter) &&
444
		     mwifiex_bypass_txlist_empty(adapter) &&
445
		     skb_queue_empty(&adapter->tx_data_q))) {
446 447 448 449 450 451 452 453 454 455 456
			if (!mwifiex_send_null_packet
			    (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
			     MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
			     MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) {
				adapter->delay_null_pkt = false;
				adapter->ps_state = PS_STATE_SLEEP;
			}
			break;
		}
	} while (true);

457
	spin_lock_irqsave(&adapter->main_proc_lock, flags);
458 459 460
	if (adapter->more_task_flag) {
		adapter->more_task_flag = false;
		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
461
		goto process_start;
462
	}
463 464 465 466 467
	adapter->mwifiex_processing = false;
	spin_unlock_irqrestore(&adapter->main_proc_lock, flags);

	return ret;
}
468
EXPORT_SYMBOL_GPL(mwifiex_main_process);
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486

/*
 * This function frees the adapter structure.
 *
 * Additionally, this closes the netlink socket, frees the timers
 * and private structures.
 */
static void mwifiex_free_adapter(struct mwifiex_adapter *adapter)
{
	if (!adapter) {
		pr_err("%s: adapter is NULL\n", __func__);
		return;
	}

	mwifiex_unregister(adapter);
	pr_debug("info: %s: free adapter\n", __func__);
}

487 488 489 490 491 492
/*
 * This function cancels all works in the queue and destroys
 * the main workqueue.
 */
static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter)
{
493 494 495 496 497
	if (adapter->workqueue) {
		flush_workqueue(adapter->workqueue);
		destroy_workqueue(adapter->workqueue);
		adapter->workqueue = NULL;
	}
498 499 500 501 502 503

	if (adapter->rx_workqueue) {
		flush_workqueue(adapter->rx_workqueue);
		destroy_workqueue(adapter->rx_workqueue);
		adapter->rx_workqueue = NULL;
	}
504 505
}

506
/*
507
 * This function gets firmware and initializes it.
508 509 510 511 512
 *
 * The main initialization steps followed are -
 *      - Download the correct firmware to card
 *      - Issue the init commands to firmware
 */
513
static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
514
{
515
	int ret;
516 517
	char fmt[64];
	struct mwifiex_adapter *adapter = context;
518
	struct mwifiex_fw_image fw;
519
	bool init_failed = false;
520
	struct wireless_dev *wdev;
521
	struct completion *fw_done = adapter->fw_done;
522

523
	if (!firmware) {
524 525
		mwifiex_dbg(adapter, ERROR,
			    "Failed to get firmware %s\n", adapter->fw_name);
526
		goto err_dnld_fw;
527
	}
528 529 530

	memset(&fw, 0, sizeof(struct mwifiex_fw_image));
	adapter->firmware = firmware;
531 532 533
	fw.fw_buf = (u8 *) adapter->firmware->data;
	fw.fw_len = adapter->firmware->size;

534
	if (adapter->if_ops.dnld_fw) {
535
		ret = adapter->if_ops.dnld_fw(adapter, &fw);
536
	} else {
537
		ret = mwifiex_dnld_fw(adapter, &fw);
538 539
	}

540
	if (ret == -1)
541
		goto err_dnld_fw;
542

543
	mwifiex_dbg(adapter, MSG, "WLAN FW is active\n");
544

545 546 547
	if (cal_data_cfg) {
		if ((request_firmware(&adapter->cal_data, cal_data_cfg,
				      adapter->dev)) < 0)
548 549
			mwifiex_dbg(adapter, ERROR,
				    "Cal data request_firmware() failed\n");
550 551
	}

D
Daniel Drake 已提交
552
	/* enable host interrupt after fw dnld is successful */
553 554 555 556
	if (adapter->if_ops.enable_int) {
		if (adapter->if_ops.enable_int(adapter))
			goto err_dnld_fw;
	}
D
Daniel Drake 已提交
557

558 559 560
	adapter->init_wait_q_woken = false;
	ret = mwifiex_init_fw(adapter);
	if (ret == -1) {
561
		goto err_init_fw;
562 563 564 565 566
	} else if (!ret) {
		adapter->hw_status = MWIFIEX_HW_STATUS_READY;
		goto done;
	}
	/* Wait for mwifiex_init to complete */
567 568 569 570 571 572
	if (!adapter->mfg_mode) {
		wait_event_interruptible(adapter->init_wait_q,
					 adapter->init_wait_q_woken);
		if (adapter->hw_status != MWIFIEX_HW_STATUS_READY)
			goto err_init_fw;
	}
573

574 575 576 577 578 579
	if (!adapter->wiphy) {
		if (mwifiex_register_cfg80211(adapter)) {
			mwifiex_dbg(adapter, ERROR,
				    "cannot register with cfg80211\n");
			goto err_init_fw;
		}
580 581
	}

582
	if (mwifiex_init_channel_scan_gap(adapter)) {
583 584
		mwifiex_dbg(adapter, ERROR,
			    "could not init channel stats table\n");
585 586 587
		goto err_init_fw;
	}

588 589 590 591 592
	if (driver_mode) {
		driver_mode &= MWIFIEX_DRIVER_MODE_BITMASK;
		driver_mode |= MWIFIEX_DRIVER_MODE_STA;
	}

593 594
	rtnl_lock();
	/* Create station interface by default */
595
	wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM,
596 597
					NL80211_IFTYPE_STATION, NULL, NULL);
	if (IS_ERR(wdev)) {
598 599
		mwifiex_dbg(adapter, ERROR,
			    "cannot create default STA interface\n");
600
		rtnl_unlock();
601
		goto err_add_intf;
602
	}
603 604

	if (driver_mode & MWIFIEX_DRIVER_MODE_UAP) {
605
		wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM,
606 607
						NL80211_IFTYPE_AP, NULL, NULL);
		if (IS_ERR(wdev)) {
608 609
			mwifiex_dbg(adapter, ERROR,
				    "cannot create AP interface\n");
610 611 612 613 614 615
			rtnl_unlock();
			goto err_add_intf;
		}
	}

	if (driver_mode & MWIFIEX_DRIVER_MODE_P2P) {
616
		wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM,
617 618 619
						NL80211_IFTYPE_P2P_CLIENT, NULL,
						NULL);
		if (IS_ERR(wdev)) {
620 621
			mwifiex_dbg(adapter, ERROR,
				    "cannot create p2p client interface\n");
622 623 624 625
			rtnl_unlock();
			goto err_add_intf;
		}
	}
626 627 628
	rtnl_unlock();

	mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);
629
	mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt);
630
	goto done;
631

632
err_add_intf:
633 634
	wiphy_unregister(adapter->wiphy);
	wiphy_free(adapter->wiphy);
635
err_init_fw:
D
Daniel Drake 已提交
636 637
	if (adapter->if_ops.disable_int)
		adapter->if_ops.disable_int(adapter);
638
err_dnld_fw:
639 640
	mwifiex_dbg(adapter, ERROR,
		    "info: %s: unregister device\n", __func__);
641 642 643
	if (adapter->if_ops.unregister_dev)
		adapter->if_ops.unregister_dev(adapter);

644 645 646
	adapter->surprise_removed = true;
	mwifiex_terminate_workqueue(adapter);

647
	if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
648
		pr_debug("info: %s: shutdown mwifiex\n", __func__);
649
		mwifiex_shutdown_drv(adapter);
650
	}
651

652
	init_failed = true;
653
done:
654 655 656 657
	if (adapter->cal_data) {
		release_firmware(adapter->cal_data);
		adapter->cal_data = NULL;
	}
658 659 660 661 662 663
	if (adapter->firmware) {
		release_firmware(adapter->firmware);
		adapter->firmware = NULL;
	}
	if (init_failed)
		mwifiex_free_adapter(adapter);
664 665
	/* Tell all current and future waiters we're finished */
	complete_all(fw_done);
666 667 668 669 670 671
	return;
}

/*
 * This function initializes the hardware and gets firmware.
 */
672 673
static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter,
			      bool req_fw_nowait)
674 675 676
{
	int ret;

677 678 679 680 681 682 683 684 685 686 687
	/* Override default firmware with manufacturing one if
	 * manufacturing mode is enabled
	 */
	if (mfg_mode) {
		if (strlcpy(adapter->fw_name, MFG_FIRMWARE,
			    sizeof(adapter->fw_name)) >=
			    sizeof(adapter->fw_name)) {
			pr_err("%s: fw_name too long!\n", __func__);
			return -1;
		}
	}
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706

	if (req_fw_nowait) {
		ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name,
					      adapter->dev, GFP_KERNEL, adapter,
					      mwifiex_fw_dpc);
		if (ret < 0)
			mwifiex_dbg(adapter, ERROR,
				    "request_firmware_nowait error %d\n", ret);
	} else {
		ret = request_firmware(&adapter->firmware,
				       adapter->fw_name,
				       adapter->dev);
		if (ret < 0)
			mwifiex_dbg(adapter, ERROR,
				    "request_firmware error %d\n", ret);
		else
			mwifiex_fw_dpc(adapter->firmware, (void *)adapter);
	}

707 708 709 710 711 712 713 714 715 716 717
	return ret;
}

/*
 * CFG802.11 network device handler for open.
 *
 * Starts the data queue.
 */
static int
mwifiex_open(struct net_device *dev)
{
718 719
	netif_carrier_off(dev);

720 721 722 723 724 725 726 727 728
	return 0;
}

/*
 * CFG802.11 network device handler for close.
 */
static int
mwifiex_close(struct net_device *dev)
{
729 730 731
	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);

	if (priv->scan_request) {
732 733 734 735
		struct cfg80211_scan_info info = {
			.aborted = true,
		};

736 737
		mwifiex_dbg(priv->adapter, INFO,
			    "aborting scan on ndo_stop\n");
738
		cfg80211_scan_done(priv->scan_request, &info);
739
		priv->scan_request = NULL;
740
		priv->scan_aborting = true;
741 742
	}

743 744 745 746 747 748 749
	if (priv->sched_scanning) {
		mwifiex_dbg(priv->adapter, INFO,
			    "aborting bgscan on ndo_stop\n");
		mwifiex_stop_bg_scan(priv);
		cfg80211_sched_scan_stopped(priv->wdev.wiphy);
	}

750 751 752
	return 0;
}

753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
static bool
mwifiex_bypass_tx_queue(struct mwifiex_private *priv,
			struct sk_buff *skb)
{
	struct ethhdr *eth_hdr = (struct ethhdr *)skb->data;

	if (ntohs(eth_hdr->h_proto) == ETH_P_PAE ||
	    mwifiex_is_skb_mgmt_frame(skb) ||
	    (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA &&
	     ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
	     (ntohs(eth_hdr->h_proto) == ETH_P_TDLS))) {
		mwifiex_dbg(priv->adapter, DATA,
			    "bypass txqueue; eth type %#x, mgmt %d\n",
			     ntohs(eth_hdr->h_proto),
			     mwifiex_is_skb_mgmt_frame(skb));
		return true;
	}

	return false;
}
773 774 775 776 777
/*
 * Add buffer into wmm tx queue and queue work to transmit it.
 */
int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb)
{
A
Avinash Patil 已提交
778 779 780 781 782 783 784
	struct netdev_queue *txq;
	int index = mwifiex_1d_to_wmm_queue[skb->priority];

	if (atomic_inc_return(&priv->wmm_tx_pending[index]) >= MAX_TX_PENDING) {
		txq = netdev_get_tx_queue(priv->netdev, index);
		if (!netif_tx_queue_stopped(txq)) {
			netif_tx_stop_queue(txq);
785 786
			mwifiex_dbg(priv->adapter, DATA,
				    "stop queue: %d\n", index);
A
Avinash Patil 已提交
787 788 789
		}
	}

790 791 792 793 794 795 796 797
	if (mwifiex_bypass_tx_queue(priv, skb)) {
		atomic_inc(&priv->adapter->tx_pending);
		atomic_inc(&priv->adapter->bypass_tx_pending);
		mwifiex_wmm_add_buf_bypass_txqueue(priv, skb);
	 } else {
		atomic_inc(&priv->adapter->tx_pending);
		mwifiex_wmm_add_buf_txqueue(priv, skb);
	 }
798

799
	mwifiex_queue_main_work(priv->adapter);
800 801 802 803

	return 0;
}

804
struct sk_buff *
805
mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
806
				struct sk_buff *skb, u8 flag, u64 *cookie)
807 808 809 810 811 812 813 814 815 816 817
{
	struct sk_buff *orig_skb = skb;
	struct mwifiex_txinfo *tx_info, *orig_tx_info;

	skb = skb_clone(skb, GFP_ATOMIC);
	if (skb) {
		unsigned long flags;
		int id;

		spin_lock_irqsave(&priv->ack_status_lock, flags);
		id = idr_alloc(&priv->ack_status_frames, orig_skb,
818
			       1, 0x10, GFP_ATOMIC);
819 820 821 822 823 824 825 826 827
		spin_unlock_irqrestore(&priv->ack_status_lock, flags);

		if (id >= 0) {
			tx_info = MWIFIEX_SKB_TXCB(skb);
			tx_info->ack_frame_id = id;
			tx_info->flags |= flag;
			orig_tx_info = MWIFIEX_SKB_TXCB(orig_skb);
			orig_tx_info->ack_frame_id = id;
			orig_tx_info->flags |= flag;
828 829 830 831

			if (flag == MWIFIEX_BUF_FLAG_ACTION_TX_STATUS && cookie)
				orig_tx_info->cookie = *cookie;

832 833 834 835 836 837 838 839 840 841 842 843 844 845
		} else if (skb_shared(skb)) {
			kfree_skb(orig_skb);
		} else {
			kfree_skb(skb);
			skb = orig_skb;
		}
	} else {
		/* couldn't clone -- lose tx status ... */
		skb = orig_skb;
	}

	return skb;
}

846 847 848 849 850 851 852
/*
 * CFG802.11 network device handler for data transmission.
 */
static int
mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
853
	struct sk_buff *new_skb;
854
	struct mwifiex_txinfo *tx_info;
855
	bool multicast;
856

857 858 859
	mwifiex_dbg(priv->adapter, DATA,
		    "data: %lu BSS(%d-%d): Data <= kernel\n",
		    jiffies, priv->bss_type, priv->bss_num);
860 861

	if (priv->adapter->surprise_removed) {
862
		kfree_skb(skb);
863 864 865 866
		priv->stats.tx_dropped++;
		return 0;
	}
	if (!skb->len || (skb->len > ETH_FRAME_LEN)) {
867 868
		mwifiex_dbg(priv->adapter, ERROR,
			    "Tx: bad skb len %d\n", skb->len);
869
		kfree_skb(skb);
870 871 872 873
		priv->stats.tx_dropped++;
		return 0;
	}
	if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN) {
874 875 876
		mwifiex_dbg(priv->adapter, DATA,
			    "data: Tx: insufficient skb headroom %d\n",
			    skb_headroom(skb));
877 878 879 880
		/* Insufficient skb headroom - allocate a new skb */
		new_skb =
			skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN);
		if (unlikely(!new_skb)) {
881 882
			mwifiex_dbg(priv->adapter, ERROR,
				    "Tx: cannot alloca new_skb\n");
883
			kfree_skb(skb);
884 885 886 887 888
			priv->stats.tx_dropped++;
			return 0;
		}
		kfree_skb(skb);
		skb = new_skb;
889 890 891
		mwifiex_dbg(priv->adapter, INFO,
			    "info: new skb headroomd %d\n",
			    skb_headroom(skb));
892 893 894
	}

	tx_info = MWIFIEX_SKB_TXCB(skb);
A
Amitkumar Karwar 已提交
895
	memset(tx_info, 0, sizeof(*tx_info));
896 897
	tx_info->bss_num = priv->bss_num;
	tx_info->bss_type = priv->bss_type;
898
	tx_info->pkt_len = skb->len;
A
Avinash Patil 已提交
899

900 901 902 903 904 905 906
	multicast = is_multicast_ether_addr(skb->data);

	if (unlikely(!multicast && skb->sk &&
		     skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS &&
		     priv->adapter->fw_api_ver == MWIFIEX_FW_V15))
		skb = mwifiex_clone_skb_for_tx_status(priv,
						      skb,
907
					MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS, NULL);
908

A
Avinash Patil 已提交
909 910 911 912 913 914 915
	/* Record the current time the packet was queued; used to
	 * determine the amount of time the packet was queued in
	 * the driver before it was sent to the firmware.
	 * The delay is then sent along with the packet to the
	 * firmware for aggregate delay calculation for stats and
	 * MSDU lifetime expiry.
	 */
916
	__net_timestamp(skb);
917

A
Avinash Patil 已提交
918 919 920 921 922 923 924
	if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
	    priv->bss_type == MWIFIEX_BSS_TYPE_STA &&
	    !ether_addr_equal_unaligned(priv->cfg_bssid, skb->data)) {
		if (priv->adapter->auto_tdls && priv->check_tdls_tx)
			mwifiex_tdls_check_tx(priv, skb);
	}

925
	mwifiex_queue_tx_pkt(priv, skb);
926 927 928 929 930 931 932 933 934 935 936

	return 0;
}

/*
 * CFG802.11 network device handler for setting MAC address.
 */
static int
mwifiex_set_mac_address(struct net_device *dev, void *addr)
{
	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
937
	struct sockaddr *hw_addr = addr;
938
	int ret;
939 940 941

	memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN);

942
	/* Send request to firmware */
943 944
	ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_MAC_ADDRESS,
			       HostCmd_ACT_GEN_SET, 0, NULL, true);
945 946 947 948

	if (!ret)
		memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN);
	else
949 950
		mwifiex_dbg(priv->adapter, ERROR,
			    "set mac address failed: ret=%d\n", ret);
951

952 953
	memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);

954
	return ret;
955 956 957 958 959 960 961 962
}

/*
 * CFG802.11 network device handler for setting multicast list.
 */
static void mwifiex_set_multicast_list(struct net_device *dev)
{
	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
963 964 965 966 967 968 969 970 971
	struct mwifiex_multicast_list mcast_list;

	if (dev->flags & IFF_PROMISC) {
		mcast_list.mode = MWIFIEX_PROMISC_MODE;
	} else if (dev->flags & IFF_ALLMULTI ||
		   netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) {
		mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
	} else {
		mcast_list.mode = MWIFIEX_MULTICAST_MODE;
972 973
		mcast_list.num_multicast_addr =
			mwifiex_copy_mcast_addr(&mcast_list, dev);
974 975
	}
	mwifiex_request_set_multicast_list(priv, &mcast_list);
976 977 978 979 980 981 982 983 984 985 986
}

/*
 * CFG802.11 network device handler for transmission timeout.
 */
static void
mwifiex_tx_timeout(struct net_device *dev)
{
	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);

	priv->num_tx_timeout++;
987
	priv->tx_timeout_cnt++;
988 989 990 991
	mwifiex_dbg(priv->adapter, ERROR,
		    "%lu : Tx timeout(#%d), bss_type-num = %d-%d\n",
		    jiffies, priv->tx_timeout_cnt, priv->bss_type,
		    priv->bss_num);
992 993 994 995
	mwifiex_set_trans_start(dev);

	if (priv->tx_timeout_cnt > TX_TIMEOUT_THRESHOLD &&
	    priv->adapter->if_ops.card_reset) {
996 997 998
		mwifiex_dbg(priv->adapter, ERROR,
			    "tx_timeout_cnt exceeds threshold.\t"
			    "Triggering card reset!\n");
999 1000
		priv->adapter->if_ops.card_reset(priv->adapter);
	}
1001 1002
}

1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter)
{
	struct usb_card_rec *card = adapter->card;
	struct mwifiex_private *priv;
	u16 tx_buf_size;
	int i, ret;

	card->mc_resync_flag = true;
	for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) {
		if (atomic_read(&card->port[i].tx_data_urb_pending)) {
			mwifiex_dbg(adapter, WARN, "pending data urb in sys\n");
			return;
		}
	}

	card->mc_resync_flag = false;
	tx_buf_size = 0xffff;
	priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
	ret = mwifiex_send_cmd(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF,
			       HostCmd_ACT_GEN_SET, 0, &tx_buf_size, false);
	if (ret)
		mwifiex_dbg(adapter, ERROR,
			    "send reconfig tx buf size cmd err\n");
}
EXPORT_SYMBOL_GPL(mwifiex_multi_chan_resync);

1029
int mwifiex_drv_info_dump(struct mwifiex_adapter *adapter, void **drv_info)
1030 1031 1032 1033 1034 1035 1036 1037 1038
{
	void *p;
	char drv_version[64];
	struct usb_card_rec *cardp;
	struct sdio_mmc_card *sdio_card;
	struct mwifiex_private *priv;
	int i, idx;
	struct netdev_queue *txq;
	struct mwifiex_debug_info *debug_info;
1039
	void *drv_info_dump;
1040

1041
	mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n");
1042

1043 1044
	/* memory allocate here should be free in mwifiex_upload_device_dump*/
	drv_info_dump = vzalloc(MWIFIEX_DRV_INFO_SIZE_MAX);
1045

1046 1047
	if (!drv_info_dump)
		return 0;
1048

1049
	p = (char *)(drv_info_dump);
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
	p += sprintf(p, "driver_name = " "\"mwifiex\"\n");

	mwifiex_drv_get_driver_version(adapter, drv_version,
				       sizeof(drv_version) - 1);
	p += sprintf(p, "driver_version = %s\n", drv_version);

	if (adapter->iface_type == MWIFIEX_USB) {
		cardp = (struct usb_card_rec *)adapter->card;
		p += sprintf(p, "tx_cmd_urb_pending = %d\n",
			     atomic_read(&cardp->tx_cmd_urb_pending));
1060 1061 1062 1063
		p += sprintf(p, "tx_data_urb_pending_port_0 = %d\n",
			     atomic_read(&cardp->port[0].tx_data_urb_pending));
		p += sprintf(p, "tx_data_urb_pending_port_1 = %d\n",
			     atomic_read(&cardp->port[1].tx_data_urb_pending));
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
		p += sprintf(p, "rx_cmd_urb_pending = %d\n",
			     atomic_read(&cardp->rx_cmd_urb_pending));
		p += sprintf(p, "rx_data_urb_pending = %d\n",
			     atomic_read(&cardp->rx_data_urb_pending));
	}

	p += sprintf(p, "tx_pending = %d\n",
		     atomic_read(&adapter->tx_pending));
	p += sprintf(p, "rx_pending = %d\n",
		     atomic_read(&adapter->rx_pending));

	if (adapter->iface_type == MWIFIEX_SDIO) {
		sdio_card = (struct sdio_mmc_card *)adapter->card;
		p += sprintf(p, "\nmp_rd_bitmap=0x%x curr_rd_port=0x%x\n",
			     sdio_card->mp_rd_bitmap, sdio_card->curr_rd_port);
		p += sprintf(p, "mp_wr_bitmap=0x%x curr_wr_port=0x%x\n",
			     sdio_card->mp_wr_bitmap, sdio_card->curr_wr_port);
	}

	for (i = 0; i < adapter->priv_num; i++) {
		if (!adapter->priv[i] || !adapter->priv[i]->netdev)
			continue;
		priv = adapter->priv[i];
		p += sprintf(p, "\n[interface  : \"%s\"]\n",
			     priv->netdev->name);
		p += sprintf(p, "wmm_tx_pending[0] = %d\n",
			     atomic_read(&priv->wmm_tx_pending[0]));
		p += sprintf(p, "wmm_tx_pending[1] = %d\n",
			     atomic_read(&priv->wmm_tx_pending[1]));
		p += sprintf(p, "wmm_tx_pending[2] = %d\n",
			     atomic_read(&priv->wmm_tx_pending[2]));
		p += sprintf(p, "wmm_tx_pending[3] = %d\n",
			     atomic_read(&priv->wmm_tx_pending[3]));
		p += sprintf(p, "media_state=\"%s\"\n", !priv->media_connected ?
			     "Disconnected" : "Connected");
		p += sprintf(p, "carrier %s\n", (netif_carrier_ok(priv->netdev)
			     ? "on" : "off"));
		for (idx = 0; idx < priv->netdev->num_tx_queues; idx++) {
			txq = netdev_get_tx_queue(priv->netdev, idx);
			p += sprintf(p, "tx queue %d:%s  ", idx,
				     netif_tx_queue_stopped(txq) ?
				     "stopped" : "started");
		}
		p += sprintf(p, "\n%s: num_tx_timeout = %d\n",
			     priv->netdev->name, priv->num_tx_timeout);
	}

1111 1112 1113 1114 1115
	if (adapter->iface_type == MWIFIEX_SDIO ||
	    adapter->iface_type == MWIFIEX_PCIE) {
		p += sprintf(p, "\n=== %s register dump===\n",
			     adapter->iface_type == MWIFIEX_SDIO ?
							"SDIO" : "PCIE");
1116 1117 1118
		if (adapter->if_ops.reg_dump)
			p += adapter->if_ops.reg_dump(adapter, p);
	}
1119
	p += sprintf(p, "\n=== more debug information\n");
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
	debug_info = kzalloc(sizeof(*debug_info), GFP_KERNEL);
	if (debug_info) {
		for (i = 0; i < adapter->priv_num; i++) {
			if (!adapter->priv[i] || !adapter->priv[i]->netdev)
				continue;
			priv = adapter->priv[i];
			mwifiex_get_debug_info(priv, debug_info);
			p += mwifiex_debug_info_to_buffer(priv, p, debug_info);
			break;
		}
		kfree(debug_info);
	}

1133
	mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n");
1134 1135
	*drv_info = drv_info_dump;
	return p - drv_info_dump;
1136
}
1137
EXPORT_SYMBOL_GPL(mwifiex_drv_info_dump);
1138

1139 1140
void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info,
				int drv_info_size)
1141 1142 1143 1144 1145
{
	u8 idx, *dump_data, *fw_dump_ptr;
	u32 dump_len;

	dump_len = (strlen("========Start dump driverinfo========\n") +
1146
		       drv_info_size +
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175
		       strlen("\n========End dump========\n"));

	for (idx = 0; idx < adapter->num_mem_types; idx++) {
		struct memory_type_mapping *entry =
				&adapter->mem_type_mapping_tbl[idx];

		if (entry->mem_ptr) {
			dump_len += (strlen("========Start dump ") +
					strlen(entry->mem_name) +
					strlen("========\n") +
					(entry->mem_size + 1) +
					strlen("\n========End dump========\n"));
		}
	}

	dump_data = vzalloc(dump_len + 1);
	if (!dump_data)
		goto done;

	fw_dump_ptr = dump_data;

	/* Dump all the memory data into single file, a userspace script will
	 * be used to split all the memory data to multiple files
	 */
	mwifiex_dbg(adapter, MSG,
		    "== mwifiex dump information to /sys/class/devcoredump start");

	strcpy(fw_dump_ptr, "========Start dump driverinfo========\n");
	fw_dump_ptr += strlen("========Start dump driverinfo========\n");
1176 1177
	memcpy(fw_dump_ptr, drv_info, drv_info_size);
	fw_dump_ptr += drv_info_size;
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214
	strcpy(fw_dump_ptr, "\n========End dump========\n");
	fw_dump_ptr += strlen("\n========End dump========\n");

	for (idx = 0; idx < adapter->num_mem_types; idx++) {
		struct memory_type_mapping *entry =
					&adapter->mem_type_mapping_tbl[idx];

		if (entry->mem_ptr) {
			strcpy(fw_dump_ptr, "========Start dump ");
			fw_dump_ptr += strlen("========Start dump ");

			strcpy(fw_dump_ptr, entry->mem_name);
			fw_dump_ptr += strlen(entry->mem_name);

			strcpy(fw_dump_ptr, "========\n");
			fw_dump_ptr += strlen("========\n");

			memcpy(fw_dump_ptr, entry->mem_ptr, entry->mem_size);
			fw_dump_ptr += entry->mem_size;

			strcpy(fw_dump_ptr, "\n========End dump========\n");
			fw_dump_ptr += strlen("\n========End dump========\n");
		}
	}

	/* device dump data will be free in device coredump release function
	 * after 5 min
	 */
	dev_coredumpv(adapter->dev, dump_data, dump_len, GFP_KERNEL);
	mwifiex_dbg(adapter, MSG,
		    "== mwifiex dump information to /sys/class/devcoredump end");

done:
	for (idx = 0; idx < adapter->num_mem_types; idx++) {
		struct memory_type_mapping *entry =
			&adapter->mem_type_mapping_tbl[idx];

1215 1216
		vfree(entry->mem_ptr);
		entry->mem_ptr = NULL;
1217 1218 1219
		entry->mem_size = 0;
	}

1220
	vfree(drv_info);
1221 1222 1223
}
EXPORT_SYMBOL_GPL(mwifiex_upload_device_dump);

1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
/*
 * CFG802.11 network device handler for statistics retrieval.
 */
static struct net_device_stats *mwifiex_get_stats(struct net_device *dev)
{
	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);

	return &priv->stats;
}

A
Avinash Patil 已提交
1234
static u16
1235
mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
1236
				void *accel_priv, select_queue_fallback_t fallback)
A
Avinash Patil 已提交
1237
{
1238
	skb->priority = cfg80211_classify8021d(skb, NULL);
A
Avinash Patil 已提交
1239 1240 1241
	return mwifiex_1d_to_wmm_queue[skb->priority];
}

1242 1243 1244 1245 1246 1247
/* Network device handlers */
static const struct net_device_ops mwifiex_netdev_ops = {
	.ndo_open = mwifiex_open,
	.ndo_stop = mwifiex_close,
	.ndo_start_xmit = mwifiex_hard_start_xmit,
	.ndo_set_mac_address = mwifiex_set_mac_address,
1248
	.ndo_validate_addr = eth_validate_addr,
1249 1250
	.ndo_tx_timeout = mwifiex_tx_timeout,
	.ndo_get_stats = mwifiex_get_stats,
1251
	.ndo_set_rx_mode = mwifiex_set_multicast_list,
A
Avinash Patil 已提交
1252
	.ndo_select_queue = mwifiex_netdev_select_wmm_queue,
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
};

/*
 * This function initializes the private structure parameters.
 *
 * The following wait queues are initialized -
 *      - IOCTL wait queue
 *      - Command wait queue
 *      - Statistics wait queue
 *
 * ...and the following default parameters are set -
 *      - Current key index     : Set to 0
 *      - Rate index            : Set to auto
 *      - Media connected       : Set to disconnected
 *      - Adhoc link sensed     : Set to false
 *      - Nick name             : Set to null
 *      - Number of Tx timeout  : Set to 0
 *      - Device address        : Set to current address
1271
 *      - Rx histogram statistc : Set to 0
1272 1273 1274
 *
 * In addition, the CFG80211 work queue is also created.
 */
1275
void mwifiex_init_priv_params(struct mwifiex_private *priv,
1276
			      struct net_device *dev)
1277 1278
{
	dev->netdev_ops = &mwifiex_netdev_ops;
1279
	dev->destructor = free_netdev;
1280 1281 1282
	/* Initialize private structure */
	priv->current_key_index = 0;
	priv->media_connected = false;
A
Avinash Patil 已提交
1283 1284
	memset(priv->mgmt_ie, 0,
	       sizeof(struct mwifiex_ie) * MAX_MGMT_IE_INDEX);
1285 1286 1287
	priv->beacon_idx = MWIFIEX_AUTO_IDX_MASK;
	priv->proberesp_idx = MWIFIEX_AUTO_IDX_MASK;
	priv->assocresp_idx = MWIFIEX_AUTO_IDX_MASK;
1288
	priv->gen_idx = MWIFIEX_AUTO_IDX_MASK;
1289
	priv->num_tx_timeout = 0;
1290
	ether_addr_copy(priv->curr_addr, priv->adapter->perm_addr);
1291
	memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);
1292 1293 1294 1295 1296 1297 1298

	if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
	    GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
		priv->hist_data = kmalloc(sizeof(*priv->hist_data), GFP_KERNEL);
		if (priv->hist_data)
			mwifiex_hist_data_reset(priv);
	}
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315
}

/*
 * This function check if command is pending.
 */
int is_command_pending(struct mwifiex_adapter *adapter)
{
	unsigned long flags;
	int is_cmd_pend_q_empty;

	spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
	is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q);
	spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);

	return !is_cmd_pend_q_empty;
}

1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330
/*
 * This is the RX work queue function.
 *
 * It handles the RX operations.
 */
static void mwifiex_rx_work_queue(struct work_struct *work)
{
	struct mwifiex_adapter *adapter =
		container_of(work, struct mwifiex_adapter, rx_work);

	if (adapter->surprise_removed)
		return;
	mwifiex_process_rx(adapter);
}

1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346
/*
 * This is the main work queue function.
 *
 * It handles the main process, which in turn handles the complete
 * driver operations.
 */
static void mwifiex_main_work_queue(struct work_struct *work)
{
	struct mwifiex_adapter *adapter =
		container_of(work, struct mwifiex_adapter, main_work);

	if (adapter->surprise_removed)
		return;
	mwifiex_main_process(adapter);
}

1347 1348 1349 1350
/*
 * This function gets called during PCIe function level reset. Required
 * code is extracted from mwifiex_remove_card()
 */
1351
int
1352
mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
1353 1354 1355 1356
{
	struct mwifiex_private *priv;
	int i;

1357 1358 1359
	if (!adapter)
		goto exit_return;

1360 1361 1362
	wait_for_completion(adapter->fw_done);
	/* Caller should ensure we aren't suspending while this happens */
	reinit_completion(adapter->fw_done);
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388

	priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
	mwifiex_deauthenticate(priv, NULL);

	/* We can no longer handle interrupts once we start doing the teardown
	 * below.
	 */
	if (adapter->if_ops.disable_int)
		adapter->if_ops.disable_int(adapter);

	adapter->surprise_removed = true;
	mwifiex_terminate_workqueue(adapter);

	/* Stop data */
	for (i = 0; i < adapter->priv_num; i++) {
		priv = adapter->priv[i];
		if (priv && priv->netdev) {
			mwifiex_stop_net_dev_queue(priv->netdev, adapter);
			if (netif_carrier_ok(priv->netdev))
				netif_carrier_off(priv->netdev);
			netif_device_detach(priv->netdev);
		}
	}

	mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n");

1389
	mwifiex_shutdown_drv(adapter);
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416
	if (adapter->if_ops.down_dev)
		adapter->if_ops.down_dev(adapter);

	mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n");
	if (atomic_read(&adapter->rx_pending) ||
	    atomic_read(&adapter->tx_pending) ||
	    atomic_read(&adapter->cmd_pending)) {
		mwifiex_dbg(adapter, ERROR,
			    "rx_pending=%d, tx_pending=%d,\t"
			    "cmd_pending=%d\n",
			    atomic_read(&adapter->rx_pending),
			    atomic_read(&adapter->tx_pending),
			    atomic_read(&adapter->cmd_pending));
	}

	for (i = 0; i < adapter->priv_num; i++) {
		priv = adapter->priv[i];
		if (!priv)
			continue;
		rtnl_lock();
		if (priv->netdev &&
		    priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED)
			mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
		rtnl_unlock();
	}

	mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
1417
exit_return:
1418 1419
	return 0;
}
1420
EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw);
1421 1422 1423 1424

/* This function gets called during PCIe function level reset. Required
 * code is extracted from mwifiex_add_card()
 */
1425 1426
int
mwifiex_reinit_sw(struct mwifiex_adapter *adapter)
1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474
{
	mwifiex_init_lock_list(adapter);
	if (adapter->if_ops.up_dev)
		adapter->if_ops.up_dev(adapter);

	adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
	adapter->surprise_removed = false;
	init_waitqueue_head(&adapter->init_wait_q);
	adapter->is_suspended = false;
	adapter->hs_activated = false;
	init_waitqueue_head(&adapter->hs_activate_wait_q);
	init_waitqueue_head(&adapter->cmd_wait_q.wait);
	adapter->cmd_wait_q.status = 0;
	adapter->scan_wait_q_woken = false;

	if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB)
		adapter->rx_work_enabled = true;

	adapter->workqueue =
		alloc_workqueue("MWIFIEX_WORK_QUEUE",
				WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
	if (!adapter->workqueue)
		goto err_kmalloc;

	INIT_WORK(&adapter->main_work, mwifiex_main_work_queue);

	if (adapter->rx_work_enabled) {
		adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE",
							WQ_HIGHPRI |
							WQ_MEM_RECLAIM |
							WQ_UNBOUND, 1);
		if (!adapter->rx_workqueue)
			goto err_kmalloc;
		INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue);
	}

	/* Register the device. Fill up the private data structure with
	 * relevant information from the card. Some code extracted from
	 * mwifiex_register_dev()
	 */
	mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__);

	if (mwifiex_init_hw_fw(adapter, false)) {
		mwifiex_dbg(adapter, ERROR,
			    "%s: firmware init failed\n", __func__);
		goto err_init_fw;
	}
	mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
1475 1476

	complete_all(adapter->fw_done);
1477 1478 1479 1480 1481 1482
	return 0;

err_init_fw:
	mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__);
	if (adapter->if_ops.unregister_dev)
		adapter->if_ops.unregister_dev(adapter);
1483 1484 1485 1486

err_kmalloc:
	adapter->surprise_removed = true;
	mwifiex_terminate_workqueue(adapter);
1487 1488 1489
	if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
		mwifiex_dbg(adapter, ERROR,
			    "info: %s: shutdown mwifiex\n", __func__);
1490
		mwifiex_shutdown_drv(adapter);
1491 1492
	}

1493
	complete_all(adapter->fw_done);
1494 1495 1496 1497
	mwifiex_dbg(adapter, INFO, "%s, error\n", __func__);

	return -1;
}
1498
EXPORT_SYMBOL_GPL(mwifiex_reinit_sw);
1499

1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515
static irqreturn_t mwifiex_irq_wakeup_handler(int irq, void *priv)
{
	struct mwifiex_adapter *adapter = priv;

	if (adapter->irq_wakeup >= 0) {
		dev_dbg(adapter->dev, "%s: wake by wifi", __func__);
		adapter->wake_by_wifi = true;
		disable_irq_nosync(irq);
	}

	/* Notify PM core we are wakeup source */
	pm_wakeup_event(adapter->dev, 0);

	return IRQ_HANDLED;
}

1516 1517
static void mwifiex_probe_of(struct mwifiex_adapter *adapter)
{
1518
	int ret;
1519 1520 1521 1522 1523 1524
	struct device *dev = adapter->dev;

	if (!dev->of_node)
		return;

	adapter->dt_node = dev->of_node;
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548
	adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0);
	if (!adapter->irq_wakeup) {
		dev_info(dev, "fail to parse irq_wakeup from device tree\n");
		return;
	}

	ret = devm_request_irq(dev, adapter->irq_wakeup,
			       mwifiex_irq_wakeup_handler, IRQF_TRIGGER_LOW,
			       "wifi_wake", adapter);
	if (ret) {
		dev_err(dev, "Failed to request irq_wakeup %d (%d)\n",
			adapter->irq_wakeup, ret);
		goto err_exit;
	}

	disable_irq(adapter->irq_wakeup);
	if (device_init_wakeup(dev, true)) {
		dev_err(dev, "fail to init wakeup for mwifiex\n");
		goto err_exit;
	}
	return;

err_exit:
	adapter->irq_wakeup = 0;
1549 1550
}

1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564
/*
 * This function adds the card.
 *
 * This function follows the following major steps to set up the device -
 *      - Initialize software. This includes probing the card, registering
 *        the interface operations table, and allocating/initializing the
 *        adapter structure
 *      - Set up the netlink socket
 *      - Create and start the main work queue
 *      - Register the device
 *      - Initialize firmware and hardware
 *      - Add logical interfaces
 */
int
1565
mwifiex_add_card(void *card, struct completion *fw_done,
1566 1567
		 struct mwifiex_if_ops *if_ops, u8 iface_type,
		 struct device *dev)
1568
{
1569
	struct mwifiex_adapter *adapter;
1570

1571
	if (mwifiex_register(card, if_ops, (void **)&adapter)) {
1572 1573 1574 1575
		pr_err("%s: software init failed\n", __func__);
		goto err_init_sw;
	}

1576
	adapter->dev = dev;
1577 1578
	mwifiex_probe_of(adapter);

1579
	adapter->iface_type = iface_type;
1580
	adapter->fw_done = fw_done;
1581

1582 1583 1584 1585 1586 1587
	adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
	adapter->surprise_removed = false;
	init_waitqueue_head(&adapter->init_wait_q);
	adapter->is_suspended = false;
	adapter->hs_activated = false;
	init_waitqueue_head(&adapter->hs_activate_wait_q);
1588 1589
	init_waitqueue_head(&adapter->cmd_wait_q.wait);
	adapter->cmd_wait_q.status = 0;
1590
	adapter->scan_wait_q_woken = false;
1591

1592
	if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) {
1593 1594 1595 1596
		adapter->rx_work_enabled = true;
		pr_notice("rx work enabled, cpus %d\n", num_possible_cpus());
	}

1597 1598 1599
	adapter->workqueue =
		alloc_workqueue("MWIFIEX_WORK_QUEUE",
				WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
1600 1601 1602 1603
	if (!adapter->workqueue)
		goto err_kmalloc;

	INIT_WORK(&adapter->main_work, mwifiex_main_work_queue);
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615

	if (adapter->rx_work_enabled) {
		adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE",
							WQ_HIGHPRI |
							WQ_MEM_RECLAIM |
							WQ_UNBOUND, 1);
		if (!adapter->rx_workqueue)
			goto err_kmalloc;

		INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue);
	}

1616
	/* Register the device. Fill up the private data structure with relevant
D
Daniel Drake 已提交
1617
	   information from the card. */
1618 1619 1620 1621 1622
	if (adapter->if_ops.register_dev(adapter)) {
		pr_err("%s: failed to register mwifiex device\n", __func__);
		goto err_registerdev;
	}

1623
	if (mwifiex_init_hw_fw(adapter, true)) {
1624 1625 1626
		pr_err("%s: firmware init failed\n", __func__);
		goto err_init_fw;
	}
1627

1628 1629 1630 1631
	return 0;

err_init_fw:
	pr_debug("info: %s: unregister device\n", __func__);
1632 1633
	if (adapter->if_ops.unregister_dev)
		adapter->if_ops.unregister_dev(adapter);
1634 1635 1636
err_registerdev:
	adapter->surprise_removed = true;
	mwifiex_terminate_workqueue(adapter);
1637 1638 1639 1640
	if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
		pr_debug("info: %s: shutdown mwifiex\n", __func__);
		mwifiex_shutdown_drv(adapter);
	}
1641
err_kmalloc:
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660
	mwifiex_free_adapter(adapter);

err_init_sw:

	return -1;
}
EXPORT_SYMBOL_GPL(mwifiex_add_card);

/*
 * This function removes the card.
 *
 * This function follows the following major steps to remove the device -
 *      - Stop data traffic
 *      - Shutdown firmware
 *      - Remove the logical interfaces
 *      - Terminate the work queue
 *      - Unregister the device
 *      - Free the adapter structure
 */
1661
int mwifiex_remove_card(struct mwifiex_adapter *adapter)
1662 1663 1664 1665 1666 1667 1668
{
	struct mwifiex_private *priv = NULL;
	int i;

	if (!adapter)
		goto exit_remove;

D
Daniel Drake 已提交
1669 1670 1671 1672 1673
	/* We can no longer handle interrupts once we start doing the teardown
	 * below. */
	if (adapter->if_ops.disable_int)
		adapter->if_ops.disable_int(adapter);

1674 1675
	adapter->surprise_removed = true;

1676 1677
	mwifiex_terminate_workqueue(adapter);

1678 1679 1680
	/* Stop data */
	for (i = 0; i < adapter->priv_num; i++) {
		priv = adapter->priv[i];
1681
		if (priv && priv->netdev) {
A
Avinash Patil 已提交
1682
			mwifiex_stop_net_dev_queue(priv->netdev, adapter);
1683 1684 1685 1686 1687
			if (netif_carrier_ok(priv->netdev))
				netif_carrier_off(priv->netdev);
		}
	}

1688 1689
	mwifiex_dbg(adapter, CMD,
		    "cmd: calling mwifiex_shutdown_drv...\n");
1690

1691
	mwifiex_shutdown_drv(adapter);
1692 1693
	mwifiex_dbg(adapter, CMD,
		    "cmd: mwifiex_shutdown_drv done\n");
1694 1695
	if (atomic_read(&adapter->rx_pending) ||
	    atomic_read(&adapter->tx_pending) ||
1696
	    atomic_read(&adapter->cmd_pending)) {
1697 1698 1699 1700 1701 1702
		mwifiex_dbg(adapter, ERROR,
			    "rx_pending=%d, tx_pending=%d,\t"
			    "cmd_pending=%d\n",
			    atomic_read(&adapter->rx_pending),
			    atomic_read(&adapter->tx_pending),
			    atomic_read(&adapter->cmd_pending));
1703 1704
	}

1705 1706 1707 1708 1709 1710 1711
	for (i = 0; i < adapter->priv_num; i++) {
		priv = adapter->priv[i];

		if (!priv)
			continue;

		rtnl_lock();
1712 1713 1714
		if (priv->netdev &&
		    priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED)
			mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
1715 1716 1717
		rtnl_unlock();
	}

1718 1719
	wiphy_unregister(adapter->wiphy);
	wiphy_free(adapter->wiphy);
1720

1721
	/* Unregister device */
1722 1723
	mwifiex_dbg(adapter, INFO,
		    "info: unregister device\n");
1724 1725
	if (adapter->if_ops.unregister_dev)
		adapter->if_ops.unregister_dev(adapter);
1726
	/* Free adapter structure */
1727 1728
	mwifiex_dbg(adapter, INFO,
		    "info: free adapter\n");
1729 1730 1731 1732 1733 1734 1735
	mwifiex_free_adapter(adapter);

exit_remove:
	return 0;
}
EXPORT_SYMBOL_GPL(mwifiex_remove_card);

1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755
void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
		  const char *fmt, ...)
{
	struct va_format vaf;
	va_list args;

	if (!adapter->dev || !(adapter->debug_mask & mask))
		return;

	va_start(args, fmt);

	vaf.fmt = fmt;
	vaf.va = &args;

	dev_info(adapter->dev, "%pV", &vaf);

	va_end(args);
}
EXPORT_SYMBOL_GPL(_mwifiex_dbg);

1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789
/*
 * This function initializes the module.
 *
 * The debug FS is also initialized if configured.
 */
static int
mwifiex_init_module(void)
{
#ifdef CONFIG_DEBUG_FS
	mwifiex_debugfs_init();
#endif
	return 0;
}

/*
 * This function cleans up the module.
 *
 * The debug FS is removed if available.
 */
static void
mwifiex_cleanup_module(void)
{
#ifdef CONFIG_DEBUG_FS
	mwifiex_debugfs_remove();
#endif
}

module_init(mwifiex_init_module);
module_exit(mwifiex_cleanup_module);

MODULE_AUTHOR("Marvell International Ltd.");
MODULE_DESCRIPTION("Marvell WiFi-Ex Driver version " VERSION);
MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL v2");