test_ap_vht.py 29 KB

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