mt76: mt7615: introduce beacon_loss mcu event
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 1 May 2020 10:36:17 +0000 (12:36 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 12 May 2020 17:52:34 +0000 (19:52 +0200)
If device has enabled beacon hw filter rx beacons are not reported to
the host. Introduce beacon_loss mcu event to trigger mac80211 mlme
connection state machine in this configuration.
IEEE80211_VIF_BEACON_FILTER has not set in vif flags since hw beacon
filter is not enabled yet

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

index da50e12..6da819a 100644 (file)
@@ -360,6 +360,40 @@ mt7615_mcu_scan_event(struct mt7615_dev *dev, struct sk_buff *skb)
 }
 
 static void
+mt7615_mcu_beacon_loss_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
+{
+       struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
+       struct mt7615_beacon_loss_event *event = priv;
+
+       if (mvif->idx != event->bss_idx)
+               return;
+
+       if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER))
+               return;
+
+       ieee80211_beacon_loss(vif);
+}
+
+static void
+mt7615_mcu_beacon_loss_event(struct mt7615_dev *dev, struct sk_buff *skb)
+{
+       struct mt7615_beacon_loss_event *event;
+       struct mt76_phy *mphy;
+       u8 band_idx = 0; /* DBDC support */
+
+       skb_pull(skb, sizeof(struct mt7615_mcu_rxd));
+       event = (struct mt7615_beacon_loss_event *)skb->data;
+       if (band_idx && dev->mt76.phy2)
+               mphy = dev->mt76.phy2;
+       else
+               mphy = &dev->mt76.phy;
+
+       ieee80211_iterate_active_interfaces_atomic(mphy->hw,
+                                       IEEE80211_IFACE_ITER_RESUME_ALL,
+                                       mt7615_mcu_beacon_loss_iter, event);
+}
+
+static void
 mt7615_mcu_bss_event(struct mt7615_dev *dev, struct sk_buff *skb)
 {
        struct mt7615_mcu_bss_event *event;
@@ -389,6 +423,9 @@ mt7615_mcu_rx_unsolicited_event(struct mt7615_dev *dev, struct sk_buff *skb)
        case MCU_EVENT_EXT:
                mt7615_mcu_rx_ext_event(dev, skb);
                break;
+       case MCU_EVENT_BSS_BEACON_LOSS:
+               mt7615_mcu_beacon_loss_event(dev, skb);
+               break;
        case MCU_EVENT_SCHED_SCAN_DONE:
        case MCU_EVENT_SCAN_DONE:
                mt7615_mcu_scan_event(dev, skb);
@@ -410,6 +447,7 @@ void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb)
            rxd->ext_eid == MCU_EXT_EVENT_FW_LOG_2_HOST ||
            rxd->ext_eid == MCU_EXT_EVENT_ASSERT_DUMP ||
            rxd->ext_eid == MCU_EXT_EVENT_PS_SYNC ||
+           rxd->eid == MCU_EVENT_BSS_BEACON_LOSS ||
            rxd->eid == MCU_EVENT_SCHED_SCAN_DONE ||
            rxd->eid == MCU_EVENT_BSS_ABSENCE ||
            rxd->eid == MCU_EVENT_SCAN_DONE ||
index 890a202..737ccec 100644 (file)
@@ -83,6 +83,7 @@ enum {
        MCU_EVENT_MT_PATCH_SEM = 0x04,
        MCU_EVENT_SCAN_DONE = 0x0d,
        MCU_EVENT_BSS_ABSENCE  = 0x11,
+       MCU_EVENT_BSS_BEACON_LOSS = 0x13,
        MCU_EVENT_CH_PRIVILEGE = 0x18,
        MCU_EVENT_SCHED_SCAN_DONE = 0x23,
        MCU_EVENT_EXT = 0xed,
@@ -291,6 +292,12 @@ struct mt7615_mcu_uni_event {
        __le32 status; /* 0: success, others: fail */
 } __packed;
 
+struct mt7615_beacon_loss_event {
+       u8 bss_idx;
+       u8 reason;
+       u8 pad[2];
+} __packed;
+
 struct mt7615_mcu_scan_ssid {
        __le32 ssid_len;
        u8 ssid[IEEE80211_MAX_SSID_LEN];