main.c (eea86b637a15bc4d4bd518b11330ac96baa6b73d) | main.c (b34939b9836950d261610132853311054b507247) |
---|---|
1/* 2 * Marvell Wireless LAN device driver: major functions 3 * 4 * Copyright (C) 2011-2014, 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 | 1/* 2 * Marvell Wireless LAN device driver: major functions 3 * 4 * Copyright (C) 2011-2014, 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 <linux/suspend.h> 21 |
|
20#include "main.h" 21#include "wmm.h" 22#include "cfg80211.h" 23#include "11n.h" 24 25#define VERSION "1.0" 26#define MFG_FIRMWARE "mwifiex_mfg.bin" 27 --- 114 unchanged lines hidden (view full) --- 142 for (i = 0 ; i < adapter->nd_info->n_matches ; i++) 143 kfree(adapter->nd_info->matches[i]); 144 kfree(adapter->nd_info); 145 adapter->nd_info = NULL; 146 } 147 148 kfree(adapter->regd); 149 | 22#include "main.h" 23#include "wmm.h" 24#include "cfg80211.h" 25#include "11n.h" 26 27#define VERSION "1.0" 28#define MFG_FIRMWARE "mwifiex_mfg.bin" 29 --- 114 unchanged lines hidden (view full) --- 144 for (i = 0 ; i < adapter->nd_info->n_matches ; i++) 145 kfree(adapter->nd_info->matches[i]); 146 kfree(adapter->nd_info); 147 adapter->nd_info = NULL; 148 } 149 150 kfree(adapter->regd); 151 |
150 vfree(adapter->chan_stats); | |
151 kfree(adapter); 152 return 0; 153} 154 155void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) 156{ 157 unsigned long flags; 158 --- 347 unchanged lines hidden (view full) --- 506 507/* 508 * This function gets firmware and initializes it. 509 * 510 * The main initialization steps followed are - 511 * - Download the correct firmware to card 512 * - Issue the init commands to firmware 513 */ | 152 kfree(adapter); 153 return 0; 154} 155 156void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) 157{ 158 unsigned long flags; 159 --- 347 unchanged lines hidden (view full) --- 507 508/* 509 * This function gets firmware and initializes it. 510 * 511 * The main initialization steps followed are - 512 * - Download the correct firmware to card 513 * - Issue the init commands to firmware 514 */ |
514static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) | 515static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context) |
515{ 516 int ret; 517 char fmt[64]; 518 struct mwifiex_adapter *adapter = context; 519 struct mwifiex_fw_image fw; 520 bool init_failed = false; 521 struct wireless_dev *wdev; 522 struct completion *fw_done = adapter->fw_done; --- 66 unchanged lines hidden (view full) --- 589 if (driver_mode) { 590 driver_mode &= MWIFIEX_DRIVER_MODE_BITMASK; 591 driver_mode |= MWIFIEX_DRIVER_MODE_STA; 592 } 593 594 rtnl_lock(); 595 /* Create station interface by default */ 596 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM, | 516{ 517 int ret; 518 char fmt[64]; 519 struct mwifiex_adapter *adapter = context; 520 struct mwifiex_fw_image fw; 521 bool init_failed = false; 522 struct wireless_dev *wdev; 523 struct completion *fw_done = adapter->fw_done; --- 66 unchanged lines hidden (view full) --- 590 if (driver_mode) { 591 driver_mode &= MWIFIEX_DRIVER_MODE_BITMASK; 592 driver_mode |= MWIFIEX_DRIVER_MODE_STA; 593 } 594 595 rtnl_lock(); 596 /* Create station interface by default */ 597 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM, |
597 NL80211_IFTYPE_STATION, NULL, NULL); | 598 NL80211_IFTYPE_STATION, NULL); |
598 if (IS_ERR(wdev)) { 599 mwifiex_dbg(adapter, ERROR, 600 "cannot create default STA interface\n"); 601 rtnl_unlock(); 602 goto err_add_intf; 603 } 604 605 if (driver_mode & MWIFIEX_DRIVER_MODE_UAP) { 606 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM, | 599 if (IS_ERR(wdev)) { 600 mwifiex_dbg(adapter, ERROR, 601 "cannot create default STA interface\n"); 602 rtnl_unlock(); 603 goto err_add_intf; 604 } 605 606 if (driver_mode & MWIFIEX_DRIVER_MODE_UAP) { 607 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM, |
607 NL80211_IFTYPE_AP, NULL, NULL); | 608 NL80211_IFTYPE_AP, NULL); |
608 if (IS_ERR(wdev)) { 609 mwifiex_dbg(adapter, ERROR, 610 "cannot create AP interface\n"); 611 rtnl_unlock(); 612 goto err_add_intf; 613 } 614 } 615 616 if (driver_mode & MWIFIEX_DRIVER_MODE_P2P) { 617 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM, | 609 if (IS_ERR(wdev)) { 610 mwifiex_dbg(adapter, ERROR, 611 "cannot create AP interface\n"); 612 rtnl_unlock(); 613 goto err_add_intf; 614 } 615 } 616 617 if (driver_mode & MWIFIEX_DRIVER_MODE_P2P) { 618 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM, |
618 NL80211_IFTYPE_P2P_CLIENT, NULL, 619 NULL); | 619 NL80211_IFTYPE_P2P_CLIENT, NULL); |
620 if (IS_ERR(wdev)) { 621 mwifiex_dbg(adapter, ERROR, 622 "cannot create p2p client interface\n"); 623 rtnl_unlock(); 624 goto err_add_intf; 625 } 626 } 627 rtnl_unlock(); 628 629 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); 630 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); 631 goto done; 632 633err_add_intf: | 620 if (IS_ERR(wdev)) { 621 mwifiex_dbg(adapter, ERROR, 622 "cannot create p2p client interface\n"); 623 rtnl_unlock(); 624 goto err_add_intf; 625 } 626 } 627 rtnl_unlock(); 628 629 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); 630 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); 631 goto done; 632 633err_add_intf: |
634 vfree(adapter->chan_stats); |
|
634 wiphy_unregister(adapter->wiphy); 635 wiphy_free(adapter->wiphy); 636err_init_fw: 637 if (adapter->if_ops.disable_int) 638 adapter->if_ops.disable_int(adapter); 639err_dnld_fw: 640 mwifiex_dbg(adapter, ERROR, 641 "info: %s: unregister device\n", __func__); --- 17 unchanged lines hidden (view full) --- 659 if (adapter->firmware) { 660 release_firmware(adapter->firmware); 661 adapter->firmware = NULL; 662 } 663 if (init_failed) 664 mwifiex_free_adapter(adapter); 665 /* Tell all current and future waiters we're finished */ 666 complete_all(fw_done); | 635 wiphy_unregister(adapter->wiphy); 636 wiphy_free(adapter->wiphy); 637err_init_fw: 638 if (adapter->if_ops.disable_int) 639 adapter->if_ops.disable_int(adapter); 640err_dnld_fw: 641 mwifiex_dbg(adapter, ERROR, 642 "info: %s: unregister device\n", __func__); --- 17 unchanged lines hidden (view full) --- 660 if (adapter->firmware) { 661 release_firmware(adapter->firmware); 662 adapter->firmware = NULL; 663 } 664 if (init_failed) 665 mwifiex_free_adapter(adapter); 666 /* Tell all current and future waiters we're finished */ 667 complete_all(fw_done); |
667 return; | 668 669 return init_failed ? -EIO : 0; |
668} 669 | 670} 671 |
672static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) 673{ 674 _mwifiex_fw_dpc(firmware, context); 675} 676 |
|
670/* | 677/* |
671 * This function initializes the hardware and gets firmware. | 678 * This function gets the firmware and (if called asynchronously) kicks off the 679 * HW init when done. |
672 */ 673static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, 674 bool req_fw_nowait) 675{ 676 int ret; 677 678 /* Override default firmware with manufacturing one if 679 * manufacturing mode is enabled --- 6 unchanged lines hidden (view full) --- 686 return -1; 687 } 688 } 689 690 if (req_fw_nowait) { 691 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, 692 adapter->dev, GFP_KERNEL, adapter, 693 mwifiex_fw_dpc); | 680 */ 681static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, 682 bool req_fw_nowait) 683{ 684 int ret; 685 686 /* Override default firmware with manufacturing one if 687 * manufacturing mode is enabled --- 6 unchanged lines hidden (view full) --- 694 return -1; 695 } 696 } 697 698 if (req_fw_nowait) { 699 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, 700 adapter->dev, GFP_KERNEL, adapter, 701 mwifiex_fw_dpc); |
694 if (ret < 0) 695 mwifiex_dbg(adapter, ERROR, 696 "request_firmware_nowait error %d\n", ret); | |
697 } else { 698 ret = request_firmware(&adapter->firmware, 699 adapter->fw_name, 700 adapter->dev); | 702 } else { 703 ret = request_firmware(&adapter->firmware, 704 adapter->fw_name, 705 adapter->dev); |
701 if (ret < 0) 702 mwifiex_dbg(adapter, ERROR, 703 "request_firmware error %d\n", ret); 704 else 705 mwifiex_fw_dpc(adapter->firmware, (void *)adapter); | |
706 } 707 | 706 } 707 |
708 if (ret < 0) 709 mwifiex_dbg(adapter, ERROR, "request_firmware%s error %d\n", 710 req_fw_nowait ? "_nowait" : "", ret); |
|
708 return ret; 709} 710 711/* 712 * CFG802.11 network device handler for open. 713 * 714 * Starts the data queue. 715 */ --- 24 unchanged lines hidden (view full) --- 740 priv->scan_request = NULL; 741 priv->scan_aborting = true; 742 } 743 744 if (priv->sched_scanning) { 745 mwifiex_dbg(priv->adapter, INFO, 746 "aborting bgscan on ndo_stop\n"); 747 mwifiex_stop_bg_scan(priv); | 711 return ret; 712} 713 714/* 715 * CFG802.11 network device handler for open. 716 * 717 * Starts the data queue. 718 */ --- 24 unchanged lines hidden (view full) --- 743 priv->scan_request = NULL; 744 priv->scan_aborting = true; 745 } 746 747 if (priv->sched_scanning) { 748 mwifiex_dbg(priv->adapter, INFO, 749 "aborting bgscan on ndo_stop\n"); 750 mwifiex_stop_bg_scan(priv); |
748 cfg80211_sched_scan_stopped(priv->wdev.wiphy); | 751 cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0); |
749 } 750 751 return 0; 752} 753 754static bool 755mwifiex_bypass_tx_queue(struct mwifiex_private *priv, 756 struct sk_buff *skb) --- 651 unchanged lines hidden (view full) --- 1408 if (!priv) 1409 continue; 1410 rtnl_lock(); 1411 if (priv->netdev && 1412 priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED) 1413 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); 1414 rtnl_unlock(); 1415 } | 752 } 753 754 return 0; 755} 756 757static bool 758mwifiex_bypass_tx_queue(struct mwifiex_private *priv, 759 struct sk_buff *skb) --- 651 unchanged lines hidden (view full) --- 1411 if (!priv) 1412 continue; 1413 rtnl_lock(); 1414 if (priv->netdev && 1415 priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED) 1416 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); 1417 rtnl_unlock(); 1418 } |
1419 vfree(adapter->chan_stats); |
|
1416 1417 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); 1418exit_return: 1419 return 0; 1420} 1421EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw); 1422 1423/* This function gets called during PCIe function level reset. Required 1424 * code is extracted from mwifiex_add_card() 1425 */ 1426int 1427mwifiex_reinit_sw(struct mwifiex_adapter *adapter) 1428{ | 1420 1421 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); 1422exit_return: 1423 return 0; 1424} 1425EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw); 1426 1427/* This function gets called during PCIe function level reset. Required 1428 * code is extracted from mwifiex_add_card() 1429 */ 1430int 1431mwifiex_reinit_sw(struct mwifiex_adapter *adapter) 1432{ |
1433 int ret; 1434 |
|
1429 mwifiex_init_lock_list(adapter); 1430 if (adapter->if_ops.up_dev) 1431 adapter->if_ops.up_dev(adapter); 1432 1433 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; 1434 adapter->surprise_removed = false; 1435 init_waitqueue_head(&adapter->init_wait_q); 1436 adapter->is_suspended = false; 1437 adapter->hs_activated = false; | 1435 mwifiex_init_lock_list(adapter); 1436 if (adapter->if_ops.up_dev) 1437 adapter->if_ops.up_dev(adapter); 1438 1439 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; 1440 adapter->surprise_removed = false; 1441 init_waitqueue_head(&adapter->init_wait_q); 1442 adapter->is_suspended = false; 1443 adapter->hs_activated = false; |
1444 adapter->is_cmd_timedout = 0; |
|
1438 init_waitqueue_head(&adapter->hs_activate_wait_q); 1439 init_waitqueue_head(&adapter->cmd_wait_q.wait); 1440 adapter->cmd_wait_q.status = 0; 1441 adapter->scan_wait_q_woken = false; 1442 1443 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) 1444 adapter->rx_work_enabled = true; 1445 --- 21 unchanged lines hidden (view full) --- 1467 */ 1468 mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__); 1469 1470 if (mwifiex_init_hw_fw(adapter, false)) { 1471 mwifiex_dbg(adapter, ERROR, 1472 "%s: firmware init failed\n", __func__); 1473 goto err_init_fw; 1474 } | 1445 init_waitqueue_head(&adapter->hs_activate_wait_q); 1446 init_waitqueue_head(&adapter->cmd_wait_q.wait); 1447 adapter->cmd_wait_q.status = 0; 1448 adapter->scan_wait_q_woken = false; 1449 1450 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) 1451 adapter->rx_work_enabled = true; 1452 --- 21 unchanged lines hidden (view full) --- 1474 */ 1475 mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__); 1476 1477 if (mwifiex_init_hw_fw(adapter, false)) { 1478 mwifiex_dbg(adapter, ERROR, 1479 "%s: firmware init failed\n", __func__); 1480 goto err_init_fw; 1481 } |
1482 1483 /* _mwifiex_fw_dpc() does its own cleanup */ 1484 ret = _mwifiex_fw_dpc(adapter->firmware, adapter); 1485 if (ret) { 1486 pr_err("Failed to bring up adapter: %d\n", ret); 1487 return ret; 1488 } |
|
1475 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); 1476 | 1489 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); 1490 |
1477 complete_all(adapter->fw_done); | |
1478 return 0; 1479 1480err_init_fw: 1481 mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__); 1482 if (adapter->if_ops.unregister_dev) 1483 adapter->if_ops.unregister_dev(adapter); 1484 1485err_kmalloc: --- 11 unchanged lines hidden (view full) --- 1497 return -1; 1498} 1499EXPORT_SYMBOL_GPL(mwifiex_reinit_sw); 1500 1501static irqreturn_t mwifiex_irq_wakeup_handler(int irq, void *priv) 1502{ 1503 struct mwifiex_adapter *adapter = priv; 1504 | 1491 return 0; 1492 1493err_init_fw: 1494 mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__); 1495 if (adapter->if_ops.unregister_dev) 1496 adapter->if_ops.unregister_dev(adapter); 1497 1498err_kmalloc: --- 11 unchanged lines hidden (view full) --- 1510 return -1; 1511} 1512EXPORT_SYMBOL_GPL(mwifiex_reinit_sw); 1513 1514static irqreturn_t mwifiex_irq_wakeup_handler(int irq, void *priv) 1515{ 1516 struct mwifiex_adapter *adapter = priv; 1517 |
1505 if (adapter->irq_wakeup >= 0) { 1506 dev_dbg(adapter->dev, "%s: wake by wifi", __func__); 1507 adapter->wake_by_wifi = true; 1508 disable_irq_nosync(irq); 1509 } | 1518 dev_dbg(adapter->dev, "%s: wake by wifi", __func__); 1519 adapter->wake_by_wifi = true; 1520 disable_irq_nosync(irq); |
1510 1511 /* Notify PM core we are wakeup source */ 1512 pm_wakeup_event(adapter->dev, 0); | 1521 1522 /* Notify PM core we are wakeup source */ 1523 pm_wakeup_event(adapter->dev, 0); |
1524 pm_system_wakeup(); |
|
1513 1514 return IRQ_HANDLED; 1515} 1516 1517static void mwifiex_probe_of(struct mwifiex_adapter *adapter) 1518{ 1519 int ret; 1520 struct device *dev = adapter->dev; --- 188 unchanged lines hidden (view full) --- 1709 continue; 1710 1711 rtnl_lock(); 1712 if (priv->netdev && 1713 priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED) 1714 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); 1715 rtnl_unlock(); 1716 } | 1525 1526 return IRQ_HANDLED; 1527} 1528 1529static void mwifiex_probe_of(struct mwifiex_adapter *adapter) 1530{ 1531 int ret; 1532 struct device *dev = adapter->dev; --- 188 unchanged lines hidden (view full) --- 1721 continue; 1722 1723 rtnl_lock(); 1724 if (priv->netdev && 1725 priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED) 1726 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); 1727 rtnl_unlock(); 1728 } |
1729 vfree(adapter->chan_stats); |
|
1717 1718 wiphy_unregister(adapter->wiphy); 1719 wiphy_free(adapter->wiphy); 1720 1721 if (adapter->irq_wakeup >= 0) 1722 device_init_wakeup(adapter->dev, false); 1723 1724 /* Unregister device */ --- 12 unchanged lines hidden (view full) --- 1737EXPORT_SYMBOL_GPL(mwifiex_remove_card); 1738 1739void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, 1740 const char *fmt, ...) 1741{ 1742 struct va_format vaf; 1743 va_list args; 1744 | 1730 1731 wiphy_unregister(adapter->wiphy); 1732 wiphy_free(adapter->wiphy); 1733 1734 if (adapter->irq_wakeup >= 0) 1735 device_init_wakeup(adapter->dev, false); 1736 1737 /* Unregister device */ --- 12 unchanged lines hidden (view full) --- 1750EXPORT_SYMBOL_GPL(mwifiex_remove_card); 1751 1752void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, 1753 const char *fmt, ...) 1754{ 1755 struct va_format vaf; 1756 va_list args; 1757 |
1745 if (!adapter->dev || !(adapter->debug_mask & mask)) | 1758 if (!(adapter->debug_mask & mask)) |
1746 return; 1747 1748 va_start(args, fmt); 1749 1750 vaf.fmt = fmt; 1751 vaf.va = &args; 1752 | 1759 return; 1760 1761 va_start(args, fmt); 1762 1763 vaf.fmt = fmt; 1764 vaf.va = &args; 1765 |
1753 dev_info(adapter->dev, "%pV", &vaf); | 1766 if (adapter->dev) 1767 dev_info(adapter->dev, "%pV", &vaf); 1768 else 1769 pr_info("%pV", &vaf); |
1754 1755 va_end(args); 1756} 1757EXPORT_SYMBOL_GPL(_mwifiex_dbg); 1758 1759/* 1760 * This function initializes the module. 1761 * --- 31 unchanged lines hidden --- | 1770 1771 va_end(args); 1772} 1773EXPORT_SYMBOL_GPL(_mwifiex_dbg); 1774 1775/* 1776 * This function initializes the module. 1777 * --- 31 unchanged lines hidden --- |