Commit 3d2776f6 authored by Sujith Manoharan's avatar Sujith Manoharan Committed by John W. Linville

ath9k: Unify valid rate calculation routines

Signed-off-by: default avatarSujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent f5c9a804
...@@ -504,50 +504,49 @@ static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv) ...@@ -504,50 +504,49 @@ static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv)
return hi; return hi;
} }
static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv) static inline bool ath_rc_check_legacy(u8 rate, u8 dot11rate, u16 rate_flags,
u32 phy, u32 capflag)
{ {
const struct ath_rate_table *rate_table = ath_rc_priv->rate_table; if (rate != dot11rate || WLAN_RC_PHY_HT(phy))
struct ath_rateset *rateset = &ath_rc_priv->neg_rates; return false;
u32 phy, capflag = ath_rc_priv->ht_cap;
u16 rate_flags;
u8 i, j, hi = 0, rate, dot11rate, valid_rate_count;
for (i = 0; i < rateset->rs_nrates; i++) { if ((rate_flags & WLAN_RC_CAP_MODE(capflag)) != WLAN_RC_CAP_MODE(capflag))
for (j = 0; j < rate_table->rate_cnt; j++) { return false;
phy = rate_table->info[j].phy;
rate_flags = rate_table->info[j].rate_flags;
rate = rateset->rs_rates[i];
dot11rate = rate_table->info[j].dot11rate;
if (rate != dot11rate if (!(rate_flags & WLAN_RC_CAP_STREAM(capflag)))
|| ((rate_flags & WLAN_RC_CAP_MODE(capflag)) != return false;
WLAN_RC_CAP_MODE(capflag))
|| !(rate_flags & WLAN_RC_CAP_STREAM(capflag))
|| WLAN_RC_PHY_HT(phy))
continue;
if (!ath_rc_valid_phyrate(phy, capflag, 0)) return true;
continue; }
valid_rate_count = ath_rc_priv->valid_phy_ratecnt[phy]; static inline bool ath_rc_check_ht(u8 rate, u8 dot11rate, u16 rate_flags,
ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = j; u32 phy, u32 capflag)
ath_rc_priv->valid_phy_ratecnt[phy] += 1; {
ath_rc_priv->valid_rate_index[j] = true; if (rate != dot11rate || !WLAN_RC_PHY_HT(phy))
hi = max(hi, j); return false;
}
}
return hi; if (!WLAN_RC_PHY_HT_VALID(rate_flags, capflag))
return false;
if (!(rate_flags & WLAN_RC_CAP_STREAM(capflag)))
return false;
return true;
} }
static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv) static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv, bool legacy)
{ {
const struct ath_rate_table *rate_table = ath_rc_priv->rate_table; const struct ath_rate_table *rate_table = ath_rc_priv->rate_table;
struct ath_rateset *rateset = &ath_rc_priv->neg_ht_rates; struct ath_rateset *rateset;
u32 phy, capflag = ath_rc_priv->ht_cap; u32 phy, capflag = ath_rc_priv->ht_cap;
u16 rate_flags; u16 rate_flags;
u8 i, j, hi = 0, rate, dot11rate, valid_rate_count; u8 i, j, hi = 0, rate, dot11rate, valid_rate_count;
if (legacy)
rateset = &ath_rc_priv->neg_rates;
else
rateset = &ath_rc_priv->neg_ht_rates;
for (i = 0; i < rateset->rs_nrates; i++) { for (i = 0; i < rateset->rs_nrates; i++) {
for (j = 0; j < rate_table->rate_cnt; j++) { for (j = 0; j < rate_table->rate_cnt; j++) {
phy = rate_table->info[j].phy; phy = rate_table->info[j].phy;
...@@ -555,9 +554,14 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv) ...@@ -555,9 +554,14 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv)
rate = rateset->rs_rates[i]; rate = rateset->rs_rates[i];
dot11rate = rate_table->info[j].dot11rate; dot11rate = rate_table->info[j].dot11rate;
if ((rate != dot11rate) || !WLAN_RC_PHY_HT(phy) || if (legacy &&
!(rate_flags & WLAN_RC_CAP_STREAM(capflag)) || !ath_rc_check_legacy(rate, dot11rate,
!WLAN_RC_PHY_HT_VALID(rate_flags, capflag)) rate_flags, phy, capflag))
continue;
if (!legacy &&
!ath_rc_check_ht(rate, dot11rate,
rate_flags, phy, capflag))
continue; continue;
if (!ath_rc_valid_phyrate(phy, capflag, 0)) if (!ath_rc_valid_phyrate(phy, capflag, 0))
...@@ -1181,10 +1185,10 @@ static void ath_rc_init(struct ath_softc *sc, ...@@ -1181,10 +1185,10 @@ static void ath_rc_init(struct ath_softc *sc,
if (!rateset->rs_nrates) { if (!rateset->rs_nrates) {
hi = ath_rc_init_validrates(ath_rc_priv); hi = ath_rc_init_validrates(ath_rc_priv);
} else { } else {
hi = ath_rc_setvalid_rates(ath_rc_priv); hi = ath_rc_setvalid_rates(ath_rc_priv, true);
if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG)
hthi = ath_rc_setvalid_htrates(ath_rc_priv); hthi = ath_rc_setvalid_rates(ath_rc_priv, false);
hi = max(hi, hthi); hi = max(hi, hthi);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment