test_ap_vht.py 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  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_100_plus(dev, apdev):
  385. """VHT with 160 MHz channel width and no DFS (100 plus)"""
  386. run_ap_vht160_no_dfs(dev, apdev, "100", "[HT40+]")
  387. def test_ap_vht160_no_dfs(dev, apdev):
  388. """VHT with 160 MHz channel width and no DFS (104 minus)"""
  389. run_ap_vht160_no_dfs(dev, apdev, "104", "[HT40-]")
  390. def test_ap_vht160_no_dfs_108_plus(dev, apdev):
  391. """VHT with 160 MHz channel width and no DFS (108 plus)"""
  392. run_ap_vht160_no_dfs(dev, apdev, "108", "[HT40+]")
  393. def test_ap_vht160_no_dfs_112_minus(dev, apdev):
  394. """VHT with 160 MHz channel width and no DFS (112 minus)"""
  395. run_ap_vht160_no_dfs(dev, apdev, "112", "[HT40-]")
  396. def test_ap_vht160_no_dfs_116_plus(dev, apdev):
  397. """VHT with 160 MHz channel width and no DFS (116 plus)"""
  398. run_ap_vht160_no_dfs(dev, apdev, "116", "[HT40+]")
  399. def test_ap_vht160_no_dfs_120_minus(dev, apdev):
  400. """VHT with 160 MHz channel width and no DFS (120 minus)"""
  401. run_ap_vht160_no_dfs(dev, apdev, "120", "[HT40-]")
  402. def test_ap_vht160_no_dfs_124_plus(dev, apdev):
  403. """VHT with 160 MHz channel width and no DFS (124 plus)"""
  404. run_ap_vht160_no_dfs(dev, apdev, "124", "[HT40+]")
  405. def test_ap_vht160_no_dfs_128_minus(dev, apdev):
  406. """VHT with 160 MHz channel width and no DFS (128 minus)"""
  407. run_ap_vht160_no_dfs(dev, apdev, "128", "[HT40-]")
  408. def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab):
  409. try:
  410. hapd = None
  411. params = { "ssid": "vht",
  412. "country_code": "ZA",
  413. "hw_mode": "a",
  414. "channel": channel,
  415. "ht_capab": ht_capab,
  416. "ieee80211n": "1",
  417. "ieee80211ac": "1",
  418. "vht_oper_chwidth": "2",
  419. "vht_oper_centr_freq_seg0_idx": "114",
  420. 'ieee80211d': '1',
  421. 'ieee80211h': '1' }
  422. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  423. ev = hapd.wait_event(["AP-ENABLED"], timeout=2)
  424. if not ev:
  425. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  426. reg = cmd.stdout.readlines()
  427. for r in reg:
  428. if "5490" in r and "DFS" in r:
  429. raise HwsimSkip("ZA regulatory rule did not have DFS requirement removed")
  430. raise Exception("AP setup timed out")
  431. freq = str(int(channel) * 5 + 5000)
  432. dev[0].connect("vht", key_mgmt="NONE", scan_freq=freq)
  433. hwsim_utils.test_connectivity(dev[0], hapd)
  434. sig = dev[0].request("SIGNAL_POLL").splitlines()
  435. if "FREQUENCY=" + freq not in sig:
  436. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  437. if "WIDTH=160 MHz" not in sig:
  438. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  439. except Exception, e:
  440. if isinstance(e, Exception) and str(e) == "AP startup failed":
  441. if not vht_supported():
  442. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  443. raise
  444. finally:
  445. dev[0].request("DISCONNECT")
  446. if hapd:
  447. hapd.request("DISABLE")
  448. subprocess.call(['iw', 'reg', 'set', '00'])
  449. dev[0].flush_scan_cache()
  450. def test_ap_vht80plus80(dev, apdev):
  451. """VHT with 80+80 MHz channel width"""
  452. try:
  453. hapd = None
  454. hapd2 = None
  455. params = { "ssid": "vht",
  456. "country_code": "US",
  457. "hw_mode": "a",
  458. "channel": "52",
  459. "ht_capab": "[HT40+]",
  460. "ieee80211n": "1",
  461. "ieee80211ac": "1",
  462. "vht_oper_chwidth": "3",
  463. "vht_oper_centr_freq_seg0_idx": "58",
  464. "vht_oper_centr_freq_seg1_idx": "155",
  465. 'ieee80211d': '1',
  466. 'ieee80211h': '1' }
  467. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  468. # This will actually fail since DFS on 80+80 is not yet supported
  469. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  470. # ignore result to avoid breaking the test once 80+80 DFS gets enabled
  471. params = { "ssid": "vht2",
  472. "country_code": "US",
  473. "hw_mode": "a",
  474. "channel": "36",
  475. "ht_capab": "[HT40+]",
  476. "ieee80211n": "1",
  477. "ieee80211ac": "1",
  478. "vht_oper_chwidth": "3",
  479. "vht_oper_centr_freq_seg0_idx": "42",
  480. "vht_oper_centr_freq_seg1_idx": "155" }
  481. hapd2 = hostapd.add_ap(apdev[1], params, wait_enabled=False)
  482. ev = hapd2.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=5)
  483. if not ev:
  484. raise Exception("AP setup timed out(2)")
  485. if "AP-DISABLED" in ev:
  486. # Assume this failed due to missing regulatory update for now
  487. raise HwsimSkip("80+80 MHz channel not supported in regulatory information")
  488. state = hapd2.get_status_field("state")
  489. if state != "ENABLED":
  490. raise Exception("Unexpected interface state(2)")
  491. dev[1].connect("vht2", key_mgmt="NONE", scan_freq="5180")
  492. hwsim_utils.test_connectivity(dev[1], hapd2)
  493. sig = dev[1].request("SIGNAL_POLL").splitlines()
  494. if "FREQUENCY=5180" not in sig:
  495. raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
  496. if "WIDTH=80+80 MHz" not in sig:
  497. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  498. if "CENTER_FRQ1=5210" not in sig:
  499. raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
  500. if "CENTER_FRQ2=5775" not in sig:
  501. raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
  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. dev[0].request("DISCONNECT")
  509. dev[1].request("DISCONNECT")
  510. if hapd:
  511. hapd.request("DISABLE")
  512. if hapd2:
  513. hapd2.request("DISABLE")
  514. subprocess.call(['iw', 'reg', 'set', '00'])
  515. dev[0].flush_scan_cache()
  516. dev[1].flush_scan_cache()
  517. def test_ap_vht80plus80_invalid(dev, apdev):
  518. """VHT with invalid 80+80 MHz channel"""
  519. try:
  520. hapd = None
  521. params = { "ssid": "vht",
  522. "country_code": "US",
  523. "hw_mode": "a",
  524. "channel": "36",
  525. "ht_capab": "[HT40+]",
  526. "ieee80211n": "1",
  527. "ieee80211ac": "1",
  528. "vht_oper_chwidth": "3",
  529. "vht_oper_centr_freq_seg0_idx": "42",
  530. "vht_oper_centr_freq_seg1_idx": "0",
  531. 'ieee80211d': '1',
  532. 'ieee80211h': '1' }
  533. hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
  534. # This fails due to missing(invalid) seg1 configuration
  535. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  536. if ev is None:
  537. raise Exception("AP-DISABLED not reported")
  538. except Exception, e:
  539. if isinstance(e, Exception) and str(e) == "AP startup failed":
  540. if not vht_supported():
  541. raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
  542. raise
  543. finally:
  544. if hapd:
  545. hapd.request("DISABLE")
  546. subprocess.call(['iw', 'reg', 'set', '00'])
  547. def test_ap_vht80_csa(dev, apdev):
  548. """VHT with 80 MHz channel width and CSA"""
  549. csa_supported(dev[0])
  550. try:
  551. hapd = None
  552. params = { "ssid": "vht",
  553. "country_code": "US",
  554. "hw_mode": "a",
  555. "channel": "149",
  556. "ht_capab": "[HT40+]",
  557. "ieee80211n": "1",
  558. "ieee80211ac": "1",
  559. "vht_oper_chwidth": "1",
  560. "vht_oper_centr_freq_seg0_idx": "155" }
  561. hapd = hostapd.add_ap(apdev[0], params)
  562. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5745")
  563. hwsim_utils.test_connectivity(dev[0], hapd)
  564. hapd.request("CHAN_SWITCH 5 5180 ht vht blocktx center_freq1=5210 sec_channel_offset=1 bandwidth=80")
  565. ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
  566. if ev is None:
  567. raise Exception("CSA finished event timed out")
  568. if "freq=5180" not in ev:
  569. raise Exception("Unexpected channel in CSA finished event")
  570. time.sleep(0.5)
  571. hwsim_utils.test_connectivity(dev[0], hapd)
  572. hapd.request("CHAN_SWITCH 5 5745")
  573. ev = hapd.wait_event(["AP-CSA-FINISHED"], timeout=10)
  574. if ev is None:
  575. raise Exception("CSA finished event timed out")
  576. if "freq=5745" not in ev:
  577. raise Exception("Unexpected channel in CSA finished event")
  578. time.sleep(0.5)
  579. hwsim_utils.test_connectivity(dev[0], hapd)
  580. # This CSA to same channel will fail in kernel, so use this only for
  581. # extra code coverage.
  582. hapd.request("CHAN_SWITCH 5 5745")
  583. hapd.wait_event(["AP-CSA-FINISHED"], timeout=1)
  584. except Exception, e:
  585. if isinstance(e, Exception) and str(e) == "AP startup failed":
  586. if not vht_supported():
  587. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  588. raise
  589. finally:
  590. dev[0].request("DISCONNECT")
  591. if hapd:
  592. hapd.request("DISABLE")
  593. subprocess.call(['iw', 'reg', 'set', '00'])
  594. dev[0].flush_scan_cache()
  595. def test_ap_vht_on_24ghz(dev, apdev):
  596. """Subset of VHT features on 2.4 GHz"""
  597. hapd = None
  598. params = { "ssid": "test-vht-2g",
  599. "hw_mode": "g",
  600. "channel": "1",
  601. "ieee80211n": "1",
  602. "vendor_vht": "1",
  603. "vht_capab": "[MAX-MPDU-11454]",
  604. "vht_oper_chwidth": "0",
  605. "vht_oper_centr_freq_seg0_idx": "1"
  606. }
  607. hapd = hostapd.add_ap(apdev[0], params)
  608. try:
  609. if "OK" not in dev[0].request("VENDOR_ELEM_ADD 13 dd1300904c0400bf0c3240820feaff0000eaff0000"):
  610. raise Exception("Failed to add vendor element")
  611. dev[0].connect("test-vht-2g", scan_freq="2412", key_mgmt="NONE")
  612. hwsim_utils.test_connectivity(dev[0], hapd)
  613. sta = hapd.get_sta(dev[0].own_addr())
  614. if '[VENDOR_VHT]' not in sta['flags']:
  615. raise Exception("No VENDOR_VHT STA flag")
  616. dev[1].connect("test-vht-2g", scan_freq="2412", key_mgmt="NONE")
  617. sta = hapd.get_sta(dev[1].own_addr())
  618. if '[VENDOR_VHT]' in sta['flags']:
  619. raise Exception("Unexpected VENDOR_VHT STA flag")
  620. finally:
  621. dev[0].request("VENDOR_ELEM_REMOVE 13 *")
  622. def test_prefer_vht40(dev, apdev):
  623. """Preference on VHT40 over HT40"""
  624. try:
  625. hapd2 = None
  626. params = { "ssid": "test",
  627. "country_code": "FI",
  628. "hw_mode": "a",
  629. "channel": "36",
  630. "ieee80211n": "1",
  631. "ht_capab": "[HT40+]" }
  632. hapd = hostapd.add_ap(apdev[0], params)
  633. bssid = apdev[0]['bssid']
  634. params = { "ssid": "test",
  635. "country_code": "FI",
  636. "hw_mode": "a",
  637. "channel": "36",
  638. "ieee80211n": "1",
  639. "ieee80211ac": "1",
  640. "ht_capab": "[HT40+]",
  641. "vht_capab": "",
  642. "vht_oper_chwidth": "0",
  643. "vht_oper_centr_freq_seg0_idx": "0",
  644. }
  645. hapd2 = hostapd.add_ap(apdev[1], params)
  646. bssid2 = apdev[1]['bssid']
  647. dev[0].scan_for_bss(bssid, freq=5180)
  648. dev[0].scan_for_bss(bssid2, freq=5180)
  649. dev[0].connect("test", scan_freq="5180", key_mgmt="NONE")
  650. if dev[0].get_status_field('bssid') != bssid2:
  651. raise Exception("Unexpected BSS selected")
  652. est = dev[0].get_bss(bssid)['est_throughput']
  653. if est != "135000":
  654. raise Exception("Unexpected BSS0 est_throughput: " + est)
  655. est = dev[0].get_bss(bssid2)['est_throughput']
  656. if est != "135001":
  657. raise Exception("Unexpected BSS1 est_throughput: " + est)
  658. finally:
  659. dev[0].request("DISCONNECT")
  660. if hapd2:
  661. hapd2.request("DISABLE")
  662. subprocess.call(['iw', 'reg', 'set', '00'])
  663. dev[0].flush_scan_cache()
  664. def test_ap_vht80_pwr_constraint(dev, apdev):
  665. """VHT with 80 MHz channel width and local power constraint"""
  666. hapd = None
  667. try:
  668. params = { "ssid": "vht",
  669. "country_code": "FI",
  670. "hw_mode": "a",
  671. "channel": "36",
  672. "ht_capab": "[HT40+]",
  673. "ieee80211d": "1",
  674. "local_pwr_constraint": "3",
  675. "ieee80211n": "1",
  676. "ieee80211ac": "1",
  677. "vht_oper_chwidth": "1",
  678. "vht_oper_centr_freq_seg0_idx": "42" }
  679. hapd = hostapd.add_ap(apdev[0], params)
  680. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  681. except Exception, e:
  682. if isinstance(e, Exception) and str(e) == "AP startup failed":
  683. if not vht_supported():
  684. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  685. raise
  686. finally:
  687. dev[0].request("DISCONNECT")
  688. if hapd:
  689. hapd.request("DISABLE")
  690. subprocess.call(['iw', 'reg', 'set', '00'])
  691. dev[0].flush_scan_cache()
  692. def test_ap_vht_use_sta_nsts(dev, apdev):
  693. """VHT with 80 MHz channel width and use_sta_nsts=1"""
  694. try:
  695. hapd = None
  696. params = { "ssid": "vht",
  697. "country_code": "FI",
  698. "hw_mode": "a",
  699. "channel": "36",
  700. "ht_capab": "[HT40+]",
  701. "ieee80211n": "1",
  702. "ieee80211ac": "1",
  703. "vht_oper_chwidth": "1",
  704. "vht_oper_centr_freq_seg0_idx": "42",
  705. "use_sta_nsts": "1" }
  706. hapd = hostapd.add_ap(apdev[0], params)
  707. bssid = apdev[0]['bssid']
  708. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  709. hwsim_utils.test_connectivity(dev[0], hapd)
  710. except Exception, e:
  711. if isinstance(e, Exception) and str(e) == "AP startup failed":
  712. if not vht_supported():
  713. raise HwsimSkip("80 MHz channel not supported in regulatory information")
  714. raise
  715. finally:
  716. dev[0].request("DISCONNECT")
  717. if hapd:
  718. hapd.request("DISABLE")
  719. subprocess.call(['iw', 'reg', 'set', '00'])
  720. dev[0].flush_scan_cache()