3 * WLAN net device structure and functions
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
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/
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.
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.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * This file declares the structure type that represents each wlan
50 * --------------------------------------------------------------------
53 #ifndef _LINUX_P80211NETDEV_H
54 #define _LINUX_P80211NETDEV_H
56 #include <linux/interrupt.h>
57 #include <linux/wireless.h>
59 /*================================================================*/
62 #define WLAN_DEVICE_CLOSED 0
63 #define WLAN_DEVICE_OPEN 1
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
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
82 #define ETH_P_ECONET 0x0018 /* needed for 2.2.x kernels */
85 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
87 #ifndef ARPHRD_IEEE80211
88 #define ARPHRD_IEEE80211 801 /* kernel 2.4.6 */
91 #ifndef ARPHRD_IEEE80211_PRISM /* kernel 2.4.18 */
92 #define ARPHRD_IEEE80211_PRISM 802
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 */
107 /*================================================================*/
110 /*================================================================*/
113 /* Received frame statistics */
114 typedef struct p80211_frmrx_t
141 UINT32 data__cfack_cfpoll;
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;
160 int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
162 #endif /* wireless extensions */
165 #define NUM_WEPKEYS 4
166 #define MAX_KEYLEN 32
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
174 extern int wlan_watchdog;
175 extern int wlan_wext_write;
177 /* WLAN device type */
178 typedef struct wlandevice
180 struct wlandevice *next; /* link for list of devices */
181 void *priv; /* private data for MSD */
183 /* Subsystem State */
184 char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
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? */
191 /* Hardware config */
195 UINT32 nsdcaps; /* NSD Capabilities flags */
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,
208 void (*tx_timeout)(struct wlandevice *wlandev);
210 #ifdef CONFIG_PROC_FS
211 int (*nsd_proc_read)(char *page, char **start, off_t offset, int count, int *eof, void *data);
215 UINT8 bssid[WLAN_BSSID_LEN];
219 int shortpreamble; /* C bool */
222 UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
223 UINT8 wep_keylens[NUM_WEPKEYS];
226 /* Request/Confirm i/f state (used by p80211) */
227 unsigned long request_pending; /* flag, access atomically */
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;
235 #ifdef CONFIG_PROC_FS
237 struct proc_dir_entry *procdir;
238 struct proc_dir_entry *procwlandev;
242 struct tasklet_struct rx_bh;
244 struct sk_buff_head nsd_rxq;
246 /* 802.11 device statistics */
247 struct p80211_frmrx_t rx;
249 /* compatibility to wireless extensions */
251 struct iw_statistics wstats;
253 /* jkriegl: iwspy fields */
255 char spy_address[IW_MAX_SPY][ETH_ALEN];
256 struct iw_quality spy_stat[IW_MAX_SPY];
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);
267 /*================================================================*/
270 /*================================================================*/
271 /* Function Declarations */
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);
284 /*================================================================*/
285 /* Function Definitions */
288 p80211netdev_stop_queue(wlandevice_t *wlandev)
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;
296 netif_stop_queue(wlandev->netdev);
301 p80211netdev_start_queue(wlandevice_t *wlandev)
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;
309 netif_start_queue(wlandev->netdev);
314 p80211netdev_wake_queue(wlandevice_t *wlandev)
316 if ( !wlandev ) return;
317 if ( !wlandev->netdev ) return;
318 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
319 wlandev->netdev->tbusy = 0;
322 netif_wake_queue(wlandev->netdev);
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);