Merge tag 'mt76-for-kvalo-2018-11-30' of https://github.com/nbd168/wireless
authorKalle Valo <kvalo@codeaurora.org>
Thu, 13 Dec 2018 14:02:19 +0000 (16:02 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 13 Dec 2018 14:02:19 +0000 (16:02 +0200)
first batch of mt76 patches for 4.21

* use the same firmware for mt76x2e and mt76x2u
* mt76x2 fixes
* mt76x0 fixes
* mt76x0e survey support
* more unification between mt76x2 and mt76x0
* mt76x0e AP mode support
* mt76x0e DFS support
* rework and fix tx status handling for mt76x0 and mt76x2

kvalo: fixed a conflict in drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
and a build problem in drivers/net/wireless/mediatek/mt76/mt76x02_util.c

1  2 
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_util.c
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c

@@@ -357,6 -425,51 +425,51 @@@ int mt76x02_conf_tx(struct ieee80211_h
  }
  EXPORT_SYMBOL_GPL(mt76x02_conf_tx);
  
 -      mutex_lock(&dev->mutex);
+ void mt76x02_set_tx_ackto(struct mt76x02_dev *dev)
+ {
+       u8 ackto, sifs, slottime = dev->slottime;
+       /* As defined by IEEE 802.11-2007 17.3.8.6 */
+       slottime += 3 * dev->coverage_class;
+       mt76_rmw_field(dev, MT_BKOFF_SLOT_CFG,
+                      MT_BKOFF_SLOT_CFG_SLOTTIME, slottime);
+       sifs = mt76_get_field(dev, MT_XIFS_TIME_CFG,
+                             MT_XIFS_TIME_CFG_OFDM_SIFS);
+       ackto = slottime + sifs;
+       mt76_rmw_field(dev, MT_TX_TIMEOUT_CFG,
+                      MT_TX_TIMEOUT_CFG_ACKTO, ackto);
+ }
+ EXPORT_SYMBOL_GPL(mt76x02_set_tx_ackto);
+ void mt76x02_set_coverage_class(struct ieee80211_hw *hw,
+                               s16 coverage_class)
+ {
+       struct mt76x02_dev *dev = hw->priv;
+       mutex_lock(&dev->mt76.mutex);
+       dev->coverage_class = coverage_class;
+       mt76x02_set_tx_ackto(dev);
+       mutex_unlock(&dev->mt76.mutex);
+ }
+ EXPORT_SYMBOL_GPL(mt76x02_set_coverage_class);
+ int mt76x02_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
+ {
+       struct mt76x02_dev *dev = hw->priv;
+       if (val != ~0 && val > 0xffff)
+               return -EINVAL;
 -      mutex_unlock(&dev->mutex);
++      mutex_lock(&dev->mt76.mutex);
+       mt76x02_mac_set_tx_protection(dev, val);
++      mutex_unlock(&dev->mt76.mutex);
+       return 0;
+ }
+ EXPORT_SYMBOL_GPL(mt76x02_set_rts_threshold);
  void mt76x02_sta_rate_tbl_update(struct ieee80211_hw *hw,
                                struct ieee80211_vif *vif,
                                struct ieee80211_sta *sta)
@@@ -475,42 -400,11 +400,13 @@@ int mt76x2_register_device(struct mt76x
        if (ret)
                return ret;
  
-       for (i = 0; i < ARRAY_SIZE(dev->macaddr_list); i++) {
-               u8 *addr = dev->macaddr_list[i].addr;
-               memcpy(addr, dev->mt76.macaddr, ETH_ALEN);
-               if (!i)
-                       continue;
-               addr[0] |= BIT(1);
-               addr[0] ^= ((i - 1) << 2);
-       }
-       wiphy->addresses = dev->macaddr_list;
-       wiphy->n_addresses = ARRAY_SIZE(dev->macaddr_list);
-       wiphy->iface_combinations = if_comb;
-       wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
-       wiphy->reg_notifier = mt76x2_regd_notifier;
-       wiphy->interface_modes =
-               BIT(NL80211_IFTYPE_STATION) |
-               BIT(NL80211_IFTYPE_AP) |
- #ifdef CONFIG_MAC80211_MESH
-               BIT(NL80211_IFTYPE_MESH_POINT) |
- #endif
-               BIT(NL80211_IFTYPE_ADHOC);
-       wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
-       mt76x2_dfs_init_detector(dev);
+       mt76x02_config_mac_addr_list(dev);
  
        /* init led callbacks */
 -      dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness;
 -      dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink;
 +      if (IS_ENABLED(CONFIG_MT76_LEDS)) {
 +              dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness;
 +              dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink;
 +      }
  
        ret = mt76_register_device(&dev->mt76, true, mt76x02_rates,
                                   ARRAY_SIZE(mt76x02_rates));