diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -5943,7 +5943,6 @@ } if (ni != NULL) { - int ridx __unused; #ifdef LINUXKPI_DEBUG_80211 int old_rate; @@ -5968,15 +5967,15 @@ IMPROVE("only update of rate matches but that requires us to get a proper rate"); ieee80211_ratectl_tx_complete(ni, &txs); - ridx = ieee80211_ratectl_rate(ni->ni_vap->iv_bss, NULL, 0); + (void) ieee80211_ratectl_rate(ni->ni_vap->iv_bss, NULL, 0); #ifdef LINUXKPI_DEBUG_80211 if (linuxkpi_debug_80211 & D80211_TRACE_TX) { - printf("TX-RATE: %s: old %d new %d ridx %d, " + printf("TX-RATE: %s: old %d new %d " "long_retries %d\n", __func__, old_rate, ieee80211_node_get_txrate_dot11rate(ni->ni_vap->iv_bss), - ridx, txs.long_retries); + txs.long_retries); } #endif } diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c --- a/sys/dev/bwi/if_bwi.c +++ b/sys/dev/bwi/if_bwi.c @@ -2916,7 +2916,7 @@ uint32_t mac_ctrl; uint16_t phy_ctrl; bus_addr_t paddr; - int type, ismcast, pkt_len, error, rix; + int type, ismcast, pkt_len, error; #if 0 const uint8_t *p; int i; @@ -2943,15 +2943,10 @@ } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { rate = rate_fb = tp->ucastrate; } else { - rix = ieee80211_ratectl_rate(ni, NULL, pkt_len); + ieee80211_ratectl_rate(ni, NULL, pkt_len); rate = ieee80211_node_get_txrate_dot11rate(ni); - - if (rix > 0) { - rate_fb = ni->ni_rates.rs_rates[rix-1] & - IEEE80211_RATE_VAL; - } else { - rate_fb = rate; - } + /* TODO: assign rate_fb the previous rate, if available */ + rate_fb = rate; } tb->tb_rate[0] = rate; tb->tb_rate[1] = rate_fb; diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -6394,7 +6394,7 @@ uint8_t *prot_ptr; unsigned int len; uint32_t macctl = 0; - int rts_rate, rts_rate_fb, ismcast, isshort, rix, type; + int rts_rate, rts_rate_fb, ismcast, isshort, type; uint16_t phyctl = 0; uint8_t rate, rate_fb; int fill_phy_ctl1 = 0; @@ -6420,14 +6420,10 @@ else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = rate_fb = tp->ucastrate; else { - rix = ieee80211_ratectl_rate(ni, NULL, 0); + ieee80211_ratectl_rate(ni, NULL, 0); rate = ieee80211_node_get_txrate_dot11rate(ni); - - if (rix > 0) - rate_fb = ni->ni_rates.rs_rates[rix - 1] & - IEEE80211_RATE_VAL; - else - rate_fb = rate; + /* TODO: assign rate_fb the previous rate, if available */ + rate_fb = rate; } sc->sc_tx_rate = rate; diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -3503,11 +3503,11 @@ if (rate_matched) { ieee80211_ratectl_tx_complete(ni, txs); - int rix = ieee80211_ratectl_rate(vap->iv_bss, NULL, 0); + ieee80211_ratectl_rate(vap->iv_bss, NULL, 0); new_rate = ieee80211_node_get_txrate_dot11rate(vap->iv_bss); if (new_rate != 0 && new_rate != cur_rate) { struct iwm_node *in = IWM_NODE(vap->iv_bss); - iwm_setrates(sc, in, rix); + iwm_setrates(sc, in, new_rate); iwm_send_lq_cmd(sc, &in->in_lq, FALSE); } } @@ -4271,16 +4271,31 @@ static void -iwm_setrates(struct iwm_softc *sc, struct iwm_node *in, int rix) +iwm_setrates(struct iwm_softc *sc, struct iwm_node *in, int dot11rate) { + struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni = &in->in_ni; struct iwm_lq_cmd *lq = &in->in_lq; struct ieee80211_rateset *rs = &ni->ni_rates; int nrates = rs->rs_nrates; int i, ridx, tab = 0; // int txant = 0; + int rix; - KASSERT(rix >= 0 && rix < nrates, ("invalid rix")); + /* + * Look up the rate index for the given legacy rate. + * + * This code path isn't currently looking at the ni_htrates + * array for setting MCS rates. It also doesn't have + * any knowledge of VHT rates. + */ + rix = ieee80211_legacy_rate_lookup(ic->ic_rt, dot11rate); + if (rix < 0) { + device_printf(sc->sc_dev, + "%s: failed to lookup dot11rate (%d)\n", + __func__, dot11rate); + rix = 0; + } if (nrates > nitems(lq->rs_table)) { device_printf(sc->sc_dev, @@ -4560,8 +4575,9 @@ iwm_enable_beacon_filter(sc, ivp); iwm_power_update_mac(sc); iwm_update_quotas(sc, ivp); - int rix = ieee80211_ratectl_rate(&in->in_ni, NULL, 0); - iwm_setrates(sc, in, rix); + ieee80211_ratectl_rate(&in->in_ni, NULL, 0); + int dot11rate = ieee80211_node_get_txrate_dot11rate(&in->in_ni); + iwm_setrates(sc, in, dot11rate); if ((error = iwm_send_lq_cmd(sc, &in->in_lq, TRUE)) != 0) { device_printf(sc->sc_dev, diff --git a/sys/net80211/ieee80211_ratectl.h b/sys/net80211/ieee80211_ratectl.h --- a/sys/net80211/ieee80211_ratectl.h +++ b/sys/net80211/ieee80211_ratectl.h @@ -127,12 +127,12 @@ vap->iv_rate->ir_node_deinit(ni); } -static int __inline +static void __inline ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg) { const struct ieee80211vap *vap = ni->ni_vap; - return vap->iv_rate->ir_rate(ni, arg, iarg); + (void) vap->iv_rate->ir_rate(ni, arg, iarg); } static __inline void