Commit e2c93b68 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7915: rely on mt76_connac_mcu_alloc_sta_req

Rely on mt76_connac_mcu_alloc_sta_req routine and remove
duplicated code.
Add MT76_CONNAC_LIB module dependency in mt7915 module
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 74c337ec
...@@ -100,6 +100,11 @@ static inline bool is_mt7663(struct mt76_dev *dev) ...@@ -100,6 +100,11 @@ static inline bool is_mt7663(struct mt76_dev *dev)
return mt76_chip(dev) == 0x7663; return mt76_chip(dev) == 0x7663;
} }
static inline bool is_mt7915(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7915;
}
int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm); int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm);
void mt76_connac_power_save_sched(struct mt76_phy *phy, void mt76_connac_power_save_sched(struct mt76_phy *phy,
struct mt76_connac_pm *pm); struct mt76_connac_pm *pm);
......
...@@ -266,8 +266,8 @@ mt76_connac_mcu_add_nested_tlv(struct sk_buff *skb, int tag, int len, ...@@ -266,8 +266,8 @@ mt76_connac_mcu_add_nested_tlv(struct sk_buff *skb, int tag, int len,
EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_nested_tlv); EXPORT_SYMBOL_GPL(mt76_connac_mcu_add_nested_tlv);
struct sk_buff * struct sk_buff *
mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif, __mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
struct mt76_wcid *wcid) struct mt76_wcid *wcid, int len)
{ {
struct sta_req_hdr hdr = { struct sta_req_hdr hdr = {
.bss_idx = mvif->idx, .bss_idx = mvif->idx,
...@@ -278,7 +278,7 @@ mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif, ...@@ -278,7 +278,7 @@ mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
mt76_connac_mcu_get_wlan_idx(dev, wcid, &hdr.wlan_idx_lo, mt76_connac_mcu_get_wlan_idx(dev, wcid, &hdr.wlan_idx_lo,
&hdr.wlan_idx_hi); &hdr.wlan_idx_hi);
skb = mt76_mcu_msg_alloc(dev, NULL, MT76_CONNAC_STA_UPDATE_MAX_SIZE); skb = mt76_mcu_msg_alloc(dev, NULL, len);
if (!skb) if (!skb)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -286,7 +286,7 @@ mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif, ...@@ -286,7 +286,7 @@ mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
return skb; return skb;
} }
EXPORT_SYMBOL_GPL(mt76_connac_mcu_alloc_sta_req); EXPORT_SYMBOL_GPL(__mt76_connac_mcu_alloc_sta_req);
struct wtbl_req_hdr * struct wtbl_req_hdr *
mt76_connac_mcu_alloc_wtbl_req(struct mt76_dev *dev, struct mt76_wcid *wcid, mt76_connac_mcu_alloc_wtbl_req(struct mt76_dev *dev, struct mt76_wcid *wcid,
......
...@@ -570,6 +570,7 @@ struct wtbl_raw { ...@@ -570,6 +570,7 @@ struct wtbl_raw {
sizeof(struct sta_rec_muru) + \ sizeof(struct sta_rec_muru) + \
sizeof(struct sta_rec_bfee) + \ sizeof(struct sta_rec_bfee) + \
sizeof(struct sta_rec_ra) + \ sizeof(struct sta_rec_ra) + \
sizeof(struct sta_rec_sec) + \
sizeof(struct sta_rec_ra_fixed) + \ sizeof(struct sta_rec_ra_fixed) + \
sizeof(struct sta_rec_he_6g_capa) + \ sizeof(struct sta_rec_he_6g_capa) + \
sizeof(struct tlv) + \ sizeof(struct tlv) + \
...@@ -1436,7 +1437,7 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid, ...@@ -1436,7 +1437,7 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
{ {
*wlan_idx_hi = 0; *wlan_idx_hi = 0;
if (is_mt7921(dev)) { if (is_mt7921(dev) || is_mt7915(dev)) {
*wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0; *wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0;
*wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0; *wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0;
} else { } else {
...@@ -1445,8 +1446,16 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid, ...@@ -1445,8 +1446,16 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
} }
struct sk_buff * struct sk_buff *
__mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
struct mt76_wcid *wcid, int len);
static inline struct sk_buff *
mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif, mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
struct mt76_wcid *wcid); struct mt76_wcid *wcid)
{
return __mt76_connac_mcu_alloc_sta_req(dev, mvif, wcid,
MT76_CONNAC_STA_UPDATE_MAX_SIZE);
}
struct wtbl_req_hdr * struct wtbl_req_hdr *
mt76_connac_mcu_alloc_wtbl_req(struct mt76_dev *dev, struct mt76_wcid *wcid, mt76_connac_mcu_alloc_wtbl_req(struct mt76_dev *dev, struct mt76_wcid *wcid,
int cmd, void *sta_wtbl, struct sk_buff **skb); int cmd, void *sta_wtbl, struct sk_buff **skb);
......
# SPDX-License-Identifier: ISC # SPDX-License-Identifier: ISC
config MT7915E config MT7915E
tristate "MediaTek MT7915E (PCIe) support" tristate "MediaTek MT7915E (PCIe) support"
select MT76_CORE select MT76_CONNAC_LIB
depends on MAC80211 depends on MAC80211
depends on PCI depends on PCI
help help
......
...@@ -82,9 +82,6 @@ struct mt7915_fw_region { ...@@ -82,9 +82,6 @@ struct mt7915_fw_region {
#define PATCH_SEC_TYPE_MASK GENMASK(15, 0) #define PATCH_SEC_TYPE_MASK GENMASK(15, 0)
#define PATCH_SEC_TYPE_INFO 0x2 #define PATCH_SEC_TYPE_INFO 0x2
#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 HE_PHY(p, c) u8_get_bits(c, IEEE80211_HE_PHY_##p) #define HE_PHY(p, c) u8_get_bits(c, IEEE80211_HE_PHY_##p)
#define HE_MAC(m, c) u8_get_bits(c, IEEE80211_HE_MAC_##m) #define HE_MAC(m, c) u8_get_bits(c, IEEE80211_HE_MAC_##m)
...@@ -577,28 +574,6 @@ void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -577,28 +574,6 @@ void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb)
mt76_mcu_rx_event(&dev->mt76, skb); mt76_mcu_rx_event(&dev->mt76, skb);
} }
static struct sk_buff *
mt7915_mcu_alloc_sta_req(struct mt7915_dev *dev, struct mt7915_vif *mvif,
struct mt7915_sta *msta, int len)
{
struct sta_req_hdr hdr = {
.bss_idx = mvif->mt76.idx,
.wlan_idx_lo = msta ? to_wcid_lo(msta->wcid.idx) : 0,
.wlan_idx_hi = msta ? to_wcid_hi(msta->wcid.idx) : 0,
.muar_idx = msta && msta->wcid.sta ? mvif->mt76.omac_idx : 0xe,
.is_tlv_append = 1,
};
struct sk_buff *skb;
skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, len);
if (!skb)
return ERR_PTR(-ENOMEM);
skb_put_data(skb, &hdr, sizeof(hdr));
return skb;
}
static struct wtbl_req_hdr * static struct wtbl_req_hdr *
mt7915_mcu_alloc_wtbl_req(struct mt7915_dev *dev, struct mt7915_sta *msta, mt7915_mcu_alloc_wtbl_req(struct mt7915_dev *dev, struct mt7915_sta *msta,
int cmd, void *sta_wtbl, struct sk_buff **skb) int cmd, void *sta_wtbl, struct sk_buff **skb)
...@@ -1010,6 +985,7 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, ...@@ -1010,6 +985,7 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy,
struct ieee80211_vif *vif, int enable) struct ieee80211_vif *vif, int enable)
{ {
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
struct mt7915_dev *dev = phy->dev;
struct sk_buff *skb; struct sk_buff *skb;
if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) { if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) {
...@@ -1017,8 +993,8 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, ...@@ -1017,8 +993,8 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy,
mt7915_mcu_muar_config(phy, vif, true, enable); mt7915_mcu_muar_config(phy, vif, true, enable);
} }
skb = mt7915_mcu_alloc_sta_req(phy->dev, mvif, NULL, skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL,
MT7915_BSS_UPDATE_MAX_SIZE); MT7915_BSS_UPDATE_MAX_SIZE);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -1045,7 +1021,7 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, ...@@ -1045,7 +1021,7 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy,
mt7915_mcu_bss_ext_tlv(skb, mvif); mt7915_mcu_bss_ext_tlv(skb, mvif);
} }
out: out:
return mt76_mcu_skb_send_msg(&phy->dev->mt76, skb, return mt76_mcu_skb_send_msg(&dev->mt76, skb,
MCU_EXT_CMD(BSS_INFO_UPDATE), true); MCU_EXT_CMD(BSS_INFO_UPDATE), true);
} }
...@@ -1124,10 +1100,10 @@ int mt7915_mcu_add_key(struct mt7915_dev *dev, struct ieee80211_vif *vif, ...@@ -1124,10 +1100,10 @@ int mt7915_mcu_add_key(struct mt7915_dev *dev, struct ieee80211_vif *vif,
{ {
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
struct sk_buff *skb; struct sk_buff *skb;
int len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_sec);
int ret; int ret;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
&msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -1204,8 +1180,8 @@ mt7915_mcu_sta_ba(struct mt7915_dev *dev, ...@@ -1204,8 +1180,8 @@ mt7915_mcu_sta_ba(struct mt7915_dev *dev,
if (enable && tx && !params->amsdu) if (enable && tx && !params->amsdu)
msta->wcid.amsdu = false; msta->wcid.amsdu = false;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
MT76_CONNAC_STA_UPDATE_MAX_SIZE); &msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -1223,8 +1199,8 @@ mt7915_mcu_sta_ba(struct mt7915_dev *dev, ...@@ -1223,8 +1199,8 @@ mt7915_mcu_sta_ba(struct mt7915_dev *dev,
if (ret) if (ret)
return ret; return ret;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
MT76_CONNAC_STA_UPDATE_MAX_SIZE); &msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -2050,9 +2026,9 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, ...@@ -2050,9 +2026,9 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
struct sta_rec_ra_fixed *ra; struct sta_rec_ra_fixed *ra;
struct sk_buff *skb; struct sk_buff *skb;
struct tlv *tlv; struct tlv *tlv;
int len = sizeof(struct sta_req_hdr) + sizeof(*ra);
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
&msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -2091,8 +2067,8 @@ int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif, ...@@ -2091,8 +2067,8 @@ int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif,
struct sk_buff *skb; struct sk_buff *skb;
int ret; int ret;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
MT76_CONNAC_STA_UPDATE_MAX_SIZE); &msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -2304,8 +2280,8 @@ int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif, ...@@ -2304,8 +2280,8 @@ int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif,
struct sk_buff *skb; struct sk_buff *skb;
int ret; int ret;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
MT76_CONNAC_STA_UPDATE_MAX_SIZE); &msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -2371,8 +2347,8 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif, ...@@ -2371,8 +2347,8 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta; msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
MT76_CONNAC_STA_UPDATE_MAX_SIZE); &msta->wcid);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
...@@ -2602,7 +2578,8 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, ...@@ -2602,7 +2578,8 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw,
struct bss_info_bcn *bcn; struct bss_info_bcn *bcn;
int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE; int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE;
rskb = mt7915_mcu_alloc_sta_req(dev, mvif, NULL, len); rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
NULL, len);
if (IS_ERR(rskb)) if (IS_ERR(rskb))
return PTR_ERR(rskb); return PTR_ERR(rskb);
...@@ -4263,7 +4240,8 @@ int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vi ...@@ -4263,7 +4240,8 @@ int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vi
struct sk_buff *skb; struct sk_buff *skb;
struct tlv *tlv; struct tlv *tlv;
skb = mt7915_mcu_alloc_sta_req(dev, mvif, NULL, len); skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
NULL, len);
if (IS_ERR(skb)) if (IS_ERR(skb))
return PTR_ERR(skb); return PTR_ERR(skb);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ktime.h> #include <linux/ktime.h>
#include "../mt76.h" #include "../mt76_connac.h"
#include "regs.h" #include "regs.h"
#define MT7915_MAX_INTERFACES 19 #define MT7915_MAX_INTERFACES 19
...@@ -479,11 +479,6 @@ int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level); ...@@ -479,11 +479,6 @@ int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb); void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
void mt7915_mcu_exit(struct mt7915_dev *dev); void mt7915_mcu_exit(struct mt7915_dev *dev);
static inline bool is_mt7915(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7915;
}
static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev) static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev)
{ {
return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE; return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE;
......
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