he.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * HE handling
  3. *
  4. * Copyright(c) 2017 Intel Deutschland GmbH
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include "ieee80211_i.h"
  11. void
  12. ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
  13. struct ieee80211_supported_band *sband,
  14. const u8 *he_cap_ie, u8 he_cap_len,
  15. struct sta_info *sta)
  16. {
  17. struct ieee80211_sta_he_cap *he_cap = &sta->sta.he_cap;
  18. struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie;
  19. u8 he_ppe_size;
  20. u8 mcs_nss_size;
  21. u8 he_total_size;
  22. memset(he_cap, 0, sizeof(*he_cap));
  23. if (!he_cap_ie || !ieee80211_get_he_sta_cap(sband))
  24. return;
  25. /* Make sure size is OK */
  26. mcs_nss_size = ieee80211_he_mcs_nss_size(he_cap_ie_elem);
  27. he_ppe_size =
  28. ieee80211_he_ppe_size(he_cap_ie[sizeof(he_cap->he_cap_elem) +
  29. mcs_nss_size],
  30. he_cap_ie_elem->phy_cap_info);
  31. he_total_size = sizeof(he_cap->he_cap_elem) + mcs_nss_size +
  32. he_ppe_size;
  33. if (he_cap_len < he_total_size)
  34. return;
  35. memcpy(&he_cap->he_cap_elem, he_cap_ie, sizeof(he_cap->he_cap_elem));
  36. /* HE Tx/Rx HE MCS NSS Support Field */
  37. memcpy(&he_cap->he_mcs_nss_supp,
  38. &he_cap_ie[sizeof(he_cap->he_cap_elem)], mcs_nss_size);
  39. /* Check if there are (optional) PPE Thresholds */
  40. if (he_cap->he_cap_elem.phy_cap_info[6] &
  41. IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT)
  42. memcpy(he_cap->ppe_thres,
  43. &he_cap_ie[sizeof(he_cap->he_cap_elem) + mcs_nss_size],
  44. he_ppe_size);
  45. he_cap->has_he = true;
  46. }