Merge tag 'char-misc-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux-2.6-block.git] / drivers / net / wireless / intersil / orinoco / orinoco.h
CommitLineData
1da177e4 1/* orinoco.h
d14c7c1d 2 *
1da177e4
LT
3 * Common definitions to all pieces of the various orinoco
4 * drivers
5 */
6
7#ifndef _ORINOCO_H
8#define _ORINOCO_H
9
f298a2ec 10#define DRIVER_VERSION "0.15"
1da177e4 11
31afcef3 12#include <linux/interrupt.h>
39d1ffee 13#include <linux/suspend.h>
1da177e4
LT
14#include <linux/netdevice.h>
15#include <linux/wireless.h>
343c686c 16#include <net/iw_handler.h>
ea60a6aa 17#include <net/cfg80211.h>
1da177e4
LT
18
19#include "hermes.h"
20
21/* To enable debug messages */
d14c7c1d 22/*#define ORINOCO_DEBUG 3*/
1da177e4 23
d14c7c1d 24#define WIRELESS_SPY /* enable iwspy support */
1da177e4 25
16739b06
CH
26#define MAX_SCAN_LEN 4096
27
5c9f41e2 28#define ORINOCO_SEQ_LEN 8
1da177e4
LT
29#define ORINOCO_MAX_KEY_SIZE 14
30#define ORINOCO_MAX_KEYS 4
31
32struct orinoco_key {
d133ae4c 33 __le16 len; /* always stored as little-endian */
1da177e4 34 char data[ORINOCO_MAX_KEY_SIZE];
ba2d3587 35} __packed;
1da177e4 36
d03032af
DK
37#define TKIP_KEYLEN 16
38#define MIC_KEYLEN 8
39
40struct orinoco_tkip_key {
41 u8 tkip[TKIP_KEYLEN];
42 u8 tx_mic[MIC_KEYLEN];
43 u8 rx_mic[MIC_KEYLEN];
44};
45
5c9f41e2
DK
46enum orinoco_alg {
47 ORINOCO_ALG_NONE,
48 ORINOCO_ALG_WEP,
49 ORINOCO_ALG_TKIP
50};
51
933d5943 52enum fwtype {
1da177e4
LT
53 FIRMWARE_TYPE_AGERE,
54 FIRMWARE_TYPE_INTERSIL,
55 FIRMWARE_TYPE_SYMBOL
933d5943 56};
1da177e4 57
4fb30784
AB
58struct firmware;
59
1da177e4
LT
60struct orinoco_private {
61 void *card; /* Pointer to card dependent structure */
3994d502 62 struct device *dev;
1da177e4 63 int (*hard_reset)(struct orinoco_private *);
3994d502 64 int (*stop_fw)(struct orinoco_private *, int);
1da177e4 65
ea60a6aa
DK
66 struct ieee80211_supported_band band;
67 struct ieee80211_channel channels[14];
68 u32 cipher_suites[3];
69
1da177e4
LT
70 /* Synchronisation stuff */
71 spinlock_t lock;
72 int hw_unavailable;
73 struct work_struct reset_work;
74
31afcef3
DK
75 /* Interrupt tasklets */
76 struct tasklet_struct rx_tasklet;
77 struct list_head rx_list;
31afcef3 78
1da177e4
LT
79 /* driver state */
80 int open;
81 u16 last_linkstatus;
16739b06 82 struct work_struct join_work;
95dd91fb 83 struct work_struct wevent_work;
1da177e4
LT
84
85 /* Net device stuff */
86 struct net_device *ndev;
87 struct net_device_stats stats;
88 struct iw_statistics wstats;
89
90 /* Hardware control variables */
933d5943 91 struct hermes hw;
1da177e4
LT
92 u16 txfid;
93
94 /* Capabilities of the hardware/firmware */
933d5943 95 enum fwtype firmware_type;
1da177e4
LT
96 int ibss_port;
97 int nicbuf_size;
98 u16 channel_mask;
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;
95dd91fb 109 unsigned int has_hostscan:1;
6eecad77 110 unsigned int has_alt_txcntl:1;
01632fa4 111 unsigned int has_ext_scan:1;
d03032af 112 unsigned int has_wpa:1;
3994d502 113 unsigned int do_fw_download:1;
1da177e4 114 unsigned int broken_disableport:1;
98c4cae1 115 unsigned int broken_monitor:1;
bb7e43c0 116 unsigned int prefer_port3:1;
1da177e4
LT
117
118 /* Configuration paramaters */
5217c571 119 enum nl80211_iftype iw_mode;
5c9f41e2
DK
120 enum orinoco_alg encode_alg;
121 u16 wep_restrict, tx_key;
4af198fb
DK
122 struct key_params keys[ORINOCO_MAX_KEYS];
123
1da177e4 124 int bitratemode;
933d5943
PR
125 char nick[IW_ESSID_MAX_SIZE + 1];
126 char desired_essid[IW_ESSID_MAX_SIZE + 1];
16739b06
CH
127 char desired_bssid[ETH_ALEN];
128 int bssid_fixed;
1da177e4
LT
129 u16 frag_thresh, mwo_robust;
130 u16 channel;
131 u16 ap_density, rts_thresh;
132 u16 pm_on, pm_mcast, pm_period, pm_timeout;
133 u16 preamble;
c3d41503
DK
134 u16 short_retry_limit, long_retry_limit;
135 u16 retry_lifetime;
1da177e4 136#ifdef WIRELESS_SPY
d14c7c1d 137 struct iw_spy_data spy_data; /* iwspy support */
343c686c 138 struct iw_public_data wireless_data;
1da177e4
LT
139#endif
140
141 /* Configuration dependent variables */
142 int port_type, createibss;
143 int promiscuous, mc_count;
95dd91fb
CH
144
145 /* Scanning support */
c63cdbe8
DK
146 struct cfg80211_scan_request *scan_request;
147 struct work_struct process_scan;
148 struct list_head scan_list;
149 spinlock_t scan_lock; /* protects the scan list */
d03032af
DK
150
151 /* WPA support */
152 u8 *wpa_ie;
153 int wpa_ie_len;
154
a60b7faf
HX
155 struct crypto_ahash *rx_tfm_mic;
156 struct crypto_ahash *tx_tfm_mic;
d03032af
DK
157
158 unsigned int wpa_enabled:1;
159 unsigned int tkip_cm_active:1;
160 unsigned int key_mgmt:3;
4fb30784 161
2bfc5cb5 162#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
2cea7b26
DK
163 /* Cached in memory firmware to use during ->resume. */
164 const struct firmware *cached_pri_fw;
4fb30784 165 const struct firmware *cached_fw;
2bfc5cb5 166#endif
39d1ffee
DK
167
168 struct notifier_block pm_notifier;
1da177e4
LT
169};
170
171#ifdef ORINOCO_DEBUG
172extern int orinoco_debug;
d14c7c1d
AB
173#define DEBUG(n, args...) do { \
174 if (orinoco_debug > (n)) \
175 printk(KERN_DEBUG args); \
176} while (0)
1da177e4
LT
177#else
178#define DEBUG(n, args...) do { } while (0)
179#endif /* ORINOCO_DEBUG */
180
1da177e4
LT
181/********************************************************************/
182/* Exported prototypes */
183/********************************************************************/
184
53406cd7
JP
185struct orinoco_private *alloc_orinocodev(int sizeof_card, struct device *device,
186 int (*hard_reset)(struct orinoco_private *),
187 int (*stop_fw)(struct orinoco_private *, int));
188void free_orinocodev(struct orinoco_private *priv);
189int orinoco_init(struct orinoco_private *priv);
190int orinoco_if_add(struct orinoco_private *priv, unsigned long base_addr,
191 unsigned int irq, const struct net_device_ops *ops);
192void orinoco_if_del(struct orinoco_private *priv);
193int orinoco_up(struct orinoco_private *priv);
194void orinoco_down(struct orinoco_private *priv);
195irqreturn_t orinoco_interrupt(int irq, void *dev_id);
196
197void __orinoco_ev_info(struct net_device *dev, struct hermes *hw);
198void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw);
9afac70a 199
bac6fafd
DK
200int orinoco_process_xmit_skb(struct sk_buff *skb,
201 struct net_device *dev,
202 struct orinoco_private *priv,
203 int *tx_control,
204 u8 *mic);
205
593ef09c
DK
206/* Common ndo functions exported for reuse by orinoco_usb */
207int orinoco_open(struct net_device *dev);
208int orinoco_stop(struct net_device *dev);
209struct net_device_stats *orinoco_get_stats(struct net_device *dev);
210void orinoco_set_multicast_list(struct net_device *dev);
211int orinoco_change_mtu(struct net_device *dev, int new_mtu);
212void orinoco_tx_timeout(struct net_device *dev);
213
1da177e4
LT
214/********************************************************************/
215/* Locking and synchronization functions */
216/********************************************************************/
217
821fe683 218static inline int orinoco_lock(struct orinoco_private *priv,
1da177e4
LT
219 unsigned long *flags)
220{
bcad6e80 221 priv->hw.ops->lock_irqsave(&priv->lock, flags);
1da177e4
LT
222 if (priv->hw_unavailable) {
223 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
224 priv->ndev);
bcad6e80 225 priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
1da177e4
LT
226 return -EBUSY;
227 }
228 return 0;
229}
230
821fe683 231static inline void orinoco_unlock(struct orinoco_private *priv,
1da177e4
LT
232 unsigned long *flags)
233{
bcad6e80
DK
234 priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
235}
236
237static inline void orinoco_lock_irq(struct orinoco_private *priv)
238{
239 priv->hw.ops->lock_irq(&priv->lock);
240}
241
242static inline void orinoco_unlock_irq(struct orinoco_private *priv)
243{
244 priv->hw.ops->unlock_irq(&priv->lock);
1da177e4
LT
245}
246
ea60a6aa
DK
247/*** Navigate from net_device to orinoco_private ***/
248static inline struct orinoco_private *ndev_priv(struct net_device *dev)
249{
250 struct wireless_dev *wdev = netdev_priv(dev);
251 return wdev_priv(wdev);
252}
1da177e4 253#endif /* _ORINOCO_H */