Commit 67aa2743 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7921: rely on mt76_connac_mcu common library

Rely on mt76_connac_mcu common library and remove duplicated code
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent ffa1bf97
...@@ -59,6 +59,11 @@ struct mt76_connac_pm { ...@@ -59,6 +59,11 @@ struct mt76_connac_pm {
extern const struct wiphy_wowlan_support mt76_connac_wowlan_support; extern const struct wiphy_wowlan_support mt76_connac_wowlan_support;
static inline bool is_mt7921(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7961;
}
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);
......
...@@ -561,6 +561,8 @@ enum { ...@@ -561,6 +561,8 @@ enum {
MCU_CMD_SCHED_SCAN_REQ = MCU_CE_PREFIX | 0x62, MCU_CMD_SCHED_SCAN_REQ = MCU_CE_PREFIX | 0x62,
MCU_CMD_REG_WRITE = MCU_CE_PREFIX | 0xc0, MCU_CMD_REG_WRITE = MCU_CE_PREFIX | 0xc0,
MCU_CMD_REG_READ = MCU_CE_PREFIX | MCU_QUERY_MASK | 0xc0, MCU_CMD_REG_READ = MCU_CE_PREFIX | MCU_QUERY_MASK | 0xc0,
MCU_CMD_FWLOG_2_HOST = MCU_CE_PREFIX | 0xc5,
MCU_CMD_GET_WTBL = MCU_CE_PREFIX | 0xcd,
}; };
enum { enum {
...@@ -575,6 +577,8 @@ enum { ...@@ -575,6 +577,8 @@ enum {
UNI_BSS_INFO_BCN_CONTENT = 7, UNI_BSS_INFO_BCN_CONTENT = 7,
UNI_BSS_INFO_QBSS = 15, UNI_BSS_INFO_QBSS = 15,
UNI_BSS_INFO_UAPSD = 19, UNI_BSS_INFO_UAPSD = 19,
UNI_BSS_INFO_PS = 21,
UNI_BSS_INFO_BCNFT = 22,
}; };
enum { enum {
...@@ -871,6 +875,23 @@ struct mt76_connac_suspend_tlv { ...@@ -871,6 +875,23 @@ struct mt76_connac_suspend_tlv {
u8 pad[5]; u8 pad[5];
} __packed; } __packed;
#define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id)
#define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id)
static inline void
mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
u8 *wlan_idx_lo, u8 *wlan_idx_hi)
{
*wlan_idx_hi = 0;
if (is_mt7921(dev)) {
*wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0;
*wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0;
} else {
*wlan_idx_lo = wcid ? wcid->idx : 0;
}
}
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);
......
# SPDX-License-Identifier: ISC # SPDX-License-Identifier: ISC
config MT7921E config MT7921E
tristate "MediaTek MT7921E (PCIe) support" tristate "MediaTek MT7921E (PCIe) support"
select MT76_CORE select MT76_CONNAC_LIB
depends on MAC80211 depends on MAC80211
depends on PCI depends on PCI
help help
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include "mt7921.h" #include "mt7921.h"
#include "mac.h" #include "mac.h"
#include "mcu.h"
#include "eeprom.h" #include "eeprom.h"
#define CCK_RATE(_idx, _rate) { \ #define CCK_RATE(_idx, _rate) { \
...@@ -139,7 +140,7 @@ static void mt7921_mac_init(struct mt7921_dev *dev) ...@@ -139,7 +140,7 @@ static void mt7921_mac_init(struct mt7921_dev *dev)
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
mt7921_mac_init_band(dev, i); mt7921_mac_init_band(dev, i);
mt7921_mcu_set_rts_thresh(&dev->phy, 0x92b); mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, 0);
} }
static void mt7921_init_work(struct work_struct *work) static void mt7921_init_work(struct work_struct *work)
......
...@@ -176,8 +176,9 @@ static int mt7921_start(struct ieee80211_hw *hw) ...@@ -176,8 +176,9 @@ static int mt7921_start(struct ieee80211_hw *hw)
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
mt7921_mcu_set_mac(dev, 0, true, false); mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, true, false);
mt7921_mcu_set_channel_domain(phy); mt76_connac_mcu_set_channel_domain(phy->mt76);
mt7921_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH); mt7921_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH);
mt7921_mac_reset_counters(phy); mt7921_mac_reset_counters(phy);
set_bit(MT76_STATE_RUNNING, &phy->mt76->state); set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
...@@ -199,7 +200,7 @@ static void mt7921_stop(struct ieee80211_hw *hw) ...@@ -199,7 +200,7 @@ static void mt7921_stop(struct ieee80211_hw *hw)
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
clear_bit(MT76_STATE_RUNNING, &phy->mt76->state); clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
mt7921_mcu_set_mac(dev, 0, false, false); mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
} }
...@@ -285,7 +286,8 @@ static int mt7921_add_interface(struct ieee80211_hw *hw, ...@@ -285,7 +286,8 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
mvif->mt76.band_idx = 0; mvif->mt76.band_idx = 0;
mvif->mt76.wmm_idx = mvif->mt76.idx % MT7921_MAX_WMM_SETS; mvif->mt76.wmm_idx = mvif->mt76.idx % MT7921_MAX_WMM_SETS;
ret = mt7921_mcu_uni_add_dev(dev, vif, true); ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
true);
if (ret) if (ret)
goto out; goto out;
...@@ -333,7 +335,7 @@ static void mt7921_remove_interface(struct ieee80211_hw *hw, ...@@ -333,7 +335,7 @@ static void mt7921_remove_interface(struct ieee80211_hw *hw,
if (vif == phy->monitor_vif) if (vif == phy->monitor_vif)
phy->monitor_vif = NULL; phy->monitor_vif = NULL;
mt7921_mcu_uni_add_dev(dev, vif, false); mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, false);
rcu_assign_pointer(dev->mt76.wcid[idx], NULL); rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
...@@ -589,11 +591,14 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -589,11 +591,14 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
msta->stats.jiffies = jiffies; msta->stats.jiffies = jiffies;
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
mt7921_mcu_uni_add_bss(&dev->phy, vif, true); mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
true);
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 = mt7921_mcu_uni_add_sta(dev, vif, sta, true); ret = mt76_connac_mcu_add_sta_cmd(&dev->mphy, vif, sta, &msta->wcid,
true, MCU_UNI_CMD_STA_REC_UPDATE);
if (ret) if (ret)
return ret; return ret;
...@@ -606,11 +611,17 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -606,11 +611,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;
mt7921_mcu_uni_add_sta(dev, vif, sta, false); mt76_connac_mcu_add_sta_cmd(&dev->mphy, vif, sta, &msta->wcid, false,
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);
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
mt7921_mcu_uni_add_bss(&dev->phy, vif, false); if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
false);
}
spin_lock_bh(&dev->sta_poll_lock); spin_lock_bh(&dev->sta_poll_lock);
if (!list_empty(&msta->poll_list)) if (!list_empty(&msta->poll_list))
...@@ -650,10 +661,9 @@ static void mt7921_tx(struct ieee80211_hw *hw, ...@@ -650,10 +661,9 @@ static void mt7921_tx(struct ieee80211_hw *hw,
static int mt7921_set_rts_threshold(struct ieee80211_hw *hw, u32 val) static int mt7921_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
{ {
struct mt7921_dev *dev = mt7921_hw_dev(hw); struct mt7921_dev *dev = mt7921_hw_dev(hw);
struct mt7921_phy *phy = mt7921_hw_phy(hw);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
mt7921_mcu_set_rts_thresh(phy, val); mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, 0);
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
return 0; return 0;
......
...@@ -166,20 +166,6 @@ struct mt7921_dev { ...@@ -166,20 +166,6 @@ struct mt7921_dev {
u8 fw_debug; u8 fw_debug;
}; };
enum {
HW_BSSID_0 = 0x0,
HW_BSSID_1,
HW_BSSID_2,
HW_BSSID_3,
HW_BSSID_MAX = HW_BSSID_3,
EXT_BSSID_START = 0x10,
EXT_BSSID_1,
EXT_BSSID_15 = 0x1f,
EXT_BSSID_MAX = EXT_BSSID_15,
REPEATER_BSSID_START = 0x20,
REPEATER_BSSID_MAX = 0x3f,
};
enum { enum {
MT_LMAC_AC00, MT_LMAC_AC00,
MT_LMAC_AC01, MT_LMAC_AC01,
...@@ -239,18 +225,12 @@ int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd); ...@@ -239,18 +225,12 @@ 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_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
int mt7921_mcu_set_eeprom(struct mt7921_dev *dev); int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
int mt7921_mcu_get_eeprom(struct mt7921_dev *dev, u32 offset); int mt7921_mcu_get_eeprom(struct mt7921_dev *dev, u32 offset);
int mt7921_mcu_set_mac(struct mt7921_dev *dev, int band, bool enable, int mt7921_mcu_get_rx_rate(struct mt7921_phy *phy, struct ieee80211_vif *vif,
bool hdr_trans); struct ieee80211_sta *sta, struct rate_info *rate);
int mt7921_mcu_set_rts_thresh(struct mt7921_phy *phy, u32 val);
int mt7921_mcu_fw_log_2_host(struct mt7921_dev *dev, u8 ctrl); int mt7921_mcu_fw_log_2_host(struct mt7921_dev *dev, u8 ctrl);
void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb); void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb);
void mt7921_mcu_exit(struct mt7921_dev *dev); void mt7921_mcu_exit(struct mt7921_dev *dev);
static inline bool is_mt7921(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7961;
}
static inline void mt7921_irq_enable(struct mt7921_dev *dev, u32 mask) static inline void mt7921_irq_enable(struct mt7921_dev *dev, u32 mask)
{ {
mt76_set_irq_mask(&dev->mt76, 0, 0, mask); mt76_set_irq_mask(&dev->mt76, 0, 0, mask);
...@@ -326,16 +306,7 @@ void mt7921_txp_skb_unmap(struct mt76_dev *dev, ...@@ -326,16 +306,7 @@ void mt7921_txp_skb_unmap(struct mt76_dev *dev,
void mt7921_set_stream_he_caps(struct mt7921_phy *phy); void mt7921_set_stream_he_caps(struct mt7921_phy *phy);
void mt7921_update_channel(struct mt76_dev *mdev); void mt7921_update_channel(struct mt76_dev *mdev);
int mt7921_init_debugfs(struct mt7921_dev *dev); int mt7921_init_debugfs(struct mt7921_dev *dev);
int
mt7921_mcu_uni_add_dev(struct mt7921_dev *dev,
struct ieee80211_vif *vif, bool enable);
int
mt7921_mcu_uni_add_bss(struct mt7921_phy *phy, struct ieee80211_vif *vif,
bool enable);
int
mt7921_mcu_uni_add_sta(struct mt7921_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, bool enable);
int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev, int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev,
struct ieee80211_ampdu_params *params, struct ieee80211_ampdu_params *params,
bool enable); bool enable);
...@@ -343,7 +314,6 @@ int mt7921_mcu_uni_rx_ba(struct mt7921_dev *dev, ...@@ -343,7 +314,6 @@ int mt7921_mcu_uni_rx_ba(struct mt7921_dev *dev,
struct ieee80211_ampdu_params *params, struct ieee80211_ampdu_params *params,
bool enable); bool enable);
void mt7921_scan_work(struct work_struct *work); void mt7921_scan_work(struct work_struct *work);
int mt7921_mcu_set_channel_domain(struct mt7921_phy *phy);
int mt7921_mcu_hw_scan(struct mt7921_phy *phy, struct ieee80211_vif *vif, int mt7921_mcu_hw_scan(struct mt7921_phy *phy, struct ieee80211_vif *vif,
struct ieee80211_scan_request *scan_req); struct ieee80211_scan_request *scan_req);
int mt7921_mcu_sched_scan_req(struct mt7921_phy *phy, int mt7921_mcu_sched_scan_req(struct mt7921_phy *phy,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "mt7921.h" #include "mt7921.h"
#include "mac.h" #include "mac.h"
#include "mcu.h"
#include "../trace.h" #include "../trace.h"
static const struct pci_device_id mt7921_pci_device_table[] = { static const struct pci_device_id mt7921_pci_device_table[] = {
......
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