Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * HE handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright(c) 2017 Intel Deutschland GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright(c) 2019 - 2020 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) ieee80211_update_from_he_6ghz_capa(const struct ieee80211_he_6ghz_capa *he_6ghz_capa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 				   struct sta_info *sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	enum ieee80211_smps_mode smps_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	    sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 		switch (le16_get_bits(he_6ghz_capa->capa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 				      IEEE80211_HE_6GHZ_CAP_SM_PS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		case WLAN_HT_CAP_SM_PS_INVALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		case WLAN_HT_CAP_SM_PS_STATIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 			smps_mode = IEEE80211_SMPS_STATIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		case WLAN_HT_CAP_SM_PS_DYNAMIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 			smps_mode = IEEE80211_SMPS_DYNAMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		case WLAN_HT_CAP_SM_PS_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			smps_mode = IEEE80211_SMPS_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		sta->sta.smps_mode = smps_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		sta->sta.smps_mode = IEEE80211_SMPS_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	switch (le16_get_bits(he_6ghz_capa->capa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			      IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		sta->sta.max_amsdu_len = IEEE80211_MAX_MPDU_LEN_VHT_11454;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		sta->sta.max_amsdu_len = IEEE80211_MAX_MPDU_LEN_VHT_7991;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		sta->sta.max_amsdu_len = IEEE80211_MAX_MPDU_LEN_VHT_3895;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	sta->sta.he_6ghz_capa = *he_6ghz_capa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 				  struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				  const u8 *he_cap_ie, u8 he_cap_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 				  const struct ieee80211_he_6ghz_capa *he_6ghz_capa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 				  struct sta_info *sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct ieee80211_sta_he_cap *he_cap = &sta->sta.he_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u8 he_ppe_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u8 mcs_nss_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u8 he_total_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	memset(he_cap, 0, sizeof(*he_cap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (!he_cap_ie || !ieee80211_get_he_sta_cap(sband))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	/* Make sure size is OK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	mcs_nss_size = ieee80211_he_mcs_nss_size(he_cap_ie_elem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	he_ppe_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		ieee80211_he_ppe_size(he_cap_ie[sizeof(he_cap->he_cap_elem) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 						mcs_nss_size],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				      he_cap_ie_elem->phy_cap_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	he_total_size = sizeof(he_cap->he_cap_elem) + mcs_nss_size +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			he_ppe_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (he_cap_len < he_total_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	memcpy(&he_cap->he_cap_elem, he_cap_ie, sizeof(he_cap->he_cap_elem));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* HE Tx/Rx HE MCS NSS Support Field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	memcpy(&he_cap->he_mcs_nss_supp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	       &he_cap_ie[sizeof(he_cap->he_cap_elem)], mcs_nss_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* Check if there are (optional) PPE Thresholds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (he_cap->he_cap_elem.phy_cap_info[6] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	    IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		memcpy(he_cap->ppe_thres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		       &he_cap_ie[sizeof(he_cap->he_cap_elem) + mcs_nss_size],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		       he_ppe_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	he_cap->has_he = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	sta->cur_max_bandwidth = ieee80211_sta_cap_rx_bw(sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	sta->sta.bandwidth = ieee80211_sta_cur_vht_bw(sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (sband->band == NL80211_BAND_6GHZ && he_6ghz_capa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		ieee80211_update_from_he_6ghz_capa(he_6ghz_capa, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			const struct ieee80211_he_operation *he_op_ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	memset(&vif->bss_conf.he_oper, 0, sizeof(vif->bss_conf.he_oper));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (!he_op_ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	vif->bss_conf.he_oper.params = __le32_to_cpu(he_op_ie->he_oper_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	vif->bss_conf.he_oper.nss_set = __le16_to_cpu(he_op_ie->he_mcs_nss_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 				const struct ieee80211_he_spr *he_spr_ie_elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	struct ieee80211_he_obss_pd *he_obss_pd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 					&vif->bss_conf.he_obss_pd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	const u8 *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	memset(he_obss_pd, 0, sizeof(*he_obss_pd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (!he_spr_ie_elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	data = he_spr_ie_elem->optional;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (he_spr_ie_elem->he_sr_control &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	    IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		data++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (he_spr_ie_elem->he_sr_control &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	    IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		he_obss_pd->max_offset = *data++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		he_obss_pd->min_offset = *data++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		he_obss_pd->enable = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }