mt76: mt7615: configure bss info adding the interface
authorSean Wang <sean.wang@mediatek.com>
Tue, 12 May 2020 20:02:50 +0000 (22:02 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 13 May 2020 18:01:11 +0000 (20:01 +0200)
Introduce essential bss information for multiple vifs hw_scan in
mt7615_mcu_uni_add_dev adding the interface

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/main.c
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h

index e87a5843c7189a82304d9b20b7931cede6d8df17..2e9e9d3519d78b295192df3cc0f0e823dd217080 100644 (file)
@@ -156,10 +156,6 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
        else
                mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
 
-       ret = mt7615_mcu_add_dev_info(dev, vif, true);
-       if (ret)
-               goto out;
-
        dev->vif_mask |= BIT(mvif->idx);
        dev->omac_mask |= BIT(mvif->omac_idx);
        phy->omac_mask |= BIT(mvif->omac_idx);
@@ -182,6 +178,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
                mt76_txq_init(&dev->mt76, vif->txq);
        }
 
+       ret = mt7615_mcu_add_dev_info(dev, vif, true);
 out:
        mutex_unlock(&dev->mt76.mutex);
 
index 92ea9dc3c1c676d9cb1fac5920101970489b9a05..b944f372738ae784adae00e3ae6d9bddf0361cd9 100644 (file)
@@ -1294,7 +1294,7 @@ mt7615_mcu_uni_add_dev(struct mt7615_dev *dev,
 {
        struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
        struct {
-               struct req_hdr {
+               struct {
                        u8 omac_idx;
                        u8 band_idx;
                        __le16 pad;
@@ -1306,7 +1306,7 @@ mt7615_mcu_uni_add_dev(struct mt7615_dev *dev,
                        u8 pad;
                        u8 omac_addr[ETH_ALEN];
                } __packed tlv;
-       } data = {
+       } dev_req = {
                .hdr = {
                        .omac_idx = mvif->omac_idx,
                        .band_idx = mvif->band_idx,
@@ -1317,11 +1317,65 @@ mt7615_mcu_uni_add_dev(struct mt7615_dev *dev,
                        .active = enable,
                },
        };
+       struct {
+               struct {
+                       u8 bss_idx;
+                       u8 pad[3];
+               } __packed hdr;
+               struct mt7615_bss_basic_tlv basic;
+       } basic_req = {
+               .hdr = {
+                       .bss_idx = mvif->idx,
+               },
+               .basic = {
+                       .tag = cpu_to_le16(UNI_BSS_INFO_BASIC),
+                       .len = cpu_to_le16(sizeof(struct mt7615_bss_basic_tlv)),
+                       .omac_idx = mvif->omac_idx,
+                       .band_idx = mvif->band_idx,
+                       .wmm_idx = mvif->wmm_idx,
+                       .active = enable,
+                       .bmc_tx_wlan_idx = cpu_to_le16(mvif->sta.wcid.idx),
+                       .sta_idx = cpu_to_le16(mvif->sta.wcid.idx),
+                       .conn_state = 1,
+               },
+       };
+       int err, idx, cmd, len;
+       void *data;
 
-       memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN);
+       switch (vif->type) {
+       case NL80211_IFTYPE_MESH_POINT:
+       case NL80211_IFTYPE_AP:
+               basic_req.basic.conn_type = cpu_to_le32(CONNECTION_INFRA_AP);
+               break;
+       case NL80211_IFTYPE_STATION:
+               basic_req.basic.conn_type = cpu_to_le32(CONNECTION_INFRA_STA);
+               break;
+       case NL80211_IFTYPE_ADHOC:
+               basic_req.basic.conn_type = cpu_to_le32(CONNECTION_IBSS_ADHOC);
+               break;
+       default:
+               WARN_ON(1);
+               break;
+       }
 
-       return __mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_DEV_INFO_UPDATE,
-                                  &data, sizeof(data), true);
+       idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx;
+       basic_req.basic.hw_bss_idx = idx;
+
+       memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN);
+
+       cmd = enable ? MCU_UNI_CMD_DEV_INFO_UPDATE : MCU_UNI_CMD_BSS_INFO_UPDATE;
+       data = enable ? (void *)&dev_req : (void *)&basic_req;
+       len = enable ? sizeof(dev_req) : sizeof(basic_req);
+
+       err = __mt76_mcu_send_msg(&dev->mt76, cmd, data, len, true);
+       if (err < 0)
+               return err;
+
+       cmd = enable ? MCU_UNI_CMD_BSS_INFO_UPDATE : MCU_UNI_CMD_DEV_INFO_UPDATE;
+       data = enable ? (void *)&basic_req : (void *)&dev_req;
+       len = enable ? sizeof(basic_req) : sizeof(dev_req);
+
+       return __mt76_mcu_send_msg(&dev->mt76, cmd, data, len, true);
 }
 
 static int
@@ -1343,44 +1397,20 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif,
                        u8 bss_idx;
                        u8 pad[3];
                } __packed hdr;
-               struct basic_tlv {
-                       __le16 tag;
-                       __le16 len;
-                       u8 active;
-                       u8 omac_idx;
-                       u8 hw_bss_idx;
-                       u8 band_idx;
-                       __le32 conn_type;
-                       u8 conn_state;
-                       u8 wmm_idx;
-                       u8 bssid[ETH_ALEN];
-                       __le16 bmc_tx_wlan_idx;
-                       __le16 bcn_interval;
-                       u8 dtim_period;
-                       u8 phymode; /* bit(0): A
-                                    * bit(1): B
-                                    * bit(2): G
-                                    * bit(3): GN
-                                    * bit(4): AN
-                                    * bit(5): AC
-                                    */
-                       __le16 sta_idx;
-                       u8 nonht_basic_phy;
-                       u8 pad[3];
-               } __packed basic;
+               struct mt7615_bss_basic_tlv basic;
        } basic_req = {
                .hdr = {
                        .bss_idx = mvif->idx,
                },
                .basic = {
                        .tag = cpu_to_le16(UNI_BSS_INFO_BASIC),
-                       .len = cpu_to_le16(sizeof(struct basic_tlv)),
+                       .len = cpu_to_le16(sizeof(struct mt7615_bss_basic_tlv)),
                        .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int),
                        .dtim_period = vif->bss_conf.dtim_period,
                        .omac_idx = mvif->omac_idx,
                        .band_idx = mvif->band_idx,
                        .wmm_idx = mvif->wmm_idx,
-                       .active = enable,
+                       .active = true, /* keep bss deactivated */
                        .phymode = 0x38,
                },
        };
@@ -1458,9 +1488,6 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif,
        if (err < 0)
                return err;
 
-       if (!mt7615_firmware_offload(dev))
-               return 0;
-
        switch (chandef->width) {
        case NL80211_CHAN_WIDTH_40:
                rlm_req.rlm.bw = CMD_CBW_40MHZ;
index 338fd077f57584652b4cc1d09fd972c7e704d18d..348521b0d44cf7e9905f7b12d4d13a464cbae72f 100644 (file)
@@ -425,6 +425,32 @@ struct mt7615_mcu_bss_event {
        u8 pad;
 } __packed;
 
+struct mt7615_bss_basic_tlv {
+       __le16 tag;
+       __le16 len;
+       u8 active;
+       u8 omac_idx;
+       u8 hw_bss_idx;
+       u8 band_idx;
+       __le32 conn_type;
+       u8 conn_state;
+       u8 wmm_idx;
+       u8 bssid[ETH_ALEN];
+       __le16 bmc_tx_wlan_idx;
+       __le16 bcn_interval;
+       u8 dtim_period;
+       u8 phymode; /* bit(0): A
+                    * bit(1): B
+                    * bit(2): G
+                    * bit(3): GN
+                    * bit(4): AN
+                    * bit(5): AC
+                    */
+       __le16 sta_idx;
+       u8 nonht_basic_phy;
+       u8 pad[3];
+} __packed;
+
 struct mt7615_wow_ctrl_tlv {
        __le16 tag;
        __le16 len;