]>
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 if 'supp_op_classes' not in sta
or len(sta
['supp_op_classes']) < 2:
79 raise Exception("No Supported Operating Classes information for STA")
80 opclass
= int(sta
['supp_op_classes'][0:2], 16)
82 raise Exception("Unexpected Current Operating Class from STA: %d" % opclass
)
83 except Exception as e
:
84 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
85 if not vht_supported():
86 raise HwsimSkip("80 MHz channel not supported in regulatory information")
89 dev
[0].request("DISCONNECT")
90 clear_regdom(hapd
, dev
)
92 def test_ap_vht_wifi_generation(dev
, apdev
):
93 """VHT and wifi_generation"""
96 params
= {"ssid": "vht",
100 "ht_capab": "[HT40+]",
103 "vht_oper_chwidth": "1",
104 "vht_oper_centr_freq_seg0_idx": "42"}
105 hapd
= hostapd
.add_ap(apdev
[0], params
)
106 bssid
= apdev
[0]['bssid']
108 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
109 status
= dev
[0].get_status()
110 if 'wifi_generation' not in status
:
111 # For now, assume this is because of missing kernel support
112 raise HwsimSkip("Association Request IE reporting not supported")
113 #raise Exception("Missing wifi_generation information")
114 if status
['wifi_generation'] != "5":
115 raise Exception("Unexpected wifi_generation value: " + status
['wifi_generation'])
117 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
118 wpas
.interface_add("wlan5", drv_params
="force_connect_cmd=1")
119 wpas
.connect("vht", key_mgmt
="NONE", scan_freq
="5180")
120 status
= wpas
.get_status()
121 if 'wifi_generation' not in status
:
122 # For now, assume this is because of missing kernel support
123 raise HwsimSkip("Association Request IE reporting not supported")
124 #raise Exception("Missing wifi_generation information (connect)")
125 if status
['wifi_generation'] != "5":
126 raise Exception("Unexpected wifi_generation value (connect): " + status
['wifi_generation'])
127 except Exception as e
:
128 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
129 if not vht_supported():
130 raise HwsimSkip("80 MHz channel not supported in regulatory information")
133 dev
[0].request("DISCONNECT")
134 clear_regdom(hapd
, dev
)
136 def vht80_test(apdev
, dev
, channel
, ht_capab
):
137 clear_scan_cache(apdev
)
140 params
= {"ssid": "vht",
141 "country_code": "FI",
143 "channel": str(channel
),
144 "ht_capab": ht_capab
,
147 "vht_oper_chwidth": "1",
148 "vht_oper_centr_freq_seg0_idx": "42"}
149 hapd
= hostapd
.add_ap(apdev
, params
)
150 bssid
= apdev
['bssid']
152 dev
[0].connect("vht", key_mgmt
="NONE",
153 scan_freq
=str(5000 + 5 * channel
))
154 hwsim_utils
.test_connectivity(dev
[0], hapd
)
155 except Exception as e
:
156 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
157 if not vht_supported():
158 raise HwsimSkip("80 MHz channel not supported in regulatory information")
161 clear_regdom(hapd
, dev
)
163 def test_ap_vht80b(dev
, apdev
):
164 """VHT with 80 MHz channel width (HT40- channel 40)"""
165 vht80_test(apdev
[0], dev
, 40, "[HT40-]")
167 def test_ap_vht80c(dev
, apdev
):
168 """VHT with 80 MHz channel width (HT40+ channel 44)"""
169 vht80_test(apdev
[0], dev
, 44, "[HT40+]")
171 def test_ap_vht80d(dev
, apdev
):
172 """VHT with 80 MHz channel width (HT40- channel 48)"""
173 vht80_test(apdev
[0], dev
, 48, "[HT40-]")
175 def test_ap_vht80_params(dev
, apdev
):
176 """VHT with 80 MHz channel width and number of optional features enabled"""
179 params
= {"ssid": "vht",
180 "country_code": "FI",
183 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
186 "vht_oper_chwidth": "1",
187 "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
188 "vht_oper_centr_freq_seg0_idx": "42",
190 hapd
= hostapd
.add_ap(apdev
[0], params
)
192 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5180",
193 disable_vht
="1", wait_connect
=False)
194 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
195 dev
[2].connect("vht", key_mgmt
="NONE", scan_freq
="5180",
197 ev
= dev
[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
199 raise Exception("Association rejection timed out")
200 if "status_code=104" not in ev
:
201 raise Exception("Unexpected rejection status code")
202 dev
[1].request("DISCONNECT")
203 hwsim_utils
.test_connectivity(dev
[0], hapd
)
204 sta0
= hapd
.get_sta(dev
[0].own_addr())
205 sta2
= hapd
.get_sta(dev
[2].own_addr())
206 capab0
= int(sta0
['vht_caps_info'], base
=16)
207 capab2
= int(sta2
['vht_caps_info'], base
=16)
208 if capab0
& 0x60 == 0:
209 raise Exception("dev[0] did not support SGI")
210 if capab2
& 0x60 != 0:
211 raise Exception("dev[2] claimed support for SGI")
212 except Exception as e
:
213 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
214 if not vht_supported():
215 raise HwsimSkip("80 MHz channel not supported in regulatory information")
218 clear_regdom(hapd
, dev
, count
=3)
220 def test_ap_vht80_invalid(dev
, apdev
):
221 """VHT with invalid 80 MHz channel configuration (seg1)"""
224 params
= {"ssid": "vht",
225 "country_code": "US",
228 "ht_capab": "[HT40+]",
231 "vht_oper_chwidth": "1",
232 "vht_oper_centr_freq_seg0_idx": "42",
233 "vht_oper_centr_freq_seg1_idx": "155",
236 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
237 # This fails due to unexpected seg1 configuration
238 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
240 raise Exception("AP-DISABLED not reported")
241 except Exception as e
:
242 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
243 if not vht_supported():
244 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
247 clear_regdom(hapd
, dev
)
249 def test_ap_vht80_invalid2(dev
, apdev
):
250 """VHT with invalid 80 MHz channel configuration (seg0)"""
253 params
= {"ssid": "vht",
254 "country_code": "US",
257 "ht_capab": "[HT40+]",
260 "vht_oper_chwidth": "1",
261 "vht_oper_centr_freq_seg0_idx": "46",
264 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
265 # This fails due to invalid seg0 configuration
266 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
268 raise Exception("AP-DISABLED not reported")
269 except Exception as e
:
270 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
271 if not vht_supported():
272 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
275 clear_regdom(hapd
, dev
)
277 def test_ap_vht_20(devs
, apdevs
):
278 """VHT and 20 MHz channel"""
283 params
= {"ssid": "test-vht20",
284 "country_code": "DE",
291 "vht_oper_chwidth": "0",
292 "vht_oper_centr_freq_seg0_idx": "0",
293 "supported_rates": "60 120 240 360 480 540",
295 hapd
= hostapd
.add_ap(ap
, params
)
296 dev
.connect("test-vht20", scan_freq
="5180", key_mgmt
="NONE")
297 hwsim_utils
.test_connectivity(dev
, hapd
)
299 sta
= hapd
.get_sta(dev
.own_addr())
300 if 'supp_op_classes' not in sta
or len(sta
['supp_op_classes']) < 2:
301 raise Exception("No Supported Operating Classes information for STA")
302 opclass
= int(sta
['supp_op_classes'][0:2], 16)
304 raise Exception("Unexpected Current Operating Class from STA: %d" % opclass
)
306 dev
.request("DISCONNECT")
307 clear_regdom(hapd
, devs
)
309 def test_ap_vht_40(devs
, apdevs
):
310 """VHT and 40 MHz channel"""
315 params
= {"ssid": "test-vht40",
316 "country_code": "DE",
321 "ht_capab": "[HT40+]",
323 "vht_oper_chwidth": "0",
324 "vht_oper_centr_freq_seg0_idx": "0"}
325 hapd
= hostapd
.add_ap(ap
, params
)
326 dev
.connect("test-vht40", scan_freq
="5180", key_mgmt
="NONE")
327 hwsim_utils
.test_connectivity(dev
, hapd
)
329 sta
= hapd
.get_sta(dev
.own_addr())
330 if 'supp_op_classes' not in sta
or len(sta
['supp_op_classes']) < 2:
331 raise Exception("No Supported Operating Classes information for STA")
332 opclass
= int(sta
['supp_op_classes'][0:2], 16)
334 raise Exception("Unexpected Current Operating Class from STA: %d" % opclass
)
336 dev
.request("DISCONNECT")
337 clear_regdom(hapd
, devs
)
339 def test_ap_vht_capab_not_supported(dev
, apdev
):
340 """VHT configuration with driver not supporting all vht_capab entries"""
342 params
= {"ssid": "vht",
343 "country_code": "FI",
346 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
349 "vht_oper_chwidth": "1",
350 "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]",
351 "vht_oper_centr_freq_seg0_idx": "42",
353 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
354 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
356 raise Exception("Startup failure not reported")
357 for i
in range(1, 7):
358 if "OK" not in hapd
.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i
):
359 raise Exception("Unexpected SET failure")
361 clear_regdom(hapd
, dev
)
363 def test_ap_vht160(dev
, apdev
):
364 """VHT with 160 MHz channel width (1)"""
367 params
= {"ssid": "vht",
368 "country_code": "FI",
371 "ht_capab": "[HT40+]",
374 "vht_oper_chwidth": "2",
375 "vht_oper_centr_freq_seg0_idx": "50",
378 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
380 ev
= wait_dfs_event(hapd
, "DFS-CAC-START", 5)
381 if "DFS-CAC-START" not in ev
:
382 raise Exception("Unexpected DFS event")
384 state
= hapd
.get_status_field("state")
386 if state
== "DISABLED" and not os
.path
.exists("dfs"):
387 # Not all systems have recent enough CRDA version and
388 # wireless-regdb changes to support 160 MHz and DFS. For now,
389 # do not report failures for this test case.
390 raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
391 raise Exception("Unexpected interface state: " + state
)
393 logger
.info("Waiting for CAC to complete")
395 ev
= wait_dfs_event(hapd
, "DFS-CAC-COMPLETED", 70)
396 if "success=1" not in ev
:
397 raise Exception("CAC failed")
398 if "freq=5180" not in ev
:
399 raise Exception("Unexpected DFS freq result")
401 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=5)
403 raise Exception("AP setup timed out")
405 state
= hapd
.get_status_field("state")
406 if state
!= "ENABLED":
407 raise Exception("Unexpected interface state")
409 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
410 dev
[0].wait_regdom(country_ie
=True)
411 hwsim_utils
.test_connectivity(dev
[0], hapd
)
412 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
413 if "FREQUENCY=5180" not in sig
:
414 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
415 if "WIDTH=160 MHz" not in sig
:
416 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
418 sta
= hapd
.get_sta(dev
[0].own_addr())
419 if 'supp_op_classes' not in sta
or len(sta
['supp_op_classes']) < 2:
420 raise Exception("No Supported Operating Classes information for STA")
421 opclass
= int(sta
['supp_op_classes'][0:2], 16)
423 raise Exception("Unexpected Current Operating Class from STA: %d" % opclass
)
424 except Exception as e
:
425 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
426 if not vht_supported():
427 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
431 hapd
.request("DISABLE")
432 dev
[0].disconnect_and_stop_scan()
433 subprocess
.call(['iw', 'reg', 'set', '00'])
434 dev
[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=0.5)
435 dev
[0].flush_scan_cache()
437 def test_ap_vht160b(dev
, apdev
):
438 """VHT with 160 MHz channel width (2)"""
442 params
= {"ssid": "vht",
443 "country_code": "FI",
446 "ht_capab": "[HT40-]",
449 "vht_oper_chwidth": "2",
450 "vht_oper_centr_freq_seg0_idx": "114",
453 hapd
= hostapd
.add_ap(apdev
[1], params
, wait_enabled
=False)
455 ev
= wait_dfs_event(hapd
, "DFS-CAC-START", 5)
456 if "DFS-CAC-START" not in ev
:
457 raise Exception("Unexpected DFS event(2)")
459 state
= hapd
.get_status_field("state")
461 if state
== "DISABLED" and not os
.path
.exists("dfs"):
462 # Not all systems have recent enough CRDA version and
463 # wireless-regdb changes to support 160 MHz and DFS. For now,
464 # do not report failures for this test case.
465 raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
466 raise Exception("Unexpected interface state: " + state
)
468 logger
.info("Waiting for CAC to complete")
470 ev
= wait_dfs_event(hapd
, "DFS-CAC-COMPLETED", 70)
471 if "success=1" not in ev
:
472 raise Exception("CAC failed(2)")
473 if "freq=5520" not in ev
:
474 raise Exception("Unexpected DFS freq result(2)")
476 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=5)
478 raise Exception("AP setup timed out(2)")
480 state
= hapd
.get_status_field("state")
481 if state
!= "ENABLED":
482 raise Exception("Unexpected interface state(2)")
484 freq
= hapd
.get_status_field("freq")
486 raise Exception("Unexpected frequency(2)")
488 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5520")
489 dev
[0].wait_regdom(country_ie
=True)
490 hwsim_utils
.test_connectivity(dev
[0], hapd
)
491 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
492 if "FREQUENCY=5520" not in sig
:
493 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
494 if "WIDTH=160 MHz" not in sig
:
495 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
496 except Exception as e
:
497 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
498 if not vht_supported():
499 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
503 hapd
.request("DISABLE")
504 dev
[0].disconnect_and_stop_scan()
505 subprocess
.call(['iw', 'reg', 'set', '00'])
506 dev
[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=0.5)
507 dev
[0].flush_scan_cache()
509 def test_ap_vht160_no_dfs_100_plus(dev
, apdev
):
510 """VHT with 160 MHz channel width and no DFS (100 plus)"""
511 run_ap_vht160_no_dfs(dev
, apdev
, "100", "[HT40+]")
513 def test_ap_vht160_no_dfs(dev
, apdev
):
514 """VHT with 160 MHz channel width and no DFS (104 minus)"""
515 run_ap_vht160_no_dfs(dev
, apdev
, "104", "[HT40-]")
517 def test_ap_vht160_no_dfs_108_plus(dev
, apdev
):
518 """VHT with 160 MHz channel width and no DFS (108 plus)"""
519 run_ap_vht160_no_dfs(dev
, apdev
, "108", "[HT40+]")
521 def test_ap_vht160_no_dfs_112_minus(dev
, apdev
):
522 """VHT with 160 MHz channel width and no DFS (112 minus)"""
523 run_ap_vht160_no_dfs(dev
, apdev
, "112", "[HT40-]")
525 def test_ap_vht160_no_dfs_116_plus(dev
, apdev
):
526 """VHT with 160 MHz channel width and no DFS (116 plus)"""
527 run_ap_vht160_no_dfs(dev
, apdev
, "116", "[HT40+]")
529 def test_ap_vht160_no_dfs_120_minus(dev
, apdev
):
530 """VHT with 160 MHz channel width and no DFS (120 minus)"""
531 run_ap_vht160_no_dfs(dev
, apdev
, "120", "[HT40-]")
533 def test_ap_vht160_no_dfs_124_plus(dev
, apdev
):
534 """VHT with 160 MHz channel width and no DFS (124 plus)"""
535 run_ap_vht160_no_dfs(dev
, apdev
, "124", "[HT40+]")
537 def test_ap_vht160_no_dfs_128_minus(dev
, apdev
):
538 """VHT with 160 MHz channel width and no DFS (128 minus)"""
539 run_ap_vht160_no_dfs(dev
, apdev
, "128", "[HT40-]")
541 def run_ap_vht160_no_dfs(dev
, apdev
, channel
, ht_capab
):
544 params
= {"ssid": "vht",
545 "country_code": "ZA",
548 "ht_capab": ht_capab
,
551 "vht_oper_chwidth": "2",
552 "vht_oper_centr_freq_seg0_idx": "114",
555 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
556 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=2)
558 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
559 reg
= cmd
.stdout
.readlines()
561 if "5490" in r
and "DFS" in r
:
562 raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
563 raise Exception("AP setup timed out")
565 freq
= str(int(channel
) * 5 + 5000)
566 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
=freq
)
567 dev
[0].wait_regdom(country_ie
=True)
568 hwsim_utils
.test_connectivity(dev
[0], hapd
)
569 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
570 if "FREQUENCY=" + freq
not in sig
:
571 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
572 if "WIDTH=160 MHz" not in sig
:
573 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
574 except Exception as e
:
575 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
576 if not vht_supported():
577 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
580 clear_regdom(hapd
, dev
)
582 def test_ap_vht160_no_ht40(dev
, apdev
):
583 """VHT with 160 MHz channel width and HT40 disabled"""
586 params
= {"ssid": "vht",
587 "country_code": "ZA",
593 "vht_oper_chwidth": "2",
594 "vht_oper_centr_freq_seg0_idx": "114",
597 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
598 ev
= hapd
.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout
=2)
600 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
601 reg
= cmd
.stdout
.readlines()
603 if "5490" in r
and "DFS" in r
:
604 raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
605 raise Exception("AP setup timed out")
606 if "AP-ENABLED" in ev
:
607 # This was supposed to fail due to sec_channel_offset == 0
608 raise Exception("Unexpected AP-ENABLED")
609 except Exception as e
:
610 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
611 if not vht_supported():
612 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
615 clear_regdom(hapd
, dev
)
617 def test_ap_vht80plus80(dev
, apdev
):
618 """VHT with 80+80 MHz channel width"""
622 params
= {"ssid": "vht",
623 "country_code": "US",
626 "ht_capab": "[HT40+]",
629 "vht_oper_chwidth": "3",
630 "vht_oper_centr_freq_seg0_idx": "58",
631 "vht_oper_centr_freq_seg1_idx": "155",
634 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
635 # This will actually fail since DFS on 80+80 is not yet supported
636 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
637 # ignore result to avoid breaking the test once 80+80 DFS gets enabled
639 params
= {"ssid": "vht2",
640 "country_code": "US",
643 "ht_capab": "[HT40+]",
646 "vht_oper_chwidth": "3",
647 "vht_oper_centr_freq_seg0_idx": "42",
648 "vht_oper_centr_freq_seg1_idx": "155"}
649 hapd2
= hostapd
.add_ap(apdev
[1], params
, wait_enabled
=False)
651 ev
= hapd2
.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout
=5)
653 raise Exception("AP setup timed out(2)")
654 if "AP-DISABLED" in ev
:
655 # Assume this failed due to missing regulatory update for now
656 raise HwsimSkip("80+80 MHz channel not supported in regulatory information")
658 state
= hapd2
.get_status_field("state")
659 if state
!= "ENABLED":
660 raise Exception("Unexpected interface state(2)")
662 dev
[1].connect("vht2", key_mgmt
="NONE", scan_freq
="5180")
663 hwsim_utils
.test_connectivity(dev
[1], hapd2
)
664 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
665 if "FREQUENCY=5180" not in sig
:
666 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
667 if "WIDTH=80+80 MHz" not in sig
:
668 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
669 if "CENTER_FRQ1=5210" not in sig
:
670 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
671 if "CENTER_FRQ2=5775" not in sig
:
672 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
674 sta
= hapd2
.get_sta(dev
[1].own_addr())
675 if 'supp_op_classes' not in sta
or len(sta
['supp_op_classes']) < 2:
676 raise Exception("No Supported Operating Classes information for STA")
677 opclass
= int(sta
['supp_op_classes'][0:2], 16)
679 raise Exception("Unexpected Current Operating Class from STA: %d" % opclass
)
680 except Exception as e
:
681 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
682 if not vht_supported():
683 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
686 dev
[0].request("DISCONNECT")
687 dev
[1].request("DISCONNECT")
689 hapd
.request("DISABLE")
691 hapd2
.request("DISABLE")
692 subprocess
.call(['iw', 'reg', 'set', '00'])
693 dev
[0].flush_scan_cache()
694 dev
[1].flush_scan_cache()
696 def test_ap_vht80plus80_invalid(dev
, apdev
):
697 """VHT with invalid 80+80 MHz channel"""
700 params
= {"ssid": "vht",
701 "country_code": "US",
704 "ht_capab": "[HT40+]",
707 "vht_oper_chwidth": "3",
708 "vht_oper_centr_freq_seg0_idx": "42",
709 "vht_oper_centr_freq_seg1_idx": "0",
712 hapd
= hostapd
.add_ap(apdev
[0], params
, wait_enabled
=False)
713 # This fails due to missing(invalid) seg1 configuration
714 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
716 raise Exception("AP-DISABLED not reported")
717 except Exception as e
:
718 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
719 if not vht_supported():
720 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
723 clear_regdom(hapd
, dev
)
725 def test_ap_vht80_csa(dev
, apdev
):
726 """VHT with 80 MHz channel width and CSA"""
727 csa_supported(dev
[0])
730 params
= {"ssid": "vht",
731 "country_code": "US",
734 "ht_capab": "[HT40+]",
737 "vht_oper_chwidth": "1",
738 "vht_oper_centr_freq_seg0_idx": "155"}
739 hapd
= hostapd
.add_ap(apdev
[0], params
)
741 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
742 hwsim_utils
.test_connectivity(dev
[0], hapd
)
744 hapd
.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
745 ev
= hapd
.wait_event(["CTRL-EVENT-STARTED-CHANNEL-SWITCH"], timeout
=10)
747 raise Exception("Channel switch start event not seen")
748 if "freq=5180" not in ev
:
749 raise Exception("Unexpected channel in CS started")
750 ev
= hapd
.wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=10)
752 raise Exception("Channel switch completion event not seen")
753 if "freq=5180" not in ev
:
754 raise Exception("Unexpected channel in CS completed")
755 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
757 raise Exception("CSA finished event timed out")
758 if "freq=5180" not in ev
:
759 raise Exception("Unexpected channel in CSA finished event")
761 hwsim_utils
.test_connectivity(dev
[0], hapd
)
763 hapd
.request("CHAN_SWITCH 5 5745")
764 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
766 raise Exception("CSA finished event timed out")
767 if "freq=5745" not in ev
:
768 raise Exception("Unexpected channel in CSA finished event")
770 hwsim_utils
.test_connectivity(dev
[0], hapd
)
772 # This CSA to same channel will fail in kernel, so use this only for
773 # extra code coverage.
774 hapd
.request("CHAN_SWITCH 5 5745")
775 hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=1)
776 except Exception as e
:
777 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
778 if not vht_supported():
779 raise HwsimSkip("80 MHz channel not supported in regulatory information")
782 dev
[0].request("DISCONNECT")
783 clear_regdom(hapd
, dev
)
785 def test_ap_vht_csa_vht40(dev
, apdev
):
786 """VHT CSA with VHT40 getting enabled"""
787 csa_supported(dev
[0])
790 params
= {"ssid": "vht",
791 "country_code": "US",
794 "ht_capab": "[HT40+]",
797 hapd
= hostapd
.add_ap(apdev
[0], params
)
798 bssid
= hapd
.own_addr()
800 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
801 hwsim_utils
.test_connectivity(dev
[0], hapd
)
803 hapd
.request("CHAN_SWITCH 5 5765 sec_channel_offset=-1 center_freq1=5755 bandwidth=40 vht")
804 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
806 raise Exception("CSA finished event timed out")
807 if "freq=5765" not in ev
:
808 raise Exception("Unexpected channel in CSA finished event")
809 ev
= dev
[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=5)
811 raise Exception("Channel switch event not seen")
812 if "freq=5765" not in ev
:
813 raise Exception("Channel mismatch: " + ev
)
814 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout
=0.5)
816 raise Exception("Unexpected disconnection event from station")
817 hwsim_utils
.test_connectivity(dev
[0], hapd
)
819 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5765")
820 hwsim_utils
.test_connectivity(dev
[1], hapd
)
822 if dev
[1].get_status_field("ieee80211ac") != '1':
823 raise Exception("VHT not enabled as part of channel switch")
825 dev
[0].request("DISCONNECT")
826 dev
[1].request("DISCONNECT")
828 hapd
.request("DISABLE")
829 subprocess
.call(['iw', 'reg', 'set', '00'])
830 dev
[0].flush_scan_cache()
831 dev
[1].flush_scan_cache()
833 def test_ap_vht_csa_vht20(dev
, apdev
):
834 """VHT CSA with VHT20 getting enabled"""
835 csa_supported(dev
[0])
838 params
= {"ssid": "vht",
839 "country_code": "US",
842 "ht_capab": "[HT40+]",
845 hapd
= hostapd
.add_ap(apdev
[0], params
)
846 bssid
= hapd
.own_addr()
848 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
849 hwsim_utils
.test_connectivity(dev
[0], hapd
)
851 hapd
.request("CHAN_SWITCH 5 5200 center_freq1=5200 bandwidth=20 vht")
852 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
854 raise Exception("CSA finished event timed out")
855 if "freq=5200" not in ev
:
856 raise Exception("Unexpected channel in CSA finished event")
858 hwsim_utils
.test_connectivity(dev
[0], hapd
)
860 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5200")
861 hwsim_utils
.test_connectivity(dev
[1], hapd
)
863 if dev
[1].get_status_field("ieee80211ac") != '1':
864 raise Exception("VHT not enabled as part of channel switch")
866 dev
[0].request("DISCONNECT")
867 dev
[1].request("DISCONNECT")
869 hapd
.request("DISABLE")
870 subprocess
.call(['iw', 'reg', 'set', '00'])
871 dev
[0].flush_scan_cache()
872 dev
[1].flush_scan_cache()
874 def test_ap_vht_csa_vht40_disable(dev
, apdev
):
875 """VHT CSA with VHT40 getting disabled"""
876 csa_supported(dev
[0])
879 params
= {"ssid": "vht",
880 "country_code": "US",
883 "ht_capab": "[HT40+]",
887 "vht_oper_chwidth": "0",
888 "vht_oper_centr_freq_seg0_idx": "0"}
889 hapd
= hostapd
.add_ap(apdev
[0], params
)
890 bssid
= hapd
.own_addr()
892 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
893 hwsim_utils
.test_connectivity(dev
[0], hapd
)
895 hapd
.request("CHAN_SWITCH 5 5200 center_freq1=5210 sec_channel_offset=1 bandwidth=40 ht")
896 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
898 raise Exception("CSA finished event timed out")
899 if "freq=5200" not in ev
:
900 raise Exception("Unexpected channel in CSA finished event")
901 ev
= dev
[0].wait_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=5)
903 raise Exception("Channel switch event not seen")
904 if "freq=5200" not in ev
:
905 raise Exception("Channel mismatch: " + ev
)
907 hwsim_utils
.test_connectivity(dev
[0], hapd
)
909 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5200")
910 hwsim_utils
.test_connectivity(dev
[1], hapd
)
912 if dev
[1].get_status_field("ieee80211ac") == '1':
913 raise Exception("VHT not disabled as part of channel switch")
915 dev
[0].request("DISCONNECT")
916 dev
[1].request("DISCONNECT")
918 hapd
.request("DISABLE")
919 subprocess
.call(['iw', 'reg', 'set', '00'])
920 dev
[0].flush_scan_cache()
921 dev
[1].flush_scan_cache()
923 def test_ap_vht_on_24ghz(dev
, apdev
):
924 """Subset of VHT features on 2.4 GHz"""
926 params
= {"ssid": "test-vht-2g",
931 "vht_capab": "[MAX-MPDU-11454]",
932 "vht_oper_chwidth": "0",
933 "vht_oper_centr_freq_seg0_idx": "1"}
934 hapd
= hostapd
.add_ap(apdev
[0], params
)
936 if "OK" not in dev
[0].request("VENDOR_ELEM_ADD 13 dd1300904c0400bf0c3240820feaff0000eaff0000"):
937 raise Exception("Failed to add vendor element")
938 dev
[0].connect("test-vht-2g", scan_freq
="2412", key_mgmt
="NONE")
940 hwsim_utils
.test_connectivity(dev
[0], hapd
)
941 sta
= hapd
.get_sta(dev
[0].own_addr())
942 if '[VENDOR_VHT]' not in sta
['flags']:
943 raise Exception("No VENDOR_VHT STA flag")
945 dev
[1].connect("test-vht-2g", scan_freq
="2412", key_mgmt
="NONE")
947 sta
= hapd
.get_sta(dev
[1].own_addr())
948 if '[VENDOR_VHT]' in sta
['flags']:
949 raise Exception("Unexpected VENDOR_VHT STA flag")
951 status
= dev
[0].get_status()
952 if 'wifi_generation' in status
:
953 if status
['wifi_generation'] != "4":
954 raise Exception("Unexpected wifi_generation value: " + status
['wifi_generation'])
956 status
= dev
[1].get_status()
957 if 'wifi_generation' in status
:
958 if status
['wifi_generation'] != "4":
959 raise Exception("Unexpected wifi_generation value(2): " + status
['wifi_generation'])
961 dev
[0].request("VENDOR_ELEM_REMOVE 13 *")
963 def test_ap_vht_on_24ghz_2(dev
, apdev
):
964 """Subset of VHT features on 2.4 GHz (2)"""
966 params
= {"ssid": "test-vht-2g",
972 "vht_capab": "[MAX-MPDU-11454]",
973 "vht_oper_chwidth": "0",
974 "vht_oper_centr_freq_seg0_idx": "1"}
975 hapd
= hostapd
.add_ap(apdev
[0], params
)
977 if "OK" not in dev
[0].request("VENDOR_ELEM_ADD 13 bf0cfa048003aaaa0000aaaa0000dd1300904c0400bf0c3240820feaff0000eaff0000"):
978 raise Exception("Failed to add vendor element")
979 dev
[0].connect("test-vht-2g", scan_freq
="2412", key_mgmt
="NONE")
981 hwsim_utils
.test_connectivity(dev
[0], hapd
)
982 sta
= hapd
.get_sta(dev
[0].own_addr())
983 if '[VHT]' not in sta
['flags']:
984 raise Exception("No VHT STA flag")
986 dev
[1].connect("test-vht-2g", scan_freq
="2412", key_mgmt
="NONE")
988 sta
= hapd
.get_sta(dev
[1].own_addr())
989 if '[VENDOR_VHT]' in sta
['flags']:
990 raise Exception("Unexpected VENDOR_VHT STA flag")
991 if '[VHT]' in sta
['flags']:
992 raise Exception("Unexpected VHT STA flag")
994 status
= dev
[0].get_status()
995 if 'wifi_generation' in status
:
996 if status
['wifi_generation'] != "4":
997 raise Exception("Unexpected wifi_generation value: " + status
['wifi_generation'])
999 status
= dev
[1].get_status()
1000 if 'wifi_generation' in status
:
1001 if status
['wifi_generation'] != "4":
1002 raise Exception("Unexpected wifi_generation value(2): " + status
['wifi_generation'])
1004 dev
[0].request("VENDOR_ELEM_REMOVE 13 *")
1006 def test_prefer_vht40(dev
, apdev
):
1007 """Preference on VHT40 over HT40"""
1011 params
= {"ssid": "test",
1012 "country_code": "FI",
1016 "ht_capab": "[HT40+]"}
1017 hapd
= hostapd
.add_ap(apdev
[0], params
)
1018 bssid
= apdev
[0]['bssid']
1020 params
= {"ssid": "test",
1021 "country_code": "FI",
1026 "ht_capab": "[HT40+]",
1028 "vht_oper_chwidth": "0",
1029 "vht_oper_centr_freq_seg0_idx": "0"}
1030 hapd2
= hostapd
.add_ap(apdev
[1], params
)
1031 bssid2
= apdev
[1]['bssid']
1033 dev
[0].scan_for_bss(bssid
, freq
=5180)
1034 dev
[0].scan_for_bss(bssid2
, freq
=5180)
1035 dev
[0].connect("test", scan_freq
="5180", key_mgmt
="NONE")
1036 if dev
[0].get_status_field('bssid') != bssid2
:
1037 raise Exception("Unexpected BSS selected")
1039 est
= dev
[0].get_bss(bssid
)['est_throughput']
1041 raise Exception("Unexpected BSS0 est_throughput: " + est
)
1043 est
= dev
[0].get_bss(bssid2
)['est_throughput']
1045 raise Exception("Unexpected BSS1 est_throughput: " + est
)
1047 dev
[0].request("DISCONNECT")
1050 clear_regdom_dev(dev
)
1052 def test_ap_vht80_pwr_constraint(dev
, apdev
):
1053 """VHT with 80 MHz channel width and local power constraint"""
1056 params
= {"ssid": "vht",
1057 "country_code": "FI",
1060 "ht_capab": "[HT40+]",
1062 "local_pwr_constraint": "3",
1065 "vht_oper_chwidth": "1",
1066 "vht_oper_centr_freq_seg0_idx": "42"}
1067 hapd
= hostapd
.add_ap(apdev
[0], params
)
1069 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
1070 dev
[0].wait_regdom(country_ie
=True)
1071 except Exception as e
:
1072 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1073 if not vht_supported():
1074 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1078 hapd
.request("DISABLE")
1079 dev
[0].disconnect_and_stop_scan()
1080 subprocess
.call(['iw', 'reg', 'set', '00'])
1081 dev
[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=0.5)
1082 dev
[0].flush_scan_cache()
1084 def test_ap_vht_use_sta_nsts(dev
, apdev
):
1085 """VHT with 80 MHz channel width and use_sta_nsts=1"""
1088 params
= {"ssid": "vht",
1089 "country_code": "FI",
1092 "ht_capab": "[HT40+]",
1095 "vht_oper_chwidth": "1",
1096 "vht_oper_centr_freq_seg0_idx": "42",
1097 "use_sta_nsts": "1"}
1098 hapd
= hostapd
.add_ap(apdev
[0], params
)
1099 bssid
= apdev
[0]['bssid']
1101 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
1102 hwsim_utils
.test_connectivity(dev
[0], hapd
)
1103 except Exception as e
:
1104 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1105 if not vht_supported():
1106 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1109 clear_regdom(hapd
, dev
)
1111 def test_ap_vht_tkip(dev
, apdev
):
1115 params
= {"ssid": "vht",
1117 "wpa_key_mgmt": "WPA-PSK",
1118 "wpa_pairwise": "TKIP",
1119 "wpa_passphrase": "12345678",
1120 "country_code": "FI",
1123 "ht_capab": "[HT40+]",
1126 "vht_oper_chwidth": "1",
1127 "vht_oper_centr_freq_seg0_idx": "42"}
1128 hapd
= hostapd
.add_ap(apdev
[0], params
)
1129 bssid
= apdev
[0]['bssid']
1131 dev
[0].connect("vht", psk
="12345678", scan_freq
="5180")
1132 hwsim_utils
.test_connectivity(dev
[0], hapd
)
1133 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1134 if "FREQUENCY=5180" not in sig
:
1135 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
1136 if "WIDTH=20 MHz (no HT)" not in sig
:
1137 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1138 status
= hapd
.get_status()
1139 logger
.info("hostapd STATUS: " + str(status
))
1140 if status
["ieee80211n"] != "0":
1141 raise Exception("Unexpected STATUS ieee80211n value")
1142 if status
["ieee80211ac"] != "0":
1143 raise Exception("Unexpected STATUS ieee80211ac value")
1144 if status
["secondary_channel"] != "0":
1145 raise Exception("Unexpected STATUS secondary_channel value")
1146 except Exception as e
:
1147 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1148 if not vht_supported():
1149 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1152 dev
[0].request("DISCONNECT")
1153 clear_regdom(hapd
, dev
)
1155 def test_ap_vht_40_fallback_to_20(devs
, apdevs
):
1156 """VHT and 40 MHz channel configuration falling back to 20 MHz"""
1161 params
= {"ssid": "test-vht40",
1162 "country_code": "US",
1164 "basic_rates": "60 120 240",
1170 "ht_capab": "[HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]",
1171 "vht_capab": "[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC1][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]",
1172 "vht_oper_chwidth": "0",
1173 "vht_oper_centr_freq_seg0_idx": "155"}
1174 hapd
= hostapd
.add_ap(ap
, params
)
1175 dev
.connect("test-vht40", scan_freq
="5805", key_mgmt
="NONE")
1176 dev
.wait_regdom(country_ie
=True)
1177 hwsim_utils
.test_connectivity(dev
, hapd
)
1179 clear_regdom(hapd
, devs
)
1181 def test_ap_vht80_to_24g_ht(dev
, apdev
):
1182 """VHT with 80 MHz channel width reconfigured to 2.4 GHz HT"""
1185 params
= {"ssid": "vht",
1186 "country_code": "FI",
1189 "ht_capab": "[HT40+]",
1192 "vht_oper_chwidth": "1",
1193 "vht_capab": "[MAX-MPDU-11454]",
1194 "vht_oper_centr_freq_seg0_idx": "42"}
1195 hapd
= hostapd
.add_ap(apdev
[0], params
)
1196 bssid
= apdev
[0]['bssid']
1199 hapd
.set("ieee80211ac", "0")
1200 hapd
.set("hw_mode", "g")
1201 hapd
.set("channel", "1")
1202 hapd
.set("ht_capab", "")
1203 hapd
.set("vht_capab", "")
1206 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="2412")
1207 except Exception as e
:
1208 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
1209 if not vht_supported():
1210 raise HwsimSkip("80 MHz channel not supported in regulatory information")
1213 dev
[0].request("DISCONNECT")
1214 clear_regdom(hapd
, dev
)