ieee80211_superg.c revision 191753
1190391Ssam/*-
2190391Ssam * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3190391Ssam * All rights reserved.
4190391Ssam *
5190391Ssam * Redistribution and use in source and binary forms, with or without
6190391Ssam * modification, are permitted provided that the following conditions
7190391Ssam * are met:
8190391Ssam * 1. Redistributions of source code must retain the above copyright
9190391Ssam *    notice, this list of conditions and the following disclaimer.
10190391Ssam * 2. Redistributions in binary form must reproduce the above copyright
11190391Ssam *    notice, this list of conditions and the following disclaimer in the
12190391Ssam *    documentation and/or other materials provided with the distribution.
13190391Ssam *
14190391Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15190391Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16190391Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17190391Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18190391Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19190391Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20190391Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21190391Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22190391Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23190391Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24190391Ssam */
25190391Ssam
26190391Ssam#include <sys/cdefs.h>
27190391Ssam__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_superg.c 191753 2009-05-02 20:16:55Z sam $");
28190391Ssam
29190391Ssam#include "opt_wlan.h"
30190391Ssam
31190391Ssam#include <sys/param.h>
32190391Ssam#include <sys/systm.h>
33190391Ssam#include <sys/mbuf.h>
34190391Ssam#include <sys/kernel.h>
35190391Ssam#include <sys/endian.h>
36190391Ssam
37190391Ssam#include <sys/socket.h>
38190391Ssam
39190391Ssam#include <net/bpf.h>
40190391Ssam#include <net/ethernet.h>
41190391Ssam#include <net/if.h>
42190391Ssam#include <net/if_llc.h>
43190391Ssam#include <net/if_media.h>
44190391Ssam
45190391Ssam#include <net80211/ieee80211_var.h>
46190391Ssam#include <net80211/ieee80211_input.h>
47190391Ssam#include <net80211/ieee80211_phy.h>
48190391Ssam#include <net80211/ieee80211_superg.h>
49190391Ssam
50190455Ssam/*
51190455Ssam * Atheros fast-frame encapsulation format.
52190455Ssam * FF max payload:
53190455Ssam * 802.2 + FFHDR + HPAD + 802.3 + 802.2 + 1500 + SPAD + 802.3 + 802.2 + 1500:
54190455Ssam *   8   +   4   +  4   +   14  +   8   + 1500 +  6   +   14  +   8   + 1500
55190455Ssam * = 3066
56190455Ssam */
57190455Ssam/* fast frame header is 32-bits */
58190455Ssam#define	ATH_FF_PROTO	0x0000003f	/* protocol */
59190455Ssam#define	ATH_FF_PROTO_S	0
60190455Ssam#define	ATH_FF_FTYPE	0x000000c0	/* frame type */
61190455Ssam#define	ATH_FF_FTYPE_S	6
62190455Ssam#define	ATH_FF_HLEN32	0x00000300	/* optional hdr length */
63190455Ssam#define	ATH_FF_HLEN32_S	8
64190455Ssam#define	ATH_FF_SEQNUM	0x001ffc00	/* sequence number */
65190455Ssam#define	ATH_FF_SEQNUM_S	10
66190455Ssam#define	ATH_FF_OFFSET	0xffe00000	/* offset to 2nd payload */
67190455Ssam#define	ATH_FF_OFFSET_S	21
68190455Ssam
69190455Ssam#define	ATH_FF_MAX_HDR_PAD	4
70190455Ssam#define	ATH_FF_MAX_SEP_PAD	6
71190455Ssam#define	ATH_FF_MAX_HDR		30
72190455Ssam
73190455Ssam#define	ATH_FF_PROTO_L2TUNNEL	0	/* L2 tunnel protocol */
74190455Ssam#define	ATH_FF_ETH_TYPE		0x88bd	/* Ether type for encapsulated frames */
75190455Ssam#define	ATH_FF_SNAP_ORGCODE_0	0x00
76190455Ssam#define	ATH_FF_SNAP_ORGCODE_1	0x03
77190455Ssam#define	ATH_FF_SNAP_ORGCODE_2	0x7f
78190455Ssam
79190579Ssam#define	ATH_FF_TXQMIN	2		/* min txq depth for staging */
80190579Ssam#define	ATH_FF_TXQMAX	50		/* maximum # of queued frames allowed */
81190579Ssam#define	ATH_FF_STAGEMAX	5		/* max waiting period for staged frame*/
82190579Ssam
83190391Ssam#define	ETHER_HEADER_COPY(dst, src) \
84190391Ssam	memcpy(dst, src, sizeof(struct ether_header))
85190391Ssam
86190579Ssam/* XXX public for sysctl hookup */
87190579Ssamint	ieee80211_ffppsmin = 2;		/* pps threshold for ff aggregation */
88190579Ssamint	ieee80211_ffagemax = -1;	/* max time frames held on stage q */
89190579Ssam
90190391Ssamvoid
91190391Ssamieee80211_superg_attach(struct ieee80211com *ic)
92190391Ssam{
93191753Ssam	struct ieee80211_superg *sg;
94191753Ssam
95191753Ssam	if (ic->ic_caps & IEEE80211_C_FF) {
96191753Ssam		sg = (struct ieee80211_superg *) malloc(
97191753Ssam		     sizeof(struct ieee80211_superg), M_80211_VAP,
98191753Ssam		     M_NOWAIT | M_ZERO);
99191753Ssam		if (sg == NULL) {
100191753Ssam			printf("%s: cannot allocate SuperG state block\n",
101191753Ssam			    __func__);
102191753Ssam			return;
103191753Ssam		}
104191753Ssam		ic->ic_superg = sg;
105191753Ssam	}
106190579Ssam	ieee80211_ffagemax = msecs_to_ticks(150);
107190391Ssam}
108190391Ssam
109190391Ssamvoid
110190391Ssamieee80211_superg_detach(struct ieee80211com *ic)
111190391Ssam{
112191753Ssam	if (ic->ic_superg != NULL) {
113191753Ssam		free(ic->ic_superg, M_80211_VAP);
114191753Ssam		ic->ic_superg = NULL;
115191753Ssam	}
116190391Ssam}
117190391Ssam
118190391Ssamvoid
119190391Ssamieee80211_superg_vattach(struct ieee80211vap *vap)
120190391Ssam{
121191753Ssam	struct ieee80211com *ic = vap->iv_ic;
122191753Ssam
123191753Ssam	if (ic->ic_superg == NULL)	/* NB: can't do fast-frames w/o state */
124191753Ssam		vap->iv_caps &= ~IEEE80211_C_FF;
125190391Ssam	if (vap->iv_caps & IEEE80211_C_FF)
126190391Ssam		vap->iv_flags |= IEEE80211_F_FF;
127190450Ssam	/* NB: we only implement sta mode */
128190450Ssam	if (vap->iv_opmode == IEEE80211_M_STA &&
129190450Ssam	    (vap->iv_caps & IEEE80211_C_TURBOP))
130190391Ssam		vap->iv_flags |= IEEE80211_F_TURBOP;
131190391Ssam}
132190391Ssam
133190391Ssamvoid
134190391Ssamieee80211_superg_vdetach(struct ieee80211vap *vap)
135190391Ssam{
136190391Ssam}
137190391Ssam
138190391Ssam#define	ATH_OUI_BYTES		0x00, 0x03, 0x7f
139190391Ssam/*
140190391Ssam * Add a WME information element to a frame.
141190391Ssam */
142190391Ssamuint8_t *
143190451Ssamieee80211_add_ath(uint8_t *frm, uint8_t caps, ieee80211_keyix defkeyix)
144190391Ssam{
145190391Ssam	static const struct ieee80211_ath_ie info = {
146190391Ssam		.ath_id		= IEEE80211_ELEMID_VENDOR,
147190391Ssam		.ath_len	= sizeof(struct ieee80211_ath_ie) - 2,
148190391Ssam		.ath_oui	= { ATH_OUI_BYTES },
149190391Ssam		.ath_oui_type	= ATH_OUI_TYPE,
150190391Ssam		.ath_oui_subtype= ATH_OUI_SUBTYPE,
151190391Ssam		.ath_version	= ATH_OUI_VERSION,
152190391Ssam	};
153190391Ssam	struct ieee80211_ath_ie *ath = (struct ieee80211_ath_ie *) frm;
154190391Ssam
155190391Ssam	memcpy(frm, &info, sizeof(info));
156190391Ssam	ath->ath_capability = caps;
157190451Ssam	if (defkeyix != IEEE80211_KEYIX_NONE) {
158190451Ssam		ath->ath_defkeyix[0] = (defkeyix & 0xff);
159190451Ssam		ath->ath_defkeyix[1] = ((defkeyix >> 8) & 0xff);
160190451Ssam	} else {
161190451Ssam		ath->ath_defkeyix[0] = 0xff;
162190451Ssam		ath->ath_defkeyix[1] = 0x7f;
163190451Ssam	}
164190391Ssam	return frm + sizeof(info);
165190391Ssam}
166190391Ssam#undef ATH_OUI_BYTES
167190391Ssam
168190451Ssamuint8_t *
169190451Ssamieee80211_add_athcaps(uint8_t *frm, const struct ieee80211_node *bss)
170190451Ssam{
171190451Ssam	const struct ieee80211vap *vap = bss->ni_vap;
172190451Ssam
173190451Ssam	return ieee80211_add_ath(frm,
174190451Ssam	    vap->iv_flags & IEEE80211_F_ATHEROS,
175190451Ssam	    ((vap->iv_flags & IEEE80211_F_WPA) == 0 &&
176190451Ssam	    bss->ni_authmode != IEEE80211_AUTH_8021X) ?
177190451Ssam	    vap->iv_def_txkey : IEEE80211_KEYIX_NONE);
178190451Ssam}
179190451Ssam
180190391Ssamvoid
181190391Ssamieee80211_parse_ath(struct ieee80211_node *ni, uint8_t *ie)
182190391Ssam{
183190391Ssam	const struct ieee80211_ath_ie *ath =
184190391Ssam		(const struct ieee80211_ath_ie *) ie;
185190391Ssam
186190391Ssam	ni->ni_ath_flags = ath->ath_capability;
187190391Ssam	ni->ni_ath_defkeyix = LE_READ_2(&ath->ath_defkeyix);
188190391Ssam}
189190391Ssam
190190391Ssamint
191190391Ssamieee80211_parse_athparams(struct ieee80211_node *ni, uint8_t *frm,
192190391Ssam	const struct ieee80211_frame *wh)
193190391Ssam{
194190391Ssam	struct ieee80211vap *vap = ni->ni_vap;
195190391Ssam	const struct ieee80211_ath_ie *ath;
196190391Ssam	u_int len = frm[1];
197190391Ssam	int capschanged;
198190391Ssam	uint16_t defkeyix;
199190391Ssam
200190391Ssam	if (len < sizeof(struct ieee80211_ath_ie)-2) {
201190391Ssam		IEEE80211_DISCARD_IE(vap,
202190391Ssam		    IEEE80211_MSG_ELEMID | IEEE80211_MSG_SUPERG,
203190391Ssam		    wh, "Atheros", "too short, len %u", len);
204190391Ssam		return -1;
205190391Ssam	}
206190391Ssam	ath = (const struct ieee80211_ath_ie *)frm;
207190391Ssam	capschanged = (ni->ni_ath_flags != ath->ath_capability);
208190391Ssam	defkeyix = LE_READ_2(ath->ath_defkeyix);
209190391Ssam	if (capschanged || defkeyix != ni->ni_ath_defkeyix) {
210190391Ssam		ni->ni_ath_flags = ath->ath_capability;
211190391Ssam		ni->ni_ath_defkeyix = defkeyix;
212190391Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
213190391Ssam		    "ath ie change: new caps 0x%x defkeyix 0x%x",
214190391Ssam		    ni->ni_ath_flags, ni->ni_ath_defkeyix);
215190391Ssam	}
216190391Ssam	if (IEEE80211_ATH_CAP(vap, ni, ATHEROS_CAP_TURBO_PRIME)) {
217190391Ssam		uint16_t curflags, newflags;
218190391Ssam
219190391Ssam		/*
220190391Ssam		 * Check for turbo mode switch.  Calculate flags
221190391Ssam		 * for the new mode and effect the switch.
222190391Ssam		 */
223190391Ssam		newflags = curflags = vap->iv_ic->ic_bsschan->ic_flags;
224190391Ssam		/* NB: BOOST is not in ic_flags, so get it from the ie */
225190391Ssam		if (ath->ath_capability & ATHEROS_CAP_BOOST)
226190391Ssam			newflags |= IEEE80211_CHAN_TURBO;
227190391Ssam		else
228190391Ssam			newflags &= ~IEEE80211_CHAN_TURBO;
229190391Ssam		if (newflags != curflags)
230190391Ssam			ieee80211_dturbo_switch(vap, newflags);
231190391Ssam	}
232190391Ssam	return capschanged;
233190391Ssam}
234190391Ssam
235190391Ssam/*
236190391Ssam * Decap the encapsulated frame pair and dispatch the first
237190391Ssam * for delivery.  The second frame is returned for delivery
238190391Ssam * via the normal path.
239190391Ssam */
240190391Ssamstruct mbuf *
241190391Ssamieee80211_ff_decap(struct ieee80211_node *ni, struct mbuf *m)
242190391Ssam{
243190391Ssam#define	FF_LLC_SIZE	(sizeof(struct ether_header) + sizeof(struct llc))
244190391Ssam#define	MS(x,f)	(((x) & f) >> f##_S)
245190391Ssam	struct ieee80211vap *vap = ni->ni_vap;
246190391Ssam	struct llc *llc;
247190391Ssam	uint32_t ath;
248190391Ssam	struct mbuf *n;
249190391Ssam	int framelen;
250190391Ssam
251190391Ssam	/* NB: we assume caller does this check for us */
252190391Ssam	KASSERT(IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF),
253190391Ssam	    ("ff not negotiated"));
254190391Ssam	/*
255190391Ssam	 * Check for fast-frame tunnel encapsulation.
256190391Ssam	 */
257190391Ssam	if (m->m_pkthdr.len < 3*FF_LLC_SIZE)
258190391Ssam		return m;
259190391Ssam	if (m->m_len < FF_LLC_SIZE &&
260190391Ssam	    (m = m_pullup(m, FF_LLC_SIZE)) == NULL) {
261190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
262190391Ssam		    ni->ni_macaddr, "fast-frame",
263190391Ssam		    "%s", "m_pullup(llc) failed");
264190391Ssam		vap->iv_stats.is_rx_tooshort++;
265190391Ssam		return NULL;
266190391Ssam	}
267190391Ssam	llc = (struct llc *)(mtod(m, uint8_t *) +
268190391Ssam	    sizeof(struct ether_header));
269190391Ssam	if (llc->llc_snap.ether_type != htons(ATH_FF_ETH_TYPE))
270190391Ssam		return m;
271190391Ssam	m_adj(m, FF_LLC_SIZE);
272190391Ssam	m_copydata(m, 0, sizeof(uint32_t), (caddr_t) &ath);
273190391Ssam	if (MS(ath, ATH_FF_PROTO) != ATH_FF_PROTO_L2TUNNEL) {
274190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
275190391Ssam		    ni->ni_macaddr, "fast-frame",
276190391Ssam		    "unsupport tunnel protocol, header 0x%x", ath);
277190391Ssam		vap->iv_stats.is_ff_badhdr++;
278190391Ssam		m_freem(m);
279190391Ssam		return NULL;
280190391Ssam	}
281190391Ssam	/* NB: skip header and alignment padding */
282190391Ssam	m_adj(m, roundup(sizeof(uint32_t) - 2, 4) + 2);
283190391Ssam
284190391Ssam	vap->iv_stats.is_ff_decap++;
285190391Ssam
286190391Ssam	/*
287190391Ssam	 * Decap the first frame, bust it apart from the
288190391Ssam	 * second and deliver; then decap the second frame
289190391Ssam	 * and return it to the caller for normal delivery.
290190391Ssam	 */
291190391Ssam	m = ieee80211_decap1(m, &framelen);
292190391Ssam	if (m == NULL) {
293190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
294190391Ssam		    ni->ni_macaddr, "fast-frame", "%s", "first decap failed");
295190391Ssam		vap->iv_stats.is_ff_tooshort++;
296190391Ssam		return NULL;
297190391Ssam	}
298190391Ssam	n = m_split(m, framelen, M_NOWAIT);
299190391Ssam	if (n == NULL) {
300190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
301190391Ssam		    ni->ni_macaddr, "fast-frame",
302190391Ssam		    "%s", "unable to split encapsulated frames");
303190391Ssam		vap->iv_stats.is_ff_split++;
304190391Ssam		m_freem(m);			/* NB: must reclaim */
305190391Ssam		return NULL;
306190391Ssam	}
307190391Ssam	/* XXX not right for WDS */
308190391Ssam	vap->iv_deliver_data(vap, ni, m);	/* 1st of pair */
309190391Ssam
310190391Ssam	/*
311190391Ssam	 * Decap second frame.
312190391Ssam	 */
313190391Ssam	m_adj(n, roundup2(framelen, 4) - framelen);	/* padding */
314190391Ssam	n = ieee80211_decap1(n, &framelen);
315190391Ssam	if (n == NULL) {
316190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
317190391Ssam		    ni->ni_macaddr, "fast-frame", "%s", "second decap failed");
318190391Ssam		vap->iv_stats.is_ff_tooshort++;
319190391Ssam	}
320190391Ssam	/* XXX verify framelen against mbuf contents */
321190391Ssam	return n;				/* 2nd delivered by caller */
322190391Ssam#undef MS
323190391Ssam#undef FF_LLC_SIZE
324190391Ssam}
325190391Ssam
326190391Ssam/*
327190391Ssam * Do Ethernet-LLC encapsulation for each payload in a fast frame
328190391Ssam * tunnel encapsulation.  The frame is assumed to have an Ethernet
329190391Ssam * header at the front that must be stripped before prepending the
330190391Ssam * LLC followed by the Ethernet header passed in (with an Ethernet
331190391Ssam * type that specifies the payload size).
332190391Ssam */
333190391Ssamstatic struct mbuf *
334190391Ssamff_encap1(struct ieee80211vap *vap, struct mbuf *m,
335190391Ssam	const struct ether_header *eh)
336190391Ssam{
337190391Ssam	struct llc *llc;
338190391Ssam	uint16_t payload;
339190391Ssam
340190391Ssam	/* XXX optimize by combining m_adj+M_PREPEND */
341190391Ssam	m_adj(m, sizeof(struct ether_header) - sizeof(struct llc));
342190391Ssam	llc = mtod(m, struct llc *);
343190391Ssam	llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP;
344190391Ssam	llc->llc_control = LLC_UI;
345190391Ssam	llc->llc_snap.org_code[0] = 0;
346190391Ssam	llc->llc_snap.org_code[1] = 0;
347190391Ssam	llc->llc_snap.org_code[2] = 0;
348190391Ssam	llc->llc_snap.ether_type = eh->ether_type;
349190391Ssam	payload = m->m_pkthdr.len;		/* NB: w/o Ethernet header */
350190391Ssam
351190391Ssam	M_PREPEND(m, sizeof(struct ether_header), M_DONTWAIT);
352190391Ssam	if (m == NULL) {		/* XXX cannot happen */
353190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
354190391Ssam			"%s: no space for ether_header\n", __func__);
355190391Ssam		vap->iv_stats.is_tx_nobuf++;
356190391Ssam		return NULL;
357190391Ssam	}
358190391Ssam	ETHER_HEADER_COPY(mtod(m, void *), eh);
359190391Ssam	mtod(m, struct ether_header *)->ether_type = htons(payload);
360190391Ssam	return m;
361190391Ssam}
362190391Ssam
363190391Ssam/*
364190391Ssam * Fast frame encapsulation.  There must be two packets
365190391Ssam * chained with m_nextpkt.  We do header adjustment for
366190391Ssam * each, add the tunnel encapsulation, and then concatenate
367190391Ssam * the mbuf chains to form a single frame for transmission.
368190391Ssam */
369190391Ssamstruct mbuf *
370190391Ssamieee80211_ff_encap(struct ieee80211vap *vap, struct mbuf *m1, int hdrspace,
371190391Ssam	struct ieee80211_key *key)
372190391Ssam{
373190391Ssam	struct mbuf *m2;
374190391Ssam	struct ether_header eh1, eh2;
375190391Ssam	struct llc *llc;
376190391Ssam	struct mbuf *m;
377190391Ssam	int pad;
378190391Ssam
379190391Ssam	m2 = m1->m_nextpkt;
380190391Ssam	if (m2 == NULL) {
381190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
382190391Ssam		    "%s: only one frame\n", __func__);
383190391Ssam		goto bad;
384190391Ssam	}
385190391Ssam	m1->m_nextpkt = NULL;
386190391Ssam	/*
387190579Ssam	 * Include fast frame headers in adjusting header layout.
388190391Ssam	 */
389190579Ssam	KASSERT(m1->m_len >= sizeof(eh1), ("no ethernet header!"));
390190579Ssam	ETHER_HEADER_COPY(&eh1, mtod(m1, caddr_t));
391190391Ssam	m1 = ieee80211_mbuf_adjust(vap,
392190391Ssam		hdrspace + sizeof(struct llc) + sizeof(uint32_t) + 2 +
393190391Ssam		    sizeof(struct ether_header),
394190391Ssam		key, m1);
395190391Ssam	if (m1 == NULL) {
396190391Ssam		/* NB: ieee80211_mbuf_adjust handles msgs+statistics */
397190391Ssam		m_freem(m2);
398190391Ssam		goto bad;
399190391Ssam	}
400190391Ssam
401190391Ssam	/*
402190391Ssam	 * Copy second frame's Ethernet header out of line
403190391Ssam	 * and adjust for encapsulation headers.  Note that
404190391Ssam	 * we make room for padding in case there isn't room
405190391Ssam	 * at the end of first frame.
406190391Ssam	 */
407190391Ssam	KASSERT(m2->m_len >= sizeof(eh2), ("no ethernet header!"));
408190391Ssam	ETHER_HEADER_COPY(&eh2, mtod(m2, caddr_t));
409190391Ssam	m2 = ieee80211_mbuf_adjust(vap,
410190391Ssam		ATH_FF_MAX_HDR_PAD + sizeof(struct ether_header),
411190391Ssam		NULL, m2);
412190391Ssam	if (m2 == NULL) {
413190391Ssam		/* NB: ieee80211_mbuf_adjust handles msgs+statistics */
414190391Ssam		goto bad;
415190391Ssam	}
416190391Ssam
417190391Ssam	/*
418190391Ssam	 * Now do tunnel encapsulation.  First, each
419190391Ssam	 * frame gets a standard encapsulation.
420190391Ssam	 */
421190391Ssam	m1 = ff_encap1(vap, m1, &eh1);
422190391Ssam	if (m1 == NULL)
423190391Ssam		goto bad;
424190391Ssam	m2 = ff_encap1(vap, m2, &eh2);
425190391Ssam	if (m2 == NULL)
426190391Ssam		goto bad;
427190391Ssam
428190391Ssam	/*
429190391Ssam	 * Pad leading frame to a 4-byte boundary.  If there
430190391Ssam	 * is space at the end of the first frame, put it
431190391Ssam	 * there; otherwise prepend to the front of the second
432190391Ssam	 * frame.  We know doing the second will always work
433190391Ssam	 * because we reserve space above.  We prefer appending
434190391Ssam	 * as this typically has better DMA alignment properties.
435190391Ssam	 */
436190391Ssam	for (m = m1; m->m_next != NULL; m = m->m_next)
437190391Ssam		;
438190391Ssam	pad = roundup2(m1->m_pkthdr.len, 4) - m1->m_pkthdr.len;
439190391Ssam	if (pad) {
440190391Ssam		if (M_TRAILINGSPACE(m) < pad) {		/* prepend to second */
441190391Ssam			m2->m_data -= pad;
442190391Ssam			m2->m_len += pad;
443190391Ssam			m2->m_pkthdr.len += pad;
444190391Ssam		} else {				/* append to first */
445190391Ssam			m->m_len += pad;
446190391Ssam			m1->m_pkthdr.len += pad;
447190391Ssam		}
448190391Ssam	}
449190391Ssam
450190391Ssam	/*
451190391Ssam	 * Now, stick 'em together and prepend the tunnel headers;
452190391Ssam	 * first the Atheros tunnel header (all zero for now) and
453190391Ssam	 * then a special fast frame LLC.
454190391Ssam	 *
455190391Ssam	 * XXX optimize by prepending together
456190391Ssam	 */
457190391Ssam	m->m_next = m2;			/* NB: last mbuf from above */
458190391Ssam	m1->m_pkthdr.len += m2->m_pkthdr.len;
459190391Ssam	M_PREPEND(m1, sizeof(uint32_t)+2, M_DONTWAIT);
460190391Ssam	if (m1 == NULL) {		/* XXX cannot happen */
461190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
462190391Ssam		    "%s: no space for tunnel header\n", __func__);
463190391Ssam		vap->iv_stats.is_tx_nobuf++;
464190391Ssam		return NULL;
465190391Ssam	}
466190391Ssam	memset(mtod(m1, void *), 0, sizeof(uint32_t)+2);
467190391Ssam
468190391Ssam	M_PREPEND(m1, sizeof(struct llc), M_DONTWAIT);
469190391Ssam	if (m1 == NULL) {		/* XXX cannot happen */
470190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
471190391Ssam		    "%s: no space for llc header\n", __func__);
472190391Ssam		vap->iv_stats.is_tx_nobuf++;
473190391Ssam		return NULL;
474190391Ssam	}
475190391Ssam	llc = mtod(m1, struct llc *);
476190391Ssam	llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP;
477190391Ssam	llc->llc_control = LLC_UI;
478190391Ssam	llc->llc_snap.org_code[0] = ATH_FF_SNAP_ORGCODE_0;
479190391Ssam	llc->llc_snap.org_code[1] = ATH_FF_SNAP_ORGCODE_1;
480190391Ssam	llc->llc_snap.org_code[2] = ATH_FF_SNAP_ORGCODE_2;
481190391Ssam	llc->llc_snap.ether_type = htons(ATH_FF_ETH_TYPE);
482190391Ssam
483190391Ssam	vap->iv_stats.is_ff_encap++;
484190391Ssam
485190391Ssam	return m1;
486190391Ssambad:
487190391Ssam	if (m1 != NULL)
488190391Ssam		m_freem(m1);
489190391Ssam	if (m2 != NULL)
490190391Ssam		m_freem(m2);
491190391Ssam	return NULL;
492190391Ssam}
493190391Ssam
494190579Ssamstatic void
495190579Ssamff_transmit(struct ieee80211_node *ni, struct mbuf *m)
496190579Ssam{
497190579Ssam	struct ieee80211vap *vap = ni->ni_vap;
498190579Ssam	int error;
499190579Ssam
500190579Ssam	/* encap and xmit */
501190579Ssam	m = ieee80211_encap(vap, ni, m);
502190579Ssam	if (m != NULL) {
503190579Ssam		struct ifnet *ifp = vap->iv_ifp;
504190579Ssam		struct ifnet *parent = ni->ni_ic->ic_ifp;
505190579Ssam
506191541Ssam		if (bpf_peers_present(vap->iv_rawbpf))
507191541Ssam			bpf_mtap(vap->iv_rawbpf, m);
508191541Ssam
509190579Ssam		error = parent->if_transmit(parent, m);
510190579Ssam		if (error != 0) {
511190579Ssam			/* NB: IFQ_HANDOFF reclaims mbuf */
512190579Ssam			ieee80211_free_node(ni);
513190579Ssam		} else {
514190579Ssam			ifp->if_opackets++;
515190579Ssam		}
516190579Ssam	} else
517190579Ssam		ieee80211_free_node(ni);
518190579Ssam}
519190579Ssam
520190391Ssam/*
521190579Ssam * Flush frames to device; note we re-use the linked list
522190579Ssam * the frames were stored on and use the sentinel (unchanged)
523190579Ssam * which may be non-NULL.
524190579Ssam */
525190579Ssamstatic void
526190579Ssamff_flush(struct mbuf *head, struct mbuf *last)
527190579Ssam{
528190579Ssam	struct mbuf *m, *next;
529190579Ssam	struct ieee80211_node *ni;
530190579Ssam	struct ieee80211vap *vap;
531190579Ssam
532190579Ssam	for (m = head; m != last; m = next) {
533190579Ssam		next = m->m_nextpkt;
534190579Ssam		m->m_nextpkt = NULL;
535190579Ssam
536190579Ssam		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
537190579Ssam		vap = ni->ni_vap;
538190579Ssam
539190579Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
540190579Ssam		    "%s: flush frame, age %u", __func__, M_AGE_GET(m));
541190579Ssam		vap->iv_stats.is_ff_flush++;
542190579Ssam
543190579Ssam		ff_transmit(ni, m);
544190579Ssam	}
545190579Ssam}
546190579Ssam
547190579Ssam/*
548190579Ssam * Age frames on the staging queue.
549190579Ssam */
550190579Ssamvoid
551191753Ssamieee80211_ff_age(struct ieee80211com *ic, struct ieee80211_stageq *sq,
552191753Ssam    int quanta)
553190579Ssam{
554191753Ssam	struct ieee80211_superg *sg = ic->ic_superg;
555190579Ssam	struct mbuf *m, *head;
556190579Ssam	struct ieee80211_node *ni;
557190579Ssam	struct ieee80211_tx_ampdu *tap;
558190579Ssam
559190579Ssam	KASSERT(sq->head != NULL, ("stageq empty"));
560190579Ssam
561190579Ssam	IEEE80211_LOCK(ic);
562190579Ssam	head = sq->head;
563190579Ssam	while ((m = sq->head) != NULL && M_AGE_GET(m) < quanta) {
564190579Ssam		/* clear tap ref to frame */
565190579Ssam		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
566190579Ssam		tap = &ni->ni_tx_ampdu[M_WME_GETAC(m)];
567190579Ssam		KASSERT(tap->txa_private == m, ("staging queue empty"));
568190579Ssam		tap->txa_private = NULL;
569190579Ssam
570190579Ssam		sq->head = m->m_nextpkt;
571190579Ssam		sq->depth--;
572191753Ssam		sg->ff_stageqdepth--;
573190579Ssam	}
574190579Ssam	if (m == NULL)
575190579Ssam		sq->tail = NULL;
576190579Ssam	else
577190579Ssam		M_AGE_SUB(m, quanta);
578190579Ssam	IEEE80211_UNLOCK(ic);
579190579Ssam
580190579Ssam	ff_flush(head, m);
581190579Ssam}
582190579Ssam
583190579Ssamstatic void
584190579Ssamstageq_add(struct ieee80211_stageq *sq, struct mbuf *m)
585190579Ssam{
586190579Ssam	int age = ieee80211_ffagemax;
587190579Ssam	if (sq->tail != NULL) {
588190579Ssam		sq->tail->m_nextpkt = m;
589190579Ssam		age -= M_AGE_GET(sq->head);
590190579Ssam	} else
591190579Ssam		sq->head = m;
592190579Ssam	KASSERT(age >= 0, ("age %d", age));
593190579Ssam	M_AGE_SET(m, age);
594190579Ssam	m->m_nextpkt = NULL;
595190579Ssam	sq->tail = m;
596190579Ssam	sq->depth++;
597190579Ssam}
598190579Ssam
599190579Ssamstatic void
600190579Ssamstageq_remove(struct ieee80211_stageq *sq, struct mbuf *mstaged)
601190579Ssam{
602190579Ssam	struct mbuf *m, *mprev;
603190579Ssam
604190579Ssam	mprev = NULL;
605190579Ssam	for (m = sq->head; m != NULL; m = m->m_nextpkt) {
606190579Ssam		if (m == mstaged) {
607190579Ssam			if (mprev == NULL)
608190579Ssam				sq->head = m->m_nextpkt;
609190579Ssam			else
610190579Ssam				mprev->m_nextpkt = m->m_nextpkt;
611190579Ssam			if (sq->tail == m)
612190579Ssam				sq->tail = mprev;
613190579Ssam			sq->depth--;
614190579Ssam			return;
615190579Ssam		}
616190579Ssam		mprev = m;
617190579Ssam	}
618190579Ssam	printf("%s: packet not found\n", __func__);
619190579Ssam}
620190579Ssam
621190579Ssamstatic uint32_t
622190579Ssamff_approx_txtime(struct ieee80211_node *ni,
623190579Ssam	const struct mbuf *m1, const struct mbuf *m2)
624190579Ssam{
625190579Ssam	struct ieee80211com *ic = ni->ni_ic;
626190579Ssam	struct ieee80211vap *vap = ni->ni_vap;
627190579Ssam	uint32_t framelen;
628190579Ssam
629190579Ssam	/*
630190579Ssam	 * Approximate the frame length to be transmitted. A swag to add
631190579Ssam	 * the following maximal values to the skb payload:
632190579Ssam	 *   - 32: 802.11 encap + CRC
633190579Ssam	 *   - 24: encryption overhead (if wep bit)
634190579Ssam	 *   - 4 + 6: fast-frame header and padding
635190579Ssam	 *   - 16: 2 LLC FF tunnel headers
636190579Ssam	 *   - 14: 1 802.3 FF tunnel header (mbuf already accounts for 2nd)
637190579Ssam	 */
638190579Ssam	framelen = m1->m_pkthdr.len + 32 +
639190579Ssam	    ATH_FF_MAX_HDR_PAD + ATH_FF_MAX_SEP_PAD + ATH_FF_MAX_HDR;
640190579Ssam	if (vap->iv_flags & IEEE80211_F_PRIVACY)
641190579Ssam		framelen += 24;
642190579Ssam	if (m2 != NULL)
643190579Ssam		framelen += m2->m_pkthdr.len;
644190579Ssam	return ieee80211_compute_duration(ic->ic_rt, framelen, ni->ni_txrate, 0);
645190579Ssam}
646190579Ssam
647190579Ssam/*
648190579Ssam * Check if the supplied frame can be partnered with an existing
649190579Ssam * or pending frame.  Return a reference to any frame that should be
650190579Ssam * sent on return; otherwise return NULL.
651190579Ssam */
652190579Ssamstruct mbuf *
653190579Ssamieee80211_ff_check(struct ieee80211_node *ni, struct mbuf *m)
654190579Ssam{
655190579Ssam	struct ieee80211vap *vap = ni->ni_vap;
656190579Ssam	struct ieee80211com *ic = ni->ni_ic;
657191753Ssam	struct ieee80211_superg *sg = ic->ic_superg;
658190579Ssam	const int pri = M_WME_GETAC(m);
659190579Ssam	struct ieee80211_stageq *sq;
660190579Ssam	struct ieee80211_tx_ampdu *tap;
661190579Ssam	struct mbuf *mstaged;
662190579Ssam	uint32_t txtime, limit;
663190579Ssam
664190579Ssam	/*
665190579Ssam	 * Check if the supplied frame can be aggregated.
666190579Ssam	 *
667190579Ssam	 * NB: we allow EAPOL frames to be aggregated with other ucast traffic.
668190579Ssam	 *     Do 802.1x EAPOL frames proceed in the clear? Then they couldn't
669190579Ssam	 *     be aggregated with other types of frames when encryption is on?
670190579Ssam	 */
671190579Ssam	IEEE80211_LOCK(ic);
672190579Ssam	tap = &ni->ni_tx_ampdu[pri];
673190579Ssam	mstaged = tap->txa_private;		/* NB: we reuse AMPDU state */
674190579Ssam	ieee80211_txampdu_count_packet(tap);
675190579Ssam
676190579Ssam	/*
677190579Ssam	 * When not in station mode never aggregate a multicast
678190579Ssam	 * frame; this insures, for example, that a combined frame
679190579Ssam	 * does not require multiple encryption keys.
680190579Ssam	 */
681190579Ssam	if (vap->iv_opmode != IEEE80211_M_STA &&
682190579Ssam	    ETHER_IS_MULTICAST(mtod(m, struct ether_header *)->ether_dhost)) {
683190579Ssam		/* XXX flush staged frame? */
684190579Ssam		IEEE80211_UNLOCK(ic);
685190579Ssam		return m;
686190579Ssam	}
687190579Ssam	/*
688190579Ssam	 * If there is no frame to combine with and the pps is
689190579Ssam	 * too low; then do not attempt to aggregate this frame.
690190579Ssam	 */
691190579Ssam	if (mstaged == NULL &&
692190579Ssam	    ieee80211_txampdu_getpps(tap) < ieee80211_ffppsmin) {
693190579Ssam		IEEE80211_UNLOCK(ic);
694190579Ssam		return m;
695190579Ssam	}
696191753Ssam	sq = &sg->ff_stageq[pri];
697190579Ssam	/*
698190579Ssam	 * Check the txop limit to insure the aggregate fits.
699190579Ssam	 */
700190579Ssam	limit = IEEE80211_TXOP_TO_US(
701190579Ssam		ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit);
702190579Ssam	if (limit != 0 &&
703190579Ssam	    (txtime = ff_approx_txtime(ni, m, mstaged)) > limit) {
704190579Ssam		/*
705190579Ssam		 * Aggregate too long, return to the caller for direct
706190579Ssam		 * transmission.  In addition, flush any pending frame
707190579Ssam		 * before sending this one.
708190579Ssam		 */
709190579Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
710190579Ssam		    "%s: txtime %u exceeds txop limit %u\n",
711190579Ssam		    __func__, txtime, limit);
712190579Ssam
713190579Ssam		tap->txa_private = NULL;
714190579Ssam		if (mstaged != NULL)
715190579Ssam			stageq_remove(sq, mstaged);
716190579Ssam		IEEE80211_UNLOCK(ic);
717190579Ssam
718190579Ssam		if (mstaged != NULL) {
719190579Ssam			IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
720190579Ssam			    "%s: flush staged frame", __func__);
721190579Ssam			/* encap and xmit */
722190579Ssam			ff_transmit(ni, mstaged);
723190579Ssam		}
724190579Ssam		return m;		/* NB: original frame */
725190579Ssam	}
726190579Ssam	/*
727190579Ssam	 * An aggregation candidate.  If there's a frame to partner
728190579Ssam	 * with then combine and return for processing.  Otherwise
729190579Ssam	 * save this frame and wait for a partner to show up (or
730190579Ssam	 * the frame to be flushed).  Note that staged frames also
731190579Ssam	 * hold their node reference.
732190579Ssam	 */
733190579Ssam	if (mstaged != NULL) {
734190579Ssam		tap->txa_private = NULL;
735190579Ssam		stageq_remove(sq, mstaged);
736190579Ssam		IEEE80211_UNLOCK(ic);
737190579Ssam
738190579Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
739190579Ssam		    "%s: aggregate fast-frame", __func__);
740190579Ssam		/*
741190579Ssam		 * Release the node reference; we only need
742190579Ssam		 * the one already in mstaged.
743190579Ssam		 */
744190579Ssam		KASSERT(mstaged->m_pkthdr.rcvif == (void *)ni,
745190579Ssam		    ("rcvif %p ni %p", mstaged->m_pkthdr.rcvif, ni));
746190579Ssam		ieee80211_free_node(ni);
747190579Ssam
748190579Ssam		m->m_nextpkt = NULL;
749190579Ssam		mstaged->m_nextpkt = m;
750190579Ssam		mstaged->m_flags |= M_FF; /* NB: mark for encap work */
751190579Ssam	} else {
752190579Ssam		KASSERT(tap->txa_private == NULL,
753190579Ssam		    ("txa_private %p", tap->txa_private));
754190579Ssam		tap->txa_private = m;
755190579Ssam
756190579Ssam		stageq_add(sq, m);
757191753Ssam		sg->ff_stageqdepth++;
758190579Ssam		IEEE80211_UNLOCK(ic);
759190579Ssam
760190579Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
761190579Ssam		    "%s: stage frame, %u queued", __func__, sq->depth);
762190579Ssam		/* NB: mstaged is NULL */
763190579Ssam	}
764190579Ssam	return mstaged;
765190579Ssam}
766190579Ssam
767190579Ssamvoid
768190579Ssamieee80211_ff_node_init(struct ieee80211_node *ni)
769190579Ssam{
770190579Ssam	/*
771190579Ssam	 * Clean FF state on re-associate.  This handles the case
772190579Ssam	 * where a station leaves w/o notifying us and then returns
773190579Ssam	 * before node is reaped for inactivity.
774190579Ssam	 */
775190579Ssam	ieee80211_ff_node_cleanup(ni);
776190579Ssam}
777190579Ssam
778190579Ssamvoid
779190579Ssamieee80211_ff_node_cleanup(struct ieee80211_node *ni)
780190579Ssam{
781190579Ssam	struct ieee80211com *ic = ni->ni_ic;
782191753Ssam	struct ieee80211_superg *sg = ic->ic_superg;
783190579Ssam	struct ieee80211_tx_ampdu *tap;
784190579Ssam	struct mbuf *m, *head;
785190579Ssam	int ac;
786190579Ssam
787190579Ssam	IEEE80211_LOCK(ic);
788190579Ssam	head = NULL;
789190579Ssam	for (ac = 0; ac < WME_NUM_AC; ac++) {
790190579Ssam		tap = &ni->ni_tx_ampdu[ac];
791190579Ssam		m = tap->txa_private;
792190579Ssam		if (m != NULL) {
793190579Ssam			tap->txa_private = NULL;
794191753Ssam			stageq_remove(&sg->ff_stageq[ac], m);
795190579Ssam			m->m_nextpkt = head;
796190579Ssam			head = m;
797190579Ssam		}
798190579Ssam	}
799190579Ssam	IEEE80211_UNLOCK(ic);
800190579Ssam
801190579Ssam	for (m = head; m != NULL; m = m->m_nextpkt) {
802190579Ssam		m_freem(m);
803190579Ssam		ieee80211_free_node(ni);
804190579Ssam	}
805190579Ssam}
806190579Ssam
807190579Ssam/*
808190391Ssam * Switch between turbo and non-turbo operating modes.
809190391Ssam * Use the specified channel flags to locate the new
810190391Ssam * channel, update 802.11 state, and then call back into
811190391Ssam * the driver to effect the change.
812190391Ssam */
813190391Ssamvoid
814190391Ssamieee80211_dturbo_switch(struct ieee80211vap *vap, int newflags)
815190391Ssam{
816190391Ssam	struct ieee80211com *ic = vap->iv_ic;
817190391Ssam	struct ieee80211_channel *chan;
818190391Ssam
819190391Ssam	chan = ieee80211_find_channel(ic, ic->ic_bsschan->ic_freq, newflags);
820190391Ssam	if (chan == NULL) {		/* XXX should not happen */
821190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
822190391Ssam		    "%s: no channel with freq %u flags 0x%x\n",
823190391Ssam		    __func__, ic->ic_bsschan->ic_freq, newflags);
824190391Ssam		return;
825190391Ssam	}
826190391Ssam
827190391Ssam	IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
828190391Ssam	    "%s: %s -> %s (freq %u flags 0x%x)\n", __func__,
829190391Ssam	    ieee80211_phymode_name[ieee80211_chan2mode(ic->ic_bsschan)],
830190391Ssam	    ieee80211_phymode_name[ieee80211_chan2mode(chan)],
831190391Ssam	    chan->ic_freq, chan->ic_flags);
832190391Ssam
833190391Ssam	ic->ic_bsschan = chan;
834190391Ssam	ic->ic_prevchan = ic->ic_curchan;
835190391Ssam	ic->ic_curchan = chan;
836190532Ssam	ic->ic_rt = ieee80211_get_ratetable(chan);
837190391Ssam	ic->ic_set_channel(ic);
838190391Ssam	/* NB: do not need to reset ERP state 'cuz we're in sta mode */
839190391Ssam}
840190391Ssam
841190391Ssam/*
842190391Ssam * Return the current ``state'' of an Atheros capbility.
843190391Ssam * If associated in station mode report the negotiated
844190391Ssam * setting. Otherwise report the current setting.
845190391Ssam */
846190391Ssamstatic int
847190391Ssamgetathcap(struct ieee80211vap *vap, int cap)
848190391Ssam{
849190391Ssam	if (vap->iv_opmode == IEEE80211_M_STA &&
850190391Ssam	    vap->iv_state == IEEE80211_S_RUN)
851190391Ssam		return IEEE80211_ATH_CAP(vap, vap->iv_bss, cap) != 0;
852190391Ssam	else
853190391Ssam		return (vap->iv_flags & cap) != 0;
854190391Ssam}
855190391Ssam
856190391Ssamstatic int
857190391Ssamsuperg_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
858190391Ssam{
859190391Ssam	switch (ireq->i_type) {
860190391Ssam	case IEEE80211_IOC_FF:
861190391Ssam		ireq->i_val = getathcap(vap, IEEE80211_F_FF);
862190391Ssam		break;
863190391Ssam	case IEEE80211_IOC_TURBOP:
864190391Ssam		ireq->i_val = getathcap(vap, IEEE80211_F_TURBOP);
865190391Ssam		break;
866190391Ssam	default:
867190391Ssam		return ENOSYS;
868190391Ssam	}
869190391Ssam	return 0;
870190391Ssam}
871190391SsamIEEE80211_IOCTL_GET(superg, superg_ioctl_get80211);
872190391Ssam
873190391Ssamstatic int
874190391Ssamsuperg_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
875190391Ssam{
876190391Ssam	switch (ireq->i_type) {
877190391Ssam	case IEEE80211_IOC_FF:
878190391Ssam		if (ireq->i_val) {
879190391Ssam			if ((vap->iv_caps & IEEE80211_C_FF) == 0)
880190391Ssam				return EOPNOTSUPP;
881190391Ssam			vap->iv_flags |= IEEE80211_F_FF;
882190391Ssam		} else
883190391Ssam			vap->iv_flags &= ~IEEE80211_F_FF;
884190530Ssam		return ENETRESET;
885190391Ssam	case IEEE80211_IOC_TURBOP:
886190391Ssam		if (ireq->i_val) {
887190391Ssam			if ((vap->iv_caps & IEEE80211_C_TURBOP) == 0)
888190391Ssam				return EOPNOTSUPP;
889190391Ssam			vap->iv_flags |= IEEE80211_F_TURBOP;
890190391Ssam		} else
891190391Ssam			vap->iv_flags &= ~IEEE80211_F_TURBOP;
892190391Ssam		return ENETRESET;
893190391Ssam	default:
894190391Ssam		return ENOSYS;
895190391Ssam	}
896190391Ssam	return 0;
897190391Ssam}
898190391SsamIEEE80211_IOCTL_SET(superg, superg_ioctl_set80211);
899