blob: c16cfe80e0194d17872e1876b06265710cb75487 [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From 61947ae7c04a86c4d6526d080e37e53fe4d17599 Mon Sep 17 00:00:00 2001
2From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Sun, 25 Dec 2022 22:43:46 +0800
4Subject: [PATCH 25/61] mtk: mac80211: add EHT BA1024 support
5
6---
7 include/linux/ieee80211.h | 2 ++
8 net/mac80211/agg-tx.c | 45 +++++++++++++++++++++++++++++++++++++--
9 2 files changed, 45 insertions(+), 2 deletions(-)
10
11diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
12index 95c39b7..70f0135 100644
13--- a/include/linux/ieee80211.h
14+++ b/include/linux/ieee80211.h
15@@ -1391,6 +1391,8 @@ struct ieee80211_mgmt {
16 __le16 status;
17 __le16 capab;
18 __le16 timeout;
19+ /* followed by BA Extension */
20+ u8 variable[0];
21 } __packed addba_resp;
22 struct{
23 u8 action_code;
24diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
25index af3d8e6..5cf478e 100644
26--- a/net/mac80211/agg-tx.c
27+++ b/net/mac80211/agg-tx.c
28@@ -72,10 +72,17 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
29 struct ieee80211_local *local = sdata->local;
30 struct sk_buff *skb;
31 struct ieee80211_mgmt *mgmt;
32+ struct ieee80211_addba_ext_ie *addba_ext;
33+ u8 *pos;
34 u16 capab = 0;
35 bool amsdu = ieee80211_hw_check(&local->hw, SUPPORTS_AMSDU_IN_AMPDU);
36
37- skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom);
38+ if (agg_size >= 1024)
39+ skb = dev_alloc_skb(sizeof(*mgmt) +
40+ 2 + sizeof(struct ieee80211_addba_ext_ie) +
41+ local->hw.extra_tx_headroom);
42+ else
43+ skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom);
44
45 if (!skb)
46 return;
47@@ -114,6 +121,15 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
48 mgmt->u.action.u.addba_req.start_seq_num =
49 cpu_to_le16(start_seq_num << 4);
50
51+ if (agg_size >= 1024 ) {
52+ pos = skb_put_zero(skb, 2 + sizeof(struct ieee80211_addba_ext_ie));
53+ *pos++ = WLAN_EID_ADDBA_EXT;
54+ *pos++ = sizeof(struct ieee80211_addba_ext_ie);
55+ addba_ext = (struct ieee80211_addba_ext_ie *)pos;
56+ addba_ext->data = u8_encode_bits(agg_size >> IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT,
57+ IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
58+ }
59+
60 ieee80211_tx_skb_tid(sdata, skb, tid, -1);
61 }
62
63@@ -481,8 +497,11 @@ static void ieee80211_send_addba_with_timeout(struct sta_info *sta,
64 sta->ampdu_mlme.addba_req_num[tid]++;
65 spin_unlock_bh(&sta->lock);
66
67- if (sta->sta.deflink.he_cap.has_he) {
68+ if (sta->sta.deflink.eht_cap.has_eht) {
69 buf_size = local->hw.max_tx_aggregation_subframes;
70+ } else if (sta->sta.deflink.he_cap.has_he) {
71+ buf_size = min_t(u16, local->hw.max_tx_aggregation_subframes,
72+ IEEE80211_MAX_AMPDU_BUF_HE);
73 } else {
74 /*
75 * We really should use what the driver told us it will
76@@ -980,8 +999,10 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
77 {
78 struct tid_ampdu_tx *tid_tx;
79 struct ieee80211_txq *txq;
80+ struct ieee802_11_elems *elems;
81 u16 capab, tid, buf_size;
82 bool amsdu;
83+ int ext_ie_len;
84
85 lockdep_assert_wiphy(sta->local->hw.wiphy);
86
87@@ -989,6 +1010,26 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
88 amsdu = capab & IEEE80211_ADDBA_PARAM_AMSDU_MASK;
89 tid = u16_get_bits(capab, IEEE80211_ADDBA_PARAM_TID_MASK);
90 buf_size = u16_get_bits(capab, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
91+ ext_ie_len = len - offsetof(struct ieee80211_mgmt,
92+ u.action.u.addba_resp.variable);
93+
94+ if (ext_ie_len < 0)
95+ goto next;
96+
97+ elems = ieee802_11_parse_elems(mgmt->u.action.u.addba_resp.variable,
98+ ext_ie_len, true, NULL);
99+
100+ if (elems && !elems->parse_error) {
101+ if (sta->sta.deflink.eht_cap.has_eht && elems->addba_ext_ie) {
102+ u8 buf_size_1k = u8_get_bits(elems->addba_ext_ie->data,
103+ IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
104+ buf_size |= buf_size_1k << IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT;
105+ }
106+ }
107+
108+ if (elems)
109+ kfree(elems);
110+next:
111 buf_size = min(buf_size, local->hw.max_tx_aggregation_subframes);
112
113 txq = sta->sta.txq[tid];
114--
1152.39.2
116