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):
86 """VHT and 20 MHz channel"""
90 params = { "ssid": "test-vht20",
98 "vht_oper_chwidth": "0",
99 "vht_oper_centr_freq_seg0_idx": "0",
100 "supported_rates": "60 120 240 360 480 540",
103 hapd = hostapd.add_ap(ap['ifname'], params)
104 dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
105 hwsim_utils.test_connectivity(dev, hapd)
107 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
109 def test_ap_vht_capab_not_supported(dev, apdev):
110 """VHT configuration with driver not supporting all vht_capab entries"""
112 params = { "ssid": "vht",
113 "country_code": "FI",
116 "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
119 "vht_oper_chwidth": "1",
120 "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]",
121 "vht_oper_centr_freq_seg0_idx": "42",
123 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
124 ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
126 raise Exception("Startup failure not reported")
127 for i in range(1, 7):
128 if "OK" not in hapd.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i):
129 raise Exception("Unexpected SET failure")
131 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
133 def test_ap_vht160(dev, apdev):
134 """VHT with 160 MHz channel width"""
136 params = { "ssid": "vht",
137 "country_code": "FI",
140 "ht_capab": "[HT40+]",
143 "vht_oper_chwidth": "2",
144 "vht_oper_centr_freq_seg0_idx": "50",
147 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
149 ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
150 if "DFS-CAC-START" not in ev:
151 raise Exception("Unexpected DFS event")
153 state = hapd.get_status_field("state")
155 if state == "DISABLED" and not os.path.exists("dfs"):
156 # Not all systems have recent enough CRDA version and
157 # wireless-regdb changes to support 160 MHz and DFS. For now,
158 # do not report failures for this test case.
160 raise Exception("Unexpected interface state: " + state)
162 params = { "ssid": "vht2",
163 "country_code": "FI",
166 "ht_capab": "[HT40+]",
169 "vht_oper_chwidth": "2",
170 "vht_oper_centr_freq_seg0_idx": "114",
173 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params, wait_enabled=False)
175 ev = wait_dfs_event(hapd2, "DFS-CAC-START", 5)
176 if "DFS-CAC-START" not in ev:
177 raise Exception("Unexpected DFS event(2)")
179 state = hapd2.get_status_field("state")
181 raise Exception("Unexpected interface state(2): " + state)
183 logger.info("Waiting for CAC to complete")
185 ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
186 if "success=1" not in ev:
187 raise Exception("CAC failed")
188 if "freq=5180" not in ev:
189 raise Exception("Unexpected DFS freq result")
191 ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
193 raise Exception("AP setup timed out")
195 state = hapd.get_status_field("state")
196 if state != "ENABLED":
197 raise Exception("Unexpected interface state")
199 ev = wait_dfs_event(hapd2, "DFS-CAC-COMPLETED", 70)
200 if "success=1" not in ev:
201 raise Exception("CAC failed(2)")
202 if "freq=5500" not in ev:
203 raise Exception("Unexpected DFS freq result(2)")
205 ev = hapd2.wait_event(["AP-ENABLED"], timeout=5)
207 raise Exception("AP setup timed out(2)")
209 state = hapd2.get_status_field("state")
210 if state != "ENABLED":
211 raise Exception("Unexpected interface state(2)")
213 freq = hapd2.get_status_field("freq")
215 raise Exception("Unexpected frequency(2)")
217 dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
218 hwsim_utils.test_connectivity(dev[0], hapd)
219 dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5500")
220 hwsim_utils.test_connectivity(dev[1], hapd2)
222 if isinstance(e, Exception) and str(e) == "AP startup failed":
223 if not vht_supported():
224 logger.info("80/160 MHz channel not supported in regulatory information")
228 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
230 def test_ap_vht80plus80(dev, apdev):
231 """VHT with 80+80 MHz channel width"""
233 params = { "ssid": "vht",
234 "country_code": "US",
237 "ht_capab": "[HT40+]",
240 "vht_oper_chwidth": "3",
241 "vht_oper_centr_freq_seg0_idx": "58",
242 "vht_oper_centr_freq_seg1_idx": "155",
245 hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
246 # This will actually fail since DFS on 80+80 is not yet supported
247 ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
248 # ignore result to avoid breaking the test once 80+80 DFS gets enabled
250 params = { "ssid": "vht2",
251 "country_code": "US",
254 "ht_capab": "[HT40+]",
257 "vht_oper_chwidth": "3",
258 "vht_oper_centr_freq_seg0_idx": "42",
259 "vht_oper_centr_freq_seg1_idx": "155" }
260 hapd2 = hostapd.add_ap(apdev[1]['ifname'], params, wait_enabled=False)
262 ev = hapd2.wait_event(["AP-ENABLED"], timeout=5)
264 raise Exception("AP setup timed out(2)")
266 state = hapd2.get_status_field("state")
267 if state != "ENABLED":
268 raise Exception("Unexpected interface state(2)")
270 dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5180")
271 hwsim_utils.test_connectivity(dev[1], hapd2)
273 if isinstance(e, Exception) and str(e) == "AP startup failed":
274 if not vht_supported():
275 logger.info("80/160 MHz channel not supported in regulatory information")
279 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
281 def test_ap_vht80_csa(dev, apdev):
282 """VHT with 80 MHz channel width and CSA"""
283 if not csa_supported(dev[0]):
286 params = { "ssid": "vht",
287 "country_code": "US",
290 "ht_capab": "[HT40+]",
293 "vht_oper_chwidth": "1",
294 "vht_oper_centr_freq_seg0_idx": "155" }
295 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
297 dev[0].connect("vht", key_mgmt="NONE", scan_freq="5745")
298 hwsim_utils.test_connectivity(dev[0], hapd)
300 hapd.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
301 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
303 raise Exception("CSA finished event timed out")
304 if "freq=5180" not in ev:
305 raise Exception("Unexpected channel in CSA finished event")
307 hwsim_utils.test_connectivity(dev[0], hapd)
309 hapd.request("CHAN_SWITCH 5 5745")
310 ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
312 raise Exception("CSA finished event timed out")
313 if "freq=5745" not in ev:
314 raise Exception("Unexpected channel in CSA finished event")
316 hwsim_utils.test_connectivity(dev[0], hapd)
318 # This CSA to same channel will fail in kernel, so use this only for
319 # extra code coverage.
320 hapd.request("CHAN_SWITCH 5 5745")
321 hapd.wait_event(["AP-CSA-FINISHED"], timeout=1)
323 if isinstance(e, Exception) and str(e) == "AP startup failed":
324 if not vht_supported():
325 logger.info("80 MHz channel not supported in regulatory information")
329 subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])