rtlwifi: Add rtl_get_hal_edca_param() to generate register's format of EDCA.
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 29 Sep 2017 19:47:55 +0000 (14:47 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 13 Oct 2017 09:43:39 +0000 (12:43 +0300)
Convert from the value of ieee80211_tx_queue_params to Realtek's
register value.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Yan-Hsuan Chuang <yhchuang@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtlwifi/base.c
drivers/net/wireless/realtek/rtlwifi/base.h

index e37d4c7..081b950 100644 (file)
@@ -1557,6 +1557,42 @@ void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms)
                         "Wait 1ms (%d/%d) to disable key.\n", i, wait_ms);
        }
 }
+
+u32 rtl_get_hal_edca_param(struct ieee80211_hw *hw,
+                          struct ieee80211_vif *vif,
+                          enum wireless_mode wirelessmode,
+                          struct ieee80211_tx_queue_params *param)
+{
+       u32 reg = 0;
+       u8 sifstime = 10;
+       u8 slottime = 20;
+
+       /* AIFS = AIFSN * slot time + SIFS */
+       switch (wirelessmode) {
+       case WIRELESS_MODE_A:
+       case WIRELESS_MODE_N_24G:
+       case WIRELESS_MODE_N_5G:
+       case WIRELESS_MODE_AC_5G:
+       case WIRELESS_MODE_AC_24G:
+               sifstime = 16;
+               slottime = 9;
+               break;
+       case WIRELESS_MODE_G:
+               slottime = (vif->bss_conf.use_short_slot ? 9 : 20);
+               break;
+       default:
+               break;
+       }
+
+       reg |= (param->txop & 0x7FF) << 16;
+       reg |= (fls(param->cw_max) & 0xF) << 12;
+       reg |= (fls(param->cw_min) & 0xF) << 8;
+       reg |= (param->aifs & 0x0F) * slottime + sifstime;
+
+       return reg;
+}
+EXPORT_SYMBOL_GPL(rtl_get_hal_edca_param);
+
 /*********************************************************
  *
  * functions called by core.c
index b56d1b7..cfea9fc 100644 (file)
@@ -137,6 +137,10 @@ void rtl_tx_report_handler(struct ieee80211_hw *hw, u8 *tmp_buf,
                           u8 c2h_cmd_len);
 bool rtl_check_tx_report_acked(struct ieee80211_hw *hw);
 void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms);
+u32 rtl_get_hal_edca_param(struct ieee80211_hw *hw,
+                          struct ieee80211_vif *vif,
+                          enum wireless_mode wirelessmode,
+                          struct ieee80211_tx_queue_params *param);
 
 void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb);
 void rtl_collect_scan_list(struct ieee80211_hw *hw, struct sk_buff *skb);