ieee80211_ht.c (184282) | ieee80211_ht.c (191552) |
---|---|
1/*- 2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> 27#ifdef __FreeBSD__ | 1/*- 2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> 27#ifdef __FreeBSD__ |
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_ht.c 184282 2008-10-26 00:43:11Z sam $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_ht.c 191552 2009-04-26 22:54:51Z sam $"); |
29#endif 30 31/* 32 * IEEE 802.11n protocol support. 33 */ 34 35#include "opt_inet.h" 36#include "opt_wlan.h" --- 78 unchanged lines hidden (view full) --- 115static void ieee80211_addba_stop(struct ieee80211_node *ni, 116 struct ieee80211_tx_ampdu *tap); 117static void ieee80211_aggr_recv_action(struct ieee80211_node *ni, 118 const uint8_t *frm, const uint8_t *efrm); 119static void ieee80211_bar_response(struct ieee80211_node *ni, 120 struct ieee80211_tx_ampdu *tap, int status); 121static void ampdu_tx_stop(struct ieee80211_tx_ampdu *tap); 122static void bar_stop_timer(struct ieee80211_tx_ampdu *tap); | 29#endif 30 31/* 32 * IEEE 802.11n protocol support. 33 */ 34 35#include "opt_inet.h" 36#include "opt_wlan.h" --- 78 unchanged lines hidden (view full) --- 115static void ieee80211_addba_stop(struct ieee80211_node *ni, 116 struct ieee80211_tx_ampdu *tap); 117static void ieee80211_aggr_recv_action(struct ieee80211_node *ni, 118 const uint8_t *frm, const uint8_t *efrm); 119static void ieee80211_bar_response(struct ieee80211_node *ni, 120 struct ieee80211_tx_ampdu *tap, int status); 121static void ampdu_tx_stop(struct ieee80211_tx_ampdu *tap); 122static void bar_stop_timer(struct ieee80211_tx_ampdu *tap); |
123static int ampdu_rx_start(struct ieee80211_node *, struct ieee80211_rx_ampdu *, 124 int baparamset, int batimeout, int baseqctl); 125static void ampdu_rx_stop(struct ieee80211_node *, struct ieee80211_rx_ampdu *); |
|
123 124void 125ieee80211_ht_attach(struct ieee80211com *ic) 126{ 127 /* setup default aggregation policy */ 128 ic->ic_recv_action = ieee80211_aggr_recv_action; 129 ic->ic_send_action = ieee80211_send_action; 130 ic->ic_ampdu_enable = ieee80211_ampdu_enable; 131 ic->ic_addba_request = ieee80211_addba_request; 132 ic->ic_addba_response = ieee80211_addba_response; 133 ic->ic_addba_stop = ieee80211_addba_stop; 134 ic->ic_bar_response = ieee80211_bar_response; | 126 127void 128ieee80211_ht_attach(struct ieee80211com *ic) 129{ 130 /* setup default aggregation policy */ 131 ic->ic_recv_action = ieee80211_aggr_recv_action; 132 ic->ic_send_action = ieee80211_send_action; 133 ic->ic_ampdu_enable = ieee80211_ampdu_enable; 134 ic->ic_addba_request = ieee80211_addba_request; 135 ic->ic_addba_response = ieee80211_addba_response; 136 ic->ic_addba_stop = ieee80211_addba_stop; 137 ic->ic_bar_response = ieee80211_bar_response; |
138 ic->ic_ampdu_rx_start = ampdu_rx_start; 139 ic->ic_ampdu_rx_stop = ampdu_rx_stop; |
|
135 136 ic->ic_htprotmode = IEEE80211_PROT_RTSCTS; 137 ic->ic_curhtprotmode = IEEE80211_HTINFO_OPMODE_PURE; 138} 139 140void 141ieee80211_ht_detach(struct ieee80211com *ic) 142{ --- 169 unchanged lines hidden (view full) --- 312 KASSERT(rap->rxa_qbytes == 0 && rap->rxa_qframes == 0, 313 ("lost %u data, %u frames on ampdu rx q", 314 rap->rxa_qbytes, rap->rxa_qframes)); 315} 316 317/* 318 * Start A-MPDU rx/re-order processing for the specified TID. 319 */ | 140 141 ic->ic_htprotmode = IEEE80211_PROT_RTSCTS; 142 ic->ic_curhtprotmode = IEEE80211_HTINFO_OPMODE_PURE; 143} 144 145void 146ieee80211_ht_detach(struct ieee80211com *ic) 147{ --- 169 unchanged lines hidden (view full) --- 317 KASSERT(rap->rxa_qbytes == 0 && rap->rxa_qframes == 0, 318 ("lost %u data, %u frames on ampdu rx q", 319 rap->rxa_qbytes, rap->rxa_qframes)); 320} 321 322/* 323 * Start A-MPDU rx/re-order processing for the specified TID. 324 */ |
320static void 321ampdu_rx_start(struct ieee80211_rx_ampdu *rap, int bufsiz, int start) | 325static int 326ampdu_rx_start(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap, 327 int baparamset, int batimeout, int baseqctl) |
322{ | 328{ |
329 int bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); 330 |
|
323 if (rap->rxa_flags & IEEE80211_AGGR_RUNNING) { 324 /* 325 * AMPDU previously setup and not terminated with a DELBA, 326 * flush the reorder q's in case anything remains. 327 */ 328 ampdu_rx_purge(rap); 329 } 330 memset(rap, 0, sizeof(*rap)); 331 rap->rxa_wnd = (bufsiz == 0) ? 332 IEEE80211_AGGR_BAWMAX : min(bufsiz, IEEE80211_AGGR_BAWMAX); | 331 if (rap->rxa_flags & IEEE80211_AGGR_RUNNING) { 332 /* 333 * AMPDU previously setup and not terminated with a DELBA, 334 * flush the reorder q's in case anything remains. 335 */ 336 ampdu_rx_purge(rap); 337 } 338 memset(rap, 0, sizeof(*rap)); 339 rap->rxa_wnd = (bufsiz == 0) ? 340 IEEE80211_AGGR_BAWMAX : min(bufsiz, IEEE80211_AGGR_BAWMAX); |
333 rap->rxa_start = start; | 341 rap->rxa_start = MS(baseqctl, IEEE80211_BASEQ_START); |
334 rap->rxa_flags |= IEEE80211_AGGR_RUNNING | IEEE80211_AGGR_XCHGPEND; | 342 rap->rxa_flags |= IEEE80211_AGGR_RUNNING | IEEE80211_AGGR_XCHGPEND; |
343 344 return 0; |
|
335} 336 337/* 338 * Stop A-MPDU rx processing for the specified TID. 339 */ 340static void | 345} 346 347/* 348 * Stop A-MPDU rx processing for the specified TID. 349 */ 350static void |
341ampdu_rx_stop(struct ieee80211_rx_ampdu *rap) | 351ampdu_rx_stop(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap) |
342{ 343 ampdu_rx_purge(rap); 344 rap->rxa_flags &= ~(IEEE80211_AGGR_RUNNING | IEEE80211_AGGR_XCHGPEND); 345} 346 347/* 348 * Dispatch a frame from the A-MPDU reorder queue. The 349 * frame is fed back into ieee80211_input marked with an --- 468 unchanged lines hidden (view full) --- 818 819/* 820 * Cleanup HT-specific state in a node. Called only 821 * when HT use has been marked. 822 */ 823void 824ieee80211_ht_node_cleanup(struct ieee80211_node *ni) 825{ | 352{ 353 ampdu_rx_purge(rap); 354 rap->rxa_flags &= ~(IEEE80211_AGGR_RUNNING | IEEE80211_AGGR_XCHGPEND); 355} 356 357/* 358 * Dispatch a frame from the A-MPDU reorder queue. The 359 * frame is fed back into ieee80211_input marked with an --- 468 unchanged lines hidden (view full) --- 828 829/* 830 * Cleanup HT-specific state in a node. Called only 831 * when HT use has been marked. 832 */ 833void 834ieee80211_ht_node_cleanup(struct ieee80211_node *ni) 835{ |
836 struct ieee80211com *ic = ni->ni_ic; |
|
826 int i; 827 828 KASSERT(ni->ni_flags & IEEE80211_NODE_HT, ("not an HT node")); 829 830 /* XXX optimize this */ 831 for (i = 0; i < WME_NUM_AC; i++) { 832 struct ieee80211_tx_ampdu *tap = &ni->ni_tx_ampdu[i]; 833 if (tap->txa_flags & IEEE80211_AGGR_SETUP) 834 ampdu_tx_stop(tap); 835 } 836 for (i = 0; i < WME_NUM_TID; i++) | 837 int i; 838 839 KASSERT(ni->ni_flags & IEEE80211_NODE_HT, ("not an HT node")); 840 841 /* XXX optimize this */ 842 for (i = 0; i < WME_NUM_AC; i++) { 843 struct ieee80211_tx_ampdu *tap = &ni->ni_tx_ampdu[i]; 844 if (tap->txa_flags & IEEE80211_AGGR_SETUP) 845 ampdu_tx_stop(tap); 846 } 847 for (i = 0; i < WME_NUM_TID; i++) |
837 ampdu_rx_stop(&ni->ni_rx_ampdu[i]); | 848 ic->ic_ampdu_rx_stop(ni, &ni->ni_rx_ampdu[i]); |
838 839 ni->ni_htcap = 0; 840 ni->ni_flags &= ~IEEE80211_NODE_HT_ALL; 841} 842 843/* 844 * Age out HT resources for a station. 845 */ --- 728 unchanged lines hidden (view full) --- 1574 switch (ia->ia_action) { 1575 case IEEE80211_ACTION_BA_ADDBA_REQUEST: 1576 dialogtoken = frm[2]; 1577 baparamset = LE_READ_2(frm+3); 1578 batimeout = LE_READ_2(frm+5); 1579 baseqctl = LE_READ_2(frm+7); 1580 1581 tid = MS(baparamset, IEEE80211_BAPS_TID); | 849 850 ni->ni_htcap = 0; 851 ni->ni_flags &= ~IEEE80211_NODE_HT_ALL; 852} 853 854/* 855 * Age out HT resources for a station. 856 */ --- 728 unchanged lines hidden (view full) --- 1585 switch (ia->ia_action) { 1586 case IEEE80211_ACTION_BA_ADDBA_REQUEST: 1587 dialogtoken = frm[2]; 1588 baparamset = LE_READ_2(frm+3); 1589 batimeout = LE_READ_2(frm+5); 1590 baseqctl = LE_READ_2(frm+7); 1591 1592 tid = MS(baparamset, IEEE80211_BAPS_TID); |
1582 bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); | |
1583 1584 IEEE80211_NOTE(vap, 1585 IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni, 1586 "recv ADDBA request: dialogtoken %u " 1587 "baparamset 0x%x (tid %d bufsiz %d) batimeout %d " 1588 "baseqctl %d:%d", | 1593 1594 IEEE80211_NOTE(vap, 1595 IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni, 1596 "recv ADDBA request: dialogtoken %u " 1597 "baparamset 0x%x (tid %d bufsiz %d) batimeout %d " 1598 "baseqctl %d:%d", |
1589 dialogtoken, baparamset, tid, bufsiz, batimeout, | 1599 dialogtoken, baparamset, 1600 tid, MS(baparamset, IEEE80211_BAPS_BUFSIZ), 1601 batimeout, |
1590 MS(baseqctl, IEEE80211_BASEQ_START), 1591 MS(baseqctl, IEEE80211_BASEQ_FRAG)); 1592 1593 rap = &ni->ni_rx_ampdu[tid]; 1594 1595 /* Send ADDBA response */ 1596 args[0] = dialogtoken; 1597 /* 1598 * NB: We ack only if the sta associated with HT and 1599 * the ap is configured to do AMPDU rx (the latter 1600 * violates the 11n spec and is mostly for testing). 1601 */ 1602 if ((ni->ni_flags & IEEE80211_NODE_AMPDU_RX) && 1603 (vap->iv_flags_ext & IEEE80211_FEXT_AMPDU_RX)) { | 1602 MS(baseqctl, IEEE80211_BASEQ_START), 1603 MS(baseqctl, IEEE80211_BASEQ_FRAG)); 1604 1605 rap = &ni->ni_rx_ampdu[tid]; 1606 1607 /* Send ADDBA response */ 1608 args[0] = dialogtoken; 1609 /* 1610 * NB: We ack only if the sta associated with HT and 1611 * the ap is configured to do AMPDU rx (the latter 1612 * violates the 11n spec and is mostly for testing). 1613 */ 1614 if ((ni->ni_flags & IEEE80211_NODE_AMPDU_RX) && 1615 (vap->iv_flags_ext & IEEE80211_FEXT_AMPDU_RX)) { |
1604 ampdu_rx_start(rap, bufsiz, 1605 MS(baseqctl, IEEE80211_BASEQ_START)); | 1616 /* XXX handle ampdu_rx_start failure */ 1617 ic->ic_ampdu_rx_start(ni, rap, 1618 baparamset, batimeout, baseqctl); |
1606 1607 args[1] = IEEE80211_STATUS_SUCCESS; 1608 } else { 1609 IEEE80211_NOTE(vap, 1610 IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, 1611 ni, "reject ADDBA request: %s", 1612 ni->ni_flags & IEEE80211_NODE_AMPDU_RX ? 1613 "administratively disabled" : --- 89 unchanged lines hidden (view full) --- 1703 MS(baparamset, IEEE80211_DELBAPS_INIT), code); 1704 1705 if ((baparamset & IEEE80211_DELBAPS_INIT) == 0) { 1706 ac = TID_TO_WME_AC(tid); 1707 tap = &ni->ni_tx_ampdu[ac]; 1708 ic->ic_addba_stop(ni, tap); 1709 } else { 1710 rap = &ni->ni_rx_ampdu[tid]; | 1619 1620 args[1] = IEEE80211_STATUS_SUCCESS; 1621 } else { 1622 IEEE80211_NOTE(vap, 1623 IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, 1624 ni, "reject ADDBA request: %s", 1625 ni->ni_flags & IEEE80211_NODE_AMPDU_RX ? 1626 "administratively disabled" : --- 89 unchanged lines hidden (view full) --- 1716 MS(baparamset, IEEE80211_DELBAPS_INIT), code); 1717 1718 if ((baparamset & IEEE80211_DELBAPS_INIT) == 0) { 1719 ac = TID_TO_WME_AC(tid); 1720 tap = &ni->ni_tx_ampdu[ac]; 1721 ic->ic_addba_stop(ni, tap); 1722 } else { 1723 rap = &ni->ni_rx_ampdu[tid]; |
1711 ampdu_rx_stop(rap); | 1724 ic->ic_ampdu_rx_stop(ni, rap); |
1712 } 1713 return; 1714 } 1715 break; 1716 } 1717 ieee80211_recv_action(ni, frm, efrm); 1718} 1719 --- 752 unchanged lines hidden --- | 1725 } 1726 return; 1727 } 1728 break; 1729 } 1730 ieee80211_recv_action(ni, frm, efrm); 1731} 1732 --- 752 unchanged lines hidden --- |