Blame SOURCES/0021-rtw89-update-scan_mac_addr-during-scanning-period.patch

56e3f4
From 8e579520ae0aa2dc263b033b3ae93339804e6b38 Mon Sep 17 00:00:00 2001
56e3f4
From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= <ihuguet@redhat.com>
56e3f4
Date: Fri, 21 Jan 2022 08:49:03 +0100
56e3f4
Subject: [PATCH 21/36] rtw89: update scan_mac_addr during scanning period
56e3f4
MIME-Version: 1.0
56e3f4
Content-Type: text/plain; charset=UTF-8
56e3f4
Content-Transfer-Encoding: 8bit
56e3f4
56e3f4
Bugzilla: http://bugzilla.redhat.com/2033291
56e3f4
56e3f4
commit e45a9e6265d2591efb745c9ffa46f4e9cceb5c65
56e3f4
Author: Ping-Ke Shih <pkshih@realtek.com>
56e3f4
Date:   Thu Nov 11 10:37:05 2021 +0800
56e3f4
56e3f4
    rtw89: update scan_mac_addr during scanning period
56e3f4
56e3f4
    Update scan_mac_addr to address CAM as A1, so hardware can ACK probe
56e3f4
    response properly.
56e3f4
56e3f4
    Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
56e3f4
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
56e3f4
    Link: https://lore.kernel.org/r/20211111023706.14154-2-pkshih@realtek.com
56e3f4
56e3f4
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
56e3f4
---
56e3f4
 drivers/net/wireless/realtek/rtw89/cam.c      | 22 ++++++++++++----------
56e3f4
 drivers/net/wireless/realtek/rtw89/cam.h      |  3 ++-
56e3f4
 drivers/net/wireless/realtek/rtw89/core.c     |  4 ++--
56e3f4
 drivers/net/wireless/realtek/rtw89/fw.c       |  5 +++--
56e3f4
 drivers/net/wireless/realtek/rtw89/fw.h       |  3 ++-
56e3f4
 drivers/net/wireless/realtek/rtw89/mac.c      |  4 ++--
56e3f4
 drivers/net/wireless/realtek/rtw89/mac80211.c |  6 +++++-
56e3f4
 7 files changed, 28 insertions(+), 19 deletions(-)
56e3f4
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/cam.c b/drivers/net/wireless/realtek/rtw89/cam.c
56e3f4
index ad7a8155dbed..ce5056ad1e5c 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/cam.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/cam.c
56e3f4
@@ -243,7 +243,7 @@ static int rtw89_cam_attach_sec_cam(struct rtw89_dev *rtwdev,
56e3f4
 	addr_cam->sec_ent[key_idx] = sec_cam->sec_cam_idx;
56e3f4
 	addr_cam->sec_entries[key_idx] = sec_cam;
56e3f4
 	set_bit(key_idx, addr_cam->sec_cam_map);
56e3f4
-	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	if (ret) {
56e3f4
 		rtw89_err(rtwdev, "failed to update addr cam sec entry: %d\n",
56e3f4
 			  ret);
56e3f4
@@ -394,7 +394,7 @@ int rtw89_cam_sec_key_del(struct rtw89_dev *rtwdev,
56e3f4
 	clear_bit(key_idx, addr_cam->sec_cam_map);
56e3f4
 	addr_cam->sec_entries[key_idx] = NULL;
56e3f4
 	if (inform_fw) {
56e3f4
-		ret = rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+		ret = rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 		if (ret)
56e3f4
 			rtw89_err(rtwdev, "failed to update cam del key: %d\n", ret);
56e3f4
 	}
56e3f4
@@ -593,7 +593,7 @@ int rtw89_cam_fill_bssid_cam_info(struct rtw89_dev *rtwdev,
56e3f4
 	return 0;
56e3f4
 }
56e3f4
 
56e3f4
-static u8 rtw89_cam_addr_hash(u8 start, u8 *addr)
56e3f4
+static u8 rtw89_cam_addr_hash(u8 start, const u8 *addr)
56e3f4
 {
56e3f4
 	u8 hash = 0;
56e3f4
 	u8 i;
56e3f4
@@ -606,12 +606,14 @@ static u8 rtw89_cam_addr_hash(u8 start, u8 *addr)
56e3f4
 
56e3f4
 void rtw89_cam_fill_addr_cam_info(struct rtw89_dev *rtwdev,
56e3f4
 				  struct rtw89_vif *rtwvif,
56e3f4
+				  const u8 *scan_mac_addr,
56e3f4
 				  u8 *cmd)
56e3f4
 {
56e3f4
 	struct ieee80211_vif *vif = rtwvif_to_vif(rtwvif);
56e3f4
 	struct ieee80211_sta *sta;
56e3f4
 	struct rtw89_sta *rtwsta;
56e3f4
 	struct rtw89_addr_cam_entry *addr_cam = &rtwvif->addr_cam;
56e3f4
+	const u8 *sma = scan_mac_addr ? scan_mac_addr : rtwvif->mac_addr;
56e3f4
 	u8 sma_hash, tma_hash, addr_msk_start;
56e3f4
 	u8 sma_start = 0;
56e3f4
 	u8 tma_start = 0;
56e3f4
@@ -623,7 +625,7 @@ void rtw89_cam_fill_addr_cam_info(struct rtw89_dev *rtwdev,
56e3f4
 		else if (addr_cam->mask_sel == RTW89_TMA)
56e3f4
 			tma_start = addr_msk_start;
56e3f4
 	}
56e3f4
-	sma_hash = rtw89_cam_addr_hash(sma_start, rtwvif->mac_addr);
56e3f4
+	sma_hash = rtw89_cam_addr_hash(sma_start, sma);
56e3f4
 	tma_hash = rtw89_cam_addr_hash(tma_start, addr_cam->tma);
56e3f4
 
56e3f4
 	FWCMD_SET_ADDR_IDX(cmd, addr_cam->addr_cam_idx);
56e3f4
@@ -642,12 +644,12 @@ void rtw89_cam_fill_addr_cam_info(struct rtw89_dev *rtwdev,
56e3f4
 
56e3f4
 	FWCMD_SET_ADDR_BSSID_CAM_IDX(cmd, addr_cam->bssid_cam_idx);
56e3f4
 
56e3f4
-	FWCMD_SET_ADDR_SMA0(cmd, rtwvif->mac_addr[0]);
56e3f4
-	FWCMD_SET_ADDR_SMA1(cmd, rtwvif->mac_addr[1]);
56e3f4
-	FWCMD_SET_ADDR_SMA2(cmd, rtwvif->mac_addr[2]);
56e3f4
-	FWCMD_SET_ADDR_SMA3(cmd, rtwvif->mac_addr[3]);
56e3f4
-	FWCMD_SET_ADDR_SMA4(cmd, rtwvif->mac_addr[4]);
56e3f4
-	FWCMD_SET_ADDR_SMA5(cmd, rtwvif->mac_addr[5]);
56e3f4
+	FWCMD_SET_ADDR_SMA0(cmd, sma[0]);
56e3f4
+	FWCMD_SET_ADDR_SMA1(cmd, sma[1]);
56e3f4
+	FWCMD_SET_ADDR_SMA2(cmd, sma[2]);
56e3f4
+	FWCMD_SET_ADDR_SMA3(cmd, sma[3]);
56e3f4
+	FWCMD_SET_ADDR_SMA4(cmd, sma[4]);
56e3f4
+	FWCMD_SET_ADDR_SMA5(cmd, sma[5]);
56e3f4
 
56e3f4
 	FWCMD_SET_ADDR_TMA0(cmd, addr_cam->tma[0]);
56e3f4
 	FWCMD_SET_ADDR_TMA1(cmd, addr_cam->tma[1]);
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/cam.h b/drivers/net/wireless/realtek/rtw89/cam.h
56e3f4
index 41d7d2712027..c0f9ef12f530 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/cam.h
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/cam.h
56e3f4
@@ -347,7 +347,8 @@ static inline void FWCMD_SET_ADDR_BSSID_BSSID5(void *cmd, u32 value)
56e3f4
 int rtw89_cam_init(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
56e3f4
 void rtw89_cam_deinit(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
56e3f4
 void rtw89_cam_fill_addr_cam_info(struct rtw89_dev *rtwdev,
56e3f4
-				  struct rtw89_vif *vif, u8 *cmd);
56e3f4
+				  struct rtw89_vif *vif,
56e3f4
+				  const u8 *scan_mac_addr, u8 *cmd);
56e3f4
 int rtw89_cam_fill_bssid_cam_info(struct rtw89_dev *rtwdev,
56e3f4
 				  struct rtw89_vif *vif, u8 *cmd);
56e3f4
 int rtw89_cam_sec_key_add(struct rtw89_dev *rtwdev,
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
56e3f4
index d02ec5a735cb..6c91e99fd28f 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/core.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/core.c
56e3f4
@@ -1872,7 +1872,7 @@ int rtw89_core_sta_disconnect(struct rtw89_dev *rtwdev,
56e3f4
 	}
56e3f4
 
56e3f4
 	/* update cam aid mac_id net_type */
56e3f4
-	rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+	rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	if (ret) {
56e3f4
 		rtw89_warn(rtwdev, "failed to send h2c cam\n");
56e3f4
 		return ret;
56e3f4
@@ -1908,7 +1908,7 @@ int rtw89_core_sta_assoc(struct rtw89_dev *rtwdev,
56e3f4
 	}
56e3f4
 
56e3f4
 	/* update cam aid mac_id net_type */
56e3f4
-	rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+	rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	if (ret) {
56e3f4
 		rtw89_warn(rtwdev, "failed to send h2c cam\n");
56e3f4
 		return ret;
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
56e3f4
index 65ef3dc9d061..c9aa86e5d4e4 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/fw.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
56e3f4
@@ -523,7 +523,8 @@ void rtw89_unload_firmware(struct rtw89_dev *rtwdev)
56e3f4
 }
56e3f4
 
56e3f4
 #define H2C_CAM_LEN 60
56e3f4
-int rtw89_fw_h2c_cam(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
56e3f4
+int rtw89_fw_h2c_cam(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
56e3f4
+		     const u8 *scan_mac_addr)
56e3f4
 {
56e3f4
 	struct sk_buff *skb;
56e3f4
 
56e3f4
@@ -533,7 +534,7 @@ int rtw89_fw_h2c_cam(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
56e3f4
 		return -ENOMEM;
56e3f4
 	}
56e3f4
 	skb_put(skb, H2C_CAM_LEN);
56e3f4
-	rtw89_cam_fill_addr_cam_info(rtwdev, rtwvif, skb->data);
56e3f4
+	rtw89_cam_fill_addr_cam_info(rtwdev, rtwvif, scan_mac_addr, skb->data);
56e3f4
 	rtw89_cam_fill_bssid_cam_info(rtwdev, rtwvif, skb->data);
56e3f4
 
56e3f4
 	rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/fw.h b/drivers/net/wireless/realtek/rtw89/fw.h
56e3f4
index cf6898f7aaee..865170a89c4a 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/fw.h
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/fw.h
56e3f4
@@ -1756,7 +1756,8 @@ int rtw89_fw_h2c_assoc_cmac_tbl(struct rtw89_dev *rtwdev,
56e3f4
 				struct ieee80211_sta *sta);
56e3f4
 int rtw89_fw_h2c_txtime_cmac_tbl(struct rtw89_dev *rtwdev,
56e3f4
 				 struct rtw89_sta *rtwsta);
56e3f4
-int rtw89_fw_h2c_cam(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
56e3f4
+int rtw89_fw_h2c_cam(struct rtw89_dev *rtwdev, struct rtw89_vif *vif,
56e3f4
+		     const u8 *scan_mac_addr);
56e3f4
 void rtw89_fw_c2h_irqsafe(struct rtw89_dev *rtwdev, struct sk_buff *c2h);
56e3f4
 void rtw89_fw_c2h_work(struct work_struct *work);
56e3f4
 int rtw89_fw_h2c_vif_maintain(struct rtw89_dev *rtwdev,
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
56e3f4
index f8389e849c67..04c5f9966521 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/mac.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/mac.c
56e3f4
@@ -2990,7 +2990,7 @@ int rtw89_mac_vif_init(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
56e3f4
 	if (ret)
56e3f4
 		return ret;
56e3f4
 
56e3f4
-	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	if (ret)
56e3f4
 		return ret;
56e3f4
 
56e3f4
@@ -3011,7 +3011,7 @@ int rtw89_mac_vif_deinit(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
56e3f4
 
56e3f4
 	rtw89_cam_deinit(rtwdev, rtwvif);
56e3f4
 
56e3f4
-	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	if (ret)
56e3f4
 		return ret;
56e3f4
 
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c b/drivers/net/wireless/realtek/rtw89/mac80211.c
56e3f4
index 16dc6fb7dbb0..16381adf006e 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/mac80211.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
56e3f4
@@ -336,7 +336,7 @@ static void rtw89_ops_bss_info_changed(struct ieee80211_hw *hw,
56e3f4
 	if (changed & BSS_CHANGED_BSSID) {
56e3f4
 		ether_addr_copy(rtwvif->bssid, conf->bssid);
56e3f4
 		rtw89_cam_bssid_changed(rtwdev, rtwvif);
56e3f4
-		rtw89_fw_h2c_cam(rtwdev, rtwvif);
56e3f4
+		rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	}
56e3f4
 
56e3f4
 	if (changed & BSS_CHANGED_ERP_SLOT)
56e3f4
@@ -615,6 +615,7 @@ static void rtw89_ops_sw_scan_start(struct ieee80211_hw *hw,
56e3f4
 				    const u8 *mac_addr)
56e3f4
 {
56e3f4
 	struct rtw89_dev *rtwdev = hw->priv;
56e3f4
+	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
56e3f4
 	struct rtw89_hal *hal = &rtwdev->hal;
56e3f4
 
56e3f4
 	mutex_lock(&rtwdev->mutex);
56e3f4
@@ -623,6 +624,7 @@ static void rtw89_ops_sw_scan_start(struct ieee80211_hw *hw,
56e3f4
 	rtw89_btc_ntfy_scan_start(rtwdev, RTW89_PHY_0, hal->current_band_type);
56e3f4
 	rtw89_chip_rfk_scan(rtwdev, true);
56e3f4
 	rtw89_hci_recalc_int_mit(rtwdev);
56e3f4
+	rtw89_fw_h2c_cam(rtwdev, rtwvif, mac_addr);
56e3f4
 	mutex_unlock(&rtwdev->mutex);
56e3f4
 }
56e3f4
 
56e3f4
@@ -630,8 +632,10 @@ static void rtw89_ops_sw_scan_complete(struct ieee80211_hw *hw,
56e3f4
 				       struct ieee80211_vif *vif)
56e3f4
 {
56e3f4
 	struct rtw89_dev *rtwdev = hw->priv;
56e3f4
+	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
56e3f4
 
56e3f4
 	mutex_lock(&rtwdev->mutex);
56e3f4
+	rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL);
56e3f4
 	rtw89_chip_rfk_scan(rtwdev, false);
56e3f4
 	rtw89_btc_ntfy_scan_finish(rtwdev, RTW89_PHY_0);
56e3f4
 	rtwdev->scanning = false;
56e3f4
-- 
56e3f4
2.13.6
56e3f4