blob: 43f4e34b21453c497e652156a391e0422df1325d [file] [log] [blame]
developerc9233442023-04-04 06:06:17 +08001From 907d5ff95a36361c4cf541aebc15c4796eca9251 Mon Sep 17 00:00:00 2001
developerab646612023-03-17 10:43:23 +08002From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Thu, 23 Mar 2023 08:49:48 +0800
developerc9233442023-04-04 06:06:17 +08004Subject: [PATCH 2/2] wifi: mt76: mt7915: Update beacon size limitation for 11v
developerab646612023-03-17 10:43:23 +08005
6Separate the beacon offload command into two;
7one is for beacons and the other is for inband discovery frames.
8Also, the TLV size limitation for these two has been expanded to
9accommodate 11v MBSSID IE.
10
11Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com>
12Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
13Co-developed-by: Money Wang <Money.Wang@mediatek.com>
14Signed-off-by: Money Wang <Money.Wang@mediatek.com>
15Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
16---
17 mt7915/main.c | 8 +++++---
18 mt7915/mcu.c | 50 +++++++++++++++++++++++++++++--------------------
developerc9233442023-04-04 06:06:17 +080019 mt7915/mcu.h | 19 +++++++++----------
developerab646612023-03-17 10:43:23 +080020 mt7915/mt7915.h | 2 ++
developerc9233442023-04-04 06:06:17 +080021 4 files changed, 46 insertions(+), 33 deletions(-)
developerab646612023-03-17 10:43:23 +080022
23diff --git a/mt7915/main.c b/mt7915/main.c
developerc9233442023-04-04 06:06:17 +080024index 3bbccbdf..ea1d4e6a 100644
developerab646612023-03-17 10:43:23 +080025--- a/mt7915/main.c
26+++ b/mt7915/main.c
27@@ -647,11 +647,13 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw,
28 mt7915_update_bss_color(hw, vif, &info->he_bss_color);
29
30 if (changed & (BSS_CHANGED_BEACON |
31- BSS_CHANGED_BEACON_ENABLED |
32- BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
33- BSS_CHANGED_FILS_DISCOVERY))
34+ BSS_CHANGED_BEACON_ENABLED))
35 mt7915_mcu_add_beacon(hw, vif, info->enable_beacon, changed);
36
37+ if (changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
38+ BSS_CHANGED_FILS_DISCOVERY))
39+ mt7915_mcu_add_inband_discov(dev, vif, changed);
40+
41 mutex_unlock(&dev->mt76.mutex);
42 }
43
44diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developerc9233442023-04-04 06:06:17 +080045index dc24a475..03ae3bc9 100644
developerab646612023-03-17 10:43:23 +080046--- a/mt7915/mcu.c
47+++ b/mt7915/mcu.c
48@@ -1953,10 +1953,9 @@ mt7915_mcu_beacon_check_caps(struct mt7915_phy *phy, struct ieee80211_vif *vif,
49 }
50 }
51
52-static void
53-mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif,
54- struct sk_buff *rskb, struct bss_info_bcn *bcn,
55- u32 changed)
56+int
57+mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif,
58+ u32 changed)
59 {
60 #define OFFLOAD_TX_MODE_SU BIT(0)
61 #define OFFLOAD_TX_MODE_MU BIT(1)
62@@ -1966,14 +1965,28 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
63 struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef;
64 enum nl80211_band band = chandef->chan->band;
65 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
66+ struct bss_info_bcn *bcn;
67 struct bss_info_inband_discovery *discov;
68 struct ieee80211_tx_info *info;
69- struct sk_buff *skb = NULL;
70- struct tlv *tlv;
71+ struct sk_buff *rskb, *skb = NULL;
72+ struct tlv *tlv, *sub_tlv;
73 bool ext_phy = phy != &dev->phy;
74 u8 *buf, interval;
75 int len;
76
77+ if (vif->bss_conf.nontransmitted)
78+ return 0;
79+
80+ rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL,
81+ MT7915_MAX_BSS_OFFLOAD_SIZE);
82+
83+ if (IS_ERR(rskb))
84+ return PTR_ERR(rskb);
85+
86+ tlv = mt76_connac_mcu_add_tlv(rskb, BSS_INFO_OFFLOAD, sizeof(*bcn));
87+ bcn = (struct bss_info_bcn *)tlv;
88+ bcn->enable = true;
89+
90 if (changed & BSS_CHANGED_FILS_DISCOVERY &&
91 vif->bss_conf.fils_discovery.max_interval) {
92 interval = vif->bss_conf.fils_discovery.max_interval;
93@@ -1985,26 +1998,25 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
94 }
95
96 if (!skb)
97- return;
98+ return -EINVAL;
99
100 info = IEEE80211_SKB_CB(skb);
101 info->control.vif = vif;
102 info->band = band;
103-
104 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, ext_phy);
105
106 len = sizeof(*discov) + MT_TXD_SIZE + skb->len;
107 len = (len & 0x3) ? ((len | 0x3) + 1) : len;
108
109- if (len > (MT7915_MAX_BSS_OFFLOAD_SIZE - rskb->len)) {
110+ if (skb->len > MT7915_MAX_BEACON_SIZE) {
111 dev_err(dev->mt76.dev, "inband discovery size limit exceed\n");
112 dev_kfree_skb(skb);
113- return;
114+ return -EINVAL;
115 }
116
117- tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_DISCOV,
118- len, &bcn->sub_ntlv, &bcn->len);
119- discov = (struct bss_info_inband_discovery *)tlv;
120+ sub_tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_DISCOV,
121+ len, &bcn->sub_ntlv, &bcn->len);
122+ discov = (struct bss_info_inband_discovery *)sub_tlv;
123 discov->tx_mode = OFFLOAD_TX_MODE_SU;
124 /* 0: UNSOL PROBE RESP, 1: FILS DISCOV */
125 discov->tx_type = !!(changed & BSS_CHANGED_FILS_DISCOVERY);
126@@ -2012,13 +2024,16 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
127 discov->prob_rsp_len = cpu_to_le16(MT_TXD_SIZE + skb->len);
128 discov->enable = true;
129
130- buf = (u8 *)tlv + sizeof(*discov);
131+ buf = (u8 *)sub_tlv + sizeof(*discov);
132
133 mt7915_mac_write_txwi(&dev->mt76, (__le32 *)buf, skb, wcid, 0, NULL,
134 0, changed);
135 memcpy(buf + MT_TXD_SIZE, skb->data, skb->len);
136
137 dev_kfree_skb(skb);
138+
139+ return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb,
140+ MCU_EXT_CMD(BSS_INFO_UPDATE), true);
141 }
142
143 int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
144@@ -2054,7 +2069,7 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
145 if (!skb)
146 return -EINVAL;
147
148- if (skb->len > MT7915_MAX_BEACON_SIZE - MT_TXD_SIZE) {
149+ if (skb->len > MT7915_MAX_BEACON_SIZE) {
150 dev_err(dev->mt76.dev, "Bcn size limit exceed\n");
151 dev_kfree_skb(skb);
152 return -EINVAL;
153@@ -2070,11 +2085,6 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
154 mt7915_mcu_beacon_cont(dev, vif, rskb, skb, bcn, &offs);
155 dev_kfree_skb(skb);
156
157- if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP ||
158- changed & BSS_CHANGED_FILS_DISCOVERY)
159- mt7915_mcu_beacon_inband_discov(dev, vif, rskb,
160- bcn, changed);
161-
162 out:
163 return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb,
164 MCU_EXT_CMD(BSS_INFO_UPDATE), true);
165diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developerc9233442023-04-04 06:06:17 +0800166index b9ea297f..739003aa 100644
developerab646612023-03-17 10:43:23 +0800167--- a/mt7915/mcu.h
168+++ b/mt7915/mcu.h
developerc9233442023-04-04 06:06:17 +0800169@@ -495,10 +495,15 @@ enum {
developerab646612023-03-17 10:43:23 +0800170 SER_RECOVER
171 };
172
173-#define MT7915_MAX_BEACON_SIZE 512
174-#define MT7915_MAX_INBAND_FRAME_SIZE 256
175-#define MT7915_MAX_BSS_OFFLOAD_SIZE (MT7915_MAX_BEACON_SIZE + \
176- MT7915_MAX_INBAND_FRAME_SIZE + \
developerab646612023-03-17 10:43:23 +0800177+#define MT7915_MAX_BEACON_SIZE 1308
178+#define MT7915_BEACON_UPDATE_SIZE (sizeof(struct sta_req_hdr) + \
179+ sizeof(struct bss_info_bcn) + \
180+ sizeof(struct bss_info_bcn_cntdwn) + \
181+ sizeof(struct bss_info_bcn_mbss) + \
182+ MT_TXD_SIZE + \
183+ sizeof(struct bss_info_bcn_cont))
184+#define MT7915_MAX_BSS_OFFLOAD_SIZE (sizeof(struct mt76_connac2_mcu_txd) + \
185+ MT7915_MAX_BEACON_SIZE + \
developerc9233442023-04-04 06:06:17 +0800186 MT7915_BEACON_UPDATE_SIZE)
187
188 #define MT7915_BSS_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
189@@ -511,12 +516,6 @@ enum {
developerab646612023-03-17 10:43:23 +0800190 sizeof(struct bss_info_bmc_rate) +\
191 sizeof(struct bss_info_ext_bss))
192
193-#define MT7915_BEACON_UPDATE_SIZE (sizeof(struct sta_req_hdr) + \
194- sizeof(struct bss_info_bcn_cntdwn) + \
195- sizeof(struct bss_info_bcn_mbss) + \
196- sizeof(struct bss_info_bcn_cont) + \
197- sizeof(struct bss_info_inband_discovery))
198-
199 static inline s8
200 mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower)
201 {
202diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerc9233442023-04-04 06:06:17 +0800203index 3cbfb9b6..b66938ba 100644
developerab646612023-03-17 10:43:23 +0800204--- a/mt7915/mt7915.h
205+++ b/mt7915/mt7915.h
206@@ -506,6 +506,8 @@ int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev,
207 bool add);
208 int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif,
209 struct cfg80211_he_bss_color *he_bss_color);
210+int mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif,
211+ u32 changed);
212 int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
213 int enable, u32 changed);
214 int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif,
215--
2162.39.0
217