vht.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * VHT handling
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/ieee80211.h>
  9. #include <linux/export.h>
  10. #include <net/mac80211.h>
  11. #include "ieee80211_i.h"
  12. void ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
  13. struct ieee80211_supported_band *sband,
  14. struct ieee80211_vht_cap *vht_cap_ie,
  15. struct sta_info *sta)
  16. {
  17. struct ieee80211_sta_vht_cap *vht_cap = &sta->sta.vht_cap;
  18. memset(vht_cap, 0, sizeof(*vht_cap));
  19. if (!sta->sta.ht_cap.ht_supported)
  20. return;
  21. if (!vht_cap_ie || !sband->vht_cap.vht_supported)
  22. return;
  23. /* A VHT STA must support 40 MHz */
  24. if (!(sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
  25. return;
  26. vht_cap->vht_supported = true;
  27. vht_cap->cap = le32_to_cpu(vht_cap_ie->vht_cap_info);
  28. /* Copy peer MCS info, the driver might need them. */
  29. memcpy(&vht_cap->vht_mcs, &vht_cap_ie->supp_mcs,
  30. sizeof(struct ieee80211_vht_mcs_info));
  31. sta->sta.bandwidth = ieee80211_sta_cur_vht_bw(sta);
  32. }
  33. enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta)
  34. {
  35. struct ieee80211_sub_if_data *sdata = sta->sdata;
  36. u32 cap = sta->sta.vht_cap.cap;
  37. if (!sta->sta.vht_cap.vht_supported)
  38. return sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 ?
  39. IEEE80211_STA_RX_BW_40 : IEEE80211_STA_RX_BW_20;
  40. /* TODO: handle VHT opmode notification data */
  41. switch (sdata->vif.bss_conf.chandef.width) {
  42. default:
  43. WARN_ON_ONCE(1);
  44. /* fall through */
  45. case NL80211_CHAN_WIDTH_20_NOHT:
  46. case NL80211_CHAN_WIDTH_20:
  47. case NL80211_CHAN_WIDTH_40:
  48. return sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 ?
  49. IEEE80211_STA_RX_BW_40 : IEEE80211_STA_RX_BW_20;
  50. case NL80211_CHAN_WIDTH_160:
  51. if (cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ)
  52. return IEEE80211_STA_RX_BW_160;
  53. /* fall through */
  54. case NL80211_CHAN_WIDTH_80P80:
  55. if (cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)
  56. return IEEE80211_STA_RX_BW_160;
  57. /* fall through */
  58. case NL80211_CHAN_WIDTH_80:
  59. return IEEE80211_STA_RX_BW_80;
  60. }
  61. }