test_ap_vht.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Test cases for VHT operations with hostapd
  2. # Copyright (c) 2014, Qualcomm Atheros, Inc.
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import logging
  7. logger = logging.getLogger()
  8. import subprocess
  9. import hwsim_utils
  10. import hostapd
  11. def vht_supported():
  12. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  13. reg = cmd.stdout.read()
  14. if "@ 80)" in reg or "@ 160)" in reg:
  15. return True
  16. return False
  17. def test_ap_vht80(dev, apdev):
  18. """VHT with 80 MHz channel width"""
  19. try:
  20. params = { "ssid": "vht",
  21. "country_code": "FI",
  22. "hw_mode": "a",
  23. "channel": "36",
  24. "ht_capab": "[HT40+]",
  25. "ieee80211n": "1",
  26. "ieee80211ac": "1",
  27. "vht_oper_chwidth": "1",
  28. "vht_oper_centr_freq_seg0_idx": "42" }
  29. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  30. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  31. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  32. except Exception, e:
  33. if isinstance(e, Exception) and str(e) == "AP startup failed":
  34. if not vht_supported():
  35. logger.info("80 MHz channel not supported in regulatory information")
  36. return "skip"
  37. raise
  38. finally:
  39. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  40. def test_ap_vht80_params(dev, apdev):
  41. """VHT with 80 MHz channel width and number of optional features enabled"""
  42. try:
  43. params = { "ssid": "vht",
  44. "country_code": "FI",
  45. "hw_mode": "a",
  46. "channel": "36",
  47. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  48. "ieee80211n": "1",
  49. "ieee80211ac": "1",
  50. "vht_oper_chwidth": "1",
  51. "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
  52. "vht_oper_centr_freq_seg0_idx": "42",
  53. "require_vht": "1" }
  54. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  55. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  56. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  57. except Exception, e:
  58. if isinstance(e, Exception) and str(e) == "AP startup failed":
  59. if not vht_supported():
  60. logger.info("80 MHz channel not supported in regulatory information")
  61. return "skip"
  62. raise
  63. finally:
  64. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])