Commit c3800cc2 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

mt76: mt7615: check mcu returned values in mt7615_ops

Properly check returned values from mcu utility routines in
mt7615_ops.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b1bed649
...@@ -29,6 +29,7 @@ static int mt7615_start(struct ieee80211_hw *hw) ...@@ -29,6 +29,7 @@ static int mt7615_start(struct ieee80211_hw *hw)
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
bool running; bool running;
int ret;
if (!mt7615_wait_for_mcu_init(dev)) if (!mt7615_wait_for_mcu_init(dev))
return -EIO; return -EIO;
...@@ -38,21 +39,38 @@ static int mt7615_start(struct ieee80211_hw *hw) ...@@ -38,21 +39,38 @@ static int mt7615_start(struct ieee80211_hw *hw)
running = mt7615_dev_running(dev); running = mt7615_dev_running(dev);
if (!running) { if (!running) {
mt7615_mcu_set_pm(dev, 0, 0); ret = mt7615_mcu_set_pm(dev, 0, 0);
mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, true, false); if (ret)
goto out;
ret = mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, true, false);
if (ret)
goto out;
mt7615_mac_enable_nf(dev, 0); mt7615_mac_enable_nf(dev, 0);
} }
if (phy != &dev->phy) { if (phy != &dev->phy) {
mt7615_mcu_set_pm(dev, 1, 0); ret = mt7615_mcu_set_pm(dev, 1, 0);
mt76_connac_mcu_set_mac_enable(&dev->mt76, 1, true, false); if (ret)
goto out;
ret = mt76_connac_mcu_set_mac_enable(&dev->mt76, 1, true, false);
if (ret)
goto out;
mt7615_mac_enable_nf(dev, 1); mt7615_mac_enable_nf(dev, 1);
} }
if (mt7615_firmware_offload(dev)) if (mt7615_firmware_offload(dev)) {
mt76_connac_mcu_set_channel_domain(phy->mt76); ret = mt76_connac_mcu_set_channel_domain(phy->mt76);
if (ret)
goto out;
}
mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH); ret = mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH);
if (ret)
goto out;
set_bit(MT76_STATE_RUNNING, &phy->mt76->state); set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
...@@ -62,9 +80,10 @@ static int mt7615_start(struct ieee80211_hw *hw) ...@@ -62,9 +80,10 @@ static int mt7615_start(struct ieee80211_hw *hw)
if (!running) if (!running)
mt7615_mac_reset_counters(dev); mt7615_mac_reset_counters(dev);
out:
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
return 0; return ret;
} }
static void mt7615_stop(struct ieee80211_hw *hw) static void mt7615_stop(struct ieee80211_hw *hw)
...@@ -197,7 +216,9 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, ...@@ -197,7 +216,9 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
dev->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); dev->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
mt7615_mcu_set_dbdc(dev); ret = mt7615_mcu_set_dbdc(dev);
if (ret)
goto out;
idx = MT7615_WTBL_RESERVED - mvif->mt76.idx; idx = MT7615_WTBL_RESERVED - mvif->mt76.idx;
...@@ -296,8 +317,13 @@ int mt7615_set_channel(struct mt7615_phy *phy) ...@@ -296,8 +317,13 @@ int mt7615_set_channel(struct mt7615_phy *phy)
mt76_set_channel(phy->mt76); mt76_set_channel(phy->mt76);
if (is_mt7615(&dev->mt76) && dev->flash_eeprom) { if (is_mt7615(&dev->mt76) && dev->flash_eeprom) {
mt7615_mcu_apply_rx_dcoc(phy); ret = mt7615_mcu_apply_rx_dcoc(phy);
mt7615_mcu_apply_tx_dpd(phy); if (ret)
goto out;
ret = mt7615_mcu_apply_tx_dpd(phy);
if (ret)
goto out;
} }
ret = mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_CHANNEL_SWITCH); ret = mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_CHANNEL_SWITCH);
...@@ -306,8 +332,13 @@ int mt7615_set_channel(struct mt7615_phy *phy) ...@@ -306,8 +332,13 @@ int mt7615_set_channel(struct mt7615_phy *phy)
mt7615_mac_set_timing(phy); mt7615_mac_set_timing(phy);
ret = mt7615_dfs_init_radar_detector(phy); ret = mt7615_dfs_init_radar_detector(phy);
if (ret)
goto out;
mt7615_mac_cca_stats_reset(phy); mt7615_mac_cca_stats_reset(phy);
mt7615_mcu_set_sku_en(phy, true); ret = mt7615_mcu_set_sku_en(phy, true);
if (ret)
goto out;
mt7615_mac_reset_counters(dev); mt7615_mac_reset_counters(dev);
phy->noise = 0; phy->noise = 0;
...@@ -587,15 +618,21 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -587,15 +618,21 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (err) if (err)
return err; return err;
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
mt7615_mcu_add_bss_info(phy, vif, sta, true); err = mt7615_mcu_add_bss_info(phy, vif, sta, true);
if (err)
return err;
}
mt7615_mac_wtbl_update(dev, idx, mt7615_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
mt7615_mcu_sta_add(&dev->phy, vif, sta, true); err = mt7615_mcu_sta_add(&dev->phy, vif, sta, true);
if (err)
return err;
mt76_connac_power_save_sched(phy->mt76, &dev->pm); mt76_connac_power_save_sched(phy->mt76, &dev->pm);
return 0; return err;
} }
EXPORT_SYMBOL_GPL(mt7615_mac_sta_add); EXPORT_SYMBOL_GPL(mt7615_mac_sta_add);
...@@ -715,13 +752,13 @@ static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val) ...@@ -715,13 +752,13 @@ static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
{ {
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
int band = phy != &dev->phy; int err, band = phy != &dev->phy;
mt7615_mutex_acquire(dev); mt7615_mutex_acquire(dev);
mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, band); err = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, band);
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
return 0; return err;
} }
static int static int
...@@ -749,16 +786,16 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -749,16 +786,16 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
case IEEE80211_AMPDU_RX_START: case IEEE80211_AMPDU_RX_START:
mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn, mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
params->buf_size); params->buf_size);
mt7615_mcu_add_rx_ba(dev, params, true); ret = mt7615_mcu_add_rx_ba(dev, params, true);
break; break;
case IEEE80211_AMPDU_RX_STOP: case IEEE80211_AMPDU_RX_STOP:
mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid); mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
mt7615_mcu_add_rx_ba(dev, params, false); ret = mt7615_mcu_add_rx_ba(dev, params, false);
break; break;
case IEEE80211_AMPDU_TX_OPERATIONAL: case IEEE80211_AMPDU_TX_OPERATIONAL:
mtxq->aggr = true; mtxq->aggr = true;
mtxq->send_bar = false; mtxq->send_bar = false;
mt7615_mcu_add_tx_ba(dev, params, true); ret = mt7615_mcu_add_tx_ba(dev, params, true);
ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid); ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
ieee80211_send_bar(vif, sta->addr, tid, ieee80211_send_bar(vif, sta->addr, tid,
IEEE80211_SN_TO_SEQ(ssn)); IEEE80211_SN_TO_SEQ(ssn));
...@@ -766,7 +803,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -766,7 +803,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
case IEEE80211_AMPDU_TX_STOP_FLUSH: case IEEE80211_AMPDU_TX_STOP_FLUSH:
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
mtxq->aggr = false; mtxq->aggr = false;
mt7615_mcu_add_tx_ba(dev, params, false); ret = mt7615_mcu_add_tx_ba(dev, params, false);
break; break;
case IEEE80211_AMPDU_TX_START: case IEEE80211_AMPDU_TX_START:
ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid); ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
...@@ -775,7 +812,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -775,7 +812,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
break; break;
case IEEE80211_AMPDU_TX_STOP_CONT: case IEEE80211_AMPDU_TX_STOP_CONT:
mtxq->aggr = false; mtxq->aggr = false;
mt7615_mcu_add_tx_ba(dev, params, false); ret = mt7615_mcu_add_tx_ba(dev, params, false);
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
break; break;
} }
...@@ -1091,6 +1128,7 @@ static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw, ...@@ -1091,6 +1128,7 @@ static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw,
struct ieee80211_vif *vif) struct ieee80211_vif *vif)
{ {
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
int err;
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
return 0; return 0;
...@@ -1099,10 +1137,10 @@ static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw, ...@@ -1099,10 +1137,10 @@ static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw,
cancel_work_sync(&phy->roc_work); cancel_work_sync(&phy->roc_work);
mt7615_mutex_acquire(phy->dev); mt7615_mutex_acquire(phy->dev);
mt7615_mcu_set_roc(phy, vif, NULL, 0); err = mt7615_mcu_set_roc(phy, vif, NULL, 0);
mt7615_mutex_release(phy->dev); mt7615_mutex_release(phy->dev);
return 0; return err;
} }
static void mt7615_sta_set_decap_offload(struct ieee80211_hw *hw, static void mt7615_sta_set_decap_offload(struct ieee80211_hw *hw,
......
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