On 11/16/19 12:45 PM, Lorenzo Bianconi wrote: >> This patch enables channel switch support on mt76 usb interfaces. >> > Hi Markus, > > I was thinking about it, but since usb does not support DFS what is the purpose > of CSA in this case? > > Regards, > Lorenzo Hi Lorenzo, for research purposes I'm currently trying out some dynamic channel allocation strategies with multiple indoor APs. I use a dedicated interface to perform surveys and monitoring the environment. These survey results are then correlated between different with traffic patterns to find out interferers. Afterwards I let the AP interfaces change their channel to a less congested one if necessary and notice the STAs via CSAs. I use mt76 based USB devices for my tests as they are quite versatile and useful for debugging with a notebook (I can just attach multiple ones). Therefore I thought, having the possibility to dynamically switch channels on this devices would maybe useful to other researchers and submitted my patches. Regards, Markus >> Signed-off-by: Markus Theil <markus.theil@xxxxxxxxxxxxx> >> --- >> drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | 7 +++++++ >> drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 2 +- >> drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c | 5 +++++ >> 3 files changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c >> index aedab4cc8d40..32e6c37aa80d 100644 >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c >> @@ -179,6 +179,12 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work) >> >> mt76x02_resync_beacon_timer(dev); >> >> + mt76_csa_check(&dev->mt76); >> + if (dev->mt76.csa_complete) { >> + mt76_csa_finish(&dev->mt76); >> + goto out; >> + } >> + >> mt76x02_mac_set_beacon_prepare(dev); >> >> ieee80211_iterate_active_interfaces(mt76_hw(dev), >> @@ -195,6 +201,7 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work) >> >> mt76x02_mac_set_beacon_finish(dev); >> >> +out: >> mt76x02u_restart_pre_tbtt_timer(dev); >> } >> >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c >> index 414b22399d93..3f95e5b24e1d 100644 >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c >> @@ -174,7 +174,6 @@ void mt76x02_init_device(struct mt76x02_dev *dev) >> wiphy->reg_notifier = mt76x02_regd_notifier; >> wiphy->iface_combinations = mt76x02_if_comb; >> wiphy->n_iface_combinations = ARRAY_SIZE(mt76x02_if_comb); >> - wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; >> >> /* init led callbacks */ >> if (IS_ENABLED(CONFIG_MT76_LEDS)) { >> @@ -184,6 +183,7 @@ void mt76x02_init_device(struct mt76x02_dev *dev) >> } >> } >> >> + wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; >> wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS); >> >> hw->sta_data_size = sizeof(struct mt76x02_sta); >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c >> index eb73cb856c81..2f2c39a6a9e6 100644 >> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c >> @@ -100,6 +100,10 @@ mt76x2u_config(struct ieee80211_hw *hw, u32 changed) >> return err; >> } >> >> +void mt76x2u_channel_switch_beacon(struct ieee80211_hw *hw, >> + struct ieee80211_vif *vif, >> + struct cfg80211_chan_def *chandef) {} >> + >> const struct ieee80211_ops mt76x2u_ops = { >> .tx = mt76x02_tx, >> .start = mt76x2u_start, >> @@ -121,4 +125,5 @@ const struct ieee80211_ops mt76x2u_ops = { >> .get_survey = mt76_get_survey, >> .set_tim = mt76_set_tim, >> .release_buffered_frames = mt76_release_buffered_frames, >> + .channel_switch_beacon = mt76x2u_channel_switch_beacon, >> }; >> -- >> 2.24.0 >> -- Markus Theil Technische Universität Ilmenau, Fachgebiet Telematik/Rechnernetze Postfach 100565 98684 Ilmenau, Germany Phone: +49 3677 69-4582 Email: markus[dot]theil[at]tu-ilmenau[dot]de Web: http://www.tu-ilmenau.de/telematik