blob: abecf0a85c40ea1a7146358dad2e96e53999e80d [file] [log] [blame]
developerbbd45e12023-05-19 08:22:06 +08001From 02041c431dd8866954f76bd0d57af44971e1167a 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
developerbbd45e12023-05-19 08:22:06 +08004Subject: [PATCH 2/6] 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 +++++++++++++++++++++++++++++--------------------
developer2e954b52023-04-11 14:14:24 +080019 mt7915/mcu.h | 18 ++++++++----------
developerab646612023-03-17 10:43:23 +080020 mt7915/mt7915.h | 2 ++
developer2e954b52023-04-11 14:14:24 +080021 4 files changed, 45 insertions(+), 33 deletions(-)
developerab646612023-03-17 10:43:23 +080022
23diff --git a/mt7915/main.c b/mt7915/main.c
developerbbd45e12023-05-19 08:22:06 +080024index 8ce7b1c..14930f5 100644
developerab646612023-03-17 10:43:23 +080025--- a/mt7915/main.c
26+++ b/mt7915/main.c
developerbbd45e12023-05-19 08:22:06 +080027@@ -645,11 +645,13 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw,
developerab646612023-03-17 10:43:23 +080028 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
developerbbd45e12023-05-19 08:22:06 +080045index 7d9c46b..8ab4239 100644
developerab646612023-03-17 10:43:23 +080046--- a/mt7915/mcu.c
47+++ b/mt7915/mcu.c
developerbbd45e12023-05-19 08:22:06 +080048@@ -1875,10 +1875,9 @@ mt7915_mcu_beacon_cont(struct mt7915_dev *dev, struct ieee80211_vif *vif,
49 memcpy(buf + MT_TXD_SIZE, skb->data, skb->len);
developerab646612023-03-17 10:43:23 +080050 }
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)
developerbbd45e12023-05-19 08:22:06 +080062@@ -1888,14 +1887,28 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
developerab646612023-03-17 10:43:23 +080063 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;
developerbbd45e12023-05-19 08:22:06 +080093@@ -1907,26 +1920,25 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
developerab646612023-03-17 10:43:23 +080094 }
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);
developerbbd45e12023-05-19 08:22:06 +0800126@@ -1934,13 +1946,16 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
developerab646612023-03-17 10:43:23 +0800127 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,
developerbbd45e12023-05-19 08:22:06 +0800144@@ -1976,7 +1991,7 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developerab646612023-03-17 10:43:23 +0800145 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;
developerbbd45e12023-05-19 08:22:06 +0800153@@ -1990,11 +2005,6 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developerab646612023-03-17 10:43:23 +0800154 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
developer1d9da7d2023-04-15 12:45:34 +0800166index b9ea297..1592b5d 100644
developerab646612023-03-17 10:43:23 +0800167--- a/mt7915/mcu.h
168+++ b/mt7915/mcu.h
developer2e954b52023-04-11 14:14:24 +0800169@@ -495,10 +495,14 @@ 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))
developer2e954b52023-04-11 14:14:24 +0800184+#define MT7915_MAX_BSS_OFFLOAD_SIZE (MT7915_MAX_BEACON_SIZE + \
developerc9233442023-04-04 06:06:17 +0800185 MT7915_BEACON_UPDATE_SIZE)
186
187 #define MT7915_BSS_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
developer2e954b52023-04-11 14:14:24 +0800188@@ -511,12 +515,6 @@ enum {
developerab646612023-03-17 10:43:23 +0800189 sizeof(struct bss_info_bmc_rate) +\
190 sizeof(struct bss_info_ext_bss))
191
192-#define MT7915_BEACON_UPDATE_SIZE (sizeof(struct sta_req_hdr) + \
193- sizeof(struct bss_info_bcn_cntdwn) + \
194- sizeof(struct bss_info_bcn_mbss) + \
195- sizeof(struct bss_info_bcn_cont) + \
196- sizeof(struct bss_info_inband_discovery))
197-
198 static inline s8
199 mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower)
200 {
201diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerbbd45e12023-05-19 08:22:06 +0800202index 103cd0d..9c79eff 100644
developerab646612023-03-17 10:43:23 +0800203--- a/mt7915/mt7915.h
204+++ b/mt7915/mt7915.h
developerbbd45e12023-05-19 08:22:06 +0800205@@ -497,6 +497,8 @@ int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev,
developerab646612023-03-17 10:43:23 +0800206 bool add);
207 int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif,
208 struct cfg80211_he_bss_color *he_bss_color);
209+int mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif,
210+ u32 changed);
211 int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
212 int enable, u32 changed);
213 int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif,
214--
developer2324aa22023-04-12 11:30:15 +08002152.18.0
developerab646612023-03-17 10:43:23 +0800216