diff mbox series

[v2] mt76: mt7915: introduce 802.11ax multi-bss support

Message ID de8955efb254ae54ed9e1b7883ad2b067ae34d0f.1647346612.git.lorenzo@kernel.org (mailing list archive)
State Accepted
Delegated to: Felix Fietkau
Headers show
Series [v2] mt76: mt7915: introduce 802.11ax multi-bss support | expand

Commit Message

Lorenzo Bianconi March 15, 2022, 12:19 p.m. UTC
Introduce mbss mcu APIs to enable 802.11ax multi-bss AP support for
mt7915 devices

Tested-by: Money Wang <money.wang@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Co-developed-by: Money Wang <money.wang@mediatek.com>
Signed-off-by: Money Wang <money.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes since v1:
- rebase on mbss mac80211 support
---
 .../wireless/mediatek/mt76/mt76_connac_mcu.c  | 19 +++++--
 .../net/wireless/mediatek/mt76/mt7915/init.c  |  2 +
 .../net/wireless/mediatek/mt76/mt7915/mcu.c   | 54 ++++++++++++++++++-
 3 files changed, 70 insertions(+), 5 deletions(-)

Comments

kernel test robot March 15, 2022, 11:28 p.m. UTC | #1
Hi Lorenzo,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on next-20220315]
[cannot apply to wireless/main v5.17-rc8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Lorenzo-Bianconi/mt76-mt7915-introduce-802-11ax-multi-bss-support/20220315-202139
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220316/202203160706.VipMbRpV-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/4887429a54676d58b10bf3d73377cd24b4a455bb
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Lorenzo-Bianconi/mt76-mt7915-introduce-802-11ax-multi-bss-support/20220315-202139
        git checkout 4887429a54676d58b10bf3d73377cd24b4a455bb
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/net/mac80211.h:20,
                    from drivers/net/wireless/mediatek/mt76/mt7915/../mt76.h:16,
                    from drivers/net/wireless/mediatek/mt76/mt7915/../mt76_connac.h:7,
                    from drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h:9,
                    from drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:6:
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c: In function 'mt7915_mcu_beacon_mbss':
>> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1834:44: error: 'struct ieee80211_mutable_offsets' has no member named 'mbssid_off'
    1834 |                             &skb->data[offs->mbssid_off],
         |                                            ^~
   include/linux/ieee80211.h:4263:47: note: in definition of macro 'for_each_element'
    4263 |         for (_elem = (const struct element *)(_data);                   \
         |                                               ^~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1833:9: note: in expansion of macro 'for_each_element_id'
    1833 |         for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
         |         ^~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1834:44: error: 'struct ieee80211_mutable_offsets' has no member named 'mbssid_off'
    1834 |                             &skb->data[offs->mbssid_off],
         |                                            ^~
   include/linux/ieee80211.h:4264:27: note: in definition of macro 'for_each_element'
    4264 |              (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >=    \
         |                           ^~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1833:9: note: in expansion of macro 'for_each_element_id'
    1833 |         for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1835:44: error: 'struct ieee80211_mutable_offsets' has no member named 'mbssid_off'
    1835 |                             skb->len - offs->mbssid_off) {
         |                                            ^~
   include/linux/ieee80211.h:4264:37: note: in definition of macro 'for_each_element'
    4264 |              (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >=    \
         |                                     ^~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1833:9: note: in expansion of macro 'for_each_element_id'
    1833 |         for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
         |         ^~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1834:44: error: 'struct ieee80211_mutable_offsets' has no member named 'mbssid_off'
    1834 |                             &skb->data[offs->mbssid_off],
         |                                            ^~
   include/linux/ieee80211.h:4266:27: note: in definition of macro 'for_each_element'
    4266 |              (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >=    \
         |                           ^~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1833:9: note: in expansion of macro 'for_each_element_id'
    1833 |         for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1835:44: error: 'struct ieee80211_mutable_offsets' has no member named 'mbssid_off'
    1835 |                             skb->len - offs->mbssid_off) {
         |                                            ^~
   include/linux/ieee80211.h:4266:37: note: in definition of macro 'for_each_element'
    4266 |              (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >=    \
         |                                     ^~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1833:9: note: in expansion of macro 'for_each_element_id'
    1833 |         for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
         |         ^~~~~~~~~~~~~~~~~~~


vim +1834 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

  1812	
  1813	static void
  1814	mt7915_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb,
  1815			       struct ieee80211_vif *vif, struct bss_info_bcn *bcn,
  1816			       struct ieee80211_mutable_offsets *offs)
  1817	{
  1818		struct bss_info_bcn_mbss *mbss;
  1819		const struct element *elem;
  1820		struct tlv *tlv;
  1821	
  1822		if (!vif->bss_conf.bssid_indicator)
  1823			return;
  1824	
  1825		tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_MBSSID,
  1826						   sizeof(*mbss), &bcn->sub_ntlv,
  1827						   &bcn->len);
  1828	
  1829		mbss = (struct bss_info_bcn_mbss *)tlv;
  1830		mbss->offset[0] = cpu_to_le16(offs->tim_offset);
  1831		mbss->bitmap = cpu_to_le32(1);
  1832	
  1833		for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
> 1834				    &skb->data[offs->mbssid_off],
  1835				    skb->len - offs->mbssid_off) {
  1836			const struct element *sub_elem;
  1837	
  1838			if (elem->datalen < 2)
  1839				continue;
  1840	
  1841			for_each_element(sub_elem, elem->data + 1, elem->datalen - 1) {
  1842				const u8 *data;
  1843	
  1844				if (sub_elem->id || sub_elem->datalen < 4)
  1845					continue; /* not a valid BSS profile */
  1846	
  1847				/* Find WLAN_EID_MULTI_BSSID_IDX
  1848				 * in the merged nontransmitted profile
  1849				 */
  1850				data = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX,
  1851							sub_elem->data,
  1852							sub_elem->datalen);
  1853				if (!data || data[1] < 1 || !data[2])
  1854					continue;
  1855	
  1856				mbss->offset[data[2]] = cpu_to_le16(data - skb->data);
  1857				mbss->bitmap |= cpu_to_le32(BIT(data[2]));
  1858			}
  1859		}
  1860	}
  1861	

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index eeb73d14552b..7cb17bf40e35 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -2675,11 +2675,25 @@  int mt76_connac_mcu_bss_basic_tlv(struct sk_buff *skb,
 	struct bss_info_basic *bss;
 	struct tlv *tlv;
 
+	tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_BASIC, sizeof(*bss));
+	bss = (struct bss_info_basic *)tlv;
+
 	switch (vif->type) {
 	case NL80211_IFTYPE_MESH_POINT:
-	case NL80211_IFTYPE_AP:
 	case NL80211_IFTYPE_MONITOR:
 		break;
+	case NL80211_IFTYPE_AP:
+		if (ieee80211_hw_check(phy->hw, SUPPORTS_MULTI_BSSID)) {
+			u8 bssid_id = vif->bss_conf.bssid_indicator;
+			struct wiphy *wiphy = phy->hw->wiphy;
+
+			if (bssid_id > ilog2(wiphy->mbssid_max_interfaces))
+				return -EINVAL;
+
+			bss->non_tx_bssid = vif->bss_conf.bssid_index;
+			bss->max_bssid = bssid_id;
+		}
+		break;
 	case NL80211_IFTYPE_STATION:
 		if (enable) {
 			rcu_read_lock();
@@ -2704,9 +2718,6 @@  int mt76_connac_mcu_bss_basic_tlv(struct sk_buff *skb,
 		break;
 	}
 
-	tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_BASIC, sizeof(*bss));
-
-	bss = (struct bss_info_basic *)tlv;
 	bss->network_type = cpu_to_le32(type);
 	bss->bmc_wcid_lo = to_wcid_lo(wlan_idx);
 	bss->bmc_wcid_hi = to_wcid_hi(wlan_idx);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 9a8df1282f8d..6d29366c5139 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -343,6 +343,7 @@  mt7915_init_wiphy(struct ieee80211_hw *hw)
 	wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
 	wiphy->reg_notifier = mt7915_regd_notifier;
 	wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
+	wiphy->mbssid_max_interfaces = 16;
 
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BSS_COLOR);
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
@@ -360,6 +361,7 @@  mt7915_init_wiphy(struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, HAS_RATE_CONTROL);
 	ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
 	ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
+	ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
 	ieee80211_hw_set(hw, WANT_MONITOR_VIF);
 
 	hw->max_tx_fragments = 4;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 10dc4bf5adec..9cd458223b00 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -1825,6 +1825,55 @@  mt7915_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb,
 	info->cnt = skb->data[offs->cntdwn_counter_offs[0]];
 }
 
+static void
+mt7915_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb,
+		       struct ieee80211_vif *vif, struct bss_info_bcn *bcn,
+		       struct ieee80211_mutable_offsets *offs)
+{
+	struct bss_info_bcn_mbss *mbss;
+	const struct element *elem;
+	struct tlv *tlv;
+
+	if (!vif->bss_conf.bssid_indicator)
+		return;
+
+	tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_MBSSID,
+					   sizeof(*mbss), &bcn->sub_ntlv,
+					   &bcn->len);
+
+	mbss = (struct bss_info_bcn_mbss *)tlv;
+	mbss->offset[0] = cpu_to_le16(offs->tim_offset);
+	mbss->bitmap = cpu_to_le32(1);
+
+	for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID,
+			    &skb->data[offs->mbssid_off],
+			    skb->len - offs->mbssid_off) {
+		const struct element *sub_elem;
+
+		if (elem->datalen < 2)
+			continue;
+
+		for_each_element(sub_elem, elem->data + 1, elem->datalen - 1) {
+			const u8 *data;
+
+			if (sub_elem->id || sub_elem->datalen < 4)
+				continue; /* not a valid BSS profile */
+
+			/* Find WLAN_EID_MULTI_BSSID_IDX
+			 * in the merged nontransmitted profile
+			 */
+			data = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX,
+						sub_elem->data,
+						sub_elem->datalen);
+			if (!data || data[1] < 1 || !data[2])
+				continue;
+
+			mbss->offset[data[2]] = cpu_to_le16(data - skb->data);
+			mbss->bitmap |= cpu_to_le32(BIT(data[2]));
+		}
+	}
+}
+
 static void
 mt7915_mcu_beacon_cont(struct mt7915_dev *dev, struct ieee80211_vif *vif,
 		       struct sk_buff *rskb, struct sk_buff *skb,
@@ -1952,6 +2001,9 @@  int mt7915_mcu_add_beacon(struct ieee80211_hw *hw,
 	int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE;
 	bool ext_phy = phy != &dev->phy;
 
+	if (vif->bss_conf.nontransmitted)
+		return 0;
+
 	rskb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
 					       NULL, len);
 	if (IS_ERR(rskb))
@@ -1981,8 +2033,8 @@  int mt7915_mcu_add_beacon(struct ieee80211_hw *hw,
 
 	mt7915_mcu_beacon_check_caps(phy, vif, skb);
 
-	/* TODO: subtag - 11v MBSSID */
 	mt7915_mcu_beacon_cntdwn(vif, rskb, skb, bcn, &offs);
+	mt7915_mcu_beacon_mbss(rskb, skb, vif, bcn, &offs);
 	mt7915_mcu_beacon_cont(dev, vif, rskb, skb, bcn, &offs);
 	dev_kfree_skb(skb);