aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath6kl/init.c
diff options
context:
space:
mode:
authorKalle Valo <kvalo@qca.qualcomm.com>2012-01-17 13:09:05 -0500
committerKalle Valo <kvalo@qca.qualcomm.com>2012-01-18 06:59:49 -0500
commit45eaa78f757b3b3992ca02c753764665e9fba0a4 (patch)
tree6a8dacef6f3fc10fb303035c218d4c16923ea523 /drivers/net/wireless/ath/ath6kl/init.c
parentf29af97853599e9537191c4f33f8ac87f3f503a9 (diff)
ath6kl: create core.c
Currently core functions are spread between various files, group all the functions into file and rename the functions to follow the style used elsewhere in the driver. This will make it easier to a separate core module. Also fix a bug where wiphy is freed too early. Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath6kl/init.c')
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c213
1 files changed, 2 insertions, 211 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 2804921d5d8a..b8252ced0968 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -25,15 +25,9 @@
25#include "debug.h" 25#include "debug.h"
26#include "hif-ops.h" 26#include "hif-ops.h"
27 27
28unsigned int debug_mask;
29static unsigned int testmode; 28static unsigned int testmode;
30static bool suspend_cutpower;
31static unsigned int uart_debug;
32 29
33module_param(debug_mask, uint, 0644);
34module_param(testmode, uint, 0644); 30module_param(testmode, uint, 0644);
35module_param(suspend_cutpower, bool, 0444);
36module_param(uart_debug, uint, 0644);
37 31
38static const struct ath6kl_hw hw_list[] = { 32static const struct ath6kl_hw hw_list[] = {
39 { 33 {
@@ -597,37 +591,6 @@ int ath6kl_configure_target(struct ath6kl *ar)
597 return 0; 591 return 0;
598} 592}
599 593
600void ath6kl_core_free(struct ath6kl *ar)
601{
602 wiphy_free(ar->wiphy);
603}
604
605void ath6kl_core_cleanup(struct ath6kl *ar)
606{
607 ath6kl_hif_power_off(ar);
608
609 destroy_workqueue(ar->ath6kl_wq);
610
611 if (ar->htc_target)
612 ath6kl_htc_cleanup(ar->htc_target);
613
614 ath6kl_cookie_cleanup(ar);
615
616 ath6kl_cleanup_amsdu_rxbufs(ar);
617
618 ath6kl_bmi_cleanup(ar);
619
620 ath6kl_debug_cleanup(ar);
621
622 kfree(ar->fw_board);
623 kfree(ar->fw_otp);
624 kfree(ar->fw);
625 kfree(ar->fw_patch);
626 kfree(ar->fw_testscript);
627
628 ath6kl_cfg80211_cleanup(ar);
629}
630
631/* firmware upload */ 594/* firmware upload */
632static int ath6kl_get_fw(struct ath6kl *ar, const char *filename, 595static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
633 u8 **fw, size_t *fw_len) 596 u8 **fw, size_t *fw_len)
@@ -1065,7 +1028,7 @@ out:
1065 return ret; 1028 return ret;
1066} 1029}
1067 1030
1068static int ath6kl_fetch_firmwares(struct ath6kl *ar) 1031int ath6kl_init_fetch_firmwares(struct ath6kl *ar)
1069{ 1032{
1070 int ret; 1033 int ret;
1071 1034
@@ -1485,7 +1448,7 @@ static int ath6kl_init_upload(struct ath6kl *ar)
1485 return status; 1448 return status;
1486} 1449}
1487 1450
1488static int ath6kl_init_hw_params(struct ath6kl *ar) 1451int ath6kl_init_hw_params(struct ath6kl *ar)
1489{ 1452{
1490 const struct ath6kl_hw *hw; 1453 const struct ath6kl_hw *hw;
1491 int i; 1454 int i;
@@ -1663,178 +1626,6 @@ int ath6kl_init_hw_stop(struct ath6kl *ar)
1663 return 0; 1626 return 0;
1664} 1627}
1665 1628
1666int ath6kl_core_init(struct ath6kl *ar)
1667{
1668 struct ath6kl_bmi_target_info targ_info;
1669 struct net_device *ndev;
1670 int ret = 0, i;
1671
1672 ar->ath6kl_wq = create_singlethread_workqueue("ath6kl");
1673 if (!ar->ath6kl_wq)
1674 return -ENOMEM;
1675
1676 ret = ath6kl_bmi_init(ar);
1677 if (ret)
1678 goto err_wq;
1679
1680 /*
1681 * Turn on power to get hardware (target) version and leave power
1682 * on delibrately as we will boot the hardware anyway within few
1683 * seconds.
1684 */
1685 ret = ath6kl_hif_power_on(ar);
1686 if (ret)
1687 goto err_bmi_cleanup;
1688
1689 ret = ath6kl_bmi_get_target_info(ar, &targ_info);
1690 if (ret)
1691 goto err_power_off;
1692
1693 ar->version.target_ver = le32_to_cpu(targ_info.version);
1694 ar->target_type = le32_to_cpu(targ_info.type);
1695 ar->wiphy->hw_version = le32_to_cpu(targ_info.version);
1696
1697 ret = ath6kl_init_hw_params(ar);
1698 if (ret)
1699 goto err_power_off;
1700
1701 ar->htc_target = ath6kl_htc_create(ar);
1702
1703 if (!ar->htc_target) {
1704 ret = -ENOMEM;
1705 goto err_power_off;
1706 }
1707
1708 ret = ath6kl_fetch_firmwares(ar);
1709 if (ret)
1710 goto err_htc_cleanup;
1711
1712 /* FIXME: we should free all firmwares in the error cases below */
1713
1714 /* Indicate that WMI is enabled (although not ready yet) */
1715 set_bit(WMI_ENABLED, &ar->flag);
1716 ar->wmi = ath6kl_wmi_init(ar);
1717 if (!ar->wmi) {
1718 ath6kl_err("failed to initialize wmi\n");
1719 ret = -EIO;
1720 goto err_htc_cleanup;
1721 }
1722
1723 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi);
1724
1725 ret = ath6kl_cfg80211_init(ar);
1726 if (ret)
1727 goto err_node_cleanup;
1728
1729 ret = ath6kl_debug_init(ar);
1730 if (ret) {
1731 wiphy_unregister(ar->wiphy);
1732 goto err_node_cleanup;
1733 }
1734
1735 for (i = 0; i < ar->vif_max; i++)
1736 ar->avail_idx_map |= BIT(i);
1737
1738 rtnl_lock();
1739
1740 /* Add an initial station interface */
1741 ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0,
1742 INFRA_NETWORK);
1743
1744 rtnl_unlock();
1745
1746 if (!ndev) {
1747 ath6kl_err("Failed to instantiate a network device\n");
1748 ret = -ENOMEM;
1749 wiphy_unregister(ar->wiphy);
1750 goto err_debug_init;
1751 }
1752
1753
1754 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n",
1755 __func__, ndev->name, ndev, ar);
1756
1757 /* setup access class priority mappings */
1758 ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */
1759 ar->ac_stream_pri_map[WMM_AC_BE] = 1;
1760 ar->ac_stream_pri_map[WMM_AC_VI] = 2;
1761 ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */
1762
1763 /* give our connected endpoints some buffers */
1764 ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep);
1765 ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]);
1766
1767 /* allocate some buffers that handle larger AMSDU frames */
1768 ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS);
1769
1770 ath6kl_cookie_init(ar);
1771
1772 ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER |
1773 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST;
1774
1775 if (suspend_cutpower)
1776 ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER;
1777
1778 if (uart_debug)
1779 ar->conf_flags |= ATH6KL_CONF_UART_DEBUG;
1780
1781 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM |
1782 WIPHY_FLAG_HAVE_AP_SME |
1783 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
1784 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
1785
1786 if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN, ar->fw_capabilities))
1787 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
1788
1789 ar->wiphy->probe_resp_offload =
1790 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
1791 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
1792 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P |
1793 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U;
1794
1795 set_bit(FIRST_BOOT, &ar->flag);
1796
1797 ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
1798
1799 ret = ath6kl_init_hw_start(ar);
1800 if (ret) {
1801 ath6kl_err("Failed to start hardware: %d\n", ret);
1802 goto err_rxbuf_cleanup;
1803 }
1804
1805 /*
1806 * Set mac address which is received in ready event
1807 * FIXME: Move to ath6kl_interface_add()
1808 */
1809 memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN);
1810
1811 return ret;
1812
1813err_rxbuf_cleanup:
1814 ath6kl_htc_flush_rx_buf(ar->htc_target);
1815 ath6kl_cleanup_amsdu_rxbufs(ar);
1816 rtnl_lock();
1817 ath6kl_cfg80211_vif_cleanup(netdev_priv(ndev));
1818 rtnl_unlock();
1819 wiphy_unregister(ar->wiphy);
1820err_debug_init:
1821 ath6kl_debug_cleanup(ar);
1822err_node_cleanup:
1823 ath6kl_wmi_shutdown(ar->wmi);
1824 clear_bit(WMI_ENABLED, &ar->flag);
1825 ar->wmi = NULL;
1826err_htc_cleanup:
1827 ath6kl_htc_cleanup(ar->htc_target);
1828err_power_off:
1829 ath6kl_hif_power_off(ar);
1830err_bmi_cleanup:
1831 ath6kl_bmi_cleanup(ar);
1832err_wq:
1833 destroy_workqueue(ar->ath6kl_wq);
1834
1835 return ret;
1836}
1837
1838/* FIXME: move this to cfg80211.c and rename to ath6kl_cfg80211_vif_stop() */ 1629/* FIXME: move this to cfg80211.c and rename to ath6kl_cfg80211_vif_stop() */
1839void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) 1630void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready)
1840{ 1631{