Changeset View
Changeset View
Standalone View
Standalone View
sys/net80211/ieee80211_node.c
| Show First 20 Lines • Show All 2,661 Lines • ▼ Show 20 Lines | ieee80211_dump_node(struct ieee80211_node_table *nt __unused, | ||||
| printf("\trssi %d noise %d intval %u capinfo 0x%x\n", | printf("\trssi %d noise %d intval %u capinfo 0x%x\n", | ||||
| node_getrssi(ni), ni->ni_noise, | node_getrssi(ni), ni->ni_noise, | ||||
| ni->ni_intval, ni->ni_capinfo); | ni->ni_intval, ni->ni_capinfo); | ||||
| printf("\tbssid %s essid \"%.*s\" channel %u:0x%x\n", | printf("\tbssid %s essid \"%.*s\" channel %u:0x%x\n", | ||||
| ether_sprintf(ni->ni_bssid), | ether_sprintf(ni->ni_bssid), | ||||
| ni->ni_esslen, ni->ni_essid, | ni->ni_esslen, ni->ni_essid, | ||||
| (ni->ni_chan != IEEE80211_CHAN_ANYC) ? ni->ni_chan->ic_freq : 0, | (ni->ni_chan != IEEE80211_CHAN_ANYC) ? ni->ni_chan->ic_freq : 0, | ||||
| (ni->ni_chan != IEEE80211_CHAN_ANYC) ? ni->ni_chan->ic_flags : 0); | (ni->ni_chan != IEEE80211_CHAN_ANYC) ? ni->ni_chan->ic_flags : 0); | ||||
| printf("\tinact %u inact_reload %u txrate %u\n", | printf("\tinact %u inact_reload %u txrate type %d dot11rate %u\n", | ||||
| ni->ni_inact, ni->ni_inact_reload, ni->ni_txrate); | ni->ni_inact, ni->ni_inact_reload, | ||||
| ni->ni_txrate.type, | |||||
| ni->ni_txrate.dot11rate); | |||||
| printf("\thtcap %x htparam %x htctlchan %u ht2ndchan %u\n", | printf("\thtcap %x htparam %x htctlchan %u ht2ndchan %u\n", | ||||
| ni->ni_htcap, ni->ni_htparam, | ni->ni_htcap, ni->ni_htparam, | ||||
| ni->ni_htctlchan, ni->ni_ht2ndchan); | ni->ni_htctlchan, ni->ni_ht2ndchan); | ||||
| printf("\thtopmode %x htstbc %x htchw %d (%s)\n", | printf("\thtopmode %x htstbc %x htchw %d (%s)\n", | ||||
| ni->ni_htopmode, ni->ni_htstbc, | ni->ni_htopmode, ni->ni_htstbc, | ||||
| ni->ni_chw, ieee80211_ni_chw_to_str(ni->ni_chw)); | ni->ni_chw, ieee80211_ni_chw_to_str(ni->ni_chw)); | ||||
| printf("\tvhtcap %x freq1 %d freq2 %d vhtbasicmcs %x\n", | printf("\tvhtcap %x freq1 %d freq2 %d vhtbasicmcs %x\n", | ||||
| ni->ni_vhtcap, (int) ni->ni_vht_chan1, (int) ni->ni_vht_chan2, | ni->ni_vhtcap, (int) ni->ni_vht_chan1, (int) ni->ni_vht_chan2, | ||||
| ▲ Show 20 Lines • Show All 453 Lines • ▼ Show 20 Lines | ieee80211_getsignal(struct ieee80211vap *vap, int8_t *rssi, int8_t *noise) | ||||
| if (vap->iv_bss == NULL) /* NB: shouldn't happen */ | if (vap->iv_bss == NULL) /* NB: shouldn't happen */ | ||||
| return; | return; | ||||
| vap->iv_ic->ic_node_getsignal(vap->iv_bss, rssi, noise); | vap->iv_ic->ic_node_getsignal(vap->iv_bss, rssi, noise); | ||||
| /* for non-station mode return avg'd rssi accounting */ | /* for non-station mode return avg'd rssi accounting */ | ||||
| if (vap->iv_opmode != IEEE80211_M_STA) | if (vap->iv_opmode != IEEE80211_M_STA) | ||||
| *rssi = ieee80211_getrssi(vap); | *rssi = ieee80211_getrssi(vap); | ||||
| } | } | ||||
| /** | |||||
| * @brief return a dot11rate / ratecode representing the current transmit rate | |||||
| * | |||||
| * This is the API call for legacy / 802.11n drivers and rate control APIs | |||||
| * which expect a dot11rate / ratecode representation for legacy and HT MCS | |||||
| * rates. | |||||
| * | |||||
| * Drivers which support VHT should not use this API, as it will log an error | |||||
| * and return a low rate if a VHT rate is selected. | |||||
| * | |||||
| * @param ni the ieee80211_node to return the transmit rate for | |||||
| * @returns the dot11rate / ratecode for legacy/MCS, or the | |||||
| * lowest available dot11rate if it's VHT (and shouldn't | |||||
| * have been called.) | |||||
| */ | |||||
| uint8_t | uint8_t | ||||
| ieee80211_node_get_txrate_dot11rate(struct ieee80211_node *ni) | ieee80211_node_get_txrate_dot11rate(struct ieee80211_node *ni) | ||||
| { | { | ||||
| return (ni->ni_txrate); | switch (ni->ni_txrate.type) { | ||||
| case IEEE80211_NODE_TXRATE_LEGACY: | |||||
| return (ni->ni_txrate.dot11rate); | |||||
| break; | |||||
| case IEEE80211_NODE_TXRATE_VHT: | |||||
| default: | |||||
| printf("%s: called for VHT / unknown rate (type %d)!\n", | |||||
| __func__, ni->ni_txrate.type); | |||||
| return (12); /* OFDM6 for now */ | |||||
| } | } | ||||
| } | |||||
| /** | |||||
| * @brief set the dot11rate / ratecode representing the current transmit rate | |||||
| * | |||||
| * This is the API call for legacy / 802.11n drivers and rate control APIs | |||||
| * which expect a dot11rate / ratecode representation for legacy and HT MCS | |||||
| * rates. | |||||
| * | |||||
| * @param ni the ieee80211_node to return the transmit rate for | |||||
| * @param dot11rate the dot11rate rate code to use | |||||
| */ | |||||
| void | void | ||||
| ieee80211_node_set_txrate_dot11rate(struct ieee80211_node *ni, | ieee80211_node_set_txrate_dot11rate(struct ieee80211_node *ni, | ||||
| uint8_t dot11Rate) | uint8_t dot11Rate) | ||||
| { | { | ||||
| ni->ni_txrate = dot11Rate; | ni->ni_txrate.type = IEEE80211_NODE_TXRATE_LEGACY; | ||||
| ni->ni_txrate.mcs = ni->ni_txrate.nss = 0; | |||||
| ni->ni_txrate.dot11rate = dot11Rate; | |||||
| } | } | ||||
| /** | |||||
| * @brief set the dot11rate / ratecode representing the current HT transmit rate | |||||
| * | |||||
| * This is the API call for 802.11n drivers and rate control APIs | |||||
| * which expect a dot11rate / ratecode representation for legacy and HT MCS | |||||
| * rates. It expects an MCS rate code from 0 .. 76. | |||||
| * | |||||
| * @param ni the ieee80211_node to return the transmit rate for | |||||
| * @param mcs the MCS rate to select | |||||
| */ | |||||
| void | void | ||||
| ieee80211_node_set_txrate_ht_mcsrate(struct ieee80211_node *ni, | ieee80211_node_set_txrate_ht_mcsrate(struct ieee80211_node *ni, | ||||
| uint8_t mcs) | uint8_t mcs) | ||||
| { | { | ||||
| KASSERT(mcs <= 76, ("%s: MCS is not 0..76 (%d)", __func__, mcs)); | KASSERT(mcs <= 76, ("%s: MCS is not 0..76 (%d)", __func__, mcs)); | ||||
| if (mcs > 76) { | if (mcs > 76) { | ||||
| ic_printf(ni->ni_ic, "%s: invalid MCS (%d)\n", __func__, mcs); | ic_printf(ni->ni_ic, "%s: invalid MCS (%d)\n", __func__, mcs); | ||||
| return; | return; | ||||
| } | } | ||||
| ni->ni_txrate = IEEE80211_RATE_MCS | mcs; | |||||
| ni->ni_txrate.type = IEEE80211_NODE_TXRATE_LEGACY; | |||||
| ni->ni_txrate.mcs = ni->ni_txrate.nss = 0; | |||||
| ni->ni_txrate.dot11rate = IEEE80211_RATE_MCS | mcs; | |||||
| } | } | ||||
| /* | /* | ||||
| * @brief Fetch the transmit rate for the given node in kbit/s. | * @brief Fetch the transmit rate for the given node in kbit/s. | ||||
| * | * | ||||
| * This currently only works for CCK, OFDM and HT rates. | * This currently only works for CCK, OFDM and HT rates. | ||||
| * | * | ||||
| * @param ni struct ieee80211_node * to lookup | * @param ni struct ieee80211_node * to lookup | ||||
| * @returns current transmit rate in kbit/s | * @returns current transmit rate in kbit/s | ||||
| */ | */ | ||||
| uint32_t | uint32_t | ||||
| ieee80211_node_get_txrate_kbit(struct ieee80211_node *ni) | ieee80211_node_get_txrate_kbit(struct ieee80211_node *ni) | ||||
| { | { | ||||
| uint32_t mbps; | uint32_t mbps; | ||||
| if (ni->ni_txrate & IEEE80211_RATE_MCS) { | /* | ||||
| * TODO: only handle legacy/HT rates, VHT will need | |||||
| * to use other logic. | |||||
| */ | |||||
| switch (ni->ni_txrate.type) { | |||||
| case IEEE80211_NODE_TXRATE_LEGACY: | |||||
| break; | |||||
| case IEEE80211_NODE_TXRATE_VHT: | |||||
| default: | |||||
| printf("%s: called for VHT / unknown rate (type %d)!\n", | |||||
| __func__, ni->ni_txrate.type); | |||||
| return (0); | |||||
| } | |||||
| /* Legacy / MCS rates */ | |||||
| if (ni->ni_txrate.dot11rate & IEEE80211_RATE_MCS) { | |||||
| const struct ieee80211_mcs_rates *mcs = | const struct ieee80211_mcs_rates *mcs = | ||||
| &ieee80211_htrates[ni->ni_txrate &~ IEEE80211_RATE_MCS]; | &ieee80211_htrates[ni->ni_txrate.dot11rate &~ | ||||
| IEEE80211_RATE_MCS]; | |||||
bz: That ~ again; also indentation on the line below should be another 4 spaces. | |||||
| if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { | if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { | ||||
| /* Note: these are in 1/2Mbit/s units */ | /* Note: these are in 1/2Mbit/s units */ | ||||
| if (ni->ni_flags & IEEE80211_NODE_SGI40) | if (ni->ni_flags & IEEE80211_NODE_SGI40) | ||||
| mbps = mcs->ht40_rate_800ns; | mbps = mcs->ht40_rate_800ns; | ||||
| else | else | ||||
| mbps = mcs->ht40_rate_400ns; | mbps = mcs->ht40_rate_400ns; | ||||
| } else { | } else { | ||||
| if (ni->ni_flags & IEEE80211_NODE_SGI20) | if (ni->ni_flags & IEEE80211_NODE_SGI20) | ||||
| mbps = mcs->ht20_rate_800ns; | mbps = mcs->ht20_rate_800ns; | ||||
| else | else | ||||
| mbps = mcs->ht20_rate_400ns; | mbps = mcs->ht20_rate_400ns; | ||||
| } | } | ||||
| } else | } else | ||||
| /* Note: CCK/OFDM dot11rate entries are in 1/2Mbit/s units */ | /* Note: CCK/OFDM dot11rate entries are in 1/2Mbit/s units */ | ||||
| mbps = ni->ni_txrate; | mbps = ni->ni_txrate.dot11rate; | ||||
| return (mbps * 500); | return (mbps * 500); | ||||
| } | } | ||||
That ~ again; also indentation on the line below should be another 4 spaces.