blob: 8e716a0fad413ca293e8907a4cabccd42321c055 [file] [log] [blame]
developer7e2761e2023-10-12 08:11:13 +08001From 274d96dc00990390f4e830452d9032471deacf33 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 6 Oct 2023 11:44:03 +0800
4Subject: [PATCH 31/98] wifi: mt76: mt7996: refine ampdu factor
5
6Firmware would parse ht/vht/he/eht cap to get correct ampdu parameters.
7---
8 mt76_connac_mcu.h | 4 +++-
9 mt7996/mcu.c | 44 ++++----------------------------------------
10 mt7996/mcu.h | 1 -
11 3 files changed, 7 insertions(+), 42 deletions(-)
12
13diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
14index 6fac67b..ca2e573 100644
15--- a/mt76_connac_mcu.h
16+++ b/mt76_connac_mcu.h
17@@ -298,7 +298,9 @@ struct sta_rec_ht {
18 __le16 tag;
19 __le16 len;
20 __le16 ht_cap;
21- u16 rsv;
22+ __le16 ht_cap_ext;
23+ u8 ampdu_param;
24+ u8 _rsv[3];
25 } __packed;
26
27 struct sta_rec_vht {
28diff --git a/mt7996/mcu.c b/mt7996/mcu.c
29index 60af1d4..8b81644 100644
30--- a/mt7996/mcu.c
31+++ b/mt7996/mcu.c
32@@ -1195,6 +1195,10 @@ mt7996_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
33
34 ht = (struct sta_rec_ht *)tlv;
35 ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap);
36+ ht->ampdu_param = u8_encode_bits(sta->deflink.ht_cap.ampdu_factor,
37+ IEEE80211_HT_AMPDU_PARM_FACTOR) |
38+ u8_encode_bits(sta->deflink.ht_cap.ampdu_density,
39+ IEEE80211_HT_AMPDU_PARM_DENSITY);
40 }
41
42 static void
43@@ -1651,44 +1655,6 @@ mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
44 bfee->fb_identity_matrix = (nrow == 1 && tx_ant == 2);
45 }
46
47-static void
48-mt7996_mcu_sta_phy_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
49- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
50-{
51- struct sta_rec_phy *phy;
52- struct tlv *tlv;
53- u8 af = 0, mm = 0;
54-
55- if (!sta->deflink.ht_cap.ht_supported && !sta->deflink.he_6ghz_capa.capa)
56- return;
57-
58- tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_PHY, sizeof(*phy));
59-
60- phy = (struct sta_rec_phy *)tlv;
61- if (sta->deflink.ht_cap.ht_supported) {
62- af = sta->deflink.ht_cap.ampdu_factor;
63- mm = sta->deflink.ht_cap.ampdu_density;
64- }
65-
66- if (sta->deflink.vht_cap.vht_supported) {
67- u8 vht_af = FIELD_GET(IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK,
68- sta->deflink.vht_cap.cap);
69-
70- af = max_t(u8, af, vht_af);
71- }
72-
73- if (sta->deflink.he_6ghz_capa.capa) {
74- af = le16_get_bits(sta->deflink.he_6ghz_capa.capa,
75- IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
76- mm = le16_get_bits(sta->deflink.he_6ghz_capa.capa,
77- IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START);
78- }
79-
80- phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR, af) |
81- FIELD_PREP(IEEE80211_HT_AMPDU_PARM_DENSITY, mm);
82- phy->max_ampdu_len = af;
83-}
84-
85 static void
86 mt7996_mcu_sta_hdrt_tlv(struct mt7996_dev *dev, struct sk_buff *skb)
87 {
88@@ -2100,8 +2066,6 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
89
90 /* tag order is in accordance with firmware dependency. */
91 if (sta) {
92- /* starec phy */
93- mt7996_mcu_sta_phy_tlv(dev, skb, vif, sta);
94 /* starec hdrt mode */
95 mt7996_mcu_sta_hdrt_tlv(dev, skb);
96 /* starec bfer */
97diff --git a/mt7996/mcu.h b/mt7996/mcu.h
98index af7cd18..ca16336 100644
99--- a/mt7996/mcu.h
100+++ b/mt7996/mcu.h
101@@ -730,7 +730,6 @@ enum {
102 sizeof(struct sta_rec_uapsd) + \
103 sizeof(struct sta_rec_amsdu) + \
104 sizeof(struct sta_rec_bfee) + \
105- sizeof(struct sta_rec_phy) + \
106 sizeof(struct sta_rec_ra_uni) + \
107 sizeof(struct sta_rec_sec) + \
108 sizeof(struct sta_rec_ra_fixed_uni) + \
109--
1102.18.0
111