2 * WL3501 Wireless LAN PCMCIA Card Driver for Linux
3 * Written originally for Linux 2.0.30 by Fox Chen, mhchen@golf.ccl.itri.org.tw
4 * Ported to 2.2, 2.4 & 2.5 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * Wireless extensions in 2.4 by Gustavo Niemeyer <niemeyer@conectiva.com>
7 * References used by Fox Chen while writing the original driver for 2.0.30:
9 * 1. WL24xx packet drivers (tooasm.asm)
10 * 2. Access Point Firmware Interface Specification for IEEE 802.11 SUTRO
12 * 4. Linux network driver (/usr/src/linux/drivers/net)
13 * 5. ISA card driver - wl24.c
14 * 6. Linux PCMCIA skeleton driver - skeleton.c
15 * 7. Linux PCMCIA 3c589 network driver - 3c589_cs.c
17 * Tested with WL2400 firmware 1.2, Linux 2.0.30, and pcmcia-cs-2.9.12
18 * 1. Performance: about 165 Kbytes/sec in TCP/IP with Ad-Hoc mode.
19 * rsh 192.168.1.3 "dd if=/dev/zero bs=1k count=1000" > /dev/null
20 * (Specification 2M bits/sec. is about 250 Kbytes/sec., but we must deduct
21 * ETHER/IP/UDP/TCP header, and acknowledgement overhead)
23 * Tested with Planet AP in 2.4.17, 184 Kbytes/s in UDP in Infrastructure mode,
24 * 173 Kbytes/s in TCP.
26 * Tested with Planet AP in 2.5.73-bk, 216 Kbytes/s in Infrastructure mode
27 * with a SMP machine (dual pentium 100), using pktgen, 432 pps (pkt_size = 60)
29 #undef REALLY_SLOW_IO /* most systems can safely undef this */
31 #include <linux/config.h>
32 #include <linux/delay.h>
33 #include <linux/types.h>
34 #include <linux/ethtool.h>
35 #include <linux/init.h>
36 #include <linux/interrupt.h>
38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <linux/fcntl.h>
41 #include <linux/if_arp.h>
42 #include <linux/ioport.h>
43 #include <linux/netdevice.h>
44 #include <linux/etherdevice.h>
45 #include <linux/skbuff.h>
46 #include <linux/slab.h>
47 #include <linux/string.h>
48 #include <linux/wireless.h>
50 #include <net/iw_handler.h>
52 #include <pcmcia/version.h>
53 #include <pcmcia/cs_types.h>
54 #include <pcmcia/cs.h>
55 #include <pcmcia/cistpl.h>
56 #include <pcmcia/cisreg.h>
57 #include <pcmcia/ds.h>
60 #include <asm/uaccess.h>
61 #include <asm/system.h>
66 #define slow_down_io()
69 /* For rough constant delay */
70 #define WL3501_NOPLOOP(n) { int x = 0; while (x++ < n) slow_down_io(); }
73 * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If you do not
74 * define PCMCIA_DEBUG at all, all the debug code will be left out. If you
75 * compile with PCMCIA_DEBUG=0, the debug code will be present but disabled --
76 * but it can then be enabled for specific modules at load time with a
77 * 'pc_debug=#' option to insmod.
79 #define PCMCIA_DEBUG 0
81 static int pc_debug = PCMCIA_DEBUG;
82 module_param(pc_debug, int, 0);
83 #define dprintk(n, format, args...) \
84 { if (pc_debug > (n)) \
85 printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##args); }
87 #define dprintk(n, format, args...)
90 #define wl3501_outb(a, b) { outb(a, b); slow_down_io(); }
91 #define wl3501_outb_p(a, b) { outb_p(a, b); slow_down_io(); }
92 #define wl3501_outsb(a, b, c) { outsb(a, b, c); slow_down_io(); }
94 #define WL3501_RELEASE_TIMEOUT (25 * HZ)
95 #define WL3501_MAX_ADHOC_TRIES 16
97 #define WL3501_RESUME 0
98 #define WL3501_SUSPEND 1
101 * The event() function is this driver's Card Services event handler. It will
102 * be called by Card Services when an appropriate card status event is
103 * received. The config() and release() entry points are used to configure or
104 * release a socket, in response to card insertion and ejection events. They
105 * are invoked from the wl24 event handler.
107 static void wl3501_config(dev_link_t *link);
108 static void wl3501_release(dev_link_t *link);
109 static int wl3501_event(event_t event, int pri, event_callback_args_t *args);
112 * The dev_info variable is the "key" that is used to match up this
113 * device driver with appropriate cards, through the card configuration
116 static dev_info_t wl3501_dev_info = "wl3501_cs";
118 static int wl3501_chan2freq[] = {
119 [0] = 2412, [1] = 2417, [2] = 2422, [3] = 2427, [4] = 2432,
120 [5] = 2437, [6] = 2442, [7] = 2447, [8] = 2452, [9] = 2457,
121 [10] = 2462, [11] = 2467, [12] = 2472, [13] = 2477,
124 static const struct {
127 } iw_channel_table[] = {
129 .reg_domain = IW_REG_DOMAIN_FCC,
135 .reg_domain = IW_REG_DOMAIN_DOC,
141 .reg_domain = IW_REG_DOMAIN_ETSI,
147 .reg_domain = IW_REG_DOMAIN_SPAIN,
153 .reg_domain = IW_REG_DOMAIN_FRANCE,
159 .reg_domain = IW_REG_DOMAIN_MKK,
165 .reg_domain = IW_REG_DOMAIN_MKK1,
171 .reg_domain = IW_REG_DOMAIN_ISRAEL,
179 * iw_valid_channel - validate channel in regulatory domain
180 * @reg_comain - regulatory domain
181 * @channel - channel to validate
183 * Returns 0 if invalid in the specified regulatory domain, non-zero if valid.
185 static int iw_valid_channel(int reg_domain, int channel)
189 for (i = 0; i < ARRAY_SIZE(iw_channel_table); i++)
190 if (reg_domain == iw_channel_table[i].reg_domain) {
191 rc = channel >= iw_channel_table[i].min &&
192 channel <= iw_channel_table[i].max;
199 * iw_default_channel - get default channel for a regulatory domain
200 * @reg_comain - regulatory domain
202 * Returns the default channel for a regulatory domain
204 static int iw_default_channel(int reg_domain)
208 for (i = 0; i < ARRAY_SIZE(iw_channel_table); i++)
209 if (reg_domain == iw_channel_table[i].reg_domain) {
210 rc = iw_channel_table[i].deflt;
216 static void iw_set_mgmt_info_element(enum iw_mgmt_info_element_ids id,
217 struct iw_mgmt_info_element *el,
218 void *value, int len)
222 memcpy(el->data, value, len);
225 static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to,
226 struct iw_mgmt_info_element *from)
228 iw_set_mgmt_info_element(from->id, to, from->data, from->len);
232 * A linked list of "instances" of the wl24 device. Each actual PCMCIA card
233 * corresponds to one device instance, and is described by one dev_link_t
234 * structure (defined in ds.h).
236 * You may not want to use a linked list for this -- for example, the memory
237 * card driver uses an array of dev_link_t pointers, where minor device numbers
238 * are used to derive the corresponding array index.
240 static dev_link_t *wl3501_dev_list;
242 static inline void wl3501_switch_page(struct wl3501_card *this, u8 page)
244 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS);
248 * Get Ethernet MAC addresss.
250 * WARNING: We switch to FPAGE0 and switc back again.
251 * Making sure there is no other WL function beening called by ISR.
253 static int wl3501_get_flash_mac_addr(struct wl3501_card *this)
255 int base_addr = this->base_addr;
258 wl3501_outb(WL3501_BSS_FPAGE3, base_addr + WL3501_NIC_BSS); /* BSS */
259 wl3501_outb(0x00, base_addr + WL3501_NIC_LMAL); /* LMAL */
260 wl3501_outb(0x40, base_addr + WL3501_NIC_LMAH); /* LMAH */
262 /* wait for reading EEPROM */
264 this->mac_addr[0] = inb(base_addr + WL3501_NIC_IODPA);
266 this->mac_addr[1] = inb(base_addr + WL3501_NIC_IODPA);
268 this->mac_addr[2] = inb(base_addr + WL3501_NIC_IODPA);
270 this->mac_addr[3] = inb(base_addr + WL3501_NIC_IODPA);
272 this->mac_addr[4] = inb(base_addr + WL3501_NIC_IODPA);
274 this->mac_addr[5] = inb(base_addr + WL3501_NIC_IODPA);
276 this->reg_domain = inb(base_addr + WL3501_NIC_IODPA);
278 wl3501_outb(WL3501_BSS_FPAGE0, base_addr + WL3501_NIC_BSS);
279 wl3501_outb(0x04, base_addr + WL3501_NIC_LMAL);
280 wl3501_outb(0x40, base_addr + WL3501_NIC_LMAH);
282 this->version[0] = inb(base_addr + WL3501_NIC_IODPA);
284 this->version[1] = inb(base_addr + WL3501_NIC_IODPA);
285 /* switch to SRAM Page 0 (for safety) */
286 wl3501_switch_page(this, WL3501_BSS_SPAGE0);
288 /* The MAC addr should be 00:60:... */
289 return this->mac_addr[0] == 0x00 && this->mac_addr[1] == 0x60;
293 * wl3501_set_to_wla - Move 'size' bytes from PC to card
294 * @dest: Card addressing space
295 * @src: PC addressing space
296 * @size: Bytes to move
298 * Move 'size' bytes from PC to card. (Shouldn't be interrupted)
300 static void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src,
303 /* switch to SRAM Page 0 */
304 wl3501_switch_page(this, (dest & 0x8000) ? WL3501_BSS_SPAGE1 :
306 /* set LMAL and LMAH */
307 wl3501_outb(dest & 0xff, this->base_addr + WL3501_NIC_LMAL);
308 wl3501_outb(((dest >> 8) & 0x7f), this->base_addr + WL3501_NIC_LMAH);
310 /* rep out to Port A */
311 wl3501_outsb(this->base_addr + WL3501_NIC_IODPA, src, size);
315 * wl3501_get_from_wla - Move 'size' bytes from card to PC
316 * @src: Card addressing space
317 * @dest: PC addressing space
318 * @size: Bytes to move
320 * Move 'size' bytes from card to PC. (Shouldn't be interrupted)
322 static void wl3501_get_from_wla(struct wl3501_card *this, u16 src, void *dest,
325 /* switch to SRAM Page 0 */
326 wl3501_switch_page(this, (src & 0x8000) ? WL3501_BSS_SPAGE1 :
328 /* set LMAL and LMAH */
329 wl3501_outb(src & 0xff, this->base_addr + WL3501_NIC_LMAL);
330 wl3501_outb((src >> 8) & 0x7f, this->base_addr + WL3501_NIC_LMAH);
332 /* rep get from Port A */
333 insb(this->base_addr + WL3501_NIC_IODPA, dest, size);
337 * Get/Allocate a free Tx Data Buffer
339 * *--------------*-----------------*----------------------------------*
340 * | PLCP | MAC Header | DST SRC Data ... |
341 * | (24 bytes) | (30 bytes) | (6) (6) (Ethernet Row Data) |
342 * *--------------*-----------------*----------------------------------*
343 * \ \- IEEE 802.11 -/ \-------------- len --------------/
344 * \-struct wl3501_80211_tx_hdr--/ \-------- Ethernet Frame -------/
346 * Return = Postion in Card
348 static u16 wl3501_get_tx_buffer(struct wl3501_card *this, u16 len)
350 u16 next, blk_cnt = 0, zero = 0;
351 u16 full_len = sizeof(struct wl3501_80211_tx_hdr) + len;
354 if (full_len > this->tx_buffer_cnt * 254)
356 ret = this->tx_buffer_head;
362 wl3501_get_from_wla(this, this->tx_buffer_head, &next,
365 wl3501_set_to_wla(this, this->tx_buffer_head, &zero,
367 this->tx_buffer_head = next;
369 /* if buffer is not enough */
370 if (!next && full_len) {
371 this->tx_buffer_head = ret;
376 this->tx_buffer_cnt -= blk_cnt;
382 * Free an allocated Tx Buffer. ptr must be correct position.
384 static void wl3501_free_tx_buffer(struct wl3501_card *this, u16 ptr)
386 /* check if all space is not free */
387 if (!this->tx_buffer_head)
388 this->tx_buffer_head = ptr;
390 wl3501_set_to_wla(this, this->tx_buffer_tail,
395 this->tx_buffer_cnt++;
396 wl3501_get_from_wla(this, ptr, &next, sizeof(next));
397 this->tx_buffer_tail = ptr;
402 static int wl3501_esbq_req_test(struct wl3501_card *this)
406 wl3501_get_from_wla(this, this->esbq_req_head + 3, &tmp, sizeof(tmp));
410 static void wl3501_esbq_req(struct wl3501_card *this, u16 *ptr)
414 wl3501_set_to_wla(this, this->esbq_req_head, ptr, 2);
415 wl3501_set_to_wla(this, this->esbq_req_head + 2, &tmp, sizeof(tmp));
416 this->esbq_req_head += 4;
417 if (this->esbq_req_head >= this->esbq_req_end)
418 this->esbq_req_head = this->esbq_req_start;
421 static int wl3501_esbq_exec(struct wl3501_card *this, void *sig, int sig_size)
425 if (wl3501_esbq_req_test(this)) {
426 u16 ptr = wl3501_get_tx_buffer(this, sig_size);
428 wl3501_set_to_wla(this, ptr, sig, sig_size);
429 wl3501_esbq_req(this, &ptr);
436 static int wl3501_get_mib_value(struct wl3501_card *this, u8 index,
439 struct wl3501_get_req sig = {
440 .sig_id = WL3501_SIG_GET_REQ,
446 spin_lock_irqsave(&this->lock, flags);
447 if (wl3501_esbq_req_test(this)) {
448 u16 ptr = wl3501_get_tx_buffer(this, sizeof(sig));
450 wl3501_set_to_wla(this, ptr, &sig, sizeof(sig));
451 wl3501_esbq_req(this, &ptr);
452 this->sig_get_confirm.mib_status = 255;
453 spin_unlock_irqrestore(&this->lock, flags);
454 rc = wait_event_interruptible(this->wait,
455 this->sig_get_confirm.mib_status != 255);
457 memcpy(bf, this->sig_get_confirm.mib_value,
462 spin_unlock_irqrestore(&this->lock, flags);
467 static int wl3501_pwr_mgmt(struct wl3501_card *this, int suspend)
469 struct wl3501_pwr_mgmt_req sig = {
470 .sig_id = WL3501_SIG_PWR_MGMT_REQ,
478 spin_lock_irqsave(&this->lock, flags);
479 if (wl3501_esbq_req_test(this)) {
480 u16 ptr = wl3501_get_tx_buffer(this, sizeof(sig));
482 wl3501_set_to_wla(this, ptr, &sig, sizeof(sig));
483 wl3501_esbq_req(this, &ptr);
484 this->sig_pwr_mgmt_confirm.status = 255;
485 spin_unlock_irqrestore(&this->lock, flags);
486 rc = wait_event_interruptible(this->wait,
487 this->sig_pwr_mgmt_confirm.status != 255);
488 printk(KERN_INFO "%s: %s status=%d\n", __FUNCTION__,
489 suspend ? "suspend" : "resume",
490 this->sig_pwr_mgmt_confirm.status);
494 spin_unlock_irqrestore(&this->lock, flags);
500 * wl3501_send_pkt - Send a packet.
505 * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr,
506 * data[6] - data[11] is Src MAC Addr)
509 static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len)
511 u16 bf, sig_bf, next, tmplen, pktlen;
512 struct wl3501_md_req sig = {
513 .sig_id = WL3501_SIG_MD_REQ,
515 u8 *pdata = (char *)data;
518 if (wl3501_esbq_req_test(this)) {
519 sig_bf = wl3501_get_tx_buffer(this, sizeof(sig));
521 if (!sig_bf) /* No free buffer available */
523 bf = wl3501_get_tx_buffer(this, len + 26 + 24);
525 /* No free buffer available */
526 wl3501_free_tx_buffer(this, sig_bf);
530 memcpy(&sig.daddr[0], pdata, 12);
534 if (((*pdata) * 256 + (*(pdata + 1))) > 1500) {
535 u8 addr4[ETH_ALEN] = {
536 [0] = 0xAA, [1] = 0xAA, [2] = 0x03, [4] = 0x00,
539 wl3501_set_to_wla(this, bf + 2 +
540 offsetof(struct wl3501_tx_hdr, addr4),
541 addr4, sizeof(addr4));
542 sig.size = pktlen + 24 + 4 + 6;
543 if (pktlen > (254 - sizeof(struct wl3501_tx_hdr))) {
544 tmplen = 254 - sizeof(struct wl3501_tx_hdr);
550 wl3501_set_to_wla(this,
551 bf + 2 + sizeof(struct wl3501_tx_hdr),
554 wl3501_get_from_wla(this, bf, &next, sizeof(next));
557 sig.size = pktlen + 24 + 4 - 2;
560 if (pktlen > (254 - sizeof(struct wl3501_tx_hdr) + 6)) {
561 tmplen = 254 - sizeof(struct wl3501_tx_hdr) + 6;
567 wl3501_set_to_wla(this, bf + 2 +
568 offsetof(struct wl3501_tx_hdr, addr4),
571 wl3501_get_from_wla(this, bf, &next, sizeof(next));
582 wl3501_set_to_wla(this, bf + 2, pdata, tmplen);
584 wl3501_get_from_wla(this, bf, &next, sizeof(next));
587 wl3501_set_to_wla(this, sig_bf, &sig, sizeof(sig));
588 wl3501_esbq_req(this, &sig_bf);
594 static int wl3501_mgmt_resync(struct wl3501_card *this)
596 struct wl3501_resync_req sig = {
597 .sig_id = WL3501_SIG_RESYNC_REQ,
600 return wl3501_esbq_exec(this, &sig, sizeof(sig));
603 static inline int wl3501_fw_bss_type(struct wl3501_card *this)
605 return this->net_type == IW_MODE_INFRA ? WL3501_NET_TYPE_INFRA :
606 WL3501_NET_TYPE_ADHOC;
609 static inline int wl3501_fw_cap_info(struct wl3501_card *this)
611 return this->net_type == IW_MODE_INFRA ? WL3501_MGMT_CAPABILITY_ESS :
612 WL3501_MGMT_CAPABILITY_IBSS;
615 static int wl3501_mgmt_scan(struct wl3501_card *this, u16 chan_time)
617 struct wl3501_scan_req sig = {
618 .sig_id = WL3501_SIG_SCAN_REQ,
619 .scan_type = WL3501_SCAN_TYPE_ACTIVE,
621 .min_chan_time = chan_time,
622 .max_chan_time = chan_time,
623 .bss_type = wl3501_fw_bss_type(this),
626 this->bss_cnt = this->join_sta_bss = 0;
627 return wl3501_esbq_exec(this, &sig, sizeof(sig));
630 static int wl3501_mgmt_join(struct wl3501_card *this, u16 stas)
632 struct wl3501_join_req sig = {
633 .sig_id = WL3501_SIG_JOIN_REQ,
637 .id = IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET,
644 memcpy(&sig.beacon_period, &this->bss_set[stas].beacon_period, 72);
645 return wl3501_esbq_exec(this, &sig, sizeof(sig));
648 static int wl3501_mgmt_start(struct wl3501_card *this)
650 struct wl3501_start_req sig = {
651 .sig_id = WL3501_SIG_START_REQ,
652 .beacon_period = 400,
656 .id = IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET,
663 .id = IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES,
666 .data_rate_labels = {
667 [0] = IW_MGMT_RATE_LABEL_MANDATORY |
668 IW_MGMT_RATE_LABEL_1MBIT,
669 [1] = IW_MGMT_RATE_LABEL_MANDATORY |
670 IW_MGMT_RATE_LABEL_2MBIT,
673 .operational_rset = {
675 .id = IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES,
678 .data_rate_labels = {
679 [0] = IW_MGMT_RATE_LABEL_MANDATORY |
680 IW_MGMT_RATE_LABEL_1MBIT,
681 [1] = IW_MGMT_RATE_LABEL_MANDATORY |
682 IW_MGMT_RATE_LABEL_2MBIT,
687 .id = IW_MGMT_INFO_ELEMENT_IBSS_PARAMETER_SET,
692 .bss_type = wl3501_fw_bss_type(this),
693 .cap_info = wl3501_fw_cap_info(this),
696 iw_copy_mgmt_info_element(&sig.ssid.el, &this->essid.el);
697 iw_copy_mgmt_info_element(&this->keep_essid.el, &this->essid.el);
698 return wl3501_esbq_exec(this, &sig, sizeof(sig));
701 static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
705 struct wl3501_scan_confirm sig;
708 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
709 if (sig.status == WL3501_STATUS_SUCCESS) {
710 dprintk(3, "success");
711 if ((this->net_type == IW_MODE_INFRA &&
712 (sig.cap_info & WL3501_MGMT_CAPABILITY_ESS)) ||
713 (this->net_type == IW_MODE_ADHOC &&
714 (sig.cap_info & WL3501_MGMT_CAPABILITY_IBSS)) ||
715 this->net_type == IW_MODE_AUTO) {
716 if (!this->essid.el.len)
718 else if (this->essid.el.len == 3 &&
719 !memcmp(this->essid.essid, "ANY", 3))
721 else if (this->essid.el.len != sig.ssid.el.len)
723 else if (memcmp(this->essid.essid, sig.ssid.essid,
729 for (i = 0; i < this->bss_cnt; i++) {
730 if (!memcmp(this->bss_set[i].bssid,
731 sig.bssid, ETH_ALEN)) {
737 if (matchflag && (i < 20)) {
738 memcpy(&this->bss_set[i].beacon_period,
739 &sig.beacon_period, 73);
741 this->rssi = sig.rssi;
744 } else if (sig.status == WL3501_STATUS_TIMEOUT) {
745 dprintk(3, "timeout");
746 this->join_sta_bss = 0;
747 for (i = this->join_sta_bss; i < this->bss_cnt; i++)
748 if (!wl3501_mgmt_join(this, i))
750 this->join_sta_bss = i;
751 if (this->join_sta_bss == this->bss_cnt) {
752 if (this->net_type == IW_MODE_INFRA)
753 wl3501_mgmt_scan(this, 100);
756 if (this->adhoc_times > WL3501_MAX_ADHOC_TRIES)
757 wl3501_mgmt_start(this);
759 wl3501_mgmt_scan(this, 100);
766 * wl3501_block_interrupt - Mask interrupt from SUTRO
769 * Mask interrupt from SUTRO. (i.e. SUTRO cannot interrupt the HOST)
770 * Return: 1 if interrupt is originally enabled
772 static int wl3501_block_interrupt(struct wl3501_card *this)
774 u8 old = inb(this->base_addr + WL3501_NIC_GCR);
775 u8 new = old & (~(WL3501_GCR_ECINT | WL3501_GCR_INT2EC |
776 WL3501_GCR_ENECINT));
778 wl3501_outb(new, this->base_addr + WL3501_NIC_GCR);
779 return old & WL3501_GCR_ENECINT;
783 * wl3501_unblock_interrupt - Enable interrupt from SUTRO
786 * Enable interrupt from SUTRO. (i.e. SUTRO can interrupt the HOST)
787 * Return: 1 if interrupt is originally enabled
789 static int wl3501_unblock_interrupt(struct wl3501_card *this)
791 u8 old = inb(this->base_addr + WL3501_NIC_GCR);
792 u8 new = (old & ~(WL3501_GCR_ECINT | WL3501_GCR_INT2EC)) |
795 wl3501_outb(new, this->base_addr + WL3501_NIC_GCR);
796 return old & WL3501_GCR_ENECINT;
800 * wl3501_receive - Receive data from Receive Queue.
802 * Receive data from Receive Queue.
805 * @bf: address of host
806 * @size: size of buffer.
808 static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size)
810 u16 next_addr, next_addr1;
814 wl3501_get_from_wla(this, this->start_seg + 2,
815 &next_addr, sizeof(next_addr));
816 if (size > WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr)) {
817 wl3501_get_from_wla(this,
819 sizeof(struct wl3501_rx_hdr), data,
821 sizeof(struct wl3501_rx_hdr));
822 size -= WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr);
823 data += WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr);
825 wl3501_get_from_wla(this,
827 sizeof(struct wl3501_rx_hdr),
832 if (size > WL3501_BLKSZ - 5) {
833 wl3501_get_from_wla(this, next_addr + 5, data,
835 size -= WL3501_BLKSZ - 5;
836 data += WL3501_BLKSZ - 5;
837 wl3501_get_from_wla(this, next_addr + 2, &next_addr1,
839 next_addr = next_addr1;
841 wl3501_get_from_wla(this, next_addr + 5, data, size);
848 static void wl3501_esbq_req_free(struct wl3501_card *this)
853 if (this->esbq_req_head == this->esbq_req_tail)
855 wl3501_get_from_wla(this, this->esbq_req_tail + 3, &tmp, sizeof(tmp));
858 wl3501_get_from_wla(this, this->esbq_req_tail, &addr, sizeof(addr));
859 wl3501_free_tx_buffer(this, addr);
860 this->esbq_req_tail += 4;
861 if (this->esbq_req_tail >= this->esbq_req_end)
862 this->esbq_req_tail = this->esbq_req_start;
867 static int wl3501_esbq_confirm(struct wl3501_card *this)
871 wl3501_get_from_wla(this, this->esbq_confirm + 3, &tmp, sizeof(tmp));
875 static void wl3501_online(struct net_device *dev)
877 struct wl3501_card *this = dev->priv;
879 printk(KERN_INFO "%s: Wireless LAN online. BSSID: "
880 "%02X %02X %02X %02X %02X %02X\n", dev->name,
881 this->bssid[0], this->bssid[1], this->bssid[2],
882 this->bssid[3], this->bssid[4], this->bssid[5]);
883 netif_wake_queue(dev);
886 static void wl3501_esbq_confirm_done(struct wl3501_card *this)
890 wl3501_set_to_wla(this, this->esbq_confirm + 3, &tmp, sizeof(tmp));
891 this->esbq_confirm += 4;
892 if (this->esbq_confirm >= this->esbq_confirm_end)
893 this->esbq_confirm = this->esbq_confirm_start;
896 static int wl3501_mgmt_auth(struct wl3501_card *this)
898 struct wl3501_auth_req sig = {
899 .sig_id = WL3501_SIG_AUTH_REQ,
900 .type = WL3501_SYS_TYPE_OPEN,
905 memcpy(sig.mac_addr, this->bssid, ETH_ALEN);
906 return wl3501_esbq_exec(this, &sig, sizeof(sig));
909 static int wl3501_mgmt_association(struct wl3501_card *this)
911 struct wl3501_assoc_req sig = {
912 .sig_id = WL3501_SIG_ASSOC_REQ,
914 .listen_interval = 5,
915 .cap_info = this->cap_info,
919 memcpy(sig.mac_addr, this->bssid, ETH_ALEN);
920 return wl3501_esbq_exec(this, &sig, sizeof(sig));
923 static void wl3501_mgmt_join_confirm(struct net_device *dev, u16 addr)
925 struct wl3501_card *this = dev->priv;
926 struct wl3501_join_confirm sig;
929 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
930 if (sig.status == WL3501_STATUS_SUCCESS) {
931 if (this->net_type == IW_MODE_INFRA) {
932 if (this->join_sta_bss < this->bss_cnt) {
933 const int i = this->join_sta_bss;
935 this->bss_set[i].bssid, ETH_ALEN);
936 this->chan = this->bss_set[i].ds_pset.chan;
937 iw_copy_mgmt_info_element(&this->keep_essid.el,
938 &this->bss_set[i].ssid.el);
939 wl3501_mgmt_auth(this);
942 const int i = this->join_sta_bss;
944 memcpy(&this->bssid, &this->bss_set[i].bssid, ETH_ALEN);
945 this->chan = this->bss_set[i].ds_pset.chan;
946 iw_copy_mgmt_info_element(&this->keep_essid.el,
947 &this->bss_set[i].ssid.el);
952 this->join_sta_bss++;
953 for (i = this->join_sta_bss; i < this->bss_cnt; i++)
954 if (!wl3501_mgmt_join(this, i))
956 this->join_sta_bss = i;
957 if (this->join_sta_bss == this->bss_cnt) {
958 if (this->net_type == IW_MODE_INFRA)
959 wl3501_mgmt_scan(this, 100);
962 if (this->adhoc_times > WL3501_MAX_ADHOC_TRIES)
963 wl3501_mgmt_start(this);
965 wl3501_mgmt_scan(this, 100);
971 static inline void wl3501_alarm_interrupt(struct net_device *dev,
972 struct wl3501_card *this)
974 if (this->net_type == IW_MODE_INFRA) {
975 printk(KERN_INFO "Wireless LAN offline\n");
976 netif_stop_queue(dev);
977 wl3501_mgmt_resync(this);
981 static inline void wl3501_md_confirm_interrupt(struct net_device *dev,
982 struct wl3501_card *this,
985 struct wl3501_md_confirm sig;
988 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
989 wl3501_free_tx_buffer(this, sig.data);
990 if (netif_queue_stopped(dev))
991 netif_wake_queue(dev);
994 static inline void wl3501_md_ind_interrupt(struct net_device *dev,
995 struct wl3501_card *this, u16 addr)
997 struct wl3501_md_ind sig;
999 u8 rssi, addr4[ETH_ALEN];
1002 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1003 this->start_seg = sig.data;
1004 wl3501_get_from_wla(this,
1005 sig.data + offsetof(struct wl3501_rx_hdr, rssi),
1006 &rssi, sizeof(rssi));
1007 this->rssi = rssi <= 63 ? (rssi * 100) / 64 : 255;
1009 wl3501_get_from_wla(this,
1011 offsetof(struct wl3501_rx_hdr, addr4),
1012 &addr4, sizeof(addr4));
1013 if (!(addr4[0] == 0xAA && addr4[1] == 0xAA &&
1014 addr4[2] == 0x03 && addr4[4] == 0x00)) {
1015 printk(KERN_INFO "Insupported packet type!\n");
1018 pkt_len = sig.size + 12 - 24 - 4 - 6;
1020 skb = dev_alloc_skb(pkt_len + 5);
1023 printk(KERN_WARNING "%s: Can't alloc a sk_buff of size %d.\n",
1024 dev->name, pkt_len);
1025 this->stats.rx_dropped++;
1028 skb_reserve(skb, 2); /* IP headers on 16 bytes boundaries */
1029 eth_copy_and_sum(skb, (unsigned char *)&sig.daddr, 12, 0);
1030 wl3501_receive(this, skb->data, pkt_len);
1031 skb_put(skb, pkt_len);
1032 skb->protocol = eth_type_trans(skb, dev);
1033 dev->last_rx = jiffies;
1034 this->stats.rx_packets++;
1035 this->stats.rx_bytes += skb->len;
1040 static inline void wl3501_get_confirm_interrupt(struct wl3501_card *this,
1041 u16 addr, void *sig, int size)
1043 dprintk(3, "entry");
1044 wl3501_get_from_wla(this, addr, &this->sig_get_confirm,
1045 sizeof(this->sig_get_confirm));
1046 wake_up(&this->wait);
1049 static inline void wl3501_start_confirm_interrupt(struct net_device *dev,
1050 struct wl3501_card *this,
1053 struct wl3501_start_confirm sig;
1055 dprintk(3, "entry");
1056 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1057 if (sig.status == WL3501_STATUS_SUCCESS)
1058 netif_wake_queue(dev);
1061 static inline void wl3501_assoc_confirm_interrupt(struct net_device *dev,
1064 struct wl3501_card *this = dev->priv;
1065 struct wl3501_assoc_confirm sig;
1067 dprintk(3, "entry");
1068 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1070 if (sig.status == WL3501_STATUS_SUCCESS)
1074 static inline void wl3501_auth_confirm_interrupt(struct wl3501_card *this,
1077 struct wl3501_auth_confirm sig;
1079 dprintk(3, "entry");
1080 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1082 if (sig.status == WL3501_STATUS_SUCCESS)
1083 wl3501_mgmt_association(this);
1085 wl3501_mgmt_resync(this);
1088 static inline void wl3501_rx_interrupt(struct net_device *dev)
1093 struct wl3501_card *this = dev->priv;
1095 dprintk(3, "entry");
1098 if (!wl3501_esbq_confirm(this))
1100 wl3501_get_from_wla(this, this->esbq_confirm, &addr, sizeof(addr));
1101 wl3501_get_from_wla(this, addr + 2, &sig_id, sizeof(sig_id));
1104 case WL3501_SIG_DEAUTH_IND:
1105 case WL3501_SIG_DISASSOC_IND:
1106 case WL3501_SIG_ALARM:
1107 wl3501_alarm_interrupt(dev, this);
1109 case WL3501_SIG_MD_CONFIRM:
1110 wl3501_md_confirm_interrupt(dev, this, addr);
1112 case WL3501_SIG_MD_IND:
1113 wl3501_md_ind_interrupt(dev, this, addr);
1115 case WL3501_SIG_GET_CONFIRM:
1116 wl3501_get_confirm_interrupt(this, addr,
1117 &this->sig_get_confirm,
1118 sizeof(this->sig_get_confirm));
1120 case WL3501_SIG_PWR_MGMT_CONFIRM:
1121 wl3501_get_confirm_interrupt(this, addr,
1122 &this->sig_pwr_mgmt_confirm,
1123 sizeof(this->sig_pwr_mgmt_confirm));
1125 case WL3501_SIG_START_CONFIRM:
1126 wl3501_start_confirm_interrupt(dev, this, addr);
1128 case WL3501_SIG_SCAN_CONFIRM:
1129 wl3501_mgmt_scan_confirm(this, addr);
1131 case WL3501_SIG_JOIN_CONFIRM:
1132 wl3501_mgmt_join_confirm(dev, addr);
1134 case WL3501_SIG_ASSOC_CONFIRM:
1135 wl3501_assoc_confirm_interrupt(dev, addr);
1137 case WL3501_SIG_AUTH_CONFIRM:
1138 wl3501_auth_confirm_interrupt(this, addr);
1140 case WL3501_SIG_RESYNC_CONFIRM:
1141 wl3501_mgmt_resync(this); /* FIXME: should be resync_confirm */
1144 wl3501_esbq_confirm_done(this);
1146 /* free request if necessary */
1148 wl3501_esbq_req_free(this);
1153 static inline void wl3501_ack_interrupt(struct wl3501_card *this)
1155 wl3501_outb(WL3501_GCR_ECINT, this->base_addr + WL3501_NIC_GCR);
1159 * wl3501_interrupt - Hardware interrupt from card.
1160 * @irq - Interrupt number
1161 * @dev_id - net_device
1164 * We must acknowledge the interrupt as soon as possible, and block the
1165 * interrupt from the same card immediately to prevent re-entry.
1167 * Before accessing the Control_Status_Block, we must lock SUTRO first.
1168 * On the other hand, to prevent SUTRO from malfunctioning, we must
1169 * unlock the SUTRO as soon as possible.
1171 static irqreturn_t wl3501_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1173 struct net_device *dev = (struct net_device *)dev_id;
1174 struct wl3501_card *this;
1180 spin_lock(&this->lock);
1181 wl3501_ack_interrupt(this);
1182 wl3501_block_interrupt(this);
1183 wl3501_rx_interrupt(dev);
1184 wl3501_unblock_interrupt(this);
1185 spin_unlock(&this->lock);
1187 return IRQ_RETVAL(handled);
1190 printk(KERN_ERR "%s: irq %d for unknown device.\n", __FUNCTION__, irq);
1194 static int wl3501_reset_board(struct wl3501_card *this)
1200 wl3501_outb_p(WL3501_GCR_CORESET, this->base_addr + WL3501_NIC_GCR);
1201 wl3501_outb_p(0, this->base_addr + WL3501_NIC_GCR);
1202 wl3501_outb_p(WL3501_GCR_CORESET, this->base_addr + WL3501_NIC_GCR);
1204 /* Reset SRAM 0x480 to zero */
1205 wl3501_set_to_wla(this, 0x480, &tmp, sizeof(tmp));
1208 wl3501_outb_p(0, this->base_addr + WL3501_NIC_GCR);
1210 WL3501_NOPLOOP(1024 * 50);
1212 wl3501_unblock_interrupt(this); /* acme: was commented */
1214 /* Polling Self_Test_Status */
1215 for (i = 0; i < 10000; i++) {
1216 wl3501_get_from_wla(this, 0x480, &tmp, sizeof(tmp));
1219 /* firmware complete all test successfully */
1221 wl3501_set_to_wla(this, 0x480, &tmp, sizeof(tmp));
1226 printk(KERN_WARNING "%s: failed to reset the board!\n", __FUNCTION__);
1232 static int wl3501_init_firmware(struct wl3501_card *this)
1235 int rc = wl3501_reset_board(this);
1239 this->card_name[0] = '\0';
1240 wl3501_get_from_wla(this, 0x1a00,
1241 this->card_name, sizeof(this->card_name));
1242 this->card_name[sizeof(this->card_name) - 1] = '\0';
1243 this->firmware_date[0] = '\0';
1244 wl3501_get_from_wla(this, 0x1a40,
1245 this->firmware_date, sizeof(this->firmware_date));
1246 this->firmware_date[sizeof(this->firmware_date) - 1] = '\0';
1247 /* Switch to SRAM Page 0 */
1248 wl3501_switch_page(this, WL3501_BSS_SPAGE0);
1249 /* Read parameter from card */
1250 wl3501_get_from_wla(this, 0x482, &this->esbq_req_start, 2);
1251 wl3501_get_from_wla(this, 0x486, &this->esbq_req_end, 2);
1252 wl3501_get_from_wla(this, 0x488, &this->esbq_confirm_start, 2);
1253 wl3501_get_from_wla(this, 0x48c, &this->esbq_confirm_end, 2);
1254 wl3501_get_from_wla(this, 0x48e, &this->tx_buffer_head, 2);
1255 wl3501_get_from_wla(this, 0x492, &this->tx_buffer_size, 2);
1256 this->esbq_req_tail = this->esbq_req_head = this->esbq_req_start;
1257 this->esbq_req_end += this->esbq_req_start;
1258 this->esbq_confirm = this->esbq_confirm_start;
1259 this->esbq_confirm_end += this->esbq_confirm_start;
1260 /* Initial Tx Buffer */
1261 this->tx_buffer_cnt = 1;
1262 ptr = this->tx_buffer_head;
1263 next = ptr + WL3501_BLKSZ;
1264 while ((next - this->tx_buffer_head) < this->tx_buffer_size) {
1265 this->tx_buffer_cnt++;
1266 wl3501_set_to_wla(this, ptr, &next, sizeof(next));
1268 next = ptr + WL3501_BLKSZ;
1272 wl3501_set_to_wla(this, ptr, &next, sizeof(next));
1273 this->tx_buffer_tail = ptr;
1277 printk(KERN_WARNING "%s: failed!\n", __FUNCTION__);
1281 static int wl3501_close(struct net_device *dev)
1283 struct wl3501_card *this = dev->priv;
1285 unsigned long flags;
1288 spin_lock_irqsave(&this->lock, flags);
1289 /* Check if the device is in wl3501_dev_list */
1290 for (link = wl3501_dev_list; link; link = link->next)
1291 if (link->priv == dev)
1297 /* Stop wl3501_hard_start_xmit() from now on */
1298 netif_stop_queue(dev);
1299 wl3501_ack_interrupt(this);
1301 /* Mask interrupts from the SUTRO */
1302 wl3501_block_interrupt(this);
1305 printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
1307 spin_unlock_irqrestore(&this->lock, flags);
1312 * wl3501_reset - Reset the SUTRO.
1313 * @dev - network device
1315 * It is almost the same as wl3501_open(). In fact, we may just wl3501_close()
1316 * and wl3501_open() again, but I wouldn't like to free_irq() when the driver
1317 * is running. It seems to be dangerous.
1319 static int wl3501_reset(struct net_device *dev)
1321 struct wl3501_card *this = dev->priv;
1324 wl3501_block_interrupt(this);
1326 if (wl3501_init_firmware(this)) {
1327 printk(KERN_WARNING "%s: Can't initialize Firmware!\n",
1329 /* Free IRQ, and mark IRQ as unused */
1330 free_irq(dev->irq, dev);
1335 * Queue has to be started only when the Card is Started
1337 netif_stop_queue(dev);
1338 this->adhoc_times = 0;
1339 wl3501_ack_interrupt(this);
1340 wl3501_unblock_interrupt(this);
1341 wl3501_mgmt_scan(this, 100);
1342 dprintk(1, "%s: device reset", dev->name);
1348 static void wl3501_tx_timeout(struct net_device *dev)
1350 struct wl3501_card *this = dev->priv;
1351 struct net_device_stats *stats = &this->stats;
1352 unsigned long flags;
1356 spin_lock_irqsave(&this->lock, flags);
1357 rc = wl3501_reset(dev);
1358 spin_unlock_irqrestore(&this->lock, flags);
1360 printk(KERN_ERR "%s: Error %d resetting card on Tx timeout!\n",
1363 dev->trans_start = jiffies;
1364 netif_wake_queue(dev);
1370 * 1 - Could not transmit (dev_queue_xmit will queue it)
1371 * and try to sent it later
1373 static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1376 struct wl3501_card *this = dev->priv;
1377 unsigned long flags;
1379 spin_lock_irqsave(&this->lock, flags);
1380 enabled = wl3501_block_interrupt(this);
1381 dev->trans_start = jiffies;
1382 rc = wl3501_send_pkt(this, skb->data, skb->len);
1384 wl3501_unblock_interrupt(this);
1386 ++this->stats.tx_dropped;
1387 netif_stop_queue(dev);
1389 ++this->stats.tx_packets;
1390 this->stats.tx_bytes += skb->len;
1393 if (this->tx_buffer_cnt < 2)
1394 netif_stop_queue(dev);
1396 spin_unlock_irqrestore(&this->lock, flags);
1400 static int wl3501_open(struct net_device *dev)
1403 struct wl3501_card *this = dev->priv;
1404 unsigned long flags;
1407 spin_lock_irqsave(&this->lock, flags);
1408 /* Check if the device is in wl3501_dev_list */
1409 for (link = wl3501_dev_list; link; link = link->next)
1410 if (link->priv == dev)
1414 netif_device_attach(dev);
1417 /* Initial WL3501 firmware */
1418 dprintk(1, "%s: Initialize WL3501 firmware...", dev->name);
1419 if (wl3501_init_firmware(this))
1421 /* Initial device variables */
1422 this->adhoc_times = 0;
1423 /* Acknowledge Interrupt, for cleaning last state */
1424 wl3501_ack_interrupt(this);
1426 /* Enable interrupt from card after all */
1427 wl3501_unblock_interrupt(this);
1428 wl3501_mgmt_scan(this, 100);
1430 dprintk(1, "%s: WL3501 opened", dev->name);
1431 printk(KERN_INFO "%s: Card Name: %s\n"
1432 "%s: Firmware Date: %s\n",
1433 dev->name, this->card_name,
1434 dev->name, this->firmware_date);
1436 spin_unlock_irqrestore(&this->lock, flags);
1439 printk(KERN_WARNING "%s: Can't initialize firmware!\n", dev->name);
1443 static struct net_device_stats *wl3501_get_stats(struct net_device *dev)
1445 struct wl3501_card *this = dev->priv;
1447 return &this->stats;
1450 static struct iw_statistics *wl3501_get_wireless_stats(struct net_device *dev)
1452 struct wl3501_card *this = dev->priv;
1453 struct iw_statistics *wstats = &this->wstats;
1454 u32 value; /* size checked: it is u32 */
1456 memset(wstats, 0, sizeof(*wstats));
1457 wstats->status = netif_running(dev);
1458 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_ICV_ERROR_COUNT,
1459 &value, sizeof(value)))
1460 wstats->discard.code += value;
1461 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_UNDECRYPTABLE_COUNT,
1462 &value, sizeof(value)))
1463 wstats->discard.code += value;
1464 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_EXCLUDED_COUNT,
1465 &value, sizeof(value)))
1466 wstats->discard.code += value;
1467 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RETRY_COUNT,
1468 &value, sizeof(value)))
1469 wstats->discard.retries = value;
1470 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FAILED_COUNT,
1471 &value, sizeof(value)))
1472 wstats->discard.misc += value;
1473 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_FAILURE_COUNT,
1474 &value, sizeof(value)))
1475 wstats->discard.misc += value;
1476 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_ACK_FAILURE_COUNT,
1477 &value, sizeof(value)))
1478 wstats->discard.misc += value;
1479 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAME_DUPLICATE_COUNT,
1480 &value, sizeof(value)))
1481 wstats->discard.misc += value;
1485 static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1487 strlcpy(info->driver, wl3501_dev_info, sizeof(info->driver));
1490 static struct ethtool_ops ops = {
1491 .get_drvinfo = wl3501_get_drvinfo
1495 * wl3501_detach - deletes a driver "instance"
1498 * This deletes a driver "instance". The device is de-registered with Card
1499 * Services. If it has been released, all local data structures are freed.
1500 * Otherwise, the structures will be freed when the device is released.
1502 static void wl3501_detach(dev_link_t *link)
1506 /* Locate device structure */
1507 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
1513 /* If the device is currently configured and active, we won't actually
1514 * delete it yet. Instead, it is marked so that when the release()
1515 * function is called, that will trigger a proper detach(). */
1517 if (link->state & DEV_CONFIG) {
1519 printk(KERN_DEBUG "wl3501_cs: detach postponed, '%s' "
1520 "still locked\n", link->dev->dev_name);
1525 /* Break the link with Card Services */
1527 pcmcia_deregister_client(link->handle);
1529 /* Unlink device structure, free pieces */
1530 *linkp = link->next;
1533 free_netdev(link->priv);
1539 static int wl3501_get_name(struct net_device *dev, struct iw_request_info *info,
1540 union iwreq_data *wrqu, char *extra)
1542 strlcpy(wrqu->name, "IEEE 802.11-DS", sizeof(wrqu->name));
1546 static int wl3501_set_freq(struct net_device *dev, struct iw_request_info *info,
1547 union iwreq_data *wrqu, char *extra)
1549 struct wl3501_card *this = dev->priv;
1550 int channel = wrqu->freq.m;
1553 if (iw_valid_channel(this->reg_domain, channel)) {
1554 this->chan = channel;
1555 rc = wl3501_reset(dev);
1560 static int wl3501_get_freq(struct net_device *dev, struct iw_request_info *info,
1561 union iwreq_data *wrqu, char *extra)
1563 struct wl3501_card *this = dev->priv;
1565 wrqu->freq.m = wl3501_chan2freq[this->chan - 1] * 100000;
1570 static int wl3501_set_mode(struct net_device *dev, struct iw_request_info *info,
1571 union iwreq_data *wrqu, char *extra)
1575 if (wrqu->mode == IW_MODE_INFRA ||
1576 wrqu->mode == IW_MODE_ADHOC ||
1577 wrqu->mode == IW_MODE_AUTO) {
1578 struct wl3501_card *this = dev->priv;
1580 this->net_type = wrqu->mode;
1581 rc = wl3501_reset(dev);
1586 static int wl3501_get_mode(struct net_device *dev, struct iw_request_info *info,
1587 union iwreq_data *wrqu, char *extra)
1589 struct wl3501_card *this = dev->priv;
1591 wrqu->mode = this->net_type;
1595 static int wl3501_get_sens(struct net_device *dev, struct iw_request_info *info,
1596 union iwreq_data *wrqu, char *extra)
1598 struct wl3501_card *this = dev->priv;
1600 wrqu->sens.value = this->rssi;
1601 wrqu->sens.disabled = !wrqu->sens.value;
1602 wrqu->sens.fixed = 1;
1606 static int wl3501_get_range(struct net_device *dev,
1607 struct iw_request_info *info,
1608 union iwreq_data *wrqu, char *extra)
1610 struct iw_range *range = (struct iw_range *)extra;
1612 /* Set the length (very important for backward compatibility) */
1613 wrqu->data.length = sizeof(*range);
1615 /* Set all the info we don't care or don't know about to zero */
1616 memset(range, 0, sizeof(*range));
1618 /* Set the Wireless Extension versions */
1619 range->we_version_compiled = WIRELESS_EXT;
1620 range->we_version_source = 1;
1621 range->throughput = 2 * 1000 * 1000; /* ~2 Mb/s */
1622 /* FIXME: study the code to fill in more fields... */
1626 static int wl3501_set_wap(struct net_device *dev, struct iw_request_info *info,
1627 union iwreq_data *wrqu, char *extra)
1629 struct wl3501_card *this = dev->priv;
1630 static const u8 bcast[ETH_ALEN] = { 255, 255, 255, 255, 255, 255 };
1633 /* FIXME: we support other ARPHRDs...*/
1634 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
1636 if (!memcmp(bcast, wrqu->ap_addr.sa_data, ETH_ALEN)) {
1637 /* FIXME: rescan? */
1639 memcpy(this->bssid, wrqu->ap_addr.sa_data, ETH_ALEN);
1640 /* FIXME: rescan? deassoc & scan? */
1646 static int wl3501_get_wap(struct net_device *dev, struct iw_request_info *info,
1647 union iwreq_data *wrqu, char *extra)
1649 struct wl3501_card *this = dev->priv;
1651 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
1652 memcpy(wrqu->ap_addr.sa_data, this->bssid, ETH_ALEN);
1656 static int wl3501_set_scan(struct net_device *dev, struct iw_request_info *info,
1657 union iwreq_data *wrqu, char *extra)
1660 * FIXME: trigger scanning with a reset, yes, I'm lazy
1662 return wl3501_reset(dev);
1665 static int wl3501_get_scan(struct net_device *dev, struct iw_request_info *info,
1666 union iwreq_data *wrqu, char *extra)
1668 struct wl3501_card *this = dev->priv;
1670 char *current_ev = extra;
1671 struct iw_event iwe;
1673 for (i = 0; i < this->bss_cnt; ++i) {
1674 iwe.cmd = SIOCGIWAP;
1675 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1676 memcpy(iwe.u.ap_addr.sa_data, this->bss_set[i].bssid, ETH_ALEN);
1677 current_ev = iwe_stream_add_event(current_ev,
1678 extra + IW_SCAN_MAX_DATA,
1679 &iwe, IW_EV_ADDR_LEN);
1680 iwe.cmd = SIOCGIWESSID;
1681 iwe.u.data.flags = 1;
1682 iwe.u.data.length = this->bss_set[i].ssid.el.len;
1683 current_ev = iwe_stream_add_point(current_ev,
1684 extra + IW_SCAN_MAX_DATA,
1686 this->bss_set[i].ssid.essid);
1687 iwe.cmd = SIOCGIWMODE;
1688 iwe.u.mode = this->bss_set[i].bss_type;
1689 current_ev = iwe_stream_add_event(current_ev,
1690 extra + IW_SCAN_MAX_DATA,
1691 &iwe, IW_EV_UINT_LEN);
1692 iwe.cmd = SIOCGIWFREQ;
1693 iwe.u.freq.m = this->bss_set[i].ds_pset.chan;
1695 current_ev = iwe_stream_add_event(current_ev,
1696 extra + IW_SCAN_MAX_DATA,
1697 &iwe, IW_EV_FREQ_LEN);
1698 iwe.cmd = SIOCGIWENCODE;
1699 if (this->bss_set[i].cap_info & WL3501_MGMT_CAPABILITY_PRIVACY)
1700 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1702 iwe.u.data.flags = IW_ENCODE_DISABLED;
1703 iwe.u.data.length = 0;
1704 current_ev = iwe_stream_add_point(current_ev,
1705 extra + IW_SCAN_MAX_DATA,
1708 /* Length of data */
1709 wrqu->data.length = (current_ev - extra);
1710 wrqu->data.flags = 0; /* FIXME: set properly these flags */
1714 static int wl3501_set_essid(struct net_device *dev,
1715 struct iw_request_info *info,
1716 union iwreq_data *wrqu, char *extra)
1718 struct wl3501_card *this = dev->priv;
1720 if (wrqu->data.flags) {
1721 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID,
1723 extra, wrqu->data.length);
1724 } else { /* We accept any ESSID */
1725 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID,
1726 &this->essid.el, "ANY", 3);
1728 return wl3501_reset(dev);
1731 static int wl3501_get_essid(struct net_device *dev,
1732 struct iw_request_info *info,
1733 union iwreq_data *wrqu, char *extra)
1735 struct wl3501_card *this = dev->priv;
1736 unsigned long flags;
1738 spin_lock_irqsave(&this->lock, flags);
1739 wrqu->essid.flags = 1;
1740 wrqu->essid.length = this->essid.el.len;
1741 memcpy(extra, this->essid.essid, this->essid.el.len);
1742 spin_unlock_irqrestore(&this->lock, flags);
1746 static int wl3501_set_nick(struct net_device *dev, struct iw_request_info *info,
1747 union iwreq_data *wrqu, char *extra)
1749 struct wl3501_card *this = dev->priv;
1751 if (wrqu->data.length > sizeof(this->nick))
1753 strlcpy(this->nick, extra, wrqu->data.length);
1757 static int wl3501_get_nick(struct net_device *dev, struct iw_request_info *info,
1758 union iwreq_data *wrqu, char *extra)
1760 struct wl3501_card *this = dev->priv;
1762 strlcpy(extra, this->nick, 32);
1763 wrqu->data.length = strlen(extra);
1767 static int wl3501_get_rate(struct net_device *dev, struct iw_request_info *info,
1768 union iwreq_data *wrqu, char *extra)
1771 * FIXME: have to see from where to get this info, perhaps this card
1772 * works at 1 Mbit/s too... for now leave at 2 Mbit/s that is the most
1773 * common with the Planet Access Points. -acme
1775 wrqu->bitrate.value = 2000000;
1776 wrqu->bitrate.fixed = 1;
1780 static int wl3501_get_rts_threshold(struct net_device *dev,
1781 struct iw_request_info *info,
1782 union iwreq_data *wrqu, char *extra)
1784 u16 threshold; /* size checked: it is u16 */
1785 struct wl3501_card *this = dev->priv;
1786 int rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_THRESHOLD,
1787 &threshold, sizeof(threshold));
1789 wrqu->rts.value = threshold;
1790 wrqu->rts.disabled = threshold >= 2347;
1791 wrqu->rts.fixed = 1;
1796 static int wl3501_get_frag_threshold(struct net_device *dev,
1797 struct iw_request_info *info,
1798 union iwreq_data *wrqu, char *extra)
1800 u16 threshold; /* size checked: it is u16 */
1801 struct wl3501_card *this = dev->priv;
1802 int rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAG_THRESHOLD,
1803 &threshold, sizeof(threshold));
1805 wrqu->frag.value = threshold;
1806 wrqu->frag.disabled = threshold >= 2346;
1807 wrqu->frag.fixed = 1;
1812 static int wl3501_get_txpow(struct net_device *dev,
1813 struct iw_request_info *info,
1814 union iwreq_data *wrqu, char *extra)
1817 struct wl3501_card *this = dev->priv;
1818 int rc = wl3501_get_mib_value(this,
1819 WL3501_MIB_ATTR_CURRENT_TX_PWR_LEVEL,
1820 &txpow, sizeof(txpow));
1822 wrqu->txpower.value = txpow;
1823 wrqu->txpower.disabled = 0;
1825 * From the MIB values I think this can be configurable,
1826 * as it lists several tx power levels -acme
1828 wrqu->txpower.fixed = 0;
1829 wrqu->txpower.flags = IW_TXPOW_MWATT;
1834 static int wl3501_get_retry(struct net_device *dev,
1835 struct iw_request_info *info,
1836 union iwreq_data *wrqu, char *extra)
1838 u8 retry; /* size checked: it is u8 */
1839 struct wl3501_card *this = dev->priv;
1840 int rc = wl3501_get_mib_value(this,
1841 WL3501_MIB_ATTR_LONG_RETRY_LIMIT,
1842 &retry, sizeof(retry));
1845 if (wrqu->retry.flags & IW_RETRY_MAX) {
1846 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1849 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT,
1850 &retry, sizeof(retry));
1853 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
1855 wrqu->retry.value = retry;
1856 wrqu->retry.disabled = 0;
1861 static int wl3501_get_encode(struct net_device *dev,
1862 struct iw_request_info *info,
1863 union iwreq_data *wrqu, char *extra)
1865 u8 implemented, restricted, keys[100], len_keys, tocopy;
1866 struct wl3501_card *this = dev->priv;
1867 int rc = wl3501_get_mib_value(this,
1868 WL3501_MIB_ATTR_PRIV_OPT_IMPLEMENTED,
1869 &implemented, sizeof(implemented));
1873 wrqu->encoding.flags = IW_ENCODE_DISABLED;
1876 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_EXCLUDE_UNENCRYPTED,
1877 &restricted, sizeof(restricted));
1880 wrqu->encoding.flags = restricted ? IW_ENCODE_RESTRICTED :
1882 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS_LEN,
1883 &len_keys, sizeof(len_keys));
1886 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS,
1890 tocopy = min_t(u8, len_keys, wrqu->encoding.length);
1891 tocopy = min_t(u8, tocopy, 100);
1892 wrqu->encoding.length = tocopy;
1893 memset(extra, 0, tocopy);
1894 memcpy(extra, keys, tocopy);
1899 static int wl3501_get_power(struct net_device *dev,
1900 struct iw_request_info *info,
1901 union iwreq_data *wrqu, char *extra)
1904 struct wl3501_card *this = dev->priv;
1905 int rc = wl3501_get_mib_value(this,
1906 WL3501_MIB_ATTR_CURRENT_PWR_STATE,
1907 &pwr_state, sizeof(pwr_state));
1910 wrqu->power.disabled = !pwr_state;
1911 wrqu->power.flags = IW_POWER_ON;
1916 static const iw_handler wl3501_handler[] = {
1917 [SIOCGIWNAME - SIOCIWFIRST] = wl3501_get_name,
1918 [SIOCSIWFREQ - SIOCIWFIRST] = wl3501_set_freq,
1919 [SIOCGIWFREQ - SIOCIWFIRST] = wl3501_get_freq,
1920 [SIOCSIWMODE - SIOCIWFIRST] = wl3501_set_mode,
1921 [SIOCGIWMODE - SIOCIWFIRST] = wl3501_get_mode,
1922 [SIOCGIWSENS - SIOCIWFIRST] = wl3501_get_sens,
1923 [SIOCGIWRANGE - SIOCIWFIRST] = wl3501_get_range,
1924 [SIOCSIWSPY - SIOCIWFIRST] = iw_handler_set_spy,
1925 [SIOCGIWSPY - SIOCIWFIRST] = iw_handler_get_spy,
1926 [SIOCSIWTHRSPY - SIOCIWFIRST] = iw_handler_set_thrspy,
1927 [SIOCGIWTHRSPY - SIOCIWFIRST] = iw_handler_get_thrspy,
1928 [SIOCSIWAP - SIOCIWFIRST] = wl3501_set_wap,
1929 [SIOCGIWAP - SIOCIWFIRST] = wl3501_get_wap,
1930 [SIOCSIWSCAN - SIOCIWFIRST] = wl3501_set_scan,
1931 [SIOCGIWSCAN - SIOCIWFIRST] = wl3501_get_scan,
1932 [SIOCSIWESSID - SIOCIWFIRST] = wl3501_set_essid,
1933 [SIOCGIWESSID - SIOCIWFIRST] = wl3501_get_essid,
1934 [SIOCSIWNICKN - SIOCIWFIRST] = wl3501_set_nick,
1935 [SIOCGIWNICKN - SIOCIWFIRST] = wl3501_get_nick,
1936 [SIOCGIWRATE - SIOCIWFIRST] = wl3501_get_rate,
1937 [SIOCGIWRTS - SIOCIWFIRST] = wl3501_get_rts_threshold,
1938 [SIOCGIWFRAG - SIOCIWFIRST] = wl3501_get_frag_threshold,
1939 [SIOCGIWTXPOW - SIOCIWFIRST] = wl3501_get_txpow,
1940 [SIOCGIWRETRY - SIOCIWFIRST] = wl3501_get_retry,
1941 [SIOCGIWENCODE - SIOCIWFIRST] = wl3501_get_encode,
1942 [SIOCGIWPOWER - SIOCIWFIRST] = wl3501_get_power,
1945 static const struct iw_handler_def wl3501_handler_def = {
1946 .num_standard = sizeof(wl3501_handler) / sizeof(iw_handler),
1947 .standard = (iw_handler *)wl3501_handler,
1948 .spy_offset = offsetof(struct wl3501_card, spy_data),
1952 * wl3501_attach - creates an "instance" of the driver
1954 * Creates an "instance" of the driver, allocating local data structures for
1955 * one device. The device is registered with Card Services.
1957 * The dev_link structure is initialized, but we don't actually configure the
1958 * card at this point -- we wait until we receive a card insertion event.
1960 static dev_link_t *wl3501_attach(void)
1962 client_reg_t client_reg;
1964 struct net_device *dev;
1967 /* Initialize the dev_link_t structure */
1968 link = kmalloc(sizeof(*link), GFP_KERNEL);
1971 memset(link, 0, sizeof(struct dev_link_t));
1973 /* The io structure describes IO port mapping */
1974 link->io.NumPorts1 = 16;
1975 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
1976 link->io.IOAddrLines = 5;
1978 /* Interrupt setup */
1979 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
1980 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
1981 link->irq.Handler = wl3501_interrupt;
1983 /* General socket configuration */
1984 link->conf.Attributes = CONF_ENABLE_IRQ;
1985 link->conf.Vcc = 50;
1986 link->conf.IntType = INT_MEMORY_AND_IO;
1987 link->conf.ConfigIndex = 1;
1988 link->conf.Present = PRESENT_OPTION;
1990 dev = alloc_etherdev(sizeof(struct wl3501_card));
1993 dev->open = wl3501_open;
1994 dev->stop = wl3501_close;
1995 dev->hard_start_xmit = wl3501_hard_start_xmit;
1996 dev->tx_timeout = wl3501_tx_timeout;
1997 dev->watchdog_timeo = 5 * HZ;
1998 dev->get_stats = wl3501_get_stats;
1999 dev->get_wireless_stats = wl3501_get_wireless_stats;
2000 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def;
2001 SET_ETHTOOL_OPS(dev, &ops);
2002 netif_stop_queue(dev);
2003 link->priv = link->irq.Instance = dev;
2005 /* Register with Card Services */
2006 link->next = wl3501_dev_list;
2007 wl3501_dev_list = link;
2008 client_reg.dev_info = &wl3501_dev_info;
2009 client_reg.EventMask = CS_EVENT_CARD_INSERTION |
2010 CS_EVENT_RESET_PHYSICAL |
2011 CS_EVENT_CARD_RESET |
2012 CS_EVENT_CARD_REMOVAL |
2013 CS_EVENT_PM_SUSPEND |
2015 client_reg.event_handler = wl3501_event;
2016 client_reg.Version = 0x0210;
2017 client_reg.event_callback_args.client_data = link;
2018 ret = pcmcia_register_client(&link->handle, &client_reg);
2020 cs_error(link->handle, RegisterClient, ret);
2021 wl3501_detach(link);
2032 #define CS_CHECK(fn, ret) \
2033 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
2036 * wl3501_config - configure the PCMCIA socket and make eth device available
2039 * wl3501_config() is scheduled to run after a CARD_INSERTION event is
2040 * received, to configure the PCMCIA socket, and to make the ethernet device
2041 * available to the system.
2043 static void wl3501_config(dev_link_t *link)
2047 client_handle_t handle = link->handle;
2048 struct net_device *dev = link->priv;
2049 int i = 0, j, last_fn, last_ret;
2050 unsigned char bf[64];
2051 struct wl3501_card *this;
2053 /* This reads the card's CONFIG tuple to find its config registers. */
2054 tuple.Attributes = 0;
2055 tuple.DesiredTuple = CISTPL_CONFIG;
2056 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
2057 tuple.TupleData = bf;
2058 tuple.TupleDataMax = sizeof(bf);
2059 tuple.TupleOffset = 0;
2060 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
2061 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
2062 link->conf.ConfigBase = parse.config.base;
2063 link->conf.Present = parse.config.rmask[0];
2065 /* Configure card */
2066 link->state |= DEV_CONFIG;
2068 /* Try allocating IO ports. This tries a few fixed addresses. If you
2069 * want, you can also read the card's config table to pick addresses --
2070 * see the serial driver for an example. */
2072 for (j = 0x280; j < 0x400; j += 0x20) {
2073 /* The '^0x300' is so that we probe 0x300-0x3ff first, then
2074 * 0x200-0x2ff, and so on, because this seems safer */
2075 link->io.BasePort1 = j;
2076 link->io.BasePort2 = link->io.BasePort1 + 0x10;
2077 i = pcmcia_request_io(link->handle, &link->io);
2078 if (i == CS_SUCCESS)
2081 if (i != CS_SUCCESS) {
2082 cs_error(link->handle, RequestIO, i);
2086 /* Now allocate an interrupt line. Note that this does not actually
2087 * assign a handler to the interrupt. */
2089 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
2091 /* This actually configures the PCMCIA socket -- setting up the I/O
2092 * windows and the interrupt mapping. */
2094 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
2096 dev->irq = link->irq.AssignedIRQ;
2097 dev->base_addr = link->io.BasePort1;
2098 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
2099 if (register_netdev(dev)) {
2100 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
2104 SET_MODULE_OWNER(dev);
2108 * At this point, the dev_node_t structure(s) should be initialized and
2109 * arranged in a linked list at link->dev.
2111 link->dev = &this->node;
2112 link->state &= ~DEV_CONFIG_PENDING;
2114 this->base_addr = dev->base_addr;
2116 if (!wl3501_get_flash_mac_addr(this)) {
2117 printk(KERN_WARNING "%s: Cant read MAC addr in flash ROM?\n",
2121 strcpy(this->node.dev_name, dev->name);
2123 /* print probe information */
2124 printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, MAC addr in flash ROM:",
2125 dev->name, this->base_addr, (int)dev->irq);
2126 for (i = 0; i < 6; i++) {
2127 dev->dev_addr[i] = ((char *)&this->mac_addr)[i];
2128 printk("%c%02x", i ? ':' : ' ', dev->dev_addr[i]);
2132 * Initialize card parameters - added by jss
2134 this->net_type = IW_MODE_INFRA;
2136 this->join_sta_bss = 0;
2137 this->adhoc_times = 0;
2138 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID, &this->essid.el,
2140 this->card_name[0] = '\0';
2141 this->firmware_date[0] = '\0';
2143 this->chan = iw_default_channel(this->reg_domain);
2144 strlcpy(this->nick, "Planet WL3501", sizeof(this->nick));
2145 spin_lock_init(&this->lock);
2146 init_waitqueue_head(&this->wait);
2147 netif_start_queue(dev);
2150 cs_error(link->handle, last_fn, last_ret);
2152 wl3501_release(link);
2158 * wl3501_release - unregister the net, release PCMCIA configuration
2161 * After a card is removed, wl3501_release() will unregister the net device,
2162 * and release the PCMCIA configuration. If the device is still open, this
2163 * will be postponed until it is closed.
2165 static void wl3501_release(dev_link_t *link)
2167 struct net_device *dev = link->priv;
2169 /* Unlink the device chain */
2171 unregister_netdev(dev);
2175 /* Don't bother checking to see if these succeed or not */
2176 pcmcia_release_configuration(link->handle);
2177 pcmcia_release_io(link->handle, &link->io);
2178 pcmcia_release_irq(link->handle, &link->irq);
2179 link->state &= ~DEV_CONFIG;
2183 * wl3501_event - The card status event handler
2186 * @args - arguments for this event
2188 * The card status event handler. Mostly, this schedules other stuff to run
2189 * after an event is received. A CARD_REMOVAL event also sets some flags to
2190 * discourage the net drivers from trying to talk to the card any more.
2192 * When a CARD_REMOVAL event is received, we immediately set a flag to block
2193 * future accesses to this device. All the functions that actually access the
2194 * device should check this flag to make sure the card is still present.
2196 static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2198 dev_link_t *link = args->client_data;
2199 struct net_device *dev = link->priv;
2202 case CS_EVENT_CARD_REMOVAL:
2203 link->state &= ~DEV_PRESENT;
2204 if (link->state & DEV_CONFIG) {
2205 while (link->open > 0)
2207 netif_device_detach(dev);
2208 wl3501_release(link);
2211 case CS_EVENT_CARD_INSERTION:
2212 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2213 wl3501_config(link);
2215 case CS_EVENT_PM_SUSPEND:
2216 link->state |= DEV_SUSPEND;
2217 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
2218 /* Fall through... */
2219 case CS_EVENT_RESET_PHYSICAL:
2220 if (link->state & DEV_CONFIG) {
2222 netif_device_detach(dev);
2223 pcmcia_release_configuration(link->handle);
2226 case CS_EVENT_PM_RESUME:
2227 link->state &= ~DEV_SUSPEND;
2228 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
2229 /* Fall through... */
2230 case CS_EVENT_CARD_RESET:
2231 if (link->state & DEV_CONFIG) {
2232 pcmcia_request_configuration(link->handle, &link->conf);
2235 netif_device_attach(dev);
2243 static struct pcmcia_driver wl3501_driver = {
2244 .owner = THIS_MODULE,
2246 .name = "wl3501_cs",
2248 .attach = wl3501_attach,
2249 .detach = wl3501_detach,
2252 static int __init wl3501_init_module(void)
2254 return pcmcia_register_driver(&wl3501_driver);
2257 static void __exit wl3501_exit_module(void)
2259 dprintk(0, ": unloading");
2260 pcmcia_unregister_driver(&wl3501_driver);
2261 BUG_ON(wl3501_dev_list != NULL);
2264 module_init(wl3501_init_module);
2265 module_exit(wl3501_exit_module);
2267 MODULE_AUTHOR("Fox Chen <mhchen@golf.ccl.itri.org.tw>, "
2268 "Arnaldo Carvalho de Melo <acme@conectiva.com.br>,"
2269 "Gustavo Niemeyer <niemeyer@conectiva.com>");
2270 MODULE_DESCRIPTION("Planet wl3501 wireless driver");
2271 MODULE_LICENSE("GPL");