Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * EHT handling
0004  *
0005  * Copyright(c) 2021-2022 Intel Corporation
0006  */
0007 
0008 #include "ieee80211_i.h"
0009 
0010 void
0011 ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,
0012                     struct ieee80211_supported_band *sband,
0013                     const u8 *he_cap_ie, u8 he_cap_len,
0014                     const struct ieee80211_eht_cap_elem *eht_cap_ie_elem,
0015                     u8 eht_cap_len,
0016                     struct link_sta_info *link_sta)
0017 {
0018     struct ieee80211_sta_eht_cap *eht_cap = &link_sta->pub->eht_cap;
0019     struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie;
0020     u8 eht_ppe_size = 0;
0021     u8 mcs_nss_size;
0022     u8 eht_total_size = sizeof(eht_cap->eht_cap_elem);
0023     u8 *pos = (u8 *)eht_cap_ie_elem;
0024 
0025     memset(eht_cap, 0, sizeof(*eht_cap));
0026 
0027     if (!eht_cap_ie_elem ||
0028         !ieee80211_get_eht_iftype_cap(sband,
0029                      ieee80211_vif_type_p2p(&sdata->vif)))
0030         return;
0031 
0032     mcs_nss_size = ieee80211_eht_mcs_nss_size(he_cap_ie_elem,
0033                           &eht_cap_ie_elem->fixed);
0034 
0035     eht_total_size += mcs_nss_size;
0036 
0037     /* Calculate the PPE thresholds length only if the header is present */
0038     if (eht_cap_ie_elem->fixed.phy_cap_info[5] &
0039             IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT) {
0040         u16 eht_ppe_hdr;
0041 
0042         if (eht_cap_len < eht_total_size + sizeof(u16))
0043             return;
0044 
0045         eht_ppe_hdr = get_unaligned_le16(eht_cap_ie_elem->optional + mcs_nss_size);
0046         eht_ppe_size =
0047             ieee80211_eht_ppe_size(eht_ppe_hdr,
0048                            eht_cap_ie_elem->fixed.phy_cap_info);
0049         eht_total_size += eht_ppe_size;
0050 
0051         /* we calculate as if NSS > 8 are valid, but don't handle that */
0052         if (eht_ppe_size > sizeof(eht_cap->eht_ppe_thres))
0053             return;
0054     }
0055 
0056     if (eht_cap_len < eht_total_size)
0057         return;
0058 
0059     /* Copy the static portion of the EHT capabilities */
0060     memcpy(&eht_cap->eht_cap_elem, pos, sizeof(eht_cap->eht_cap_elem));
0061     pos += sizeof(eht_cap->eht_cap_elem);
0062 
0063     /* Copy MCS/NSS which depends on the peer capabilities */
0064     memset(&eht_cap->eht_mcs_nss_supp, 0,
0065            sizeof(eht_cap->eht_mcs_nss_supp));
0066     memcpy(&eht_cap->eht_mcs_nss_supp, pos, mcs_nss_size);
0067 
0068     if (eht_ppe_size)
0069         memcpy(eht_cap->eht_ppe_thres,
0070                &eht_cap_ie_elem->optional[mcs_nss_size],
0071                eht_ppe_size);
0072 
0073     eht_cap->has_eht = true;
0074 
0075     link_sta->cur_max_bandwidth = ieee80211_sta_cap_rx_bw(link_sta);
0076     link_sta->pub->bandwidth = ieee80211_sta_cur_vht_bw(link_sta);
0077 }