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/cs_types.h>
53 #include <pcmcia/cs.h>
54 #include <pcmcia/cistpl.h>
55 #include <pcmcia/cisreg.h>
56 #include <pcmcia/ds.h>
59 #include <asm/uaccess.h>
60 #include <asm/system.h>
65 #define slow_down_io()
68 /* For rough constant delay */
69 #define WL3501_NOPLOOP(n) { int x = 0; while (x++ < n) slow_down_io(); }
72 * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If you do not
73 * define PCMCIA_DEBUG at all, all the debug code will be left out. If you
74 * compile with PCMCIA_DEBUG=0, the debug code will be present but disabled --
75 * but it can then be enabled for specific modules at load time with a
76 * 'pc_debug=#' option to insmod.
78 #define PCMCIA_DEBUG 0
80 static int pc_debug = PCMCIA_DEBUG;
81 module_param(pc_debug, int, 0);
82 #define dprintk(n, format, args...) \
83 { if (pc_debug > (n)) \
84 printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##args); }
86 #define dprintk(n, format, args...)
89 #define wl3501_outb(a, b) { outb(a, b); slow_down_io(); }
90 #define wl3501_outb_p(a, b) { outb_p(a, b); slow_down_io(); }
91 #define wl3501_outsb(a, b, c) { outsb(a, b, c); slow_down_io(); }
93 #define WL3501_RELEASE_TIMEOUT (25 * HZ)
94 #define WL3501_MAX_ADHOC_TRIES 16
96 #define WL3501_RESUME 0
97 #define WL3501_SUSPEND 1
100 * The event() function is this driver's Card Services event handler. It will
101 * be called by Card Services when an appropriate card status event is
102 * received. The config() and release() entry points are used to configure or
103 * release a socket, in response to card insertion and ejection events. They
104 * are invoked from the wl24 event handler.
106 static void wl3501_config(dev_link_t *link);
107 static void wl3501_release(dev_link_t *link);
108 static int wl3501_event(event_t event, int pri, event_callback_args_t *args);
111 * The dev_info variable is the "key" that is used to match up this
112 * device driver with appropriate cards, through the card configuration
115 static dev_info_t wl3501_dev_info = "wl3501_cs";
117 static int wl3501_chan2freq[] = {
118 [0] = 2412, [1] = 2417, [2] = 2422, [3] = 2427, [4] = 2432,
119 [5] = 2437, [6] = 2442, [7] = 2447, [8] = 2452, [9] = 2457,
120 [10] = 2462, [11] = 2467, [12] = 2472, [13] = 2477,
123 static const struct {
126 } iw_channel_table[] = {
128 .reg_domain = IW_REG_DOMAIN_FCC,
134 .reg_domain = IW_REG_DOMAIN_DOC,
140 .reg_domain = IW_REG_DOMAIN_ETSI,
146 .reg_domain = IW_REG_DOMAIN_SPAIN,
152 .reg_domain = IW_REG_DOMAIN_FRANCE,
158 .reg_domain = IW_REG_DOMAIN_MKK,
164 .reg_domain = IW_REG_DOMAIN_MKK1,
170 .reg_domain = IW_REG_DOMAIN_ISRAEL,
178 * iw_valid_channel - validate channel in regulatory domain
179 * @reg_comain - regulatory domain
180 * @channel - channel to validate
182 * Returns 0 if invalid in the specified regulatory domain, non-zero if valid.
184 static int iw_valid_channel(int reg_domain, int channel)
188 for (i = 0; i < ARRAY_SIZE(iw_channel_table); i++)
189 if (reg_domain == iw_channel_table[i].reg_domain) {
190 rc = channel >= iw_channel_table[i].min &&
191 channel <= iw_channel_table[i].max;
198 * iw_default_channel - get default channel for a regulatory domain
199 * @reg_comain - regulatory domain
201 * Returns the default channel for a regulatory domain
203 static int iw_default_channel(int reg_domain)
207 for (i = 0; i < ARRAY_SIZE(iw_channel_table); i++)
208 if (reg_domain == iw_channel_table[i].reg_domain) {
209 rc = iw_channel_table[i].deflt;
215 static void iw_set_mgmt_info_element(enum iw_mgmt_info_element_ids id,
216 struct iw_mgmt_info_element *el,
217 void *value, int len)
221 memcpy(el->data, value, len);
224 static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to,
225 struct iw_mgmt_info_element *from)
227 iw_set_mgmt_info_element(from->id, to, from->data, from->len);
231 * A linked list of "instances" of the wl24 device. Each actual PCMCIA card
232 * corresponds to one device instance, and is described by one dev_link_t
233 * structure (defined in ds.h).
235 * You may not want to use a linked list for this -- for example, the memory
236 * card driver uses an array of dev_link_t pointers, where minor device numbers
237 * are used to derive the corresponding array index.
239 static dev_link_t *wl3501_dev_list;
241 static inline void wl3501_switch_page(struct wl3501_card *this, u8 page)
243 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS);
247 * Get Ethernet MAC addresss.
249 * WARNING: We switch to FPAGE0 and switc back again.
250 * Making sure there is no other WL function beening called by ISR.
252 static int wl3501_get_flash_mac_addr(struct wl3501_card *this)
254 int base_addr = this->base_addr;
257 wl3501_outb(WL3501_BSS_FPAGE3, base_addr + WL3501_NIC_BSS); /* BSS */
258 wl3501_outb(0x00, base_addr + WL3501_NIC_LMAL); /* LMAL */
259 wl3501_outb(0x40, base_addr + WL3501_NIC_LMAH); /* LMAH */
261 /* wait for reading EEPROM */
263 this->mac_addr[0] = inb(base_addr + WL3501_NIC_IODPA);
265 this->mac_addr[1] = inb(base_addr + WL3501_NIC_IODPA);
267 this->mac_addr[2] = inb(base_addr + WL3501_NIC_IODPA);
269 this->mac_addr[3] = inb(base_addr + WL3501_NIC_IODPA);
271 this->mac_addr[4] = inb(base_addr + WL3501_NIC_IODPA);
273 this->mac_addr[5] = inb(base_addr + WL3501_NIC_IODPA);
275 this->reg_domain = inb(base_addr + WL3501_NIC_IODPA);
277 wl3501_outb(WL3501_BSS_FPAGE0, base_addr + WL3501_NIC_BSS);
278 wl3501_outb(0x04, base_addr + WL3501_NIC_LMAL);
279 wl3501_outb(0x40, base_addr + WL3501_NIC_LMAH);
281 this->version[0] = inb(base_addr + WL3501_NIC_IODPA);
283 this->version[1] = inb(base_addr + WL3501_NIC_IODPA);
284 /* switch to SRAM Page 0 (for safety) */
285 wl3501_switch_page(this, WL3501_BSS_SPAGE0);
287 /* The MAC addr should be 00:60:... */
288 return this->mac_addr[0] == 0x00 && this->mac_addr[1] == 0x60;
292 * wl3501_set_to_wla - Move 'size' bytes from PC to card
293 * @dest: Card addressing space
294 * @src: PC addressing space
295 * @size: Bytes to move
297 * Move 'size' bytes from PC to card. (Shouldn't be interrupted)
299 void wl3501_set_to_wla(struct wl3501_card *this, u16 dest, void *src, int size)
301 /* switch to SRAM Page 0 */
302 wl3501_switch_page(this, (dest & 0x8000) ? WL3501_BSS_SPAGE1 :
304 /* set LMAL and LMAH */
305 wl3501_outb(dest & 0xff, this->base_addr + WL3501_NIC_LMAL);
306 wl3501_outb(((dest >> 8) & 0x7f), this->base_addr + WL3501_NIC_LMAH);
308 /* rep out to Port A */
309 wl3501_outsb(this->base_addr + WL3501_NIC_IODPA, src, size);
313 * wl3501_get_from_wla - Move 'size' bytes from card to PC
314 * @src: Card addressing space
315 * @dest: PC addressing space
316 * @size: Bytes to move
318 * Move 'size' bytes from card to PC. (Shouldn't be interrupted)
320 void wl3501_get_from_wla(struct wl3501_card *this, u16 src, void *dest,
323 /* switch to SRAM Page 0 */
324 wl3501_switch_page(this, (src & 0x8000) ? WL3501_BSS_SPAGE1 :
326 /* set LMAL and LMAH */
327 wl3501_outb(src & 0xff, this->base_addr + WL3501_NIC_LMAL);
328 wl3501_outb((src >> 8) & 0x7f, this->base_addr + WL3501_NIC_LMAH);
330 /* rep get from Port A */
331 insb(this->base_addr + WL3501_NIC_IODPA, dest, size);
335 * Get/Allocate a free Tx Data Buffer
337 * *--------------*-----------------*----------------------------------*
338 * | PLCP | MAC Header | DST SRC Data ... |
339 * | (24 bytes) | (30 bytes) | (6) (6) (Ethernet Row Data) |
340 * *--------------*-----------------*----------------------------------*
341 * \ \- IEEE 802.11 -/ \-------------- len --------------/
342 * \-struct wl3501_80211_tx_hdr--/ \-------- Ethernet Frame -------/
344 * Return = Postion in Card
346 static u16 wl3501_get_tx_buffer(struct wl3501_card *this, u16 len)
348 u16 next, blk_cnt = 0, zero = 0;
349 u16 full_len = sizeof(struct wl3501_80211_tx_hdr) + len;
352 if (full_len > this->tx_buffer_cnt * 254)
354 ret = this->tx_buffer_head;
360 wl3501_get_from_wla(this, this->tx_buffer_head, &next,
363 wl3501_set_to_wla(this, this->tx_buffer_head, &zero,
365 this->tx_buffer_head = next;
367 /* if buffer is not enough */
368 if (!next && full_len) {
369 this->tx_buffer_head = ret;
374 this->tx_buffer_cnt -= blk_cnt;
380 * Free an allocated Tx Buffer. ptr must be correct position.
382 static void wl3501_free_tx_buffer(struct wl3501_card *this, u16 ptr)
384 /* check if all space is not free */
385 if (!this->tx_buffer_head)
386 this->tx_buffer_head = ptr;
388 wl3501_set_to_wla(this, this->tx_buffer_tail,
393 this->tx_buffer_cnt++;
394 wl3501_get_from_wla(this, ptr, &next, sizeof(next));
395 this->tx_buffer_tail = ptr;
400 static int wl3501_esbq_req_test(struct wl3501_card *this)
404 wl3501_get_from_wla(this, this->esbq_req_head + 3, &tmp, sizeof(tmp));
408 static void wl3501_esbq_req(struct wl3501_card *this, u16 *ptr)
412 wl3501_set_to_wla(this, this->esbq_req_head, ptr, 2);
413 wl3501_set_to_wla(this, this->esbq_req_head + 2, &tmp, sizeof(tmp));
414 this->esbq_req_head += 4;
415 if (this->esbq_req_head >= this->esbq_req_end)
416 this->esbq_req_head = this->esbq_req_start;
419 static int wl3501_esbq_exec(struct wl3501_card *this, void *sig, int sig_size)
423 if (wl3501_esbq_req_test(this)) {
424 u16 ptr = wl3501_get_tx_buffer(this, sig_size);
426 wl3501_set_to_wla(this, ptr, sig, sig_size);
427 wl3501_esbq_req(this, &ptr);
434 static int wl3501_get_mib_value(struct wl3501_card *this, u8 index,
437 struct wl3501_get_req sig = {
438 .sig_id = WL3501_SIG_GET_REQ,
444 spin_lock_irqsave(&this->lock, flags);
445 if (wl3501_esbq_req_test(this)) {
446 u16 ptr = wl3501_get_tx_buffer(this, sizeof(sig));
448 wl3501_set_to_wla(this, ptr, &sig, sizeof(sig));
449 wl3501_esbq_req(this, &ptr);
450 this->sig_get_confirm.mib_status = 255;
451 spin_unlock_irqrestore(&this->lock, flags);
452 rc = wait_event_interruptible(this->wait,
453 this->sig_get_confirm.mib_status != 255);
455 memcpy(bf, this->sig_get_confirm.mib_value,
460 spin_unlock_irqrestore(&this->lock, flags);
465 static int wl3501_pwr_mgmt(struct wl3501_card *this, int suspend)
467 struct wl3501_pwr_mgmt_req sig = {
468 .sig_id = WL3501_SIG_PWR_MGMT_REQ,
476 spin_lock_irqsave(&this->lock, flags);
477 if (wl3501_esbq_req_test(this)) {
478 u16 ptr = wl3501_get_tx_buffer(this, sizeof(sig));
480 wl3501_set_to_wla(this, ptr, &sig, sizeof(sig));
481 wl3501_esbq_req(this, &ptr);
482 this->sig_pwr_mgmt_confirm.status = 255;
483 spin_unlock_irqrestore(&this->lock, flags);
484 rc = wait_event_interruptible(this->wait,
485 this->sig_pwr_mgmt_confirm.status != 255);
486 printk(KERN_INFO "%s: %s status=%d\n", __FUNCTION__,
487 suspend ? "suspend" : "resume",
488 this->sig_pwr_mgmt_confirm.status);
492 spin_unlock_irqrestore(&this->lock, flags);
498 * wl3501_send_pkt - Send a packet.
503 * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr,
504 * data[6] - data[11] is Src MAC Addr)
507 static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len)
509 u16 bf, sig_bf, next, tmplen, pktlen;
510 struct wl3501_md_req sig = {
511 .sig_id = WL3501_SIG_MD_REQ,
513 u8 *pdata = (char *)data;
516 if (wl3501_esbq_req_test(this)) {
517 sig_bf = wl3501_get_tx_buffer(this, sizeof(sig));
519 if (!sig_bf) /* No free buffer available */
521 bf = wl3501_get_tx_buffer(this, len + 26 + 24);
523 /* No free buffer available */
524 wl3501_free_tx_buffer(this, sig_bf);
528 memcpy(&sig.daddr[0], pdata, 12);
532 if (((*pdata) * 256 + (*(pdata + 1))) > 1500) {
533 u8 addr4[ETH_ALEN] = {
534 [0] = 0xAA, [1] = 0xAA, [2] = 0x03, [4] = 0x00,
537 wl3501_set_to_wla(this, bf + 2 +
538 offsetof(struct wl3501_tx_hdr, addr4),
539 addr4, sizeof(addr4));
540 sig.size = pktlen + 24 + 4 + 6;
541 if (pktlen > (254 - sizeof(struct wl3501_tx_hdr))) {
542 tmplen = 254 - sizeof(struct wl3501_tx_hdr);
548 wl3501_set_to_wla(this,
549 bf + 2 + sizeof(struct wl3501_tx_hdr),
552 wl3501_get_from_wla(this, bf, &next, sizeof(next));
555 sig.size = pktlen + 24 + 4 - 2;
558 if (pktlen > (254 - sizeof(struct wl3501_tx_hdr) + 6)) {
559 tmplen = 254 - sizeof(struct wl3501_tx_hdr) + 6;
565 wl3501_set_to_wla(this, bf + 2 +
566 offsetof(struct wl3501_tx_hdr, addr4),
569 wl3501_get_from_wla(this, bf, &next, sizeof(next));
580 wl3501_set_to_wla(this, bf + 2, pdata, tmplen);
582 wl3501_get_from_wla(this, bf, &next, sizeof(next));
585 wl3501_set_to_wla(this, sig_bf, &sig, sizeof(sig));
586 wl3501_esbq_req(this, &sig_bf);
592 static int wl3501_mgmt_resync(struct wl3501_card *this)
594 struct wl3501_resync_req sig = {
595 .sig_id = WL3501_SIG_RESYNC_REQ,
598 return wl3501_esbq_exec(this, &sig, sizeof(sig));
601 static inline int wl3501_fw_bss_type(struct wl3501_card *this)
603 return this->net_type == IW_MODE_INFRA ? WL3501_NET_TYPE_INFRA :
604 WL3501_NET_TYPE_ADHOC;
607 static inline int wl3501_fw_cap_info(struct wl3501_card *this)
609 return this->net_type == IW_MODE_INFRA ? WL3501_MGMT_CAPABILITY_ESS :
610 WL3501_MGMT_CAPABILITY_IBSS;
613 static int wl3501_mgmt_scan(struct wl3501_card *this, u16 chan_time)
615 struct wl3501_scan_req sig = {
616 .sig_id = WL3501_SIG_SCAN_REQ,
617 .scan_type = WL3501_SCAN_TYPE_ACTIVE,
619 .min_chan_time = chan_time,
620 .max_chan_time = chan_time,
621 .bss_type = wl3501_fw_bss_type(this),
624 this->bss_cnt = this->join_sta_bss = 0;
625 return wl3501_esbq_exec(this, &sig, sizeof(sig));
628 static int wl3501_mgmt_join(struct wl3501_card *this, u16 stas)
630 struct wl3501_join_req sig = {
631 .sig_id = WL3501_SIG_JOIN_REQ,
635 .id = IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET,
642 memcpy(&sig.beacon_period, &this->bss_set[stas].beacon_period, 72);
643 return wl3501_esbq_exec(this, &sig, sizeof(sig));
646 static int wl3501_mgmt_start(struct wl3501_card *this)
648 struct wl3501_start_req sig = {
649 .sig_id = WL3501_SIG_START_REQ,
650 .beacon_period = 400,
654 .id = IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET,
661 .id = IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES,
664 .data_rate_labels = {
665 [0] = IW_MGMT_RATE_LABEL_MANDATORY |
666 IW_MGMT_RATE_LABEL_1MBIT,
667 [1] = IW_MGMT_RATE_LABEL_MANDATORY |
668 IW_MGMT_RATE_LABEL_2MBIT,
671 .operational_rset = {
673 .id = IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES,
676 .data_rate_labels = {
677 [0] = IW_MGMT_RATE_LABEL_MANDATORY |
678 IW_MGMT_RATE_LABEL_1MBIT,
679 [1] = IW_MGMT_RATE_LABEL_MANDATORY |
680 IW_MGMT_RATE_LABEL_2MBIT,
685 .id = IW_MGMT_INFO_ELEMENT_IBSS_PARAMETER_SET,
690 .bss_type = wl3501_fw_bss_type(this),
691 .cap_info = wl3501_fw_cap_info(this),
694 iw_copy_mgmt_info_element(&sig.ssid.el, &this->essid.el);
695 iw_copy_mgmt_info_element(&this->keep_essid.el, &this->essid.el);
696 return wl3501_esbq_exec(this, &sig, sizeof(sig));
699 static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
703 struct wl3501_scan_confirm sig;
706 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
707 if (sig.status == WL3501_STATUS_SUCCESS) {
708 dprintk(3, "success");
709 if ((this->net_type == IW_MODE_INFRA &&
710 (sig.cap_info & WL3501_MGMT_CAPABILITY_ESS)) ||
711 (this->net_type == IW_MODE_ADHOC &&
712 (sig.cap_info & WL3501_MGMT_CAPABILITY_IBSS)) ||
713 this->net_type == IW_MODE_AUTO) {
714 if (!this->essid.el.len)
716 else if (this->essid.el.len == 3 &&
717 !memcmp(this->essid.essid, "ANY", 3))
719 else if (this->essid.el.len != sig.ssid.el.len)
721 else if (memcmp(this->essid.essid, sig.ssid.essid,
727 for (i = 0; i < this->bss_cnt; i++) {
728 if (!memcmp(this->bss_set[i].bssid,
729 sig.bssid, ETH_ALEN)) {
735 if (matchflag && (i < 20)) {
736 memcpy(&this->bss_set[i].beacon_period,
737 &sig.beacon_period, 73);
739 this->rssi = sig.rssi;
742 } else if (sig.status == WL3501_STATUS_TIMEOUT) {
743 dprintk(3, "timeout");
744 this->join_sta_bss = 0;
745 for (i = this->join_sta_bss; i < this->bss_cnt; i++)
746 if (!wl3501_mgmt_join(this, i))
748 this->join_sta_bss = i;
749 if (this->join_sta_bss == this->bss_cnt) {
750 if (this->net_type == IW_MODE_INFRA)
751 wl3501_mgmt_scan(this, 100);
754 if (this->adhoc_times > WL3501_MAX_ADHOC_TRIES)
755 wl3501_mgmt_start(this);
757 wl3501_mgmt_scan(this, 100);
764 * wl3501_block_interrupt - Mask interrupt from SUTRO
767 * Mask interrupt from SUTRO. (i.e. SUTRO cannot interrupt the HOST)
768 * Return: 1 if interrupt is originally enabled
770 static int wl3501_block_interrupt(struct wl3501_card *this)
772 u8 old = inb(this->base_addr + WL3501_NIC_GCR);
773 u8 new = old & (~(WL3501_GCR_ECINT | WL3501_GCR_INT2EC |
774 WL3501_GCR_ENECINT));
776 wl3501_outb(new, this->base_addr + WL3501_NIC_GCR);
777 return old & WL3501_GCR_ENECINT;
781 * wl3501_unblock_interrupt - Enable interrupt from SUTRO
784 * Enable interrupt from SUTRO. (i.e. SUTRO can interrupt the HOST)
785 * Return: 1 if interrupt is originally enabled
787 static int wl3501_unblock_interrupt(struct wl3501_card *this)
789 u8 old = inb(this->base_addr + WL3501_NIC_GCR);
790 u8 new = (old & ~(WL3501_GCR_ECINT | WL3501_GCR_INT2EC)) |
793 wl3501_outb(new, this->base_addr + WL3501_NIC_GCR);
794 return old & WL3501_GCR_ENECINT;
798 * wl3501_receive - Receive data from Receive Queue.
800 * Receive data from Receive Queue.
803 * @bf: address of host
804 * @size: size of buffer.
806 static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size)
808 u16 next_addr, next_addr1;
812 wl3501_get_from_wla(this, this->start_seg + 2,
813 &next_addr, sizeof(next_addr));
814 if (size > WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr)) {
815 wl3501_get_from_wla(this,
817 sizeof(struct wl3501_rx_hdr), data,
819 sizeof(struct wl3501_rx_hdr));
820 size -= WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr);
821 data += WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr);
823 wl3501_get_from_wla(this,
825 sizeof(struct wl3501_rx_hdr),
830 if (size > WL3501_BLKSZ - 5) {
831 wl3501_get_from_wla(this, next_addr + 5, data,
833 size -= WL3501_BLKSZ - 5;
834 data += WL3501_BLKSZ - 5;
835 wl3501_get_from_wla(this, next_addr + 2, &next_addr1,
837 next_addr = next_addr1;
839 wl3501_get_from_wla(this, next_addr + 5, data, size);
846 static void wl3501_esbq_req_free(struct wl3501_card *this)
851 if (this->esbq_req_head == this->esbq_req_tail)
853 wl3501_get_from_wla(this, this->esbq_req_tail + 3, &tmp, sizeof(tmp));
856 wl3501_get_from_wla(this, this->esbq_req_tail, &addr, sizeof(addr));
857 wl3501_free_tx_buffer(this, addr);
858 this->esbq_req_tail += 4;
859 if (this->esbq_req_tail >= this->esbq_req_end)
860 this->esbq_req_tail = this->esbq_req_start;
865 static int wl3501_esbq_confirm(struct wl3501_card *this)
869 wl3501_get_from_wla(this, this->esbq_confirm + 3, &tmp, sizeof(tmp));
873 static void wl3501_online(struct net_device *dev)
875 struct wl3501_card *this = dev->priv;
877 printk(KERN_INFO "%s: Wireless LAN online. BSSID: "
878 "%02X %02X %02X %02X %02X %02X\n", dev->name,
879 this->bssid[0], this->bssid[1], this->bssid[2],
880 this->bssid[3], this->bssid[4], this->bssid[5]);
881 netif_wake_queue(dev);
884 static void wl3501_esbq_confirm_done(struct wl3501_card *this)
888 wl3501_set_to_wla(this, this->esbq_confirm + 3, &tmp, sizeof(tmp));
889 this->esbq_confirm += 4;
890 if (this->esbq_confirm >= this->esbq_confirm_end)
891 this->esbq_confirm = this->esbq_confirm_start;
894 static int wl3501_mgmt_auth(struct wl3501_card *this)
896 struct wl3501_auth_req sig = {
897 .sig_id = WL3501_SIG_AUTH_REQ,
898 .type = WL3501_SYS_TYPE_OPEN,
903 memcpy(sig.mac_addr, this->bssid, ETH_ALEN);
904 return wl3501_esbq_exec(this, &sig, sizeof(sig));
907 static int wl3501_mgmt_association(struct wl3501_card *this)
909 struct wl3501_assoc_req sig = {
910 .sig_id = WL3501_SIG_ASSOC_REQ,
912 .listen_interval = 5,
913 .cap_info = this->cap_info,
917 memcpy(sig.mac_addr, this->bssid, ETH_ALEN);
918 return wl3501_esbq_exec(this, &sig, sizeof(sig));
921 static void wl3501_mgmt_join_confirm(struct net_device *dev, u16 addr)
923 struct wl3501_card *this = dev->priv;
924 struct wl3501_join_confirm sig;
927 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
928 if (sig.status == WL3501_STATUS_SUCCESS) {
929 if (this->net_type == IW_MODE_INFRA) {
930 if (this->join_sta_bss < this->bss_cnt) {
931 const int i = this->join_sta_bss;
933 this->bss_set[i].bssid, ETH_ALEN);
934 this->chan = this->bss_set[i].ds_pset.chan;
935 iw_copy_mgmt_info_element(&this->keep_essid.el,
936 &this->bss_set[i].ssid.el);
937 wl3501_mgmt_auth(this);
940 const int i = this->join_sta_bss;
942 memcpy(&this->bssid, &this->bss_set[i].bssid, ETH_ALEN);
943 this->chan = this->bss_set[i].ds_pset.chan;
944 iw_copy_mgmt_info_element(&this->keep_essid.el,
945 &this->bss_set[i].ssid.el);
950 this->join_sta_bss++;
951 for (i = this->join_sta_bss; i < this->bss_cnt; i++)
952 if (!wl3501_mgmt_join(this, i))
954 this->join_sta_bss = i;
955 if (this->join_sta_bss == this->bss_cnt) {
956 if (this->net_type == IW_MODE_INFRA)
957 wl3501_mgmt_scan(this, 100);
960 if (this->adhoc_times > WL3501_MAX_ADHOC_TRIES)
961 wl3501_mgmt_start(this);
963 wl3501_mgmt_scan(this, 100);
969 static inline void wl3501_alarm_interrupt(struct net_device *dev,
970 struct wl3501_card *this)
972 if (this->net_type == IW_MODE_INFRA) {
973 printk(KERN_INFO "Wireless LAN offline\n");
974 netif_stop_queue(dev);
975 wl3501_mgmt_resync(this);
979 static inline void wl3501_md_confirm_interrupt(struct net_device *dev,
980 struct wl3501_card *this,
983 struct wl3501_md_confirm sig;
986 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
987 wl3501_free_tx_buffer(this, sig.data);
988 if (netif_queue_stopped(dev))
989 netif_wake_queue(dev);
992 static inline void wl3501_md_ind_interrupt(struct net_device *dev,
993 struct wl3501_card *this, u16 addr)
995 struct wl3501_md_ind sig;
997 u8 rssi, addr4[ETH_ALEN];
1000 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1001 this->start_seg = sig.data;
1002 wl3501_get_from_wla(this,
1003 sig.data + offsetof(struct wl3501_rx_hdr, rssi),
1004 &rssi, sizeof(rssi));
1005 this->rssi = rssi <= 63 ? (rssi * 100) / 64 : 255;
1007 wl3501_get_from_wla(this,
1009 offsetof(struct wl3501_rx_hdr, addr4),
1010 &addr4, sizeof(addr4));
1011 if (!(addr4[0] == 0xAA && addr4[1] == 0xAA &&
1012 addr4[2] == 0x03 && addr4[4] == 0x00)) {
1013 printk(KERN_INFO "Insupported packet type!\n");
1016 pkt_len = sig.size + 12 - 24 - 4 - 6;
1018 skb = dev_alloc_skb(pkt_len + 5);
1021 printk(KERN_WARNING "%s: Can't alloc a sk_buff of size %d.\n",
1022 dev->name, pkt_len);
1023 this->stats.rx_dropped++;
1026 skb_reserve(skb, 2); /* IP headers on 16 bytes boundaries */
1027 eth_copy_and_sum(skb, (unsigned char *)&sig.daddr, 12, 0);
1028 wl3501_receive(this, skb->data, pkt_len);
1029 skb_put(skb, pkt_len);
1030 skb->protocol = eth_type_trans(skb, dev);
1031 dev->last_rx = jiffies;
1032 this->stats.rx_packets++;
1033 this->stats.rx_bytes += skb->len;
1038 static inline void wl3501_get_confirm_interrupt(struct wl3501_card *this,
1039 u16 addr, void *sig, int size)
1041 dprintk(3, "entry");
1042 wl3501_get_from_wla(this, addr, &this->sig_get_confirm,
1043 sizeof(this->sig_get_confirm));
1044 wake_up(&this->wait);
1047 static inline void wl3501_start_confirm_interrupt(struct net_device *dev,
1048 struct wl3501_card *this,
1051 struct wl3501_start_confirm sig;
1053 dprintk(3, "entry");
1054 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1055 if (sig.status == WL3501_STATUS_SUCCESS)
1056 netif_wake_queue(dev);
1059 static inline void wl3501_assoc_confirm_interrupt(struct net_device *dev,
1062 struct wl3501_card *this = dev->priv;
1063 struct wl3501_assoc_confirm sig;
1065 dprintk(3, "entry");
1066 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1068 if (sig.status == WL3501_STATUS_SUCCESS)
1072 static inline void wl3501_auth_confirm_interrupt(struct wl3501_card *this,
1075 struct wl3501_auth_confirm sig;
1077 dprintk(3, "entry");
1078 wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
1080 if (sig.status == WL3501_STATUS_SUCCESS)
1081 wl3501_mgmt_association(this);
1083 wl3501_mgmt_resync(this);
1086 static inline void wl3501_rx_interrupt(struct net_device *dev)
1091 struct wl3501_card *this = dev->priv;
1093 dprintk(3, "entry");
1096 if (!wl3501_esbq_confirm(this))
1098 wl3501_get_from_wla(this, this->esbq_confirm, &addr, sizeof(addr));
1099 wl3501_get_from_wla(this, addr + 2, &sig_id, sizeof(sig_id));
1102 case WL3501_SIG_DEAUTH_IND:
1103 case WL3501_SIG_DISASSOC_IND:
1104 case WL3501_SIG_ALARM:
1105 wl3501_alarm_interrupt(dev, this);
1107 case WL3501_SIG_MD_CONFIRM:
1108 wl3501_md_confirm_interrupt(dev, this, addr);
1110 case WL3501_SIG_MD_IND:
1111 wl3501_md_ind_interrupt(dev, this, addr);
1113 case WL3501_SIG_GET_CONFIRM:
1114 wl3501_get_confirm_interrupt(this, addr,
1115 &this->sig_get_confirm,
1116 sizeof(this->sig_get_confirm));
1118 case WL3501_SIG_PWR_MGMT_CONFIRM:
1119 wl3501_get_confirm_interrupt(this, addr,
1120 &this->sig_pwr_mgmt_confirm,
1121 sizeof(this->sig_pwr_mgmt_confirm));
1123 case WL3501_SIG_START_CONFIRM:
1124 wl3501_start_confirm_interrupt(dev, this, addr);
1126 case WL3501_SIG_SCAN_CONFIRM:
1127 wl3501_mgmt_scan_confirm(this, addr);
1129 case WL3501_SIG_JOIN_CONFIRM:
1130 wl3501_mgmt_join_confirm(dev, addr);
1132 case WL3501_SIG_ASSOC_CONFIRM:
1133 wl3501_assoc_confirm_interrupt(dev, addr);
1135 case WL3501_SIG_AUTH_CONFIRM:
1136 wl3501_auth_confirm_interrupt(this, addr);
1138 case WL3501_SIG_RESYNC_CONFIRM:
1139 wl3501_mgmt_resync(this); /* FIXME: should be resync_confirm */
1142 wl3501_esbq_confirm_done(this);
1144 /* free request if necessary */
1146 wl3501_esbq_req_free(this);
1151 static inline void wl3501_ack_interrupt(struct wl3501_card *this)
1153 wl3501_outb(WL3501_GCR_ECINT, this->base_addr + WL3501_NIC_GCR);
1157 * wl3501_interrupt - Hardware interrupt from card.
1158 * @irq - Interrupt number
1159 * @dev_id - net_device
1162 * We must acknowledge the interrupt as soon as possible, and block the
1163 * interrupt from the same card immediately to prevent re-entry.
1165 * Before accessing the Control_Status_Block, we must lock SUTRO first.
1166 * On the other hand, to prevent SUTRO from malfunctioning, we must
1167 * unlock the SUTRO as soon as possible.
1169 static irqreturn_t wl3501_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1171 struct net_device *dev = (struct net_device *)dev_id;
1172 struct wl3501_card *this;
1178 spin_lock(&this->lock);
1179 wl3501_ack_interrupt(this);
1180 wl3501_block_interrupt(this);
1181 wl3501_rx_interrupt(dev);
1182 wl3501_unblock_interrupt(this);
1183 spin_unlock(&this->lock);
1185 return IRQ_RETVAL(handled);
1188 printk(KERN_ERR "%s: irq %d for unknown device.\n", __FUNCTION__, irq);
1192 static int wl3501_reset_board(struct wl3501_card *this)
1198 wl3501_outb_p(WL3501_GCR_CORESET, this->base_addr + WL3501_NIC_GCR);
1199 wl3501_outb_p(0, this->base_addr + WL3501_NIC_GCR);
1200 wl3501_outb_p(WL3501_GCR_CORESET, this->base_addr + WL3501_NIC_GCR);
1202 /* Reset SRAM 0x480 to zero */
1203 wl3501_set_to_wla(this, 0x480, &tmp, sizeof(tmp));
1206 wl3501_outb_p(0, this->base_addr + WL3501_NIC_GCR);
1208 WL3501_NOPLOOP(1024 * 50);
1210 wl3501_unblock_interrupt(this); /* acme: was commented */
1212 /* Polling Self_Test_Status */
1213 for (i = 0; i < 10000; i++) {
1214 wl3501_get_from_wla(this, 0x480, &tmp, sizeof(tmp));
1217 /* firmware complete all test successfully */
1219 wl3501_set_to_wla(this, 0x480, &tmp, sizeof(tmp));
1224 printk(KERN_WARNING "%s: failed to reset the board!\n", __FUNCTION__);
1230 static int wl3501_init_firmware(struct wl3501_card *this)
1233 int rc = wl3501_reset_board(this);
1237 this->card_name[0] = '\0';
1238 wl3501_get_from_wla(this, 0x1a00,
1239 this->card_name, sizeof(this->card_name));
1240 this->card_name[sizeof(this->card_name) - 1] = '\0';
1241 this->firmware_date[0] = '\0';
1242 wl3501_get_from_wla(this, 0x1a40,
1243 this->firmware_date, sizeof(this->firmware_date));
1244 this->firmware_date[sizeof(this->firmware_date) - 1] = '\0';
1245 /* Switch to SRAM Page 0 */
1246 wl3501_switch_page(this, WL3501_BSS_SPAGE0);
1247 /* Read parameter from card */
1248 wl3501_get_from_wla(this, 0x482, &this->esbq_req_start, 2);
1249 wl3501_get_from_wla(this, 0x486, &this->esbq_req_end, 2);
1250 wl3501_get_from_wla(this, 0x488, &this->esbq_confirm_start, 2);
1251 wl3501_get_from_wla(this, 0x48c, &this->esbq_confirm_end, 2);
1252 wl3501_get_from_wla(this, 0x48e, &this->tx_buffer_head, 2);
1253 wl3501_get_from_wla(this, 0x492, &this->tx_buffer_size, 2);
1254 this->esbq_req_tail = this->esbq_req_head = this->esbq_req_start;
1255 this->esbq_req_end += this->esbq_req_start;
1256 this->esbq_confirm = this->esbq_confirm_start;
1257 this->esbq_confirm_end += this->esbq_confirm_start;
1258 /* Initial Tx Buffer */
1259 this->tx_buffer_cnt = 1;
1260 ptr = this->tx_buffer_head;
1261 next = ptr + WL3501_BLKSZ;
1262 while ((next - this->tx_buffer_head) < this->tx_buffer_size) {
1263 this->tx_buffer_cnt++;
1264 wl3501_set_to_wla(this, ptr, &next, sizeof(next));
1266 next = ptr + WL3501_BLKSZ;
1270 wl3501_set_to_wla(this, ptr, &next, sizeof(next));
1271 this->tx_buffer_tail = ptr;
1275 printk(KERN_WARNING "%s: failed!\n", __FUNCTION__);
1279 static int wl3501_close(struct net_device *dev)
1281 struct wl3501_card *this = dev->priv;
1283 unsigned long flags;
1286 spin_lock_irqsave(&this->lock, flags);
1287 /* Check if the device is in wl3501_dev_list */
1288 for (link = wl3501_dev_list; link; link = link->next)
1289 if (link->priv == dev)
1295 /* Stop wl3501_hard_start_xmit() from now on */
1296 netif_stop_queue(dev);
1297 wl3501_ack_interrupt(this);
1299 /* Mask interrupts from the SUTRO */
1300 wl3501_block_interrupt(this);
1303 printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
1305 spin_unlock_irqrestore(&this->lock, flags);
1310 * wl3501_reset - Reset the SUTRO.
1311 * @dev - network device
1313 * It is almost the same as wl3501_open(). In fact, we may just wl3501_close()
1314 * and wl3501_open() again, but I wouldn't like to free_irq() when the driver
1315 * is running. It seems to be dangerous.
1317 static int wl3501_reset(struct net_device *dev)
1319 struct wl3501_card *this = dev->priv;
1322 wl3501_block_interrupt(this);
1324 if (wl3501_init_firmware(this)) {
1325 printk(KERN_WARNING "%s: Can't initialize Firmware!\n",
1327 /* Free IRQ, and mark IRQ as unused */
1328 free_irq(dev->irq, dev);
1333 * Queue has to be started only when the Card is Started
1335 netif_stop_queue(dev);
1336 this->adhoc_times = 0;
1337 wl3501_ack_interrupt(this);
1338 wl3501_unblock_interrupt(this);
1339 wl3501_mgmt_scan(this, 100);
1340 dprintk(1, "%s: device reset", dev->name);
1346 static void wl3501_tx_timeout(struct net_device *dev)
1348 struct wl3501_card *this = dev->priv;
1349 struct net_device_stats *stats = &this->stats;
1350 unsigned long flags;
1354 spin_lock_irqsave(&this->lock, flags);
1355 rc = wl3501_reset(dev);
1356 spin_unlock_irqrestore(&this->lock, flags);
1358 printk(KERN_ERR "%s: Error %d resetting card on Tx timeout!\n",
1361 dev->trans_start = jiffies;
1362 netif_wake_queue(dev);
1368 * 1 - Could not transmit (dev_queue_xmit will queue it)
1369 * and try to sent it later
1371 static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1374 struct wl3501_card *this = dev->priv;
1375 unsigned long flags;
1377 spin_lock_irqsave(&this->lock, flags);
1378 enabled = wl3501_block_interrupt(this);
1379 dev->trans_start = jiffies;
1380 rc = wl3501_send_pkt(this, skb->data, skb->len);
1382 wl3501_unblock_interrupt(this);
1384 ++this->stats.tx_dropped;
1385 netif_stop_queue(dev);
1387 ++this->stats.tx_packets;
1388 this->stats.tx_bytes += skb->len;
1391 if (this->tx_buffer_cnt < 2)
1392 netif_stop_queue(dev);
1394 spin_unlock_irqrestore(&this->lock, flags);
1398 static int wl3501_open(struct net_device *dev)
1401 struct wl3501_card *this = dev->priv;
1402 unsigned long flags;
1405 spin_lock_irqsave(&this->lock, flags);
1406 /* Check if the device is in wl3501_dev_list */
1407 for (link = wl3501_dev_list; link; link = link->next)
1408 if (link->priv == dev)
1412 netif_device_attach(dev);
1415 /* Initial WL3501 firmware */
1416 dprintk(1, "%s: Initialize WL3501 firmware...", dev->name);
1417 if (wl3501_init_firmware(this))
1419 /* Initial device variables */
1420 this->adhoc_times = 0;
1421 /* Acknowledge Interrupt, for cleaning last state */
1422 wl3501_ack_interrupt(this);
1424 /* Enable interrupt from card after all */
1425 wl3501_unblock_interrupt(this);
1426 wl3501_mgmt_scan(this, 100);
1428 dprintk(1, "%s: WL3501 opened", dev->name);
1429 printk(KERN_INFO "%s: Card Name: %s\n"
1430 "%s: Firmware Date: %s\n",
1431 dev->name, this->card_name,
1432 dev->name, this->firmware_date);
1434 spin_unlock_irqrestore(&this->lock, flags);
1437 printk(KERN_WARNING "%s: Can't initialize firmware!\n", dev->name);
1441 struct net_device_stats *wl3501_get_stats(struct net_device *dev)
1443 struct wl3501_card *this = dev->priv;
1445 return &this->stats;
1448 struct iw_statistics *wl3501_get_wireless_stats(struct net_device *dev)
1450 struct wl3501_card *this = dev->priv;
1451 struct iw_statistics *wstats = &this->wstats;
1452 u32 value; /* size checked: it is u32 */
1454 memset(wstats, 0, sizeof(*wstats));
1455 wstats->status = netif_running(dev);
1456 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_ICV_ERROR_COUNT,
1457 &value, sizeof(value)))
1458 wstats->discard.code += value;
1459 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_UNDECRYPTABLE_COUNT,
1460 &value, sizeof(value)))
1461 wstats->discard.code += value;
1462 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_EXCLUDED_COUNT,
1463 &value, sizeof(value)))
1464 wstats->discard.code += value;
1465 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RETRY_COUNT,
1466 &value, sizeof(value)))
1467 wstats->discard.retries = value;
1468 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FAILED_COUNT,
1469 &value, sizeof(value)))
1470 wstats->discard.misc += value;
1471 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_FAILURE_COUNT,
1472 &value, sizeof(value)))
1473 wstats->discard.misc += value;
1474 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_ACK_FAILURE_COUNT,
1475 &value, sizeof(value)))
1476 wstats->discard.misc += value;
1477 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAME_DUPLICATE_COUNT,
1478 &value, sizeof(value)))
1479 wstats->discard.misc += value;
1483 static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1485 strlcpy(info->driver, wl3501_dev_info, sizeof(info->driver));
1488 static struct ethtool_ops ops = {
1489 .get_drvinfo = wl3501_get_drvinfo
1493 * wl3501_detach - deletes a driver "instance"
1496 * This deletes a driver "instance". The device is de-registered with Card
1497 * Services. If it has been released, all local data structures are freed.
1498 * Otherwise, the structures will be freed when the device is released.
1500 static void wl3501_detach(dev_link_t *link)
1504 /* Locate device structure */
1505 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
1511 /* If the device is currently configured and active, we won't actually
1512 * delete it yet. Instead, it is marked so that when the release()
1513 * function is called, that will trigger a proper detach(). */
1515 if (link->state & DEV_CONFIG) {
1517 printk(KERN_DEBUG "wl3501_cs: detach postponed, '%s' "
1518 "still locked\n", link->dev->dev_name);
1523 /* Break the link with Card Services */
1525 pcmcia_deregister_client(link->handle);
1527 /* Unlink device structure, free pieces */
1528 *linkp = link->next;
1531 free_netdev(link->priv);
1537 static int wl3501_get_name(struct net_device *dev, struct iw_request_info *info,
1538 union iwreq_data *wrqu, char *extra)
1540 strlcpy(wrqu->name, "IEEE 802.11-DS", sizeof(wrqu->name));
1544 static int wl3501_set_freq(struct net_device *dev, struct iw_request_info *info,
1545 union iwreq_data *wrqu, char *extra)
1547 struct wl3501_card *this = dev->priv;
1548 int channel = wrqu->freq.m;
1551 if (iw_valid_channel(this->reg_domain, channel)) {
1552 this->chan = channel;
1553 rc = wl3501_reset(dev);
1558 static int wl3501_get_freq(struct net_device *dev, struct iw_request_info *info,
1559 union iwreq_data *wrqu, char *extra)
1561 struct wl3501_card *this = dev->priv;
1563 wrqu->freq.m = wl3501_chan2freq[this->chan - 1] * 100000;
1568 static int wl3501_set_mode(struct net_device *dev, struct iw_request_info *info,
1569 union iwreq_data *wrqu, char *extra)
1573 if (wrqu->mode == IW_MODE_INFRA ||
1574 wrqu->mode == IW_MODE_ADHOC ||
1575 wrqu->mode == IW_MODE_AUTO) {
1576 struct wl3501_card *this = dev->priv;
1578 this->net_type = wrqu->mode;
1579 rc = wl3501_reset(dev);
1584 static int wl3501_get_mode(struct net_device *dev, struct iw_request_info *info,
1585 union iwreq_data *wrqu, char *extra)
1587 struct wl3501_card *this = dev->priv;
1589 wrqu->mode = this->net_type;
1593 static int wl3501_get_sens(struct net_device *dev, struct iw_request_info *info,
1594 union iwreq_data *wrqu, char *extra)
1596 struct wl3501_card *this = dev->priv;
1598 wrqu->sens.value = this->rssi;
1599 wrqu->sens.disabled = !wrqu->sens.value;
1600 wrqu->sens.fixed = 1;
1604 static int wl3501_get_range(struct net_device *dev,
1605 struct iw_request_info *info,
1606 union iwreq_data *wrqu, char *extra)
1608 struct iw_range *range = (struct iw_range *)extra;
1610 /* Set the length (very important for backward compatibility) */
1611 wrqu->data.length = sizeof(*range);
1613 /* Set all the info we don't care or don't know about to zero */
1614 memset(range, 0, sizeof(*range));
1616 /* Set the Wireless Extension versions */
1617 range->we_version_compiled = WIRELESS_EXT;
1618 range->we_version_source = 1;
1619 range->throughput = 2 * 1000 * 1000; /* ~2 Mb/s */
1620 /* FIXME: study the code to fill in more fields... */
1624 static int wl3501_set_wap(struct net_device *dev, struct iw_request_info *info,
1625 union iwreq_data *wrqu, char *extra)
1627 struct wl3501_card *this = dev->priv;
1628 static const u8 bcast[ETH_ALEN] = { 255, 255, 255, 255, 255, 255 };
1631 /* FIXME: we support other ARPHRDs...*/
1632 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
1634 if (!memcmp(bcast, wrqu->ap_addr.sa_data, ETH_ALEN)) {
1635 /* FIXME: rescan? */
1637 memcpy(this->bssid, wrqu->ap_addr.sa_data, ETH_ALEN);
1638 /* FIXME: rescan? deassoc & scan? */
1644 static int wl3501_get_wap(struct net_device *dev, struct iw_request_info *info,
1645 union iwreq_data *wrqu, char *extra)
1647 struct wl3501_card *this = dev->priv;
1649 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
1650 memcpy(wrqu->ap_addr.sa_data, this->bssid, ETH_ALEN);
1654 static int wl3501_set_scan(struct net_device *dev, struct iw_request_info *info,
1655 union iwreq_data *wrqu, char *extra)
1658 * FIXME: trigger scanning with a reset, yes, I'm lazy
1660 return wl3501_reset(dev);
1663 static int wl3501_get_scan(struct net_device *dev, struct iw_request_info *info,
1664 union iwreq_data *wrqu, char *extra)
1666 struct wl3501_card *this = dev->priv;
1668 char *current_ev = extra;
1669 struct iw_event iwe;
1671 for (i = 0; i < this->bss_cnt; ++i) {
1672 iwe.cmd = SIOCGIWAP;
1673 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1674 memcpy(iwe.u.ap_addr.sa_data, this->bss_set[i].bssid, ETH_ALEN);
1675 current_ev = iwe_stream_add_event(current_ev,
1676 extra + IW_SCAN_MAX_DATA,
1677 &iwe, IW_EV_ADDR_LEN);
1678 iwe.cmd = SIOCGIWESSID;
1679 iwe.u.data.flags = 1;
1680 iwe.u.data.length = this->bss_set[i].ssid.el.len;
1681 current_ev = iwe_stream_add_point(current_ev,
1682 extra + IW_SCAN_MAX_DATA,
1684 this->bss_set[i].ssid.essid);
1685 iwe.cmd = SIOCGIWMODE;
1686 iwe.u.mode = this->bss_set[i].bss_type;
1687 current_ev = iwe_stream_add_event(current_ev,
1688 extra + IW_SCAN_MAX_DATA,
1689 &iwe, IW_EV_UINT_LEN);
1690 iwe.cmd = SIOCGIWFREQ;
1691 iwe.u.freq.m = this->bss_set[i].ds_pset.chan;
1693 current_ev = iwe_stream_add_event(current_ev,
1694 extra + IW_SCAN_MAX_DATA,
1695 &iwe, IW_EV_FREQ_LEN);
1696 iwe.cmd = SIOCGIWENCODE;
1697 if (this->bss_set[i].cap_info & WL3501_MGMT_CAPABILITY_PRIVACY)
1698 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1700 iwe.u.data.flags = IW_ENCODE_DISABLED;
1701 iwe.u.data.length = 0;
1702 current_ev = iwe_stream_add_point(current_ev,
1703 extra + IW_SCAN_MAX_DATA,
1706 /* Length of data */
1707 wrqu->data.length = (current_ev - extra);
1708 wrqu->data.flags = 0; /* FIXME: set properly these flags */
1712 static int wl3501_set_essid(struct net_device *dev,
1713 struct iw_request_info *info,
1714 union iwreq_data *wrqu, char *extra)
1716 struct wl3501_card *this = dev->priv;
1718 if (wrqu->data.flags) {
1719 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID,
1721 extra, wrqu->data.length);
1722 } else { /* We accept any ESSID */
1723 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID,
1724 &this->essid.el, "ANY", 3);
1726 return wl3501_reset(dev);
1729 static int wl3501_get_essid(struct net_device *dev,
1730 struct iw_request_info *info,
1731 union iwreq_data *wrqu, char *extra)
1733 struct wl3501_card *this = dev->priv;
1734 unsigned long flags;
1736 spin_lock_irqsave(&this->lock, flags);
1737 wrqu->essid.flags = 1;
1738 wrqu->essid.length = this->essid.el.len;
1739 memcpy(extra, this->essid.essid, this->essid.el.len);
1740 spin_unlock_irqrestore(&this->lock, flags);
1744 static int wl3501_set_nick(struct net_device *dev, struct iw_request_info *info,
1745 union iwreq_data *wrqu, char *extra)
1747 struct wl3501_card *this = dev->priv;
1749 if (wrqu->data.length > sizeof(this->nick))
1751 strlcpy(this->nick, extra, wrqu->data.length);
1755 static int wl3501_get_nick(struct net_device *dev, struct iw_request_info *info,
1756 union iwreq_data *wrqu, char *extra)
1758 struct wl3501_card *this = dev->priv;
1760 strlcpy(extra, this->nick, 32);
1761 wrqu->data.length = strlen(extra);
1765 static int wl3501_get_rate(struct net_device *dev, struct iw_request_info *info,
1766 union iwreq_data *wrqu, char *extra)
1769 * FIXME: have to see from where to get this info, perhaps this card
1770 * works at 1 Mbit/s too... for now leave at 2 Mbit/s that is the most
1771 * common with the Planet Access Points. -acme
1773 wrqu->bitrate.value = 2000000;
1774 wrqu->bitrate.fixed = 1;
1778 static int wl3501_get_rts_threshold(struct net_device *dev,
1779 struct iw_request_info *info,
1780 union iwreq_data *wrqu, char *extra)
1782 u16 threshold; /* size checked: it is u16 */
1783 struct wl3501_card *this = dev->priv;
1784 int rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_THRESHOLD,
1785 &threshold, sizeof(threshold));
1787 wrqu->rts.value = threshold;
1788 wrqu->rts.disabled = threshold >= 2347;
1789 wrqu->rts.fixed = 1;
1794 static int wl3501_get_frag_threshold(struct net_device *dev,
1795 struct iw_request_info *info,
1796 union iwreq_data *wrqu, char *extra)
1798 u16 threshold; /* size checked: it is u16 */
1799 struct wl3501_card *this = dev->priv;
1800 int rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAG_THRESHOLD,
1801 &threshold, sizeof(threshold));
1803 wrqu->frag.value = threshold;
1804 wrqu->frag.disabled = threshold >= 2346;
1805 wrqu->frag.fixed = 1;
1810 static int wl3501_get_txpow(struct net_device *dev,
1811 struct iw_request_info *info,
1812 union iwreq_data *wrqu, char *extra)
1815 struct wl3501_card *this = dev->priv;
1816 int rc = wl3501_get_mib_value(this,
1817 WL3501_MIB_ATTR_CURRENT_TX_PWR_LEVEL,
1818 &txpow, sizeof(txpow));
1820 wrqu->txpower.value = txpow;
1821 wrqu->txpower.disabled = 0;
1823 * From the MIB values I think this can be configurable,
1824 * as it lists several tx power levels -acme
1826 wrqu->txpower.fixed = 0;
1827 wrqu->txpower.flags = IW_TXPOW_MWATT;
1832 static int wl3501_get_retry(struct net_device *dev,
1833 struct iw_request_info *info,
1834 union iwreq_data *wrqu, char *extra)
1836 u8 retry; /* size checked: it is u8 */
1837 struct wl3501_card *this = dev->priv;
1838 int rc = wl3501_get_mib_value(this,
1839 WL3501_MIB_ATTR_LONG_RETRY_LIMIT,
1840 &retry, sizeof(retry));
1843 if (wrqu->retry.flags & IW_RETRY_MAX) {
1844 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1847 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT,
1848 &retry, sizeof(retry));
1851 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
1853 wrqu->retry.value = retry;
1854 wrqu->retry.disabled = 0;
1859 static int wl3501_get_encode(struct net_device *dev,
1860 struct iw_request_info *info,
1861 union iwreq_data *wrqu, char *extra)
1863 u8 implemented, restricted, keys[100], len_keys, tocopy;
1864 struct wl3501_card *this = dev->priv;
1865 int rc = wl3501_get_mib_value(this,
1866 WL3501_MIB_ATTR_PRIV_OPT_IMPLEMENTED,
1867 &implemented, sizeof(implemented));
1871 wrqu->encoding.flags = IW_ENCODE_DISABLED;
1874 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_EXCLUDE_UNENCRYPTED,
1875 &restricted, sizeof(restricted));
1878 wrqu->encoding.flags = restricted ? IW_ENCODE_RESTRICTED :
1880 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS_LEN,
1881 &len_keys, sizeof(len_keys));
1884 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS,
1888 tocopy = min_t(u8, len_keys, wrqu->encoding.length);
1889 tocopy = min_t(u8, tocopy, 100);
1890 wrqu->encoding.length = tocopy;
1891 memset(extra, 0, tocopy);
1892 memcpy(extra, keys, tocopy);
1897 static int wl3501_get_power(struct net_device *dev,
1898 struct iw_request_info *info,
1899 union iwreq_data *wrqu, char *extra)
1902 struct wl3501_card *this = dev->priv;
1903 int rc = wl3501_get_mib_value(this,
1904 WL3501_MIB_ATTR_CURRENT_PWR_STATE,
1905 &pwr_state, sizeof(pwr_state));
1908 wrqu->power.disabled = !pwr_state;
1909 wrqu->power.flags = IW_POWER_ON;
1914 static const iw_handler wl3501_handler[] = {
1915 [SIOCGIWNAME - SIOCIWFIRST] = wl3501_get_name,
1916 [SIOCSIWFREQ - SIOCIWFIRST] = wl3501_set_freq,
1917 [SIOCGIWFREQ - SIOCIWFIRST] = wl3501_get_freq,
1918 [SIOCSIWMODE - SIOCIWFIRST] = wl3501_set_mode,
1919 [SIOCGIWMODE - SIOCIWFIRST] = wl3501_get_mode,
1920 [SIOCGIWSENS - SIOCIWFIRST] = wl3501_get_sens,
1921 [SIOCGIWRANGE - SIOCIWFIRST] = wl3501_get_range,
1922 [SIOCSIWSPY - SIOCIWFIRST] = iw_handler_set_spy,
1923 [SIOCGIWSPY - SIOCIWFIRST] = iw_handler_get_spy,
1924 [SIOCSIWTHRSPY - SIOCIWFIRST] = iw_handler_set_thrspy,
1925 [SIOCGIWTHRSPY - SIOCIWFIRST] = iw_handler_get_thrspy,
1926 [SIOCSIWAP - SIOCIWFIRST] = wl3501_set_wap,
1927 [SIOCGIWAP - SIOCIWFIRST] = wl3501_get_wap,
1928 [SIOCSIWSCAN - SIOCIWFIRST] = wl3501_set_scan,
1929 [SIOCGIWSCAN - SIOCIWFIRST] = wl3501_get_scan,
1930 [SIOCSIWESSID - SIOCIWFIRST] = wl3501_set_essid,
1931 [SIOCGIWESSID - SIOCIWFIRST] = wl3501_get_essid,
1932 [SIOCSIWNICKN - SIOCIWFIRST] = wl3501_set_nick,
1933 [SIOCGIWNICKN - SIOCIWFIRST] = wl3501_get_nick,
1934 [SIOCGIWRATE - SIOCIWFIRST] = wl3501_get_rate,
1935 [SIOCGIWRTS - SIOCIWFIRST] = wl3501_get_rts_threshold,
1936 [SIOCGIWFRAG - SIOCIWFIRST] = wl3501_get_frag_threshold,
1937 [SIOCGIWTXPOW - SIOCIWFIRST] = wl3501_get_txpow,
1938 [SIOCGIWRETRY - SIOCIWFIRST] = wl3501_get_retry,
1939 [SIOCGIWENCODE - SIOCIWFIRST] = wl3501_get_encode,
1940 [SIOCGIWPOWER - SIOCIWFIRST] = wl3501_get_power,
1943 static const struct iw_handler_def wl3501_handler_def = {
1944 .num_standard = sizeof(wl3501_handler) / sizeof(iw_handler),
1945 .standard = (iw_handler *)wl3501_handler,
1946 .spy_offset = offsetof(struct wl3501_card, spy_data),
1950 * wl3501_attach - creates an "instance" of the driver
1952 * Creates an "instance" of the driver, allocating local data structures for
1953 * one device. The device is registered with Card Services.
1955 * The dev_link structure is initialized, but we don't actually configure the
1956 * card at this point -- we wait until we receive a card insertion event.
1958 static dev_link_t *wl3501_attach(void)
1960 client_reg_t client_reg;
1962 struct net_device *dev;
1965 /* Initialize the dev_link_t structure */
1966 link = kmalloc(sizeof(*link), GFP_KERNEL);
1969 memset(link, 0, sizeof(struct dev_link_t));
1971 /* The io structure describes IO port mapping */
1972 link->io.NumPorts1 = 16;
1973 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
1974 link->io.IOAddrLines = 5;
1976 /* Interrupt setup */
1977 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
1978 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
1979 link->irq.Handler = wl3501_interrupt;
1981 /* General socket configuration */
1982 link->conf.Attributes = CONF_ENABLE_IRQ;
1983 link->conf.Vcc = 50;
1984 link->conf.IntType = INT_MEMORY_AND_IO;
1985 link->conf.ConfigIndex = 1;
1986 link->conf.Present = PRESENT_OPTION;
1988 dev = alloc_etherdev(sizeof(struct wl3501_card));
1991 dev->open = wl3501_open;
1992 dev->stop = wl3501_close;
1993 dev->hard_start_xmit = wl3501_hard_start_xmit;
1994 dev->tx_timeout = wl3501_tx_timeout;
1995 dev->watchdog_timeo = 5 * HZ;
1996 dev->get_stats = wl3501_get_stats;
1997 dev->get_wireless_stats = wl3501_get_wireless_stats;
1998 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def;
1999 SET_ETHTOOL_OPS(dev, &ops);
2000 netif_stop_queue(dev);
2001 link->priv = link->irq.Instance = dev;
2003 /* Register with Card Services */
2004 link->next = wl3501_dev_list;
2005 wl3501_dev_list = link;
2006 client_reg.dev_info = &wl3501_dev_info;
2007 client_reg.Version = 0x0210;
2008 client_reg.event_callback_args.client_data = link;
2009 ret = pcmcia_register_client(&link->handle, &client_reg);
2011 cs_error(link->handle, RegisterClient, ret);
2012 wl3501_detach(link);
2023 #define CS_CHECK(fn, ret) \
2024 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
2027 * wl3501_config - configure the PCMCIA socket and make eth device available
2030 * wl3501_config() is scheduled to run after a CARD_INSERTION event is
2031 * received, to configure the PCMCIA socket, and to make the ethernet device
2032 * available to the system.
2034 static void wl3501_config(dev_link_t *link)
2038 client_handle_t handle = link->handle;
2039 struct net_device *dev = link->priv;
2040 int i = 0, j, last_fn, last_ret;
2041 unsigned char bf[64];
2042 struct wl3501_card *this;
2044 /* This reads the card's CONFIG tuple to find its config registers. */
2045 tuple.Attributes = 0;
2046 tuple.DesiredTuple = CISTPL_CONFIG;
2047 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
2048 tuple.TupleData = bf;
2049 tuple.TupleDataMax = sizeof(bf);
2050 tuple.TupleOffset = 0;
2051 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
2052 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
2053 link->conf.ConfigBase = parse.config.base;
2054 link->conf.Present = parse.config.rmask[0];
2056 /* Configure card */
2057 link->state |= DEV_CONFIG;
2059 /* Try allocating IO ports. This tries a few fixed addresses. If you
2060 * want, you can also read the card's config table to pick addresses --
2061 * see the serial driver for an example. */
2063 for (j = 0x280; j < 0x400; j += 0x20) {
2064 /* The '^0x300' is so that we probe 0x300-0x3ff first, then
2065 * 0x200-0x2ff, and so on, because this seems safer */
2066 link->io.BasePort1 = j;
2067 link->io.BasePort2 = link->io.BasePort1 + 0x10;
2068 i = pcmcia_request_io(link->handle, &link->io);
2069 if (i == CS_SUCCESS)
2072 if (i != CS_SUCCESS) {
2073 cs_error(link->handle, RequestIO, i);
2077 /* Now allocate an interrupt line. Note that this does not actually
2078 * assign a handler to the interrupt. */
2080 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
2082 /* This actually configures the PCMCIA socket -- setting up the I/O
2083 * windows and the interrupt mapping. */
2085 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
2087 dev->irq = link->irq.AssignedIRQ;
2088 dev->base_addr = link->io.BasePort1;
2089 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
2090 if (register_netdev(dev)) {
2091 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
2095 SET_MODULE_OWNER(dev);
2099 * At this point, the dev_node_t structure(s) should be initialized and
2100 * arranged in a linked list at link->dev.
2102 link->dev = &this->node;
2103 link->state &= ~DEV_CONFIG_PENDING;
2105 this->base_addr = dev->base_addr;
2107 if (!wl3501_get_flash_mac_addr(this)) {
2108 printk(KERN_WARNING "%s: Cant read MAC addr in flash ROM?\n",
2112 strcpy(this->node.dev_name, dev->name);
2114 /* print probe information */
2115 printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, MAC addr in flash ROM:",
2116 dev->name, this->base_addr, (int)dev->irq);
2117 for (i = 0; i < 6; i++) {
2118 dev->dev_addr[i] = ((char *)&this->mac_addr)[i];
2119 printk("%c%02x", i ? ':' : ' ', dev->dev_addr[i]);
2123 * Initialize card parameters - added by jss
2125 this->net_type = IW_MODE_INFRA;
2127 this->join_sta_bss = 0;
2128 this->adhoc_times = 0;
2129 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID, &this->essid.el,
2131 this->card_name[0] = '\0';
2132 this->firmware_date[0] = '\0';
2134 this->chan = iw_default_channel(this->reg_domain);
2135 strlcpy(this->nick, "Planet WL3501", sizeof(this->nick));
2136 spin_lock_init(&this->lock);
2137 init_waitqueue_head(&this->wait);
2138 netif_start_queue(dev);
2141 cs_error(link->handle, last_fn, last_ret);
2143 wl3501_release(link);
2149 * wl3501_release - unregister the net, release PCMCIA configuration
2152 * After a card is removed, wl3501_release() will unregister the net device,
2153 * and release the PCMCIA configuration. If the device is still open, this
2154 * will be postponed until it is closed.
2156 static void wl3501_release(dev_link_t *link)
2158 struct net_device *dev = link->priv;
2160 /* Unlink the device chain */
2162 unregister_netdev(dev);
2166 /* Don't bother checking to see if these succeed or not */
2167 pcmcia_release_configuration(link->handle);
2168 pcmcia_release_io(link->handle, &link->io);
2169 pcmcia_release_irq(link->handle, &link->irq);
2170 link->state &= ~DEV_CONFIG;
2174 * wl3501_event - The card status event handler
2177 * @args - arguments for this event
2179 * The card status event handler. Mostly, this schedules other stuff to run
2180 * after an event is received. A CARD_REMOVAL event also sets some flags to
2181 * discourage the net drivers from trying to talk to the card any more.
2183 * When a CARD_REMOVAL event is received, we immediately set a flag to block
2184 * future accesses to this device. All the functions that actually access the
2185 * device should check this flag to make sure the card is still present.
2187 static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2189 dev_link_t *link = args->client_data;
2190 struct net_device *dev = link->priv;
2193 case CS_EVENT_CARD_REMOVAL:
2194 link->state &= ~DEV_PRESENT;
2195 if (link->state & DEV_CONFIG) {
2196 while (link->open > 0)
2198 netif_device_detach(dev);
2199 wl3501_release(link);
2202 case CS_EVENT_CARD_INSERTION:
2203 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2204 wl3501_config(link);
2206 case CS_EVENT_PM_SUSPEND:
2207 link->state |= DEV_SUSPEND;
2208 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
2209 /* Fall through... */
2210 case CS_EVENT_RESET_PHYSICAL:
2211 if (link->state & DEV_CONFIG) {
2213 netif_device_detach(dev);
2214 pcmcia_release_configuration(link->handle);
2217 case CS_EVENT_PM_RESUME:
2218 link->state &= ~DEV_SUSPEND;
2219 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
2220 /* Fall through... */
2221 case CS_EVENT_CARD_RESET:
2222 if (link->state & DEV_CONFIG) {
2223 pcmcia_request_configuration(link->handle, &link->conf);
2226 netif_device_attach(dev);
2234 static struct pcmcia_device_id wl3501_ids[] = {
2235 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2238 MODULE_DEVICE_TABLE(pcmcia, wl3501_ids);
2240 static struct pcmcia_driver wl3501_driver = {
2241 .owner = THIS_MODULE,
2243 .name = "wl3501_cs",
2245 .attach = wl3501_attach,
2246 .event = wl3501_event,
2247 .detach = wl3501_detach,
2248 .id_table = wl3501_ids,
2251 static int __init wl3501_init_module(void)
2253 return pcmcia_register_driver(&wl3501_driver);
2256 static void __exit wl3501_exit_module(void)
2258 dprintk(0, ": unloading");
2259 pcmcia_unregister_driver(&wl3501_driver);
2260 BUG_ON(wl3501_dev_list != NULL);
2263 module_init(wl3501_init_module);
2264 module_exit(wl3501_exit_module);
2266 MODULE_AUTHOR("Fox Chen <mhchen@golf.ccl.itri.org.tw>, "
2267 "Arnaldo Carvalho de Melo <acme@conectiva.com.br>,"
2268 "Gustavo Niemeyer <niemeyer@conectiva.com>");
2269 MODULE_DESCRIPTION("Planet wl3501 wireless driver");
2270 MODULE_LICENSE("GPL");