mt76: enable TDLS support
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 22 Apr 2020 16:29:32 +0000 (18:29 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 12 May 2020 17:52:33 +0000 (19:52 +0200)
Enable mac80211 TDLS support by default. Disable TDLS hw filtering for
mt7615 devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/mediatek/mt76/mt7615/init.c
drivers/net/wireless/mediatek/mt76/mt7615/main.c
drivers/net/wireless/mediatek/mt76/mt7615/mmio.c
drivers/net/wireless/mediatek/mt76/mt7615/regs.h
drivers/net/wireless/mediatek/mt76/mt7615/usb.c

index b6c0a6d0dfc1f3cb2f375f463ca5e0344c5aece8..176c22a5319a5199f048a169597125100650b35c 100644 (file)
@@ -278,7 +278,8 @@ mt76_phy_init(struct mt76_dev *dev, struct ieee80211_hw *hw)
        SET_IEEE80211_PERM_ADDR(hw, dev->macaddr);
 
        wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
-       wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
+       wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH |
+                       WIPHY_FLAG_SUPPORTS_TDLS;
 
        wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
        wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_AIRTIME_FAIRNESS);
index 6fc3f5aa94c0992332e365453a722049ee5c9c08..9880643888ba21b7e54da7fc02394ce0b868331a 100644 (file)
@@ -63,6 +63,7 @@ mt7615_init_mac_chain(struct mt7615_dev *dev, int chain)
                FIELD_PREP(MT_AGG_ARxCR_LIMIT(6), MT7615_RATE_RETRY - 1) |
                FIELD_PREP(MT_AGG_ARxCR_LIMIT(7), MT7615_RATE_RETRY - 1));
 
+       mt76_clear(dev, MT_DMA_RCFR0(chain), MT_DMA_RCFR0_MCU_RX_TDLS);
        if (!mt7615_firmware_offload(dev)) {
                u32 mask, set;
 
@@ -117,6 +118,8 @@ void mt7615_mac_init(struct mt7615_dev *dev)
        mt76_wr(dev, MT_DMA_DCR0,
                FIELD_PREP(MT_DMA_DCR0_MAX_RX_LEN, 3072) |
                MT_DMA_DCR0_RX_VEC_DROP);
+       /* disable TDLS filtering */
+       mt76_clear(dev, MT_WF_PFCR, MT_WF_PFCR_TDLS_EN);
        mt76_set(dev, MT_WF_MIB_SCR0, MT_MIB_SCR0_AGG_CNT_RANGE_EN);
        if (is_mt7663(&dev->mt76)) {
                mt76_wr(dev, MT_WF_AGG(0x160), 0x5c341c02);
index 3c35b8d0489c158f980578b0671d61a66e21d2c8..4e1d162b2664e9bab58de6cd7d4b65c49f59b9b5 100644 (file)
@@ -542,7 +542,7 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
        msta->wcid.idx = idx;
        msta->wcid.ext_phy = mvif->band_idx;
 
-       if (vif->type == NL80211_IFTYPE_STATION) {
+       if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
                struct mt7615_phy *phy;
 
                phy = mvif->band_idx ? mt7615_ext_phy(dev) : &dev->phy;
@@ -565,7 +565,7 @@ void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
        mt7615_mcu_sta_add(dev, vif, sta, false);
        mt7615_mac_wtbl_update(dev, msta->wcid.idx,
                               MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
-       if (vif->type == NL80211_IFTYPE_STATION) {
+       if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
                struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
                struct mt7615_phy *phy;
 
index 2c4b1a315d5b37fdfb673aec78a408bc3a304d30..c9f5b1ce70aeb2648baefc12e26dc3116338e8f7 100644 (file)
@@ -21,6 +21,7 @@ const u32 mt7615e_reg_map[] = {
        [MT_TMAC_BASE]          = 0x21000,
        [MT_RMAC_BASE]          = 0x21200,
        [MT_DMA_BASE]           = 0x21800,
+       [MT_PF_BASE]            = 0x22000,
        [MT_WTBL_BASE_ON]       = 0x23000,
        [MT_WTBL_BASE_OFF]      = 0x23400,
        [MT_LPON_BASE]          = 0x24200,
@@ -45,6 +46,7 @@ const u32 mt7663e_reg_map[] = {
        [MT_TMAC_BASE]          = 0x24000,
        [MT_RMAC_BASE]          = 0x25000,
        [MT_DMA_BASE]           = 0x27000,
+       [MT_PF_BASE]            = 0x28000,
        [MT_WTBL_BASE_ON]       = 0x29000,
        [MT_WTBL_BASE_OFF]      = 0x29800,
        [MT_LPON_BASE]          = 0x2b000,
index 054831ecad68d0c8ad351b8412ecd0142ebe61f3..68d30bcc087a6406b6db2341288507939a6ae4b9 100644 (file)
@@ -18,6 +18,7 @@ enum mt7615_reg_base {
        MT_TMAC_BASE,
        MT_RMAC_BASE,
        MT_DMA_BASE,
+       MT_PF_BASE,
        MT_WTBL_BASE_ON,
        MT_WTBL_BASE_OFF,
        MT_LPON_BASE,
@@ -321,10 +322,17 @@ enum mt7615_reg_base {
 #define MT_DMA_RCFR0_MCU_RX_MGMT       BIT(2)
 #define MT_DMA_RCFR0_MCU_RX_CTL_NON_BAR        BIT(3)
 #define MT_DMA_RCFR0_MCU_RX_CTL_BAR    BIT(4)
+#define MT_DMA_RCFR0_MCU_RX_TDLS       BIT(19)
 #define MT_DMA_RCFR0_MCU_RX_BYPASS     BIT(21)
 #define MT_DMA_RCFR0_RX_DROPPED_UCAST  GENMASK(25, 24)
 #define MT_DMA_RCFR0_RX_DROPPED_MCAST  GENMASK(27, 26)
 
+#define MT_WF_PF_BASE                  ((dev)->reg_map[MT_PF_BASE])
+#define MT_WF_PF(ofs)                  (MT_WF_PF_BASE + (ofs))
+
+#define MT_WF_PFCR                     MT_WF_PF(0x000)
+#define MT_WF_PFCR_TDLS_EN             BIT(9)
+
 #define MT_WTBL_BASE(dev)              ((dev)->reg_map[MT_WTBL_BASE_ADDR])
 #define MT_WTBL_ENTRY_SIZE             256
 
index eee6f820959f4bd96eda6fcb539eacc4a901d778..bcd131969923e5415b10d1c06db1494bea40b48f 100644 (file)
@@ -31,6 +31,7 @@ static const u32 mt7663u_reg_map[] = {
        [MT_TMAC_BASE]          = 0x820f4000,
        [MT_RMAC_BASE]          = 0x820f5000,
        [MT_DMA_BASE]           = 0x820f7000,
+       [MT_PF_BASE]            = 0x820f8000,
        [MT_WTBL_BASE_ON]       = 0x820f9000,
        [MT_WTBL_BASE_OFF]      = 0x820f9800,
        [MT_LPON_BASE]          = 0x820fb000,