Xenomai 3.3.2
Loading...
Searching...
No Matches
rtwlan.h
1/* rtwlan.h
2 *
3 * This file is a rtnet adaption from ieee80211/ieee80211.h used by the
4 * rt2x00-2.0.0-b3 sourceforge project
5 *
6 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
7 * remains copyright by the original authors
8 *
9 * Portions of the merged code are based on Host AP (software wireless
10 * LAN access point) driver for Intersil Prism2/2.5/3.
11 *
12 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
13 * <jkmaline@cc.hut.fi>
14 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
15 *
16 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
17 * <jketreno@linux.intel.com>
18 * Copyright (c) 2004-2005, Intel Corporation
19 *
20 * Adaption to rtnet
21 * Copyright (c) 2006, Daniel Gregorek <dxg@gmx.de>
22 *
23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 2 of the License, or
26 * (at your option) any later version.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 *
37 */
38
39#ifndef RTWLAN_H
40#define RTWLAN_H
41
42#include <linux/if_ether.h> /* ETH_ALEN */
43#include <linux/kernel.h> /* ARRAY_SIZE */
44
45#include <rtskb.h>
46#include <rtwlan_io.h>
47
48#define IEEE80211_1ADDR_LEN 10
49#define IEEE80211_2ADDR_LEN 16
50#define IEEE80211_3ADDR_LEN 24
51#define IEEE80211_4ADDR_LEN 30
52#define IEEE80211_FCS_LEN 4
53#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
54#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
55
56#define MIN_FRAG_THRESHOLD 256U
57#define MAX_FRAG_THRESHOLD 2346U
58
59/* Frame control field constants */
60#define IEEE80211_FCTL_VERS 0x0003
61#define IEEE80211_FCTL_FTYPE 0x000c
62#define IEEE80211_FCTL_STYPE 0x00f0
63#define IEEE80211_FCTL_TODS 0x0100
64#define IEEE80211_FCTL_FROMDS 0x0200
65#define IEEE80211_FCTL_MOREFRAGS 0x0400
66#define IEEE80211_FCTL_RETRY 0x0800
67#define IEEE80211_FCTL_PM 0x1000
68#define IEEE80211_FCTL_MOREDATA 0x2000
69#define IEEE80211_FCTL_PROTECTED 0x4000
70#define IEEE80211_FCTL_ORDER 0x8000
71
72#define IEEE80211_FTYPE_MGMT 0x0000
73#define IEEE80211_FTYPE_CTL 0x0004
74#define IEEE80211_FTYPE_DATA 0x0008
75
76/* management */
77#define IEEE80211_STYPE_ASSOC_REQ 0x0000
78#define IEEE80211_STYPE_ASSOC_RESP 0x0010
79#define IEEE80211_STYPE_REASSOC_REQ 0x0020
80#define IEEE80211_STYPE_REASSOC_RESP 0x0030
81#define IEEE80211_STYPE_PROBE_REQ 0x0040
82#define IEEE80211_STYPE_PROBE_RESP 0x0050
83#define IEEE80211_STYPE_BEACON 0x0080
84#define IEEE80211_STYPE_ATIM 0x0090
85#define IEEE80211_STYPE_DISASSOC 0x00A0
86#define IEEE80211_STYPE_AUTH 0x00B0
87#define IEEE80211_STYPE_DEAUTH 0x00C0
88#define IEEE80211_STYPE_ACTION 0x00D0
89
90/* control */
91#define IEEE80211_STYPE_PSPOLL 0x00A0
92#define IEEE80211_STYPE_RTS 0x00B0
93#define IEEE80211_STYPE_CTS 0x00C0
94#define IEEE80211_STYPE_ACK 0x00D0
95#define IEEE80211_STYPE_CFEND 0x00E0
96#define IEEE80211_STYPE_CFENDACK 0x00F0
97
98/* data */
99#define IEEE80211_STYPE_DATA 0x0000
100#define IEEE80211_STYPE_DATA_CFACK 0x0010
101#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
102#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
103#define IEEE80211_STYPE_NULLFUNC 0x0040
104#define IEEE80211_STYPE_CFACK 0x0050
105#define IEEE80211_STYPE_CFPOLL 0x0060
106#define IEEE80211_STYPE_CFACKPOLL 0x0070
107#define IEEE80211_STYPE_QOS_DATA 0x0080
108
109#define RTWLAN_SCTL_SEQ 0xFFF0
110
111#define WLAN_FC_GET_VERS(fc) ((fc)&IEEE80211_FCTL_VERS)
112#define WLAN_FC_GET_TYPE(fc) ((fc)&IEEE80211_FCTL_FTYPE)
113#define WLAN_FC_GET_STYPE(fc) ((fc)&IEEE80211_FCTL_STYPE)
114
115#define IEEE80211_DSSS_RATE_1MB 0x02
116#define IEEE80211_DSSS_RATE_2MB 0x04
117#define IEEE80211_DSSS_RATE_5MB 0x0B
118#define IEEE80211_DSSS_RATE_11MB 0x16
119#define IEEE80211_OFDM_RATE_6MB 0x0C
120#define IEEE80211_OFDM_RATE_9MB 0x12
121#define IEEE80211_OFDM_RATE_12MB 0x18
122#define IEEE80211_OFDM_RATE_18MB 0x24
123#define IEEE80211_OFDM_RATE_24MB 0x30
124#define IEEE80211_OFDM_RATE_36MB 0x48
125#define IEEE80211_OFDM_RATE_48MB 0x60
126#define IEEE80211_OFDM_RATE_54MB 0x6C
127#define IEEE80211_BASIC_RATE_MASK 0x80
128
129#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
130#define MAC_ARG(x) \
131 ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], \
132 ((u8 *)(x))[4], ((u8 *)(x))[5]
133
134struct rtwlan_stats {
135 unsigned long rx_packets; /* total packets received */
136 unsigned long tx_packets; /* total packets transmitted */
137 unsigned long tx_retry; /* total packets transmitted with retry */
138};
139
140struct rtwlan_device {
141 struct rtwlan_stats stats;
142
143 struct rtskb_pool skb_pool;
144
145 int mode;
146
147 int (*hard_start_xmit)(struct rtskb *rtskb,
148 struct rtnet_device *rtnet_dev);
149
150 /* This must be the last item */
151 u8 priv[0];
152};
153
154/* Minimal header; can be used for passing 802.11 frames with sufficient
155 * information to determine what type of underlying data type is actually
156 * stored in the data. */
157struct ieee80211_hdr {
158 u16 frame_ctl;
159 u16 duration_id;
160 u8 payload[0];
161} __attribute__((packed));
162
163struct ieee80211_hdr_3addr {
164 u16 frame_ctl;
165 u16 duration_id;
166 u8 addr1[ETH_ALEN];
167 u8 addr2[ETH_ALEN];
168 u8 addr3[ETH_ALEN];
169 u16 seq_ctl;
170 u8 payload[0];
171} __attribute__((packed));
172
173static inline int ieee80211_get_hdrlen(u16 fc)
174{
175 int hdrlen = IEEE80211_3ADDR_LEN;
176 u16 stype = WLAN_FC_GET_STYPE(fc);
177
178 switch (WLAN_FC_GET_TYPE(fc)) {
179 case IEEE80211_FTYPE_DATA:
180 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
181 hdrlen = IEEE80211_4ADDR_LEN;
182 if (stype & IEEE80211_STYPE_QOS_DATA)
183 hdrlen += 2;
184 break;
185
186 case IEEE80211_FTYPE_CTL:
187 switch (WLAN_FC_GET_STYPE(fc)) {
188 case IEEE80211_STYPE_CTS:
189 case IEEE80211_STYPE_ACK:
190 hdrlen = IEEE80211_1ADDR_LEN;
191 break;
192
193 default:
194 hdrlen = IEEE80211_2ADDR_LEN;
195 break;
196 }
197 break;
198 }
199
200 return hdrlen;
201}
202
203static inline int ieee80211_is_ofdm_rate(u8 rate)
204{
205 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
206 case IEEE80211_OFDM_RATE_6MB:
207 case IEEE80211_OFDM_RATE_9MB:
208 case IEEE80211_OFDM_RATE_12MB:
209 case IEEE80211_OFDM_RATE_18MB:
210 case IEEE80211_OFDM_RATE_24MB:
211 case IEEE80211_OFDM_RATE_36MB:
212 case IEEE80211_OFDM_RATE_48MB:
213 case IEEE80211_OFDM_RATE_54MB:
214 return 1;
215 }
216 return 0;
217}
218
219static inline int ieee80211_is_dsss_rate(u8 rate)
220{
221 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
222 case IEEE80211_DSSS_RATE_1MB:
223 case IEEE80211_DSSS_RATE_2MB:
224 case IEEE80211_DSSS_RATE_5MB:
225 case IEEE80211_DSSS_RATE_11MB:
226 return 1;
227 }
228 return 0;
229}
230
231static inline void *rtwlan_priv(struct rtwlan_device *rtwlan_dev)
232{
233 return (void *)rtwlan_dev + sizeof(struct rtwlan_device);
234}
235
236struct rtnet_device *rtwlan_alloc_dev(unsigned sizeof_priv,
237 unsigned dev_pool_size);
238int rtwlan_rx(struct rtskb *rtskb, struct rtnet_device *rtnet_dev);
239int rtwlan_tx(struct rtskb *rtskb, struct rtnet_device *rtnet_dev);
240
241#ifdef CONFIG_XENO_DRIVERS_NET_RTWLAN
242int __init rtwlan_init(void);
243void rtwlan_exit(void);
244#else /* !CONFIG_XENO_DRIVERS_NET_RTWLAN */
245#define rtwlan_init() 0
246#define rtwlan_exit()
247#endif /* CONFIG_XENO_DRIVERS_NET_RTWLAN */
248
249#endif