blob: 54938958bbf6af1d023265b66e9f597fbea90150 [file] [log] [blame]
developer8eb72a32023-03-30 08:32:07 +08001From 21b39d41faf3a67127778d85a79029002ed65291 Mon Sep 17 00:00:00 2001
developer1413c882023-02-15 00:01:06 +08002From: MeiChia Chiu <meichia.chiu@mediatek.com>
developer3e0400f2023-02-10 08:32:03 +08003Date: Sun, 25 Dec 2022 22:43:46 +0800
developer8eb72a32023-03-30 08:32:07 +08004Subject: [PATCH 100/102] mac80211: mtk: add EHT BA1024 support
developer3e0400f2023-02-10 08:32:03 +08005
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 6f70394..27321f2 100644
13--- a/include/linux/ieee80211.h
14+++ b/include/linux/ieee80211.h
15@@ -1270,6 +1270,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
developer8eb72a32023-03-30 08:32:07 +080025index 56cd1fc..8daf292 100644
developer3e0400f2023-02-10 08:32:03 +080026--- a/net/mac80211/agg-tx.c
27+++ b/net/mac80211/agg-tx.c
28@@ -66,10 +66,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@@ -108,6 +115,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@@ -469,8 +485,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
developer8eb72a32023-03-30 08:32:07 +080076@@ -978,13 +997,35 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
developer3e0400f2023-02-10 08:32:03 +080077 {
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 capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
86 amsdu = capab & IEEE80211_ADDBA_PARAM_AMSDU_MASK;
87 tid = u16_get_bits(capab, IEEE80211_ADDBA_PARAM_TID_MASK);
88 buf_size = u16_get_bits(capab, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
89+ ext_ie_len = len - offsetof(struct ieee80211_mgmt,
90+ u.action.u.addba_resp.variable);
91+
92+ if (ext_ie_len < 0)
93+ goto next;
94+
95+ elems = ieee802_11_parse_elems(mgmt->u.action.u.addba_resp.variable,
96+ ext_ie_len, true, NULL);
97+
98+ if (elems && !elems->parse_error) {
99+ if (sta->sta.deflink.eht_cap.has_eht && elems->addba_ext_ie) {
100+ u8 buf_size_1k = u8_get_bits(elems->addba_ext_ie->data,
101+ IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
102+ buf_size |= buf_size_1k << IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT;
103+ }
104+ }
105+
106+ if (elems)
107+ kfree(elems);
108+next:
109 buf_size = min(buf_size, local->hw.max_tx_aggregation_subframes);
110
111 txq = sta->sta.txq[tid];
112--
developer8eb72a32023-03-30 08:32:07 +08001132.18.0
developer3e0400f2023-02-10 08:32:03 +0800114