]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ap_vht.py
1 # Test cases for VHT operations with hostapd
2 # Copyright (c) 2014, Qualcomm Atheros, Inc.
3 # Copyright (c) 2013, Intel Corporation
5 # This software may be distributed under the terms of the BSD license.
6 # See README for more details.
9 logger
= logging
.getLogger()
11 import subprocess
, time
15 from wpasupplicant
import WpaSupplicant
17 from test_dfs
import wait_dfs_event
18 from test_ap_csa
import csa_supported
19 from test_ap_ht
import clear_scan_cache
22 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
23 reg
= cmd
.stdout
.read()
24 if "@ 80)" in reg
or "@ 160)" in reg
:
28 def test_ap_vht80(dev
, apdev
):
29 """VHT with 80 MHz channel width"""
32 params
= {"ssid": "vht",
36 "ht_capab": "[HT40+]",
39 "vht_oper_chwidth": "1",
40 "vht_oper_centr_freq_seg0_idx": "42"}
41 hapd
= hostapd
.add_ap(apdev
[0], params
)
42 bssid
= apdev
[0]['bssid']
44 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
45 hwsim_utils
.test_connectivity(dev
[0], hapd
)
46 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
47 if "FREQUENCY=5180" not in sig
:
48 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
49 if "WIDTH=80 MHz" not in sig
:
50 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
51 est
= dev
[0].get_bss(bssid
)['est_throughput']
53 raise Exception("Unexpected BSS est_throughput: " + est
)
54 status
= dev
[0].get_status()
55 if status
["ieee80211ac"] != "1":
56 raise Exception("Unexpected STATUS ieee80211ac value (STA)")
57 status
= hapd
.get_status()
58 logger
.info("hostapd STATUS: " + str(status
))
59 if status
["ieee80211n"] != "1":
60 raise Exception("Unexpected STATUS ieee80211n value")
61 if status
["ieee80211ac"] != "1":
62 raise Exception("Unexpected STATUS ieee80211ac value")
63 if status
["secondary_channel"] != "1":
64 raise Exception("Unexpected STATUS secondary_channel value")
65 if status
["vht_oper_chwidth"] != "1":
66 raise Exception("Unexpected STATUS vht_oper_chwidth value")
67 if status
["vht_oper_centr_freq_seg0_idx"] != "42":
68 raise Exception("Unexpected STATUS vht_oper_centr_freq_seg0_idx value")
69 if "vht_caps_info" not in status
:
70 raise Exception("Missing vht_caps_info")
72 sta
= hapd
.get_sta(dev
[0].own_addr())
73 logger
.info("hostapd STA: " + str(sta
))
74 if "[HT]" not in sta
['flags']:
75 raise Exception("Missing STA flag: HT")
76 if "[VHT]" not in sta
['flags']:
77 raise Exception("Missing STA flag: VHT")
78 except Exception as e
:
79 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
80 if not vht_supported():
81 raise HwsimSkip("80 MHz channel not supported in regulatory information")
84 dev
[0].request("DISCONNECT")
85 clear_regdom(hapd
, dev
)
87 def test_ap_vht_wifi_generation(dev
, apdev
):
88 """VHT and wifi_generation"""
91 params
= {"ssid": "vht",
95 "ht_capab": "[HT40+]",
98 "vht_oper_chwidth": "1",
99 "vht_oper_centr_freq_seg0_idx": "42"}
100 hapd
= hostapd
.add_ap(apdev
[0], params
)
101 bssid
= apdev
[0]['bssid']
103 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
104 status
= dev
[0].get_status()
105 if 'wifi_generation' not in status
:
106 # For now, assume this is because of missing kernel support
107 raise HwsimSkip("Association Request IE reporting not supported")
108 #raise Exception("Missing wifi_generation information")
109 if status
['wifi_generation'] != "5":
110 raise Exception("Unexpected wifi_generation value: " + status
['wifi_generation'])
112 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
113 wpas
.interface_add("wlan5", drv_params
="force_connect_cmd=1")
114 wpas
.connect("vht", key_mgmt
="NONE", scan_freq
="5180")
115 status
= wpas
.get_status()
116 if 'wifi_generation' not in status
:
117 # For now, assume this is because of missing kernel support
118 raise HwsimSkip("Association Request IE reporting not supported")
119 #raise Exception("Missing wifi_generation information (connect)")
120 if status
['wifi_generation'] != "5":
121 raise Exception("Unexpected wifi_generation value (connect): " + status
['wifi_generation'])
122 except Exception as e
:
123 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
124 if not vht_supported():
125 raise HwsimSkip("80 MHz channel not supported in regulatory information")
128 dev
[0].request("DISCONNECT")
129 clear_regdom(hapd
, dev
)
131 def vht80_test(apdev
, dev
, channel
, ht_capab
):
132 clear_scan_cache(apdev
)
135 params
= {"ssid": "vht",
136 "country_code": "FI",
138 "channel": str(channel
),
139 "ht_capab": ht_capab
,
142 "vht_oper_chwidth": "1",
143 "vht_oper_centr_freq_seg0_idx": "42"}
144 hapd
= hostapd
.add_ap(apdev
, params
)
145 bssid
= apdev
['bssid']
147 dev
[0].connect("vht", key_mgmt
="NONE",
148 scan_freq
=str(5000 + 5 * channel
))
149 hwsim_utils
.test_connectivity(dev
[0], hapd
)
150 except Exception as e
:
151 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
152 if not vht_supported():
153 raise HwsimSkip("80 MHz channel not supported in regulatory information")
156 clear_regdom(hapd
, dev
)
158 def test_ap_vht80b(dev
, apdev
):
159 """VHT with 80 MHz channel width (HT40- channel 40)"""
160 vht80_test(apdev
[0], dev
, 40, "[HT40-]")
162 def test_ap_vht80c(dev
, apdev
):
163 """VHT with 80 MHz channel width (HT40+ channel 44)"""
164 vht80_test(apdev
[0], dev
, 44, "[HT40+]")
166 def test_ap_vht80d(dev
, apdev
):
167 """VHT with 80 MHz channel width (HT40- channel 48)"""
168 vht80_test(apdev
[0], dev
, 48, "[HT40-]")
170 def test_ap_vht80_params(dev
, apdev
):
171 """VHT with 80 MHz channel width and number of optional features enabled"""
174 params
= {"ssid": "vht",
175 "country_code": "FI",
178 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
181 "vht_oper_chwidth": "1",
182 "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
183 "vht_oper_centr_freq_seg0_idx": "42",
185 hapd
= hostapd
.add_ap(apdev
[0], params
)
187 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5180",
188 disable_vht
="1", wait_connect
=False)
189 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
190 dev
[2].connect("vht", key_mgmt
="NONE", scan_freq
="5180",
192 ev
= dev
[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
194 raise Exception("Association rejection timed out")
195 if "status_code=104" not in ev
:
196 raise Exception("Unexpected rejection status code")
197 dev
[1].request("DISCONNECT")
198 hwsim_utils
.test_connectivity(dev
[0], hapd
)
199 sta0
= hapd
.get_sta(dev
[0].own_addr())
200 sta2
= hapd
.get_sta(dev
[2].own_addr())
201 capab0
= int(sta0
['vht_caps_info'], base
=16)
202 capab2
= int(sta2
['vht_caps_info'], base
=16)
203 if capab0
& 0x60 == 0:
204 raise Exception("dev[0] did not support SGI")
205 if capab2
& 0x60 != 0:
206 raise Exception("dev[2] claimed support for SGI")
207 except Exception as e
:
208 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
209 if not vht_supported():
210 raise HwsimSkip("80 MHz channel not supported in regulatory information")
213 clear_regdom(hapd
, dev
, count
=3)
215 def test_ap_vht80_invalid(dev
, apdev
):
216 """VHT with invalid 80 MHz channel configuration (seg1)"""
219 params
= {"ssid": "vht",
220 "country_code": "US",
223 "ht_capab": "[HT40+]",
226 "vht_oper_chwidth": "1",
227 "vht_oper_centr_freq_seg0_idx": "42",
228 "vht_oper_centr_freq_seg1_idx": "155",
231 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
232 # This fails due to unexpected seg1 configuration
233 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
235 raise Exception("AP-DISABLED not reported")
236 except Exception as e
:
237 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
238 if not vht_supported():
239 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
242 clear_regdom(hapd
, dev
)
244 def test_ap_vht80_invalid2(dev
, apdev
):
245 """VHT with invalid 80 MHz channel configuration (seg0)"""
248 params
= {"ssid": "vht",
249 "country_code": "US",
252 "ht_capab": "[HT40+]",
255 "vht_oper_chwidth": "1",
256 "vht_oper_centr_freq_seg0_idx": "46",
259 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
260 # This fails due to invalid seg0 configuration
261 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
263 raise Exception("AP-DISABLED not reported")
264 except Exception as e
:
265 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
266 if not vht_supported():
267 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
270 clear_regdom(hapd
, dev
)
272 def test_ap_vht_20(devs
, apdevs
):
273 """VHT and 20 MHz channel"""
278 params
= {"ssid": "test-vht20",
279 "country_code": "DE",
286 "vht_oper_chwidth": "0",
287 "vht_oper_centr_freq_seg0_idx": "0",
288 "supported_rates": "60 120 240 360 480 540",
290 hapd
= hostapd
.add_ap(ap
, params
)
291 dev
.connect("test-vht20", scan_freq
="5180", key_mgmt
="NONE")
292 hwsim_utils
.test_connectivity(dev
, hapd
)
294 dev
.request("DISCONNECT")
295 clear_regdom(hapd
, devs
)
297 def test_ap_vht_40(devs
, apdevs
):
298 """VHT and 40 MHz channel"""
303 params
= {"ssid": "test-vht40",
304 "country_code": "DE",
309 "ht_capab": "[HT40+]",
311 "vht_oper_chwidth": "0",
312 "vht_oper_centr_freq_seg0_idx": "0"}
313 hapd
= hostapd
.add_ap(ap
, params
)
314 dev
.connect("test-vht40", scan_freq
="5180", key_mgmt
="NONE")
315 hwsim_utils
.test_connectivity(dev
, hapd
)
317 dev
.request("DISCONNECT")
318 clear_regdom(hapd
, devs
)
320 def test_ap_vht_capab_not_supported(dev
, apdev
):
321 """VHT configuration with driver not supporting all vht_capab entries"""
323 params
= {"ssid": "vht",
324 "country_code": "FI",
327 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
330 "vht_oper_chwidth": "1",
331 "vht_capab": "[MAX-MPDU-7991][MAX-MPDU-11454][VHT160][VHT160-80PLUS80][RXLDPC][SHORT-GI-80][SHORT-GI-160][TX-STBC-2BY1][RX-STBC-1][RX-STBC-12][RX-STBC-123][RX-STBC-1234][SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][BF-ANTENNA-3][BF-ANTENNA-4][SOUNDING-DIMENSION-2][SOUNDING-DIMENSION-3][SOUNDING-DIMENSION-4][MU-BEAMFORMER][VHT-TXOP-PS][HTC-VHT][MAX-A-MPDU-LEN-EXP0][MAX-A-MPDU-LEN-EXP7][VHT-LINK-ADAPT2][VHT-LINK-ADAPT3][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN]",
332 "vht_oper_centr_freq_seg0_idx": "42",
334 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
335 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
337 raise Exception("Startup failure not reported")
338 for i
in range(1, 7):
339 if "OK" not in hapd
.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i
):
340 raise Exception("Unexpected SET failure")
342 clear_regdom(hapd
, dev
)
344 def test_ap_vht160(dev
, apdev
):
345 """VHT with 160 MHz channel width (1)"""
348 params
= {"ssid": "vht",
349 "country_code": "FI",
352 "ht_capab": "[HT40+]",
355 "vht_oper_chwidth": "2",
356 "vht_oper_centr_freq_seg0_idx": "50",
359 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
361 ev
= wait_dfs_event(hapd
, "DFS-CAC-START", 5)
362 if "DFS-CAC-START" not in ev
:
363 raise Exception("Unexpected DFS event")
365 state
= hapd
.get_status_field("state")
367 if state
== "DISABLED" and not os
.path
.exists("dfs"):
368 # Not all systems have recent enough CRDA version and
369 # wireless-regdb changes to support 160 MHz and DFS. For now,
370 # do not report failures for this test case.
371 raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
372 raise Exception("Unexpected interface state: " + state
)
374 logger
.info("Waiting for CAC to complete")
376 ev
= wait_dfs_event(hapd
, "DFS-CAC-COMPLETED", 70)
377 if "success=1" not in ev
:
378 raise Exception("CAC failed")
379 if "freq=5180" not in ev
:
380 raise Exception("Unexpected DFS freq result")
382 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=5)
384 raise Exception("AP setup timed out")
386 state
= hapd
.get_status_field("state")
387 if state
!= "ENABLED":
388 raise Exception("Unexpected interface state")
390 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
391 dev
[0].wait_regdom(country_ie
=True)
392 hwsim_utils
.test_connectivity(dev
[0], hapd
)
393 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
394 if "FREQUENCY=5180" not in sig
:
395 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
396 if "WIDTH=160 MHz" not in sig
:
397 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
398 except Exception as e
:
399 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
400 if not vht_supported():
401 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
405 hapd
.request("DISABLE")
406 dev
[0].disconnect_and_stop_scan()
407 subprocess
.call(['iw', 'reg', 'set', '00'])
408 dev
[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=0.5)
409 dev
[0].flush_scan_cache()
411 def test_ap_vht160b(dev
, apdev
):
412 """VHT with 160 MHz channel width (2)"""
416 params
= {"ssid": "vht",
417 "country_code": "FI",
420 "ht_capab": "[HT40-]",
423 "vht_oper_chwidth": "2",
424 "vht_oper_centr_freq_seg0_idx": "114",
427 hapd
= hostapd
.add_ap(apdev
[1], params
, wait_enabled
=False)
429 ev
= wait_dfs_event(hapd
, "DFS-CAC-START", 5)
430 if "DFS-CAC-START" not in ev
:
431 raise Exception("Unexpected DFS event(2)")
433 state
= hapd
.get_status_field("state")
435 if state
== "DISABLED" and not os
.path
.exists("dfs"):
436 # Not all systems have recent enough CRDA version and
437 # wireless-regdb changes to support 160 MHz and DFS. For now,
438 # do not report failures for this test case.
439 raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
440 raise Exception("Unexpected interface state: " + state
)
442 logger
.info("Waiting for CAC to complete")
444 ev
= wait_dfs_event(hapd
, "DFS-CAC-COMPLETED", 70)
445 if "success=1" not in ev
:
446 raise Exception("CAC failed(2)")
447 if "freq=5520" not in ev
:
448 raise Exception("Unexpected DFS freq result(2)")
450 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=5)
452 raise Exception("AP setup timed out(2)")
454 state
= hapd
.get_status_field("state")
455 if state
!= "ENABLED":
456 raise Exception("Unexpected interface state(2)")
458 freq
= hapd
.get_status_field("freq")
460 raise Exception("Unexpected frequency(2)")
462 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5520")
463 dev
[0].wait_regdom(country_ie
=True)
464 hwsim_utils
.test_connectivity(dev
[0], hapd
)
465 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
466 if "FREQUENCY=5520" not in sig
:
467 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
468 if "WIDTH=160 MHz" not in sig
:
469 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
470 except Exception as e
:
471 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
472 if not vht_supported():
473 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
477 hapd
.request("DISABLE")
478 dev
[0].disconnect_and_stop_scan()
479 subprocess
.call(['iw', 'reg', 'set', '00'])
480 dev
[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=0.5)
481 dev
[0].flush_scan_cache()
483 def test_ap_vht160_no_dfs_100_plus(dev
, apdev
):
484 """VHT with 160 MHz channel width and no DFS (100 plus)"""
485 run_ap_vht160_no_dfs(dev
, apdev
, "100", "[HT40+]")
487 def test_ap_vht160_no_dfs(dev
, apdev
):
488 """VHT with 160 MHz channel width and no DFS (104 minus)"""
489 run_ap_vht160_no_dfs(dev
, apdev
, "104", "[HT40-]")
491 def test_ap_vht160_no_dfs_108_plus(dev
, apdev
):
492 """VHT with 160 MHz channel width and no DFS (108 plus)"""
493 run_ap_vht160_no_dfs(dev
, apdev
, "108", "[HT40+]")
495 def test_ap_vht160_no_dfs_112_minus(dev
, apdev
):
496 """VHT with 160 MHz channel width and no DFS (112 minus)"""
497 run_ap_vht160_no_dfs(dev
, apdev
, "112", "[HT40-]")
499 def test_ap_vht160_no_dfs_116_plus(dev
, apdev
):
500 """VHT with 160 MHz channel width and no DFS (116 plus)"""
501 run_ap_vht160_no_dfs(dev
, apdev
, "116", "[HT40+]")
503 def test_ap_vht160_no_dfs_120_minus(dev
, apdev
):
504 """VHT with 160 MHz channel width and no DFS (120 minus)"""
505 run_ap_vht160_no_dfs(dev
, apdev
, "120", "[HT40-]")
507 def test_ap_vht160_no_dfs_124_plus(dev
, apdev
):
508 """VHT with 160 MHz channel width and no DFS (124 plus)"""
509 run_ap_vht160_no_dfs(dev
, apdev
, "124", "[HT40+]")
511 def test_ap_vht160_no_dfs_128_minus(dev
, apdev
):
512 """VHT with 160 MHz channel width and no DFS (128 minus)"""
513 run_ap_vht160_no_dfs(dev
, apdev
, "128", "[HT40-]")
515 def run_ap_vht160_no_dfs(dev
, apdev
, channel
, ht_capab
):
518 params
= {"ssid": "vht",
519 "country_code": "ZA",
522 "ht_capab": ht_capab
,
525 "vht_oper_chwidth": "2",
526 "vht_oper_centr_freq_seg0_idx": "114",
529 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
530 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=2)
532 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
533 reg
= cmd
.stdout
.readlines()
535 if "5490" in r
and "DFS" in r
:
536 raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
537 raise Exception("AP setup timed out")
539 freq
= str(int(channel
) * 5 + 5000)
540 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
=freq
)
541 dev
[0].wait_regdom(country_ie
=True)
542 hwsim_utils
.test_connectivity(dev
[0], hapd
)
543 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
544 if "FREQUENCY=" + freq
not in sig
:
545 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
546 if "WIDTH=160 MHz" not in sig
:
547 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
548 except Exception as e
:
549 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
550 if not vht_supported():
551 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
554 clear_regdom(hapd
, dev
)
556 def test_ap_vht160_no_ht40(dev
, apdev
):
557 """VHT with 160 MHz channel width and HT40 disabled"""
560 params
= {"ssid": "vht",
561 "country_code": "ZA",
567 "vht_oper_chwidth": "2",
568 "vht_oper_centr_freq_seg0_idx": "114",
571 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
572 ev
= hapd
.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout
=2)
574 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
575 reg
= cmd
.stdout
.readlines()
577 if "5490" in r
and "DFS" in r
:
578 raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
579 raise Exception("AP setup timed out")
580 if "AP-ENABLED" in ev
:
581 # This was supposed to fail due to sec_channel_offset == 0
582 raise Exception("Unexpected AP-ENABLED")
583 except Exception as e
:
584 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
585 if not vht_supported():
586 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
589 clear_regdom(hapd
, dev
)
591 def test_ap_vht80plus80(dev
, apdev
):
592 """VHT with 80+80 MHz channel width"""
596 params
= {"ssid": "vht",
597 "country_code": "US",
600 "ht_capab": "[HT40+]",
603 "vht_oper_chwidth": "3",
604 "vht_oper_centr_freq_seg0_idx": "58",
605 "vht_oper_centr_freq_seg1_idx": "155",
608 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
609 # This will actually fail since DFS on 80+80 is not yet supported
610 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
611 # ignore result to avoid breaking the test once 80+80 DFS gets enabled
613 params
= {"ssid": "vht2",
614 "country_code": "US",
617 "ht_capab": "[HT40+]",
620 "vht_oper_chwidth": "3",
621 "vht_oper_centr_freq_seg0_idx": "42",
622 "vht_oper_centr_freq_seg1_idx": "155"}
623 hapd2
= hostapd
.add_ap(apdev
[1], params
, wait_enabled
=False)
625 ev
= hapd2
.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout
=5)
627 raise Exception("AP setup timed out(2)")
628 if "AP-DISABLED" in ev
:
629 # Assume this failed due to missing regulatory update for now
630 raise HwsimSkip("80+80 MHz channel not supported in regulatory information")
632 state
= hapd2
.get_status_field("state")
633 if state
!= "ENABLED":
634 raise Exception("Unexpected interface state(2)")
636 dev
[1].connect("vht2", key_mgmt
="NONE", scan_freq
="5180")
637 hwsim_utils
.test_connectivity(dev
[1], hapd2
)
638 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
639 if "FREQUENCY=5180" not in sig
:
640 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
641 if "WIDTH=80+80 MHz" not in sig
:
642 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
643 if "CENTER_FRQ1=5210" not in sig
:
644 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
645 if "CENTER_FRQ2=5775" not in sig
:
646 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
647 except Exception as e
:
648 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
649 if not vht_supported():
650 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
653 dev
[0].request("DISCONNECT")
654 dev
[1].request("DISCONNECT")
656 hapd
.request("DISABLE")
658 hapd2
.request("DISABLE")
659 subprocess
.call(['iw', 'reg', 'set', '00'])
660 dev
[0].flush_scan_cache()
661 dev
[1].flush_scan_cache()
663 def test_ap_vht80plus80_invalid(dev
, apdev
):
664 """VHT with invalid 80+80 MHz channel"""
667 params
= {"ssid": "vht",
668 "country_code": "US",
671 "ht_capab": "[HT40+]",
674 "vht_oper_chwidth": "3",
675 "vht_oper_centr_freq_seg0_idx": "42",
676 "vht_oper_centr_freq_seg1_idx": "0",
679 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
680 # This fails due to missing(invalid) seg1 configuration
681 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
683 raise Exception("AP-DISABLED not reported")
684 except Exception as e
:
685 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
686 if not vht_supported():
687 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
690 clear_regdom(hapd
, dev
)
692 def test_ap_vht80_csa(dev
, apdev
):
693 """VHT with 80 MHz channel width and CSA"""
694 csa_supported(dev
[0])
697 params
= {"ssid": "vht",
698 "country_code": "US",
701 "ht_capab": "[HT40+]",
704 "vht_oper_chwidth": "1",
705 "vht_oper_centr_freq_seg0_idx": "155"}
706 hapd
= hostapd
.add_ap(apdev
[0], params
)
708 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
709 hwsim_utils
.test_connectivity(dev
[0], hapd
)
711 hapd
.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
712 ev
= hapd
.wait_event(["CTRL-EVENT-STARTED-CHANNEL-SWITCH"], timeout
=10)
714 raise Exception("Channel switch start event not seen")
715 if "freq=5180" not in ev
:
716 raise Exception("Unexpected channel in CS started")
717 ev
= hapd
.wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=10)
719 raise Exception("Channel switch completion event not seen")
720 if "freq=5180" not in ev
:
721 raise Exception("Unexpected channel in CS completed")
722 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
724 raise Exception("CSA finished event timed out")
725 if "freq=5180" not in ev
:
726 raise Exception("Unexpected channel in CSA finished event")
728 hwsim_utils
.test_connectivity(dev
[0], hapd
)
730 hapd
.request("CHAN_SWITCH 5 5745")
731 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
733 raise Exception("CSA finished event timed out")
734 if "freq=5745" not in ev
:
735 raise Exception("Unexpected channel in CSA finished event")
737 hwsim_utils
.test_connectivity(dev
[0], hapd
)
739 # This CSA to same channel will fail in kernel, so use this only for
740 # extra code coverage.
741 hapd
.request("CHAN_SWITCH 5 5745")
742 hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=1)
743 except Exception as e
:
744 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
745 if not vht_supported():
746 raise HwsimSkip("80 MHz channel not supported in regulatory information")
749 dev
[0].request("DISCONNECT")
750 clear_regdom(hapd
, dev
)
752 def test_ap_vht_csa_vht40(dev
, apdev
):
753 """VHT CSA with VHT40 getting enabled"""
754 csa_supported(dev
[0])
757 params
= {"ssid": "vht",
758 "country_code": "US",
761 "ht_capab": "[HT40+]",
764 hapd
= hostapd
.add_ap(apdev
[0], params
)
765 bssid
= hapd
.own_addr()
767 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
768 hwsim_utils
.test_connectivity(dev
[0], hapd
)
770 hapd
.request("CHAN_SWITCH 5 5765 sec_channel_offset=-1 center_freq1=5755 bandwidth=40 vht")
771 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
773 raise Exception("CSA finished event timed out")
774 if "freq=5765" not in ev
:
775 raise Exception("Unexpected channel in CSA finished event")
776 ev
= dev
[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=5)
778 raise Exception("Channel switch event not seen")
779 if "freq=5765" not in ev
:
780 raise Exception("Channel mismatch: " + ev
)
781 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout
=0.5)
783 raise Exception("Unexpected disconnection event from station")
784 hwsim_utils
.test_connectivity(dev
[0], hapd
)
786 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5765")
787 hwsim_utils
.test_connectivity(dev
[1], hapd
)
789 if dev
[1].get_status_field("ieee80211ac") != '1':
790 raise Exception("VHT not enabled as part of channel switch")
792 dev
[0].request("DISCONNECT")
793 dev
[1].request("DISCONNECT")
795 hapd
.request("DISABLE")
796 subprocess
.call(['iw', 'reg', 'set', '00'])
797 dev
[0].flush_scan_cache()
798 dev
[1].flush_scan_cache()
800 def test_ap_vht_csa_vht20(dev
, apdev
):
801 """VHT CSA with VHT20 getting enabled"""
802 csa_supported(dev
[0])
805 params
= {"ssid": "vht",
806 "country_code": "US",
809 "ht_capab": "[HT40+]",
812 hapd
= hostapd
.add_ap(apdev
[0], params
)
813 bssid
= hapd
.own_addr()
815 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
816 hwsim_utils
.test_connectivity(dev
[0], hapd
)
818 hapd
.request("CHAN_SWITCH 5 5200 center_freq1=5200 bandwidth=20 vht")
819 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
821 raise Exception("CSA finished event timed out")
822 if "freq=5200" not in ev
:
823 raise Exception("Unexpected channel in CSA finished event")
825 hwsim_utils
.test_connectivity(dev
[0], hapd
)
827 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5200")
828 hwsim_utils
.test_connectivity(dev
[1], hapd
)
830 if dev
[1].get_status_field("ieee80211ac") != '1':
831 raise Exception("VHT not enabled as part of channel switch")
833 dev
[0].request("DISCONNECT")
834 dev
[1].request("DISCONNECT")
836 hapd
.request("DISABLE")
837 subprocess
.call(['iw', 'reg', 'set', '00'])
838 dev
[0].flush_scan_cache()
839 dev
[1].flush_scan_cache()
841 def test_ap_vht_csa_vht40_disable(dev
, apdev
):
842 """VHT CSA with VHT40 getting disabled"""
843 csa_supported(dev
[0])
846 params
= {"ssid": "vht",
847 "country_code": "US",
850 "ht_capab": "[HT40+]",
854 "vht_oper_chwidth": "0",
855 "vht_oper_centr_freq_seg0_idx": "0"}
856 hapd
= hostapd
.add_ap(apdev
[0], params
)
857 bssid
= hapd
.own_addr()
859 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
860 hwsim_utils
.test_connectivity(dev
[0], hapd
)
862 hapd
.request("CHAN_SWITCH 5 5200 center_freq1=5200 bandwidth=40 ht")
863 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
865 raise Exception("CSA finished event timed out")
866 if "freq=5200" not in ev
:
867 raise Exception("Unexpected channel in CSA finished event")
868 ev
= dev
[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=5)
870 raise Exception("Channel switch event not seen")
871 if "freq=5200" not in ev
:
872 raise Exception("Channel mismatch: " + ev
)
874 hwsim_utils
.test_connectivity(dev
[0], hapd
)
876 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5200")
877 hwsim_utils
.test_connectivity(dev
[1], hapd
)
879 if dev
[1].get_status_field("ieee80211ac") == '1':
880 raise Exception("VHT not disabled as part of channel switch")
882 dev
[0].request("DISCONNECT")
883 dev
[1].request("DISCONNECT")
885 hapd
.request("DISABLE")
886 subprocess
.call(['iw', 'reg', 'set', '00'])
887 dev
[0].flush_scan_cache()
888 dev
[1].flush_scan_cache()
890 def test_ap_vht_on_24ghz(dev
, apdev
):
891 """Subset of VHT features on 2.4 GHz"""
893 params
= {"ssid": "test-vht-2g",
898 "vht_capab": "[MAX-MPDU-11454]",
899 "vht_oper_chwidth": "0",
900 "vht_oper_centr_freq_seg0_idx": "1"}
901 hapd
= hostapd
.add_ap(apdev
[0], params
)
903 if "OK" not in dev
[0].request("VENDOR_ELEM_ADD 13 dd1300904c0400bf0c3240820feaff0000eaff0000"):
904 raise Exception("Failed to add vendor element")
905 dev
[0].connect("test-vht-2g", scan_freq
="2412", key_mgmt
="NONE")
906 hwsim_utils
.test_connectivity(dev
[0], hapd
)
907 sta
= hapd
.get_sta(dev
[0].own_addr())
908 if '[VENDOR_VHT]' not in sta
['flags']:
909 raise Exception("No VENDOR_VHT STA flag")
911 dev
[1].connect("test-vht-2g", scan_freq
="2412", key_mgmt
="NONE")
912 sta
= hapd
.get_sta(dev
[1].own_addr())
913 if '[VENDOR_VHT]' in sta
['flags']:
914 raise Exception("Unexpected VENDOR_VHT STA flag")
916 dev
[0].request("VENDOR_ELEM_REMOVE 13 *")
918 def test_prefer_vht40(dev
, apdev
):
919 """Preference on VHT40 over HT40"""
923 params
= {"ssid": "test",
924 "country_code": "FI",
928 "ht_capab": "[HT40+]"}
929 hapd
= hostapd
.add_ap(apdev
[0], params
)
930 bssid
= apdev
[0]['bssid']
932 params
= {"ssid": "test",
933 "country_code": "FI",
938 "ht_capab": "[HT40+]",
940 "vht_oper_chwidth": "0",
941 "vht_oper_centr_freq_seg0_idx": "0"}
942 hapd2
= hostapd
.add_ap(apdev
[1], params
)
943 bssid2
= apdev
[1]['bssid']
945 dev
[0].scan_for_bss(bssid
, freq
=5180)
946 dev
[0].scan_for_bss(bssid2
, freq
=5180)
947 dev
[0].connect("test", scan_freq
="5180", key_mgmt
="NONE")
948 if dev
[0].get_status_field('bssid') != bssid2
:
949 raise Exception("Unexpected BSS selected")
951 est
= dev
[0].get_bss(bssid
)['est_throughput']
953 raise Exception("Unexpected BSS0 est_throughput: " + est
)
955 est
= dev
[0].get_bss(bssid2
)['est_throughput']
957 raise Exception("Unexpected BSS1 est_throughput: " + est
)
959 dev
[0].request("DISCONNECT")
962 clear_regdom_dev(dev
)
964 def test_ap_vht80_pwr_constraint(dev
, apdev
):
965 """VHT with 80 MHz channel width and local power constraint"""
968 params
= {"ssid": "vht",
969 "country_code": "FI",
972 "ht_capab": "[HT40+]",
974 "local_pwr_constraint": "3",
977 "vht_oper_chwidth": "1",
978 "vht_oper_centr_freq_seg0_idx": "42"}
979 hapd
= hostapd
.add_ap(apdev
[0], params
)
981 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
982 dev
[0].wait_regdom(country_ie
=True)
983 except Exception as e
:
984 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
985 if not vht_supported():
986 raise HwsimSkip("80 MHz channel not supported in regulatory information")
990 hapd
.request("DISABLE")
991 dev
[0].disconnect_and_stop_scan()
992 subprocess
.call(['iw', 'reg', 'set', '00'])
993 dev
[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=0.5)
994 dev
[0].flush_scan_cache()
996 def test_ap_vht_use_sta_nsts(dev
, apdev
):
997 """VHT with 80 MHz channel width and use_sta_nsts=1"""
1000 params
= {"ssid": "vht",
1001 "country_code": "FI",
1004 "ht_capab": "[HT40+]",
1007 "vht_oper_chwidth": "1",
1008 "vht_oper_centr_freq_seg0_idx": "42",
1009 "use_sta_nsts": "1"}
1010 hapd
= hostapd
.add_ap(apdev
[0], params
)
1011 bssid
= apdev
[0]['bssid']
1013 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
1014 hwsim_utils
.test_connectivity(dev
[0], hapd
)
1015 except Exception as e
:
1016 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1017 if not vht_supported():
1018 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1021 clear_regdom(hapd
, dev
)
1023 def test_ap_vht_tkip(dev
, apdev
):
1027 params
= {"ssid": "vht",
1029 "wpa_key_mgmt": "WPA-PSK",
1030 "wpa_pairwise": "TKIP",
1031 "wpa_passphrase": "12345678",
1032 "country_code": "FI",
1035 "ht_capab": "[HT40+]",
1038 "vht_oper_chwidth": "1",
1039 "vht_oper_centr_freq_seg0_idx": "42"}
1040 hapd
= hostapd
.add_ap(apdev
[0], params
)
1041 bssid
= apdev
[0]['bssid']
1043 dev
[0].connect("vht", psk
="12345678", scan_freq
="5180")
1044 hwsim_utils
.test_connectivity(dev
[0], hapd
)
1045 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1046 if "FREQUENCY=5180" not in sig
:
1047 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
1048 if "WIDTH=20 MHz (no HT)" not in sig
:
1049 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1050 status
= hapd
.get_status()
1051 logger
.info("hostapd STATUS: " + str(status
))
1052 if status
["ieee80211n"] != "0":
1053 raise Exception("Unexpected STATUS ieee80211n value")
1054 if status
["ieee80211ac"] != "0":
1055 raise Exception("Unexpected STATUS ieee80211ac value")
1056 if status
["secondary_channel"] != "0":
1057 raise Exception("Unexpected STATUS secondary_channel value")
1058 except Exception as e
:
1059 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1060 if not vht_supported():
1061 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1064 dev
[0].request("DISCONNECT")
1065 clear_regdom(hapd
, dev
)
1067 def test_ap_vht_40_fallback_to_20(devs
, apdevs
):
1068 """VHT and 40 MHz channel configuration falling back to 20 MHz"""
1073 params
= {"ssid": "test-vht40",
1074 "country_code": "US",
1076 "basic_rates": "60 120 240",
1082 "ht_capab": "[HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]",
1083 "vht_capab": "[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC1][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]",
1084 "vht_oper_chwidth": "0",
1085 "vht_oper_centr_freq_seg0_idx": "155"}
1086 hapd
= hostapd
.add_ap(ap
, params
)
1087 dev
.connect("test-vht40", scan_freq
="5805", key_mgmt
="NONE")
1088 dev
.wait_regdom(country_ie
=True)
1089 hwsim_utils
.test_connectivity(dev
, hapd
)
1091 clear_regdom(hapd
, devs
)
1093 def test_ap_vht80_to_24g_ht(dev
, apdev
):
1094 """VHT with 80 MHz channel width reconfigured to 2.4 GHz HT"""
1097 params
= {"ssid": "vht",
1098 "country_code": "FI",
1101 "ht_capab": "[HT40+]",
1104 "vht_oper_chwidth": "1",
1105 "vht_capab": "[MAX-MPDU-11454]",
1106 "vht_oper_centr_freq_seg0_idx": "42"}
1107 hapd
= hostapd
.add_ap(apdev
[0], params
)
1108 bssid
= apdev
[0]['bssid']
1111 hapd
.set("ieee80211ac", "0")
1112 hapd
.set("hw_mode", "g")
1113 hapd
.set("channel", "1")
1114 hapd
.set("ht_capab", "")
1115 hapd
.set("vht_capab", "")
1118 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="2412")
1119 except Exception as e
:
1120 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1121 if not vht_supported():
1122 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1125 dev
[0].request("DISCONNECT")
1126 clear_regdom(hapd
, dev
)