Commit 4cb23b65 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76x0: pci: enable AP support

Add missing mac80211 callbacks to mt76x0e_ops data structure
and add mt76x02_beacon utility routines in mt76x0_bss_info_changed
in order to enable/disable beacon transmission
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent fc245983
...@@ -75,23 +75,3 @@ void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot, ...@@ -75,23 +75,3 @@ void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot,
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
mt76_wr(dev, MT_CCK_PROT_CFG + i * 4, prot[i]); mt76_wr(dev, MT_CCK_PROT_CFG + i * 4, prot[i]);
} }
void mt76x0_mac_config_tsf(struct mt76x02_dev *dev, bool enable, int interval)
{
u32 val = mt76_rr(dev, MT_BEACON_TIME_CFG);
val &= ~(MT_BEACON_TIME_CFG_TIMER_EN |
MT_BEACON_TIME_CFG_SYNC_MODE |
MT_BEACON_TIME_CFG_TBTT_EN);
if (!enable) {
mt76_wr(dev, MT_BEACON_TIME_CFG, val);
return;
}
val &= ~MT_BEACON_TIME_CFG_INTVAL;
val |= FIELD_PREP(MT_BEACON_TIME_CFG_INTVAL, interval << 4) |
MT_BEACON_TIME_CFG_TIMER_EN |
MT_BEACON_TIME_CFG_SYNC_MODE |
MT_BEACON_TIME_CFG_TBTT_EN;
}
...@@ -72,30 +72,23 @@ int mt76x0_config(struct ieee80211_hw *hw, u32 changed) ...@@ -72,30 +72,23 @@ int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
} }
EXPORT_SYMBOL_GPL(mt76x0_config); EXPORT_SYMBOL_GPL(mt76x0_config);
static void
mt76x0_addr_wr(struct mt76x02_dev *dev, const u32 offset, const u8 *addr)
{
mt76_wr(dev, offset, get_unaligned_le32(addr));
mt76_wr(dev, offset + 4, addr[4] | addr[5] << 8);
}
void mt76x0_bss_info_changed(struct ieee80211_hw *hw, void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *info, u32 changed) struct ieee80211_bss_conf *info, u32 changed)
{ {
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
struct mt76x02_dev *dev = hw->priv; struct mt76x02_dev *dev = hw->priv;
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
if (changed & BSS_CHANGED_BSSID) { if (changed & BSS_CHANGED_BSSID)
mt76x0_addr_wr(dev, MT_MAC_BSSID_DW0, info->bssid); mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
/* Note: this is a hack because beacon_int is not changed if (changed & BSS_CHANGED_BEACON_ENABLED) {
* on leave nor is any more appropriate event generated. tasklet_disable(&dev->pre_tbtt_tasklet);
* rt2x00 doesn't seem to be bothered though. mt76x02_mac_set_beacon_enable(dev, mvif->idx,
*/ info->enable_beacon);
if (is_zero_ether_addr(info->bssid)) tasklet_enable(&dev->pre_tbtt_tasklet);
mt76x0_mac_config_tsf(dev, false, 0);
} }
if (changed & BSS_CHANGED_BASIC_RATES) { if (changed & BSS_CHANGED_BASIC_RATES) {
...@@ -106,8 +99,13 @@ void mt76x0_bss_info_changed(struct ieee80211_hw *hw, ...@@ -106,8 +99,13 @@ void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
mt76_wr(dev, MT_LG_FBK_CFG1, 0x00002100); mt76_wr(dev, MT_LG_FBK_CFG1, 0x00002100);
} }
if (changed & BSS_CHANGED_BEACON_INT) if (changed & BSS_CHANGED_BEACON_INT) {
mt76x0_mac_config_tsf(dev, true, info->beacon_int); mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
MT_BEACON_TIME_CFG_INTVAL,
info->beacon_int << 4);
dev->beacon_int = info->beacon_int;
dev->tbtt_count = 0;
}
if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT) if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
mt76x0_mac_set_protection(dev, info->use_cts_prot, mt76x0_mac_set_protection(dev, info->use_cts_prot,
......
...@@ -78,6 +78,4 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on); ...@@ -78,6 +78,4 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on);
/* MAC */ /* MAC */
void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot, void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot,
int ht_mode); int ht_mode);
void mt76x0_mac_config_tsf(struct mt76x02_dev *dev, bool enable, int interval);
#endif #endif
...@@ -68,6 +68,19 @@ static void mt76x0e_stop(struct ieee80211_hw *hw) ...@@ -68,6 +68,19 @@ static void mt76x0e_stop(struct ieee80211_hw *hw)
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
} }
static void
mt76x0e_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
u32 queues, bool drop)
{
}
static int
mt76x0e_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
bool set)
{
return 0;
}
static const struct ieee80211_ops mt76x0e_ops = { static const struct ieee80211_ops mt76x0e_ops = {
.tx = mt76x02_tx, .tx = mt76x02_tx,
.start = mt76x0e_start, .start = mt76x0e_start,
...@@ -76,6 +89,7 @@ static const struct ieee80211_ops mt76x0e_ops = { ...@@ -76,6 +89,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
.remove_interface = mt76x02_remove_interface, .remove_interface = mt76x02_remove_interface,
.config = mt76x0_config, .config = mt76x0_config,
.configure_filter = mt76x02_configure_filter, .configure_filter = mt76x02_configure_filter,
.bss_info_changed = mt76x0_bss_info_changed,
.sta_add = mt76x02_sta_add, .sta_add = mt76x02_sta_add,
.sta_remove = mt76x02_sta_remove, .sta_remove = mt76x02_sta_remove,
.set_key = mt76x02_set_key, .set_key = mt76x02_set_key,
...@@ -87,6 +101,9 @@ static const struct ieee80211_ops mt76x0e_ops = { ...@@ -87,6 +101,9 @@ static const struct ieee80211_ops mt76x0e_ops = {
.wake_tx_queue = mt76_wake_tx_queue, .wake_tx_queue = mt76_wake_tx_queue,
.get_survey = mt76_get_survey, .get_survey = mt76_get_survey,
.get_txpower = mt76x02_get_txpower, .get_txpower = mt76x02_get_txpower,
.flush = mt76x0e_flush,
.set_tim = mt76x0e_set_tim,
.release_buffered_frames = mt76_release_buffered_frames,
}; };
static int mt76x0e_register_device(struct mt76x02_dev *dev) static int mt76x0e_register_device(struct mt76x02_dev *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment