1190391Ssam/*- 2190391Ssam * Copyright (c) 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 * $FreeBSD$ 26190391Ssam */ 27190391Ssam#ifndef _NET80211_IEEE80211_SUPERG_H_ 28190391Ssam#define _NET80211_IEEE80211_SUPERG_H_ 29190391Ssam 30190391Ssam/* 31190391Ssam * Atheros' 802.11 SuperG protocol support. 32190391Ssam */ 33190391Ssam 34190455Ssam/* 35190455Ssam * Atheros advanced capability information element. 36190455Ssam */ 37190455Ssamstruct ieee80211_ath_ie { 38190455Ssam uint8_t ath_id; /* IEEE80211_ELEMID_VENDOR */ 39190455Ssam uint8_t ath_len; /* length in bytes */ 40190455Ssam uint8_t ath_oui[3]; /* ATH_OUI */ 41190455Ssam uint8_t ath_oui_type; /* ATH_OUI_TYPE */ 42190455Ssam uint8_t ath_oui_subtype; /* ATH_OUI_SUBTYPE */ 43190455Ssam uint8_t ath_version; /* spec revision */ 44190455Ssam uint8_t ath_capability; /* capability info */ 45190455Ssam#define ATHEROS_CAP_TURBO_PRIME 0x01 /* dynamic turbo--aka Turbo' */ 46190455Ssam#define ATHEROS_CAP_COMPRESSION 0x02 /* data compression */ 47190455Ssam#define ATHEROS_CAP_FAST_FRAME 0x04 /* fast (jumbo) frames */ 48190455Ssam#define ATHEROS_CAP_XR 0x08 /* Xtended Range support */ 49190455Ssam#define ATHEROS_CAP_AR 0x10 /* Advanded Radar support */ 50190455Ssam#define ATHEROS_CAP_BURST 0x20 /* Bursting - not negotiated */ 51190455Ssam#define ATHEROS_CAP_WME 0x40 /* CWMin tuning */ 52190455Ssam#define ATHEROS_CAP_BOOST 0x80 /* use turbo/!turbo mode */ 53190455Ssam uint8_t ath_defkeyix[2]; 54190455Ssam} __packed; 55190455Ssam 56190455Ssam#define ATH_OUI_VERSION 0x00 57190455Ssam#define ATH_OUI_SUBTYPE 0x01 58190455Ssam 59190455Ssam#ifdef _KERNEL 60191753Ssamstruct ieee80211_stageq { 61191753Ssam struct mbuf *head; /* frames linked w/ m_nextpkt */ 62191753Ssam struct mbuf *tail; /* last frame in queue */ 63191753Ssam int depth; /* # items on head */ 64191753Ssam}; 65191753Ssam 66191753Ssamstruct ieee80211_superg { 67191753Ssam /* fast-frames staging q */ 68191753Ssam struct ieee80211_stageq ff_stageq[WME_NUM_AC]; 69191753Ssam}; 70191753Ssam 71190391Ssamvoid ieee80211_superg_attach(struct ieee80211com *); 72190391Ssamvoid ieee80211_superg_detach(struct ieee80211com *); 73190391Ssamvoid ieee80211_superg_vattach(struct ieee80211vap *); 74190391Ssamvoid ieee80211_superg_vdetach(struct ieee80211vap *); 75190391Ssam 76190451Ssamuint8_t *ieee80211_add_ath(uint8_t *, uint8_t, ieee80211_keyix); 77190451Ssamuint8_t *ieee80211_add_athcaps(uint8_t *, const struct ieee80211_node *); 78190391Ssamvoid ieee80211_parse_ath(struct ieee80211_node *, uint8_t *); 79190391Ssamint ieee80211_parse_athparams(struct ieee80211_node *, uint8_t *, 80190391Ssam const struct ieee80211_frame *); 81190391Ssam 82190579Ssamvoid ieee80211_ff_node_init(struct ieee80211_node *); 83190579Ssamvoid ieee80211_ff_node_cleanup(struct ieee80211_node *); 84190579Ssam 85297603Sadrianstatic inline int 86297603Sadrianieee80211_amsdu_tx_ok(struct ieee80211_node *ni) 87297603Sadrian{ 88297603Sadrian 89297603Sadrian /* First: software A-MSDU transmit? */ 90297603Sadrian if ((ni->ni_ic->ic_caps & IEEE80211_C_SWAMSDUTX) == 0) 91297603Sadrian return (0); 92297603Sadrian 93297603Sadrian /* Next: does the VAP have AMSDU TX enabled? */ 94297603Sadrian if ((ni->ni_vap->iv_flags_ht & IEEE80211_FHT_AMSDU_TX) == 0) 95297603Sadrian return (0); 96297603Sadrian 97297603Sadrian /* Next: 11n node? (assumed that A-MSDU TX to HT nodes is ok */ 98297603Sadrian if ((ni->ni_flags & IEEE80211_NODE_HT) == 0) 99297603Sadrian return (0); 100297603Sadrian 101297603Sadrian /* ok, we can at least /do/ AMSDU to this node */ 102297603Sadrian return (1); 103297603Sadrian} 104297603Sadrian 105297603Sadrianstruct mbuf * ieee80211_amsdu_check(struct ieee80211_node *ni, struct mbuf *m); 106190579Ssamstruct mbuf *ieee80211_ff_check(struct ieee80211_node *, struct mbuf *); 107191753Ssamvoid ieee80211_ff_age(struct ieee80211com *, struct ieee80211_stageq *, 108191753Ssam int quanta); 109190579Ssam 110190579Ssamstatic __inline void 111302283Savosieee80211_ff_age_all(struct ieee80211com *ic, int quanta) 112190579Ssam{ 113191753Ssam struct ieee80211_superg *sg = ic->ic_superg; 114191753Ssam 115302283Savos if (sg != NULL) { 116302283Savos ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VO], quanta); 117302283Savos ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VI], quanta); 118302283Savos ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BE], quanta); 119302283Savos ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BK], quanta); 120302283Savos } 121190579Ssam} 122190579Ssam 123190579Ssamstatic __inline void 124302283Savosieee80211_ff_flush(struct ieee80211com *ic, int ac) 125190579Ssam{ 126191753Ssam struct ieee80211_superg *sg = ic->ic_superg; 127191753Ssam 128302283Savos if (sg != NULL) 129302283Savos ieee80211_ff_age(ic, &sg->ff_stageq[ac], 0x7fffffff); 130190579Ssam} 131190579Ssam 132302283Savosstatic __inline void 133302283Savosieee80211_ff_flush_all(struct ieee80211com *ic) 134302283Savos{ 135302283Savos ieee80211_ff_age_all(ic, 0x7fffffff); 136302283Savos} 137302283Savos 138190391Ssamstruct mbuf *ieee80211_ff_encap(struct ieee80211vap *, struct mbuf *, 139190391Ssam int, struct ieee80211_key *); 140297603Sadrianstruct mbuf * ieee80211_amsdu_encap(struct ieee80211vap *vap, struct mbuf *m1, 141297603Sadrian int hdrspace, struct ieee80211_key *key); 142190391Ssam 143190391Ssamstruct mbuf *ieee80211_ff_decap(struct ieee80211_node *, struct mbuf *); 144190391Ssam 145190391Ssamstatic __inline struct mbuf * 146190391Ssamieee80211_decap_fastframe(struct ieee80211vap *vap, struct ieee80211_node *ni, 147190391Ssam struct mbuf *m) 148190391Ssam{ 149190391Ssam return IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF) ? 150190391Ssam ieee80211_ff_decap(ni, m) : m; 151190391Ssam} 152190455Ssam#endif /* _KERNEL */ 153190391Ssam#endif /* _NET80211_IEEE80211_SUPERG_H_ */ 154