blob: e0acb633e9d56cc96605fe6d5f3ffe1e1e94a9c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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
Pavel Roskinf298a2e2006-04-07 04:11:02 -040010#define DRIVER_VERSION "0.15"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/netdevice.h>
13#include <linux/wireless.h>
Pavel Roskin343c6862005-09-09 18:43:02 -040014#include <net/iw_handler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#include "hermes.h"
17
18/* To enable debug messages */
19//#define ORINOCO_DEBUG 3
20
21#define WIRELESS_SPY // enable iwspy support
22
Christoph Hellwig16739b02005-06-19 01:27:51 +020023#define MAX_SCAN_LEN 4096
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define ORINOCO_MAX_KEY_SIZE 14
26#define ORINOCO_MAX_KEYS 4
27
28struct orinoco_key {
Pavel Roskind133ae42005-09-23 04:18:06 -040029 __le16 len; /* always stored as little-endian */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 char data[ORINOCO_MAX_KEY_SIZE];
31} __attribute__ ((packed));
32
33typedef enum {
34 FIRMWARE_TYPE_AGERE,
35 FIRMWARE_TYPE_INTERSIL,
36 FIRMWARE_TYPE_SYMBOL
37} fwtype_t;
38
Dan Williams1e3428e2007-10-10 23:56:25 -040039typedef struct {
40 union hermes_scan_info bss;
41 unsigned long last_scanned;
42 struct list_head list;
43} bss_element;
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045struct orinoco_private {
46 void *card; /* Pointer to card dependent structure */
David Kilroy3994d502008-08-21 23:27:54 +010047 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 int (*hard_reset)(struct orinoco_private *);
David Kilroy3994d502008-08-21 23:27:54 +010049 int (*stop_fw)(struct orinoco_private *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 /* Synchronisation stuff */
52 spinlock_t lock;
53 int hw_unavailable;
54 struct work_struct reset_work;
55
56 /* driver state */
57 int open;
58 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020059 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020060 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62 /* Net device stuff */
63 struct net_device *ndev;
64 struct net_device_stats stats;
65 struct iw_statistics wstats;
66
67 /* Hardware control variables */
68 hermes_t hw;
69 u16 txfid;
70
71 /* Capabilities of the hardware/firmware */
72 fwtype_t firmware_type;
73 char fw_name[32];
74 int ibss_port;
75 int nicbuf_size;
76 u16 channel_mask;
77
78 /* Boolean capabilities */
79 unsigned int has_ibss:1;
80 unsigned int has_port3:1;
81 unsigned int has_wep:1;
82 unsigned int has_big_wep:1;
83 unsigned int has_mwo:1;
84 unsigned int has_pm:1;
85 unsigned int has_preamble:1;
86 unsigned int has_sensitivity:1;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020087 unsigned int has_hostscan:1;
David Kilroy3994d502008-08-21 23:27:54 +010088 unsigned int do_fw_download:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +020090 unsigned int broken_monitor:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92 /* Configuration paramaters */
93 u32 iw_mode;
94 int prefer_port3;
95 u16 wep_on, wep_restrict, tx_key;
96 struct orinoco_key keys[ORINOCO_MAX_KEYS];
97 int bitratemode;
98 char nick[IW_ESSID_MAX_SIZE+1];
99 char desired_essid[IW_ESSID_MAX_SIZE+1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200100 char desired_bssid[ETH_ALEN];
101 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 u16 frag_thresh, mwo_robust;
103 u16 channel;
104 u16 ap_density, rts_thresh;
105 u16 pm_on, pm_mcast, pm_period, pm_timeout;
106 u16 preamble;
107#ifdef WIRELESS_SPY
Pavel Roskin343c6862005-09-09 18:43:02 -0400108 struct iw_spy_data spy_data; /* iwspy support */
109 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#endif
111
112 /* Configuration dependent variables */
113 int port_type, createibss;
114 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200115
116 /* Scanning support */
Dan Williams1e3428e2007-10-10 23:56:25 -0400117 struct list_head bss_list;
118 struct list_head bss_free_list;
119 bss_element *bss_data;
120
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200121 int scan_inprogress; /* Scan pending... */
122 u32 scan_mode; /* Type of scan done */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123};
124
125#ifdef ORINOCO_DEBUG
126extern int orinoco_debug;
127#define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
128#else
129#define DEBUG(n, args...) do { } while (0)
130#endif /* ORINOCO_DEBUG */
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132/********************************************************************/
133/* Exported prototypes */
134/********************************************************************/
135
David Kilroy3994d502008-08-21 23:27:54 +0100136extern struct net_device *alloc_orinocodev(
137 int sizeof_card, struct device *device,
138 int (*hard_reset)(struct orinoco_private *),
139 int (*stop_fw)(struct orinoco_private *, int));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140extern void free_orinocodev(struct net_device *dev);
141extern int __orinoco_up(struct net_device *dev);
142extern int __orinoco_down(struct net_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143extern int orinoco_reinit_firmware(struct net_device *dev);
David Howells7d12e782006-10-05 14:55:46 +0100144extern irqreturn_t orinoco_interrupt(int irq, void * dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146/********************************************************************/
147/* Locking and synchronization functions */
148/********************************************************************/
149
Pavel Roskin821fe682006-08-15 20:45:00 -0400150static inline int orinoco_lock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 unsigned long *flags)
152{
153 spin_lock_irqsave(&priv->lock, *flags);
154 if (priv->hw_unavailable) {
155 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
156 priv->ndev);
157 spin_unlock_irqrestore(&priv->lock, *flags);
158 return -EBUSY;
159 }
160 return 0;
161}
162
Pavel Roskin821fe682006-08-15 20:45:00 -0400163static inline void orinoco_unlock(struct orinoco_private *priv,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 unsigned long *flags)
165{
166 spin_unlock_irqrestore(&priv->lock, *flags);
167}
168
169#endif /* _ORINOCO_H */