aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/net/wireless/ath/ath6kl/Makefile1
-rw-r--r--drivers/net/wireless/ath/ath6kl/cfg80211.c94
-rw-r--r--drivers/net/wireless/ath/ath6kl/cfg80211.h4
-rw-r--r--drivers/net/wireless/ath/ath6kl/common.h3
-rw-r--r--drivers/net/wireless/ath/ath6kl/core.c292
-rw-r--r--drivers/net/wireless/ath/ath6kl/core.h9
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c213
-rw-r--r--drivers/net/wireless/ath/ath6kl/sdio.c4
8 files changed, 332 insertions, 288 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile
index e24b61799158..854694b26a4b 100644
--- a/drivers/net/wireless/ath/ath6kl/Makefile
+++ b/drivers/net/wireless/ath/ath6kl/Makefile
@@ -31,5 +31,6 @@ ath6kl-y += init.o
31ath6kl-y += main.o 31ath6kl-y += main.o
32ath6kl-y += txrx.o 32ath6kl-y += txrx.o
33ath6kl-y += wmi.o 33ath6kl-y += wmi.o
34ath6kl-y += core.o
34ath6kl-y += sdio.o 35ath6kl-y += sdio.o
35ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o 36ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 44fdd39e1701..7ff9806de50b 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -23,10 +23,6 @@
23#include "hif-ops.h" 23#include "hif-ops.h"
24#include "testmode.h" 24#include "testmode.h"
25 25
26static unsigned int ath6kl_p2p;
27
28module_param(ath6kl_p2p, uint, 0644);
29
30#define RATETAB_ENT(_rate, _rateid, _flags) { \ 26#define RATETAB_ENT(_rate, _rateid, _flags) { \
31 .bitrate = (_rate), \ 27 .bitrate = (_rate), \
32 .flags = (_flags), \ 28 .flags = (_flags), \
@@ -2693,68 +2689,6 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar)
2693 ath6kl_cfg80211_stop(vif); 2689 ath6kl_cfg80211_stop(vif);
2694} 2690}
2695 2691
2696struct ath6kl *ath6kl_core_alloc(struct device *dev)
2697{
2698 struct ath6kl *ar;
2699 struct wiphy *wiphy;
2700 u8 ctr;
2701
2702 /* create a new wiphy for use with cfg80211 */
2703 wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl));
2704
2705 if (!wiphy) {
2706 ath6kl_err("couldn't allocate wiphy device\n");
2707 return NULL;
2708 }
2709
2710 ar = wiphy_priv(wiphy);
2711 ar->p2p = !!ath6kl_p2p;
2712 ar->wiphy = wiphy;
2713 ar->dev = dev;
2714
2715 ar->vif_max = 1;
2716
2717 ar->max_norm_iface = 1;
2718
2719 spin_lock_init(&ar->lock);
2720 spin_lock_init(&ar->mcastpsq_lock);
2721 spin_lock_init(&ar->list_lock);
2722
2723 init_waitqueue_head(&ar->event_wq);
2724 sema_init(&ar->sem, 1);
2725
2726 INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue);
2727 INIT_LIST_HEAD(&ar->vif_list);
2728
2729 clear_bit(WMI_ENABLED, &ar->flag);
2730 clear_bit(SKIP_SCAN, &ar->flag);
2731 clear_bit(DESTROY_IN_PROGRESS, &ar->flag);
2732
2733 ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL;
2734 ar->tx_pwr = 0;
2735
2736 ar->intra_bss = 1;
2737 ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD;
2738
2739 ar->state = ATH6KL_STATE_OFF;
2740
2741 memset((u8 *)ar->sta_list, 0,
2742 AP_MAX_NUM_STA * sizeof(struct ath6kl_sta));
2743
2744 /* Init the PS queues */
2745 for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
2746 spin_lock_init(&ar->sta_list[ctr].psq_lock);
2747 skb_queue_head_init(&ar->sta_list[ctr].psq);
2748 skb_queue_head_init(&ar->sta_list[ctr].apsdq);
2749 }
2750
2751 skb_queue_head_init(&ar->mcastpsq);
2752
2753 memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3);
2754
2755 return ar;
2756}
2757
2758static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif) 2692static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif)
2759{ 2693{
2760 vif->aggr_cntxt = aggr_init(vif->ndev); 2694 vif->aggr_cntxt = aggr_init(vif->ndev);
@@ -2910,10 +2844,30 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
2910void ath6kl_cfg80211_cleanup(struct ath6kl *ar) 2844void ath6kl_cfg80211_cleanup(struct ath6kl *ar)
2911{ 2845{
2912 wiphy_unregister(ar->wiphy); 2846 wiphy_unregister(ar->wiphy);
2847}
2913 2848
2914 /* 2849struct ath6kl *ath6kl_cfg80211_create(void)
2915 * FIXME: should be removed as we remove wiphy in 2850{
2916 * ath6kl_core_free(). Most likely this causes a use after free. 2851 struct ath6kl *ar;
2917 */ 2852 struct wiphy *wiphy;
2853
2854 /* create a new wiphy for use with cfg80211 */
2855 wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl));
2856
2857 if (!wiphy) {
2858 ath6kl_err("couldn't allocate wiphy device\n");
2859 return NULL;
2860 }
2861
2862 ar = wiphy_priv(wiphy);
2863 ar->wiphy = wiphy;
2864
2865 return ar;
2866}
2867
2868/* Note: ar variable must not be accessed after calling this! */
2869void ath6kl_cfg80211_destroy(struct ath6kl *ar)
2870{
2918 wiphy_free(ar->wiphy); 2871 wiphy_free(ar->wiphy);
2919} 2872}
2873
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h
index 08d97691039c..3c693b7c0efd 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.h
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h
@@ -27,7 +27,6 @@ enum ath6kl_cfg_suspend_mode {
27struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, 27struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name,
28 enum nl80211_iftype type, 28 enum nl80211_iftype type,
29 u8 fw_vif_idx, u8 nw_type); 29 u8 fw_vif_idx, u8 nw_type);
30struct ath6kl *ath6kl_core_alloc(struct device *dev);
31void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted); 30void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted);
32 31
33void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, 32void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
@@ -58,4 +57,7 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar);
58int ath6kl_cfg80211_init(struct ath6kl *ar); 57int ath6kl_cfg80211_init(struct ath6kl *ar);
59void ath6kl_cfg80211_cleanup(struct ath6kl *ar); 58void ath6kl_cfg80211_cleanup(struct ath6kl *ar);
60 59
60struct ath6kl *ath6kl_cfg80211_create(void);
61void ath6kl_cfg80211_destroy(struct ath6kl *ar);
62
61#endif /* ATH6KL_CFG80211_H */ 63#endif /* ATH6KL_CFG80211_H */
diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h
index bfd6597763da..f89f1e180da3 100644
--- a/drivers/net/wireless/ath/ath6kl/common.h
+++ b/drivers/net/wireless/ath/ath6kl/common.h
@@ -79,8 +79,5 @@ struct ath6kl;
79enum htc_credit_dist_reason; 79enum htc_credit_dist_reason;
80struct ath6kl_htc_credit_info; 80struct ath6kl_htc_credit_info;
81 81
82struct ath6kl *ath6kl_core_alloc(struct device *sdev);
83int ath6kl_core_init(struct ath6kl *ar);
84void ath6kl_core_cleanup(struct ath6kl *ar);
85struct sk_buff *ath6kl_buf_alloc(int size); 82struct sk_buff *ath6kl_buf_alloc(int size);
86#endif /* COMMON_H */ 83#endif /* COMMON_H */
diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
new file mode 100644
index 000000000000..40fad5ec9366
--- /dev/null
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -0,0 +1,292 @@
1/*
2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "core.h"
18
19#include <linux/moduleparam.h>
20
21#include "debug.h"
22#include "hif-ops.h"
23#include "cfg80211.h"
24
25unsigned int debug_mask;
26static bool suspend_cutpower;
27static unsigned int uart_debug;
28static unsigned int ath6kl_p2p;
29
30module_param(debug_mask, uint, 0644);
31module_param(suspend_cutpower, bool, 0444);
32module_param(uart_debug, uint, 0644);
33module_param(ath6kl_p2p, uint, 0644);
34
35int ath6kl_core_init(struct ath6kl *ar)
36{
37 struct ath6kl_bmi_target_info targ_info;
38 struct net_device *ndev;
39 int ret = 0, i;
40
41 ar->ath6kl_wq = create_singlethread_workqueue("ath6kl");
42 if (!ar->ath6kl_wq)
43 return -ENOMEM;
44
45 ret = ath6kl_bmi_init(ar);
46 if (ret)
47 goto err_wq;
48
49 /*
50 * Turn on power to get hardware (target) version and leave power
51 * on delibrately as we will boot the hardware anyway within few
52 * seconds.
53 */
54 ret = ath6kl_hif_power_on(ar);
55 if (ret)
56 goto err_bmi_cleanup;
57
58 ret = ath6kl_bmi_get_target_info(ar, &targ_info);
59 if (ret)
60 goto err_power_off;
61
62 ar->version.target_ver = le32_to_cpu(targ_info.version);
63 ar->target_type = le32_to_cpu(targ_info.type);
64 ar->wiphy->hw_version = le32_to_cpu(targ_info.version);
65
66 ret = ath6kl_init_hw_params(ar);
67 if (ret)
68 goto err_power_off;
69
70 ar->htc_target = ath6kl_htc_create(ar);
71
72 if (!ar->htc_target) {
73 ret = -ENOMEM;
74 goto err_power_off;
75 }
76
77 ret = ath6kl_init_fetch_firmwares(ar);
78 if (ret)
79 goto err_htc_cleanup;
80
81 /* FIXME: we should free all firmwares in the error cases below */
82
83 /* Indicate that WMI is enabled (although not ready yet) */
84 set_bit(WMI_ENABLED, &ar->flag);
85 ar->wmi = ath6kl_wmi_init(ar);
86 if (!ar->wmi) {
87 ath6kl_err("failed to initialize wmi\n");
88 ret = -EIO;
89 goto err_htc_cleanup;
90 }
91
92 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi);
93
94 ret = ath6kl_cfg80211_init(ar);
95 if (ret)
96 goto err_node_cleanup;
97
98 ret = ath6kl_debug_init(ar);
99 if (ret) {
100 wiphy_unregister(ar->wiphy);
101 goto err_node_cleanup;
102 }
103
104 for (i = 0; i < ar->vif_max; i++)
105 ar->avail_idx_map |= BIT(i);
106
107 rtnl_lock();
108
109 /* Add an initial station interface */
110 ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0,
111 INFRA_NETWORK);
112
113 rtnl_unlock();
114
115 if (!ndev) {
116 ath6kl_err("Failed to instantiate a network device\n");
117 ret = -ENOMEM;
118 wiphy_unregister(ar->wiphy);
119 goto err_debug_init;
120 }
121
122
123 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n",
124 __func__, ndev->name, ndev, ar);
125
126 /* setup access class priority mappings */
127 ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */
128 ar->ac_stream_pri_map[WMM_AC_BE] = 1;
129 ar->ac_stream_pri_map[WMM_AC_VI] = 2;
130 ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */
131
132 /* give our connected endpoints some buffers */
133 ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep);
134 ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]);
135
136 /* allocate some buffers that handle larger AMSDU frames */
137 ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS);
138
139 ath6kl_cookie_init(ar);
140
141 ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER |
142 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST;
143
144 if (suspend_cutpower)
145 ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER;
146
147 if (uart_debug)
148 ar->conf_flags |= ATH6KL_CONF_UART_DEBUG;
149
150 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM |
151 WIPHY_FLAG_HAVE_AP_SME |
152 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
153 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
154
155 if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN, ar->fw_capabilities))
156 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
157
158 ar->wiphy->probe_resp_offload =
159 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
160 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
161 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P |
162 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U;
163
164 set_bit(FIRST_BOOT, &ar->flag);
165
166 ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
167
168 ret = ath6kl_init_hw_start(ar);
169 if (ret) {
170 ath6kl_err("Failed to start hardware: %d\n", ret);
171 goto err_rxbuf_cleanup;
172 }
173
174 /*
175 * Set mac address which is received in ready event
176 * FIXME: Move to ath6kl_interface_add()
177 */
178 memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN);
179
180 return ret;
181
182err_rxbuf_cleanup:
183 ath6kl_htc_flush_rx_buf(ar->htc_target);
184 ath6kl_cleanup_amsdu_rxbufs(ar);
185 rtnl_lock();
186 ath6kl_cfg80211_vif_cleanup(netdev_priv(ndev));
187 rtnl_unlock();
188 wiphy_unregister(ar->wiphy);
189err_debug_init:
190 ath6kl_debug_cleanup(ar);
191err_node_cleanup:
192 ath6kl_wmi_shutdown(ar->wmi);
193 clear_bit(WMI_ENABLED, &ar->flag);
194 ar->wmi = NULL;
195err_htc_cleanup:
196 ath6kl_htc_cleanup(ar->htc_target);
197err_power_off:
198 ath6kl_hif_power_off(ar);
199err_bmi_cleanup:
200 ath6kl_bmi_cleanup(ar);
201err_wq:
202 destroy_workqueue(ar->ath6kl_wq);
203
204 return ret;
205}
206
207struct ath6kl *ath6kl_core_create(struct device *dev)
208{
209 struct ath6kl *ar;
210 u8 ctr;
211
212 ar = ath6kl_cfg80211_create();
213 if (!ar)
214 return NULL;
215
216 ar->p2p = !!ath6kl_p2p;
217 ar->dev = dev;
218
219 ar->vif_max = 1;
220
221 ar->max_norm_iface = 1;
222
223 spin_lock_init(&ar->lock);
224 spin_lock_init(&ar->mcastpsq_lock);
225 spin_lock_init(&ar->list_lock);
226
227 init_waitqueue_head(&ar->event_wq);
228 sema_init(&ar->sem, 1);
229
230 INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue);
231 INIT_LIST_HEAD(&ar->vif_list);
232
233 clear_bit(WMI_ENABLED, &ar->flag);
234 clear_bit(SKIP_SCAN, &ar->flag);
235 clear_bit(DESTROY_IN_PROGRESS, &ar->flag);
236
237 ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL;
238 ar->tx_pwr = 0;
239
240 ar->intra_bss = 1;
241 ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD;
242
243 ar->state = ATH6KL_STATE_OFF;
244
245 memset((u8 *)ar->sta_list, 0,
246 AP_MAX_NUM_STA * sizeof(struct ath6kl_sta));
247
248 /* Init the PS queues */
249 for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
250 spin_lock_init(&ar->sta_list[ctr].psq_lock);
251 skb_queue_head_init(&ar->sta_list[ctr].psq);
252 skb_queue_head_init(&ar->sta_list[ctr].apsdq);
253 }
254
255 skb_queue_head_init(&ar->mcastpsq);
256
257 memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3);
258
259 return ar;
260}
261
262void ath6kl_core_cleanup(struct ath6kl *ar)
263{
264 ath6kl_hif_power_off(ar);
265
266 destroy_workqueue(ar->ath6kl_wq);
267
268 if (ar->htc_target)
269 ath6kl_htc_cleanup(ar->htc_target);
270
271 ath6kl_cookie_cleanup(ar);
272
273 ath6kl_cleanup_amsdu_rxbufs(ar);
274
275 ath6kl_bmi_cleanup(ar);
276
277 ath6kl_debug_cleanup(ar);
278
279 kfree(ar->fw_board);
280 kfree(ar->fw_otp);
281 kfree(ar->fw);
282 kfree(ar->fw_patch);
283 kfree(ar->fw_testscript);
284
285 ath6kl_cfg80211_cleanup(ar);
286}
287
288void ath6kl_core_destroy(struct ath6kl *ar)
289{
290 ath6kl_cfg80211_destroy(ar);
291}
292
diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index 78c0402e2d33..67b22e4bbcc2 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -754,11 +754,18 @@ void ath6kl_wakeup_event(void *dev);
754void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, 754void ath6kl_reset_device(struct ath6kl *ar, u32 target_type,
755 bool wait_fot_compltn, bool cold_reset); 755 bool wait_fot_compltn, bool cold_reset);
756void ath6kl_init_control_info(struct ath6kl_vif *vif); 756void ath6kl_init_control_info(struct ath6kl_vif *vif);
757void ath6kl_core_free(struct ath6kl *ar);
758struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); 757struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar);
759void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready); 758void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready);
760int ath6kl_init_hw_start(struct ath6kl *ar); 759int ath6kl_init_hw_start(struct ath6kl *ar);
761int ath6kl_init_hw_stop(struct ath6kl *ar); 760int ath6kl_init_hw_stop(struct ath6kl *ar);
761int ath6kl_init_fetch_firmwares(struct ath6kl *ar);
762int ath6kl_init_hw_params(struct ath6kl *ar);
763
762void ath6kl_check_wow_status(struct ath6kl *ar); 764void ath6kl_check_wow_status(struct ath6kl *ar);
763 765
766struct ath6kl *ath6kl_core_create(struct device *dev);
767int ath6kl_core_init(struct ath6kl *ar);
768void ath6kl_core_cleanup(struct ath6kl *ar);
769void ath6kl_core_destroy(struct ath6kl *ar);
770
764#endif /* CORE_H */ 771#endif /* CORE_H */
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{
diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c
index 662b47dc71e5..bef32ecea792 100644
--- a/drivers/net/wireless/ath/ath6kl/sdio.c
+++ b/drivers/net/wireless/ath/ath6kl/sdio.c
@@ -1261,7 +1261,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func,
1261 for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) 1261 for (count = 0; count < BUS_REQUEST_MAX_NUM; count++)
1262 ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]); 1262 ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]);
1263 1263
1264 ar = ath6kl_core_alloc(&ar_sdio->func->dev); 1264 ar = ath6kl_core_create(&ar_sdio->func->dev);
1265 if (!ar) { 1265 if (!ar) {
1266 ath6kl_err("Failed to alloc ath6kl core\n"); 1266 ath6kl_err("Failed to alloc ath6kl core\n");
1267 ret = -ENOMEM; 1267 ret = -ENOMEM;
@@ -1291,7 +1291,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func,
1291 return ret; 1291 return ret;
1292 1292
1293err_core_alloc: 1293err_core_alloc:
1294 ath6kl_core_free(ar_sdio->ar); 1294 ath6kl_core_destroy(ar_sdio->ar);
1295err_dma: 1295err_dma:
1296 kfree(ar_sdio->dma_buffer); 1296 kfree(ar_sdio->dma_buffer);
1297err_hif: 1297err_hif: