test_ap_vht.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. # Test cases for VHT operations with hostapd
  2. # Copyright (c) 2014, Qualcomm Atheros, Inc.
  3. # Copyright (c) 2013, Intel Corporation
  4. #
  5. # This software may be distributed under the terms of the BSD license.
  6. # See README for more details.
  7. import logging
  8. logger = logging.getLogger()
  9. import os
  10. import subprocess, time
  11. import hwsim_utils
  12. import hostapd
  13. from utils import HwsimSkip
  14. from test_dfs import wait_dfs_event
  15. from test_ap_csa import csa_supported
  16. from test_ap_ht import clear_scan_cache
  17. def vht_supported():
  18. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  19. reg = cmd.stdout.read()
  20. if "@ 80)" in reg or "@ 160)" in reg:
  21. return True
  22. return False
  23. def test_ap_vht80(dev, apdev):
  24. """VHT with 80 MHz channel width"""
  25. try:
  26. hapd = None
  27. params = { "ssid": "vht",
  28. "country_code": "FI",
  29. "hw_mode": "a",
  30. "channel": "36",
  31. "ht_capab": "[HT40+]",
  32. "ieee80211n": "1",
  33. "ieee80211ac": "1",
  34. "vht_oper_chwidth": "1",
  35. "vht_oper_centr_freq_seg0_idx": "42" }
  36. hapd = hostapd.add_ap(apdev[0], params)
  37. bssid = apdev[0]['bssid']
  38. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  39. hwsim_utils.test_connectivity(dev[0], hapd)
  40. sig = dev[0].request("SIGNAL_POLL").splitlines()
  41. if "FREQUENCY=5180" not in sig:
  42. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  43. if "WIDTH=80 MHz" not in sig:
  44. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  45. est = dev[0].get_bss(bssid)['est_throughput']
  46. if est != "390001":
  47. raise Exception("Unexpected BSS est_throughput: " + est)
  48. except Exception, e:
  49. if isinstance(e, Exception) and str(e) == "AP startup failed":
  50. if not vht_supported():
  51. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  52. raise
  53. finally:
  54. dev[0].request("DISCONNECT")
  55. if hapd:
  56. hapd.request("DISABLE")
  57. subprocess.call(['iw', 'reg', 'set', '00'])
  58. dev[0].flush_scan_cache()
  59. def vht80_test(apdev, dev, channel, ht_capab):
  60. clear_scan_cache(apdev['ifname'])
  61. try:
  62. hapd = None
  63. params = { "ssid": "vht",
  64. "country_code": "FI",
  65. "hw_mode": "a",
  66. "channel": str(channel),
  67. "ht_capab": ht_capab,
  68. "ieee80211n": "1",
  69. "ieee80211ac": "1",
  70. "vht_oper_chwidth": "1",
  71. "vht_oper_centr_freq_seg0_idx": "42" }
  72. hapd = hostapd.add_ap(apdev, params)
  73. bssid = apdev['bssid']
  74. dev.connect("vht", key_mgmt="NONE", scan_freq=str(5000 + 5 * channel))
  75. hwsim_utils.test_connectivity(dev, hapd)
  76. except Exception, e:
  77. if isinstance(e, Exception) and str(e) == "AP startup failed":
  78. if not vht_supported():
  79. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  80. raise
  81. finally:
  82. dev.request("DISCONNECT")
  83. if hapd:
  84. hapd.request("DISABLE")
  85. subprocess.call(['iw', 'reg', 'set', '00'])
  86. dev.flush_scan_cache()
  87. def test_ap_vht80b(dev, apdev):
  88. """VHT with 80 MHz channel width (HT40- channel 40)"""
  89. vht80_test(apdev[0], dev[0], 40, "[HT40-]")
  90. def test_ap_vht80c(dev, apdev):
  91. """VHT with 80 MHz channel width (HT40+ channel 44)"""
  92. vht80_test(apdev[0], dev[0], 44, "[HT40+]")
  93. def test_ap_vht80d(dev, apdev):
  94. """VHT with 80 MHz channel width (HT40- channel 48)"""
  95. vht80_test(apdev[0], dev[0], 48, "[HT40-]")
  96. def test_ap_vht80_params(dev, apdev):
  97. """VHT with 80 MHz channel width and number of optional features enabled"""
  98. try:
  99. hapd = None
  100. params = { "ssid": "vht",
  101. "country_code": "FI",
  102. "hw_mode": "a",
  103. "channel": "36",
  104. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  105. "ieee80211n": "1",
  106. "ieee80211ac": "1",
  107. "vht_oper_chwidth": "1",
  108. "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
  109. "vht_oper_centr_freq_seg0_idx": "42",
  110. "require_vht": "1" }
  111. hapd = hostapd.add_ap(apdev[0], params)
  112. dev[1].connect("vht", key_mgmt="NONE", scan_freq="5180",
  113. disable_vht="1", wait_connect=False)
  114. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  115. ev = dev[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
  116. if ev is None:
  117. raise Exception("Association rejection timed out")
  118. if "status_code=104" not in ev:
  119. raise Exception("Unexpected rejection status code")
  120. dev[1].request("DISCONNECT")
  121. hwsim_utils.test_connectivity(dev[0], hapd)
  122. except Exception, 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")
  126. raise
  127. finally:
  128. dev[0].request("DISCONNECT")
  129. dev[1].request("DISCONNECT")
  130. if hapd:
  131. hapd.request("DISABLE")
  132. subprocess.call(['iw', 'reg', 'set', '00'])
  133. dev[0].flush_scan_cache()
  134. dev[1].flush_scan_cache()
  135. def test_ap_vht80_invalid(dev, apdev):
  136. """VHT with invalid 80 MHz channel configuration (seg1)"""
  137. try:
  138. hapd = None
  139. params = { "ssid": "vht",
  140. "country_code": "US",
  141. "hw_mode": "a",
  142. "channel": "36",
  143. "ht_capab": "[HT40+]",
  144. "ieee80211n": "1",
  145. "ieee80211ac": "1",
  146. "vht_oper_chwidth": "1",
  147. "vht_oper_centr_freq_seg0_idx": "42",
  148. "vht_oper_centr_freq_seg1_idx": "155",
  149. 'ieee80211d': '1',
  150. 'ieee80211h': '1' }
  151. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  152. # This fails due to unexpected seg1 configuration
  153. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  154. if ev is None:
  155. raise Exception("AP-DISABLED not reported")
  156. except Exception, e:
  157. if isinstance(e, Exception) and str(e) == "AP startup failed":
  158. if not vht_supported():
  159. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  160. raise
  161. finally:
  162. if hapd:
  163. hapd.request("DISABLE")
  164. subprocess.call(['iw', 'reg', 'set', '00'])
  165. def test_ap_vht80_invalid2(dev, apdev):
  166. """VHT with invalid 80 MHz channel configuration (seg0)"""
  167. try:
  168. hapd = None
  169. params = { "ssid": "vht",
  170. "country_code": "US",
  171. "hw_mode": "a",
  172. "channel": "36",
  173. "ht_capab": "[HT40+]",
  174. "ieee80211n": "1",
  175. "ieee80211ac": "1",
  176. "vht_oper_chwidth": "1",
  177. "vht_oper_centr_freq_seg0_idx": "46",
  178. 'ieee80211d': '1',
  179. 'ieee80211h': '1' }
  180. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  181. # This fails due to invalid seg0 configuration
  182. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  183. if ev is None:
  184. raise Exception("AP-DISABLED not reported")
  185. except Exception, e:
  186. if isinstance(e, Exception) and str(e) == "AP startup failed":
  187. if not vht_supported():
  188. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  189. raise
  190. finally:
  191. if hapd:
  192. hapd.request("DISABLE")
  193. subprocess.call(['iw', 'reg', 'set', '00'])
  194. def test_ap_vht_20(devs, apdevs):
  195. """VHT and 20 MHz channel"""
  196. dev = devs[0]
  197. ap = apdevs[0]
  198. try:
  199. hapd = None
  200. params = { "ssid": "test-vht20",
  201. "country_code": "DE",
  202. "hw_mode": "a",
  203. "channel": "36",
  204. "ieee80211n": "1",
  205. "ieee80211ac": "1",
  206. "ht_capab": "",
  207. "vht_capab": "",
  208. "vht_oper_chwidth": "0",
  209. "vht_oper_centr_freq_seg0_idx": "0",
  210. "supported_rates": "60 120 240 360 480 540",
  211. "require_vht": "1",
  212. }
  213. hapd = hostapd.add_ap(ap, params)
  214. dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
  215. hwsim_utils.test_connectivity(dev, hapd)
  216. finally:
  217. dev.request("DISCONNECT")
  218. if hapd:
  219. hapd.request("DISABLE")
  220. subprocess.call(['iw', 'reg', 'set', '00'])
  221. dev.flush_scan_cache()
  222. def test_ap_vht_40(devs, apdevs):
  223. """VHT and 40 MHz channel"""
  224. dev = devs[0]
  225. ap = apdevs[0]
  226. try:
  227. hapd = None
  228. params = { "ssid": "test-vht40",
  229. "country_code": "DE",
  230. "hw_mode": "a",
  231. "channel": "36",
  232. "ieee80211n": "1",
  233. "ieee80211ac": "1",
  234. "ht_capab": "[HT40+]",
  235. "vht_capab": "",
  236. "vht_oper_chwidth": "0",
  237. "vht_oper_centr_freq_seg0_idx": "0",
  238. }
  239. hapd = hostapd.add_ap(ap, params)
  240. dev.connect("test-vht40", scan_freq="5180", key_mgmt="NONE")
  241. hwsim_utils.test_connectivity(dev, hapd)
  242. finally:
  243. dev.request("DISCONNECT")
  244. if hapd:
  245. hapd.request("DISABLE")
  246. subprocess.call(['iw', 'reg', 'set', '00'])
  247. dev.flush_scan_cache()
  248. def test_ap_vht_capab_not_supported(dev, apdev):
  249. """VHT configuration with driver not supporting all vht_capab entries"""
  250. try:
  251. params = { "ssid": "vht",
  252. "country_code": "FI",
  253. "hw_mode": "a",
  254. "channel": "36",
  255. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  256. "ieee80211n": "1",
  257. "ieee80211ac": "1",
  258. "vht_oper_chwidth": "1",
  259. "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]",
  260. "vht_oper_centr_freq_seg0_idx": "42",
  261. "require_vht": "1" }
  262. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  263. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  264. if ev is None:
  265. raise Exception("Startup failure not reported")
  266. for i in range(1, 7):
  267. if "OK" not in hapd.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i):
  268. raise Exception("Unexpected SET failure")
  269. finally:
  270. subprocess.call(['iw', 'reg', 'set', '00'])
  271. def test_ap_vht160(dev, apdev):
  272. """VHT with 160 MHz channel width"""
  273. try:
  274. hapd = None
  275. hapd2 = None
  276. params = { "ssid": "vht",
  277. "country_code": "FI",
  278. "hw_mode": "a",
  279. "channel": "36",
  280. "ht_capab": "[HT40+]",
  281. "ieee80211n": "1",
  282. "ieee80211ac": "1",
  283. "vht_oper_chwidth": "2",
  284. "vht_oper_centr_freq_seg0_idx": "50",
  285. 'ieee80211d': '1',
  286. 'ieee80211h': '1' }
  287. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  288. ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
  289. if "DFS-CAC-START" not in ev:
  290. raise Exception("Unexpected DFS event")
  291. state = hapd.get_status_field("state")
  292. if state != "DFS":
  293. if state == "DISABLED" and not os.path.exists("dfs"):
  294. # Not all systems have recent enough CRDA version and
  295. # wireless-regdb changes to support 160 MHz and DFS. For now,
  296. # do not report failures for this test case.
  297. raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
  298. raise Exception("Unexpected interface state: " + state)
  299. params = { "ssid": "vht2",
  300. "country_code": "FI",
  301. "hw_mode": "a",
  302. "channel": "104",
  303. "ht_capab": "[HT40-]",
  304. "ieee80211n": "1",
  305. "ieee80211ac": "1",
  306. "vht_oper_chwidth": "2",
  307. "vht_oper_centr_freq_seg0_idx": "114",
  308. 'ieee80211d': '1',
  309. 'ieee80211h': '1' }
  310. hapd2 = hostapd.add_ap(apdev[1], params, wait_enabled=False)
  311. ev = wait_dfs_event(hapd2, "DFS-CAC-START", 5)
  312. if "DFS-CAC-START" not in ev:
  313. raise Exception("Unexpected DFS event(2)")
  314. state = hapd2.get_status_field("state")
  315. if state != "DFS":
  316. raise Exception("Unexpected interface state(2): " + state)
  317. logger.info("Waiting for CAC to complete")
  318. ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
  319. if "success=1" not in ev:
  320. raise Exception("CAC failed")
  321. if "freq=5180" not in ev:
  322. raise Exception("Unexpected DFS freq result")
  323. ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
  324. if not ev:
  325. raise Exception("AP setup timed out")
  326. state = hapd.get_status_field("state")
  327. if state != "ENABLED":
  328. raise Exception("Unexpected interface state")
  329. ev = wait_dfs_event(hapd2, "DFS-CAC-COMPLETED", 70)
  330. if "success=1" not in ev:
  331. raise Exception("CAC failed(2)")
  332. if "freq=5520" not in ev:
  333. raise Exception("Unexpected DFS freq result(2)")
  334. ev = hapd2.wait_event(["AP-ENABLED"], timeout=5)
  335. if not ev:
  336. raise Exception("AP setup timed out(2)")
  337. state = hapd2.get_status_field("state")
  338. if state != "ENABLED":
  339. raise Exception("Unexpected interface state(2)")
  340. freq = hapd2.get_status_field("freq")
  341. if freq != "5520":
  342. raise Exception("Unexpected frequency(2)")
  343. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  344. hwsim_utils.test_connectivity(dev[0], hapd)
  345. sig = dev[0].request("SIGNAL_POLL").splitlines()
  346. if "FREQUENCY=5180" not in sig:
  347. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  348. if "WIDTH=160 MHz" not in sig:
  349. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  350. dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5520")
  351. hwsim_utils.test_connectivity(dev[1], hapd2)
  352. sig = dev[1].request("SIGNAL_POLL").splitlines()
  353. if "FREQUENCY=5520" not in sig:
  354. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  355. if "WIDTH=160 MHz" not in sig:
  356. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  357. except Exception, e:
  358. if isinstance(e, Exception) and str(e) == "AP startup failed":
  359. if not vht_supported():
  360. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  361. raise
  362. finally:
  363. dev[0].request("DISCONNECT")
  364. dev[1].request("DISCONNECT")
  365. if hapd:
  366. hapd.request("DISABLE")
  367. if hapd2:
  368. hapd2.request("DISABLE")
  369. subprocess.call(['iw', 'reg', 'set', '00'])
  370. dev[0].flush_scan_cache()
  371. dev[1].flush_scan_cache()
  372. def test_ap_vht160_no_dfs(dev, apdev):
  373. """VHT with 160 MHz channel width and no DFS"""
  374. try:
  375. hapd = None
  376. params = { "ssid": "vht",
  377. "country_code": "ZA",
  378. "hw_mode": "a",
  379. "channel": "104",
  380. "ht_capab": "[HT40-]",
  381. "ieee80211n": "1",
  382. "ieee80211ac": "1",
  383. "vht_oper_chwidth": "2",
  384. "vht_oper_centr_freq_seg0_idx": "114",
  385. 'ieee80211d': '1',
  386. 'ieee80211h': '1' }
  387. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  388. ev = hapd.wait_event(["AP-ENABLED"], timeout=2)
  389. if not ev:
  390. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  391. reg = cmd.stdout.readlines()
  392. for r in reg:
  393. if "5490" in r and "DFS" in r:
  394. raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
  395. raise Exception("AP setup timed out")
  396. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5520")
  397. hwsim_utils.test_connectivity(dev[0], hapd)
  398. sig = dev[0].request("SIGNAL_POLL").splitlines()
  399. if "FREQUENCY=5520" not in sig:
  400. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  401. if "WIDTH=160 MHz" not in sig:
  402. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  403. except Exception, e:
  404. if isinstance(e, Exception) and str(e) == "AP startup failed":
  405. if not vht_supported():
  406. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  407. raise
  408. finally:
  409. dev[0].request("DISCONNECT")
  410. if hapd:
  411. hapd.request("DISABLE")
  412. subprocess.call(['iw', 'reg', 'set', '00'])
  413. dev[0].flush_scan_cache()
  414. def test_ap_vht80plus80(dev, apdev):
  415. """VHT with 80+80 MHz channel width"""
  416. try:
  417. hapd = None
  418. hapd2 = None
  419. params = { "ssid": "vht",
  420. "country_code": "US",
  421. "hw_mode": "a",
  422. "channel": "52",
  423. "ht_capab": "[HT40+]",
  424. "ieee80211n": "1",
  425. "ieee80211ac": "1",
  426. "vht_oper_chwidth": "3",
  427. "vht_oper_centr_freq_seg0_idx": "58",
  428. "vht_oper_centr_freq_seg1_idx": "155",
  429. 'ieee80211d': '1',
  430. 'ieee80211h': '1' }
  431. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  432. # This will actually fail since DFS on 80+80 is not yet supported
  433. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  434. # ignore result to avoid breaking the test once 80+80 DFS gets enabled
  435. params = { "ssid": "vht2",
  436. "country_code": "US",
  437. "hw_mode": "a",
  438. "channel": "36",
  439. "ht_capab": "[HT40+]",
  440. "ieee80211n": "1",
  441. "ieee80211ac": "1",
  442. "vht_oper_chwidth": "3",
  443. "vht_oper_centr_freq_seg0_idx": "42",
  444. "vht_oper_centr_freq_seg1_idx": "155" }
  445. hapd2 = hostapd.add_ap(apdev[1], params, wait_enabled=False)
  446. ev = hapd2.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=5)
  447. if not ev:
  448. raise Exception("AP setup timed out(2)")
  449. if "AP-DISABLED" in ev:
  450. # Assume this failed due to missing regulatory update for now
  451. raise HwsimSkip("80+80 MHz channel not supported in regulatory information")
  452. state = hapd2.get_status_field("state")
  453. if state != "ENABLED":
  454. raise Exception("Unexpected interface state(2)")
  455. dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5180")
  456. hwsim_utils.test_connectivity(dev[1], hapd2)
  457. sig = dev[1].request("SIGNAL_POLL").splitlines()
  458. if "FREQUENCY=5180" not in sig:
  459. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  460. if "WIDTH=80+80 MHz" not in sig:
  461. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  462. if "CENTER_FRQ1=5210" not in sig:
  463. raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
  464. if "CENTER_FRQ2=5775" not in sig:
  465. raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
  466. except Exception, e:
  467. if isinstance(e, Exception) and str(e) == "AP startup failed":
  468. if not vht_supported():
  469. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  470. raise
  471. finally:
  472. dev[0].request("DISCONNECT")
  473. dev[1].request("DISCONNECT")
  474. if hapd:
  475. hapd.request("DISABLE")
  476. if hapd2:
  477. hapd2.request("DISABLE")
  478. subprocess.call(['iw', 'reg', 'set', '00'])
  479. dev[0].flush_scan_cache()
  480. dev[1].flush_scan_cache()
  481. def test_ap_vht80plus80_invalid(dev, apdev):
  482. """VHT with invalid 80+80 MHz channel"""
  483. try:
  484. hapd = None
  485. params = { "ssid": "vht",
  486. "country_code": "US",
  487. "hw_mode": "a",
  488. "channel": "36",
  489. "ht_capab": "[HT40+]",
  490. "ieee80211n": "1",
  491. "ieee80211ac": "1",
  492. "vht_oper_chwidth": "3",
  493. "vht_oper_centr_freq_seg0_idx": "42",
  494. "vht_oper_centr_freq_seg1_idx": "0",
  495. 'ieee80211d': '1',
  496. 'ieee80211h': '1' }
  497. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  498. # This fails due to missing(invalid) seg1 configuration
  499. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  500. if ev is None:
  501. raise Exception("AP-DISABLED not reported")
  502. except Exception, e:
  503. if isinstance(e, Exception) and str(e) == "AP startup failed":
  504. if not vht_supported():
  505. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  506. raise
  507. finally:
  508. if hapd:
  509. hapd.request("DISABLE")
  510. subprocess.call(['iw', 'reg', 'set', '00'])
  511. def test_ap_vht80_csa(dev, apdev):
  512. """VHT with 80 MHz channel width and CSA"""
  513. csa_supported(dev[0])
  514. try:
  515. hapd = None
  516. params = { "ssid": "vht",
  517. "country_code": "US",
  518. "hw_mode": "a",
  519. "channel": "149",
  520. "ht_capab": "[HT40+]",
  521. "ieee80211n": "1",
  522. "ieee80211ac": "1",
  523. "vht_oper_chwidth": "1",
  524. "vht_oper_centr_freq_seg0_idx": "155" }
  525. hapd = hostapd.add_ap(apdev[0], params)
  526. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5745")
  527. hwsim_utils.test_connectivity(dev[0], hapd)
  528. hapd.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
  529. ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
  530. if ev is None:
  531. raise Exception("CSA finished event timed out")
  532. if "freq=5180" not in ev:
  533. raise Exception("Unexpected channel in CSA finished event")
  534. time.sleep(0.5)
  535. hwsim_utils.test_connectivity(dev[0], hapd)
  536. hapd.request("CHAN_SWITCH 5 5745")
  537. ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
  538. if ev is None:
  539. raise Exception("CSA finished event timed out")
  540. if "freq=5745" not in ev:
  541. raise Exception("Unexpected channel in CSA finished event")
  542. time.sleep(0.5)
  543. hwsim_utils.test_connectivity(dev[0], hapd)
  544. # This CSA to same channel will fail in kernel, so use this only for
  545. # extra code coverage.
  546. hapd.request("CHAN_SWITCH 5 5745")
  547. hapd.wait_event(["AP-CSA-FINISHED"], timeout=1)
  548. except Exception, e:
  549. if isinstance(e, Exception) and str(e) == "AP startup failed":
  550. if not vht_supported():
  551. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  552. raise
  553. finally:
  554. dev[0].request("DISCONNECT")
  555. if hapd:
  556. hapd.request("DISABLE")
  557. subprocess.call(['iw', 'reg', 'set', '00'])
  558. dev[0].flush_scan_cache()
  559. def test_ap_vht_on_24ghz(dev, apdev):
  560. """Subset of VHT features on 2.4 GHz"""
  561. hapd = None
  562. params = { "ssid": "test-vht-2g",
  563. "hw_mode": "g",
  564. "channel": "1",
  565. "ieee80211n": "1",
  566. "vendor_vht": "1",
  567. "vht_capab": "[MAX-MPDU-11454]",
  568. "vht_oper_chwidth": "0",
  569. "vht_oper_centr_freq_seg0_idx": "1"
  570. }
  571. hapd = hostapd.add_ap(apdev[0], params)
  572. try:
  573. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 13 dd1300904c0400bf0c3240820feaff0000eaff0000"):
  574. raise Exception("Failed to add vendor element")
  575. dev[0].connect("test-vht-2g", scan_freq="2412", key_mgmt="NONE")
  576. hwsim_utils.test_connectivity(dev[0], hapd)
  577. sta = hapd.get_sta(dev[0].own_addr())
  578. if '[VENDOR_VHT]' not in sta['flags']:
  579. raise Exception("No VENDOR_VHT STA flag")
  580. dev[1].connect("test-vht-2g", scan_freq="2412", key_mgmt="NONE")
  581. sta = hapd.get_sta(dev[1].own_addr())
  582. if '[VENDOR_VHT]' in sta['flags']:
  583. raise Exception("Unexpected VENDOR_VHT STA flag")
  584. finally:
  585. dev[0].request("VENDOR_ELEM_REMOVE 13 *")
  586. def test_prefer_vht40(dev, apdev):
  587. """Preference on VHT40 over HT40"""
  588. try:
  589. hapd2 = None
  590. params = { "ssid": "test",
  591. "country_code": "FI",
  592. "hw_mode": "a",
  593. "channel": "36",
  594. "ieee80211n": "1",
  595. "ht_capab": "[HT40+]" }
  596. hapd = hostapd.add_ap(apdev[0], params)
  597. bssid = apdev[0]['bssid']
  598. params = { "ssid": "test",
  599. "country_code": "FI",
  600. "hw_mode": "a",
  601. "channel": "36",
  602. "ieee80211n": "1",
  603. "ieee80211ac": "1",
  604. "ht_capab": "[HT40+]",
  605. "vht_capab": "",
  606. "vht_oper_chwidth": "0",
  607. "vht_oper_centr_freq_seg0_idx": "0",
  608. }
  609. hapd2 = hostapd.add_ap(apdev[1], params)
  610. bssid2 = apdev[1]['bssid']
  611. dev[0].scan_for_bss(bssid, freq=5180)
  612. dev[0].scan_for_bss(bssid2, freq=5180)
  613. dev[0].connect("test", scan_freq="5180", key_mgmt="NONE")
  614. if dev[0].get_status_field('bssid') != bssid2:
  615. raise Exception("Unexpected BSS selected")
  616. est = dev[0].get_bss(bssid)['est_throughput']
  617. if est != "135000":
  618. raise Exception("Unexpected BSS0 est_throughput: " + est)
  619. est = dev[0].get_bss(bssid2)['est_throughput']
  620. if est != "135001":
  621. raise Exception("Unexpected BSS1 est_throughput: " + est)
  622. finally:
  623. dev[0].request("DISCONNECT")
  624. if hapd2:
  625. hapd2.request("DISABLE")
  626. subprocess.call(['iw', 'reg', 'set', '00'])
  627. dev[0].flush_scan_cache()
  628. def test_ap_vht80_pwr_constraint(dev, apdev):
  629. """VHT with 80 MHz channel width and local power constraint"""
  630. hapd = None
  631. try:
  632. params = { "ssid": "vht",
  633. "country_code": "FI",
  634. "hw_mode": "a",
  635. "channel": "36",
  636. "ht_capab": "[HT40+]",
  637. "ieee80211d": "1",
  638. "local_pwr_constraint": "3",
  639. "ieee80211n": "1",
  640. "ieee80211ac": "1",
  641. "vht_oper_chwidth": "1",
  642. "vht_oper_centr_freq_seg0_idx": "42" }
  643. hapd = hostapd.add_ap(apdev[0], params)
  644. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  645. except Exception, e:
  646. if isinstance(e, Exception) and str(e) == "AP startup failed":
  647. if not vht_supported():
  648. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  649. raise
  650. finally:
  651. dev[0].request("DISCONNECT")
  652. if hapd:
  653. hapd.request("DISABLE")
  654. subprocess.call(['iw', 'reg', 'set', '00'])
  655. dev[0].flush_scan_cache()