Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* orinoco.h |
| 2 | * |
| 3 | * Common definitions to all pieces of the various orinoco |
| 4 | * drivers |
| 5 | */ |
| 6 | |
| 7 | #ifndef _ORINOCO_H |
| 8 | #define _ORINOCO_H |
| 9 | |
Pavel Roskin | f298a2e | 2006-04-07 04:11:02 -0400 | [diff] [blame] | 10 | #define DRIVER_VERSION "0.15" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/netdevice.h> |
| 13 | #include <linux/wireless.h> |
Pavel Roskin | 343c686 | 2005-09-09 18:43:02 -0400 | [diff] [blame] | 14 | #include <net/iw_handler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #include "hermes.h" |
| 17 | |
| 18 | /* To enable debug messages */ |
| 19 | //#define ORINOCO_DEBUG 3 |
| 20 | |
| 21 | #define WIRELESS_SPY // enable iwspy support |
| 22 | |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 23 | #define MAX_SCAN_LEN 4096 |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #define ORINOCO_MAX_KEY_SIZE 14 |
| 26 | #define ORINOCO_MAX_KEYS 4 |
| 27 | |
| 28 | struct orinoco_key { |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 29 | __le16 len; /* always stored as little-endian */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | char data[ORINOCO_MAX_KEY_SIZE]; |
| 31 | } __attribute__ ((packed)); |
| 32 | |
| 33 | typedef enum { |
| 34 | FIRMWARE_TYPE_AGERE, |
| 35 | FIRMWARE_TYPE_INTERSIL, |
| 36 | FIRMWARE_TYPE_SYMBOL |
| 37 | } fwtype_t; |
| 38 | |
David Kilroy | 3056c40 | 2008-08-21 23:27:57 +0100 | [diff] [blame] | 39 | struct bss_element { |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 40 | union hermes_scan_info bss; |
| 41 | unsigned long last_scanned; |
| 42 | struct list_head list; |
David Kilroy | 3056c40 | 2008-08-21 23:27:57 +0100 | [diff] [blame] | 43 | }; |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 44 | |
David Kilroy | 01632fa | 2008-08-21 23:27:58 +0100 | [diff] [blame^] | 45 | struct xbss_element { |
| 46 | struct agere_ext_scan_info bss; |
| 47 | unsigned long last_scanned; |
| 48 | struct list_head list; |
| 49 | }; |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct orinoco_private { |
| 52 | void *card; /* Pointer to card dependent structure */ |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 53 | struct device *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | int (*hard_reset)(struct orinoco_private *); |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 55 | int (*stop_fw)(struct orinoco_private *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | /* Synchronisation stuff */ |
| 58 | spinlock_t lock; |
| 59 | int hw_unavailable; |
| 60 | struct work_struct reset_work; |
| 61 | |
| 62 | /* driver state */ |
| 63 | int open; |
| 64 | u16 last_linkstatus; |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 65 | struct work_struct join_work; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 66 | struct work_struct wevent_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | /* Net device stuff */ |
| 69 | struct net_device *ndev; |
| 70 | struct net_device_stats stats; |
| 71 | struct iw_statistics wstats; |
| 72 | |
| 73 | /* Hardware control variables */ |
| 74 | hermes_t hw; |
| 75 | u16 txfid; |
| 76 | |
| 77 | /* Capabilities of the hardware/firmware */ |
| 78 | fwtype_t firmware_type; |
| 79 | char fw_name[32]; |
| 80 | int ibss_port; |
| 81 | int nicbuf_size; |
| 82 | u16 channel_mask; |
| 83 | |
| 84 | /* Boolean capabilities */ |
| 85 | unsigned int has_ibss:1; |
| 86 | unsigned int has_port3:1; |
| 87 | unsigned int has_wep:1; |
| 88 | unsigned int has_big_wep:1; |
| 89 | unsigned int has_mwo:1; |
| 90 | unsigned int has_pm:1; |
| 91 | unsigned int has_preamble:1; |
| 92 | unsigned int has_sensitivity:1; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 93 | unsigned int has_hostscan:1; |
David Kilroy | 6eecad7 | 2008-08-21 23:27:56 +0100 | [diff] [blame] | 94 | unsigned int has_alt_txcntl:1; |
David Kilroy | 01632fa | 2008-08-21 23:27:58 +0100 | [diff] [blame^] | 95 | unsigned int has_ext_scan:1; |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 96 | unsigned int do_fw_download:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | unsigned int broken_disableport:1; |
Christoph Hellwig | 98c4cae | 2005-06-19 01:28:06 +0200 | [diff] [blame] | 98 | unsigned int broken_monitor:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | /* Configuration paramaters */ |
| 101 | u32 iw_mode; |
| 102 | int prefer_port3; |
| 103 | u16 wep_on, wep_restrict, tx_key; |
| 104 | struct orinoco_key keys[ORINOCO_MAX_KEYS]; |
| 105 | int bitratemode; |
| 106 | char nick[IW_ESSID_MAX_SIZE+1]; |
| 107 | char desired_essid[IW_ESSID_MAX_SIZE+1]; |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 108 | char desired_bssid[ETH_ALEN]; |
| 109 | int bssid_fixed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | u16 frag_thresh, mwo_robust; |
| 111 | u16 channel; |
| 112 | u16 ap_density, rts_thresh; |
| 113 | u16 pm_on, pm_mcast, pm_period, pm_timeout; |
| 114 | u16 preamble; |
| 115 | #ifdef WIRELESS_SPY |
Pavel Roskin | 343c686 | 2005-09-09 18:43:02 -0400 | [diff] [blame] | 116 | struct iw_spy_data spy_data; /* iwspy support */ |
| 117 | struct iw_public_data wireless_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | #endif |
| 119 | |
| 120 | /* Configuration dependent variables */ |
| 121 | int port_type, createibss; |
| 122 | int promiscuous, mc_count; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 123 | |
| 124 | /* Scanning support */ |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 125 | struct list_head bss_list; |
| 126 | struct list_head bss_free_list; |
David Kilroy | 01632fa | 2008-08-21 23:27:58 +0100 | [diff] [blame^] | 127 | void *bss_xbss_data; |
Dan Williams | 1e3428e | 2007-10-10 23:56:25 -0400 | [diff] [blame] | 128 | |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 129 | int scan_inprogress; /* Scan pending... */ |
| 130 | u32 scan_mode; /* Type of scan done */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | #ifdef ORINOCO_DEBUG |
| 134 | extern int orinoco_debug; |
| 135 | #define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0) |
| 136 | #else |
| 137 | #define DEBUG(n, args...) do { } while (0) |
| 138 | #endif /* ORINOCO_DEBUG */ |
| 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | /********************************************************************/ |
| 141 | /* Exported prototypes */ |
| 142 | /********************************************************************/ |
| 143 | |
David Kilroy | 3994d50 | 2008-08-21 23:27:54 +0100 | [diff] [blame] | 144 | extern struct net_device *alloc_orinocodev( |
| 145 | int sizeof_card, struct device *device, |
| 146 | int (*hard_reset)(struct orinoco_private *), |
| 147 | int (*stop_fw)(struct orinoco_private *, int)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | extern void free_orinocodev(struct net_device *dev); |
| 149 | extern int __orinoco_up(struct net_device *dev); |
| 150 | extern int __orinoco_down(struct net_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | extern int orinoco_reinit_firmware(struct net_device *dev); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 152 | extern irqreturn_t orinoco_interrupt(int irq, void * dev_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | /********************************************************************/ |
| 155 | /* Locking and synchronization functions */ |
| 156 | /********************************************************************/ |
| 157 | |
Pavel Roskin | 821fe68 | 2006-08-15 20:45:00 -0400 | [diff] [blame] | 158 | static inline int orinoco_lock(struct orinoco_private *priv, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | unsigned long *flags) |
| 160 | { |
| 161 | spin_lock_irqsave(&priv->lock, *flags); |
| 162 | if (priv->hw_unavailable) { |
| 163 | DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n", |
| 164 | priv->ndev); |
| 165 | spin_unlock_irqrestore(&priv->lock, *flags); |
| 166 | return -EBUSY; |
| 167 | } |
| 168 | return 0; |
| 169 | } |
| 170 | |
Pavel Roskin | 821fe68 | 2006-08-15 20:45:00 -0400 | [diff] [blame] | 171 | static inline void orinoco_unlock(struct orinoco_private *priv, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | unsigned long *flags) |
| 173 | { |
| 174 | spin_unlock_irqrestore(&priv->lock, *flags); |
| 175 | } |
| 176 | |
| 177 | #endif /* _ORINOCO_H */ |