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