| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
| 3 | * IEEE 802.11 VHT definitions |
| 4 | * |
| 5 | * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen |
| 6 | * <jkmaline@cc.hut.fi> |
| 7 | * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> |
| 8 | * Copyright (c) 2005, Devicescape Software, Inc. |
| 9 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> |
| 10 | * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH |
| 11 | * Copyright (c) 2016 - 2017 Intel Deutschland GmbH |
| 12 | * Copyright (c) 2018 - 2025 Intel Corporation |
| 13 | */ |
| 14 | |
| 15 | #ifndef LINUX_IEEE80211_VHT_H |
| 16 | #define LINUX_IEEE80211_VHT_H |
| 17 | |
| 18 | #include <linux/types.h> |
| 19 | #include <linux/if_ether.h> |
| 20 | |
| 21 | #define IEEE80211_MAX_MPDU_LEN_VHT_3895 3895 |
| 22 | #define IEEE80211_MAX_MPDU_LEN_VHT_7991 7991 |
| 23 | #define IEEE80211_MAX_MPDU_LEN_VHT_11454 11454 |
| 24 | |
| 25 | /** |
| 26 | * enum ieee80211_vht_opmode_bits - VHT operating mode field bits |
| 27 | * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK: channel width mask |
| 28 | * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: 20 MHz channel width |
| 29 | * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width |
| 30 | * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width |
| 31 | * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width |
| 32 | * @IEEE80211_OPMODE_NOTIF_BW_160_80P80: 160 / 80+80 MHz indicator flag |
| 33 | * @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask |
| 34 | * (the NSS value is the value of this field + 1) |
| 35 | * @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift |
| 36 | * @IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF: indicates streams in SU-MIMO PPDU |
| 37 | * using a beamforming steering matrix |
| 38 | */ |
| 39 | enum ieee80211_vht_opmode_bits { |
| 40 | IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 0x03, |
| 41 | IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0, |
| 42 | IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1, |
| 43 | IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2, |
| 44 | IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3, |
| 45 | IEEE80211_OPMODE_NOTIF_BW_160_80P80 = 0x04, |
| 46 | IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 0x70, |
| 47 | IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4, |
| 48 | IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80, |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * Maximum length of AMPDU that the STA can receive in VHT. |
| 53 | * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets) |
| 54 | */ |
| 55 | enum ieee80211_vht_max_ampdu_length_exp { |
| 56 | IEEE80211_VHT_MAX_AMPDU_8K = 0, |
| 57 | IEEE80211_VHT_MAX_AMPDU_16K = 1, |
| 58 | IEEE80211_VHT_MAX_AMPDU_32K = 2, |
| 59 | IEEE80211_VHT_MAX_AMPDU_64K = 3, |
| 60 | IEEE80211_VHT_MAX_AMPDU_128K = 4, |
| 61 | IEEE80211_VHT_MAX_AMPDU_256K = 5, |
| 62 | IEEE80211_VHT_MAX_AMPDU_512K = 6, |
| 63 | IEEE80211_VHT_MAX_AMPDU_1024K = 7 |
| 64 | }; |
| 65 | |
| 66 | /** |
| 67 | * struct ieee80211_vht_mcs_info - VHT MCS information |
| 68 | * @rx_mcs_map: RX MCS map 2 bits for each stream, total 8 streams |
| 69 | * @rx_highest: Indicates highest long GI VHT PPDU data rate |
| 70 | * STA can receive. Rate expressed in units of 1 Mbps. |
| 71 | * If this field is 0 this value should not be used to |
| 72 | * consider the highest RX data rate supported. |
| 73 | * The top 3 bits of this field indicate the Maximum NSTS,total |
| 74 | * (a beamformee capability.) |
| 75 | * @tx_mcs_map: TX MCS map 2 bits for each stream, total 8 streams |
| 76 | * @tx_highest: Indicates highest long GI VHT PPDU data rate |
| 77 | * STA can transmit. Rate expressed in units of 1 Mbps. |
| 78 | * If this field is 0 this value should not be used to |
| 79 | * consider the highest TX data rate supported. |
| 80 | * The top 2 bits of this field are reserved, the |
| 81 | * 3rd bit from the top indiciates VHT Extended NSS BW |
| 82 | * Capability. |
| 83 | */ |
| 84 | struct ieee80211_vht_mcs_info { |
| 85 | __le16 rx_mcs_map; |
| 86 | __le16 rx_highest; |
| 87 | __le16 tx_mcs_map; |
| 88 | __le16 tx_highest; |
| 89 | } __packed; |
| 90 | |
| 91 | /* for rx_highest */ |
| 92 | #define IEEE80211_VHT_MAX_NSTS_TOTAL_SHIFT 13 |
| 93 | #define IEEE80211_VHT_MAX_NSTS_TOTAL_MASK (7 << IEEE80211_VHT_MAX_NSTS_TOTAL_SHIFT) |
| 94 | |
| 95 | /* for tx_highest */ |
| 96 | #define IEEE80211_VHT_EXT_NSS_BW_CAPABLE (1 << 13) |
| 97 | |
| 98 | /** |
| 99 | * enum ieee80211_vht_mcs_support - VHT MCS support definitions |
| 100 | * @IEEE80211_VHT_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the |
| 101 | * number of streams |
| 102 | * @IEEE80211_VHT_MCS_SUPPORT_0_8: MCSes 0-8 are supported |
| 103 | * @IEEE80211_VHT_MCS_SUPPORT_0_9: MCSes 0-9 are supported |
| 104 | * @IEEE80211_VHT_MCS_NOT_SUPPORTED: This number of streams isn't supported |
| 105 | * |
| 106 | * These definitions are used in each 2-bit subfield of the @rx_mcs_map |
| 107 | * and @tx_mcs_map fields of &struct ieee80211_vht_mcs_info, which are |
| 108 | * both split into 8 subfields by number of streams. These values indicate |
| 109 | * which MCSes are supported for the number of streams the value appears |
| 110 | * for. |
| 111 | */ |
| 112 | enum ieee80211_vht_mcs_support { |
| 113 | IEEE80211_VHT_MCS_SUPPORT_0_7 = 0, |
| 114 | IEEE80211_VHT_MCS_SUPPORT_0_8 = 1, |
| 115 | IEEE80211_VHT_MCS_SUPPORT_0_9 = 2, |
| 116 | IEEE80211_VHT_MCS_NOT_SUPPORTED = 3, |
| 117 | }; |
| 118 | |
| 119 | /** |
| 120 | * struct ieee80211_vht_cap - VHT capabilities |
| 121 | * |
| 122 | * This structure is the "VHT capabilities element" as |
| 123 | * described in 802.11ac D3.0 8.4.2.160 |
| 124 | * @vht_cap_info: VHT capability info |
| 125 | * @supp_mcs: VHT MCS supported rates |
| 126 | */ |
| 127 | struct ieee80211_vht_cap { |
| 128 | __le32 vht_cap_info; |
| 129 | struct ieee80211_vht_mcs_info supp_mcs; |
| 130 | } __packed; |
| 131 | |
| 132 | /** |
| 133 | * enum ieee80211_vht_chanwidth - VHT channel width |
| 134 | * @IEEE80211_VHT_CHANWIDTH_USE_HT: use the HT operation IE to |
| 135 | * determine the channel width (20 or 40 MHz) |
| 136 | * @IEEE80211_VHT_CHANWIDTH_80MHZ: 80 MHz bandwidth |
| 137 | * @IEEE80211_VHT_CHANWIDTH_160MHZ: 160 MHz bandwidth |
| 138 | * @IEEE80211_VHT_CHANWIDTH_80P80MHZ: 80+80 MHz bandwidth |
| 139 | */ |
| 140 | enum ieee80211_vht_chanwidth { |
| 141 | IEEE80211_VHT_CHANWIDTH_USE_HT = 0, |
| 142 | IEEE80211_VHT_CHANWIDTH_80MHZ = 1, |
| 143 | IEEE80211_VHT_CHANWIDTH_160MHZ = 2, |
| 144 | IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, |
| 145 | }; |
| 146 | |
| 147 | /** |
| 148 | * struct ieee80211_vht_operation - VHT operation IE |
| 149 | * |
| 150 | * This structure is the "VHT operation element" as |
| 151 | * described in 802.11ac D3.0 8.4.2.161 |
| 152 | * @chan_width: Operating channel width |
| 153 | * @center_freq_seg0_idx: center freq segment 0 index |
| 154 | * @center_freq_seg1_idx: center freq segment 1 index |
| 155 | * @basic_mcs_set: VHT Basic MCS rate set |
| 156 | */ |
| 157 | struct ieee80211_vht_operation { |
| 158 | u8 chan_width; |
| 159 | u8 center_freq_seg0_idx; |
| 160 | u8 center_freq_seg1_idx; |
| 161 | __le16 basic_mcs_set; |
| 162 | } __packed; |
| 163 | |
| 164 | /* 802.11ac VHT Capabilities */ |
| 165 | #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000 |
| 166 | #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001 |
| 167 | #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002 |
| 168 | #define IEEE80211_VHT_CAP_MAX_MPDU_MASK 0x00000003 |
| 169 | #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004 |
| 170 | #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008 |
| 171 | #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C |
| 172 | #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_SHIFT 2 |
| 173 | #define IEEE80211_VHT_CAP_RXLDPC 0x00000010 |
| 174 | #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020 |
| 175 | #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040 |
| 176 | #define IEEE80211_VHT_CAP_TXSTBC 0x00000080 |
| 177 | #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100 |
| 178 | #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200 |
| 179 | #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300 |
| 180 | #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400 |
| 181 | #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 |
| 182 | #define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8 |
| 183 | #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 |
| 184 | #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 |
| 185 | #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13 |
| 186 | #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK \ |
| 187 | (7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT) |
| 188 | #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16 |
| 189 | #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \ |
| 190 | (7 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT) |
| 191 | #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000 |
| 192 | #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000 |
| 193 | #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000 |
| 194 | #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000 |
| 195 | #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23 |
| 196 | #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \ |
| 197 | (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT) |
| 198 | #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000 |
| 199 | #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000 |
| 200 | #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000 |
| 201 | #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000 |
| 202 | #define IEEE80211_VHT_CAP_EXT_NSS_BW_SHIFT 30 |
| 203 | #define IEEE80211_VHT_CAP_EXT_NSS_BW_MASK 0xc0000000 |
| 204 | |
| 205 | /** |
| 206 | * ieee80211_get_vht_max_nss - return max NSS for a given bandwidth/MCS |
| 207 | * @cap: VHT capabilities of the peer |
| 208 | * @bw: bandwidth to use |
| 209 | * @mcs: MCS index to use |
| 210 | * @ext_nss_bw_capable: indicates whether or not the local transmitter |
| 211 | * (rate scaling algorithm) can deal with the new logic |
| 212 | * (dot11VHTExtendedNSSBWCapable) |
| 213 | * @max_vht_nss: current maximum NSS as advertised by the STA in |
| 214 | * operating mode notification, can be 0 in which case the |
| 215 | * capability data will be used to derive this (from MCS support) |
| 216 | * Return: The maximum NSS that can be used for the given bandwidth/MCS |
| 217 | * combination |
| 218 | * |
| 219 | * Due to the VHT Extended NSS Bandwidth Support, the maximum NSS can |
| 220 | * vary for a given BW/MCS. This function parses the data. |
| 221 | * |
| 222 | * Note: This function is exported by cfg80211. |
| 223 | */ |
| 224 | int ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *cap, |
| 225 | enum ieee80211_vht_chanwidth bw, |
| 226 | int mcs, bool ext_nss_bw_capable, |
| 227 | unsigned int max_vht_nss); |
| 228 | |
| 229 | /* VHT action codes */ |
| 230 | enum ieee80211_vht_actioncode { |
| 231 | WLAN_VHT_ACTION_COMPRESSED_BF = 0, |
| 232 | WLAN_VHT_ACTION_GROUPID_MGMT = 1, |
| 233 | WLAN_VHT_ACTION_OPMODE_NOTIF = 2, |
| 234 | }; |
| 235 | |
| 236 | #endif /* LINUX_IEEE80211_VHT_H */ |
| 237 | |