aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/libertas/Makefile2
-rw-r--r--drivers/net/wireless/libertas/decl.h5
-rw-r--r--drivers/net/wireless/libertas/fw.c346
-rw-r--r--drivers/net/wireless/libertas/if_usb.c78
-rw-r--r--drivers/net/wireless/libertas/main.c278
5 files changed, 354 insertions, 355 deletions
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile
index 61e0d6e07901..b56b4c55de31 100644
--- a/drivers/net/wireless/libertas/Makefile
+++ b/drivers/net/wireless/libertas/Makefile
@@ -1,4 +1,4 @@
1libertas-objs := main.o fw.o wext.o \ 1libertas-objs := main.o wext.o \
2 rx.o tx.o cmd.o \ 2 rx.o tx.o cmd.o \
3 cmdresp.o scan.o \ 3 cmdresp.o scan.o \
4 join.o 11d.o \ 4 join.o 11d.o \
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 129b021d35fd..113cfc1395e3 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -75,14 +75,11 @@ void libertas_mac_event_disconnected(wlan_private * priv);
75 75
76void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str); 76void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str);
77 77
78/* fw.c */
79int libertas_init_fw(wlan_private * priv, char *fw_name);
80
81/* main.c */ 78/* main.c */
82struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band, 79struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band,
83 int *cfp_no); 80 int *cfp_no);
84wlan_private *libertas_add_card(void *card, struct device *dmdev); 81wlan_private *libertas_add_card(void *card, struct device *dmdev);
85int libertas_activate_card(wlan_private *priv, char *fw_name); 82int libertas_activate_card(wlan_private *priv);
86int libertas_remove_card(wlan_private *priv); 83int libertas_remove_card(wlan_private *priv);
87int libertas_add_mesh(wlan_private *priv, struct device *dev); 84int libertas_add_mesh(wlan_private *priv, struct device *dev);
88void libertas_remove_mesh(wlan_private *priv); 85void libertas_remove_mesh(wlan_private *priv);
diff --git a/drivers/net/wireless/libertas/fw.c b/drivers/net/wireless/libertas/fw.c
deleted file mode 100644
index 6c259878da96..000000000000
--- a/drivers/net/wireless/libertas/fw.c
+++ /dev/null
@@ -1,346 +0,0 @@
1/**
2 * This file contains the initialization for FW and HW
3 */
4#include <linux/firmware.h>
5
6#include "host.h"
7#include "defs.h"
8#include "decl.h"
9#include "dev.h"
10#include "wext.h"
11#include "if_usb.h"
12
13/**
14 * @brief This function checks the validity of Boot2/FW image.
15 *
16 * @param data pointer to image
17 * len image length
18 * @return 0 or -1
19 */
20static int check_fwfile_format(u8 *data, u32 totlen)
21{
22 u32 bincmd, exit;
23 u32 blksize, offset, len;
24 int ret;
25
26 ret = 1;
27 exit = len = 0;
28
29 do {
30 struct fwheader *fwh = (void *)data;
31
32 bincmd = le32_to_cpu(fwh->dnldcmd);
33 blksize = le32_to_cpu(fwh->datalength);
34 switch (bincmd) {
35 case FW_HAS_DATA_TO_RECV:
36 offset = sizeof(struct fwheader) + blksize;
37 data += offset;
38 len += offset;
39 if (len >= totlen)
40 exit = 1;
41 break;
42 case FW_HAS_LAST_BLOCK:
43 exit = 1;
44 ret = 0;
45 break;
46 default:
47 exit = 1;
48 break;
49 }
50 } while (!exit);
51
52 if (ret)
53 lbs_pr_err("firmware file format check FAIL\n");
54 else
55 lbs_deb_fw("firmware file format check PASS\n");
56
57 return ret;
58}
59
60/**
61 * @brief This function downloads firmware image, gets
62 * HW spec from firmware and set basic parameters to
63 * firmware.
64 *
65 * @param priv A pointer to wlan_private structure
66 * @return 0 or -1
67 */
68static int wlan_setup_station_hw(wlan_private * priv, char *fw_name)
69{
70 int ret = -1;
71 wlan_adapter *adapter = priv->adapter;
72
73 lbs_deb_enter(LBS_DEB_FW);
74
75 if ((ret = request_firmware(&priv->firmware, fw_name,
76 priv->hotplug_device)) < 0) {
77 lbs_pr_err("request_firmware() failed with %#x\n", ret);
78 lbs_pr_err("firmware %s not found\n", fw_name);
79 goto done;
80 }
81
82 if (check_fwfile_format(priv->firmware->data, priv->firmware->size)) {
83 release_firmware(priv->firmware);
84 goto done;
85 }
86
87 ret = priv->hw_prog_firmware(priv);
88
89 release_firmware(priv->firmware);
90
91 if (ret) {
92 lbs_deb_fw("bootloader in invalid state\n");
93 ret = -1;
94 goto done;
95 }
96
97 /*
98 * Read MAC address from HW
99 */
100 memset(adapter->current_addr, 0xff, ETH_ALEN);
101
102 ret = libertas_prepare_and_send_command(priv, CMD_GET_HW_SPEC,
103 0, CMD_OPTION_WAITFORRSP, 0, NULL);
104
105 if (ret) {
106 ret = -1;
107 goto done;
108 }
109
110 libertas_set_mac_packet_filter(priv);
111
112 /* Get the supported Data rates */
113 ret = libertas_prepare_and_send_command(priv, CMD_802_11_DATA_RATE,
114 CMD_ACT_GET_TX_RATE,
115 CMD_OPTION_WAITFORRSP, 0, NULL);
116
117 if (ret) {
118 ret = -1;
119 goto done;
120 }
121
122 ret = 0;
123done:
124 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
125 return ret;
126}
127
128static int wlan_allocate_adapter(wlan_private * priv)
129{
130 size_t bufsize;
131 wlan_adapter *adapter = priv->adapter;
132
133 /* Allocate buffer to store the BSSID list */
134 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor);
135 adapter->networks = kzalloc(bufsize, GFP_KERNEL);
136 if (!adapter->networks) {
137 lbs_pr_err("Out of memory allocating beacons\n");
138 libertas_free_adapter(priv);
139 return -ENOMEM;
140 }
141
142 /* Allocate the command buffers */
143 libertas_allocate_cmd_buffer(priv);
144
145 memset(&adapter->libertas_ps_confirm_sleep, 0, sizeof(struct PS_CMD_ConfirmSleep));
146 adapter->libertas_ps_confirm_sleep.seqnum = cpu_to_le16(++adapter->seqnum);
147 adapter->libertas_ps_confirm_sleep.command =
148 cpu_to_le16(CMD_802_11_PS_MODE);
149 adapter->libertas_ps_confirm_sleep.size =
150 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep));
151 adapter->libertas_ps_confirm_sleep.result = 0;
152 adapter->libertas_ps_confirm_sleep.action =
153 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED);
154
155 return 0;
156}
157
158static void wlan_init_adapter(wlan_private * priv)
159{
160 wlan_adapter *adapter = priv->adapter;
161 int i;
162
163 adapter->scanprobes = 0;
164
165 adapter->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;
166 adapter->data_avg_factor = DEFAULT_DATA_AVG_FACTOR;
167
168 /* ATIM params */
169 adapter->atimwindow = 0;
170
171 adapter->connect_status = LIBERTAS_DISCONNECTED;
172 memset(adapter->current_addr, 0xff, ETH_ALEN);
173
174 /* scan type */
175 adapter->scantype = CMD_SCAN_TYPE_ACTIVE;
176
177 /* scan mode */
178 adapter->scanmode = CMD_BSS_TYPE_ANY;
179
180 /* 802.11 specific */
181 adapter->secinfo.wep_enabled = 0;
182 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]);
183 i++)
184 memset(&adapter->wep_keys[i], 0, sizeof(struct enc_key));
185 adapter->wep_tx_keyidx = 0;
186 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
187 adapter->mode = IW_MODE_INFRA;
188
189 adapter->pending_assoc_req = NULL;
190 adapter->in_progress_assoc_req = NULL;
191
192 /* Initialize scan result lists */
193 INIT_LIST_HEAD(&adapter->network_free_list);
194 INIT_LIST_HEAD(&adapter->network_list);
195 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
196 list_add_tail(&adapter->networks[i].list,
197 &adapter->network_free_list);
198 }
199
200 mutex_init(&adapter->lock);
201
202 adapter->prescan = 1;
203
204 memset(&adapter->curbssparams, 0, sizeof(adapter->curbssparams));
205 adapter->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
206
207 /* PnP and power profile */
208 adapter->surpriseremoved = 0;
209
210 adapter->currentpacketfilter =
211 CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
212
213 adapter->radioon = RADIO_ON;
214 adapter->txantenna = RF_ANTENNA_2;
215 adapter->rxantenna = RF_ANTENNA_AUTO;
216
217 adapter->auto_rate = 1;
218 adapter->cur_rate = 0;
219 adapter->adhoc_grate_enabled = 0;
220
221 adapter->beaconperiod = MRVDRV_BEACON_INTERVAL;
222
223 // set default capabilities
224 adapter->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
225
226 adapter->psmode = WLAN802_11POWERMODECAM;
227 adapter->multipledtim = MRVDRV_DEFAULT_MULTIPLE_DTIM;
228
229 adapter->listeninterval = MRVDRV_DEFAULT_LISTEN_INTERVAL;
230
231 adapter->psstate = PS_STATE_FULL_POWER;
232 adapter->needtowakeup = 0;
233 adapter->locallisteninterval = 0; /* default value in firmware will be used */
234
235 adapter->intcounter = 0;
236
237 adapter->currenttxskb = NULL;
238 adapter->pkttxctrl = 0;
239
240 memset(&adapter->tx_queue_ps, 0, NR_TX_QUEUE*sizeof(struct sk_buff*));
241 adapter->tx_queue_idx = 0;
242 spin_lock_init(&adapter->txqueue_lock);
243
244 return;
245}
246
247static void command_timer_fn(unsigned long data);
248
249int libertas_init_fw(wlan_private * priv, char *fw_name)
250{
251 int ret = -1;
252 wlan_adapter *adapter = priv->adapter;
253
254 lbs_deb_enter(LBS_DEB_FW);
255
256 /* Allocate adapter structure */
257 if ((ret = wlan_allocate_adapter(priv)) != 0)
258 goto done;
259
260 /* init adapter structure */
261 wlan_init_adapter(priv);
262
263 /* init timer etc. */
264 setup_timer(&adapter->command_timer, command_timer_fn,
265 (unsigned long)priv);
266
267 /* download fimrware etc. */
268 if ((ret = wlan_setup_station_hw(priv, fw_name)) != 0) {
269 del_timer_sync(&adapter->command_timer);
270 goto done;
271 }
272
273 /* init 802.11d */
274 libertas_init_11d(priv);
275
276 ret = 0;
277done:
278 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
279 return ret;
280}
281
282void libertas_free_adapter(wlan_private * priv)
283{
284 wlan_adapter *adapter = priv->adapter;
285
286 if (!adapter) {
287 lbs_deb_fw("why double free adapter?\n");
288 return;
289 }
290
291 lbs_deb_fw("free command buffer\n");
292 libertas_free_cmd_buffer(priv);
293
294 lbs_deb_fw("free command_timer\n");
295 del_timer(&adapter->command_timer);
296
297 lbs_deb_fw("free scan results table\n");
298 kfree(adapter->networks);
299 adapter->networks = NULL;
300
301 /* Free the adapter object itself */
302 lbs_deb_fw("free adapter\n");
303 kfree(adapter);
304 priv->adapter = NULL;
305}
306
307/**
308 * This function handles the timeout of command sending.
309 * It will re-send the same command again.
310 */
311static void command_timer_fn(unsigned long data)
312{
313 wlan_private *priv = (wlan_private *)data;
314 wlan_adapter *adapter = priv->adapter;
315 struct cmd_ctrl_node *ptempnode;
316 struct cmd_ds_command *cmd;
317 unsigned long flags;
318
319 ptempnode = adapter->cur_cmd;
320 if (ptempnode == NULL) {
321 lbs_deb_fw("ptempnode empty\n");
322 return;
323 }
324
325 cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr;
326 if (!cmd) {
327 lbs_deb_fw("cmd is NULL\n");
328 return;
329 }
330
331 lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command);
332
333 if (!adapter->fw_ready)
334 return;
335
336 spin_lock_irqsave(&adapter->driver_lock, flags);
337 adapter->cur_cmd = NULL;
338 spin_unlock_irqrestore(&adapter->driver_lock, flags);
339
340 lbs_deb_fw("re-sending same command because of timeout\n");
341 libertas_queue_cmd(adapter, ptempnode, 0);
342
343 wake_up_interruptible(&priv->waitq);
344
345 return;
346}
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index e38fce73cf74..ac1cfc253fdc 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -216,7 +216,7 @@ static int if_usb_probe(struct usb_interface *intf,
216 priv->hw_get_int_status = if_usb_get_int_status; 216 priv->hw_get_int_status = if_usb_get_int_status;
217 priv->hw_read_event_cause = if_usb_read_event_cause; 217 priv->hw_read_event_cause = if_usb_read_event_cause;
218 218
219 if (libertas_activate_card(priv, libertas_fw_name)) 219 if (libertas_activate_card(priv))
220 goto err_activate_card; 220 goto err_activate_card;
221 221
222 list_add_tail(&cardp->list, &usb_devices); 222 list_add_tail(&cardp->list, &usb_devices);
@@ -819,7 +819,7 @@ static int if_usb_issue_boot_command(wlan_private *priv, int ivalue)
819} 819}
820 820
821 821
822static int if_usb_prog_firmware(wlan_private * priv) 822static int if_usb_do_prog_firmware(wlan_private * priv)
823{ 823{
824 struct usb_card_rec *cardp = priv->card; 824 struct usb_card_rec *cardp = priv->card;
825 int i = 0; 825 int i = 0;
@@ -903,6 +903,80 @@ done:
903 return ret; 903 return ret;
904} 904}
905 905
906/**
907 * @brief This function checks the validity of Boot2/FW image.
908 *
909 * @param data pointer to image
910 * len image length
911 * @return 0 or -1
912 */
913static int check_fwfile_format(u8 *data, u32 totlen)
914{
915 u32 bincmd, exit;
916 u32 blksize, offset, len;
917 int ret;
918
919 ret = 1;
920 exit = len = 0;
921
922 do {
923 struct fwheader *fwh = (void *)data;
924
925 bincmd = le32_to_cpu(fwh->dnldcmd);
926 blksize = le32_to_cpu(fwh->datalength);
927 switch (bincmd) {
928 case FW_HAS_DATA_TO_RECV:
929 offset = sizeof(struct fwheader) + blksize;
930 data += offset;
931 len += offset;
932 if (len >= totlen)
933 exit = 1;
934 break;
935 case FW_HAS_LAST_BLOCK:
936 exit = 1;
937 ret = 0;
938 break;
939 default:
940 exit = 1;
941 break;
942 }
943 } while (!exit);
944
945 if (ret)
946 lbs_pr_err("firmware file format check FAIL\n");
947 else
948 lbs_deb_fw("firmware file format check PASS\n");
949
950 return ret;
951}
952
953
954static int if_usb_prog_firmware(wlan_private *priv)
955{
956 int ret = -1;
957
958 lbs_deb_enter(LBS_DEB_FW);
959
960 if ((ret = request_firmware(&priv->firmware, libertas_fw_name,
961 priv->hotplug_device)) < 0) {
962 lbs_pr_err("request_firmware() failed with %#x\n", ret);
963 lbs_pr_err("firmware %s not found\n", libertas_fw_name);
964 goto done;
965 }
966
967 if (check_fwfile_format(priv->firmware->data, priv->firmware->size)) {
968 release_firmware(priv->firmware);
969 goto done;
970 }
971
972 ret = if_usb_do_prog_firmware(priv);
973
974 release_firmware(priv->firmware);
975done:
976 return ret;
977}
978
979
906#ifdef CONFIG_PM 980#ifdef CONFIG_PM
907static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) 981static int if_usb_suspend(struct usb_interface *intf, pm_message_t message)
908{ 982{
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 03217f5537ad..7e417eacbc77 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -794,6 +794,280 @@ static int libertas_thread(void *data)
794} 794}
795 795
796/** 796/**
797 * @brief This function downloads firmware image, gets
798 * HW spec from firmware and set basic parameters to
799 * firmware.
800 *
801 * @param priv A pointer to wlan_private structure
802 * @return 0 or -1
803 */
804static int wlan_setup_station_hw(wlan_private * priv)
805{
806 int ret = -1;
807 wlan_adapter *adapter = priv->adapter;
808
809 lbs_deb_enter(LBS_DEB_FW);
810
811 ret = priv->hw_prog_firmware(priv);
812
813 if (ret) {
814 lbs_deb_fw("bootloader in invalid state\n");
815 ret = -1;
816 goto done;
817 }
818
819 /*
820 * Read MAC address from HW
821 */
822 memset(adapter->current_addr, 0xff, ETH_ALEN);
823
824 ret = libertas_prepare_and_send_command(priv, CMD_GET_HW_SPEC,
825 0, CMD_OPTION_WAITFORRSP, 0, NULL);
826
827 if (ret) {
828 ret = -1;
829 goto done;
830 }
831
832 libertas_set_mac_packet_filter(priv);
833
834 /* Get the supported Data rates */
835 ret = libertas_prepare_and_send_command(priv, CMD_802_11_DATA_RATE,
836 CMD_ACT_GET_TX_RATE,
837 CMD_OPTION_WAITFORRSP, 0, NULL);
838
839 if (ret) {
840 ret = -1;
841 goto done;
842 }
843
844 ret = 0;
845done:
846 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
847 return ret;
848}
849
850static void command_timer_fn(unsigned long data);
851
852/**
853 * This function handles the timeout of command sending.
854 * It will re-send the same command again.
855 */
856static void command_timer_fn(unsigned long data)
857{
858 wlan_private *priv = (wlan_private *)data;
859 wlan_adapter *adapter = priv->adapter;
860 struct cmd_ctrl_node *ptempnode;
861 struct cmd_ds_command *cmd;
862 unsigned long flags;
863
864 ptempnode = adapter->cur_cmd;
865 if (ptempnode == NULL) {
866 lbs_deb_fw("ptempnode empty\n");
867 return;
868 }
869
870 cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr;
871 if (!cmd) {
872 lbs_deb_fw("cmd is NULL\n");
873 return;
874 }
875
876 lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command);
877
878 if (!adapter->fw_ready)
879 return;
880
881 spin_lock_irqsave(&adapter->driver_lock, flags);
882 adapter->cur_cmd = NULL;
883 spin_unlock_irqrestore(&adapter->driver_lock, flags);
884
885 lbs_deb_fw("re-sending same command because of timeout\n");
886 libertas_queue_cmd(adapter, ptempnode, 0);
887
888 wake_up_interruptible(&priv->waitq);
889
890 return;
891}
892
893static int wlan_allocate_adapter(wlan_private * priv)
894{
895 size_t bufsize;
896 wlan_adapter *adapter = priv->adapter;
897
898 /* Allocate buffer to store the BSSID list */
899 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor);
900 adapter->networks = kzalloc(bufsize, GFP_KERNEL);
901 if (!adapter->networks) {
902 lbs_pr_err("Out of memory allocating beacons\n");
903 libertas_free_adapter(priv);
904 return -ENOMEM;
905 }
906
907 /* Allocate the command buffers */
908 libertas_allocate_cmd_buffer(priv);
909
910 memset(&adapter->libertas_ps_confirm_sleep, 0, sizeof(struct PS_CMD_ConfirmSleep));
911 adapter->libertas_ps_confirm_sleep.seqnum = cpu_to_le16(++adapter->seqnum);
912 adapter->libertas_ps_confirm_sleep.command =
913 cpu_to_le16(CMD_802_11_PS_MODE);
914 adapter->libertas_ps_confirm_sleep.size =
915 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep));
916 adapter->libertas_ps_confirm_sleep.result = 0;
917 adapter->libertas_ps_confirm_sleep.action =
918 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED);
919
920 return 0;
921}
922
923static void wlan_init_adapter(wlan_private * priv)
924{
925 wlan_adapter *adapter = priv->adapter;
926 int i;
927
928 adapter->scanprobes = 0;
929
930 adapter->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;
931 adapter->data_avg_factor = DEFAULT_DATA_AVG_FACTOR;
932
933 /* ATIM params */
934 adapter->atimwindow = 0;
935
936 adapter->connect_status = LIBERTAS_DISCONNECTED;
937 memset(adapter->current_addr, 0xff, ETH_ALEN);
938
939 /* scan type */
940 adapter->scantype = CMD_SCAN_TYPE_ACTIVE;
941
942 /* scan mode */
943 adapter->scanmode = CMD_BSS_TYPE_ANY;
944
945 /* 802.11 specific */
946 adapter->secinfo.wep_enabled = 0;
947 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]);
948 i++)
949 memset(&adapter->wep_keys[i], 0, sizeof(struct enc_key));
950 adapter->wep_tx_keyidx = 0;
951 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
952 adapter->mode = IW_MODE_INFRA;
953
954 adapter->pending_assoc_req = NULL;
955 adapter->in_progress_assoc_req = NULL;
956
957 /* Initialize scan result lists */
958 INIT_LIST_HEAD(&adapter->network_free_list);
959 INIT_LIST_HEAD(&adapter->network_list);
960 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
961 list_add_tail(&adapter->networks[i].list,
962 &adapter->network_free_list);
963 }
964
965 mutex_init(&adapter->lock);
966
967 adapter->prescan = 1;
968
969 memset(&adapter->curbssparams, 0, sizeof(adapter->curbssparams));
970 adapter->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
971
972 /* PnP and power profile */
973 adapter->surpriseremoved = 0;
974
975 adapter->currentpacketfilter =
976 CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
977
978 adapter->radioon = RADIO_ON;
979 adapter->txantenna = RF_ANTENNA_2;
980 adapter->rxantenna = RF_ANTENNA_AUTO;
981
982 adapter->auto_rate = 1;
983 adapter->cur_rate = 0;
984 adapter->adhoc_grate_enabled = 0;
985
986 adapter->beaconperiod = MRVDRV_BEACON_INTERVAL;
987
988 // set default capabilities
989 adapter->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
990
991 adapter->psmode = WLAN802_11POWERMODECAM;
992 adapter->multipledtim = MRVDRV_DEFAULT_MULTIPLE_DTIM;
993
994 adapter->listeninterval = MRVDRV_DEFAULT_LISTEN_INTERVAL;
995
996 adapter->psstate = PS_STATE_FULL_POWER;
997 adapter->needtowakeup = 0;
998 adapter->locallisteninterval = 0; /* default value in firmware will be used */
999
1000 adapter->intcounter = 0;
1001
1002 adapter->currenttxskb = NULL;
1003 adapter->pkttxctrl = 0;
1004
1005 memset(&adapter->tx_queue_ps, 0, NR_TX_QUEUE*sizeof(struct sk_buff*));
1006 adapter->tx_queue_idx = 0;
1007 spin_lock_init(&adapter->txqueue_lock);
1008
1009 return;
1010}
1011
1012void libertas_free_adapter(wlan_private * priv)
1013{
1014 wlan_adapter *adapter = priv->adapter;
1015
1016 if (!adapter) {
1017 lbs_deb_fw("why double free adapter?\n");
1018 return;
1019 }
1020
1021 lbs_deb_fw("free command buffer\n");
1022 libertas_free_cmd_buffer(priv);
1023
1024 lbs_deb_fw("free command_timer\n");
1025 del_timer(&adapter->command_timer);
1026
1027 lbs_deb_fw("free scan results table\n");
1028 kfree(adapter->networks);
1029 adapter->networks = NULL;
1030
1031 /* Free the adapter object itself */
1032 lbs_deb_fw("free adapter\n");
1033 kfree(adapter);
1034 priv->adapter = NULL;
1035}
1036
1037static int libertas_init_fw(wlan_private * priv)
1038{
1039 int ret = -1;
1040 wlan_adapter *adapter = priv->adapter;
1041
1042 lbs_deb_enter(LBS_DEB_FW);
1043
1044 /* Allocate adapter structure */
1045 if ((ret = wlan_allocate_adapter(priv)) != 0)
1046 goto done;
1047
1048 /* init adapter structure */
1049 wlan_init_adapter(priv);
1050
1051 /* init timer etc. */
1052 setup_timer(&adapter->command_timer, command_timer_fn,
1053 (unsigned long)priv);
1054
1055 /* download fimrware etc. */
1056 if ((ret = wlan_setup_station_hw(priv)) != 0) {
1057 del_timer_sync(&adapter->command_timer);
1058 goto done;
1059 }
1060
1061 /* init 802.11d */
1062 libertas_init_11d(priv);
1063
1064 ret = 0;
1065done:
1066 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
1067 return ret;
1068}
1069
1070/**
797 * @brief This function adds the card. it will probe the 1071 * @brief This function adds the card. it will probe the
798 * card, allocate the wlan_priv and initialize the device. 1072 * card, allocate the wlan_priv and initialize the device.
799 * 1073 *
@@ -863,7 +1137,7 @@ done:
863} 1137}
864EXPORT_SYMBOL_GPL(libertas_add_card); 1138EXPORT_SYMBOL_GPL(libertas_add_card);
865 1139
866int libertas_activate_card(wlan_private *priv, char *fw_name) 1140int libertas_activate_card(wlan_private *priv)
867{ 1141{
868 struct net_device *dev = priv->dev; 1142 struct net_device *dev = priv->dev;
869 int ret = -1; 1143 int ret = -1;
@@ -894,7 +1168,7 @@ int libertas_activate_card(wlan_private *priv, char *fw_name)
894 } 1168 }
895 1169
896 /* init FW and HW */ 1170 /* init FW and HW */
897 if (fw_name && libertas_init_fw(priv, fw_name)) { 1171 if (libertas_init_fw(priv)) {
898 lbs_pr_err("firmware init failed\n"); 1172 lbs_pr_err("firmware init failed\n");
899 goto err_registerdev; 1173 goto err_registerdev;
900 } 1174 }