[RFC PATCH v3 3/4] wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips

Georg Müller posted 4 patches 3 weeks, 3 days ago
[RFC PATCH v3 3/4] wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips
Posted by Georg Müller 3 weeks, 3 days ago
---
 drivers/net/wireless/realtek/rtl8xxxu/core.c | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index 5ad23c5c9305..15fc4843edb2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -3884,6 +3884,15 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)
 	rtl8xxxu_write8(priv, REG_RSV_CTRL, val8);
 }
 
+static u8 rtl8xxxu_max_acquired_macid(struct rtl8xxxu_priv *priv)
+{
+	u8 macid;
+
+	macid = find_last_bit(priv->mac_id_map, RTL8XXXU_MAX_MAC_ID_NUM);
+
+	return macid;
+}
+
 static u8 rtl8xxxu_acquire_macid(struct rtl8xxxu_priv *priv)
 {
 	u8 macid;
@@ -7499,6 +7508,7 @@ static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
 	struct rtl8xxxu_sta_info *sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
 	struct rtl8xxxu_vif *rtlvif = (struct rtl8xxxu_vif *)vif->drv_priv;
 	struct rtl8xxxu_priv *priv = hw->priv;
+	u8 max_mac_id;
 
 	mutex_lock(&priv->sta_mutex);
 	ewma_rssi_init(&sta_info->avg_rssi);
@@ -7510,6 +7520,11 @@ static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
 			return -ENOSPC;
 		}
 
+		if (priv->rtl_chip == RTL8188E) {
+			max_mac_id = rtl8xxxu_max_acquired_macid(priv);
+			rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL + 1, max_mac_id + 1);
+		}
+
 		rtl8xxxu_refresh_rate_mask(priv, 0, sta, true);
 		priv->fops->report_connect(priv, sta_info->macid, H2C_MACID_ROLE_STA, true);
 	} else {
@@ -7535,10 +7550,16 @@ static int rtl8xxxu_sta_remove(struct ieee80211_hw *hw,
 {
 	struct rtl8xxxu_sta_info *sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
 	struct rtl8xxxu_priv *priv = hw->priv;
+	u8 max_mac_id;
 
 	mutex_lock(&priv->sta_mutex);
-	if (vif->type == NL80211_IFTYPE_AP)
+	if (vif->type == NL80211_IFTYPE_AP) {
 		rtl8xxxu_release_macid(priv, sta_info->macid);
+		if (priv->rtl_chip == RTL8188E) {
+			max_mac_id = rtl8xxxu_max_acquired_macid(priv);
+			rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL + 1, max_mac_id + 1);
+		}
+	}
 	mutex_unlock(&priv->sta_mutex);
 
 	return 0;
-- 
2.53.0
RE: [RFC PATCH v3 3/4] wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips
Posted by Ping-Ke Shih 3 weeks, 1 day ago
Georg Müller <georgmueller@gmx.net> wrote:

remember to add commit messages when you send formal patch.

> 
> ---
>  drivers/net/wireless/realtek/rtl8xxxu/core.c | 23 +++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> index 5ad23c5c9305..15fc4843edb2 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> @@ -3884,6 +3884,15 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)
>         rtl8xxxu_write8(priv, REG_RSV_CTRL, val8);
>  }
> 
> +static u8 rtl8xxxu_max_acquired_macid(struct rtl8xxxu_priv *priv)
> +{
> +       u8 macid;
> +
> +       macid = find_last_bit(priv->mac_id_map, RTL8XXXU_MAX_MAC_ID_NUM);
> +
> +       return macid;
> +}
> +
>  static u8 rtl8xxxu_acquire_macid(struct rtl8xxxu_priv *priv)
>  {
>         u8 macid;
> @@ -7499,6 +7508,7 @@ static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
>         struct rtl8xxxu_sta_info *sta_info = (struct rtl8xxxu_sta_info
> *)sta->drv_priv;
>         struct rtl8xxxu_vif *rtlvif = (struct rtl8xxxu_vif *)vif->drv_priv;
>         struct rtl8xxxu_priv *priv = hw->priv;
> +       u8 max_mac_id;
> 
>         mutex_lock(&priv->sta_mutex);
>         ewma_rssi_init(&sta_info->avg_rssi);
> @@ -7510,6 +7520,11 @@ static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
>                         return -ENOSPC;
>                 }
> 
> +               if (priv->rtl_chip == RTL8188E) {
> +                       max_mac_id = rtl8xxxu_max_acquired_macid(priv);
> +                       rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL + 1,
> max_mac_id + 1);
> +               }
> +
>                 rtl8xxxu_refresh_rate_mask(priv, 0, sta, true);
>                 priv->fops->report_connect(priv, sta_info->macid,
> H2C_MACID_ROLE_STA, true);
>         } else {
> @@ -7535,10 +7550,16 @@ static int rtl8xxxu_sta_remove(struct ieee80211_hw *hw,
>  {
>         struct rtl8xxxu_sta_info *sta_info = (struct rtl8xxxu_sta_info
> *)sta->drv_priv;
>         struct rtl8xxxu_priv *priv = hw->priv;
> +       u8 max_mac_id;
> 
>         mutex_lock(&priv->sta_mutex);
> -       if (vif->type == NL80211_IFTYPE_AP)
> +       if (vif->type == NL80211_IFTYPE_AP) {
>                 rtl8xxxu_release_macid(priv, sta_info->macid);
> +               if (priv->rtl_chip == RTL8188E) {
> +                       max_mac_id = rtl8xxxu_max_acquired_macid(priv);
> +                       rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL + 1,
> max_mac_id + 1);
> +               }
> +       }

At first glance, I'd say should we consider STA+AP concurrent case? 
Because days ago, we talked about that in another thread. 

It looks like MAC ID is another problem for concurrent case, because
rtl8xxxu_max_acquired_macid() returns MAC ID starting from 0.

But special MAC IDs are defined for non-AP vif:

#define RTL8XXXU_BC_MC_MACID	0
#define RTL8XXXU_BC_MC_MACID1	1

(But this is not scope of this patch.)

>         mutex_unlock(&priv->sta_mutex);
> 
>         return 0;
> --
> 2.53.0
>