| From de01138c9689f49a30908dfb2657fee979b738a2 Mon Sep 17 00:00:00 2001 |
| From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| Date: Thu, 23 Mar 2023 08:49:48 +0800 |
| Subject: [PATCH] wifi: mt76: mt7915: Update beacon size limitation for 11v |
| |
| Separate the beacon offload command into two; |
| one is for beacons and the other is for inband discovery frames. |
| Also, the TLV size limitation for these two has been expanded to |
| accommodate 11v MBSSID IE. |
| |
| Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| Co-developed-by: Money Wang <Money.Wang@mediatek.com> |
| Signed-off-by: Money Wang <Money.Wang@mediatek.com> |
| Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com> |
| --- |
| mt7915/main.c | 8 +++++--- |
| mt7915/mcu.c | 50 +++++++++++++++++++++++++++++-------------------- |
| mt7915/mcu.h | 18 ++++++++---------- |
| mt7915/mt7915.h | 2 ++ |
| 4 files changed, 45 insertions(+), 33 deletions(-) |
| |
| diff --git a/mt7915/main.c b/mt7915/main.c |
| index 33bfa4a..f741517 100644 |
| --- a/mt7915/main.c |
| +++ b/mt7915/main.c |
| @@ -645,11 +645,13 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw, |
| mt7915_update_bss_color(hw, vif, &info->he_bss_color); |
| |
| if (changed & (BSS_CHANGED_BEACON | |
| - BSS_CHANGED_BEACON_ENABLED | |
| - BSS_CHANGED_UNSOL_BCAST_PROBE_RESP | |
| - BSS_CHANGED_FILS_DISCOVERY)) |
| + BSS_CHANGED_BEACON_ENABLED)) |
| mt7915_mcu_add_beacon(hw, vif, info->enable_beacon, changed); |
| |
| + if (changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP | |
| + BSS_CHANGED_FILS_DISCOVERY)) |
| + mt7915_mcu_add_inband_discov(dev, vif, changed); |
| + |
| if (set_bss_info == 0) |
| mt7915_mcu_add_bss_info(phy, vif, false); |
| if (set_sta == 0) |
| diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
| index b0328d4..79d2354 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -1882,10 +1882,9 @@ mt7915_mcu_beacon_cont(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| memcpy(buf + MT_TXD_SIZE, skb->data, skb->len); |
| } |
| |
| -static void |
| -mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| - struct sk_buff *rskb, struct bss_info_bcn *bcn, |
| - u32 changed) |
| +int |
| +mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| + u32 changed) |
| { |
| #define OFFLOAD_TX_MODE_SU BIT(0) |
| #define OFFLOAD_TX_MODE_MU BIT(1) |
| @@ -1895,14 +1894,28 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi |
| struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; |
| enum nl80211_band band = chandef->chan->band; |
| struct mt76_wcid *wcid = &dev->mt76.global_wcid; |
| + struct bss_info_bcn *bcn; |
| struct bss_info_inband_discovery *discov; |
| struct ieee80211_tx_info *info; |
| - struct sk_buff *skb = NULL; |
| - struct tlv *tlv; |
| + struct sk_buff *rskb, *skb = NULL; |
| + struct tlv *tlv, *sub_tlv; |
| bool ext_phy = phy != &dev->phy; |
| u8 *buf, interval; |
| int len; |
| |
| + if (vif->bss_conf.nontransmitted) |
| + return 0; |
| + |
| + rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, NULL, |
| + MT7915_MAX_BSS_OFFLOAD_SIZE); |
| + |
| + if (IS_ERR(rskb)) |
| + return PTR_ERR(rskb); |
| + |
| + tlv = mt76_connac_mcu_add_tlv(rskb, BSS_INFO_OFFLOAD, sizeof(*bcn)); |
| + bcn = (struct bss_info_bcn *)tlv; |
| + bcn->enable = true; |
| + |
| if (changed & BSS_CHANGED_FILS_DISCOVERY && |
| vif->bss_conf.fils_discovery.max_interval) { |
| interval = vif->bss_conf.fils_discovery.max_interval; |
| @@ -1914,26 +1927,25 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi |
| } |
| |
| if (!skb) |
| - return; |
| + return -EINVAL; |
| |
| info = IEEE80211_SKB_CB(skb); |
| info->control.vif = vif; |
| info->band = band; |
| - |
| info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, ext_phy); |
| |
| len = sizeof(*discov) + MT_TXD_SIZE + skb->len; |
| len = (len & 0x3) ? ((len | 0x3) + 1) : len; |
| |
| - if (len > (MT7915_MAX_BSS_OFFLOAD_SIZE - rskb->len)) { |
| + if (skb->len > MT7915_MAX_BEACON_SIZE) { |
| dev_err(dev->mt76.dev, "inband discovery size limit exceed\n"); |
| dev_kfree_skb(skb); |
| - return; |
| + return -EINVAL; |
| } |
| |
| - tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_DISCOV, |
| - len, &bcn->sub_ntlv, &bcn->len); |
| - discov = (struct bss_info_inband_discovery *)tlv; |
| + sub_tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_DISCOV, |
| + len, &bcn->sub_ntlv, &bcn->len); |
| + discov = (struct bss_info_inband_discovery *)sub_tlv; |
| discov->tx_mode = OFFLOAD_TX_MODE_SU; |
| /* 0: UNSOL PROBE RESP, 1: FILS DISCOV */ |
| discov->tx_type = !!(changed & BSS_CHANGED_FILS_DISCOVERY); |
| @@ -1941,13 +1953,16 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi |
| discov->prob_rsp_len = cpu_to_le16(MT_TXD_SIZE + skb->len); |
| discov->enable = true; |
| |
| - buf = (u8 *)tlv + sizeof(*discov); |
| + buf = (u8 *)sub_tlv + sizeof(*discov); |
| |
| mt7915_mac_write_txwi(&dev->mt76, (__le32 *)buf, skb, wcid, 0, NULL, |
| 0, changed); |
| memcpy(buf + MT_TXD_SIZE, skb->data, skb->len); |
| |
| dev_kfree_skb(skb); |
| + |
| + return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, |
| + MCU_EXT_CMD(BSS_INFO_UPDATE), true); |
| } |
| |
| int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| @@ -1983,7 +1998,7 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| if (!skb) |
| return -EINVAL; |
| |
| - if (skb->len > MT7915_MAX_BEACON_SIZE - MT_TXD_SIZE) { |
| + if (skb->len > MT7915_MAX_BEACON_SIZE) { |
| dev_err(dev->mt76.dev, "Bcn size limit exceed\n"); |
| dev_kfree_skb(skb); |
| return -EINVAL; |
| @@ -1997,11 +2012,6 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| mt7915_mcu_beacon_cont(dev, vif, rskb, skb, bcn, &offs); |
| dev_kfree_skb(skb); |
| |
| - if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP || |
| - changed & BSS_CHANGED_FILS_DISCOVERY) |
| - mt7915_mcu_beacon_inband_discov(dev, vif, rskb, |
| - bcn, changed); |
| - |
| out: |
| return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, |
| MCU_EXT_CMD(BSS_INFO_UPDATE), true); |
| diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
| index b9ea297..1592b5d 100644 |
| --- a/mt7915/mcu.h |
| +++ b/mt7915/mcu.h |
| @@ -495,10 +495,14 @@ enum { |
| SER_RECOVER |
| }; |
| |
| -#define MT7915_MAX_BEACON_SIZE 512 |
| -#define MT7915_MAX_INBAND_FRAME_SIZE 256 |
| -#define MT7915_MAX_BSS_OFFLOAD_SIZE (MT7915_MAX_BEACON_SIZE + \ |
| - MT7915_MAX_INBAND_FRAME_SIZE + \ |
| +#define MT7915_MAX_BEACON_SIZE 1308 |
| +#define MT7915_BEACON_UPDATE_SIZE (sizeof(struct sta_req_hdr) + \ |
| + sizeof(struct bss_info_bcn) + \ |
| + sizeof(struct bss_info_bcn_cntdwn) + \ |
| + sizeof(struct bss_info_bcn_mbss) + \ |
| + MT_TXD_SIZE + \ |
| + sizeof(struct bss_info_bcn_cont)) |
| +#define MT7915_MAX_BSS_OFFLOAD_SIZE (MT7915_MAX_BEACON_SIZE + \ |
| MT7915_BEACON_UPDATE_SIZE) |
| |
| #define MT7915_BSS_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ |
| @@ -511,12 +515,6 @@ enum { |
| sizeof(struct bss_info_bmc_rate) +\ |
| sizeof(struct bss_info_ext_bss)) |
| |
| -#define MT7915_BEACON_UPDATE_SIZE (sizeof(struct sta_req_hdr) + \ |
| - sizeof(struct bss_info_bcn_cntdwn) + \ |
| - sizeof(struct bss_info_bcn_mbss) + \ |
| - sizeof(struct bss_info_bcn_cont) + \ |
| - sizeof(struct bss_info_inband_discovery)) |
| - |
| static inline s8 |
| mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower) |
| { |
| diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
| index 0456e56..21984e9 100644 |
| --- a/mt7915/mt7915.h |
| +++ b/mt7915/mt7915.h |
| @@ -447,6 +447,8 @@ int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev, |
| bool add); |
| int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| struct cfg80211_he_bss_color *he_bss_color); |
| +int mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| + u32 changed); |
| int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| int enable, u32 changed); |
| int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif, |
| -- |
| 2.18.0 |
| |