x_get_wcid(struct mt7615_dev *dev, struct mt7615_sta *sta; struct mt76_wcid *wcid; - if (idx >= MT7615_WTBL_SIZE) - return NULL; - - wcid = rcu_dereference(dev->mt76.wcid[idx]); + wcid = mt76_wcid_ptr(dev, idx); if (unicast || !wcid) return wcid; @@ -1507,7 +1504,7 @@ static void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data) rcu_read_lock(); - wcid = rcu_dereference(dev->mt76.wcid[wcidx]); + wcid = mt76_wcid_ptr(dev, wcidx); if (!wcid) goto out; diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/main.c b/sys/contrib/dev/mediatek/mt76/mt7615/main.c index 2e7b05eeef7a..15fe155ac3f3 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/main.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/main.c @@ -97,7 +97,7 @@ static void mt7615_stop(struct ieee80211_hw *hw, bool suspend) struct mt7615_phy *phy = mt7615_hw_phy(hw); cancel_delayed_work_sync(&phy->mt76->mac_work); - del_timer_sync(&phy->roc_timer); + timer_delete_sync(&phy->roc_timer); cancel_work_sync(&phy->roc_work); cancel_delayed_work_sync(&dev->pm.ps_work); @@ -420,7 +420,7 @@ static int mt7615_set_sar_specs(struct ieee80211_hw *hw, return mt76_update_channel(phy->mt76); } -static int mt7615_config(struct ieee80211_hw *hw, u32 changed) +static int mt7615_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) { struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw); @@ -784,7 +784,8 @@ static void mt7615_tx(struct ieee80211_hw *hw, mt76_connac_pm_queue_skb(hw, &dev->pm, wcid, skb); } -static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val) +static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, + u32 val) { struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw); @@ -972,7 +973,8 @@ mt7615_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, } static void -mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class) +mt7615_set_coverage_class(struct ieee80211_hw *hw, int radio_idx, + s16 coverage_class) { struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_dev *dev = phy->dev; @@ -984,7 +986,8 @@ mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class) } static int -mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) +mt7615_set_antenna(struct ieee80211_hw *hw, int radio_idx, + u32 tx_ant, u32 rx_ant) { struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw); @@ -1043,7 +1046,7 @@ void mt7615_roc_work(struct work_struct *work) void mt7615_roc_timer(struct timer_list *timer) { - struct mt7615_phy *phy = from_timer(phy, timer, roc_timer); + struct mt7615_phy *phy = timer_container_of(phy, timer, roc_timer); ieee80211_queue_work(phy->mt76->hw, &phy->roc_work); } @@ -1194,7 +1197,7 @@ static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw, if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) return 0; - del_timer_sync(&phy->roc_timer); + timer_delete_sync(&phy->roc_timer); cancel_work_sync(&phy->roc_work); mt7615_mutex_acquire(phy->dev); diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c b/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c index ccc36ee0900c..ec2f759d407f 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c @@ -2071,7 +2071,7 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku) }; tx_power = mt76_get_sar_power(mphy, mphy->chandef.chan, tx_power); - tx_power -= mt76_tx_power_nss_delta(n_chains); + tx_power -= mt76_tx_power_path_delta(n_chains); tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan, &limits, tx_power); mphy->txpower_cur = tx_power; @@ -2088,8 +2088,8 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku) int delta = 0; if (i < n_chains - 1) - delta = mt76_tx_power_nss_delta(n_chains) - - mt76_tx_power_nss_delta(i + 1); + delta = mt76_tx_power_path_delta(n_chains) - + mt76_tx_power_path_delta(i + 1); sku[MT_SKU_1SS_DELTA + i] = delta; } } diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c b/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c index 5da2bf332af0..fe8a3d852dbf 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c @@ -223,12 +223,12 @@ void mt7615_mac_reset_work(struct work_struct *work) set_bit(MT76_MCU_RESET, &dev->mphy.state); wake_up(&dev->mt76.mcu.wait); cancel_delayed_work_sync(&dev->mphy.mac_work); - del_timer_sync(&dev->phy.roc_timer); + timer_delete_sync(&dev->phy.roc_timer); cancel_work_sync(&dev->phy.roc_work); if (phy2) { set_bit(MT76_RESET, &phy2->mt76->state); cancel_delayed_work_sync(&phy2->mt76->mac_work); - del_timer_sync(&phy2->roc_timer); + timer_delete_sync(&phy2->roc_timer); cancel_work_sync(&phy2->roc_work); } diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/sdio_mcu.c b/sys/contrib/dev/mediatek/mt76/mt7615/sdio_mcu.c deleted file mode 100644 index a7b8acb2da83..000000000000 --- a/sys/contrib/dev/mediatek/mt76/mt7615/sdio_mcu.c +++ /dev/null @@ -1,180 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2020 MediaTek Inc. - * - * Author: Felix Fietkau - * Lorenzo Bianconi - * Sean Wang - */ -#include -#include -#include -#include - -#include "../sdio.h" -#include "mt7615.h" -#include "mac.h" -#include "mcu.h" -#include "regs.h" - -static int mt7663s_mcu_init_sched(struct mt7615_dev *dev) -{ - struct mt76_sdio *sdio = &dev->mt76.sdio; - u32 txdwcnt; - - sdio->sched.pse_data_quota = mt76_get_field(dev, MT_PSE_PG_HIF0_GROUP, - MT_HIF0_MIN_QUOTA); - sdio->sched.pse_mcu_quota = mt76_get_field(dev, MT_PSE_PG_HIF1_GROUP, - MT_HIF1_MIN_QUOTA); - sdio->sched.ple_data_quota = mt76_get_field(dev, MT_PLE_PG_HIF0_GROUP, - MT_HIF0_MIN_QUOTA); - sdio->sched.pse_page_size = MT_PSE_PAGE_SZ; - txdwcnt = mt76_get_field(dev, MT_PP_TXDWCNT, - MT_PP_TXDWCNT_TX1_ADD_DW_CNT); - sdio->sched.deficit = txdwcnt << 2; - - return 0; -} - -static int -mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, - int cmd, int *seq) -{ - struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); - int ret; - - mt7615_mcu_fill_msg(dev, skb, cmd, seq); - ret = mt76_tx_queue_skb_raw(dev, mdev->q_mcu[MT_MCUQ_WM], skb, 0); - if (ret) - return ret; - - mt76_queue_kick(dev, mdev->q_mcu[MT_MCUQ_WM]); - - return ret; -} - -static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) -{ - struct sdio_func *func = dev->mt76.sdio.func; - struct mt76_phy *mphy = &dev->mt76.phy; - struct mt76_connac_pm *pm = &dev->pm; - u32 status; - int ret; - - sdio_claim_host(func); - - sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, NULL); - - ret = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status, - status & WHLPCR_IS_DRIVER_OWN, 2000, 1000000); - if (ret < 0) { - dev_err(dev->mt76.dev, "Cannot get ownership from device"); - } else { - clear_bit(MT76_STATE_PM, &mphy->state); - - pm->stats.last_wake_event = jiffies; - pm->stats.doze_time += pm->stats.last_wake_event - - pm->stats.last_doze_event; - } - sdio_release_host(func); - - return ret; -} - -static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) -{ - struct mt76_phy *mphy = &dev->mt76.phy; - int ret = 0; - - mutex_lock(&dev->pm.mutex); - - if (test_bit(MT76_STATE_PM, &mphy->state)) - ret = __mt7663s_mcu_drv_pmctrl(dev); - - mutex_unlock(&dev->pm.mutex); - - return ret; -} - -static int mt7663s_mcu_fw_pmctrl(struct mt7615_dev *dev) -{ - struct sdio_func *func = dev->mt76.sdio.func; - struct mt76_phy *mphy = &dev->mt76.phy; - struct mt76_connac_pm *pm = &dev->pm; - int ret = 0; - u32 status; - - mutex_lock(&pm->mutex); - - if (mt76_connac_skip_fw_pmctrl(mphy, pm)) - goto out; - - sdio_claim_host(func); - - sdio_writel(func, WHLPCR_FW_OWN_REQ_SET, MCR_WHLPCR, NULL); - - ret = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status, - !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000); - if (ret < 0) { - dev_err(dev->mt76.dev, "Cannot set ownership to device"); - clear_bit(MT76_STATE_PM, &mphy->state); - } else { - pm->stats.last_doze_event = jiffies; - pm->stats.awake_time += pm->stats.last_doze_event - - pm->stats.last_wake_event; - } - - sdio_release_host(func); -out: - mutex_unlock(&pm->mutex); - - return ret; -} - -int mt7663s_mcu_init(struct mt7615_dev *dev) -{ - static const struct mt76_mcu_ops mt7663s_mcu_ops = { - .headroom = sizeof(struct mt7615_mcu_txd), - .tailroom = MT_USB_TAIL_SIZE, - .mcu_skb_send_msg = mt7663s_mcu_send_message, - .mcu_parse_response = mt7615_mcu_parse_response, - .mcu_rr = mt76_connac_mcu_reg_rr, - .mcu_wr = mt76_connac_mcu_reg_wr, - }; - struct mt7615_mcu_ops *mcu_ops; - int ret; - - ret = __mt7663s_mcu_drv_pmctrl(dev); - if (ret) - return ret; - - dev->mt76.mcu_ops = &mt7663s_mcu_ops; - - ret = mt76_get_field(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_N9_RDY); - if (ret) { - mt7615_mcu_restart(&dev->mt76); - if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, - MT_TOP_MISC2_FW_N9_RDY, 0, 500)) - return -EIO; - } - - ret = __mt7663_load_firmware(dev); - if (ret) - return ret; - - mcu_ops = devm_kmemdup(dev->mt76.dev, dev->mcu_ops, sizeof(*mcu_ops), - GFP_KERNEL); - if (!mcu_ops) - return -ENOMEM; - - mcu_ops->set_drv_ctrl = mt7663s_mcu_drv_pmctrl; - mcu_ops->set_fw_ctrl = mt7663s_mcu_fw_pmctrl; - dev->mcu_ops = mcu_ops; - - ret = mt7663s_mcu_init_sched(dev); - if (ret) - return ret; - - set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); - - return 0; -} diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/usb.c b/sys/contrib/dev/mediatek/mt76/mt7615/usb.c index 4aa9fa1c4a23..d96e06b4fee1 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/usb.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/usb.c @@ -85,7 +85,7 @@ static void mt7663u_stop(struct ieee80211_hw *hw, bool suspend) struct mt7615_dev *dev = hw->priv; clear_bit(MT76_STATE_RUNNING, &dev->mphy.state); - del_timer_sync(&phy->roc_timer); + timer_delete_sync(&phy->roc_timer); cancel_work_sync(&phy->roc_work); cancel_delayed_work_sync(&phy->scan_work); cancel_delayed_work_sync(&phy->mt76->mac_work); diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/usb_mcu.c b/sys/contrib/dev/mediatek/mt76/mt7615/usb_mcu.c deleted file mode 100644 index 33c01f8ce8e2..000000000000 --- a/sys/contrib/dev/mediatek/mt76/mt7615/usb_mcu.c +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2019 MediaTek Inc. - * - * Author: Felix Fietkau - * Lorenzo Bianconi - * Sean Wang - */ -#include -#include - -#include "mt7615.h" -#include "mac.h" -#include "mcu.h" -#include "regs.h" - -static int -mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, - int cmd, int *seq) -{ - struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); - int ret, ep, len, pad; - - mt7615_mcu_fill_msg(dev, skb, cmd, seq); - if (cmd != MCU_CMD(FW_SCATTER)) - ep = MT_EP_OUT_INBAND_CMD; - else - ep = MT_EP_OUT_AC_BE; - - len = skb->len; - put_unaligned_le32(len, skb_push(skb, sizeof(len))); - pad = round_up(skb->len, 4) + 4 - skb->len; - ret = mt76_skb_adjust_pad(skb, pad); - if (ret < 0) - goto out; - *** 10286 LINES SKIPPED ***