rtw88: allows to set RTS in TX descriptor
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Wed, 2 Oct 2019 06:35:19 +0000 (14:35 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 4 Oct 2019 13:44:55 +0000 (16:44 +0300)
Allows driver to send RTS by filling tx descriptor.

The user may want to set the rts threshold. But since we have not
been taking over rate control from mac80211 to driver by setting flag
IEEE80211_HW_HAS_RATE_CONTROL, there is nothing we can do about it.
So here just store the value, and mac80211 will tell us to use rts
protection by ieee80211_tx_info::control::use_rts.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtw88/mac80211.c
drivers/net/wireless/realtek/rtw88/main.h
drivers/net/wireless/realtek/rtw88/tx.c
drivers/net/wireless/realtek/rtw88/tx.h

index 97777c7fdce804e1cbc2628730d7b0fc3cde9043..1646f38fd94071f9df5a860c8b6c85506900e880 100644 (file)
@@ -541,6 +541,17 @@ static void rtw_ops_mgd_prepare_tx(struct ieee80211_hw *hw,
        mutex_unlock(&rtwdev->mutex);
 }
 
+static int rtw_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
+{
+       struct rtw_dev *rtwdev = hw->priv;
+
+       mutex_lock(&rtwdev->mutex);
+       rtwdev->rts_threshold = value;
+       mutex_unlock(&rtwdev->mutex);
+
+       return 0;
+}
+
 const struct ieee80211_ops rtw_ops = {
        .tx                     = rtw_ops_tx,
        .start                  = rtw_ops_start,
@@ -557,5 +568,6 @@ const struct ieee80211_ops rtw_ops = {
        .sw_scan_start          = rtw_ops_sw_scan_start,
        .sw_scan_complete       = rtw_ops_sw_scan_complete,
        .mgd_prepare_tx         = rtw_ops_mgd_prepare_tx,
+       .set_rts_threshold      = rtw_ops_set_rts_threshold,
 };
 EXPORT_SYMBOL(rtw_ops);
index 161297ad7d99f223db0f4ff7a98e7365fd06e55e..810bf151ad36c4e92122d67f61726a1915ae50eb 100644 (file)
@@ -484,6 +484,7 @@ struct rtw_tx_pkt_info {
        bool fs;
        bool short_gi;
        bool report;
+       bool rts;
 };
 
 struct rtw_rx_pkt_stat {
@@ -1377,6 +1378,7 @@ struct rtw_dev {
        struct dentry *debugfs;
 
        u8 sta_cnt;
+       u32 rts_threshold;
 
        DECLARE_BITMAP(mac_id_map, RTW_MAX_MAC_ID_NUM);
        DECLARE_BITMAP(flags, NUM_OF_RTW_FLAGS);
index 91bfd8c28ff7ad5caae20cd23c3c6697f9b9cb89..25fa932d02083f4a99792e1bba24bee149ebd4f0 100644 (file)
@@ -56,6 +56,7 @@ void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb)
        SET_TX_DESC_DATA_SHORT(txdesc, pkt_info->short_gi);
        SET_TX_DESC_SPE_RPT(txdesc, pkt_info->report);
        SET_TX_DESC_SW_DEFINE(txdesc, pkt_info->sn);
+       SET_TX_DESC_USE_RTS(txdesc, pkt_info->rts);
 }
 EXPORT_SYMBOL(rtw_tx_fill_tx_desc);
 
@@ -258,6 +259,9 @@ static void rtw_tx_data_pkt_info_update(struct rtw_dev *rtwdev,
                ampdu_density = get_tx_ampdu_density(sta);
        }
 
+       if (info->control.use_rts)
+               pkt_info->rts = true;
+
        if (sta->vht_cap.vht_supported)
                rate = get_highest_vht_tx_rate(rtwdev, sta);
        else if (sta->ht_cap.ht_supported)
index 8338dbf5557679afa2132ffe639cebf5ea270600..ab5b71f8ac2275b5be391c1be80ea24d9ddbe4b9 100644 (file)
@@ -35,6 +35,8 @@
        le32p_replace_bits((__le32 *)(txdesc) + 0x09, value, GENMASK(23, 12))
 #define SET_TX_DESC_MAX_AGG_NUM(txdesc, value)                                 \
        le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, GENMASK(21, 17))
+#define SET_TX_DESC_USE_RTS(tx_desc, value)                                    \
+       le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(12))
 #define SET_TX_DESC_AMPDU_DENSITY(txdesc, value)                               \
        le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, GENMASK(22, 20))
 #define SET_TX_DESC_DATA_STBC(txdesc, value)                                   \