1 /* main.c - (formerly known as dldwd_cs.c, orinoco_cs.c and orinoco.c)
3 * A driver for Hermes or Prism 2 chipset based PCMCIA wireless
4 * adaptors, with Lucent/Agere, Intersil or Symbol firmware.
6 * Current maintainers (as of 29 September 2003) are:
7 * Pavel Roskin <proski AT gnu.org>
8 * and David Gibson <hermes AT gibson.dropbear.id.au>
10 * (C) Copyright David Gibson, IBM Corporation 2001-2003.
11 * Copyright (C) 2000 David Gibson, Linuxcare Australia.
12 * With some help from :
13 * Copyright (C) 2001 Jean Tourrilhes, HP Labs
14 * Copyright (C) 2001 Benjamin Herrenschmidt
16 * Based on dummy_cs.c 1.27 2000/06/12 21:27:25
18 * Portions based on wvlan_cs.c 1.0.6, Copyright Andreas Neuhaus <andy
19 * AT fasta.fh-dortmund.de>
20 * http://www.stud.fh-dortmund.de/~andy/wvlan/
22 * The contents of this file are subject to the Mozilla Public License
23 * Version 1.1 (the "License"); you may not use this file except in
24 * compliance with the License. You may obtain a copy of the License
25 * at http://www.mozilla.org/MPL/
27 * Software distributed under the License is distributed on an "AS IS"
28 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
29 * the License for the specific language governing rights and
30 * limitations under the License.
32 * The initial developer of the original code is David A. Hinds
33 * <dahinds AT users.sourceforge.net>. Portions created by David
34 * A. Hinds are Copyright (C) 1999 David A. Hinds. All Rights
37 * Alternatively, the contents of this file may be used under the
38 * terms of the GNU General Public License version 2 (the "GPL"), in
39 * which case the provisions of the GPL are applicable instead of the
40 * above. If you wish to allow the use of your version of this file
41 * only under the terms of the GPL and not to allow others to use your
42 * version of this file under the MPL, indicate your decision by
43 * deleting the provisions above and replace them with the notice and
44 * other provisions required by the GPL. If you do not delete the
45 * provisions above, a recipient may use your version of this file
46 * under either the MPL or the GPL. */
50 * o Handle de-encapsulation within network layer, provide 802.11
51 * headers (patch from Thomas 'Dent' Mirlacher)
52 * o Fix possible races in SPY handling.
53 * o Disconnect wireless extensions from fundamental configuration.
54 * o (maybe) Software WEP support (patch from Stano Meduna).
55 * o (maybe) Use multiple Tx buffers - driver handling queue
56 * rather than firmware.
59 /* Locking and synchronization:
61 * The basic principle is that everything is serialized through a
62 * single spinlock, priv->lock. The lock is used in user, bh and irq
63 * context, so when taken outside hardirq context it should always be
64 * taken with interrupts disabled. The lock protects both the
65 * hardware and the struct orinoco_private.
67 * Another flag, priv->hw_unavailable indicates that the hardware is
68 * unavailable for an extended period of time (e.g. suspended, or in
69 * the middle of a hard reset). This flag is protected by the
70 * spinlock. All code which touches the hardware should check the
71 * flag after taking the lock, and if it is set, give up on whatever
72 * they are doing and drop the lock again. The orinoco_lock()
73 * function handles this (it unlocks and returns -EBUSY if
74 * hw_unavailable is non-zero).
77 #define DRIVER_NAME "orinoco"
79 #include <linux/module.h>
80 #include <linux/kernel.h>
81 #include <linux/slab.h>
82 #include <linux/init.h>
83 #include <linux/delay.h>
84 #include <linux/device.h>
85 #include <linux/netdevice.h>
86 #include <linux/etherdevice.h>
87 #include <linux/suspend.h>
88 #include <linux/if_arp.h>
89 #include <linux/wireless.h>
90 #include <linux/ieee80211.h>
91 #include <net/iw_handler.h>
92 #include <net/cfg80211.h>
94 #include "hermes_rid.h"
95 #include "hermes_dld.h"
106 /********************************************************************/
107 /* Module information */
108 /********************************************************************/
110 MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> & "
111 "David Gibson <hermes@gibson.dropbear.id.au>");
112 MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based "
113 "and similar wireless cards");
114 MODULE_LICENSE("Dual MPL/GPL");
116 /* Level of debugging. Used in the macros in orinoco.h */
118 int orinoco_debug
= ORINOCO_DEBUG
;
119 EXPORT_SYMBOL(orinoco_debug
);
120 module_param(orinoco_debug
, int, 0644);
121 MODULE_PARM_DESC(orinoco_debug
, "Debug level");
124 static bool suppress_linkstatus
; /* = 0 */
125 module_param(suppress_linkstatus
, bool, 0644);
126 MODULE_PARM_DESC(suppress_linkstatus
, "Don't log link status changes");
128 static int ignore_disconnect
; /* = 0 */
129 module_param(ignore_disconnect
, int, 0644);
130 MODULE_PARM_DESC(ignore_disconnect
,
131 "Don't report lost link to the network layer");
133 int force_monitor
; /* = 0 */
134 module_param(force_monitor
, int, 0644);
135 MODULE_PARM_DESC(force_monitor
, "Allow monitor mode for all firmware versions");
137 /********************************************************************/
138 /* Internal constants */
139 /********************************************************************/
141 /* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
142 static const u8 encaps_hdr
[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
143 #define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
145 #define ORINOCO_MIN_MTU 256
146 #define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD)
148 #define MAX_IRQLOOPS_PER_IRQ 10
149 #define MAX_IRQLOOPS_PER_JIFFY (20000 / HZ) /* Based on a guestimate of
150 * how many events the
152 * legitimately generate */
154 #define DUMMY_FID 0xFFFF
156 /*#define MAX_MULTICAST(priv) (priv->firmware_type == FIRMWARE_TYPE_AGERE ? \
157 HERMES_MAX_MULTICAST : 0)*/
158 #define MAX_MULTICAST(priv) (HERMES_MAX_MULTICAST)
160 #define ORINOCO_INTEN (HERMES_EV_RX | HERMES_EV_ALLOC \
161 | HERMES_EV_TX | HERMES_EV_TXEXC \
162 | HERMES_EV_WTERR | HERMES_EV_INFO \
165 /********************************************************************/
167 /********************************************************************/
169 /* Beginning of the Tx descriptor, used in TxExc handling */
170 struct hermes_txexc_data
{
171 struct hermes_tx_descriptor desc
;
177 /* Rx frame header except compatibility 802.3 header */
178 struct hermes_rx_descriptor
{
201 struct orinoco_rx_data
{
202 struct hermes_rx_descriptor
*desc
;
204 struct list_head list
;
207 struct orinoco_scan_data
{
211 struct list_head list
;
214 /********************************************************************/
215 /* Function prototypes */
216 /********************************************************************/
218 static int __orinoco_set_multicast_list(struct net_device
*dev
);
219 static int __orinoco_up(struct orinoco_private
*priv
);
220 static int __orinoco_down(struct orinoco_private
*priv
);
221 static int __orinoco_commit(struct orinoco_private
*priv
);
223 /********************************************************************/
224 /* Internal helper functions */
225 /********************************************************************/
227 void set_port_type(struct orinoco_private
*priv
)
229 switch (priv
->iw_mode
) {
230 case NL80211_IFTYPE_STATION
:
232 priv
->createibss
= 0;
234 case NL80211_IFTYPE_ADHOC
:
235 if (priv
->prefer_port3
) {
237 priv
->createibss
= 0;
239 priv
->port_type
= priv
->ibss_port
;
240 priv
->createibss
= 1;
243 case NL80211_IFTYPE_MONITOR
:
245 priv
->createibss
= 0;
248 printk(KERN_ERR
"%s: Invalid priv->iw_mode in set_port_type()\n",
253 /********************************************************************/
255 /********************************************************************/
257 int orinoco_open(struct net_device
*dev
)
259 struct orinoco_private
*priv
= ndev_priv(dev
);
263 if (orinoco_lock(priv
, &flags
) != 0)
266 err
= __orinoco_up(priv
);
271 orinoco_unlock(priv
, &flags
);
275 EXPORT_SYMBOL(orinoco_open
);
277 int orinoco_stop(struct net_device
*dev
)
279 struct orinoco_private
*priv
= ndev_priv(dev
);
282 /* We mustn't use orinoco_lock() here, because we need to be
283 able to close the interface even if hw_unavailable is set
284 (e.g. as we're released after a PC Card removal) */
285 orinoco_lock_irq(priv
);
289 err
= __orinoco_down(priv
);
291 orinoco_unlock_irq(priv
);
295 EXPORT_SYMBOL(orinoco_stop
);
297 void orinoco_set_multicast_list(struct net_device
*dev
)
299 struct orinoco_private
*priv
= ndev_priv(dev
);
302 if (orinoco_lock(priv
, &flags
) != 0) {
303 printk(KERN_DEBUG
"%s: orinoco_set_multicast_list() "
304 "called when hw_unavailable\n", dev
->name
);
308 __orinoco_set_multicast_list(dev
);
309 orinoco_unlock(priv
, &flags
);
311 EXPORT_SYMBOL(orinoco_set_multicast_list
);
313 int orinoco_change_mtu(struct net_device
*dev
, int new_mtu
)
315 struct orinoco_private
*priv
= ndev_priv(dev
);
317 /* MTU + encapsulation + header length */
318 if ((new_mtu
+ ENCAPS_OVERHEAD
+ sizeof(struct ieee80211_hdr
)) >
319 (priv
->nicbuf_size
- ETH_HLEN
))
326 EXPORT_SYMBOL(orinoco_change_mtu
);
328 /********************************************************************/
330 /********************************************************************/
332 /* Add encapsulation and MIC to the existing SKB.
333 * The main xmit routine will then send the whole lot to the card.
334 * Need 8 bytes headroom
335 * Need 8 bytes tailroom
337 * With encapsulated ethernet II frame
339 * 803.3 header (14 bytes)
342 * 803.3 header (14 bytes) len[2]
343 * dst[6] 803.2 header (8 bytes)
345 * len[2] <- leave alone -> len[2]
346 * -------- -------- <-- 0
354 * returns 0 on success, -ENOMEM on error.
356 int orinoco_process_xmit_skb(struct sk_buff
*skb
,
357 struct net_device
*dev
,
358 struct orinoco_private
*priv
,
362 struct orinoco_tkip_key
*key
;
366 key
= (struct orinoco_tkip_key
*) priv
->keys
[priv
->tx_key
].key
;
368 do_mic
= ((priv
->encode_alg
== ORINOCO_ALG_TKIP
) &&
372 *tx_control
|= (priv
->tx_key
<< HERMES_MIC_KEY_ID_SHIFT
) |
375 eh
= (struct ethhdr
*)skb
->data
;
377 /* Encapsulate Ethernet-II frames */
378 if (ntohs(eh
->h_proto
) > ETH_DATA_LEN
) { /* Ethernet-II frame */
379 struct header_struct
{
380 struct ethhdr eth
; /* 802.3 header */
381 u8 encap
[6]; /* 802.2 header */
383 int len
= skb
->len
+ sizeof(encaps_hdr
) - (2 * ETH_ALEN
);
385 if (skb_headroom(skb
) < ENCAPS_OVERHEAD
) {
388 "%s: Not enough headroom for 802.2 headers %d\n",
389 dev
->name
, skb_headroom(skb
));
393 /* Fill in new header */
394 memcpy(&hdr
.eth
, eh
, 2 * ETH_ALEN
);
395 hdr
.eth
.h_proto
= htons(len
);
396 memcpy(hdr
.encap
, encaps_hdr
, sizeof(encaps_hdr
));
398 /* Make room for the new header, and copy it in */
399 eh
= skb_push(skb
, ENCAPS_OVERHEAD
);
400 memcpy(eh
, &hdr
, sizeof(hdr
));
403 /* Calculate Michael MIC */
405 size_t len
= skb
->len
- ETH_HLEN
;
406 u8
*mic
= &mic_buf
[0];
408 /* Have to write to an even address, so copy the spare
411 *mic
= skb
->data
[skb
->len
- 1];
415 orinoco_mic(priv
->tx_tfm_mic
, key
->tx_mic
,
416 eh
->h_dest
, eh
->h_source
, 0 /* priority */,
417 skb
->data
+ ETH_HLEN
,
423 EXPORT_SYMBOL(orinoco_process_xmit_skb
);
425 static netdev_tx_t
orinoco_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
427 struct orinoco_private
*priv
= ndev_priv(dev
);
428 struct net_device_stats
*stats
= &dev
->stats
;
429 struct hermes
*hw
= &priv
->hw
;
431 u16 txfid
= priv
->txfid
;
434 u8 mic_buf
[MICHAEL_MIC_LEN
+ 1];
436 if (!netif_running(dev
)) {
437 printk(KERN_ERR
"%s: Tx on stopped device!\n",
439 return NETDEV_TX_BUSY
;
442 if (netif_queue_stopped(dev
)) {
443 printk(KERN_DEBUG
"%s: Tx while transmitter busy!\n",
445 return NETDEV_TX_BUSY
;
448 if (orinoco_lock(priv
, &flags
) != 0) {
449 printk(KERN_ERR
"%s: orinoco_xmit() called while hw_unavailable\n",
451 return NETDEV_TX_BUSY
;
454 if (!netif_carrier_ok(dev
) ||
455 (priv
->iw_mode
== NL80211_IFTYPE_MONITOR
)) {
456 /* Oops, the firmware hasn't established a connection,
457 silently drop the packet (this seems to be the
462 /* Check packet length */
463 if (skb
->len
< ETH_HLEN
)
466 tx_control
= HERMES_TXCTRL_TX_OK
| HERMES_TXCTRL_TX_EX
;
468 err
= orinoco_process_xmit_skb(skb
, dev
, priv
, &tx_control
,
473 if (priv
->has_alt_txcntl
) {
474 /* WPA enabled firmwares have tx_cntl at the end of
475 * the 802.11 header. So write zeroed descriptor and
476 * 802.11 header at the same time
478 char desc
[HERMES_802_3_OFFSET
];
479 __le16
*txcntl
= (__le16
*) &desc
[HERMES_TXCNTL2_OFFSET
];
481 memset(&desc
, 0, sizeof(desc
));
483 *txcntl
= cpu_to_le16(tx_control
);
484 err
= hw
->ops
->bap_pwrite(hw
, USER_BAP
, &desc
, sizeof(desc
),
488 printk(KERN_ERR
"%s: Error %d writing Tx "
489 "descriptor to BAP\n", dev
->name
, err
);
493 struct hermes_tx_descriptor desc
;
495 memset(&desc
, 0, sizeof(desc
));
497 desc
.tx_control
= cpu_to_le16(tx_control
);
498 err
= hw
->ops
->bap_pwrite(hw
, USER_BAP
, &desc
, sizeof(desc
),
502 printk(KERN_ERR
"%s: Error %d writing Tx "
503 "descriptor to BAP\n", dev
->name
, err
);
507 /* Clear the 802.11 header and data length fields - some
508 * firmwares (e.g. Lucent/Agere 8.xx) appear to get confused
509 * if this isn't done. */
510 hermes_clear_words(hw
, HERMES_DATA0
,
511 HERMES_802_3_OFFSET
- HERMES_802_11_OFFSET
);
514 err
= hw
->ops
->bap_pwrite(hw
, USER_BAP
, skb
->data
, skb
->len
,
515 txfid
, HERMES_802_3_OFFSET
);
517 printk(KERN_ERR
"%s: Error %d writing packet to BAP\n",
522 if (tx_control
& HERMES_TXCTRL_MIC
) {
523 size_t offset
= HERMES_802_3_OFFSET
+ skb
->len
;
524 size_t len
= MICHAEL_MIC_LEN
;
530 err
= hw
->ops
->bap_pwrite(hw
, USER_BAP
, &mic_buf
[0], len
,
533 printk(KERN_ERR
"%s: Error %d writing MIC to BAP\n",
539 /* Finally, we actually initiate the send */
540 netif_stop_queue(dev
);
542 err
= hw
->ops
->cmd_wait(hw
, HERMES_CMD_TX
| HERMES_CMD_RECL
,
545 netif_start_queue(dev
);
547 printk(KERN_ERR
"%s: Error %d transmitting packet\n",
552 stats
->tx_bytes
+= HERMES_802_3_OFFSET
+ skb
->len
;
560 orinoco_unlock(priv
, &flags
);
566 schedule_work(&priv
->reset_work
);
567 orinoco_unlock(priv
, &flags
);
568 return NETDEV_TX_BUSY
;
571 static void __orinoco_ev_alloc(struct net_device
*dev
, struct hermes
*hw
)
573 struct orinoco_private
*priv
= ndev_priv(dev
);
574 u16 fid
= hermes_read_regn(hw
, ALLOCFID
);
576 if (fid
!= priv
->txfid
) {
577 if (fid
!= DUMMY_FID
)
578 printk(KERN_WARNING
"%s: Allocate event on unexpected fid (%04X)\n",
583 hermes_write_regn(hw
, ALLOCFID
, DUMMY_FID
);
586 static void __orinoco_ev_tx(struct net_device
*dev
, struct hermes
*hw
)
588 dev
->stats
.tx_packets
++;
590 netif_wake_queue(dev
);
592 hermes_write_regn(hw
, TXCOMPLFID
, DUMMY_FID
);
595 static void __orinoco_ev_txexc(struct net_device
*dev
, struct hermes
*hw
)
597 struct net_device_stats
*stats
= &dev
->stats
;
598 u16 fid
= hermes_read_regn(hw
, TXCOMPLFID
);
600 struct hermes_txexc_data hdr
;
603 if (fid
== DUMMY_FID
)
604 return; /* Nothing's really happened */
606 /* Read part of the frame header - we need status and addr1 */
607 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, &hdr
,
608 sizeof(struct hermes_txexc_data
),
611 hermes_write_regn(hw
, TXCOMPLFID
, DUMMY_FID
);
615 printk(KERN_WARNING
"%s: Unable to read descriptor on Tx error "
616 "(FID=%04X error %d)\n",
617 dev
->name
, fid
, err
);
621 DEBUG(1, "%s: Tx error, err %d (FID=%04X)\n", dev
->name
,
624 /* We produce a TXDROP event only for retry or lifetime
625 * exceeded, because that's the only status that really mean
626 * that this particular node went away.
627 * Other errors means that *we* screwed up. - Jean II */
628 status
= le16_to_cpu(hdr
.desc
.status
);
629 if (status
& (HERMES_TXSTAT_RETRYERR
| HERMES_TXSTAT_AGEDERR
)) {
630 union iwreq_data wrqu
;
632 /* Copy 802.11 dest address.
633 * We use the 802.11 header because the frame may
634 * not be 802.3 or may be mangled...
635 * In Ad-Hoc mode, it will be the node address.
636 * In managed mode, it will be most likely the AP addr
637 * User space will figure out how to convert it to
638 * whatever it needs (IP address or else).
640 memcpy(wrqu
.addr
.sa_data
, hdr
.addr1
, ETH_ALEN
);
641 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
643 /* Send event to user space */
644 wireless_send_event(dev
, IWEVTXDROP
, &wrqu
, NULL
);
647 netif_wake_queue(dev
);
650 void orinoco_tx_timeout(struct net_device
*dev
)
652 struct orinoco_private
*priv
= ndev_priv(dev
);
653 struct net_device_stats
*stats
= &dev
->stats
;
654 struct hermes
*hw
= &priv
->hw
;
656 printk(KERN_WARNING
"%s: Tx timeout! "
657 "ALLOCFID=%04x, TXCOMPLFID=%04x, EVSTAT=%04x\n",
658 dev
->name
, hermes_read_regn(hw
, ALLOCFID
),
659 hermes_read_regn(hw
, TXCOMPLFID
), hermes_read_regn(hw
, EVSTAT
));
663 schedule_work(&priv
->reset_work
);
665 EXPORT_SYMBOL(orinoco_tx_timeout
);
667 /********************************************************************/
668 /* Rx path (data frames) */
669 /********************************************************************/
671 /* Does the frame have a SNAP header indicating it should be
672 * de-encapsulated to Ethernet-II? */
673 static inline int is_ethersnap(void *_hdr
)
677 /* We de-encapsulate all packets which, a) have SNAP headers
678 * (i.e. SSAP=DSAP=0xaa and CTRL=0x3 in the 802.2 LLC header
679 * and where b) the OUI of the SNAP header is 00:00:00 or
680 * 00:00:f8 - we need both because different APs appear to use
681 * different OUIs for some reason */
682 return (memcmp(hdr
, &encaps_hdr
, 5) == 0)
683 && ((hdr
[5] == 0x00) || (hdr
[5] == 0xf8));
686 static inline void orinoco_spy_gather(struct net_device
*dev
, u_char
*mac
,
687 int level
, int noise
)
689 struct iw_quality wstats
;
690 wstats
.level
= level
- 0x95;
691 wstats
.noise
= noise
- 0x95;
692 wstats
.qual
= (level
> noise
) ? (level
- noise
) : 0;
693 wstats
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
694 /* Update spy records */
695 wireless_spy_update(dev
, mac
, &wstats
);
698 static void orinoco_stat_gather(struct net_device
*dev
,
700 struct hermes_rx_descriptor
*desc
)
702 struct orinoco_private
*priv
= ndev_priv(dev
);
704 /* Using spy support with lots of Rx packets, like in an
705 * infrastructure (AP), will really slow down everything, because
706 * the MAC address must be compared to each entry of the spy list.
707 * If the user really asks for it (set some address in the
708 * spy list), we do it, but he will pay the price.
709 * Note that to get here, you need both WIRELESS_SPY
710 * compiled in AND some addresses in the list !!!
712 /* Note : gcc will optimise the whole section away if
713 * WIRELESS_SPY is not defined... - Jean II */
714 if (SPY_NUMBER(priv
)) {
715 orinoco_spy_gather(dev
, skb_mac_header(skb
) + ETH_ALEN
,
716 desc
->signal
, desc
->silence
);
721 * orinoco_rx_monitor - handle received monitor frames.
726 * desc rx descriptor of the frame
728 * Call context: interrupt
730 static void orinoco_rx_monitor(struct net_device
*dev
, u16 rxfid
,
731 struct hermes_rx_descriptor
*desc
)
733 u32 hdrlen
= 30; /* return full header by default */
739 struct orinoco_private
*priv
= ndev_priv(dev
);
740 struct net_device_stats
*stats
= &dev
->stats
;
741 struct hermes
*hw
= &priv
->hw
;
743 len
= le16_to_cpu(desc
->data_len
);
745 /* Determine the size of the header and the data */
746 fc
= le16_to_cpu(desc
->frame_ctl
);
747 switch (fc
& IEEE80211_FCTL_FTYPE
) {
748 case IEEE80211_FTYPE_DATA
:
749 if ((fc
& IEEE80211_FCTL_TODS
)
750 && (fc
& IEEE80211_FCTL_FROMDS
))
756 case IEEE80211_FTYPE_MGMT
:
760 case IEEE80211_FTYPE_CTL
:
761 switch (fc
& IEEE80211_FCTL_STYPE
) {
762 case IEEE80211_STYPE_PSPOLL
:
763 case IEEE80211_STYPE_RTS
:
764 case IEEE80211_STYPE_CFEND
:
765 case IEEE80211_STYPE_CFENDACK
:
768 case IEEE80211_STYPE_CTS
:
769 case IEEE80211_STYPE_ACK
:
775 /* Unknown frame type */
779 /* sanity check the length */
780 if (datalen
> IEEE80211_MAX_DATA_LEN
+ 12) {
781 printk(KERN_DEBUG
"%s: oversized monitor frame, "
782 "data length = %d\n", dev
->name
, datalen
);
783 stats
->rx_length_errors
++;
787 skb
= dev_alloc_skb(hdrlen
+ datalen
);
789 printk(KERN_WARNING
"%s: Cannot allocate skb for monitor frame\n",
794 /* Copy the 802.11 header to the skb */
795 skb_put_data(skb
, &(desc
->frame_ctl
), hdrlen
);
796 skb_reset_mac_header(skb
);
798 /* If any, copy the data from the card to the skb */
800 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, skb_put(skb
, datalen
),
801 ALIGN(datalen
, 2), rxfid
,
802 HERMES_802_2_OFFSET
);
804 printk(KERN_ERR
"%s: error %d reading monitor frame\n",
811 skb
->ip_summed
= CHECKSUM_NONE
;
812 skb
->pkt_type
= PACKET_OTHERHOST
;
813 skb
->protocol
= cpu_to_be16(ETH_P_802_2
);
816 stats
->rx_bytes
+= skb
->len
;
822 dev_kfree_skb_irq(skb
);
828 void __orinoco_ev_rx(struct net_device
*dev
, struct hermes
*hw
)
830 struct orinoco_private
*priv
= ndev_priv(dev
);
831 struct net_device_stats
*stats
= &dev
->stats
;
832 struct iw_statistics
*wstats
= &priv
->wstats
;
833 struct sk_buff
*skb
= NULL
;
836 struct hermes_rx_descriptor
*desc
;
837 struct orinoco_rx_data
*rx_data
;
840 desc
= kmalloc(sizeof(*desc
), GFP_ATOMIC
);
844 rxfid
= hermes_read_regn(hw
, RXFID
);
846 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, desc
, sizeof(*desc
),
849 printk(KERN_ERR
"%s: error %d reading Rx descriptor. "
850 "Frame dropped.\n", dev
->name
, err
);
854 status
= le16_to_cpu(desc
->status
);
856 if (status
& HERMES_RXSTAT_BADCRC
) {
857 DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n",
859 stats
->rx_crc_errors
++;
863 /* Handle frames in monitor mode */
864 if (priv
->iw_mode
== NL80211_IFTYPE_MONITOR
) {
865 orinoco_rx_monitor(dev
, rxfid
, desc
);
869 if (status
& HERMES_RXSTAT_UNDECRYPTABLE
) {
870 DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n",
872 wstats
->discard
.code
++;
876 length
= le16_to_cpu(desc
->data_len
);
879 if (length
< 3) { /* No for even an 802.2 LLC header */
880 /* At least on Symbol firmware with PCF we get quite a
881 lot of these legitimately - Poll frames with no
885 if (length
> IEEE80211_MAX_DATA_LEN
) {
886 printk(KERN_WARNING
"%s: Oversized frame received (%d bytes)\n",
888 stats
->rx_length_errors
++;
892 /* Payload size does not include Michael MIC. Increase payload
893 * size to read it together with the data. */
894 if (status
& HERMES_RXSTAT_MIC
)
895 length
+= MICHAEL_MIC_LEN
;
897 /* We need space for the packet data itself, plus an ethernet
898 header, plus 2 bytes so we can align the IP header on a
899 32bit boundary, plus 1 byte so we can read in odd length
900 packets from the card, which has an IO granularity of 16
902 skb
= dev_alloc_skb(length
+ ETH_HLEN
+ 2 + 1);
904 printk(KERN_WARNING
"%s: Can't allocate skb for Rx\n",
909 /* We'll prepend the header, so reserve space for it. The worst
910 case is no decapsulation, when 802.3 header is prepended and
911 nothing is removed. 2 is for aligning the IP header. */
912 skb_reserve(skb
, ETH_HLEN
+ 2);
914 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, skb_put(skb
, length
),
915 ALIGN(length
, 2), rxfid
,
916 HERMES_802_2_OFFSET
);
918 printk(KERN_ERR
"%s: error %d reading frame. "
919 "Frame dropped.\n", dev
->name
, err
);
923 /* Add desc and skb to rx queue */
924 rx_data
= kzalloc(sizeof(*rx_data
), GFP_ATOMIC
);
928 rx_data
->desc
= desc
;
930 list_add_tail(&rx_data
->list
, &priv
->rx_list
);
931 tasklet_schedule(&priv
->rx_tasklet
);
936 dev_kfree_skb_irq(skb
);
943 EXPORT_SYMBOL(__orinoco_ev_rx
);
945 static void orinoco_rx(struct net_device
*dev
,
946 struct hermes_rx_descriptor
*desc
,
949 struct orinoco_private
*priv
= ndev_priv(dev
);
950 struct net_device_stats
*stats
= &dev
->stats
;
955 status
= le16_to_cpu(desc
->status
);
956 length
= le16_to_cpu(desc
->data_len
);
957 fc
= le16_to_cpu(desc
->frame_ctl
);
959 /* Calculate and check MIC */
960 if (status
& HERMES_RXSTAT_MIC
) {
961 struct orinoco_tkip_key
*key
;
962 int key_id
= ((status
& HERMES_RXSTAT_MIC_KEY_ID
) >>
963 HERMES_MIC_KEY_ID_SHIFT
);
964 u8 mic
[MICHAEL_MIC_LEN
];
966 u8
*src
= (fc
& IEEE80211_FCTL_FROMDS
) ?
967 desc
->addr3
: desc
->addr2
;
969 /* Extract Michael MIC from payload */
970 rxmic
= skb
->data
+ skb
->len
- MICHAEL_MIC_LEN
;
972 skb_trim(skb
, skb
->len
- MICHAEL_MIC_LEN
);
973 length
-= MICHAEL_MIC_LEN
;
975 key
= (struct orinoco_tkip_key
*) priv
->keys
[key_id
].key
;
978 printk(KERN_WARNING
"%s: Received encrypted frame from "
979 "%pM using key %i, but key is not installed\n",
980 dev
->name
, src
, key_id
);
984 orinoco_mic(priv
->rx_tfm_mic
, key
->rx_mic
, desc
->addr1
, src
,
985 0, /* priority or QoS? */
986 skb
->data
, skb
->len
, &mic
[0]);
988 if (memcmp(mic
, rxmic
,
990 union iwreq_data wrqu
;
991 struct iw_michaelmicfailure wxmic
;
993 printk(KERN_WARNING
"%s: "
994 "Invalid Michael MIC in data frame from %pM, "
996 dev
->name
, src
, key_id
);
998 /* TODO: update stats */
1000 /* Notify userspace */
1001 memset(&wxmic
, 0, sizeof(wxmic
));
1002 wxmic
.flags
= key_id
& IW_MICFAILURE_KEY_ID
;
1003 wxmic
.flags
|= (desc
->addr1
[0] & 1) ?
1004 IW_MICFAILURE_GROUP
: IW_MICFAILURE_PAIRWISE
;
1005 wxmic
.src_addr
.sa_family
= ARPHRD_ETHER
;
1006 memcpy(wxmic
.src_addr
.sa_data
, src
, ETH_ALEN
);
1008 (void) orinoco_hw_get_tkip_iv(priv
, key_id
,
1011 memset(&wrqu
, 0, sizeof(wrqu
));
1012 wrqu
.data
.length
= sizeof(wxmic
);
1013 wireless_send_event(dev
, IWEVMICHAELMICFAILURE
, &wrqu
,
1020 /* Handle decapsulation
1021 * In most cases, the firmware tell us about SNAP frames.
1022 * For some reason, the SNAP frames sent by LinkSys APs
1023 * are not properly recognised by most firmwares.
1024 * So, check ourselves */
1025 if (length
>= ENCAPS_OVERHEAD
&&
1026 (((status
& HERMES_RXSTAT_MSGTYPE
) == HERMES_RXSTAT_1042
) ||
1027 ((status
& HERMES_RXSTAT_MSGTYPE
) == HERMES_RXSTAT_TUNNEL
) ||
1028 is_ethersnap(skb
->data
))) {
1029 /* These indicate a SNAP within 802.2 LLC within
1030 802.11 frame which we'll need to de-encapsulate to
1031 the original EthernetII frame. */
1032 hdr
= skb_push(skb
, ETH_HLEN
- ENCAPS_OVERHEAD
);
1034 /* 802.3 frame - prepend 802.3 header as is */
1035 hdr
= skb_push(skb
, ETH_HLEN
);
1036 hdr
->h_proto
= htons(length
);
1038 memcpy(hdr
->h_dest
, desc
->addr1
, ETH_ALEN
);
1039 if (fc
& IEEE80211_FCTL_FROMDS
)
1040 memcpy(hdr
->h_source
, desc
->addr3
, ETH_ALEN
);
1042 memcpy(hdr
->h_source
, desc
->addr2
, ETH_ALEN
);
1044 skb
->protocol
= eth_type_trans(skb
, dev
);
1045 skb
->ip_summed
= CHECKSUM_NONE
;
1046 if (fc
& IEEE80211_FCTL_TODS
)
1047 skb
->pkt_type
= PACKET_OTHERHOST
;
1049 /* Process the wireless stats if needed */
1050 orinoco_stat_gather(dev
, skb
, desc
);
1052 /* Pass the packet to the networking stack */
1054 stats
->rx_packets
++;
1055 stats
->rx_bytes
+= length
;
1062 stats
->rx_dropped
++;
1065 static void orinoco_rx_isr_tasklet(unsigned long data
)
1067 struct orinoco_private
*priv
= (struct orinoco_private
*) data
;
1068 struct net_device
*dev
= priv
->ndev
;
1069 struct orinoco_rx_data
*rx_data
, *temp
;
1070 struct hermes_rx_descriptor
*desc
;
1071 struct sk_buff
*skb
;
1072 unsigned long flags
;
1074 /* orinoco_rx requires the driver lock, and we also need to
1075 * protect priv->rx_list, so just hold the lock over the
1078 * If orinoco_lock fails, we've unplugged the card. In this
1079 * case just abort. */
1080 if (orinoco_lock(priv
, &flags
) != 0)
1083 /* extract desc and skb from queue */
1084 list_for_each_entry_safe(rx_data
, temp
, &priv
->rx_list
, list
) {
1085 desc
= rx_data
->desc
;
1087 list_del(&rx_data
->list
);
1090 orinoco_rx(dev
, desc
, skb
);
1095 orinoco_unlock(priv
, &flags
);
1098 /********************************************************************/
1099 /* Rx path (info frames) */
1100 /********************************************************************/
1102 static void print_linkstatus(struct net_device
*dev
, u16 status
)
1106 if (suppress_linkstatus
)
1110 case HERMES_LINKSTATUS_NOT_CONNECTED
:
1111 s
= "Not Connected";
1113 case HERMES_LINKSTATUS_CONNECTED
:
1116 case HERMES_LINKSTATUS_DISCONNECTED
:
1119 case HERMES_LINKSTATUS_AP_CHANGE
:
1122 case HERMES_LINKSTATUS_AP_OUT_OF_RANGE
:
1123 s
= "AP Out of Range";
1125 case HERMES_LINKSTATUS_AP_IN_RANGE
:
1128 case HERMES_LINKSTATUS_ASSOC_FAILED
:
1129 s
= "Association Failed";
1135 printk(KERN_DEBUG
"%s: New link status: %s (%04x)\n",
1136 dev
->name
, s
, status
);
1139 /* Search scan results for requested BSSID, join it if found */
1140 static void orinoco_join_ap(struct work_struct
*work
)
1142 struct orinoco_private
*priv
=
1143 container_of(work
, struct orinoco_private
, join_work
);
1144 struct net_device
*dev
= priv
->ndev
;
1145 struct hermes
*hw
= &priv
->hw
;
1147 unsigned long flags
;
1152 const int atom_len
= offsetof(struct prism2_scan_apinfo
, atim
);
1153 struct prism2_scan_apinfo
*atom
= NULL
;
1159 /* Allocate buffer for scan results */
1160 buf
= kmalloc(MAX_SCAN_LEN
, GFP_KERNEL
);
1164 if (orinoco_lock(priv
, &flags
) != 0)
1167 /* Sanity checks in case user changed something in the meantime */
1168 if (!priv
->bssid_fixed
)
1171 if (strlen(priv
->desired_essid
) == 0)
1174 /* Read scan results from the firmware */
1175 err
= hw
->ops
->read_ltv(hw
, USER_BAP
,
1176 HERMES_RID_SCANRESULTSTABLE
,
1177 MAX_SCAN_LEN
, &len
, buf
);
1179 printk(KERN_ERR
"%s: Cannot read scan results\n",
1184 len
= HERMES_RECLEN_TO_BYTES(len
);
1186 /* Go through the scan results looking for the channel of the AP
1187 * we were requested to join */
1188 for (; offset
+ atom_len
<= len
; offset
+= atom_len
) {
1189 atom
= (struct prism2_scan_apinfo
*) (buf
+ offset
);
1190 if (memcmp(&atom
->bssid
, priv
->desired_bssid
, ETH_ALEN
) == 0) {
1197 DEBUG(1, "%s: Requested AP not found in scan results\n",
1202 memcpy(req
.bssid
, priv
->desired_bssid
, ETH_ALEN
);
1203 req
.channel
= atom
->channel
; /* both are little-endian */
1204 err
= HERMES_WRITE_RECORD(hw
, USER_BAP
, HERMES_RID_CNFJOINREQUEST
,
1207 printk(KERN_ERR
"%s: Error issuing join request\n", dev
->name
);
1210 orinoco_unlock(priv
, &flags
);
1216 /* Send new BSSID to userspace */
1217 static void orinoco_send_bssid_wevent(struct orinoco_private
*priv
)
1219 struct net_device
*dev
= priv
->ndev
;
1220 struct hermes
*hw
= &priv
->hw
;
1221 union iwreq_data wrqu
;
1224 err
= hw
->ops
->read_ltv(hw
, USER_BAP
, HERMES_RID_CURRENTBSSID
,
1225 ETH_ALEN
, NULL
, wrqu
.ap_addr
.sa_data
);
1229 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1231 /* Send event to user space */
1232 wireless_send_event(dev
, SIOCGIWAP
, &wrqu
, NULL
);
1235 static void orinoco_send_assocreqie_wevent(struct orinoco_private
*priv
)
1237 struct net_device
*dev
= priv
->ndev
;
1238 struct hermes
*hw
= &priv
->hw
;
1239 union iwreq_data wrqu
;
1247 err
= hw
->ops
->read_ltv(hw
, USER_BAP
, HERMES_RID_CURRENT_ASSOC_REQ_INFO
,
1248 sizeof(buf
), NULL
, &buf
);
1252 ie
= orinoco_get_wpa_ie(buf
, sizeof(buf
));
1254 int rem
= sizeof(buf
) - (ie
- &buf
[0]);
1255 wrqu
.data
.length
= ie
[1] + 2;
1256 if (wrqu
.data
.length
> rem
)
1257 wrqu
.data
.length
= rem
;
1259 if (wrqu
.data
.length
)
1260 /* Send event to user space */
1261 wireless_send_event(dev
, IWEVASSOCREQIE
, &wrqu
, ie
);
1265 static void orinoco_send_assocrespie_wevent(struct orinoco_private
*priv
)
1267 struct net_device
*dev
= priv
->ndev
;
1268 struct hermes
*hw
= &priv
->hw
;
1269 union iwreq_data wrqu
;
1271 u8 buf
[88]; /* TODO: verify max size or IW_GENERIC_IE_MAX */
1277 err
= hw
->ops
->read_ltv(hw
, USER_BAP
,
1278 HERMES_RID_CURRENT_ASSOC_RESP_INFO
,
1279 sizeof(buf
), NULL
, &buf
);
1283 ie
= orinoco_get_wpa_ie(buf
, sizeof(buf
));
1285 int rem
= sizeof(buf
) - (ie
- &buf
[0]);
1286 wrqu
.data
.length
= ie
[1] + 2;
1287 if (wrqu
.data
.length
> rem
)
1288 wrqu
.data
.length
= rem
;
1290 if (wrqu
.data
.length
)
1291 /* Send event to user space */
1292 wireless_send_event(dev
, IWEVASSOCRESPIE
, &wrqu
, ie
);
1296 static void orinoco_send_wevents(struct work_struct
*work
)
1298 struct orinoco_private
*priv
=
1299 container_of(work
, struct orinoco_private
, wevent_work
);
1300 unsigned long flags
;
1302 if (orinoco_lock(priv
, &flags
) != 0)
1305 orinoco_send_assocreqie_wevent(priv
);
1306 orinoco_send_assocrespie_wevent(priv
);
1307 orinoco_send_bssid_wevent(priv
);
1309 orinoco_unlock(priv
, &flags
);
1312 static void qbuf_scan(struct orinoco_private
*priv
, void *buf
,
1315 struct orinoco_scan_data
*sd
;
1316 unsigned long flags
;
1318 sd
= kmalloc(sizeof(*sd
), GFP_ATOMIC
);
1326 spin_lock_irqsave(&priv
->scan_lock
, flags
);
1327 list_add_tail(&sd
->list
, &priv
->scan_list
);
1328 spin_unlock_irqrestore(&priv
->scan_lock
, flags
);
1330 schedule_work(&priv
->process_scan
);
1333 static void qabort_scan(struct orinoco_private
*priv
)
1335 struct orinoco_scan_data
*sd
;
1336 unsigned long flags
;
1338 sd
= kmalloc(sizeof(*sd
), GFP_ATOMIC
);
1342 sd
->len
= -1; /* Abort */
1344 spin_lock_irqsave(&priv
->scan_lock
, flags
);
1345 list_add_tail(&sd
->list
, &priv
->scan_list
);
1346 spin_unlock_irqrestore(&priv
->scan_lock
, flags
);
1348 schedule_work(&priv
->process_scan
);
1351 static void orinoco_process_scan_results(struct work_struct
*work
)
1353 struct orinoco_private
*priv
=
1354 container_of(work
, struct orinoco_private
, process_scan
);
1355 struct orinoco_scan_data
*sd
, *temp
;
1356 unsigned long flags
;
1361 spin_lock_irqsave(&priv
->scan_lock
, flags
);
1362 list_for_each_entry_safe(sd
, temp
, &priv
->scan_list
, list
) {
1368 list_del(&sd
->list
);
1369 spin_unlock_irqrestore(&priv
->scan_lock
, flags
);
1373 if (type
== HERMES_INQ_CHANNELINFO
)
1374 orinoco_add_extscan_result(priv
, buf
, len
);
1376 orinoco_add_hostscan_results(priv
, buf
, len
);
1380 /* Either abort or complete the scan */
1381 orinoco_scan_done(priv
, (len
< 0));
1384 spin_lock_irqsave(&priv
->scan_lock
, flags
);
1386 spin_unlock_irqrestore(&priv
->scan_lock
, flags
);
1389 void __orinoco_ev_info(struct net_device
*dev
, struct hermes
*hw
)
1391 struct orinoco_private
*priv
= ndev_priv(dev
);
1400 /* This is an answer to an INQUIRE command that we did earlier,
1401 * or an information "event" generated by the card
1402 * The controller return to us a pseudo frame containing
1403 * the information in question - Jean II */
1404 infofid
= hermes_read_regn(hw
, INFOFID
);
1406 /* Read the info frame header - don't try too hard */
1407 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, &info
, sizeof(info
),
1410 printk(KERN_ERR
"%s: error %d reading info frame. "
1411 "Frame dropped.\n", dev
->name
, err
);
1415 len
= HERMES_RECLEN_TO_BYTES(le16_to_cpu(info
.len
));
1416 type
= le16_to_cpu(info
.type
);
1419 case HERMES_INQ_TALLIES
: {
1420 struct hermes_tallies_frame tallies
;
1421 struct iw_statistics
*wstats
= &priv
->wstats
;
1423 if (len
> sizeof(tallies
)) {
1424 printk(KERN_WARNING
"%s: Tallies frame too long (%d bytes)\n",
1426 len
= sizeof(tallies
);
1429 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, &tallies
, len
,
1430 infofid
, sizeof(info
));
1434 /* Increment our various counters */
1435 /* wstats->discard.nwid - no wrong BSSID stuff */
1436 wstats
->discard
.code
+=
1437 le16_to_cpu(tallies
.RxWEPUndecryptable
);
1438 if (len
== sizeof(tallies
))
1439 wstats
->discard
.code
+=
1440 le16_to_cpu(tallies
.RxDiscards_WEPICVError
) +
1441 le16_to_cpu(tallies
.RxDiscards_WEPExcluded
);
1442 wstats
->discard
.misc
+=
1443 le16_to_cpu(tallies
.TxDiscardsWrongSA
);
1444 wstats
->discard
.fragment
+=
1445 le16_to_cpu(tallies
.RxMsgInBadMsgFragments
);
1446 wstats
->discard
.retries
+=
1447 le16_to_cpu(tallies
.TxRetryLimitExceeded
);
1448 /* wstats->miss.beacon - no match */
1451 case HERMES_INQ_LINKSTATUS
: {
1452 struct hermes_linkstatus linkstatus
;
1456 if (priv
->iw_mode
== NL80211_IFTYPE_MONITOR
)
1459 if (len
!= sizeof(linkstatus
)) {
1460 printk(KERN_WARNING
"%s: Unexpected size for linkstatus frame (%d bytes)\n",
1465 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, &linkstatus
, len
,
1466 infofid
, sizeof(info
));
1469 newstatus
= le16_to_cpu(linkstatus
.linkstatus
);
1471 /* Symbol firmware uses "out of range" to signal that
1472 * the hostscan frame can be requested. */
1473 if (newstatus
== HERMES_LINKSTATUS_AP_OUT_OF_RANGE
&&
1474 priv
->firmware_type
== FIRMWARE_TYPE_SYMBOL
&&
1475 priv
->has_hostscan
&& priv
->scan_request
) {
1476 hermes_inquire(hw
, HERMES_INQ_HOSTSCAN_SYMBOL
);
1480 connected
= (newstatus
== HERMES_LINKSTATUS_CONNECTED
)
1481 || (newstatus
== HERMES_LINKSTATUS_AP_CHANGE
)
1482 || (newstatus
== HERMES_LINKSTATUS_AP_IN_RANGE
);
1485 netif_carrier_on(dev
);
1486 else if (!ignore_disconnect
)
1487 netif_carrier_off(dev
);
1489 if (newstatus
!= priv
->last_linkstatus
) {
1490 priv
->last_linkstatus
= newstatus
;
1491 print_linkstatus(dev
, newstatus
);
1492 /* The info frame contains only one word which is the
1493 * status (see hermes.h). The status is pretty boring
1494 * in itself, that's why we export the new BSSID...
1496 schedule_work(&priv
->wevent_work
);
1500 case HERMES_INQ_SCAN
:
1501 if (!priv
->scan_request
&& priv
->bssid_fixed
&&
1502 priv
->firmware_type
== FIRMWARE_TYPE_INTERSIL
) {
1503 schedule_work(&priv
->join_work
);
1507 case HERMES_INQ_HOSTSCAN
:
1508 case HERMES_INQ_HOSTSCAN_SYMBOL
: {
1509 /* Result of a scanning. Contains information about
1510 * cells in the vicinity - Jean II */
1515 printk(KERN_WARNING
"%s: Scan results too large (%d bytes)\n",
1521 /* Allocate buffer for results */
1522 buf
= kmalloc(len
, GFP_ATOMIC
);
1524 /* No memory, so can't printk()... */
1529 /* Read scan data */
1530 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, (void *) buf
, len
,
1531 infofid
, sizeof(info
));
1538 #ifdef ORINOCO_DEBUG
1541 printk(KERN_DEBUG
"Scan result [%02X", buf
[0]);
1542 for (i
= 1; i
< (len
* 2); i
++)
1543 printk(":%02X", buf
[i
]);
1546 #endif /* ORINOCO_DEBUG */
1548 qbuf_scan(priv
, buf
, len
, type
);
1551 case HERMES_INQ_CHANNELINFO
:
1553 struct agere_ext_scan_info
*bss
;
1555 if (!priv
->scan_request
) {
1556 printk(KERN_DEBUG
"%s: Got chaninfo without scan, "
1557 "len=%d\n", dev
->name
, len
);
1561 /* An empty result indicates that the scan is complete */
1563 qbuf_scan(priv
, NULL
, len
, type
);
1568 else if (len
< (offsetof(struct agere_ext_scan_info
,
1570 /* Drop this result now so we don't have to
1571 * keep checking later */
1573 "%s: Ext scan results too short (%d bytes)\n",
1578 bss
= kmalloc(len
, GFP_ATOMIC
);
1582 /* Read scan data */
1583 err
= hw
->ops
->bap_pread(hw
, IRQ_BAP
, (void *) bss
, len
,
1584 infofid
, sizeof(info
));
1588 qbuf_scan(priv
, bss
, len
, type
);
1592 case HERMES_INQ_SEC_STAT_AGERE
:
1593 /* Security status (Agere specific) */
1594 /* Ignore this frame for now */
1595 if (priv
->firmware_type
== FIRMWARE_TYPE_AGERE
)
1599 printk(KERN_DEBUG
"%s: Unknown information frame received: "
1600 "type 0x%04x, length %d\n", dev
->name
, type
, len
);
1601 /* We don't actually do anything about it */
1605 EXPORT_SYMBOL(__orinoco_ev_info
);
1607 static void __orinoco_ev_infdrop(struct net_device
*dev
, struct hermes
*hw
)
1609 if (net_ratelimit())
1610 printk(KERN_DEBUG
"%s: Information frame lost.\n", dev
->name
);
1613 /********************************************************************/
1614 /* Internal hardware control routines */
1615 /********************************************************************/
1617 static int __orinoco_up(struct orinoco_private
*priv
)
1619 struct net_device
*dev
= priv
->ndev
;
1620 struct hermes
*hw
= &priv
->hw
;
1623 netif_carrier_off(dev
); /* just to make sure */
1625 err
= __orinoco_commit(priv
);
1627 printk(KERN_ERR
"%s: Error %d configuring card\n",
1632 /* Fire things up again */
1633 hermes_set_irqmask(hw
, ORINOCO_INTEN
);
1634 err
= hermes_enable_port(hw
, 0);
1636 printk(KERN_ERR
"%s: Error %d enabling MAC port\n",
1641 netif_start_queue(dev
);
1646 static int __orinoco_down(struct orinoco_private
*priv
)
1648 struct net_device
*dev
= priv
->ndev
;
1649 struct hermes
*hw
= &priv
->hw
;
1652 netif_stop_queue(dev
);
1654 if (!priv
->hw_unavailable
) {
1655 if (!priv
->broken_disableport
) {
1656 err
= hermes_disable_port(hw
, 0);
1658 /* Some firmwares (e.g. Intersil 1.3.x) seem
1659 * to have problems disabling the port, oh
1661 printk(KERN_WARNING
"%s: Error %d disabling MAC port\n",
1663 priv
->broken_disableport
= 1;
1666 hermes_set_irqmask(hw
, 0);
1667 hermes_write_regn(hw
, EVACK
, 0xffff);
1670 orinoco_scan_done(priv
, true);
1672 /* firmware will have to reassociate */
1673 netif_carrier_off(dev
);
1674 priv
->last_linkstatus
= 0xffff;
1679 static int orinoco_reinit_firmware(struct orinoco_private
*priv
)
1681 struct hermes
*hw
= &priv
->hw
;
1684 err
= hw
->ops
->init(hw
);
1685 if (priv
->do_fw_download
&& !err
) {
1686 err
= orinoco_download(priv
);
1688 priv
->do_fw_download
= 0;
1691 err
= orinoco_hw_allocate_fid(priv
);
1697 __orinoco_set_multicast_list(struct net_device
*dev
)
1699 struct orinoco_private
*priv
= ndev_priv(dev
);
1701 int promisc
, mc_count
;
1703 /* The Hermes doesn't seem to have an allmulti mode, so we go
1704 * into promiscuous mode and let the upper levels deal. */
1705 if ((dev
->flags
& IFF_PROMISC
) || (dev
->flags
& IFF_ALLMULTI
) ||
1706 (netdev_mc_count(dev
) > MAX_MULTICAST(priv
))) {
1711 mc_count
= netdev_mc_count(dev
);
1714 err
= __orinoco_hw_set_multicast_list(priv
, dev
, mc_count
, promisc
);
1719 /* This must be called from user context, without locks held - use
1720 * schedule_work() */
1721 void orinoco_reset(struct work_struct
*work
)
1723 struct orinoco_private
*priv
=
1724 container_of(work
, struct orinoco_private
, reset_work
);
1725 struct net_device
*dev
= priv
->ndev
;
1726 struct hermes
*hw
= &priv
->hw
;
1728 unsigned long flags
;
1730 if (orinoco_lock(priv
, &flags
) != 0)
1731 /* When the hardware becomes available again, whatever
1732 * detects that is responsible for re-initializing
1733 * it. So no need for anything further */
1736 netif_stop_queue(dev
);
1738 /* Shut off interrupts. Depending on what state the hardware
1739 * is in, this might not work, but we'll try anyway */
1740 hermes_set_irqmask(hw
, 0);
1741 hermes_write_regn(hw
, EVACK
, 0xffff);
1743 priv
->hw_unavailable
++;
1744 priv
->last_linkstatus
= 0xffff; /* firmware will have to reassociate */
1745 netif_carrier_off(dev
);
1747 orinoco_unlock(priv
, &flags
);
1749 /* Scanning support: Notify scan cancellation */
1750 orinoco_scan_done(priv
, true);
1752 if (priv
->hard_reset
) {
1753 err
= (*priv
->hard_reset
)(priv
);
1755 printk(KERN_ERR
"%s: orinoco_reset: Error %d "
1756 "performing hard reset\n", dev
->name
, err
);
1761 err
= orinoco_reinit_firmware(priv
);
1763 printk(KERN_ERR
"%s: orinoco_reset: Error %d re-initializing firmware\n",
1768 /* This has to be called from user context */
1769 orinoco_lock_irq(priv
);
1771 priv
->hw_unavailable
--;
1773 /* priv->open or priv->hw_unavailable might have changed while
1774 * we dropped the lock */
1775 if (priv
->open
&& (!priv
->hw_unavailable
)) {
1776 err
= __orinoco_up(priv
);
1778 printk(KERN_ERR
"%s: orinoco_reset: Error %d reenabling card\n",
1781 netif_trans_update(dev
);
1784 orinoco_unlock_irq(priv
);
1788 hermes_set_irqmask(hw
, 0);
1789 netif_device_detach(dev
);
1790 printk(KERN_ERR
"%s: Device has been disabled!\n", dev
->name
);
1793 static int __orinoco_commit(struct orinoco_private
*priv
)
1795 struct net_device
*dev
= priv
->ndev
;
1798 /* If we've called commit, we are reconfiguring or bringing the
1799 * interface up. Maintaining countermeasures across this would
1800 * be confusing, so note that we've disabled them. The port will
1801 * be enabled later in orinoco_commit or __orinoco_up. */
1802 priv
->tkip_cm_active
= 0;
1804 err
= orinoco_hw_program_rids(priv
);
1806 /* FIXME: what about netif_tx_lock */
1807 (void) __orinoco_set_multicast_list(dev
);
1812 /* Ensures configuration changes are applied. May result in a reset.
1813 * The caller should hold priv->lock
1815 int orinoco_commit(struct orinoco_private
*priv
)
1817 struct net_device
*dev
= priv
->ndev
;
1818 struct hermes
*hw
= &priv
->hw
;
1821 if (priv
->broken_disableport
) {
1822 schedule_work(&priv
->reset_work
);
1826 err
= hermes_disable_port(hw
, 0);
1828 printk(KERN_WARNING
"%s: Unable to disable port "
1829 "while reconfiguring card\n", dev
->name
);
1830 priv
->broken_disableport
= 1;
1834 err
= __orinoco_commit(priv
);
1836 printk(KERN_WARNING
"%s: Unable to reconfigure card\n",
1841 err
= hermes_enable_port(hw
, 0);
1843 printk(KERN_WARNING
"%s: Unable to enable port while reconfiguring card\n",
1850 printk(KERN_WARNING
"%s: Resetting instead...\n", dev
->name
);
1851 schedule_work(&priv
->reset_work
);
1857 /********************************************************************/
1858 /* Interrupt handler */
1859 /********************************************************************/
1861 static void __orinoco_ev_tick(struct net_device
*dev
, struct hermes
*hw
)
1863 printk(KERN_DEBUG
"%s: TICK\n", dev
->name
);
1866 static void __orinoco_ev_wterr(struct net_device
*dev
, struct hermes
*hw
)
1868 /* This seems to happen a fair bit under load, but ignoring it
1869 seems to work fine...*/
1870 printk(KERN_DEBUG
"%s: MAC controller error (WTERR). Ignoring.\n",
1874 irqreturn_t
orinoco_interrupt(int irq
, void *dev_id
)
1876 struct orinoco_private
*priv
= dev_id
;
1877 struct net_device
*dev
= priv
->ndev
;
1878 struct hermes
*hw
= &priv
->hw
;
1879 int count
= MAX_IRQLOOPS_PER_IRQ
;
1881 /* These are used to detect a runaway interrupt situation.
1883 * If we get more than MAX_IRQLOOPS_PER_JIFFY iterations in a jiffy,
1884 * we panic and shut down the hardware
1886 /* jiffies value the last time we were called */
1887 static int last_irq_jiffy
; /* = 0 */
1888 static int loops_this_jiffy
; /* = 0 */
1889 unsigned long flags
;
1891 if (orinoco_lock(priv
, &flags
) != 0) {
1892 /* If hw is unavailable - we don't know if the irq was
1897 evstat
= hermes_read_regn(hw
, EVSTAT
);
1898 events
= evstat
& hw
->inten
;
1900 orinoco_unlock(priv
, &flags
);
1904 if (jiffies
!= last_irq_jiffy
)
1905 loops_this_jiffy
= 0;
1906 last_irq_jiffy
= jiffies
;
1908 while (events
&& count
--) {
1909 if (++loops_this_jiffy
> MAX_IRQLOOPS_PER_JIFFY
) {
1910 printk(KERN_WARNING
"%s: IRQ handler is looping too "
1911 "much! Resetting.\n", dev
->name
);
1912 /* Disable interrupts for now */
1913 hermes_set_irqmask(hw
, 0);
1914 schedule_work(&priv
->reset_work
);
1918 /* Check the card hasn't been removed */
1919 if (!hermes_present(hw
)) {
1920 DEBUG(0, "orinoco_interrupt(): card removed\n");
1924 if (events
& HERMES_EV_TICK
)
1925 __orinoco_ev_tick(dev
, hw
);
1926 if (events
& HERMES_EV_WTERR
)
1927 __orinoco_ev_wterr(dev
, hw
);
1928 if (events
& HERMES_EV_INFDROP
)
1929 __orinoco_ev_infdrop(dev
, hw
);
1930 if (events
& HERMES_EV_INFO
)
1931 __orinoco_ev_info(dev
, hw
);
1932 if (events
& HERMES_EV_RX
)
1933 __orinoco_ev_rx(dev
, hw
);
1934 if (events
& HERMES_EV_TXEXC
)
1935 __orinoco_ev_txexc(dev
, hw
);
1936 if (events
& HERMES_EV_TX
)
1937 __orinoco_ev_tx(dev
, hw
);
1938 if (events
& HERMES_EV_ALLOC
)
1939 __orinoco_ev_alloc(dev
, hw
);
1941 hermes_write_regn(hw
, EVACK
, evstat
);
1943 evstat
= hermes_read_regn(hw
, EVSTAT
);
1944 events
= evstat
& hw
->inten
;
1947 orinoco_unlock(priv
, &flags
);
1950 EXPORT_SYMBOL(orinoco_interrupt
);
1952 /********************************************************************/
1953 /* Power management */
1954 /********************************************************************/
1955 #if defined(CONFIG_PM_SLEEP) && !defined(CONFIG_HERMES_CACHE_FW_ON_INIT)
1956 static int orinoco_pm_notifier(struct notifier_block
*notifier
,
1957 unsigned long pm_event
,
1960 struct orinoco_private
*priv
= container_of(notifier
,
1961 struct orinoco_private
,
1964 /* All we need to do is cache the firmware before suspend, and
1965 * release it when we come out.
1967 * Only need to do this if we're downloading firmware. */
1968 if (!priv
->do_fw_download
)
1972 case PM_HIBERNATION_PREPARE
:
1973 case PM_SUSPEND_PREPARE
:
1974 orinoco_cache_fw(priv
, 0);
1977 case PM_POST_RESTORE
:
1978 /* Restore from hibernation failed. We need to clean
1979 * up in exactly the same way, so fall through. */
1980 case PM_POST_HIBERNATION
:
1981 case PM_POST_SUSPEND
:
1982 orinoco_uncache_fw(priv
);
1985 case PM_RESTORE_PREPARE
:
1993 static void orinoco_register_pm_notifier(struct orinoco_private
*priv
)
1995 priv
->pm_notifier
.notifier_call
= orinoco_pm_notifier
;
1996 register_pm_notifier(&priv
->pm_notifier
);
1999 static void orinoco_unregister_pm_notifier(struct orinoco_private
*priv
)
2001 unregister_pm_notifier(&priv
->pm_notifier
);
2003 #else /* !PM_SLEEP || HERMES_CACHE_FW_ON_INIT */
2004 #define orinoco_register_pm_notifier(priv) do { } while (0)
2005 #define orinoco_unregister_pm_notifier(priv) do { } while (0)
2008 /********************************************************************/
2009 /* Initialization */
2010 /********************************************************************/
2012 int orinoco_init(struct orinoco_private
*priv
)
2014 struct device
*dev
= priv
->dev
;
2015 struct wiphy
*wiphy
= priv_to_wiphy(priv
);
2016 struct hermes
*hw
= &priv
->hw
;
2019 /* No need to lock, the hw_unavailable flag is already set in
2020 * alloc_orinocodev() */
2021 priv
->nicbuf_size
= IEEE80211_MAX_FRAME_LEN
+ ETH_HLEN
;
2023 /* Initialize the firmware */
2024 err
= hw
->ops
->init(hw
);
2026 dev_err(dev
, "Failed to initialize firmware (err = %d)\n",
2031 err
= determine_fw_capabilities(priv
, wiphy
->fw_version
,
2032 sizeof(wiphy
->fw_version
),
2033 &wiphy
->hw_version
);
2035 dev_err(dev
, "Incompatible firmware, aborting\n");
2039 if (priv
->do_fw_download
) {
2040 #ifdef CONFIG_HERMES_CACHE_FW_ON_INIT
2041 orinoco_cache_fw(priv
, 0);
2044 err
= orinoco_download(priv
);
2046 priv
->do_fw_download
= 0;
2048 /* Check firmware version again */
2049 err
= determine_fw_capabilities(priv
, wiphy
->fw_version
,
2050 sizeof(wiphy
->fw_version
),
2051 &wiphy
->hw_version
);
2053 dev_err(dev
, "Incompatible firmware, aborting\n");
2058 if (priv
->has_port3
)
2059 dev_info(dev
, "Ad-hoc demo mode supported\n");
2061 dev_info(dev
, "IEEE standard IBSS ad-hoc mode supported\n");
2063 dev_info(dev
, "WEP supported, %s-bit key\n",
2064 priv
->has_big_wep
? "104" : "40");
2065 if (priv
->has_wpa
) {
2066 dev_info(dev
, "WPA-PSK supported\n");
2067 if (orinoco_mic_init(priv
)) {
2068 dev_err(dev
, "Failed to setup MIC crypto algorithm. "
2069 "Disabling WPA support\n");
2074 err
= orinoco_hw_read_card_settings(priv
, wiphy
->perm_addr
);
2078 err
= orinoco_hw_allocate_fid(priv
);
2080 dev_err(dev
, "Failed to allocate NIC buffer!\n");
2084 /* Set up the default configuration */
2085 priv
->iw_mode
= NL80211_IFTYPE_STATION
;
2086 /* By default use IEEE/IBSS ad-hoc mode if we have it */
2087 priv
->prefer_port3
= priv
->has_port3
&& (!priv
->has_ibss
);
2088 set_port_type(priv
);
2089 priv
->channel
= 0; /* use firmware default */
2091 priv
->promiscuous
= 0;
2092 priv
->encode_alg
= ORINOCO_ALG_NONE
;
2094 priv
->wpa_enabled
= 0;
2095 priv
->tkip_cm_active
= 0;
2097 priv
->wpa_ie_len
= 0;
2098 priv
->wpa_ie
= NULL
;
2100 if (orinoco_wiphy_register(wiphy
)) {
2105 /* Make the hardware available, as long as it hasn't been
2106 * removed elsewhere (e.g. by PCMCIA hot unplug) */
2107 orinoco_lock_irq(priv
);
2108 priv
->hw_unavailable
--;
2109 orinoco_unlock_irq(priv
);
2111 dev_dbg(dev
, "Ready\n");
2116 EXPORT_SYMBOL(orinoco_init
);
2118 static const struct net_device_ops orinoco_netdev_ops
= {
2119 .ndo_open
= orinoco_open
,
2120 .ndo_stop
= orinoco_stop
,
2121 .ndo_start_xmit
= orinoco_xmit
,
2122 .ndo_set_rx_mode
= orinoco_set_multicast_list
,
2123 .ndo_change_mtu
= orinoco_change_mtu
,
2124 .ndo_set_mac_address
= eth_mac_addr
,
2125 .ndo_validate_addr
= eth_validate_addr
,
2126 .ndo_tx_timeout
= orinoco_tx_timeout
,
2129 /* Allocate private data.
2131 * This driver has a number of structures associated with it
2132 * netdev - Net device structure for each network interface
2133 * wiphy - structure associated with wireless phy
2134 * wireless_dev (wdev) - structure for each wireless interface
2135 * hw - structure for hermes chip info
2136 * card - card specific structure for use by the card driver
2137 * (airport, orinoco_cs)
2138 * priv - orinoco private data
2139 * device - generic linux device structure
2141 * +---------+ +---------+
2142 * | wiphy | | netdev |
2143 * | +-------+ | +-------+
2144 * | | priv | | | wdev |
2145 * | | +-----+ +-+-------+
2151 * priv has a link to netdev and device
2152 * wdev has a link to wiphy
2154 struct orinoco_private
2155 *alloc_orinocodev(int sizeof_card
,
2156 struct device
*device
,
2157 int (*hard_reset
)(struct orinoco_private
*),
2158 int (*stop_fw
)(struct orinoco_private
*, int))
2160 struct orinoco_private
*priv
;
2161 struct wiphy
*wiphy
;
2164 * NOTE: We only support a single virtual interface
2165 * but this may change when monitor mode is added
2167 wiphy
= wiphy_new(&orinoco_cfg_ops
,
2168 sizeof(struct orinoco_private
) + sizeof_card
);
2172 priv
= wiphy_priv(wiphy
);
2176 priv
->card
= (void *)((unsigned long)priv
2177 + sizeof(struct orinoco_private
));
2181 orinoco_wiphy_init(wiphy
);
2184 priv
->wireless_data
.spy_data
= &priv
->spy_data
;
2187 /* Set up default callbacks */
2188 priv
->hard_reset
= hard_reset
;
2189 priv
->stop_fw
= stop_fw
;
2191 spin_lock_init(&priv
->lock
);
2193 priv
->hw_unavailable
= 1; /* orinoco_init() must clear this
2194 * before anything else touches the
2196 INIT_WORK(&priv
->reset_work
, orinoco_reset
);
2197 INIT_WORK(&priv
->join_work
, orinoco_join_ap
);
2198 INIT_WORK(&priv
->wevent_work
, orinoco_send_wevents
);
2200 INIT_LIST_HEAD(&priv
->rx_list
);
2201 tasklet_init(&priv
->rx_tasklet
, orinoco_rx_isr_tasklet
,
2202 (unsigned long) priv
);
2204 spin_lock_init(&priv
->scan_lock
);
2205 INIT_LIST_HEAD(&priv
->scan_list
);
2206 INIT_WORK(&priv
->process_scan
, orinoco_process_scan_results
);
2208 priv
->last_linkstatus
= 0xffff;
2210 #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
2211 priv
->cached_pri_fw
= NULL
;
2212 priv
->cached_fw
= NULL
;
2215 /* Register PM notifiers */
2216 orinoco_register_pm_notifier(priv
);
2220 EXPORT_SYMBOL(alloc_orinocodev
);
2222 /* We can only support a single interface. We provide a separate
2223 * function to set it up to distinguish between hardware
2224 * initialisation and interface setup.
2226 * The base_addr and irq parameters are passed on to netdev for use
2229 int orinoco_if_add(struct orinoco_private
*priv
,
2230 unsigned long base_addr
,
2232 const struct net_device_ops
*ops
)
2234 struct wiphy
*wiphy
= priv_to_wiphy(priv
);
2235 struct wireless_dev
*wdev
;
2236 struct net_device
*dev
;
2239 dev
= alloc_etherdev(sizeof(struct wireless_dev
));
2244 /* Initialise wireless_dev */
2245 wdev
= netdev_priv(dev
);
2246 wdev
->wiphy
= wiphy
;
2247 wdev
->iftype
= NL80211_IFTYPE_STATION
;
2249 /* Setup / override net_device fields */
2250 dev
->ieee80211_ptr
= wdev
;
2251 dev
->watchdog_timeo
= HZ
; /* 1 second timeout */
2252 dev
->wireless_handlers
= &orinoco_handler_def
;
2254 dev
->wireless_data
= &priv
->wireless_data
;
2256 /* Default to standard ops if not set */
2258 dev
->netdev_ops
= ops
;
2260 dev
->netdev_ops
= &orinoco_netdev_ops
;
2262 /* we use the default eth_mac_addr for setting the MAC addr */
2264 /* Reserve space in skb for the SNAP header */
2265 dev
->needed_headroom
= ENCAPS_OVERHEAD
;
2267 netif_carrier_off(dev
);
2269 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2271 dev
->base_addr
= base_addr
;
2274 dev
->min_mtu
= ORINOCO_MIN_MTU
;
2275 dev
->max_mtu
= ORINOCO_MAX_MTU
;
2277 SET_NETDEV_DEV(dev
, priv
->dev
);
2278 ret
= register_netdev(dev
);
2284 /* Report what we've done */
2285 dev_dbg(priv
->dev
, "Registered interface %s.\n", dev
->name
);
2293 EXPORT_SYMBOL(orinoco_if_add
);
2295 void orinoco_if_del(struct orinoco_private
*priv
)
2297 struct net_device
*dev
= priv
->ndev
;
2299 unregister_netdev(dev
);
2302 EXPORT_SYMBOL(orinoco_if_del
);
2304 void free_orinocodev(struct orinoco_private
*priv
)
2306 struct wiphy
*wiphy
= priv_to_wiphy(priv
);
2307 struct orinoco_rx_data
*rx_data
, *temp
;
2308 struct orinoco_scan_data
*sd
, *sdtemp
;
2310 /* If the tasklet is scheduled when we call tasklet_kill it
2311 * will run one final time. However the tasklet will only
2312 * drain priv->rx_list if the hw is still available. */
2313 tasklet_kill(&priv
->rx_tasklet
);
2315 /* Explicitly drain priv->rx_list */
2316 list_for_each_entry_safe(rx_data
, temp
, &priv
->rx_list
, list
) {
2317 list_del(&rx_data
->list
);
2319 dev_kfree_skb(rx_data
->skb
);
2320 kfree(rx_data
->desc
);
2324 cancel_work_sync(&priv
->process_scan
);
2325 /* Explicitly drain priv->scan_list */
2326 list_for_each_entry_safe(sd
, sdtemp
, &priv
->scan_list
, list
) {
2327 list_del(&sd
->list
);
2334 orinoco_unregister_pm_notifier(priv
);
2335 orinoco_uncache_fw(priv
);
2337 priv
->wpa_ie_len
= 0;
2338 kfree(priv
->wpa_ie
);
2339 orinoco_mic_free(priv
);
2342 EXPORT_SYMBOL(free_orinocodev
);
2344 int orinoco_up(struct orinoco_private
*priv
)
2346 struct net_device
*dev
= priv
->ndev
;
2347 unsigned long flags
;
2350 priv
->hw
.ops
->lock_irqsave(&priv
->lock
, &flags
);
2352 err
= orinoco_reinit_firmware(priv
);
2354 printk(KERN_ERR
"%s: Error %d re-initializing firmware\n",
2359 netif_device_attach(dev
);
2360 priv
->hw_unavailable
--;
2362 if (priv
->open
&& !priv
->hw_unavailable
) {
2363 err
= __orinoco_up(priv
);
2365 printk(KERN_ERR
"%s: Error %d restarting card\n",
2370 priv
->hw
.ops
->unlock_irqrestore(&priv
->lock
, &flags
);
2374 EXPORT_SYMBOL(orinoco_up
);
2376 void orinoco_down(struct orinoco_private
*priv
)
2378 struct net_device
*dev
= priv
->ndev
;
2379 unsigned long flags
;
2382 priv
->hw
.ops
->lock_irqsave(&priv
->lock
, &flags
);
2383 err
= __orinoco_down(priv
);
2385 printk(KERN_WARNING
"%s: Error %d downing interface\n",
2388 netif_device_detach(dev
);
2389 priv
->hw_unavailable
++;
2390 priv
->hw
.ops
->unlock_irqrestore(&priv
->lock
, &flags
);
2392 EXPORT_SYMBOL(orinoco_down
);
2394 /********************************************************************/
2395 /* Module initialization */
2396 /********************************************************************/
2398 /* Can't be declared "const" or the whole __initdata section will
2400 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
2401 " (David Gibson <hermes@gibson.dropbear.id.au>, "
2402 "Pavel Roskin <proski@gnu.org>, et al)";
2404 static int __init
init_orinoco(void)
2406 printk(KERN_DEBUG
"%s\n", version
);
2410 static void __exit
exit_orinoco(void)
2414 module_init(init_orinoco
);
2415 module_exit(exit_orinoco
);