1 /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */ 2 /* 3 * 4 * WLAN net device structure and functions 5 * 6 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. 7 * -------------------------------------------------------------------- 8 * 9 * linux-wlan 10 * 11 * -------------------------------------------------------------------- 12 * 13 * Inquiries regarding the linux-wlan Open Source project can be 14 * made directly to: 15 * 16 * AbsoluteValue Systems Inc. 17 * info@linux-wlan.com 18 * http://www.linux-wlan.com 19 * 20 * -------------------------------------------------------------------- 21 * 22 * Portions of the development of this software were funded by 23 * Intersil Corporation as part of PRISM(R) chipset product development. 24 * 25 * -------------------------------------------------------------------- 26 * 27 * This file declares the structure type that represents each wlan 28 * interface. 29 * 30 * -------------------------------------------------------------------- 31 */ 32 33 #ifndef _LINUX_P80211NETDEV_H 34 #define _LINUX_P80211NETDEV_H 35 36 #include <linux/interrupt.h> 37 #include <linux/wireless.h> 38 #include <linux/netdevice.h> 39 40 #define WLAN_RELEASE "0.3.0-staging" 41 42 #define WLAN_DEVICE_CLOSED 0 43 #define WLAN_DEVICE_OPEN 1 44 45 #define WLAN_MACMODE_NONE 0 46 #define WLAN_MACMODE_IBSS_STA 1 47 #define WLAN_MACMODE_ESS_STA 2 48 #define WLAN_MACMODE_ESS_AP 3 49 50 /* MSD States */ 51 #define WLAN_MSD_HWPRESENT_PENDING 1 52 #define WLAN_MSD_HWFAIL 2 53 #define WLAN_MSD_HWPRESENT 3 54 #define WLAN_MSD_FWLOAD_PENDING 4 55 #define WLAN_MSD_FWLOAD 5 56 #define WLAN_MSD_RUNNING_PENDING 6 57 #define WLAN_MSD_RUNNING 7 58 59 #ifndef ETH_P_ECONET 60 #define ETH_P_ECONET 0x0018 /* needed for 2.2.x kernels */ 61 #endif 62 63 #define ETH_P_80211_RAW (ETH_P_ECONET + 1) 64 65 #ifndef ARPHRD_IEEE80211 66 #define ARPHRD_IEEE80211 801 /* kernel 2.4.6 */ 67 #endif 68 69 #ifndef ARPHRD_IEEE80211_PRISM /* kernel 2.4.18 */ 70 #define ARPHRD_IEEE80211_PRISM 802 71 #endif 72 73 /*--- NSD Capabilities Flags ------------------------------*/ 74 #define P80211_NSDCAP_HARDWAREWEP 0x01 /* hardware wep engine */ 75 #define P80211_NSDCAP_SHORT_PREAMBLE 0x10 /* hardware supports */ 76 #define P80211_NSDCAP_HWFRAGMENT 0x80 /* nsd handles frag/defrag */ 77 #define P80211_NSDCAP_AUTOJOIN 0x100 /* nsd does autojoin */ 78 #define P80211_NSDCAP_NOSCAN 0x200 /* nsd can scan */ 79 80 /* Received frame statistics */ 81 struct p80211_frmrx { 82 u32 mgmt; 83 u32 assocreq; 84 u32 assocresp; 85 u32 reassocreq; 86 u32 reassocresp; 87 u32 probereq; 88 u32 proberesp; 89 u32 beacon; 90 u32 atim; 91 u32 disassoc; 92 u32 authen; 93 u32 deauthen; 94 u32 mgmt_unknown; 95 u32 ctl; 96 u32 pspoll; 97 u32 rts; 98 u32 cts; 99 u32 ack; 100 u32 cfend; 101 u32 cfendcfack; 102 u32 ctl_unknown; 103 u32 data; 104 u32 dataonly; 105 u32 data_cfack; 106 u32 data_cfpoll; 107 u32 data__cfack_cfpoll; 108 u32 null; 109 u32 cfack; 110 u32 cfpoll; 111 u32 cfack_cfpoll; 112 u32 data_unknown; 113 u32 decrypt; 114 u32 decrypt_err; 115 }; 116 117 /* called by /proc/net/wireless */ 118 struct iw_statistics *p80211wext_get_wireless_stats(struct net_device *dev); 119 120 /* WEP stuff */ 121 #define NUM_WEPKEYS 4 122 #define MAX_KEYLEN 32 123 124 #define HOSTWEP_DEFAULTKEY_MASK GENMASK(1, 0) 125 #define HOSTWEP_SHAREDKEY BIT(3) 126 #define HOSTWEP_DECRYPT BIT(4) 127 #define HOSTWEP_ENCRYPT BIT(5) 128 #define HOSTWEP_PRIVACYINVOKED BIT(6) 129 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT(7) 130 131 extern int wlan_watchdog; 132 extern int wlan_wext_write; 133 134 /* WLAN device type */ 135 struct wlandevice { 136 void *priv; /* private data for MSD */ 137 138 /* Subsystem State */ 139 char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev() */ 140 char *nsdname; 141 142 u32 state; /* Device I/F state (open/closed) */ 143 u32 msdstate; /* state of underlying driver */ 144 u32 hwremoved; /* Has the hw been yanked out? */ 145 146 /* Hardware config */ 147 unsigned int irq; 148 unsigned int iobase; 149 unsigned int membase; 150 u32 nsdcaps; /* NSD Capabilities flags */ 151 152 /* Config vars */ 153 unsigned int ethconv; 154 155 /* device methods (init by MSD, used by p80211 */ 156 int (*open)(struct wlandevice *wlandev); 157 int (*close)(struct wlandevice *wlandev); 158 void (*reset)(struct wlandevice *wlandev); 159 int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, 160 struct p80211_hdr *p80211_hdr, 161 struct p80211_metawep *p80211_wep); 162 int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg); 163 int (*set_multicast_list)(struct wlandevice *wlandev, 164 struct net_device *dev); 165 void (*tx_timeout)(struct wlandevice *wlandev); 166 167 /* 802.11 State */ 168 u8 bssid[WLAN_BSSID_LEN]; 169 struct p80211pstr32 ssid; 170 u32 macmode; 171 int linkstatus; 172 173 /* WEP State */ 174 u8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN]; 175 u8 wep_keylens[NUM_WEPKEYS]; 176 int hostwep; 177 178 /* Request/Confirm i/f state (used by p80211) */ 179 unsigned long request_pending; /* flag, access atomically */ 180 181 /* netlink socket */ 182 /* queue for indications waiting for cmd completion */ 183 /* Linux netdevice and support */ 184 struct net_device *netdev; /* ptr to linux netdevice */ 185 186 /* Rx bottom half */ 187 struct tasklet_struct rx_bh; 188 189 struct sk_buff_head nsd_rxq; 190 191 /* 802.11 device statistics */ 192 struct p80211_frmrx rx; 193 194 struct iw_statistics wstats; 195 196 /* jkriegl: iwspy fields */ 197 u8 spy_number; 198 char spy_address[IW_MAX_SPY][ETH_ALEN]; 199 struct iw_quality spy_stat[IW_MAX_SPY]; 200 }; 201 202 /* WEP stuff */ 203 int wep_change_key(struct wlandevice *wlandev, int keynum, u8 *key, int keylen); 204 int wep_decrypt(struct wlandevice *wlandev, u8 *buf, u32 len, int key_override, 205 u8 *iv, u8 *icv); 206 int wep_encrypt(struct wlandevice *wlandev, u8 *buf, u8 *dst, u32 len, 207 int keynum, u8 *iv, u8 *icv); 208 209 int wlan_setup(struct wlandevice *wlandev, struct device *physdev); 210 void wlan_unsetup(struct wlandevice *wlandev); 211 int register_wlandev(struct wlandevice *wlandev); 212 int unregister_wlandev(struct wlandevice *wlandev); 213 void p80211netdev_rx(struct wlandevice *wlandev, struct sk_buff *skb); 214 void p80211netdev_hwremoved(struct wlandevice *wlandev); 215 #endif 216