ieee80211_ht.c (229284) | ieee80211_ht.c (233452) |
---|---|
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 229284 2012-01-02 16:02:30Z bschmidt $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_ht.c 233452 2012-03-25 03:11:57Z adrian $"); |
29#endif 30 31/* 32 * IEEE 802.11n protocol support. 33 */ 34 35#include "opt_inet.h" 36#include "opt_wlan.h" --- 1386 unchanged lines hidden (view full) --- 1423 * Handle 11n channel switch. Use the received HT ie's to 1424 * identify the right channel to use. If we cannot locate it 1425 * in the channel table then fallback to legacy operation. 1426 * Note that we use this information to identify the node's 1427 * channel only; the caller is responsible for insuring any 1428 * required channel change is done (e.g. in sta mode when 1429 * parsing the contents of a beacon frame). 1430 */ | 29#endif 30 31/* 32 * IEEE 802.11n protocol support. 33 */ 34 35#include "opt_inet.h" 36#include "opt_wlan.h" --- 1386 unchanged lines hidden (view full) --- 1423 * Handle 11n channel switch. Use the received HT ie's to 1424 * identify the right channel to use. If we cannot locate it 1425 * in the channel table then fallback to legacy operation. 1426 * Note that we use this information to identify the node's 1427 * channel only; the caller is responsible for insuring any 1428 * required channel change is done (e.g. in sta mode when 1429 * parsing the contents of a beacon frame). 1430 */ |
1431static void | 1431static int |
1432htinfo_update_chw(struct ieee80211_node *ni, int htflags) 1433{ 1434 struct ieee80211com *ic = ni->ni_ic; 1435 struct ieee80211_channel *c; 1436 int chanflags; | 1432htinfo_update_chw(struct ieee80211_node *ni, int htflags) 1433{ 1434 struct ieee80211com *ic = ni->ni_ic; 1435 struct ieee80211_channel *c; 1436 int chanflags; |
1437 int ret = 0; |
|
1437 1438 chanflags = (ni->ni_chan->ic_flags &~ IEEE80211_CHAN_HT) | htflags; 1439 if (chanflags != ni->ni_chan->ic_flags) { 1440 /* XXX not right for ht40- */ 1441 c = ieee80211_find_channel(ic, ni->ni_chan->ic_freq, chanflags); 1442 if (c == NULL && (htflags & IEEE80211_CHAN_HT40)) { 1443 /* 1444 * No HT40 channel entry in our table; fall back --- 10 unchanged lines hidden (view full) --- 1455 } 1456 if (c != NULL && c != ni->ni_chan) { 1457 IEEE80211_NOTE(ni->ni_vap, 1458 IEEE80211_MSG_ASSOC | IEEE80211_MSG_11N, ni, 1459 "switch station to HT%d channel %u/0x%x", 1460 IEEE80211_IS_CHAN_HT40(c) ? 40 : 20, 1461 c->ic_freq, c->ic_flags); 1462 ni->ni_chan = c; | 1438 1439 chanflags = (ni->ni_chan->ic_flags &~ IEEE80211_CHAN_HT) | htflags; 1440 if (chanflags != ni->ni_chan->ic_flags) { 1441 /* XXX not right for ht40- */ 1442 c = ieee80211_find_channel(ic, ni->ni_chan->ic_freq, chanflags); 1443 if (c == NULL && (htflags & IEEE80211_CHAN_HT40)) { 1444 /* 1445 * No HT40 channel entry in our table; fall back --- 10 unchanged lines hidden (view full) --- 1456 } 1457 if (c != NULL && c != ni->ni_chan) { 1458 IEEE80211_NOTE(ni->ni_vap, 1459 IEEE80211_MSG_ASSOC | IEEE80211_MSG_11N, ni, 1460 "switch station to HT%d channel %u/0x%x", 1461 IEEE80211_IS_CHAN_HT40(c) ? 40 : 20, 1462 c->ic_freq, c->ic_flags); 1463 ni->ni_chan = c; |
1464 ret = 1; |
|
1463 } 1464 /* NB: caller responsible for forcing any channel change */ 1465 } 1466 /* update node's tx channel width */ 1467 ni->ni_chw = IEEE80211_IS_CHAN_HT40(ni->ni_chan)? 40 : 20; | 1465 } 1466 /* NB: caller responsible for forcing any channel change */ 1467 } 1468 /* update node's tx channel width */ 1469 ni->ni_chw = IEEE80211_IS_CHAN_HT40(ni->ni_chan)? 40 : 20; |
1470 return (ret); |
|
1468} 1469 1470/* 1471 * Update 11n MIMO PS state according to received htcap. 1472 */ 1473static __inline int 1474htcap_update_mimo_ps(struct ieee80211_node *ni) 1475{ --- 34 unchanged lines hidden (view full) --- 1510 (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)) 1511 ni->ni_flags |= IEEE80211_NODE_SGI40; 1512} 1513 1514/* 1515 * Parse and update HT-related state extracted from 1516 * the HT cap and info ie's. 1517 */ | 1471} 1472 1473/* 1474 * Update 11n MIMO PS state according to received htcap. 1475 */ 1476static __inline int 1477htcap_update_mimo_ps(struct ieee80211_node *ni) 1478{ --- 34 unchanged lines hidden (view full) --- 1513 (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)) 1514 ni->ni_flags |= IEEE80211_NODE_SGI40; 1515} 1516 1517/* 1518 * Parse and update HT-related state extracted from 1519 * the HT cap and info ie's. 1520 */ |
1518void | 1521int |
1519ieee80211_ht_updateparams(struct ieee80211_node *ni, 1520 const uint8_t *htcapie, const uint8_t *htinfoie) 1521{ 1522 struct ieee80211vap *vap = ni->ni_vap; 1523 const struct ieee80211_ie_htinfo *htinfo; 1524 int htflags; | 1522ieee80211_ht_updateparams(struct ieee80211_node *ni, 1523 const uint8_t *htcapie, const uint8_t *htinfoie) 1524{ 1525 struct ieee80211vap *vap = ni->ni_vap; 1526 const struct ieee80211_ie_htinfo *htinfo; 1527 int htflags; |
1528 int ret = 0; |
|
1525 1526 ieee80211_parse_htcap(ni, htcapie); 1527 if (vap->iv_htcaps & IEEE80211_HTCAP_SMPS) 1528 htcap_update_mimo_ps(ni); 1529 htcap_update_shortgi(ni); 1530 1531 if (htinfoie[0] == IEEE80211_ELEMID_VENDOR) 1532 htinfoie += 4; --- 5 unchanged lines hidden (view full) --- 1538 /* NB: honor operating mode constraint */ 1539 if ((htinfo->hi_byte1 & IEEE80211_HTINFO_TXWIDTH_2040) && 1540 (vap->iv_flags_ht & IEEE80211_FHT_USEHT40)) { 1541 if (ni->ni_ht2ndchan == IEEE80211_HTINFO_2NDCHAN_ABOVE) 1542 htflags = IEEE80211_CHAN_HT40U; 1543 else if (ni->ni_ht2ndchan == IEEE80211_HTINFO_2NDCHAN_BELOW) 1544 htflags = IEEE80211_CHAN_HT40D; 1545 } | 1529 1530 ieee80211_parse_htcap(ni, htcapie); 1531 if (vap->iv_htcaps & IEEE80211_HTCAP_SMPS) 1532 htcap_update_mimo_ps(ni); 1533 htcap_update_shortgi(ni); 1534 1535 if (htinfoie[0] == IEEE80211_ELEMID_VENDOR) 1536 htinfoie += 4; --- 5 unchanged lines hidden (view full) --- 1542 /* NB: honor operating mode constraint */ 1543 if ((htinfo->hi_byte1 & IEEE80211_HTINFO_TXWIDTH_2040) && 1544 (vap->iv_flags_ht & IEEE80211_FHT_USEHT40)) { 1545 if (ni->ni_ht2ndchan == IEEE80211_HTINFO_2NDCHAN_ABOVE) 1546 htflags = IEEE80211_CHAN_HT40U; 1547 else if (ni->ni_ht2ndchan == IEEE80211_HTINFO_2NDCHAN_BELOW) 1548 htflags = IEEE80211_CHAN_HT40D; 1549 } |
1546 htinfo_update_chw(ni, htflags); | 1550 if (htinfo_update_chw(ni, htflags)) 1551 ret = 1; |
1547 1548 if ((htinfo->hi_byte1 & IEEE80211_HTINFO_RIFSMODE_PERM) && 1549 (vap->iv_flags_ht & IEEE80211_FHT_RIFS)) 1550 ni->ni_flags |= IEEE80211_NODE_RIFS; 1551 else 1552 ni->ni_flags &= ~IEEE80211_NODE_RIFS; | 1552 1553 if ((htinfo->hi_byte1 & IEEE80211_HTINFO_RIFSMODE_PERM) && 1554 (vap->iv_flags_ht & IEEE80211_FHT_RIFS)) 1555 ni->ni_flags |= IEEE80211_NODE_RIFS; 1556 else 1557 ni->ni_flags &= ~IEEE80211_NODE_RIFS; |
1558 1559 return (ret); |
|
1553} 1554 1555/* 1556 * Parse and update HT-related state extracted from the HT cap ie 1557 * for a station joining an HT BSS. 1558 */ 1559void 1560ieee80211_ht_updatehtcap(struct ieee80211_node *ni, const uint8_t *htcapie) --- 12 unchanged lines hidden (view full) --- 1573 IEEE80211_CHAN_HT20 : 0; 1574 if ((ni->ni_htcap & IEEE80211_HTCAP_CHWIDTH40) && 1575 (vap->iv_flags_ht & IEEE80211_FHT_USEHT40)) { 1576 if (IEEE80211_IS_CHAN_HT40U(vap->iv_bss->ni_chan)) 1577 htflags = IEEE80211_CHAN_HT40U; 1578 else if (IEEE80211_IS_CHAN_HT40D(vap->iv_bss->ni_chan)) 1579 htflags = IEEE80211_CHAN_HT40D; 1580 } | 1560} 1561 1562/* 1563 * Parse and update HT-related state extracted from the HT cap ie 1564 * for a station joining an HT BSS. 1565 */ 1566void 1567ieee80211_ht_updatehtcap(struct ieee80211_node *ni, const uint8_t *htcapie) --- 12 unchanged lines hidden (view full) --- 1580 IEEE80211_CHAN_HT20 : 0; 1581 if ((ni->ni_htcap & IEEE80211_HTCAP_CHWIDTH40) && 1582 (vap->iv_flags_ht & IEEE80211_FHT_USEHT40)) { 1583 if (IEEE80211_IS_CHAN_HT40U(vap->iv_bss->ni_chan)) 1584 htflags = IEEE80211_CHAN_HT40U; 1585 else if (IEEE80211_IS_CHAN_HT40D(vap->iv_bss->ni_chan)) 1586 htflags = IEEE80211_CHAN_HT40D; 1587 } |
1581 htinfo_update_chw(ni, htflags); | 1588 (void) htinfo_update_chw(ni, htflags); |
1582} 1583 1584/* 1585 * Install received HT rate set by parsing the HT cap ie. 1586 */ 1587int 1588ieee80211_setup_htrates(struct ieee80211_node *ni, const uint8_t *ie, int flags) 1589{ --- 1193 unchanged lines hidden --- | 1589} 1590 1591/* 1592 * Install received HT rate set by parsing the HT cap ie. 1593 */ 1594int 1595ieee80211_setup_htrates(struct ieee80211_node *ni, const uint8_t *ie, int flags) 1596{ --- 1193 unchanged lines hidden --- |