2013-11-03 20:57:39 +01:00
|
|
|
# Test cases for DFS
|
2019-01-06 11:28:11 +01:00
|
|
|
# Copyright (c) 2013-2019, Jouni Malinen <j@w1.fi>
|
2013-11-03 20:57:39 +01:00
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
from remotehost import remote_compatible
|
2013-11-03 20:57:39 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger()
|
|
|
|
|
|
|
|
import hwsim_utils
|
|
|
|
import hostapd
|
2019-01-06 11:28:11 +01:00
|
|
|
from utils import *
|
2013-11-03 20:57:39 +01:00
|
|
|
|
|
|
|
def wait_dfs_event(hapd, event, timeout):
|
2019-03-15 11:10:37 +01:00
|
|
|
dfs_events = ["DFS-RADAR-DETECTED", "DFS-NEW-CHANNEL",
|
|
|
|
"DFS-CAC-START", "DFS-CAC-COMPLETED",
|
|
|
|
"DFS-NOP-FINISHED", "AP-ENABLED", "AP-CSA-FINISHED"]
|
2013-11-03 20:57:39 +01:00
|
|
|
ev = hapd.wait_event(dfs_events, timeout=timeout)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("DFS event timed out")
|
2014-10-09 00:59:52 +02:00
|
|
|
if event and event not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev + " (expected: %s)" % event)
|
2013-11-03 20:57:39 +01:00
|
|
|
return ev
|
|
|
|
|
2020-01-03 14:41:54 +01:00
|
|
|
def start_dfs_ap(ap, ssid="dfs", ht=True, ht40=False,
|
2016-03-27 19:30:40 +02:00
|
|
|
ht40minus=False, vht80=False, vht20=False, chanlist=None,
|
2020-03-03 17:36:10 +01:00
|
|
|
channel=None, country="FI", rrm_beacon_report=False,
|
|
|
|
chan100=False):
|
2013-11-03 20:57:39 +01:00
|
|
|
ifname = ap['ifname']
|
|
|
|
logger.info("Starting AP " + ifname + " on DFS channel")
|
2016-04-07 07:38:05 +02:00
|
|
|
hapd = hostapd.add_ap(ap, {}, no_enable=True)
|
2014-10-25 09:52:06 +02:00
|
|
|
hapd.set("ssid", ssid)
|
2017-05-13 19:01:06 +02:00
|
|
|
hapd.set("country_code", country)
|
2013-11-03 20:57:39 +01:00
|
|
|
hapd.set("ieee80211d", "1")
|
|
|
|
hapd.set("ieee80211h", "1")
|
|
|
|
hapd.set("hw_mode", "a")
|
2020-03-03 17:36:10 +01:00
|
|
|
if chan100:
|
|
|
|
hapd.set("channel", "100")
|
|
|
|
else:
|
|
|
|
hapd.set("channel", "52")
|
2014-12-20 12:50:19 +01:00
|
|
|
if not ht:
|
|
|
|
hapd.set("ieee80211n", "0")
|
2014-10-25 09:52:06 +02:00
|
|
|
if ht40:
|
|
|
|
hapd.set("ht_capab", "[HT40+]")
|
2014-12-20 12:50:19 +01:00
|
|
|
elif ht40minus:
|
|
|
|
hapd.set("ht_capab", "[HT40-]")
|
|
|
|
hapd.set("channel", "56")
|
2014-11-01 18:42:49 +01:00
|
|
|
if vht80:
|
|
|
|
hapd.set("ieee80211ac", "1")
|
|
|
|
hapd.set("vht_oper_chwidth", "1")
|
2020-03-03 17:36:10 +01:00
|
|
|
if chan100:
|
|
|
|
hapd.set("vht_oper_centr_freq_seg0_idx", "106")
|
|
|
|
else:
|
|
|
|
hapd.set("vht_oper_centr_freq_seg0_idx", "58")
|
2014-11-01 18:42:49 +01:00
|
|
|
if vht20:
|
|
|
|
hapd.set("ieee80211ac", "1")
|
|
|
|
hapd.set("vht_oper_chwidth", "0")
|
|
|
|
hapd.set("vht_oper_centr_freq_seg0_idx", "0")
|
|
|
|
if chanlist:
|
|
|
|
hapd.set("chanlist", chanlist)
|
2016-03-27 19:30:40 +02:00
|
|
|
if channel:
|
|
|
|
hapd.set("channel", str(channel))
|
2020-01-03 14:53:03 +01:00
|
|
|
if rrm_beacon_report:
|
|
|
|
hapd.set("rrm_beacon_report", "1")
|
2013-11-03 20:57:39 +01:00
|
|
|
hapd.enable()
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if "DFS-CAC-START" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2013-11-03 20:57:39 +01:00
|
|
|
|
|
|
|
state = hapd.get_status_field("state")
|
|
|
|
if state != "DFS":
|
2014-03-22 16:14:44 +01:00
|
|
|
raise Exception("Unexpected interface state: " + state)
|
2013-11-03 20:57:39 +01:00
|
|
|
|
|
|
|
return hapd
|
|
|
|
|
2014-10-25 09:52:06 +02:00
|
|
|
def dfs_simulate_radar(hapd):
|
|
|
|
logger.info("Trigger a simulated radar event")
|
|
|
|
phyname = hapd.get_driver_status_field("phyname")
|
|
|
|
radar_file = '/sys/kernel/debug/ieee80211/' + phyname + '/hwsim/dfs_simulate_radar'
|
|
|
|
with open(radar_file, 'w') as f:
|
|
|
|
f.write('1')
|
|
|
|
|
2013-11-03 20:57:39 +01:00
|
|
|
def test_dfs(dev, apdev):
|
|
|
|
"""DFS CAC functionality on clear channel"""
|
2014-03-22 16:14:44 +01:00
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], country="US")
|
2014-03-22 16:14:44 +01:00
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
state = hapd.get_status_field("state")
|
|
|
|
if state != "ENABLED":
|
|
|
|
raise Exception("Unexpected interface state")
|
|
|
|
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5260":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
2023-11-24 21:25:18 +01:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", timeout=30)
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-10-09 00:23:21 +02:00
|
|
|
|
|
|
|
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
|
|
|
|
ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("DFS-RADAR-DETECTED event not reported")
|
|
|
|
if "freq=5260" not in ev:
|
2016-07-03 18:37:50 +02:00
|
|
|
raise Exception("Incorrect frequency in radar detected event: " + ev)
|
2014-10-09 00:23:21 +02:00
|
|
|
ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=70)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("DFS-NEW-CHANNEL event not reported")
|
|
|
|
if "freq=5260" in ev:
|
2016-07-03 18:37:50 +02:00
|
|
|
raise Exception("Channel did not change after radar was detected")
|
2014-10-09 00:23:21 +02:00
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=70)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("AP-CSA-FINISHED event not reported")
|
|
|
|
if "freq=5260" in ev:
|
2016-07-03 18:37:50 +02:00
|
|
|
raise Exception("Channel did not change after radar was detected(2)")
|
2014-10-09 00:23:21 +02:00
|
|
|
time.sleep(1)
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2017-05-13 19:01:06 +02:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2017-05-13 19:01:06 +02:00
|
|
|
|
2020-04-18 10:00:49 +02:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_etsi(dev, apdev):
|
|
|
|
"""DFS and uniform spreading requirement for ETSI"""
|
2017-05-13 19:01:06 +02:00
|
|
|
try:
|
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0])
|
2017-05-13 19:01:06 +02:00
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
state = hapd.get_status_field("state")
|
|
|
|
if state != "ENABLED":
|
|
|
|
raise Exception("Unexpected interface state")
|
|
|
|
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5260":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
2024-01-26 11:00:24 +01:00
|
|
|
hapd.dump_monitor()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
|
2017-05-13 19:01:06 +02:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2024-01-26 11:00:24 +01:00
|
|
|
time.sleep(1)
|
2017-05-13 19:01:06 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
2024-01-26 11:00:24 +01:00
|
|
|
hapd.dump_monitor()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
|
2017-05-13 19:01:06 +02:00
|
|
|
hapd.request("RADAR DETECTED freq=%s ht_enabled=1 chan_width=1" % freq)
|
|
|
|
ev = hapd.wait_event(["DFS-RADAR-DETECTED"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("DFS-RADAR-DETECTED event not reported")
|
|
|
|
if "freq=%s" % freq not in ev:
|
|
|
|
raise Exception("Incorrect frequency in radar detected event: " + ev)
|
|
|
|
ev = hapd.wait_event(["DFS-NEW-CHANNEL"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("DFS-NEW-CHANNEL event not reported")
|
|
|
|
if "freq=%s" % freq in ev:
|
|
|
|
raise Exception("Channel did not change after radar was detected")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-CSA-FINISHED", "DFS-CAC-START"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("AP-CSA-FINISHED or DFS-CAC-START event not reported")
|
|
|
|
if "DFS-CAC-START" in ev:
|
|
|
|
# The selected new channel requires CAC
|
2024-01-26 11:00:24 +01:00
|
|
|
dev[0].wait_disconnected()
|
2017-05-13 19:01:06 +02:00
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=30)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("STA did not reconnect on new DFS channel")
|
2024-01-26 11:00:24 +01:00
|
|
|
dev[0].wait_connected()
|
2017-05-13 19:01:06 +02:00
|
|
|
else:
|
|
|
|
# The new channel did not require CAC - try again
|
|
|
|
if "freq=%s" % freq in ev:
|
|
|
|
raise Exception("Channel did not change after radar was detected(2)")
|
2024-01-26 11:00:24 +01:00
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Channel switch not reported on STA")
|
2017-05-13 19:01:06 +02:00
|
|
|
time.sleep(1)
|
2024-01-26 11:00:24 +01:00
|
|
|
|
|
|
|
hapd.dump_monitor()
|
|
|
|
dev[0].dump_monitor()
|
|
|
|
time.sleep(1)
|
2017-05-13 19:01:06 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-03-22 16:14:44 +01:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2013-11-03 20:57:39 +01:00
|
|
|
|
2017-11-26 11:57:27 +01:00
|
|
|
def test_dfs_radar1(dev, apdev):
|
|
|
|
"""DFS CAC functionality with radar detected during initial CAC"""
|
2014-03-22 16:14:44 +01:00
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0])
|
2014-10-09 00:59:52 +02:00
|
|
|
time.sleep(1)
|
2013-11-03 20:57:39 +01:00
|
|
|
|
2014-10-25 09:52:06 +02:00
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
2014-10-09 00:59:52 +02:00
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
2014-03-22 16:14:44 +01:00
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq")
|
2013-11-03 20:57:39 +01:00
|
|
|
|
2014-03-22 16:14:44 +01:00
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5260" in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq")
|
2013-11-03 20:57:39 +01:00
|
|
|
|
2014-10-09 00:59:52 +02:00
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" in ev:
|
|
|
|
logger.info("Started AP on non-DFS channel")
|
|
|
|
else:
|
|
|
|
logger.info("Trying to start AP on another DFS channel")
|
|
|
|
if "DFS-CAC-START" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2014-10-09 00:59:52 +02:00
|
|
|
if "freq=5260" in ev:
|
|
|
|
raise Exception("Unexpected DFS CAC freq")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5260" in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result - radar channel")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
state = hapd.get_status_field("state")
|
|
|
|
if state != "ENABLED":
|
|
|
|
raise Exception("Unexpected interface state")
|
|
|
|
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq == "5260":
|
|
|
|
raise Exception("Unexpected frequency: " + freq)
|
2013-11-03 20:57:39 +01:00
|
|
|
|
2014-10-08 17:27:12 +02:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2017-11-26 11:57:27 +01:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2014-10-25 09:52:06 +02:00
|
|
|
|
2017-11-26 11:57:27 +01:00
|
|
|
def test_dfs_radar2(dev, apdev):
|
|
|
|
"""DFS CAC functionality with radar detected after initial CAC"""
|
|
|
|
try:
|
|
|
|
hapd = None
|
|
|
|
hapd = start_dfs_ap(apdev[0], ssid="dfs2", ht40=True)
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=70)
|
2014-10-25 09:52:06 +02:00
|
|
|
if not ev:
|
|
|
|
raise Exception("AP2 setup timed out")
|
|
|
|
|
2017-11-26 11:57:27 +01:00
|
|
|
dfs_simulate_radar(hapd)
|
2014-10-25 09:52:06 +02:00
|
|
|
|
2017-11-26 11:57:27 +01:00
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
2014-10-25 09:52:06 +02:00
|
|
|
if "freq=5260 ht_enabled=1 chan_offset=1 chan_width=2" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq from AP2")
|
|
|
|
|
2017-11-26 11:57:27 +01:00
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
2014-10-25 09:52:06 +02:00
|
|
|
if "freq=5260" in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq for AP2")
|
|
|
|
|
2017-11-26 11:57:27 +01:00
|
|
|
wait_dfs_event(hapd, None, 5)
|
2014-03-22 16:14:44 +01:00
|
|
|
finally:
|
2019-06-06 07:27:37 +02:00
|
|
|
clear_regdom(hapd, dev)
|
2013-11-03 20:57:39 +01:00
|
|
|
|
2016-06-23 19:16:36 +02:00
|
|
|
@remote_compatible
|
2014-03-22 16:14:44 +01:00
|
|
|
def test_dfs_radar_on_non_dfs_channel(dev, apdev):
|
|
|
|
"""DFS radar detection test code on non-DFS channel"""
|
2019-03-15 11:10:37 +01:00
|
|
|
params = {"ssid": "radar"}
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-22 16:14:44 +01:00
|
|
|
|
|
|
|
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
|
|
|
|
hapd.request("RADAR DETECTED freq=2412 ht_enabled=1 chan_width=1")
|
2014-11-01 18:42:49 +01:00
|
|
|
|
|
|
|
def test_dfs_radar_chanlist(dev, apdev):
|
|
|
|
"""DFS chanlist when radar is detected"""
|
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="40 44")
|
2014-11-01 18:42:49 +01:00
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5200 chan=40" not in ev and "freq=5220 chan=44" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2014-11-01 18:42:49 +01:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2014-11-01 18:42:49 +01:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2014-11-01 18:42:49 +01:00
|
|
|
|
|
|
|
def test_dfs_radar_chanlist_vht80(dev, apdev):
|
|
|
|
"""DFS chanlist when radar is detected and VHT80 configured"""
|
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="36", ht40=True, vht80=True)
|
2014-11-01 18:42:49 +01:00
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5180 chan=36 sec_chan=1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2014-11-01 18:42:49 +01:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2014-11-01 18:42:49 +01:00
|
|
|
|
|
|
|
if hapd.get_status_field('vht_oper_centr_freq_seg0_idx') != "42":
|
|
|
|
raise Exception("Unexpected seg0 idx")
|
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2014-11-01 18:42:49 +01:00
|
|
|
|
|
|
|
def test_dfs_radar_chanlist_vht20(dev, apdev):
|
|
|
|
"""DFS chanlist when radar is detected and VHT40 configured"""
|
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="36", vht20=True)
|
2014-11-01 18:42:49 +01:00
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5180 chan=36 sec_chan=0" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2014-11-01 18:42:49 +01:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2014-11-01 18:42:49 +01:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2014-12-20 12:50:19 +01:00
|
|
|
|
|
|
|
def test_dfs_radar_no_ht(dev, apdev):
|
|
|
|
"""DFS chanlist when radar is detected and no HT configured"""
|
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="36", ht=False)
|
2014-12-20 12:50:19 +01:00
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5260 ht_enabled=0" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5180 chan=36 sec_chan=0" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2014-12-20 12:50:19 +01:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2014-12-20 12:50:19 +01:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2014-12-20 12:50:19 +01:00
|
|
|
|
|
|
|
def test_dfs_radar_ht40minus(dev, apdev):
|
|
|
|
"""DFS chanlist when radar is detected and HT40- configured"""
|
|
|
|
try:
|
2015-01-17 12:04:11 +01:00
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="36", ht40minus=True)
|
2014-12-20 12:50:19 +01:00
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5280 ht_enabled=1 chan_offset=-1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5280 ht_enabled=1 chan_offset=-1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5180 chan=36 sec_chan=1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" not in ev:
|
2017-03-31 12:13:12 +02:00
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
2014-12-20 12:50:19 +01:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
|
|
|
dev[0].request("STA_AUTOCONNECT 0")
|
2014-12-20 12:50:19 +01:00
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].request("STA_AUTOCONNECT 1")
|
2016-03-27 19:30:40 +02:00
|
|
|
|
2020-04-18 10:00:49 +02:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_ht40_minus(dev, apdev):
|
|
|
|
"""DFS CAC functionality on channel 104 HT40-"""
|
2016-03-27 19:30:40 +02:00
|
|
|
try:
|
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0], ht40minus=True, channel=104)
|
2016-03-27 19:30:40 +02:00
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5520" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
state = hapd.get_status_field("state")
|
|
|
|
if state != "ENABLED":
|
|
|
|
raise Exception("Unexpected interface state")
|
|
|
|
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5520":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520")
|
2018-12-22 14:55:19 +01:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
2016-03-27 19:30:40 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
finally:
|
2019-01-06 11:28:11 +01:00
|
|
|
clear_regdom(hapd, dev)
|
2019-01-07 23:36:07 +01:00
|
|
|
|
|
|
|
def test_dfs_cac_restart_on_enable(dev, apdev):
|
|
|
|
"""DFS CAC interrupted and restarted"""
|
|
|
|
try:
|
|
|
|
hapd = None
|
2020-01-03 14:41:54 +01:00
|
|
|
hapd = start_dfs_ap(apdev[0])
|
2019-01-07 23:36:07 +01:00
|
|
|
time.sleep(0.1)
|
|
|
|
subprocess.check_call(['ip', 'link', 'set', 'dev', hapd.ifname, 'down'])
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
time.sleep(0.1)
|
|
|
|
subprocess.check_call(['ip', 'link', 'set', 'dev', hapd.ifname, 'up'])
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if "DFS-CAC-START" not in ev:
|
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
|
|
|
hapd.disable()
|
|
|
|
|
|
|
|
finally:
|
2019-05-30 10:05:53 +02:00
|
|
|
clear_regdom(hapd, dev)
|
2020-01-03 14:53:03 +01:00
|
|
|
|
2020-04-18 10:00:49 +02:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_rrm(dev, apdev):
|
|
|
|
"""DFS with RRM"""
|
2020-01-03 14:53:03 +01:00
|
|
|
try:
|
|
|
|
hapd = None
|
|
|
|
hapd = start_dfs_ap(apdev[0], country="US", rrm_beacon_report=True)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev or "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5260")
|
|
|
|
dev[0].wait_regdom(country_ie=True)
|
|
|
|
hapd.wait_sta()
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
addr = dev[0].own_addr()
|
|
|
|
token = hapd.request("REQ_BEACON " + addr + " " + "51000000000002ffffffffffff")
|
|
|
|
if "FAIL" in token:
|
|
|
|
raise Exception("REQ_BEACON failed")
|
|
|
|
ev = hapd.wait_event(["BEACON-RESP-RX"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Beacon report response not received")
|
|
|
|
finally:
|
|
|
|
clear_regdom(hapd, dev)
|
2020-03-03 17:36:10 +01:00
|
|
|
|
2020-04-18 10:00:49 +02:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_radar_vht80_downgrade(dev, apdev):
|
|
|
|
"""DFS channel bandwidth downgrade from VHT80 to VHT40"""
|
2020-03-03 17:36:10 +01:00
|
|
|
try:
|
|
|
|
# Start with 80 MHz channel 100 (5500 MHz) to find a radar
|
|
|
|
hapd = None
|
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="100-140",
|
|
|
|
ht40=True, vht80=True, chan100=True)
|
|
|
|
time.sleep(1)
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event")
|
|
|
|
if "success=0 freq=5500" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5500" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq: " + ev)
|
|
|
|
|
|
|
|
# The only other available 80 MHz channel in the chanlist is
|
|
|
|
# 116 (5580 MHz), so that will be selected next.
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5580 chan=116 sec_chan=1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "DFS-CAC-START" not in ev:
|
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
|
|
|
if "freq=5580" not in ev:
|
|
|
|
raise Exception("Unexpected DFS CAC freq: " + ev)
|
|
|
|
|
|
|
|
time.sleep(1)
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Timeout on DFS aborted event (2)")
|
|
|
|
if "success=0 freq=5580" not in ev:
|
|
|
|
raise Exception("Unexpected DFS aborted event (2) contents: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5580" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection (2) freq: " + ev)
|
|
|
|
|
|
|
|
# No more 80 MHz channels are available, so have to downgrade to 40 MHz
|
|
|
|
# channels and the only remaining one is channel 132 (5660 MHz).
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5660 chan=132 sec_chan=1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq (2): " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "DFS-CAC-START" not in ev:
|
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
|
|
|
if "freq=5660" not in ev:
|
|
|
|
raise Exception("Unexpected DFS CAC freq (2): " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5660" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result: " + ev)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, None, 5)
|
|
|
|
if "AP-ENABLED" not in ev:
|
|
|
|
raise Exception("Unexpected DFS event: " + ev)
|
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5660")
|
|
|
|
dev[0].wait_regdom(country_ie=True)
|
|
|
|
sig = dev[0].request("SIGNAL_POLL").splitlines()
|
|
|
|
if "FREQUENCY=5660" not in sig or "WIDTH=40 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected SIGNAL_POLL value: " + str(sig))
|
|
|
|
finally:
|
|
|
|
clear_regdom(hapd, dev)
|
2020-03-29 19:49:27 +02:00
|
|
|
|
2020-04-18 10:00:49 +02:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_chan_switch(dev, apdev):
|
|
|
|
"""DFS channel switch"""
|
2020-03-29 19:49:27 +02:00
|
|
|
try:
|
|
|
|
hapd = None
|
|
|
|
hapd = start_dfs_ap(apdev[0], country="US")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5260":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
2024-04-27 00:11:18 +02:00
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5260 5280 5180 5500")
|
2020-03-29 19:49:27 +02:00
|
|
|
dev[0].wait_regdom(country_ie=True)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
if "OK" not in hapd.request("CHAN_SWITCH 5 5280 ht"):
|
|
|
|
raise Exception("CHAN_SWITCH failed")
|
|
|
|
# This results in BSS going down before restart, so the STA is expected
|
|
|
|
# to report disconnection.
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if "freq=5280" not in ev:
|
|
|
|
raise Exception("Unexpected channel: " + ev)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5280" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5280":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
dev[0].wait_connected(timeout=30)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2024-04-27 00:11:18 +02:00
|
|
|
|
|
|
|
# Move to non DFS channel: 36, opclass 115
|
|
|
|
if "OK" not in hapd.request("CHAN_SWITCH 5 5180"):
|
|
|
|
raise Exception("CHAN_SWITCH failed")
|
|
|
|
ev = wait_dfs_event(hapd, "AP-CSA-FINISHED", 5)
|
|
|
|
|
|
|
|
if "freq=5180" not in ev:
|
|
|
|
raise Exception("Unexpected channel: " + ev)
|
|
|
|
time.sleep(1)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
# Move to channel 100, opclass 121
|
|
|
|
if "OK" not in hapd.request("CHAN_SWITCH 5 5500 ht"):
|
|
|
|
raise Exception("CHAN_SWITCH failed")
|
|
|
|
# This results in BSS going down before restart, so the STA is expected
|
|
|
|
# to report disconnection.
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if "freq=5500" not in ev:
|
|
|
|
raise Exception("Unexpected channel: " + ev)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5500" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5500":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
dev[0].wait_connected(timeout=30)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2020-03-29 19:49:27 +02:00
|
|
|
finally:
|
|
|
|
clear_regdom(hapd, dev)
|
2020-12-02 15:47:28 +01:00
|
|
|
|
2023-12-10 19:57:05 +01:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_chan_switch_to_vht80(dev, apdev):
|
|
|
|
"""DFS channel switch to VHT80"""
|
|
|
|
run_dfs_chan_switch_to_vht(dev, apdev, vht80=True)
|
|
|
|
|
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_chan_switch_to_vht80p80(dev, apdev):
|
|
|
|
"""DFS channel switch to VHT80+80"""
|
|
|
|
run_dfs_chan_switch_to_vht(dev, apdev, vht80p80=True)
|
|
|
|
|
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_chan_switch_to_vht160(dev, apdev):
|
|
|
|
"""DFS channel switch to VHT160"""
|
|
|
|
run_dfs_chan_switch_to_vht(dev, apdev, vht160=True)
|
|
|
|
|
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_chan_switch_to_vht160b(dev, apdev):
|
|
|
|
"""DFS channel switch to VHT160 from non-DFS"""
|
|
|
|
run_dfs_chan_switch_to_vht(dev, apdev, vht160=True, start_dfs=False)
|
|
|
|
|
|
|
|
def run_dfs_chan_switch_to_vht(dev, apdev, vht80=False, vht80p80=False,
|
|
|
|
vht160=False, start_dfs=True):
|
|
|
|
try:
|
|
|
|
hapd = None
|
|
|
|
if start_dfs:
|
|
|
|
hapd = start_dfs_ap(apdev[0], country="US")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5260":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5260 5180")
|
|
|
|
else:
|
|
|
|
params = {"ssid": "dfs",
|
|
|
|
"country_code": "US",
|
|
|
|
"ieee80211d": "1",
|
|
|
|
"hw_mode": "a",
|
|
|
|
"channel": "40"}
|
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
|
|
|
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5260 5180 5200")
|
|
|
|
dev[0].wait_regdom(country_ie=True)
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
if vht160:
|
|
|
|
if not start_dfs:
|
|
|
|
hapd.set("ieee80211h", "1")
|
|
|
|
cmd = "CHAN_SWITCH 5 5180 sec_channel_offset=1 center_freq1=5250 bandwidth=160 ht vht"
|
|
|
|
if vht80p80:
|
|
|
|
cmd = "CHAN_SWITCH 5 5180 sec_channel_offset=1 center_freq1=5210 center_freq2=5775 bandwidth=80 ht vht"
|
|
|
|
if vht80:
|
|
|
|
cmd = "CHAN_SWITCH 5 5180 sec_channel_offset=1 center_freq1=5210 bandwidth=80 ht vht"
|
|
|
|
if "OK" not in hapd.request(cmd):
|
|
|
|
raise Exception("CHAN_SWITCH command failed")
|
|
|
|
if vht160:
|
|
|
|
# This results in BSS going down before restart, so the STA is
|
|
|
|
# expected to report disconnection.
|
|
|
|
dev[0].wait_disconnected()
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if "freq=5180" not in ev:
|
|
|
|
raise Exception("Unexpected channel: " + ev)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
else:
|
|
|
|
ev = wait_dfs_event(hapd, "AP-CSA-FINISHED", 5)
|
|
|
|
if "freq=5180" not in ev:
|
|
|
|
raise Exception("Unexpected channel: " + ev)
|
|
|
|
if vht160:
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5180":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
status = hapd.get_status()
|
|
|
|
logger.info("hostapd STATUS: " + str(status))
|
|
|
|
if status["ieee80211n"] != "1":
|
|
|
|
raise Exception("Unexpected STATUS ieee80211n value")
|
|
|
|
if status["ieee80211ac"] != "1":
|
|
|
|
raise Exception("Unexpected STATUS ieee80211ac value")
|
|
|
|
if status["secondary_channel"] != "1":
|
|
|
|
raise Exception("Unexpected STATUS secondary_channel value")
|
|
|
|
if vht80 and status["vht_oper_chwidth"] != "1":
|
|
|
|
raise Exception("Unexpected STATUS vht_oper_chwidth value")
|
|
|
|
if vht80p80 and status["vht_oper_chwidth"] != "3":
|
|
|
|
raise Exception("Unexpected STATUS vht_oper_chwidth value")
|
|
|
|
if vht160 and status["vht_oper_chwidth"] != "2":
|
|
|
|
raise Exception("Unexpected STATUS vht_oper_chwidth value")
|
|
|
|
if vht160:
|
|
|
|
if status["vht_oper_centr_freq_seg0_idx"] != "50":
|
|
|
|
raise Exception("Unexpected STATUS vht_oper_centr_freq_seg0_idx value")
|
|
|
|
else:
|
|
|
|
if status["vht_oper_centr_freq_seg0_idx"] != "42":
|
|
|
|
raise Exception("Unexpected STATUS vht_oper_centr_freq_seg0_idx value")
|
|
|
|
if vht80p80 and status["vht_oper_centr_freq_seg1_idx"] != "155":
|
|
|
|
raise Exception("Unexpected STATUS vht_oper_centr_freq_seg1_idx value")
|
|
|
|
if "vht_caps_info" not in status:
|
|
|
|
raise Exception("Missing vht_caps_info")
|
|
|
|
|
|
|
|
if vht160:
|
|
|
|
dev[0].wait_connected(timeout=30)
|
|
|
|
else:
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Channel switch not reported")
|
|
|
|
if "freq=5180" not in ev:
|
|
|
|
raise Exception("Unexpected frequency: " + ev)
|
|
|
|
sig = dev[0].request("SIGNAL_POLL").splitlines()
|
|
|
|
logger.info("STA0: " + str(sig))
|
|
|
|
if "FREQUENCY=5180" not in sig:
|
|
|
|
raise Exception("Unexpected channel: " + str(sig))
|
|
|
|
if vht160 and "WIDTH=160 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected channel[1]: " + str(sig))
|
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
|
|
|
|
|
|
|
dev[1].connect("dfs", key_mgmt="NONE", scan_freq="5180")
|
|
|
|
sig = dev[1].request("SIGNAL_POLL").splitlines()
|
|
|
|
logger.info("STA1: " + str(sig))
|
|
|
|
if "FREQUENCY=5180" not in sig:
|
|
|
|
raise Exception("Unexpected channel[1]: " + str(sig))
|
|
|
|
if vht80 and "WIDTH=80 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected channel[1]: " + str(sig))
|
|
|
|
if vht80p80 and "WIDTH=80+80 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected channel[1]: " + str(sig))
|
|
|
|
if vht160 and "WIDTH=160 MHz" not in sig:
|
|
|
|
raise Exception("Unexpected channel[1]: " + str(sig))
|
|
|
|
finally:
|
|
|
|
clear_regdom(hapd, dev)
|
|
|
|
|
2020-12-02 15:47:28 +01:00
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_no_available_channel(dev, apdev):
|
|
|
|
"""DFS and no available channel after radar detection"""
|
|
|
|
try:
|
|
|
|
hapd = None
|
|
|
|
hapd = start_dfs_ap(apdev[0], chanlist="56")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=70)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP2 setup timed out")
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5260 ht_enabled=1 chan_offset=0 chan_width=1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq from AP")
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-NEW-CHANNEL", 5)
|
|
|
|
if "freq=5280 chan=56" not in ev:
|
|
|
|
raise Exception("Unexpected DFS new freq: " + ev)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if "freq=5280" not in ev:
|
|
|
|
raise Exception("Unexpected channel: " + ev)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5280" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
|
|
|
|
dfs_simulate_radar(hapd)
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-RADAR-DETECTED", 5)
|
|
|
|
if "freq=5280 ht_enabled=1 chan_offset=0 chan_width=1" not in ev:
|
|
|
|
raise Exception("Unexpected DFS radar detection freq from AP [2]")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-DISABLED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("AP was not disabled")
|
|
|
|
finally:
|
|
|
|
clear_regdom(hapd, dev)
|
2020-10-11 21:01:53 +02:00
|
|
|
|
|
|
|
def dfs_chan_switch_precac(dev, apdev, country):
|
|
|
|
"""DFS channel switch pre CAC"""
|
|
|
|
try:
|
|
|
|
hapd = None
|
|
|
|
|
|
|
|
# Toggle regulatory - clean all preCAC
|
|
|
|
hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', 'US'])
|
|
|
|
|
|
|
|
hapd = start_dfs_ap(apdev[0], country=country)
|
|
|
|
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
|
|
|
|
if "success=1" not in ev:
|
|
|
|
raise Exception("CAC failed")
|
|
|
|
if "freq=5260" not in ev:
|
|
|
|
raise Exception("Unexpected DFS freq result")
|
|
|
|
ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("AP setup timed out")
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5260":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
# TODO add/connect station here
|
|
|
|
# Today skip this step while dev[0].connect()
|
|
|
|
# for some reason toggle regulatory to US
|
|
|
|
# and clean preCAC
|
|
|
|
|
|
|
|
# Back to non DFS channel
|
|
|
|
if "OK" not in hapd.request("CHAN_SWITCH 5 5180 ht"):
|
|
|
|
raise Exception("CHAN_SWITCH 5180 failed")
|
|
|
|
|
|
|
|
ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("No CSA finished event - 5180")
|
|
|
|
freq = hapd.get_status_field("freq")
|
|
|
|
if freq != "5180":
|
|
|
|
raise Exception("Unexpected frequency")
|
|
|
|
|
|
|
|
# Today cfg80211 first send AP-CSA-FINISHED and next
|
|
|
|
# DFS-PRE-CAC-EXPIRED
|
|
|
|
ev = hapd.wait_event(["DFS-PRE-CAC-EXPIRED"], timeout=3)
|
|
|
|
if not ev and country == 'US':
|
|
|
|
raise Exception("US - no CAC-EXPIRED event")
|
|
|
|
|
|
|
|
# Back again to DFS channel (CAC passed)
|
|
|
|
if "OK" not in hapd.request("CHAN_SWITCH 5 5260 ht"):
|
|
|
|
raise Exception("CHAN_SWITCH 5260 failed")
|
|
|
|
|
|
|
|
if country == 'US':
|
|
|
|
# For non EU we should start CAC again
|
|
|
|
ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("No DFS CAC start event")
|
|
|
|
else:
|
|
|
|
# For EU preCAC should be used
|
|
|
|
ev = wait_dfs_event(hapd, "AP-CSA-FINISHED", 5)
|
|
|
|
if not ev:
|
|
|
|
raise Exception("No CSA finished event - 5260")
|
|
|
|
finally:
|
|
|
|
clear_regdom(hapd, dev)
|
|
|
|
|
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_eu_chan_switch_precac(dev, apdev):
|
|
|
|
"""DFS channel switch pre CAC - ETSI domain"""
|
|
|
|
dfs_chan_switch_precac(dev, apdev, 'PL')
|
|
|
|
|
|
|
|
@long_duration_test
|
|
|
|
def test_dfs_us_chan_switch_precac(dev, apdev):
|
|
|
|
"""DFS channel switch pre CAC - FCC domain"""
|
|
|
|
dfs_chan_switch_precac(dev, apdev, 'US')
|