Skip to contentSkip to conversation

wifi: mt76: mt7996: revise TXS size

PATCH In review Felix Fietkau 4 participants 15 messages Mar 11, 2025 – Mar 14, 2025

Subsystems (2)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/8 wifi: mt76: mt7996: revise TXS size

From: Benjamin Lin <[email protected]>

Size of MPDU/PPDU TXS is 12 DWs.
In mt7996/mt7992, last 4 DWs are reserved, so TXS size was mistakenly considered to be 8 DWs. However, in mt7990, 9th DW of TXS starts to be used.

---
 drivers/net/wireless/mediatek/mt76/mt76_connac3_mac.h | 3 +++
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c       | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac3_mac.h +3 -0
index db0c29e65185..487ad716f872 100644
@@ -314,6 +314,9 @@ enum tx_frag_idx {
 #define MT_TXFREE_INFO_COUNT		GENMASK(27, 24)
 #define MT_TXFREE_INFO_STAT		GENMASK(29, 28)
 
+#define MT_TXS_HDR_SIZE			4 /* Unit: DW */
+#define MT_TXS_SIZE			12 /* Unit: DW */
+
 #define MT_TXS0_BW			GENMASK(31, 29)
 #define MT_TXS0_TID			GENMASK(28, 26)
 #define MT_TXS0_AMPDU			BIT(25)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -2
index 019c925ae600..33a8049d3356 100644
@@ -1399,7 +1399,7 @@ bool mt7996_rx_check(struct mt76_dev *mdev, void *data, int len)
 		mt7996_mac_tx_free(dev, data, len);
 		return false;
 	case PKT_TYPE_TXS:
-		for (rxd += 4; rxd + 8 <= end; rxd += 8)
+		for (rxd += MT_TXS_HDR_SIZE; rxd + MT_TXS_SIZE <= end; rxd += MT_TXS_SIZE)
 			mt7996_mac_add_txs(dev, rxd);
 		return false;
 	case PKT_TYPE_RX_FW_MONITOR:
@@ -1442,7 +1442,7 @@ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
 		mt7996_mcu_rx_event(dev, skb);
 		break;
 	case PKT_TYPE_TXS:
-		for (rxd += 4; rxd + 8 <= end; rxd += 8)
+		for (rxd += MT_TXS_HDR_SIZE; rxd + MT_TXS_SIZE <= end; rxd += MT_TXS_SIZE)
 			mt7996_mac_add_txs(dev, rxd);
 		dev_kfree_skb(skb);
 		break;
Signature · 1 line
2.47.1
author maintainer
#1 lore raw

PATCH 2/8 wifi: mt76: mt7996: fix SER reset trigger on WED reset

From: Rex Lu <[email protected]>

The firmware needs a specific trigger when WED is being reset due to an ethernet reset condition. This helps prevent further L1 SER failure.

---
 drivers/net/wireless/mediatek/mt76/mt7996/mcu.h  | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt7996/mmio.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.h +2 -1
index bd1ba00e1bc6..5fdc47dad28c 100644
@@ -896,7 +896,8 @@ enum {
 	UNI_CMD_SER_SET_RECOVER_L3_TX_DISABLE,
 	UNI_CMD_SER_SET_RECOVER_L3_BF,
 	UNI_CMD_SER_SET_RECOVER_L4_MDP,
-	UNI_CMD_SER_SET_RECOVER_FULL,
+	UNI_CMD_SER_SET_RECOVER_FROM_ETH,
+	UNI_CMD_SER_SET_RECOVER_FULL = 8,
 	UNI_CMD_SER_SET_SYSTEM_ASSERT,
 	/* action */
 	UNI_CMD_SER_ENABLE = 1,
drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +1 -1
index 7a8ee6c75cf2..9d37f8238746 100644
@@ -281,7 +281,7 @@ static int mt7996_mmio_wed_reset(struct mtk_wed_device *wed)
 	if (test_and_set_bit(MT76_STATE_WED_RESET, &mphy->state))
 		return -EBUSY;
 
-	ret = mt7996_mcu_set_ser(dev, UNI_CMD_SER_TRIGGER, UNI_CMD_SER_SET_RECOVER_L1,
+	ret = mt7996_mcu_set_ser(dev, UNI_CMD_SER_TRIGGER, UNI_CMD_SER_SET_RECOVER_FROM_ETH,
 				 mphy->band_idx);
 	if (ret)
 		goto out;
Signature · 1 line
2.47.1
author maintainer
#2 lore raw

PATCH 3/8 wifi: mt76: mt7996: remove unnecessary key->cipher check for BIP frames

In reply to Felix Fietkau

From: Michael-CY Lee <[email protected]>

The cipher type check is redundant, and there is no need to dereference the key struct here.

---
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1 -2
index 33a8049d3356..162d1552602e 100644
@@ -773,8 +773,7 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi,
 	    info->flags & IEEE80211_TX_CTL_USE_MINRATE)
 		val |= MT_TXD1_FIXED_RATE;
 
-	if (key && multicast && ieee80211_is_robust_mgmt_frame(skb) &&
-	    key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
+	if (key && multicast && ieee80211_is_robust_mgmt_frame(skb)) {
 		val |= MT_TXD1_BIP;
 		txwi[3] &= ~cpu_to_le32(MT_TXD3_PROTECT_FRAME);
 	}
Signature · 1 line
2.47.1
author maintainer
#3 lore raw

PATCH 4/8 wifi: mt76: scan: set vif offchannel link for scanning/roc

In reply to Felix Fietkau

The driver needs to know what vif link to use

---
 drivers/net/wireless/mediatek/mt76/channel.c | 3 +++
 drivers/net/wireless/mediatek/mt76/mt76.h    | 2 ++
 2 files changed, 5 insertions(+)
drivers/net/wireless/mediatek/mt76/channel.c +3 -0
index 6a35c6ebd823..e7b839e74290 100644
@@ -293,6 +293,7 @@ struct mt76_vif_link *mt76_get_vif_phy_link(struct mt76_phy *phy,
 		kfree(mlink);
 		return ERR_PTR(ret);
 	}
+	rcu_assign_pointer(mvif->offchannel_link, mlink);
 
 	return mlink;
 }
@@ -301,10 +302,12 @@ void mt76_put_vif_phy_link(struct mt76_phy *phy, struct ieee80211_vif *vif,
 			   struct mt76_vif_link *mlink)
 {
 	struct mt76_dev *dev = phy->dev;
+	struct mt76_vif_data *mvif = mlink->mvif;
 
 	if (IS_ERR_OR_NULL(mlink) || !mlink->offchannel)
 		return;
 
+	rcu_assign_pointer(mvif->offchannel_link, NULL);
 	dev->drv->vif_link_remove(phy, vif, &vif->bss_conf, mlink);
 	kfree(mlink);
 }
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
index 7596191252dc..c16a6743ad64 100644
@@ -351,6 +351,7 @@ struct mt76_wcid {
 	u8 hw_key_idx;
 	u8 hw_key_idx2;
 
+	u8 offchannel:1;
 	u8 sta:1;
 	u8 sta_disabled:1;
 	u8 amsdu:1;
@@ -787,6 +788,7 @@ struct mt76_vif_link {
 
 struct mt76_vif_data {
 	struct mt76_vif_link __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
+	struct mt76_vif_link __rcu *offchannel_link;
 
 	struct mt76_phy *roc_phy;
 	u16 valid_links;
Signature · 1 line
2.47.1
author maintainer
#4 lore raw

PATCH 5/8 wifi: mt76: mt7996: use the correct vif link for scanning/roc

In reply to Felix Fietkau

Use the newly added offchannel_link pointer in vif data

---
 .../net/wireless/mediatek/mt76/mt7996/mac.c   | 40 +++++++++++++------
 .../net/wireless/mediatek/mt76/mt7996/main.c  |  1 +
 2 files changed, 28 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +27 -13
index 162d1552602e..9dfc8106ebec 100644
@@ -831,7 +831,8 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
 	u8 band_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2;
 	u8 p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
 	bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
-	struct mt76_vif_link *mvif;
+	struct mt76_vif_link *mlink = NULL;
+	struct mt7996_vif *mvif;
 	u16 tx_count = 15;
 	u32 val;
 	bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
@@ -839,11 +840,18 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
 	bool beacon = !!(changed & (BSS_CHANGED_BEACON |
 				    BSS_CHANGED_BEACON_ENABLED)) && (!inband_disc);
 
-	mvif = vif ? (struct mt76_vif_link *)vif->drv_priv : NULL;
-	if (mvif) {
-		omac_idx = mvif->omac_idx;
-		wmm_idx = mvif->wmm_idx;
-		band_idx = mvif->band_idx;
+	if (vif) {
+		mvif = (struct mt7996_vif *)vif->drv_priv;
+		if (wcid->offchannel)
+			mlink = rcu_dereference(mvif->mt76.offchannel_link);
+		if (!mlink)
+			mlink = &mvif->deflink.mt76;
+	}
+
+	if (mlink) {
+		omac_idx = mlink->omac_idx;
+		wmm_idx = mlink->wmm_idx;
+		band_idx = mlink->band_idx;
 	}
 
 	if (inband_disc) {
@@ -909,13 +917,13 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
 			     is_multicast_ether_addr(hdr->addr1);
 		u8 idx = MT7996_BASIC_RATES_TBL;
 
-		if (mvif) {
-			if (mcast && mvif->mcast_rates_idx)
-				idx = mvif->mcast_rates_idx;
-			else if (beacon && mvif->beacon_rates_idx)
-				idx = mvif->beacon_rates_idx;
+		if (mlink) {
+			if (mcast && mlink->mcast_rates_idx)
+				idx = mlink->mcast_rates_idx;
+			else if (beacon && mlink->beacon_rates_idx)
+				idx = mlink->beacon_rates_idx;
 			else
-				idx = mvif->basic_rates_idx;
+				idx = mlink->basic_rates_idx;
 		}
 
 		val = FIELD_PREP(MT_TXD6_TX_RATE, idx) | MT_TXD6_FIXED_BW;
@@ -983,8 +991,14 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 
 	if (vif) {
 		struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+		struct mt76_vif_link *mlink = NULL;
 
-		txp->fw.bss_idx = mvif->deflink.mt76.idx;
+		if (wcid->offchannel)
+			mlink = rcu_dereference(mvif->mt76.offchannel_link);
+		if (!mlink)
+			mlink = &mvif->deflink.mt76;
+
+		txp->fw.bss_idx = mlink->idx;
 	}
 
 	txp->fw.token = cpu_to_le16(id);
drivers/net/wireless/mediatek/mt76/mt7996/main.c +1 -0
index 69dd565d8319..886b6ef3462b 100644
@@ -249,6 +249,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
 	mlink->band_idx = band_idx;
 	mlink->wmm_idx = vif->type == NL80211_IFTYPE_AP ? 0 : 3;
 	mlink->wcid = &link->sta.wcid;
+	mlink->wcid->offchannel = mlink->offchannel;
 
 	ret = mt7996_mcu_add_dev_info(phy, vif, link_conf, mlink, true);
 	if (ret)
Signature · 1 line
2.47.1
#5 lore raw

RE: [PATCH 5/8] wifi: mt76: mt7996: use the correct vif link for scanning/roc

drivers/net/wireless/mediatek/mt76/mt7996/mac.c void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi, · line 846

Quoted 13 lines
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +4 -5
@@ -839,11 +840,18 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
        bool beacon = !!(changed & (BSS_CHANGED_BEACON |
                                    BSS_CHANGED_BEACON_ENABLED)) && (!inband_disc);
 
-       mvif = vif ? (struct mt76_vif_link *)vif->drv_priv : NULL;
-       if (mvif) {
-               omac_idx = mvif->omac_idx;
-               wmm_idx = mvif->wmm_idx;
-               band_idx = mvif->band_idx;
+       if (vif) {
+               mvif = (struct mt7996_vif *)vif->drv_priv;
+               if (wcid->offchannel)
+                       mlink = rcu_dereference(mvif->mt76.offchannel_link);

need a RCU read lock?

Quoted 11 lines
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +8 -0
+               if (!mlink)
+                       mlink = &mvif->deflink.mt76;
+       }
+
+       if (mlink) {
+               omac_idx = mlink->omac_idx;
+               wmm_idx = mlink->wmm_idx;
+               band_idx = mlink->band_idx;
        }
 
        if (inband_disc) {
author maintainer
#6 lore raw

Re: [PATCH 5/8] wifi: mt76: mt7996: use the correct vif link for scanning/roc

Quoted 4 lines · Ping-Ke Shih
Quoted 4 lines
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +0 -0
@@ -839,11 +840,18 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
        bool beacon = !!(changed & (BSS_CHANGED_BEACON |
                                    BSS_CHANGED_BEACON_ENABLED)) && (!inband_disc);
 
Quoted 11 lines

drivers/net/wireless/mediatek/mt76/mt7996/mac.c void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi, · line 846

Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +4 -5
-       mvif = vif ? (struct mt76_vif_link *)vif->drv_priv : NULL;
-       if (mvif) {
-               omac_idx = mvif->omac_idx;
-               wmm_idx = mvif->wmm_idx;
-               band_idx = mvif->band_idx;
+       if (vif) {
+               mvif = (struct mt7996_vif *)vif->drv_priv;
+               if (wcid->offchannel)
+                       mlink = rcu_dereference(mvif->mt76.offchannel_link);

need a RCU read lock?

This path can only be reached from code that already holds the RCU lock.

- Felix

author maintainer
#7 lore raw

PATCH 6/8 mt76: only mark tx-status-failed frames as ACKed on mt76x0/2

In reply to Felix Fietkau

The interrupt status polling is unreliable, which can cause status events to get lost. On all newer chips, txs-timeout is an indication that the packet was either never sent, or never acked.
Fixes issues with inactivity polling.

---
 drivers/net/wireless/mediatek/mt76/mt76.h       | 1 +
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt76x2/pci.c | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | 3 ++-
 drivers/net/wireless/mediatek/mt76/tx.c         | 3 ++-
 6 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
index c16a6743ad64..b461273c3306 100644
@@ -492,6 +492,7 @@ struct mt76_hw_cap {
 #define MT_DRV_RX_DMA_HDR		BIT(3)
 #define MT_DRV_HW_MGMT_TXQ		BIT(4)
 #define MT_DRV_AMSDU_OFFLOAD		BIT(5)
+#define MT_DRV_IGNORE_TXS_FAILED	BIT(6)
 
 struct mt76_driver_ops {
 	u32 drv_flags;
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +2 -1
index b456ccd00d58..11c16d1fc70f 100644
@@ -156,7 +156,8 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	static const struct mt76_driver_ops drv_ops = {
 		.txwi_size = sizeof(struct mt76x02_txwi),
 		.drv_flags = MT_DRV_TX_ALIGNED4_SKBS |
-			     MT_DRV_SW_RX_AIRTIME,
+			     MT_DRV_SW_RX_AIRTIME |
+			     MT_DRV_IGNORE_TXS_FAILED,
 		.survey_flags = SURVEY_INFO_TIME_TX,
 		.update_survey = mt76x02_update_channel,
 		.set_channel = mt76x0_set_channel,
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +2 -1
index b031c500b741..90e5666c0857 100644
@@ -214,7 +214,8 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
 			 const struct usb_device_id *id)
 {
 	static const struct mt76_driver_ops drv_ops = {
-		.drv_flags = MT_DRV_SW_RX_AIRTIME,
+		.drv_flags = MT_DRV_SW_RX_AIRTIME |
+			     MT_DRV_IGNORE_TXS_FAILED,
 		.survey_flags = SURVEY_INFO_TIME_TX,
 		.update_survey = mt76x02_update_channel,
 		.set_channel = mt76x0_set_channel,
drivers/net/wireless/mediatek/mt76/mt76x2/pci.c +2 -1
index 727bfdd00b40..2303019670e2 100644
@@ -22,7 +22,8 @@ mt76x2e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	static const struct mt76_driver_ops drv_ops = {
 		.txwi_size = sizeof(struct mt76x02_txwi),
 		.drv_flags = MT_DRV_TX_ALIGNED4_SKBS |
-			     MT_DRV_SW_RX_AIRTIME,
+			     MT_DRV_SW_RX_AIRTIME |
+			     MT_DRV_IGNORE_TXS_FAILED,
 		.survey_flags = SURVEY_INFO_TIME_TX,
 		.update_survey = mt76x02_update_channel,
 		.set_channel = mt76x2e_set_channel,
drivers/net/wireless/mediatek/mt76/mt76x2/usb.c +2 -1
index e832ad53e239..3747f9ed31e6 100644
@@ -29,7 +29,8 @@ static int mt76x2u_probe(struct usb_interface *intf,
 			 const struct usb_device_id *id)
 {
 	static const struct mt76_driver_ops drv_ops = {
-		.drv_flags = MT_DRV_SW_RX_AIRTIME,
+		.drv_flags = MT_DRV_SW_RX_AIRTIME |
+			     MT_DRV_IGNORE_TXS_FAILED,
 		.survey_flags = SURVEY_INFO_TIME_TX,
 		.update_survey = mt76x02_update_channel,
 		.set_channel = mt76x2u_set_channel,
drivers/net/wireless/mediatek/mt76/tx.c +2 -1
index af0c50c983ec..513916469ca2 100644
@@ -100,7 +100,8 @@ __mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb, u8 flags,
 		return;
 
 	/* Tx status can be unreliable. if it fails, mark the frame as ACKed */
-	if (flags & MT_TX_CB_TXS_FAILED) {
+	if (flags & MT_TX_CB_TXS_FAILED &&
+	    (dev->drv->drv_flags & MT_DRV_IGNORE_TXS_FAILED)) {
 		info->status.rates[0].count = 0;
 		info->status.rates[0].idx = -1;
 		info->flags |= IEEE80211_TX_STAT_ACK;
Signature · 1 line
2.47.1
author maintainer
#8 lore raw

Re: [PATCH 6/8] mt76: only mark tx-status-failed frames as ACKed on mt76x0/2

Quoted 6 lines · Felix Fietkau

The interrupt status polling is unreliable, which can cause status events to get lost. On all newer chips, txs-timeout is an indication that the packet was either never sent, or never acked.
Fixes issues with inactivity polling.

Forgot the wifi: prefix in the subject here - I will add it when I apply the patch.

- Felix

author maintainer
#9 lore raw

PATCH 7/8 wifi: mt76: mt7996: implement driver specific get_txpower function

In reply to Felix Fietkau

Fixes reporting tx power for vifs that don't have a channel context assigned. Report the tx power of a phy that is covered by the vif's radio mask.

---
 .../net/wireless/mediatek/mt76/mt7996/main.c  | 27 ++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +26 -1
index 886b6ef3462b..89fc3f102555 100644
@@ -602,6 +602,31 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw,
 	mutex_unlock(&dev->mt76.mutex);
 }
 
+static int
+mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int *dbm)
+{
+	struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+	struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
+	struct mt7996_dev *dev = mt7996_hw_dev(hw);
+	struct wireless_dev *wdev;
+	int n_chains, delta, i;
+
+	if (!phy) {
+		wdev = ieee80211_vif_to_wdev(vif);
+		for (i = 0; i < hw->wiphy->n_radio; i++)
+			if (wdev->radio_mask & BIT(i))
+				phy = dev->radio_phy[i];
+
+		if (!phy)
+			return -EINVAL;
+	}
+
+	n_chains = hweight16(phy->mt76->chainmask);
+	delta = mt76_tx_power_nss_delta(n_chains);
+	*dbm = DIV_ROUND_UP(phy->mt76->txpower_cur + delta, 2);
+
+	return 0;
+}
 static u8
 mt7996_get_rates_table(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
 		       bool beacon, bool mcast)
@@ -1651,7 +1676,7 @@ const struct ieee80211_ops mt7996_ops = {
 	.remain_on_channel = mt76_remain_on_channel,
 	.cancel_remain_on_channel = mt76_cancel_remain_on_channel,
 	.release_buffered_frames = mt76_release_buffered_frames,
-	.get_txpower = mt76_get_txpower,
+	.get_txpower = mt7996_get_txpower,
 	.channel_switch_beacon = mt7996_channel_switch_beacon,
 	.get_stats = mt7996_get_stats,
 	.get_et_sset_count = mt7996_get_et_sset_count,
Signature · 1 line
2.47.1
maintainer
#10 lore raw

Re: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function

Quoted 14 lines · Felix Fietkau

Fixes reporting tx power for vifs that don't have a channel context assigned. Report the tx power of a phy that is covered by the vif's radio mask.

---
 .../net/wireless/mediatek/mt76/mt7996/main.c  | 27 ++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +0 -0
index 886b6ef3462b..89fc3f102555 100644

drivers/net/wireless/mediatek/mt76/mt7996/main.c static void mt7996_configure_filter(struct ieee80211_hw *hw, · line 606

Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt7996/main.c +2 -0
@@ -602,6 +602,31 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw,
 	mutex_unlock(&dev->mt76.mutex);
 }
 
+static int
+mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int *dbm)

I guess the signature here should be:

static int
mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
unsigned int link_id, int *dbm)
{
}

Regards,
Lorenzo

Quoted 39 lines
drivers/net/wireless/mediatek/mt76/mt7996/main.c +24 -1
+{
+	struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+	struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
+	struct mt7996_dev *dev = mt7996_hw_dev(hw);
+	struct wireless_dev *wdev;
+	int n_chains, delta, i;
+
+	if (!phy) {
+		wdev = ieee80211_vif_to_wdev(vif);
+		for (i = 0; i < hw->wiphy->n_radio; i++)
+			if (wdev->radio_mask & BIT(i))
+				phy = dev->radio_phy[i];
+
+		if (!phy)
+			return -EINVAL;
+	}
+
+	n_chains = hweight16(phy->mt76->chainmask);
+	delta = mt76_tx_power_nss_delta(n_chains);
+	*dbm = DIV_ROUND_UP(phy->mt76->txpower_cur + delta, 2);
+
+	return 0;
+}
 static u8
 mt7996_get_rates_table(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
 		       bool beacon, bool mcast)
@@ -1651,7 +1676,7 @@ const struct ieee80211_ops mt7996_ops = {
 	.remain_on_channel = mt76_remain_on_channel,
 	.cancel_remain_on_channel = mt76_cancel_remain_on_channel,
 	.release_buffered_frames = mt76_release_buffered_frames,
-	.get_txpower = mt76_get_txpower,
+	.get_txpower = mt7996_get_txpower,
 	.channel_switch_beacon = mt7996_channel_switch_beacon,
 	.get_stats = mt7996_get_stats,
 	.get_et_sset_count = mt7996_get_et_sset_count,
Signature · 1 line
2.47.1
author maintainer
#11 lore raw

Re: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function

Quoted 23 lines · Lorenzo Bianconi
Quoted 14 lines · Felix Fietkau

Fixes reporting tx power for vifs that don't have a channel context assigned. Report the tx power of a phy that is covered by the vif's radio mask.

---
 .../net/wireless/mediatek/mt76/mt7996/main.c  | 27 ++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +0 -0
index 886b6ef3462b..89fc3f102555 100644

drivers/net/wireless/mediatek/mt76/mt7996/main.c static void mt7996_configure_filter(struct ieee80211_hw *hw, · line 606

Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt7996/main.c +2 -0
@@ -602,6 +602,31 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw,
 	mutex_unlock(&dev->mt76.mutex);
 }
 
+static int
+mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int *dbm)

I guess the signature here should be:

Quoted 5 lines

static int
mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
unsigned int link_id, int *dbm)
{
}

Will fix, thanks.

- Felix

#12 lore raw

Re: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function

In reply to Felix Fietkau
kernel test robot noticed the following build errors:

Hi Felix,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v6.14-rc6 next-20250311] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Felix-Fietkau/wifi-mt76-mt7996-fix-SER-reset-trigger-on-WED-reset/20250311-184157
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20250311103646.43346-7-nbd%40nbd.name
patch subject: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function
config: i386-buildonly-randconfig-005-20250312 (https://download.01.org/0day-ci/archive/20250312/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250312/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7996/main.c:1679:24: error: initialization of 'int (*)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int,  int *)' from incompatible pointer type 'int (*)(struct ieee80211_hw *, struct ieee80211_vif *, int *)' [-Werror=incompatible-pointer-types]
    1679 |         .get_txpower = mt7996_get_txpower,
         |                        ^~~~~~~~~~~~~~~~~~

drivers/net/wireless/mediatek/mt76/mt7996/main.c:1679:24: note: (near initialization for 'mt7996_ops.get_txpower')
cc1: some warnings being treated as errors

vim +1679 drivers/net/wireless/mediatek/mt76/mt7996/main.c

1650
1651 const struct ieee80211_ops mt7996_ops = {
1652 .add_chanctx = mt76_add_chanctx,
1653 .remove_chanctx = mt76_remove_chanctx,
1654 .change_chanctx = mt76_change_chanctx,
1655 .assign_vif_chanctx = mt76_assign_vif_chanctx,
1656 .unassign_vif_chanctx = mt76_unassign_vif_chanctx,
1657 .switch_vif_chanctx = mt76_switch_vif_chanctx,
1658 .tx = mt7996_tx,
1659 .start = mt7996_start,
1660 .stop = mt7996_stop,
1661 .add_interface = mt7996_add_interface,
1662 .remove_interface = mt7996_remove_interface,
1663 .config = mt7996_config,
1664 .conf_tx = mt7996_conf_tx,
1665 .configure_filter = mt7996_configure_filter,
1666 .bss_info_changed = mt7996_bss_info_changed,
1667 .sta_state = mt76_sta_state,
1668 .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
1669 .link_sta_rc_update = mt7996_sta_rc_update,
1670 .set_key = mt7996_set_key,
1671 .ampdu_action = mt7996_ampdu_action,
1672 .set_rts_threshold = mt7996_set_rts_threshold,
1673 .wake_tx_queue = mt76_wake_tx_queue,
1674 .hw_scan = mt76_hw_scan,
1675 .cancel_hw_scan = mt76_cancel_hw_scan,
1676 .remain_on_channel = mt76_remain_on_channel,
1677 .cancel_remain_on_channel = mt76_cancel_remain_on_channel,
1678 .release_buffered_frames = mt76_release_buffered_frames,

> 1679		.get_txpower = mt7996_get_txpower,
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#13 lore raw

Re: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function

In reply to Felix Fietkau
kernel test robot noticed the following build errors:

Hi Felix,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v6.14-rc6 next-20250314] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Felix-Fietkau/wifi-mt76-mt7996-fix-SER-reset-trigger-on-WED-reset/20250311-184157
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20250311103646.43346-7-nbd%40nbd.name
patch subject: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20250315/[email protected]/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250315/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/net/wireless/mediatek/mt76/mt7996/main.c:6:
In file included from drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h:11:
In file included from drivers/net/wireless/mediatek/mt76/mt7996/../mt76_connac.h:7:
In file included from drivers/net/wireless/mediatek/mt76/mt7996/../mt76.h:12:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]

     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/wireless/mediatek/mt76/mt7996/main.c:6:
   drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h:303:10: warning: arithmetic between different enumeration types ('enum mt76_rxq_id' and 'enum mt76_mcuq_id') [-Wenum-enum-conversion]
     303 |         u8 q_id[MT7996_MAX_QUEUE];
         |                 ^~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h:84:41: note: expanded from macro 'MT7996_MAX_QUEUE'
      84 | #define MT7996_MAX_QUEUE                (__MT_RXQ_MAX + __MT_MCUQ_MAX + 3)
         |                                          ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h:304:17: warning: arithmetic between different enumeration types ('enum mt76_rxq_id' and 'enum mt76_mcuq_id') [-Wenum-enum-conversion]
     304 |         u32 q_int_mask[MT7996_MAX_QUEUE];
         |                        ^~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h:84:41: note: expanded from macro 'MT7996_MAX_QUEUE'
      84 | #define MT7996_MAX_QUEUE                (__MT_RXQ_MAX + __MT_MCUQ_MAX + 3)
         |                                          ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7996/main.c:1679:17: error: incompatible function pointer types initializing 'int (*)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, int *)' with an expression of type 'int (struct ieee80211_hw *, struct ieee80211_vif *, int *)' [-Wincompatible-function-pointer-types]
    1679 |         .get_txpower = mt7996_get_txpower,
         |                        ^~~~~~~~~~~~~~~~~~

5 warnings and 1 error generated.

vim +1679 drivers/net/wireless/mediatek/mt76/mt7996/main.c

1650
1651 const struct ieee80211_ops mt7996_ops = {
1652 .add_chanctx = mt76_add_chanctx,
1653 .remove_chanctx = mt76_remove_chanctx,
1654 .change_chanctx = mt76_change_chanctx,
1655 .assign_vif_chanctx = mt76_assign_vif_chanctx,
1656 .unassign_vif_chanctx = mt76_unassign_vif_chanctx,
1657 .switch_vif_chanctx = mt76_switch_vif_chanctx,
1658 .tx = mt7996_tx,
1659 .start = mt7996_start,
1660 .stop = mt7996_stop,
1661 .add_interface = mt7996_add_interface,
1662 .remove_interface = mt7996_remove_interface,
1663 .config = mt7996_config,
1664 .conf_tx = mt7996_conf_tx,
1665 .configure_filter = mt7996_configure_filter,
1666 .bss_info_changed = mt7996_bss_info_changed,
1667 .sta_state = mt76_sta_state,
1668 .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
1669 .link_sta_rc_update = mt7996_sta_rc_update,
1670 .set_key = mt7996_set_key,
1671 .ampdu_action = mt7996_ampdu_action,
1672 .set_rts_threshold = mt7996_set_rts_threshold,
1673 .wake_tx_queue = mt76_wake_tx_queue,
1674 .hw_scan = mt76_hw_scan,
1675 .cancel_hw_scan = mt76_cancel_hw_scan,
1676 .remain_on_channel = mt76_remain_on_channel,
1677 .cancel_remain_on_channel = mt76_cancel_remain_on_channel,
1678 .release_buffered_frames = mt76_release_buffered_frames,

> 1679		.get_txpower = mt7996_get_txpower,
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#14 lore raw

PATCH 8/8 wifi: mt76: scan: fix setting tx_info fields

In reply to Felix Fietkau

ieee80211_tx_prepare_skb initializes the skb cb, so fields need to be set afterwards.

---
 drivers/net/wireless/mediatek/mt76/scan.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/scan.c +13 -8
index 1c4f9deaaada..9b20ccbeb8cf 100644
@@ -52,11 +52,6 @@ mt76_scan_send_probe(struct mt76_dev *dev, struct cfg80211_ssid *ssid)
 		ether_addr_copy(hdr->addr3, req->bssid);
 	}
 
-	info = IEEE80211_SKB_CB(skb);
-	if (req->no_cck)
-		info->flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
-	info->control.flags |= IEEE80211_TX_CTRL_DONT_USE_RATE_MASK;
-
 	if (req->ie_len)
 		skb_put_data(skb, req->ie, req->ie_len);
 
@@ -64,10 +59,20 @@ mt76_scan_send_probe(struct mt76_dev *dev, struct cfg80211_ssid *ssid)
 	skb_set_queue_mapping(skb, IEEE80211_AC_VO);
 
 	rcu_read_lock();
-	if (ieee80211_tx_prepare_skb(phy->hw, vif, skb, band, NULL))
-		mt76_tx(phy, NULL, mvif->wcid, skb);
-	else
+
+	if (!ieee80211_tx_prepare_skb(phy->hw, vif, skb, band, NULL)) {
 		ieee80211_free_txskb(phy->hw, skb);
+		goto out;
+	}
+
+	info = IEEE80211_SKB_CB(skb);
+	if (req->no_cck)
+		info->flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
+	info->control.flags |= IEEE80211_TX_CTRL_DONT_USE_RATE_MASK;
+
+	mt76_tx(phy, NULL, mvif->wcid, skb);
+
+out:
 	rcu_read_unlock();
 }
 
Signature · 1 line
2.47.1