test_ap_vht.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 subprocess, time
  10. import hwsim_utils
  11. import hostapd
  12. def vht_supported():
  13. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  14. reg = cmd.stdout.read()
  15. if "@ 80)" in reg or "@ 160)" in reg:
  16. return True
  17. return False
  18. def test_ap_vht80(dev, apdev):
  19. """VHT with 80 MHz channel width"""
  20. try:
  21. params = { "ssid": "vht",
  22. "country_code": "FI",
  23. "hw_mode": "a",
  24. "channel": "36",
  25. "ht_capab": "[HT40+]",
  26. "ieee80211n": "1",
  27. "ieee80211ac": "1",
  28. "vht_oper_chwidth": "1",
  29. "vht_oper_centr_freq_seg0_idx": "42" }
  30. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  31. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  32. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  33. except Exception, e:
  34. if isinstance(e, Exception) and str(e) == "AP startup failed":
  35. if not vht_supported():
  36. logger.info("80 MHz channel not supported in regulatory information")
  37. return "skip"
  38. raise
  39. finally:
  40. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  41. def test_ap_vht80_params(dev, apdev):
  42. """VHT with 80 MHz channel width and number of optional features enabled"""
  43. try:
  44. params = { "ssid": "vht",
  45. "country_code": "FI",
  46. "hw_mode": "a",
  47. "channel": "36",
  48. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  49. "ieee80211n": "1",
  50. "ieee80211ac": "1",
  51. "vht_oper_chwidth": "1",
  52. "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
  53. "vht_oper_centr_freq_seg0_idx": "42",
  54. "require_vht": "1" }
  55. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  56. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  57. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  58. except Exception, e:
  59. if isinstance(e, Exception) and str(e) == "AP startup failed":
  60. if not vht_supported():
  61. logger.info("80 MHz channel not supported in regulatory information")
  62. return "skip"
  63. raise
  64. finally:
  65. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  66. def test_ap_vht_20(devs, apdevs):
  67. dev = devs[0]
  68. ap = apdevs[0]
  69. try:
  70. params = { "ssid": "test-vht20",
  71. "country_code": "DE",
  72. "hw_mode": "a",
  73. "channel": "36",
  74. "ieee80211n": "1",
  75. "ieee80211ac": "1",
  76. "ht_capab": "",
  77. "vht_capab": "",
  78. "vht_oper_chwidth": "0",
  79. "vht_oper_centr_freq_seg0_idx": "0",
  80. "require_vht": "1",
  81. }
  82. hostapd.add_ap(ap['ifname'], params)
  83. dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
  84. hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
  85. finally:
  86. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])