Skip to content

Commit

Permalink
mac80211: reduce peer HE MCS/NSS to own capabilities
Browse files Browse the repository at this point in the history
For VHT capbility, we do intersection of MCS and NSS for peers in
mac80211, to simplify drivers.

Add this for HE as well.

Signed-off-by: Wen Gong <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[reword commit message, style cleanups, fix endian annotations]
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
Wen Gong authored and jmberg-intel committed Jan 22, 2021
1 parent 2d5e09d commit 7f7aa94
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions net/mac80211/he.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,57 @@ ieee80211_update_from_he_6ghz_capa(const struct ieee80211_he_6ghz_capa *he_6ghz_
sta->sta.he_6ghz_capa = *he_6ghz_capa;
}

static void ieee80211_he_mcs_disable(__le16 *he_mcs)
{
u32 i;

for (i = 0; i < 8; i++)
*he_mcs |= cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2);
}

static void ieee80211_he_mcs_intersection(__le16 *he_own_rx, __le16 *he_peer_rx,
__le16 *he_own_tx, __le16 *he_peer_tx)
{
u32 i;
u16 own_rx, own_tx, peer_rx, peer_tx;

for (i = 0; i < 8; i++) {
own_rx = le16_to_cpu(*he_own_rx);
own_rx = (own_rx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;

own_tx = le16_to_cpu(*he_own_tx);
own_tx = (own_tx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;

peer_rx = le16_to_cpu(*he_peer_rx);
peer_rx = (peer_rx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;

peer_tx = le16_to_cpu(*he_peer_tx);
peer_tx = (peer_tx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;

if (peer_tx != IEEE80211_HE_MCS_NOT_SUPPORTED) {
if (own_rx == IEEE80211_HE_MCS_NOT_SUPPORTED)
peer_tx = IEEE80211_HE_MCS_NOT_SUPPORTED;
else if (own_rx < peer_tx)
peer_tx = own_rx;
}

if (peer_rx != IEEE80211_HE_MCS_NOT_SUPPORTED) {
if (own_tx == IEEE80211_HE_MCS_NOT_SUPPORTED)
peer_rx = IEEE80211_HE_MCS_NOT_SUPPORTED;
else if (own_tx < peer_rx)
peer_rx = own_tx;
}

*he_peer_rx &=
~cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2);
*he_peer_rx |= cpu_to_le16(peer_rx << i * 2);

*he_peer_tx &=
~cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2);
*he_peer_tx |= cpu_to_le16(peer_tx << i * 2);
}
}

void
ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
struct ieee80211_supported_band *sband,
Expand All @@ -60,10 +111,12 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta)
{
struct ieee80211_sta_he_cap *he_cap = &sta->sta.he_cap;
struct ieee80211_sta_he_cap own_he_cap = sband->iftype_data->he_cap;
struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie;
u8 he_ppe_size;
u8 mcs_nss_size;
u8 he_total_size;
bool own_160, peer_160, own_80p80, peer_80p80;

memset(he_cap, 0, sizeof(*he_cap));

Expand Down Expand Up @@ -101,6 +154,45 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,

if (sband->band == NL80211_BAND_6GHZ && he_6ghz_capa)
ieee80211_update_from_he_6ghz_capa(he_6ghz_capa, sta);

ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_80,
&he_cap->he_mcs_nss_supp.rx_mcs_80,
&own_he_cap.he_mcs_nss_supp.tx_mcs_80,
&he_cap->he_mcs_nss_supp.tx_mcs_80);

own_160 = own_he_cap.he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
peer_160 = he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;

if (peer_160 && own_160) {
ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_160,
&he_cap->he_mcs_nss_supp.rx_mcs_160,
&own_he_cap.he_mcs_nss_supp.tx_mcs_160,
&he_cap->he_mcs_nss_supp.tx_mcs_160);
} else if (peer_160 && !own_160) {
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.rx_mcs_160);
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.tx_mcs_160);
he_cap->he_cap_elem.phy_cap_info[0] &=
~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
}

own_80p80 = own_he_cap.he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
peer_80p80 = he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;

if (peer_80p80 && own_80p80) {
ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_80p80,
&he_cap->he_mcs_nss_supp.rx_mcs_80p80,
&own_he_cap.he_mcs_nss_supp.tx_mcs_80p80,
&he_cap->he_mcs_nss_supp.tx_mcs_80p80);
} else if (peer_80p80 && !own_80p80) {
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.rx_mcs_80p80);
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.tx_mcs_80p80);
he_cap->he_cap_elem.phy_cap_info[0] &=
~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
}
}

void
Expand Down

0 comments on commit 7f7aa94

Please sign in to comment.