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)
30 #include <linux/delay.h>
31 #include <linux/types.h>
32 #include <linux/ethtool.h>
33 #include <linux/init.h>
34 #include <linux/interrupt.h>
36 #include <linux/kernel.h>
37 #include <linux/module.h>
38 #include <linux/fcntl.h>
39 #include <linux/if_arp.h>
40 #include <linux/ioport.h>
41 #include <linux/netdevice.h>
42 #include <linux/etherdevice.h>
43 #include <linux/skbuff.h>
44 #include <linux/slab.h>
45 #include <linux/string.h>
46 #include <linux/wireless.h>
47 #include <linux/ieee80211.h>
49 #include <net/iw_handler.h>
51 #include <pcmcia/cs_types.h>
52 #include <pcmcia/cs.h>
53 #include <pcmcia/cistpl.h>
54 #include <pcmcia/cisreg.h>
55 #include <pcmcia/ds.h>
58 #include <asm/uaccess.h>
59 #include <asm/system.h>
64 #define slow_down_io()
67 /* For rough constant delay */
68 #define WL3501_NOPLOOP(n) { int x = 0; while (x++ < n) slow_down_io(); }
71 * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If you do not
72 * define PCMCIA_DEBUG at all, all the debug code will be left out. If you
73 * compile with PCMCIA_DEBUG=0, the debug code will be present but disabled --
74 * but it can then be enabled for specific modules at load time with a
75 * 'pc_debug=#' option to insmod.
77 #define PCMCIA_DEBUG 0
79 static int pc_debug
= PCMCIA_DEBUG
;
80 module_param(pc_debug
, int, 0);
81 #define dprintk(n, format, args...) \
82 { if (pc_debug > (n)) \
83 printk(KERN_INFO "%s: " format "\n", __func__ , ##args); }
85 #define dprintk(n, format, args...)
88 #define wl3501_outb(a, b) { outb(a, b); slow_down_io(); }
89 #define wl3501_outb_p(a, b) { outb_p(a, b); slow_down_io(); }
90 #define wl3501_outsb(a, b, c) { outsb(a, b, c); slow_down_io(); }
92 #define WL3501_RELEASE_TIMEOUT (25 * HZ)
93 #define WL3501_MAX_ADHOC_TRIES 16
95 #define WL3501_RESUME 0
96 #define WL3501_SUSPEND 1
99 * The event() function is this driver's Card Services event handler. It will
100 * be called by Card Services when an appropriate card status event is
101 * received. The config() and release() entry points are used to configure or
102 * release a socket, in response to card insertion and ejection events. They
103 * are invoked from the wl24 event handler.
105 static int wl3501_config(struct pcmcia_device
*link
);
106 static void wl3501_release(struct pcmcia_device
*link
);
109 * The dev_info variable is the "key" that is used to match up this
110 * device driver with appropriate cards, through the card configuration
113 static dev_info_t wl3501_dev_info
= "wl3501_cs";
115 static const struct {
118 } iw_channel_table
[] = {
120 .reg_domain
= IW_REG_DOMAIN_FCC
,
126 .reg_domain
= IW_REG_DOMAIN_DOC
,
132 .reg_domain
= IW_REG_DOMAIN_ETSI
,
138 .reg_domain
= IW_REG_DOMAIN_SPAIN
,
144 .reg_domain
= IW_REG_DOMAIN_FRANCE
,
150 .reg_domain
= IW_REG_DOMAIN_MKK
,
156 .reg_domain
= IW_REG_DOMAIN_MKK1
,
162 .reg_domain
= IW_REG_DOMAIN_ISRAEL
,
170 * iw_valid_channel - validate channel in regulatory domain
171 * @reg_comain - regulatory domain
172 * @channel - channel to validate
174 * Returns 0 if invalid in the specified regulatory domain, non-zero if valid.
176 static int iw_valid_channel(int reg_domain
, int channel
)
180 for (i
= 0; i
< ARRAY_SIZE(iw_channel_table
); i
++)
181 if (reg_domain
== iw_channel_table
[i
].reg_domain
) {
182 rc
= channel
>= iw_channel_table
[i
].min
&&
183 channel
<= iw_channel_table
[i
].max
;
190 * iw_default_channel - get default channel for a regulatory domain
191 * @reg_comain - regulatory domain
193 * Returns the default channel for a regulatory domain
195 static int iw_default_channel(int reg_domain
)
199 for (i
= 0; i
< ARRAY_SIZE(iw_channel_table
); i
++)
200 if (reg_domain
== iw_channel_table
[i
].reg_domain
) {
201 rc
= iw_channel_table
[i
].deflt
;
207 static void iw_set_mgmt_info_element(enum iw_mgmt_info_element_ids id
,
208 struct iw_mgmt_info_element
*el
,
209 void *value
, int len
)
213 memcpy(el
->data
, value
, len
);
216 static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element
*to
,
217 struct iw_mgmt_info_element
*from
)
219 iw_set_mgmt_info_element(from
->id
, to
, from
->data
, from
->len
);
222 static inline void wl3501_switch_page(struct wl3501_card
*this, u8 page
)
224 wl3501_outb(page
, this->base_addr
+ WL3501_NIC_BSS
);
228 * Get Ethernet MAC addresss.
230 * WARNING: We switch to FPAGE0 and switc back again.
231 * Making sure there is no other WL function beening called by ISR.
233 static int wl3501_get_flash_mac_addr(struct wl3501_card
*this)
235 int base_addr
= this->base_addr
;
238 wl3501_outb(WL3501_BSS_FPAGE3
, base_addr
+ WL3501_NIC_BSS
); /* BSS */
239 wl3501_outb(0x00, base_addr
+ WL3501_NIC_LMAL
); /* LMAL */
240 wl3501_outb(0x40, base_addr
+ WL3501_NIC_LMAH
); /* LMAH */
242 /* wait for reading EEPROM */
244 this->mac_addr
[0] = inb(base_addr
+ WL3501_NIC_IODPA
);
246 this->mac_addr
[1] = inb(base_addr
+ WL3501_NIC_IODPA
);
248 this->mac_addr
[2] = inb(base_addr
+ WL3501_NIC_IODPA
);
250 this->mac_addr
[3] = inb(base_addr
+ WL3501_NIC_IODPA
);
252 this->mac_addr
[4] = inb(base_addr
+ WL3501_NIC_IODPA
);
254 this->mac_addr
[5] = inb(base_addr
+ WL3501_NIC_IODPA
);
256 this->reg_domain
= inb(base_addr
+ WL3501_NIC_IODPA
);
258 wl3501_outb(WL3501_BSS_FPAGE0
, base_addr
+ WL3501_NIC_BSS
);
259 wl3501_outb(0x04, base_addr
+ WL3501_NIC_LMAL
);
260 wl3501_outb(0x40, base_addr
+ WL3501_NIC_LMAH
);
262 this->version
[0] = inb(base_addr
+ WL3501_NIC_IODPA
);
264 this->version
[1] = inb(base_addr
+ WL3501_NIC_IODPA
);
265 /* switch to SRAM Page 0 (for safety) */
266 wl3501_switch_page(this, WL3501_BSS_SPAGE0
);
268 /* The MAC addr should be 00:60:... */
269 return this->mac_addr
[0] == 0x00 && this->mac_addr
[1] == 0x60;
273 * wl3501_set_to_wla - Move 'size' bytes from PC to card
274 * @dest: Card addressing space
275 * @src: PC addressing space
276 * @size: Bytes to move
278 * Move 'size' bytes from PC to card. (Shouldn't be interrupted)
280 static void wl3501_set_to_wla(struct wl3501_card
*this, u16 dest
, void *src
,
283 /* switch to SRAM Page 0 */
284 wl3501_switch_page(this, (dest
& 0x8000) ? WL3501_BSS_SPAGE1
:
286 /* set LMAL and LMAH */
287 wl3501_outb(dest
& 0xff, this->base_addr
+ WL3501_NIC_LMAL
);
288 wl3501_outb(((dest
>> 8) & 0x7f), this->base_addr
+ WL3501_NIC_LMAH
);
290 /* rep out to Port A */
291 wl3501_outsb(this->base_addr
+ WL3501_NIC_IODPA
, src
, size
);
295 * wl3501_get_from_wla - Move 'size' bytes from card to PC
296 * @src: Card addressing space
297 * @dest: PC addressing space
298 * @size: Bytes to move
300 * Move 'size' bytes from card to PC. (Shouldn't be interrupted)
302 static void wl3501_get_from_wla(struct wl3501_card
*this, u16 src
, void *dest
,
305 /* switch to SRAM Page 0 */
306 wl3501_switch_page(this, (src
& 0x8000) ? WL3501_BSS_SPAGE1
:
308 /* set LMAL and LMAH */
309 wl3501_outb(src
& 0xff, this->base_addr
+ WL3501_NIC_LMAL
);
310 wl3501_outb((src
>> 8) & 0x7f, this->base_addr
+ WL3501_NIC_LMAH
);
312 /* rep get from Port A */
313 insb(this->base_addr
+ WL3501_NIC_IODPA
, dest
, size
);
317 * Get/Allocate a free Tx Data Buffer
319 * *--------------*-----------------*----------------------------------*
320 * | PLCP | MAC Header | DST SRC Data ... |
321 * | (24 bytes) | (30 bytes) | (6) (6) (Ethernet Row Data) |
322 * *--------------*-----------------*----------------------------------*
323 * \ \- IEEE 802.11 -/ \-------------- len --------------/
324 * \-struct wl3501_80211_tx_hdr--/ \-------- Ethernet Frame -------/
326 * Return = Postion in Card
328 static u16
wl3501_get_tx_buffer(struct wl3501_card
*this, u16 len
)
330 u16 next
, blk_cnt
= 0, zero
= 0;
331 u16 full_len
= sizeof(struct wl3501_80211_tx_hdr
) + len
;
334 if (full_len
> this->tx_buffer_cnt
* 254)
336 ret
= this->tx_buffer_head
;
342 wl3501_get_from_wla(this, this->tx_buffer_head
, &next
,
345 wl3501_set_to_wla(this, this->tx_buffer_head
, &zero
,
347 this->tx_buffer_head
= next
;
349 /* if buffer is not enough */
350 if (!next
&& full_len
) {
351 this->tx_buffer_head
= ret
;
356 this->tx_buffer_cnt
-= blk_cnt
;
362 * Free an allocated Tx Buffer. ptr must be correct position.
364 static void wl3501_free_tx_buffer(struct wl3501_card
*this, u16 ptr
)
366 /* check if all space is not free */
367 if (!this->tx_buffer_head
)
368 this->tx_buffer_head
= ptr
;
370 wl3501_set_to_wla(this, this->tx_buffer_tail
,
375 this->tx_buffer_cnt
++;
376 wl3501_get_from_wla(this, ptr
, &next
, sizeof(next
));
377 this->tx_buffer_tail
= ptr
;
382 static int wl3501_esbq_req_test(struct wl3501_card
*this)
386 wl3501_get_from_wla(this, this->esbq_req_head
+ 3, &tmp
, sizeof(tmp
));
390 static void wl3501_esbq_req(struct wl3501_card
*this, u16
*ptr
)
394 wl3501_set_to_wla(this, this->esbq_req_head
, ptr
, 2);
395 wl3501_set_to_wla(this, this->esbq_req_head
+ 2, &tmp
, sizeof(tmp
));
396 this->esbq_req_head
+= 4;
397 if (this->esbq_req_head
>= this->esbq_req_end
)
398 this->esbq_req_head
= this->esbq_req_start
;
401 static int wl3501_esbq_exec(struct wl3501_card
*this, void *sig
, int sig_size
)
405 if (wl3501_esbq_req_test(this)) {
406 u16 ptr
= wl3501_get_tx_buffer(this, sig_size
);
408 wl3501_set_to_wla(this, ptr
, sig
, sig_size
);
409 wl3501_esbq_req(this, &ptr
);
416 static int wl3501_get_mib_value(struct wl3501_card
*this, u8 index
,
419 struct wl3501_get_req sig
= {
420 .sig_id
= WL3501_SIG_GET_REQ
,
426 spin_lock_irqsave(&this->lock
, flags
);
427 if (wl3501_esbq_req_test(this)) {
428 u16 ptr
= wl3501_get_tx_buffer(this, sizeof(sig
));
430 wl3501_set_to_wla(this, ptr
, &sig
, sizeof(sig
));
431 wl3501_esbq_req(this, &ptr
);
432 this->sig_get_confirm
.mib_status
= 255;
433 spin_unlock_irqrestore(&this->lock
, flags
);
434 rc
= wait_event_interruptible(this->wait
,
435 this->sig_get_confirm
.mib_status
!= 255);
437 memcpy(bf
, this->sig_get_confirm
.mib_value
,
442 spin_unlock_irqrestore(&this->lock
, flags
);
447 static int wl3501_pwr_mgmt(struct wl3501_card
*this, int suspend
)
449 struct wl3501_pwr_mgmt_req sig
= {
450 .sig_id
= WL3501_SIG_PWR_MGMT_REQ
,
458 spin_lock_irqsave(&this->lock
, flags
);
459 if (wl3501_esbq_req_test(this)) {
460 u16 ptr
= wl3501_get_tx_buffer(this, sizeof(sig
));
462 wl3501_set_to_wla(this, ptr
, &sig
, sizeof(sig
));
463 wl3501_esbq_req(this, &ptr
);
464 this->sig_pwr_mgmt_confirm
.status
= 255;
465 spin_unlock_irqrestore(&this->lock
, flags
);
466 rc
= wait_event_interruptible(this->wait
,
467 this->sig_pwr_mgmt_confirm
.status
!= 255);
468 printk(KERN_INFO
"%s: %s status=%d\n", __func__
,
469 suspend
? "suspend" : "resume",
470 this->sig_pwr_mgmt_confirm
.status
);
474 spin_unlock_irqrestore(&this->lock
, flags
);
480 * wl3501_send_pkt - Send a packet.
485 * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr,
486 * data[6] - data[11] is Src MAC Addr)
489 static int wl3501_send_pkt(struct wl3501_card
*this, u8
*data
, u16 len
)
491 u16 bf
, sig_bf
, next
, tmplen
, pktlen
;
492 struct wl3501_md_req sig
= {
493 .sig_id
= WL3501_SIG_MD_REQ
,
495 u8
*pdata
= (char *)data
;
498 if (wl3501_esbq_req_test(this)) {
499 sig_bf
= wl3501_get_tx_buffer(this, sizeof(sig
));
501 if (!sig_bf
) /* No free buffer available */
503 bf
= wl3501_get_tx_buffer(this, len
+ 26 + 24);
505 /* No free buffer available */
506 wl3501_free_tx_buffer(this, sig_bf
);
510 memcpy(&sig
.daddr
[0], pdata
, 12);
514 if (((*pdata
) * 256 + (*(pdata
+ 1))) > 1500) {
515 u8 addr4
[ETH_ALEN
] = {
516 [0] = 0xAA, [1] = 0xAA, [2] = 0x03, [4] = 0x00,
519 wl3501_set_to_wla(this, bf
+ 2 +
520 offsetof(struct wl3501_tx_hdr
, addr4
),
521 addr4
, sizeof(addr4
));
522 sig
.size
= pktlen
+ 24 + 4 + 6;
523 if (pktlen
> (254 - sizeof(struct wl3501_tx_hdr
))) {
524 tmplen
= 254 - sizeof(struct wl3501_tx_hdr
);
530 wl3501_set_to_wla(this,
531 bf
+ 2 + sizeof(struct wl3501_tx_hdr
),
534 wl3501_get_from_wla(this, bf
, &next
, sizeof(next
));
537 sig
.size
= pktlen
+ 24 + 4 - 2;
540 if (pktlen
> (254 - sizeof(struct wl3501_tx_hdr
) + 6)) {
541 tmplen
= 254 - sizeof(struct wl3501_tx_hdr
) + 6;
547 wl3501_set_to_wla(this, bf
+ 2 +
548 offsetof(struct wl3501_tx_hdr
, addr4
),
551 wl3501_get_from_wla(this, bf
, &next
, sizeof(next
));
562 wl3501_set_to_wla(this, bf
+ 2, pdata
, tmplen
);
564 wl3501_get_from_wla(this, bf
, &next
, sizeof(next
));
567 wl3501_set_to_wla(this, sig_bf
, &sig
, sizeof(sig
));
568 wl3501_esbq_req(this, &sig_bf
);
574 static int wl3501_mgmt_resync(struct wl3501_card
*this)
576 struct wl3501_resync_req sig
= {
577 .sig_id
= WL3501_SIG_RESYNC_REQ
,
580 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
583 static inline int wl3501_fw_bss_type(struct wl3501_card
*this)
585 return this->net_type
== IW_MODE_INFRA
? WL3501_NET_TYPE_INFRA
:
586 WL3501_NET_TYPE_ADHOC
;
589 static inline int wl3501_fw_cap_info(struct wl3501_card
*this)
591 return this->net_type
== IW_MODE_INFRA
? WL3501_MGMT_CAPABILITY_ESS
:
592 WL3501_MGMT_CAPABILITY_IBSS
;
595 static int wl3501_mgmt_scan(struct wl3501_card
*this, u16 chan_time
)
597 struct wl3501_scan_req sig
= {
598 .sig_id
= WL3501_SIG_SCAN_REQ
,
599 .scan_type
= WL3501_SCAN_TYPE_ACTIVE
,
601 .min_chan_time
= chan_time
,
602 .max_chan_time
= chan_time
,
603 .bss_type
= wl3501_fw_bss_type(this),
606 this->bss_cnt
= this->join_sta_bss
= 0;
607 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
610 static int wl3501_mgmt_join(struct wl3501_card
*this, u16 stas
)
612 struct wl3501_join_req sig
= {
613 .sig_id
= WL3501_SIG_JOIN_REQ
,
617 .id
= IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET
,
624 memcpy(&sig
.beacon_period
, &this->bss_set
[stas
].beacon_period
, 72);
625 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
628 static int wl3501_mgmt_start(struct wl3501_card
*this)
630 struct wl3501_start_req sig
= {
631 .sig_id
= WL3501_SIG_START_REQ
,
632 .beacon_period
= 400,
636 .id
= IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET
,
643 .id
= IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES
,
646 .data_rate_labels
= {
647 [0] = IW_MGMT_RATE_LABEL_MANDATORY
|
648 IW_MGMT_RATE_LABEL_1MBIT
,
649 [1] = IW_MGMT_RATE_LABEL_MANDATORY
|
650 IW_MGMT_RATE_LABEL_2MBIT
,
653 .operational_rset
= {
655 .id
= IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES
,
658 .data_rate_labels
= {
659 [0] = IW_MGMT_RATE_LABEL_MANDATORY
|
660 IW_MGMT_RATE_LABEL_1MBIT
,
661 [1] = IW_MGMT_RATE_LABEL_MANDATORY
|
662 IW_MGMT_RATE_LABEL_2MBIT
,
667 .id
= IW_MGMT_INFO_ELEMENT_IBSS_PARAMETER_SET
,
672 .bss_type
= wl3501_fw_bss_type(this),
673 .cap_info
= wl3501_fw_cap_info(this),
676 iw_copy_mgmt_info_element(&sig
.ssid
.el
, &this->essid
.el
);
677 iw_copy_mgmt_info_element(&this->keep_essid
.el
, &this->essid
.el
);
678 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
681 static void wl3501_mgmt_scan_confirm(struct wl3501_card
*this, u16 addr
)
685 struct wl3501_scan_confirm sig
;
688 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
689 if (sig
.status
== WL3501_STATUS_SUCCESS
) {
690 dprintk(3, "success");
691 if ((this->net_type
== IW_MODE_INFRA
&&
692 (sig
.cap_info
& WL3501_MGMT_CAPABILITY_ESS
)) ||
693 (this->net_type
== IW_MODE_ADHOC
&&
694 (sig
.cap_info
& WL3501_MGMT_CAPABILITY_IBSS
)) ||
695 this->net_type
== IW_MODE_AUTO
) {
696 if (!this->essid
.el
.len
)
698 else if (this->essid
.el
.len
== 3 &&
699 !memcmp(this->essid
.essid
, "ANY", 3))
701 else if (this->essid
.el
.len
!= sig
.ssid
.el
.len
)
703 else if (memcmp(this->essid
.essid
, sig
.ssid
.essid
,
709 for (i
= 0; i
< this->bss_cnt
; i
++) {
710 if (!memcmp(this->bss_set
[i
].bssid
,
711 sig
.bssid
, ETH_ALEN
)) {
717 if (matchflag
&& (i
< 20)) {
718 memcpy(&this->bss_set
[i
].beacon_period
,
719 &sig
.beacon_period
, 73);
721 this->rssi
= sig
.rssi
;
724 } else if (sig
.status
== WL3501_STATUS_TIMEOUT
) {
725 dprintk(3, "timeout");
726 this->join_sta_bss
= 0;
727 for (i
= this->join_sta_bss
; i
< this->bss_cnt
; i
++)
728 if (!wl3501_mgmt_join(this, i
))
730 this->join_sta_bss
= i
;
731 if (this->join_sta_bss
== this->bss_cnt
) {
732 if (this->net_type
== IW_MODE_INFRA
)
733 wl3501_mgmt_scan(this, 100);
736 if (this->adhoc_times
> WL3501_MAX_ADHOC_TRIES
)
737 wl3501_mgmt_start(this);
739 wl3501_mgmt_scan(this, 100);
746 * wl3501_block_interrupt - Mask interrupt from SUTRO
749 * Mask interrupt from SUTRO. (i.e. SUTRO cannot interrupt the HOST)
750 * Return: 1 if interrupt is originally enabled
752 static int wl3501_block_interrupt(struct wl3501_card
*this)
754 u8 old
= inb(this->base_addr
+ WL3501_NIC_GCR
);
755 u8
new = old
& (~(WL3501_GCR_ECINT
| WL3501_GCR_INT2EC
|
756 WL3501_GCR_ENECINT
));
758 wl3501_outb(new, this->base_addr
+ WL3501_NIC_GCR
);
759 return old
& WL3501_GCR_ENECINT
;
763 * wl3501_unblock_interrupt - Enable interrupt from SUTRO
766 * Enable interrupt from SUTRO. (i.e. SUTRO can interrupt the HOST)
767 * Return: 1 if interrupt is originally enabled
769 static int wl3501_unblock_interrupt(struct wl3501_card
*this)
771 u8 old
= inb(this->base_addr
+ WL3501_NIC_GCR
);
772 u8
new = (old
& ~(WL3501_GCR_ECINT
| WL3501_GCR_INT2EC
)) |
775 wl3501_outb(new, this->base_addr
+ WL3501_NIC_GCR
);
776 return old
& WL3501_GCR_ENECINT
;
780 * wl3501_receive - Receive data from Receive Queue.
782 * Receive data from Receive Queue.
785 * @bf: address of host
786 * @size: size of buffer.
788 static u16
wl3501_receive(struct wl3501_card
*this, u8
*bf
, u16 size
)
790 u16 next_addr
, next_addr1
;
794 wl3501_get_from_wla(this, this->start_seg
+ 2,
795 &next_addr
, sizeof(next_addr
));
796 if (size
> WL3501_BLKSZ
- sizeof(struct wl3501_rx_hdr
)) {
797 wl3501_get_from_wla(this,
799 sizeof(struct wl3501_rx_hdr
), data
,
801 sizeof(struct wl3501_rx_hdr
));
802 size
-= WL3501_BLKSZ
- sizeof(struct wl3501_rx_hdr
);
803 data
+= WL3501_BLKSZ
- sizeof(struct wl3501_rx_hdr
);
805 wl3501_get_from_wla(this,
807 sizeof(struct wl3501_rx_hdr
),
812 if (size
> WL3501_BLKSZ
- 5) {
813 wl3501_get_from_wla(this, next_addr
+ 5, data
,
815 size
-= WL3501_BLKSZ
- 5;
816 data
+= WL3501_BLKSZ
- 5;
817 wl3501_get_from_wla(this, next_addr
+ 2, &next_addr1
,
819 next_addr
= next_addr1
;
821 wl3501_get_from_wla(this, next_addr
+ 5, data
, size
);
828 static void wl3501_esbq_req_free(struct wl3501_card
*this)
833 if (this->esbq_req_head
== this->esbq_req_tail
)
835 wl3501_get_from_wla(this, this->esbq_req_tail
+ 3, &tmp
, sizeof(tmp
));
838 wl3501_get_from_wla(this, this->esbq_req_tail
, &addr
, sizeof(addr
));
839 wl3501_free_tx_buffer(this, addr
);
840 this->esbq_req_tail
+= 4;
841 if (this->esbq_req_tail
>= this->esbq_req_end
)
842 this->esbq_req_tail
= this->esbq_req_start
;
847 static int wl3501_esbq_confirm(struct wl3501_card
*this)
851 wl3501_get_from_wla(this, this->esbq_confirm
+ 3, &tmp
, sizeof(tmp
));
855 static void wl3501_online(struct net_device
*dev
)
857 struct wl3501_card
*this = netdev_priv(dev
);
859 printk(KERN_INFO
"%s: Wireless LAN online. BSSID: %pM\n",
860 dev
->name
, this->bssid
);
861 netif_wake_queue(dev
);
864 static void wl3501_esbq_confirm_done(struct wl3501_card
*this)
868 wl3501_set_to_wla(this, this->esbq_confirm
+ 3, &tmp
, sizeof(tmp
));
869 this->esbq_confirm
+= 4;
870 if (this->esbq_confirm
>= this->esbq_confirm_end
)
871 this->esbq_confirm
= this->esbq_confirm_start
;
874 static int wl3501_mgmt_auth(struct wl3501_card
*this)
876 struct wl3501_auth_req sig
= {
877 .sig_id
= WL3501_SIG_AUTH_REQ
,
878 .type
= WL3501_SYS_TYPE_OPEN
,
883 memcpy(sig
.mac_addr
, this->bssid
, ETH_ALEN
);
884 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
887 static int wl3501_mgmt_association(struct wl3501_card
*this)
889 struct wl3501_assoc_req sig
= {
890 .sig_id
= WL3501_SIG_ASSOC_REQ
,
892 .listen_interval
= 5,
893 .cap_info
= this->cap_info
,
897 memcpy(sig
.mac_addr
, this->bssid
, ETH_ALEN
);
898 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
901 static void wl3501_mgmt_join_confirm(struct net_device
*dev
, u16 addr
)
903 struct wl3501_card
*this = netdev_priv(dev
);
904 struct wl3501_join_confirm sig
;
907 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
908 if (sig
.status
== WL3501_STATUS_SUCCESS
) {
909 if (this->net_type
== IW_MODE_INFRA
) {
910 if (this->join_sta_bss
< this->bss_cnt
) {
911 const int i
= this->join_sta_bss
;
913 this->bss_set
[i
].bssid
, ETH_ALEN
);
914 this->chan
= this->bss_set
[i
].ds_pset
.chan
;
915 iw_copy_mgmt_info_element(&this->keep_essid
.el
,
916 &this->bss_set
[i
].ssid
.el
);
917 wl3501_mgmt_auth(this);
920 const int i
= this->join_sta_bss
;
922 memcpy(&this->bssid
, &this->bss_set
[i
].bssid
, ETH_ALEN
);
923 this->chan
= this->bss_set
[i
].ds_pset
.chan
;
924 iw_copy_mgmt_info_element(&this->keep_essid
.el
,
925 &this->bss_set
[i
].ssid
.el
);
930 this->join_sta_bss
++;
931 for (i
= this->join_sta_bss
; i
< this->bss_cnt
; i
++)
932 if (!wl3501_mgmt_join(this, i
))
934 this->join_sta_bss
= i
;
935 if (this->join_sta_bss
== this->bss_cnt
) {
936 if (this->net_type
== IW_MODE_INFRA
)
937 wl3501_mgmt_scan(this, 100);
940 if (this->adhoc_times
> WL3501_MAX_ADHOC_TRIES
)
941 wl3501_mgmt_start(this);
943 wl3501_mgmt_scan(this, 100);
949 static inline void wl3501_alarm_interrupt(struct net_device
*dev
,
950 struct wl3501_card
*this)
952 if (this->net_type
== IW_MODE_INFRA
) {
953 printk(KERN_INFO
"Wireless LAN offline\n");
954 netif_stop_queue(dev
);
955 wl3501_mgmt_resync(this);
959 static inline void wl3501_md_confirm_interrupt(struct net_device
*dev
,
960 struct wl3501_card
*this,
963 struct wl3501_md_confirm sig
;
966 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
967 wl3501_free_tx_buffer(this, sig
.data
);
968 if (netif_queue_stopped(dev
))
969 netif_wake_queue(dev
);
972 static inline void wl3501_md_ind_interrupt(struct net_device
*dev
,
973 struct wl3501_card
*this, u16 addr
)
975 struct wl3501_md_ind sig
;
977 u8 rssi
, addr4
[ETH_ALEN
];
980 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
981 this->start_seg
= sig
.data
;
982 wl3501_get_from_wla(this,
983 sig
.data
+ offsetof(struct wl3501_rx_hdr
, rssi
),
984 &rssi
, sizeof(rssi
));
985 this->rssi
= rssi
<= 63 ? (rssi
* 100) / 64 : 255;
987 wl3501_get_from_wla(this,
989 offsetof(struct wl3501_rx_hdr
, addr4
),
990 &addr4
, sizeof(addr4
));
991 if (!(addr4
[0] == 0xAA && addr4
[1] == 0xAA &&
992 addr4
[2] == 0x03 && addr4
[4] == 0x00)) {
993 printk(KERN_INFO
"Insupported packet type!\n");
996 pkt_len
= sig
.size
+ 12 - 24 - 4 - 6;
998 skb
= dev_alloc_skb(pkt_len
+ 5);
1001 printk(KERN_WARNING
"%s: Can't alloc a sk_buff of size %d.\n",
1002 dev
->name
, pkt_len
);
1003 dev
->stats
.rx_dropped
++;
1006 skb_reserve(skb
, 2); /* IP headers on 16 bytes boundaries */
1007 skb_copy_to_linear_data(skb
, (unsigned char *)&sig
.daddr
, 12);
1008 wl3501_receive(this, skb
->data
, pkt_len
);
1009 skb_put(skb
, pkt_len
);
1010 skb
->protocol
= eth_type_trans(skb
, dev
);
1011 dev
->stats
.rx_packets
++;
1012 dev
->stats
.rx_bytes
+= skb
->len
;
1017 static inline void wl3501_get_confirm_interrupt(struct wl3501_card
*this,
1018 u16 addr
, void *sig
, int size
)
1020 dprintk(3, "entry");
1021 wl3501_get_from_wla(this, addr
, &this->sig_get_confirm
,
1022 sizeof(this->sig_get_confirm
));
1023 wake_up(&this->wait
);
1026 static inline void wl3501_start_confirm_interrupt(struct net_device
*dev
,
1027 struct wl3501_card
*this,
1030 struct wl3501_start_confirm sig
;
1032 dprintk(3, "entry");
1033 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
1034 if (sig
.status
== WL3501_STATUS_SUCCESS
)
1035 netif_wake_queue(dev
);
1038 static inline void wl3501_assoc_confirm_interrupt(struct net_device
*dev
,
1041 struct wl3501_card
*this = netdev_priv(dev
);
1042 struct wl3501_assoc_confirm sig
;
1044 dprintk(3, "entry");
1045 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
1047 if (sig
.status
== WL3501_STATUS_SUCCESS
)
1051 static inline void wl3501_auth_confirm_interrupt(struct wl3501_card
*this,
1054 struct wl3501_auth_confirm sig
;
1056 dprintk(3, "entry");
1057 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
1059 if (sig
.status
== WL3501_STATUS_SUCCESS
)
1060 wl3501_mgmt_association(this);
1062 wl3501_mgmt_resync(this);
1065 static inline void wl3501_rx_interrupt(struct net_device
*dev
)
1070 struct wl3501_card
*this = netdev_priv(dev
);
1072 dprintk(3, "entry");
1075 if (!wl3501_esbq_confirm(this))
1077 wl3501_get_from_wla(this, this->esbq_confirm
, &addr
, sizeof(addr
));
1078 wl3501_get_from_wla(this, addr
+ 2, &sig_id
, sizeof(sig_id
));
1081 case WL3501_SIG_DEAUTH_IND
:
1082 case WL3501_SIG_DISASSOC_IND
:
1083 case WL3501_SIG_ALARM
:
1084 wl3501_alarm_interrupt(dev
, this);
1086 case WL3501_SIG_MD_CONFIRM
:
1087 wl3501_md_confirm_interrupt(dev
, this, addr
);
1089 case WL3501_SIG_MD_IND
:
1090 wl3501_md_ind_interrupt(dev
, this, addr
);
1092 case WL3501_SIG_GET_CONFIRM
:
1093 wl3501_get_confirm_interrupt(this, addr
,
1094 &this->sig_get_confirm
,
1095 sizeof(this->sig_get_confirm
));
1097 case WL3501_SIG_PWR_MGMT_CONFIRM
:
1098 wl3501_get_confirm_interrupt(this, addr
,
1099 &this->sig_pwr_mgmt_confirm
,
1100 sizeof(this->sig_pwr_mgmt_confirm
));
1102 case WL3501_SIG_START_CONFIRM
:
1103 wl3501_start_confirm_interrupt(dev
, this, addr
);
1105 case WL3501_SIG_SCAN_CONFIRM
:
1106 wl3501_mgmt_scan_confirm(this, addr
);
1108 case WL3501_SIG_JOIN_CONFIRM
:
1109 wl3501_mgmt_join_confirm(dev
, addr
);
1111 case WL3501_SIG_ASSOC_CONFIRM
:
1112 wl3501_assoc_confirm_interrupt(dev
, addr
);
1114 case WL3501_SIG_AUTH_CONFIRM
:
1115 wl3501_auth_confirm_interrupt(this, addr
);
1117 case WL3501_SIG_RESYNC_CONFIRM
:
1118 wl3501_mgmt_resync(this); /* FIXME: should be resync_confirm */
1121 wl3501_esbq_confirm_done(this);
1123 /* free request if necessary */
1125 wl3501_esbq_req_free(this);
1130 static inline void wl3501_ack_interrupt(struct wl3501_card
*this)
1132 wl3501_outb(WL3501_GCR_ECINT
, this->base_addr
+ WL3501_NIC_GCR
);
1136 * wl3501_interrupt - Hardware interrupt from card.
1137 * @irq - Interrupt number
1138 * @dev_id - net_device
1140 * We must acknowledge the interrupt as soon as possible, and block the
1141 * interrupt from the same card immediately to prevent re-entry.
1143 * Before accessing the Control_Status_Block, we must lock SUTRO first.
1144 * On the other hand, to prevent SUTRO from malfunctioning, we must
1145 * unlock the SUTRO as soon as possible.
1147 static irqreturn_t
wl3501_interrupt(int irq
, void *dev_id
)
1149 struct net_device
*dev
= dev_id
;
1150 struct wl3501_card
*this;
1152 this = netdev_priv(dev
);
1153 spin_lock(&this->lock
);
1154 wl3501_ack_interrupt(this);
1155 wl3501_block_interrupt(this);
1156 wl3501_rx_interrupt(dev
);
1157 wl3501_unblock_interrupt(this);
1158 spin_unlock(&this->lock
);
1163 static int wl3501_reset_board(struct wl3501_card
*this)
1169 wl3501_outb_p(WL3501_GCR_CORESET
, this->base_addr
+ WL3501_NIC_GCR
);
1170 wl3501_outb_p(0, this->base_addr
+ WL3501_NIC_GCR
);
1171 wl3501_outb_p(WL3501_GCR_CORESET
, this->base_addr
+ WL3501_NIC_GCR
);
1173 /* Reset SRAM 0x480 to zero */
1174 wl3501_set_to_wla(this, 0x480, &tmp
, sizeof(tmp
));
1177 wl3501_outb_p(0, this->base_addr
+ WL3501_NIC_GCR
);
1179 WL3501_NOPLOOP(1024 * 50);
1181 wl3501_unblock_interrupt(this); /* acme: was commented */
1183 /* Polling Self_Test_Status */
1184 for (i
= 0; i
< 10000; i
++) {
1185 wl3501_get_from_wla(this, 0x480, &tmp
, sizeof(tmp
));
1188 /* firmware complete all test successfully */
1190 wl3501_set_to_wla(this, 0x480, &tmp
, sizeof(tmp
));
1195 printk(KERN_WARNING
"%s: failed to reset the board!\n", __func__
);
1201 static int wl3501_init_firmware(struct wl3501_card
*this)
1204 int rc
= wl3501_reset_board(this);
1208 this->card_name
[0] = '\0';
1209 wl3501_get_from_wla(this, 0x1a00,
1210 this->card_name
, sizeof(this->card_name
));
1211 this->card_name
[sizeof(this->card_name
) - 1] = '\0';
1212 this->firmware_date
[0] = '\0';
1213 wl3501_get_from_wla(this, 0x1a40,
1214 this->firmware_date
, sizeof(this->firmware_date
));
1215 this->firmware_date
[sizeof(this->firmware_date
) - 1] = '\0';
1216 /* Switch to SRAM Page 0 */
1217 wl3501_switch_page(this, WL3501_BSS_SPAGE0
);
1218 /* Read parameter from card */
1219 wl3501_get_from_wla(this, 0x482, &this->esbq_req_start
, 2);
1220 wl3501_get_from_wla(this, 0x486, &this->esbq_req_end
, 2);
1221 wl3501_get_from_wla(this, 0x488, &this->esbq_confirm_start
, 2);
1222 wl3501_get_from_wla(this, 0x48c, &this->esbq_confirm_end
, 2);
1223 wl3501_get_from_wla(this, 0x48e, &this->tx_buffer_head
, 2);
1224 wl3501_get_from_wla(this, 0x492, &this->tx_buffer_size
, 2);
1225 this->esbq_req_tail
= this->esbq_req_head
= this->esbq_req_start
;
1226 this->esbq_req_end
+= this->esbq_req_start
;
1227 this->esbq_confirm
= this->esbq_confirm_start
;
1228 this->esbq_confirm_end
+= this->esbq_confirm_start
;
1229 /* Initial Tx Buffer */
1230 this->tx_buffer_cnt
= 1;
1231 ptr
= this->tx_buffer_head
;
1232 next
= ptr
+ WL3501_BLKSZ
;
1233 while ((next
- this->tx_buffer_head
) < this->tx_buffer_size
) {
1234 this->tx_buffer_cnt
++;
1235 wl3501_set_to_wla(this, ptr
, &next
, sizeof(next
));
1237 next
= ptr
+ WL3501_BLKSZ
;
1241 wl3501_set_to_wla(this, ptr
, &next
, sizeof(next
));
1242 this->tx_buffer_tail
= ptr
;
1246 printk(KERN_WARNING
"%s: failed!\n", __func__
);
1250 static int wl3501_close(struct net_device
*dev
)
1252 struct wl3501_card
*this = netdev_priv(dev
);
1254 unsigned long flags
;
1255 struct pcmcia_device
*link
;
1258 spin_lock_irqsave(&this->lock
, flags
);
1261 /* Stop wl3501_hard_start_xmit() from now on */
1262 netif_stop_queue(dev
);
1263 wl3501_ack_interrupt(this);
1265 /* Mask interrupts from the SUTRO */
1266 wl3501_block_interrupt(this);
1269 printk(KERN_INFO
"%s: WL3501 closed\n", dev
->name
);
1270 spin_unlock_irqrestore(&this->lock
, flags
);
1275 * wl3501_reset - Reset the SUTRO.
1276 * @dev - network device
1278 * It is almost the same as wl3501_open(). In fact, we may just wl3501_close()
1279 * and wl3501_open() again, but I wouldn't like to free_irq() when the driver
1280 * is running. It seems to be dangerous.
1282 static int wl3501_reset(struct net_device
*dev
)
1284 struct wl3501_card
*this = netdev_priv(dev
);
1287 wl3501_block_interrupt(this);
1289 if (wl3501_init_firmware(this)) {
1290 printk(KERN_WARNING
"%s: Can't initialize Firmware!\n",
1292 /* Free IRQ, and mark IRQ as unused */
1293 free_irq(dev
->irq
, dev
);
1298 * Queue has to be started only when the Card is Started
1300 netif_stop_queue(dev
);
1301 this->adhoc_times
= 0;
1302 wl3501_ack_interrupt(this);
1303 wl3501_unblock_interrupt(this);
1304 wl3501_mgmt_scan(this, 100);
1305 dprintk(1, "%s: device reset", dev
->name
);
1311 static void wl3501_tx_timeout(struct net_device
*dev
)
1313 struct wl3501_card
*this = netdev_priv(dev
);
1314 struct net_device_stats
*stats
= &dev
->stats
;
1315 unsigned long flags
;
1319 spin_lock_irqsave(&this->lock
, flags
);
1320 rc
= wl3501_reset(dev
);
1321 spin_unlock_irqrestore(&this->lock
, flags
);
1323 printk(KERN_ERR
"%s: Error %d resetting card on Tx timeout!\n",
1326 dev
->trans_start
= jiffies
;
1327 netif_wake_queue(dev
);
1333 * 1 - Could not transmit (dev_queue_xmit will queue it)
1334 * and try to sent it later
1336 static netdev_tx_t
wl3501_hard_start_xmit(struct sk_buff
*skb
,
1337 struct net_device
*dev
)
1340 struct wl3501_card
*this = netdev_priv(dev
);
1341 unsigned long flags
;
1343 spin_lock_irqsave(&this->lock
, flags
);
1344 enabled
= wl3501_block_interrupt(this);
1345 dev
->trans_start
= jiffies
;
1346 rc
= wl3501_send_pkt(this, skb
->data
, skb
->len
);
1348 wl3501_unblock_interrupt(this);
1350 ++dev
->stats
.tx_dropped
;
1351 netif_stop_queue(dev
);
1353 ++dev
->stats
.tx_packets
;
1354 dev
->stats
.tx_bytes
+= skb
->len
;
1357 if (this->tx_buffer_cnt
< 2)
1358 netif_stop_queue(dev
);
1360 spin_unlock_irqrestore(&this->lock
, flags
);
1361 return NETDEV_TX_OK
;
1364 static int wl3501_open(struct net_device
*dev
)
1367 struct wl3501_card
*this = netdev_priv(dev
);
1368 unsigned long flags
;
1369 struct pcmcia_device
*link
;
1372 spin_lock_irqsave(&this->lock
, flags
);
1373 if (!pcmcia_dev_present(link
))
1375 netif_device_attach(dev
);
1378 /* Initial WL3501 firmware */
1379 dprintk(1, "%s: Initialize WL3501 firmware...", dev
->name
);
1380 if (wl3501_init_firmware(this))
1382 /* Initial device variables */
1383 this->adhoc_times
= 0;
1384 /* Acknowledge Interrupt, for cleaning last state */
1385 wl3501_ack_interrupt(this);
1387 /* Enable interrupt from card after all */
1388 wl3501_unblock_interrupt(this);
1389 wl3501_mgmt_scan(this, 100);
1391 dprintk(1, "%s: WL3501 opened", dev
->name
);
1392 printk(KERN_INFO
"%s: Card Name: %s\n"
1393 "%s: Firmware Date: %s\n",
1394 dev
->name
, this->card_name
,
1395 dev
->name
, this->firmware_date
);
1397 spin_unlock_irqrestore(&this->lock
, flags
);
1400 printk(KERN_WARNING
"%s: Can't initialize firmware!\n", dev
->name
);
1404 static struct iw_statistics
*wl3501_get_wireless_stats(struct net_device
*dev
)
1406 struct wl3501_card
*this = netdev_priv(dev
);
1407 struct iw_statistics
*wstats
= &this->wstats
;
1408 u32 value
; /* size checked: it is u32 */
1410 memset(wstats
, 0, sizeof(*wstats
));
1411 wstats
->status
= netif_running(dev
);
1412 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_ICV_ERROR_COUNT
,
1413 &value
, sizeof(value
)))
1414 wstats
->discard
.code
+= value
;
1415 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_UNDECRYPTABLE_COUNT
,
1416 &value
, sizeof(value
)))
1417 wstats
->discard
.code
+= value
;
1418 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_EXCLUDED_COUNT
,
1419 &value
, sizeof(value
)))
1420 wstats
->discard
.code
+= value
;
1421 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RETRY_COUNT
,
1422 &value
, sizeof(value
)))
1423 wstats
->discard
.retries
= value
;
1424 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FAILED_COUNT
,
1425 &value
, sizeof(value
)))
1426 wstats
->discard
.misc
+= value
;
1427 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_FAILURE_COUNT
,
1428 &value
, sizeof(value
)))
1429 wstats
->discard
.misc
+= value
;
1430 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_ACK_FAILURE_COUNT
,
1431 &value
, sizeof(value
)))
1432 wstats
->discard
.misc
+= value
;
1433 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAME_DUPLICATE_COUNT
,
1434 &value
, sizeof(value
)))
1435 wstats
->discard
.misc
+= value
;
1439 static void wl3501_get_drvinfo(struct net_device
*dev
, struct ethtool_drvinfo
*info
)
1441 strlcpy(info
->driver
, wl3501_dev_info
, sizeof(info
->driver
));
1444 static const struct ethtool_ops ops
= {
1445 .get_drvinfo
= wl3501_get_drvinfo
1449 * wl3501_detach - deletes a driver "instance"
1452 * This deletes a driver "instance". The device is de-registered with Card
1453 * Services. If it has been released, all local data structures are freed.
1454 * Otherwise, the structures will be freed when the device is released.
1456 static void wl3501_detach(struct pcmcia_device
*link
)
1458 struct net_device
*dev
= link
->priv
;
1460 /* If the device is currently configured and active, we won't actually
1461 * delete it yet. Instead, it is marked so that when the release()
1462 * function is called, that will trigger a proper detach(). */
1464 while (link
->open
> 0)
1467 netif_device_detach(dev
);
1468 wl3501_release(link
);
1471 free_netdev(link
->priv
);
1476 static int wl3501_get_name(struct net_device
*dev
, struct iw_request_info
*info
,
1477 union iwreq_data
*wrqu
, char *extra
)
1479 strlcpy(wrqu
->name
, "IEEE 802.11-DS", sizeof(wrqu
->name
));
1483 static int wl3501_set_freq(struct net_device
*dev
, struct iw_request_info
*info
,
1484 union iwreq_data
*wrqu
, char *extra
)
1486 struct wl3501_card
*this = netdev_priv(dev
);
1487 int channel
= wrqu
->freq
.m
;
1490 if (iw_valid_channel(this->reg_domain
, channel
)) {
1491 this->chan
= channel
;
1492 rc
= wl3501_reset(dev
);
1497 static int wl3501_get_freq(struct net_device
*dev
, struct iw_request_info
*info
,
1498 union iwreq_data
*wrqu
, char *extra
)
1500 struct wl3501_card
*this = netdev_priv(dev
);
1502 wrqu
->freq
.m
= ieee80211_dsss_chan_to_freq(this->chan
) * 100000;
1507 static int wl3501_set_mode(struct net_device
*dev
, struct iw_request_info
*info
,
1508 union iwreq_data
*wrqu
, char *extra
)
1512 if (wrqu
->mode
== IW_MODE_INFRA
||
1513 wrqu
->mode
== IW_MODE_ADHOC
||
1514 wrqu
->mode
== IW_MODE_AUTO
) {
1515 struct wl3501_card
*this = netdev_priv(dev
);
1517 this->net_type
= wrqu
->mode
;
1518 rc
= wl3501_reset(dev
);
1523 static int wl3501_get_mode(struct net_device
*dev
, struct iw_request_info
*info
,
1524 union iwreq_data
*wrqu
, char *extra
)
1526 struct wl3501_card
*this = netdev_priv(dev
);
1528 wrqu
->mode
= this->net_type
;
1532 static int wl3501_get_sens(struct net_device
*dev
, struct iw_request_info
*info
,
1533 union iwreq_data
*wrqu
, char *extra
)
1535 struct wl3501_card
*this = netdev_priv(dev
);
1537 wrqu
->sens
.value
= this->rssi
;
1538 wrqu
->sens
.disabled
= !wrqu
->sens
.value
;
1539 wrqu
->sens
.fixed
= 1;
1543 static int wl3501_get_range(struct net_device
*dev
,
1544 struct iw_request_info
*info
,
1545 union iwreq_data
*wrqu
, char *extra
)
1547 struct iw_range
*range
= (struct iw_range
*)extra
;
1549 /* Set the length (very important for backward compatibility) */
1550 wrqu
->data
.length
= sizeof(*range
);
1552 /* Set all the info we don't care or don't know about to zero */
1553 memset(range
, 0, sizeof(*range
));
1555 /* Set the Wireless Extension versions */
1556 range
->we_version_compiled
= WIRELESS_EXT
;
1557 range
->we_version_source
= 1;
1558 range
->throughput
= 2 * 1000 * 1000; /* ~2 Mb/s */
1559 /* FIXME: study the code to fill in more fields... */
1563 static int wl3501_set_wap(struct net_device
*dev
, struct iw_request_info
*info
,
1564 union iwreq_data
*wrqu
, char *extra
)
1566 struct wl3501_card
*this = netdev_priv(dev
);
1567 static const u8 bcast
[ETH_ALEN
] = { 255, 255, 255, 255, 255, 255 };
1570 /* FIXME: we support other ARPHRDs...*/
1571 if (wrqu
->ap_addr
.sa_family
!= ARPHRD_ETHER
)
1573 if (!memcmp(bcast
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
)) {
1574 /* FIXME: rescan? */
1576 memcpy(this->bssid
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
);
1577 /* FIXME: rescan? deassoc & scan? */
1583 static int wl3501_get_wap(struct net_device
*dev
, struct iw_request_info
*info
,
1584 union iwreq_data
*wrqu
, char *extra
)
1586 struct wl3501_card
*this = netdev_priv(dev
);
1588 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1589 memcpy(wrqu
->ap_addr
.sa_data
, this->bssid
, ETH_ALEN
);
1593 static int wl3501_set_scan(struct net_device
*dev
, struct iw_request_info
*info
,
1594 union iwreq_data
*wrqu
, char *extra
)
1597 * FIXME: trigger scanning with a reset, yes, I'm lazy
1599 return wl3501_reset(dev
);
1602 static int wl3501_get_scan(struct net_device
*dev
, struct iw_request_info
*info
,
1603 union iwreq_data
*wrqu
, char *extra
)
1605 struct wl3501_card
*this = netdev_priv(dev
);
1607 char *current_ev
= extra
;
1608 struct iw_event iwe
;
1610 for (i
= 0; i
< this->bss_cnt
; ++i
) {
1611 iwe
.cmd
= SIOCGIWAP
;
1612 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1613 memcpy(iwe
.u
.ap_addr
.sa_data
, this->bss_set
[i
].bssid
, ETH_ALEN
);
1614 current_ev
= iwe_stream_add_event(info
, current_ev
,
1615 extra
+ IW_SCAN_MAX_DATA
,
1616 &iwe
, IW_EV_ADDR_LEN
);
1617 iwe
.cmd
= SIOCGIWESSID
;
1618 iwe
.u
.data
.flags
= 1;
1619 iwe
.u
.data
.length
= this->bss_set
[i
].ssid
.el
.len
;
1620 current_ev
= iwe_stream_add_point(info
, current_ev
,
1621 extra
+ IW_SCAN_MAX_DATA
,
1623 this->bss_set
[i
].ssid
.essid
);
1624 iwe
.cmd
= SIOCGIWMODE
;
1625 iwe
.u
.mode
= this->bss_set
[i
].bss_type
;
1626 current_ev
= iwe_stream_add_event(info
, current_ev
,
1627 extra
+ IW_SCAN_MAX_DATA
,
1628 &iwe
, IW_EV_UINT_LEN
);
1629 iwe
.cmd
= SIOCGIWFREQ
;
1630 iwe
.u
.freq
.m
= this->bss_set
[i
].ds_pset
.chan
;
1632 current_ev
= iwe_stream_add_event(info
, current_ev
,
1633 extra
+ IW_SCAN_MAX_DATA
,
1634 &iwe
, IW_EV_FREQ_LEN
);
1635 iwe
.cmd
= SIOCGIWENCODE
;
1636 if (this->bss_set
[i
].cap_info
& WL3501_MGMT_CAPABILITY_PRIVACY
)
1637 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1639 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1640 iwe
.u
.data
.length
= 0;
1641 current_ev
= iwe_stream_add_point(info
, current_ev
,
1642 extra
+ IW_SCAN_MAX_DATA
,
1645 /* Length of data */
1646 wrqu
->data
.length
= (current_ev
- extra
);
1647 wrqu
->data
.flags
= 0; /* FIXME: set properly these flags */
1651 static int wl3501_set_essid(struct net_device
*dev
,
1652 struct iw_request_info
*info
,
1653 union iwreq_data
*wrqu
, char *extra
)
1655 struct wl3501_card
*this = netdev_priv(dev
);
1657 if (wrqu
->data
.flags
) {
1658 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID
,
1660 extra
, wrqu
->data
.length
);
1661 } else { /* We accept any ESSID */
1662 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID
,
1663 &this->essid
.el
, "ANY", 3);
1665 return wl3501_reset(dev
);
1668 static int wl3501_get_essid(struct net_device
*dev
,
1669 struct iw_request_info
*info
,
1670 union iwreq_data
*wrqu
, char *extra
)
1672 struct wl3501_card
*this = netdev_priv(dev
);
1673 unsigned long flags
;
1675 spin_lock_irqsave(&this->lock
, flags
);
1676 wrqu
->essid
.flags
= 1;
1677 wrqu
->essid
.length
= this->essid
.el
.len
;
1678 memcpy(extra
, this->essid
.essid
, this->essid
.el
.len
);
1679 spin_unlock_irqrestore(&this->lock
, flags
);
1683 static int wl3501_set_nick(struct net_device
*dev
, struct iw_request_info
*info
,
1684 union iwreq_data
*wrqu
, char *extra
)
1686 struct wl3501_card
*this = netdev_priv(dev
);
1688 if (wrqu
->data
.length
> sizeof(this->nick
))
1690 strlcpy(this->nick
, extra
, wrqu
->data
.length
);
1694 static int wl3501_get_nick(struct net_device
*dev
, struct iw_request_info
*info
,
1695 union iwreq_data
*wrqu
, char *extra
)
1697 struct wl3501_card
*this = netdev_priv(dev
);
1699 strlcpy(extra
, this->nick
, 32);
1700 wrqu
->data
.length
= strlen(extra
);
1704 static int wl3501_get_rate(struct net_device
*dev
, struct iw_request_info
*info
,
1705 union iwreq_data
*wrqu
, char *extra
)
1708 * FIXME: have to see from where to get this info, perhaps this card
1709 * works at 1 Mbit/s too... for now leave at 2 Mbit/s that is the most
1710 * common with the Planet Access Points. -acme
1712 wrqu
->bitrate
.value
= 2000000;
1713 wrqu
->bitrate
.fixed
= 1;
1717 static int wl3501_get_rts_threshold(struct net_device
*dev
,
1718 struct iw_request_info
*info
,
1719 union iwreq_data
*wrqu
, char *extra
)
1721 u16 threshold
; /* size checked: it is u16 */
1722 struct wl3501_card
*this = netdev_priv(dev
);
1723 int rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_THRESHOLD
,
1724 &threshold
, sizeof(threshold
));
1726 wrqu
->rts
.value
= threshold
;
1727 wrqu
->rts
.disabled
= threshold
>= 2347;
1728 wrqu
->rts
.fixed
= 1;
1733 static int wl3501_get_frag_threshold(struct net_device
*dev
,
1734 struct iw_request_info
*info
,
1735 union iwreq_data
*wrqu
, char *extra
)
1737 u16 threshold
; /* size checked: it is u16 */
1738 struct wl3501_card
*this = netdev_priv(dev
);
1739 int rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAG_THRESHOLD
,
1740 &threshold
, sizeof(threshold
));
1742 wrqu
->frag
.value
= threshold
;
1743 wrqu
->frag
.disabled
= threshold
>= 2346;
1744 wrqu
->frag
.fixed
= 1;
1749 static int wl3501_get_txpow(struct net_device
*dev
,
1750 struct iw_request_info
*info
,
1751 union iwreq_data
*wrqu
, char *extra
)
1754 struct wl3501_card
*this = netdev_priv(dev
);
1755 int rc
= wl3501_get_mib_value(this,
1756 WL3501_MIB_ATTR_CURRENT_TX_PWR_LEVEL
,
1757 &txpow
, sizeof(txpow
));
1759 wrqu
->txpower
.value
= txpow
;
1760 wrqu
->txpower
.disabled
= 0;
1762 * From the MIB values I think this can be configurable,
1763 * as it lists several tx power levels -acme
1765 wrqu
->txpower
.fixed
= 0;
1766 wrqu
->txpower
.flags
= IW_TXPOW_MWATT
;
1771 static int wl3501_get_retry(struct net_device
*dev
,
1772 struct iw_request_info
*info
,
1773 union iwreq_data
*wrqu
, char *extra
)
1775 u8 retry
; /* size checked: it is u8 */
1776 struct wl3501_card
*this = netdev_priv(dev
);
1777 int rc
= wl3501_get_mib_value(this,
1778 WL3501_MIB_ATTR_LONG_RETRY_LIMIT
,
1779 &retry
, sizeof(retry
));
1782 if (wrqu
->retry
.flags
& IW_RETRY_LONG
) {
1783 wrqu
->retry
.flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1786 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT
,
1787 &retry
, sizeof(retry
));
1790 wrqu
->retry
.flags
= IW_RETRY_LIMIT
| IW_RETRY_SHORT
;
1792 wrqu
->retry
.value
= retry
;
1793 wrqu
->retry
.disabled
= 0;
1798 static int wl3501_get_encode(struct net_device
*dev
,
1799 struct iw_request_info
*info
,
1800 union iwreq_data
*wrqu
, char *extra
)
1802 u8 implemented
, restricted
, keys
[100], len_keys
, tocopy
;
1803 struct wl3501_card
*this = netdev_priv(dev
);
1804 int rc
= wl3501_get_mib_value(this,
1805 WL3501_MIB_ATTR_PRIV_OPT_IMPLEMENTED
,
1806 &implemented
, sizeof(implemented
));
1810 wrqu
->encoding
.flags
= IW_ENCODE_DISABLED
;
1813 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_EXCLUDE_UNENCRYPTED
,
1814 &restricted
, sizeof(restricted
));
1817 wrqu
->encoding
.flags
= restricted
? IW_ENCODE_RESTRICTED
:
1819 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS_LEN
,
1820 &len_keys
, sizeof(len_keys
));
1823 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS
,
1827 tocopy
= min_t(u8
, len_keys
, wrqu
->encoding
.length
);
1828 tocopy
= min_t(u8
, tocopy
, 100);
1829 wrqu
->encoding
.length
= tocopy
;
1830 memcpy(extra
, keys
, tocopy
);
1835 static int wl3501_get_power(struct net_device
*dev
,
1836 struct iw_request_info
*info
,
1837 union iwreq_data
*wrqu
, char *extra
)
1840 struct wl3501_card
*this = netdev_priv(dev
);
1841 int rc
= wl3501_get_mib_value(this,
1842 WL3501_MIB_ATTR_CURRENT_PWR_STATE
,
1843 &pwr_state
, sizeof(pwr_state
));
1846 wrqu
->power
.disabled
= !pwr_state
;
1847 wrqu
->power
.flags
= IW_POWER_ON
;
1852 static const iw_handler wl3501_handler
[] = {
1853 [SIOCGIWNAME
- SIOCIWFIRST
] = wl3501_get_name
,
1854 [SIOCSIWFREQ
- SIOCIWFIRST
] = wl3501_set_freq
,
1855 [SIOCGIWFREQ
- SIOCIWFIRST
] = wl3501_get_freq
,
1856 [SIOCSIWMODE
- SIOCIWFIRST
] = wl3501_set_mode
,
1857 [SIOCGIWMODE
- SIOCIWFIRST
] = wl3501_get_mode
,
1858 [SIOCGIWSENS
- SIOCIWFIRST
] = wl3501_get_sens
,
1859 [SIOCGIWRANGE
- SIOCIWFIRST
] = wl3501_get_range
,
1860 [SIOCSIWSPY
- SIOCIWFIRST
] = iw_handler_set_spy
,
1861 [SIOCGIWSPY
- SIOCIWFIRST
] = iw_handler_get_spy
,
1862 [SIOCSIWTHRSPY
- SIOCIWFIRST
] = iw_handler_set_thrspy
,
1863 [SIOCGIWTHRSPY
- SIOCIWFIRST
] = iw_handler_get_thrspy
,
1864 [SIOCSIWAP
- SIOCIWFIRST
] = wl3501_set_wap
,
1865 [SIOCGIWAP
- SIOCIWFIRST
] = wl3501_get_wap
,
1866 [SIOCSIWSCAN
- SIOCIWFIRST
] = wl3501_set_scan
,
1867 [SIOCGIWSCAN
- SIOCIWFIRST
] = wl3501_get_scan
,
1868 [SIOCSIWESSID
- SIOCIWFIRST
] = wl3501_set_essid
,
1869 [SIOCGIWESSID
- SIOCIWFIRST
] = wl3501_get_essid
,
1870 [SIOCSIWNICKN
- SIOCIWFIRST
] = wl3501_set_nick
,
1871 [SIOCGIWNICKN
- SIOCIWFIRST
] = wl3501_get_nick
,
1872 [SIOCGIWRATE
- SIOCIWFIRST
] = wl3501_get_rate
,
1873 [SIOCGIWRTS
- SIOCIWFIRST
] = wl3501_get_rts_threshold
,
1874 [SIOCGIWFRAG
- SIOCIWFIRST
] = wl3501_get_frag_threshold
,
1875 [SIOCGIWTXPOW
- SIOCIWFIRST
] = wl3501_get_txpow
,
1876 [SIOCGIWRETRY
- SIOCIWFIRST
] = wl3501_get_retry
,
1877 [SIOCGIWENCODE
- SIOCIWFIRST
] = wl3501_get_encode
,
1878 [SIOCGIWPOWER
- SIOCIWFIRST
] = wl3501_get_power
,
1881 static const struct iw_handler_def wl3501_handler_def
= {
1882 .num_standard
= ARRAY_SIZE(wl3501_handler
),
1883 .standard
= (iw_handler
*)wl3501_handler
,
1884 .get_wireless_stats
= wl3501_get_wireless_stats
,
1887 static const struct net_device_ops wl3501_netdev_ops
= {
1888 .ndo_open
= wl3501_open
,
1889 .ndo_stop
= wl3501_close
,
1890 .ndo_start_xmit
= wl3501_hard_start_xmit
,
1891 .ndo_tx_timeout
= wl3501_tx_timeout
,
1892 .ndo_change_mtu
= eth_change_mtu
,
1893 .ndo_set_mac_address
= eth_mac_addr
,
1894 .ndo_validate_addr
= eth_validate_addr
,
1898 * wl3501_attach - creates an "instance" of the driver
1900 * Creates an "instance" of the driver, allocating local data structures for
1901 * one device. The device is registered with Card Services.
1903 * The dev_link structure is initialized, but we don't actually configure the
1904 * card at this point -- we wait until we receive a card insertion event.
1906 static int wl3501_probe(struct pcmcia_device
*p_dev
)
1908 struct net_device
*dev
;
1909 struct wl3501_card
*this;
1911 /* The io structure describes IO port mapping */
1912 p_dev
->io
.NumPorts1
= 16;
1913 p_dev
->io
.Attributes1
= IO_DATA_PATH_WIDTH_8
;
1914 p_dev
->io
.IOAddrLines
= 5;
1916 /* Interrupt setup */
1917 p_dev
->irq
.Attributes
= IRQ_TYPE_DYNAMIC_SHARING
| IRQ_HANDLE_PRESENT
;
1918 p_dev
->irq
.IRQInfo1
= IRQ_LEVEL_ID
;
1919 p_dev
->irq
.Handler
= wl3501_interrupt
;
1921 /* General socket configuration */
1922 p_dev
->conf
.Attributes
= CONF_ENABLE_IRQ
;
1923 p_dev
->conf
.IntType
= INT_MEMORY_AND_IO
;
1924 p_dev
->conf
.ConfigIndex
= 1;
1926 dev
= alloc_etherdev(sizeof(struct wl3501_card
));
1931 dev
->netdev_ops
= &wl3501_netdev_ops
;
1932 dev
->watchdog_timeo
= 5 * HZ
;
1934 this = netdev_priv(dev
);
1935 this->wireless_data
.spy_data
= &this->spy_data
;
1936 this->p_dev
= p_dev
;
1937 dev
->wireless_data
= &this->wireless_data
;
1938 dev
->wireless_handlers
= &wl3501_handler_def
;
1939 SET_ETHTOOL_OPS(dev
, &ops
);
1940 netif_stop_queue(dev
);
1941 p_dev
->priv
= p_dev
->irq
.Instance
= dev
;
1943 return wl3501_config(p_dev
);
1948 #define CS_CHECK(fn, ret) \
1949 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
1952 * wl3501_config - configure the PCMCIA socket and make eth device available
1955 * wl3501_config() is scheduled to run after a CARD_INSERTION event is
1956 * received, to configure the PCMCIA socket, and to make the ethernet device
1957 * available to the system.
1959 static int wl3501_config(struct pcmcia_device
*link
)
1961 struct net_device
*dev
= link
->priv
;
1962 int i
= 0, j
, last_fn
, last_ret
;
1963 struct wl3501_card
*this;
1965 /* Try allocating IO ports. This tries a few fixed addresses. If you
1966 * want, you can also read the card's config table to pick addresses --
1967 * see the serial driver for an example. */
1969 for (j
= 0x280; j
< 0x400; j
+= 0x20) {
1970 /* The '^0x300' is so that we probe 0x300-0x3ff first, then
1971 * 0x200-0x2ff, and so on, because this seems safer */
1972 link
->io
.BasePort1
= j
;
1973 link
->io
.BasePort2
= link
->io
.BasePort1
+ 0x10;
1974 i
= pcmcia_request_io(link
, &link
->io
);
1979 cs_error(link
, RequestIO
, i
);
1983 /* Now allocate an interrupt line. Note that this does not actually
1984 * assign a handler to the interrupt. */
1986 CS_CHECK(RequestIRQ
, pcmcia_request_irq(link
, &link
->irq
));
1988 /* This actually configures the PCMCIA socket -- setting up the I/O
1989 * windows and the interrupt mapping. */
1991 CS_CHECK(RequestConfiguration
, pcmcia_request_configuration(link
, &link
->conf
));
1993 dev
->irq
= link
->irq
.AssignedIRQ
;
1994 dev
->base_addr
= link
->io
.BasePort1
;
1995 SET_NETDEV_DEV(dev
, &handle_to_dev(link
));
1996 if (register_netdev(dev
)) {
1997 printk(KERN_NOTICE
"wl3501_cs: register_netdev() failed\n");
2001 this = netdev_priv(dev
);
2003 * At this point, the dev_node_t structure(s) should be initialized and
2004 * arranged in a linked list at link->dev_node.
2006 link
->dev_node
= &this->node
;
2008 this->base_addr
= dev
->base_addr
;
2010 if (!wl3501_get_flash_mac_addr(this)) {
2011 printk(KERN_WARNING
"%s: Cant read MAC addr in flash ROM?\n",
2015 strcpy(this->node
.dev_name
, dev
->name
);
2017 for (i
= 0; i
< 6; i
++)
2018 dev
->dev_addr
[i
] = ((char *)&this->mac_addr
)[i
];
2020 /* print probe information */
2021 printk(KERN_INFO
"%s: wl3501 @ 0x%3.3x, IRQ %d, "
2022 "MAC addr in flash ROM:%pM\n",
2023 dev
->name
, this->base_addr
, (int)dev
->irq
,
2026 * Initialize card parameters - added by jss
2028 this->net_type
= IW_MODE_INFRA
;
2030 this->join_sta_bss
= 0;
2031 this->adhoc_times
= 0;
2032 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID
, &this->essid
.el
,
2034 this->card_name
[0] = '\0';
2035 this->firmware_date
[0] = '\0';
2037 this->chan
= iw_default_channel(this->reg_domain
);
2038 strlcpy(this->nick
, "Planet WL3501", sizeof(this->nick
));
2039 spin_lock_init(&this->lock
);
2040 init_waitqueue_head(&this->wait
);
2041 netif_start_queue(dev
);
2045 cs_error(link
, last_fn
, last_ret
);
2047 wl3501_release(link
);
2052 * wl3501_release - unregister the net, release PCMCIA configuration
2055 * After a card is removed, wl3501_release() will unregister the net device,
2056 * and release the PCMCIA configuration. If the device is still open, this
2057 * will be postponed until it is closed.
2059 static void wl3501_release(struct pcmcia_device
*link
)
2061 struct net_device
*dev
= link
->priv
;
2063 /* Unlink the device chain */
2065 unregister_netdev(dev
);
2067 pcmcia_disable_device(link
);
2070 static int wl3501_suspend(struct pcmcia_device
*link
)
2072 struct net_device
*dev
= link
->priv
;
2074 wl3501_pwr_mgmt(netdev_priv(dev
), WL3501_SUSPEND
);
2076 netif_device_detach(dev
);
2081 static int wl3501_resume(struct pcmcia_device
*link
)
2083 struct net_device
*dev
= link
->priv
;
2085 wl3501_pwr_mgmt(netdev_priv(dev
), WL3501_RESUME
);
2088 netif_device_attach(dev
);
2095 static struct pcmcia_device_id wl3501_ids
[] = {
2096 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2099 MODULE_DEVICE_TABLE(pcmcia
, wl3501_ids
);
2101 static struct pcmcia_driver wl3501_driver
= {
2102 .owner
= THIS_MODULE
,
2104 .name
= "wl3501_cs",
2106 .probe
= wl3501_probe
,
2107 .remove
= wl3501_detach
,
2108 .id_table
= wl3501_ids
,
2109 .suspend
= wl3501_suspend
,
2110 .resume
= wl3501_resume
,
2113 static int __init
wl3501_init_module(void)
2115 return pcmcia_register_driver(&wl3501_driver
);
2118 static void __exit
wl3501_exit_module(void)
2120 pcmcia_unregister_driver(&wl3501_driver
);
2123 module_init(wl3501_init_module
);
2124 module_exit(wl3501_exit_module
);
2126 MODULE_AUTHOR("Fox Chen <mhchen@golf.ccl.itri.org.tw>, "
2127 "Arnaldo Carvalho de Melo <acme@conectiva.com.br>,"
2128 "Gustavo Niemeyer <niemeyer@conectiva.com>");
2129 MODULE_DESCRIPTION("Planet wl3501 wireless driver");
2130 MODULE_LICENSE("GPL");