]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/wlan-ng/p80211netdev.h
Staging: wlan-ng: Eliminate usage of procfs.
[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 extern struct iw_handler_def p80211wext_handler_def;
157 int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
158 #endif /* wireless extensions */
159
160 /* WEP stuff */
161 #define NUM_WEPKEYS 4
162 #define MAX_KEYLEN 32
163
164 #define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
165 #define HOSTWEP_DECRYPT  BIT4
166 #define HOSTWEP_ENCRYPT  BIT5
167 #define HOSTWEP_PRIVACYINVOKED BIT6
168 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
169
170 extern int wlan_watchdog;
171 extern int wlan_wext_write;
172
173 /* WLAN device type */
174 typedef struct wlandevice
175 {
176         struct wlandevice       *next;          /* link for list of devices */
177         void                    *priv;          /* private data for MSD */
178
179         /* Subsystem State */
180         char            name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
181         char            *nsdname;
182
183         UINT32          state;          /* Device I/F state (open/closed) */
184         UINT32          msdstate;       /* state of underlying driver */
185         UINT32          hwremoved;      /* Has the hw been yanked out? */
186
187         /* Hardware config */
188         UINT            irq;
189         UINT            iobase;
190         UINT            membase;
191         UINT32          nsdcaps;  /* NSD Capabilities flags */
192
193         /* Config vars */
194         UINT            ethconv;
195
196         /* device methods (init by MSD, used by p80211 */
197         int             (*open)(struct wlandevice *wlandev);
198         int             (*close)(struct wlandevice *wlandev);
199         void            (*reset)(struct wlandevice *wlandev );
200         int             (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
201         int             (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
202         int             (*set_multicast_list)(struct wlandevice *wlandev,
203                                               netdevice_t *dev);
204         void            (*tx_timeout)(struct wlandevice *wlandev);
205
206         /* 802.11 State */
207         UINT8           bssid[WLAN_BSSID_LEN];
208         p80211pstr32_t  ssid;
209         UINT32          macmode;
210         int             linkstatus;
211         int             shortpreamble;  /* C bool */
212
213         /* WEP State */
214         UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
215         UINT8 wep_keylens[NUM_WEPKEYS];
216         int   hostwep;
217
218         /* Request/Confirm i/f state (used by p80211) */
219         unsigned long           request_pending; /* flag, access atomically */
220
221         /* netlink socket */
222         /* queue for indications waiting for cmd completion */
223         /* Linux netdevice and support */
224         netdevice_t             *netdev;        /* ptr to linux netdevice */
225         struct net_device_stats linux_stats;
226
227         /* Rx bottom half */
228         struct tasklet_struct   rx_bh;
229
230         struct sk_buff_head     nsd_rxq;
231
232         /* 802.11 device statistics */
233         struct p80211_frmrx_t   rx;
234
235 /* compatibility to wireless extensions */
236 #ifdef WIRELESS_EXT
237         struct iw_statistics    wstats;
238
239         /* jkriegl: iwspy fields */
240         UINT8                   spy_number;
241         char                    spy_address[IW_MAX_SPY][ETH_ALEN];
242         struct iw_quality       spy_stat[IW_MAX_SPY];
243
244 #endif
245
246 } wlandevice_t;
247
248 /* WEP stuff */
249 int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen);
250 int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv);
251 int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv);
252
253 /*================================================================*/
254 /* Externs */
255
256 /*================================================================*/
257 /* Function Declarations */
258
259 void    p80211netdev_startup(void);
260 void    p80211netdev_shutdown(void);
261 int     wlan_setup(wlandevice_t *wlandev);
262 int     wlan_unsetup(wlandevice_t *wlandev);
263 int     register_wlandev(wlandevice_t *wlandev);
264 int     unregister_wlandev(wlandevice_t *wlandev);
265 void    p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
266 void    p80211netdev_hwremoved(wlandevice_t *wlandev);
267 void    p80211_suspend(wlandevice_t *wlandev);
268 void    p80211_resume(wlandevice_t *wlandev);
269
270 /*================================================================*/
271 /* Function Definitions */
272
273 static inline void
274 p80211netdev_stop_queue(wlandevice_t *wlandev)
275 {
276         if ( !wlandev ) return;
277         if ( !wlandev->netdev ) return;
278         netif_stop_queue(wlandev->netdev);
279 }
280
281 static inline void
282 p80211netdev_start_queue(wlandevice_t *wlandev)
283 {
284         if ( !wlandev ) return;
285         if ( !wlandev->netdev ) return;
286         netif_start_queue(wlandev->netdev);
287 }
288
289 static inline void
290 p80211netdev_wake_queue(wlandevice_t *wlandev)
291 {
292         if ( !wlandev ) return;
293         if ( !wlandev->netdev ) return;
294         netif_wake_queue(wlandev->netdev);
295 }
296
297 #endif