developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 1 | From 02041c431dd8866954f76bd0d57af44971e1167a Mon Sep 17 00:00:00 2001 |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 3 | Date: Thu, 23 Mar 2023 08:49:48 +0800 |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 4 | Subject: [PATCH 2/6] wifi: mt76: mt7915: Update beacon size limitation for 11v |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 5 | |
| 6 | Separate the beacon offload command into two; |
| 7 | one is for beacons and the other is for inband discovery frames. |
| 8 | Also, the TLV size limitation for these two has been expanded to |
| 9 | accommodate 11v MBSSID IE. |
| 10 | |
| 11 | Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 12 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 13 | Co-developed-by: Money Wang <Money.Wang@mediatek.com> |
| 14 | Signed-off-by: Money Wang <Money.Wang@mediatek.com> |
| 15 | Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com> |
| 16 | --- |
| 17 | mt7915/main.c | 8 +++++--- |
| 18 | mt7915/mcu.c | 50 +++++++++++++++++++++++++++++-------------------- |
developer | 2e954b5 | 2023-04-11 14:14:24 +0800 | [diff] [blame] | 19 | mt7915/mcu.h | 18 ++++++++---------- |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 20 | mt7915/mt7915.h | 2 ++ |
developer | 2e954b5 | 2023-04-11 14:14:24 +0800 | [diff] [blame] | 21 | 4 files changed, 45 insertions(+), 33 deletions(-) |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 22 | |
| 23 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 24 | index 8ce7b1c..14930f5 100644 |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 25 | --- a/mt7915/main.c |
| 26 | +++ b/mt7915/main.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 27 | @@ -645,11 +645,13 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw, |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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 | |
| 44 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 45 | index 7d9c46b..8ab4239 100644 |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 46 | --- a/mt7915/mcu.c |
| 47 | +++ b/mt7915/mcu.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 48 | @@ -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); |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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) |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 62 | @@ -1888,14 +1887,28 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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; |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 93 | @@ -1907,26 +1920,25 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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); |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 126 | @@ -1934,13 +1946,16 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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, |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 144 | @@ -1976,7 +1991,7 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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; |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 153 | @@ -1990,11 +2005,6 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 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); |
| 165 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 166 | index b9ea297..1592b5d 100644 |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 167 | --- a/mt7915/mcu.h |
| 168 | +++ b/mt7915/mcu.h |
developer | 2e954b5 | 2023-04-11 14:14:24 +0800 | [diff] [blame] | 169 | @@ -495,10 +495,14 @@ enum { |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 170 | 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 + \ |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 177 | +#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)) |
developer | 2e954b5 | 2023-04-11 14:14:24 +0800 | [diff] [blame] | 184 | +#define MT7915_MAX_BSS_OFFLOAD_SIZE (MT7915_MAX_BEACON_SIZE + \ |
developer | c923344 | 2023-04-04 06:06:17 +0800 | [diff] [blame] | 185 | MT7915_BEACON_UPDATE_SIZE) |
| 186 | |
| 187 | #define MT7915_BSS_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ |
developer | 2e954b5 | 2023-04-11 14:14:24 +0800 | [diff] [blame] | 188 | @@ -511,12 +515,6 @@ enum { |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 189 | 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 | { |
| 201 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 202 | index 103cd0d..9c79eff 100644 |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 203 | --- a/mt7915/mt7915.h |
| 204 | +++ b/mt7915/mt7915.h |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 205 | @@ -497,6 +497,8 @@ int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev, |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 206 | 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 | -- |
developer | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 215 | 2.18.0 |
developer | ab64661 | 2023-03-17 10:43:23 +0800 | [diff] [blame] | 216 | |