blob: eebd2be21ee9067e7d90f45f32b227bb07601998 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* orinoco.h
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +03002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Common definitions to all pieces of the various orinoco
4 * drivers
5 */
6
7#ifndef _ORINOCO_H
8#define _ORINOCO_H
9
Pavel Roskinf298a2e2006-04-07 04:11:02 -040010#define DRIVER_VERSION "0.15"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
David Kilroy31afcef2008-08-21 23:28:04 +010012#include <linux/interrupt.h>
David Kilroy39d1ffe2008-11-22 10:37:28 +000013#include <linux/suspend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/netdevice.h>
15#include <linux/wireless.h>
Pavel Roskin343c6862005-09-09 18:43:02 -040016#include <net/iw_handler.h>
David Kilroyea60a6a2009-06-18 23:21:26 +010017#include <net/cfg80211.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19#include "hermes.h"
20
21/* To enable debug messages */
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +030022/*#define ORINOCO_DEBUG 3*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +030024#define WIRELESS_SPY /* enable iwspy support */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Christoph Hellwig16739b02005-06-19 01:27:51 +020026#define MAX_SCAN_LEN 4096
27
David Kilroy5c9f41e2009-08-05 21:23:28 +010028#define ORINOCO_SEQ_LEN 8
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#define ORINOCO_MAX_KEY_SIZE 14
30#define ORINOCO_MAX_KEYS 4
31
32struct orinoco_key {
Pavel Roskind133ae42005-09-23 04:18:06 -040033 __le16 len; /* always stored as little-endian */
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 char data[ORINOCO_MAX_KEY_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +000035} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
David Kilroyd03032a2008-08-21 23:28:02 +010037#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
David Kilroy5c9f41e2009-08-05 21:23:28 +010046enum orinoco_alg {
47 ORINOCO_ALG_NONE,
48 ORINOCO_ALG_WEP,
49 ORINOCO_ALG_TKIP
50};
51
Pavel Roskin933d5942011-07-13 11:19:57 -040052enum fwtype {
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 FIRMWARE_TYPE_AGERE,
54 FIRMWARE_TYPE_INTERSIL,
55 FIRMWARE_TYPE_SYMBOL
Pavel Roskin933d5942011-07-13 11:19:57 -040056};
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Andrey Borzenkov4fb30782008-10-19 12:06:11 +040058struct firmware;
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060struct orinoco_private {
61 void *card; /* Pointer to card dependent structure */
David Kilroy3994d502008-08-21 23:27:54 +010062 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 int (*hard_reset)(struct orinoco_private *);
David Kilroy3994d502008-08-21 23:27:54 +010064 int (*stop_fw)(struct orinoco_private *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
David Kilroyea60a6a2009-06-18 23:21:26 +010066 struct ieee80211_supported_band band;
67 struct ieee80211_channel channels[14];
68 u32 cipher_suites[3];
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 /* Synchronisation stuff */
71 spinlock_t lock;
72 int hw_unavailable;
73 struct work_struct reset_work;
74
David Kilroy31afcef2008-08-21 23:28:04 +010075 /* Interrupt tasklets */
76 struct tasklet_struct rx_tasklet;
77 struct list_head rx_list;
David Kilroy31afcef2008-08-21 23:28:04 +010078
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 /* driver state */
80 int open;
81 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020082 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020083 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
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 */
Pavel Roskin933d5942011-07-13 11:19:57 -040091 struct hermes hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 u16 txfid;
93
94 /* Capabilities of the hardware/firmware */
Pavel Roskin933d5942011-07-13 11:19:57 -040095 enum fwtype firmware_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 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;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200109 unsigned int has_hostscan:1;
David Kilroy6eecad72008-08-21 23:27:56 +0100110 unsigned int has_alt_txcntl:1;
David Kilroy01632fa2008-08-21 23:27:58 +0100111 unsigned int has_ext_scan:1;
David Kilroyd03032a2008-08-21 23:28:02 +0100112 unsigned int has_wpa:1;
David Kilroy3994d502008-08-21 23:27:54 +0100113 unsigned int do_fw_download:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +0200115 unsigned int broken_monitor:1;
David Kilroybb7e43c2009-08-05 21:23:27 +0100116 unsigned int prefer_port3:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 /* Configuration paramaters */
David Kilroy5217c572009-06-18 23:21:32 +0100119 enum nl80211_iftype iw_mode;
David Kilroy5c9f41e2009-08-05 21:23:28 +0100120 enum orinoco_alg encode_alg;
121 u16 wep_restrict, tx_key;
David Kilroy4af198f2009-08-05 21:23:32 +0100122 struct key_params keys[ORINOCO_MAX_KEYS];
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 int bitratemode;
Pavel Roskin933d5942011-07-13 11:19:57 -0400125 char nick[IW_ESSID_MAX_SIZE + 1];
126 char desired_essid[IW_ESSID_MAX_SIZE + 1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200127 char desired_bssid[ETH_ALEN];
128 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 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;
David Kilroyc3d41502010-04-19 08:16:21 +0100134 u16 short_retry_limit, long_retry_limit;
135 u16 retry_lifetime;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136#ifdef WIRELESS_SPY
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +0300137 struct iw_spy_data spy_data; /* iwspy support */
Pavel Roskin343c6862005-09-09 18:43:02 -0400138 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#endif
140
141 /* Configuration dependent variables */
142 int port_type, createibss;
143 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200144
145 /* Scanning support */
David Kilroyc63cdbe2009-06-18 23:21:33 +0100146 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 */
David Kilroyd03032a2008-08-21 23:28:02 +0100150
151 /* WPA support */
152 u8 *wpa_ie;
153 int wpa_ie_len;
154
David Kilroy23edcc42008-08-21 23:28:05 +0100155 struct crypto_hash *rx_tfm_mic;
156 struct crypto_hash *tx_tfm_mic;
David Kilroyd03032a2008-08-21 23:28:02 +0100157
158 unsigned int wpa_enabled:1;
159 unsigned int tkip_cm_active:1;
160 unsigned int key_mgmt:3;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400161
Andrey Borzenkov2bfc5cb2009-02-28 23:09:09 +0300162#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
David Kilroy2cea7b22008-11-22 10:37:26 +0000163 /* Cached in memory firmware to use during ->resume. */
164 const struct firmware *cached_pri_fw;
Andrey Borzenkov4fb30782008-10-19 12:06:11 +0400165 const struct firmware *cached_fw;
Andrey Borzenkov2bfc5cb2009-02-28 23:09:09 +0300166#endif
David Kilroy39d1ffe2008-11-22 10:37:28 +0000167
168 struct notifier_block pm_notifier;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169};
170
171#ifdef ORINOCO_DEBUG
172extern int orinoco_debug;
Andrey Borzenkovd14c7c12009-01-25 23:08:43 +0300173#define DEBUG(n, args...) do { \
174 if (orinoco_debug > (n)) \
175 printk(KERN_DEBUG args); \
176} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177#else
178#define DEBUG(n, args...) do { } while (0)
179#endif /* ORINOCO_DEBUG */
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181/********************************************************************/
182/* Exported prototypes */
183/********************************************************************/
184
Joe Perches53406cd2013-09-23 11:37:59 -0700185struct 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Joe Perches53406cd2013-09-23 11:37:59 -0700197void __orinoco_ev_info(struct net_device *dev, struct hermes *hw);
198void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw);
David Kilroy9afac702010-05-01 14:05:41 +0100199
David Kilroybac6faf2010-05-04 22:54:41 +0100200int 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
David Kilroy593ef092010-05-01 14:05:39 +0100206/* 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214/********************************************************************/
215/* Locking and synchronization functions */
216/********************************************************************/
217
Pavel Roskin821fe682006-08-15 20:45:00 -0400218static inline int orinoco_lock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 unsigned long *flags)
220{
David Kilroybcad6e82010-05-01 14:05:40 +0100221 priv->hw.ops->lock_irqsave(&priv->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 if (priv->hw_unavailable) {
223 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
224 priv->ndev);
David Kilroybcad6e82010-05-01 14:05:40 +0100225 priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 return -EBUSY;
227 }
228 return 0;
229}
230
Pavel Roskin821fe682006-08-15 20:45:00 -0400231static inline void orinoco_unlock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 unsigned long *flags)
233{
David Kilroybcad6e82010-05-01 14:05:40 +0100234 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245}
246
David Kilroyea60a6a2009-06-18 23:21:26 +0100247/*** 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}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253#endif /* _ORINOCO_H */