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 libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
34 /* Module parameters */
35 unsigned int libertas_debug = 0;
36 module_param(libertas_debug, int, 0644);
37 EXPORT_SYMBOL_GPL(libertas_debug);
40 #define WLAN_TX_PWR_DEFAULT 20 /*100mW */
41 #define WLAN_TX_PWR_US_DEFAULT 20 /*100mW */
42 #define WLAN_TX_PWR_JP_DEFAULT 16 /*50mW */
43 #define WLAN_TX_PWR_FR_DEFAULT 20 /*100mW */
44 #define WLAN_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, WLAN_TX_PWR_US_DEFAULT},
50 {2, 2417, WLAN_TX_PWR_US_DEFAULT},
51 {3, 2422, WLAN_TX_PWR_US_DEFAULT},
52 {4, 2427, WLAN_TX_PWR_US_DEFAULT},
53 {5, 2432, WLAN_TX_PWR_US_DEFAULT},
54 {6, 2437, WLAN_TX_PWR_US_DEFAULT},
55 {7, 2442, WLAN_TX_PWR_US_DEFAULT},
56 {8, 2447, WLAN_TX_PWR_US_DEFAULT},
57 {9, 2452, WLAN_TX_PWR_US_DEFAULT},
58 {10, 2457, WLAN_TX_PWR_US_DEFAULT},
59 {11, 2462, WLAN_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, WLAN_TX_PWR_EMEA_DEFAULT},
65 {2, 2417, WLAN_TX_PWR_EMEA_DEFAULT},
66 {3, 2422, WLAN_TX_PWR_EMEA_DEFAULT},
67 {4, 2427, WLAN_TX_PWR_EMEA_DEFAULT},
68 {5, 2432, WLAN_TX_PWR_EMEA_DEFAULT},
69 {6, 2437, WLAN_TX_PWR_EMEA_DEFAULT},
70 {7, 2442, WLAN_TX_PWR_EMEA_DEFAULT},
71 {8, 2447, WLAN_TX_PWR_EMEA_DEFAULT},
72 {9, 2452, WLAN_TX_PWR_EMEA_DEFAULT},
73 {10, 2457, WLAN_TX_PWR_EMEA_DEFAULT},
74 {11, 2462, WLAN_TX_PWR_EMEA_DEFAULT},
75 {12, 2467, WLAN_TX_PWR_EMEA_DEFAULT},
76 {13, 2472, WLAN_TX_PWR_EMEA_DEFAULT}
79 /* band: 'B/G', region: Spain */
80 static struct chan_freq_power channel_freq_power_SPN_BG[] = {
81 {10, 2457, WLAN_TX_PWR_DEFAULT},
82 {11, 2462, WLAN_TX_PWR_DEFAULT}
85 /* band: 'B/G', region: France */
86 static struct chan_freq_power channel_freq_power_FR_BG[] = {
87 {10, 2457, WLAN_TX_PWR_FR_DEFAULT},
88 {11, 2462, WLAN_TX_PWR_FR_DEFAULT},
89 {12, 2467, WLAN_TX_PWR_FR_DEFAULT},
90 {13, 2472, WLAN_TX_PWR_FR_DEFAULT}
93 /* band: 'B/G', region: Japan */
94 static struct chan_freq_power channel_freq_power_JPN_BG[] = {
95 {1, 2412, WLAN_TX_PWR_JP_DEFAULT},
96 {2, 2417, WLAN_TX_PWR_JP_DEFAULT},
97 {3, 2422, WLAN_TX_PWR_JP_DEFAULT},
98 {4, 2427, WLAN_TX_PWR_JP_DEFAULT},
99 {5, 2432, WLAN_TX_PWR_JP_DEFAULT},
100 {6, 2437, WLAN_TX_PWR_JP_DEFAULT},
101 {7, 2442, WLAN_TX_PWR_JP_DEFAULT},
102 {8, 2447, WLAN_TX_PWR_JP_DEFAULT},
103 {9, 2452, WLAN_TX_PWR_JP_DEFAULT},
104 {10, 2457, WLAN_TX_PWR_JP_DEFAULT},
105 {11, 2462, WLAN_TX_PWR_JP_DEFAULT},
106 {12, 2467, WLAN_TX_PWR_JP_DEFAULT},
107 {13, 2472, WLAN_TX_PWR_JP_DEFAULT},
108 {14, 2484, WLAN_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 sizeof(channel_freq_power_US_BG) / sizeof(struct chan_freq_power),
129 {0x20, /*CANADA IC */
130 channel_freq_power_US_BG,
131 sizeof(channel_freq_power_US_BG) / sizeof(struct chan_freq_power),
134 {0x30, /*EU*/ channel_freq_power_EU_BG,
135 sizeof(channel_freq_power_EU_BG) / sizeof(struct chan_freq_power),
138 {0x31, /*SPAIN*/ channel_freq_power_SPN_BG,
139 sizeof(channel_freq_power_SPN_BG) / sizeof(struct chan_freq_power),
142 {0x32, /*FRANCE*/ channel_freq_power_FR_BG,
143 sizeof(channel_freq_power_FR_BG) / sizeof(struct chan_freq_power),
146 {0x40, /*JAPAN*/ channel_freq_power_JPN_BG,
147 sizeof(channel_freq_power_JPN_BG) / sizeof(struct chan_freq_power),
150 /*Add new region here */
154 * the table to keep region code
156 u16 libertas_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 libertas_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 libertas_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 libertas_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 libertas_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 libertas_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 libertas_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 libertas_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 libertas_add_rtap(wlan_private *priv);
251 void libertas_remove_rtap(wlan_private *priv);
254 * Get function for sysfs attribute rtap
256 static ssize_t libertas_rtap_get(struct device * dev,
257 struct device_attribute *attr, char * buf)
259 wlan_private *priv = (wlan_private *) dev->driver_data;
260 wlan_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 libertas_rtap_set(struct device * dev,
268 struct device_attribute *attr, const char * buf, size_t count)
271 wlan_private *priv = (wlan_private *) dev->driver_data;
272 wlan_adapter *adapter = priv->adapter;
274 sscanf(buf, "%x", &monitor_mode);
275 if (monitor_mode != WLAN_MONITOR_OFF) {
276 if(adapter->monitormode == monitor_mode)
278 if (adapter->monitormode == WLAN_MONITOR_OFF) {
279 if (adapter->mode == IW_MODE_INFRA)
280 libertas_send_deauthentication(priv);
281 else if (adapter->mode == IW_MODE_ADHOC)
282 libertas_stop_adhoc_network(priv);
283 libertas_add_rtap(priv);
285 adapter->monitormode = monitor_mode;
289 if(adapter->monitormode == WLAN_MONITOR_OFF)
291 adapter->monitormode = WLAN_MONITOR_OFF;
292 libertas_remove_rtap(priv);
293 netif_wake_queue(priv->dev);
294 netif_wake_queue(priv->mesh_dev);
297 libertas_prepare_and_send_command(priv,
298 CMD_802_11_MONITOR_MODE, CMD_ACT_SET,
299 CMD_OPTION_WAITFORRSP, 0, &adapter->monitormode);
304 * libertas_rtap attribute to be exported per mshX interface
305 * through sysfs (/sys/class/net/mshX/libertas-rtap)
307 static DEVICE_ATTR(libertas_rtap, 0644, libertas_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, libertas_anycast_get, libertas_anycast_set);
316 static ssize_t libertas_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 libertas_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 libertas_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 wlan_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 = libertas_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 libertas_autostart_enabled_get, libertas_autostart_enabled_set);
355 static struct attribute *libertas_mesh_sysfs_entries[] = {
356 &dev_attr_anycast_mask.attr,
357 &dev_attr_autostart_enabled.attr,
361 static struct attribute_group libertas_mesh_attr_group = {
362 .attrs = libertas_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 wlan_private *priv = (wlan_private *) dev->priv;
379 wlan_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 libertas_dev_open(struct net_device *dev)
402 wlan_private *priv = (wlan_private *) dev->priv;
403 wlan_adapter *adapter = priv->adapter;
405 lbs_deb_enter(LBS_DEB_NET);
409 if (adapter->connect_status == LIBERTAS_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 libertas_mesh_open(struct net_device *dev)
430 wlan_private *priv = (wlan_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 libertas_dev_open(priv->dev) ;
442 * @brief This function opens the ethX interface
444 * @param dev A pointer to net_device structure
447 static int libertas_open(struct net_device *dev)
449 wlan_private *priv = (wlan_private *) dev->priv ;
451 if(pre_open_check(dev) == -1)
453 priv->infra_open = 1 ;
454 netif_wake_queue(priv->dev);
456 return libertas_dev_open(priv->dev) ;
460 static int libertas_dev_close(struct net_device *dev)
462 wlan_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 libertas_mesh_close(struct net_device *dev)
481 wlan_private *priv = (wlan_private *) (dev->priv);
484 netif_stop_queue(priv->mesh_dev);
485 if (priv->infra_open == 0)
486 return libertas_dev_close(dev);
492 * @brief This function closes the ethX interface
494 * @param dev A pointer to net_device structure
497 static int libertas_close(struct net_device *dev)
499 wlan_private *priv = (wlan_private *) dev->priv;
501 netif_stop_queue(dev);
502 priv->infra_open = 0;
503 if (priv->mesh_open == 0)
504 return libertas_dev_close(dev);
510 static int libertas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
513 wlan_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 (libertas_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 libertas_hard_start_xmit
537 static int libertas_mesh_pre_start_xmit(struct sk_buff *skb,
538 struct net_device *dev)
540 wlan_private *priv = dev->priv;
543 lbs_deb_enter(LBS_DEB_MESH);
544 if(priv->adapter->monitormode != WLAN_MONITOR_OFF) {
545 netif_stop_queue(dev);
551 ret = libertas_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 libertas_hard_start_xmit
560 static int libertas_pre_start_xmit(struct sk_buff *skb, struct net_device *dev)
562 wlan_private *priv = dev->priv;
565 lbs_deb_enter(LBS_DEB_NET);
567 if(priv->adapter->monitormode != WLAN_MONITOR_OFF) {
568 netif_stop_queue(dev);
572 UNSET_MESH_FRAME(skb);
574 ret = libertas_hard_start_xmit(skb, dev);
575 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
579 static void libertas_tx_timeout(struct net_device *dev)
581 wlan_private *priv = (wlan_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 != WLAN_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 libertas_send_tx_feedback(priv);
597 wake_up_interruptible(&priv->waitq);
598 } else if (priv->adapter->connect_status == LIBERTAS_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 wlan_private structure
611 * @return A pointer to net_device_stats structure
613 static struct net_device_stats *libertas_get_stats(struct net_device *dev)
615 wlan_private *priv = (wlan_private *) dev->priv;
620 static int libertas_set_mac_address(struct net_device *dev, void *addr)
623 wlan_private *priv = (wlan_private *) dev->priv;
624 wlan_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 = libertas_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 libertas_copy_multicast_address(wlan_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 libertas_set_multicast_list(struct net_device *dev)
677 wlan_private *priv = dev->priv;
678 wlan_adapter *adapter = priv->adapter;
681 lbs_deb_enter(LBS_DEB_NET);
683 oldpacketfilter = adapter->currentpacketfilter;
685 if (dev->flags & IFF_PROMISC) {
686 lbs_deb_net("enable promiscuous mode\n");
687 adapter->currentpacketfilter |=
688 CMD_ACT_MAC_PROMISCUOUS_ENABLE;
689 adapter->currentpacketfilter &=
690 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE |
691 CMD_ACT_MAC_MULTICAST_ENABLE);
694 adapter->currentpacketfilter &=
695 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE;
697 if (dev->flags & IFF_ALLMULTI || dev->mc_count >
698 MRVDRV_MAX_MULTICAST_LIST_SIZE) {
699 lbs_deb_net( "enabling all multicast\n");
700 adapter->currentpacketfilter |=
701 CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
702 adapter->currentpacketfilter &=
703 ~CMD_ACT_MAC_MULTICAST_ENABLE;
705 adapter->currentpacketfilter &=
706 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
708 if (!dev->mc_count) {
709 lbs_deb_net("no multicast addresses, "
710 "disabling multicast\n");
711 adapter->currentpacketfilter &=
712 ~CMD_ACT_MAC_MULTICAST_ENABLE;
716 adapter->currentpacketfilter |=
717 CMD_ACT_MAC_MULTICAST_ENABLE;
719 adapter->nr_of_multicastmacaddr =
720 libertas_copy_multicast_address(adapter, dev);
722 lbs_deb_net("multicast addresses: %d\n",
725 for (i = 0; i < dev->mc_count; i++) {
726 lbs_deb_net("Multicast address %d:"
728 adapter->multicastlist[i][0],
729 adapter->multicastlist[i][1],
730 adapter->multicastlist[i][2],
731 adapter->multicastlist[i][3],
732 adapter->multicastlist[i][4],
733 adapter->multicastlist[i][5]);
735 /* send multicast addresses to firmware */
736 libertas_prepare_and_send_command(priv,
737 CMD_MAC_MULTICAST_ADR,
744 if (adapter->currentpacketfilter != oldpacketfilter) {
745 libertas_set_mac_packet_filter(priv);
748 lbs_deb_leave(LBS_DEB_NET);
752 * @brief This function handles the major jobs in the WLAN driver.
753 * It handles all events generated by firmware, RX data received
754 * from firmware and TX data sent from kernel.
756 * @param data A pointer to wlan_thread structure
759 static int libertas_thread(void *data)
761 struct net_device *dev = data;
762 wlan_private *priv = dev->priv;
763 wlan_adapter *adapter = priv->adapter;
767 lbs_deb_enter(LBS_DEB_THREAD);
769 init_waitqueue_entry(&wait, current);
773 lbs_deb_thread( "main-thread 111: intcounter=%d "
774 "currenttxskb=%p dnld_sent=%d\n",
776 adapter->currenttxskb, priv->dnld_sent);
778 add_wait_queue(&priv->waitq, &wait);
779 set_current_state(TASK_INTERRUPTIBLE);
780 spin_lock_irq(&adapter->driver_lock);
781 if ((adapter->psstate == PS_STATE_SLEEP) ||
782 (!adapter->intcounter
783 && (priv->dnld_sent || adapter->cur_cmd ||
784 list_empty(&adapter->cmdpendingq)))) {
786 "main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
787 adapter->connect_status, adapter->intcounter,
788 adapter->psmode, adapter->psstate);
789 spin_unlock_irq(&adapter->driver_lock);
792 spin_unlock_irq(&adapter->driver_lock);
796 "main-thread 222 (waking up): intcounter=%d currenttxskb=%p "
797 "dnld_sent=%d\n", adapter->intcounter,
798 adapter->currenttxskb, priv->dnld_sent);
800 set_current_state(TASK_RUNNING);
801 remove_wait_queue(&priv->waitq, &wait);
804 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p "
807 adapter->currenttxskb, priv->dnld_sent);
809 if (kthread_should_stop()
810 || adapter->surpriseremoved) {
812 "main-thread: break from main thread: surpriseremoved=0x%x\n",
813 adapter->surpriseremoved);
818 spin_lock_irq(&adapter->driver_lock);
819 if (adapter->intcounter) {
821 adapter->intcounter = 0;
822 int_status = priv->hw_get_int_status(priv, &ireg);
826 "main-thread: reading HOST_INT_STATUS_REG failed\n");
827 spin_unlock_irq(&adapter->driver_lock);
830 adapter->hisregcpy |= ireg;
833 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p "
836 adapter->currenttxskb, priv->dnld_sent);
838 /* command response? */
839 if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) {
840 lbs_deb_thread("main-thread: cmd response ready\n");
842 adapter->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY;
843 spin_unlock_irq(&adapter->driver_lock);
844 libertas_process_rx_command(priv);
845 spin_lock_irq(&adapter->driver_lock);
849 if (adapter->hisregcpy & MRVDRV_CARDEVENT) {
850 lbs_deb_thread("main-thread: Card Event Activity\n");
852 adapter->hisregcpy &= ~MRVDRV_CARDEVENT;
854 if (priv->hw_read_event_cause(priv)) {
856 "main-thread: hw_read_event_cause failed\n");
857 spin_unlock_irq(&adapter->driver_lock);
860 spin_unlock_irq(&adapter->driver_lock);
861 libertas_process_event(priv);
863 spin_unlock_irq(&adapter->driver_lock);
865 /* Check if we need to confirm Sleep Request received previously */
866 if (adapter->psstate == PS_STATE_PRE_SLEEP) {
867 if (!priv->dnld_sent && !adapter->cur_cmd) {
868 if (adapter->connect_status ==
869 LIBERTAS_CONNECTED) {
871 "main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p "
872 "dnld_sent=%d cur_cmd=%p, confirm now\n",
874 adapter->currenttxskb,
878 libertas_ps_confirm_sleep(priv,
879 (u16) adapter->psmode);
881 /* workaround for firmware sending
882 * deauth/linkloss event immediately
883 * after sleep request, remove this
884 * after firmware fixes it
886 adapter->psstate = PS_STATE_AWAKE;
888 "main-thread: ignore PS_SleepConfirm in non-connected state\n");
893 /* The PS state is changed during processing of Sleep Request
896 if ((priv->adapter->psstate == PS_STATE_SLEEP) ||
897 (priv->adapter->psstate == PS_STATE_PRE_SLEEP))
900 /* Execute the next command */
901 if (!priv->dnld_sent && !priv->adapter->cur_cmd)
902 libertas_execute_next_command(priv);
904 /* Wake-up command waiters which can't sleep in
905 * libertas_prepare_and_send_command
907 if (!adapter->nr_cmd_pending)
908 wake_up_all(&adapter->cmd_pending);
910 libertas_tx_runqueue(priv);
913 del_timer(&adapter->command_timer);
914 adapter->nr_cmd_pending = 0;
915 wake_up_all(&adapter->cmd_pending);
917 lbs_deb_leave(LBS_DEB_THREAD);
922 * @brief This function downloads firmware image, gets
923 * HW spec from firmware and set basic parameters to
926 * @param priv A pointer to wlan_private structure
929 static int wlan_setup_station_hw(wlan_private * priv)
932 wlan_adapter *adapter = priv->adapter;
933 struct cmd_ds_mesh_access mesh_access;
935 lbs_deb_enter(LBS_DEB_FW);
937 ret = priv->hw_prog_firmware(priv);
940 lbs_deb_fw("bootloader in invalid state\n");
946 * Read MAC address from HW
948 memset(adapter->current_addr, 0xff, ETH_ALEN);
950 ret = libertas_prepare_and_send_command(priv, CMD_GET_HW_SPEC,
951 0, CMD_OPTION_WAITFORRSP, 0, NULL);
958 libertas_set_mac_packet_filter(priv);
960 /* Get the supported Data rates */
961 ret = libertas_prepare_and_send_command(priv, CMD_802_11_DATA_RATE,
963 CMD_OPTION_WAITFORRSP, 0, NULL);
970 /* Disable mesh autostart */
971 if (priv->mesh_dev) {
972 memset(&mesh_access, 0, sizeof(mesh_access));
973 mesh_access.data[0] = cpu_to_le32(0);
974 ret = libertas_prepare_and_send_command(priv,
976 CMD_ACT_MESH_SET_AUTOSTART_ENABLED,
977 CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access);
982 priv->mesh_autostart_enabled = 0;
985 /* Set the boot2 version in firmware */
986 ret = libertas_prepare_and_send_command(priv, CMD_SET_BOOT2_VER,
987 0, CMD_OPTION_WAITFORRSP, 0, NULL);
991 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
995 static void command_timer_fn(unsigned long data);
998 * This function handles the timeout of command sending.
999 * It will re-send the same command again.
1001 static void command_timer_fn(unsigned long data)
1003 wlan_private *priv = (wlan_private *)data;
1004 wlan_adapter *adapter = priv->adapter;
1005 struct cmd_ctrl_node *ptempnode;
1006 struct cmd_ds_command *cmd;
1007 unsigned long flags;
1009 ptempnode = adapter->cur_cmd;
1010 if (ptempnode == NULL) {
1011 lbs_deb_fw("ptempnode empty\n");
1015 cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr;
1017 lbs_deb_fw("cmd is NULL\n");
1021 lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command);
1023 if (!adapter->fw_ready)
1026 spin_lock_irqsave(&adapter->driver_lock, flags);
1027 adapter->cur_cmd = NULL;
1028 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1030 lbs_deb_fw("re-sending same command because of timeout\n");
1031 libertas_queue_cmd(adapter, ptempnode, 0);
1033 wake_up_interruptible(&priv->waitq);
1038 static void libertas_free_adapter(wlan_private * priv)
1040 wlan_adapter *adapter = priv->adapter;
1043 lbs_deb_fw("why double free adapter?\n");
1047 lbs_deb_fw("free command buffer\n");
1048 libertas_free_cmd_buffer(priv);
1050 lbs_deb_fw("free command_timer\n");
1051 del_timer(&adapter->command_timer);
1053 lbs_deb_fw("free scan results table\n");
1054 kfree(adapter->networks);
1055 adapter->networks = NULL;
1057 /* Free the adapter object itself */
1058 lbs_deb_fw("free adapter\n");
1060 priv->adapter = NULL;
1063 static int wlan_allocate_adapter(wlan_private * priv)
1066 wlan_adapter *adapter = priv->adapter;
1068 /* Allocate buffer to store the BSSID list */
1069 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor);
1070 adapter->networks = kzalloc(bufsize, GFP_KERNEL);
1071 if (!adapter->networks) {
1072 lbs_pr_err("Out of memory allocating beacons\n");
1073 libertas_free_adapter(priv);
1077 /* Allocate the command buffers */
1078 libertas_allocate_cmd_buffer(priv);
1080 memset(&adapter->libertas_ps_confirm_sleep, 0, sizeof(struct PS_CMD_ConfirmSleep));
1081 adapter->libertas_ps_confirm_sleep.seqnum = cpu_to_le16(++adapter->seqnum);
1082 adapter->libertas_ps_confirm_sleep.command =
1083 cpu_to_le16(CMD_802_11_PS_MODE);
1084 adapter->libertas_ps_confirm_sleep.size =
1085 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep));
1086 adapter->libertas_ps_confirm_sleep.result = 0;
1087 adapter->libertas_ps_confirm_sleep.action =
1088 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED);
1093 static void wlan_init_adapter(wlan_private * priv)
1095 wlan_adapter *adapter = priv->adapter;
1098 adapter->connect_status = LIBERTAS_DISCONNECTED;
1099 memset(adapter->current_addr, 0xff, ETH_ALEN);
1101 /* 802.11 specific */
1102 adapter->secinfo.wep_enabled = 0;
1103 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]);
1105 memset(&adapter->wep_keys[i], 0, sizeof(struct enc_key));
1106 adapter->wep_tx_keyidx = 0;
1107 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1108 adapter->mode = IW_MODE_INFRA;
1110 adapter->pending_assoc_req = NULL;
1111 adapter->in_progress_assoc_req = NULL;
1113 /* Initialize scan result lists */
1114 INIT_LIST_HEAD(&adapter->network_free_list);
1115 INIT_LIST_HEAD(&adapter->network_list);
1116 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
1117 list_add_tail(&adapter->networks[i].list,
1118 &adapter->network_free_list);
1121 mutex_init(&adapter->lock);
1123 memset(&adapter->curbssparams, 0, sizeof(adapter->curbssparams));
1124 adapter->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
1126 /* PnP and power profile */
1127 adapter->surpriseremoved = 0;
1129 adapter->currentpacketfilter =
1130 CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
1132 adapter->radioon = RADIO_ON;
1134 adapter->auto_rate = 1;
1135 adapter->cur_rate = 0;
1137 // set default capabilities
1138 adapter->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
1140 adapter->psmode = WLAN802_11POWERMODECAM;
1142 adapter->psstate = PS_STATE_FULL_POWER;
1143 adapter->needtowakeup = 0;
1145 adapter->intcounter = 0;
1147 adapter->currenttxskb = NULL;
1149 memset(&adapter->tx_queue_ps, 0, NR_TX_QUEUE*sizeof(struct sk_buff*));
1150 adapter->tx_queue_idx = 0;
1151 spin_lock_init(&adapter->txqueue_lock);
1156 static int libertas_init_fw(wlan_private * priv)
1159 wlan_adapter *adapter = priv->adapter;
1161 lbs_deb_enter(LBS_DEB_FW);
1163 /* Allocate adapter structure */
1164 if ((ret = wlan_allocate_adapter(priv)) != 0)
1167 /* init adapter structure */
1168 wlan_init_adapter(priv);
1170 /* init timer etc. */
1171 setup_timer(&adapter->command_timer, command_timer_fn,
1172 (unsigned long)priv);
1174 /* download fimrware etc. */
1175 if ((ret = wlan_setup_station_hw(priv)) != 0) {
1176 del_timer_sync(&adapter->command_timer);
1181 libertas_init_11d(priv);
1185 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
1190 * @brief This function adds the card. it will probe the
1191 * card, allocate the wlan_priv and initialize the device.
1193 * @param card A pointer to card
1194 * @return A pointer to wlan_private structure
1196 wlan_private *libertas_add_card(void *card, struct device *dmdev)
1198 struct net_device *dev = NULL;
1199 wlan_private *priv = NULL;
1201 lbs_deb_enter(LBS_DEB_NET);
1203 /* Allocate an Ethernet device and register it */
1204 if (!(dev = alloc_etherdev(sizeof(wlan_private)))) {
1205 lbs_pr_err("init ethX device failed\n");
1210 /* allocate buffer for wlan_adapter */
1211 if (!(priv->adapter = kzalloc(sizeof(wlan_adapter), GFP_KERNEL))) {
1212 lbs_pr_err("allocate buffer for wlan_adapter failed\n");
1218 priv->mesh_open = 0;
1219 priv->infra_open = 0;
1221 SET_MODULE_OWNER(dev);
1223 /* Setup the OS Interface to our functions */
1224 dev->open = libertas_open;
1225 dev->hard_start_xmit = libertas_pre_start_xmit;
1226 dev->stop = libertas_close;
1227 dev->set_mac_address = libertas_set_mac_address;
1228 dev->tx_timeout = libertas_tx_timeout;
1229 dev->get_stats = libertas_get_stats;
1230 dev->watchdog_timeo = 5 * HZ;
1231 dev->ethtool_ops = &libertas_ethtool_ops;
1233 dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def;
1235 #define NETIF_F_DYNALLOC 16
1236 dev->features |= NETIF_F_DYNALLOC;
1237 dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
1238 dev->set_multicast_list = libertas_set_multicast_list;
1240 SET_NETDEV_DEV(dev, dmdev);
1242 INIT_LIST_HEAD(&priv->adapter->cmdfreeq);
1243 INIT_LIST_HEAD(&priv->adapter->cmdpendingq);
1245 spin_lock_init(&priv->adapter->driver_lock);
1246 init_waitqueue_head(&priv->adapter->cmd_pending);
1247 priv->adapter->nr_cmd_pending = 0;
1248 priv->rtap_net_dev = NULL;
1249 if (device_create_file(dmdev, &dev_attr_libertas_rtap))
1257 lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv);
1260 EXPORT_SYMBOL_GPL(libertas_add_card);
1262 int libertas_activate_card(wlan_private *priv)
1264 struct net_device *dev = priv->dev;
1267 lbs_deb_enter(LBS_DEB_MAIN);
1269 lbs_deb_thread("Starting main thread...\n");
1270 init_waitqueue_head(&priv->waitq);
1271 priv->main_thread = kthread_run(libertas_thread, dev, "libertas_main");
1272 if (IS_ERR(priv->main_thread)) {
1273 lbs_deb_thread("Error creating main thread.\n");
1277 priv->work_thread = create_singlethread_workqueue("libertas_worker");
1278 INIT_DELAYED_WORK(&priv->assoc_work, libertas_association_worker);
1279 INIT_DELAYED_WORK(&priv->scan_work, libertas_scan_worker);
1281 INIT_WORK(&priv->sync_channel, libertas_sync_channel);
1284 * Register the device. Fillup the private data structure with
1285 * relevant information from the card and request for the required
1288 if (priv->hw_register_dev(priv) < 0) {
1289 lbs_pr_err("failed to register WLAN device\n");
1290 goto err_registerdev;
1293 /* init FW and HW */
1294 if (libertas_init_fw(priv)) {
1295 lbs_pr_err("firmware init failed\n");
1296 goto err_registerdev;
1299 if (register_netdev(dev)) {
1300 lbs_pr_err("cannot register ethX device\n");
1304 lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name);
1306 libertas_debugfs_init_one(priv, dev);
1312 priv->hw_unregister_dev(priv);
1314 destroy_workqueue(priv->work_thread);
1315 /* Stop the thread servicing the interrupts */
1316 wake_up_interruptible(&priv->waitq);
1317 kthread_stop(priv->main_thread);
1319 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
1322 EXPORT_SYMBOL_GPL(libertas_activate_card);
1326 * @brief This function adds mshX interface
1328 * @param priv A pointer to the wlan_private structure
1329 * @return 0 if successful, -X otherwise
1331 int libertas_add_mesh(wlan_private *priv, struct device *dev)
1333 struct net_device *mesh_dev = NULL;
1336 lbs_deb_enter(LBS_DEB_MESH);
1338 /* Allocate a virtual mesh device */
1339 if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) {
1340 lbs_deb_mesh("init mshX device failed\n");
1344 mesh_dev->priv = priv;
1345 priv->mesh_dev = mesh_dev;
1347 SET_MODULE_OWNER(mesh_dev);
1349 mesh_dev->open = libertas_mesh_open;
1350 mesh_dev->hard_start_xmit = libertas_mesh_pre_start_xmit;
1351 mesh_dev->stop = libertas_mesh_close;
1352 mesh_dev->get_stats = libertas_get_stats;
1353 mesh_dev->set_mac_address = libertas_set_mac_address;
1354 mesh_dev->ethtool_ops = &libertas_ethtool_ops;
1355 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
1356 sizeof(priv->dev->dev_addr));
1358 SET_NETDEV_DEV(priv->mesh_dev, dev);
1361 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def;
1363 #define NETIF_F_DYNALLOC 16
1365 /* Register virtual mesh interface */
1366 ret = register_netdev(mesh_dev);
1368 lbs_pr_err("cannot register mshX virtual interface\n");
1372 ret = sysfs_create_group(&(mesh_dev->dev.kobj), &libertas_mesh_attr_group);
1374 goto err_unregister;
1376 /* Everything successful */
1381 unregister_netdev(mesh_dev);
1384 free_netdev(mesh_dev);
1387 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
1390 EXPORT_SYMBOL_GPL(libertas_add_mesh);
1392 static void wake_pending_cmdnodes(wlan_private *priv)
1394 struct cmd_ctrl_node *cmdnode;
1395 unsigned long flags;
1397 lbs_deb_enter(LBS_DEB_HOST);
1399 spin_lock_irqsave(&priv->adapter->driver_lock, flags);
1400 list_for_each_entry(cmdnode, &priv->adapter->cmdpendingq, list) {
1401 cmdnode->cmdwaitqwoken = 1;
1402 wake_up_interruptible(&cmdnode->cmdwait_q);
1404 spin_unlock_irqrestore(&priv->adapter->driver_lock, flags);
1408 int libertas_remove_card(wlan_private *priv)
1410 wlan_adapter *adapter;
1411 struct net_device *dev;
1412 union iwreq_data wrqu;
1414 lbs_deb_enter(LBS_DEB_NET);
1416 libertas_remove_rtap(priv);
1420 adapter = priv->adapter;
1426 device_remove_file(priv->hotplug_device, &dev_attr_libertas_rtap);
1428 netif_stop_queue(priv->dev);
1429 netif_carrier_off(priv->dev);
1431 wake_pending_cmdnodes(priv);
1433 unregister_netdev(dev);
1435 cancel_delayed_work(&priv->scan_work);
1436 cancel_delayed_work(&priv->assoc_work);
1437 destroy_workqueue(priv->work_thread);
1439 if (adapter->psmode == WLAN802_11POWERMODEMAX_PSP) {
1440 adapter->psmode = WLAN802_11POWERMODECAM;
1441 libertas_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
1444 memset(wrqu.ap_addr.sa_data, 0xaa, ETH_ALEN);
1445 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1446 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
1448 adapter->surpriseremoved = 1;
1450 /* Stop the thread servicing the interrupts */
1451 kthread_stop(priv->main_thread);
1453 libertas_debugfs_remove_one(priv);
1455 lbs_deb_net("free adapter\n");
1456 libertas_free_adapter(priv);
1458 lbs_deb_net("unregister finish\n");
1464 lbs_deb_leave(LBS_DEB_NET);
1467 EXPORT_SYMBOL_GPL(libertas_remove_card);
1470 void libertas_remove_mesh(wlan_private *priv)
1472 struct net_device *mesh_dev;
1474 lbs_deb_enter(LBS_DEB_NET);
1479 mesh_dev = priv->mesh_dev;
1481 netif_stop_queue(mesh_dev);
1482 netif_carrier_off(priv->mesh_dev);
1484 sysfs_remove_group(&(mesh_dev->dev.kobj), &libertas_mesh_attr_group);
1485 unregister_netdev(mesh_dev);
1487 priv->mesh_dev = NULL ;
1488 free_netdev(mesh_dev);
1491 lbs_deb_leave(LBS_DEB_NET);
1493 EXPORT_SYMBOL_GPL(libertas_remove_mesh);
1496 * @brief This function finds the CFP in
1497 * region_cfp_table based on region and band parameter.
1499 * @param region The region code
1500 * @param band The band
1501 * @param cfp_no A pointer to CFP number
1502 * @return A pointer to CFP
1504 struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band, int *cfp_no)
1508 lbs_deb_enter(LBS_DEB_MAIN);
1510 end = sizeof(region_cfp_table)/sizeof(struct region_cfp_table);
1512 for (i = 0; i < end ; i++) {
1513 lbs_deb_main("region_cfp_table[i].region=%d\n",
1514 region_cfp_table[i].region);
1515 if (region_cfp_table[i].region == region) {
1516 *cfp_no = region_cfp_table[i].cfp_no_BG;
1517 lbs_deb_leave(LBS_DEB_MAIN);
1518 return region_cfp_table[i].cfp_BG;
1522 lbs_deb_leave_args(LBS_DEB_MAIN, "ret NULL");
1526 int libertas_set_regiontable(wlan_private * priv, u8 region, u8 band)
1528 wlan_adapter *adapter = priv->adapter;
1532 struct chan_freq_power *cfp;
1535 lbs_deb_enter(LBS_DEB_MAIN);
1537 memset(adapter->region_channel, 0, sizeof(adapter->region_channel));
1540 cfp = libertas_get_region_cfp_table(region, band, &cfp_no);
1542 adapter->region_channel[i].nrcfp = cfp_no;
1543 adapter->region_channel[i].CFP = cfp;
1545 lbs_deb_main("wrong region code %#x in band B/G\n",
1550 adapter->region_channel[i].valid = 1;
1551 adapter->region_channel[i].region = region;
1552 adapter->region_channel[i].band = band;
1556 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1561 * @brief This function handles the interrupt. it will change PS
1562 * state if applicable. it will wake up main_thread to handle
1563 * the interrupt event as well.
1565 * @param dev A pointer to net_device structure
1568 void libertas_interrupt(struct net_device *dev)
1570 wlan_private *priv = dev->priv;
1572 lbs_deb_enter(LBS_DEB_THREAD);
1574 lbs_deb_thread("libertas_interrupt: intcounter=%d\n",
1575 priv->adapter->intcounter);
1577 priv->adapter->intcounter++;
1579 if (priv->adapter->psstate == PS_STATE_SLEEP) {
1580 priv->adapter->psstate = PS_STATE_AWAKE;
1581 netif_wake_queue(dev);
1583 netif_wake_queue(priv->mesh_dev);
1586 wake_up_interruptible(&priv->waitq);
1588 lbs_deb_leave(LBS_DEB_THREAD);
1590 EXPORT_SYMBOL_GPL(libertas_interrupt);
1592 int libertas_reset_device(wlan_private *priv)
1596 lbs_deb_enter(LBS_DEB_MAIN);
1597 ret = libertas_prepare_and_send_command(priv, CMD_802_11_RESET,
1598 CMD_ACT_HALT, 0, 0, NULL);
1599 msleep_interruptible(10);
1601 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1604 EXPORT_SYMBOL_GPL(libertas_reset_device);
1606 static int libertas_init_module(void)
1608 lbs_deb_enter(LBS_DEB_MAIN);
1609 libertas_debugfs_init();
1610 lbs_deb_leave(LBS_DEB_MAIN);
1614 static void libertas_exit_module(void)
1616 lbs_deb_enter(LBS_DEB_MAIN);
1618 libertas_debugfs_remove();
1620 lbs_deb_leave(LBS_DEB_MAIN);
1624 * rtap interface support fuctions
1627 static int libertas_rtap_open(struct net_device *dev)
1629 netif_carrier_off(dev);
1630 netif_stop_queue(dev);
1634 static int libertas_rtap_stop(struct net_device *dev)
1639 static int libertas_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1641 netif_stop_queue(dev);
1645 static struct net_device_stats *libertas_rtap_get_stats(struct net_device *dev)
1647 wlan_private *priv = dev->priv;
1648 return &priv->ieee->stats;
1652 void libertas_remove_rtap(wlan_private *priv)
1654 if (priv->rtap_net_dev == NULL)
1656 unregister_netdev(priv->rtap_net_dev);
1657 free_ieee80211(priv->rtap_net_dev);
1658 priv->rtap_net_dev = NULL;
1661 int libertas_add_rtap(wlan_private *priv)
1665 if (priv->rtap_net_dev)
1668 priv->rtap_net_dev = alloc_ieee80211(0);
1669 if (priv->rtap_net_dev == NULL)
1673 priv->ieee = netdev_priv(priv->rtap_net_dev);
1675 strcpy(priv->rtap_net_dev->name, "rtap%d");
1677 priv->rtap_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
1678 priv->rtap_net_dev->open = libertas_rtap_open;
1679 priv->rtap_net_dev->stop = libertas_rtap_stop;
1680 priv->rtap_net_dev->get_stats = libertas_rtap_get_stats;
1681 priv->rtap_net_dev->hard_start_xmit = libertas_rtap_hard_start_xmit;
1682 priv->rtap_net_dev->set_multicast_list = libertas_set_multicast_list;
1683 priv->rtap_net_dev->priv = priv;
1685 priv->ieee->iw_mode = IW_MODE_MONITOR;
1687 rc = register_netdev(priv->rtap_net_dev);
1689 free_ieee80211(priv->rtap_net_dev);
1690 priv->rtap_net_dev = NULL;
1698 module_init(libertas_init_module);
1699 module_exit(libertas_exit_module);
1701 MODULE_DESCRIPTION("Libertas WLAN Driver Library");
1702 MODULE_AUTHOR("Marvell International Ltd.");
1703 MODULE_LICENSE("GPL");