vserver 1.9.3
[linux-2.6.git] / 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.13e"
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 ORINOCO_MAX_KEY_SIZE    14
26 #define ORINOCO_MAX_KEYS        4
27
28 struct orinoco_key {
29         u16 len;        /* always stored as little-endian */
30         char data[ORINOCO_MAX_KEY_SIZE];
31 } __attribute__ ((packed));
32
33 struct orinoco_private {
34         void *card;     /* Pointer to card dependent structure */
35         int (*hard_reset)(struct orinoco_private *);
36
37         /* Synchronisation stuff */
38         spinlock_t lock;
39         int hw_unavailable;
40         struct work_struct reset_work;
41
42         /* driver state */
43         int open;
44         u16 last_linkstatus;
45         int connected;
46
47         /* Net device stuff */
48         struct net_device *ndev;
49         struct net_device_stats stats;
50         struct iw_statistics wstats;
51
52         /* Hardware control variables */
53         hermes_t hw;
54         u16 txfid;
55
56         /* Capabilities of the hardware/firmware */
57         int firmware_type;
58 #define FIRMWARE_TYPE_AGERE 1
59 #define FIRMWARE_TYPE_INTERSIL 2
60 #define FIRMWARE_TYPE_SYMBOL 3
61         int has_ibss, has_port3, has_ibss_any, ibss_port;
62         int has_wep, has_big_wep;
63         int has_mwo;
64         int has_pm;
65         int has_preamble;
66         int has_sensitivity;
67         int nicbuf_size;
68         u16 channel_mask;
69         int broken_disableport;
70
71         /* Configuration paramaters */
72         u32 iw_mode;
73         int prefer_port3;
74         u16 wep_on, wep_restrict, tx_key;
75         struct orinoco_key keys[ORINOCO_MAX_KEYS];
76         int bitratemode;
77         char nick[IW_ESSID_MAX_SIZE+1];
78         char desired_essid[IW_ESSID_MAX_SIZE+1];
79         u16 frag_thresh, mwo_robust;
80         u16 channel;
81         u16 ap_density, rts_thresh;
82         u16 pm_on, pm_mcast, pm_period, pm_timeout;
83         u16 preamble;
84 #ifdef WIRELESS_SPY
85         int                     spy_number;
86         u_char                  spy_address[IW_MAX_SPY][ETH_ALEN];
87         struct iw_quality       spy_stat[IW_MAX_SPY];
88 #endif
89
90         /* Configuration dependent variables */
91         int port_type, createibss;
92         int promiscuous, mc_count;
93 };
94
95 #ifdef ORINOCO_DEBUG
96 extern int orinoco_debug;
97 #define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
98 #else
99 #define DEBUG(n, args...) do { } while (0)
100 #endif  /* ORINOCO_DEBUG */
101
102 #define TRACE_ENTER(devname) DEBUG(2, "%s: -> %s()\n", devname, __FUNCTION__);
103 #define TRACE_EXIT(devname)  DEBUG(2, "%s: <- %s()\n", devname, __FUNCTION__);
104
105 /********************************************************************/
106 /* Exported prototypes                                              */
107 /********************************************************************/
108
109 extern struct net_device *alloc_orinocodev(int sizeof_card,
110                                            int (*hard_reset)(struct orinoco_private *));
111 extern int __orinoco_up(struct net_device *dev);
112 extern int __orinoco_down(struct net_device *dev);
113 extern int orinoco_stop(struct net_device *dev);
114 extern int orinoco_reinit_firmware(struct net_device *dev);
115 extern irqreturn_t orinoco_interrupt(int irq, void * dev_id, struct pt_regs *regs);
116
117 /********************************************************************/
118 /* Locking and synchronization functions                            */
119 /********************************************************************/
120
121 /* These functions *must* be inline or they will break horribly on
122  * SPARC, due to its weird semantics for save/restore flags. extern
123  * inline should prevent the kernel from linking or module from
124  * loading if they are not inlined. */
125 extern inline int orinoco_lock(struct orinoco_private *priv,
126                                unsigned long *flags)
127 {
128         spin_lock_irqsave(&priv->lock, *flags);
129         if (priv->hw_unavailable) {
130                 printk(KERN_DEBUG "orinoco_lock() called with hw_unavailable (dev=%p)\n",
131                        priv->ndev);
132                 spin_unlock_irqrestore(&priv->lock, *flags);
133                 return -EBUSY;
134         }
135         return 0;
136 }
137
138 extern inline void orinoco_unlock(struct orinoco_private *priv,
139                                   unsigned long *flags)
140 {
141         spin_unlock_irqrestore(&priv->lock, *flags);
142 }
143
144 #endif /* _ORINOCO_H */