Merge branch 'for-linus' of git://repo.or.cz/cris-mirror
[linux-2.6] / drivers / staging / wlan-ng / p80211netdev.h
1 /* p80211netdev.h
2 *
3 * WLAN net device structure and functions
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 *
47 * This file declares the structure type that represents each wlan
48 * interface.
49 *
50 * --------------------------------------------------------------------
51 */
52
53 #ifndef _LINUX_P80211NETDEV_H
54 #define _LINUX_P80211NETDEV_H
55
56 #include <linux/interrupt.h>
57 #include <linux/wireless.h>
58 #include <linux/netdevice.h>
59
60 /*================================================================*/
61 /* Constants */
62
63 #undef netdevice_t
64 typedef struct net_device netdevice_t;
65
66 #define WLAN_RELEASE    "0.3.0-staging"
67
68 #define WLAN_DEVICE_CLOSED      0
69 #define WLAN_DEVICE_OPEN        1
70
71 #define WLAN_MACMODE_NONE       0
72 #define WLAN_MACMODE_IBSS_STA   1
73 #define WLAN_MACMODE_ESS_STA    2
74 #define WLAN_MACMODE_ESS_AP     3
75
76 /* MSD States */
77 #define WLAN_MSD_HWPRESENT_PENDING      1
78 #define WLAN_MSD_HWFAIL                 2
79 #define WLAN_MSD_HWPRESENT              3
80 #define WLAN_MSD_FWLOAD_PENDING         4
81 #define WLAN_MSD_FWLOAD                 5
82 #define WLAN_MSD_RUNNING_PENDING        6
83 #define WLAN_MSD_RUNNING                7
84
85 #ifndef ETH_P_ECONET
86 #define ETH_P_ECONET   0x0018   /* needed for 2.2.x kernels */
87 #endif
88
89 #define ETH_P_80211_RAW        (ETH_P_ECONET + 1)
90
91 #ifndef ARPHRD_IEEE80211
92 #define ARPHRD_IEEE80211 801    /* kernel 2.4.6 */
93 #endif
94
95 #ifndef ARPHRD_IEEE80211_PRISM  /* kernel 2.4.18 */
96 #define ARPHRD_IEEE80211_PRISM 802
97 #endif
98
99 /*--- NSD Capabilities Flags ------------------------------*/
100 #define P80211_NSDCAP_HARDWAREWEP           0x01        /* hardware wep engine */
101 #define P80211_NSDCAP_SHORT_PREAMBLE        0x10        /* hardware supports */
102 #define P80211_NSDCAP_HWFRAGMENT            0x80        /* nsd handles frag/defrag */
103 #define P80211_NSDCAP_AUTOJOIN              0x100       /* nsd does autojoin */
104 #define P80211_NSDCAP_NOSCAN                0x200       /* nsd can scan */
105
106 /* Received frame statistics */
107 typedef struct p80211_frmrx_t {
108         u32 mgmt;
109         u32 assocreq;
110         u32 assocresp;
111         u32 reassocreq;
112         u32 reassocresp;
113         u32 probereq;
114         u32 proberesp;
115         u32 beacon;
116         u32 atim;
117         u32 disassoc;
118         u32 authen;
119         u32 deauthen;
120         u32 mgmt_unknown;
121         u32 ctl;
122         u32 pspoll;
123         u32 rts;
124         u32 cts;
125         u32 ack;
126         u32 cfend;
127         u32 cfendcfack;
128         u32 ctl_unknown;
129         u32 data;
130         u32 dataonly;
131         u32 data_cfack;
132         u32 data_cfpoll;
133         u32 data__cfack_cfpoll;
134         u32 null;
135         u32 cfack;
136         u32 cfpoll;
137         u32 cfack_cfpoll;
138         u32 data_unknown;
139         u32 decrypt;
140         u32 decrypt_err;
141 } p80211_frmrx_t;
142
143 /* called by /proc/net/wireless */
144 struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t * dev);
145 /* wireless extensions' ioctls */
146 extern struct iw_handler_def p80211wext_handler_def;
147 int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
148
149 /* WEP stuff */
150 #define NUM_WEPKEYS 4
151 #define MAX_KEYLEN 32
152
153 #define HOSTWEP_DEFAULTKEY_MASK (BIT(1)|BIT(0))
154 #define HOSTWEP_DECRYPT  BIT(4)
155 #define HOSTWEP_ENCRYPT  BIT(5)
156 #define HOSTWEP_PRIVACYINVOKED BIT(6)
157 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT(7)
158
159 extern int wlan_watchdog;
160 extern int wlan_wext_write;
161
162 /* WLAN device type */
163 typedef struct wlandevice {
164         struct wlandevice *next;        /* link for list of devices */
165         void *priv;             /* private data for MSD */
166
167         /* Subsystem State */
168         char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev() */
169         char *nsdname;
170
171         u32 state;              /* Device I/F state (open/closed) */
172         u32 msdstate;           /* state of underlying driver */
173         u32 hwremoved;          /* Has the hw been yanked out? */
174
175         /* Hardware config */
176         unsigned int irq;
177         unsigned int iobase;
178         unsigned int membase;
179         u32 nsdcaps;            /* NSD Capabilities flags */
180
181         /* Config vars */
182         unsigned int ethconv;
183
184         /* device methods (init by MSD, used by p80211 */
185         int (*open) (struct wlandevice *wlandev);
186         int (*close) (struct wlandevice *wlandev);
187         void (*reset) (struct wlandevice *wlandev);
188         int (*txframe) (struct wlandevice *wlandev, struct sk_buff *skb,
189                         p80211_hdr_t *p80211_hdr,
190                         p80211_metawep_t *p80211_wep);
191         int (*mlmerequest) (struct wlandevice *wlandev, p80211msg_t *msg);
192         int (*set_multicast_list) (struct wlandevice *wlandev,
193                                    netdevice_t *dev);
194         void (*tx_timeout) (struct wlandevice *wlandev);
195
196         /* 802.11 State */
197         u8 bssid[WLAN_BSSID_LEN];
198         p80211pstr32_t ssid;
199         u32 macmode;
200         int linkstatus;
201
202         /* WEP State */
203         u8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
204         u8 wep_keylens[NUM_WEPKEYS];
205         int hostwep;
206
207         /* Request/Confirm i/f state (used by p80211) */
208         unsigned long request_pending;  /* flag, access atomically */
209
210         /* netlink socket */
211         /* queue for indications waiting for cmd completion */
212         /* Linux netdevice and support */
213         netdevice_t *netdev;    /* ptr to linux netdevice */
214         struct net_device_stats linux_stats;
215
216         /* Rx bottom half */
217         struct tasklet_struct rx_bh;
218
219         struct sk_buff_head nsd_rxq;
220
221         /* 802.11 device statistics */
222         struct p80211_frmrx_t rx;
223
224         struct iw_statistics wstats;
225
226         /* jkriegl: iwspy fields */
227         u8 spy_number;
228         char spy_address[IW_MAX_SPY][ETH_ALEN];
229         struct iw_quality spy_stat[IW_MAX_SPY];
230
231         struct mutex ioctl_lock;
232 } wlandevice_t;
233
234 /* WEP stuff */
235 int wep_change_key(wlandevice_t *wlandev, int keynum, u8 *key, int keylen);
236 int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override,
237                 u8 *iv, u8 *icv);
238 int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum,
239                 u8 *iv, u8 *icv);
240
241 int wlan_setup(wlandevice_t *wlandev);
242 int wlan_unsetup(wlandevice_t *wlandev);
243 int register_wlandev(wlandevice_t *wlandev);
244 int unregister_wlandev(wlandevice_t *wlandev);
245 void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
246 void p80211netdev_hwremoved(wlandevice_t *wlandev);
247 void p80211_allow_ioctls(wlandevice_t *wlandev);
248 #endif