2 * This file contains the major functions in WLAN
3 * driver. It includes init, exit, open, close and main
7 #include <linux/moduleparam.h>
8 #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>
13 #include <linux/kthread.h>
15 #include <net/iw_handler.h>
16 #include <net/ieee80211.h>
26 #define DRIVER_RELEASE_VERSION "323.p0"
27 const char lbs_driver_version
[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
34 /* Module parameters */
35 unsigned int lbs_debug
;
36 EXPORT_SYMBOL_GPL(lbs_debug
);
37 module_param_named(libertas_debug
, lbs_debug
, int, 0644);
40 #define LBS_TX_PWR_DEFAULT 20 /*100mW */
41 #define LBS_TX_PWR_US_DEFAULT 20 /*100mW */
42 #define LBS_TX_PWR_JP_DEFAULT 16 /*50mW */
43 #define LBS_TX_PWR_FR_DEFAULT 20 /*100mW */
44 #define LBS_TX_PWR_EMEA_DEFAULT 20 /*100mW */
46 /* Format { channel, frequency (MHz), maxtxpower } */
47 /* band: 'B/G', region: USA FCC/Canada IC */
48 static struct chan_freq_power channel_freq_power_US_BG
[] = {
49 {1, 2412, LBS_TX_PWR_US_DEFAULT
},
50 {2, 2417, LBS_TX_PWR_US_DEFAULT
},
51 {3, 2422, LBS_TX_PWR_US_DEFAULT
},
52 {4, 2427, LBS_TX_PWR_US_DEFAULT
},
53 {5, 2432, LBS_TX_PWR_US_DEFAULT
},
54 {6, 2437, LBS_TX_PWR_US_DEFAULT
},
55 {7, 2442, LBS_TX_PWR_US_DEFAULT
},
56 {8, 2447, LBS_TX_PWR_US_DEFAULT
},
57 {9, 2452, LBS_TX_PWR_US_DEFAULT
},
58 {10, 2457, LBS_TX_PWR_US_DEFAULT
},
59 {11, 2462, LBS_TX_PWR_US_DEFAULT
}
62 /* band: 'B/G', region: Europe ETSI */
63 static struct chan_freq_power channel_freq_power_EU_BG
[] = {
64 {1, 2412, LBS_TX_PWR_EMEA_DEFAULT
},
65 {2, 2417, LBS_TX_PWR_EMEA_DEFAULT
},
66 {3, 2422, LBS_TX_PWR_EMEA_DEFAULT
},
67 {4, 2427, LBS_TX_PWR_EMEA_DEFAULT
},
68 {5, 2432, LBS_TX_PWR_EMEA_DEFAULT
},
69 {6, 2437, LBS_TX_PWR_EMEA_DEFAULT
},
70 {7, 2442, LBS_TX_PWR_EMEA_DEFAULT
},
71 {8, 2447, LBS_TX_PWR_EMEA_DEFAULT
},
72 {9, 2452, LBS_TX_PWR_EMEA_DEFAULT
},
73 {10, 2457, LBS_TX_PWR_EMEA_DEFAULT
},
74 {11, 2462, LBS_TX_PWR_EMEA_DEFAULT
},
75 {12, 2467, LBS_TX_PWR_EMEA_DEFAULT
},
76 {13, 2472, LBS_TX_PWR_EMEA_DEFAULT
}
79 /* band: 'B/G', region: Spain */
80 static struct chan_freq_power channel_freq_power_SPN_BG
[] = {
81 {10, 2457, LBS_TX_PWR_DEFAULT
},
82 {11, 2462, LBS_TX_PWR_DEFAULT
}
85 /* band: 'B/G', region: France */
86 static struct chan_freq_power channel_freq_power_FR_BG
[] = {
87 {10, 2457, LBS_TX_PWR_FR_DEFAULT
},
88 {11, 2462, LBS_TX_PWR_FR_DEFAULT
},
89 {12, 2467, LBS_TX_PWR_FR_DEFAULT
},
90 {13, 2472, LBS_TX_PWR_FR_DEFAULT
}
93 /* band: 'B/G', region: Japan */
94 static struct chan_freq_power channel_freq_power_JPN_BG
[] = {
95 {1, 2412, LBS_TX_PWR_JP_DEFAULT
},
96 {2, 2417, LBS_TX_PWR_JP_DEFAULT
},
97 {3, 2422, LBS_TX_PWR_JP_DEFAULT
},
98 {4, 2427, LBS_TX_PWR_JP_DEFAULT
},
99 {5, 2432, LBS_TX_PWR_JP_DEFAULT
},
100 {6, 2437, LBS_TX_PWR_JP_DEFAULT
},
101 {7, 2442, LBS_TX_PWR_JP_DEFAULT
},
102 {8, 2447, LBS_TX_PWR_JP_DEFAULT
},
103 {9, 2452, LBS_TX_PWR_JP_DEFAULT
},
104 {10, 2457, LBS_TX_PWR_JP_DEFAULT
},
105 {11, 2462, LBS_TX_PWR_JP_DEFAULT
},
106 {12, 2467, LBS_TX_PWR_JP_DEFAULT
},
107 {13, 2472, LBS_TX_PWR_JP_DEFAULT
},
108 {14, 2484, LBS_TX_PWR_JP_DEFAULT
}
112 * the structure for channel, frequency and power
114 struct region_cfp_table
{
116 struct chan_freq_power
*cfp_BG
;
121 * the structure for the mapping between region and CFP
123 static struct region_cfp_table region_cfp_table
[] = {
125 channel_freq_power_US_BG
,
126 ARRAY_SIZE(channel_freq_power_US_BG
),
129 {0x20, /*CANADA IC */
130 channel_freq_power_US_BG
,
131 ARRAY_SIZE(channel_freq_power_US_BG
),
134 {0x30, /*EU*/ channel_freq_power_EU_BG
,
135 ARRAY_SIZE(channel_freq_power_EU_BG
),
138 {0x31, /*SPAIN*/ channel_freq_power_SPN_BG
,
139 ARRAY_SIZE(channel_freq_power_SPN_BG
),
142 {0x32, /*FRANCE*/ channel_freq_power_FR_BG
,
143 ARRAY_SIZE(channel_freq_power_FR_BG
),
146 {0x40, /*JAPAN*/ channel_freq_power_JPN_BG
,
147 ARRAY_SIZE(channel_freq_power_JPN_BG
),
150 /*Add new region here */
154 * the table to keep region code
156 u16 lbs_region_code_to_index
[MRVDRV_MAX_REGION_CODE
] =
157 { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 };
160 * 802.11b/g supported bitrates (in 500Kb/s units)
162 u8 lbs_bg_rates
[MAX_RATES
] =
163 { 0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c,
167 * FW rate table. FW refers to rates by their index in this table, not by the
168 * rate value itself. Values of 0x00 are
169 * reserved positions.
171 static u8 fw_data_rates
[MAX_RATES
] =
172 { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12,
173 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00
177 * @brief use index to get the data rate
179 * @param idx The index of data rate
180 * @return data rate or 0
182 u32
lbs_fw_index_to_data_rate(u8 idx
)
184 if (idx
>= sizeof(fw_data_rates
))
186 return fw_data_rates
[idx
];
190 * @brief use rate to get the index
192 * @param rate data rate
195 u8
lbs_data_rate_to_fw_index(u32 rate
)
202 for (i
= 0; i
< sizeof(fw_data_rates
); i
++) {
203 if (rate
== fw_data_rates
[i
])
210 * Attributes exported through sysfs
214 * @brief Get function for sysfs attribute anycast_mask
216 static ssize_t
lbs_anycast_get(struct device
*dev
,
217 struct device_attribute
*attr
, char * buf
)
219 struct cmd_ds_mesh_access mesh_access
;
221 memset(&mesh_access
, 0, sizeof(mesh_access
));
222 lbs_prepare_and_send_command(to_net_dev(dev
)->priv
,
224 CMD_ACT_MESH_GET_ANYCAST
,
225 CMD_OPTION_WAITFORRSP
, 0, (void *)&mesh_access
);
227 return snprintf(buf
, 12, "0x%X\n", le32_to_cpu(mesh_access
.data
[0]));
231 * @brief Set function for sysfs attribute anycast_mask
233 static ssize_t
lbs_anycast_set(struct device
*dev
,
234 struct device_attribute
*attr
, const char * buf
, size_t count
)
236 struct cmd_ds_mesh_access mesh_access
;
239 memset(&mesh_access
, 0, sizeof(mesh_access
));
240 sscanf(buf
, "%x", &datum
);
241 mesh_access
.data
[0] = cpu_to_le32(datum
);
243 lbs_prepare_and_send_command((to_net_dev(dev
))->priv
,
245 CMD_ACT_MESH_SET_ANYCAST
,
246 CMD_OPTION_WAITFORRSP
, 0, (void *)&mesh_access
);
250 int lbs_add_rtap(lbs_private
*priv
);
251 void lbs_remove_rtap(lbs_private
*priv
);
254 * Get function for sysfs attribute rtap
256 static ssize_t
lbs_rtap_get(struct device
*dev
,
257 struct device_attribute
*attr
, char * buf
)
259 lbs_private
*priv
= (lbs_private
*) (to_net_dev(dev
))->priv
;
260 lbs_adapter
*adapter
= priv
->adapter
;
261 return snprintf(buf
, 5, "0x%X\n", adapter
->monitormode
);
265 * Set function for sysfs attribute rtap
267 static ssize_t
lbs_rtap_set(struct device
*dev
,
268 struct device_attribute
*attr
, const char * buf
, size_t count
)
271 lbs_private
*priv
= (lbs_private
*) (to_net_dev(dev
))->priv
;
272 lbs_adapter
*adapter
= priv
->adapter
;
274 sscanf(buf
, "%x", &monitor_mode
);
275 if (monitor_mode
!= LBS_MONITOR_OFF
) {
276 if(adapter
->monitormode
== monitor_mode
)
278 if (adapter
->monitormode
== LBS_MONITOR_OFF
) {
279 if (adapter
->mode
== IW_MODE_INFRA
)
280 lbs_send_deauthentication(priv
);
281 else if (adapter
->mode
== IW_MODE_ADHOC
)
282 lbs_stop_adhoc_network(priv
);
285 adapter
->monitormode
= monitor_mode
;
289 if (adapter
->monitormode
== LBS_MONITOR_OFF
)
291 adapter
->monitormode
= LBS_MONITOR_OFF
;
292 lbs_remove_rtap(priv
);
293 netif_wake_queue(priv
->dev
);
294 netif_wake_queue(priv
->mesh_dev
);
297 lbs_prepare_and_send_command(priv
,
298 CMD_802_11_MONITOR_MODE
, CMD_ACT_SET
,
299 CMD_OPTION_WAITFORRSP
, 0, &adapter
->monitormode
);
304 * lbs_rtap attribute to be exported per mshX interface
305 * through sysfs (/sys/class/net/mshX/libertas-rtap)
307 static DEVICE_ATTR(lbs_rtap
, 0644, lbs_rtap_get
,
311 * anycast_mask attribute to be exported per mshX interface
312 * through sysfs (/sys/class/net/mshX/anycast_mask)
314 static DEVICE_ATTR(anycast_mask
, 0644, lbs_anycast_get
, lbs_anycast_set
);
316 static ssize_t
lbs_autostart_enabled_get(struct device
*dev
,
317 struct device_attribute
*attr
, char * buf
)
319 struct cmd_ds_mesh_access mesh_access
;
321 memset(&mesh_access
, 0, sizeof(mesh_access
));
322 lbs_prepare_and_send_command(to_net_dev(dev
)->priv
,
324 CMD_ACT_MESH_GET_AUTOSTART_ENABLED
,
325 CMD_OPTION_WAITFORRSP
, 0, (void *)&mesh_access
);
327 return sprintf(buf
, "%d\n", le32_to_cpu(mesh_access
.data
[0]));
330 static ssize_t
lbs_autostart_enabled_set(struct device
*dev
,
331 struct device_attribute
*attr
, const char * buf
, size_t count
)
333 struct cmd_ds_mesh_access mesh_access
;
335 lbs_private
*priv
= (to_net_dev(dev
))->priv
;
338 memset(&mesh_access
, 0, sizeof(mesh_access
));
339 sscanf(buf
, "%d", &datum
);
340 mesh_access
.data
[0] = cpu_to_le32(datum
);
342 ret
= lbs_prepare_and_send_command(priv
,
344 CMD_ACT_MESH_SET_AUTOSTART_ENABLED
,
345 CMD_OPTION_WAITFORRSP
, 0, (void *)&mesh_access
);
347 priv
->mesh_autostart_enabled
= datum
? 1 : 0;
352 static DEVICE_ATTR(autostart_enabled
, 0644,
353 lbs_autostart_enabled_get
, lbs_autostart_enabled_set
);
355 static struct attribute
*lbs_mesh_sysfs_entries
[] = {
356 &dev_attr_anycast_mask
.attr
,
357 &dev_attr_autostart_enabled
.attr
,
361 static struct attribute_group lbs_mesh_attr_group
= {
362 .attrs
= lbs_mesh_sysfs_entries
,
366 * @brief Check if the device can be open and wait if necessary.
368 * @param dev A pointer to net_device structure
371 * For USB adapter, on some systems the device open handler will be
372 * called before FW ready. Use the following flag check and wait
373 * function to work around the issue.
376 static int pre_open_check(struct net_device
*dev
)
378 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
379 lbs_adapter
*adapter
= priv
->adapter
;
382 while (!adapter
->fw_ready
&& i
< 20) {
384 msleep_interruptible(100);
386 if (!adapter
->fw_ready
) {
387 lbs_pr_err("firmware not ready\n");
395 * @brief This function opens the device
397 * @param dev A pointer to net_device structure
400 static int lbs_dev_open(struct net_device
*dev
)
402 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
403 lbs_adapter
*adapter
= priv
->adapter
;
405 lbs_deb_enter(LBS_DEB_NET
);
409 if (adapter
->connect_status
== LBS_CONNECTED
) {
410 netif_carrier_on(priv
->dev
);
412 netif_carrier_on(priv
->mesh_dev
);
414 netif_carrier_off(priv
->dev
);
416 netif_carrier_off(priv
->mesh_dev
);
419 lbs_deb_leave(LBS_DEB_NET
);
423 * @brief This function opens the mshX interface
425 * @param dev A pointer to net_device structure
428 static int lbs_mesh_open(struct net_device
*dev
)
430 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
432 if (pre_open_check(dev
) == -1)
434 priv
->mesh_open
= 1 ;
435 netif_wake_queue(priv
->mesh_dev
);
436 if (priv
->infra_open
== 0)
437 return lbs_dev_open(priv
->dev
) ;
442 * @brief This function opens the ethX interface
444 * @param dev A pointer to net_device structure
447 static int lbs_open(struct net_device
*dev
)
449 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
451 if(pre_open_check(dev
) == -1)
453 priv
->infra_open
= 1 ;
454 netif_wake_queue(priv
->dev
);
456 return lbs_dev_open(priv
->dev
) ;
460 static int lbs_dev_close(struct net_device
*dev
)
462 lbs_private
*priv
= dev
->priv
;
464 lbs_deb_enter(LBS_DEB_NET
);
466 netif_carrier_off(priv
->dev
);
469 lbs_deb_leave(LBS_DEB_NET
);
474 * @brief This function closes the mshX interface
476 * @param dev A pointer to net_device structure
479 static int lbs_mesh_close(struct net_device
*dev
)
481 lbs_private
*priv
= (lbs_private
*) (dev
->priv
);
484 netif_stop_queue(priv
->mesh_dev
);
485 if (priv
->infra_open
== 0)
486 return lbs_dev_close(dev
);
492 * @brief This function closes the ethX interface
494 * @param dev A pointer to net_device structure
497 static int lbs_close(struct net_device
*dev
)
499 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
501 netif_stop_queue(dev
);
502 priv
->infra_open
= 0;
503 if (priv
->mesh_open
== 0)
504 return lbs_dev_close(dev
);
510 static int lbs_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
513 lbs_private
*priv
= dev
->priv
;
515 lbs_deb_enter(LBS_DEB_NET
);
517 if (priv
->dnld_sent
|| priv
->adapter
->TxLockFlag
) {
518 priv
->stats
.tx_dropped
++;
522 netif_stop_queue(priv
->dev
);
524 netif_stop_queue(priv
->mesh_dev
);
526 if (lbs_process_tx(priv
, skb
) == 0)
527 dev
->trans_start
= jiffies
;
529 lbs_deb_leave_args(LBS_DEB_NET
, "ret %d", ret
);
534 * @brief Mark mesh packets and handover them to lbs_hard_start_xmit
537 static int lbs_mesh_pre_start_xmit(struct sk_buff
*skb
,
538 struct net_device
*dev
)
540 lbs_private
*priv
= dev
->priv
;
543 lbs_deb_enter(LBS_DEB_MESH
);
544 if (priv
->adapter
->monitormode
!= LBS_MONITOR_OFF
) {
545 netif_stop_queue(dev
);
551 ret
= lbs_hard_start_xmit(skb
, priv
->dev
);
552 lbs_deb_leave_args(LBS_DEB_MESH
, "ret %d", ret
);
557 * @brief Mark non-mesh packets and handover them to lbs_hard_start_xmit
560 static int lbs_pre_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
562 lbs_private
*priv
= dev
->priv
;
565 lbs_deb_enter(LBS_DEB_NET
);
567 if (priv
->adapter
->monitormode
!= LBS_MONITOR_OFF
) {
568 netif_stop_queue(dev
);
572 UNSET_MESH_FRAME(skb
);
574 ret
= lbs_hard_start_xmit(skb
, dev
);
575 lbs_deb_leave_args(LBS_DEB_NET
, "ret %d", ret
);
579 static void lbs_tx_timeout(struct net_device
*dev
)
581 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
583 lbs_deb_enter(LBS_DEB_TX
);
585 lbs_pr_err("tx watch dog timeout\n");
587 priv
->dnld_sent
= DNLD_RES_RECEIVED
;
588 dev
->trans_start
= jiffies
;
590 if (priv
->adapter
->currenttxskb
) {
591 if (priv
->adapter
->monitormode
!= LBS_MONITOR_OFF
) {
592 /* If we are here, we have not received feedback from
593 the previous packet. Assume TX_FAIL and move on. */
594 priv
->adapter
->eventcause
= 0x01000000;
595 lbs_send_tx_feedback(priv
);
597 wake_up_interruptible(&priv
->waitq
);
598 } else if (priv
->adapter
->connect_status
== LBS_CONNECTED
) {
599 netif_wake_queue(priv
->dev
);
601 netif_wake_queue(priv
->mesh_dev
);
604 lbs_deb_leave(LBS_DEB_TX
);
608 * @brief This function returns the network statistics
610 * @param dev A pointer to lbs_private structure
611 * @return A pointer to net_device_stats structure
613 static struct net_device_stats
*lbs_get_stats(struct net_device
*dev
)
615 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
620 static int lbs_set_mac_address(struct net_device
*dev
, void *addr
)
623 lbs_private
*priv
= (lbs_private
*) dev
->priv
;
624 lbs_adapter
*adapter
= priv
->adapter
;
625 struct sockaddr
*phwaddr
= addr
;
627 lbs_deb_enter(LBS_DEB_NET
);
629 /* In case it was called from the mesh device */
632 memset(adapter
->current_addr
, 0, ETH_ALEN
);
634 /* dev->dev_addr is 8 bytes */
635 lbs_deb_hex(LBS_DEB_NET
, "dev->dev_addr", dev
->dev_addr
, ETH_ALEN
);
637 lbs_deb_hex(LBS_DEB_NET
, "addr", phwaddr
->sa_data
, ETH_ALEN
);
638 memcpy(adapter
->current_addr
, phwaddr
->sa_data
, ETH_ALEN
);
640 ret
= lbs_prepare_and_send_command(priv
, CMD_802_11_MAC_ADDRESS
,
642 CMD_OPTION_WAITFORRSP
, 0, NULL
);
645 lbs_deb_net("set MAC address failed\n");
650 lbs_deb_hex(LBS_DEB_NET
, "adapter->macaddr", adapter
->current_addr
, ETH_ALEN
);
651 memcpy(dev
->dev_addr
, adapter
->current_addr
, ETH_ALEN
);
653 memcpy(priv
->mesh_dev
->dev_addr
, adapter
->current_addr
, ETH_ALEN
);
656 lbs_deb_leave_args(LBS_DEB_NET
, "ret %d", ret
);
660 static int lbs_copy_multicast_address(lbs_adapter
*adapter
,
661 struct net_device
*dev
)
664 struct dev_mc_list
*mcptr
= dev
->mc_list
;
666 for (i
= 0; i
< dev
->mc_count
; i
++) {
667 memcpy(&adapter
->multicastlist
[i
], mcptr
->dmi_addr
, ETH_ALEN
);
675 static void lbs_set_multicast_list(struct net_device
*dev
)
677 lbs_private
*priv
= dev
->priv
;
678 lbs_adapter
*adapter
= priv
->adapter
;
680 DECLARE_MAC_BUF(mac
);
682 lbs_deb_enter(LBS_DEB_NET
);
684 oldpacketfilter
= adapter
->currentpacketfilter
;
686 if (dev
->flags
& IFF_PROMISC
) {
687 lbs_deb_net("enable promiscuous mode\n");
688 adapter
->currentpacketfilter
|=
689 CMD_ACT_MAC_PROMISCUOUS_ENABLE
;
690 adapter
->currentpacketfilter
&=
691 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE
|
692 CMD_ACT_MAC_MULTICAST_ENABLE
);
695 adapter
->currentpacketfilter
&=
696 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE
;
698 if (dev
->flags
& IFF_ALLMULTI
|| dev
->mc_count
>
699 MRVDRV_MAX_MULTICAST_LIST_SIZE
) {
700 lbs_deb_net( "enabling all multicast\n");
701 adapter
->currentpacketfilter
|=
702 CMD_ACT_MAC_ALL_MULTICAST_ENABLE
;
703 adapter
->currentpacketfilter
&=
704 ~CMD_ACT_MAC_MULTICAST_ENABLE
;
706 adapter
->currentpacketfilter
&=
707 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE
;
709 if (!dev
->mc_count
) {
710 lbs_deb_net("no multicast addresses, "
711 "disabling multicast\n");
712 adapter
->currentpacketfilter
&=
713 ~CMD_ACT_MAC_MULTICAST_ENABLE
;
717 adapter
->currentpacketfilter
|=
718 CMD_ACT_MAC_MULTICAST_ENABLE
;
720 adapter
->nr_of_multicastmacaddr
=
721 lbs_copy_multicast_address(adapter
, dev
);
723 lbs_deb_net("multicast addresses: %d\n",
726 for (i
= 0; i
< dev
->mc_count
; i
++) {
727 lbs_deb_net("Multicast address %d:%s\n",
729 adapter
->multicastlist
[i
]));
731 /* send multicast addresses to firmware */
732 lbs_prepare_and_send_command(priv
,
733 CMD_MAC_MULTICAST_ADR
,
740 if (adapter
->currentpacketfilter
!= oldpacketfilter
) {
741 lbs_set_mac_packet_filter(priv
);
744 lbs_deb_leave(LBS_DEB_NET
);
748 * @brief This function handles the major jobs in the LBS driver.
749 * It handles all events generated by firmware, RX data received
750 * from firmware and TX data sent from kernel.
752 * @param data A pointer to lbs_thread structure
755 static int lbs_thread(void *data
)
757 struct net_device
*dev
= data
;
758 lbs_private
*priv
= dev
->priv
;
759 lbs_adapter
*adapter
= priv
->adapter
;
763 lbs_deb_enter(LBS_DEB_THREAD
);
765 init_waitqueue_entry(&wait
, current
);
769 lbs_deb_thread( "main-thread 111: intcounter=%d "
770 "currenttxskb=%p dnld_sent=%d\n",
772 adapter
->currenttxskb
, priv
->dnld_sent
);
774 add_wait_queue(&priv
->waitq
, &wait
);
775 set_current_state(TASK_INTERRUPTIBLE
);
776 spin_lock_irq(&adapter
->driver_lock
);
777 if ((adapter
->psstate
== PS_STATE_SLEEP
) ||
778 (!adapter
->intcounter
779 && (priv
->dnld_sent
|| adapter
->cur_cmd
||
780 list_empty(&adapter
->cmdpendingq
)))) {
782 "main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
783 adapter
->connect_status
, adapter
->intcounter
,
784 adapter
->psmode
, adapter
->psstate
);
785 spin_unlock_irq(&adapter
->driver_lock
);
788 spin_unlock_irq(&adapter
->driver_lock
);
791 "main-thread 222 (waking up): intcounter=%d currenttxskb=%p "
792 "dnld_sent=%d\n", adapter
->intcounter
,
793 adapter
->currenttxskb
, priv
->dnld_sent
);
795 set_current_state(TASK_RUNNING
);
796 remove_wait_queue(&priv
->waitq
, &wait
);
799 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p "
802 adapter
->currenttxskb
, priv
->dnld_sent
);
804 if (kthread_should_stop()
805 || adapter
->surpriseremoved
) {
807 "main-thread: break from main thread: surpriseremoved=0x%x\n",
808 adapter
->surpriseremoved
);
813 spin_lock_irq(&adapter
->driver_lock
);
814 if (adapter
->intcounter
) {
816 adapter
->intcounter
= 0;
817 int_status
= priv
->hw_get_int_status(priv
, &ireg
);
821 "main-thread: reading HOST_INT_STATUS_REG failed\n");
822 spin_unlock_irq(&adapter
->driver_lock
);
825 adapter
->hisregcpy
|= ireg
;
828 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p "
831 adapter
->currenttxskb
, priv
->dnld_sent
);
833 /* command response? */
834 if (adapter
->hisregcpy
& MRVDRV_CMD_UPLD_RDY
) {
835 lbs_deb_thread("main-thread: cmd response ready\n");
837 adapter
->hisregcpy
&= ~MRVDRV_CMD_UPLD_RDY
;
838 spin_unlock_irq(&adapter
->driver_lock
);
839 lbs_process_rx_command(priv
);
840 spin_lock_irq(&adapter
->driver_lock
);
844 if (adapter
->hisregcpy
& MRVDRV_CARDEVENT
) {
845 lbs_deb_thread("main-thread: Card Event Activity\n");
847 adapter
->hisregcpy
&= ~MRVDRV_CARDEVENT
;
849 if (priv
->hw_read_event_cause(priv
)) {
851 "main-thread: hw_read_event_cause failed\n");
852 spin_unlock_irq(&adapter
->driver_lock
);
855 spin_unlock_irq(&adapter
->driver_lock
);
856 lbs_process_event(priv
);
858 spin_unlock_irq(&adapter
->driver_lock
);
860 /* Check if we need to confirm Sleep Request received previously */
861 if (adapter
->psstate
== PS_STATE_PRE_SLEEP
) {
862 if (!priv
->dnld_sent
&& !adapter
->cur_cmd
) {
863 if (adapter
->connect_status
==
866 "main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p "
867 "dnld_sent=%d cur_cmd=%p, confirm now\n",
869 adapter
->currenttxskb
,
873 lbs_ps_confirm_sleep(priv
,
874 (u16
) adapter
->psmode
);
876 /* workaround for firmware sending
877 * deauth/linkloss event immediately
878 * after sleep request, remove this
879 * after firmware fixes it
881 adapter
->psstate
= PS_STATE_AWAKE
;
883 "main-thread: ignore PS_SleepConfirm in non-connected state\n");
888 /* The PS state is changed during processing of Sleep Request
891 if ((priv
->adapter
->psstate
== PS_STATE_SLEEP
) ||
892 (priv
->adapter
->psstate
== PS_STATE_PRE_SLEEP
))
895 /* Execute the next command */
896 if (!priv
->dnld_sent
&& !priv
->adapter
->cur_cmd
)
897 lbs_execute_next_command(priv
);
899 /* Wake-up command waiters which can't sleep in
900 * lbs_prepare_and_send_command
902 if (!adapter
->nr_cmd_pending
)
903 wake_up_all(&adapter
->cmd_pending
);
905 lbs_tx_runqueue(priv
);
908 del_timer(&adapter
->command_timer
);
909 adapter
->nr_cmd_pending
= 0;
910 wake_up_all(&adapter
->cmd_pending
);
912 lbs_deb_leave(LBS_DEB_THREAD
);
917 * @brief This function downloads firmware image, gets
918 * HW spec from firmware and set basic parameters to
921 * @param priv A pointer to lbs_private structure
924 static int lbs_setup_firmware(lbs_private
*priv
)
927 lbs_adapter
*adapter
= priv
->adapter
;
928 struct cmd_ds_mesh_access mesh_access
;
930 lbs_deb_enter(LBS_DEB_FW
);
933 * Read MAC address from HW
935 memset(adapter
->current_addr
, 0xff, ETH_ALEN
);
937 ret
= lbs_prepare_and_send_command(priv
, CMD_GET_HW_SPEC
,
938 0, CMD_OPTION_WAITFORRSP
, 0, NULL
);
945 lbs_set_mac_packet_filter(priv
);
947 /* Get the supported Data rates */
948 ret
= lbs_prepare_and_send_command(priv
, CMD_802_11_DATA_RATE
,
950 CMD_OPTION_WAITFORRSP
, 0, NULL
);
957 /* Disable mesh autostart */
958 if (priv
->mesh_dev
) {
959 memset(&mesh_access
, 0, sizeof(mesh_access
));
960 mesh_access
.data
[0] = cpu_to_le32(0);
961 ret
= lbs_prepare_and_send_command(priv
,
963 CMD_ACT_MESH_SET_AUTOSTART_ENABLED
,
964 CMD_OPTION_WAITFORRSP
, 0, (void *)&mesh_access
);
969 priv
->mesh_autostart_enabled
= 0;
972 /* Set the boot2 version in firmware */
973 ret
= lbs_prepare_and_send_command(priv
, CMD_SET_BOOT2_VER
,
974 0, CMD_OPTION_WAITFORRSP
, 0, NULL
);
978 lbs_deb_leave_args(LBS_DEB_FW
, "ret %d", ret
);
983 * This function handles the timeout of command sending.
984 * It will re-send the same command again.
986 static void command_timer_fn(unsigned long data
)
988 lbs_private
*priv
= (lbs_private
*)data
;
989 lbs_adapter
*adapter
= priv
->adapter
;
990 struct cmd_ctrl_node
*ptempnode
;
991 struct cmd_ds_command
*cmd
;
994 ptempnode
= adapter
->cur_cmd
;
995 if (ptempnode
== NULL
) {
996 lbs_deb_fw("ptempnode empty\n");
1000 cmd
= (struct cmd_ds_command
*)ptempnode
->bufvirtualaddr
;
1002 lbs_deb_fw("cmd is NULL\n");
1006 lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd
->command
);
1008 if (!adapter
->fw_ready
)
1011 spin_lock_irqsave(&adapter
->driver_lock
, flags
);
1012 adapter
->cur_cmd
= NULL
;
1013 spin_unlock_irqrestore(&adapter
->driver_lock
, flags
);
1015 lbs_deb_fw("re-sending same command because of timeout\n");
1016 lbs_queue_cmd(adapter
, ptempnode
, 0);
1018 wake_up_interruptible(&priv
->waitq
);
1023 static int lbs_init_adapter(lbs_private
*priv
)
1025 lbs_adapter
*adapter
= priv
->adapter
;
1029 /* Allocate buffer to store the BSSID list */
1030 bufsize
= MAX_NETWORK_COUNT
* sizeof(struct bss_descriptor
);
1031 adapter
->networks
= kzalloc(bufsize
, GFP_KERNEL
);
1032 if (!adapter
->networks
) {
1033 lbs_pr_err("Out of memory allocating beacons\n");
1038 /* Initialize scan result lists */
1039 INIT_LIST_HEAD(&adapter
->network_free_list
);
1040 INIT_LIST_HEAD(&adapter
->network_list
);
1041 for (i
= 0; i
< MAX_NETWORK_COUNT
; i
++) {
1042 list_add_tail(&adapter
->networks
[i
].list
,
1043 &adapter
->network_free_list
);
1046 adapter
->lbs_ps_confirm_sleep
.seqnum
= cpu_to_le16(++adapter
->seqnum
);
1047 adapter
->lbs_ps_confirm_sleep
.command
=
1048 cpu_to_le16(CMD_802_11_PS_MODE
);
1049 adapter
->lbs_ps_confirm_sleep
.size
=
1050 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep
));
1051 adapter
->lbs_ps_confirm_sleep
.action
=
1052 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED
);
1054 memset(adapter
->current_addr
, 0xff, ETH_ALEN
);
1056 adapter
->connect_status
= LBS_DISCONNECTED
;
1057 adapter
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1058 adapter
->mode
= IW_MODE_INFRA
;
1059 adapter
->curbssparams
.channel
= DEFAULT_AD_HOC_CHANNEL
;
1060 adapter
->currentpacketfilter
= CMD_ACT_MAC_RX_ON
| CMD_ACT_MAC_TX_ON
;
1061 adapter
->radioon
= RADIO_ON
;
1062 adapter
->auto_rate
= 1;
1063 adapter
->capability
= WLAN_CAPABILITY_SHORT_PREAMBLE
;
1064 adapter
->psmode
= LBS802_11POWERMODECAM
;
1065 adapter
->psstate
= PS_STATE_FULL_POWER
;
1067 mutex_init(&adapter
->lock
);
1069 memset(&adapter
->tx_queue_ps
, 0, NR_TX_QUEUE
*sizeof(struct sk_buff
*));
1070 adapter
->tx_queue_idx
= 0;
1071 spin_lock_init(&adapter
->txqueue_lock
);
1073 setup_timer(&adapter
->command_timer
, command_timer_fn
,
1074 (unsigned long)priv
);
1076 INIT_LIST_HEAD(&adapter
->cmdfreeq
);
1077 INIT_LIST_HEAD(&adapter
->cmdpendingq
);
1079 spin_lock_init(&adapter
->driver_lock
);
1080 init_waitqueue_head(&adapter
->cmd_pending
);
1081 adapter
->nr_cmd_pending
= 0;
1083 /* Allocate the command buffers */
1084 if (lbs_allocate_cmd_buffer(priv
)) {
1085 lbs_pr_err("Out of memory allocating command buffers\n");
1093 static void lbs_free_adapter(lbs_private
*priv
)
1095 lbs_adapter
*adapter
= priv
->adapter
;
1098 lbs_deb_fw("why double free adapter?\n");
1102 lbs_deb_fw("free command buffer\n");
1103 lbs_free_cmd_buffer(priv
);
1105 lbs_deb_fw("free command_timer\n");
1106 del_timer(&adapter
->command_timer
);
1108 lbs_deb_fw("free scan results table\n");
1109 kfree(adapter
->networks
);
1110 adapter
->networks
= NULL
;
1112 /* Free the adapter object itself */
1113 lbs_deb_fw("free adapter\n");
1115 priv
->adapter
= NULL
;
1119 * @brief This function adds the card. it will probe the
1120 * card, allocate the lbs_priv and initialize the device.
1122 * @param card A pointer to card
1123 * @return A pointer to lbs_private structure
1125 lbs_private
*lbs_add_card(void *card
, struct device
*dmdev
)
1127 struct net_device
*dev
= NULL
;
1128 lbs_private
*priv
= NULL
;
1130 lbs_deb_enter(LBS_DEB_NET
);
1132 /* Allocate an Ethernet device and register it */
1133 if (!(dev
= alloc_etherdev(sizeof(lbs_private
)))) {
1134 lbs_pr_err("init ethX device failed\n");
1139 /* allocate buffer for lbs_adapter */
1140 if (!(priv
->adapter
= kzalloc(sizeof(lbs_adapter
), GFP_KERNEL
))) {
1141 lbs_pr_err("allocate buffer for lbs_adapter failed\n");
1145 if (lbs_init_adapter(priv
)) {
1146 lbs_pr_err("failed to initialize adapter structure.\n");
1147 goto err_init_adapter
;
1152 priv
->mesh_open
= 0;
1153 priv
->infra_open
= 0;
1154 priv
->hotplug_device
= dmdev
;
1156 /* Setup the OS Interface to our functions */
1157 dev
->open
= lbs_open
;
1158 dev
->hard_start_xmit
= lbs_pre_start_xmit
;
1159 dev
->stop
= lbs_close
;
1160 dev
->set_mac_address
= lbs_set_mac_address
;
1161 dev
->tx_timeout
= lbs_tx_timeout
;
1162 dev
->get_stats
= lbs_get_stats
;
1163 dev
->watchdog_timeo
= 5 * HZ
;
1164 dev
->ethtool_ops
= &lbs_ethtool_ops
;
1166 dev
->wireless_handlers
= (struct iw_handler_def
*)&lbs_handler_def
;
1168 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
1169 dev
->set_multicast_list
= lbs_set_multicast_list
;
1171 SET_NETDEV_DEV(dev
, dmdev
);
1173 priv
->rtap_net_dev
= NULL
;
1174 if (device_create_file(dmdev
, &dev_attr_lbs_rtap
))
1175 goto err_init_adapter
;
1177 lbs_deb_thread("Starting main thread...\n");
1178 init_waitqueue_head(&priv
->waitq
);
1179 priv
->main_thread
= kthread_run(lbs_thread
, dev
, "lbs_main");
1180 if (IS_ERR(priv
->main_thread
)) {
1181 lbs_deb_thread("Error creating main thread.\n");
1182 goto err_kthread_run
;
1185 priv
->work_thread
= create_singlethread_workqueue("lbs_worker");
1186 INIT_DELAYED_WORK(&priv
->assoc_work
, lbs_association_worker
);
1187 INIT_DELAYED_WORK(&priv
->scan_work
, lbs_scan_worker
);
1188 INIT_WORK(&priv
->sync_channel
, lbs_sync_channel
);
1193 device_remove_file(dmdev
, &dev_attr_lbs_rtap
);
1196 lbs_free_adapter(priv
);
1203 lbs_deb_leave_args(LBS_DEB_NET
, "priv %p", priv
);
1206 EXPORT_SYMBOL_GPL(lbs_add_card
);
1209 int lbs_remove_card(lbs_private
*priv
)
1211 lbs_adapter
*adapter
= priv
->adapter
;
1212 struct net_device
*dev
= priv
->dev
;
1213 union iwreq_data wrqu
;
1215 lbs_deb_enter(LBS_DEB_MAIN
);
1217 lbs_remove_rtap(priv
);
1220 device_remove_file(priv
->hotplug_device
, &dev_attr_lbs_rtap
);
1222 cancel_delayed_work(&priv
->scan_work
);
1223 cancel_delayed_work(&priv
->assoc_work
);
1224 destroy_workqueue(priv
->work_thread
);
1226 if (adapter
->psmode
== LBS802_11POWERMODEMAX_PSP
) {
1227 adapter
->psmode
= LBS802_11POWERMODECAM
;
1228 lbs_ps_wakeup(priv
, CMD_OPTION_WAITFORRSP
);
1231 memset(wrqu
.ap_addr
.sa_data
, 0xaa, ETH_ALEN
);
1232 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1233 wireless_send_event(priv
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1235 /* Stop the thread servicing the interrupts */
1236 adapter
->surpriseremoved
= 1;
1237 kthread_stop(priv
->main_thread
);
1239 lbs_free_adapter(priv
);
1244 lbs_deb_leave(LBS_DEB_MAIN
);
1247 EXPORT_SYMBOL_GPL(lbs_remove_card
);
1250 int lbs_start_card(lbs_private
*priv
)
1252 struct net_device
*dev
= priv
->dev
;
1255 lbs_deb_enter(LBS_DEB_MAIN
);
1257 /* poke the firmware */
1258 ret
= lbs_setup_firmware(priv
);
1265 if (register_netdev(dev
)) {
1266 lbs_pr_err("cannot register ethX device\n");
1270 lbs_debugfs_init_one(priv
, dev
);
1272 lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev
->name
);
1277 lbs_deb_leave_args(LBS_DEB_MAIN
, "ret %d", ret
);
1280 EXPORT_SYMBOL_GPL(lbs_start_card
);
1283 int lbs_stop_card(lbs_private
*priv
)
1285 struct net_device
*dev
= priv
->dev
;
1287 struct cmd_ctrl_node
*cmdnode
;
1288 unsigned long flags
;
1290 lbs_deb_enter(LBS_DEB_MAIN
);
1292 netif_stop_queue(priv
->dev
);
1293 netif_carrier_off(priv
->dev
);
1295 lbs_debugfs_remove_one(priv
);
1297 /* Flush pending command nodes */
1298 spin_lock_irqsave(&priv
->adapter
->driver_lock
, flags
);
1299 list_for_each_entry(cmdnode
, &priv
->adapter
->cmdpendingq
, list
) {
1300 cmdnode
->cmdwaitqwoken
= 1;
1301 wake_up_interruptible(&cmdnode
->cmdwait_q
);
1303 spin_unlock_irqrestore(&priv
->adapter
->driver_lock
, flags
);
1305 unregister_netdev(dev
);
1307 lbs_deb_leave_args(LBS_DEB_MAIN
, "ret %d", ret
);
1310 EXPORT_SYMBOL_GPL(lbs_stop_card
);
1314 * @brief This function adds mshX interface
1316 * @param priv A pointer to the lbs_private structure
1317 * @return 0 if successful, -X otherwise
1319 int lbs_add_mesh(lbs_private
*priv
, struct device
*dev
)
1321 struct net_device
*mesh_dev
= NULL
;
1324 lbs_deb_enter(LBS_DEB_MESH
);
1326 /* Allocate a virtual mesh device */
1327 if (!(mesh_dev
= alloc_netdev(0, "msh%d", ether_setup
))) {
1328 lbs_deb_mesh("init mshX device failed\n");
1332 mesh_dev
->priv
= priv
;
1333 priv
->mesh_dev
= mesh_dev
;
1335 mesh_dev
->open
= lbs_mesh_open
;
1336 mesh_dev
->hard_start_xmit
= lbs_mesh_pre_start_xmit
;
1337 mesh_dev
->stop
= lbs_mesh_close
;
1338 mesh_dev
->get_stats
= lbs_get_stats
;
1339 mesh_dev
->set_mac_address
= lbs_set_mac_address
;
1340 mesh_dev
->ethtool_ops
= &lbs_ethtool_ops
;
1341 memcpy(mesh_dev
->dev_addr
, priv
->dev
->dev_addr
,
1342 sizeof(priv
->dev
->dev_addr
));
1344 SET_NETDEV_DEV(priv
->mesh_dev
, dev
);
1347 mesh_dev
->wireless_handlers
= (struct iw_handler_def
*)&mesh_handler_def
;
1349 /* Register virtual mesh interface */
1350 ret
= register_netdev(mesh_dev
);
1352 lbs_pr_err("cannot register mshX virtual interface\n");
1356 ret
= sysfs_create_group(&(mesh_dev
->dev
.kobj
), &lbs_mesh_attr_group
);
1358 goto err_unregister
;
1360 /* Everything successful */
1365 unregister_netdev(mesh_dev
);
1368 free_netdev(mesh_dev
);
1371 lbs_deb_leave_args(LBS_DEB_MESH
, "ret %d", ret
);
1374 EXPORT_SYMBOL_GPL(lbs_add_mesh
);
1377 void lbs_remove_mesh(lbs_private
*priv
)
1379 struct net_device
*mesh_dev
;
1381 lbs_deb_enter(LBS_DEB_MAIN
);
1386 mesh_dev
= priv
->mesh_dev
;
1388 netif_stop_queue(mesh_dev
);
1389 netif_carrier_off(priv
->mesh_dev
);
1391 sysfs_remove_group(&(mesh_dev
->dev
.kobj
), &lbs_mesh_attr_group
);
1392 unregister_netdev(mesh_dev
);
1394 priv
->mesh_dev
= NULL
;
1395 free_netdev(mesh_dev
);
1398 lbs_deb_leave(LBS_DEB_MAIN
);
1400 EXPORT_SYMBOL_GPL(lbs_remove_mesh
);
1403 * @brief This function finds the CFP in
1404 * region_cfp_table based on region and band parameter.
1406 * @param region The region code
1407 * @param band The band
1408 * @param cfp_no A pointer to CFP number
1409 * @return A pointer to CFP
1411 struct chan_freq_power
*lbs_get_region_cfp_table(u8 region
, u8 band
, int *cfp_no
)
1415 lbs_deb_enter(LBS_DEB_MAIN
);
1417 end
= ARRAY_SIZE(region_cfp_table
);
1419 for (i
= 0; i
< end
; i
++) {
1420 lbs_deb_main("region_cfp_table[i].region=%d\n",
1421 region_cfp_table
[i
].region
);
1422 if (region_cfp_table
[i
].region
== region
) {
1423 *cfp_no
= region_cfp_table
[i
].cfp_no_BG
;
1424 lbs_deb_leave(LBS_DEB_MAIN
);
1425 return region_cfp_table
[i
].cfp_BG
;
1429 lbs_deb_leave_args(LBS_DEB_MAIN
, "ret NULL");
1433 int lbs_set_regiontable(lbs_private
*priv
, u8 region
, u8 band
)
1435 lbs_adapter
*adapter
= priv
->adapter
;
1439 struct chan_freq_power
*cfp
;
1442 lbs_deb_enter(LBS_DEB_MAIN
);
1444 memset(adapter
->region_channel
, 0, sizeof(adapter
->region_channel
));
1447 cfp
= lbs_get_region_cfp_table(region
, band
, &cfp_no
);
1449 adapter
->region_channel
[i
].nrcfp
= cfp_no
;
1450 adapter
->region_channel
[i
].CFP
= cfp
;
1452 lbs_deb_main("wrong region code %#x in band B/G\n",
1457 adapter
->region_channel
[i
].valid
= 1;
1458 adapter
->region_channel
[i
].region
= region
;
1459 adapter
->region_channel
[i
].band
= band
;
1463 lbs_deb_leave_args(LBS_DEB_MAIN
, "ret %d", ret
);
1468 * @brief This function handles the interrupt. it will change PS
1469 * state if applicable. it will wake up main_thread to handle
1470 * the interrupt event as well.
1472 * @param dev A pointer to net_device structure
1475 void lbs_interrupt(struct net_device
*dev
)
1477 lbs_private
*priv
= dev
->priv
;
1479 lbs_deb_enter(LBS_DEB_THREAD
);
1481 lbs_deb_thread("lbs_interrupt: intcounter=%d\n",
1482 priv
->adapter
->intcounter
);
1484 priv
->adapter
->intcounter
++;
1486 if (priv
->adapter
->psstate
== PS_STATE_SLEEP
) {
1487 priv
->adapter
->psstate
= PS_STATE_AWAKE
;
1488 netif_wake_queue(dev
);
1490 netif_wake_queue(priv
->mesh_dev
);
1493 wake_up_interruptible(&priv
->waitq
);
1495 lbs_deb_leave(LBS_DEB_THREAD
);
1497 EXPORT_SYMBOL_GPL(lbs_interrupt
);
1499 int lbs_reset_device(lbs_private
*priv
)
1503 lbs_deb_enter(LBS_DEB_MAIN
);
1504 ret
= lbs_prepare_and_send_command(priv
, CMD_802_11_RESET
,
1505 CMD_ACT_HALT
, 0, 0, NULL
);
1506 msleep_interruptible(10);
1508 lbs_deb_leave_args(LBS_DEB_MAIN
, "ret %d", ret
);
1511 EXPORT_SYMBOL_GPL(lbs_reset_device
);
1513 static int __init
lbs_init_module(void)
1515 lbs_deb_enter(LBS_DEB_MAIN
);
1517 lbs_deb_leave(LBS_DEB_MAIN
);
1521 static void __exit
lbs_exit_module(void)
1523 lbs_deb_enter(LBS_DEB_MAIN
);
1525 lbs_debugfs_remove();
1527 lbs_deb_leave(LBS_DEB_MAIN
);
1531 * rtap interface support fuctions
1534 static int lbs_rtap_open(struct net_device
*dev
)
1536 netif_carrier_off(dev
);
1537 netif_stop_queue(dev
);
1541 static int lbs_rtap_stop(struct net_device
*dev
)
1546 static int lbs_rtap_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
1548 netif_stop_queue(dev
);
1552 static struct net_device_stats
*lbs_rtap_get_stats(struct net_device
*dev
)
1554 lbs_private
*priv
= dev
->priv
;
1555 return &priv
->ieee
->stats
;
1559 void lbs_remove_rtap(lbs_private
*priv
)
1561 if (priv
->rtap_net_dev
== NULL
)
1563 unregister_netdev(priv
->rtap_net_dev
);
1564 free_ieee80211(priv
->rtap_net_dev
);
1565 priv
->rtap_net_dev
= NULL
;
1568 int lbs_add_rtap(lbs_private
*priv
)
1572 if (priv
->rtap_net_dev
)
1575 priv
->rtap_net_dev
= alloc_ieee80211(0);
1576 if (priv
->rtap_net_dev
== NULL
)
1580 priv
->ieee
= netdev_priv(priv
->rtap_net_dev
);
1582 strcpy(priv
->rtap_net_dev
->name
, "rtap%d");
1584 priv
->rtap_net_dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
1585 priv
->rtap_net_dev
->open
= lbs_rtap_open
;
1586 priv
->rtap_net_dev
->stop
= lbs_rtap_stop
;
1587 priv
->rtap_net_dev
->get_stats
= lbs_rtap_get_stats
;
1588 priv
->rtap_net_dev
->hard_start_xmit
= lbs_rtap_hard_start_xmit
;
1589 priv
->rtap_net_dev
->set_multicast_list
= lbs_set_multicast_list
;
1590 priv
->rtap_net_dev
->priv
= priv
;
1592 priv
->ieee
->iw_mode
= IW_MODE_MONITOR
;
1594 rc
= register_netdev(priv
->rtap_net_dev
);
1596 free_ieee80211(priv
->rtap_net_dev
);
1597 priv
->rtap_net_dev
= NULL
;
1605 module_init(lbs_init_module
);
1606 module_exit(lbs_exit_module
);
1608 MODULE_DESCRIPTION("Libertas WLAN Driver Library");
1609 MODULE_AUTHOR("Marvell International Ltd.");
1610 MODULE_LICENSE("GPL");