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$");
28190391Ssam
29190391Ssam#include "opt_wlan.h"
30190391Ssam
31246226Sadrian#ifdef	IEEE80211_SUPPORT_SUPERG
32246226Sadrian
33190391Ssam#include <sys/param.h>
34190391Ssam#include <sys/systm.h>
35190391Ssam#include <sys/mbuf.h>
36190391Ssam#include <sys/kernel.h>
37190391Ssam#include <sys/endian.h>
38190391Ssam
39190391Ssam#include <sys/socket.h>
40190391Ssam
41190391Ssam#include <net/bpf.h>
42190391Ssam#include <net/ethernet.h>
43190391Ssam#include <net/if.h>
44190391Ssam#include <net/if_llc.h>
45190391Ssam#include <net/if_media.h>
46190391Ssam
47190391Ssam#include <net80211/ieee80211_var.h>
48190391Ssam#include <net80211/ieee80211_input.h>
49190391Ssam#include <net80211/ieee80211_phy.h>
50190391Ssam#include <net80211/ieee80211_superg.h>
51190391Ssam
52190455Ssam/*
53190455Ssam * Atheros fast-frame encapsulation format.
54190455Ssam * FF max payload:
55190455Ssam * 802.2 + FFHDR + HPAD + 802.3 + 802.2 + 1500 + SPAD + 802.3 + 802.2 + 1500:
56190455Ssam *   8   +   4   +  4   +   14  +   8   + 1500 +  6   +   14  +   8   + 1500
57190455Ssam * = 3066
58190455Ssam */
59190455Ssam/* fast frame header is 32-bits */
60190455Ssam#define	ATH_FF_PROTO	0x0000003f	/* protocol */
61190455Ssam#define	ATH_FF_PROTO_S	0
62190455Ssam#define	ATH_FF_FTYPE	0x000000c0	/* frame type */
63190455Ssam#define	ATH_FF_FTYPE_S	6
64190455Ssam#define	ATH_FF_HLEN32	0x00000300	/* optional hdr length */
65190455Ssam#define	ATH_FF_HLEN32_S	8
66190455Ssam#define	ATH_FF_SEQNUM	0x001ffc00	/* sequence number */
67190455Ssam#define	ATH_FF_SEQNUM_S	10
68190455Ssam#define	ATH_FF_OFFSET	0xffe00000	/* offset to 2nd payload */
69190455Ssam#define	ATH_FF_OFFSET_S	21
70190455Ssam
71190455Ssam#define	ATH_FF_MAX_HDR_PAD	4
72190455Ssam#define	ATH_FF_MAX_SEP_PAD	6
73190455Ssam#define	ATH_FF_MAX_HDR		30
74190455Ssam
75190455Ssam#define	ATH_FF_PROTO_L2TUNNEL	0	/* L2 tunnel protocol */
76190455Ssam#define	ATH_FF_ETH_TYPE		0x88bd	/* Ether type for encapsulated frames */
77190455Ssam#define	ATH_FF_SNAP_ORGCODE_0	0x00
78190455Ssam#define	ATH_FF_SNAP_ORGCODE_1	0x03
79190455Ssam#define	ATH_FF_SNAP_ORGCODE_2	0x7f
80190455Ssam
81190579Ssam#define	ATH_FF_TXQMIN	2		/* min txq depth for staging */
82190579Ssam#define	ATH_FF_TXQMAX	50		/* maximum # of queued frames allowed */
83190579Ssam#define	ATH_FF_STAGEMAX	5		/* max waiting period for staged frame*/
84190579Ssam
85190391Ssam#define	ETHER_HEADER_COPY(dst, src) \
86190391Ssam	memcpy(dst, src, sizeof(struct ether_header))
87190391Ssam
88193115Ssamstatic	int ieee80211_ffppsmin = 2;	/* pps threshold for ff aggregation */
89193115SsamSYSCTL_INT(_net_wlan, OID_AUTO, ffppsmin, CTLTYPE_INT | CTLFLAG_RW,
90193115Ssam	&ieee80211_ffppsmin, 0, "min packet rate before fast-frame staging");
91193115Ssamstatic	int ieee80211_ffagemax = -1;	/* max time frames held on stage q */
92193115SsamSYSCTL_PROC(_net_wlan, OID_AUTO, ffagemax, CTLTYPE_INT | CTLFLAG_RW,
93193115Ssam	&ieee80211_ffagemax, 0, ieee80211_sysctl_msecs_ticks, "I",
94193115Ssam	"max hold time for fast-frame staging (ms)");
95190579Ssam
96190391Ssamvoid
97190391Ssamieee80211_superg_attach(struct ieee80211com *ic)
98190391Ssam{
99191753Ssam	struct ieee80211_superg *sg;
100191753Ssam
101191753Ssam	if (ic->ic_caps & IEEE80211_C_FF) {
102191753Ssam		sg = (struct ieee80211_superg *) malloc(
103191753Ssam		     sizeof(struct ieee80211_superg), M_80211_VAP,
104191753Ssam		     M_NOWAIT | M_ZERO);
105191753Ssam		if (sg == NULL) {
106191753Ssam			printf("%s: cannot allocate SuperG state block\n",
107191753Ssam			    __func__);
108191753Ssam			return;
109191753Ssam		}
110191753Ssam		ic->ic_superg = sg;
111191753Ssam	}
112190579Ssam	ieee80211_ffagemax = msecs_to_ticks(150);
113190391Ssam}
114190391Ssam
115190391Ssamvoid
116190391Ssamieee80211_superg_detach(struct ieee80211com *ic)
117190391Ssam{
118191753Ssam	if (ic->ic_superg != NULL) {
119191753Ssam		free(ic->ic_superg, M_80211_VAP);
120191753Ssam		ic->ic_superg = NULL;
121191753Ssam	}
122190391Ssam}
123190391Ssam
124190391Ssamvoid
125190391Ssamieee80211_superg_vattach(struct ieee80211vap *vap)
126190391Ssam{
127191753Ssam	struct ieee80211com *ic = vap->iv_ic;
128191753Ssam
129191753Ssam	if (ic->ic_superg == NULL)	/* NB: can't do fast-frames w/o state */
130191753Ssam		vap->iv_caps &= ~IEEE80211_C_FF;
131190391Ssam	if (vap->iv_caps & IEEE80211_C_FF)
132190391Ssam		vap->iv_flags |= IEEE80211_F_FF;
133190450Ssam	/* NB: we only implement sta mode */
134190450Ssam	if (vap->iv_opmode == IEEE80211_M_STA &&
135190450Ssam	    (vap->iv_caps & IEEE80211_C_TURBOP))
136190391Ssam		vap->iv_flags |= IEEE80211_F_TURBOP;
137190391Ssam}
138190391Ssam
139190391Ssamvoid
140190391Ssamieee80211_superg_vdetach(struct ieee80211vap *vap)
141190391Ssam{
142190391Ssam}
143190391Ssam
144190391Ssam#define	ATH_OUI_BYTES		0x00, 0x03, 0x7f
145190391Ssam/*
146190391Ssam * Add a WME information element to a frame.
147190391Ssam */
148190391Ssamuint8_t *
149190451Ssamieee80211_add_ath(uint8_t *frm, uint8_t caps, ieee80211_keyix defkeyix)
150190391Ssam{
151190391Ssam	static const struct ieee80211_ath_ie info = {
152190391Ssam		.ath_id		= IEEE80211_ELEMID_VENDOR,
153190391Ssam		.ath_len	= sizeof(struct ieee80211_ath_ie) - 2,
154190391Ssam		.ath_oui	= { ATH_OUI_BYTES },
155190391Ssam		.ath_oui_type	= ATH_OUI_TYPE,
156190391Ssam		.ath_oui_subtype= ATH_OUI_SUBTYPE,
157190391Ssam		.ath_version	= ATH_OUI_VERSION,
158190391Ssam	};
159190391Ssam	struct ieee80211_ath_ie *ath = (struct ieee80211_ath_ie *) frm;
160190391Ssam
161190391Ssam	memcpy(frm, &info, sizeof(info));
162190391Ssam	ath->ath_capability = caps;
163190451Ssam	if (defkeyix != IEEE80211_KEYIX_NONE) {
164190451Ssam		ath->ath_defkeyix[0] = (defkeyix & 0xff);
165190451Ssam		ath->ath_defkeyix[1] = ((defkeyix >> 8) & 0xff);
166190451Ssam	} else {
167190451Ssam		ath->ath_defkeyix[0] = 0xff;
168190451Ssam		ath->ath_defkeyix[1] = 0x7f;
169190451Ssam	}
170190391Ssam	return frm + sizeof(info);
171190391Ssam}
172190391Ssam#undef ATH_OUI_BYTES
173190391Ssam
174190451Ssamuint8_t *
175190451Ssamieee80211_add_athcaps(uint8_t *frm, const struct ieee80211_node *bss)
176190451Ssam{
177190451Ssam	const struct ieee80211vap *vap = bss->ni_vap;
178190451Ssam
179190451Ssam	return ieee80211_add_ath(frm,
180190451Ssam	    vap->iv_flags & IEEE80211_F_ATHEROS,
181190451Ssam	    ((vap->iv_flags & IEEE80211_F_WPA) == 0 &&
182190451Ssam	    bss->ni_authmode != IEEE80211_AUTH_8021X) ?
183190451Ssam	    vap->iv_def_txkey : IEEE80211_KEYIX_NONE);
184190451Ssam}
185190451Ssam
186190391Ssamvoid
187190391Ssamieee80211_parse_ath(struct ieee80211_node *ni, uint8_t *ie)
188190391Ssam{
189190391Ssam	const struct ieee80211_ath_ie *ath =
190190391Ssam		(const struct ieee80211_ath_ie *) ie;
191190391Ssam
192190391Ssam	ni->ni_ath_flags = ath->ath_capability;
193190391Ssam	ni->ni_ath_defkeyix = LE_READ_2(&ath->ath_defkeyix);
194190391Ssam}
195190391Ssam
196190391Ssamint
197190391Ssamieee80211_parse_athparams(struct ieee80211_node *ni, uint8_t *frm,
198190391Ssam	const struct ieee80211_frame *wh)
199190391Ssam{
200190391Ssam	struct ieee80211vap *vap = ni->ni_vap;
201190391Ssam	const struct ieee80211_ath_ie *ath;
202190391Ssam	u_int len = frm[1];
203190391Ssam	int capschanged;
204190391Ssam	uint16_t defkeyix;
205190391Ssam
206190391Ssam	if (len < sizeof(struct ieee80211_ath_ie)-2) {
207190391Ssam		IEEE80211_DISCARD_IE(vap,
208190391Ssam		    IEEE80211_MSG_ELEMID | IEEE80211_MSG_SUPERG,
209190391Ssam		    wh, "Atheros", "too short, len %u", len);
210190391Ssam		return -1;
211190391Ssam	}
212190391Ssam	ath = (const struct ieee80211_ath_ie *)frm;
213190391Ssam	capschanged = (ni->ni_ath_flags != ath->ath_capability);
214190391Ssam	defkeyix = LE_READ_2(ath->ath_defkeyix);
215190391Ssam	if (capschanged || defkeyix != ni->ni_ath_defkeyix) {
216190391Ssam		ni->ni_ath_flags = ath->ath_capability;
217190391Ssam		ni->ni_ath_defkeyix = defkeyix;
218190391Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
219190391Ssam		    "ath ie change: new caps 0x%x defkeyix 0x%x",
220190391Ssam		    ni->ni_ath_flags, ni->ni_ath_defkeyix);
221190391Ssam	}
222190391Ssam	if (IEEE80211_ATH_CAP(vap, ni, ATHEROS_CAP_TURBO_PRIME)) {
223190391Ssam		uint16_t curflags, newflags;
224190391Ssam
225190391Ssam		/*
226190391Ssam		 * Check for turbo mode switch.  Calculate flags
227190391Ssam		 * for the new mode and effect the switch.
228190391Ssam		 */
229190391Ssam		newflags = curflags = vap->iv_ic->ic_bsschan->ic_flags;
230190391Ssam		/* NB: BOOST is not in ic_flags, so get it from the ie */
231190391Ssam		if (ath->ath_capability & ATHEROS_CAP_BOOST)
232190391Ssam			newflags |= IEEE80211_CHAN_TURBO;
233190391Ssam		else
234190391Ssam			newflags &= ~IEEE80211_CHAN_TURBO;
235190391Ssam		if (newflags != curflags)
236190391Ssam			ieee80211_dturbo_switch(vap, newflags);
237190391Ssam	}
238190391Ssam	return capschanged;
239190391Ssam}
240190391Ssam
241190391Ssam/*
242190391Ssam * Decap the encapsulated frame pair and dispatch the first
243190391Ssam * for delivery.  The second frame is returned for delivery
244190391Ssam * via the normal path.
245190391Ssam */
246190391Ssamstruct mbuf *
247190391Ssamieee80211_ff_decap(struct ieee80211_node *ni, struct mbuf *m)
248190391Ssam{
249190391Ssam#define	FF_LLC_SIZE	(sizeof(struct ether_header) + sizeof(struct llc))
250190391Ssam#define	MS(x,f)	(((x) & f) >> f##_S)
251190391Ssam	struct ieee80211vap *vap = ni->ni_vap;
252190391Ssam	struct llc *llc;
253190391Ssam	uint32_t ath;
254190391Ssam	struct mbuf *n;
255190391Ssam	int framelen;
256190391Ssam
257190391Ssam	/* NB: we assume caller does this check for us */
258190391Ssam	KASSERT(IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF),
259190391Ssam	    ("ff not negotiated"));
260190391Ssam	/*
261190391Ssam	 * Check for fast-frame tunnel encapsulation.
262190391Ssam	 */
263190391Ssam	if (m->m_pkthdr.len < 3*FF_LLC_SIZE)
264190391Ssam		return m;
265190391Ssam	if (m->m_len < FF_LLC_SIZE &&
266190391Ssam	    (m = m_pullup(m, FF_LLC_SIZE)) == NULL) {
267190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
268190391Ssam		    ni->ni_macaddr, "fast-frame",
269190391Ssam		    "%s", "m_pullup(llc) failed");
270190391Ssam		vap->iv_stats.is_rx_tooshort++;
271190391Ssam		return NULL;
272190391Ssam	}
273190391Ssam	llc = (struct llc *)(mtod(m, uint8_t *) +
274190391Ssam	    sizeof(struct ether_header));
275190391Ssam	if (llc->llc_snap.ether_type != htons(ATH_FF_ETH_TYPE))
276190391Ssam		return m;
277190391Ssam	m_adj(m, FF_LLC_SIZE);
278190391Ssam	m_copydata(m, 0, sizeof(uint32_t), (caddr_t) &ath);
279190391Ssam	if (MS(ath, ATH_FF_PROTO) != ATH_FF_PROTO_L2TUNNEL) {
280190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
281190391Ssam		    ni->ni_macaddr, "fast-frame",
282190391Ssam		    "unsupport tunnel protocol, header 0x%x", ath);
283190391Ssam		vap->iv_stats.is_ff_badhdr++;
284190391Ssam		m_freem(m);
285190391Ssam		return NULL;
286190391Ssam	}
287190391Ssam	/* NB: skip header and alignment padding */
288190391Ssam	m_adj(m, roundup(sizeof(uint32_t) - 2, 4) + 2);
289190391Ssam
290190391Ssam	vap->iv_stats.is_ff_decap++;
291190391Ssam
292190391Ssam	/*
293190391Ssam	 * Decap the first frame, bust it apart from the
294190391Ssam	 * second and deliver; then decap the second frame
295190391Ssam	 * and return it to the caller for normal delivery.
296190391Ssam	 */
297190391Ssam	m = ieee80211_decap1(m, &framelen);
298190391Ssam	if (m == NULL) {
299190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
300190391Ssam		    ni->ni_macaddr, "fast-frame", "%s", "first decap failed");
301190391Ssam		vap->iv_stats.is_ff_tooshort++;
302190391Ssam		return NULL;
303190391Ssam	}
304190391Ssam	n = m_split(m, framelen, M_NOWAIT);
305190391Ssam	if (n == NULL) {
306190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
307190391Ssam		    ni->ni_macaddr, "fast-frame",
308190391Ssam		    "%s", "unable to split encapsulated frames");
309190391Ssam		vap->iv_stats.is_ff_split++;
310190391Ssam		m_freem(m);			/* NB: must reclaim */
311190391Ssam		return NULL;
312190391Ssam	}
313190391Ssam	/* XXX not right for WDS */
314190391Ssam	vap->iv_deliver_data(vap, ni, m);	/* 1st of pair */
315190391Ssam
316190391Ssam	/*
317190391Ssam	 * Decap second frame.
318190391Ssam	 */
319190391Ssam	m_adj(n, roundup2(framelen, 4) - framelen);	/* padding */
320190391Ssam	n = ieee80211_decap1(n, &framelen);
321190391Ssam	if (n == NULL) {
322190391Ssam		IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
323190391Ssam		    ni->ni_macaddr, "fast-frame", "%s", "second decap failed");
324190391Ssam		vap->iv_stats.is_ff_tooshort++;
325190391Ssam	}
326190391Ssam	/* XXX verify framelen against mbuf contents */
327190391Ssam	return n;				/* 2nd delivered by caller */
328190391Ssam#undef MS
329190391Ssam#undef FF_LLC_SIZE
330190391Ssam}
331190391Ssam
332190391Ssam/*
333190391Ssam * Fast frame encapsulation.  There must be two packets
334190391Ssam * chained with m_nextpkt.  We do header adjustment for
335190391Ssam * each, add the tunnel encapsulation, and then concatenate
336190391Ssam * the mbuf chains to form a single frame for transmission.
337190391Ssam */
338190391Ssamstruct mbuf *
339190391Ssamieee80211_ff_encap(struct ieee80211vap *vap, struct mbuf *m1, int hdrspace,
340190391Ssam	struct ieee80211_key *key)
341190391Ssam{
342190391Ssam	struct mbuf *m2;
343190391Ssam	struct ether_header eh1, eh2;
344190391Ssam	struct llc *llc;
345190391Ssam	struct mbuf *m;
346190391Ssam	int pad;
347190391Ssam
348190391Ssam	m2 = m1->m_nextpkt;
349190391Ssam	if (m2 == NULL) {
350190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
351190391Ssam		    "%s: only one frame\n", __func__);
352190391Ssam		goto bad;
353190391Ssam	}
354190391Ssam	m1->m_nextpkt = NULL;
355190391Ssam	/*
356190579Ssam	 * Include fast frame headers in adjusting header layout.
357190391Ssam	 */
358190579Ssam	KASSERT(m1->m_len >= sizeof(eh1), ("no ethernet header!"));
359190579Ssam	ETHER_HEADER_COPY(&eh1, mtod(m1, caddr_t));
360190391Ssam	m1 = ieee80211_mbuf_adjust(vap,
361190391Ssam		hdrspace + sizeof(struct llc) + sizeof(uint32_t) + 2 +
362190391Ssam		    sizeof(struct ether_header),
363190391Ssam		key, m1);
364190391Ssam	if (m1 == NULL) {
365190391Ssam		/* NB: ieee80211_mbuf_adjust handles msgs+statistics */
366190391Ssam		m_freem(m2);
367190391Ssam		goto bad;
368190391Ssam	}
369190391Ssam
370190391Ssam	/*
371190391Ssam	 * Copy second frame's Ethernet header out of line
372190391Ssam	 * and adjust for encapsulation headers.  Note that
373190391Ssam	 * we make room for padding in case there isn't room
374190391Ssam	 * at the end of first frame.
375190391Ssam	 */
376190391Ssam	KASSERT(m2->m_len >= sizeof(eh2), ("no ethernet header!"));
377190391Ssam	ETHER_HEADER_COPY(&eh2, mtod(m2, caddr_t));
378190391Ssam	m2 = ieee80211_mbuf_adjust(vap,
379190391Ssam		ATH_FF_MAX_HDR_PAD + sizeof(struct ether_header),
380190391Ssam		NULL, m2);
381190391Ssam	if (m2 == NULL) {
382190391Ssam		/* NB: ieee80211_mbuf_adjust handles msgs+statistics */
383190391Ssam		goto bad;
384190391Ssam	}
385190391Ssam
386190391Ssam	/*
387190391Ssam	 * Now do tunnel encapsulation.  First, each
388190391Ssam	 * frame gets a standard encapsulation.
389190391Ssam	 */
390254900Sadrian	m1 = ieee80211_ff_encap1(vap, m1, &eh1);
391190391Ssam	if (m1 == NULL)
392190391Ssam		goto bad;
393254900Sadrian	m2 = ieee80211_ff_encap1(vap, m2, &eh2);
394190391Ssam	if (m2 == NULL)
395190391Ssam		goto bad;
396190391Ssam
397190391Ssam	/*
398190391Ssam	 * Pad leading frame to a 4-byte boundary.  If there
399190391Ssam	 * is space at the end of the first frame, put it
400190391Ssam	 * there; otherwise prepend to the front of the second
401190391Ssam	 * frame.  We know doing the second will always work
402190391Ssam	 * because we reserve space above.  We prefer appending
403190391Ssam	 * as this typically has better DMA alignment properties.
404190391Ssam	 */
405190391Ssam	for (m = m1; m->m_next != NULL; m = m->m_next)
406190391Ssam		;
407190391Ssam	pad = roundup2(m1->m_pkthdr.len, 4) - m1->m_pkthdr.len;
408190391Ssam	if (pad) {
409190391Ssam		if (M_TRAILINGSPACE(m) < pad) {		/* prepend to second */
410190391Ssam			m2->m_data -= pad;
411190391Ssam			m2->m_len += pad;
412190391Ssam			m2->m_pkthdr.len += pad;
413190391Ssam		} else {				/* append to first */
414190391Ssam			m->m_len += pad;
415190391Ssam			m1->m_pkthdr.len += pad;
416190391Ssam		}
417190391Ssam	}
418190391Ssam
419190391Ssam	/*
420190391Ssam	 * Now, stick 'em together and prepend the tunnel headers;
421190391Ssam	 * first the Atheros tunnel header (all zero for now) and
422190391Ssam	 * then a special fast frame LLC.
423190391Ssam	 *
424190391Ssam	 * XXX optimize by prepending together
425190391Ssam	 */
426190391Ssam	m->m_next = m2;			/* NB: last mbuf from above */
427190391Ssam	m1->m_pkthdr.len += m2->m_pkthdr.len;
428243882Sglebius	M_PREPEND(m1, sizeof(uint32_t)+2, M_NOWAIT);
429190391Ssam	if (m1 == NULL) {		/* XXX cannot happen */
430190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
431190391Ssam		    "%s: no space for tunnel header\n", __func__);
432190391Ssam		vap->iv_stats.is_tx_nobuf++;
433190391Ssam		return NULL;
434190391Ssam	}
435190391Ssam	memset(mtod(m1, void *), 0, sizeof(uint32_t)+2);
436190391Ssam
437243882Sglebius	M_PREPEND(m1, sizeof(struct llc), M_NOWAIT);
438190391Ssam	if (m1 == NULL) {		/* XXX cannot happen */
439190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
440190391Ssam		    "%s: no space for llc header\n", __func__);
441190391Ssam		vap->iv_stats.is_tx_nobuf++;
442190391Ssam		return NULL;
443190391Ssam	}
444190391Ssam	llc = mtod(m1, struct llc *);
445190391Ssam	llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP;
446190391Ssam	llc->llc_control = LLC_UI;
447190391Ssam	llc->llc_snap.org_code[0] = ATH_FF_SNAP_ORGCODE_0;
448190391Ssam	llc->llc_snap.org_code[1] = ATH_FF_SNAP_ORGCODE_1;
449190391Ssam	llc->llc_snap.org_code[2] = ATH_FF_SNAP_ORGCODE_2;
450190391Ssam	llc->llc_snap.ether_type = htons(ATH_FF_ETH_TYPE);
451190391Ssam
452190391Ssam	vap->iv_stats.is_ff_encap++;
453190391Ssam
454190391Ssam	return m1;
455190391Ssambad:
456190391Ssam	if (m1 != NULL)
457190391Ssam		m_freem(m1);
458190391Ssam	if (m2 != NULL)
459190391Ssam		m_freem(m2);
460190391Ssam	return NULL;
461190391Ssam}
462190391Ssam
463190579Ssamstatic void
464190579Ssamff_transmit(struct ieee80211_node *ni, struct mbuf *m)
465190579Ssam{
466190579Ssam	struct ieee80211vap *vap = ni->ni_vap;
467248069Sadrian	struct ieee80211com *ic = ni->ni_ic;
468190579Ssam	int error;
469190579Ssam
470248069Sadrian	IEEE80211_TX_LOCK_ASSERT(vap->iv_ic);
471248069Sadrian
472190579Ssam	/* encap and xmit */
473190579Ssam	m = ieee80211_encap(vap, ni, m);
474190579Ssam	if (m != NULL) {
475190579Ssam		struct ifnet *ifp = vap->iv_ifp;
476190579Ssam
477254082Sadrian		error = ieee80211_parent_xmitpkt(ic, m);;
478190579Ssam		if (error != 0) {
479190579Ssam			/* NB: IFQ_HANDOFF reclaims mbuf */
480190579Ssam			ieee80211_free_node(ni);
481190579Ssam		} else {
482190579Ssam			ifp->if_opackets++;
483190579Ssam		}
484190579Ssam	} else
485190579Ssam		ieee80211_free_node(ni);
486190579Ssam}
487190579Ssam
488190391Ssam/*
489190579Ssam * Flush frames to device; note we re-use the linked list
490190579Ssam * the frames were stored on and use the sentinel (unchanged)
491190579Ssam * which may be non-NULL.
492190579Ssam */
493190579Ssamstatic void
494190579Ssamff_flush(struct mbuf *head, struct mbuf *last)
495190579Ssam{
496190579Ssam	struct mbuf *m, *next;
497190579Ssam	struct ieee80211_node *ni;
498190579Ssam	struct ieee80211vap *vap;
499190579Ssam
500190579Ssam	for (m = head; m != last; m = next) {
501190579Ssam		next = m->m_nextpkt;
502190579Ssam		m->m_nextpkt = NULL;
503190579Ssam
504190579Ssam		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
505190579Ssam		vap = ni->ni_vap;
506190579Ssam
507190579Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
508190579Ssam		    "%s: flush frame, age %u", __func__, M_AGE_GET(m));
509190579Ssam		vap->iv_stats.is_ff_flush++;
510190579Ssam
511190579Ssam		ff_transmit(ni, m);
512190579Ssam	}
513190579Ssam}
514190579Ssam
515190579Ssam/*
516190579Ssam * Age frames on the staging queue.
517244044Sadrian *
518244044Sadrian * This is called without the comlock held, but it does all its work
519244044Sadrian * behind the comlock.  Because of this, it's possible that the
520244044Sadrian * staging queue will be serviced between the function which called
521244044Sadrian * it and now; thus simply checking that the queue has work in it
522244044Sadrian * may fail.
523244044Sadrian *
524244044Sadrian * See PR kern/174283 for more details.
525190579Ssam */
526190579Ssamvoid
527191753Ssamieee80211_ff_age(struct ieee80211com *ic, struct ieee80211_stageq *sq,
528191753Ssam    int quanta)
529190579Ssam{
530190579Ssam	struct mbuf *m, *head;
531190579Ssam	struct ieee80211_node *ni;
532190579Ssam	struct ieee80211_tx_ampdu *tap;
533190579Ssam
534244044Sadrian#if 0
535190579Ssam	KASSERT(sq->head != NULL, ("stageq empty"));
536244044Sadrian#endif
537190579Ssam
538190579Ssam	IEEE80211_LOCK(ic);
539190579Ssam	head = sq->head;
540190579Ssam	while ((m = sq->head) != NULL && M_AGE_GET(m) < quanta) {
541234324Sadrian		int tid = WME_AC_TO_TID(M_WME_GETAC(m));
542234324Sadrian
543190579Ssam		/* clear tap ref to frame */
544190579Ssam		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
545234324Sadrian		tap = &ni->ni_tx_ampdu[tid];
546190579Ssam		KASSERT(tap->txa_private == m, ("staging queue empty"));
547190579Ssam		tap->txa_private = NULL;
548190579Ssam
549190579Ssam		sq->head = m->m_nextpkt;
550190579Ssam		sq->depth--;
551190579Ssam	}
552190579Ssam	if (m == NULL)
553190579Ssam		sq->tail = NULL;
554190579Ssam	else
555190579Ssam		M_AGE_SUB(m, quanta);
556190579Ssam	IEEE80211_UNLOCK(ic);
557190579Ssam
558248069Sadrian	IEEE80211_TX_LOCK(ic);
559190579Ssam	ff_flush(head, m);
560248069Sadrian	IEEE80211_TX_UNLOCK(ic);
561190579Ssam}
562190579Ssam
563190579Ssamstatic void
564244051Sadrianstageq_add(struct ieee80211com *ic, struct ieee80211_stageq *sq, struct mbuf *m)
565190579Ssam{
566190579Ssam	int age = ieee80211_ffagemax;
567244051Sadrian
568244051Sadrian	IEEE80211_LOCK_ASSERT(ic);
569244051Sadrian
570190579Ssam	if (sq->tail != NULL) {
571190579Ssam		sq->tail->m_nextpkt = m;
572190579Ssam		age -= M_AGE_GET(sq->head);
573190579Ssam	} else
574190579Ssam		sq->head = m;
575190579Ssam	KASSERT(age >= 0, ("age %d", age));
576190579Ssam	M_AGE_SET(m, age);
577190579Ssam	m->m_nextpkt = NULL;
578190579Ssam	sq->tail = m;
579190579Ssam	sq->depth++;
580190579Ssam}
581190579Ssam
582190579Ssamstatic void
583244051Sadrianstageq_remove(struct ieee80211com *ic, struct ieee80211_stageq *sq, struct mbuf *mstaged)
584190579Ssam{
585190579Ssam	struct mbuf *m, *mprev;
586190579Ssam
587244051Sadrian	IEEE80211_LOCK_ASSERT(ic);
588244051Sadrian
589190579Ssam	mprev = NULL;
590190579Ssam	for (m = sq->head; m != NULL; m = m->m_nextpkt) {
591190579Ssam		if (m == mstaged) {
592190579Ssam			if (mprev == NULL)
593190579Ssam				sq->head = m->m_nextpkt;
594190579Ssam			else
595190579Ssam				mprev->m_nextpkt = m->m_nextpkt;
596190579Ssam			if (sq->tail == m)
597190579Ssam				sq->tail = mprev;
598190579Ssam			sq->depth--;
599190579Ssam			return;
600190579Ssam		}
601190579Ssam		mprev = m;
602190579Ssam	}
603190579Ssam	printf("%s: packet not found\n", __func__);
604190579Ssam}
605190579Ssam
606190579Ssamstatic uint32_t
607190579Ssamff_approx_txtime(struct ieee80211_node *ni,
608190579Ssam	const struct mbuf *m1, const struct mbuf *m2)
609190579Ssam{
610190579Ssam	struct ieee80211com *ic = ni->ni_ic;
611190579Ssam	struct ieee80211vap *vap = ni->ni_vap;
612190579Ssam	uint32_t framelen;
613190579Ssam
614190579Ssam	/*
615190579Ssam	 * Approximate the frame length to be transmitted. A swag to add
616190579Ssam	 * the following maximal values to the skb payload:
617190579Ssam	 *   - 32: 802.11 encap + CRC
618190579Ssam	 *   - 24: encryption overhead (if wep bit)
619190579Ssam	 *   - 4 + 6: fast-frame header and padding
620190579Ssam	 *   - 16: 2 LLC FF tunnel headers
621190579Ssam	 *   - 14: 1 802.3 FF tunnel header (mbuf already accounts for 2nd)
622190579Ssam	 */
623190579Ssam	framelen = m1->m_pkthdr.len + 32 +
624190579Ssam	    ATH_FF_MAX_HDR_PAD + ATH_FF_MAX_SEP_PAD + ATH_FF_MAX_HDR;
625190579Ssam	if (vap->iv_flags & IEEE80211_F_PRIVACY)
626190579Ssam		framelen += 24;
627190579Ssam	if (m2 != NULL)
628190579Ssam		framelen += m2->m_pkthdr.len;
629190579Ssam	return ieee80211_compute_duration(ic->ic_rt, framelen, ni->ni_txrate, 0);
630190579Ssam}
631190579Ssam
632190579Ssam/*
633190579Ssam * Check if the supplied frame can be partnered with an existing
634190579Ssam * or pending frame.  Return a reference to any frame that should be
635190579Ssam * sent on return; otherwise return NULL.
636190579Ssam */
637190579Ssamstruct mbuf *
638190579Ssamieee80211_ff_check(struct ieee80211_node *ni, struct mbuf *m)
639190579Ssam{
640190579Ssam	struct ieee80211vap *vap = ni->ni_vap;
641190579Ssam	struct ieee80211com *ic = ni->ni_ic;
642191753Ssam	struct ieee80211_superg *sg = ic->ic_superg;
643190579Ssam	const int pri = M_WME_GETAC(m);
644190579Ssam	struct ieee80211_stageq *sq;
645190579Ssam	struct ieee80211_tx_ampdu *tap;
646190579Ssam	struct mbuf *mstaged;
647190579Ssam	uint32_t txtime, limit;
648190579Ssam
649248069Sadrian	IEEE80211_TX_UNLOCK_ASSERT(ic);
650248069Sadrian
651190579Ssam	/*
652190579Ssam	 * Check if the supplied frame can be aggregated.
653190579Ssam	 *
654190579Ssam	 * NB: we allow EAPOL frames to be aggregated with other ucast traffic.
655190579Ssam	 *     Do 802.1x EAPOL frames proceed in the clear? Then they couldn't
656190579Ssam	 *     be aggregated with other types of frames when encryption is on?
657190579Ssam	 */
658190579Ssam	IEEE80211_LOCK(ic);
659234324Sadrian	tap = &ni->ni_tx_ampdu[WME_AC_TO_TID(pri)];
660190579Ssam	mstaged = tap->txa_private;		/* NB: we reuse AMPDU state */
661190579Ssam	ieee80211_txampdu_count_packet(tap);
662190579Ssam
663190579Ssam	/*
664190579Ssam	 * When not in station mode never aggregate a multicast
665190579Ssam	 * frame; this insures, for example, that a combined frame
666190579Ssam	 * does not require multiple encryption keys.
667190579Ssam	 */
668190579Ssam	if (vap->iv_opmode != IEEE80211_M_STA &&
669190579Ssam	    ETHER_IS_MULTICAST(mtod(m, struct ether_header *)->ether_dhost)) {
670190579Ssam		/* XXX flush staged frame? */
671190579Ssam		IEEE80211_UNLOCK(ic);
672190579Ssam		return m;
673190579Ssam	}
674190579Ssam	/*
675190579Ssam	 * If there is no frame to combine with and the pps is
676190579Ssam	 * too low; then do not attempt to aggregate this frame.
677190579Ssam	 */
678190579Ssam	if (mstaged == NULL &&
679190579Ssam	    ieee80211_txampdu_getpps(tap) < ieee80211_ffppsmin) {
680190579Ssam		IEEE80211_UNLOCK(ic);
681190579Ssam		return m;
682190579Ssam	}
683191753Ssam	sq = &sg->ff_stageq[pri];
684190579Ssam	/*
685190579Ssam	 * Check the txop limit to insure the aggregate fits.
686190579Ssam	 */
687190579Ssam	limit = IEEE80211_TXOP_TO_US(
688190579Ssam		ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit);
689190579Ssam	if (limit != 0 &&
690190579Ssam	    (txtime = ff_approx_txtime(ni, m, mstaged)) > limit) {
691190579Ssam		/*
692190579Ssam		 * Aggregate too long, return to the caller for direct
693190579Ssam		 * transmission.  In addition, flush any pending frame
694190579Ssam		 * before sending this one.
695190579Ssam		 */
696190579Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
697190579Ssam		    "%s: txtime %u exceeds txop limit %u\n",
698190579Ssam		    __func__, txtime, limit);
699190579Ssam
700190579Ssam		tap->txa_private = NULL;
701190579Ssam		if (mstaged != NULL)
702244051Sadrian			stageq_remove(ic, sq, mstaged);
703190579Ssam		IEEE80211_UNLOCK(ic);
704190579Ssam
705190579Ssam		if (mstaged != NULL) {
706248069Sadrian			IEEE80211_TX_LOCK(ic);
707190579Ssam			IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
708190579Ssam			    "%s: flush staged frame", __func__);
709190579Ssam			/* encap and xmit */
710190579Ssam			ff_transmit(ni, mstaged);
711248069Sadrian			IEEE80211_TX_UNLOCK(ic);
712190579Ssam		}
713190579Ssam		return m;		/* NB: original frame */
714190579Ssam	}
715190579Ssam	/*
716190579Ssam	 * An aggregation candidate.  If there's a frame to partner
717190579Ssam	 * with then combine and return for processing.  Otherwise
718190579Ssam	 * save this frame and wait for a partner to show up (or
719190579Ssam	 * the frame to be flushed).  Note that staged frames also
720190579Ssam	 * hold their node reference.
721190579Ssam	 */
722190579Ssam	if (mstaged != NULL) {
723190579Ssam		tap->txa_private = NULL;
724244051Sadrian		stageq_remove(ic, sq, mstaged);
725190579Ssam		IEEE80211_UNLOCK(ic);
726190579Ssam
727190579Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
728190579Ssam		    "%s: aggregate fast-frame", __func__);
729190579Ssam		/*
730190579Ssam		 * Release the node reference; we only need
731190579Ssam		 * the one already in mstaged.
732190579Ssam		 */
733190579Ssam		KASSERT(mstaged->m_pkthdr.rcvif == (void *)ni,
734190579Ssam		    ("rcvif %p ni %p", mstaged->m_pkthdr.rcvif, ni));
735190579Ssam		ieee80211_free_node(ni);
736190579Ssam
737190579Ssam		m->m_nextpkt = NULL;
738190579Ssam		mstaged->m_nextpkt = m;
739190579Ssam		mstaged->m_flags |= M_FF; /* NB: mark for encap work */
740190579Ssam	} else {
741190579Ssam		KASSERT(tap->txa_private == NULL,
742190579Ssam		    ("txa_private %p", tap->txa_private));
743190579Ssam		tap->txa_private = m;
744190579Ssam
745244051Sadrian		stageq_add(ic, sq, m);
746190579Ssam		IEEE80211_UNLOCK(ic);
747190579Ssam
748190579Ssam		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
749190579Ssam		    "%s: stage frame, %u queued", __func__, sq->depth);
750190579Ssam		/* NB: mstaged is NULL */
751190579Ssam	}
752190579Ssam	return mstaged;
753190579Ssam}
754190579Ssam
755190579Ssamvoid
756190579Ssamieee80211_ff_node_init(struct ieee80211_node *ni)
757190579Ssam{
758190579Ssam	/*
759190579Ssam	 * Clean FF state on re-associate.  This handles the case
760190579Ssam	 * where a station leaves w/o notifying us and then returns
761190579Ssam	 * before node is reaped for inactivity.
762190579Ssam	 */
763190579Ssam	ieee80211_ff_node_cleanup(ni);
764190579Ssam}
765190579Ssam
766190579Ssamvoid
767190579Ssamieee80211_ff_node_cleanup(struct ieee80211_node *ni)
768190579Ssam{
769190579Ssam	struct ieee80211com *ic = ni->ni_ic;
770191753Ssam	struct ieee80211_superg *sg = ic->ic_superg;
771190579Ssam	struct ieee80211_tx_ampdu *tap;
772244025Sadrian	struct mbuf *m, *next_m, *head;
773234324Sadrian	int tid;
774190579Ssam
775190579Ssam	IEEE80211_LOCK(ic);
776190579Ssam	head = NULL;
777234324Sadrian	for (tid = 0; tid < WME_NUM_TID; tid++) {
778234324Sadrian		int ac = TID_TO_WME_AC(tid);
779234324Sadrian
780234324Sadrian		tap = &ni->ni_tx_ampdu[tid];
781190579Ssam		m = tap->txa_private;
782190579Ssam		if (m != NULL) {
783190579Ssam			tap->txa_private = NULL;
784244051Sadrian			stageq_remove(ic, &sg->ff_stageq[ac], m);
785190579Ssam			m->m_nextpkt = head;
786190579Ssam			head = m;
787190579Ssam		}
788190579Ssam	}
789190579Ssam	IEEE80211_UNLOCK(ic);
790190579Ssam
791244025Sadrian	/*
792244025Sadrian	 * Free mbufs, taking care to not dereference the mbuf after
793244025Sadrian	 * we free it (hence grabbing m_nextpkt before we free it.)
794244025Sadrian	 */
795244025Sadrian	m = head;
796244025Sadrian	while (m != NULL) {
797244025Sadrian		next_m = m->m_nextpkt;
798190579Ssam		m_freem(m);
799190579Ssam		ieee80211_free_node(ni);
800244025Sadrian		m = next_m;
801190579Ssam	}
802190579Ssam}
803190579Ssam
804190579Ssam/*
805190391Ssam * Switch between turbo and non-turbo operating modes.
806190391Ssam * Use the specified channel flags to locate the new
807190391Ssam * channel, update 802.11 state, and then call back into
808190391Ssam * the driver to effect the change.
809190391Ssam */
810190391Ssamvoid
811190391Ssamieee80211_dturbo_switch(struct ieee80211vap *vap, int newflags)
812190391Ssam{
813190391Ssam	struct ieee80211com *ic = vap->iv_ic;
814190391Ssam	struct ieee80211_channel *chan;
815190391Ssam
816190391Ssam	chan = ieee80211_find_channel(ic, ic->ic_bsschan->ic_freq, newflags);
817190391Ssam	if (chan == NULL) {		/* XXX should not happen */
818190391Ssam		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
819190391Ssam		    "%s: no channel with freq %u flags 0x%x\n",
820190391Ssam		    __func__, ic->ic_bsschan->ic_freq, newflags);
821190391Ssam		return;
822190391Ssam	}
823190391Ssam
824190391Ssam	IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG,
825190391Ssam	    "%s: %s -> %s (freq %u flags 0x%x)\n", __func__,
826190391Ssam	    ieee80211_phymode_name[ieee80211_chan2mode(ic->ic_bsschan)],
827190391Ssam	    ieee80211_phymode_name[ieee80211_chan2mode(chan)],
828190391Ssam	    chan->ic_freq, chan->ic_flags);
829190391Ssam
830190391Ssam	ic->ic_bsschan = chan;
831190391Ssam	ic->ic_prevchan = ic->ic_curchan;
832190391Ssam	ic->ic_curchan = chan;
833190532Ssam	ic->ic_rt = ieee80211_get_ratetable(chan);
834190391Ssam	ic->ic_set_channel(ic);
835192468Ssam	ieee80211_radiotap_chan_change(ic);
836190391Ssam	/* NB: do not need to reset ERP state 'cuz we're in sta mode */
837190391Ssam}
838190391Ssam
839190391Ssam/*
840190391Ssam * Return the current ``state'' of an Atheros capbility.
841190391Ssam * If associated in station mode report the negotiated
842190391Ssam * setting. Otherwise report the current setting.
843190391Ssam */
844190391Ssamstatic int
845190391Ssamgetathcap(struct ieee80211vap *vap, int cap)
846190391Ssam{
847190391Ssam	if (vap->iv_opmode == IEEE80211_M_STA &&
848190391Ssam	    vap->iv_state == IEEE80211_S_RUN)
849190391Ssam		return IEEE80211_ATH_CAP(vap, vap->iv_bss, cap) != 0;
850190391Ssam	else
851190391Ssam		return (vap->iv_flags & cap) != 0;
852190391Ssam}
853190391Ssam
854190391Ssamstatic int
855190391Ssamsuperg_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
856190391Ssam{
857190391Ssam	switch (ireq->i_type) {
858190391Ssam	case IEEE80211_IOC_FF:
859190391Ssam		ireq->i_val = getathcap(vap, IEEE80211_F_FF);
860190391Ssam		break;
861190391Ssam	case IEEE80211_IOC_TURBOP:
862190391Ssam		ireq->i_val = getathcap(vap, IEEE80211_F_TURBOP);
863190391Ssam		break;
864190391Ssam	default:
865190391Ssam		return ENOSYS;
866190391Ssam	}
867190391Ssam	return 0;
868190391Ssam}
869190391SsamIEEE80211_IOCTL_GET(superg, superg_ioctl_get80211);
870190391Ssam
871190391Ssamstatic int
872190391Ssamsuperg_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
873190391Ssam{
874190391Ssam	switch (ireq->i_type) {
875190391Ssam	case IEEE80211_IOC_FF:
876190391Ssam		if (ireq->i_val) {
877190391Ssam			if ((vap->iv_caps & IEEE80211_C_FF) == 0)
878190391Ssam				return EOPNOTSUPP;
879190391Ssam			vap->iv_flags |= IEEE80211_F_FF;
880190391Ssam		} else
881190391Ssam			vap->iv_flags &= ~IEEE80211_F_FF;
882190530Ssam		return ENETRESET;
883190391Ssam	case IEEE80211_IOC_TURBOP:
884190391Ssam		if (ireq->i_val) {
885190391Ssam			if ((vap->iv_caps & IEEE80211_C_TURBOP) == 0)
886190391Ssam				return EOPNOTSUPP;
887190391Ssam			vap->iv_flags |= IEEE80211_F_TURBOP;
888190391Ssam		} else
889190391Ssam			vap->iv_flags &= ~IEEE80211_F_TURBOP;
890190391Ssam		return ENETRESET;
891190391Ssam	default:
892190391Ssam		return ENOSYS;
893190391Ssam	}
894190391Ssam	return 0;
895190391Ssam}
896190391SsamIEEE80211_IOCTL_SET(superg, superg_ioctl_set80211);
897246226Sadrian
898246226Sadrian#endif	/* IEEE80211_SUPPORT_SUPERG */
899