diff options
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7921/mcu.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 126 |
1 files changed, 75 insertions, 51 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index aa55667b6ed7..5f3d56d570a5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -160,8 +160,10 @@ mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, int ret = 0; if (!skb) { - dev_err(mdev->dev, "Message %d (seq %d) timeout\n", + dev_err(mdev->dev, "Message %08x (seq %d) timeout\n", cmd, seq); + mt7921_reset(mdev); + return -ETIMEDOUT; } @@ -500,7 +502,7 @@ mt7921_mcu_debug_msg_event(struct mt7921_dev *dev, struct sk_buff *skb) if (!msg->content[i]) msg->content[i] = ' '; } - wiphy_info(mt76_hw(dev)->wiphy, "%*s", len, msg->content); + wiphy_info(mt76_hw(dev)->wiphy, "%.*s", len, msg->content); } } @@ -974,7 +976,6 @@ int mt7921_mcu_init(struct mt7921_dev *dev) .mcu_skb_send_msg = mt7921_mcu_send_message, .mcu_parse_response = mt7921_mcu_parse_response, .mcu_restart = mt7921_mcu_restart, - .mcu_reset = mt7921_reset, }; dev->mt76.mcu_ops = &mt7921_mcu_ops; @@ -1264,12 +1265,35 @@ int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, sizeof(req), false); } +int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta, + struct ieee80211_vif *vif, bool enable) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + int rssi = -ewma_rssi_read(&mvif->rssi); + struct mt76_sta_cmd_info info = { + .sta = sta, + .vif = vif, + .enable = enable, + .cmd = MCU_UNI_CMD_STA_REC_UPDATE, + .rcpi = to_rcpi(rssi), + }; + struct mt7921_sta *msta; + + msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL; + info.wcid = msta ? &msta->wcid : &mvif->sta.wcid; + + return mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info); +} + int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev) { struct mt76_phy *mphy = &dev->mt76.phy; - int i; + struct mt76_connac_pm *pm = &dev->pm; + int i, err = 0; + + mutex_lock(&pm->mutex); - if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state)) + if (!test_bit(MT76_STATE_PM, &mphy->state)) goto out; for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) { @@ -1281,23 +1305,35 @@ int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev) if (i == MT7921_DRV_OWN_RETRY_COUNT) { dev_err(dev->mt76.dev, "driver own failed\n"); - mt7921_reset(&dev->mt76); - return -EIO; + err = -EIO; + goto out; } + mt7921_wpdma_reinit_cond(dev); + 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; out: - dev->pm.last_activity = jiffies; + mutex_unlock(&pm->mutex); - return 0; + if (err) + mt7921_reset(&dev->mt76); + + return err; } int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev) { struct mt76_phy *mphy = &dev->mt76.phy; - int i; + struct mt76_connac_pm *pm = &dev->pm; + int i, err = 0; - if (test_and_set_bit(MT76_STATE_PM, &mphy->state)) - return 0; + mutex_lock(&pm->mutex); + + if (mt76_connac_skip_fw_pmctrl(mphy, pm)) + goto out; for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) { mt76_wr(dev, MT_CONN_ON_LPCTL, PCIE_LPCR_HOST_SET_OWN); @@ -1308,11 +1344,20 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev) if (i == MT7921_DRV_OWN_RETRY_COUNT) { dev_err(dev->mt76.dev, "firmware own failed\n"); - mt7921_reset(&dev->mt76); - return -EIO; + clear_bit(MT76_STATE_PM, &mphy->state); + err = -EIO; } - return 0; + pm->stats.last_doze_event = jiffies; + pm->stats.awake_time += pm->stats.last_doze_event - + pm->stats.last_wake_event; +out: + mutex_unlock(&pm->mutex); + + if (err) + mt7921_reset(&dev->mt76); + + return err; } void @@ -1339,46 +1384,25 @@ mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) } } -int mt7921_mcu_update_arp_filter(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *info) +int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr) { - struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; - struct mt7921_dev *dev = mt7921_hw_dev(hw); - struct sk_buff *skb; - int i, len = min_t(int, info->arp_addr_cnt, - IEEE80211_BSS_ARP_ADDR_LIST_LEN); - struct { - struct { - u8 bss_idx; - u8 pad[3]; - } __packed hdr; - struct mt76_connac_arpns_tlv arp; - } req_hdr = { - .hdr = { - .bss_idx = mvif->mt76.idx, - }, - .arp = { - .tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ARP), - .len = cpu_to_le16(sizeof(struct mt76_connac_arpns_tlv)), - .ips_num = len, - .mode = 2, /* update */ - .option = 1, - }, + struct mt7921_txpwr_event *event; + struct mt7921_txpwr_req req = { + .dbdc_idx = 0, }; + struct sk_buff *skb; + int ret; - skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, - sizeof(req_hdr) + len * sizeof(__be32)); - if (!skb) - return -ENOMEM; + ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_CMD_GET_TXPWR, + &req, sizeof(req), true, &skb); + if (ret) + return ret; - skb_put_data(skb, &req_hdr, sizeof(req_hdr)); - for (i = 0; i < len; i++) { - u8 *addr = (u8 *)skb_put(skb, sizeof(__be32)); + event = (struct mt7921_txpwr_event *)skb->data; + WARN_ON(skb->len != le16_to_cpu(event->len)); + memcpy(txpwr, &event->txpwr, sizeof(event->txpwr)); - memcpy(addr, &info->arp_addr_list[i], sizeof(__be32)); - } + dev_kfree_skb(skb); - return mt76_mcu_skb_send_msg(&dev->mt76, skb, MCU_UNI_CMD_OFFLOAD, - true); + return 0; } |