developer | 82d3406 | 2024-02-29 09:50:59 +0800 | [diff] [blame^] | 1 | From 3863199669fc17a8712a6102ddf5c6b20bd73194 Mon Sep 17 00:00:00 2001 |
developer | 8541b84 | 2024-01-29 14:38:48 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Mon, 29 Jan 2024 10:38:35 +0800 |
developer | 82d3406 | 2024-02-29 09:50:59 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 11/15] wifi: mt76: mt7915: fix mcu command format for mt7915 |
developer | 8541b84 | 2024-01-29 14:38:48 +0800 | [diff] [blame] | 5 | tx stats |
| 6 | |
| 7 | The mcu command format are different for mt7915 and mt7986. |
| 8 | Fix the mt7915_mcu_wed_wa_tx_stats to support mt7915 and mt7986. |
| 9 | |
| 10 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 11 | --- |
| 12 | mt7915/mcu.c | 42 ++++++++++++++++++++++++++++++------------ |
| 13 | 1 file changed, 30 insertions(+), 12 deletions(-) |
| 14 | |
| 15 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 82d3406 | 2024-02-29 09:50:59 +0800 | [diff] [blame^] | 16 | index d101cbf4..d443d503 100644 |
developer | 8541b84 | 2024-01-29 14:38:48 +0800 | [diff] [blame] | 17 | --- a/mt7915/mcu.c |
| 18 | +++ b/mt7915/mcu.c |
developer | a72bbd8 | 2024-02-04 18:27:28 +0800 | [diff] [blame] | 19 | @@ -4050,30 +4050,46 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx) |
developer | 8541b84 | 2024-01-29 14:38:48 +0800 | [diff] [blame] | 20 | { |
| 21 | struct { |
| 22 | __le32 cmd; |
| 23 | - __le32 num; |
| 24 | - __le32 __rsv; |
| 25 | - __le16 wlan_idx; |
| 26 | - } req = { |
| 27 | + __le32 arg0; |
| 28 | + __le32 arg1; |
| 29 | + __le16 arg2; |
| 30 | + } __packed req = { |
| 31 | .cmd = cpu_to_le32(0x15), |
| 32 | - .num = cpu_to_le32(1), |
| 33 | - .wlan_idx = cpu_to_le16(wlan_idx), |
| 34 | }; |
| 35 | struct mt7915_mcu_wa_tx_stat { |
| 36 | - __le16 wlan_idx; |
| 37 | - u8 __rsv[2]; |
| 38 | + union { |
| 39 | + struct { |
| 40 | + u8 wcid; |
| 41 | + u8 __rsv[3]; |
| 42 | + } __packed mt7915_hdr; |
| 43 | + struct { |
| 44 | + u16 wcid; |
| 45 | + u8 __rsv2[2]; |
| 46 | + } __packed mt7986_hdr; |
| 47 | + } u; |
| 48 | |
| 49 | /* tx_bytes is deprecated since WA byte counter uses u32, |
| 50 | * which easily leads to overflow. |
| 51 | */ |
| 52 | __le32 tx_bytes; |
| 53 | __le32 tx_packets; |
| 54 | - } *res; |
| 55 | + } __packed *res; |
| 56 | struct mt76_wcid *wcid; |
| 57 | struct sk_buff *skb; |
| 58 | - int ret; |
| 59 | + int ret, len; |
| 60 | + u16 ret_wcid; |
| 61 | + |
| 62 | + if (is_mt7915(&dev->mt76)) { |
| 63 | + req.arg0 = cpu_to_le32(wlan_idx); |
| 64 | + len = sizeof(req) - sizeof(req.arg2); |
| 65 | + } else { |
| 66 | + req.arg0 = cpu_to_le32(1); |
| 67 | + req.arg2 = cpu_to_le16(wlan_idx); |
| 68 | + len = sizeof(req); |
| 69 | + } |
| 70 | |
| 71 | ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WA_PARAM_CMD(QUERY), |
| 72 | - &req, sizeof(req), true, &skb); |
| 73 | + &req, len, true, &skb); |
| 74 | if (ret) |
| 75 | return ret; |
| 76 | |
developer | a72bbd8 | 2024-02-04 18:27:28 +0800 | [diff] [blame] | 77 | @@ -4082,7 +4098,9 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx) |
developer | 8541b84 | 2024-01-29 14:38:48 +0800 | [diff] [blame] | 78 | |
| 79 | res = (struct mt7915_mcu_wa_tx_stat *)skb->data; |
| 80 | |
| 81 | - if (le16_to_cpu(res->wlan_idx) != wlan_idx) { |
| 82 | + ret_wcid = is_mt7915(&dev->mt76) ? res->u.mt7915_hdr.wcid : |
| 83 | + le16_to_cpu(res->u.mt7986_hdr.wcid); |
| 84 | + if (ret_wcid != wlan_idx) { |
| 85 | ret = -EINVAL; |
| 86 | goto out; |
| 87 | } |
| 88 | -- |
| 89 | 2.18.0 |
| 90 | |