eht.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * EHT handling
  4. *
  5. * Copyright(c) 2021-2023 Intel Corporation
  6. */
  7. #include "ieee80211_i.h"
  8. void
  9. ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,
  10. struct ieee80211_supported_band *sband,
  11. const u8 *he_cap_ie, u8 he_cap_len,
  12. const struct ieee80211_eht_cap_elem *eht_cap_ie_elem,
  13. u8 eht_cap_len,
  14. struct link_sta_info *link_sta)
  15. {
  16. struct ieee80211_sta_eht_cap *eht_cap = &link_sta->pub->eht_cap;
  17. struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie;
  18. u8 eht_ppe_size = 0;
  19. u8 mcs_nss_size;
  20. u8 eht_total_size = sizeof(eht_cap->eht_cap_elem);
  21. u8 *pos = (u8 *)eht_cap_ie_elem;
  22. memset(eht_cap, 0, sizeof(*eht_cap));
  23. if (!eht_cap_ie_elem ||
  24. !ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif))
  25. return;
  26. mcs_nss_size = ieee80211_eht_mcs_nss_size(he_cap_ie_elem,
  27. &eht_cap_ie_elem->fixed,
  28. sdata->vif.type ==
  29. NL80211_IFTYPE_STATION);
  30. eht_total_size += mcs_nss_size;
  31. /* Calculate the PPE thresholds length only if the header is present */
  32. if (eht_cap_ie_elem->fixed.phy_cap_info[5] &
  33. IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT) {
  34. u16 eht_ppe_hdr;
  35. if (eht_cap_len < eht_total_size + sizeof(u16))
  36. return;
  37. eht_ppe_hdr = get_unaligned_le16(eht_cap_ie_elem->optional + mcs_nss_size);
  38. eht_ppe_size =
  39. ieee80211_eht_ppe_size(eht_ppe_hdr,
  40. eht_cap_ie_elem->fixed.phy_cap_info);
  41. eht_total_size += eht_ppe_size;
  42. /* we calculate as if NSS > 8 are valid, but don't handle that */
  43. if (eht_ppe_size > sizeof(eht_cap->eht_ppe_thres))
  44. return;
  45. }
  46. if (eht_cap_len < eht_total_size)
  47. return;
  48. /* Copy the static portion of the EHT capabilities */
  49. memcpy(&eht_cap->eht_cap_elem, pos, sizeof(eht_cap->eht_cap_elem));
  50. pos += sizeof(eht_cap->eht_cap_elem);
  51. /* Copy MCS/NSS which depends on the peer capabilities */
  52. memset(&eht_cap->eht_mcs_nss_supp, 0,
  53. sizeof(eht_cap->eht_mcs_nss_supp));
  54. memcpy(&eht_cap->eht_mcs_nss_supp, pos, mcs_nss_size);
  55. if (eht_ppe_size)
  56. memcpy(eht_cap->eht_ppe_thres,
  57. &eht_cap_ie_elem->optional[mcs_nss_size],
  58. eht_ppe_size);
  59. eht_cap->has_eht = true;
  60. link_sta->cur_max_bandwidth = ieee80211_sta_cap_rx_bw(link_sta);
  61. link_sta->pub->bandwidth = ieee80211_sta_cur_vht_bw(link_sta);
  62. }