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 | acc4b98 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 10 | #define DRIVER_VERSION "0.15rc3" |
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 | |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 33 | struct header_struct { |
| 34 | /* 802.3 */ |
| 35 | u8 dest[ETH_ALEN]; |
| 36 | u8 src[ETH_ALEN]; |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 37 | __be16 len; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 38 | /* 802.2 */ |
| 39 | u8 dsap; |
| 40 | u8 ssap; |
| 41 | u8 ctrl; |
| 42 | /* SNAP */ |
| 43 | u8 oui[3]; |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 44 | unsigned short ethertype; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 45 | } __attribute__ ((packed)); |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | typedef enum { |
| 48 | FIRMWARE_TYPE_AGERE, |
| 49 | FIRMWARE_TYPE_INTERSIL, |
| 50 | FIRMWARE_TYPE_SYMBOL |
| 51 | } fwtype_t; |
| 52 | |
| 53 | struct orinoco_private { |
| 54 | void *card; /* Pointer to card dependent structure */ |
| 55 | int (*hard_reset)(struct orinoco_private *); |
| 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | unsigned int broken_disableport:1; |
Christoph Hellwig | 98c4cae | 2005-06-19 01:28:06 +0200 | [diff] [blame] | 95 | unsigned int broken_monitor:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* Configuration paramaters */ |
| 98 | u32 iw_mode; |
| 99 | int prefer_port3; |
| 100 | u16 wep_on, wep_restrict, tx_key; |
| 101 | struct orinoco_key keys[ORINOCO_MAX_KEYS]; |
| 102 | int bitratemode; |
| 103 | char nick[IW_ESSID_MAX_SIZE+1]; |
| 104 | char desired_essid[IW_ESSID_MAX_SIZE+1]; |
Christoph Hellwig | 16739b0 | 2005-06-19 01:27:51 +0200 | [diff] [blame] | 105 | char desired_bssid[ETH_ALEN]; |
| 106 | int bssid_fixed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | u16 frag_thresh, mwo_robust; |
| 108 | u16 channel; |
| 109 | u16 ap_density, rts_thresh; |
| 110 | u16 pm_on, pm_mcast, pm_period, pm_timeout; |
| 111 | u16 preamble; |
| 112 | #ifdef WIRELESS_SPY |
Pavel Roskin | 343c686 | 2005-09-09 18:43:02 -0400 | [diff] [blame] | 113 | struct iw_spy_data spy_data; /* iwspy support */ |
| 114 | struct iw_public_data wireless_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #endif |
| 116 | |
| 117 | /* Configuration dependent variables */ |
| 118 | int port_type, createibss; |
| 119 | int promiscuous, mc_count; |
Christoph Hellwig | 95dd91f | 2005-06-19 01:27:56 +0200 | [diff] [blame] | 120 | |
| 121 | /* Scanning support */ |
| 122 | int scan_inprogress; /* Scan pending... */ |
| 123 | u32 scan_mode; /* Type of scan done */ |
| 124 | char * scan_result; /* Result of previous scan */ |
| 125 | int scan_len; /* Lenght of result */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | #ifdef ORINOCO_DEBUG |
| 129 | extern int orinoco_debug; |
| 130 | #define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0) |
| 131 | #else |
| 132 | #define DEBUG(n, args...) do { } while (0) |
| 133 | #endif /* ORINOCO_DEBUG */ |
| 134 | |
| 135 | #define TRACE_ENTER(devname) DEBUG(2, "%s: -> %s()\n", devname, __FUNCTION__); |
| 136 | #define TRACE_EXIT(devname) DEBUG(2, "%s: <- %s()\n", devname, __FUNCTION__); |
| 137 | |
| 138 | /********************************************************************/ |
| 139 | /* Exported prototypes */ |
| 140 | /********************************************************************/ |
| 141 | |
| 142 | extern struct net_device *alloc_orinocodev(int sizeof_card, |
| 143 | int (*hard_reset)(struct orinoco_private *)); |
| 144 | extern void free_orinocodev(struct net_device *dev); |
| 145 | extern int __orinoco_up(struct net_device *dev); |
| 146 | extern int __orinoco_down(struct net_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | extern int orinoco_reinit_firmware(struct net_device *dev); |
| 148 | extern irqreturn_t orinoco_interrupt(int irq, void * dev_id, struct pt_regs *regs); |
| 149 | |
| 150 | /********************************************************************/ |
| 151 | /* Locking and synchronization functions */ |
| 152 | /********************************************************************/ |
| 153 | |
| 154 | /* These functions *must* be inline or they will break horribly on |
| 155 | * SPARC, due to its weird semantics for save/restore flags. extern |
| 156 | * inline should prevent the kernel from linking or module from |
| 157 | * loading if they are not inlined. */ |
| 158 | extern inline int orinoco_lock(struct orinoco_private *priv, |
| 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 | |
| 171 | extern inline void orinoco_unlock(struct orinoco_private *priv, |
| 172 | unsigned long *flags) |
| 173 | { |
| 174 | spin_unlock_irqrestore(&priv->lock, *flags); |
| 175 | } |
| 176 | |
| 177 | #endif /* _ORINOCO_H */ |