test_ap_vht.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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]['ifname'], 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['ifname'], 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]['ifname'], 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_vht_20(devs, apdevs):
  136. """VHT and 20 MHz channel"""
  137. dev = devs[0]
  138. ap = apdevs[0]
  139. try:
  140. hapd = None
  141. params = { "ssid": "test-vht20",
  142. "country_code": "DE",
  143. "hw_mode": "a",
  144. "channel": "36",
  145. "ieee80211n": "1",
  146. "ieee80211ac": "1",
  147. "ht_capab": "",
  148. "vht_capab": "",
  149. "vht_oper_chwidth": "0",
  150. "vht_oper_centr_freq_seg0_idx": "0",
  151. "supported_rates": "60 120 240 360 480 540",
  152. "require_vht": "1",
  153. }
  154. hapd = hostapd.add_ap(ap['ifname'], params)
  155. dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
  156. hwsim_utils.test_connectivity(dev, hapd)
  157. finally:
  158. dev.request("DISCONNECT")
  159. if hapd:
  160. hapd.request("DISABLE")
  161. subprocess.call(['iw', 'reg', 'set', '00'])
  162. dev.flush_scan_cache()
  163. def test_ap_vht_40(devs, apdevs):
  164. """VHT and 40 MHz channel"""
  165. dev = devs[0]
  166. ap = apdevs[0]
  167. try:
  168. hapd = None
  169. params = { "ssid": "test-vht40",
  170. "country_code": "DE",
  171. "hw_mode": "a",
  172. "channel": "36",
  173. "ieee80211n": "1",
  174. "ieee80211ac": "1",
  175. "ht_capab": "[HT40+]",
  176. "vht_capab": "",
  177. "vht_oper_chwidth": "0",
  178. "vht_oper_centr_freq_seg0_idx": "0",
  179. }
  180. hapd = hostapd.add_ap(ap['ifname'], params)
  181. dev.connect("test-vht40", scan_freq="5180", key_mgmt="NONE")
  182. hwsim_utils.test_connectivity(dev, hapd)
  183. finally:
  184. dev.request("DISCONNECT")
  185. if hapd:
  186. hapd.request("DISABLE")
  187. subprocess.call(['iw', 'reg', 'set', '00'])
  188. dev.flush_scan_cache()
  189. def test_ap_vht_capab_not_supported(dev, apdev):
  190. """VHT configuration with driver not supporting all vht_capab entries"""
  191. try:
  192. params = { "ssid": "vht",
  193. "country_code": "FI",
  194. "hw_mode": "a",
  195. "channel": "36",
  196. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  197. "ieee80211n": "1",
  198. "ieee80211ac": "1",
  199. "vht_oper_chwidth": "1",
  200. "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]",
  201. "vht_oper_centr_freq_seg0_idx": "42",
  202. "require_vht": "1" }
  203. hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
  204. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  205. if ev is None:
  206. raise Exception("Startup failure not reported")
  207. for i in range(1, 7):
  208. if "OK" not in hapd.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i):
  209. raise Exception("Unexpected SET failure")
  210. finally:
  211. subprocess.call(['iw', 'reg', 'set', '00'])
  212. def test_ap_vht160(dev, apdev):
  213. """VHT with 160 MHz channel width"""
  214. try:
  215. hapd = None
  216. hapd2 = None
  217. params = { "ssid": "vht",
  218. "country_code": "FI",
  219. "hw_mode": "a",
  220. "channel": "36",
  221. "ht_capab": "[HT40+]",
  222. "ieee80211n": "1",
  223. "ieee80211ac": "1",
  224. "vht_oper_chwidth": "2",
  225. "vht_oper_centr_freq_seg0_idx": "50",
  226. 'ieee80211d': '1',
  227. 'ieee80211h': '1' }
  228. hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
  229. ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
  230. if "DFS-CAC-START" not in ev:
  231. raise Exception("Unexpected DFS event")
  232. state = hapd.get_status_field("state")
  233. if state != "DFS":
  234. if state == "DISABLED" and not os.path.exists("dfs"):
  235. # Not all systems have recent enough CRDA version and
  236. # wireless-regdb changes to support 160 MHz and DFS. For now,
  237. # do not report failures for this test case.
  238. raise HwsimSkip("CRDA or wireless-regdb did not support 160 MHz")
  239. raise Exception("Unexpected interface state: " + state)
  240. params = { "ssid": "vht2",
  241. "country_code": "FI",
  242. "hw_mode": "a",
  243. "channel": "104",
  244. "ht_capab": "[HT40-]",
  245. "ieee80211n": "1",
  246. "ieee80211ac": "1",
  247. "vht_oper_chwidth": "2",
  248. "vht_oper_centr_freq_seg0_idx": "114",
  249. 'ieee80211d': '1',
  250. 'ieee80211h': '1' }
  251. hapd2 = hostapd.add_ap(apdev[1]['ifname'], params, wait_enabled=False)
  252. ev = wait_dfs_event(hapd2, "DFS-CAC-START", 5)
  253. if "DFS-CAC-START" not in ev:
  254. raise Exception("Unexpected DFS event(2)")
  255. state = hapd2.get_status_field("state")
  256. if state != "DFS":
  257. raise Exception("Unexpected interface state(2): " + state)
  258. logger.info("Waiting for CAC to complete")
  259. ev = wait_dfs_event(hapd, "DFS-CAC-COMPLETED", 70)
  260. if "success=1" not in ev:
  261. raise Exception("CAC failed")
  262. if "freq=5180" not in ev:
  263. raise Exception("Unexpected DFS freq result")
  264. ev = hapd.wait_event(["AP-ENABLED"], timeout=5)
  265. if not ev:
  266. raise Exception("AP setup timed out")
  267. state = hapd.get_status_field("state")
  268. if state != "ENABLED":
  269. raise Exception("Unexpected interface state")
  270. ev = wait_dfs_event(hapd2, "DFS-CAC-COMPLETED", 70)
  271. if "success=1" not in ev:
  272. raise Exception("CAC failed(2)")
  273. if "freq=5520" not in ev:
  274. raise Exception("Unexpected DFS freq result(2)")
  275. ev = hapd2.wait_event(["AP-ENABLED"], timeout=5)
  276. if not ev:
  277. raise Exception("AP setup timed out(2)")
  278. state = hapd2.get_status_field("state")
  279. if state != "ENABLED":
  280. raise Exception("Unexpected interface state(2)")
  281. freq = hapd2.get_status_field("freq")
  282. if freq != "5520":
  283. raise Exception("Unexpected frequency(2)")
  284. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  285. hwsim_utils.test_connectivity(dev[0], hapd)
  286. sig = dev[0].request("SIGNAL_POLL").splitlines()
  287. if "FREQUENCY=5180" not in sig:
  288. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  289. if "WIDTH=160 MHz" not in sig:
  290. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  291. dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5520")
  292. hwsim_utils.test_connectivity(dev[1], hapd2)
  293. sig = dev[1].request("SIGNAL_POLL").splitlines()
  294. if "FREQUENCY=5520" not in sig:
  295. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  296. if "WIDTH=160 MHz" not in sig:
  297. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  298. except Exception, e:
  299. if isinstance(e, Exception) and str(e) == "AP startup failed":
  300. if not vht_supported():
  301. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  302. raise
  303. finally:
  304. dev[0].request("DISCONNECT")
  305. dev[1].request("DISCONNECT")
  306. if hapd:
  307. hapd.request("DISABLE")
  308. if hapd2:
  309. hapd2.request("DISABLE")
  310. subprocess.call(['iw', 'reg', 'set', '00'])
  311. dev[0].flush_scan_cache()
  312. dev[1].flush_scan_cache()
  313. def test_ap_vht160_no_dfs(dev, apdev):
  314. """VHT with 160 MHz channel width and no DFS"""
  315. try:
  316. hapd = None
  317. params = { "ssid": "vht",
  318. "country_code": "ZA",
  319. "hw_mode": "a",
  320. "channel": "104",
  321. "ht_capab": "[HT40-]",
  322. "ieee80211n": "1",
  323. "ieee80211ac": "1",
  324. "vht_oper_chwidth": "2",
  325. "vht_oper_centr_freq_seg0_idx": "114",
  326. 'ieee80211d': '1',
  327. 'ieee80211h': '1' }
  328. hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
  329. ev = hapd.wait_event(["AP-ENABLED"], timeout=2)
  330. if not ev:
  331. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  332. reg = cmd.stdout.readlines()
  333. for r in reg:
  334. if "5490" in r and "DFS" in r:
  335. raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
  336. raise Exception("AP setup timed out")
  337. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5520")
  338. hwsim_utils.test_connectivity(dev[0], hapd)
  339. sig = dev[0].request("SIGNAL_POLL").splitlines()
  340. if "FREQUENCY=5520" not in sig:
  341. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  342. if "WIDTH=160 MHz" not in sig:
  343. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  344. except Exception, e:
  345. if isinstance(e, Exception) and str(e) == "AP startup failed":
  346. if not vht_supported():
  347. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  348. raise
  349. finally:
  350. dev[0].request("DISCONNECT")
  351. if hapd:
  352. hapd.request("DISABLE")
  353. subprocess.call(['iw', 'reg', 'set', '00'])
  354. dev[0].flush_scan_cache()
  355. def test_ap_vht80plus80(dev, apdev):
  356. """VHT with 80+80 MHz channel width"""
  357. try:
  358. hapd = None
  359. hapd2 = None
  360. params = { "ssid": "vht",
  361. "country_code": "US",
  362. "hw_mode": "a",
  363. "channel": "52",
  364. "ht_capab": "[HT40+]",
  365. "ieee80211n": "1",
  366. "ieee80211ac": "1",
  367. "vht_oper_chwidth": "3",
  368. "vht_oper_centr_freq_seg0_idx": "58",
  369. "vht_oper_centr_freq_seg1_idx": "155",
  370. 'ieee80211d': '1',
  371. 'ieee80211h': '1' }
  372. hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
  373. # This will actually fail since DFS on 80+80 is not yet supported
  374. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  375. # ignore result to avoid breaking the test once 80+80 DFS gets enabled
  376. params = { "ssid": "vht2",
  377. "country_code": "US",
  378. "hw_mode": "a",
  379. "channel": "36",
  380. "ht_capab": "[HT40+]",
  381. "ieee80211n": "1",
  382. "ieee80211ac": "1",
  383. "vht_oper_chwidth": "3",
  384. "vht_oper_centr_freq_seg0_idx": "42",
  385. "vht_oper_centr_freq_seg1_idx": "155" }
  386. hapd2 = hostapd.add_ap(apdev[1]['ifname'], params, wait_enabled=False)
  387. ev = hapd2.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=5)
  388. if not ev:
  389. raise Exception("AP setup timed out(2)")
  390. if "AP-DISABLED" in ev:
  391. # Assume this failed due to missing regulatory update for now
  392. raise HwsimSkip("80+80 MHz channel not supported in regulatory information")
  393. state = hapd2.get_status_field("state")
  394. if state != "ENABLED":
  395. raise Exception("Unexpected interface state(2)")
  396. dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5180")
  397. hwsim_utils.test_connectivity(dev[1], hapd2)
  398. sig = dev[1].request("SIGNAL_POLL").splitlines()
  399. if "FREQUENCY=5180" not in sig:
  400. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  401. if "WIDTH=80+80 MHz" not in sig:
  402. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  403. if "CENTER_FRQ1=5210" not in sig:
  404. raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
  405. if "CENTER_FRQ2=5775" not in sig:
  406. raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
  407. except Exception, e:
  408. if isinstance(e, Exception) and str(e) == "AP startup failed":
  409. if not vht_supported():
  410. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  411. raise
  412. finally:
  413. dev[0].request("DISCONNECT")
  414. dev[1].request("DISCONNECT")
  415. if hapd:
  416. hapd.request("DISABLE")
  417. if hapd2:
  418. hapd2.request("DISABLE")
  419. subprocess.call(['iw', 'reg', 'set', '00'])
  420. dev[0].flush_scan_cache()
  421. dev[1].flush_scan_cache()
  422. def test_ap_vht80_csa(dev, apdev):
  423. """VHT with 80 MHz channel width and CSA"""
  424. csa_supported(dev[0])
  425. try:
  426. hapd = None
  427. params = { "ssid": "vht",
  428. "country_code": "US",
  429. "hw_mode": "a",
  430. "channel": "149",
  431. "ht_capab": "[HT40+]",
  432. "ieee80211n": "1",
  433. "ieee80211ac": "1",
  434. "vht_oper_chwidth": "1",
  435. "vht_oper_centr_freq_seg0_idx": "155" }
  436. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  437. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5745")
  438. hwsim_utils.test_connectivity(dev[0], hapd)
  439. hapd.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
  440. ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
  441. if ev is None:
  442. raise Exception("CSA finished event timed out")
  443. if "freq=5180" not in ev:
  444. raise Exception("Unexpected channel in CSA finished event")
  445. time.sleep(0.5)
  446. hwsim_utils.test_connectivity(dev[0], hapd)
  447. hapd.request("CHAN_SWITCH 5 5745")
  448. ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
  449. if ev is None:
  450. raise Exception("CSA finished event timed out")
  451. if "freq=5745" not in ev:
  452. raise Exception("Unexpected channel in CSA finished event")
  453. time.sleep(0.5)
  454. hwsim_utils.test_connectivity(dev[0], hapd)
  455. # This CSA to same channel will fail in kernel, so use this only for
  456. # extra code coverage.
  457. hapd.request("CHAN_SWITCH 5 5745")
  458. hapd.wait_event(["AP-CSA-FINISHED"], timeout=1)
  459. except Exception, e:
  460. if isinstance(e, Exception) and str(e) == "AP startup failed":
  461. if not vht_supported():
  462. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  463. raise
  464. finally:
  465. dev[0].request("DISCONNECT")
  466. if hapd:
  467. hapd.request("DISABLE")
  468. subprocess.call(['iw', 'reg', 'set', '00'])
  469. dev[0].flush_scan_cache()
  470. def test_ap_vht_on_24ghz(dev, apdev):
  471. """Subset of VHT features on 2.4 GHz"""
  472. hapd = None
  473. params = { "ssid": "test-vht-2g",
  474. "hw_mode": "g",
  475. "channel": "1",
  476. "ieee80211n": "1",
  477. "vendor_vht": "1",
  478. "vht_capab": "[MAX-MPDU-11454]",
  479. "vht_oper_chwidth": "0",
  480. "vht_oper_centr_freq_seg0_idx": "1"
  481. }
  482. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  483. try:
  484. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 13 dd1300904c0400bf0c3240820feaff0000eaff0000"):
  485. raise Exception("Failed to add vendor element")
  486. dev[0].connect("test-vht-2g", scan_freq="2412", key_mgmt="NONE")
  487. hwsim_utils.test_connectivity(dev[0], hapd)
  488. sta = hapd.get_sta(dev[0].own_addr())
  489. if '[VENDOR_VHT]' not in sta['flags']:
  490. raise Exception("No VENDOR_VHT STA flag")
  491. dev[1].connect("test-vht-2g", scan_freq="2412", key_mgmt="NONE")
  492. sta = hapd.get_sta(dev[1].own_addr())
  493. if '[VENDOR_VHT]' in sta['flags']:
  494. raise Exception("Unexpected VENDOR_VHT STA flag")
  495. finally:
  496. dev[0].request("VENDOR_ELEM_REMOVE 13 *")
  497. def test_prefer_vht40(dev, apdev):
  498. """Preference on VHT40 over HT40"""
  499. try:
  500. hapd2 = None
  501. params = { "ssid": "test",
  502. "country_code": "FI",
  503. "hw_mode": "a",
  504. "channel": "36",
  505. "ieee80211n": "1",
  506. "ht_capab": "[HT40+]" }
  507. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  508. bssid = apdev[0]['bssid']
  509. params = { "ssid": "test",
  510. "country_code": "FI",
  511. "hw_mode": "a",
  512. "channel": "36",
  513. "ieee80211n": "1",
  514. "ieee80211ac": "1",
  515. "ht_capab": "[HT40+]",
  516. "vht_capab": "",
  517. "vht_oper_chwidth": "0",
  518. "vht_oper_centr_freq_seg0_idx": "0",
  519. }
  520. hapd2 = hostapd.add_ap(apdev[1]['ifname'], params)
  521. bssid2 = apdev[1]['bssid']
  522. dev[0].scan_for_bss(bssid, freq=5180)
  523. dev[0].scan_for_bss(bssid2, freq=5180)
  524. dev[0].connect("test", scan_freq="5180", key_mgmt="NONE")
  525. if dev[0].get_status_field('bssid') != bssid2:
  526. raise Exception("Unexpected BSS selected")
  527. est = dev[0].get_bss(bssid)['est_throughput']
  528. if est != "135000":
  529. raise Exception("Unexpected BSS0 est_throughput: " + est)
  530. est = dev[0].get_bss(bssid2)['est_throughput']
  531. if est != "135001":
  532. raise Exception("Unexpected BSS1 est_throughput: " + est)
  533. finally:
  534. dev[0].request("DISCONNECT")
  535. if hapd2:
  536. hapd2.request("DISABLE")
  537. subprocess.call(['iw', 'reg', 'set', '00'])
  538. dev[0].flush_scan_cache()
  539. def test_ap_vht80_pwr_constraint(dev, apdev):
  540. """VHT with 80 MHz channel width and local power constraint"""
  541. hapd = None
  542. try:
  543. params = { "ssid": "vht",
  544. "country_code": "FI",
  545. "hw_mode": "a",
  546. "channel": "36",
  547. "ht_capab": "[HT40+]",
  548. "ieee80211d": "1",
  549. "local_pwr_constraint": "3",
  550. "ieee80211n": "1",
  551. "ieee80211ac": "1",
  552. "vht_oper_chwidth": "1",
  553. "vht_oper_centr_freq_seg0_idx": "42" }
  554. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  555. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  556. except Exception, e:
  557. if isinstance(e, Exception) and str(e) == "AP startup failed":
  558. if not vht_supported():
  559. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  560. raise
  561. finally:
  562. dev[0].request("DISCONNECT")
  563. if hapd:
  564. hapd.request("DISABLE")
  565. subprocess.call(['iw', 'reg', 'set', '00'])
  566. dev[0].flush_scan_cache()