mt76: rewrite dma descriptor base and ring size on queue reset
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/3 mt76: rewrite dma descriptor base and ring size on queue reset
Useful in case the hardware reset clobbers these values
Signed-off-by Felix Fietkau <[email protected]>
--- drivers/net/wireless/mediatek/mt76/dma.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/dma.c +2 -0
@@ -137,6 +137,8 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx,static void mt76_dma_sync_idx (struct mt76_dev *dev,struct mt76_queue *q) { +iowrite32 (q->desc_dma, &q->regs->desc_base); +iowrite32 (q->ndesc, &q->regs->ring_size); q->head =ioread32 (&q->regs->dma_idx); q->tail = q->head;iowrite32 (q->head, &q->regs->cpu_idx);
Signature · 1 line
2.17.0
Felix Fietkau
maintainerPATCH 2/3 mt76: mt76x02: when setting a key, use PN from mac80211
Preparation for full device restart support
Signed-off-by Felix Fietkau <[email protected]>
--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +15 -1
@@ -73,6 +73,7 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx,enum mt76x02_cipher_type cipher;u8 key_data[32 ];u8 iv_data[8 ]; +u64 pn; cipher =mt76x02_mac_get_key_info (key, key_data);if (cipher ==MT_CIPHER_NONE && key)
@@ -85,9 +86,22 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx,if (key) {mt76_rmw_field (dev,MT_WCID_ATTR (idx),MT_WCID_ATTR_PAIRWISE , !!(key->flags &IEEE80211_KEY_FLAG_PAIRWISE )); + + pn =atomic64_read (&key->tx_pn); + iv_data[3 ] = key->keyidx <<6 ; -if (cipher >=MT_CIPHER_TKIP ) +if (cipher >=MT_CIPHER_TKIP ) { iv_data[3 ] |=0x20 ; +put_unaligned_le32 (pn >>16 , &iv_data[4 ]); + } + +if (cipher ==MT_CIPHER_TKIP ) { + iv_data[0 ] = (pn >>8 ) &0xff ; + iv_data[1 ] = (iv_data[0 ] |0x20 ) &0x7f ; + iv_data[2 ] = pn &0xff ; + }else if (cipher >=MT_CIPHER_AES_CCMP ) { +put_unaligned_le16 ((pn &0xffff ), &iv_data[0 ]); + } }mt76_wr_copy (dev,MT_WCID_IV (idx), iv_data,sizeof (iv_data));
Signature · 1 line
2.17.0
Felix Fietkau
maintainerPATCH 3/3 mt76: mt76x2: implement full device restart on watchdog reset
In reply to Felix FietkauRestart the firmware and re-initialize the MAC to be able to recover from more kinds of hang states
Signed-off-by Felix Fietkau <[email protected]>
--- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + .../net/wireless/mediatek/mt76/mt76x02_mac.c | 26 ++++++ .../net/wireless/mediatek/mt76/mt76x02_mac.h | 2 + .../net/wireless/mediatek/mt76/mt76x02_mmio.c | 81 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt76x02_util.c | 4 + .../wireless/mediatek/mt76/mt76x2/mt76x2.h | 1 + .../wireless/mediatek/mt76/mt76x2/pci_init.c | 2 +- .../wireless/mediatek/mt76/mt76x2/pci_mcu.c | 21 +++++ drivers/net/wireless/mediatek/mt76/tx.c | 3 + 9 files changed, 132 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -144,6 +144,7 @@ struct mt76_mcu_ops { const struct mt76_reg_pair *rp, int len);int (*mcu_rd_rp)(struct mt76_dev *dev,u32 base,struct mt76_reg_pair *rp,int len); +int (*mcu_restart)(struct mt76_dev *dev); };struct mt76_queue_ops {
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +26 -0
@@ -67,6 +67,32 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, }EXPORT_SYMBOL_GPL (mt76x02_mac_shared_key_setup); +void mt76x02_mac_wcid_sync_pn (struct mt76x02_dev *dev,u8 idx, +struct ieee80211_key_conf *key) +{ +enum mt76x02_cipher_type cipher; +u8 key_data[32 ]; +u32 iv, eiv; +u64 pn; + + cipher =mt76x02_mac_get_key_info (key, key_data); + iv =mt76_rr (dev,MT_WCID_IV (idx)); + eiv =mt76_rr (dev,MT_WCID_IV (idx) +4 ); + + pn = (u64 )eiv <<16 ; +if (cipher ==MT_CIPHER_TKIP ) { + pn |= (iv >>16 ) &0xff ; + pn |= (iv &0xff ) <<8 ; + }else if (cipher >=MT_CIPHER_AES_CCMP ) { + pn |= iv &0xffff ; + }else { +return ; + } + +atomic64_set (&key->tx_pn, pn); +} + +int mt76x02_mac_wcid_set_key (struct mt76x02_dev *dev,u8 idx,struct ieee80211_key_conf *key) {
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +2 -0
@@ -177,6 +177,8 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, u8 key_idx, struct ieee80211_key_conf *key);int mt76x02_mac_wcid_set_key (struct mt76x02_dev *dev,u8 idx,struct ieee80211_key_conf *key); +void mt76x02_mac_wcid_sync_pn (struct mt76x02_dev *dev,u8 idx, +struct ieee80211_key_conf *key);void mt76x02_mac_wcid_setup (struct mt76x02_dev *dev,u8 idx,u8 vif_idx,u8 *mac);void mt76x02_mac_wcid_set_drop (struct mt76x02_dev *dev,u8 idx,bool drop);
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c +73 -8
123 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x02_util.c +4 -0
@@ -237,6 +237,8 @@ int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;int idx =0 ; +memset (msta,0 ,sizeof (*msta)); + idx =mt76_wcid_alloc (dev->mt76.wcid_mask,ARRAY_SIZE (dev->mt76.wcid));if (idx <0 )return -ENOSPC ;
@@ -274,6 +276,8 @@ mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;struct mt76_txq *mtxq; +memset (mvif,0 ,sizeof (*mvif)); + mvif->idx = idx; mvif->group_wcid.idx =MT_VIF_WCID (idx); mvif->group_wcid.hw_key_idx =-1 ;
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +1 -0
@@ -71,6 +71,7 @@ int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level,void mt76x2_cleanup (struct mt76x02_dev *dev); +int mt76x2_mac_reset (struct mt76x02_dev *dev,bool hard);void mt76x2_reset_wlan (struct mt76x02_dev *dev,bool enable);void mt76x2_init_txpower (struct mt76x02_dev *dev,struct ieee80211_supported_band *sband);
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +1 -1
@@ -77,7 +77,7 @@ mt76x2_fixup_xtal(struct mt76x02_dev *dev) } } -static int mt76x2_mac_reset (struct mt76x02_dev *dev,bool hard) +int mt76x2_mac_reset (struct mt76x02_dev *dev,bool hard) {const u8 *macaddr = dev->mt76.macaddr;u32 val;
drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c +21 -0
@@ -165,9 +165,30 @@ mt76pci_load_firmware(struct mt76x02_dev *dev)return -ENOENT ; } +static int +mt76pci_mcu_restart (struct mt76_dev *mdev) +{ +struct mt76x02_dev *dev; +int ret; + + dev = container_of(mdev, struct mt76x02_dev, mt76); + +mt76x02_mcu_cleanup (dev); +mt76x2_mac_reset (dev, true); + + ret =mt76pci_load_firmware (dev); +if (ret) +return ret; + +mt76_wr (dev,MT_WPDMA_RST_IDX , ~0 ); + +return 0 ; +} +int mt76x2_mcu_init (struct mt76x02_dev *dev) {static const struct mt76_mcu_ops mt76x2_mcu_ops = { + .mcu_restart = mt76pci_mcu_restart, .mcu_send_msg = mt76x02_mcu_msg_send, };int ret;
drivers/net/wireless/mediatek/mt76/tx.c +3 -0
@@ -580,6 +580,9 @@ void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv;struct mt76_queue *hwq = mtxq->hwq; +if (!test_bit (MT76_STATE_RUNNING , &dev->state)) +return ; +spin_lock_bh (&hwq->lock);if (list_empty (&mtxq->list))list_add_tail (&mtxq->list, &hwq->swq);
Signature · 1 line
2.17.0