test_ap_vht.py 24 KB

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