1 /* orinoco.c - (formerly known as dldwd_cs.c and orinoco_cs.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/init.h>
82 #include <linux/delay.h>
83 #include <linux/netdevice.h>
84 #include <linux/etherdevice.h>
85 #include <linux/ethtool.h>
86 #include <linux/firmware.h>
87 #include <linux/if_arp.h>
88 #include <linux/wireless.h>
89 #include <net/iw_handler.h>
90 #include <net/ieee80211.h>
92 #include "hermes_rid.h"
93 #include "hermes_dld.h"
96 /********************************************************************/
97 /* Module information */
98 /********************************************************************/
100 MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> & David Gibson <hermes@gibson.dropbear.id.au>");
101 MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based and similar wireless cards");
102 MODULE_LICENSE("Dual MPL/GPL");
104 /* Level of debugging. Used in the macros in orinoco.h */
106 int orinoco_debug = ORINOCO_DEBUG;
107 module_param(orinoco_debug, int, 0644);
108 MODULE_PARM_DESC(orinoco_debug, "Debug level");
109 EXPORT_SYMBOL(orinoco_debug);
112 static int suppress_linkstatus; /* = 0 */
113 module_param(suppress_linkstatus, bool, 0644);
114 MODULE_PARM_DESC(suppress_linkstatus, "Don't log link status changes");
115 static int ignore_disconnect; /* = 0 */
116 module_param(ignore_disconnect, int, 0644);
117 MODULE_PARM_DESC(ignore_disconnect, "Don't report lost link to the network layer");
119 static int force_monitor; /* = 0 */
120 module_param(force_monitor, int, 0644);
121 MODULE_PARM_DESC(force_monitor, "Allow monitor mode for all firmware versions");
123 /********************************************************************/
124 /* Compile time configuration and compatibility stuff */
125 /********************************************************************/
127 /* We do this this way to avoid ifdefs in the actual code */
129 #define SPY_NUMBER(priv) (priv->spy_data.spy_number)
131 #define SPY_NUMBER(priv) 0
132 #endif /* WIRELESS_SPY */
134 /********************************************************************/
135 /* Internal constants */
136 /********************************************************************/
138 /* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
139 static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
140 #define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
142 #define ORINOCO_MIN_MTU 256
143 #define ORINOCO_MAX_MTU (IEEE80211_DATA_LEN - ENCAPS_OVERHEAD)
145 #define SYMBOL_MAX_VER_LEN (14)
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 */
153 #define SMALL_KEY_SIZE 5
154 #define LARGE_KEY_SIZE 13
155 #define TX_NICBUF_SIZE_BUG 1585 /* Bug in Symbol firmware */
157 #define DUMMY_FID 0xFFFF
159 /*#define MAX_MULTICAST(priv) (priv->firmware_type == FIRMWARE_TYPE_AGERE ? \
160 HERMES_MAX_MULTICAST : 0)*/
161 #define MAX_MULTICAST(priv) (HERMES_MAX_MULTICAST)
163 #define ORINOCO_INTEN (HERMES_EV_RX | HERMES_EV_ALLOC \
164 | HERMES_EV_TX | HERMES_EV_TXEXC \
165 | HERMES_EV_WTERR | HERMES_EV_INFO \
166 | HERMES_EV_INFDROP )
168 #define MAX_RID_LEN 1024
170 static const struct iw_handler_def orinoco_handler_def;
171 static const struct ethtool_ops orinoco_ethtool_ops;
173 /********************************************************************/
175 /********************************************************************/
177 /* The frequency of each channel in MHz */
178 static const long channel_frequency[] = {
179 2412, 2417, 2422, 2427, 2432, 2437, 2442,
180 2447, 2452, 2457, 2462, 2467, 2472, 2484
182 #define NUM_CHANNELS ARRAY_SIZE(channel_frequency)
184 /* This tables gives the actual meanings of the bitrate IDs returned
185 * by the firmware. */
187 int bitrate; /* in 100s of kilobits */
189 u16 agere_txratectrl;
190 u16 intersil_txratectrl;
191 } bitrate_table[] = {
192 {110, 1, 3, 15}, /* Entry 0 is the default */
201 #define BITRATE_TABLE_SIZE ARRAY_SIZE(bitrate_table)
203 /********************************************************************/
205 /********************************************************************/
207 /* Beginning of the Tx descriptor, used in TxExc handling */
208 struct hermes_txexc_data {
209 struct hermes_tx_descriptor desc;
213 } __attribute__ ((packed));
215 /* Rx frame header except compatibility 802.3 header */
216 struct hermes_rx_descriptor {
237 } __attribute__ ((packed));
239 /********************************************************************/
240 /* Function prototypes */
241 /********************************************************************/
243 static int __orinoco_program_rids(struct net_device *dev);
244 static void __orinoco_set_multicast_list(struct net_device *dev);
246 /********************************************************************/
247 /* Internal helper functions */
248 /********************************************************************/
250 static inline void set_port_type(struct orinoco_private *priv)
252 switch (priv->iw_mode) {
255 priv->createibss = 0;
258 if (priv->prefer_port3) {
260 priv->createibss = 0;
262 priv->port_type = priv->ibss_port;
263 priv->createibss = 1;
266 case IW_MODE_MONITOR:
268 priv->createibss = 0;
271 printk(KERN_ERR "%s: Invalid priv->iw_mode in set_port_type()\n",
276 #define ORINOCO_MAX_BSS_COUNT 64
277 static int orinoco_bss_data_allocate(struct orinoco_private *priv)
279 if (priv->bss_xbss_data)
282 if (priv->has_ext_scan)
283 priv->bss_xbss_data = kzalloc(ORINOCO_MAX_BSS_COUNT *
284 sizeof(struct xbss_element),
287 priv->bss_xbss_data = kzalloc(ORINOCO_MAX_BSS_COUNT *
288 sizeof(struct bss_element),
291 if (!priv->bss_xbss_data) {
292 printk(KERN_WARNING "Out of memory allocating beacons");
298 static void orinoco_bss_data_free(struct orinoco_private *priv)
300 kfree(priv->bss_xbss_data);
301 priv->bss_xbss_data = NULL;
304 #define PRIV_BSS ((struct bss_element *)priv->bss_xbss_data)
305 #define PRIV_XBSS ((struct xbss_element *)priv->bss_xbss_data)
306 static void orinoco_bss_data_init(struct orinoco_private *priv)
310 INIT_LIST_HEAD(&priv->bss_free_list);
311 INIT_LIST_HEAD(&priv->bss_list);
312 if (priv->has_ext_scan)
313 for (i = 0; i < ORINOCO_MAX_BSS_COUNT; i++)
314 list_add_tail(&(PRIV_XBSS[i].list),
315 &priv->bss_free_list);
317 for (i = 0; i < ORINOCO_MAX_BSS_COUNT; i++)
318 list_add_tail(&(PRIV_BSS[i].list),
319 &priv->bss_free_list);
323 static inline u8 *orinoco_get_ie(u8 *data, size_t len,
324 enum ieee80211_mfie eid)
327 while ((p + 2) < (data + len)) {
335 #define WPA_OUI_TYPE "\x00\x50\xF2\x01"
336 #define WPA_SELECTOR_LEN 4
337 static inline u8 *orinoco_get_wpa_ie(u8 *data, size_t len)
340 while ((p + 2 + WPA_SELECTOR_LEN) < (data + len)) {
341 if ((p[0] == MFIE_TYPE_GENERIC) &&
342 (memcmp(&p[2], WPA_OUI_TYPE, WPA_SELECTOR_LEN) == 0))
350 /********************************************************************/
351 /* Download functionality */
352 /********************************************************************/
362 const static struct fw_info orinoco_fw[] = {
363 { "", "agere_sta_fw.bin", "agere_ap_fw.bin", 0x00390000, 1000 },
364 { "", "prism_sta_fw.bin", "prism_ap_fw.bin", 0, 1024 },
365 { "symbol_sp24t_prim_fw", "symbol_sp24t_sec_fw", "", 0x00003100, 0x100 }
368 /* Structure used to access fields in FW
369 * Make sure LE decoding macros are used
371 struct orinoco_fw_header {
372 char hdr_vers[6]; /* ASCII string for header version */
373 __le16 headersize; /* Total length of header */
374 __le32 entry_point; /* NIC entry point */
375 __le32 blocks; /* Number of blocks to program */
376 __le32 block_offset; /* Offset of block data from eof header */
377 __le32 pdr_offset; /* Offset to PDR data from eof header */
378 __le32 pri_offset; /* Offset to primary plug data */
379 __le32 compat_offset; /* Offset to compatibility data*/
380 char signature[0]; /* FW signature length headersize-20 */
381 } __attribute__ ((packed));
383 /* Download either STA or AP firmware into the card. */
385 orinoco_dl_firmware(struct orinoco_private *priv,
386 const struct fw_info *fw,
389 /* Plug Data Area (PDA) */
390 __le16 pda[512] = { 0 };
392 hermes_t *hw = &priv->hw;
393 const struct firmware *fw_entry;
394 const struct orinoco_fw_header *hdr;
395 const unsigned char *first_block;
396 const unsigned char *end;
397 const char *firmware;
398 struct net_device *dev = priv->ndev;
402 firmware = fw->ap_fw;
404 firmware = fw->sta_fw;
406 printk(KERN_DEBUG "%s: Attempting to download firmware %s\n",
407 dev->name, firmware);
409 /* Read current plug data */
410 err = hermes_read_pda(hw, pda, fw->pda_addr,
411 min_t(u16, fw->pda_size, sizeof(pda)), 0);
412 printk(KERN_DEBUG "%s: Read PDA returned %d\n", dev->name, err);
416 err = request_firmware(&fw_entry, firmware, priv->dev);
418 printk(KERN_ERR "%s: Cannot find firmware %s\n",
419 dev->name, firmware);
423 hdr = (const struct orinoco_fw_header *) fw_entry->data;
425 /* Enable aux port to allow programming */
426 err = hermesi_program_init(hw, le32_to_cpu(hdr->entry_point));
427 printk(KERN_DEBUG "%s: Program init returned %d\n", dev->name, err);
432 first_block = (fw_entry->data +
433 le16_to_cpu(hdr->headersize) +
434 le32_to_cpu(hdr->block_offset));
435 end = fw_entry->data + fw_entry->size;
437 err = hermes_program(hw, first_block, end);
438 printk(KERN_DEBUG "%s: Program returned %d\n", dev->name, err);
442 /* Update production data */
443 first_block = (fw_entry->data +
444 le16_to_cpu(hdr->headersize) +
445 le32_to_cpu(hdr->pdr_offset));
447 err = hermes_apply_pda_with_defaults(hw, first_block, pda);
448 printk(KERN_DEBUG "%s: Apply PDA returned %d\n", dev->name, err);
452 /* Tell card we've finished */
453 err = hermesi_program_end(hw);
454 printk(KERN_DEBUG "%s: Program end returned %d\n", dev->name, err);
458 /* Check if we're running */
459 printk(KERN_DEBUG "%s: hermes_present returned %d\n",
460 dev->name, hermes_present(hw));
463 release_firmware(fw_entry);
468 #define TEXT_END 0x1A /* End of text header */
471 * Process a firmware image - stop the card, load the firmware, reset
472 * the card and make sure it responds. For the secondary firmware take
473 * care of the PDA - read it and then write it on top of the firmware.
476 symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw,
477 const unsigned char *image, const unsigned char *end,
480 hermes_t *hw = &priv->hw;
482 const unsigned char *ptr;
483 const unsigned char *first_block;
485 /* Plug Data Area (PDA) */
488 /* Binary block begins after the 0x1A marker */
490 while (*ptr++ != TEXT_END);
493 /* Read the PDA from EEPROM */
495 ret = hermes_read_pda(hw, pda, fw->pda_addr, sizeof(pda), 1);
500 /* Stop the firmware, so that it can be safely rewritten */
502 ret = priv->stop_fw(priv, 1);
507 /* Program the adapter with new firmware */
508 ret = hermes_program(hw, first_block, end);
512 /* Write the PDA to the adapter */
514 size_t len = hermes_blocks_length(first_block);
515 ptr = first_block + len;
516 ret = hermes_apply_pda(hw, ptr, pda);
521 /* Run the firmware */
523 ret = priv->stop_fw(priv, 0);
528 /* Reset hermes chip and make sure it responds */
529 ret = hermes_init(hw);
531 /* hermes_reset() should return 0 with the secondary firmware */
532 if (secondary && ret != 0)
535 /* And this should work with any firmware */
536 if (!hermes_present(hw))
544 * Download the firmware into the card, this also does a PCMCIA soft
545 * reset on the card, to make sure it's in a sane state.
548 symbol_dl_firmware(struct orinoco_private *priv,
549 const struct fw_info *fw)
551 struct net_device *dev = priv->ndev;
553 const struct firmware *fw_entry;
555 if (request_firmware(&fw_entry, fw->pri_fw,
557 printk(KERN_ERR "%s: Cannot find firmware: %s\n",
558 dev->name, fw->pri_fw);
562 /* Load primary firmware */
563 ret = symbol_dl_image(priv, fw, fw_entry->data,
564 fw_entry->data + fw_entry->size, 0);
565 release_firmware(fw_entry);
567 printk(KERN_ERR "%s: Primary firmware download failed\n",
572 if (request_firmware(&fw_entry, fw->sta_fw,
574 printk(KERN_ERR "%s: Cannot find firmware: %s\n",
575 dev->name, fw->sta_fw);
579 /* Load secondary firmware */
580 ret = symbol_dl_image(priv, fw, fw_entry->data,
581 fw_entry->data + fw_entry->size, 1);
582 release_firmware(fw_entry);
584 printk(KERN_ERR "%s: Secondary firmware download failed\n",
591 static int orinoco_download(struct orinoco_private *priv)
594 /* Reload firmware */
595 switch (priv->firmware_type) {
596 case FIRMWARE_TYPE_AGERE:
597 /* case FIRMWARE_TYPE_INTERSIL: */
598 err = orinoco_dl_firmware(priv,
599 &orinoco_fw[priv->firmware_type], 0);
602 case FIRMWARE_TYPE_SYMBOL:
603 err = symbol_dl_firmware(priv,
604 &orinoco_fw[priv->firmware_type]);
606 case FIRMWARE_TYPE_INTERSIL:
609 /* TODO: if we fail we probably need to reinitialise
615 /********************************************************************/
617 /********************************************************************/
619 static int orinoco_open(struct net_device *dev)
621 struct orinoco_private *priv = netdev_priv(dev);
625 if (orinoco_lock(priv, &flags) != 0)
628 err = __orinoco_up(dev);
633 orinoco_unlock(priv, &flags);
638 static int orinoco_stop(struct net_device *dev)
640 struct orinoco_private *priv = netdev_priv(dev);
643 /* We mustn't use orinoco_lock() here, because we need to be
644 able to close the interface even if hw_unavailable is set
645 (e.g. as we're released after a PC Card removal) */
646 spin_lock_irq(&priv->lock);
650 err = __orinoco_down(dev);
652 spin_unlock_irq(&priv->lock);
657 static struct net_device_stats *orinoco_get_stats(struct net_device *dev)
659 struct orinoco_private *priv = netdev_priv(dev);
664 static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
666 struct orinoco_private *priv = netdev_priv(dev);
667 hermes_t *hw = &priv->hw;
668 struct iw_statistics *wstats = &priv->wstats;
672 if (! netif_device_present(dev)) {
673 printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n",
675 return NULL; /* FIXME: Can we do better than this? */
678 /* If busy, return the old stats. Returning NULL may cause
679 * the interface to disappear from /proc/net/wireless */
680 if (orinoco_lock(priv, &flags) != 0)
683 /* We can't really wait for the tallies inquiry command to
684 * complete, so we just use the previous results and trigger
685 * a new tallies inquiry command for next time - Jean II */
686 /* FIXME: Really we should wait for the inquiry to come back -
687 * as it is the stats we give don't make a whole lot of sense.
688 * Unfortunately, it's not clear how to do that within the
689 * wireless extensions framework: I think we're in user
690 * context, but a lock seems to be held by the time we get in
691 * here so we're not safe to sleep here. */
692 hermes_inquire(hw, HERMES_INQ_TALLIES);
694 if (priv->iw_mode == IW_MODE_ADHOC) {
695 memset(&wstats->qual, 0, sizeof(wstats->qual));
696 /* If a spy address is defined, we report stats of the
697 * first spy address - Jean II */
698 if (SPY_NUMBER(priv)) {
699 wstats->qual.qual = priv->spy_data.spy_stat[0].qual;
700 wstats->qual.level = priv->spy_data.spy_stat[0].level;
701 wstats->qual.noise = priv->spy_data.spy_stat[0].noise;
702 wstats->qual.updated = priv->spy_data.spy_stat[0].updated;
706 __le16 qual, signal, noise, unused;
707 } __attribute__ ((packed)) cq;
709 err = HERMES_READ_RECORD(hw, USER_BAP,
710 HERMES_RID_COMMSQUALITY, &cq);
713 wstats->qual.qual = (int)le16_to_cpu(cq.qual);
714 wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95;
715 wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95;
716 wstats->qual.updated = 7;
720 orinoco_unlock(priv, &flags);
724 static void orinoco_set_multicast_list(struct net_device *dev)
726 struct orinoco_private *priv = netdev_priv(dev);
729 if (orinoco_lock(priv, &flags) != 0) {
730 printk(KERN_DEBUG "%s: orinoco_set_multicast_list() "
731 "called when hw_unavailable\n", dev->name);
735 __orinoco_set_multicast_list(dev);
736 orinoco_unlock(priv, &flags);
739 static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
741 struct orinoco_private *priv = netdev_priv(dev);
743 if ( (new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU) )
746 if ( (new_mtu + ENCAPS_OVERHEAD + IEEE80211_HLEN) >
747 (priv->nicbuf_size - ETH_HLEN) )
755 /********************************************************************/
757 /********************************************************************/
759 static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
761 struct orinoco_private *priv = netdev_priv(dev);
762 struct net_device_stats *stats = &priv->stats;
763 hermes_t *hw = &priv->hw;
765 u16 txfid = priv->txfid;
771 if (! netif_running(dev)) {
772 printk(KERN_ERR "%s: Tx on stopped device!\n",
774 return NETDEV_TX_BUSY;
777 if (netif_queue_stopped(dev)) {
778 printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
780 return NETDEV_TX_BUSY;
783 if (orinoco_lock(priv, &flags) != 0) {
784 printk(KERN_ERR "%s: orinoco_xmit() called while hw_unavailable\n",
786 return NETDEV_TX_BUSY;
789 if (! netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) {
790 /* Oops, the firmware hasn't established a connection,
791 silently drop the packet (this seems to be the
796 /* Check packet length */
797 if (skb->len < ETH_HLEN)
800 eh = (struct ethhdr *)skb->data;
802 tx_control = HERMES_TXCTRL_TX_OK | HERMES_TXCTRL_TX_EX;
804 if (priv->has_alt_txcntl) {
805 /* WPA enabled firmwares have tx_cntl at the end of
806 * the 802.11 header. So write zeroed descriptor and
807 * 802.11 header at the same time
809 char desc[HERMES_802_3_OFFSET];
810 __le16 *txcntl = (__le16 *) &desc[HERMES_TXCNTL2_OFFSET];
812 memset(&desc, 0, sizeof(desc));
814 *txcntl = cpu_to_le16(tx_control);
815 err = hermes_bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
819 printk(KERN_ERR "%s: Error %d writing Tx "
820 "descriptor to BAP\n", dev->name, err);
824 struct hermes_tx_descriptor desc;
826 memset(&desc, 0, sizeof(desc));
828 desc.tx_control = cpu_to_le16(tx_control);
829 err = hermes_bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
833 printk(KERN_ERR "%s: Error %d writing Tx "
834 "descriptor to BAP\n", dev->name, err);
838 /* Clear the 802.11 header and data length fields - some
839 * firmwares (e.g. Lucent/Agere 8.xx) appear to get confused
840 * if this isn't done. */
841 hermes_clear_words(hw, HERMES_DATA0,
842 HERMES_802_3_OFFSET - HERMES_802_11_OFFSET);
845 /* Encapsulate Ethernet-II frames */
846 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */
847 struct header_struct {
848 struct ethhdr eth; /* 802.3 header */
849 u8 encap[6]; /* 802.2 header */
850 } __attribute__ ((packed)) hdr;
852 /* Strip destination and source from the data */
853 skb_pull(skb, 2 * ETH_ALEN);
854 data_off = HERMES_802_2_OFFSET + sizeof(encaps_hdr);
856 /* And move them to a separate header */
857 memcpy(&hdr.eth, eh, 2 * ETH_ALEN);
858 hdr.eth.h_proto = htons(sizeof(encaps_hdr) + skb->len);
859 memcpy(hdr.encap, encaps_hdr, sizeof(encaps_hdr));
861 err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr),
862 txfid, HERMES_802_3_OFFSET);
865 printk(KERN_ERR "%s: Error %d writing packet "
866 "header to BAP\n", dev->name, err);
869 } else { /* IEEE 802.3 frame */
870 data_off = HERMES_802_3_OFFSET;
873 err = hermes_bap_pwrite(hw, USER_BAP, skb->data, skb->len,
876 printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
881 /* Finally, we actually initiate the send */
882 netif_stop_queue(dev);
884 err = hermes_docmd_wait(hw, HERMES_CMD_TX | HERMES_CMD_RECL,
887 netif_start_queue(dev);
889 printk(KERN_ERR "%s: Error %d transmitting packet\n",
894 dev->trans_start = jiffies;
895 stats->tx_bytes += data_off + skb->len;
903 orinoco_unlock(priv, &flags);
909 schedule_work(&priv->reset_work);
910 orinoco_unlock(priv, &flags);
911 return NETDEV_TX_BUSY;
914 static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
916 struct orinoco_private *priv = netdev_priv(dev);
917 u16 fid = hermes_read_regn(hw, ALLOCFID);
919 if (fid != priv->txfid) {
920 if (fid != DUMMY_FID)
921 printk(KERN_WARNING "%s: Allocate event on unexpected fid (%04X)\n",
926 hermes_write_regn(hw, ALLOCFID, DUMMY_FID);
929 static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)
931 struct orinoco_private *priv = netdev_priv(dev);
932 struct net_device_stats *stats = &priv->stats;
936 netif_wake_queue(dev);
938 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
941 static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
943 struct orinoco_private *priv = netdev_priv(dev);
944 struct net_device_stats *stats = &priv->stats;
945 u16 fid = hermes_read_regn(hw, TXCOMPLFID);
947 struct hermes_txexc_data hdr;
950 if (fid == DUMMY_FID)
951 return; /* Nothing's really happened */
953 /* Read part of the frame header - we need status and addr1 */
954 err = hermes_bap_pread(hw, IRQ_BAP, &hdr,
955 sizeof(struct hermes_txexc_data),
958 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
962 printk(KERN_WARNING "%s: Unable to read descriptor on Tx error "
963 "(FID=%04X error %d)\n",
964 dev->name, fid, err);
968 DEBUG(1, "%s: Tx error, err %d (FID=%04X)\n", dev->name,
971 /* We produce a TXDROP event only for retry or lifetime
972 * exceeded, because that's the only status that really mean
973 * that this particular node went away.
974 * Other errors means that *we* screwed up. - Jean II */
975 status = le16_to_cpu(hdr.desc.status);
976 if (status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
977 union iwreq_data wrqu;
979 /* Copy 802.11 dest address.
980 * We use the 802.11 header because the frame may
981 * not be 802.3 or may be mangled...
982 * In Ad-Hoc mode, it will be the node address.
983 * In managed mode, it will be most likely the AP addr
984 * User space will figure out how to convert it to
985 * whatever it needs (IP address or else).
987 memcpy(wrqu.addr.sa_data, hdr.addr1, ETH_ALEN);
988 wrqu.addr.sa_family = ARPHRD_ETHER;
990 /* Send event to user space */
991 wireless_send_event(dev, IWEVTXDROP, &wrqu, NULL);
994 netif_wake_queue(dev);
997 static void orinoco_tx_timeout(struct net_device *dev)
999 struct orinoco_private *priv = netdev_priv(dev);
1000 struct net_device_stats *stats = &priv->stats;
1001 struct hermes *hw = &priv->hw;
1003 printk(KERN_WARNING "%s: Tx timeout! "
1004 "ALLOCFID=%04x, TXCOMPLFID=%04x, EVSTAT=%04x\n",
1005 dev->name, hermes_read_regn(hw, ALLOCFID),
1006 hermes_read_regn(hw, TXCOMPLFID), hermes_read_regn(hw, EVSTAT));
1010 schedule_work(&priv->reset_work);
1013 /********************************************************************/
1014 /* Rx path (data frames) */
1015 /********************************************************************/
1017 /* Does the frame have a SNAP header indicating it should be
1018 * de-encapsulated to Ethernet-II? */
1019 static inline int is_ethersnap(void *_hdr)
1023 /* We de-encapsulate all packets which, a) have SNAP headers
1024 * (i.e. SSAP=DSAP=0xaa and CTRL=0x3 in the 802.2 LLC header
1025 * and where b) the OUI of the SNAP header is 00:00:00 or
1026 * 00:00:f8 - we need both because different APs appear to use
1027 * different OUIs for some reason */
1028 return (memcmp(hdr, &encaps_hdr, 5) == 0)
1029 && ( (hdr[5] == 0x00) || (hdr[5] == 0xf8) );
1032 static inline void orinoco_spy_gather(struct net_device *dev, u_char *mac,
1033 int level, int noise)
1035 struct iw_quality wstats;
1036 wstats.level = level - 0x95;
1037 wstats.noise = noise - 0x95;
1038 wstats.qual = (level > noise) ? (level - noise) : 0;
1040 /* Update spy records */
1041 wireless_spy_update(dev, mac, &wstats);
1044 static void orinoco_stat_gather(struct net_device *dev,
1045 struct sk_buff *skb,
1046 struct hermes_rx_descriptor *desc)
1048 struct orinoco_private *priv = netdev_priv(dev);
1050 /* Using spy support with lots of Rx packets, like in an
1051 * infrastructure (AP), will really slow down everything, because
1052 * the MAC address must be compared to each entry of the spy list.
1053 * If the user really asks for it (set some address in the
1054 * spy list), we do it, but he will pay the price.
1055 * Note that to get here, you need both WIRELESS_SPY
1056 * compiled in AND some addresses in the list !!!
1058 /* Note : gcc will optimise the whole section away if
1059 * WIRELESS_SPY is not defined... - Jean II */
1060 if (SPY_NUMBER(priv)) {
1061 orinoco_spy_gather(dev, skb_mac_header(skb) + ETH_ALEN,
1062 desc->signal, desc->silence);
1067 * orinoco_rx_monitor - handle received monitor frames.
1070 * dev network device
1071 * rxfid received FID
1072 * desc rx descriptor of the frame
1074 * Call context: interrupt
1076 static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
1077 struct hermes_rx_descriptor *desc)
1079 u32 hdrlen = 30; /* return full header by default */
1084 struct sk_buff *skb;
1085 struct orinoco_private *priv = netdev_priv(dev);
1086 struct net_device_stats *stats = &priv->stats;
1087 hermes_t *hw = &priv->hw;
1089 len = le16_to_cpu(desc->data_len);
1091 /* Determine the size of the header and the data */
1092 fc = le16_to_cpu(desc->frame_ctl);
1093 switch (fc & IEEE80211_FCTL_FTYPE) {
1094 case IEEE80211_FTYPE_DATA:
1095 if ((fc & IEEE80211_FCTL_TODS)
1096 && (fc & IEEE80211_FCTL_FROMDS))
1102 case IEEE80211_FTYPE_MGMT:
1106 case IEEE80211_FTYPE_CTL:
1107 switch (fc & IEEE80211_FCTL_STYPE) {
1108 case IEEE80211_STYPE_PSPOLL:
1109 case IEEE80211_STYPE_RTS:
1110 case IEEE80211_STYPE_CFEND:
1111 case IEEE80211_STYPE_CFENDACK:
1114 case IEEE80211_STYPE_CTS:
1115 case IEEE80211_STYPE_ACK:
1121 /* Unknown frame type */
1125 /* sanity check the length */
1126 if (datalen > IEEE80211_DATA_LEN + 12) {
1127 printk(KERN_DEBUG "%s: oversized monitor frame, "
1128 "data length = %d\n", dev->name, datalen);
1129 stats->rx_length_errors++;
1133 skb = dev_alloc_skb(hdrlen + datalen);
1135 printk(KERN_WARNING "%s: Cannot allocate skb for monitor frame\n",
1140 /* Copy the 802.11 header to the skb */
1141 memcpy(skb_put(skb, hdrlen), &(desc->frame_ctl), hdrlen);
1142 skb_reset_mac_header(skb);
1144 /* If any, copy the data from the card to the skb */
1146 err = hermes_bap_pread(hw, IRQ_BAP, skb_put(skb, datalen),
1147 ALIGN(datalen, 2), rxfid,
1148 HERMES_802_2_OFFSET);
1150 printk(KERN_ERR "%s: error %d reading monitor frame\n",
1157 skb->ip_summed = CHECKSUM_NONE;
1158 skb->pkt_type = PACKET_OTHERHOST;
1159 skb->protocol = __constant_htons(ETH_P_802_2);
1161 dev->last_rx = jiffies;
1162 stats->rx_packets++;
1163 stats->rx_bytes += skb->len;
1169 dev_kfree_skb_irq(skb);
1172 stats->rx_dropped++;
1175 static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
1177 struct orinoco_private *priv = netdev_priv(dev);
1178 struct net_device_stats *stats = &priv->stats;
1179 struct iw_statistics *wstats = &priv->wstats;
1180 struct sk_buff *skb = NULL;
1183 struct hermes_rx_descriptor *desc;
1184 struct orinoco_rx_data *rx_data;
1187 desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
1190 "%s: Can't allocate space for RX descriptor\n",
1195 rxfid = hermes_read_regn(hw, RXFID);
1197 err = hermes_bap_pread(hw, IRQ_BAP, desc, sizeof(*desc),
1200 printk(KERN_ERR "%s: error %d reading Rx descriptor. "
1201 "Frame dropped.\n", dev->name, err);
1205 status = le16_to_cpu(desc->status);
1207 if (status & HERMES_RXSTAT_BADCRC) {
1208 DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n",
1210 stats->rx_crc_errors++;
1214 /* Handle frames in monitor mode */
1215 if (priv->iw_mode == IW_MODE_MONITOR) {
1216 orinoco_rx_monitor(dev, rxfid, desc);
1220 if (status & HERMES_RXSTAT_UNDECRYPTABLE) {
1221 DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n",
1223 wstats->discard.code++;
1227 length = le16_to_cpu(desc->data_len);
1230 if (length < 3) { /* No for even an 802.2 LLC header */
1231 /* At least on Symbol firmware with PCF we get quite a
1232 lot of these legitimately - Poll frames with no
1236 if (length > IEEE80211_DATA_LEN) {
1237 printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
1239 stats->rx_length_errors++;
1243 /* We need space for the packet data itself, plus an ethernet
1244 header, plus 2 bytes so we can align the IP header on a
1245 32bit boundary, plus 1 byte so we can read in odd length
1246 packets from the card, which has an IO granularity of 16
1248 skb = dev_alloc_skb(length+ETH_HLEN+2+1);
1250 printk(KERN_WARNING "%s: Can't allocate skb for Rx\n",
1255 /* We'll prepend the header, so reserve space for it. The worst
1256 case is no decapsulation, when 802.3 header is prepended and
1257 nothing is removed. 2 is for aligning the IP header. */
1258 skb_reserve(skb, ETH_HLEN + 2);
1260 err = hermes_bap_pread(hw, IRQ_BAP, skb_put(skb, length),
1261 ALIGN(length, 2), rxfid,
1262 HERMES_802_2_OFFSET);
1264 printk(KERN_ERR "%s: error %d reading frame. "
1265 "Frame dropped.\n", dev->name, err);
1269 /* Add desc and skb to rx queue */
1270 rx_data = kzalloc(sizeof(*rx_data), GFP_ATOMIC);
1272 printk(KERN_WARNING "%s: Can't allocate RX packet\n",
1276 rx_data->desc = desc;
1278 list_add_tail(&rx_data->list, &priv->rx_list);
1279 tasklet_schedule(&priv->rx_tasklet);
1284 dev_kfree_skb_irq(skb);
1287 stats->rx_dropped++;
1292 static void orinoco_rx(struct net_device *dev,
1293 struct hermes_rx_descriptor *desc,
1294 struct sk_buff *skb)
1296 struct orinoco_private *priv = netdev_priv(dev);
1297 struct net_device_stats *stats = &priv->stats;
1302 status = le16_to_cpu(desc->status);
1303 length = le16_to_cpu(desc->data_len);
1304 fc = le16_to_cpu(desc->frame_ctl);
1306 /* Handle decapsulation
1307 * In most cases, the firmware tell us about SNAP frames.
1308 * For some reason, the SNAP frames sent by LinkSys APs
1309 * are not properly recognised by most firmwares.
1310 * So, check ourselves */
1311 if (length >= ENCAPS_OVERHEAD &&
1312 (((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_1042) ||
1313 ((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_TUNNEL) ||
1314 is_ethersnap(skb->data))) {
1315 /* These indicate a SNAP within 802.2 LLC within
1316 802.11 frame which we'll need to de-encapsulate to
1317 the original EthernetII frame. */
1318 hdr = (struct ethhdr *)skb_push(skb, ETH_HLEN - ENCAPS_OVERHEAD);
1320 /* 802.3 frame - prepend 802.3 header as is */
1321 hdr = (struct ethhdr *)skb_push(skb, ETH_HLEN);
1322 hdr->h_proto = htons(length);
1324 memcpy(hdr->h_dest, desc->addr1, ETH_ALEN);
1325 if (fc & IEEE80211_FCTL_FROMDS)
1326 memcpy(hdr->h_source, desc->addr3, ETH_ALEN);
1328 memcpy(hdr->h_source, desc->addr2, ETH_ALEN);
1330 dev->last_rx = jiffies;
1331 skb->protocol = eth_type_trans(skb, dev);
1332 skb->ip_summed = CHECKSUM_NONE;
1333 if (fc & IEEE80211_FCTL_TODS)
1334 skb->pkt_type = PACKET_OTHERHOST;
1336 /* Process the wireless stats if needed */
1337 orinoco_stat_gather(dev, skb, desc);
1339 /* Pass the packet to the networking stack */
1341 stats->rx_packets++;
1342 stats->rx_bytes += length;
1347 static void orinoco_rx_isr_tasklet(unsigned long data)
1349 struct net_device *dev = (struct net_device *) data;
1350 struct orinoco_private *priv = netdev_priv(dev);
1351 struct orinoco_rx_data *rx_data, *temp;
1352 struct hermes_rx_descriptor *desc;
1353 struct sk_buff *skb;
1355 /* extract desc and skb from queue */
1356 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
1357 desc = rx_data->desc;
1359 list_del(&rx_data->list);
1362 orinoco_rx(dev, desc, skb);
1368 /********************************************************************/
1369 /* Rx path (info frames) */
1370 /********************************************************************/
1372 static void print_linkstatus(struct net_device *dev, u16 status)
1376 if (suppress_linkstatus)
1380 case HERMES_LINKSTATUS_NOT_CONNECTED:
1381 s = "Not Connected";
1383 case HERMES_LINKSTATUS_CONNECTED:
1386 case HERMES_LINKSTATUS_DISCONNECTED:
1389 case HERMES_LINKSTATUS_AP_CHANGE:
1392 case HERMES_LINKSTATUS_AP_OUT_OF_RANGE:
1393 s = "AP Out of Range";
1395 case HERMES_LINKSTATUS_AP_IN_RANGE:
1398 case HERMES_LINKSTATUS_ASSOC_FAILED:
1399 s = "Association Failed";
1405 printk(KERN_INFO "%s: New link status: %s (%04x)\n",
1406 dev->name, s, status);
1409 /* Search scan results for requested BSSID, join it if found */
1410 static void orinoco_join_ap(struct work_struct *work)
1412 struct orinoco_private *priv =
1413 container_of(work, struct orinoco_private, join_work);
1414 struct net_device *dev = priv->ndev;
1415 struct hermes *hw = &priv->hw;
1417 unsigned long flags;
1421 } __attribute__ ((packed)) req;
1422 const int atom_len = offsetof(struct prism2_scan_apinfo, atim);
1423 struct prism2_scan_apinfo *atom = NULL;
1429 /* Allocate buffer for scan results */
1430 buf = kmalloc(MAX_SCAN_LEN, GFP_KERNEL);
1434 if (orinoco_lock(priv, &flags) != 0)
1437 /* Sanity checks in case user changed something in the meantime */
1438 if (! priv->bssid_fixed)
1441 if (strlen(priv->desired_essid) == 0)
1444 /* Read scan results from the firmware */
1445 err = hermes_read_ltv(hw, USER_BAP,
1446 HERMES_RID_SCANRESULTSTABLE,
1447 MAX_SCAN_LEN, &len, buf);
1449 printk(KERN_ERR "%s: Cannot read scan results\n",
1454 len = HERMES_RECLEN_TO_BYTES(len);
1456 /* Go through the scan results looking for the channel of the AP
1457 * we were requested to join */
1458 for (; offset + atom_len <= len; offset += atom_len) {
1459 atom = (struct prism2_scan_apinfo *) (buf + offset);
1460 if (memcmp(&atom->bssid, priv->desired_bssid, ETH_ALEN) == 0) {
1467 DEBUG(1, "%s: Requested AP not found in scan results\n",
1472 memcpy(req.bssid, priv->desired_bssid, ETH_ALEN);
1473 req.channel = atom->channel; /* both are little-endian */
1474 err = HERMES_WRITE_RECORD(hw, USER_BAP, HERMES_RID_CNFJOINREQUEST,
1477 printk(KERN_ERR "%s: Error issuing join request\n", dev->name);
1480 orinoco_unlock(priv, &flags);
1486 /* Send new BSSID to userspace */
1487 static void orinoco_send_bssid_wevent(struct orinoco_private *priv)
1489 struct net_device *dev = priv->ndev;
1490 struct hermes *hw = &priv->hw;
1491 union iwreq_data wrqu;
1494 err = hermes_read_ltv(hw, IRQ_BAP, HERMES_RID_CURRENTBSSID,
1495 ETH_ALEN, NULL, wrqu.ap_addr.sa_data);
1499 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1501 /* Send event to user space */
1502 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
1505 static void orinoco_send_assocreqie_wevent(struct orinoco_private *priv)
1507 struct net_device *dev = priv->ndev;
1508 struct hermes *hw = &priv->hw;
1509 union iwreq_data wrqu;
1517 err = hermes_read_ltv(hw, IRQ_BAP, HERMES_RID_CURRENT_ASSOC_REQ_INFO,
1518 sizeof(buf), NULL, &buf);
1522 ie = orinoco_get_wpa_ie(buf, sizeof(buf));
1524 int rem = sizeof(buf) - (ie - &buf[0]);
1525 wrqu.data.length = ie[1] + 2;
1526 if (wrqu.data.length > rem)
1527 wrqu.data.length = rem;
1529 if (wrqu.data.length)
1530 /* Send event to user space */
1531 wireless_send_event(dev, IWEVASSOCREQIE, &wrqu, ie);
1535 static void orinoco_send_assocrespie_wevent(struct orinoco_private *priv)
1537 struct net_device *dev = priv->ndev;
1538 struct hermes *hw = &priv->hw;
1539 union iwreq_data wrqu;
1541 u8 buf[88]; /* TODO: verify max size or IW_GENERIC_IE_MAX */
1547 err = hermes_read_ltv(hw, IRQ_BAP, HERMES_RID_CURRENT_ASSOC_RESP_INFO,
1548 sizeof(buf), NULL, &buf);
1552 ie = orinoco_get_wpa_ie(buf, sizeof(buf));
1554 int rem = sizeof(buf) - (ie - &buf[0]);
1555 wrqu.data.length = ie[1] + 2;
1556 if (wrqu.data.length > rem)
1557 wrqu.data.length = rem;
1559 if (wrqu.data.length)
1560 /* Send event to user space */
1561 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, ie);
1565 static void orinoco_send_wevents(struct work_struct *work)
1567 struct orinoco_private *priv =
1568 container_of(work, struct orinoco_private, wevent_work);
1569 unsigned long flags;
1571 if (orinoco_lock(priv, &flags) != 0)
1574 orinoco_send_assocreqie_wevent(priv);
1575 orinoco_send_assocrespie_wevent(priv);
1576 orinoco_send_bssid_wevent(priv);
1578 orinoco_unlock(priv, &flags);
1581 static inline void orinoco_clear_scan_results(struct orinoco_private *priv,
1582 unsigned long scan_age)
1584 if (priv->has_ext_scan) {
1585 struct xbss_element *bss;
1586 struct xbss_element *tmp_bss;
1588 /* Blow away current list of scan results */
1589 list_for_each_entry_safe(bss, tmp_bss, &priv->bss_list, list) {
1591 time_after(jiffies, bss->last_scanned + scan_age)) {
1592 list_move_tail(&bss->list,
1593 &priv->bss_free_list);
1594 /* Don't blow away ->list, just BSS data */
1595 memset(&bss->bss, 0, sizeof(bss->bss));
1596 bss->last_scanned = 0;
1600 struct bss_element *bss;
1601 struct bss_element *tmp_bss;
1603 /* Blow away current list of scan results */
1604 list_for_each_entry_safe(bss, tmp_bss, &priv->bss_list, list) {
1606 time_after(jiffies, bss->last_scanned + scan_age)) {
1607 list_move_tail(&bss->list,
1608 &priv->bss_free_list);
1609 /* Don't blow away ->list, just BSS data */
1610 memset(&bss->bss, 0, sizeof(bss->bss));
1611 bss->last_scanned = 0;
1617 static void orinoco_add_ext_scan_result(struct orinoco_private *priv,
1618 struct agere_ext_scan_info *atom)
1620 struct xbss_element *bss = NULL;
1623 /* Try to update an existing bss first */
1624 list_for_each_entry(bss, &priv->bss_list, list) {
1625 if (compare_ether_addr(bss->bss.bssid, atom->bssid))
1628 if (bss->bss.data[1] != atom->data[1])
1630 if (memcmp(&bss->bss.data[2], &atom->data[2],
1637 /* Grab a bss off the free list */
1638 if (!found && !list_empty(&priv->bss_free_list)) {
1639 bss = list_entry(priv->bss_free_list.next,
1640 struct xbss_element, list);
1641 list_del(priv->bss_free_list.next);
1643 list_add_tail(&bss->list, &priv->bss_list);
1647 /* Always update the BSS to get latest beacon info */
1648 memcpy(&bss->bss, atom, sizeof(bss->bss));
1649 bss->last_scanned = jiffies;
1653 static int orinoco_process_scan_results(struct net_device *dev,
1657 struct orinoco_private *priv = netdev_priv(dev);
1658 int offset; /* In the scan data */
1659 union hermes_scan_info *atom;
1662 switch (priv->firmware_type) {
1663 case FIRMWARE_TYPE_AGERE:
1664 atom_len = sizeof(struct agere_scan_apinfo);
1667 case FIRMWARE_TYPE_SYMBOL:
1668 /* Lack of documentation necessitates this hack.
1669 * Different firmwares have 68 or 76 byte long atoms.
1670 * We try modulo first. If the length divides by both,
1671 * we check what would be the channel in the second
1672 * frame for a 68-byte atom. 76-byte atoms have 0 there.
1673 * Valid channel cannot be 0. */
1678 else if (len >= 1292 && buf[68] == 0)
1684 case FIRMWARE_TYPE_INTERSIL:
1686 if (priv->has_hostscan) {
1687 atom_len = le16_to_cpup((__le16 *)buf);
1688 /* Sanity check for atom_len */
1689 if (atom_len < sizeof(struct prism2_scan_apinfo)) {
1690 printk(KERN_ERR "%s: Invalid atom_len in scan "
1691 "data: %d\n", dev->name, atom_len);
1695 atom_len = offsetof(struct prism2_scan_apinfo, atim);
1701 /* Check that we got an whole number of atoms */
1702 if ((len - offset) % atom_len) {
1703 printk(KERN_ERR "%s: Unexpected scan data length %d, "
1704 "atom_len %d, offset %d\n", dev->name, len,
1709 orinoco_clear_scan_results(priv, msecs_to_jiffies(15000));
1711 /* Read the entries one by one */
1712 for (; offset + atom_len <= len; offset += atom_len) {
1714 struct bss_element *bss = NULL;
1717 atom = (union hermes_scan_info *) (buf + offset);
1719 /* Try to update an existing bss first */
1720 list_for_each_entry(bss, &priv->bss_list, list) {
1721 if (compare_ether_addr(bss->bss.a.bssid, atom->a.bssid))
1723 if (le16_to_cpu(bss->bss.a.essid_len) !=
1724 le16_to_cpu(atom->a.essid_len))
1726 if (memcmp(bss->bss.a.essid, atom->a.essid,
1727 le16_to_cpu(atom->a.essid_len)))
1733 /* Grab a bss off the free list */
1734 if (!found && !list_empty(&priv->bss_free_list)) {
1735 bss = list_entry(priv->bss_free_list.next,
1736 struct bss_element, list);
1737 list_del(priv->bss_free_list.next);
1739 list_add_tail(&bss->list, &priv->bss_list);
1743 /* Always update the BSS to get latest beacon info */
1744 memcpy(&bss->bss, atom, sizeof(bss->bss));
1745 bss->last_scanned = jiffies;
1752 static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1754 struct orinoco_private *priv = netdev_priv(dev);
1759 } __attribute__ ((packed)) info;
1763 /* This is an answer to an INQUIRE command that we did earlier,
1764 * or an information "event" generated by the card
1765 * The controller return to us a pseudo frame containing
1766 * the information in question - Jean II */
1767 infofid = hermes_read_regn(hw, INFOFID);
1769 /* Read the info frame header - don't try too hard */
1770 err = hermes_bap_pread(hw, IRQ_BAP, &info, sizeof(info),
1773 printk(KERN_ERR "%s: error %d reading info frame. "
1774 "Frame dropped.\n", dev->name, err);
1778 len = HERMES_RECLEN_TO_BYTES(le16_to_cpu(info.len));
1779 type = le16_to_cpu(info.type);
1782 case HERMES_INQ_TALLIES: {
1783 struct hermes_tallies_frame tallies;
1784 struct iw_statistics *wstats = &priv->wstats;
1786 if (len > sizeof(tallies)) {
1787 printk(KERN_WARNING "%s: Tallies frame too long (%d bytes)\n",
1789 len = sizeof(tallies);
1792 err = hermes_bap_pread(hw, IRQ_BAP, &tallies, len,
1793 infofid, sizeof(info));
1797 /* Increment our various counters */
1798 /* wstats->discard.nwid - no wrong BSSID stuff */
1799 wstats->discard.code +=
1800 le16_to_cpu(tallies.RxWEPUndecryptable);
1801 if (len == sizeof(tallies))
1802 wstats->discard.code +=
1803 le16_to_cpu(tallies.RxDiscards_WEPICVError) +
1804 le16_to_cpu(tallies.RxDiscards_WEPExcluded);
1805 wstats->discard.misc +=
1806 le16_to_cpu(tallies.TxDiscardsWrongSA);
1807 wstats->discard.fragment +=
1808 le16_to_cpu(tallies.RxMsgInBadMsgFragments);
1809 wstats->discard.retries +=
1810 le16_to_cpu(tallies.TxRetryLimitExceeded);
1811 /* wstats->miss.beacon - no match */
1814 case HERMES_INQ_LINKSTATUS: {
1815 struct hermes_linkstatus linkstatus;
1819 if (priv->iw_mode == IW_MODE_MONITOR)
1822 if (len != sizeof(linkstatus)) {
1823 printk(KERN_WARNING "%s: Unexpected size for linkstatus frame (%d bytes)\n",
1828 err = hermes_bap_pread(hw, IRQ_BAP, &linkstatus, len,
1829 infofid, sizeof(info));
1832 newstatus = le16_to_cpu(linkstatus.linkstatus);
1834 /* Symbol firmware uses "out of range" to signal that
1835 * the hostscan frame can be requested. */
1836 if (newstatus == HERMES_LINKSTATUS_AP_OUT_OF_RANGE &&
1837 priv->firmware_type == FIRMWARE_TYPE_SYMBOL &&
1838 priv->has_hostscan && priv->scan_inprogress) {
1839 hermes_inquire(hw, HERMES_INQ_HOSTSCAN_SYMBOL);
1843 connected = (newstatus == HERMES_LINKSTATUS_CONNECTED)
1844 || (newstatus == HERMES_LINKSTATUS_AP_CHANGE)
1845 || (newstatus == HERMES_LINKSTATUS_AP_IN_RANGE);
1848 netif_carrier_on(dev);
1849 else if (!ignore_disconnect)
1850 netif_carrier_off(dev);
1852 if (newstatus != priv->last_linkstatus) {
1853 priv->last_linkstatus = newstatus;
1854 print_linkstatus(dev, newstatus);
1855 /* The info frame contains only one word which is the
1856 * status (see hermes.h). The status is pretty boring
1857 * in itself, that's why we export the new BSSID...
1859 schedule_work(&priv->wevent_work);
1863 case HERMES_INQ_SCAN:
1864 if (!priv->scan_inprogress && priv->bssid_fixed &&
1865 priv->firmware_type == FIRMWARE_TYPE_INTERSIL) {
1866 schedule_work(&priv->join_work);
1870 case HERMES_INQ_HOSTSCAN:
1871 case HERMES_INQ_HOSTSCAN_SYMBOL: {
1872 /* Result of a scanning. Contains information about
1873 * cells in the vicinity - Jean II */
1874 union iwreq_data wrqu;
1877 /* Scan is no longer in progress */
1878 priv->scan_inprogress = 0;
1882 printk(KERN_WARNING "%s: Scan results too large (%d bytes)\n",
1887 /* Allocate buffer for results */
1888 buf = kmalloc(len, GFP_ATOMIC);
1890 /* No memory, so can't printk()... */
1893 /* Read scan data */
1894 err = hermes_bap_pread(hw, IRQ_BAP, (void *) buf, len,
1895 infofid, sizeof(info));
1901 #ifdef ORINOCO_DEBUG
1904 printk(KERN_DEBUG "Scan result [%02X", buf[0]);
1905 for(i = 1; i < (len * 2); i++)
1906 printk(":%02X", buf[i]);
1909 #endif /* ORINOCO_DEBUG */
1911 if (orinoco_process_scan_results(dev, buf, len) == 0) {
1912 /* Send an empty event to user space.
1913 * We don't send the received data on the event because
1914 * it would require us to do complex transcoding, and
1915 * we want to minimise the work done in the irq handler
1916 * Use a request to extract the data - Jean II */
1917 wrqu.data.length = 0;
1918 wrqu.data.flags = 0;
1919 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
1924 case HERMES_INQ_CHANNELINFO:
1926 struct agere_ext_scan_info *bss;
1928 if (!priv->scan_inprogress) {
1929 printk(KERN_DEBUG "%s: Got chaninfo without scan, "
1930 "len=%d\n", dev->name, len);
1934 /* An empty result indicates that the scan is complete */
1936 union iwreq_data wrqu;
1938 /* Scan is no longer in progress */
1939 priv->scan_inprogress = 0;
1941 wrqu.data.length = 0;
1942 wrqu.data.flags = 0;
1943 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
1948 else if (len > sizeof(*bss)) {
1950 "%s: Ext scan results too large (%d bytes). "
1951 "Truncating results to %zd bytes.\n",
1952 dev->name, len, sizeof(*bss));
1954 } else if (len < (offsetof(struct agere_ext_scan_info,
1956 /* Drop this result now so we don't have to
1957 * keep checking later */
1959 "%s: Ext scan results too short (%d bytes)\n",
1964 bss = kmalloc(sizeof(*bss), GFP_ATOMIC);
1968 /* Read scan data */
1969 err = hermes_bap_pread(hw, IRQ_BAP, (void *) bss, len,
1970 infofid, sizeof(info));
1976 orinoco_add_ext_scan_result(priv, bss);
1981 case HERMES_INQ_SEC_STAT_AGERE:
1982 /* Security status (Agere specific) */
1983 /* Ignore this frame for now */
1984 if (priv->firmware_type == FIRMWARE_TYPE_AGERE)
1988 printk(KERN_DEBUG "%s: Unknown information frame received: "
1989 "type 0x%04x, length %d\n", dev->name, type, len);
1990 /* We don't actually do anything about it */
1995 static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw)
1997 if (net_ratelimit())
1998 printk(KERN_DEBUG "%s: Information frame lost.\n", dev->name);
2001 /********************************************************************/
2002 /* Internal hardware control routines */
2003 /********************************************************************/
2005 int __orinoco_up(struct net_device *dev)
2007 struct orinoco_private *priv = netdev_priv(dev);
2008 struct hermes *hw = &priv->hw;
2011 netif_carrier_off(dev); /* just to make sure */
2013 err = __orinoco_program_rids(dev);
2015 printk(KERN_ERR "%s: Error %d configuring card\n",
2020 /* Fire things up again */
2021 hermes_set_irqmask(hw, ORINOCO_INTEN);
2022 err = hermes_enable_port(hw, 0);
2024 printk(KERN_ERR "%s: Error %d enabling MAC port\n",
2029 netif_start_queue(dev);
2034 int __orinoco_down(struct net_device *dev)
2036 struct orinoco_private *priv = netdev_priv(dev);
2037 struct hermes *hw = &priv->hw;
2040 netif_stop_queue(dev);
2042 if (! priv->hw_unavailable) {
2043 if (! priv->broken_disableport) {
2044 err = hermes_disable_port(hw, 0);
2046 /* Some firmwares (e.g. Intersil 1.3.x) seem
2047 * to have problems disabling the port, oh
2049 printk(KERN_WARNING "%s: Error %d disabling MAC port\n",
2051 priv->broken_disableport = 1;
2054 hermes_set_irqmask(hw, 0);
2055 hermes_write_regn(hw, EVACK, 0xffff);
2058 /* firmware will have to reassociate */
2059 netif_carrier_off(dev);
2060 priv->last_linkstatus = 0xffff;
2065 static int orinoco_allocate_fid(struct net_device *dev)
2067 struct orinoco_private *priv = netdev_priv(dev);
2068 struct hermes *hw = &priv->hw;
2071 err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid);
2072 if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) {
2073 /* Try workaround for old Symbol firmware bug */
2074 printk(KERN_WARNING "%s: firmware ALLOC bug detected "
2075 "(old Symbol firmware?). Trying to work around... ",
2078 priv->nicbuf_size = TX_NICBUF_SIZE_BUG;
2079 err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid);
2081 printk("failed!\n");
2089 int orinoco_reinit_firmware(struct net_device *dev)
2091 struct orinoco_private *priv = netdev_priv(dev);
2092 struct hermes *hw = &priv->hw;
2095 err = hermes_init(hw);
2097 err = orinoco_allocate_fid(dev);
2102 static int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
2104 hermes_t *hw = &priv->hw;
2107 if (priv->bitratemode >= BITRATE_TABLE_SIZE) {
2108 printk(KERN_ERR "%s: BUG: Invalid bitrate mode %d\n",
2109 priv->ndev->name, priv->bitratemode);
2113 switch (priv->firmware_type) {
2114 case FIRMWARE_TYPE_AGERE:
2115 err = hermes_write_wordrec(hw, USER_BAP,
2116 HERMES_RID_CNFTXRATECONTROL,
2117 bitrate_table[priv->bitratemode].agere_txratectrl);
2119 case FIRMWARE_TYPE_INTERSIL:
2120 case FIRMWARE_TYPE_SYMBOL:
2121 err = hermes_write_wordrec(hw, USER_BAP,
2122 HERMES_RID_CNFTXRATECONTROL,
2123 bitrate_table[priv->bitratemode].intersil_txratectrl);
2132 /* Set fixed AP address */
2133 static int __orinoco_hw_set_wap(struct orinoco_private *priv)
2137 hermes_t *hw = &priv->hw;
2139 switch (priv->firmware_type) {
2140 case FIRMWARE_TYPE_AGERE:
2143 case FIRMWARE_TYPE_INTERSIL:
2144 if (priv->bssid_fixed)
2149 err = hermes_write_wordrec(hw, USER_BAP,
2150 HERMES_RID_CNFROAMINGMODE,
2153 case FIRMWARE_TYPE_SYMBOL:
2154 err = HERMES_WRITE_RECORD(hw, USER_BAP,
2155 HERMES_RID_CNFMANDATORYBSSID_SYMBOL,
2156 &priv->desired_bssid);
2162 /* Change the WEP keys and/or the current keys. Can be called
2163 * either from __orinoco_hw_setup_enc() or directly from
2164 * orinoco_ioctl_setiwencode(). In the later case the association
2165 * with the AP is not broken (if the firmware can handle it),
2166 * which is needed for 802.1x implementations. */
2167 static int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv)
2169 hermes_t *hw = &priv->hw;
2172 switch (priv->firmware_type) {
2173 case FIRMWARE_TYPE_AGERE:
2174 err = HERMES_WRITE_RECORD(hw, USER_BAP,
2175 HERMES_RID_CNFWEPKEYS_AGERE,
2179 err = hermes_write_wordrec(hw, USER_BAP,
2180 HERMES_RID_CNFTXKEY_AGERE,
2185 case FIRMWARE_TYPE_INTERSIL:
2186 case FIRMWARE_TYPE_SYMBOL:
2191 /* Force uniform key length to work around firmware bugs */
2192 keylen = le16_to_cpu(priv->keys[priv->tx_key].len);
2194 if (keylen > LARGE_KEY_SIZE) {
2195 printk(KERN_ERR "%s: BUG: Key %d has oversize length %d.\n",
2196 priv->ndev->name, priv->tx_key, keylen);
2200 /* Write all 4 keys */
2201 for(i = 0; i < ORINOCO_MAX_KEYS; i++) {
2202 err = hermes_write_ltv(hw, USER_BAP,
2203 HERMES_RID_CNFDEFAULTKEY0 + i,
2204 HERMES_BYTES_TO_RECLEN(keylen),
2205 priv->keys[i].data);
2210 /* Write the index of the key used in transmission */
2211 err = hermes_write_wordrec(hw, USER_BAP,
2212 HERMES_RID_CNFWEPDEFAULTKEYID,
2223 static int __orinoco_hw_setup_enc(struct orinoco_private *priv)
2225 hermes_t *hw = &priv->hw;
2227 int master_wep_flag;
2231 /* Setup WEP keys for WEP and WPA */
2232 if (priv->encode_alg)
2233 __orinoco_hw_setup_wepkeys(priv);
2235 if (priv->wep_restrict)
2236 auth_flag = HERMES_AUTH_SHARED_KEY;
2238 auth_flag = HERMES_AUTH_OPEN;
2240 if (priv->wpa_enabled)
2242 else if (priv->encode_alg == IW_ENCODE_ALG_WEP)
2247 switch (priv->firmware_type) {
2248 case FIRMWARE_TYPE_AGERE: /* Agere style WEP */
2249 if (priv->encode_alg == IW_ENCODE_ALG_WEP) {
2250 /* Enable the shared-key authentication. */
2251 err = hermes_write_wordrec(hw, USER_BAP,
2252 HERMES_RID_CNFAUTHENTICATION_AGERE,
2255 err = hermes_write_wordrec(hw, USER_BAP,
2256 HERMES_RID_CNFWEPENABLED_AGERE,
2261 if (priv->has_wpa) {
2262 /* Set WPA key management */
2263 err = hermes_write_wordrec(hw, USER_BAP,
2264 HERMES_RID_CNFSETWPAAUTHMGMTSUITE_AGERE,
2272 case FIRMWARE_TYPE_INTERSIL: /* Intersil style WEP */
2273 case FIRMWARE_TYPE_SYMBOL: /* Symbol style WEP */
2274 if (priv->encode_alg == IW_ENCODE_ALG_WEP) {
2275 if (priv->wep_restrict ||
2276 (priv->firmware_type == FIRMWARE_TYPE_SYMBOL))
2277 master_wep_flag = HERMES_WEP_PRIVACY_INVOKED |
2278 HERMES_WEP_EXCL_UNENCRYPTED;
2280 master_wep_flag = HERMES_WEP_PRIVACY_INVOKED;
2282 err = hermes_write_wordrec(hw, USER_BAP,
2283 HERMES_RID_CNFAUTHENTICATION,
2288 master_wep_flag = 0;
2290 if (priv->iw_mode == IW_MODE_MONITOR)
2291 master_wep_flag |= HERMES_WEP_HOST_DECRYPT;
2293 /* Master WEP setting : on/off */
2294 err = hermes_write_wordrec(hw, USER_BAP,
2295 HERMES_RID_CNFWEPFLAGS_INTERSIL,
2306 /* key must be 32 bytes, including the tx and rx MIC keys.
2307 * rsc must be 8 bytes
2308 * tsc must be 8 bytes or NULL
2310 static int __orinoco_hw_set_tkip_key(hermes_t *hw, int key_idx, int set_tx,
2311 u8 *key, u8 *rsc, u8 *tsc)
2315 u8 rsc[IW_ENCODE_SEQ_MAX_SIZE];
2316 u8 key[TKIP_KEYLEN];
2317 u8 tx_mic[MIC_KEYLEN];
2318 u8 rx_mic[MIC_KEYLEN];
2319 u8 tsc[IW_ENCODE_SEQ_MAX_SIZE];
2320 } __attribute__ ((packed)) buf;
2331 buf.idx = cpu_to_le16(key_idx);
2332 memcpy(buf.key, key,
2333 sizeof(buf.key) + sizeof(buf.tx_mic) + sizeof(buf.rx_mic));
2336 memset(buf.rsc, 0, sizeof(buf.rsc));
2338 memcpy(buf.rsc, rsc, sizeof(buf.rsc));
2341 memset(buf.tsc, 0, sizeof(buf.tsc));
2344 memcpy(buf.tsc, tsc, sizeof(buf.tsc));
2347 /* Wait upto 100ms for tx queue to empty */
2352 ret = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_TXQUEUEEMPTY,
2356 } while ((k > 0) && xmitting);
2361 err = HERMES_WRITE_RECORD(hw, USER_BAP,
2362 HERMES_RID_CNFADDDEFAULTTKIPKEY_AGERE,
2365 return ret ? ret : err;
2368 static int orinoco_clear_tkip_key(struct orinoco_private *priv,
2371 hermes_t *hw = &priv->hw;
2374 memset(&priv->tkip_key[key_idx], 0, sizeof(priv->tkip_key[key_idx]));
2375 err = hermes_write_wordrec(hw, USER_BAP,
2376 HERMES_RID_CNFREMDEFAULTTKIPKEY_AGERE,
2379 printk(KERN_WARNING "%s: Error %d clearing TKIP key %d\n",
2380 priv->ndev->name, err, key_idx);
2384 static int __orinoco_program_rids(struct net_device *dev)
2386 struct orinoco_private *priv = netdev_priv(dev);
2387 hermes_t *hw = &priv->hw;
2389 struct hermes_idstring idbuf;
2391 /* Set the MAC address */
2392 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
2393 HERMES_BYTES_TO_RECLEN(ETH_ALEN), dev->dev_addr);
2395 printk(KERN_ERR "%s: Error %d setting MAC address\n",
2400 /* Set up the link mode */
2401 err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFPORTTYPE,
2404 printk(KERN_ERR "%s: Error %d setting port type\n",
2408 /* Set the channel/frequency */
2409 if (priv->channel != 0 && priv->iw_mode != IW_MODE_INFRA) {
2410 err = hermes_write_wordrec(hw, USER_BAP,
2411 HERMES_RID_CNFOWNCHANNEL,
2414 printk(KERN_ERR "%s: Error %d setting channel %d\n",
2415 dev->name, err, priv->channel);
2420 if (priv->has_ibss) {
2423 if ((strlen(priv->desired_essid) == 0) && (priv->createibss)) {
2424 printk(KERN_WARNING "%s: This firmware requires an "
2425 "ESSID in IBSS-Ad-Hoc mode.\n", dev->name);
2426 /* With wvlan_cs, in this case, we would crash.
2427 * hopefully, this driver will behave better...
2431 createibss = priv->createibss;
2434 err = hermes_write_wordrec(hw, USER_BAP,
2435 HERMES_RID_CNFCREATEIBSS,
2438 printk(KERN_ERR "%s: Error %d setting CREATEIBSS\n",
2444 /* Set the desired BSSID */
2445 err = __orinoco_hw_set_wap(priv);
2447 printk(KERN_ERR "%s: Error %d setting AP address\n",
2451 /* Set the desired ESSID */
2452 idbuf.len = cpu_to_le16(strlen(priv->desired_essid));
2453 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val));
2454 /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */
2455 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID,
2456 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2),
2459 printk(KERN_ERR "%s: Error %d setting OWNSSID\n",
2463 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID,
2464 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2),
2467 printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n",
2472 /* Set the station name */
2473 idbuf.len = cpu_to_le16(strlen(priv->nick));
2474 memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val));
2475 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
2476 HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2),
2479 printk(KERN_ERR "%s: Error %d setting nickname\n",
2484 /* Set AP density */
2485 if (priv->has_sensitivity) {
2486 err = hermes_write_wordrec(hw, USER_BAP,
2487 HERMES_RID_CNFSYSTEMSCALE,
2490 printk(KERN_WARNING "%s: Error %d setting SYSTEMSCALE. "
2491 "Disabling sensitivity control\n",
2494 priv->has_sensitivity = 0;
2498 /* Set RTS threshold */
2499 err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
2502 printk(KERN_ERR "%s: Error %d setting RTS threshold\n",
2507 /* Set fragmentation threshold or MWO robustness */
2509 err = hermes_write_wordrec(hw, USER_BAP,
2510 HERMES_RID_CNFMWOROBUST_AGERE,
2513 err = hermes_write_wordrec(hw, USER_BAP,
2514 HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
2517 printk(KERN_ERR "%s: Error %d setting fragmentation\n",
2523 err = __orinoco_hw_set_bitrate(priv);
2525 printk(KERN_ERR "%s: Error %d setting bitrate\n",
2530 /* Set power management */
2532 err = hermes_write_wordrec(hw, USER_BAP,
2533 HERMES_RID_CNFPMENABLED,
2536 printk(KERN_ERR "%s: Error %d setting up PM\n",
2541 err = hermes_write_wordrec(hw, USER_BAP,
2542 HERMES_RID_CNFMULTICASTRECEIVE,
2545 printk(KERN_ERR "%s: Error %d setting up PM\n",
2549 err = hermes_write_wordrec(hw, USER_BAP,
2550 HERMES_RID_CNFMAXSLEEPDURATION,
2553 printk(KERN_ERR "%s: Error %d setting up PM\n",
2557 err = hermes_write_wordrec(hw, USER_BAP,
2558 HERMES_RID_CNFPMHOLDOVERDURATION,
2561 printk(KERN_ERR "%s: Error %d setting up PM\n",
2567 /* Set preamble - only for Symbol so far... */
2568 if (priv->has_preamble) {
2569 err = hermes_write_wordrec(hw, USER_BAP,
2570 HERMES_RID_CNFPREAMBLE_SYMBOL,
2573 printk(KERN_ERR "%s: Error %d setting preamble\n",
2579 /* Set up encryption */
2580 if (priv->has_wep || priv->has_wpa) {
2581 err = __orinoco_hw_setup_enc(priv);
2583 printk(KERN_ERR "%s: Error %d activating encryption\n",
2589 if (priv->iw_mode == IW_MODE_MONITOR) {
2590 /* Enable monitor mode */
2591 dev->type = ARPHRD_IEEE80211;
2592 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
2593 HERMES_TEST_MONITOR, 0, NULL);
2595 /* Disable monitor mode */
2596 dev->type = ARPHRD_ETHER;
2597 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
2598 HERMES_TEST_STOP, 0, NULL);
2603 /* Set promiscuity / multicast*/
2604 priv->promiscuous = 0;
2607 /* FIXME: what about netif_tx_lock */
2608 __orinoco_set_multicast_list(dev);
2613 /* FIXME: return int? */
2615 __orinoco_set_multicast_list(struct net_device *dev)
2617 struct orinoco_private *priv = netdev_priv(dev);
2618 hermes_t *hw = &priv->hw;
2620 int promisc, mc_count;
2622 /* The Hermes doesn't seem to have an allmulti mode, so we go
2623 * into promiscuous mode and let the upper levels deal. */
2624 if ( (dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI) ||
2625 (dev->mc_count > MAX_MULTICAST(priv)) ) {
2630 mc_count = dev->mc_count;
2633 if (promisc != priv->promiscuous) {
2634 err = hermes_write_wordrec(hw, USER_BAP,
2635 HERMES_RID_CNFPROMISCUOUSMODE,
2638 printk(KERN_ERR "%s: Error %d setting PROMISCUOUSMODE to 1.\n",
2641 priv->promiscuous = promisc;
2644 if (! promisc && (mc_count || priv->mc_count) ) {
2645 struct dev_mc_list *p = dev->mc_list;
2646 struct hermes_multicast mclist;
2649 for (i = 0; i < mc_count; i++) {
2650 /* paranoia: is list shorter than mc_count? */
2652 /* paranoia: bad address size in list? */
2653 BUG_ON(p->dmi_addrlen != ETH_ALEN);
2655 memcpy(mclist.addr[i], p->dmi_addr, ETH_ALEN);
2660 printk(KERN_WARNING "%s: Multicast list is "
2661 "longer than mc_count\n", dev->name);
2663 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFGROUPADDRESSES,
2664 HERMES_BYTES_TO_RECLEN(priv->mc_count * ETH_ALEN),
2667 printk(KERN_ERR "%s: Error %d setting multicast list.\n",
2670 priv->mc_count = mc_count;
2674 /* This must be called from user context, without locks held - use
2675 * schedule_work() */
2676 static void orinoco_reset(struct work_struct *work)
2678 struct orinoco_private *priv =
2679 container_of(work, struct orinoco_private, reset_work);
2680 struct net_device *dev = priv->ndev;
2681 struct hermes *hw = &priv->hw;
2683 unsigned long flags;
2685 if (orinoco_lock(priv, &flags) != 0)
2686 /* When the hardware becomes available again, whatever
2687 * detects that is responsible for re-initializing
2688 * it. So no need for anything further */
2691 netif_stop_queue(dev);
2693 /* Shut off interrupts. Depending on what state the hardware
2694 * is in, this might not work, but we'll try anyway */
2695 hermes_set_irqmask(hw, 0);
2696 hermes_write_regn(hw, EVACK, 0xffff);
2698 priv->hw_unavailable++;
2699 priv->last_linkstatus = 0xffff; /* firmware will have to reassociate */
2700 netif_carrier_off(dev);
2702 orinoco_unlock(priv, &flags);
2704 /* Scanning support: Cleanup of driver struct */
2705 orinoco_clear_scan_results(priv, 0);
2706 priv->scan_inprogress = 0;
2708 if (priv->hard_reset) {
2709 err = (*priv->hard_reset)(priv);
2711 printk(KERN_ERR "%s: orinoco_reset: Error %d "
2712 "performing hard reset\n", dev->name, err);
2717 if (priv->do_fw_download) {
2718 err = orinoco_download(priv);
2720 priv->do_fw_download = 0;
2723 err = orinoco_reinit_firmware(dev);
2725 printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n",
2730 spin_lock_irq(&priv->lock); /* This has to be called from user context */
2732 priv->hw_unavailable--;
2734 /* priv->open or priv->hw_unavailable might have changed while
2735 * we dropped the lock */
2736 if (priv->open && (! priv->hw_unavailable)) {
2737 err = __orinoco_up(dev);
2739 printk(KERN_ERR "%s: orinoco_reset: Error %d reenabling card\n",
2742 dev->trans_start = jiffies;
2745 spin_unlock_irq(&priv->lock);
2749 hermes_set_irqmask(hw, 0);
2750 netif_device_detach(dev);
2751 printk(KERN_ERR "%s: Device has been disabled!\n", dev->name);
2754 /********************************************************************/
2755 /* Interrupt handler */
2756 /********************************************************************/
2758 static void __orinoco_ev_tick(struct net_device *dev, hermes_t *hw)
2760 printk(KERN_DEBUG "%s: TICK\n", dev->name);
2763 static void __orinoco_ev_wterr(struct net_device *dev, hermes_t *hw)
2765 /* This seems to happen a fair bit under load, but ignoring it
2766 seems to work fine...*/
2767 printk(KERN_DEBUG "%s: MAC controller error (WTERR). Ignoring.\n",
2771 irqreturn_t orinoco_interrupt(int irq, void *dev_id)
2773 struct net_device *dev = dev_id;
2774 struct orinoco_private *priv = netdev_priv(dev);
2775 hermes_t *hw = &priv->hw;
2776 int count = MAX_IRQLOOPS_PER_IRQ;
2778 /* These are used to detect a runaway interrupt situation */
2779 /* If we get more than MAX_IRQLOOPS_PER_JIFFY iterations in a jiffy,
2780 * we panic and shut down the hardware */
2781 static int last_irq_jiffy = 0; /* jiffies value the last time
2783 static int loops_this_jiffy = 0;
2784 unsigned long flags;
2786 if (orinoco_lock(priv, &flags) != 0) {
2787 /* If hw is unavailable - we don't know if the irq was
2792 evstat = hermes_read_regn(hw, EVSTAT);
2793 events = evstat & hw->inten;
2795 orinoco_unlock(priv, &flags);
2799 if (jiffies != last_irq_jiffy)
2800 loops_this_jiffy = 0;
2801 last_irq_jiffy = jiffies;
2803 while (events && count--) {
2804 if (++loops_this_jiffy > MAX_IRQLOOPS_PER_JIFFY) {
2805 printk(KERN_WARNING "%s: IRQ handler is looping too "
2806 "much! Resetting.\n", dev->name);
2807 /* Disable interrupts for now */
2808 hermes_set_irqmask(hw, 0);
2809 schedule_work(&priv->reset_work);
2813 /* Check the card hasn't been removed */
2814 if (! hermes_present(hw)) {
2815 DEBUG(0, "orinoco_interrupt(): card removed\n");
2819 if (events & HERMES_EV_TICK)
2820 __orinoco_ev_tick(dev, hw);
2821 if (events & HERMES_EV_WTERR)
2822 __orinoco_ev_wterr(dev, hw);
2823 if (events & HERMES_EV_INFDROP)
2824 __orinoco_ev_infdrop(dev, hw);
2825 if (events & HERMES_EV_INFO)
2826 __orinoco_ev_info(dev, hw);
2827 if (events & HERMES_EV_RX)
2828 __orinoco_ev_rx(dev, hw);
2829 if (events & HERMES_EV_TXEXC)
2830 __orinoco_ev_txexc(dev, hw);
2831 if (events & HERMES_EV_TX)
2832 __orinoco_ev_tx(dev, hw);
2833 if (events & HERMES_EV_ALLOC)
2834 __orinoco_ev_alloc(dev, hw);
2836 hermes_write_regn(hw, EVACK, evstat);
2838 evstat = hermes_read_regn(hw, EVSTAT);
2839 events = evstat & hw->inten;
2842 orinoco_unlock(priv, &flags);
2846 /********************************************************************/
2847 /* Initialization */
2848 /********************************************************************/
2851 u16 id, variant, major, minor;
2852 } __attribute__ ((packed));
2854 static inline fwtype_t determine_firmware_type(struct comp_id *nic_id)
2856 if (nic_id->id < 0x8000)
2857 return FIRMWARE_TYPE_AGERE;
2858 else if (nic_id->id == 0x8000 && nic_id->major == 0)
2859 return FIRMWARE_TYPE_SYMBOL;
2861 return FIRMWARE_TYPE_INTERSIL;
2864 /* Set priv->firmware type, determine firmware properties */
2865 static int determine_firmware(struct net_device *dev)
2867 struct orinoco_private *priv = netdev_priv(dev);
2868 hermes_t *hw = &priv->hw;
2870 struct comp_id nic_id, sta_id;
2871 unsigned int firmver;
2872 char tmp[SYMBOL_MAX_VER_LEN+1] __attribute__((aligned(2)));
2874 /* Get the hardware version */
2875 err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id);
2877 printk(KERN_ERR "%s: Cannot read hardware identity: error %d\n",
2882 le16_to_cpus(&nic_id.id);
2883 le16_to_cpus(&nic_id.variant);
2884 le16_to_cpus(&nic_id.major);
2885 le16_to_cpus(&nic_id.minor);
2886 printk(KERN_DEBUG "%s: Hardware identity %04x:%04x:%04x:%04x\n",
2887 dev->name, nic_id.id, nic_id.variant,
2888 nic_id.major, nic_id.minor);
2890 priv->firmware_type = determine_firmware_type(&nic_id);
2892 /* Get the firmware version */
2893 err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id);
2895 printk(KERN_ERR "%s: Cannot read station identity: error %d\n",
2900 le16_to_cpus(&sta_id.id);
2901 le16_to_cpus(&sta_id.variant);
2902 le16_to_cpus(&sta_id.major);
2903 le16_to_cpus(&sta_id.minor);
2904 printk(KERN_DEBUG "%s: Station identity %04x:%04x:%04x:%04x\n",
2905 dev->name, sta_id.id, sta_id.variant,
2906 sta_id.major, sta_id.minor);
2908 switch (sta_id.id) {
2910 printk(KERN_ERR "%s: Primary firmware is active\n",
2914 printk(KERN_ERR "%s: Tertiary firmware is active\n",
2917 case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */
2918 case 0x21: /* Symbol Spectrum24 Trilogy */
2921 printk(KERN_NOTICE "%s: Unknown station ID, please report\n",
2926 /* Default capabilities */
2927 priv->has_sensitivity = 1;
2929 priv->has_preamble = 0;
2930 priv->has_port3 = 1;
2933 priv->has_big_wep = 0;
2934 priv->has_alt_txcntl = 0;
2935 priv->has_ext_scan = 0;
2937 priv->do_fw_download = 0;
2939 /* Determine capabilities from the firmware version */
2940 switch (priv->firmware_type) {
2941 case FIRMWARE_TYPE_AGERE:
2942 /* Lucent Wavelan IEEE, Lucent Orinoco, Cabletron RoamAbout,
2943 ELSA, Melco, HP, IBM, Dell 1150, Compaq 110/210 */
2944 snprintf(priv->fw_name, sizeof(priv->fw_name) - 1,
2945 "Lucent/Agere %d.%02d", sta_id.major, sta_id.minor);
2947 firmver = ((unsigned long)sta_id.major << 16) | sta_id.minor;
2949 priv->has_ibss = (firmver >= 0x60006);
2950 priv->has_wep = (firmver >= 0x40020);
2951 priv->has_big_wep = 1; /* FIXME: this is wrong - how do we tell
2952 Gold cards from the others? */
2953 priv->has_mwo = (firmver >= 0x60000);
2954 priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */
2955 priv->ibss_port = 1;
2956 priv->has_hostscan = (firmver >= 0x8000a);
2957 priv->do_fw_download = 1;
2958 priv->broken_monitor = (firmver >= 0x80000);
2959 priv->has_alt_txcntl = (firmver >= 0x90000); /* All 9.x ? */
2960 priv->has_ext_scan = (firmver >= 0x90000); /* All 9.x ? */
2961 priv->has_wpa = (firmver >= 0x9002a);
2962 /* Tested with Agere firmware :
2963 * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II
2964 * Tested CableTron firmware : 4.32 => Anton */
2966 case FIRMWARE_TYPE_SYMBOL:
2967 /* Symbol , 3Com AirConnect, Intel, Ericsson WLAN */
2968 /* Intel MAC : 00:02:B3:* */
2969 /* 3Com MAC : 00:50:DA:* */
2970 memset(tmp, 0, sizeof(tmp));
2971 /* Get the Symbol firmware version */
2972 err = hermes_read_ltv(hw, USER_BAP,
2973 HERMES_RID_SECONDARYVERSION_SYMBOL,
2974 SYMBOL_MAX_VER_LEN, NULL, &tmp);
2977 "%s: Error %d reading Symbol firmware info. Wildly guessing capabilities...\n",
2982 /* The firmware revision is a string, the format is
2983 * something like : "V2.20-01".
2984 * Quick and dirty parsing... - Jean II
2986 firmver = ((tmp[1] - '0') << 16) | ((tmp[3] - '0') << 12)
2987 | ((tmp[4] - '0') << 8) | ((tmp[6] - '0') << 4)
2990 tmp[SYMBOL_MAX_VER_LEN] = '\0';
2993 snprintf(priv->fw_name, sizeof(priv->fw_name) - 1,
2996 priv->has_ibss = (firmver >= 0x20000);
2997 priv->has_wep = (firmver >= 0x15012);
2998 priv->has_big_wep = (firmver >= 0x20000);
2999 priv->has_pm = (firmver >= 0x20000 && firmver < 0x22000) ||
3000 (firmver >= 0x29000 && firmver < 0x30000) ||
3002 priv->has_preamble = (firmver >= 0x20000);
3003 priv->ibss_port = 4;
3005 /* Symbol firmware is found on various cards, but
3006 * there has been no attempt to check firmware
3007 * download on non-spectrum_cs based cards.
3009 * Given that the Agere firmware download works
3010 * differently, we should avoid doing a firmware
3011 * download with the Symbol algorithm on non-spectrum
3014 * For now we can identify a spectrum_cs based card
3015 * because it has a firmware reset function.
3017 priv->do_fw_download = (priv->stop_fw != NULL);
3019 priv->broken_disableport = (firmver == 0x25013) ||
3020 (firmver >= 0x30000 && firmver <= 0x31000);
3021 priv->has_hostscan = (firmver >= 0x31001) ||
3022 (firmver >= 0x29057 && firmver < 0x30000);
3023 /* Tested with Intel firmware : 0x20015 => Jean II */
3024 /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */
3026 case FIRMWARE_TYPE_INTERSIL:
3027 /* D-Link, Linksys, Adtron, ZoomAir, and many others...
3028 * Samsung, Compaq 100/200 and Proxim are slightly
3029 * different and less well tested */
3030 /* D-Link MAC : 00:40:05:* */
3031 /* Addtron MAC : 00:90:D1:* */
3032 snprintf(priv->fw_name, sizeof(priv->fw_name) - 1,
3033 "Intersil %d.%d.%d", sta_id.major, sta_id.minor,
3036 firmver = ((unsigned long)sta_id.major << 16) |
3037 ((unsigned long)sta_id.minor << 8) | sta_id.variant;
3039 priv->has_ibss = (firmver >= 0x000700); /* FIXME */
3040 priv->has_big_wep = priv->has_wep = (firmver >= 0x000800);
3041 priv->has_pm = (firmver >= 0x000700);
3042 priv->has_hostscan = (firmver >= 0x010301);
3044 if (firmver >= 0x000800)
3045 priv->ibss_port = 0;
3047 printk(KERN_NOTICE "%s: Intersil firmware earlier "
3048 "than v0.8.x - several features not supported\n",
3050 priv->ibss_port = 1;
3054 printk(KERN_DEBUG "%s: Firmware determined as %s\n", dev->name,
3060 static int orinoco_init(struct net_device *dev)
3062 struct orinoco_private *priv = netdev_priv(dev);
3063 hermes_t *hw = &priv->hw;
3065 struct hermes_idstring nickbuf;
3068 DECLARE_MAC_BUF(mac);
3070 /* No need to lock, the hw_unavailable flag is already set in
3071 * alloc_orinocodev() */
3072 priv->nicbuf_size = IEEE80211_FRAME_LEN + ETH_HLEN;
3074 /* Initialize the firmware */
3075 err = hermes_init(hw);
3077 printk(KERN_ERR "%s: failed to initialize firmware (err = %d)\n",
3082 err = determine_firmware(dev);
3084 printk(KERN_ERR "%s: Incompatible firmware, aborting\n",
3089 if (priv->do_fw_download) {
3090 err = orinoco_download(priv);
3092 priv->do_fw_download = 0;
3094 /* Check firmware version again */
3095 err = determine_firmware(dev);
3097 printk(KERN_ERR "%s: Incompatible firmware, aborting\n",
3103 if (priv->has_port3)
3104 printk(KERN_DEBUG "%s: Ad-hoc demo mode supported\n", dev->name);
3106 printk(KERN_DEBUG "%s: IEEE standard IBSS ad-hoc mode supported\n",
3108 if (priv->has_wep) {
3109 printk(KERN_DEBUG "%s: WEP supported, ", dev->name);
3110 if (priv->has_big_wep)
3111 printk("104-bit key\n");
3113 printk("40-bit key\n");
3116 printk(KERN_DEBUG "%s: WPA-PSK supported\n", dev->name);
3118 /* Now we have the firmware capabilities, allocate appropiate
3119 * sized scan buffers */
3120 if (orinoco_bss_data_allocate(priv))
3122 orinoco_bss_data_init(priv);
3124 /* Get the MAC address */
3125 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
3126 ETH_ALEN, NULL, dev->dev_addr);
3128 printk(KERN_WARNING "%s: failed to read MAC address!\n",
3133 printk(KERN_DEBUG "%s: MAC address %s\n",
3134 dev->name, print_mac(mac, dev->dev_addr));
3136 /* Get the station name */
3137 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
3138 sizeof(nickbuf), &reclen, &nickbuf);
3140 printk(KERN_ERR "%s: failed to read station name\n",
3145 len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len));
3147 len = min(IW_ESSID_MAX_SIZE, 2 * reclen);
3148 memcpy(priv->nick, &nickbuf.val, len);
3149 priv->nick[len] = '\0';
3151 printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick);
3153 err = orinoco_allocate_fid(dev);
3155 printk(KERN_ERR "%s: failed to allocate NIC buffer!\n",
3160 /* Get allowed channels */
3161 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST,
3162 &priv->channel_mask);
3164 printk(KERN_ERR "%s: failed to read channel list!\n",
3169 /* Get initial AP density */
3170 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE,
3172 if (err || priv->ap_density < 1 || priv->ap_density > 3) {
3173 priv->has_sensitivity = 0;
3176 /* Get initial RTS threshold */
3177 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
3180 printk(KERN_ERR "%s: failed to read RTS threshold!\n",
3185 /* Get initial fragmentation settings */
3187 err = hermes_read_wordrec(hw, USER_BAP,
3188 HERMES_RID_CNFMWOROBUST_AGERE,
3191 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
3192 &priv->frag_thresh);
3194 printk(KERN_ERR "%s: failed to read fragmentation settings!\n",
3199 /* Power management setup */
3203 err = hermes_read_wordrec(hw, USER_BAP,
3204 HERMES_RID_CNFMAXSLEEPDURATION,
3207 printk(KERN_ERR "%s: failed to read power management period!\n",
3211 err = hermes_read_wordrec(hw, USER_BAP,
3212 HERMES_RID_CNFPMHOLDOVERDURATION,
3215 printk(KERN_ERR "%s: failed to read power management timeout!\n",
3221 /* Preamble setup */
3222 if (priv->has_preamble) {
3223 err = hermes_read_wordrec(hw, USER_BAP,
3224 HERMES_RID_CNFPREAMBLE_SYMBOL,
3230 /* Set up the default configuration */
3231 priv->iw_mode = IW_MODE_INFRA;
3232 /* By default use IEEE/IBSS ad-hoc mode if we have it */
3233 priv->prefer_port3 = priv->has_port3 && (! priv->has_ibss);
3234 set_port_type(priv);
3235 priv->channel = 0; /* use firmware default */
3237 priv->promiscuous = 0;
3238 priv->encode_alg = IW_ENCODE_ALG_NONE;
3240 priv->wpa_enabled = 0;
3241 priv->tkip_cm_active = 0;
3243 priv->wpa_ie_len = 0;
3244 priv->wpa_ie = NULL;
3246 /* Make the hardware available, as long as it hasn't been
3247 * removed elsewhere (e.g. by PCMCIA hot unplug) */
3248 spin_lock_irq(&priv->lock);
3249 priv->hw_unavailable--;
3250 spin_unlock_irq(&priv->lock);
3252 printk(KERN_DEBUG "%s: ready\n", dev->name);
3259 *alloc_orinocodev(int sizeof_card,
3260 struct device *device,
3261 int (*hard_reset)(struct orinoco_private *),
3262 int (*stop_fw)(struct orinoco_private *, int))
3264 struct net_device *dev;
3265 struct orinoco_private *priv;
3267 dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card);
3270 priv = netdev_priv(dev);
3273 priv->card = (void *)((unsigned long)priv
3274 + sizeof(struct orinoco_private));
3279 /* Setup / override net_device fields */
3280 dev->init = orinoco_init;
3281 dev->hard_start_xmit = orinoco_xmit;
3282 dev->tx_timeout = orinoco_tx_timeout;
3283 dev->watchdog_timeo = HZ; /* 1 second timeout */
3284 dev->get_stats = orinoco_get_stats;
3285 dev->ethtool_ops = &orinoco_ethtool_ops;
3286 dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def;
3288 priv->wireless_data.spy_data = &priv->spy_data;
3289 dev->wireless_data = &priv->wireless_data;
3291 dev->change_mtu = orinoco_change_mtu;
3292 dev->set_multicast_list = orinoco_set_multicast_list;
3293 /* we use the default eth_mac_addr for setting the MAC addr */
3295 /* Set up default callbacks */
3296 dev->open = orinoco_open;
3297 dev->stop = orinoco_stop;
3298 priv->hard_reset = hard_reset;
3299 priv->stop_fw = stop_fw;
3301 spin_lock_init(&priv->lock);
3303 priv->hw_unavailable = 1; /* orinoco_init() must clear this
3304 * before anything else touches the
3306 INIT_WORK(&priv->reset_work, orinoco_reset);
3307 INIT_WORK(&priv->join_work, orinoco_join_ap);
3308 INIT_WORK(&priv->wevent_work, orinoco_send_wevents);
3310 INIT_LIST_HEAD(&priv->rx_list);
3311 tasklet_init(&priv->rx_tasklet, orinoco_rx_isr_tasklet,
3312 (unsigned long) dev);
3314 netif_carrier_off(dev);
3315 priv->last_linkstatus = 0xffff;
3320 void free_orinocodev(struct net_device *dev)
3322 struct orinoco_private *priv = netdev_priv(dev);
3324 /* No need to empty priv->rx_list: if the tasklet is scheduled
3325 * when we call tasklet_kill it will run one final time,
3326 * emptying the list */
3327 tasklet_kill(&priv->rx_tasklet);
3328 priv->wpa_ie_len = 0;
3329 kfree(priv->wpa_ie);
3330 orinoco_bss_data_free(priv);
3334 /********************************************************************/
3335 /* Wireless extensions */
3336 /********************************************************************/
3338 /* Return : < 0 -> error code ; >= 0 -> length */
3339 static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
3340 char buf[IW_ESSID_MAX_SIZE+1])
3342 hermes_t *hw = &priv->hw;
3344 struct hermes_idstring essidbuf;
3345 char *p = (char *)(&essidbuf.val);
3347 unsigned long flags;
3349 if (orinoco_lock(priv, &flags) != 0)
3352 if (strlen(priv->desired_essid) > 0) {
3353 /* We read the desired SSID from the hardware rather
3354 than from priv->desired_essid, just in case the
3355 firmware is allowed to change it on us. I'm not
3357 /* My guess is that the OWNSSID should always be whatever
3358 * we set to the card, whereas CURRENT_SSID is the one that
3359 * may change... - Jean II */
3364 rid = (priv->port_type == 3) ? HERMES_RID_CNFOWNSSID :
3365 HERMES_RID_CNFDESIREDSSID;
3367 err = hermes_read_ltv(hw, USER_BAP, rid, sizeof(essidbuf),
3374 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTSSID,
3375 sizeof(essidbuf), NULL, &essidbuf);
3380 len = le16_to_cpu(essidbuf.len);
3381 BUG_ON(len > IW_ESSID_MAX_SIZE);
3383 memset(buf, 0, IW_ESSID_MAX_SIZE);
3384 memcpy(buf, p, len);
3388 orinoco_unlock(priv, &flags);
3393 static long orinoco_hw_get_freq(struct orinoco_private *priv)
3396 hermes_t *hw = &priv->hw;
3400 unsigned long flags;
3402 if (orinoco_lock(priv, &flags) != 0)
3405 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CURRENTCHANNEL, &channel);
3409 /* Intersil firmware 1.3.5 returns 0 when the interface is down */
3415 if ( (channel < 1) || (channel > NUM_CHANNELS) ) {
3416 printk(KERN_WARNING "%s: Channel out of range (%d)!\n",
3417 priv->ndev->name, channel);
3422 freq = channel_frequency[channel-1] * 100000;
3425 orinoco_unlock(priv, &flags);
3429 return err ? err : freq;
3432 static int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
3433 int *numrates, s32 *rates, int max)
3435 hermes_t *hw = &priv->hw;
3436 struct hermes_idstring list;
3437 unsigned char *p = (unsigned char *)&list.val;
3441 unsigned long flags;
3443 if (orinoco_lock(priv, &flags) != 0)
3446 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_SUPPORTEDDATARATES,
3447 sizeof(list), NULL, &list);
3448 orinoco_unlock(priv, &flags);
3453 num = le16_to_cpu(list.len);
3455 num = min(num, max);
3457 for (i = 0; i < num; i++) {
3458 rates[i] = (p[i] & 0x7f) * 500000; /* convert to bps */
3464 static int orinoco_ioctl_getname(struct net_device *dev,
3465 struct iw_request_info *info,
3469 struct orinoco_private *priv = netdev_priv(dev);
3473 err = orinoco_hw_get_bitratelist(priv, &numrates, NULL, 0);
3475 if (!err && (numrates > 2))
3476 strcpy(name, "IEEE 802.11b");
3478 strcpy(name, "IEEE 802.11-DS");
3483 static int orinoco_ioctl_setwap(struct net_device *dev,
3484 struct iw_request_info *info,
3485 struct sockaddr *ap_addr,
3488 struct orinoco_private *priv = netdev_priv(dev);
3489 int err = -EINPROGRESS; /* Call commit handler */
3490 unsigned long flags;
3491 static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
3492 static const u8 any_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
3494 if (orinoco_lock(priv, &flags) != 0)
3497 /* Enable automatic roaming - no sanity checks are needed */
3498 if (memcmp(&ap_addr->sa_data, off_addr, ETH_ALEN) == 0 ||
3499 memcmp(&ap_addr->sa_data, any_addr, ETH_ALEN) == 0) {
3500 priv->bssid_fixed = 0;
3501 memset(priv->desired_bssid, 0, ETH_ALEN);
3503 /* "off" means keep existing connection */
3504 if (ap_addr->sa_data[0] == 0) {
3505 __orinoco_hw_set_wap(priv);
3511 if (priv->firmware_type == FIRMWARE_TYPE_AGERE) {
3512 printk(KERN_WARNING "%s: Lucent/Agere firmware doesn't "
3513 "support manual roaming\n",
3519 if (priv->iw_mode != IW_MODE_INFRA) {
3520 printk(KERN_WARNING "%s: Manual roaming supported only in "
3521 "managed mode\n", dev->name);
3526 /* Intersil firmware hangs without Desired ESSID */
3527 if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL &&
3528 strlen(priv->desired_essid) == 0) {
3529 printk(KERN_WARNING "%s: Desired ESSID must be set for "
3530 "manual roaming\n", dev->name);
3535 /* Finally, enable manual roaming */
3536 priv->bssid_fixed = 1;
3537 memcpy(priv->desired_bssid, &ap_addr->sa_data, ETH_ALEN);
3540 orinoco_unlock(priv, &flags);
3544 static int orinoco_ioctl_getwap(struct net_device *dev,
3545 struct iw_request_info *info,
3546 struct sockaddr *ap_addr,
3549 struct orinoco_private *priv = netdev_priv(dev);
3551 hermes_t *hw = &priv->hw;
3553 unsigned long flags;
3555 if (orinoco_lock(priv, &flags) != 0)
3558 ap_addr->sa_family = ARPHRD_ETHER;
3559 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
3560 ETH_ALEN, NULL, ap_addr->sa_data);
3562 orinoco_unlock(priv, &flags);
3567 static int orinoco_ioctl_setmode(struct net_device *dev,
3568 struct iw_request_info *info,
3572 struct orinoco_private *priv = netdev_priv(dev);
3573 int err = -EINPROGRESS; /* Call commit handler */
3574 unsigned long flags;
3576 if (priv->iw_mode == *mode)
3579 if (orinoco_lock(priv, &flags) != 0)
3584 if (!priv->has_ibss && !priv->has_port3)
3591 case IW_MODE_MONITOR:
3592 if (priv->broken_monitor && !force_monitor) {
3593 printk(KERN_WARNING "%s: Monitor mode support is "
3594 "buggy in this firmware, not enabling\n",
3605 if (err == -EINPROGRESS) {
3606 priv->iw_mode = *mode;
3607 set_port_type(priv);
3610 orinoco_unlock(priv, &flags);
3615 static int orinoco_ioctl_getmode(struct net_device *dev,
3616 struct iw_request_info *info,
3620 struct orinoco_private *priv = netdev_priv(dev);
3622 *mode = priv->iw_mode;
3626 static int orinoco_ioctl_getiwrange(struct net_device *dev,
3627 struct iw_request_info *info,
3628 struct iw_point *rrq,
3631 struct orinoco_private *priv = netdev_priv(dev);
3633 struct iw_range *range = (struct iw_range *) extra;
3637 rrq->length = sizeof(struct iw_range);
3638 memset(range, 0, sizeof(struct iw_range));
3640 range->we_version_compiled = WIRELESS_EXT;
3641 range->we_version_source = 22;
3643 /* Set available channels/frequencies */
3644 range->num_channels = NUM_CHANNELS;
3646 for (i = 0; i < NUM_CHANNELS; i++) {
3647 if (priv->channel_mask & (1 << i)) {
3648 range->freq[k].i = i + 1;
3649 range->freq[k].m = channel_frequency[i] * 100000;
3650 range->freq[k].e = 1;
3654 if (k >= IW_MAX_FREQUENCIES)
3657 range->num_frequency = k;
3658 range->sensitivity = 3;
3660 if (priv->has_wep) {
3661 range->max_encoding_tokens = ORINOCO_MAX_KEYS;
3662 range->encoding_size[0] = SMALL_KEY_SIZE;
3663 range->num_encoding_sizes = 1;
3665 if (priv->has_big_wep) {
3666 range->encoding_size[1] = LARGE_KEY_SIZE;
3667 range->num_encoding_sizes = 2;
3672 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_CIPHER_TKIP;
3674 if ((priv->iw_mode == IW_MODE_ADHOC) && (!SPY_NUMBER(priv))){
3675 /* Quality stats meaningless in ad-hoc mode */
3677 range->max_qual.qual = 0x8b - 0x2f;
3678 range->max_qual.level = 0x2f - 0x95 - 1;
3679 range->max_qual.noise = 0x2f - 0x95 - 1;
3680 /* Need to get better values */
3681 range->avg_qual.qual = 0x24;
3682 range->avg_qual.level = 0xC2;
3683 range->avg_qual.noise = 0x9E;
3686 err = orinoco_hw_get_bitratelist(priv, &numrates,
3687 range->bitrate, IW_MAX_BITRATES);
3690 range->num_bitrates = numrates;
3692 /* Set an indication of the max TCP throughput in bit/s that we can
3693 * expect using this interface. May be use for QoS stuff...
3696 range->throughput = 5 * 1000 * 1000; /* ~5 Mb/s */
3698 range->throughput = 1.5 * 1000 * 1000; /* ~1.5 Mb/s */
3701 range->max_rts = 2347;
3702 range->min_frag = 256;
3703 range->max_frag = 2346;
3706 range->max_pmp = 65535000;
3708 range->max_pmt = 65535 * 1000; /* ??? */
3709 range->pmp_flags = IW_POWER_PERIOD;
3710 range->pmt_flags = IW_POWER_TIMEOUT;
3711 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
3713 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
3714 range->retry_flags = IW_RETRY_LIMIT;
3715 range->r_time_flags = IW_RETRY_LIFETIME;
3716 range->min_retry = 0;
3717 range->max_retry = 65535; /* ??? */
3718 range->min_r_time = 0;
3719 range->max_r_time = 65535 * 1000; /* ??? */
3721 if (priv->firmware_type == FIRMWARE_TYPE_AGERE)
3722 range->scan_capa = IW_SCAN_CAPA_ESSID;
3724 range->scan_capa = IW_SCAN_CAPA_NONE;
3726 /* Event capability (kernel) */
3727 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
3728 /* Event capability (driver) */
3729 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY);
3730 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
3731 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
3732 IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
3737 static int orinoco_ioctl_setiwencode(struct net_device *dev,
3738 struct iw_request_info *info,
3739 struct iw_point *erq,
3742 struct orinoco_private *priv = netdev_priv(dev);
3743 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
3744 int setindex = priv->tx_key;
3745 int encode_alg = priv->encode_alg;
3746 int restricted = priv->wep_restrict;
3748 int err = -EINPROGRESS; /* Call commit handler */
3749 unsigned long flags;
3751 if (! priv->has_wep)
3755 /* We actually have a key to set - check its length */
3756 if (erq->length > LARGE_KEY_SIZE)
3759 if ( (erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep )
3763 if (orinoco_lock(priv, &flags) != 0)
3766 /* Clear any TKIP key we have */
3767 if ((priv->has_wpa) && (priv->encode_alg == IW_ENCODE_ALG_TKIP))
3768 (void) orinoco_clear_tkip_key(priv, setindex);
3770 if (erq->length > 0) {
3771 if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
3772 index = priv->tx_key;
3774 /* Adjust key length to a supported value */
3775 if (erq->length > SMALL_KEY_SIZE) {
3776 xlen = LARGE_KEY_SIZE;
3777 } else if (erq->length > 0) {
3778 xlen = SMALL_KEY_SIZE;
3782 /* Switch on WEP if off */
3783 if ((encode_alg != IW_ENCODE_ALG_WEP) && (xlen > 0)) {
3785 encode_alg = IW_ENCODE_ALG_WEP;
3788 /* Important note : if the user do "iwconfig eth0 enc off",
3789 * we will arrive there with an index of -1. This is valid
3790 * but need to be taken care off... Jean II */
3791 if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) {
3792 if((index != -1) || (erq->flags == 0)) {
3797 /* Set the index : Check that the key is valid */
3798 if(priv->keys[index].len == 0) {
3806 if (erq->flags & IW_ENCODE_DISABLED)
3807 encode_alg = IW_ENCODE_ALG_NONE;
3808 if (erq->flags & IW_ENCODE_OPEN)
3810 if (erq->flags & IW_ENCODE_RESTRICTED)
3813 if (erq->pointer && erq->length > 0) {
3814 priv->keys[index].len = cpu_to_le16(xlen);
3815 memset(priv->keys[index].data, 0,
3816 sizeof(priv->keys[index].data));
3817 memcpy(priv->keys[index].data, keybuf, erq->length);
3819 priv->tx_key = setindex;
3821 /* Try fast key change if connected and only keys are changed */
3822 if ((priv->encode_alg == encode_alg) &&
3823 (priv->wep_restrict == restricted) &&
3824 netif_carrier_ok(dev)) {
3825 err = __orinoco_hw_setup_wepkeys(priv);
3826 /* No need to commit if successful */
3830 priv->encode_alg = encode_alg;
3831 priv->wep_restrict = restricted;
3834 orinoco_unlock(priv, &flags);
3839 static int orinoco_ioctl_getiwencode(struct net_device *dev,
3840 struct iw_request_info *info,
3841 struct iw_point *erq,
3844 struct orinoco_private *priv = netdev_priv(dev);
3845 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
3847 unsigned long flags;
3849 if (! priv->has_wep)
3852 if (orinoco_lock(priv, &flags) != 0)
3855 if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
3856 index = priv->tx_key;
3859 if (!priv->encode_alg)
3860 erq->flags |= IW_ENCODE_DISABLED;
3861 erq->flags |= index + 1;
3863 if (priv->wep_restrict)
3864 erq->flags |= IW_ENCODE_RESTRICTED;
3866 erq->flags |= IW_ENCODE_OPEN;
3868 xlen = le16_to_cpu(priv->keys[index].len);
3872 memcpy(keybuf, priv->keys[index].data, ORINOCO_MAX_KEY_SIZE);
3874 orinoco_unlock(priv, &flags);
3878 static int orinoco_ioctl_setessid(struct net_device *dev,
3879 struct iw_request_info *info,
3880 struct iw_point *erq,
3883 struct orinoco_private *priv = netdev_priv(dev);
3884 unsigned long flags;
3886 /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
3887 * anyway... - Jean II */
3889 /* Hum... Should not use Wireless Extension constant (may change),
3890 * should use our own... - Jean II */
3891 if (erq->length > IW_ESSID_MAX_SIZE)
3894 if (orinoco_lock(priv, &flags) != 0)
3897 /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */
3898 memset(priv->desired_essid, 0, sizeof(priv->desired_essid));
3900 /* If not ANY, get the new ESSID */
3902 memcpy(priv->desired_essid, essidbuf, erq->length);
3905 orinoco_unlock(priv, &flags);
3907 return -EINPROGRESS; /* Call commit handler */
3910 static int orinoco_ioctl_getessid(struct net_device *dev,
3911 struct iw_request_info *info,
3912 struct iw_point *erq,
3915 struct orinoco_private *priv = netdev_priv(dev);
3918 unsigned long flags;
3920 if (netif_running(dev)) {
3921 err = orinoco_hw_get_essid(priv, &active, essidbuf);
3926 if (orinoco_lock(priv, &flags) != 0)
3928 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE);
3929 erq->length = strlen(priv->desired_essid);
3930 orinoco_unlock(priv, &flags);
3938 static int orinoco_ioctl_setnick(struct net_device *dev,
3939 struct iw_request_info *info,
3940 struct iw_point *nrq,
3943 struct orinoco_private *priv = netdev_priv(dev);
3944 unsigned long flags;
3946 if (nrq->length > IW_ESSID_MAX_SIZE)
3949 if (orinoco_lock(priv, &flags) != 0)
3952 memset(priv->nick, 0, sizeof(priv->nick));
3953 memcpy(priv->nick, nickbuf, nrq->length);
3955 orinoco_unlock(priv, &flags);
3957 return -EINPROGRESS; /* Call commit handler */
3960 static int orinoco_ioctl_getnick(struct net_device *dev,
3961 struct iw_request_info *info,
3962 struct iw_point *nrq,
3965 struct orinoco_private *priv = netdev_priv(dev);
3966 unsigned long flags;
3968 if (orinoco_lock(priv, &flags) != 0)
3971 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE);
3972 orinoco_unlock(priv, &flags);
3974 nrq->length = strlen(priv->nick);
3979 static int orinoco_ioctl_setfreq(struct net_device *dev,
3980 struct iw_request_info *info,
3981 struct iw_freq *frq,
3984 struct orinoco_private *priv = netdev_priv(dev);
3986 unsigned long flags;
3987 int err = -EINPROGRESS; /* Call commit handler */
3989 /* In infrastructure mode the AP sets the channel */
3990 if (priv->iw_mode == IW_MODE_INFRA)
3993 if ( (frq->e == 0) && (frq->m <= 1000) ) {
3994 /* Setting by channel number */
3997 /* Setting by frequency - search the table */
4001 for (i = 0; i < (6 - frq->e); i++)
4004 for (i = 0; i < NUM_CHANNELS; i++)
4005 if (frq->m == (channel_frequency[i] * mult))
4009 if ( (chan < 1) || (chan > NUM_CHANNELS) ||
4010 ! (priv->channel_mask & (1 << (chan-1)) ) )
4013 if (orinoco_lock(priv, &flags) != 0)
4016 priv->channel = chan;
4017 if (priv->iw_mode == IW_MODE_MONITOR) {
4018 /* Fast channel change - no commit if successful */
4019 hermes_t *hw = &priv->hw;
4020 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
4021 HERMES_TEST_SET_CHANNEL,
4024 orinoco_unlock(priv, &flags);
4029 static int orinoco_ioctl_getfreq(struct net_device *dev,
4030 struct iw_request_info *info,
4031 struct iw_freq *frq,
4034 struct orinoco_private *priv = netdev_priv(dev);
4037 /* Locking done in there */
4038 tmp = orinoco_hw_get_freq(priv);
4049 static int orinoco_ioctl_getsens(struct net_device *dev,
4050 struct iw_request_info *info,
4051 struct iw_param *srq,
4054 struct orinoco_private *priv = netdev_priv(dev);
4055 hermes_t *hw = &priv->hw;
4058 unsigned long flags;
4060 if (!priv->has_sensitivity)
4063 if (orinoco_lock(priv, &flags) != 0)
4065 err = hermes_read_wordrec(hw, USER_BAP,
4066 HERMES_RID_CNFSYSTEMSCALE, &val);
4067 orinoco_unlock(priv, &flags);
4073 srq->fixed = 0; /* auto */
4078 static int orinoco_ioctl_setsens(struct net_device *dev,
4079 struct iw_request_info *info,
4080 struct iw_param *srq,
4083 struct orinoco_private *priv = netdev_priv(dev);
4084 int val = srq->value;
4085 unsigned long flags;
4087 if (!priv->has_sensitivity)
4090 if ((val < 1) || (val > 3))
4093 if (orinoco_lock(priv, &flags) != 0)
4095 priv->ap_density = val;
4096 orinoco_unlock(priv, &flags);
4098 return -EINPROGRESS; /* Call commit handler */
4101 static int orinoco_ioctl_setrts(struct net_device *dev,
4102 struct iw_request_info *info,
4103 struct iw_param *rrq,
4106 struct orinoco_private *priv = netdev_priv(dev);
4107 int val = rrq->value;
4108 unsigned long flags;
4113 if ( (val < 0) || (val > 2347) )
4116 if (orinoco_lock(priv, &flags) != 0)
4119 priv->rts_thresh = val;
4120 orinoco_unlock(priv, &flags);
4122 return -EINPROGRESS; /* Call commit handler */
4125 static int orinoco_ioctl_getrts(struct net_device *dev,
4126 struct iw_request_info *info,
4127 struct iw_param *rrq,
4130 struct orinoco_private *priv = netdev_priv(dev);
4132 rrq->value = priv->rts_thresh;
4133 rrq->disabled = (rrq->value == 2347);
4139 static int orinoco_ioctl_setfrag(struct net_device *dev,
4140 struct iw_request_info *info,
4141 struct iw_param *frq,
4144 struct orinoco_private *priv = netdev_priv(dev);
4145 int err = -EINPROGRESS; /* Call commit handler */
4146 unsigned long flags;
4148 if (orinoco_lock(priv, &flags) != 0)
4151 if (priv->has_mwo) {
4153 priv->mwo_robust = 0;
4156 printk(KERN_WARNING "%s: Fixed fragmentation is "
4157 "not supported on this firmware. "
4158 "Using MWO robust instead.\n", dev->name);
4159 priv->mwo_robust = 1;
4163 priv->frag_thresh = 2346;
4165 if ( (frq->value < 256) || (frq->value > 2346) )
4168 priv->frag_thresh = frq->value & ~0x1; /* must be even */
4172 orinoco_unlock(priv, &flags);
4177 static int orinoco_ioctl_getfrag(struct net_device *dev,
4178 struct iw_request_info *info,
4179 struct iw_param *frq,
4182 struct orinoco_private *priv = netdev_priv(dev);
4183 hermes_t *hw = &priv->hw;
4186 unsigned long flags;
4188 if (orinoco_lock(priv, &flags) != 0)
4191 if (priv->has_mwo) {
4192 err = hermes_read_wordrec(hw, USER_BAP,
4193 HERMES_RID_CNFMWOROBUST_AGERE,
4198 frq->value = val ? 2347 : 0;
4199 frq->disabled = ! val;
4202 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
4208 frq->disabled = (val >= 2346);
4212 orinoco_unlock(priv, &flags);
4217 static int orinoco_ioctl_setrate(struct net_device *dev,
4218 struct iw_request_info *info,
4219 struct iw_param *rrq,
4222 struct orinoco_private *priv = netdev_priv(dev);
4224 int bitrate; /* 100s of kilobits */
4226 unsigned long flags;
4228 /* As the user space doesn't know our highest rate, it uses -1
4229 * to ask us to set the highest rate. Test it using "iwconfig
4230 * ethX rate auto" - Jean II */
4231 if (rrq->value == -1)
4234 if (rrq->value % 100000)
4236 bitrate = rrq->value / 100000;
4239 if ( (bitrate != 10) && (bitrate != 20) &&
4240 (bitrate != 55) && (bitrate != 110) )
4243 for (i = 0; i < BITRATE_TABLE_SIZE; i++)
4244 if ( (bitrate_table[i].bitrate == bitrate) &&
4245 (bitrate_table[i].automatic == ! rrq->fixed) ) {
4253 if (orinoco_lock(priv, &flags) != 0)
4255 priv->bitratemode = ratemode;
4256 orinoco_unlock(priv, &flags);
4258 return -EINPROGRESS;
4261 static int orinoco_ioctl_getrate(struct net_device *dev,
4262 struct iw_request_info *info,
4263 struct iw_param *rrq,
4266 struct orinoco_private *priv = netdev_priv(dev);
4267 hermes_t *hw = &priv->hw;
4272 unsigned long flags;
4274 if (orinoco_lock(priv, &flags) != 0)
4277 ratemode = priv->bitratemode;
4279 BUG_ON((ratemode < 0) || (ratemode >= BITRATE_TABLE_SIZE));
4281 rrq->value = bitrate_table[ratemode].bitrate * 100000;
4282 rrq->fixed = ! bitrate_table[ratemode].automatic;
4285 /* If the interface is running we try to find more about the
4287 if (netif_running(dev)) {
4288 err = hermes_read_wordrec(hw, USER_BAP,
4289 HERMES_RID_CURRENTTXRATE, &val);
4293 switch (priv->firmware_type) {
4294 case FIRMWARE_TYPE_AGERE: /* Lucent style rate */
4295 /* Note : in Lucent firmware, the return value of
4296 * HERMES_RID_CURRENTTXRATE is the bitrate in Mb/s,
4297 * and therefore is totally different from the
4298 * encoding of HERMES_RID_CNFTXRATECONTROL.
4299 * Don't forget that 6Mb/s is really 5.5Mb/s */
4301 rrq->value = 5500000;
4303 rrq->value = val * 1000000;
4305 case FIRMWARE_TYPE_INTERSIL: /* Intersil style rate */
4306 case FIRMWARE_TYPE_SYMBOL: /* Symbol style rate */
4307 for (i = 0; i < BITRATE_TABLE_SIZE; i++)
4308 if (bitrate_table[i].intersil_txratectrl == val) {
4312 if (i >= BITRATE_TABLE_SIZE)
4313 printk(KERN_INFO "%s: Unable to determine current bitrate (0x%04hx)\n",
4316 rrq->value = bitrate_table[ratemode].bitrate * 100000;
4324 orinoco_unlock(priv, &flags);
4329 static int orinoco_ioctl_setpower(struct net_device *dev,
4330 struct iw_request_info *info,
4331 struct iw_param *prq,
4334 struct orinoco_private *priv = netdev_priv(dev);
4335 int err = -EINPROGRESS; /* Call commit handler */
4336 unsigned long flags;
4338 if (orinoco_lock(priv, &flags) != 0)
4341 if (prq->disabled) {
4344 switch (prq->flags & IW_POWER_MODE) {
4345 case IW_POWER_UNICAST_R:
4349 case IW_POWER_ALL_R:
4354 /* No flags : but we may have a value - Jean II */
4361 if (prq->flags & IW_POWER_TIMEOUT) {
4363 priv->pm_timeout = prq->value / 1000;
4365 if (prq->flags & IW_POWER_PERIOD) {
4367 priv->pm_period = prq->value / 1000;
4369 /* It's valid to not have a value if we are just toggling
4370 * the flags... Jean II */
4378 orinoco_unlock(priv, &flags);
4383 static int orinoco_ioctl_getpower(struct net_device *dev,
4384 struct iw_request_info *info,
4385 struct iw_param *prq,
4388 struct orinoco_private *priv = netdev_priv(dev);
4389 hermes_t *hw = &priv->hw;
4391 u16 enable, period, timeout, mcast;
4392 unsigned long flags;
4394 if (orinoco_lock(priv, &flags) != 0)
4397 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFPMENABLED, &enable);
4401 err = hermes_read_wordrec(hw, USER_BAP,
4402 HERMES_RID_CNFMAXSLEEPDURATION, &period);
4406 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFPMHOLDOVERDURATION, &timeout);
4410 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFMULTICASTRECEIVE, &mcast);
4414 prq->disabled = !enable;
4415 /* Note : by default, display the period */
4416 if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
4417 prq->flags = IW_POWER_TIMEOUT;
4418 prq->value = timeout * 1000;
4420 prq->flags = IW_POWER_PERIOD;
4421 prq->value = period * 1000;
4424 prq->flags |= IW_POWER_ALL_R;
4426 prq->flags |= IW_POWER_UNICAST_R;
4429 orinoco_unlock(priv, &flags);
4434 static int orinoco_ioctl_set_encodeext(struct net_device *dev,
4435 struct iw_request_info *info,
4436 union iwreq_data *wrqu,
4439 struct orinoco_private *priv = netdev_priv(dev);
4440 struct iw_point *encoding = &wrqu->encoding;
4441 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4442 int idx, alg = ext->alg, set_key = 1;
4443 unsigned long flags;
4447 if (orinoco_lock(priv, &flags) != 0)
4450 /* Determine and validate the key index */
4451 idx = encoding->flags & IW_ENCODE_INDEX;
4453 if ((idx < 1) || (idx > WEP_KEYS))
4459 if (encoding->flags & IW_ENCODE_DISABLED)
4460 alg = IW_ENCODE_ALG_NONE;
4462 if (priv->has_wpa && (alg != IW_ENCODE_ALG_TKIP)) {
4463 /* Clear any TKIP TX key we had */
4464 (void) orinoco_clear_tkip_key(priv, priv->tx_key);
4467 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
4469 set_key = ((alg == IW_ENCODE_ALG_TKIP) ||
4470 (ext->key_len > 0)) ? 1 : 0;
4474 /* Set the requested key first */
4476 case IW_ENCODE_ALG_NONE:
4477 priv->encode_alg = alg;
4478 priv->keys[idx].len = 0;
4481 case IW_ENCODE_ALG_WEP:
4482 if (ext->key_len > SMALL_KEY_SIZE)
4483 key_len = LARGE_KEY_SIZE;
4484 else if (ext->key_len > 0)
4485 key_len = SMALL_KEY_SIZE;
4489 priv->encode_alg = alg;
4490 priv->keys[idx].len = cpu_to_le16(key_len);
4492 key_len = min(ext->key_len, key_len);
4494 memset(priv->keys[idx].data, 0, ORINOCO_MAX_KEY_SIZE);
4495 memcpy(priv->keys[idx].data, ext->key, key_len);
4498 case IW_ENCODE_ALG_TKIP:
4500 hermes_t *hw = &priv->hw;
4503 if (!priv->has_wpa ||
4504 (ext->key_len > sizeof(priv->tkip_key[0])))
4507 priv->encode_alg = alg;
4508 memset(&priv->tkip_key[idx], 0,
4509 sizeof(priv->tkip_key[idx]));
4510 memcpy(&priv->tkip_key[idx], ext->key, ext->key_len);
4512 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
4513 tkip_iv = &ext->rx_seq[0];
4515 err = __orinoco_hw_set_tkip_key(hw, idx,
4516 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
4517 (u8 *) &priv->tkip_key[idx],
4520 printk(KERN_ERR "%s: Error %d setting TKIP key"
4521 "\n", dev->name, err);
4531 orinoco_unlock(priv, &flags);
4536 static int orinoco_ioctl_get_encodeext(struct net_device *dev,
4537 struct iw_request_info *info,
4538 union iwreq_data *wrqu,
4541 struct orinoco_private *priv = netdev_priv(dev);
4542 struct iw_point *encoding = &wrqu->encoding;
4543 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4544 int idx, max_key_len;
4545 unsigned long flags;
4548 if (orinoco_lock(priv, &flags) != 0)
4552 max_key_len = encoding->length - sizeof(*ext);
4553 if (max_key_len < 0)
4556 idx = encoding->flags & IW_ENCODE_INDEX;
4558 if ((idx < 1) || (idx > WEP_KEYS))
4564 encoding->flags = idx + 1;
4565 memset(ext, 0, sizeof(*ext));
4567 ext->alg = priv->encode_alg;
4568 switch (priv->encode_alg) {
4569 case IW_ENCODE_ALG_NONE:
4571 encoding->flags |= IW_ENCODE_DISABLED;
4573 case IW_ENCODE_ALG_WEP:
4574 ext->key_len = min(le16_to_cpu(priv->keys[idx].len),
4576 memcpy(ext->key, priv->keys[idx].data, ext->key_len);
4577 encoding->flags |= IW_ENCODE_ENABLED;
4579 case IW_ENCODE_ALG_TKIP:
4580 ext->key_len = min((u16) sizeof(struct orinoco_tkip_key),
4582 memcpy(ext->key, &priv->tkip_key[idx], ext->key_len);
4583 encoding->flags |= IW_ENCODE_ENABLED;
4589 orinoco_unlock(priv, &flags);
4594 static int orinoco_ioctl_set_auth(struct net_device *dev,
4595 struct iw_request_info *info,
4596 union iwreq_data *wrqu, char *extra)
4598 struct orinoco_private *priv = netdev_priv(dev);
4599 hermes_t *hw = &priv->hw;
4600 struct iw_param *param = &wrqu->param;
4601 unsigned long flags;
4602 int ret = -EINPROGRESS;
4604 if (orinoco_lock(priv, &flags) != 0)
4607 switch (param->flags & IW_AUTH_INDEX) {
4608 case IW_AUTH_WPA_VERSION:
4609 case IW_AUTH_CIPHER_PAIRWISE:
4610 case IW_AUTH_CIPHER_GROUP:
4611 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4612 case IW_AUTH_PRIVACY_INVOKED:
4613 case IW_AUTH_DROP_UNENCRYPTED:
4615 * orinoco does not use these parameters
4619 case IW_AUTH_KEY_MGMT:
4620 /* wl_lkm implies value 2 == PSK for Hermes I
4621 * which ties in with WEXT
4622 * no other hints tho :(
4624 priv->key_mgmt = param->value;
4627 case IW_AUTH_TKIP_COUNTERMEASURES:
4628 /* When countermeasures are enabled, shut down the
4629 * card; when disabled, re-enable the card. This must
4630 * take effect immediately.
4632 * TODO: Make sure that the EAPOL message is getting
4633 * out before card disabled
4636 priv->tkip_cm_active = 1;
4637 ret = hermes_enable_port(hw, 0);
4639 priv->tkip_cm_active = 0;
4640 ret = hermes_disable_port(hw, 0);
4644 case IW_AUTH_80211_AUTH_ALG:
4645 if (param->value & IW_AUTH_ALG_SHARED_KEY)
4646 priv->wep_restrict = 1;
4647 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
4648 priv->wep_restrict = 0;
4653 case IW_AUTH_WPA_ENABLED:
4654 if (priv->has_wpa) {
4655 priv->wpa_enabled = param->value ? 1 : 0;
4659 /* else silently accept disable of WPA */
4660 priv->wpa_enabled = 0;
4668 orinoco_unlock(priv, &flags);
4672 static int orinoco_ioctl_get_auth(struct net_device *dev,
4673 struct iw_request_info *info,
4674 union iwreq_data *wrqu, char *extra)
4676 struct orinoco_private *priv = netdev_priv(dev);
4677 struct iw_param *param = &wrqu->param;
4678 unsigned long flags;
4681 if (orinoco_lock(priv, &flags) != 0)
4684 switch (param->flags & IW_AUTH_INDEX) {
4685 case IW_AUTH_KEY_MGMT:
4686 param->value = priv->key_mgmt;
4689 case IW_AUTH_TKIP_COUNTERMEASURES:
4690 param->value = priv->tkip_cm_active;
4693 case IW_AUTH_80211_AUTH_ALG:
4694 if (priv->wep_restrict)
4695 param->value = IW_AUTH_ALG_SHARED_KEY;
4697 param->value = IW_AUTH_ALG_OPEN_SYSTEM;
4700 case IW_AUTH_WPA_ENABLED:
4701 param->value = priv->wpa_enabled;
4708 orinoco_unlock(priv, &flags);
4712 static int orinoco_ioctl_set_genie(struct net_device *dev,
4713 struct iw_request_info *info,
4714 union iwreq_data *wrqu, char *extra)
4716 struct orinoco_private *priv = netdev_priv(dev);
4718 unsigned long flags;
4721 if ((wrqu->data.length > MAX_WPA_IE_LEN) ||
4722 (wrqu->data.length && (extra == NULL)))
4725 if (orinoco_lock(priv, &flags) != 0)
4728 if (wrqu->data.length) {
4729 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
4735 memcpy(buf, extra, wrqu->data.length);
4736 kfree(priv->wpa_ie);
4738 priv->wpa_ie_len = wrqu->data.length;
4740 kfree(priv->wpa_ie);
4741 priv->wpa_ie = NULL;
4742 priv->wpa_ie_len = 0;
4746 /* Looks like wl_lkm wants to check the auth alg, and
4747 * somehow pass it to the firmware.
4748 * Instead it just calls the key mgmt rid
4749 * - we do this in set auth.
4754 orinoco_unlock(priv, &flags);
4758 static int orinoco_ioctl_get_genie(struct net_device *dev,
4759 struct iw_request_info *info,
4760 union iwreq_data *wrqu, char *extra)
4762 struct orinoco_private *priv = netdev_priv(dev);
4763 unsigned long flags;
4766 if (orinoco_lock(priv, &flags) != 0)
4769 if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) {
4770 wrqu->data.length = 0;
4774 if (wrqu->data.length < priv->wpa_ie_len) {
4779 wrqu->data.length = priv->wpa_ie_len;
4780 memcpy(extra, priv->wpa_ie, priv->wpa_ie_len);
4783 orinoco_unlock(priv, &flags);
4787 static int orinoco_ioctl_set_mlme(struct net_device *dev,
4788 struct iw_request_info *info,
4789 union iwreq_data *wrqu, char *extra)
4791 struct orinoco_private *priv = netdev_priv(dev);
4792 hermes_t *hw = &priv->hw;
4793 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4794 unsigned long flags;
4797 if (orinoco_lock(priv, &flags) != 0)
4800 switch (mlme->cmd) {
4801 case IW_MLME_DEAUTH:
4802 /* silently ignore */
4805 case IW_MLME_DISASSOC:
4810 } __attribute__ ((packed)) buf;
4812 memcpy(buf.addr, mlme->addr.sa_data, ETH_ALEN);
4813 buf.reason_code = cpu_to_le16(mlme->reason_code);
4814 ret = HERMES_WRITE_RECORD(hw, USER_BAP,
4815 HERMES_RID_CNFDISASSOCIATE,
4823 orinoco_unlock(priv, &flags);
4827 static int orinoco_ioctl_getretry(struct net_device *dev,
4828 struct iw_request_info *info,
4829 struct iw_param *rrq,
4832 struct orinoco_private *priv = netdev_priv(dev);
4833 hermes_t *hw = &priv->hw;
4835 u16 short_limit, long_limit, lifetime;
4836 unsigned long flags;
4838 if (orinoco_lock(priv, &flags) != 0)
4841 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT,
4846 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT,
4851 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME,
4856 rrq->disabled = 0; /* Can't be disabled */
4858 /* Note : by default, display the retry number */
4859 if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
4860 rrq->flags = IW_RETRY_LIFETIME;
4861 rrq->value = lifetime * 1000; /* ??? */
4863 /* By default, display the min number */
4864 if ((rrq->flags & IW_RETRY_LONG)) {
4865 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4866 rrq->value = long_limit;
4868 rrq->flags = IW_RETRY_LIMIT;
4869 rrq->value = short_limit;
4870 if(short_limit != long_limit)
4871 rrq->flags |= IW_RETRY_SHORT;
4876 orinoco_unlock(priv, &flags);
4881 static int orinoco_ioctl_reset(struct net_device *dev,
4882 struct iw_request_info *info,
4886 struct orinoco_private *priv = netdev_priv(dev);
4888 if (! capable(CAP_NET_ADMIN))
4891 if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) {
4892 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
4894 /* Firmware reset */
4895 orinoco_reset(&priv->reset_work);
4897 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
4899 schedule_work(&priv->reset_work);
4905 static int orinoco_ioctl_setibssport(struct net_device *dev,
4906 struct iw_request_info *info,
4911 struct orinoco_private *priv = netdev_priv(dev);
4912 int val = *( (int *) extra );
4913 unsigned long flags;
4915 if (orinoco_lock(priv, &flags) != 0)
4918 priv->ibss_port = val ;
4920 /* Actually update the mode we are using */
4921 set_port_type(priv);
4923 orinoco_unlock(priv, &flags);
4924 return -EINPROGRESS; /* Call commit handler */
4927 static int orinoco_ioctl_getibssport(struct net_device *dev,
4928 struct iw_request_info *info,
4932 struct orinoco_private *priv = netdev_priv(dev);
4933 int *val = (int *) extra;
4935 *val = priv->ibss_port;
4939 static int orinoco_ioctl_setport3(struct net_device *dev,
4940 struct iw_request_info *info,
4944 struct orinoco_private *priv = netdev_priv(dev);
4945 int val = *( (int *) extra );
4947 unsigned long flags;
4949 if (orinoco_lock(priv, &flags) != 0)
4953 case 0: /* Try to do IEEE ad-hoc mode */
4954 if (! priv->has_ibss) {
4958 priv->prefer_port3 = 0;
4962 case 1: /* Try to do Lucent proprietary ad-hoc mode */
4963 if (! priv->has_port3) {
4967 priv->prefer_port3 = 1;
4975 /* Actually update the mode we are using */
4976 set_port_type(priv);
4980 orinoco_unlock(priv, &flags);
4985 static int orinoco_ioctl_getport3(struct net_device *dev,
4986 struct iw_request_info *info,
4990 struct orinoco_private *priv = netdev_priv(dev);
4991 int *val = (int *) extra;
4993 *val = priv->prefer_port3;
4997 static int orinoco_ioctl_setpreamble(struct net_device *dev,
4998 struct iw_request_info *info,
5002 struct orinoco_private *priv = netdev_priv(dev);
5003 unsigned long flags;
5006 if (! priv->has_preamble)
5009 /* 802.11b has recently defined some short preamble.
5010 * Basically, the Phy header has been reduced in size.
5011 * This increase performance, especially at high rates
5012 * (the preamble is transmitted at 1Mb/s), unfortunately
5013 * this give compatibility troubles... - Jean II */
5014 val = *( (int *) extra );
5016 if (orinoco_lock(priv, &flags) != 0)
5024 orinoco_unlock(priv, &flags);
5026 return -EINPROGRESS; /* Call commit handler */
5029 static int orinoco_ioctl_getpreamble(struct net_device *dev,
5030 struct iw_request_info *info,
5034 struct orinoco_private *priv = netdev_priv(dev);
5035 int *val = (int *) extra;
5037 if (! priv->has_preamble)
5040 *val = priv->preamble;
5044 /* ioctl interface to hermes_read_ltv()
5045 * To use with iwpriv, pass the RID as the token argument, e.g.
5046 * iwpriv get_rid [0xfc00]
5047 * At least Wireless Tools 25 is required to use iwpriv.
5048 * For Wireless Tools 25 and 26 append "dummy" are the end. */
5049 static int orinoco_ioctl_getrid(struct net_device *dev,
5050 struct iw_request_info *info,
5051 struct iw_point *data,
5054 struct orinoco_private *priv = netdev_priv(dev);
5055 hermes_t *hw = &priv->hw;
5056 int rid = data->flags;
5059 unsigned long flags;
5061 /* It's a "get" function, but we don't want users to access the
5062 * WEP key and other raw firmware data */
5063 if (! capable(CAP_NET_ADMIN))
5066 if (rid < 0xfc00 || rid > 0xffff)
5069 if (orinoco_lock(priv, &flags) != 0)
5072 err = hermes_read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
5077 data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length),
5081 orinoco_unlock(priv, &flags);
5085 /* Trigger a scan (look for other cells in the vicinity) */
5086 static int orinoco_ioctl_setscan(struct net_device *dev,
5087 struct iw_request_info *info,
5088 struct iw_param *srq,
5091 struct orinoco_private *priv = netdev_priv(dev);
5092 hermes_t *hw = &priv->hw;
5093 struct iw_scan_req *si = (struct iw_scan_req *) extra;
5095 unsigned long flags;
5097 /* Note : you may have realised that, as this is a SET operation,
5098 * this is privileged and therefore a normal user can't
5100 * This is not an error, while the device perform scanning,
5101 * traffic doesn't flow, so it's a perfect DoS...
5104 if (orinoco_lock(priv, &flags) != 0)
5107 /* Scanning with port 0 disabled would fail */
5108 if (!netif_running(dev)) {
5113 /* In monitor mode, the scan results are always empty.
5114 * Probe responses are passed to the driver as received
5115 * frames and could be processed in software. */
5116 if (priv->iw_mode == IW_MODE_MONITOR) {
5121 /* Note : because we don't lock out the irq handler, the way
5122 * we access scan variables in priv is critical.
5123 * o scan_inprogress : not touched by irq handler
5124 * o scan_mode : not touched by irq handler
5125 * Before modifying anything on those variables, please think hard !
5129 priv->scan_mode = srq->flags;
5131 /* Always trigger scanning, even if it's in progress.
5132 * This way, if the info frame get lost, we will recover somewhat
5133 * gracefully - Jean II */
5135 if (priv->has_hostscan) {
5136 switch (priv->firmware_type) {
5137 case FIRMWARE_TYPE_SYMBOL:
5138 err = hermes_write_wordrec(hw, USER_BAP,
5139 HERMES_RID_CNFHOSTSCAN_SYMBOL,
5140 HERMES_HOSTSCAN_SYMBOL_ONCE |
5141 HERMES_HOSTSCAN_SYMBOL_BCAST);
5143 case FIRMWARE_TYPE_INTERSIL: {
5146 req[0] = cpu_to_le16(0x3fff); /* All channels */
5147 req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */
5148 req[2] = 0; /* Any ESSID */
5149 err = HERMES_WRITE_RECORD(hw, USER_BAP,
5150 HERMES_RID_CNFHOSTSCAN, &req);
5153 case FIRMWARE_TYPE_AGERE:
5154 if (priv->scan_mode & IW_SCAN_THIS_ESSID) {
5155 struct hermes_idstring idbuf;
5156 size_t len = min(sizeof(idbuf.val),
5157 (size_t) si->essid_len);
5158 idbuf.len = cpu_to_le16(len);
5159 memcpy(idbuf.val, si->essid, len);
5161 err = hermes_write_ltv(hw, USER_BAP,
5162 HERMES_RID_CNFSCANSSID_AGERE,
5163 HERMES_BYTES_TO_RECLEN(len + 2),
5166 err = hermes_write_wordrec(hw, USER_BAP,
5167 HERMES_RID_CNFSCANSSID_AGERE,
5172 if (priv->has_ext_scan) {
5173 /* Clear scan results at the start of
5174 * an extended scan */
5175 orinoco_clear_scan_results(priv,
5176 msecs_to_jiffies(15000));
5178 /* TODO: Is this available on older firmware?
5179 * Can we use it to scan specific channels
5180 * for IW_SCAN_THIS_FREQ? */
5181 err = hermes_write_wordrec(hw, USER_BAP,
5182 HERMES_RID_CNFSCANCHANNELS2GHZ,
5187 err = hermes_inquire(hw,
5188 HERMES_INQ_CHANNELINFO);
5190 err = hermes_inquire(hw, HERMES_INQ_SCAN);
5194 err = hermes_inquire(hw, HERMES_INQ_SCAN);
5196 /* One more client */
5198 priv->scan_inprogress = 1;
5201 orinoco_unlock(priv, &flags);
5205 #define MAX_CUSTOM_LEN 64
5207 /* Translate scan data returned from the card to a card independant
5208 * format that the Wireless Tools will understand - Jean II */
5209 static inline char *orinoco_translate_scan(struct net_device *dev,
5210 struct iw_request_info *info,
5213 union hermes_scan_info *bss,
5214 unsigned int last_scanned)
5216 struct orinoco_private *priv = netdev_priv(dev);
5219 struct iw_event iwe; /* Temporary buffer */
5220 char custom[MAX_CUSTOM_LEN];
5222 memset(&iwe, 0, sizeof(iwe));
5224 /* First entry *MUST* be the AP MAC address */
5225 iwe.cmd = SIOCGIWAP;
5226 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
5227 memcpy(iwe.u.ap_addr.sa_data, bss->a.bssid, ETH_ALEN);
5228 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5229 &iwe, IW_EV_ADDR_LEN);
5231 /* Other entries will be displayed in the order we give them */
5234 iwe.u.data.length = le16_to_cpu(bss->a.essid_len);
5235 if (iwe.u.data.length > 32)
5236 iwe.u.data.length = 32;
5237 iwe.cmd = SIOCGIWESSID;
5238 iwe.u.data.flags = 1;
5239 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5240 &iwe, bss->a.essid);
5243 iwe.cmd = SIOCGIWMODE;
5244 capabilities = le16_to_cpu(bss->a.capabilities);
5245 if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
5246 if (capabilities & WLAN_CAPABILITY_ESS)
5247 iwe.u.mode = IW_MODE_MASTER;
5249 iwe.u.mode = IW_MODE_ADHOC;
5250 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5251 &iwe, IW_EV_UINT_LEN);
5254 channel = bss->s.channel;
5255 if ((channel >= 1) && (channel <= NUM_CHANNELS)) {
5256 /* Add channel and frequency */
5257 iwe.cmd = SIOCGIWFREQ;
5258 iwe.u.freq.m = channel;
5260 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5261 &iwe, IW_EV_FREQ_LEN);
5263 iwe.u.freq.m = channel_frequency[channel-1] * 100000;
5265 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5266 &iwe, IW_EV_FREQ_LEN);
5269 /* Add quality statistics. level and noise in dB. No link quality */
5271 iwe.u.qual.updated = IW_QUAL_DBM | IW_QUAL_QUAL_INVALID;
5272 iwe.u.qual.level = (__u8) le16_to_cpu(bss->a.level) - 0x95;
5273 iwe.u.qual.noise = (__u8) le16_to_cpu(bss->a.noise) - 0x95;
5274 /* Wireless tools prior to 27.pre22 will show link quality
5275 * anyway, so we provide a reasonable value. */
5276 if (iwe.u.qual.level > iwe.u.qual.noise)
5277 iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise;
5279 iwe.u.qual.qual = 0;
5280 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5281 &iwe, IW_EV_QUAL_LEN);
5283 /* Add encryption capability */
5284 iwe.cmd = SIOCGIWENCODE;
5285 if (capabilities & WLAN_CAPABILITY_PRIVACY)
5286 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
5288 iwe.u.data.flags = IW_ENCODE_DISABLED;
5289 iwe.u.data.length = 0;
5290 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5293 /* Bit rate is not available in Lucent/Agere firmwares */
5294 if (priv->firmware_type != FIRMWARE_TYPE_AGERE) {
5295 char *current_val = current_ev + iwe_stream_lcp_len(info);
5299 if (priv->firmware_type == FIRMWARE_TYPE_SYMBOL)
5304 iwe.cmd = SIOCGIWRATE;
5305 /* Those two flags are ignored... */
5306 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
5308 for (i = 0; i < 10; i += step) {
5309 /* NULL terminated */
5310 if (bss->p.rates[i] == 0x0)
5312 /* Bit rate given in 500 kb/s units (+ 0x80) */
5313 iwe.u.bitrate.value =
5314 ((bss->p.rates[i] & 0x7f) * 500000);
5315 current_val = iwe_stream_add_value(info, current_ev,
5320 /* Check if we added any event */
5321 if ((current_val - current_ev) > iwe_stream_lcp_len(info))
5322 current_ev = current_val;
5325 /* Beacon interval */
5326 iwe.cmd = IWEVCUSTOM;
5327 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5329 le16_to_cpu(bss->a.beacon_interv));
5330 if (iwe.u.data.length)
5331 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5335 iwe.cmd = IWEVCUSTOM;
5336 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5339 if (iwe.u.data.length)
5340 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5343 /* Add EXTRA: Age to display seconds since last beacon/probe response
5344 * for given network. */
5345 iwe.cmd = IWEVCUSTOM;
5346 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5347 " Last beacon: %dms ago",
5348 jiffies_to_msecs(jiffies - last_scanned));
5349 if (iwe.u.data.length)
5350 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5356 static inline char *orinoco_translate_ext_scan(struct net_device *dev,
5357 struct iw_request_info *info,
5360 struct agere_ext_scan_info *bss,
5361 unsigned int last_scanned)
5365 struct iw_event iwe; /* Temporary buffer */
5366 char custom[MAX_CUSTOM_LEN];
5369 memset(&iwe, 0, sizeof(iwe));
5371 /* First entry *MUST* be the AP MAC address */
5372 iwe.cmd = SIOCGIWAP;
5373 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
5374 memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN);
5375 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5376 &iwe, IW_EV_ADDR_LEN);
5378 /* Other entries will be displayed in the order we give them */
5382 iwe.u.data.length = ie[1];
5383 if (iwe.u.data.length) {
5384 if (iwe.u.data.length > 32)
5385 iwe.u.data.length = 32;
5386 iwe.cmd = SIOCGIWESSID;
5387 iwe.u.data.flags = 1;
5388 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5393 capabilities = le16_to_cpu(bss->capabilities);
5394 if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
5395 iwe.cmd = SIOCGIWMODE;
5396 if (capabilities & WLAN_CAPABILITY_ESS)
5397 iwe.u.mode = IW_MODE_MASTER;
5399 iwe.u.mode = IW_MODE_ADHOC;
5400 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5401 &iwe, IW_EV_UINT_LEN);
5404 ie = orinoco_get_ie(bss->data, sizeof(bss->data), MFIE_TYPE_DS_SET);
5405 channel = ie ? ie[2] : 0;
5406 if ((channel >= 1) && (channel <= NUM_CHANNELS)) {
5407 /* Add channel and frequency */
5408 iwe.cmd = SIOCGIWFREQ;
5409 iwe.u.freq.m = channel;
5411 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5412 &iwe, IW_EV_FREQ_LEN);
5414 iwe.u.freq.m = channel_frequency[channel-1] * 100000;
5416 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5417 &iwe, IW_EV_FREQ_LEN);
5420 /* Add quality statistics. level and noise in dB. No link quality */
5422 iwe.u.qual.updated = IW_QUAL_DBM | IW_QUAL_QUAL_INVALID;
5423 iwe.u.qual.level = bss->level - 0x95;
5424 iwe.u.qual.noise = bss->noise - 0x95;
5425 /* Wireless tools prior to 27.pre22 will show link quality
5426 * anyway, so we provide a reasonable value. */
5427 if (iwe.u.qual.level > iwe.u.qual.noise)
5428 iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise;
5430 iwe.u.qual.qual = 0;
5431 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5432 &iwe, IW_EV_QUAL_LEN);
5434 /* Add encryption capability */
5435 iwe.cmd = SIOCGIWENCODE;
5436 if (capabilities & WLAN_CAPABILITY_PRIVACY)
5437 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
5439 iwe.u.data.flags = IW_ENCODE_DISABLED;
5440 iwe.u.data.length = 0;
5441 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5445 ie = orinoco_get_wpa_ie(bss->data, sizeof(bss->data));
5447 iwe.cmd = IWEVGENIE;
5448 iwe.u.data.length = ie[1] + 2;
5449 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5454 ie = orinoco_get_ie(bss->data, sizeof(bss->data), MFIE_TYPE_RSN);
5456 iwe.cmd = IWEVGENIE;
5457 iwe.u.data.length = ie[1] + 2;
5458 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5462 ie = orinoco_get_ie(bss->data, sizeof(bss->data), MFIE_TYPE_RATES);
5464 char *p = current_ev + iwe_stream_lcp_len(info);
5467 iwe.cmd = SIOCGIWRATE;
5468 /* Those two flags are ignored... */
5469 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
5471 for (i = 2; i < (ie[1] + 2); i++) {
5472 iwe.u.bitrate.value = ((ie[i] & 0x7F) * 500000);
5473 p = iwe_stream_add_value(info, current_ev, p, end_buf,
5474 &iwe, IW_EV_PARAM_LEN);
5476 /* Check if we added any event */
5477 if (p > (current_ev + iwe_stream_lcp_len(info)))
5482 iwe.cmd = IWEVCUSTOM;
5483 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5485 le64_to_cpu(bss->timestamp));
5486 if (iwe.u.data.length)
5487 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5490 /* Beacon interval */
5491 iwe.cmd = IWEVCUSTOM;
5492 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5494 le16_to_cpu(bss->beacon_interval));
5495 if (iwe.u.data.length)
5496 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5500 iwe.cmd = IWEVCUSTOM;
5501 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5504 if (iwe.u.data.length)
5505 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5508 /* Add EXTRA: Age to display seconds since last beacon/probe response
5509 * for given network. */
5510 iwe.cmd = IWEVCUSTOM;
5511 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN,
5512 " Last beacon: %dms ago",
5513 jiffies_to_msecs(jiffies - last_scanned));
5514 if (iwe.u.data.length)
5515 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5521 /* Return results of a scan */
5522 static int orinoco_ioctl_getscan(struct net_device *dev,
5523 struct iw_request_info *info,
5524 struct iw_point *srq,
5527 struct orinoco_private *priv = netdev_priv(dev);
5529 unsigned long flags;
5530 char *current_ev = extra;
5532 if (orinoco_lock(priv, &flags) != 0)
5535 if (priv->scan_inprogress) {
5536 /* Important note : we don't want to block the caller
5537 * until results are ready for various reasons.
5538 * First, managing wait queues is complex and racy.
5539 * Second, we grab some rtnetlink lock before comming
5540 * here (in dev_ioctl()).
5541 * Third, we generate an Wireless Event, so the
5542 * caller can wait itself on that - Jean II */
5547 if (priv->has_ext_scan) {
5548 struct xbss_element *bss;
5550 list_for_each_entry(bss, &priv->bss_list, list) {
5551 /* Translate this entry to WE format */
5553 orinoco_translate_ext_scan(dev, info,
5555 extra + srq->length,
5559 /* Check if there is space for one more entry */
5560 if ((extra + srq->length - current_ev)
5561 <= IW_EV_ADDR_LEN) {
5562 /* Ask user space to try again with a
5570 struct bss_element *bss;
5572 list_for_each_entry(bss, &priv->bss_list, list) {
5573 /* Translate this entry to WE format */
5574 current_ev = orinoco_translate_scan(dev, info,
5576 extra + srq->length,
5580 /* Check if there is space for one more entry */
5581 if ((extra + srq->length - current_ev)
5582 <= IW_EV_ADDR_LEN) {
5583 /* Ask user space to try again with a
5591 srq->length = (current_ev - extra);
5592 srq->flags = (__u16) priv->scan_mode;
5595 orinoco_unlock(priv, &flags);
5599 /* Commit handler, called after set operations */
5600 static int orinoco_ioctl_commit(struct net_device *dev,
5601 struct iw_request_info *info,
5605 struct orinoco_private *priv = netdev_priv(dev);
5606 struct hermes *hw = &priv->hw;
5607 unsigned long flags;
5613 if (priv->broken_disableport) {
5614 orinoco_reset(&priv->reset_work);
5618 if (orinoco_lock(priv, &flags) != 0)
5621 err = hermes_disable_port(hw, 0);
5623 printk(KERN_WARNING "%s: Unable to disable port "
5624 "while reconfiguring card\n", dev->name);
5625 priv->broken_disableport = 1;
5629 err = __orinoco_program_rids(dev);
5631 printk(KERN_WARNING "%s: Unable to reconfigure card\n",
5636 err = hermes_enable_port(hw, 0);
5638 printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n",
5645 printk(KERN_WARNING "%s: Resetting instead...\n", dev->name);
5646 schedule_work(&priv->reset_work);
5650 orinoco_unlock(priv, &flags);
5654 static const struct iw_priv_args orinoco_privtab[] = {
5655 { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
5656 { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
5657 { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5659 { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5661 { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5662 0, "set_preamble" },
5663 { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5665 { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5666 0, "set_ibssport" },
5667 { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5669 { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN,
5675 * Structures to export the Wireless Handlers
5678 #define STD_IW_HANDLER(id, func) \
5679 [IW_IOCTL_IDX(id)] = (iw_handler) func
5680 static const iw_handler orinoco_handler[] = {
5681 STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit),
5682 STD_IW_HANDLER(SIOCGIWNAME, orinoco_ioctl_getname),
5683 STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq),
5684 STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq),
5685 STD_IW_HANDLER(SIOCSIWMODE, orinoco_ioctl_setmode),
5686 STD_IW_HANDLER(SIOCGIWMODE, orinoco_ioctl_getmode),
5687 STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens),
5688 STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens),
5689 STD_IW_HANDLER(SIOCGIWRANGE, orinoco_ioctl_getiwrange),
5690 STD_IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
5691 STD_IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
5692 STD_IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
5693 STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
5694 STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap),
5695 STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap),
5696 STD_IW_HANDLER(SIOCSIWSCAN, orinoco_ioctl_setscan),
5697 STD_IW_HANDLER(SIOCGIWSCAN, orinoco_ioctl_getscan),
5698 STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid),
5699 STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid),
5700 STD_IW_HANDLER(SIOCSIWNICKN, orinoco_ioctl_setnick),
5701 STD_IW_HANDLER(SIOCGIWNICKN, orinoco_ioctl_getnick),
5702 STD_IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate),
5703 STD_IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate),
5704 STD_IW_HANDLER(SIOCSIWRTS, orinoco_ioctl_setrts),
5705 STD_IW_HANDLER(SIOCGIWRTS, orinoco_ioctl_getrts),
5706 STD_IW_HANDLER(SIOCSIWFRAG, orinoco_ioctl_setfrag),
5707 STD_IW_HANDLER(SIOCGIWFRAG, orinoco_ioctl_getfrag),
5708 STD_IW_HANDLER(SIOCGIWRETRY, orinoco_ioctl_getretry),
5709 STD_IW_HANDLER(SIOCSIWENCODE, orinoco_ioctl_setiwencode),
5710 STD_IW_HANDLER(SIOCGIWENCODE, orinoco_ioctl_getiwencode),
5711 STD_IW_HANDLER(SIOCSIWPOWER, orinoco_ioctl_setpower),
5712 STD_IW_HANDLER(SIOCGIWPOWER, orinoco_ioctl_getpower),
5713 STD_IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie),
5714 STD_IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie),
5715 STD_IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme),
5716 STD_IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth),
5717 STD_IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth),
5718 STD_IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext),
5719 STD_IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext),
5724 Added typecasting since we no longer use iwreq_data -- Moustafa
5726 static const iw_handler orinoco_private_handler[] = {
5727 [0] = (iw_handler) orinoco_ioctl_reset,
5728 [1] = (iw_handler) orinoco_ioctl_reset,
5729 [2] = (iw_handler) orinoco_ioctl_setport3,
5730 [3] = (iw_handler) orinoco_ioctl_getport3,
5731 [4] = (iw_handler) orinoco_ioctl_setpreamble,
5732 [5] = (iw_handler) orinoco_ioctl_getpreamble,
5733 [6] = (iw_handler) orinoco_ioctl_setibssport,
5734 [7] = (iw_handler) orinoco_ioctl_getibssport,
5735 [9] = (iw_handler) orinoco_ioctl_getrid,
5738 static const struct iw_handler_def orinoco_handler_def = {
5739 .num_standard = ARRAY_SIZE(orinoco_handler),
5740 .num_private = ARRAY_SIZE(orinoco_private_handler),
5741 .num_private_args = ARRAY_SIZE(orinoco_privtab),
5742 .standard = orinoco_handler,
5743 .private = orinoco_private_handler,
5744 .private_args = orinoco_privtab,
5745 .get_wireless_stats = orinoco_get_wireless_stats,
5748 static void orinoco_get_drvinfo(struct net_device *dev,
5749 struct ethtool_drvinfo *info)
5751 struct orinoco_private *priv = netdev_priv(dev);
5753 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
5754 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
5755 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
5756 if (dev->dev.parent)
5757 strncpy(info->bus_info, dev->dev.parent->bus_id,
5758 sizeof(info->bus_info) - 1);
5760 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
5761 "PCMCIA %p", priv->hw.iobase);
5764 static const struct ethtool_ops orinoco_ethtool_ops = {
5765 .get_drvinfo = orinoco_get_drvinfo,
5766 .get_link = ethtool_op_get_link,
5769 /********************************************************************/
5770 /* Module initialization */
5771 /********************************************************************/
5773 EXPORT_SYMBOL(alloc_orinocodev);
5774 EXPORT_SYMBOL(free_orinocodev);
5776 EXPORT_SYMBOL(__orinoco_up);
5777 EXPORT_SYMBOL(__orinoco_down);
5778 EXPORT_SYMBOL(orinoco_reinit_firmware);
5780 EXPORT_SYMBOL(orinoco_interrupt);
5782 /* Can't be declared "const" or the whole __initdata section will
5784 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
5785 " (David Gibson <hermes@gibson.dropbear.id.au>, "
5786 "Pavel Roskin <proski@gnu.org>, et al)";
5788 static int __init init_orinoco(void)
5790 printk(KERN_DEBUG "%s\n", version);
5794 static void __exit exit_orinoco(void)
5798 module_init(init_orinoco);
5799 module_exit(exit_orinoco);