* [PATCH v3 1/2] mt76: connac: add mt76_connac_mcu_update_sta_cmd support
@ 2021-06-03 3:02 ` sean.wang
0 siblings, 0 replies; 8+ messages in thread
From: sean.wang @ 2021-06-03 3:02 UTC (permalink / raw)
To: nbd, lorenzo.bianconi
Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun, Eric.Liang,
Stella.Chang, jemele, yenlinlai, linux-wireless, linux-mediatek
From: Sean Wang <sean.wang@mediatek.com>
Add mt76_connac_mcu_update_sta_cmd support that is the prerequisite patch
for we are able to update the station record with the current state the
station has into the offload firmware at runtime.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v1->v2: no change
v2->v3: 1. rebase the latest mt76
2. turn into using enum mt76_sta_info_state
3. drop unneeded .state parameter passing in __mt7615_mcu_add_sta
4. make mt76_connac_mcu_add_sta_cmd and
mt76_connac_mcu_update_sta_cmd static inline in
mt76_connac_mcu.h
---
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 5 +--
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 21 +++++++------
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 31 ++++++++++++++++---
.../net/wireless/mediatek/mt76/mt7921/main.c | 8 +++--
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++-
.../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +-
6 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index cf4a4f2637d5..2f73bcb607dd 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1028,9 +1028,10 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
if (IS_ERR(sskb))
return PTR_ERR(sskb);
- mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable);
+ mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable, true);
if (enable && sta)
- mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0);
+ mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0,
+ MT76_STA_INFO_STATE_ASSOC);
wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
WTBL_RESET_AND_SET, NULL,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index b155e7b8d89d..45465eb3581a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -304,7 +304,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_alloc_wtbl_req);
void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
- bool enable)
+ bool enable, bool newly)
{
struct sta_rec_basic *basic;
struct tlv *tlv;
@@ -316,7 +316,8 @@ void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
basic->extra_info = cpu_to_le16(EXTRA_INFO_VER);
if (enable) {
- basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
+ if (newly)
+ basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
basic->conn_state = CONN_STATE_PORT_SECURE;
} else {
basic->conn_state = CONN_STATE_DISCONNECT;
@@ -709,7 +710,7 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
struct ieee80211_sta *sta,
struct ieee80211_vif *vif,
- u8 rcpi)
+ u8 rcpi, u8 sta_state)
{
struct cfg80211_chan_def *chandef = &mphy->chandef;
enum nl80211_band band = chandef->chan->band;
@@ -770,7 +771,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_STATE, sizeof(*state));
state = (struct sta_rec_state *)tlv;
- state->state = 2;
+ state->state = sta_state;
if (sta->vht_cap.vht_supported) {
state->vht_opmode = sta->bandwidth;
@@ -862,8 +863,9 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
}
EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ht_tlv);
-int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
- struct mt76_sta_cmd_info *info)
+int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info,
+ bool newly)
{
struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv;
struct mt76_dev *dev = phy->dev;
@@ -875,10 +877,11 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
if (IS_ERR(skb))
return PTR_ERR(skb);
- mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable);
+ mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable,
+ newly);
if (info->enable && info->sta)
mt76_connac_mcu_sta_tlv(phy, skb, info->sta, info->vif,
- info->rcpi);
+ info->rcpi, info->state);
sta_wtbl = mt76_connac_mcu_add_tlv(skb, STA_REC_WTBL,
sizeof(struct tlv));
@@ -902,7 +905,7 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
}
-EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_sta_cmd);
+EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_cmd);
void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_ampdu_params *params,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 3076417ead5f..c7b809ff3045 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -904,6 +904,12 @@ struct mt76_connac_suspend_tlv {
u8 pad[5];
} __packed;
+enum mt76_sta_info_state {
+ MT76_STA_INFO_STATE_NONE,
+ MT76_STA_INFO_STATE_AUTH,
+ MT76_STA_INFO_STATE_ASSOC
+};
+
struct mt76_sta_cmd_info {
struct ieee80211_sta *sta;
struct mt76_wcid *wcid;
@@ -913,6 +919,7 @@ struct mt76_sta_cmd_info {
bool enable;
int cmd;
u8 rcpi;
+ u8 state;
};
#define MT_SKU_POWER_LIMIT 161
@@ -982,7 +989,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif,
- struct ieee80211_sta *sta, bool enable);
+ struct ieee80211_sta *sta, bool enable,
+ bool newly);
void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta, void *sta_wtbl,
@@ -997,7 +1005,7 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev,
void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
struct ieee80211_sta *sta,
struct ieee80211_vif *vif,
- u8 rcpi);
+ u8 rcpi, u8 state);
void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_sta *sta, void *sta_wtbl,
void *wtbl_tlv);
@@ -1019,8 +1027,9 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
struct ieee80211_vif *vif,
struct mt76_wcid *wcid,
bool enable);
-int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
- struct mt76_sta_cmd_info *info);
+int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info,
+ bool newly);
void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac,
struct ieee80211_vif *vif);
int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band);
@@ -1059,4 +1068,18 @@ int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable);
void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb,
struct mt76_connac_coredump *coredump);
int mt76_connac_mcu_set_rate_txpower(struct mt76_phy *phy);
+
+static inline int
+mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info)
+{
+ return mt76_connac_mcu_sta_cmd(phy, info, true);
+}
+
+static inline int
+mt76_connac_mcu_update_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info)
+{
+ return mt76_connac_mcu_sta_cmd(phy, info, false);
+}
#endif /* __MT76_CONNAC_MCU_H */
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 84930ad5ebc7..c641a92b140c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -578,7 +578,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
mt7921_mcu_uni_bss_ps(dev, vif);
if (changed & BSS_CHANGED_ASSOC) {
- mt7921_mcu_sta_add(dev, NULL, vif, true);
+ mt7921_mcu_sta_add(dev, NULL, vif, true,
+ MT76_STA_INFO_STATE_ASSOC);
mt7921_bss_bcnft_apply(dev, vif, info->assoc);
}
@@ -627,7 +628,8 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- ret = mt7921_mcu_sta_add(dev, sta, vif, true);
+ ret = mt7921_mcu_sta_add(dev, sta, vif, true,
+ MT76_STA_INFO_STATE_ASSOC);
if (ret)
return ret;
@@ -645,7 +647,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);
- mt7921_mcu_sta_add(dev, sta, vif, false);
+ mt7921_mcu_sta_add(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
mt7921_mac_wtbl_update(dev, msta->wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index ffc83717fd0d..4f0fd9674950 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -1268,7 +1268,8 @@ int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
}
int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
- struct ieee80211_vif *vif, bool enable)
+ struct ieee80211_vif *vif, bool enable,
+ enum mt76_sta_info_state state)
{
struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
int rssi = -ewma_rssi_read(&mvif->rssi);
@@ -1276,6 +1277,7 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
.sta = sta,
.vif = vif,
.enable = enable,
+ .state = state,
.cmd = MCU_UNI_CMD_STA_REC_UPDATE,
.rcpi = to_rcpi(rssi),
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index 8aa8d2ecdffa..d4d84b898011 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -263,7 +263,8 @@ int mt7921_mcu_add_key(struct mt7921_dev *dev, struct ieee80211_vif *vif,
enum set_key_cmd cmd);
int mt7921_set_channel(struct mt7921_phy *phy);
int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
- struct ieee80211_vif *vif, bool enable);
+ struct ieee80211_vif *vif, bool enable,
+ enum mt76_sta_info_state state);
int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 1/2] mt76: connac: add mt76_connac_mcu_update_sta_cmd support
@ 2021-06-03 3:02 ` sean.wang
0 siblings, 0 replies; 8+ messages in thread
From: sean.wang @ 2021-06-03 3:02 UTC (permalink / raw)
To: nbd, lorenzo.bianconi
Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun, Eric.Liang,
Stella.Chang, jemele, yenlinlai, linux-wireless, linux-mediatek
From: Sean Wang <sean.wang@mediatek.com>
Add mt76_connac_mcu_update_sta_cmd support that is the prerequisite patch
for we are able to update the station record with the current state the
station has into the offload firmware at runtime.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v1->v2: no change
v2->v3: 1. rebase the latest mt76
2. turn into using enum mt76_sta_info_state
3. drop unneeded .state parameter passing in __mt7615_mcu_add_sta
4. make mt76_connac_mcu_add_sta_cmd and
mt76_connac_mcu_update_sta_cmd static inline in
mt76_connac_mcu.h
---
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 5 +--
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 21 +++++++------
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 31 ++++++++++++++++---
.../net/wireless/mediatek/mt76/mt7921/main.c | 8 +++--
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++-
.../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +-
6 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index cf4a4f2637d5..2f73bcb607dd 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1028,9 +1028,10 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
if (IS_ERR(sskb))
return PTR_ERR(sskb);
- mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable);
+ mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable, true);
if (enable && sta)
- mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0);
+ mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0,
+ MT76_STA_INFO_STATE_ASSOC);
wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
WTBL_RESET_AND_SET, NULL,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index b155e7b8d89d..45465eb3581a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -304,7 +304,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_alloc_wtbl_req);
void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
- bool enable)
+ bool enable, bool newly)
{
struct sta_rec_basic *basic;
struct tlv *tlv;
@@ -316,7 +316,8 @@ void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
basic->extra_info = cpu_to_le16(EXTRA_INFO_VER);
if (enable) {
- basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
+ if (newly)
+ basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
basic->conn_state = CONN_STATE_PORT_SECURE;
} else {
basic->conn_state = CONN_STATE_DISCONNECT;
@@ -709,7 +710,7 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
struct ieee80211_sta *sta,
struct ieee80211_vif *vif,
- u8 rcpi)
+ u8 rcpi, u8 sta_state)
{
struct cfg80211_chan_def *chandef = &mphy->chandef;
enum nl80211_band band = chandef->chan->band;
@@ -770,7 +771,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_STATE, sizeof(*state));
state = (struct sta_rec_state *)tlv;
- state->state = 2;
+ state->state = sta_state;
if (sta->vht_cap.vht_supported) {
state->vht_opmode = sta->bandwidth;
@@ -862,8 +863,9 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
}
EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ht_tlv);
-int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
- struct mt76_sta_cmd_info *info)
+int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info,
+ bool newly)
{
struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv;
struct mt76_dev *dev = phy->dev;
@@ -875,10 +877,11 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
if (IS_ERR(skb))
return PTR_ERR(skb);
- mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable);
+ mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable,
+ newly);
if (info->enable && info->sta)
mt76_connac_mcu_sta_tlv(phy, skb, info->sta, info->vif,
- info->rcpi);
+ info->rcpi, info->state);
sta_wtbl = mt76_connac_mcu_add_tlv(skb, STA_REC_WTBL,
sizeof(struct tlv));
@@ -902,7 +905,7 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
}
-EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_sta_cmd);
+EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_cmd);
void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_ampdu_params *params,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 3076417ead5f..c7b809ff3045 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -904,6 +904,12 @@ struct mt76_connac_suspend_tlv {
u8 pad[5];
} __packed;
+enum mt76_sta_info_state {
+ MT76_STA_INFO_STATE_NONE,
+ MT76_STA_INFO_STATE_AUTH,
+ MT76_STA_INFO_STATE_ASSOC
+};
+
struct mt76_sta_cmd_info {
struct ieee80211_sta *sta;
struct mt76_wcid *wcid;
@@ -913,6 +919,7 @@ struct mt76_sta_cmd_info {
bool enable;
int cmd;
u8 rcpi;
+ u8 state;
};
#define MT_SKU_POWER_LIMIT 161
@@ -982,7 +989,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif,
- struct ieee80211_sta *sta, bool enable);
+ struct ieee80211_sta *sta, bool enable,
+ bool newly);
void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta, void *sta_wtbl,
@@ -997,7 +1005,7 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev,
void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
struct ieee80211_sta *sta,
struct ieee80211_vif *vif,
- u8 rcpi);
+ u8 rcpi, u8 state);
void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_sta *sta, void *sta_wtbl,
void *wtbl_tlv);
@@ -1019,8 +1027,9 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
struct ieee80211_vif *vif,
struct mt76_wcid *wcid,
bool enable);
-int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
- struct mt76_sta_cmd_info *info);
+int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info,
+ bool newly);
void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac,
struct ieee80211_vif *vif);
int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band);
@@ -1059,4 +1068,18 @@ int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable);
void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb,
struct mt76_connac_coredump *coredump);
int mt76_connac_mcu_set_rate_txpower(struct mt76_phy *phy);
+
+static inline int
+mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info)
+{
+ return mt76_connac_mcu_sta_cmd(phy, info, true);
+}
+
+static inline int
+mt76_connac_mcu_update_sta_cmd(struct mt76_phy *phy,
+ struct mt76_sta_cmd_info *info)
+{
+ return mt76_connac_mcu_sta_cmd(phy, info, false);
+}
#endif /* __MT76_CONNAC_MCU_H */
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 84930ad5ebc7..c641a92b140c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -578,7 +578,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
mt7921_mcu_uni_bss_ps(dev, vif);
if (changed & BSS_CHANGED_ASSOC) {
- mt7921_mcu_sta_add(dev, NULL, vif, true);
+ mt7921_mcu_sta_add(dev, NULL, vif, true,
+ MT76_STA_INFO_STATE_ASSOC);
mt7921_bss_bcnft_apply(dev, vif, info->assoc);
}
@@ -627,7 +628,8 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- ret = mt7921_mcu_sta_add(dev, sta, vif, true);
+ ret = mt7921_mcu_sta_add(dev, sta, vif, true,
+ MT76_STA_INFO_STATE_ASSOC);
if (ret)
return ret;
@@ -645,7 +647,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);
- mt7921_mcu_sta_add(dev, sta, vif, false);
+ mt7921_mcu_sta_add(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
mt7921_mac_wtbl_update(dev, msta->wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index ffc83717fd0d..4f0fd9674950 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -1268,7 +1268,8 @@ int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
}
int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
- struct ieee80211_vif *vif, bool enable)
+ struct ieee80211_vif *vif, bool enable,
+ enum mt76_sta_info_state state)
{
struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
int rssi = -ewma_rssi_read(&mvif->rssi);
@@ -1276,6 +1277,7 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
.sta = sta,
.vif = vif,
.enable = enable,
+ .state = state,
.cmd = MCU_UNI_CMD_STA_REC_UPDATE,
.rcpi = to_rcpi(rssi),
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index 8aa8d2ecdffa..d4d84b898011 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -263,7 +263,8 @@ int mt7921_mcu_add_key(struct mt7921_dev *dev, struct ieee80211_vif *vif,
enum set_key_cmd cmd);
int mt7921_set_channel(struct mt7921_phy *phy);
int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
- struct ieee80211_vif *vif, bool enable);
+ struct ieee80211_vif *vif, bool enable,
+ enum mt76_sta_info_state state);
int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
--
2.25.1
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/2] mt76: mt7921: fix sta_state incorrect implementation
2021-06-03 3:02 ` sean.wang
@ 2021-06-03 3:02 ` sean.wang
-1 siblings, 0 replies; 8+ messages in thread
From: sean.wang @ 2021-06-03 3:02 UTC (permalink / raw)
To: nbd, lorenzo.bianconi
Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun, Eric.Liang,
Stella.Chang, jemele, yenlinlai, linux-wireless, linux-mediatek
From: Sean Wang <sean.wang@mediatek.com>
When .sta_state is implemented, mac80211 assumes that the station entry is
usable after the NOTEXIST->NONE transition.
So we should create the sta entry as early as possible in order that
mac80211 pass assoc/auth frames to mt76 with the newly created sta entry,
and add .sta_assoc to mt76 core to refresh the sta entry again when sta is
being associated.
Fixes: 8aa5a9b7361c ("mt76: mt7921: enable deep sleep at runtime")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v1->v2: Put back the careless change not belonged to the patch to keep
mt7921_mcu_sta_add for BC entry and mt76_connac_mcu_uni_add_bss
on the association.
v2->v3: 1. rebase the latest mt76
2. squashing 2/3 to the one
3. add the proper lock in mt7921_mac_sta_assoc
---
.../net/wireless/mediatek/mt76/mt7921/main.c | 55 ++++++++-----------
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 20 +++++++
.../wireless/mediatek/mt76/mt7921/mt7921.h | 4 ++
.../net/wireless/mediatek/mt76/mt7921/pci.c | 1 +
4 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index c641a92b140c..af98835b5134 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -618,18 +618,14 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (ret)
return ret;
- if (vif->type == NL80211_IFTYPE_STATION) {
+ if (vif->type == NL80211_IFTYPE_STATION)
mvif->wep_sta = msta;
- if (!sta->tdls)
- mt76_connac_mcu_uni_add_bss(&dev->mphy, vif,
- &mvif->sta.wcid, true);
- }
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
ret = mt7921_mcu_sta_add(dev, sta, vif, true,
- MT76_STA_INFO_STATE_ASSOC);
+ MT76_STA_INFO_STATE_NONE);
if (ret)
return ret;
@@ -638,6 +634,27 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
return 0;
}
+void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
+ struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
+ struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
+
+ mt7921_mutex_acquire(dev);
+
+ if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
+ mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
+ true);
+
+ mt7921_mac_wtbl_update(dev, msta->wcid.idx,
+ MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
+
+ mt7921_mcu_sta_update(dev, sta, vif, MT76_STA_INFO_STATE_ASSOC);
+
+ mt7921_mutex_release(dev);
+}
+
void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
@@ -793,22 +810,6 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return ret;
}
-static int
-mt7921_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
-{
- return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
- IEEE80211_STA_NONE);
-}
-
-static int
-mt7921_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
-{
- return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
- IEEE80211_STA_NOTEXIST);
-}
-
static int mt7921_sta_state(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
@@ -823,15 +824,7 @@ static int mt7921_sta_state(struct ieee80211_hw *hw,
mt7921_mutex_release(dev);
}
- if (old_state == IEEE80211_STA_AUTH &&
- new_state == IEEE80211_STA_ASSOC) {
- return mt7921_sta_add(hw, vif, sta);
- } else if (old_state == IEEE80211_STA_ASSOC &&
- new_state == IEEE80211_STA_AUTH) {
- return mt7921_sta_remove(hw, vif, sta);
- }
-
- return 0;
+ return mt76_sta_state(hw, vif, sta, old_state, new_state);
}
static int
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 4f0fd9674950..ab338bdf4f4a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -1289,6 +1289,26 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
return mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
}
+int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
+ struct ieee80211_vif *vif, u8 state)
+{
+ struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
+ int rssi = -ewma_rssi_read(&mvif->rssi);
+ struct mt76_sta_cmd_info info = {
+ .sta = sta,
+ .vif = vif,
+ .enable = true,
+ .state = state,
+ .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
+ .rcpi = to_rcpi(rssi),
+ };
+ struct mt7921_sta *msta;
+
+ msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL;
+ info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
+ return mt76_connac_mcu_update_sta_cmd(&dev->mphy, &info);
+}
+
int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev)
{
struct mt76_phy *mphy = &dev->mt76.phy;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index d4d84b898011..196e47f89fc1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -265,6 +265,8 @@ int mt7921_set_channel(struct mt7921_phy *phy);
int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
struct ieee80211_vif *vif, bool enable,
enum mt76_sta_info_state state);
+int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
+ struct ieee80211_vif *vif, u8 state);
int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
@@ -336,6 +338,8 @@ void mt7921_mac_fill_rx_vector(struct mt7921_dev *dev, struct sk_buff *skb);
void mt7921_mac_tx_free(struct mt7921_dev *dev, struct sk_buff *skb);
int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
+void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta);
void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
void mt7921_mac_work(struct work_struct *work);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
index 13263f50dc00..27906b2cd912 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
@@ -106,6 +106,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
.rx_poll_complete = mt7921_rx_poll_complete,
.sta_ps = mt7921_sta_ps,
.sta_add = mt7921_mac_sta_add,
+ .sta_assoc = mt7921_mac_sta_assoc,
.sta_remove = mt7921_mac_sta_remove,
.update_survey = mt7921_update_channel,
};
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/2] mt76: mt7921: fix sta_state incorrect implementation
@ 2021-06-03 3:02 ` sean.wang
0 siblings, 0 replies; 8+ messages in thread
From: sean.wang @ 2021-06-03 3:02 UTC (permalink / raw)
To: nbd, lorenzo.bianconi
Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun, Eric.Liang,
Stella.Chang, jemele, yenlinlai, linux-wireless, linux-mediatek
From: Sean Wang <sean.wang@mediatek.com>
When .sta_state is implemented, mac80211 assumes that the station entry is
usable after the NOTEXIST->NONE transition.
So we should create the sta entry as early as possible in order that
mac80211 pass assoc/auth frames to mt76 with the newly created sta entry,
and add .sta_assoc to mt76 core to refresh the sta entry again when sta is
being associated.
Fixes: 8aa5a9b7361c ("mt76: mt7921: enable deep sleep at runtime")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v1->v2: Put back the careless change not belonged to the patch to keep
mt7921_mcu_sta_add for BC entry and mt76_connac_mcu_uni_add_bss
on the association.
v2->v3: 1. rebase the latest mt76
2. squashing 2/3 to the one
3. add the proper lock in mt7921_mac_sta_assoc
---
.../net/wireless/mediatek/mt76/mt7921/main.c | 55 ++++++++-----------
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 20 +++++++
.../wireless/mediatek/mt76/mt7921/mt7921.h | 4 ++
.../net/wireless/mediatek/mt76/mt7921/pci.c | 1 +
4 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index c641a92b140c..af98835b5134 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -618,18 +618,14 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (ret)
return ret;
- if (vif->type == NL80211_IFTYPE_STATION) {
+ if (vif->type == NL80211_IFTYPE_STATION)
mvif->wep_sta = msta;
- if (!sta->tdls)
- mt76_connac_mcu_uni_add_bss(&dev->mphy, vif,
- &mvif->sta.wcid, true);
- }
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
ret = mt7921_mcu_sta_add(dev, sta, vif, true,
- MT76_STA_INFO_STATE_ASSOC);
+ MT76_STA_INFO_STATE_NONE);
if (ret)
return ret;
@@ -638,6 +634,27 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
return 0;
}
+void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
+ struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
+ struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
+
+ mt7921_mutex_acquire(dev);
+
+ if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
+ mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
+ true);
+
+ mt7921_mac_wtbl_update(dev, msta->wcid.idx,
+ MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
+
+ mt7921_mcu_sta_update(dev, sta, vif, MT76_STA_INFO_STATE_ASSOC);
+
+ mt7921_mutex_release(dev);
+}
+
void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
@@ -793,22 +810,6 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return ret;
}
-static int
-mt7921_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
-{
- return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
- IEEE80211_STA_NONE);
-}
-
-static int
-mt7921_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
-{
- return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
- IEEE80211_STA_NOTEXIST);
-}
-
static int mt7921_sta_state(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
@@ -823,15 +824,7 @@ static int mt7921_sta_state(struct ieee80211_hw *hw,
mt7921_mutex_release(dev);
}
- if (old_state == IEEE80211_STA_AUTH &&
- new_state == IEEE80211_STA_ASSOC) {
- return mt7921_sta_add(hw, vif, sta);
- } else if (old_state == IEEE80211_STA_ASSOC &&
- new_state == IEEE80211_STA_AUTH) {
- return mt7921_sta_remove(hw, vif, sta);
- }
-
- return 0;
+ return mt76_sta_state(hw, vif, sta, old_state, new_state);
}
static int
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 4f0fd9674950..ab338bdf4f4a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -1289,6 +1289,26 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
return mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
}
+int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
+ struct ieee80211_vif *vif, u8 state)
+{
+ struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
+ int rssi = -ewma_rssi_read(&mvif->rssi);
+ struct mt76_sta_cmd_info info = {
+ .sta = sta,
+ .vif = vif,
+ .enable = true,
+ .state = state,
+ .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
+ .rcpi = to_rcpi(rssi),
+ };
+ struct mt7921_sta *msta;
+
+ msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL;
+ info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
+ return mt76_connac_mcu_update_sta_cmd(&dev->mphy, &info);
+}
+
int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev)
{
struct mt76_phy *mphy = &dev->mt76.phy;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index d4d84b898011..196e47f89fc1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -265,6 +265,8 @@ int mt7921_set_channel(struct mt7921_phy *phy);
int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
struct ieee80211_vif *vif, bool enable,
enum mt76_sta_info_state state);
+int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
+ struct ieee80211_vif *vif, u8 state);
int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
@@ -336,6 +338,8 @@ void mt7921_mac_fill_rx_vector(struct mt7921_dev *dev, struct sk_buff *skb);
void mt7921_mac_tx_free(struct mt7921_dev *dev, struct sk_buff *skb);
int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
+void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta);
void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
void mt7921_mac_work(struct work_struct *work);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
index 13263f50dc00..27906b2cd912 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
@@ -106,6 +106,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
.rx_poll_complete = mt7921_rx_poll_complete,
.sta_ps = mt7921_sta_ps,
.sta_add = mt7921_mac_sta_add,
+ .sta_assoc = mt7921_mac_sta_assoc,
.sta_remove = mt7921_mac_sta_remove,
.update_survey = mt7921_update_channel,
};
--
2.25.1
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] mt76: connac: add mt76_connac_mcu_update_sta_cmd support
2021-06-03 3:02 ` sean.wang
@ 2021-06-03 8:35 ` Lorenzo Bianconi
-1 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2021-06-03 8:35 UTC (permalink / raw)
To: sean.wang
Cc: nbd, lorenzo.bianconi, Soul.Huang, YN.Chen, Leon.Yen,
Eric-SY.Chang, Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun,
Eric.Liang, Stella.Chang, jemele, yenlinlai, linux-wireless,
linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 11934 bytes --]
> From: Sean Wang <sean.wang@mediatek.com>
>
> Add mt76_connac_mcu_update_sta_cmd support that is the prerequisite patch
> for we are able to update the station record with the current state the
> station has into the offload firmware at runtime.
could you please rebase it on top of "mt76: connac: fix UC entry is being overwritten"?
https://patchwork.kernel.org/project/linux-wireless/patch/3d30cb9e40df970e2f4ef09c975f9fd6f7dc02dd.1622649436.git.lorenzo@kernel.org/
>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v1->v2: no change
> v2->v3: 1. rebase the latest mt76
> 2. turn into using enum mt76_sta_info_state
> 3. drop unneeded .state parameter passing in __mt7615_mcu_add_sta
> 4. make mt76_connac_mcu_add_sta_cmd and
> mt76_connac_mcu_update_sta_cmd static inline in
> mt76_connac_mcu.h
> ---
> .../net/wireless/mediatek/mt76/mt7615/mcu.c | 5 +--
> .../wireless/mediatek/mt76/mt76_connac_mcu.c | 21 +++++++------
> .../wireless/mediatek/mt76/mt76_connac_mcu.h | 31 ++++++++++++++++---
> .../net/wireless/mediatek/mt76/mt7921/main.c | 8 +++--
> .../net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++-
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +-
> 6 files changed, 52 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index cf4a4f2637d5..2f73bcb607dd 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -1028,9 +1028,10 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
> if (IS_ERR(sskb))
> return PTR_ERR(sskb);
>
> - mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable);
> + mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable, true);
> if (enable && sta)
> - mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0);
> + mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0,
> + MT76_STA_INFO_STATE_ASSOC);
>
> wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
> WTBL_RESET_AND_SET, NULL,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
> index b155e7b8d89d..45465eb3581a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
> @@ -304,7 +304,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_alloc_wtbl_req);
> void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta,
> - bool enable)
> + bool enable, bool newly)
> {
> struct sta_rec_basic *basic;
> struct tlv *tlv;
> @@ -316,7 +316,8 @@ void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
> basic->extra_info = cpu_to_le16(EXTRA_INFO_VER);
>
> if (enable) {
> - basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
> + if (newly)
> + basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
> basic->conn_state = CONN_STATE_PORT_SECURE;
> } else {
> basic->conn_state = CONN_STATE_DISCONNECT;
> @@ -709,7 +710,7 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
> void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
> struct ieee80211_sta *sta,
> struct ieee80211_vif *vif,
> - u8 rcpi)
> + u8 rcpi, u8 sta_state)
> {
> struct cfg80211_chan_def *chandef = &mphy->chandef;
> enum nl80211_band band = chandef->chan->band;
> @@ -770,7 +771,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
>
> tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_STATE, sizeof(*state));
> state = (struct sta_rec_state *)tlv;
> - state->state = 2;
> + state->state = sta_state;
>
> if (sta->vht_cap.vht_supported) {
> state->vht_opmode = sta->bandwidth;
> @@ -862,8 +863,9 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> }
> EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ht_tlv);
>
> -int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> - struct mt76_sta_cmd_info *info)
> +int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info,
> + bool newly)
> {
> struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv;
> struct mt76_dev *dev = phy->dev;
> @@ -875,10 +877,11 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> if (IS_ERR(skb))
> return PTR_ERR(skb);
>
> - mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable);
> + mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable,
> + newly);
> if (info->enable && info->sta)
> mt76_connac_mcu_sta_tlv(phy, skb, info->sta, info->vif,
> - info->rcpi);
> + info->rcpi, info->state);
>
> sta_wtbl = mt76_connac_mcu_add_tlv(skb, STA_REC_WTBL,
> sizeof(struct tlv));
> @@ -902,7 +905,7 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
>
> return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
> }
> -EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_sta_cmd);
> +EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_cmd);
>
> void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> struct ieee80211_ampdu_params *params,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> index 3076417ead5f..c7b809ff3045 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> @@ -904,6 +904,12 @@ struct mt76_connac_suspend_tlv {
> u8 pad[5];
> } __packed;
>
> +enum mt76_sta_info_state {
> + MT76_STA_INFO_STATE_NONE,
> + MT76_STA_INFO_STATE_AUTH,
> + MT76_STA_INFO_STATE_ASSOC
> +};
> +
> struct mt76_sta_cmd_info {
> struct ieee80211_sta *sta;
> struct mt76_wcid *wcid;
> @@ -913,6 +919,7 @@ struct mt76_sta_cmd_info {
> bool enable;
> int cmd;
> u8 rcpi;
> + u8 state;
why not enum mt76_sta_info_state here swapping with rcpi?
> };
>
> #define MT_SKU_POWER_LIMIT 161
> @@ -982,7 +989,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
> int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
> void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
> struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta, bool enable);
> + struct ieee80211_sta *sta, bool enable,
> + bool newly);
> void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta, void *sta_wtbl,
> @@ -997,7 +1005,7 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev,
> void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
> struct ieee80211_sta *sta,
> struct ieee80211_vif *vif,
> - u8 rcpi);
> + u8 rcpi, u8 state);
why not enum mt76_sta_info_state here?
> void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> struct ieee80211_sta *sta, void *sta_wtbl,
> void *wtbl_tlv);
> @@ -1019,8 +1027,9 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
> struct ieee80211_vif *vif,
> struct mt76_wcid *wcid,
> bool enable);
> -int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> - struct mt76_sta_cmd_info *info);
> +int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info,
> + bool newly);
> void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac,
> struct ieee80211_vif *vif);
> int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band);
> @@ -1059,4 +1068,18 @@ int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable);
> void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb,
> struct mt76_connac_coredump *coredump);
> int mt76_connac_mcu_set_rate_txpower(struct mt76_phy *phy);
> +
> +static inline int
> +mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info)
> +{
> + return mt76_connac_mcu_sta_cmd(phy, info, true);
> +}
> +
> +static inline int
> +mt76_connac_mcu_update_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info)
> +{
> + return mt76_connac_mcu_sta_cmd(phy, info, false);
> +}
> #endif /* __MT76_CONNAC_MCU_H */
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 84930ad5ebc7..c641a92b140c 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -578,7 +578,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
> mt7921_mcu_uni_bss_ps(dev, vif);
>
> if (changed & BSS_CHANGED_ASSOC) {
> - mt7921_mcu_sta_add(dev, NULL, vif, true);
> + mt7921_mcu_sta_add(dev, NULL, vif, true,
> + MT76_STA_INFO_STATE_ASSOC);
> mt7921_bss_bcnft_apply(dev, vif, info->assoc);
> }
>
> @@ -627,7 +628,8 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> mt7921_mac_wtbl_update(dev, idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> - ret = mt7921_mcu_sta_add(dev, sta, vif, true);
> + ret = mt7921_mcu_sta_add(dev, sta, vif, true,
> + MT76_STA_INFO_STATE_ASSOC);
> if (ret)
> return ret;
>
> @@ -645,7 +647,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
> mt76_connac_pm_wake(&dev->mphy, &dev->pm);
>
> - mt7921_mcu_sta_add(dev, sta, vif, false);
> + mt7921_mcu_sta_add(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
> mt7921_mac_wtbl_update(dev, msta->wcid.idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index ffc83717fd0d..4f0fd9674950 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -1268,7 +1268,8 @@ int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
> }
>
> int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> - struct ieee80211_vif *vif, bool enable)
> + struct ieee80211_vif *vif, bool enable,
> + enum mt76_sta_info_state state)
> {
> struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> int rssi = -ewma_rssi_read(&mvif->rssi);
> @@ -1276,6 +1277,7 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> .sta = sta,
> .vif = vif,
> .enable = enable,
> + .state = state,
> .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
> .rcpi = to_rcpi(rssi),
> };
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 8aa8d2ecdffa..d4d84b898011 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -263,7 +263,8 @@ int mt7921_mcu_add_key(struct mt7921_dev *dev, struct ieee80211_vif *vif,
> enum set_key_cmd cmd);
> int mt7921_set_channel(struct mt7921_phy *phy);
> int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> - struct ieee80211_vif *vif, bool enable);
> + struct ieee80211_vif *vif, bool enable,
> + enum mt76_sta_info_state state);
> int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
> int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
> int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] mt76: connac: add mt76_connac_mcu_update_sta_cmd support
@ 2021-06-03 8:35 ` Lorenzo Bianconi
0 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2021-06-03 8:35 UTC (permalink / raw)
To: sean.wang
Cc: nbd, lorenzo.bianconi, Soul.Huang, YN.Chen, Leon.Yen,
Eric-SY.Chang, Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun,
Eric.Liang, Stella.Chang, jemele, yenlinlai, linux-wireless,
linux-mediatek
[-- Attachment #1.1: Type: text/plain, Size: 11934 bytes --]
> From: Sean Wang <sean.wang@mediatek.com>
>
> Add mt76_connac_mcu_update_sta_cmd support that is the prerequisite patch
> for we are able to update the station record with the current state the
> station has into the offload firmware at runtime.
could you please rebase it on top of "mt76: connac: fix UC entry is being overwritten"?
https://patchwork.kernel.org/project/linux-wireless/patch/3d30cb9e40df970e2f4ef09c975f9fd6f7dc02dd.1622649436.git.lorenzo@kernel.org/
>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v1->v2: no change
> v2->v3: 1. rebase the latest mt76
> 2. turn into using enum mt76_sta_info_state
> 3. drop unneeded .state parameter passing in __mt7615_mcu_add_sta
> 4. make mt76_connac_mcu_add_sta_cmd and
> mt76_connac_mcu_update_sta_cmd static inline in
> mt76_connac_mcu.h
> ---
> .../net/wireless/mediatek/mt76/mt7615/mcu.c | 5 +--
> .../wireless/mediatek/mt76/mt76_connac_mcu.c | 21 +++++++------
> .../wireless/mediatek/mt76/mt76_connac_mcu.h | 31 ++++++++++++++++---
> .../net/wireless/mediatek/mt76/mt7921/main.c | 8 +++--
> .../net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++-
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +-
> 6 files changed, 52 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index cf4a4f2637d5..2f73bcb607dd 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -1028,9 +1028,10 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
> if (IS_ERR(sskb))
> return PTR_ERR(sskb);
>
> - mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable);
> + mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable, true);
> if (enable && sta)
> - mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0);
> + mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0,
> + MT76_STA_INFO_STATE_ASSOC);
>
> wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
> WTBL_RESET_AND_SET, NULL,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
> index b155e7b8d89d..45465eb3581a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
> @@ -304,7 +304,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_alloc_wtbl_req);
> void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta,
> - bool enable)
> + bool enable, bool newly)
> {
> struct sta_rec_basic *basic;
> struct tlv *tlv;
> @@ -316,7 +316,8 @@ void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
> basic->extra_info = cpu_to_le16(EXTRA_INFO_VER);
>
> if (enable) {
> - basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
> + if (newly)
> + basic->extra_info |= cpu_to_le16(EXTRA_INFO_NEW);
> basic->conn_state = CONN_STATE_PORT_SECURE;
> } else {
> basic->conn_state = CONN_STATE_DISCONNECT;
> @@ -709,7 +710,7 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
> void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
> struct ieee80211_sta *sta,
> struct ieee80211_vif *vif,
> - u8 rcpi)
> + u8 rcpi, u8 sta_state)
> {
> struct cfg80211_chan_def *chandef = &mphy->chandef;
> enum nl80211_band band = chandef->chan->band;
> @@ -770,7 +771,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
>
> tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_STATE, sizeof(*state));
> state = (struct sta_rec_state *)tlv;
> - state->state = 2;
> + state->state = sta_state;
>
> if (sta->vht_cap.vht_supported) {
> state->vht_opmode = sta->bandwidth;
> @@ -862,8 +863,9 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> }
> EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ht_tlv);
>
> -int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> - struct mt76_sta_cmd_info *info)
> +int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info,
> + bool newly)
> {
> struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv;
> struct mt76_dev *dev = phy->dev;
> @@ -875,10 +877,11 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> if (IS_ERR(skb))
> return PTR_ERR(skb);
>
> - mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable);
> + mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable,
> + newly);
> if (info->enable && info->sta)
> mt76_connac_mcu_sta_tlv(phy, skb, info->sta, info->vif,
> - info->rcpi);
> + info->rcpi, info->state);
>
> sta_wtbl = mt76_connac_mcu_add_tlv(skb, STA_REC_WTBL,
> sizeof(struct tlv));
> @@ -902,7 +905,7 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
>
> return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
> }
> -EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_sta_cmd);
> +EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_cmd);
>
> void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> struct ieee80211_ampdu_params *params,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> index 3076417ead5f..c7b809ff3045 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> @@ -904,6 +904,12 @@ struct mt76_connac_suspend_tlv {
> u8 pad[5];
> } __packed;
>
> +enum mt76_sta_info_state {
> + MT76_STA_INFO_STATE_NONE,
> + MT76_STA_INFO_STATE_AUTH,
> + MT76_STA_INFO_STATE_ASSOC
> +};
> +
> struct mt76_sta_cmd_info {
> struct ieee80211_sta *sta;
> struct mt76_wcid *wcid;
> @@ -913,6 +919,7 @@ struct mt76_sta_cmd_info {
> bool enable;
> int cmd;
> u8 rcpi;
> + u8 state;
why not enum mt76_sta_info_state here swapping with rcpi?
> };
>
> #define MT_SKU_POWER_LIMIT 161
> @@ -982,7 +989,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
> int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
> void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
> struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta, bool enable);
> + struct ieee80211_sta *sta, bool enable,
> + bool newly);
> void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta, void *sta_wtbl,
> @@ -997,7 +1005,7 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev,
> void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
> struct ieee80211_sta *sta,
> struct ieee80211_vif *vif,
> - u8 rcpi);
> + u8 rcpi, u8 state);
why not enum mt76_sta_info_state here?
> void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
> struct ieee80211_sta *sta, void *sta_wtbl,
> void *wtbl_tlv);
> @@ -1019,8 +1027,9 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
> struct ieee80211_vif *vif,
> struct mt76_wcid *wcid,
> bool enable);
> -int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> - struct mt76_sta_cmd_info *info);
> +int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info,
> + bool newly);
> void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac,
> struct ieee80211_vif *vif);
> int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band);
> @@ -1059,4 +1068,18 @@ int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable);
> void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb,
> struct mt76_connac_coredump *coredump);
> int mt76_connac_mcu_set_rate_txpower(struct mt76_phy *phy);
> +
> +static inline int
> +mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info)
> +{
> + return mt76_connac_mcu_sta_cmd(phy, info, true);
> +}
> +
> +static inline int
> +mt76_connac_mcu_update_sta_cmd(struct mt76_phy *phy,
> + struct mt76_sta_cmd_info *info)
> +{
> + return mt76_connac_mcu_sta_cmd(phy, info, false);
> +}
> #endif /* __MT76_CONNAC_MCU_H */
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 84930ad5ebc7..c641a92b140c 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -578,7 +578,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
> mt7921_mcu_uni_bss_ps(dev, vif);
>
> if (changed & BSS_CHANGED_ASSOC) {
> - mt7921_mcu_sta_add(dev, NULL, vif, true);
> + mt7921_mcu_sta_add(dev, NULL, vif, true,
> + MT76_STA_INFO_STATE_ASSOC);
> mt7921_bss_bcnft_apply(dev, vif, info->assoc);
> }
>
> @@ -627,7 +628,8 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> mt7921_mac_wtbl_update(dev, idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> - ret = mt7921_mcu_sta_add(dev, sta, vif, true);
> + ret = mt7921_mcu_sta_add(dev, sta, vif, true,
> + MT76_STA_INFO_STATE_ASSOC);
> if (ret)
> return ret;
>
> @@ -645,7 +647,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
> mt76_connac_pm_wake(&dev->mphy, &dev->pm);
>
> - mt7921_mcu_sta_add(dev, sta, vif, false);
> + mt7921_mcu_sta_add(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
> mt7921_mac_wtbl_update(dev, msta->wcid.idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index ffc83717fd0d..4f0fd9674950 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -1268,7 +1268,8 @@ int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
> }
>
> int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> - struct ieee80211_vif *vif, bool enable)
> + struct ieee80211_vif *vif, bool enable,
> + enum mt76_sta_info_state state)
> {
> struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> int rssi = -ewma_rssi_read(&mvif->rssi);
> @@ -1276,6 +1277,7 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> .sta = sta,
> .vif = vif,
> .enable = enable,
> + .state = state,
> .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
> .rcpi = to_rcpi(rssi),
> };
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 8aa8d2ecdffa..d4d84b898011 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -263,7 +263,8 @@ int mt7921_mcu_add_key(struct mt7921_dev *dev, struct ieee80211_vif *vif,
> enum set_key_cmd cmd);
> int mt7921_set_channel(struct mt7921_phy *phy);
> int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> - struct ieee80211_vif *vif, bool enable);
> + struct ieee80211_vif *vif, bool enable,
> + enum mt76_sta_info_state state);
> int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
> int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
> int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
> --
> 2.25.1
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 2/2] mt76: mt7921: fix sta_state incorrect implementation
2021-06-03 3:02 ` sean.wang
@ 2021-06-03 8:36 ` Lorenzo Bianconi
-1 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2021-06-03 8:36 UTC (permalink / raw)
To: sean.wang
Cc: nbd, lorenzo.bianconi, Soul.Huang, YN.Chen, Leon.Yen,
Eric-SY.Chang, Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun,
Eric.Liang, Stella.Chang, jemele, yenlinlai, linux-wireless,
linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 7727 bytes --]
> From: Sean Wang <sean.wang@mediatek.com>
>
> When .sta_state is implemented, mac80211 assumes that the station entry is
> usable after the NOTEXIST->NONE transition.
>
> So we should create the sta entry as early as possible in order that
> mac80211 pass assoc/auth frames to mt76 with the newly created sta entry,
> and add .sta_assoc to mt76 core to refresh the sta entry again when sta is
> being associated.
>
> Fixes: 8aa5a9b7361c ("mt76: mt7921: enable deep sleep at runtime")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v1->v2: Put back the careless change not belonged to the patch to keep
> mt7921_mcu_sta_add for BC entry and mt76_connac_mcu_uni_add_bss
> on the association.
> v2->v3: 1. rebase the latest mt76
> 2. squashing 2/3 to the one
> 3. add the proper lock in mt7921_mac_sta_assoc
> ---
> .../net/wireless/mediatek/mt76/mt7921/main.c | 55 ++++++++-----------
> .../net/wireless/mediatek/mt76/mt7921/mcu.c | 20 +++++++
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 4 ++
> .../net/wireless/mediatek/mt76/mt7921/pci.c | 1 +
> 4 files changed, 49 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index c641a92b140c..af98835b5134 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -618,18 +618,14 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> if (ret)
> return ret;
>
> - if (vif->type == NL80211_IFTYPE_STATION) {
> + if (vif->type == NL80211_IFTYPE_STATION)
> mvif->wep_sta = msta;
> - if (!sta->tdls)
> - mt76_connac_mcu_uni_add_bss(&dev->mphy, vif,
> - &mvif->sta.wcid, true);
> - }
>
> mt7921_mac_wtbl_update(dev, idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> ret = mt7921_mcu_sta_add(dev, sta, vif, true,
> - MT76_STA_INFO_STATE_ASSOC);
> + MT76_STA_INFO_STATE_NONE);
> if (ret)
> return ret;
>
> @@ -638,6 +634,27 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> return 0;
> }
>
> +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> + struct ieee80211_sta *sta)
> +{
> + struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
> + struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
> + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> +
> + mt7921_mutex_acquire(dev);
> +
> + if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
> + mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
> + true);
> +
> + mt7921_mac_wtbl_update(dev, msta->wcid.idx,
> + MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
> +
> + mt7921_mcu_sta_update(dev, sta, vif, MT76_STA_INFO_STATE_ASSOC);
> +
> + mt7921_mutex_release(dev);
> +}
> +
> void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta)
> {
> @@ -793,22 +810,6 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> return ret;
> }
>
> -static int
> -mt7921_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta)
> -{
> - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
> - IEEE80211_STA_NONE);
> -}
> -
> -static int
> -mt7921_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta)
> -{
> - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
> - IEEE80211_STA_NOTEXIST);
> -}
> -
> static int mt7921_sta_state(struct ieee80211_hw *hw,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta,
> @@ -823,15 +824,7 @@ static int mt7921_sta_state(struct ieee80211_hw *hw,
> mt7921_mutex_release(dev);
> }
>
> - if (old_state == IEEE80211_STA_AUTH &&
> - new_state == IEEE80211_STA_ASSOC) {
> - return mt7921_sta_add(hw, vif, sta);
> - } else if (old_state == IEEE80211_STA_ASSOC &&
> - new_state == IEEE80211_STA_AUTH) {
> - return mt7921_sta_remove(hw, vif, sta);
> - }
> -
> - return 0;
> + return mt76_sta_state(hw, vif, sta, old_state, new_state);
> }
>
> static int
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index 4f0fd9674950..ab338bdf4f4a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -1289,6 +1289,26 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> return mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
> }
>
> +int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> + struct ieee80211_vif *vif, u8 state)
> +{
> + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> + int rssi = -ewma_rssi_read(&mvif->rssi);
> + struct mt76_sta_cmd_info info = {
> + .sta = sta,
> + .vif = vif,
> + .enable = true,
> + .state = state,
> + .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
> + .rcpi = to_rcpi(rssi),
> + };
> + struct mt7921_sta *msta;
> +
> + msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL;
> + info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
> + return mt76_connac_mcu_update_sta_cmd(&dev->mphy, &info);
It seems to me it is quite the same of mt7921_mcu_sta_add, right?
Why not always use mt7921_mcu_sta_update?
Regards,
Lorenzo
> +}
> +
> int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev)
> {
> struct mt76_phy *mphy = &dev->mt76.phy;
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index d4d84b898011..196e47f89fc1 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -265,6 +265,8 @@ int mt7921_set_channel(struct mt7921_phy *phy);
> int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> struct ieee80211_vif *vif, bool enable,
> enum mt76_sta_info_state state);
> +int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> + struct ieee80211_vif *vif, u8 state);
> int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
> int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
> int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
> @@ -336,6 +338,8 @@ void mt7921_mac_fill_rx_vector(struct mt7921_dev *dev, struct sk_buff *skb);
> void mt7921_mac_tx_free(struct mt7921_dev *dev, struct sk_buff *skb);
> int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta);
> +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> + struct ieee80211_sta *sta);
> void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta);
> void mt7921_mac_work(struct work_struct *work);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> index 13263f50dc00..27906b2cd912 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> @@ -106,6 +106,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
> .rx_poll_complete = mt7921_rx_poll_complete,
> .sta_ps = mt7921_sta_ps,
> .sta_add = mt7921_mac_sta_add,
> + .sta_assoc = mt7921_mac_sta_assoc,
> .sta_remove = mt7921_mac_sta_remove,
> .update_survey = mt7921_update_channel,
> };
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 2/2] mt76: mt7921: fix sta_state incorrect implementation
@ 2021-06-03 8:36 ` Lorenzo Bianconi
0 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2021-06-03 8:36 UTC (permalink / raw)
To: sean.wang
Cc: nbd, lorenzo.bianconi, Soul.Huang, YN.Chen, Leon.Yen,
Eric-SY.Chang, Deren.Wu, km.lin, robin.chiu, ch.yeh, posh.sun,
Eric.Liang, Stella.Chang, jemele, yenlinlai, linux-wireless,
linux-mediatek
[-- Attachment #1.1: Type: text/plain, Size: 7727 bytes --]
> From: Sean Wang <sean.wang@mediatek.com>
>
> When .sta_state is implemented, mac80211 assumes that the station entry is
> usable after the NOTEXIST->NONE transition.
>
> So we should create the sta entry as early as possible in order that
> mac80211 pass assoc/auth frames to mt76 with the newly created sta entry,
> and add .sta_assoc to mt76 core to refresh the sta entry again when sta is
> being associated.
>
> Fixes: 8aa5a9b7361c ("mt76: mt7921: enable deep sleep at runtime")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v1->v2: Put back the careless change not belonged to the patch to keep
> mt7921_mcu_sta_add for BC entry and mt76_connac_mcu_uni_add_bss
> on the association.
> v2->v3: 1. rebase the latest mt76
> 2. squashing 2/3 to the one
> 3. add the proper lock in mt7921_mac_sta_assoc
> ---
> .../net/wireless/mediatek/mt76/mt7921/main.c | 55 ++++++++-----------
> .../net/wireless/mediatek/mt76/mt7921/mcu.c | 20 +++++++
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 4 ++
> .../net/wireless/mediatek/mt76/mt7921/pci.c | 1 +
> 4 files changed, 49 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index c641a92b140c..af98835b5134 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -618,18 +618,14 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> if (ret)
> return ret;
>
> - if (vif->type == NL80211_IFTYPE_STATION) {
> + if (vif->type == NL80211_IFTYPE_STATION)
> mvif->wep_sta = msta;
> - if (!sta->tdls)
> - mt76_connac_mcu_uni_add_bss(&dev->mphy, vif,
> - &mvif->sta.wcid, true);
> - }
>
> mt7921_mac_wtbl_update(dev, idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> ret = mt7921_mcu_sta_add(dev, sta, vif, true,
> - MT76_STA_INFO_STATE_ASSOC);
> + MT76_STA_INFO_STATE_NONE);
> if (ret)
> return ret;
>
> @@ -638,6 +634,27 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> return 0;
> }
>
> +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> + struct ieee80211_sta *sta)
> +{
> + struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
> + struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
> + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> +
> + mt7921_mutex_acquire(dev);
> +
> + if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
> + mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
> + true);
> +
> + mt7921_mac_wtbl_update(dev, msta->wcid.idx,
> + MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
> +
> + mt7921_mcu_sta_update(dev, sta, vif, MT76_STA_INFO_STATE_ASSOC);
> +
> + mt7921_mutex_release(dev);
> +}
> +
> void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta)
> {
> @@ -793,22 +810,6 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> return ret;
> }
>
> -static int
> -mt7921_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta)
> -{
> - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
> - IEEE80211_STA_NONE);
> -}
> -
> -static int
> -mt7921_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta)
> -{
> - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
> - IEEE80211_STA_NOTEXIST);
> -}
> -
> static int mt7921_sta_state(struct ieee80211_hw *hw,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta,
> @@ -823,15 +824,7 @@ static int mt7921_sta_state(struct ieee80211_hw *hw,
> mt7921_mutex_release(dev);
> }
>
> - if (old_state == IEEE80211_STA_AUTH &&
> - new_state == IEEE80211_STA_ASSOC) {
> - return mt7921_sta_add(hw, vif, sta);
> - } else if (old_state == IEEE80211_STA_ASSOC &&
> - new_state == IEEE80211_STA_AUTH) {
> - return mt7921_sta_remove(hw, vif, sta);
> - }
> -
> - return 0;
> + return mt76_sta_state(hw, vif, sta, old_state, new_state);
> }
>
> static int
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index 4f0fd9674950..ab338bdf4f4a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -1289,6 +1289,26 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> return mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
> }
>
> +int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> + struct ieee80211_vif *vif, u8 state)
> +{
> + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> + int rssi = -ewma_rssi_read(&mvif->rssi);
> + struct mt76_sta_cmd_info info = {
> + .sta = sta,
> + .vif = vif,
> + .enable = true,
> + .state = state,
> + .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
> + .rcpi = to_rcpi(rssi),
> + };
> + struct mt7921_sta *msta;
> +
> + msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL;
> + info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
> + return mt76_connac_mcu_update_sta_cmd(&dev->mphy, &info);
It seems to me it is quite the same of mt7921_mcu_sta_add, right?
Why not always use mt7921_mcu_sta_update?
Regards,
Lorenzo
> +}
> +
> int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev)
> {
> struct mt76_phy *mphy = &dev->mt76.phy;
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index d4d84b898011..196e47f89fc1 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -265,6 +265,8 @@ int mt7921_set_channel(struct mt7921_phy *phy);
> int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> struct ieee80211_vif *vif, bool enable,
> enum mt76_sta_info_state state);
> +int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> + struct ieee80211_vif *vif, u8 state);
> int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
> int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
> int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
> @@ -336,6 +338,8 @@ void mt7921_mac_fill_rx_vector(struct mt7921_dev *dev, struct sk_buff *skb);
> void mt7921_mac_tx_free(struct mt7921_dev *dev, struct sk_buff *skb);
> int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta);
> +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> + struct ieee80211_sta *sta);
> void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta);
> void mt7921_mac_work(struct work_struct *work);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> index 13263f50dc00..27906b2cd912 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> @@ -106,6 +106,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
> .rx_poll_complete = mt7921_rx_poll_complete,
> .sta_ps = mt7921_sta_ps,
> .sta_add = mt7921_mac_sta_add,
> + .sta_assoc = mt7921_mac_sta_assoc,
> .sta_remove = mt7921_mac_sta_remove,
> .update_survey = mt7921_update_channel,
> };
> --
> 2.25.1
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-06-03 8:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 3:02 [PATCH v3 1/2] mt76: connac: add mt76_connac_mcu_update_sta_cmd support sean.wang
2021-06-03 3:02 ` sean.wang
2021-06-03 3:02 ` [PATCH v3 2/2] mt76: mt7921: fix sta_state incorrect implementation sean.wang
2021-06-03 3:02 ` sean.wang
2021-06-03 8:36 ` Lorenzo Bianconi
2021-06-03 8:36 ` Lorenzo Bianconi
2021-06-03 8:35 ` [PATCH v3 1/2] mt76: connac: add mt76_connac_mcu_update_sta_cmd support Lorenzo Bianconi
2021-06-03 8:35 ` Lorenzo Bianconi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.