blob: f9bdd123ec450f0a25cc394e73e3924b7337a8dd [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains the major functions in WLAN
3 * driver. It includes init, exit, open, close and main
4 * thread etc..
5 */
6
Holger Schuriga46c6412007-05-25 11:32:07 -04007#include <linux/moduleparam.h>
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02008#include <linux/delay.h>
9#include <linux/freezer.h>
10#include <linux/etherdevice.h>
11#include <linux/netdevice.h>
12#include <linux/if_arp.h>
Dan Williamsfe336152007-08-02 11:32:25 -040013#include <linux/kthread.h>
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020014
15#include <net/iw_handler.h>
Holger Schurig9012b282007-05-25 11:27:16 -040016#include <net/ieee80211.h>
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020017
18#include "host.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020019#include "decl.h"
20#include "dev.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020021#include "wext.h"
22#include "debugfs.h"
23#include "assoc.h"
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -040024#include "join.h"
Dan Williams6e66f032007-12-11 12:42:16 -050025#include "cmd.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020026
Dan Williams7856a542007-08-03 09:43:03 -040027#define DRIVER_RELEASE_VERSION "323.p0"
Holger Schurig10078322007-11-15 18:05:47 -050028const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
Dan Williams3ce40232007-05-10 23:03:07 -040029#ifdef DEBUG
30 "-dbg"
31#endif
32 "";
33
Holger Schuriga46c6412007-05-25 11:32:07 -040034
35/* Module parameters */
Holger Schurig10078322007-11-15 18:05:47 -050036unsigned int lbs_debug;
37EXPORT_SYMBOL_GPL(lbs_debug);
38module_param_named(libertas_debug, lbs_debug, int, 0644);
Holger Schuriga46c6412007-05-25 11:32:07 -040039
40
Holger Schurig10078322007-11-15 18:05:47 -050041#define LBS_TX_PWR_DEFAULT 20 /*100mW */
42#define LBS_TX_PWR_US_DEFAULT 20 /*100mW */
43#define LBS_TX_PWR_JP_DEFAULT 16 /*50mW */
44#define LBS_TX_PWR_FR_DEFAULT 20 /*100mW */
45#define LBS_TX_PWR_EMEA_DEFAULT 20 /*100mW */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020046
47/* Format { channel, frequency (MHz), maxtxpower } */
48/* band: 'B/G', region: USA FCC/Canada IC */
49static struct chan_freq_power channel_freq_power_US_BG[] = {
Holger Schurig10078322007-11-15 18:05:47 -050050 {1, 2412, LBS_TX_PWR_US_DEFAULT},
51 {2, 2417, LBS_TX_PWR_US_DEFAULT},
52 {3, 2422, LBS_TX_PWR_US_DEFAULT},
53 {4, 2427, LBS_TX_PWR_US_DEFAULT},
54 {5, 2432, LBS_TX_PWR_US_DEFAULT},
55 {6, 2437, LBS_TX_PWR_US_DEFAULT},
56 {7, 2442, LBS_TX_PWR_US_DEFAULT},
57 {8, 2447, LBS_TX_PWR_US_DEFAULT},
58 {9, 2452, LBS_TX_PWR_US_DEFAULT},
59 {10, 2457, LBS_TX_PWR_US_DEFAULT},
60 {11, 2462, LBS_TX_PWR_US_DEFAULT}
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020061};
62
63/* band: 'B/G', region: Europe ETSI */
64static struct chan_freq_power channel_freq_power_EU_BG[] = {
Holger Schurig10078322007-11-15 18:05:47 -050065 {1, 2412, LBS_TX_PWR_EMEA_DEFAULT},
66 {2, 2417, LBS_TX_PWR_EMEA_DEFAULT},
67 {3, 2422, LBS_TX_PWR_EMEA_DEFAULT},
68 {4, 2427, LBS_TX_PWR_EMEA_DEFAULT},
69 {5, 2432, LBS_TX_PWR_EMEA_DEFAULT},
70 {6, 2437, LBS_TX_PWR_EMEA_DEFAULT},
71 {7, 2442, LBS_TX_PWR_EMEA_DEFAULT},
72 {8, 2447, LBS_TX_PWR_EMEA_DEFAULT},
73 {9, 2452, LBS_TX_PWR_EMEA_DEFAULT},
74 {10, 2457, LBS_TX_PWR_EMEA_DEFAULT},
75 {11, 2462, LBS_TX_PWR_EMEA_DEFAULT},
76 {12, 2467, LBS_TX_PWR_EMEA_DEFAULT},
77 {13, 2472, LBS_TX_PWR_EMEA_DEFAULT}
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020078};
79
80/* band: 'B/G', region: Spain */
81static struct chan_freq_power channel_freq_power_SPN_BG[] = {
Holger Schurig10078322007-11-15 18:05:47 -050082 {10, 2457, LBS_TX_PWR_DEFAULT},
83 {11, 2462, LBS_TX_PWR_DEFAULT}
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020084};
85
86/* band: 'B/G', region: France */
87static struct chan_freq_power channel_freq_power_FR_BG[] = {
Holger Schurig10078322007-11-15 18:05:47 -050088 {10, 2457, LBS_TX_PWR_FR_DEFAULT},
89 {11, 2462, LBS_TX_PWR_FR_DEFAULT},
90 {12, 2467, LBS_TX_PWR_FR_DEFAULT},
91 {13, 2472, LBS_TX_PWR_FR_DEFAULT}
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020092};
93
94/* band: 'B/G', region: Japan */
95static struct chan_freq_power channel_freq_power_JPN_BG[] = {
Holger Schurig10078322007-11-15 18:05:47 -050096 {1, 2412, LBS_TX_PWR_JP_DEFAULT},
97 {2, 2417, LBS_TX_PWR_JP_DEFAULT},
98 {3, 2422, LBS_TX_PWR_JP_DEFAULT},
99 {4, 2427, LBS_TX_PWR_JP_DEFAULT},
100 {5, 2432, LBS_TX_PWR_JP_DEFAULT},
101 {6, 2437, LBS_TX_PWR_JP_DEFAULT},
102 {7, 2442, LBS_TX_PWR_JP_DEFAULT},
103 {8, 2447, LBS_TX_PWR_JP_DEFAULT},
104 {9, 2452, LBS_TX_PWR_JP_DEFAULT},
105 {10, 2457, LBS_TX_PWR_JP_DEFAULT},
106 {11, 2462, LBS_TX_PWR_JP_DEFAULT},
107 {12, 2467, LBS_TX_PWR_JP_DEFAULT},
108 {13, 2472, LBS_TX_PWR_JP_DEFAULT},
109 {14, 2484, LBS_TX_PWR_JP_DEFAULT}
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200110};
111
112/**
113 * the structure for channel, frequency and power
114 */
115struct region_cfp_table {
116 u8 region;
117 struct chan_freq_power *cfp_BG;
118 int cfp_no_BG;
119};
120
121/**
122 * the structure for the mapping between region and CFP
123 */
124static struct region_cfp_table region_cfp_table[] = {
125 {0x10, /*US FCC */
126 channel_freq_power_US_BG,
Denis Chengff8ac602007-09-02 18:30:18 +0800127 ARRAY_SIZE(channel_freq_power_US_BG),
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200128 }
129 ,
130 {0x20, /*CANADA IC */
131 channel_freq_power_US_BG,
Denis Chengff8ac602007-09-02 18:30:18 +0800132 ARRAY_SIZE(channel_freq_power_US_BG),
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200133 }
134 ,
135 {0x30, /*EU*/ channel_freq_power_EU_BG,
Denis Chengff8ac602007-09-02 18:30:18 +0800136 ARRAY_SIZE(channel_freq_power_EU_BG),
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200137 }
138 ,
139 {0x31, /*SPAIN*/ channel_freq_power_SPN_BG,
Denis Chengff8ac602007-09-02 18:30:18 +0800140 ARRAY_SIZE(channel_freq_power_SPN_BG),
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200141 }
142 ,
143 {0x32, /*FRANCE*/ channel_freq_power_FR_BG,
Denis Chengff8ac602007-09-02 18:30:18 +0800144 ARRAY_SIZE(channel_freq_power_FR_BG),
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200145 }
146 ,
147 {0x40, /*JAPAN*/ channel_freq_power_JPN_BG,
Denis Chengff8ac602007-09-02 18:30:18 +0800148 ARRAY_SIZE(channel_freq_power_JPN_BG),
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200149 }
150 ,
151/*Add new region here */
152};
153
154/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200155 * the table to keep region code
156 */
Holger Schurig10078322007-11-15 18:05:47 -0500157u16 lbs_region_code_to_index[MRVDRV_MAX_REGION_CODE] =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200158 { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 };
159
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200160/**
Dan Williams8c512762007-08-02 11:40:45 -0400161 * 802.11b/g supported bitrates (in 500Kb/s units)
162 */
Holger Schurig10078322007-11-15 18:05:47 -0500163u8 lbs_bg_rates[MAX_RATES] =
Dan Williams8c512762007-08-02 11:40:45 -0400164 { 0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c,
1650x00, 0x00 };
166
167/**
168 * FW rate table. FW refers to rates by their index in this table, not by the
169 * rate value itself. Values of 0x00 are
170 * reserved positions.
171 */
172static u8 fw_data_rates[MAX_RATES] =
173 { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12,
174 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00
175};
176
177/**
178 * @brief use index to get the data rate
179 *
180 * @param idx The index of data rate
181 * @return data rate or 0
182 */
Holger Schurig10078322007-11-15 18:05:47 -0500183u32 lbs_fw_index_to_data_rate(u8 idx)
Dan Williams8c512762007-08-02 11:40:45 -0400184{
185 if (idx >= sizeof(fw_data_rates))
186 idx = 0;
187 return fw_data_rates[idx];
188}
189
190/**
191 * @brief use rate to get the index
192 *
193 * @param rate data rate
194 * @return index or 0
195 */
Holger Schurig10078322007-11-15 18:05:47 -0500196u8 lbs_data_rate_to_fw_index(u32 rate)
Dan Williams8c512762007-08-02 11:40:45 -0400197{
198 u8 i;
199
200 if (!rate)
201 return 0;
202
203 for (i = 0; i < sizeof(fw_data_rates); i++) {
204 if (rate == fw_data_rates[i])
205 return i;
206 }
207 return 0;
208}
209
210/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200211 * Attributes exported through sysfs
212 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200213
214/**
Luis Carlos82fde742007-06-07 16:40:59 -0400215 * @brief Get function for sysfs attribute anycast_mask
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200216 */
Holger Schurig10078322007-11-15 18:05:47 -0500217static ssize_t lbs_anycast_get(struct device *dev,
Dan Williamsb59bb612007-06-18 11:50:43 -0400218 struct device_attribute *attr, char * buf)
219{
David Woodhouse301eacb2007-12-11 15:23:59 -0500220 struct lbs_private *priv = to_net_dev(dev)->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200221 struct cmd_ds_mesh_access mesh_access;
David Woodhouse301eacb2007-12-11 15:23:59 -0500222 int ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200223
224 memset(&mesh_access, 0, sizeof(mesh_access));
David Woodhouse301eacb2007-12-11 15:23:59 -0500225
226 ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_ANYCAST, &mesh_access);
227 if (ret)
228 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200229
Luis Carlos82fde742007-06-07 16:40:59 -0400230 return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0]));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200231}
232
233/**
Luis Carlos82fde742007-06-07 16:40:59 -0400234 * @brief Set function for sysfs attribute anycast_mask
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200235 */
Holger Schurig10078322007-11-15 18:05:47 -0500236static ssize_t lbs_anycast_set(struct device *dev,
Dan Williamsb59bb612007-06-18 11:50:43 -0400237 struct device_attribute *attr, const char * buf, size_t count)
238{
David Woodhouse301eacb2007-12-11 15:23:59 -0500239 struct lbs_private *priv = to_net_dev(dev)->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200240 struct cmd_ds_mesh_access mesh_access;
David Woodhouse981f1872007-05-25 23:36:54 -0400241 uint32_t datum;
David Woodhouse301eacb2007-12-11 15:23:59 -0500242 int ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200243
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200244 memset(&mesh_access, 0, sizeof(mesh_access));
Luis Carlos82fde742007-06-07 16:40:59 -0400245 sscanf(buf, "%x", &datum);
David Woodhouse981f1872007-05-25 23:36:54 -0400246 mesh_access.data[0] = cpu_to_le32(datum);
247
David Woodhouse301eacb2007-12-11 15:23:59 -0500248 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_ANYCAST, &mesh_access);
249 if (ret)
250 return ret;
251
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200252 return strlen(buf);
253}
254
David Woodhouse2fd6cfe2007-12-11 17:44:10 -0500255static int lbs_add_rtap(struct lbs_private *priv);
256static void lbs_remove_rtap(struct lbs_private *priv);
David Woodhouse23a397a2007-12-11 18:56:42 -0500257static int lbs_add_mesh(struct lbs_private *priv);
258static void lbs_remove_mesh(struct lbs_private *priv);
259
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400260
261/**
262 * Get function for sysfs attribute rtap
263 */
Holger Schurig10078322007-11-15 18:05:47 -0500264static ssize_t lbs_rtap_get(struct device *dev,
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400265 struct device_attribute *attr, char * buf)
266{
David Woodhousee7deced2007-12-08 18:29:16 +0000267 struct lbs_private *priv = to_net_dev(dev)->priv;
David Woodhouseaa21c002007-12-08 20:04:36 +0000268 return snprintf(buf, 5, "0x%X\n", priv->monitormode);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400269}
270
271/**
272 * Set function for sysfs attribute rtap
273 */
Holger Schurig10078322007-11-15 18:05:47 -0500274static ssize_t lbs_rtap_set(struct device *dev,
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400275 struct device_attribute *attr, const char * buf, size_t count)
276{
277 int monitor_mode;
David Woodhousee7deced2007-12-08 18:29:16 +0000278 struct lbs_private *priv = to_net_dev(dev)->priv;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400279
280 sscanf(buf, "%x", &monitor_mode);
Holger Schurig10078322007-11-15 18:05:47 -0500281 if (monitor_mode != LBS_MONITOR_OFF) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000282 if(priv->monitormode == monitor_mode)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400283 return strlen(buf);
David Woodhouseaa21c002007-12-08 20:04:36 +0000284 if (priv->monitormode == LBS_MONITOR_OFF) {
David Woodhouse85528552007-12-10 16:38:18 -0500285 if (priv->infra_open || priv->mesh_open)
286 return -EBUSY;
David Woodhouseaa21c002007-12-08 20:04:36 +0000287 if (priv->mode == IW_MODE_INFRA)
Holger Schurig10078322007-11-15 18:05:47 -0500288 lbs_send_deauthentication(priv);
David Woodhouseaa21c002007-12-08 20:04:36 +0000289 else if (priv->mode == IW_MODE_ADHOC)
Holger Schurig10078322007-11-15 18:05:47 -0500290 lbs_stop_adhoc_network(priv);
291 lbs_add_rtap(priv);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400292 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000293 priv->monitormode = monitor_mode;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400294 }
295
296 else {
David Woodhouseaa21c002007-12-08 20:04:36 +0000297 if (priv->monitormode == LBS_MONITOR_OFF)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400298 return strlen(buf);
David Woodhouseaa21c002007-12-08 20:04:36 +0000299 priv->monitormode = LBS_MONITOR_OFF;
Holger Schurig10078322007-11-15 18:05:47 -0500300 lbs_remove_rtap(priv);
David Woodhousef86a93e2007-12-08 19:46:19 +0000301
David Woodhouseaa21c002007-12-08 20:04:36 +0000302 if (priv->currenttxskb) {
303 dev_kfree_skb_any(priv->currenttxskb);
304 priv->currenttxskb = NULL;
David Woodhousef86a93e2007-12-08 19:46:19 +0000305 }
306
307 /* Wake queues, command thread, etc. */
308 lbs_host_to_card_done(priv);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400309 }
310
Holger Schurig10078322007-11-15 18:05:47 -0500311 lbs_prepare_and_send_command(priv,
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400312 CMD_802_11_MONITOR_MODE, CMD_ACT_SET,
David Woodhouseaa21c002007-12-08 20:04:36 +0000313 CMD_OPTION_WAITFORRSP, 0, &priv->monitormode);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400314 return strlen(buf);
315}
316
317/**
David Woodhouse23a397a2007-12-11 18:56:42 -0500318 * lbs_rtap attribute to be exported per ethX interface
319 * through sysfs (/sys/class/net/ethX/lbs_rtap)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400320 */
David Woodhouse23a397a2007-12-11 18:56:42 -0500321static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set );
322
323/**
324 * Get function for sysfs attribute mesh
325 */
326static ssize_t lbs_mesh_get(struct device *dev,
327 struct device_attribute *attr, char * buf)
328{
329 struct lbs_private *priv = to_net_dev(dev)->priv;
330 return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
331}
332
333/**
334 * Set function for sysfs attribute mesh
335 */
336static ssize_t lbs_mesh_set(struct device *dev,
337 struct device_attribute *attr, const char * buf, size_t count)
338{
339 struct lbs_private *priv = to_net_dev(dev)->priv;
340 int enable;
341 int ret;
342
343 sscanf(buf, "%x", &enable);
344 enable = !!enable;
345 if (enable == !!priv->mesh_dev)
346 return count;
347
348 ret = lbs_mesh_config(priv, enable);
349 if (ret)
350 return ret;
351
352 if (enable)
353 lbs_add_mesh(priv);
354 else
355 lbs_remove_mesh(priv);
356
357 return count;
358}
359
360/**
361 * lbs_mesh attribute to be exported per ethX interface
362 * through sysfs (/sys/class/net/ethX/lbs_mesh)
363 */
364static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -0400365
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200366/**
Luis Carlos82fde742007-06-07 16:40:59 -0400367 * anycast_mask attribute to be exported per mshX interface
368 * through sysfs (/sys/class/net/mshX/anycast_mask)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200369 */
Holger Schurig10078322007-11-15 18:05:47 -0500370static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200371
Holger Schurig10078322007-11-15 18:05:47 -0500372static struct attribute *lbs_mesh_sysfs_entries[] = {
Luis Carlos Coboa9f38d02007-08-02 11:52:29 -0400373 &dev_attr_anycast_mask.attr,
Luis Carlos Coboa9f38d02007-08-02 11:52:29 -0400374 NULL,
375};
376
Holger Schurig10078322007-11-15 18:05:47 -0500377static struct attribute_group lbs_mesh_attr_group = {
378 .attrs = lbs_mesh_sysfs_entries,
Luis Carlos Coboa9f38d02007-08-02 11:52:29 -0400379};
380
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200381/**
David Woodhouse85528552007-12-10 16:38:18 -0500382 * @brief This function opens the ethX or mshX interface
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200383 *
384 * @param dev A pointer to net_device structure
David Woodhouse85528552007-12-10 16:38:18 -0500385 * @return 0 or -EBUSY if monitor mode active
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200386 */
Holger Schurig10078322007-11-15 18:05:47 -0500387static int lbs_dev_open(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200388{
David Woodhouse85528552007-12-10 16:38:18 -0500389 struct lbs_private *priv = (struct lbs_private *) dev->priv ;
390 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200391
David Woodhouse85528552007-12-10 16:38:18 -0500392 spin_lock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200393
David Woodhouse85528552007-12-10 16:38:18 -0500394 if (priv->monitormode != LBS_MONITOR_OFF) {
395 ret = -EBUSY;
396 goto out;
Javier Cardona51d84f52007-05-25 12:06:56 -0400397 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200398
David Woodhouse85528552007-12-10 16:38:18 -0500399 if (dev == priv->mesh_dev) {
400 priv->mesh_open = 1;
401 priv->mesh_connect_status = LBS_CONNECTED;
402 netif_carrier_on(dev);
403 } else {
404 priv->infra_open = 1;
405
406 if (priv->connect_status == LBS_CONNECTED)
407 netif_carrier_on(dev);
408 else
409 netif_carrier_off(dev);
410 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200411
David Woodhouse85528552007-12-10 16:38:18 -0500412 if (!priv->tx_pending_len)
413 netif_wake_queue(dev);
414 out:
Brajesh Dave01d77d82007-11-20 17:44:14 -0500415
David Woodhouse85528552007-12-10 16:38:18 -0500416 spin_unlock_irq(&priv->driver_lock);
417 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200418}
419
420/**
421 * @brief This function closes the mshX interface
422 *
423 * @param dev A pointer to net_device structure
424 * @return 0
425 */
David Woodhouse85528552007-12-10 16:38:18 -0500426static int lbs_mesh_stop(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200427{
Holger Schurig69f90322007-11-23 15:43:44 +0100428 struct lbs_private *priv = (struct lbs_private *) (dev->priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200429
David Woodhouse85528552007-12-10 16:38:18 -0500430 spin_lock_irq(&priv->driver_lock);
431
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200432 priv->mesh_open = 0;
David Woodhouse85528552007-12-10 16:38:18 -0500433 priv->mesh_connect_status = LBS_DISCONNECTED;
434
435 netif_stop_queue(dev);
436 netif_carrier_off(dev);
437
438 spin_unlock_irq(&priv->driver_lock);
439 return 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200440}
441
442/**
443 * @brief This function closes the ethX interface
444 *
445 * @param dev A pointer to net_device structure
446 * @return 0
447 */
David Woodhouse85528552007-12-10 16:38:18 -0500448static int lbs_eth_stop(struct net_device *dev)
Holger Schurig78523da2007-05-25 11:49:19 -0400449{
Holger Schurig69f90322007-11-23 15:43:44 +0100450 struct lbs_private *priv = (struct lbs_private *) dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200451
David Woodhouse85528552007-12-10 16:38:18 -0500452 spin_lock_irq(&priv->driver_lock);
453
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200454 priv->infra_open = 0;
David Woodhouse85528552007-12-10 16:38:18 -0500455
456 netif_stop_queue(dev);
457
458 spin_unlock_irq(&priv->driver_lock);
459 return 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200460}
461
Holger Schurig10078322007-11-15 18:05:47 -0500462static void lbs_tx_timeout(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200463{
Holger Schurig69f90322007-11-23 15:43:44 +0100464 struct lbs_private *priv = (struct lbs_private *) dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200465
Holger Schurig9012b282007-05-25 11:27:16 -0400466 lbs_deb_enter(LBS_DEB_TX);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200467
Holger Schurig9012b282007-05-25 11:27:16 -0400468 lbs_pr_err("tx watch dog timeout\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200469
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200470 dev->trans_start = jiffies;
471
David Woodhouseaa21c002007-12-08 20:04:36 +0000472 if (priv->currenttxskb) {
David Woodhousea63b22b2007-12-08 20:56:44 +0000473 priv->eventcause = 0x01000000;
474 lbs_send_tx_feedback(priv);
Javier Cardona51d84f52007-05-25 12:06:56 -0400475 }
David Woodhousea63b22b2007-12-08 20:56:44 +0000476 /* XX: Shouldn't we also call into the hw-specific driver
477 to kick it somehow? */
478 lbs_host_to_card_done(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200479
Holger Schurig9012b282007-05-25 11:27:16 -0400480 lbs_deb_leave(LBS_DEB_TX);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200481}
482
David Woodhousee775ed72007-12-06 14:36:11 +0000483void lbs_host_to_card_done(struct lbs_private *priv)
484{
David Woodhousea63b22b2007-12-08 20:56:44 +0000485 unsigned long flags;
486
487 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhousee775ed72007-12-06 14:36:11 +0000488
489 priv->dnld_sent = DNLD_RES_RECEIVED;
490
491 /* Wake main thread if commands are pending */
David Woodhousea27b9f92007-12-12 00:41:51 -0500492 if (!priv->cur_cmd || priv->tx_pending_len > 0)
David Woodhousee775ed72007-12-06 14:36:11 +0000493 wake_up_interruptible(&priv->waitq);
494
David Woodhousea63b22b2007-12-08 20:56:44 +0000495 spin_unlock_irqrestore(&priv->driver_lock, flags);
David Woodhousee775ed72007-12-06 14:36:11 +0000496}
497EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
498
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200499/**
500 * @brief This function returns the network statistics
501 *
Holger Schurig69f90322007-11-23 15:43:44 +0100502 * @param dev A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200503 * @return A pointer to net_device_stats structure
504 */
Holger Schurig10078322007-11-15 18:05:47 -0500505static struct net_device_stats *lbs_get_stats(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200506{
Holger Schurig69f90322007-11-23 15:43:44 +0100507 struct lbs_private *priv = (struct lbs_private *) dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200508
509 return &priv->stats;
510}
511
Holger Schurig10078322007-11-15 18:05:47 -0500512static int lbs_set_mac_address(struct net_device *dev, void *addr)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200513{
514 int ret = 0;
Holger Schurig69f90322007-11-23 15:43:44 +0100515 struct lbs_private *priv = (struct lbs_private *) dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200516 struct sockaddr *phwaddr = addr;
517
Holger Schurig9012b282007-05-25 11:27:16 -0400518 lbs_deb_enter(LBS_DEB_NET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200519
Luis Carlos Cobo Rus0a0d08a2007-05-25 23:05:27 -0400520 /* In case it was called from the mesh device */
521 dev = priv->dev ;
522
David Woodhouseaa21c002007-12-08 20:04:36 +0000523 memset(priv->current_addr, 0, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200524
525 /* dev->dev_addr is 8 bytes */
Holger Schurigece56192007-08-02 11:53:06 -0400526 lbs_deb_hex(LBS_DEB_NET, "dev->dev_addr", dev->dev_addr, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200527
Holger Schurigece56192007-08-02 11:53:06 -0400528 lbs_deb_hex(LBS_DEB_NET, "addr", phwaddr->sa_data, ETH_ALEN);
David Woodhouseaa21c002007-12-08 20:04:36 +0000529 memcpy(priv->current_addr, phwaddr->sa_data, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200530
Holger Schurig10078322007-11-15 18:05:47 -0500531 ret = lbs_prepare_and_send_command(priv, CMD_802_11_MAC_ADDRESS,
Dan Williams0aef64d2007-08-02 11:31:18 -0400532 CMD_ACT_SET,
533 CMD_OPTION_WAITFORRSP, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200534
535 if (ret) {
Holger Schurig9012b282007-05-25 11:27:16 -0400536 lbs_deb_net("set MAC address failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200537 ret = -1;
538 goto done;
539 }
540
David Woodhouseaa21c002007-12-08 20:04:36 +0000541 lbs_deb_hex(LBS_DEB_NET, "priv->macaddr", priv->current_addr, ETH_ALEN);
542 memcpy(dev->dev_addr, priv->current_addr, ETH_ALEN);
Holger Schurig78523da2007-05-25 11:49:19 -0400543 if (priv->mesh_dev)
David Woodhouseaa21c002007-12-08 20:04:36 +0000544 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200545
546done:
Holger Schurig9012b282007-05-25 11:27:16 -0400547 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200548 return ret;
549}
550
David Woodhouseaa21c002007-12-08 20:04:36 +0000551static int lbs_copy_multicast_address(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200552 struct net_device *dev)
553{
554 int i = 0;
555 struct dev_mc_list *mcptr = dev->mc_list;
556
557 for (i = 0; i < dev->mc_count; i++) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000558 memcpy(&priv->multicastlist[i], mcptr->dmi_addr, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200559 mcptr = mcptr->next;
560 }
561
562 return i;
563
564}
565
Holger Schurig10078322007-11-15 18:05:47 -0500566static void lbs_set_multicast_list(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200567{
Holger Schurig69f90322007-11-23 15:43:44 +0100568 struct lbs_private *priv = dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200569 int oldpacketfilter;
Joe Perches0795af52007-10-03 17:59:30 -0700570 DECLARE_MAC_BUF(mac);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200571
Holger Schurig9012b282007-05-25 11:27:16 -0400572 lbs_deb_enter(LBS_DEB_NET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200573
David Woodhouseaa21c002007-12-08 20:04:36 +0000574 oldpacketfilter = priv->currentpacketfilter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200575
576 if (dev->flags & IFF_PROMISC) {
Holger Schurig9012b282007-05-25 11:27:16 -0400577 lbs_deb_net("enable promiscuous mode\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000578 priv->currentpacketfilter |=
Dan Williams0aef64d2007-08-02 11:31:18 -0400579 CMD_ACT_MAC_PROMISCUOUS_ENABLE;
David Woodhouseaa21c002007-12-08 20:04:36 +0000580 priv->currentpacketfilter &=
Dan Williams0aef64d2007-08-02 11:31:18 -0400581 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE |
582 CMD_ACT_MAC_MULTICAST_ENABLE);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200583 } else {
584 /* Multicast */
David Woodhouseaa21c002007-12-08 20:04:36 +0000585 priv->currentpacketfilter &=
Dan Williams0aef64d2007-08-02 11:31:18 -0400586 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200587
588 if (dev->flags & IFF_ALLMULTI || dev->mc_count >
589 MRVDRV_MAX_MULTICAST_LIST_SIZE) {
Holger Schurig9012b282007-05-25 11:27:16 -0400590 lbs_deb_net( "enabling all multicast\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000591 priv->currentpacketfilter |=
Dan Williams0aef64d2007-08-02 11:31:18 -0400592 CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
David Woodhouseaa21c002007-12-08 20:04:36 +0000593 priv->currentpacketfilter &=
Dan Williams0aef64d2007-08-02 11:31:18 -0400594 ~CMD_ACT_MAC_MULTICAST_ENABLE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200595 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +0000596 priv->currentpacketfilter &=
Dan Williams0aef64d2007-08-02 11:31:18 -0400597 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200598
599 if (!dev->mc_count) {
Holger Schurig9012b282007-05-25 11:27:16 -0400600 lbs_deb_net("no multicast addresses, "
601 "disabling multicast\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000602 priv->currentpacketfilter &=
Dan Williams0aef64d2007-08-02 11:31:18 -0400603 ~CMD_ACT_MAC_MULTICAST_ENABLE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200604 } else {
605 int i;
606
David Woodhouseaa21c002007-12-08 20:04:36 +0000607 priv->currentpacketfilter |=
Dan Williams0aef64d2007-08-02 11:31:18 -0400608 CMD_ACT_MAC_MULTICAST_ENABLE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200609
David Woodhouseaa21c002007-12-08 20:04:36 +0000610 priv->nr_of_multicastmacaddr =
611 lbs_copy_multicast_address(priv, dev);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200612
Holger Schurig9012b282007-05-25 11:27:16 -0400613 lbs_deb_net("multicast addresses: %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200614 dev->mc_count);
615
616 for (i = 0; i < dev->mc_count; i++) {
Joe Perches0795af52007-10-03 17:59:30 -0700617 lbs_deb_net("Multicast address %d:%s\n",
618 i, print_mac(mac,
David Woodhouseaa21c002007-12-08 20:04:36 +0000619 priv->multicastlist[i]));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200620 }
Holger Schurig9012b282007-05-25 11:27:16 -0400621 /* send multicast addresses to firmware */
Holger Schurig10078322007-11-15 18:05:47 -0500622 lbs_prepare_and_send_command(priv,
Dan Williams0aef64d2007-08-02 11:31:18 -0400623 CMD_MAC_MULTICAST_ADR,
624 CMD_ACT_SET, 0, 0,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200625 NULL);
626 }
627 }
628 }
629
David Woodhouseaa21c002007-12-08 20:04:36 +0000630 if (priv->currentpacketfilter != oldpacketfilter) {
Holger Schurig10078322007-11-15 18:05:47 -0500631 lbs_set_mac_packet_filter(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200632 }
633
Holger Schurig9012b282007-05-25 11:27:16 -0400634 lbs_deb_leave(LBS_DEB_NET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200635}
636
637/**
Holger Schurig10078322007-11-15 18:05:47 -0500638 * @brief This function handles the major jobs in the LBS driver.
Holger Schurig9012b282007-05-25 11:27:16 -0400639 * It handles all events generated by firmware, RX data received
640 * from firmware and TX data sent from kernel.
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200641 *
Holger Schurig10078322007-11-15 18:05:47 -0500642 * @param data A pointer to lbs_thread structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200643 * @return 0
644 */
Holger Schurig10078322007-11-15 18:05:47 -0500645static int lbs_thread(void *data)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200646{
Dan Williamsfe336152007-08-02 11:32:25 -0400647 struct net_device *dev = data;
Holger Schurig69f90322007-11-23 15:43:44 +0100648 struct lbs_private *priv = dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200649 wait_queue_t wait;
650 u8 ireg = 0;
651
Holger Schurig9012b282007-05-25 11:27:16 -0400652 lbs_deb_enter(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200653
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200654 init_waitqueue_entry(&wait, current);
655
Dan Williamsb1b19072007-08-20 11:10:45 -0400656 set_freezable();
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000657
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200658 for (;;) {
David Woodhouseb8d40bc2007-12-09 23:44:43 -0500659 int shouldsleep;
660
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000661 lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000662 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200663
Dan Williamsfe336152007-08-02 11:32:25 -0400664 add_wait_queue(&priv->waitq, &wait);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200665 set_current_state(TASK_INTERRUPTIBLE);
David Woodhouseaa21c002007-12-08 20:04:36 +0000666 spin_lock_irq(&priv->driver_lock);
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000667
David Woodhouseb8d40bc2007-12-09 23:44:43 -0500668 if (priv->surpriseremoved)
669 shouldsleep = 0; /* Bye */
670 else if (priv->psstate == PS_STATE_SLEEP)
671 shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */
672 else if (priv->intcounter)
673 shouldsleep = 0; /* Interrupt pending. Deal with it now */
David Woodhouseb15152a2007-12-11 11:55:37 -0500674 else if (!priv->fw_ready)
675 shouldsleep = 1; /* Firmware not ready. We're waiting for it */
David Woodhouseb8d40bc2007-12-09 23:44:43 -0500676 else if (priv->dnld_sent)
677 shouldsleep = 1; /* Something is en route to the device already */
David Woodhouse2eb188a2007-12-09 23:54:27 -0500678 else if (priv->tx_pending_len > 0)
679 shouldsleep = 0; /* We've a packet to send */
David Woodhouseb8d40bc2007-12-09 23:44:43 -0500680 else if (priv->cur_cmd)
681 shouldsleep = 1; /* Can't send a command; one already running */
682 else if (!list_empty(&priv->cmdpendingq))
683 shouldsleep = 0; /* We have a command to send */
684 else
685 shouldsleep = 1; /* No command */
686
687 if (shouldsleep) {
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000688 lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000689 priv->connect_status, priv->intcounter,
690 priv->psmode, priv->psstate);
691 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200692 schedule();
693 } else
David Woodhouseaa21c002007-12-08 20:04:36 +0000694 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200695
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000696 lbs_deb_thread("main-thread 222 (waking up): intcounter=%d currenttxskb=%p dnld_sent=%d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000697 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200698
699 set_current_state(TASK_RUNNING);
Dan Williamsfe336152007-08-02 11:32:25 -0400700 remove_wait_queue(&priv->waitq, &wait);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200701 try_to_freeze();
702
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000703 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000704 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200705
David Woodhouseaa21c002007-12-08 20:04:36 +0000706 if (kthread_should_stop() || priv->surpriseremoved) {
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000707 lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000708 priv->surpriseremoved);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200709 break;
710 }
711
712
David Woodhouseaa21c002007-12-08 20:04:36 +0000713 spin_lock_irq(&priv->driver_lock);
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000714
David Woodhouseaa21c002007-12-08 20:04:36 +0000715 if (priv->intcounter) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200716 u8 int_status;
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000717
David Woodhouseaa21c002007-12-08 20:04:36 +0000718 priv->intcounter = 0;
Holger Schurig208fdd22007-05-25 12:17:06 -0400719 int_status = priv->hw_get_int_status(priv, &ireg);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200720
721 if (int_status) {
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000722 lbs_deb_thread("main-thread: reading HOST_INT_STATUS_REG failed\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000723 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200724 continue;
725 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000726 priv->hisregcpy |= ireg;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200727 }
728
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000729 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000730 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200731
732 /* command response? */
David Woodhouseaa21c002007-12-08 20:04:36 +0000733 if (priv->hisregcpy & MRVDRV_CMD_UPLD_RDY) {
Holger Schurig9012b282007-05-25 11:27:16 -0400734 lbs_deb_thread("main-thread: cmd response ready\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200735
David Woodhouseaa21c002007-12-08 20:04:36 +0000736 priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY;
737 spin_unlock_irq(&priv->driver_lock);
Holger Schurig10078322007-11-15 18:05:47 -0500738 lbs_process_rx_command(priv);
David Woodhouseaa21c002007-12-08 20:04:36 +0000739 spin_lock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200740 }
741
742 /* Any Card Event */
David Woodhouseaa21c002007-12-08 20:04:36 +0000743 if (priv->hisregcpy & MRVDRV_CARDEVENT) {
Holger Schurig9012b282007-05-25 11:27:16 -0400744 lbs_deb_thread("main-thread: Card Event Activity\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200745
David Woodhouseaa21c002007-12-08 20:04:36 +0000746 priv->hisregcpy &= ~MRVDRV_CARDEVENT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200747
Holger Schurig208fdd22007-05-25 12:17:06 -0400748 if (priv->hw_read_event_cause(priv)) {
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000749 lbs_pr_alert("main-thread: hw_read_event_cause failed\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000750 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200751 continue;
752 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000753 spin_unlock_irq(&priv->driver_lock);
Holger Schurig10078322007-11-15 18:05:47 -0500754 lbs_process_event(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200755 } else
David Woodhouseaa21c002007-12-08 20:04:36 +0000756 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200757
David Woodhouseb15152a2007-12-11 11:55:37 -0500758 if (!priv->fw_ready)
759 continue;
760
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200761 /* Check if we need to confirm Sleep Request received previously */
David Woodhouseaa21c002007-12-08 20:04:36 +0000762 if (priv->psstate == PS_STATE_PRE_SLEEP &&
763 !priv->dnld_sent && !priv->cur_cmd) {
764 if (priv->connect_status == LBS_CONNECTED) {
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000765 lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000766 priv->intcounter, priv->currenttxskb, priv->dnld_sent, priv->cur_cmd);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200767
David Woodhouseaa21c002007-12-08 20:04:36 +0000768 lbs_ps_confirm_sleep(priv, (u16) priv->psmode);
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000769 } else {
770 /* workaround for firmware sending
771 * deauth/linkloss event immediately
772 * after sleep request; remove this
773 * after firmware fixes it
774 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000775 priv->psstate = PS_STATE_AWAKE;
David Woodhouse59f3e4b2007-12-08 17:42:59 +0000776 lbs_pr_alert("main-thread: ignore PS_SleepConfirm in non-connected state\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200777 }
778 }
779
780 /* The PS state is changed during processing of Sleep Request
781 * event above
782 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000783 if ((priv->psstate == PS_STATE_SLEEP) ||
784 (priv->psstate == PS_STATE_PRE_SLEEP))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200785 continue;
786
787 /* Execute the next command */
David Woodhouseaa21c002007-12-08 20:04:36 +0000788 if (!priv->dnld_sent && !priv->cur_cmd)
Holger Schurig10078322007-11-15 18:05:47 -0500789 lbs_execute_next_command(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200790
791 /* Wake-up command waiters which can't sleep in
Holger Schurig10078322007-11-15 18:05:47 -0500792 * lbs_prepare_and_send_command
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200793 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000794 if (!list_empty(&priv->cmdpendingq))
795 wake_up_all(&priv->cmd_pending);
David Woodhouse2eb188a2007-12-09 23:54:27 -0500796
797 spin_lock_irq(&priv->driver_lock);
798 if (!priv->dnld_sent && priv->tx_pending_len > 0) {
799 int ret = priv->hw_host_to_card(priv, MVMS_DAT,
800 priv->tx_pending_buf,
801 priv->tx_pending_len);
802 if (ret) {
803 lbs_deb_tx("host_to_card failed %d\n", ret);
804 priv->dnld_sent = DNLD_RES_RECEIVED;
805 }
806 priv->tx_pending_len = 0;
807 if (!priv->currenttxskb) {
808 /* We can wake the queues immediately if we aren't
809 waiting for TX feedback */
810 if (priv->connect_status == LBS_CONNECTED)
811 netif_wake_queue(priv->dev);
812 if (priv->mesh_dev &&
813 priv->mesh_connect_status == LBS_CONNECTED)
814 netif_wake_queue(priv->mesh_dev);
815 }
816 }
817 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200818 }
819
David Woodhouseaa21c002007-12-08 20:04:36 +0000820 del_timer(&priv->command_timer);
821 wake_up_all(&priv->cmd_pending);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200822
Holger Schurig9012b282007-05-25 11:27:16 -0400823 lbs_deb_leave(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200824 return 0;
825}
826
827/**
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400828 * @brief This function downloads firmware image, gets
829 * HW spec from firmware and set basic parameters to
830 * firmware.
831 *
Holger Schurig69f90322007-11-23 15:43:44 +0100832 * @param priv A pointer to struct lbs_private structure
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400833 * @return 0 or -1
834 */
Holger Schurig69f90322007-11-23 15:43:44 +0100835static int lbs_setup_firmware(struct lbs_private *priv)
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400836{
837 int ret = -1;
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400838
839 lbs_deb_enter(LBS_DEB_FW);
840
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400841 /*
842 * Read MAC address from HW
843 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000844 memset(priv->current_addr, 0xff, ETH_ALEN);
Dan Williams6e66f032007-12-11 12:42:16 -0500845 ret = lbs_update_hw_spec(priv);
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400846 if (ret) {
847 ret = -1;
848 goto done;
849 }
850
Holger Schurig10078322007-11-15 18:05:47 -0500851 lbs_set_mac_packet_filter(priv);
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400852
Dan Williams8e3c91b2007-12-11 15:50:59 -0500853 ret = lbs_get_data_rate(priv);
854 if (ret < 0) {
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400855 ret = -1;
856 goto done;
857 }
858
859 ret = 0;
860done:
861 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
862 return ret;
863}
864
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400865/**
866 * This function handles the timeout of command sending.
867 * It will re-send the same command again.
868 */
869static void command_timer_fn(unsigned long data)
870{
Holger Schurig69f90322007-11-23 15:43:44 +0100871 struct lbs_private *priv = (struct lbs_private *)data;
Dan Williamsddac4522007-12-11 13:49:39 -0500872 struct cmd_ctrl_node *node;
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400873 unsigned long flags;
874
Dan Williamsddac4522007-12-11 13:49:39 -0500875 node = priv->cur_cmd;
876 if (node == NULL) {
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400877 lbs_deb_fw("ptempnode empty\n");
878 return;
879 }
880
Dan Williamsddac4522007-12-11 13:49:39 -0500881 if (!node->cmdbuf) {
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400882 lbs_deb_fw("cmd is NULL\n");
883 return;
884 }
885
David Woodhousee1258172007-12-11 23:42:49 -0500886 lbs_pr_info("command %x timed out\n", le16_to_cpu(node->cmdbuf->command));
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400887
David Woodhouseaa21c002007-12-08 20:04:36 +0000888 if (!priv->fw_ready)
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400889 return;
890
David Woodhouseaa21c002007-12-08 20:04:36 +0000891 spin_lock_irqsave(&priv->driver_lock, flags);
892 priv->cur_cmd = NULL;
893 spin_unlock_irqrestore(&priv->driver_lock, flags);
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400894
895 lbs_deb_fw("re-sending same command because of timeout\n");
Dan Williamsddac4522007-12-11 13:49:39 -0500896 lbs_queue_cmd(priv, node, 0);
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400897
898 wake_up_interruptible(&priv->waitq);
899
900 return;
901}
902
Holger Schurig69f90322007-11-23 15:43:44 +0100903static int lbs_init_adapter(struct lbs_private *priv)
Dan Williams954ee162007-08-20 11:43:25 -0400904{
Dan Williams954ee162007-08-20 11:43:25 -0400905 size_t bufsize;
906 int i, ret = 0;
907
908 /* Allocate buffer to store the BSSID list */
909 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor);
David Woodhouseaa21c002007-12-08 20:04:36 +0000910 priv->networks = kzalloc(bufsize, GFP_KERNEL);
911 if (!priv->networks) {
Dan Williams954ee162007-08-20 11:43:25 -0400912 lbs_pr_err("Out of memory allocating beacons\n");
913 ret = -1;
914 goto out;
915 }
916
917 /* Initialize scan result lists */
David Woodhouseaa21c002007-12-08 20:04:36 +0000918 INIT_LIST_HEAD(&priv->network_free_list);
919 INIT_LIST_HEAD(&priv->network_list);
Dan Williams954ee162007-08-20 11:43:25 -0400920 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000921 list_add_tail(&priv->networks[i].list,
922 &priv->network_free_list);
Dan Williams954ee162007-08-20 11:43:25 -0400923 }
924
David Woodhouseaa21c002007-12-08 20:04:36 +0000925 priv->lbs_ps_confirm_sleep.seqnum = cpu_to_le16(++priv->seqnum);
926 priv->lbs_ps_confirm_sleep.command =
Dan Williams954ee162007-08-20 11:43:25 -0400927 cpu_to_le16(CMD_802_11_PS_MODE);
David Woodhouseaa21c002007-12-08 20:04:36 +0000928 priv->lbs_ps_confirm_sleep.size =
Dan Williams954ee162007-08-20 11:43:25 -0400929 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep));
David Woodhouseaa21c002007-12-08 20:04:36 +0000930 priv->lbs_ps_confirm_sleep.action =
Dan Williams954ee162007-08-20 11:43:25 -0400931 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED);
932
David Woodhouseaa21c002007-12-08 20:04:36 +0000933 memset(priv->current_addr, 0xff, ETH_ALEN);
Dan Williams954ee162007-08-20 11:43:25 -0400934
David Woodhouseaa21c002007-12-08 20:04:36 +0000935 priv->connect_status = LBS_DISCONNECTED;
936 priv->mesh_connect_status = LBS_DISCONNECTED;
937 priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
938 priv->mode = IW_MODE_INFRA;
939 priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
940 priv->currentpacketfilter = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
941 priv->radioon = RADIO_ON;
942 priv->auto_rate = 1;
943 priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
944 priv->psmode = LBS802_11POWERMODECAM;
945 priv->psstate = PS_STATE_FULL_POWER;
Dan Williams954ee162007-08-20 11:43:25 -0400946
David Woodhouseaa21c002007-12-08 20:04:36 +0000947 mutex_init(&priv->lock);
Dan Williams954ee162007-08-20 11:43:25 -0400948
David Woodhouseaa21c002007-12-08 20:04:36 +0000949 setup_timer(&priv->command_timer, command_timer_fn,
Dan Williams954ee162007-08-20 11:43:25 -0400950 (unsigned long)priv);
951
David Woodhouseaa21c002007-12-08 20:04:36 +0000952 INIT_LIST_HEAD(&priv->cmdfreeq);
953 INIT_LIST_HEAD(&priv->cmdpendingq);
Dan Williams954ee162007-08-20 11:43:25 -0400954
David Woodhouseaa21c002007-12-08 20:04:36 +0000955 spin_lock_init(&priv->driver_lock);
956 init_waitqueue_head(&priv->cmd_pending);
Dan Williams954ee162007-08-20 11:43:25 -0400957
958 /* Allocate the command buffers */
Holger Schurig10078322007-11-15 18:05:47 -0500959 if (lbs_allocate_cmd_buffer(priv)) {
Dan Williams954ee162007-08-20 11:43:25 -0400960 lbs_pr_err("Out of memory allocating command buffers\n");
961 ret = -1;
962 }
963
964out:
965 return ret;
966}
967
Holger Schurig69f90322007-11-23 15:43:44 +0100968static void lbs_free_adapter(struct lbs_private *priv)
Holger Schurigac558ca2007-08-02 11:49:06 -0400969{
Holger Schurigac558ca2007-08-02 11:49:06 -0400970 lbs_deb_fw("free command buffer\n");
Holger Schurig10078322007-11-15 18:05:47 -0500971 lbs_free_cmd_buffer(priv);
Holger Schurigac558ca2007-08-02 11:49:06 -0400972
973 lbs_deb_fw("free command_timer\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000974 del_timer(&priv->command_timer);
Holger Schurigac558ca2007-08-02 11:49:06 -0400975
976 lbs_deb_fw("free scan results table\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000977 kfree(priv->networks);
978 priv->networks = NULL;
Holger Schurigac558ca2007-08-02 11:49:06 -0400979}
980
Holger Schurig1df4e8f2007-08-02 11:45:12 -0400981/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200982 * @brief This function adds the card. it will probe the
Holger Schurig10078322007-11-15 18:05:47 -0500983 * card, allocate the lbs_priv and initialize the device.
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200984 *
985 * @param card A pointer to card
Holger Schurig69f90322007-11-23 15:43:44 +0100986 * @return A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200987 */
Holger Schurig69f90322007-11-23 15:43:44 +0100988struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200989{
990 struct net_device *dev = NULL;
Holger Schurig69f90322007-11-23 15:43:44 +0100991 struct lbs_private *priv = NULL;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200992
Holger Schurig9012b282007-05-25 11:27:16 -0400993 lbs_deb_enter(LBS_DEB_NET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200994
995 /* Allocate an Ethernet device and register it */
Holger Schurig69f90322007-11-23 15:43:44 +0100996 dev = alloc_etherdev(sizeof(struct lbs_private));
997 if (!dev) {
Holger Schurig9012b282007-05-25 11:27:16 -0400998 lbs_pr_err("init ethX device failed\n");
Dan Williams954ee162007-08-20 11:43:25 -0400999 goto done;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001000 }
Dan Williams64f104e2007-08-20 11:45:16 -04001001 priv = dev->priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001002
Holger Schurig10078322007-11-15 18:05:47 -05001003 if (lbs_init_adapter(priv)) {
Dan Williams954ee162007-08-20 11:43:25 -04001004 lbs_pr_err("failed to initialize adapter structure.\n");
1005 goto err_init_adapter;
1006 }
1007
Holger Schurig634b8f42007-05-25 13:05:16 -04001008 priv->dev = dev;
1009 priv->card = card;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001010 priv->mesh_open = 0;
1011 priv->infra_open = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001012
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001013 /* Setup the OS Interface to our functions */
David Woodhouse85528552007-12-10 16:38:18 -05001014 dev->open = lbs_dev_open;
David Woodhouse198cefb2007-12-09 15:04:19 -05001015 dev->hard_start_xmit = lbs_hard_start_xmit;
David Woodhouse85528552007-12-10 16:38:18 -05001016 dev->stop = lbs_eth_stop;
Holger Schurig10078322007-11-15 18:05:47 -05001017 dev->set_mac_address = lbs_set_mac_address;
1018 dev->tx_timeout = lbs_tx_timeout;
1019 dev->get_stats = lbs_get_stats;
Holger Schurigfb3dddf2007-05-25 11:58:22 -04001020 dev->watchdog_timeo = 5 * HZ;
Holger Schurig10078322007-11-15 18:05:47 -05001021 dev->ethtool_ops = &lbs_ethtool_ops;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001022#ifdef WIRELESS_EXT
Holger Schurig10078322007-11-15 18:05:47 -05001023 dev->wireless_handlers = (struct iw_handler_def *)&lbs_handler_def;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001024#endif
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001025 dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
Holger Schurig10078322007-11-15 18:05:47 -05001026 dev->set_multicast_list = lbs_set_multicast_list;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001027
Dan Williams7732ca42007-05-25 13:13:25 -04001028 SET_NETDEV_DEV(dev, dmdev);
1029
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001030 priv->rtap_net_dev = NULL;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001031
Dan Williamsfe336152007-08-02 11:32:25 -04001032 lbs_deb_thread("Starting main thread...\n");
1033 init_waitqueue_head(&priv->waitq);
Holger Schurig10078322007-11-15 18:05:47 -05001034 priv->main_thread = kthread_run(lbs_thread, dev, "lbs_main");
Dan Williamsfe336152007-08-02 11:32:25 -04001035 if (IS_ERR(priv->main_thread)) {
1036 lbs_deb_thread("Error creating main thread.\n");
David Woodhousee7deced2007-12-08 18:29:16 +00001037 goto err_init_adapter;
Dan Williamsfe336152007-08-02 11:32:25 -04001038 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001039
Holger Schurig10078322007-11-15 18:05:47 -05001040 priv->work_thread = create_singlethread_workqueue("lbs_worker");
1041 INIT_DELAYED_WORK(&priv->assoc_work, lbs_association_worker);
1042 INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker);
1043 INIT_WORK(&priv->sync_channel, lbs_sync_channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001044
David Woodhouse23a397a2007-12-11 18:56:42 -05001045 sprintf(priv->mesh_ssid, "mesh");
1046 priv->mesh_ssid_len = 4;
1047
Dan Williams954ee162007-08-20 11:43:25 -04001048 goto done;
1049
Dan Williams954ee162007-08-20 11:43:25 -04001050err_init_adapter:
Holger Schurig10078322007-11-15 18:05:47 -05001051 lbs_free_adapter(priv);
Dan Williams954ee162007-08-20 11:43:25 -04001052 free_netdev(dev);
1053 priv = NULL;
1054
1055done:
1056 lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv);
1057 return priv;
1058}
Holger Schurig10078322007-11-15 18:05:47 -05001059EXPORT_SYMBOL_GPL(lbs_add_card);
Dan Williams954ee162007-08-20 11:43:25 -04001060
1061
Holger Schurig69f90322007-11-23 15:43:44 +01001062int lbs_remove_card(struct lbs_private *priv)
Dan Williams954ee162007-08-20 11:43:25 -04001063{
Dan Williams954ee162007-08-20 11:43:25 -04001064 struct net_device *dev = priv->dev;
1065 union iwreq_data wrqu;
1066
1067 lbs_deb_enter(LBS_DEB_MAIN);
1068
David Woodhouse23a397a2007-12-11 18:56:42 -05001069 lbs_remove_mesh(priv);
Holger Schurig10078322007-11-15 18:05:47 -05001070 lbs_remove_rtap(priv);
Dan Williams954ee162007-08-20 11:43:25 -04001071
1072 dev = priv->dev;
Dan Williams954ee162007-08-20 11:43:25 -04001073
1074 cancel_delayed_work(&priv->scan_work);
1075 cancel_delayed_work(&priv->assoc_work);
1076 destroy_workqueue(priv->work_thread);
1077
David Woodhouseaa21c002007-12-08 20:04:36 +00001078 if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
1079 priv->psmode = LBS802_11POWERMODECAM;
Holger Schurig10078322007-11-15 18:05:47 -05001080 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001081 }
1082
Dan Williams954ee162007-08-20 11:43:25 -04001083 memset(wrqu.ap_addr.sa_data, 0xaa, ETH_ALEN);
1084 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1085 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
1086
1087 /* Stop the thread servicing the interrupts */
David Woodhouseaa21c002007-12-08 20:04:36 +00001088 priv->surpriseremoved = 1;
Dan Williams954ee162007-08-20 11:43:25 -04001089 kthread_stop(priv->main_thread);
1090
Holger Schurig10078322007-11-15 18:05:47 -05001091 lbs_free_adapter(priv);
Dan Williams954ee162007-08-20 11:43:25 -04001092
1093 priv->dev = NULL;
1094 free_netdev(dev);
1095
1096 lbs_deb_leave(LBS_DEB_MAIN);
1097 return 0;
1098}
Holger Schurig10078322007-11-15 18:05:47 -05001099EXPORT_SYMBOL_GPL(lbs_remove_card);
Dan Williams954ee162007-08-20 11:43:25 -04001100
1101
Holger Schurig69f90322007-11-23 15:43:44 +01001102int lbs_start_card(struct lbs_private *priv)
Dan Williams954ee162007-08-20 11:43:25 -04001103{
1104 struct net_device *dev = priv->dev;
1105 int ret = -1;
1106
1107 lbs_deb_enter(LBS_DEB_MAIN);
1108
1109 /* poke the firmware */
Holger Schurig10078322007-11-15 18:05:47 -05001110 ret = lbs_setup_firmware(priv);
Dan Williams954ee162007-08-20 11:43:25 -04001111 if (ret)
1112 goto done;
1113
1114 /* init 802.11d */
Holger Schurig10078322007-11-15 18:05:47 -05001115 lbs_init_11d(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001116
1117 if (register_netdev(dev)) {
Holger Schurig9012b282007-05-25 11:27:16 -04001118 lbs_pr_err("cannot register ethX device\n");
Dan Williams954ee162007-08-20 11:43:25 -04001119 goto done;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001120 }
David Woodhousee7deced2007-12-08 18:29:16 +00001121 if (device_create_file(&dev->dev, &dev_attr_lbs_rtap))
1122 lbs_pr_err("cannot register lbs_rtap attribute\n");
David Woodhouse23a397a2007-12-11 18:56:42 -05001123 if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
1124 lbs_pr_err("cannot register lbs_mesh attribute\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001125
Holger Schurig10078322007-11-15 18:05:47 -05001126 lbs_debugfs_init_one(priv, dev);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001127
Dan Williams954ee162007-08-20 11:43:25 -04001128 lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001129
Dan Williams954ee162007-08-20 11:43:25 -04001130 ret = 0;
1131
Holger Schurig32a74b72007-05-25 12:04:31 -04001132done:
Dan Williams954ee162007-08-20 11:43:25 -04001133 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
Holger Schurig32a74b72007-05-25 12:04:31 -04001134 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001135}
Holger Schurig10078322007-11-15 18:05:47 -05001136EXPORT_SYMBOL_GPL(lbs_start_card);
Dan Williams954ee162007-08-20 11:43:25 -04001137
1138
Holger Schurig69f90322007-11-23 15:43:44 +01001139int lbs_stop_card(struct lbs_private *priv)
Dan Williams954ee162007-08-20 11:43:25 -04001140{
1141 struct net_device *dev = priv->dev;
1142 int ret = -1;
1143 struct cmd_ctrl_node *cmdnode;
1144 unsigned long flags;
1145
1146 lbs_deb_enter(LBS_DEB_MAIN);
1147
1148 netif_stop_queue(priv->dev);
1149 netif_carrier_off(priv->dev);
1150
Holger Schurig10078322007-11-15 18:05:47 -05001151 lbs_debugfs_remove_one(priv);
David Woodhouse10bca0d2007-12-11 12:54:43 -05001152 device_remove_file(&dev->dev, &dev_attr_lbs_rtap);
David Woodhouse23a397a2007-12-11 18:56:42 -05001153 device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
Dan Williams954ee162007-08-20 11:43:25 -04001154
1155 /* Flush pending command nodes */
David Woodhouseaa21c002007-12-08 20:04:36 +00001156 spin_lock_irqsave(&priv->driver_lock, flags);
1157 list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
Dan Williams954ee162007-08-20 11:43:25 -04001158 cmdnode->cmdwaitqwoken = 1;
1159 wake_up_interruptible(&cmdnode->cmdwait_q);
1160 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001161 spin_unlock_irqrestore(&priv->driver_lock, flags);
Dan Williams954ee162007-08-20 11:43:25 -04001162
1163 unregister_netdev(dev);
1164
1165 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1166 return ret;
1167}
Holger Schurig10078322007-11-15 18:05:47 -05001168EXPORT_SYMBOL_GPL(lbs_stop_card);
Holger Schurig084708b2007-05-25 12:37:58 -04001169
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001170
Holger Schurig78523da2007-05-25 11:49:19 -04001171/**
1172 * @brief This function adds mshX interface
1173 *
Holger Schurig69f90322007-11-23 15:43:44 +01001174 * @param priv A pointer to the struct lbs_private structure
Holger Schurig78523da2007-05-25 11:49:19 -04001175 * @return 0 if successful, -X otherwise
1176 */
David Woodhouse23a397a2007-12-11 18:56:42 -05001177static int lbs_add_mesh(struct lbs_private *priv)
Holger Schurig78523da2007-05-25 11:49:19 -04001178{
1179 struct net_device *mesh_dev = NULL;
1180 int ret = 0;
1181
1182 lbs_deb_enter(LBS_DEB_MESH);
1183
1184 /* Allocate a virtual mesh device */
1185 if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) {
1186 lbs_deb_mesh("init mshX device failed\n");
1187 ret = -ENOMEM;
1188 goto done;
1189 }
1190 mesh_dev->priv = priv;
1191 priv->mesh_dev = mesh_dev;
1192
David Woodhouse85528552007-12-10 16:38:18 -05001193 mesh_dev->open = lbs_dev_open;
David Woodhouse198cefb2007-12-09 15:04:19 -05001194 mesh_dev->hard_start_xmit = lbs_hard_start_xmit;
David Woodhouse85528552007-12-10 16:38:18 -05001195 mesh_dev->stop = lbs_mesh_stop;
Holger Schurig10078322007-11-15 18:05:47 -05001196 mesh_dev->get_stats = lbs_get_stats;
1197 mesh_dev->set_mac_address = lbs_set_mac_address;
1198 mesh_dev->ethtool_ops = &lbs_ethtool_ops;
Holger Schurig634b8f42007-05-25 13:05:16 -04001199 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
1200 sizeof(priv->dev->dev_addr));
Holger Schurig78523da2007-05-25 11:49:19 -04001201
David Woodhouse23a397a2007-12-11 18:56:42 -05001202 SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
Dan Williams7732ca42007-05-25 13:13:25 -04001203
Holger Schurig78523da2007-05-25 11:49:19 -04001204#ifdef WIRELESS_EXT
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04001205 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def;
Holger Schurig78523da2007-05-25 11:49:19 -04001206#endif
Holger Schurig78523da2007-05-25 11:49:19 -04001207 /* Register virtual mesh interface */
1208 ret = register_netdev(mesh_dev);
1209 if (ret) {
1210 lbs_pr_err("cannot register mshX virtual interface\n");
1211 goto err_free;
1212 }
1213
Holger Schurig10078322007-11-15 18:05:47 -05001214 ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
Holger Schurig78523da2007-05-25 11:49:19 -04001215 if (ret)
1216 goto err_unregister;
1217
1218 /* Everything successful */
1219 ret = 0;
1220 goto done;
1221
Holger Schurig78523da2007-05-25 11:49:19 -04001222err_unregister:
1223 unregister_netdev(mesh_dev);
1224
1225err_free:
1226 free_netdev(mesh_dev);
1227
1228done:
1229 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
1230 return ret;
1231}
Holger Schurig10078322007-11-15 18:05:47 -05001232EXPORT_SYMBOL_GPL(lbs_add_mesh);
Holger Schurig78523da2007-05-25 11:49:19 -04001233
Holger Schurig084708b2007-05-25 12:37:58 -04001234
David Woodhouse23a397a2007-12-11 18:56:42 -05001235static void lbs_remove_mesh(struct lbs_private *priv)
Holger Schurig78523da2007-05-25 11:49:19 -04001236{
1237 struct net_device *mesh_dev;
1238
Dan Williams954ee162007-08-20 11:43:25 -04001239 lbs_deb_enter(LBS_DEB_MAIN);
Holger Schurig78523da2007-05-25 11:49:19 -04001240
1241 if (!priv)
1242 goto out;
1243
1244 mesh_dev = priv->mesh_dev;
David Woodhouse23a397a2007-12-11 18:56:42 -05001245 if (!mesh_dev)
1246 goto out;
Holger Schurig78523da2007-05-25 11:49:19 -04001247
1248 netif_stop_queue(mesh_dev);
Javier Cardona51d84f52007-05-25 12:06:56 -04001249 netif_carrier_off(priv->mesh_dev);
Holger Schurig78523da2007-05-25 11:49:19 -04001250
Holger Schurig10078322007-11-15 18:05:47 -05001251 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
Holger Schurig78523da2007-05-25 11:49:19 -04001252 unregister_netdev(mesh_dev);
1253
David Woodhouse23a397a2007-12-11 18:56:42 -05001254 priv->mesh_dev = NULL;
Holger Schurig78523da2007-05-25 11:49:19 -04001255 free_netdev(mesh_dev);
1256
1257out:
Dan Williams954ee162007-08-20 11:43:25 -04001258 lbs_deb_leave(LBS_DEB_MAIN);
Holger Schurig78523da2007-05-25 11:49:19 -04001259}
Holger Schurig10078322007-11-15 18:05:47 -05001260EXPORT_SYMBOL_GPL(lbs_remove_mesh);
Holger Schurig78523da2007-05-25 11:49:19 -04001261
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001262/**
1263 * @brief This function finds the CFP in
1264 * region_cfp_table based on region and band parameter.
1265 *
1266 * @param region The region code
1267 * @param band The band
1268 * @param cfp_no A pointer to CFP number
1269 * @return A pointer to CFP
1270 */
Holger Schurig10078322007-11-15 18:05:47 -05001271struct chan_freq_power *lbs_get_region_cfp_table(u8 region, u8 band, int *cfp_no)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001272{
1273 int i, end;
1274
Holger Schurig9012b282007-05-25 11:27:16 -04001275 lbs_deb_enter(LBS_DEB_MAIN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001276
Denis Chengff8ac602007-09-02 18:30:18 +08001277 end = ARRAY_SIZE(region_cfp_table);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001278
1279 for (i = 0; i < end ; i++) {
Holger Schurig9012b282007-05-25 11:27:16 -04001280 lbs_deb_main("region_cfp_table[i].region=%d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001281 region_cfp_table[i].region);
1282 if (region_cfp_table[i].region == region) {
1283 *cfp_no = region_cfp_table[i].cfp_no_BG;
Holger Schurig9012b282007-05-25 11:27:16 -04001284 lbs_deb_leave(LBS_DEB_MAIN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001285 return region_cfp_table[i].cfp_BG;
1286 }
1287 }
1288
Holger Schurig9012b282007-05-25 11:27:16 -04001289 lbs_deb_leave_args(LBS_DEB_MAIN, "ret NULL");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001290 return NULL;
1291}
1292
Holger Schurig69f90322007-11-23 15:43:44 +01001293int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001294{
Holger Schurig9012b282007-05-25 11:27:16 -04001295 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001296 int i = 0;
1297
1298 struct chan_freq_power *cfp;
1299 int cfp_no;
1300
Holger Schurig9012b282007-05-25 11:27:16 -04001301 lbs_deb_enter(LBS_DEB_MAIN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001302
David Woodhouseaa21c002007-12-08 20:04:36 +00001303 memset(priv->region_channel, 0, sizeof(priv->region_channel));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001304
1305 {
Holger Schurig10078322007-11-15 18:05:47 -05001306 cfp = lbs_get_region_cfp_table(region, band, &cfp_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001307 if (cfp != NULL) {
David Woodhouseaa21c002007-12-08 20:04:36 +00001308 priv->region_channel[i].nrcfp = cfp_no;
1309 priv->region_channel[i].CFP = cfp;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001310 } else {
Holger Schurig9012b282007-05-25 11:27:16 -04001311 lbs_deb_main("wrong region code %#x in band B/G\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001312 region);
Holger Schurig9012b282007-05-25 11:27:16 -04001313 ret = -1;
1314 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001315 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001316 priv->region_channel[i].valid = 1;
1317 priv->region_channel[i].region = region;
1318 priv->region_channel[i].band = band;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001319 i++;
1320 }
Holger Schurig9012b282007-05-25 11:27:16 -04001321out:
1322 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1323 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001324}
1325
1326/**
1327 * @brief This function handles the interrupt. it will change PS
1328 * state if applicable. it will wake up main_thread to handle
1329 * the interrupt event as well.
1330 *
1331 * @param dev A pointer to net_device structure
1332 * @return n/a
1333 */
David Woodhouse4f679492007-12-10 14:58:37 -05001334void lbs_interrupt(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001335{
Holger Schuriged37b512007-05-25 11:52:42 -04001336 lbs_deb_enter(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001337
David Woodhouse4f679492007-12-10 14:58:37 -05001338 lbs_deb_thread("lbs_interrupt: intcounter=%d\n", priv->intcounter);
1339
1340 if (spin_trylock(&priv->driver_lock)) {
1341 spin_unlock(&priv->driver_lock);
1342 printk(KERN_CRIT "%s called without driver_lock held\n", __func__);
1343 WARN_ON(1);
1344 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001345
David Woodhouseaa21c002007-12-08 20:04:36 +00001346 priv->intcounter++;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001347
David Woodhouse4f679492007-12-10 14:58:37 -05001348 if (priv->psstate == PS_STATE_SLEEP)
David Woodhouseaa21c002007-12-08 20:04:36 +00001349 priv->psstate = PS_STATE_AWAKE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001350
Dan Williamsfe336152007-08-02 11:32:25 -04001351 wake_up_interruptible(&priv->waitq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001352
Holger Schuriged37b512007-05-25 11:52:42 -04001353 lbs_deb_leave(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001354}
Holger Schurig10078322007-11-15 18:05:47 -05001355EXPORT_SYMBOL_GPL(lbs_interrupt);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001356
Holger Schurig69f90322007-11-23 15:43:44 +01001357int lbs_reset_device(struct lbs_private *priv)
Dan Williamseedc2a32007-08-02 11:36:22 -04001358{
1359 int ret;
1360
1361 lbs_deb_enter(LBS_DEB_MAIN);
Holger Schurig10078322007-11-15 18:05:47 -05001362 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RESET,
Dan Williamseedc2a32007-08-02 11:36:22 -04001363 CMD_ACT_HALT, 0, 0, NULL);
1364 msleep_interruptible(10);
1365
1366 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1367 return ret;
1368}
Holger Schurig10078322007-11-15 18:05:47 -05001369EXPORT_SYMBOL_GPL(lbs_reset_device);
Dan Williamseedc2a32007-08-02 11:36:22 -04001370
Andres Salomon4fb910f2007-11-20 17:43:45 -05001371static int __init lbs_init_module(void)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001372{
Holger Schurig9012b282007-05-25 11:27:16 -04001373 lbs_deb_enter(LBS_DEB_MAIN);
Holger Schurig10078322007-11-15 18:05:47 -05001374 lbs_debugfs_init();
Holger Schurig084708b2007-05-25 12:37:58 -04001375 lbs_deb_leave(LBS_DEB_MAIN);
1376 return 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001377}
1378
Andres Salomon4fb910f2007-11-20 17:43:45 -05001379static void __exit lbs_exit_module(void)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001380{
Holger Schurig9012b282007-05-25 11:27:16 -04001381 lbs_deb_enter(LBS_DEB_MAIN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001382
Holger Schurig10078322007-11-15 18:05:47 -05001383 lbs_debugfs_remove();
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001384
Holger Schurig9012b282007-05-25 11:27:16 -04001385 lbs_deb_leave(LBS_DEB_MAIN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001386}
1387
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001388/*
1389 * rtap interface support fuctions
1390 */
1391
Holger Schurig10078322007-11-15 18:05:47 -05001392static int lbs_rtap_open(struct net_device *dev)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001393{
David Woodhouse85528552007-12-10 16:38:18 -05001394 /* Yes, _stop_ the queue. Because we don't support injection */
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001395 netif_carrier_off(dev);
1396 netif_stop_queue(dev);
1397 return 0;
1398}
1399
Holger Schurig10078322007-11-15 18:05:47 -05001400static int lbs_rtap_stop(struct net_device *dev)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001401{
1402 return 0;
1403}
1404
Holger Schurig10078322007-11-15 18:05:47 -05001405static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001406{
1407 netif_stop_queue(dev);
David Woodhouse85528552007-12-10 16:38:18 -05001408 return NETDEV_TX_BUSY;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001409}
1410
Holger Schurig10078322007-11-15 18:05:47 -05001411static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001412{
Holger Schurig69f90322007-11-23 15:43:44 +01001413 struct lbs_private *priv = dev->priv;
David Woodhoused9268fb2007-12-09 16:22:21 -05001414 return &priv->stats;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001415}
1416
1417
David Woodhouse2fd6cfe2007-12-11 17:44:10 -05001418static void lbs_remove_rtap(struct lbs_private *priv)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001419{
1420 if (priv->rtap_net_dev == NULL)
1421 return;
1422 unregister_netdev(priv->rtap_net_dev);
David Woodhoused9268fb2007-12-09 16:22:21 -05001423 free_netdev(priv->rtap_net_dev);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001424 priv->rtap_net_dev = NULL;
1425}
1426
David Woodhouse2fd6cfe2007-12-11 17:44:10 -05001427static int lbs_add_rtap(struct lbs_private *priv)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001428{
1429 int rc = 0;
David Woodhoused9268fb2007-12-09 16:22:21 -05001430 struct net_device *rtap_dev;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001431
1432 if (priv->rtap_net_dev)
1433 return -EPERM;
1434
David Woodhoused9268fb2007-12-09 16:22:21 -05001435 rtap_dev = alloc_netdev(0, "rtap%d", ether_setup);
1436 if (rtap_dev == NULL)
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001437 return -ENOMEM;
1438
David Woodhouse121947c2007-12-09 19:54:11 -05001439 memcpy(rtap_dev->dev_addr, priv->current_addr, ETH_ALEN);
David Woodhoused9268fb2007-12-09 16:22:21 -05001440 rtap_dev->type = ARPHRD_IEEE80211_RADIOTAP;
1441 rtap_dev->open = lbs_rtap_open;
1442 rtap_dev->stop = lbs_rtap_stop;
1443 rtap_dev->get_stats = lbs_rtap_get_stats;
1444 rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit;
1445 rtap_dev->set_multicast_list = lbs_set_multicast_list;
1446 rtap_dev->priv = priv;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001447
David Woodhoused9268fb2007-12-09 16:22:21 -05001448 rc = register_netdev(rtap_dev);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001449 if (rc) {
David Woodhoused9268fb2007-12-09 16:22:21 -05001450 free_netdev(rtap_dev);
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001451 return rc;
1452 }
David Woodhoused9268fb2007-12-09 16:22:21 -05001453 priv->rtap_net_dev = rtap_dev;
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -04001454
1455 return 0;
1456}
1457
1458
Holger Schurig10078322007-11-15 18:05:47 -05001459module_init(lbs_init_module);
1460module_exit(lbs_exit_module);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001461
Holger Schurig084708b2007-05-25 12:37:58 -04001462MODULE_DESCRIPTION("Libertas WLAN Driver Library");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001463MODULE_AUTHOR("Marvell International Ltd.");
1464MODULE_LICENSE("GPL");