blob: bf724c82902c40800b8ef9376743d664c3ac76b7 [file] [log] [blame]
developer064da3c2023-06-13 15:57:26 +08001From 0449694e4e963d0b48354ae2c52016c34899fba6 Mon Sep 17 00:00:00 2001
2From: mtk20656 <chank.chen@mediatek.com>
3Date: Wed, 8 Mar 2023 14:18:29 +0800
4Subject: [PATCH 28/39] wifi: mt76: mt7996: add 11v mbss support for mt76
5
6Signed-off-by: mtk20656 <chank.chen@mediatek.com>
7---
8 mt76_connac_mcu.h | 10 ++++++
9 mt7996/init.c | 2 ++
10 mt7996/mcu.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++-
11 3 files changed, 90 insertions(+), 1 deletion(-)
12
13diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
14index 724a48a..97f874b 100644
15--- a/mt76_connac_mcu.h
16+++ b/mt76_connac_mcu.h
17@@ -1281,6 +1281,7 @@ enum {
18 UNI_BSS_INFO_RLM = 2,
19 UNI_BSS_INFO_BSS_COLOR = 4,
20 UNI_BSS_INFO_HE_BASIC = 5,
21+ UNI_BSS_INFO_11V_MBSSID = 6,
22 UNI_BSS_INFO_BCN_CONTENT = 7,
23 UNI_BSS_INFO_BCN_CSA = 8,
24 UNI_BSS_INFO_BCN_BCC = 9,
25@@ -1551,6 +1552,15 @@ struct bss_info_uni_he {
26 u8 rsv[2];
27 } __packed;
28
29+struct bss_info_uni_mbssid {
30+ __le16 tag;
31+ __le16 len;
32+ u8 max_indicator;
33+ u8 mbss_idx;
34+ u8 tx_bss_omac_idx;
35+ u8 rsv[1];
36+} __packed;
37+
38 struct mt76_connac_gtk_rekey_tlv {
39 __le16 tag;
40 __le16 len;
41diff --git a/mt7996/init.c b/mt7996/init.c
42index 192af3f..0562439 100644
43--- a/mt7996/init.c
44+++ b/mt7996/init.c
45@@ -359,6 +359,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw)
46 wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
47 wiphy->reg_notifier = mt7996_regd_notifier;
48 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
49+ wiphy->mbssid_max_interfaces = 16;
50
51 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BSS_COLOR);
52 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
53@@ -381,6 +382,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw)
54 ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
55 ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
56 ieee80211_hw_set(hw, WANT_MONITOR_VIF);
57+ ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
58
59 hw->max_tx_fragments = 4;
60
61diff --git a/mt7996/mcu.c b/mt7996/mcu.c
62index 6bcb33e..a369a08 100644
63--- a/mt7996/mcu.c
64+++ b/mt7996/mcu.c
65@@ -631,6 +631,24 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
66 he->max_nss_mcs[CMD_HE_MCS_BW8080] = cap->he_mcs_nss_supp.tx_mcs_80p80;
67 }
68
69+static void
70+mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
71+ struct mt7996_phy *phy)
72+{
73+ struct bss_info_uni_mbssid *mbssid;
74+ struct tlv *tlv;
75+
76+ tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_11V_MBSSID, sizeof(*mbssid));
77+
78+ mbssid = (struct bss_info_uni_mbssid *)tlv;
79+
80+ mbssid->max_indicator = vif->bss_conf.bssid_indicator;
81+ mbssid->mbss_idx = vif->bss_conf.bssid_index;
82+ mbssid->tx_bss_omac_idx = 0;
83+
84+ return;
85+}
86+
87 static void
88 mt7996_mcu_bss_bmc_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
89 struct mt7996_phy *phy)
90@@ -895,6 +913,9 @@ int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
91 if (vif->bss_conf.he_support)
92 mt7996_mcu_bss_he_tlv(skb, vif, phy);
93
94+ if (vif->bss_conf.bssid_indicator)
95+ mt7996_mcu_bss_mbssid_tlv(skb, vif, phy);
96+
97 /* this tag is necessary no matter if the vif is MLD */
98 mt7996_mcu_bss_mld_tlv(skb, vif);
99 }
100@@ -2162,6 +2183,59 @@ mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb,
101 info->cnt = skb->data[offs->cntdwn_counter_offs[0]];
102 }
103
104+static void
105+mt7996_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb,
106+ struct ieee80211_vif *vif, struct bss_bcn_content_tlv *bcn,
107+ struct ieee80211_mutable_offsets *offs)
108+{
109+ struct bss_bcn_mbss_tlv *mbss;
110+ const struct element *elem;
111+ struct tlv *tlv;
112+
113+ if (!vif->bss_conf.bssid_indicator)
114+ return;
115+
116+ tlv = mt7996_mcu_add_uni_tlv(rskb, UNI_BSS_INFO_BCN_MBSSID, sizeof(*mbss));
117+
118+ mbss = (struct bss_bcn_mbss_tlv *)tlv;
119+ mbss->offset[0] = cpu_to_le16(offs->tim_offset);
120+ mbss->bitmap = cpu_to_le32(1);
121+
122+ for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
123+ &skb->data[offs->mbssid_off],
124+ skb->len - offs->mbssid_off) {
125+ const struct element *sub_elem;
126+
127+ if (elem->datalen < 2)
128+ continue;
129+
130+ for_each_element(sub_elem, elem->data + 1, elem->datalen - 1) {
131+ const struct ieee80211_bssid_index *idx;
132+ const u8 *idx_ie;
133+
134+ if (sub_elem->id || sub_elem->datalen < 4)
135+ continue; /* not a valid BSS profile */
136+
137+ /* Find WLAN_EID_MULTI_BSSID_IDX
138+ * in the merged nontransmitted profile
139+ */
140+ idx_ie = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX,
141+ sub_elem->data,
142+ sub_elem->datalen);
143+ if (!idx_ie || idx_ie[1] < sizeof(*idx))
144+ continue;
145+
146+ idx = (void *)(idx_ie + 2);
147+ if (!idx->bssid_index || idx->bssid_index > 31)
148+ continue;
149+
150+ mbss->offset[idx->bssid_index] =
151+ cpu_to_le16(idx_ie - skb->data);
152+ mbss->bitmap |= cpu_to_le32(BIT(idx->bssid_index));
153+ }
154+ }
155+}
156+
157 static void
158 mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif,
159 struct sk_buff *rskb, struct sk_buff *skb,
160@@ -2202,6 +2276,9 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw,
161 struct tlv *tlv;
162 struct bss_bcn_content_tlv *bcn;
163
164+ if (vif->bss_conf.nontransmitted)
165+ return 0;
166+
167 rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
168 MT7996_BEACON_UPDATE_SIZE);
169 if (IS_ERR(rskb))
170@@ -2229,7 +2306,7 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw,
171 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->mt76->band_idx);
172
173 mt7996_mcu_beacon_cont(dev, vif, rskb, skb, bcn, &offs);
174- /* TODO: subtag - 11v MBSSID */
175+ mt7996_mcu_beacon_mbss(rskb, skb, vif, bcn, &offs);
176 mt7996_mcu_beacon_cntdwn(vif, rskb, skb, &offs);
177 dev_kfree_skb(skb);
178 out:
179--
1802.18.0
181