blob: 1e6a774fc7c50d77314a64a1ab089cae212df3b5 [file] [log] [blame]
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001/* 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>
Moritz Muehlenhoff96c5abd2009-02-05 23:55:56 +010058#include <linux/netdevice.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070059
Moritz Muehlenhoff1f613792009-01-21 22:00:43 +010060#define WLAN_RELEASE "0.3.0-staging"
61
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070062#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 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070071#define WLAN_MSD_HWPRESENT_PENDING 1
72#define WLAN_MSD_HWFAIL 2
73#define WLAN_MSD_HWPRESENT 3
74#define WLAN_MSD_FWLOAD_PENDING 4
75#define WLAN_MSD_FWLOAD 5
76#define WLAN_MSD_RUNNING_PENDING 6
77#define WLAN_MSD_RUNNING 7
78
79#ifndef ETH_P_ECONET
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +010080#define ETH_P_ECONET 0x0018 /* needed for 2.2.x kernels */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070081#endif
82
83#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
84
85#ifndef ARPHRD_IEEE80211
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +010086#define ARPHRD_IEEE80211 801 /* kernel 2.4.6 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070087#endif
88
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +010089#ifndef ARPHRD_IEEE80211_PRISM /* kernel 2.4.18 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070090#define ARPHRD_IEEE80211_PRISM 802
91#endif
92
93/*--- NSD Capabilities Flags ------------------------------*/
Johan Meiring4314e5a2010-11-06 18:22:42 +020094#define P80211_NSDCAP_HARDWAREWEP 0x01 /* hardware wep engine */
95#define P80211_NSDCAP_SHORT_PREAMBLE 0x10 /* hardware supports */
96#define P80211_NSDCAP_HWFRAGMENT 0x80 /* nsd handles frag/defrag */
97#define P80211_NSDCAP_AUTOJOIN 0x100 /* nsd does autojoin */
98#define P80211_NSDCAP_NOSCAN 0x200 /* nsd can scan */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070099
100/* Received frame statistics */
Sergio Paracuellosae84ee12016-09-27 19:33:52 +0200101struct p80211_frmrx {
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100102 u32 mgmt;
103 u32 assocreq;
104 u32 assocresp;
105 u32 reassocreq;
106 u32 reassocresp;
107 u32 probereq;
108 u32 proberesp;
109 u32 beacon;
110 u32 atim;
111 u32 disassoc;
112 u32 authen;
113 u32 deauthen;
114 u32 mgmt_unknown;
115 u32 ctl;
116 u32 pspoll;
117 u32 rts;
118 u32 cts;
119 u32 ack;
120 u32 cfend;
121 u32 cfendcfack;
122 u32 ctl_unknown;
123 u32 data;
124 u32 dataonly;
125 u32 data_cfack;
126 u32 data_cfpoll;
127 u32 data__cfack_cfpoll;
128 u32 null;
129 u32 cfack;
130 u32 cfpoll;
131 u32 cfack_cfpoll;
132 u32 data_unknown;
133 u32 decrypt;
134 u32 decrypt_err;
Sergio Paracuellosae84ee12016-09-27 19:33:52 +0200135};
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700136
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700137/* called by /proc/net/wireless */
Sergio Paracuellos19066982016-09-27 19:33:51 +0200138struct iw_statistics *p80211wext_get_wireless_stats(struct net_device *dev);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700139/* wireless extensions' ioctls */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700140extern struct iw_handler_def p80211wext_handler_def;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700141
142/* WEP stuff */
143#define NUM_WEPKEYS 4
144#define MAX_KEYLEN 32
145
Moritz Muehlenhoff7f6e0e42009-01-25 21:54:55 +0100146#define HOSTWEP_DEFAULTKEY_MASK (BIT(1)|BIT(0))
Karl Reltoncb3126e2010-06-03 23:04:06 +0100147#define HOSTWEP_SHAREDKEY BIT(3)
Moritz Muehlenhoff7f6e0e42009-01-25 21:54:55 +0100148#define HOSTWEP_DECRYPT BIT(4)
149#define HOSTWEP_ENCRYPT BIT(5)
150#define HOSTWEP_PRIVACYINVOKED BIT(6)
151#define HOSTWEP_EXCLUDEUNENCRYPTED BIT(7)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700152
153extern int wlan_watchdog;
154extern int wlan_wext_write;
155
156/* WLAN device type */
sayli karnikc9573a82016-09-18 15:11:14 +0530157struct wlandevice {
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100158 void *priv; /* private data for MSD */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700159
160 /* Subsystem State */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100161 char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev() */
162 char *nsdname;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700163
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100164 u32 state; /* Device I/F state (open/closed) */
165 u32 msdstate; /* state of underlying driver */
166 u32 hwremoved; /* Has the hw been yanked out? */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700167
168 /* Hardware config */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100169 unsigned int irq;
170 unsigned int iobase;
171 unsigned int membase;
172 u32 nsdcaps; /* NSD Capabilities flags */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700173
174 /* Config vars */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100175 unsigned int ethconv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700176
177 /* device methods (init by MSD, used by p80211 */
Aybuke Ozdemir43bb32a2014-09-25 01:11:45 +0300178 int (*open)(struct wlandevice *wlandev);
179 int (*close)(struct wlandevice *wlandev);
180 void (*reset)(struct wlandevice *wlandev);
181 int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb,
Edgardo Hames93df38e2010-07-30 22:51:55 -0300182 union p80211_hdr *p80211_hdr,
Edgardo Hames51e48962010-07-31 13:06:52 -0300183 struct p80211_metawep *p80211_wep);
Aybuke Ozdemir43bb32a2014-09-25 01:11:45 +0300184 int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg);
185 int (*set_multicast_list)(struct wlandevice *wlandev,
Sergio Paracuellos19066982016-09-27 19:33:51 +0200186 struct net_device *dev);
Aybuke Ozdemir43bb32a2014-09-25 01:11:45 +0300187 void (*tx_timeout)(struct wlandevice *wlandev);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700188
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700189 /* 802.11 State */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100190 u8 bssid[WLAN_BSSID_LEN];
Sergio Paracuellos758f140d2016-09-25 15:34:56 +0200191 struct p80211pstr32 ssid;
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100192 u32 macmode;
193 int linkstatus;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700194
195 /* WEP State */
Solomon Peachyaaad4302008-10-29 10:42:53 -0400196 u8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
197 u8 wep_keylens[NUM_WEPKEYS];
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100198 int hostwep;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700199
200 /* Request/Confirm i/f state (used by p80211) */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100201 unsigned long request_pending; /* flag, access atomically */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700202
203 /* netlink socket */
204 /* queue for indications waiting for cmd completion */
205 /* Linux netdevice and support */
Sergio Paracuellos19066982016-09-27 19:33:51 +0200206 struct net_device *netdev; /* ptr to linux netdevice */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700207
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700208 /* Rx bottom half */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100209 struct tasklet_struct rx_bh;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700210
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100211 struct sk_buff_head nsd_rxq;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700212
213 /* 802.11 device statistics */
Sergio Paracuellosae84ee12016-09-27 19:33:52 +0200214 struct p80211_frmrx rx;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700215
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100216 struct iw_statistics wstats;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700217
218 /* jkriegl: iwspy fields */
Moritz Muehlenhoffa32fb5f2009-02-08 02:20:59 +0100219 u8 spy_number;
220 char spy_address[IW_MAX_SPY][ETH_ALEN];
221 struct iw_quality spy_stat[IW_MAX_SPY];
sayli karnikc9573a82016-09-18 15:11:14 +0530222};
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700223
224/* WEP stuff */
sayli karnikc9573a82016-09-18 15:11:14 +0530225int wep_change_key(struct wlandevice *wlandev, int keynum, u8 *key, int keylen);
226int wep_decrypt(struct wlandevice *wlandev, u8 *buf, u32 len, int key_override,
Svenne Krap5dd8acc2010-02-14 18:59:00 +0100227 u8 *iv, u8 *icv);
Sergio Paracuellosa0cc6bf2016-09-27 19:33:53 +0200228int wep_encrypt(struct wlandevice *wlandev, u8 *buf, u8 *dst, u32 len,
229 int keynum, u8 *iv, u8 *icv);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700230
sayli karnikc9573a82016-09-18 15:11:14 +0530231int wlan_setup(struct wlandevice *wlandev, struct device *physdev);
232void wlan_unsetup(struct wlandevice *wlandev);
233int register_wlandev(struct wlandevice *wlandev);
234int unregister_wlandev(struct wlandevice *wlandev);
235void p80211netdev_rx(struct wlandevice *wlandev, struct sk_buff *skb);
236void p80211netdev_hwremoved(struct wlandevice *wlandev);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700237#endif