]>
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 test_dfs
import wait_dfs_event
16 from test_ap_csa
import csa_supported
19 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
20 reg
= cmd
.stdout
.read()
21 if "@ 80)" in reg
or "@ 160)" in reg
:
25 def test_ap_vht80(dev
, apdev
):
26 """VHT with 80 MHz channel width"""
28 params
= { "ssid": "vht",
32 "ht_capab": "[HT40+]",
35 "vht_oper_chwidth": "1",
36 "vht_oper_centr_freq_seg0_idx": "42" }
37 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
)
39 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
40 hwsim_utils
.test_connectivity(dev
[0], hapd
)
42 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
43 if not vht_supported():
44 logger
.info("80 MHz channel not supported in regulatory information")
48 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])
50 def test_ap_vht80_params(dev
, apdev
):
51 """VHT with 80 MHz channel width and number of optional features enabled"""
53 params
= { "ssid": "vht",
57 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
60 "vht_oper_chwidth": "1",
61 "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
62 "vht_oper_centr_freq_seg0_idx": "42",
64 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
)
66 dev
[1].connect("vht", key_mgmt
="NONE", scan_freq
="5180",
67 disable_vht
="1", wait_connect
=False)
68 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
69 ev
= dev
[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
71 raise Exception("Association rejection timed out")
72 if "status_code=104" not in ev
:
73 raise Exception("Unexpected rejection status code")
74 dev
[1].request("DISCONNECT")
75 hwsim_utils
.test_connectivity(dev
[0], hapd
)
77 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
78 if not vht_supported():
79 logger
.info("80 MHz channel not supported in regulatory information")
83 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])
85 def test_ap_vht_20(devs
, apdevs
):
89 params
= { "ssid": "test-vht20",
97 "vht_oper_chwidth": "0",
98 "vht_oper_centr_freq_seg0_idx": "0",
99 "supported_rates": "60 120 240 360 480 540",
102 hapd
= hostapd
.add_ap(ap
['ifname'], params
)
103 dev
.connect("test-vht20", scan_freq
="5180", key_mgmt
="NONE")
104 hwsim_utils
.test_connectivity(dev
, hapd
)
106 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])
108 def test_ap_vht_capab_not_supported(dev
, apdev
):
109 """VHT configuration with driver not supporting all vht_capab entries"""
111 params
= { "ssid": "vht",
112 "country_code": "FI",
115 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
118 "vht_oper_chwidth": "1",
119 "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][SOUNDING-DIMENSION-2][MU-BEAMFORMER][MU-BEAMFORMEE][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]",
120 "vht_oper_centr_freq_seg0_idx": "42",
122 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
, wait_enabled
=False)
123 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
125 raise Exception("Startup failure not reported")
126 for i
in range(1, 7):
127 if "OK" not in hapd
.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i
):
128 raise Exception("Unexpected SET failure")
130 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])
132 def test_ap_vht160(dev
, apdev
):
133 """VHT with 160 MHz channel width"""
135 params
= { "ssid": "vht",
136 "country_code": "FI",
139 "ht_capab": "[HT40+]",
142 "vht_oper_chwidth": "2",
143 "vht_oper_centr_freq_seg0_idx": "50",
146 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
, wait_enabled
=False)
148 ev
= wait_dfs_event(hapd
, "DFS-CAC-START", 5)
149 if "DFS-CAC-START" not in ev
:
150 raise Exception("Unexpected DFS event")
152 state
= hapd
.get_status_field("state")
154 if state
== "DISABLED" and not os
.path
.exists("dfs"):
155 # Not all systems have recent enough CRDA version and
156 # wireless-regdb changes to support 160 MHz and DFS. For now,
157 # do not report failures for this test case.
159 raise Exception("Unexpected interface state: " + state
)
161 params
= { "ssid": "vht2",
162 "country_code": "FI",
165 "ht_capab": "[HT40+]",
168 "vht_oper_chwidth": "2",
169 "vht_oper_centr_freq_seg0_idx": "114",
172 hapd2
= hostapd
.add_ap(apdev
[1]['ifname'], params
, wait_enabled
=False)
174 ev
= wait_dfs_event(hapd2
, "DFS-CAC-START", 5)
175 if "DFS-CAC-START" not in ev
:
176 raise Exception("Unexpected DFS event(2)")
178 state
= hapd2
.get_status_field("state")
180 raise Exception("Unexpected interface state(2): " + state
)
182 logger
.info("Waiting for CAC to complete")
184 ev
= wait_dfs_event(hapd
, "DFS-CAC-COMPLETED", 70)
185 if "success=1" not in ev
:
186 raise Exception("CAC failed")
187 if "freq=5180" not in ev
:
188 raise Exception("Unexpected DFS freq result")
190 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=5)
192 raise Exception("AP setup timed out")
194 state
= hapd
.get_status_field("state")
195 if state
!= "ENABLED":
196 raise Exception("Unexpected interface state")
198 ev
= wait_dfs_event(hapd2
, "DFS-CAC-COMPLETED", 70)
199 if "success=1" not in ev
:
200 raise Exception("CAC failed(2)")
201 if "freq=5500" not in ev
:
202 raise Exception("Unexpected DFS freq result(2)")
204 ev
= hapd2
.wait_event(["AP-ENABLED"], timeout
=5)
206 raise Exception("AP setup timed out(2)")
208 state
= hapd2
.get_status_field("state")
209 if state
!= "ENABLED":
210 raise Exception("Unexpected interface state(2)")
212 freq
= hapd2
.get_status_field("freq")
214 raise Exception("Unexpected frequency(2)")
216 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5180")
217 hwsim_utils
.test_connectivity(dev
[0], hapd
)
218 dev
[1].connect("vht2", key_mgmt
="NONE", scan_freq
="5500")
219 hwsim_utils
.test_connectivity(dev
[1], hapd2
)
221 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
222 if not vht_supported():
223 logger
.info("80/160 MHz channel not supported in regulatory information")
227 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])
229 def test_ap_vht80plus80(dev
, apdev
):
230 """VHT with 80+80 MHz channel width"""
232 params
= { "ssid": "vht",
233 "country_code": "US",
236 "ht_capab": "[HT40+]",
239 "vht_oper_chwidth": "3",
240 "vht_oper_centr_freq_seg0_idx": "58",
241 "vht_oper_centr_freq_seg1_idx": "155",
244 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
, wait_enabled
=False)
245 # This will actually fail since DFS on 80+80 is not yet supported
246 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=5)
247 # ignore result to avoid breaking the test once 80+80 DFS gets enabled
249 params
= { "ssid": "vht2",
250 "country_code": "US",
253 "ht_capab": "[HT40+]",
256 "vht_oper_chwidth": "3",
257 "vht_oper_centr_freq_seg0_idx": "42",
258 "vht_oper_centr_freq_seg1_idx": "155" }
259 hapd2
= hostapd
.add_ap(apdev
[1]['ifname'], params
, wait_enabled
=False)
261 ev
= hapd2
.wait_event(["AP-ENABLED"], timeout
=5)
263 raise Exception("AP setup timed out(2)")
265 state
= hapd2
.get_status_field("state")
266 if state
!= "ENABLED":
267 raise Exception("Unexpected interface state(2)")
269 dev
[1].connect("vht2", key_mgmt
="NONE", scan_freq
="5180")
270 hwsim_utils
.test_connectivity(dev
[1], hapd2
)
272 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
273 if not vht_supported():
274 logger
.info("80/160 MHz channel not supported in regulatory information")
278 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])
280 def test_ap_vht80_csa(dev
, apdev
):
281 """VHT with 80 MHz channel width and CSA"""
282 if not csa_supported(dev
[0]):
285 params
= { "ssid": "vht",
286 "country_code": "US",
289 "ht_capab": "[HT40+]",
292 "vht_oper_chwidth": "1",
293 "vht_oper_centr_freq_seg0_idx": "155" }
294 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
)
296 dev
[0].connect("vht", key_mgmt
="NONE", scan_freq
="5745")
297 hwsim_utils
.test_connectivity(dev
[0], hapd
)
299 hapd
.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
300 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
302 raise Exception("CSA finished event timed out")
303 if "freq=5180" not in ev
:
304 raise Exception("Unexpected channel in CSA finished event")
306 hwsim_utils
.test_connectivity(dev
[0], hapd
)
308 hapd
.request("CHAN_SWITCH 5 5745")
309 ev
= hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=10)
311 raise Exception("CSA finished event timed out")
312 if "freq=5745" not in ev
:
313 raise Exception("Unexpected channel in CSA finished event")
315 hwsim_utils
.test_connectivity(dev
[0], hapd
)
317 # This CSA to same channel will fail in kernel, so use this only for
318 # extra code coverage.
319 hapd
.request("CHAN_SWITCH 5 5745")
320 hapd
.wait_event(["AP-CSA-FINISHED"], timeout
=1)
322 if isinstance(e
, Exception) and str(e
) == "AP startup failed":
323 if not vht_supported():
324 logger
.info("80 MHz channel not supported in regulatory information")
328 subprocess
.call(['sudo', 'iw', 'reg', 'set', '00'])