[rdk-b][common][bsp][Refactor and sync kernel/wifi from Openwrt]
[Description]
Refactor and sync kernel/wifi from Openwrt
[Release-log]
N/A
diff --git a/recipes-connectivity/hostapd/files/src/src/ap/ubus.c b/recipes-connectivity/hostapd/files/src/src/ap/ubus.c
index 182aae7..622eab8 100644
--- a/recipes-connectivity/hostapd/files/src/src/ap/ubus.c
+++ b/recipes-connectivity/hostapd/files/src/src/ap/ubus.c
@@ -318,6 +318,10 @@
blobmsg_add_u8(&b, sta_flags[i].name,
!!(sta->flags & sta_flags[i].flag));
+#ifdef CONFIG_MBO
+ blobmsg_add_u8(&b, "mbo", !!(sta->cell_capa));
+#endif
+
r = blobmsg_open_array(&b, "rrm");
for (i = 0; i < ARRAY_SIZE(sta->rrm_enabled_capa); i++)
blobmsg_add_u32(&b, "", sta->rrm_enabled_capa[i]);
diff --git a/recipes-connectivity/wpa-supplicant/files/src/src/ap/ubus.c b/recipes-connectivity/wpa-supplicant/files/src/src/ap/ubus.c
index 182aae7..622eab8 100644
--- a/recipes-connectivity/wpa-supplicant/files/src/src/ap/ubus.c
+++ b/recipes-connectivity/wpa-supplicant/files/src/src/ap/ubus.c
@@ -318,6 +318,10 @@
blobmsg_add_u8(&b, sta_flags[i].name,
!!(sta->flags & sta_flags[i].flag));
+#ifdef CONFIG_MBO
+ blobmsg_add_u8(&b, "mbo", !!(sta->cell_capa));
+#endif
+
r = blobmsg_open_array(&b, "rrm");
for (i = 0; i < ARRAY_SIZE(sta->rrm_enabled_capa); i++)
blobmsg_add_u32(&b, "", sta->rrm_enabled_capa[i]);
diff --git a/recipes-kernel/linux-mt76/files/patches/1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch b/recipes-kernel/linux-mt76/files/patches/1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch
deleted file mode 100644
index c7e2e09..0000000
--- a/recipes-kernel/linux-mt76/files/patches/1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From ac7abe57fec7283da9c50d4f513c1b6171e0e912 Mon Sep 17 00:00:00 2001
-From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Mon, 4 Jul 2022 19:24:34 +0800
-Subject: [PATCH 1113/1119] mt76: mt7915: drop packets when TWT stations use
-
----
- .../net/wireless/mediatek/mt76/mt7915/mac.c | 21 ++++++++++++++++---
- .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++
- 2 files changed, 20 insertions(+), 3 deletions(-)
-
-diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 5e5df23d..55b38d16 100644
---- a/mt7915/mac.c
-+++ b/mt7915/mac.c
-@@ -725,6 +725,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb);
- struct ieee80211_key_conf *key = info->control.hw_key;
- struct ieee80211_vif *vif = info->control.vif;
-+ struct mt7915_sta *msta = NULL;
- struct mt76_connac_fw_txp *txp;
- struct mt76_txwi_cache *t;
- int id, i, nbuf = tx_info->nbuf - 1;
-@@ -738,8 +739,6 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
- wcid = &dev->mt76.global_wcid;
-
- if (sta) {
-- struct mt7915_sta *msta;
--
- msta = (struct mt7915_sta *)sta->drv_priv;
-
- if (time_after(jiffies, msta->jiffies + HZ / 4)) {
-@@ -755,10 +754,22 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
- mgmt->u.action.category == 0xff)
- return -1;
-
-+ spin_lock_bh(&mdev->token_lock);
-+ if (msta && msta->twt.flowid_mask && msta->token_count > 128) {
-+ spin_unlock_bh(&mdev->token_lock);
-+ return -1;
-+ }
-+ spin_unlock_bh(&mdev->token_lock);
-+
- id = mt76_token_consume(mdev, &t);
- if (id < 0)
- return id;
-
-+ spin_lock_bh(&mdev->token_lock);
-+ if (msta)
-+ msta->token_count++;
-+ spin_unlock_bh(&mdev->token_lock);
-+
- pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
- mt7915_mac_write_txwi(mdev, txwi_ptr, tx_info->skb, wcid, pid, key,
- qid, 0);
-@@ -939,6 +950,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- struct mt76_dev *mdev = &dev->mt76;
- struct mt76_txwi_cache *txwi;
- struct ieee80211_sta *sta = NULL;
-+ struct mt7915_sta *msta = NULL;
- LIST_HEAD(free_list);
- void *end = data + len;
- bool v3, wake = false;
-@@ -962,7 +974,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- * 1'b0: msdu_id with the same 'wcid pair' as above.
- */
- if (info & MT_TX_FREE_PAIR) {
-- struct mt7915_sta *msta;
- struct mt76_wcid *wcid;
- u16 idx;
-
-@@ -995,6 +1006,10 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- txwi = mt76_token_release(mdev, msdu, &wake);
- if (!txwi)
- continue;
-+ spin_lock(&mdev->token_lock);
-+ if (msta)
-+ msta->token_count--;
-+ spin_unlock(&mdev->token_lock);
-
- mt7915_txwi_free(dev, txwi, sta, &free_list);
- }
-diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 7c7d6bd3..5f11b3fb 100644
---- a/mt7915/mt7915.h
-+++ b/mt7915/mt7915.h
-@@ -136,6 +136,8 @@ struct mt7915_sta {
- u8 flowid_mask;
- struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT];
- } twt;
-+
-+ int token_count;
- };
-
- struct mt7915_vif_cap {
---
-2.25.1
-
diff --git a/recipes-kernel/linux-mt76/files/patches/1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch b/recipes-kernel/linux-mt76/files/patches/1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch
new file mode 100644
index 0000000..4d28ad7
--- /dev/null
+++ b/recipes-kernel/linux-mt76/files/patches/1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch
@@ -0,0 +1,28 @@
+From af6a70a816d5a98d22b5bb1012e21cc2ecb4d5db Mon Sep 17 00:00:00 2001
+From: Peter Chiu <chui-hao.chiu@mediatek.com>
+Date: Thu, 4 Aug 2022 14:08:11 +0800
+Subject: [PATCH] mt76: mt7915: reduce TWT SP sent to FW for cert
+
+Set TWT SP duration to 88 percent to prevent HW sends PPDU over TWT SP.
+
+Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
+---
+ mt7915/mcu.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mt7915/mcu.c b/mt7915/mcu.c
+index d7e717f4..2bd67f7c 100644
+--- a/mt7915/mcu.c
++++ b/mt7915/mcu.c
+@@ -3538,7 +3538,7 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
+ .own_mac_idx = mvif->mt76.omac_idx,
+ .flowid = flow->id,
+ .peer_id = cpu_to_le16(flow->wcid),
+- .duration = flow->duration,
++ .duration = (flow->duration * 7) >> 3,
+ .bss_idx = mvif->mt76.idx,
+ .start_tsf = cpu_to_le64(flow->tsf),
+ .mantissa = flow->mantissa,
+--
+2.18.0
+
diff --git a/recipes-kernel/linux-mt76/files/patches/1119-mt76-mt7915-initialize-wcid.patch b/recipes-kernel/linux-mt76/files/patches/1119-mt76-mt7915-initialize-wcid.patch
index ed572cc..d26e59c 100644
--- a/recipes-kernel/linux-mt76/files/patches/1119-mt76-mt7915-initialize-wcid.patch
+++ b/recipes-kernel/linux-mt76/files/patches/1119-mt76-mt7915-initialize-wcid.patch
@@ -1,26 +1,26 @@
-From ce1b7634efbf75007f431dd770ebd70e47771029 Mon Sep 17 00:00:00 2001
+From 1c4ec7f43f20ebbbe0c30100e6798ace079c3714 Mon Sep 17 00:00:00 2001
From: Sujuan Chen <sujuan.chen@mediatek.com>
Date: Tue, 12 Jul 2022 13:56:07 +0800
-Subject: [PATCH 1119/1119] mt76 mt7915 initialize wcid
+Subject: [PATCH] mt76 mt7915 initialize wcid
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
---
- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +-
+ mt7915/mac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 55b38d16..0310ca74 100644
+index 5e5df23d..9674015d 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
-@@ -974,7 +974,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
- * 1'b0: msdu_id with the same 'wcid pair' as above.
+@@ -963,7 +963,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
*/
if (info & MT_TX_FREE_PAIR) {
+ struct mt7915_sta *msta;
- struct mt76_wcid *wcid;
+ struct mt76_wcid *wcid = NULL;
u16 idx;
idx = FIELD_GET(MT_TX_FREE_WLAN_ID, info);
--
-2.25.1
+2.18.0
diff --git a/recipes-kernel/linux-mt76/files/patches/1120-mt76-HEMU-Add-dump-support.patch b/recipes-kernel/linux-mt76/files/patches/1120-mt76-HEMU-Add-dump-support.patch
new file mode 100644
index 0000000..e333271
--- /dev/null
+++ b/recipes-kernel/linux-mt76/files/patches/1120-mt76-HEMU-Add-dump-support.patch
@@ -0,0 +1,77 @@
+From 2bfc2727beaeebe4c475f27e65a22522a47e5ec0 Mon Sep 17 00:00:00 2001
+From: TomLiu <tomml.liu@mediatek.com>
+Date: Thu, 11 Aug 2022 18:09:45 -0700
+Subject: [PATCH] mt76: HEMU: Add dump support
+
+Change-Id: I521214f3feb6f0d528a9f550255050ffd1ec96d2
+---
+ mt7915/vendor.c | 26 ++++++++++++++++++++++++++
+ mt7915/vendor.h | 1 +
+ 2 files changed, 27 insertions(+)
+
+diff --git a/mt7915/vendor.c b/mt7915/vendor.c
+index 5a28a55..7acb330 100644
+--- a/mt7915/vendor.c
++++ b/mt7915/vendor.c
+@@ -37,6 +37,7 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = {
+ static const struct nla_policy
+ hemu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_HEMU_CTRL] = {
+ [MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF] = {.type = NLA_U8 },
++ [MTK_VENDOR_ATTR_HEMU_CTRL_DUMP] = {.type = NLA_U8 },
+ };
+
+ static const struct nla_policy
+@@ -997,6 +998,30 @@ static int mt7915_vendor_hemu_ctrl(struct wiphy *wiphy,
+ return 0;
+ }
+
++
++static int
++mt7915_vendor_hemu_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
++ struct sk_buff *skb, const void *data, int data_len,
++ unsigned long *storage)
++{
++ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
++ struct mt7915_phy *phy = mt7915_hw_phy(hw);
++ struct mt7915_dev *dev = phy->dev;
++ void *a;
++ int len = 0;
++
++ if (*storage == 1)
++ return -ENOENT;
++ *storage = 1;
++
++ if (nla_put_u8(skb, MTK_VENDOR_ATTR_HEMU_CTRL_DUMP, dev->dbg.muru_onoff))
++ return -ENOMEM;
++ len += 1;
++
++ return len;
++}
++
++
+ static int
+ mt7915_vendor_phy_capa_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
+ struct sk_buff *skb, const void *data, int data_len,
+@@ -1122,6 +1147,7 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
+ WIPHY_VENDOR_CMD_NEED_RUNNING,
+ .doit = mt7915_vendor_hemu_ctrl,
++ .dumpit = mt7915_vendor_hemu_ctrl_dump,
+ .policy = hemu_ctrl_policy,
+ .maxattr = MTK_VENDOR_ATTR_HEMU_CTRL_MAX,
+ },
+diff --git a/mt7915/vendor.h b/mt7915/vendor.h
+index 83c41bc..57f52f3 100644
+--- a/mt7915/vendor.h
++++ b/mt7915/vendor.h
+@@ -58,6 +58,7 @@ enum mtk_vendor_attr_hemu_ctrl {
+ MTK_VENDOR_ATTR_HEMU_CTRL_UNSPEC,
+
+ MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF,
++ MTK_VENDOR_ATTR_HEMU_CTRL_DUMP,
+
+ /* keep last */
+ NUM_MTK_VENDOR_ATTRS_HEMU_CTRL,
+--
+2.32.0
+
diff --git a/recipes-kernel/linux-mt76/files/patches/3004-mt76-add-ser-spport-when-wed-on.patch b/recipes-kernel/linux-mt76/files/patches/3004-mt76-add-ser-spport-when-wed-on.patch
index f1c1b02..17bea92 100755
--- a/recipes-kernel/linux-mt76/files/patches/3004-mt76-add-ser-spport-when-wed-on.patch
+++ b/recipes-kernel/linux-mt76/files/patches/3004-mt76-add-ser-spport-when-wed-on.patch
@@ -1,21 +1,41 @@
-From 6a2341ff1a75100d530982d0c021a133124174cc Mon Sep 17 00:00:00 2001
+From f9d72a188038fcda7cc4d8d5a166af4065ca645c Mon Sep 17 00:00:00 2001
From: Sujuan Chen <sujuan.chen@mediatek.com>
Date: Thu, 28 Jul 2022 11:16:15 +0800
-Subject: [PATCH 3/3] mt76 add ser spport when wed on
+Subject: [PATCH] mt76 add ser spport when wed on
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
---
- dma.c | 26 ++++++++++++++++++--------
- dma.h | 2 +-
- mt7915/dma.c | 26 +++++++++++++++++++++-----
- mt7915/mac.c | 6 ++++++
- 4 files changed, 46 insertions(+), 14 deletions(-)
+ dma.c | 29 ++++++++++++++++++++---------
+ dma.h | 2 +-
+ mt76.h | 1 +
+ mt7915/dma.c | 36 +++++++++++++++++++++++++++++++-----
+ mt7915/mac.c | 20 ++++++++++++++++++++
+ mt7915/mmio.c | 2 ++
+ mt7915/mt7915.h | 1 +
+ 7 files changed, 76 insertions(+), 15 deletions(-)
diff --git a/dma.c b/dma.c
-index 4d4d4046..9c821442 100644
+index 4d4d4046..9f886b77 100644
--- a/dma.c
+++ b/dma.c
-@@ -624,14 +624,18 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
+@@ -169,7 +169,7 @@ mt76_free_pending_txwi(struct mt76_dev *dev)
+ local_bh_enable();
+ }
+
+-static void
++void
+ mt76_free_pending_rxwi(struct mt76_dev *dev)
+ {
+ struct mt76_txwi_cache *r;
+@@ -183,6 +183,7 @@ mt76_free_pending_rxwi(struct mt76_dev *dev)
+ }
+ local_bh_enable();
+ }
++EXPORT_SYMBOL_GPL(mt76_free_pending_rxwi);
+
+ static void
+ mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q)
+@@ -624,14 +625,18 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
return frames;
}
@@ -29,15 +49,15 @@
int ret, type, ring;
- u8 flags = q->flags;
+ u8 flags;
-+
+
+ if (!q || !q->ndesc)
+ return -EINVAL;
-
++
+ flags = q->flags;
if (!mtk_wed_device_active(wed))
q->flags &= ~MT_QFLAG_WED;
-@@ -643,7 +647,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
+@@ -643,7 +648,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
switch (type) {
case MT76_WED_Q_TX:
@@ -46,7 +66,7 @@
if (!ret)
q->wed_regs = wed->tx_ring[ring].reg_base;
break;
-@@ -659,7 +663,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
+@@ -659,7 +664,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
q->wed_regs = wed->txfree_ring.reg_base;
break;
case MT76_WED_Q_RX:
@@ -55,7 +75,7 @@
if (!ret)
q->wed_regs = wed->rx_ring[ring].reg_base;
break;
-@@ -672,6 +676,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
+@@ -672,6 +677,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
return 0;
#endif
}
@@ -63,7 +83,7 @@
static int
mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
-@@ -704,7 +709,7 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
+@@ -704,7 +710,7 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
if (!q->entry)
return -ENOMEM;
@@ -72,7 +92,7 @@
if (ret)
return ret;
-@@ -755,8 +760,13 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
+@@ -755,8 +761,13 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
q->desc[i].ctrl = cpu_to_le32(MT_DMA_CTL_DMA_DONE);
mt76_dma_rx_cleanup(dev, q);
@@ -99,11 +119,31 @@
-
+int mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset);
#endif
+diff --git a/mt76.h b/mt76.h
+index 0043c7c8..5e03f565 100644
+--- a/mt76.h
++++ b/mt76.h
+@@ -1367,6 +1367,7 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb)
+ void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t);
+ void mt76_put_rxwi(struct mt76_dev *dev, struct mt76_txwi_cache *t);
+ struct mt76_txwi_cache *mt76_get_rxwi(struct mt76_dev *dev);
++void mt76_free_pending_rxwi(struct mt76_dev *dev);
+ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
+ struct napi_struct *napi);
+ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
diff --git a/mt7915/dma.c b/mt7915/dma.c
-index 7d8d60bb..8df7d0ee 100644
+index 7d8d60bb..6435604b 100644
--- a/mt7915/dma.c
+++ b/mt7915/dma.c
-@@ -549,28 +549,44 @@ int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
+@@ -529,6 +529,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
+ int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
+ {
+ struct mt76_phy *mphy_ext = dev->mt76.phy2;
++ struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
+ int i;
+
+ /* clean up hw queues */
+@@ -549,28 +550,53 @@ int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
mt7915_wfsys_reset(dev);
/* disable wfdma */
@@ -111,18 +151,27 @@
+ mtk_wed_device_dma_reset(&dev->mt76.mmio.wed);
mt7915_dma_disable(dev, force);
++ /* set wifi reset done, wait FE reset */
++ if (mtk_wed_device_active(wed) && atomic_read(&wed->fe_reset)) {
++ atomic_set(&wed->fe_reset, 0);
++ rtnl_lock();
++ complete(&wed->wlan_reset_done);
++ rtnl_unlock();
++ wait_for_completion(&wed->fe_reset_done);
++ }
++
/* reset hw queues */
for (i = 0; i < __MT_TXQ_MAX; i++) {
mt76_queue_reset(dev, dev->mphy.q_tx[i]);
- if (mphy_ext)
+ if (mphy_ext) {
mt76_queue_reset(dev, mphy_ext->q_tx[i]);
-+ if (mtk_wed_device_active(&dev->mt76.mmio.wed))
++ if (mtk_wed_device_active(wed))
+ mt76_dma_wed_setup(&dev->mt76,
+ mphy_ext->q_tx[i],
+ true);
+ }
-+ if (mtk_wed_device_active(&dev->mt76.mmio.wed))
++ if (mtk_wed_device_active(wed))
+ mt76_dma_wed_setup(&dev->mt76, dev->mphy.q_tx[i],
+ true);
}
@@ -144,7 +193,7 @@
mt76_for_each_q_rx(&dev->mt76, i)
mt76_queue_rx_reset(dev, i);
-+ if(mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(&dev->mt76))
++ if(mtk_wed_device_active(wed) && is_mt7915(&dev->mt76))
+ mt76_rmw(dev, MT_WFDMA0_EXT0_CFG, MT_WFDMA0_EXT0_RXWB_KEEP,
+ MT_WFDMA0_EXT0_RXWB_KEEP);
+
@@ -154,10 +203,38 @@
}
diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 1f8e1230..f53de870 100644
+index 1f8e1230..b0df0be0 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
-@@ -1674,6 +1674,12 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -925,6 +925,8 @@ void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed)
+ mt76_put_rxwi(&dev->mt76, rxwi);
+ }
+
++ mt76_free_pending_rxwi(&dev->mt76);
++
+ if (wed->rx_page.va)
+ return;
+
+@@ -935,6 +937,18 @@ void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed)
+ return;
+ }
+
++void mt7915_wed_trigger_ser(struct mtk_wed_device *wed)
++{
++ struct mt7915_dev *dev;
++ u8 band_idx;
++ dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
++ band_idx = dev->phy.band_idx;
++
++ mt7915_mcu_set_ser(dev, SER_RECOVER, 1, band_idx);
++
++ return;
++}
++
+ static void
+ mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
+ {
+@@ -1674,6 +1688,12 @@ void mt7915_mac_reset_work(struct work_struct *work)
if (!(READ_ONCE(dev->reset_state) & MT_MCU_CMD_STOP_DMA))
return;
@@ -170,6 +247,31 @@
ieee80211_stop_queues(mt76_hw(dev));
if (ext_phy)
ieee80211_stop_queues(ext_phy->hw);
+diff --git a/mt7915/mmio.c b/mt7915/mmio.c
+index 9316e056..e1445595 100644
+--- a/mt7915/mmio.c
++++ b/mt7915/mmio.c
+@@ -757,6 +757,8 @@ mt7915_pci_wed_init(struct mt7915_dev *dev, struct device *pdev, int *irq)
+ wed->wlan.init_rx_buf = mt7915_wed_init_rx_buf;
+ wed->wlan.release_rx_buf = mt7915_wed_release_rx_buf;
+
++ wed->wlan.ser_trigger = mt7915_wed_trigger_ser;
++
+ dev->mt76.rx_token_size = wed->wlan.rx_pkt;
+ if (mtk_wed_device_attach(wed) != 0)
+ return 0;
+diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
+index 97eac730..bcc58e5f 100644
+--- a/mt7915/mt7915.h
++++ b/mt7915/mt7915.h
+@@ -548,6 +548,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
+ u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed,
+ int pkt_num);
+ void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed);
++void mt7915_wed_trigger_ser(struct mtk_wed_device *wed);
+ int mt7915_register_device(struct mt7915_dev *dev);
+ void mt7915_unregister_device(struct mt7915_dev *dev);
+ int mt7915_eeprom_init(struct mt7915_dev *dev);
--
2.18.0
diff --git a/recipes-kernel/linux-mt76/files/patches/patches.inc b/recipes-kernel/linux-mt76/files/patches/patches.inc
index 92e3aa2..cb34658 100644
--- a/recipes-kernel/linux-mt76/files/patches/patches.inc
+++ b/recipes-kernel/linux-mt76/files/patches/patches.inc
@@ -20,13 +20,14 @@
file://1008-mt76-mt7915-add-mt76-vendor-muru-onoff-command.patch \
file://1111-mt76-testmode-additional-supports.patch \
file://1112-mt76-mt7915-init-rssi-in-WTBL-when-add-station.patch \
- file://1113-mt76-mt7915-drop-packets-when-TWT-stations-use.patch \
+ file://1113-mt76-mt7915-reduce-TWT-SP-sent-to-FW-for-cert.patch \
file://1114-mt76-airtime-fairness-feature-off-in-mac80211.patch \
file://1115-mt76-mt7915-add-mt7986-and-mt7916-pre-calibration.patch \
file://1116-mt76-mt7915-add-phy-capability-vendor-command.patch \
file://1117-mt76-mt7915-add-vendor-subcmd-EDCCA-ctrl.patch \
file://1118-mt76-mt7915-implement-bin-file-mode.patch \
file://1119-mt76-mt7915-initialize-wcid.patch \
+ file://1120-mt76-HEMU-Add-dump-support.patch \
file://3001-mt76-add-wed-tx-support.patch \
file://3002-mt76-add-wed-rx-support.patch \
file://3003-mt76-add-fill-receive-path-to-report-wed-idx.patch \
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 063aea1..bd70441 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -381,7 +381,7 @@
if (state->interface != PHY_INTERFACE_MODE_SGMII)
err = mtk_sgmii_setup_mode_force(eth->sgmii, sid,
state);
- else if (phylink_autoneg_inband(mode))
+ else
err = mtk_sgmii_setup_mode_an(eth->sgmii, sid);
if (err) {
@@ -538,7 +538,8 @@
case PHY_INTERFACE_MODE_2500BASEX:
phylink_set(mask, 1000baseX_Full);
phylink_set(mask, 2500baseX_Full);
- break;
+ phylink_set(mask, 2500baseT_Full);
+ /* fall through; */
case PHY_INTERFACE_MODE_GMII:
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
@@ -3449,6 +3450,20 @@
return ret;
}
+static void mtk_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
+{
+ struct mtk_mac *mac = netdev_priv(dev);
+
+ phylink_ethtool_get_pauseparam(mac->phylink, pause);
+}
+
+static int mtk_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
+{
+ struct mtk_mac *mac = netdev_priv(dev);
+
+ return phylink_ethtool_set_pauseparam(mac->phylink, pause);
+}
+
static const struct ethtool_ops mtk_ethtool_ops = {
.get_link_ksettings = mtk_get_link_ksettings,
.set_link_ksettings = mtk_set_link_ksettings,
@@ -3462,6 +3477,8 @@
.get_ethtool_stats = mtk_get_ethtool_stats,
.get_rxnfc = mtk_get_rxnfc,
.set_rxnfc = mtk_set_rxnfc,
+ .get_pauseparam = mtk_get_pauseparam,
+ .set_pauseparam = mtk_set_pauseparam,
};
static const struct net_device_ops mtk_netdev_ops = {
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_sgmii.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_sgmii.c
index dacdf3c..8198c7c 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_sgmii.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_sgmii.c
@@ -44,6 +44,13 @@
if (!ss->regmap[id])
return -EINVAL;
+ /* Assert PHYA power down state */
+ regmap_write(ss->regmap[id], SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD);
+
+ regmap_read(ss->regmap[id], ss->ana_rgc3, &val);
+ val &= ~RG_PHY_SPEED_3_125G;
+ regmap_write(ss->regmap[id], ss->ana_rgc3, val);
+
/* Setup the link timer and QPHY power up inside SGMIISYS */
regmap_write(ss->regmap[id], SGMSYS_PCS_LINK_TIMER,
SGMII_LINK_TIMER_DEFAULT);
@@ -52,8 +59,15 @@
val |= SGMII_REMOTE_FAULT_DIS;
regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val);
+ /* SGMII AN mode setting */
+ regmap_read(ss->regmap[id], SGMSYS_SGMII_MODE, &val);
+ val &= ~SGMII_IF_MODE_MASK;
+ val |= SGMII_SPEED_DUPLEX_AN;
+ regmap_write(ss->regmap[id], SGMSYS_SGMII_MODE, val);
+
regmap_read(ss->regmap[id], SGMSYS_PCS_CONTROL_1, &val);
val |= SGMII_AN_RESTART;
+ val |= SGMII_AN_ENABLE;
regmap_write(ss->regmap[id], SGMSYS_PCS_CONTROL_1, val);
if(MTK_HAS_FLAGS(ss->flags[id],MTK_SGMII_PN_SWAP))
@@ -74,6 +88,9 @@
if (!ss->regmap[id])
return -EINVAL;
+ /* Assert PHYA power down state */
+ regmap_write(ss->regmap[id], SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD);
+
regmap_read(ss->regmap[id], ss->ana_rgc3, &val);
val &= ~RG_PHY_SPEED_MASK;
if (state->interface == PHY_INTERFACE_MODE_2500BASEX)
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/phy/mediatek-ge.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/phy/mediatek-ge.c
index d8f9d6a..c0abdc7 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/phy/mediatek-ge.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/phy/mediatek-ge.c
@@ -21,14 +21,21 @@
#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5
/* Registers on MDIO_MMD_VEND1 */
-#define MTK_PHY_1st_OVERSHOOT_LEVEL_0TO1 (0x1)
-#define MTK_PHY_2nd_OVERSHOOT_LEVEL_0TO1 (0x2)
-#define MTK_PHY_1st_OVERSHOOT_LEVEL_1TO0 (0x4)
-#define MTK_PHY_2nd_OVERSHOOT_LEVEL_1TO0 (0x5)
-#define MTK_PHY_1st_OVERSHOOT_LEVEL_0TON1 (0x7) /* N means negative */
-#define MTK_PHY_2nd_OVERSHOOT_LEVEL_0TON1 (0x8)
-#define MTK_PHY_1st_OVERSHOOT_LEVEL_N1TO0 (0xa)
-#define MTK_PHY_2nd_OVERSHOOT_LEVEL_N1TO0 (0xb)
+typedef enum {
+ MTK_PHY_MIDDLE_LEVEL_SHAPPER_0TO1 = 0,
+ MTK_PHY_1st_OVERSHOOT_LEVEL_0TO1,
+ MTK_PHY_2nd_OVERSHOOT_LEVEL_0TO1,
+ MTK_PHY_MIDDLE_LEVEL_SHAPPER_1TO0,
+ MTK_PHY_1st_OVERSHOOT_LEVEL_1TO0,
+ MTK_PHY_2nd_OVERSHOOT_LEVEL_1TO0,
+ MTK_PHY_MIDDLE_LEVEL_SHAPPER_0TON1, /* N means negative */
+ MTK_PHY_1st_OVERSHOOT_LEVEL_0TON1,
+ MTK_PHY_2nd_OVERSHOOT_LEVEL_0TON1,
+ MTK_PHY_MIDDLE_LEVEL_SHAPPER_N1TO0,
+ MTK_PHY_1st_OVERSHOOT_LEVEL_N1TO0,
+ MTK_PHY_2nd_OVERSHOOT_LEVEL_N1TO0,
+ MTK_PHY_TX_MLT3_END,
+};
#define MTK_PHY_TXVLD_DA_RG (0x12)
#define MTK_PHY_DA_TX_I2MPB_A_GBE_MASK GENMASK(15, 10)
@@ -240,7 +247,7 @@
#define SW_EFUSE_CAL(cal_item, cal_mode_get, pair_mode,...) \
if ((efs_valid && ret) || \
- (!ret && strcmp("efuse", cal_mode_get) == 0)) { \
+ (efs_valid && !ret && strcmp("efuse", cal_mode_get) == 0)) { \
CAL_##pair_mode(cal_item, efuse, ##__VA_ARGS__) \
} else if ((!efs_valid && ret) || \
(!ret && strcmp("sw", cal_mode_get) == 0)) { \
@@ -249,7 +256,7 @@
#define EFUSE_CAL(cal_item, cal_mode_get, pair_mode, ...) \
if ((efs_valid && ret) || \
- (!ret && strcmp("efuse", cal_mode_get) == 0)) {\
+ (efs_valid && !ret && strcmp("efuse", cal_mode_get) == 0)) {\
CAL_##pair_mode(cal_item, efuse, ##__VA_ARGS__) \
}
@@ -795,7 +802,7 @@
return 0;
}
-static inline void mt798x_phy_finetune(struct phy_device *phydev)
+static inline void mt7981_phy_finetune(struct phy_device *phydev)
{
/* 100M eye finetune:
* Keep middle level of TX MLT3 shapper as default.
@@ -809,7 +816,7 @@
phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_2nd_OVERSHOOT_LEVEL_0TON1, 0x3c0);
phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_1st_OVERSHOOT_LEVEL_N1TO0, 0x13);
phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_2nd_OVERSHOOT_LEVEL_N1TO0, 0x5);
-#
+
/* TX-AMP finetune:
* 100M +4, 1000M +6 to default value.
* If efuse values aren't valid, TX-AMP uses the below values.
@@ -824,10 +831,23 @@
phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, 0x2426);
}
+static inline void mt7988_phy_finetune(struct phy_device *phydev)
+{
+ int i;
+ u16 val[12] = {0x0187, 0x01cd, 0x01c8, 0x0182,
+ 0x020d, 0x0206, 0x0384, 0x03d0,
+ 0x03c6, 0x030a, 0x0011, 0x0005};
+
+ for(i=0; i<MTK_PHY_TX_MLT3_END; i++) {
+ phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[i]);
+ }
+}
+
-static int mt798x_phy_config_init(struct phy_device *phydev)
+static int mt798x_phy_calibration(struct phy_device *phydev)
{
const char *cal_mode_from_dts;
- int i, ret, cal_ret;
+ int i, ret;
+ int cal_ret = 0;
u32 *buf;
bool efs_valid = true;
size_t len;
@@ -836,8 +856,6 @@
if (phydev->interface != PHY_INTERFACE_MODE_GMII)
return -EINVAL;
- mt798x_phy_finetune(phydev);
-
cell = nvmem_cell_get(&phydev->mdio.dev, "phy-cal-data");
if (IS_ERR(cell)) {
if (PTR_ERR(cell) == -EPROBE_DEFER)
@@ -871,6 +889,25 @@
return ret;
}
+static int mt7981_phy_config_init(struct phy_device *phydev)
+{
+ mt7981_phy_finetune(phydev);
+
+ return mt798x_phy_calibration(phydev);
+}
+
+static int mt7988_phy_config_init(struct phy_device *phydev)
+{
+ mt7988_phy_finetune(phydev);
+
+ return mt798x_phy_calibration(phydev);
+}
+
+static int mt7988_phy_probe(struct phy_device *phydev)
+{
+ return mt7988_phy_config_init(phydev);
+}
+
static struct phy_driver mtk_gephy_driver[] = {
#if 0
{
@@ -904,8 +941,23 @@
#endif
{
PHY_ID_MATCH_EXACT(0x03a29461),
- .name = "MediaTek MT798x PHY",
- .config_init = mt798x_phy_config_init,
+ .name = "MediaTek MT7981 PHY",
+ .config_init = mt7981_phy_config_init,
+ /* Interrupts are handled by the switch, not the PHY
+ * itself.
+ */
+ .config_intr = genphy_no_config_intr,
+ .handle_interrupt = genphy_no_ack_interrupt,
+ .suspend = genphy_suspend,
+ .resume = genphy_resume,
+ .read_page = mtk_gephy_read_page,
+ .write_page = mtk_gephy_write_page,
+ },
+ {
+ PHY_ID_MATCH_EXACT(0x03a29481),
+ .name = "MediaTek MT7988 PHY",
+ .probe = mt7988_phy_probe,
+ .config_init = mt7988_phy_config_init,
/* Interrupts are handled by the switch, not the PHY
* itself.
*/
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9993-add-wed.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9993-add-wed.patch
index 66c497d..166ab26 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9993-add-wed.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9993-add-wed.patch
@@ -840,7 +840,7 @@
memcpy(&hwe->data, &entry->data, sizeof(hwe->data));
wmb();
hwe->ib1 = entry->ib1;
-@@ -362,32 +519,197 @@ int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry,
+@@ -362,32 +519,198 @@ int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry,
dma_wmb();
mtk_ppe_cache_clear(ppe);
@@ -927,6 +927,7 @@
+ struct mtk_foe_entry *hwe = &ppe->foe_table[hash];
+ struct mtk_flow_entry *entry;
+ struct mtk_foe_bridge key = {};
++ struct hlist_node *n;
+ struct ethhdr *eh;
+ bool found = false;
+ u8 *tag;
@@ -936,7 +937,7 @@
+ if (FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == MTK_FOE_STATE_BIND)
+ goto out;
+
-+ hlist_for_each_entry(entry, head, list) {
++ hlist_for_each_entry_safe(entry, n, head, list) {
+ if (entry->type == MTK_FLOW_TYPE_L2_SUBFLOW) {
+ if (unlikely(FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) ==
+ MTK_FOE_STATE_BIND))
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9999-add-wed-ser-support.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9999-add-wed-ser-support.patch
index fcc5e3a..6442853 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9999-add-wed-ser-support.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9999-add-wed-ser-support.patch
@@ -5,17 +5,61 @@
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
---
- drivers/net/ethernet/mediatek/mtk_wed.c | 298 ++++++++++++++-----
- drivers/net/ethernet/mediatek/mtk_wed.h | 1 +
+ drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 +-
+ drivers/net/ethernet/mediatek/mtk_wed.c | 347 ++++++++++++++-----
+ drivers/net/ethernet/mediatek/mtk_wed.h | 2 +
drivers/net/ethernet/mediatek/mtk_wed_regs.h | 12 +
- include/linux/soc/mediatek/mtk_wed.h | 24 +-
- 4 files changed, 245 insertions(+), 90 deletions(-)
+ include/linux/soc/mediatek/mtk_wed.h | 28 +-
+ 5 files changed, 297 insertions(+), 101 deletions(-)
+diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+index c582bb9..5259141 100644
+--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+@@ -3220,10 +3220,14 @@ static void mtk_pending_work(struct work_struct *work)
+ mtk_prepare_reset_fe(eth);
+
+ /* Trigger Wifi SER reset */
++#ifdef CONFIG_NET_MEDIATEK_SOC_WED
++ mtk_wed_fe_reset(MTK_FE_START_RESET);
++#else
+ call_netdevice_notifiers(MTK_FE_START_RESET, eth->netdev[0]);
+ rtnl_unlock();
+ wait_for_completion_timeout(&wait_ser_done, 5000);
+ rtnl_lock();
++#endif
+
+ while (test_and_set_bit_lock(MTK_RESETTING, ð->state))
+ cpu_relax();
+@@ -3284,8 +3288,11 @@ static void mtk_pending_work(struct work_struct *work)
+
+ call_netdevice_notifiers(MTK_FE_RESET_NAT_DONE, eth->netdev[0]);
+ pr_info("[%s] HNAT reset done !\n", __func__);
+-
++#ifdef CONFIG_NET_MEDIATEK_SOC_WED
++ mtk_wed_fe_reset(MTK_FE_RESET_DONE);
++#else
+ call_netdevice_notifiers(MTK_FE_RESET_DONE, eth->netdev[0]);
++#endif
+ pr_info("[%s] WiFi SER reset done !\n", __func__);
+
+ atomic_dec(&reset_lock);
diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
-index 0750def..7b6b777 100644
+index 7552795..c98d749 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c
-@@ -71,23 +71,27 @@ mtk_wdma_read_reset(struct mtk_wed_device *dev)
+@@ -13,8 +13,10 @@
+ #include <linux/debugfs.h>
+ #include <linux/iopoll.h>
+ #include <linux/soc/mediatek/mtk_wed.h>
++#include <net/rtnetlink.h>
+
+ #include "mtk_eth_soc.h"
++#include "mtk_eth_reset.h"
+ #include "mtk_wed_regs.h"
+ #include "mtk_wed.h"
+ #include "mtk_ppe.h"
+@@ -71,23 +73,27 @@ mtk_wdma_read_reset(struct mtk_wed_device *dev)
return wdma_r32(dev, MTK_WDMA_GLO_CFG);
}
@@ -48,7 +92,7 @@
}
static void
-@@ -99,9 +103,11 @@ mtk_wdma_tx_reset(struct mtk_wed_device *dev)
+@@ -99,14 +105,14 @@ mtk_wdma_tx_reset(struct mtk_wed_device *dev)
wdma_clr(dev, MTK_WDMA_GLO_CFG, MTK_WDMA_GLO_CFG_TX_DMA_EN);
if (readx_poll_timeout(mtk_wdma_read_reset, dev, status,
@@ -59,8 +103,15 @@
+ wdma_w32(dev, MTK_WDMA_RESET_IDX, MTK_WDMA_RESET_IDX_TX);
+ wdma_w32(dev, MTK_WDMA_RESET_IDX, 0);
for (i = 0; i < ARRAY_SIZE(dev->tx_wdma); i++)
- if (!dev->tx_wdma[i].desc) {
- wdma_w32(dev, MTK_WDMA_RING_TX(i) +
+- if (!dev->tx_wdma[i].desc) {
+- wdma_w32(dev, MTK_WDMA_RING_TX(i) +
+- MTK_WED_RING_OFS_CPU_IDX, 0);
+- }
++ wdma_w32(dev, MTK_WDMA_RING_TX(i) +
++ MTK_WED_RING_OFS_CPU_IDX, 0);
+ }
+
+ static u32
@@ -505,8 +511,8 @@ mtk_wed_check_wfdma_rx_fill(struct mtk_wed_device *dev, int idx)
wifi_w32(dev, dev->wlan.wpdma_rx_glo -
dev->wlan.phy_base, val);
@@ -208,8 +259,8 @@
return read_poll_timeout(mtk_wed_check_busy, val, !val, sleep,
- timeout, false, dev);
+ timeout, false, dev, reg, mask);
- }
-
++}
++
+static void
+mtk_wed_rx_reset(struct mtk_wed_device *dev)
+{
@@ -309,8 +360,8 @@
+ }
+
+ mtk_wed_free_rx_bm(dev);
-+}
-+
+ }
+
+
static void
mtk_wed_reset_dma(struct mtk_wed_device *dev)
@@ -400,8 +451,59 @@
+ mtk_wed_rx_reset(dev);
}
+ }
+@@ -1101,13 +1218,15 @@ mtk_wed_ring_alloc(struct mtk_wed_device *dev, struct mtk_wed_ring *ring,
+ }
+
+ static int
+-mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev, int idx, int size)
++mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev,
++ int idx, int size, bool reset)
+ {
+ struct mtk_wed_ring *wdma = &dev->tx_wdma[idx];
+
+- if (mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE,
+- dev->ver, true))
+- return -ENOMEM;
++ if(!reset)
++ if (mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE,
++ dev->ver, true))
++ return -ENOMEM;
+
+ wdma_w32(dev, MTK_WDMA_RING_RX(idx) + MTK_WED_RING_OFS_BASE,
+ wdma->desc_phys);
+@@ -1124,13 +1243,15 @@ mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev, int idx, int size)
}
-@@ -1253,6 +1370,9 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)
+
+ static int
+-mtk_wed_wdma_tx_ring_setup(struct mtk_wed_device *dev, int idx, int size)
++mtk_wed_wdma_tx_ring_setup(struct mtk_wed_device *dev,
++ int idx, int size, bool reset)
+ {
+ struct mtk_wed_ring *wdma = &dev->rx_wdma[idx];
+
+- if (mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE,
+- dev->ver, true))
+- return -ENOMEM;
++ if (!reset)
++ if (mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE,
++ dev->ver, true))
++ return -ENOMEM;
+
+ wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_BASE,
+ wdma->desc_phys);
+@@ -1140,7 +1261,9 @@ mtk_wed_wdma_tx_ring_setup(struct mtk_wed_device *dev, int idx, int size)
+ MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_CPU_IDX, 0);
+ wdma_w32(dev,
+ MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_DMA_IDX, 0);
+-
++ if (reset)
++ mtk_wed_ring_reset(wdma->desc, MTK_WED_WDMA_RING_SIZE,
++ dev->ver, true);
+ if (idx == 0) {
+ wed_w32(dev, MTK_WED_WDMA_RING_TX
+ + MTK_WED_RING_OFS_BASE, wdma->desc_phys);
+@@ -1253,9 +1376,12 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)
{
int i, ret;
@@ -410,8 +512,12 @@
+
for (i = 0; i < ARRAY_SIZE(dev->tx_wdma); i++)
if (!dev->tx_wdma[i].desc)
- mtk_wed_wdma_rx_ring_setup(dev, i, 16);
-@@ -1340,10 +1460,6 @@ mtk_wed_attach(struct mtk_wed_device *dev)
+- mtk_wed_wdma_rx_ring_setup(dev, i, 16);
++ mtk_wed_wdma_rx_ring_setup(dev, i, 16, false);
+
+ mtk_wed_hw_init(dev);
+
+@@ -1340,10 +1466,6 @@ mtk_wed_attach(struct mtk_wed_device *dev)
goto error;
if (dev->ver > MTK_WED_V1) {
@@ -422,7 +528,18 @@
ret = mtk_wed_rro_alloc(dev);
if (ret)
goto error;
-@@ -1367,7 +1483,8 @@ out:
+@@ -1351,6 +1473,10 @@ mtk_wed_attach(struct mtk_wed_device *dev)
+
+ mtk_wed_hw_init_early(dev);
+
++ init_completion(&dev->fe_reset_done);
++ init_completion(&dev->wlan_reset_done);
++ atomic_set(&dev->fe_reset, 0);
++
+ if (dev->ver == MTK_WED_V1)
+ regmap_update_bits(hw->hifsys, HIFSYS_DMA_AG_MAP,
+ BIT(hw->index), 0);
+@@ -1367,7 +1493,8 @@ out:
}
static int
@@ -432,28 +549,23 @@
{
struct mtk_wed_ring *ring = &dev->tx_ring[idx];
-@@ -1385,12 +1502,15 @@ mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)
+@@ -1385,10 +1512,12 @@ mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)
BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
- if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE, 1, true))
- return -ENOMEM;
--
-- if (mtk_wed_wdma_rx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE))
-- return -ENOMEM;
-+ if (!reset) {
++ if (!reset)
+ if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE,
+ 1, true))
+ return -ENOMEM;
-+ if (mtk_wed_wdma_rx_ring_setup(dev, idx,
-+ MTK_WED_WDMA_RING_SIZE))
-+ return -ENOMEM;
-+ }
- ring->reg_base = MTK_WED_RING_TX(idx);
- ring->wpdma = regs;
+- if (mtk_wed_wdma_rx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE))
++ if (mtk_wed_wdma_rx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE, reset))
+ return -ENOMEM;
-@@ -1436,21 +1556,39 @@ mtk_wed_txfree_ring_setup(struct mtk_wed_device *dev, void __iomem *regs)
+ ring->reg_base = MTK_WED_RING_TX(idx);
+@@ -1436,21 +1565,24 @@ mtk_wed_txfree_ring_setup(struct mtk_wed_device *dev, void __iomem *regs)
}
static int
@@ -465,7 +577,7 @@
BUG_ON(idx > ARRAY_SIZE(dev->rx_ring));
-+ if (!reset) {
++ if (!reset)
+ if (mtk_wed_ring_alloc(dev, ring, MTK_WED_RX_RING_SIZE,
+ 1, false))
+ return -ENOMEM;
@@ -474,34 +586,59 @@
- return -ENOMEM;
-
- if (mtk_wed_wdma_tx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE))
-- return -ENOMEM;
--
-+ if (mtk_wed_wdma_tx_ring_setup(dev, idx,
-+ MTK_WED_WDMA_RING_SIZE))
-+ return -ENOMEM;
-+ } else {
-+ struct mtk_wed_ring *wdma = &dev->rx_wdma[idx];
-+
-+ mtk_wed_ring_reset(wdma->desc, MTK_WED_WDMA_RING_SIZE, dev->ver, true);
-+ if (idx == 0) {
-+ wed_w32(dev, MTK_WED_WDMA_RING_TX
-+ + MTK_WED_RING_OFS_BASE, wdma->desc_phys);
-+ wed_w32(dev, MTK_WED_WDMA_RING_TX
-+ + MTK_WED_RING_OFS_COUNT, MTK_WED_WDMA_RING_SIZE);
-+ wed_w32(dev, MTK_WED_WDMA_RING_TX
-+ + MTK_WED_RING_OFS_CPU_IDX, 0);
-+ wed_w32(dev, MTK_WED_WDMA_RING_TX
-+ + MTK_WED_RING_OFS_DMA_IDX, 0);
-+ }
-+ }
++ if (mtk_wed_wdma_tx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE, reset))
+ return -ENOMEM;
+
ring->reg_base = MTK_WED_RING_RX_DATA(idx);
ring->wpdma = regs;
+ dev->hw->ring_num = idx + 1;
/* WPDMA -> WED */
wpdma_rx_w32(dev, idx, MTK_WED_RING_OFS_BASE, ring->desc_phys);
+@@ -1492,6 +1624,41 @@ mtk_wed_irq_set_mask(struct mtk_wed_device *dev, u32 mask)
+ wed_w32(dev, MTK_WED_INT_MASK, mask);
+ }
+
++void mtk_wed_fe_reset(int cmd)
++{
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
++ struct mtk_wed_hw *hw = hw_list[i];
++ struct mtk_wed_device *dev;
++
++ dev = hw->wed_dev ;
++ if (!dev)
++ continue;
++
++ switch (cmd) {
++ case MTK_FE_START_RESET:
++ pr_info("%s: receive fe reset start event, trigger SER\n", __func__);
++ atomic_set(&dev->fe_reset, 1);
++ dev->wlan.ser_trigger(dev);
++ rtnl_unlock();
++ wait_for_completion(&dev->wlan_reset_done);
++ rtnl_lock();
++
++ break;
++ case MTK_FE_RESET_DONE:
++ pr_info("%s: receive fe reset done event, continue SER\n", __func__);
++ complete(&dev->fe_reset_done);
++ break;
++ default:
++ break;
++ }
++
++ }
++
++ return;
++}
++
+ int mtk_wed_flow_add(int index)
+ {
+ struct mtk_wed_hw *hw = hw_list[index];
diff --git a/drivers/net/ethernet/mediatek/mtk_wed.h b/drivers/net/ethernet/mediatek/mtk_wed.h
-index 8ef5253..27aba72 100644
+index 8ef5253..f757eac 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed.h
+++ b/drivers/net/ethernet/mediatek/mtk_wed.h
@@ -47,6 +47,7 @@ struct mtk_wed_hw {
@@ -512,6 +649,13 @@
int irq;
int index;
u32 ver;
+@@ -196,5 +197,6 @@ void mtk_wed_mcu_rx_event(struct mtk_wed_wo *wo, struct sk_buff *skb);
+ int mtk_wed_mcu_send_msg(struct mtk_wed_wo *wo,int to_id, int cmd,
+ const void *data, int len, bool wait_resp);
+ int mtk_wed_wo_rx_poll(struct napi_struct *napi, int budget);
++void mtk_wed_fe_reset(int cmd);
+
+ #endif
diff --git a/drivers/net/ethernet/mediatek/mtk_wed_regs.h b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
index 9d021e2..cfcd94f 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
@@ -556,10 +700,21 @@
#define MTK_WED_WPDMA_RX_D_RXD_READ_LEN GENMASK(31, 24)
diff --git a/include/linux/soc/mediatek/mtk_wed.h b/include/linux/soc/mediatek/mtk_wed.h
-index 9a9cc1b..bb23a7a 100644
+index 9a9cc1b..31f4a26 100644
--- a/include/linux/soc/mediatek/mtk_wed.h
+++ b/include/linux/soc/mediatek/mtk_wed.h
-@@ -121,16 +121,16 @@ struct mtk_wed_device {
+@@ -114,23 +114,27 @@ struct mtk_wed_device {
+ u32 (*init_rx_buf)(struct mtk_wed_device *wed,
+ int pkt_num);
+ void (*release_rx_buf)(struct mtk_wed_device *wed);
++ void (*ser_trigger)(struct mtk_wed_device *wed);
+ } wlan;
++ struct completion fe_reset_done;
++ struct completion wlan_reset_done;
++ atomic_t fe_reset;
+ #endif
+ };
+
struct mtk_wed_ops {
int (*attach)(struct mtk_wed_device *dev);
int (*tx_ring_setup)(struct mtk_wed_device *dev, int ring,
@@ -579,7 +734,7 @@
void (*start)(struct mtk_wed_device *dev, u32 irq_mask);
void (*reset_dma)(struct mtk_wed_device *dev);
-@@ -169,12 +169,13 @@ mtk_wed_device_attach(struct mtk_wed_device *dev)
+@@ -169,12 +173,13 @@ mtk_wed_device_attach(struct mtk_wed_device *dev)
#define mtk_wed_device_active(_dev) !!(_dev)->ops
#define mtk_wed_device_detach(_dev) (_dev)->ops->detach(_dev)
#define mtk_wed_device_start(_dev, _mask) (_dev)->ops->start(_dev, _mask)
@@ -597,7 +752,7 @@
#define mtk_wed_device_update_msg(_dev, _id, _msg, _len) \
(_dev)->ops->msg_update(_dev, _id, _msg, _len)
#define mtk_wed_device_reg_read(_dev, _reg) \
-@@ -185,6 +186,8 @@ mtk_wed_device_attach(struct mtk_wed_device *dev)
+@@ -185,6 +190,8 @@ mtk_wed_device_attach(struct mtk_wed_device *dev)
(_dev)->ops->irq_get(_dev, _mask)
#define mtk_wed_device_irq_set_mask(_dev, _mask) \
(_dev)->ops->irq_set_mask(_dev, _mask)
@@ -606,7 +761,7 @@
#define mtk_wed_device_ppe_check(_dev, _skb, _reason, _hash) \
(_dev)->ops->ppe_check(_dev, _skb, _reason, _hash)
#else
-@@ -194,14 +197,15 @@ static inline bool mtk_wed_device_active(struct mtk_wed_device *dev)
+@@ -194,14 +201,15 @@ static inline bool mtk_wed_device_active(struct mtk_wed_device *dev)
}
#define mtk_wed_device_detach(_dev) do {} while (0)
#define mtk_wed_device_start(_dev, _mask) do {} while (0)