blob: c800563034a7fe408e0653b2439595bdd2b14134 [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
Jeff Garzik1a9fe632005-06-27 00:27:07 -040010#define DRIVER_VERSION "0.15rc2"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12#include <linux/types.h>
13#include <linux/spinlock.h>
14#include <linux/netdevice.h>
15#include <linux/wireless.h>
Pavel Roskin343c6862005-09-09 18:43:02 -040016#include <net/iw_handler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/version.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
Christoph Hellwig16739b02005-06-19 01:27:51 +020026#define MAX_SCAN_LEN 4096
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#define ORINOCO_MAX_KEY_SIZE 14
29#define ORINOCO_MAX_KEYS 4
30
31struct orinoco_key {
32 u16 len; /* always stored as little-endian */
33 char data[ORINOCO_MAX_KEY_SIZE];
34} __attribute__ ((packed));
35
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020036struct header_struct {
37 /* 802.3 */
38 u8 dest[ETH_ALEN];
39 u8 src[ETH_ALEN];
40 u16 len;
41 /* 802.2 */
42 u8 dsap;
43 u8 ssap;
44 u8 ctrl;
45 /* SNAP */
46 u8 oui[3];
47 u16 ethertype;
48} __attribute__ ((packed));
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050typedef enum {
51 FIRMWARE_TYPE_AGERE,
52 FIRMWARE_TYPE_INTERSIL,
53 FIRMWARE_TYPE_SYMBOL
54} fwtype_t;
55
56struct orinoco_private {
57 void *card; /* Pointer to card dependent structure */
58 int (*hard_reset)(struct orinoco_private *);
59
60 /* Synchronisation stuff */
61 spinlock_t lock;
62 int hw_unavailable;
63 struct work_struct reset_work;
64
65 /* driver state */
66 int open;
67 u16 last_linkstatus;
Christoph Hellwig16739b02005-06-19 01:27:51 +020068 struct work_struct join_work;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020069 struct work_struct wevent_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71 /* Net device stuff */
72 struct net_device *ndev;
73 struct net_device_stats stats;
74 struct iw_statistics wstats;
75
76 /* Hardware control variables */
77 hermes_t hw;
78 u16 txfid;
79
80 /* Capabilities of the hardware/firmware */
81 fwtype_t firmware_type;
82 char fw_name[32];
83 int ibss_port;
84 int nicbuf_size;
85 u16 channel_mask;
86
87 /* Boolean capabilities */
88 unsigned int has_ibss:1;
89 unsigned int has_port3:1;
90 unsigned int has_wep:1;
91 unsigned int has_big_wep:1;
92 unsigned int has_mwo:1;
93 unsigned int has_pm:1;
94 unsigned int has_preamble:1;
95 unsigned int has_sensitivity:1;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +020096 unsigned int has_hostscan:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 unsigned int broken_disableport:1;
Christoph Hellwig98c4cae2005-06-19 01:28:06 +020098 unsigned int broken_monitor:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 /* Configuration paramaters */
101 u32 iw_mode;
102 int prefer_port3;
103 u16 wep_on, wep_restrict, tx_key;
104 struct orinoco_key keys[ORINOCO_MAX_KEYS];
105 int bitratemode;
106 char nick[IW_ESSID_MAX_SIZE+1];
107 char desired_essid[IW_ESSID_MAX_SIZE+1];
Christoph Hellwig16739b02005-06-19 01:27:51 +0200108 char desired_bssid[ETH_ALEN];
109 int bssid_fixed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 u16 frag_thresh, mwo_robust;
111 u16 channel;
112 u16 ap_density, rts_thresh;
113 u16 pm_on, pm_mcast, pm_period, pm_timeout;
114 u16 preamble;
115#ifdef WIRELESS_SPY
Pavel Roskin343c6862005-09-09 18:43:02 -0400116 struct iw_spy_data spy_data; /* iwspy support */
117 struct iw_public_data wireless_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#endif
119
120 /* Configuration dependent variables */
121 int port_type, createibss;
122 int promiscuous, mc_count;
Christoph Hellwig95dd91f2005-06-19 01:27:56 +0200123
124 /* Scanning support */
125 int scan_inprogress; /* Scan pending... */
126 u32 scan_mode; /* Type of scan done */
127 char * scan_result; /* Result of previous scan */
128 int scan_len; /* Lenght of result */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129};
130
131#ifdef ORINOCO_DEBUG
132extern int orinoco_debug;
133#define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0)
134#else
135#define DEBUG(n, args...) do { } while (0)
136#endif /* ORINOCO_DEBUG */
137
138#define TRACE_ENTER(devname) DEBUG(2, "%s: -> %s()\n", devname, __FUNCTION__);
139#define TRACE_EXIT(devname) DEBUG(2, "%s: <- %s()\n", devname, __FUNCTION__);
140
141/********************************************************************/
142/* Exported prototypes */
143/********************************************************************/
144
145extern struct net_device *alloc_orinocodev(int sizeof_card,
146 int (*hard_reset)(struct orinoco_private *));
147extern void free_orinocodev(struct net_device *dev);
148extern int __orinoco_up(struct net_device *dev);
149extern int __orinoco_down(struct net_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150extern int orinoco_reinit_firmware(struct net_device *dev);
151extern irqreturn_t orinoco_interrupt(int irq, void * dev_id, struct pt_regs *regs);
152
153/********************************************************************/
154/* Locking and synchronization functions */
155/********************************************************************/
156
157/* These functions *must* be inline or they will break horribly on
158 * SPARC, due to its weird semantics for save/restore flags. extern
159 * inline should prevent the kernel from linking or module from
160 * loading if they are not inlined. */
161extern inline int orinoco_lock(struct orinoco_private *priv,
162 unsigned long *flags)
163{
164 spin_lock_irqsave(&priv->lock, *flags);
165 if (priv->hw_unavailable) {
166 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
167 priv->ndev);
168 spin_unlock_irqrestore(&priv->lock, *flags);
169 return -EBUSY;
170 }
171 return 0;
172}
173
174extern inline void orinoco_unlock(struct orinoco_private *priv,
175 unsigned long *flags)
176{
177 spin_unlock_irqrestore(&priv->lock, *flags);
178}
179
180#endif /* _ORINOCO_H */