test_ap_vht.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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[1].connect("vht", key_mgmt="NONE", scan_freq="5180",
  57. disable_vht="1", wait_connect=False)
  58. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  59. ev = dev[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
  60. if ev is None:
  61. raise Exception("Association rejection timed out")
  62. if "status_code=104" not in ev:
  63. raise Exception("Unexpected rejection status code")
  64. dev[1].request("DISCONNECT")
  65. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  66. except Exception, e:
  67. if isinstance(e, Exception) and str(e) == "AP startup failed":
  68. if not vht_supported():
  69. logger.info("80 MHz channel not supported in regulatory information")
  70. return "skip"
  71. raise
  72. finally:
  73. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  74. def test_ap_vht_20(devs, apdevs):
  75. dev = devs[0]
  76. ap = apdevs[0]
  77. try:
  78. params = { "ssid": "test-vht20",
  79. "country_code": "DE",
  80. "hw_mode": "a",
  81. "channel": "36",
  82. "ieee80211n": "1",
  83. "ieee80211ac": "1",
  84. "ht_capab": "",
  85. "vht_capab": "",
  86. "vht_oper_chwidth": "0",
  87. "vht_oper_centr_freq_seg0_idx": "0",
  88. "supported_rates": "60 120 240 360 480 540",
  89. "require_vht": "1",
  90. }
  91. hostapd.add_ap(ap['ifname'], params)
  92. dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
  93. hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
  94. finally:
  95. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  96. def test_ap_vht_capab_not_supported(dev, apdev):
  97. """VHT configuration with driver not supporting all vht_capab entries"""
  98. try:
  99. params = { "ssid": "vht",
  100. "country_code": "FI",
  101. "hw_mode": "a",
  102. "channel": "36",
  103. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  104. "ieee80211n": "1",
  105. "ieee80211ac": "1",
  106. "vht_oper_chwidth": "1",
  107. "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][SOUNDING-DIMENSION-2][MU-BEAMFORMER][MU-BEAMFORMEE][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]",
  108. "vht_oper_centr_freq_seg0_idx": "42",
  109. "require_vht": "1" }
  110. hapd = hostapd.add_ap(apdev[0]['ifname'], params, wait_enabled=False)
  111. ev = hapd.wait_event(["AP-DISABLED"], timeout=5)
  112. if ev is None:
  113. raise Exception("Startup failure not reported")
  114. for i in range(1, 7):
  115. if "OK" not in hapd.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i):
  116. raise Exception("Unexpected SET failure")
  117. finally:
  118. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])