[PATCH] orinoco: scanning support
[safe/jmp/linux-2.6] / drivers / net / wireless / orinoco.h
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
10 #define DRIVER_VERSION "0.14alpha2"
11
12 #include <linux/types.h>
13 #include <linux/spinlock.h>
14 #include <linux/netdevice.h>
15 #include <linux/wireless.h>
16 #include <linux/version.h>
17
18 #include "hermes.h"
19
20 /* To enable debug messages */
21 //#define ORINOCO_DEBUG         3
22
23 #define WIRELESS_SPY            // enable iwspy support
24
25 #define MAX_SCAN_LEN            4096
26
27 #define ORINOCO_MAX_KEY_SIZE    14
28 #define ORINOCO_MAX_KEYS        4
29
30 struct orinoco_key {
31         u16 len;        /* always stored as little-endian */
32         char data[ORINOCO_MAX_KEY_SIZE];
33 } __attribute__ ((packed));
34
35 struct header_struct {
36         /* 802.3 */
37         u8 dest[ETH_ALEN];
38         u8 src[ETH_ALEN];
39         u16 len;
40         /* 802.2 */
41         u8 dsap;
42         u8 ssap;
43         u8 ctrl;
44         /* SNAP */
45         u8 oui[3];
46         u16 ethertype;
47 } __attribute__ ((packed));
48
49 typedef enum {
50         FIRMWARE_TYPE_AGERE,
51         FIRMWARE_TYPE_INTERSIL,
52         FIRMWARE_TYPE_SYMBOL
53 } fwtype_t;
54
55 struct orinoco_private {
56         void *card;     /* Pointer to card dependent structure */
57         int (*hard_reset)(struct orinoco_private *);
58
59         /* Synchronisation stuff */
60         spinlock_t lock;
61         int hw_unavailable;
62         struct work_struct reset_work;
63
64         /* driver state */
65         int open;
66         u16 last_linkstatus;
67         struct work_struct join_work;
68         struct work_struct wevent_work;
69
70         /* Net device stuff */
71         struct net_device *ndev;
72         struct net_device_stats stats;
73         struct iw_statistics wstats;
74
75         /* Hardware control variables */
76         hermes_t hw;
77         u16 txfid;
78
79         /* Capabilities of the hardware/firmware */
80         fwtype_t firmware_type;
81         char fw_name[32];
82         int ibss_port;
83         int nicbuf_size;
84         u16 channel_mask;
85
86         /* Boolean capabilities */
87         unsigned int has_ibss:1;
88         unsigned int has_port3:1;
89         unsigned int has_wep:1;
90         unsigned int has_big_wep:1;
91         unsigned int has_mwo:1;
92         unsigned int has_pm:1;
93         unsigned int has_preamble:1;
94         unsigned int has_sensitivity:1;
95         unsigned int has_hostscan:1;
96         unsigned int broken_disableport:1;
97
98         /* Configuration paramaters */
99         u32 iw_mode;
100         int prefer_port3;
101         u16 wep_on, wep_restrict, tx_key;
102         struct orinoco_key keys[ORINOCO_MAX_KEYS];
103         int bitratemode;
104         char nick[IW_ESSID_MAX_SIZE+1];
105         char desired_essid[IW_ESSID_MAX_SIZE+1];
106         char desired_bssid[ETH_ALEN];
107         int bssid_fixed;
108         u16 frag_thresh, mwo_robust;
109         u16 channel;
110         u16 ap_density, rts_thresh;
111         u16 pm_on, pm_mcast, pm_period, pm_timeout;
112         u16 preamble;
113 #ifdef WIRELESS_SPY
114         int                     spy_number;
115         u_char                  spy_address[IW_MAX_SPY][ETH_ALEN];
116         struct iw_quality       spy_stat[IW_MAX_SPY];
117 #endif
118
119         /* Configuration dependent variables */
120         int port_type, createibss;
121         int promiscuous, mc_count;
122
123         /* Scanning support */
124         int     scan_inprogress;        /* Scan pending... */
125         u32     scan_mode;              /* Type of scan done */
126         char *  scan_result;            /* Result of previous scan */
127         int     scan_len;               /* Lenght of result */
128 };
129
130 #ifdef ORINOCO_DEBUG
131 extern int orinoco_debug;
132 #define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
133 #else
134 #define DEBUG(n, args...) do { } while (0)
135 #endif  /* ORINOCO_DEBUG */
136
137 #define TRACE_ENTER(devname) DEBUG(2, "%s: -> %s()\n", devname, __FUNCTION__);
138 #define TRACE_EXIT(devname)  DEBUG(2, "%s: <- %s()\n", devname, __FUNCTION__);
139
140 /********************************************************************/
141 /* Exported prototypes                                              */
142 /********************************************************************/
143
144 extern struct net_device *alloc_orinocodev(int sizeof_card,
145                                            int (*hard_reset)(struct orinoco_private *));
146 extern void free_orinocodev(struct net_device *dev);
147 extern int __orinoco_up(struct net_device *dev);
148 extern int __orinoco_down(struct net_device *dev);
149 extern int orinoco_reinit_firmware(struct net_device *dev);
150 extern irqreturn_t orinoco_interrupt(int irq, void * dev_id, struct pt_regs *regs);
151
152 /********************************************************************/
153 /* Locking and synchronization functions                            */
154 /********************************************************************/
155
156 /* These functions *must* be inline or they will break horribly on
157  * SPARC, due to its weird semantics for save/restore flags. extern
158  * inline should prevent the kernel from linking or module from
159  * loading if they are not inlined. */
160 extern inline int orinoco_lock(struct orinoco_private *priv,
161                                unsigned long *flags)
162 {
163         spin_lock_irqsave(&priv->lock, *flags);
164         if (priv->hw_unavailable) {
165                 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
166                        priv->ndev);
167                 spin_unlock_irqrestore(&priv->lock, *flags);
168                 return -EBUSY;
169         }
170         return 0;
171 }
172
173 extern inline void orinoco_unlock(struct orinoco_private *priv,
174                                   unsigned long *flags)
175 {
176         spin_unlock_irqrestore(&priv->lock, *flags);
177 }
178
179 #endif /* _ORINOCO_H */