]> git.baikalelectronics.ru Git - kernel.git/commitdiff
rtw88: add support for random mac scan
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Fri, 14 Jun 2019 07:24:06 +0000 (15:24 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 25 Jun 2019 05:08:54 +0000 (08:08 +0300)
When driver uses random mac address to scan, the unicast probe response
will not be received because the addr1 is not matched. Configure port
address by requested mac address to receive probe response from AP.

To support random mac scan, we need to configure the mac address during
scan period to receive unicast prop_resp. After scan is completed,
configure the mac address back to the original one that the port used.

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.c

index abded63f138d4e21d3f0c63b46b0fc69684a1e96..61436bb37427cecc97f0ff81216b7a0c2d82a7c0 100644 (file)
@@ -446,20 +446,39 @@ static void rtw_ops_sw_scan_start(struct ieee80211_hw *hw,
 {
        struct rtw_dev *rtwdev = hw->priv;
        struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
+       u32 config = 0;
 
        rtw_leave_lps(rtwdev, rtwvif);
 
+       mutex_lock(&rtwdev->mutex);
+
+       ether_addr_copy(rtwvif->mac_addr, mac_addr);
+       config |= PORT_SET_MAC_ADDR;
+       rtw_vif_port_config(rtwdev, rtwvif, config);
+
        rtw_flag_set(rtwdev, RTW_FLAG_DIG_DISABLE);
        rtw_flag_set(rtwdev, RTW_FLAG_SCANNING);
+
+       mutex_unlock(&rtwdev->mutex);
 }
 
 static void rtw_ops_sw_scan_complete(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif)
 {
        struct rtw_dev *rtwdev = hw->priv;
+       struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
+       u32 config = 0;
+
+       mutex_lock(&rtwdev->mutex);
 
        rtw_flag_clear(rtwdev, RTW_FLAG_SCANNING);
        rtw_flag_clear(rtwdev, RTW_FLAG_DIG_DISABLE);
+
+       ether_addr_copy(rtwvif->mac_addr, vif->addr);
+       config |= PORT_SET_MAC_ADDR;
+       rtw_vif_port_config(rtwdev, rtwvif, config);
+
+       mutex_unlock(&rtwdev->mutex);
 }
 
 const struct ieee80211_ops rtw_ops = {
index d2e8d2ee8b44bd30b1a520396fe51ab5cfdf247f..306d7992138885a29a515860baad23455e0fb227 100644 (file)
@@ -1178,6 +1178,8 @@ int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw)
        hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
                            WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
 
+       hw->wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
+
        rtw_set_supported_band(hw, rtwdev->chip);
        SET_IEEE80211_PERM_ADDR(hw, rtwdev->efuse.addr);