diff options
author | sam <sam@FreeBSD.org> | 2009-03-24 20:39:08 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2009-03-24 20:39:08 +0000 |
commit | 88b91b235f5ae6e04f407012ae5eb0da3d64facc (patch) | |
tree | 082efe3e253ba758a9687229364efee996a6bfae /sys/net80211/ieee80211_output.c | |
parent | ff1a464cfe436346fa187a3148a6067339e4cd2b (diff) | |
download | FreeBSD-src-88b91b235f5ae6e04f407012ae5eb0da3d64facc.zip FreeBSD-src-88b91b235f5ae6e04f407012ae5eb0da3d64facc.tar.gz |
split Atheros SuperG support out into it's own file that's included only
with a new IEEE80211_SUPPORT_SUPERG option
Diffstat (limited to 'sys/net80211/ieee80211_output.c')
-rw-r--r-- | sys/net80211/ieee80211_output.c | 237 |
1 files changed, 26 insertions, 211 deletions
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index 66b8c94..1e5788b 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -47,6 +47,9 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_regdomain.h> +#ifdef IEEE80211_SUPPORT_SUPERG +#include <net80211/ieee80211_superg.h> +#endif #ifdef IEEE80211_SUPPORT_TDMA #include <net80211/ieee80211_tdma.h> #endif @@ -62,9 +65,6 @@ __FBSDID("$FreeBSD$"); #define ETHER_HEADER_COPY(dst, src) \ memcpy(dst, src, sizeof(struct ether_header)) -static struct mbuf *ieee80211_encap_fastframe(struct ieee80211vap *, - struct mbuf *m1, const struct ether_header *eh1, - struct mbuf *m2, const struct ether_header *eh2); static int ieee80211_fragment(struct ieee80211vap *, struct mbuf *, u_int hdrsize, u_int ciphdrsize, u_int mtu); static void ieee80211_tx_mgt_cb(struct ieee80211_node *, void *, int); @@ -731,7 +731,7 @@ done: * Drivers and cipher modules assume we have done the necessary work * and fail rudely if they don't find the space they need. */ -static struct mbuf * +struct mbuf * ieee80211_mbuf_adjust(struct ieee80211vap *vap, int hdrsize, struct ieee80211_key *key, struct mbuf *m) { @@ -861,7 +861,7 @@ ieee80211_encap(struct ieee80211_node *ni, struct mbuf *m) struct ieee80211_frame *wh; struct ieee80211_key *key; struct llc *llc; - int hdrsize, hdrspace, datalen, addqos, txfrag, isff, is4addr; + int hdrsize, hdrspace, datalen, addqos, txfrag, is4addr; /* * Copy existing Ethernet header to a safe place. The @@ -935,56 +935,7 @@ ieee80211_encap(struct ieee80211_node *ni, struct mbuf *m) else hdrspace = hdrsize; - if ((isff = m->m_flags & M_FF) != 0) { - struct mbuf *m2; - struct ether_header eh2; - - /* - * Fast frame encapsulation. There must be two packets - * chained with m_nextpkt. We do header adjustment for - * each, add the tunnel encapsulation, and then concatenate - * the mbuf chains to form a single frame for transmission. - */ - m2 = m->m_nextpkt; - if (m2 == NULL) { - IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, - "%s: only one frame\n", __func__); - goto bad; - } - m->m_nextpkt = NULL; - /* - * Include fast frame headers in adjusting header - * layout; this allocates space according to what - * ieee80211_encap_fastframe will do. - */ - m = ieee80211_mbuf_adjust(vap, - hdrspace + sizeof(struct llc) + sizeof(uint32_t) + 2 + - sizeof(struct ether_header), - key, m); - if (m == NULL) { - /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ - m_freem(m2); - goto bad; - } - /* - * Copy second frame's Ethernet header out of line - * and adjust for encapsulation headers. Note that - * we make room for padding in case there isn't room - * at the end of first frame. - */ - KASSERT(m2->m_len >= sizeof(eh2), ("no ethernet header!")); - ETHER_HEADER_COPY(&eh2, mtod(m2, caddr_t)); - m2 = ieee80211_mbuf_adjust(vap, - ATH_FF_MAX_HDR_PAD + sizeof(struct ether_header), - NULL, m2); - if (m2 == NULL) { - /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ - goto bad; - } - m = ieee80211_encap_fastframe(vap, m, &eh, m2, &eh2); - if (m == NULL) - goto bad; - } else { + if (__predict_true((m->m_flags & M_FF) == 0)) { /* * Normal frame. */ @@ -1002,6 +953,12 @@ ieee80211_encap(struct ieee80211_node *ni, struct mbuf *m) llc->llc_snap.org_code[1] = 0; llc->llc_snap.org_code[2] = 0; llc->llc_snap.ether_type = eh.ether_type; + } else { +#ifdef IEEE80211_SUPPORT_SUPERG + m = ieee80211_ff_encap(vap, m, hdrspace, key); + if (m == NULL) +#endif + goto bad; } datalen = m->m_pkthdr.len; /* NB: w/o 802.11 header */ @@ -1047,7 +1004,7 @@ ieee80211_encap(struct ieee80211_node *ni, struct mbuf *m) case IEEE80211_M_WDS: /* NB: is4addr should always be true */ goto bad; } - if (m->m_flags & M_MORE_DATA) + if (m->m_flags & M_MORE_DATA) wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; if (addqos) { uint8_t *qos; @@ -1128,7 +1085,7 @@ ieee80211_encap(struct ieee80211_node *ni, struct mbuf *m) txfrag = (m->m_pkthdr.len > vap->iv_fragthreshold && !IEEE80211_IS_MULTICAST(wh->i_addr1) && (vap->iv_caps & IEEE80211_C_TXFRAG) && - !isff); /* NB: don't fragment ff's */ + (m->m_flags & M_FF) == 0); /* NB: don't fragment ff's */ if (key != NULL) { /* * IEEE 802.1X: send EAPOL frames always in the clear. @@ -1175,135 +1132,6 @@ bad: } /* - * Do Ethernet-LLC encapsulation for each payload in a fast frame - * tunnel encapsulation. The frame is assumed to have an Ethernet - * header at the front that must be stripped before prepending the - * LLC followed by the Ethernet header passed in (with an Ethernet - * type that specifies the payload size). - */ -static struct mbuf * -ieee80211_encap1(struct ieee80211vap *vap, struct mbuf *m, - const struct ether_header *eh) -{ - struct llc *llc; - uint16_t payload; - - /* XXX optimize by combining m_adj+M_PREPEND */ - m_adj(m, sizeof(struct ether_header) - sizeof(struct llc)); - llc = mtod(m, struct llc *); - llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; - llc->llc_control = LLC_UI; - llc->llc_snap.org_code[0] = 0; - llc->llc_snap.org_code[1] = 0; - llc->llc_snap.org_code[2] = 0; - llc->llc_snap.ether_type = eh->ether_type; - payload = m->m_pkthdr.len; /* NB: w/o Ethernet header */ - - M_PREPEND(m, sizeof(struct ether_header), M_DONTWAIT); - if (m == NULL) { /* XXX cannot happen */ - IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, - "%s: no space for ether_header\n", __func__); - vap->iv_stats.is_tx_nobuf++; - return NULL; - } - ETHER_HEADER_COPY(mtod(m, void *), eh); - mtod(m, struct ether_header *)->ether_type = htons(payload); - return m; -} - -/* - * Do fast frame tunnel encapsulation. The two frames and - * Ethernet headers are supplied. The caller is assumed to - * have arrange for space in the mbuf chains for encapsulating - * headers (to avoid major mbuf fragmentation). - * - * The encapsulated frame is returned or NULL if there is a - * problem (should not happen). - */ -static struct mbuf * -ieee80211_encap_fastframe(struct ieee80211vap *vap, - struct mbuf *m1, const struct ether_header *eh1, - struct mbuf *m2, const struct ether_header *eh2) -{ - struct llc *llc; - struct mbuf *m; - int pad; - - /* - * First, each frame gets a standard encapsulation. - */ - m1 = ieee80211_encap1(vap, m1, eh1); - if (m1 == NULL) { - m_freem(m2); - return NULL; - } - m2 = ieee80211_encap1(vap, m2, eh2); - if (m2 == NULL) { - m_freem(m1); - return NULL; - } - - /* - * Pad leading frame to a 4-byte boundary. If there - * is space at the end of the first frame, put it - * there; otherwise prepend to the front of the second - * frame. We know doing the second will always work - * because we reserve space above. We prefer appending - * as this typically has better DMA alignment properties. - */ - for (m = m1; m->m_next != NULL; m = m->m_next) - ; - pad = roundup2(m1->m_pkthdr.len, 4) - m1->m_pkthdr.len; - if (pad) { - if (M_TRAILINGSPACE(m) < pad) { /* prepend to second */ - m2->m_data -= pad; - m2->m_len += pad; - m2->m_pkthdr.len += pad; - } else { /* append to first */ - m->m_len += pad; - m1->m_pkthdr.len += pad; - } - } - - /* - * Now, stick 'em together and prepend the tunnel headers; - * first the Atheros tunnel header (all zero for now) and - * then a special fast frame LLC. - * - * XXX optimize by prepending together - */ - m->m_next = m2; /* NB: last mbuf from above */ - m1->m_pkthdr.len += m2->m_pkthdr.len; - M_PREPEND(m1, sizeof(uint32_t)+2, M_DONTWAIT); - if (m1 == NULL) { /* XXX cannot happen */ - IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, - "%s: no space for tunnel header\n", __func__); - vap->iv_stats.is_tx_nobuf++; - return NULL; - } - memset(mtod(m1, void *), 0, sizeof(uint32_t)+2); - - M_PREPEND(m1, sizeof(struct llc), M_DONTWAIT); - if (m1 == NULL) { /* XXX cannot happen */ - IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, - "%s: no space for llc header\n", __func__); - vap->iv_stats.is_tx_nobuf++; - return NULL; - } - llc = mtod(m1, struct llc *); - llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; - llc->llc_control = LLC_UI; - llc->llc_snap.org_code[0] = ATH_FF_SNAP_ORGCODE_0; - llc->llc_snap.org_code[1] = ATH_FF_SNAP_ORGCODE_1; - llc->llc_snap.org_code[2] = ATH_FF_SNAP_ORGCODE_2; - llc->llc_snap.ether_type = htons(ATH_FF_ETH_TYPE); - - vap->iv_stats.is_ff_encap++; - - return m1; -} - -/* * Fragment the frame according to the specified mtu. * The size of the 802.11 header (w/o padding) is provided * so we don't need to recalculate it. We create a new @@ -1568,31 +1396,6 @@ ieee80211_add_wme_param(uint8_t *frm, struct ieee80211_wme_state *wme) } #undef WME_OUI_BYTES -#define ATH_OUI_BYTES 0x00, 0x03, 0x7f -/* - * Add a WME information element to a frame. - */ -static uint8_t * -ieee80211_add_ath(uint8_t *frm, uint8_t caps, uint16_t defkeyix) -{ - static const struct ieee80211_ath_ie info = { - .ath_id = IEEE80211_ELEMID_VENDOR, - .ath_len = sizeof(struct ieee80211_ath_ie) - 2, - .ath_oui = { ATH_OUI_BYTES }, - .ath_oui_type = ATH_OUI_TYPE, - .ath_oui_subtype= ATH_OUI_SUBTYPE, - .ath_version = ATH_OUI_VERSION, - }; - struct ieee80211_ath_ie *ath = (struct ieee80211_ath_ie *) frm; - - memcpy(frm, &info, sizeof(info)); - ath->ath_capability = caps; - ath->ath_defkeyix[0] = (defkeyix & 0xff); - ath->ath_defkeyix[1] = ((defkeyix >> 8) & 0xff); - return frm + sizeof(info); -} -#undef ATH_OUI_BYTES - /* * Add an 11h Power Constraint element to a frame. */ @@ -1977,7 +1780,9 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) + sizeof(struct ieee80211_wme_info) + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htcap) +#ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) +#endif + (vap->iv_appie_wpa != NULL ? vap->iv_appie_wpa->ie_len : 0) + (vap->iv_appie_assocreq != NULL ? @@ -2046,6 +1851,7 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) ni->ni_ies.htcap_ie != NULL && ni->ni_ies.htcap_ie[0] == IEEE80211_ELEMID_VENDOR) frm = ieee80211_add_htcap_vendor(frm, ni); +#ifdef IEEE80211_SUPPORT_SUPERG if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_F_ATHEROS)) frm = ieee80211_add_ath(frm, IEEE80211_ATH_CAP(vap, ni, IEEE80211_F_ATHEROS), @@ -2053,6 +1859,7 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) ni->ni_authmode != IEEE80211_AUTH_8021X && vap->iv_def_txkey != IEEE80211_KEYIX_NONE ? vap->iv_def_txkey : 0x7fff); +#endif /* IEEE80211_SUPPORT_SUPERG */ if (vap->iv_appie_assocreq != NULL) frm = add_appie(frm, vap->iv_appie_assocreq); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); @@ -2088,7 +1895,9 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htinfo) + 4 + sizeof(struct ieee80211_wme_param) +#ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) +#endif + (vap->iv_appie_assocresp != NULL ? vap->iv_appie_assocresp->ie_len : 0) ); @@ -2123,10 +1932,12 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) frm = ieee80211_add_htcap_vendor(frm, ni); frm = ieee80211_add_htinfo_vendor(frm, ni); } +#ifdef IEEE80211_SUPPORT_SUPERG if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_F_ATHEROS)) frm = ieee80211_add_ath(frm, IEEE80211_ATH_CAP(vap, ni, IEEE80211_F_ATHEROS), ni->ni_ath_defkeyix); +#endif /* IEEE80211_SUPPORT_SUPERG */ if (vap->iv_appie_assocresp != NULL) frm = add_appie(frm, vap->iv_appie_assocresp); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); @@ -2227,7 +2038,9 @@ ieee80211_alloc_proberesp(struct ieee80211_node *bss, int legacy) + sizeof(struct ieee80211_wme_param) + 4 + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htinfo) +#ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) +#endif + (vap->iv_appie_proberesp != NULL ? vap->iv_appie_proberesp->ie_len : 0) ); @@ -2310,9 +2123,11 @@ ieee80211_alloc_proberesp(struct ieee80211_node *bss, int legacy) frm = ieee80211_add_htcap_vendor(frm, bss); frm = ieee80211_add_htinfo_vendor(frm, bss); } +#ifdef IEEE80211_SUPPORT_SUPERG if (bss->ni_ies.ath_ie != NULL && legacy != IEEE80211_SEND_LEGACY_11B) frm = ieee80211_add_ath(frm, bss->ni_ath_flags, bss->ni_ath_defkeyix); +#endif if (vap->iv_appie_proberesp != NULL) frm = add_appie(frm, vap->iv_appie_proberesp); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); |