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 */ 81struct 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/* WEP stuff */ 118#define NUM_WEPKEYS 4 119#define MAX_KEYLEN 32 120 121#define HOSTWEP_DEFAULTKEY_MASK GENMASK(1, 0) 122#define HOSTWEP_SHAREDKEY BIT(3) 123#define HOSTWEP_DECRYPT BIT(4) 124#define HOSTWEP_ENCRYPT BIT(5) 125#define HOSTWEP_PRIVACYINVOKED BIT(6) 126#define HOSTWEP_EXCLUDEUNENCRYPTED BIT(7) 127 128extern int wlan_watchdog; 129extern int wlan_wext_write; 130 131/* WLAN device type */ 132struct wlandevice { 133 void *priv; /* private data for MSD */ 134 135 /* Subsystem State */ 136 char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev() */ 137 char *nsdname; 138 139 u32 state; /* Device I/F state (open/closed) */ 140 u32 msdstate; /* state of underlying driver */ 141 u32 hwremoved; /* Has the hw been yanked out? */ 142 143 /* Hardware config */ 144 unsigned int irq; 145 unsigned int iobase; 146 unsigned int membase; 147 u32 nsdcaps; /* NSD Capabilities flags */ 148 149 /* Config vars */ 150 unsigned int ethconv; 151 152 /* device methods (init by MSD, used by p80211 */ 153 int (*open)(struct wlandevice *wlandev); 154 int (*close)(struct wlandevice *wlandev); 155 void (*reset)(struct wlandevice *wlandev); 156 int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, 157 struct p80211_hdr *p80211_hdr, 158 struct p80211_metawep *p80211_wep); 159 int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg); 160 int (*set_multicast_list)(struct wlandevice *wlandev, 161 struct net_device *dev); 162 void (*tx_timeout)(struct wlandevice *wlandev); 163 164 /* 802.11 State */ 165 u8 bssid[WLAN_BSSID_LEN]; 166 struct p80211pstr32 ssid; 167 u32 macmode; 168 int linkstatus; 169 170 /* WEP State */ 171 u8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN]; 172 u8 wep_keylens[NUM_WEPKEYS]; 173 int hostwep; 174 175 /* Request/Confirm i/f state (used by p80211) */ 176 unsigned long request_pending; /* flag, access atomically */ 177 178 /* netlink socket */ 179 /* queue for indications waiting for cmd completion */ 180 /* Linux netdevice and support */ 181 struct net_device *netdev; /* ptr to linux netdevice */ 182 183 /* Rx bottom half */ 184 struct tasklet_struct rx_bh; 185 186 struct sk_buff_head nsd_rxq; 187 188 /* 802.11 device statistics */ 189 struct p80211_frmrx rx; 190 191 struct iw_statistics wstats; 192 193 /* jkriegl: iwspy fields */ 194 u8 spy_number; 195 char spy_address[IW_MAX_SPY][ETH_ALEN]; 196 struct iw_quality spy_stat[IW_MAX_SPY]; 197}; 198 199/* WEP stuff */ 200int wep_change_key(struct wlandevice *wlandev, int keynum, u8 *key, int keylen); 201int wep_decrypt(struct wlandevice *wlandev, u8 *buf, u32 len, int key_override, 202 u8 *iv, u8 *icv); 203int wep_encrypt(struct wlandevice *wlandev, u8 *buf, u8 *dst, u32 len, 204 int keynum, u8 *iv, u8 *icv); 205 206int wlan_setup(struct wlandevice *wlandev, struct device *physdev); 207void wlan_unsetup(struct wlandevice *wlandev); 208int register_wlandev(struct wlandevice *wlandev); 209int unregister_wlandev(struct wlandevice *wlandev); 210void p80211netdev_rx(struct wlandevice *wlandev, struct sk_buff *skb); 211void p80211netdev_hwremoved(struct wlandevice *wlandev); 212#endif 213