1 /* 2 * Copyright (c) 2011,2014-2020 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef EXTERNAL_USE_ONLY 21 #include "osdep.h" 22 #endif /* EXTERNAL_USE_ONLY */ 23 #include "cds_ieee80211_common_i.h" 24 #include "cdp_txrx_mob_def.h" 25 26 #ifndef CDS_COMMON_IEEE80211_H_ 27 #define CDS_COMMON_IEEE80211_H_ 28 29 /* 30 * generic definitions for IEEE 802.11 frames 31 */ 32 struct ieee80211_frame { 33 uint8_t i_fc[2]; 34 uint8_t i_dur[2]; 35 union { 36 struct { 37 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 38 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 39 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 40 }; 41 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 42 }; 43 uint8_t i_seq[2]; 44 /* possibly followed by addr4[QDF_MAC_ADDR_SIZE]; */ 45 /* see below */ 46 } __packed; 47 48 struct ieee80211_qosframe { 49 uint8_t i_fc[2]; 50 uint8_t i_dur[2]; 51 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 52 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 53 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 54 uint8_t i_seq[2]; 55 uint8_t i_qos[2]; 56 /* possibly followed by addr4[QDF_MAC_ADDR_SIZE]; */ 57 /* see below */ 58 } __packed; 59 60 struct ieee80211_frame_bar { 61 uint8_t i_fc[2]; 62 uint8_t i_dur[2]; 63 uint8_t i_ra[QDF_MAC_ADDR_SIZE]; 64 uint8_t i_ta[QDF_MAC_ADDR_SIZE]; 65 uint16_t i_ctl; 66 uint16_t i_seq; 67 /* FCS */ 68 } __packed; 69 70 struct ieee80211_qoscntl { 71 uint8_t i_qos[2]; 72 }; 73 74 struct ieee80211_frame_addr4 { 75 uint8_t i_fc[2]; 76 uint8_t i_dur[2]; 77 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 78 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 79 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 80 uint8_t i_seq[2]; 81 uint8_t i_addr4[QDF_MAC_ADDR_SIZE]; 82 } __packed; 83 84 struct ieee80211_qosframe_addr4 { 85 uint8_t i_fc[2]; 86 uint8_t i_dur[2]; 87 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 88 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 89 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 90 uint8_t i_seq[2]; 91 uint8_t i_addr4[QDF_MAC_ADDR_SIZE]; 92 uint8_t i_qos[2]; 93 } __packed; 94 95 /* HTC frame for TxBF*/ 96 /* for TxBF RC */ 97 struct ieee80211_frame_min_one { 98 uint8_t i_fc[2]; 99 uint8_t i_dur[2]; 100 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 101 } __packed; /* For TxBF RC */ 102 103 struct ieee80211_qosframe_htc_addr4 { 104 uint8_t i_fc[2]; 105 uint8_t i_dur[2]; 106 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 107 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 108 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 109 uint8_t i_seq[2]; 110 uint8_t i_addr4[QDF_MAC_ADDR_SIZE]; 111 uint8_t i_qos[2]; 112 uint8_t i_htc[4]; 113 } __packed; 114 115 struct ieee80211_htc { 116 uint8_t i_htc[4]; 117 }; 118 119 #define IEEE80211_FC0_VERSION_0 0x00 120 #define IEEE80211_FC0_TYPE_MASK 0x0c 121 #define IEEE80211_FC0_TYPE_MGT 0x00 122 #define IEEE80211_FC0_TYPE_CTL 0x04 123 #define IEEE80211_FC0_TYPE_DATA 0x08 124 125 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 126 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 127 128 #define IEEE80211_FC1_DIR_MASK 0x03 129 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 130 #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 131 #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 132 #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 133 134 #define IEEE80211_FC1_MORE_FRAG 0x04 135 #define IEEE80211_FC1_RETRY 0x08 136 #define IEEE80211_FC1_PWR_MGT 0x10 137 #define IEEE80211_FC1_MORE_DATA 0x20 138 #define IEEE80211_FC1_ORDER 0x80 139 140 #define IEEE80211_SEQ_FRAG_MASK 0x000f 141 #define IEEE80211_SEQ_FRAG_SHIFT 0 142 #define IEEE80211_SEQ_SEQ_MASK 0xfff0 143 #define IEEE80211_SEQ_SEQ_SHIFT 4 144 #define IEEE80211_SEQ_MAX 4096 145 146 #define IEEE80211_QOS_AMSDU 0x80 147 #define IEEE80211_QOS_ACKPOLICY_S 5 148 #define IEEE80211_QOS_TID 0x0f 149 150 #define IEEE80211_IS_DATA(_frame) (((_frame)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA) 151 152 /* does frame have QoS sequence control data */ 153 #define IEEE80211_QOS_HAS_SEQ(wh) \ 154 (((wh)->i_fc[0] & \ 155 (IEEE80211_FC0_TYPE_MASK | QDF_IEEE80211_FC0_SUBTYPE_QOS)) == \ 156 (IEEE80211_FC0_TYPE_DATA | QDF_IEEE80211_FC0_SUBTYPE_QOS)) 157 158 #define IEEE80211_HTCAP_MAXRXAMPDU_FACTOR 13 159 160 struct ieee80211_channelswitch_ie { 161 uint8_t ie; /* IEEE80211_ELEMID_CHANSWITCHANN */ 162 uint8_t len; 163 uint8_t switchmode; 164 uint8_t newchannel; 165 uint8_t tbttcount; 166 } __packed; 167 168 struct ieee80211_extendedchannelswitch_ie { 169 uint8_t ie; /* IEEE80211_ELEMID_EXTCHANSWITCHANN */ 170 uint8_t len; 171 uint8_t switchmode; 172 uint8_t newClass; 173 uint8_t newchannel; 174 uint8_t tbttcount; 175 } __packed; 176 177 /* 178 * Reason codes 179 * 180 * Unlisted codes are reserved 181 */ 182 enum { 183 IEEE80211_REASON_UNSPECIFIED = 1, 184 IEEE80211_REASON_AUTH_EXPIRE = 2, 185 IEEE80211_REASON_AUTH_LEAVE = 3, 186 IEEE80211_REASON_ASSOC_EXPIRE = 4, 187 IEEE80211_REASON_ASSOC_TOOMANY = 5, 188 IEEE80211_REASON_NOT_AUTHED = 6, 189 IEEE80211_REASON_NOT_ASSOCED = 7, 190 IEEE80211_REASON_ASSOC_LEAVE = 8, 191 IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, 192 193 IEEE80211_REASON_RSN_REQUIRED = 11, 194 IEEE80211_REASON_RSN_INCONSISTENT = 12, 195 IEEE80211_REASON_IE_INVALID = 13, 196 IEEE80211_REASON_MIC_FAILURE = 14, 197 198 IEEE80211_REASON_QOS = 32, 199 IEEE80211_REASON_QOS_BANDWITDH = 33, 200 IEEE80211_REASON_QOS_CH_CONDITIONS = 34, 201 IEEE80211_REASON_QOS_TXOP = 35, 202 IEEE80211_REASON_QOS_LEAVE = 36, 203 IEEE80211_REASON_QOS_DECLINED = 37, 204 IEEE80211_REASON_QOS_SETUP_REQUIRED = 38, 205 IEEE80211_REASON_QOS_TIMEOUT = 39, 206 IEEE80211_REASON_QOS_CIPHER = 45, 207 208 IEEE80211_STATUS_SUCCESS = 0, 209 IEEE80211_STATUS_UNSPECIFIED = 1, 210 IEEE80211_STATUS_CAPINFO = 10, 211 IEEE80211_STATUS_NOT_ASSOCED = 11, 212 IEEE80211_STATUS_OTHER = 12, 213 IEEE80211_STATUS_ALG = 13, 214 IEEE80211_STATUS_SEQUENCE = 14, 215 IEEE80211_STATUS_CHALLENGE = 15, 216 IEEE80211_STATUS_TIMEOUT = 16, 217 IEEE80211_STATUS_TOOMANY = 17, 218 IEEE80211_STATUS_BASIC_RATE = 18, 219 IEEE80211_STATUS_SP_REQUIRED = 19, 220 IEEE80211_STATUS_PBCC_REQUIRED = 20, 221 IEEE80211_STATUS_CA_REQUIRED = 21, 222 IEEE80211_STATUS_TOO_MANY_STATIONS = 22, 223 IEEE80211_STATUS_RATES = 23, 224 IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, 225 IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, 226 IEEE80211_STATUS_NO_HT = 27, 227 IEEE80211_STATUS_REJECT_TEMP = 30, 228 IEEE80211_STATUS_MFP_VIOLATION = 31, 229 IEEE80211_STATUS_REFUSED = 37, 230 IEEE80211_STATUS_INVALID_PARAM = 38, 231 232 IEEE80211_STATUS_DLS_NOT_ALLOWED = 48, 233 }; 234 235 #define IEEE80211_WEP_IVLEN 3 /* 24bit */ 236 #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ 237 #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ 238 239 /* 240 * 802.11i defines an extended IV for use with non-WEP ciphers. 241 * When the EXTIV bit is set in the key id byte an additional 242 * 4 bytes immediately follow the IV for TKIP. For CCMP the 243 * EXTIV bit is likewise set but the 8 bytes represent the 244 * CCMP header rather than IV+extended-IV. 245 */ 246 #define IEEE80211_WEP_EXTIV 0x20 247 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ 248 #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ 249 250 /* 251 * 802.11w defines a MMIE chunk to be attached at the end of 252 * any outgoing broadcast or multicast robust management frame. 253 * MMIE field is total 18 bytes in size. Following the diagram of MMIE 254 * 255 * <------------ 18 Bytes MMIE -----------------------> 256 * +--------+---------+---------+-----------+---------+ 257 * |Element | Length | Key id | IPN | MIC | 258 * | id | | | | | 259 * +--------+---------+---------+-----------+---------+ 260 * bytes 1 1 2 6 8 261 * 262 */ 263 #define IEEE80211_MMIE_LEN 18 264 #define IEEE80211_MMIE_IPNLEN 6 265 #define IEEE80211_MMIE_MICLEN 8 266 267 /* 268 * 802.11ac Wide Bandwidth Channel Switch Element 269 */ 270 271 struct ieee80211_ie_wide_bw_switch { 272 uint8_t elem_id; 273 uint8_t elem_len; 274 uint8_t new_ch_width; /* New channel width */ 275 uint8_t new_ch_freq_seg1; /* Channel Center frequency 1 */ 276 uint8_t new_ch_freq_seg2; /* Channel Center frequency 2 */ 277 } __packed; 278 279 #endif /* CDS_COMMON_IEEE80211_H_ */ 280