Skip to content

Commit

Permalink
mt76: mt76_connac: create mcu library
Browse files Browse the repository at this point in the history
Introduce mt76_connac common mcu library for code sharing between mt7615 and
mt7921 devices

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Jan 29, 2021
1 parent 261d184 commit 50349a8
Show file tree
Hide file tree
Showing 11 changed files with 1,860 additions and 1,420 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ obj-$(CONFIG_MT76_USB) += mt76-usb.o
obj-$(CONFIG_MT76_SDIO) += mt76-sdio.o
obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o
obj-$(CONFIG_MT76_CONNAC_LIB) += mt76-connac-lib.o

mt76-y := \
mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \
Expand All @@ -27,6 +28,8 @@ mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \

mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o

mt76-connac-lib-y := mt76_connac_mcu.o

obj-$(CONFIG_MT76x0_COMMON) += mt76x0/
obj-$(CONFIG_MT76x2_COMMON) += mt76x2/
obj-$(CONFIG_MT7603E) += mt7603/
Expand Down
2 changes: 1 addition & 1 deletion mt7615/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

config MT7615_COMMON
tristate
select MT76_CORE
select MT76_CONNAC_LIB

config MT7615E
tristate "MediaTek MT7615E and MT7663E (PCIe) support"
Expand Down
6 changes: 4 additions & 2 deletions mt7615/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/etherdevice.h>
#include "mt7615.h"
#include "mac.h"
#include "mcu.h"
#include "eeprom.h"

static void
Expand Down Expand Up @@ -96,7 +97,7 @@ mt7615_mac_init(struct mt7615_dev *dev)
MT_TMAC_CTCR0_INS_DDLMT_VHT_SMPDU_EN |
MT_TMAC_CTCR0_INS_DDLMT_EN);

mt7615_mcu_set_rts_thresh(&dev->phy, 0x92b);
mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, 0);
mt7615_mac_set_scs(&dev->phy, true);

mt76_rmw(dev, MT_AGG_SCR, MT_AGG_SCR_NLNAV_MID_PTEC_DIS,
Expand Down Expand Up @@ -321,7 +322,8 @@ mt7615_regd_notifier(struct wiphy *wiphy,

if (chandef->chan->flags & IEEE80211_CHAN_RADAR)
mt7615_dfs_init_radar_detector(phy);
mt7615_mcu_set_channel_domain(phy);
if (mt7615_firmware_offload(phy->dev))
mt76_connac_mcu_set_channel_domain(mphy);

mt7615_mutex_release(dev);
}
Expand Down
27 changes: 15 additions & 12 deletions mt7615/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@ static int mt7615_start(struct ieee80211_hw *hw)

if (!running) {
mt7615_mcu_set_pm(dev, 0, 0);
mt7615_mcu_set_mac_enable(dev, 0, true);
mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, true, false);
mt7615_mac_enable_nf(dev, 0);
}

if (phy != &dev->phy) {
mt7615_mcu_set_pm(dev, 1, 0);
mt7615_mcu_set_mac_enable(dev, 1, true);
mt76_connac_mcu_set_mac_enable(&dev->mt76, 1, true, false);
mt7615_mac_enable_nf(dev, 1);
}

mt7615_mcu_set_channel_domain(phy);
if (mt7615_firmware_offload(dev))
mt76_connac_mcu_set_channel_domain(phy->mt76);

mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH);

set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
Expand Down Expand Up @@ -104,12 +106,12 @@ static void mt7615_stop(struct ieee80211_hw *hw)

if (phy != &dev->phy) {
mt7615_mcu_set_pm(dev, 1, 1);
mt7615_mcu_set_mac_enable(dev, 1, false);
mt76_connac_mcu_set_mac_enable(&dev->mt76, 1, false, false);
}

if (!mt7615_dev_running(dev)) {
mt7615_mcu_set_pm(dev, 0, 1);
mt7615_mcu_set_mac_enable(dev, 0, false);
mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
}

mt7615_mutex_release(dev);
Expand Down Expand Up @@ -228,7 +230,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
mtxq->wcid = &mvif->sta.wcid;
}

ret = mt7615_mcu_add_dev_info(dev, vif, true);
ret = mt7615_mcu_add_dev_info(phy, vif, true);
if (ret)
goto out;

Expand Down Expand Up @@ -259,7 +261,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
mt7615_free_pending_tx_skbs(dev, msta);

mt7615_mac_set_beacon_filter(phy, vif, false);
mt7615_mcu_add_dev_info(dev, vif, false);
mt7615_mcu_add_dev_info(phy, vif, false);

rcu_assign_pointer(dev->mt76.wcid[idx], NULL);

Expand Down Expand Up @@ -542,7 +544,7 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,

if (changed & BSS_CHANGED_BEACON_ENABLED) {
mt7615_mcu_add_bss_info(phy, vif, NULL, info->enable_beacon);
mt7615_mcu_sta_add(dev, vif, NULL, info->enable_beacon);
mt7615_mcu_sta_add(phy, vif, NULL, info->enable_beacon);

if (vif->p2p && info->enable_beacon)
mt7615_mcu_set_p2p_oppps(hw, vif);
Expand All @@ -553,7 +555,7 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
mt7615_mcu_add_beacon(dev, hw, vif, info->enable_beacon);

if (changed & BSS_CHANGED_PS)
mt7615_mcu_set_vif_ps(dev, vif);
mt76_connac_mcu_set_vif_ps(&dev->mt76, vif);

if (changed & BSS_CHANGED_ARP_FILTER)
mt7615_mcu_update_arp_filter(hw, vif, info);
Expand Down Expand Up @@ -603,7 +605,7 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
}
mt7615_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
mt7615_mcu_sta_add(dev, vif, sta, true);
mt7615_mcu_sta_add(&dev->phy, vif, sta, true);

mt7615_pm_power_save_sched(dev);

Expand All @@ -620,7 +622,7 @@ void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7615_free_pending_tx_skbs(dev, msta);
mt7615_pm_wake(dev);

mt7615_mcu_sta_add(dev, vif, sta, false);
mt7615_mcu_sta_add(&dev->phy, vif, sta, false);
mt7615_mac_wtbl_update(dev, msta->wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
Expand Down Expand Up @@ -737,9 +739,10 @@ static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
{
struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw);
int band = phy != &dev->phy;

mt7615_mutex_acquire(dev);
mt7615_mcu_set_rts_thresh(phy, val);
mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, band);
mt7615_mutex_release(dev);

return 0;
Expand Down
Loading

0 comments on commit 50349a8

Please sign in to comment.