Commit c6a9de08 authored by Chaoming_Li's avatar Chaoming_Li Committed by John W. Linville

rtlwifi: Convert rc routines for addition of rtl8192se and rtl8192de

Convert rc routines for addition of RTL8192SE and RTL8192DE code
Signed-off-by: default avatarChaoming_Li <chaoming_li@realsil.com.cn>
Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent cc7dc0c4
...@@ -38,17 +38,14 @@ ...@@ -38,17 +38,14 @@
*CCK11M or OFDM_54M based on wireless mode. *CCK11M or OFDM_54M based on wireless mode.
*/ */
static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv, static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
struct ieee80211_sta *sta,
struct sk_buff *skb, bool not_data) struct sk_buff *skb, bool not_data)
{ {
struct rtl_mac *rtlmac = rtl_mac(rtlpriv); struct rtl_mac *rtlmac = rtl_mac(rtlpriv);
struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
/* struct rtl_phy *rtlphy = &(rtlpriv->phy);
*mgt use 1M, although we have check it struct rtl_sta_info *sta_entry = NULL;
*before this function use rate_control_send_low, u8 wireless_mode = 0;
*we still check it here
*/
if (not_data)
return rtlpriv->cfg->maps[RTL_RC_CCK_RATE1M];
/* /*
*this rate is no use for true rate, firmware *this rate is no use for true rate, firmware
...@@ -57,35 +54,78 @@ static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv, ...@@ -57,35 +54,78 @@ static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
*2.in rtl_get_tcb_desc when we check rate is *2.in rtl_get_tcb_desc when we check rate is
* 1M we will not use FW rate but user rate. * 1M we will not use FW rate but user rate.
*/ */
if (rtl_is_special_data(rtlpriv->mac80211.hw, skb, true)) { if (rtlmac->opmode == NL80211_IFTYPE_AP ||
return rtlpriv->cfg->maps[RTL_RC_CCK_RATE1M]; rtlmac->opmode == NL80211_IFTYPE_ADHOC) {
if (sta) {
sta_entry = (struct rtl_sta_info *) sta->drv_priv;
wireless_mode = sta_entry->wireless_mode;
} else {
return 0;
}
} else {
wireless_mode = rtlmac->mode;
}
if (rtl_is_special_data(rtlpriv->mac80211.hw, skb, true) ||
not_data) {
return 0;
} else {
if (rtlhal->current_bandtype == BAND_ON_2_4G) {
if (wireless_mode == WIRELESS_MODE_B) {
return B_MODE_MAX_RIX;
} else if (wireless_mode == WIRELESS_MODE_G) {
return G_MODE_MAX_RIX;
} else {
if (get_rf_type(rtlphy) != RF_2T2R)
return N_MODE_MCS7_RIX;
else
return N_MODE_MCS15_RIX;
}
} else {
if (wireless_mode == WIRELESS_MODE_A) {
return A_MODE_MAX_RIX;
} else { } else {
if (rtlmac->mode == WIRELESS_MODE_B) if (get_rf_type(rtlphy) != RF_2T2R)
return rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M]; return N_MODE_MCS7_RIX;
else else
return rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M]; return N_MODE_MCS15_RIX;
}
}
} }
} }
static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv, static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
struct ieee80211_sta *sta,
struct ieee80211_tx_rate *rate, struct ieee80211_tx_rate *rate,
struct ieee80211_tx_rate_control *txrc, struct ieee80211_tx_rate_control *txrc,
u8 tries, u8 rix, int rtsctsenable, u8 tries, char rix, int rtsctsenable,
bool not_data) bool not_data)
{ {
struct rtl_mac *mac = rtl_mac(rtlpriv); struct rtl_mac *mac = rtl_mac(rtlpriv);
u8 sgi_20 = 0, sgi_40 = 0;
if (sta) {
sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
}
rate->count = tries; rate->count = tries;
rate->idx = (rix > 0x2) ? rix : 0x2; rate->idx = rix >= 0x00 ? rix : 0x00;
if (!not_data) { if (!not_data) {
if (txrc->short_preamble) if (txrc->short_preamble)
rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE; rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
if (mac->opmode == NL80211_IFTYPE_AP ||
mac->opmode == NL80211_IFTYPE_ADHOC) {
if (sta && (sta->ht_cap.cap &
IEEE80211_HT_CAP_SUP_WIDTH_20_40))
rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
} else {
if (mac->bw_40) if (mac->bw_40)
rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
if (mac->sgi_20 || mac->sgi_40) }
if (sgi_20 || sgi_40)
rate->flags |= IEEE80211_TX_RC_SHORT_GI; rate->flags |= IEEE80211_TX_RC_SHORT_GI;
if (mac->ht_enable) if (sta && sta->ht_cap.ht_supported)
rate->flags |= IEEE80211_TX_RC_MCS; rate->flags |= IEEE80211_TX_RC_MCS;
} }
} }
...@@ -97,39 +137,39 @@ static void rtl_get_rate(void *ppriv, struct ieee80211_sta *sta, ...@@ -97,39 +137,39 @@ static void rtl_get_rate(void *ppriv, struct ieee80211_sta *sta,
struct sk_buff *skb = txrc->skb; struct sk_buff *skb = txrc->skb;
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
struct ieee80211_tx_rate *rates = tx_info->control.rates; struct ieee80211_tx_rate *rates = tx_info->control.rates;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; __le16 fc = rtl_get_fc(skb);
__le16 fc = hdr->frame_control;
u8 try_per_rate, i, rix; u8 try_per_rate, i, rix;
bool not_data = !ieee80211_is_data(fc); bool not_data = !ieee80211_is_data(fc);
if (rate_control_send_low(sta, priv_sta, txrc)) if (rate_control_send_low(sta, priv_sta, txrc))
return; return;
rix = _rtl_rc_get_highest_rix(rtlpriv, skb, not_data); rix = _rtl_rc_get_highest_rix(rtlpriv, sta, skb, not_data);
try_per_rate = 1; try_per_rate = 1;
_rtl_rc_rate_set_series(rtlpriv, &rates[0], txrc, _rtl_rc_rate_set_series(rtlpriv, sta, &rates[0], txrc,
try_per_rate, rix, 1, not_data); try_per_rate, rix, 1, not_data);
if (!not_data) { if (!not_data) {
for (i = 1; i < 4; i++) for (i = 1; i < 4; i++)
_rtl_rc_rate_set_series(rtlpriv, &rates[i], _rtl_rc_rate_set_series(rtlpriv, sta, &rates[i],
txrc, i, (rix - i), 1, txrc, i, (rix - i), 1,
not_data); not_data);
} }
} }
static bool _rtl_tx_aggr_check(struct rtl_priv *rtlpriv, u16 tid) static bool _rtl_tx_aggr_check(struct rtl_priv *rtlpriv,
struct rtl_sta_info *sta_entry, u16 tid)
{ {
struct rtl_mac *mac = rtl_mac(rtlpriv); struct rtl_mac *mac = rtl_mac(rtlpriv);
if (mac->act_scanning) if (mac->act_scanning)
return false; return false;
if (mac->cnt_after_linked < 3) if (mac->opmode == NL80211_IFTYPE_STATION &&
mac->cnt_after_linked < 3)
return false; return false;
if (mac->tids[tid].agg.agg_state == RTL_AGG_OFF) if (sta_entry->tids[tid].agg.agg_state == RTL_AGG_STOP)
return true; return true;
return false; return false;
...@@ -143,11 +183,9 @@ static void rtl_tx_status(void *ppriv, ...@@ -143,11 +183,9 @@ static void rtl_tx_status(void *ppriv,
{ {
struct rtl_priv *rtlpriv = ppriv; struct rtl_priv *rtlpriv = ppriv;
struct rtl_mac *mac = rtl_mac(rtlpriv); struct rtl_mac *mac = rtl_mac(rtlpriv);
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
__le16 fc; __le16 fc = rtl_get_fc(skb);
struct rtl_sta_info *sta_entry;
hdr = (struct ieee80211_hdr *)skb->data;
fc = hdr->frame_control;
if (!priv_sta || !ieee80211_is_data(fc)) if (!priv_sta || !ieee80211_is_data(fc))
return; return;
...@@ -159,17 +197,21 @@ static void rtl_tx_status(void *ppriv, ...@@ -159,17 +197,21 @@ static void rtl_tx_status(void *ppriv,
|| is_broadcast_ether_addr(ieee80211_get_DA(hdr))) || is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
return; return;
if (sta) {
/* Check if aggregation has to be enabled for this tid */ /* Check if aggregation has to be enabled for this tid */
if (conf_is_ht(&mac->hw->conf) && sta_entry = (struct rtl_sta_info *) sta->drv_priv;
if ((sta->ht_cap.ht_supported == true) &&
!(skb->protocol == cpu_to_be16(ETH_P_PAE))) { !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
if (ieee80211_is_data_qos(fc)) { if (ieee80211_is_data_qos(fc)) {
u8 *qc, tid; u8 tid = rtl_get_tid(skb);
if (_rtl_tx_aggr_check(rtlpriv, sta_entry,
qc = ieee80211_get_qos_ctl(hdr); tid)) {
tid = qc[0] & 0xf; sta_entry->tids[tid].agg.agg_state =
RTL_AGG_PROGRESS;
if (_rtl_tx_aggr_check(rtlpriv, tid)) ieee80211_start_tx_ba_session(sta,
ieee80211_start_tx_ba_session(sta, tid, 5000); tid, 5000);
}
}
} }
} }
} }
...@@ -178,43 +220,6 @@ static void rtl_rate_init(void *ppriv, ...@@ -178,43 +220,6 @@ static void rtl_rate_init(void *ppriv,
struct ieee80211_supported_band *sband, struct ieee80211_supported_band *sband,
struct ieee80211_sta *sta, void *priv_sta) struct ieee80211_sta *sta, void *priv_sta)
{ {
struct rtl_priv *rtlpriv = ppriv;
struct rtl_mac *mac = rtl_mac(rtlpriv);
u8 is_ht = conf_is_ht(&mac->hw->conf);
if ((mac->opmode == NL80211_IFTYPE_STATION) ||
(mac->opmode == NL80211_IFTYPE_MESH_POINT) ||
(mac->opmode == NL80211_IFTYPE_ADHOC)) {
switch (sband->band) {
case IEEE80211_BAND_2GHZ:
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_G;
if (is_ht)
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_NGB;
break;
case IEEE80211_BAND_5GHZ:
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_A;
if (is_ht)
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_NGB;
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
("Invalid band\n"));
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_NGB;
break;
}
RT_TRACE(rtlpriv, COMP_RATE, DBG_DMESG,
("Choosing rate table index: %d\n",
rtlpriv->rate_priv->cur_ratetab_idx));
}
} }
static void rtl_rate_update(void *ppriv, static void rtl_rate_update(void *ppriv,
...@@ -223,49 +228,6 @@ static void rtl_rate_update(void *ppriv, ...@@ -223,49 +228,6 @@ static void rtl_rate_update(void *ppriv,
u32 changed, u32 changed,
enum nl80211_channel_type oper_chan_type) enum nl80211_channel_type oper_chan_type)
{ {
struct rtl_priv *rtlpriv = ppriv;
struct rtl_mac *mac = rtl_mac(rtlpriv);
struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
bool oper_cw40 = false, oper_sgi40;
bool local_cw40 = mac->bw_40;
bool local_sgi40 = mac->sgi_40;
u8 is_ht = conf_is_ht(&mac->hw->conf);
if (changed & IEEE80211_RC_HT_CHANGED) {
if (mac->opmode != NL80211_IFTYPE_STATION)
return;
if (rtlhal->hw->conf.channel_type == NL80211_CHAN_HT40MINUS ||
rtlhal->hw->conf.channel_type == NL80211_CHAN_HT40PLUS)
oper_cw40 = true;
oper_sgi40 = mac->sgi_40;
if ((local_cw40 != oper_cw40) || (local_sgi40 != oper_sgi40)) {
switch (sband->band) {
case IEEE80211_BAND_2GHZ:
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_G;
if (is_ht)
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_NGB;
break;
case IEEE80211_BAND_5GHZ:
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_A;
if (is_ht)
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_NGB;
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
("Invalid band\n"));
rtlpriv->rate_priv->cur_ratetab_idx =
RATR_INX_WIRELESS_NGB;
break;
}
}
}
} }
static void *rtl_rate_alloc(struct ieee80211_hw *hw, static void *rtl_rate_alloc(struct ieee80211_hw *hw,
......
...@@ -30,8 +30,15 @@ ...@@ -30,8 +30,15 @@
#ifndef __RTL_RC_H__ #ifndef __RTL_RC_H__
#define __RTL_RC_H__ #define __RTL_RC_H__
#define B_MODE_MAX_RIX 3
#define G_MODE_MAX_RIX 11
#define A_MODE_MAX_RIX 7
/* in mac80211 mcs0-mcs15 is idx0-idx15*/
#define N_MODE_MCS7_RIX 7
#define N_MODE_MCS15_RIX 15
struct rtl_rate_priv { struct rtl_rate_priv {
u8 cur_ratetab_idx;
u8 ht_cap; u8 ht_cap;
}; };
......
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