Commit 5802106f authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: connac: introduce mt76_sta_cmd_info data structure

Introduce mt76_sta_cmd_info data structure to contain parameters passed
to mt76_sta_cmd_info routine. This is preliminary patch to properly
configure rcpi for mt7921 devices.
Tested-by: default avatarJayden.Kuo <jayden.kuo@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 14edf109
...@@ -988,7 +988,7 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif, ...@@ -988,7 +988,7 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable); mt76_connac_mcu_sta_basic_tlv(sskb, vif, sta, enable);
if (enable && sta) if (enable && sta)
mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif); mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0);
wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid, wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
WTBL_RESET_AND_SET, NULL, WTBL_RESET_AND_SET, NULL,
...@@ -1086,10 +1086,15 @@ __mt7615_mcu_add_sta(struct mt76_phy *phy, struct ieee80211_vif *vif, ...@@ -1086,10 +1086,15 @@ __mt7615_mcu_add_sta(struct mt76_phy *phy, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, bool enable, int cmd) struct ieee80211_sta *sta, bool enable, int cmd)
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt76_wcid *wcid; struct mt76_sta_cmd_info info = {
.sta = sta,
.vif = vif,
.enable = enable,
.cmd = cmd,
};
wcid = sta ? (struct mt76_wcid *)sta->drv_priv : &mvif->sta.wcid; info.wcid = sta ? (struct mt76_wcid *)sta->drv_priv : &mvif->sta.wcid;
return mt76_connac_mcu_add_sta_cmd(phy, vif, sta, wcid, enable, cmd); return mt76_connac_mcu_add_sta_cmd(phy, &info);
} }
static int static int
......
...@@ -674,7 +674,8 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif, ...@@ -674,7 +674,8 @@ 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, void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
struct ieee80211_sta *sta, struct ieee80211_sta *sta,
struct ieee80211_vif *vif) struct ieee80211_vif *vif,
u8 rcpi)
{ {
struct cfg80211_chan_def *chandef = &mphy->chandef; struct cfg80211_chan_def *chandef = &mphy->chandef;
enum nl80211_band band = chandef->chan->band; enum nl80211_band band = chandef->chan->band;
...@@ -723,6 +724,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, ...@@ -723,6 +724,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
phy = (struct sta_rec_phy *)tlv; phy = (struct sta_rec_phy *)tlv;
phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta); phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta);
phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates); phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates);
phy->rcpi = rcpi;
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info)); tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info));
ra_info = (struct sta_rec_ra_info *)tlv; ra_info = (struct sta_rec_ra_info *)tlv;
...@@ -827,43 +829,42 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -827,43 +829,42 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ht_tlv); EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ht_tlv);
int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy, int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
struct ieee80211_vif *vif, struct mt76_sta_cmd_info *info)
struct ieee80211_sta *sta,
struct mt76_wcid *wcid,
bool enable, int cmd)
{ {
struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv;
struct mt76_dev *dev = phy->dev; struct mt76_dev *dev = phy->dev;
struct wtbl_req_hdr *wtbl_hdr; struct wtbl_req_hdr *wtbl_hdr;
struct tlv *sta_wtbl; struct tlv *sta_wtbl;
struct sk_buff *skb; struct sk_buff *skb;
skb = mt76_connac_mcu_alloc_sta_req(dev, mvif, wcid); skb = mt76_connac_mcu_alloc_sta_req(dev, mvif, info->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
mt76_connac_mcu_sta_basic_tlv(skb, vif, sta, enable); mt76_connac_mcu_sta_basic_tlv(skb, info->vif, info->sta, info->enable);
if (enable && sta) if (info->enable && info->sta)
mt76_connac_mcu_sta_tlv(phy, skb, sta, vif); mt76_connac_mcu_sta_tlv(phy, skb, info->sta, info->vif,
info->rcpi);
sta_wtbl = mt76_connac_mcu_add_tlv(skb, STA_REC_WTBL, sta_wtbl = mt76_connac_mcu_add_tlv(skb, STA_REC_WTBL,
sizeof(struct tlv)); sizeof(struct tlv));
wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(dev, wcid, wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(dev, info->wcid,
WTBL_RESET_AND_SET, WTBL_RESET_AND_SET,
sta_wtbl, &skb); sta_wtbl, &skb);
if (IS_ERR(wtbl_hdr)) if (IS_ERR(wtbl_hdr))
return PTR_ERR(wtbl_hdr); return PTR_ERR(wtbl_hdr);
if (enable) { if (info->enable) {
mt76_connac_mcu_wtbl_generic_tlv(dev, skb, vif, sta, sta_wtbl, mt76_connac_mcu_wtbl_generic_tlv(dev, skb, info->vif,
info->sta, sta_wtbl,
wtbl_hdr); wtbl_hdr);
if (sta) if (info->sta)
mt76_connac_mcu_wtbl_ht_tlv(dev, skb, sta, sta_wtbl, mt76_connac_mcu_wtbl_ht_tlv(dev, skb, info->sta,
wtbl_hdr); sta_wtbl, wtbl_hdr);
} }
return mt76_mcu_skb_send_msg(dev, skb, cmd, true); 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_add_sta_cmd);
......
...@@ -881,6 +881,17 @@ struct mt76_connac_suspend_tlv { ...@@ -881,6 +881,17 @@ struct mt76_connac_suspend_tlv {
u8 pad[5]; u8 pad[5];
} __packed; } __packed;
struct mt76_sta_cmd_info {
struct ieee80211_sta *sta;
struct mt76_wcid *wcid;
struct ieee80211_vif *vif;
bool enable;
int cmd;
u8 rcpi;
};
#define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id) #define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id)
#define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id) #define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id)
...@@ -928,7 +939,8 @@ void mt76_connac_mcu_wtbl_hdr_trans_tlv(struct sk_buff *skb, ...@@ -928,7 +939,8 @@ void mt76_connac_mcu_wtbl_hdr_trans_tlv(struct sk_buff *skb,
void *sta_wtbl, void *wtbl_tlv); void *sta_wtbl, void *wtbl_tlv);
void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
struct ieee80211_sta *sta, struct ieee80211_sta *sta,
struct ieee80211_vif *vif); struct ieee80211_vif *vif,
u8 rcpi);
void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb, void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_sta *sta, void *sta_wtbl, struct ieee80211_sta *sta, void *sta_wtbl,
void *wtbl_tlv); void *wtbl_tlv);
...@@ -951,10 +963,7 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy, ...@@ -951,10 +963,7 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
struct mt76_wcid *wcid, struct mt76_wcid *wcid,
bool enable); bool enable);
int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy, int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
struct ieee80211_vif *vif, struct mt76_sta_cmd_info *info);
struct ieee80211_sta *sta,
struct mt76_wcid *wcid,
bool enable, int cmd);
void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac, void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac,
struct ieee80211_vif *vif); struct ieee80211_vif *vif);
int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band); int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band);
......
...@@ -624,6 +624,13 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -624,6 +624,13 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv; struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
struct mt76_sta_cmd_info info = {
.sta = sta,
.vif = vif,
.enable = true,
.cmd = MCU_UNI_CMD_STA_REC_UPDATE,
.wcid = &msta->wcid,
};
int ret, idx; int ret, idx;
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1); idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
...@@ -650,8 +657,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -650,8 +657,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7921_mac_wtbl_update(dev, idx, mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
ret = mt76_connac_mcu_add_sta_cmd(&dev->mphy, vif, sta, &msta->wcid, ret = mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
true, MCU_UNI_CMD_STA_REC_UPDATE);
if (ret) if (ret)
return ret; return ret;
...@@ -665,12 +671,17 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -665,12 +671,17 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
{ {
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv; struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
struct mt76_sta_cmd_info info = {
.sta = sta,
.vif = vif,
.cmd = MCU_UNI_CMD_STA_REC_UPDATE,
.wcid = &msta->wcid,
};
mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid); mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm); mt76_connac_pm_wake(&dev->mphy, &dev->pm);
mt76_connac_mcu_add_sta_cmd(&dev->mphy, vif, sta, &msta->wcid, false, mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
MCU_UNI_CMD_STA_REC_UPDATE);
mt7921_mac_wtbl_update(dev, msta->wcid.idx, mt7921_mac_wtbl_update(dev, msta->wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment