]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/wlan-ng/p80211netdev.h
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
[linux-2.6-omap-h63xx.git] / 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
59 /*================================================================*/
60 /* Constants */
61
62 #define WLAN_DEVICE_CLOSED      0
63 #define WLAN_DEVICE_OPEN        1
64
65 #define WLAN_MACMODE_NONE       0
66 #define WLAN_MACMODE_IBSS_STA   1
67 #define WLAN_MACMODE_ESS_STA    2
68 #define WLAN_MACMODE_ESS_AP     3
69
70 /* MSD States */
71 #define WLAN_MSD_START                  -1
72 #define WLAN_MSD_DRIVERLOADED           0
73 #define WLAN_MSD_HWPRESENT_PENDING      1
74 #define WLAN_MSD_HWFAIL                 2
75 #define WLAN_MSD_HWPRESENT              3
76 #define WLAN_MSD_FWLOAD_PENDING         4
77 #define WLAN_MSD_FWLOAD                 5
78 #define WLAN_MSD_RUNNING_PENDING        6
79 #define WLAN_MSD_RUNNING                7
80
81 #ifndef ETH_P_ECONET
82 #define ETH_P_ECONET   0x0018    /* needed for 2.2.x kernels */
83 #endif
84
85 #define ETH_P_80211_RAW        (ETH_P_ECONET + 1)
86
87 #ifndef ARPHRD_IEEE80211
88 #define ARPHRD_IEEE80211 801     /* kernel 2.4.6 */
89 #endif
90
91 #ifndef ARPHRD_IEEE80211_PRISM  /* kernel 2.4.18 */
92 #define ARPHRD_IEEE80211_PRISM 802
93 #endif
94
95 /*--- NSD Capabilities Flags ------------------------------*/
96 #define P80211_NSDCAP_HARDWAREWEP           0x01  /* hardware wep engine */
97 #define P80211_NSDCAP_TIEDWEP               0x02  /* can't decouple en/de */
98 #define P80211_NSDCAP_NOHOSTWEP             0x04  /* must use hardware wep */
99 #define P80211_NSDCAP_PBCC                  0x08  /* hardware supports PBCC */
100 #define P80211_NSDCAP_SHORT_PREAMBLE        0x10  /* hardware supports */
101 #define P80211_NSDCAP_AGILITY               0x20  /* hardware supports */
102 #define P80211_NSDCAP_AP_RETRANSMIT         0x40  /* nsd handles retransmits */
103 #define P80211_NSDCAP_HWFRAGMENT            0x80  /* nsd handles frag/defrag */
104 #define P80211_NSDCAP_AUTOJOIN              0x100  /* nsd does autojoin */
105 #define P80211_NSDCAP_NOSCAN                0x200  /* nsd can scan */
106
107 /*================================================================*/
108 /* Macros */
109
110 /*================================================================*/
111 /* Types */
112
113 /* Received frame statistics */
114 typedef struct p80211_frmrx_t
115 {
116         UINT32  mgmt;
117         UINT32  assocreq;
118         UINT32  assocresp;
119         UINT32  reassocreq;
120         UINT32  reassocresp;
121         UINT32  probereq;
122         UINT32  proberesp;
123         UINT32  beacon;
124         UINT32  atim;
125         UINT32  disassoc;
126         UINT32  authen;
127         UINT32  deauthen;
128         UINT32  mgmt_unknown;
129         UINT32  ctl;
130         UINT32  pspoll;
131         UINT32  rts;
132         UINT32  cts;
133         UINT32  ack;
134         UINT32  cfend;
135         UINT32  cfendcfack;
136         UINT32  ctl_unknown;
137         UINT32  data;
138         UINT32  dataonly;
139         UINT32  data_cfack;
140         UINT32  data_cfpoll;
141         UINT32  data__cfack_cfpoll;
142         UINT32  null;
143         UINT32  cfack;
144         UINT32  cfpoll;
145         UINT32  cfack_cfpoll;
146         UINT32  data_unknown;
147         UINT32  decrypt;
148         UINT32  decrypt_err;
149 } p80211_frmrx_t;
150
151 #ifdef WIRELESS_EXT
152 /* called by /proc/net/wireless */
153 struct iw_statistics* p80211wext_get_wireless_stats(netdevice_t *dev);
154 /* wireless extensions' ioctls */
155 int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
156 #if WIRELESS_EXT > 12
157 extern struct iw_handler_def p80211wext_handler_def;
158 #endif
159
160 int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
161
162 #endif /* wireless extensions */
163
164 /* WEP stuff */
165 #define NUM_WEPKEYS 4
166 #define MAX_KEYLEN 32
167
168 #define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
169 #define HOSTWEP_DECRYPT  BIT4
170 #define HOSTWEP_ENCRYPT  BIT5
171 #define HOSTWEP_PRIVACYINVOKED BIT6
172 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
173
174 extern int wlan_watchdog;
175 extern int wlan_wext_write;
176
177 /* WLAN device type */
178 typedef struct wlandevice
179 {
180         struct wlandevice       *next;          /* link for list of devices */
181         void                    *priv;          /* private data for MSD */
182
183         /* Subsystem State */
184         char            name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
185         char            *nsdname;
186
187         UINT32          state;          /* Device I/F state (open/closed) */
188         UINT32          msdstate;       /* state of underlying driver */
189         UINT32          hwremoved;      /* Has the hw been yanked out? */
190
191         /* Hardware config */
192         UINT            irq;
193         UINT            iobase;
194         UINT            membase;
195         UINT32          nsdcaps;  /* NSD Capabilities flags */
196
197         /* Config vars */
198         UINT            ethconv;
199
200         /* device methods (init by MSD, used by p80211 */
201         int             (*open)(struct wlandevice *wlandev);
202         int             (*close)(struct wlandevice *wlandev);
203         void            (*reset)(struct wlandevice *wlandev );
204         int             (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
205         int             (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
206         int             (*set_multicast_list)(struct wlandevice *wlandev,
207                                               netdevice_t *dev);
208         void            (*tx_timeout)(struct wlandevice *wlandev);
209
210 #ifdef CONFIG_PROC_FS
211         int             (*nsd_proc_read)(char *page, char **start, off_t offset, int count, int *eof, void *data);
212 #endif
213
214         /* 802.11 State */
215         UINT8           bssid[WLAN_BSSID_LEN];
216         p80211pstr32_t  ssid;
217         UINT32          macmode;
218         int             linkstatus;
219         int             shortpreamble;  /* C bool */
220
221         /* WEP State */
222         UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
223         UINT8 wep_keylens[NUM_WEPKEYS];
224         int   hostwep;
225
226         /* Request/Confirm i/f state (used by p80211) */
227         unsigned long           request_pending; /* flag, access atomically */
228
229         /* netlink socket */
230         /* queue for indications waiting for cmd completion */
231         /* Linux netdevice and support */
232         netdevice_t             *netdev;        /* ptr to linux netdevice */
233         struct net_device_stats linux_stats;
234
235 #ifdef CONFIG_PROC_FS
236         /* Procfs support */
237         struct proc_dir_entry   *procdir;
238         struct proc_dir_entry   *procwlandev;
239 #endif
240
241         /* Rx bottom half */
242         struct tasklet_struct   rx_bh;
243
244         struct sk_buff_head     nsd_rxq;
245
246         /* 802.11 device statistics */
247         struct p80211_frmrx_t   rx;
248
249 /* compatibility to wireless extensions */
250 #ifdef WIRELESS_EXT
251         struct iw_statistics    wstats;
252
253         /* jkriegl: iwspy fields */
254         UINT8                   spy_number;
255         char                    spy_address[IW_MAX_SPY][ETH_ALEN];
256         struct iw_quality       spy_stat[IW_MAX_SPY];
257
258 #endif
259
260 } wlandevice_t;
261
262 /* WEP stuff */
263 int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen);
264 int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv);
265 int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv);
266
267 /*================================================================*/
268 /* Externs */
269
270 /*================================================================*/
271 /* Function Declarations */
272
273 void    p80211netdev_startup(void);
274 void    p80211netdev_shutdown(void);
275 int     wlan_setup(wlandevice_t *wlandev);
276 int     wlan_unsetup(wlandevice_t *wlandev);
277 int     register_wlandev(wlandevice_t *wlandev);
278 int     unregister_wlandev(wlandevice_t *wlandev);
279 void    p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
280 void    p80211netdev_hwremoved(wlandevice_t *wlandev);
281 void    p80211_suspend(wlandevice_t *wlandev);
282 void    p80211_resume(wlandevice_t *wlandev);
283
284 /*================================================================*/
285 /* Function Definitions */
286
287 static inline void
288 p80211netdev_stop_queue(wlandevice_t *wlandev)
289 {
290         if ( !wlandev ) return;
291         if ( !wlandev->netdev ) return;
292 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
293         wlandev->netdev->tbusy = 1;
294         wlandev->netdev->start = 0;
295 #else
296         netif_stop_queue(wlandev->netdev);
297 #endif
298 }
299
300 static inline void
301 p80211netdev_start_queue(wlandevice_t *wlandev)
302 {
303         if ( !wlandev ) return;
304         if ( !wlandev->netdev ) return;
305 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
306         wlandev->netdev->tbusy = 0;
307         wlandev->netdev->start = 1;
308 #else
309         netif_start_queue(wlandev->netdev);
310 #endif
311 }
312
313 static inline void
314 p80211netdev_wake_queue(wlandevice_t *wlandev)
315 {
316         if ( !wlandev ) return;
317         if ( !wlandev->netdev ) return;
318 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
319         wlandev->netdev->tbusy = 0;
320         mark_bh(NET_BH);
321 #else
322         netif_wake_queue(wlandev->netdev);
323 #endif
324 }
325
326 #ifdef CONFIG_HOTPLUG
327 #define WLAN_HOTPLUG_REGISTER "register"
328 #define WLAN_HOTPLUG_REMOVE   "remove"
329 #define WLAN_HOTPLUG_STARTUP  "startup"
330 #define WLAN_HOTPLUG_SHUTDOWN "shutdown"
331 #define WLAN_HOTPLUG_SUSPEND "suspend"
332 #define WLAN_HOTPLUG_RESUME "resume"
333 int p80211_run_sbin_hotplug(wlandevice_t *wlandev, char *action);
334 #endif
335
336 #endif