rtw89: extend role_maintain to support AP mode
authorPing-Ke Shih <pkshih@realtek.com>
Mon, 7 Feb 2022 06:38:54 +0000 (14:38 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 10 Feb 2022 08:40:49 +0000 (10:40 +0200)
Fill mac_id and self_role depends on the operation mode.

In AP mode, echo connected station has an unique mac_id, and each vif also
has one mac_id to represent itself.

The self_role is assigned to vif if the operation mode is decided, and
RTW89_SELF_ROLE_AP_CLIENT is assigned to the connected STA in AP mode,

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220207063900.43643-2-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h
drivers/net/wireless/realtek/rtw89/mac.c

index 2d5b6323b607d52d78c6809699a547799cab3ede..7fa60fd00143a03460e82a0d87c3c2dac3729036 100644 (file)
@@ -993,9 +993,21 @@ int rtw89_fw_h2c_update_beacon(struct rtw89_dev *rtwdev,
 #define H2C_ROLE_MAINTAIN_LEN 4
 int rtw89_fw_h2c_role_maintain(struct rtw89_dev *rtwdev,
                               struct rtw89_vif *rtwvif,
+                              struct rtw89_sta *rtwsta,
                               enum rtw89_upd_mode upd_mode)
 {
        struct sk_buff *skb;
+       u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id;
+       u8 self_role;
+
+       if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE) {
+               if (rtwsta)
+                       self_role = RTW89_SELF_ROLE_AP_CLIENT;
+               else
+                       self_role = rtwvif->self_role;
+       } else {
+               self_role = rtwvif->self_role;
+       }
 
        skb = rtw89_fw_h2c_alloc_skb_with_hdr(H2C_ROLE_MAINTAIN_LEN);
        if (!skb) {
@@ -1003,8 +1015,8 @@ int rtw89_fw_h2c_role_maintain(struct rtw89_dev *rtwdev,
                return -ENOMEM;
        }
        skb_put(skb, H2C_ROLE_MAINTAIN_LEN);
-       SET_FWROLE_MAINTAIN_MACID(skb->data, rtwvif->mac_id);
-       SET_FWROLE_MAINTAIN_SELF_ROLE(skb->data, rtwvif->self_role);
+       SET_FWROLE_MAINTAIN_MACID(skb->data, mac_id);
+       SET_FWROLE_MAINTAIN_SELF_ROLE(skb->data, self_role);
        SET_FWROLE_MAINTAIN_UPD_MODE(skb->data, upd_mode);
        SET_FWROLE_MAINTAIN_WIFI_ROLE(skb->data, rtwvif->wifi_role);
 
index b30cf0a2cc1e04fc00ac95fe04b6d216fe78eafd..83f4eaaf90f3be71525ceb8cd46d1418d4b4f476 100644 (file)
@@ -1886,6 +1886,7 @@ void rtw89_fw_c2h_irqsafe(struct rtw89_dev *rtwdev, struct sk_buff *c2h);
 void rtw89_fw_c2h_work(struct work_struct *work);
 int rtw89_fw_h2c_role_maintain(struct rtw89_dev *rtwdev,
                               struct rtw89_vif *rtwvif,
+                              struct rtw89_sta *rtwsta,
                               enum rtw89_upd_mode upd_mode);
 int rtw89_fw_h2c_join_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
                           struct rtw89_sta *rtwsta, bool dis_conn);
index 2e95d9007c41dbb96fe9aa0361f1b13f07f85ac2..2ced6a8b36c2dd133d5aeccd0f0ce4bfadc2b845 100644 (file)
@@ -3025,7 +3025,7 @@ int rtw89_mac_vif_init(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
        if (ret)
                return ret;
 
-       ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif, RTW89_ROLE_CREATE);
+       ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif, NULL, RTW89_ROLE_CREATE);
        if (ret)
                return ret;
 
@@ -3048,7 +3048,7 @@ int rtw89_mac_vif_deinit(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
 {
        int ret;
 
-       ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif, RTW89_ROLE_REMOVE);
+       ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif, NULL, RTW89_ROLE_REMOVE);
        if (ret)
                return ret;