Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
orinoco.h
Go to the documentation of this file.
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.15"
11 
12 #include <linux/interrupt.h>
13 #include <linux/suspend.h>
14 #include <linux/netdevice.h>
15 #include <linux/wireless.h>
16 #include <net/iw_handler.h>
17 #include <net/cfg80211.h>
18 
19 #include "hermes.h"
20 
21 /* To enable debug messages */
22 /*#define ORINOCO_DEBUG 3*/
23 
24 #define WIRELESS_SPY /* enable iwspy support */
25 
26 #define MAX_SCAN_LEN 4096
27 
28 #define ORINOCO_SEQ_LEN 8
29 #define ORINOCO_MAX_KEY_SIZE 14
30 #define ORINOCO_MAX_KEYS 4
31 
32 struct orinoco_key {
33  __le16 len; /* always stored as little-endian */
35 } __packed;
36 
37 #define TKIP_KEYLEN 16
38 #define MIC_KEYLEN 8
39 
44 };
45 
50 };
51 
52 enum fwtype {
56 };
57 
58 struct firmware;
59 
61  void *card; /* Pointer to card dependent structure */
62  struct device *dev;
64  int (*stop_fw)(struct orinoco_private *, int);
65 
69 
70  /* Synchronisation stuff */
74 
75  /* Interrupt tasklets */
78 
79  /* driver state */
80  int open;
84 
85  /* Net device stuff */
86  struct net_device *ndev;
89 
90  /* Hardware control variables */
91  struct hermes hw;
93 
94  /* Capabilities of the hardware/firmware */
96  int ibss_port;
99 
100  /* Boolean capabilities */
101  unsigned int has_ibss:1;
102  unsigned int has_port3:1;
103  unsigned int has_wep:1;
104  unsigned int has_big_wep:1;
105  unsigned int has_mwo:1;
106  unsigned int has_pm:1;
107  unsigned int has_preamble:1;
108  unsigned int has_sensitivity:1;
109  unsigned int has_hostscan:1;
110  unsigned int has_alt_txcntl:1;
111  unsigned int has_ext_scan:1;
112  unsigned int has_wpa:1;
113  unsigned int do_fw_download:1;
114  unsigned int broken_disableport:1;
115  unsigned int broken_monitor:1;
116  unsigned int prefer_port3:1;
117 
118  /* Configuration paramaters */
123 
136 #ifdef WIRELESS_SPY
137  struct iw_spy_data spy_data; /* iwspy support */
139 #endif
140 
141  /* Configuration dependent variables */
144 
145  /* Scanning support */
149  spinlock_t scan_lock; /* protects the scan list */
150 
151  /* WPA support */
154 
157 
158  unsigned int wpa_enabled:1;
159  unsigned int tkip_cm_active:1;
160  unsigned int key_mgmt:3;
161 
162 #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
163  /* Cached in memory firmware to use during ->resume. */
164  const struct firmware *cached_pri_fw;
165  const struct firmware *cached_fw;
166 #endif
167 
169 };
170 
171 #ifdef ORINOCO_DEBUG
172 extern int orinoco_debug;
173 #define DEBUG(n, args...) do { \
174  if (orinoco_debug > (n)) \
175  printk(KERN_DEBUG args); \
176 } while (0)
177 #else
178 #define DEBUG(n, args...) do { } while (0)
179 #endif /* ORINOCO_DEBUG */
180 
181 /********************************************************************/
182 /* Exported prototypes */
183 /********************************************************************/
184 
185 extern struct orinoco_private *alloc_orinocodev(
186  int sizeof_card, struct device *device,
187  int (*hard_reset)(struct orinoco_private *),
188  int (*stop_fw)(struct orinoco_private *, int));
189 extern void free_orinocodev(struct orinoco_private *priv);
190 extern int orinoco_init(struct orinoco_private *priv);
191 extern int orinoco_if_add(struct orinoco_private *priv,
192  unsigned long base_addr,
193  unsigned int irq,
194  const struct net_device_ops *ops);
195 extern void orinoco_if_del(struct orinoco_private *priv);
196 extern int orinoco_up(struct orinoco_private *priv);
197 extern void orinoco_down(struct orinoco_private *priv);
198 extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
199 
200 extern void __orinoco_ev_info(struct net_device *dev, struct hermes *hw);
201 extern void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw);
202 
204  struct net_device *dev,
205  struct orinoco_private *priv,
206  int *tx_control,
207  u8 *mic);
208 
209 /* Common ndo functions exported for reuse by orinoco_usb */
210 int orinoco_open(struct net_device *dev);
211 int orinoco_stop(struct net_device *dev);
214 int orinoco_change_mtu(struct net_device *dev, int new_mtu);
215 void orinoco_tx_timeout(struct net_device *dev);
216 
217 /********************************************************************/
218 /* Locking and synchronization functions */
219 /********************************************************************/
220 
221 static inline int orinoco_lock(struct orinoco_private *priv,
222  unsigned long *flags)
223 {
224  priv->hw.ops->lock_irqsave(&priv->lock, flags);
225  if (priv->hw_unavailable) {
226  DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
227  priv->ndev);
228  priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
229  return -EBUSY;
230  }
231  return 0;
232 }
233 
234 static inline void orinoco_unlock(struct orinoco_private *priv,
235  unsigned long *flags)
236 {
237  priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
238 }
239 
240 static inline void orinoco_lock_irq(struct orinoco_private *priv)
241 {
242  priv->hw.ops->lock_irq(&priv->lock);
243 }
244 
245 static inline void orinoco_unlock_irq(struct orinoco_private *priv)
246 {
247  priv->hw.ops->unlock_irq(&priv->lock);
248 }
249 
250 /*** Navigate from net_device to orinoco_private ***/
251 static inline struct orinoco_private *ndev_priv(struct net_device *dev)
252 {
253  struct wireless_dev *wdev = netdev_priv(dev);
254  return wdev_priv(wdev);
255 }
256 #endif /* _ORINOCO_H */