1 /* 2 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 #include "qdf_util.h" 19 #include "qdf_types.h" 20 #include "qdf_lock.h" 21 #include "qdf_mem.h" 22 #include "qdf_nbuf.h" 23 #include "tcl_data_cmd.h" 24 #include "mac_tcl_reg_seq_hwioreg.h" 25 #include "phyrx_rssi_legacy.h" 26 #include "rx_msdu_start.h" 27 #include "tlv_tag_def.h" 28 #include "hal_hw_headers.h" 29 #include "hal_internal.h" 30 #include "cdp_txrx_mon_struct.h" 31 #include "qdf_trace.h" 32 #include "hal_rx.h" 33 #include "hal_tx.h" 34 #include "dp_types.h" 35 #include "hal_api_mon.h" 36 #include "phyrx_other_receive_info_ru_details.h" 37 38 #define HAL_RX_MSDU_START_MIMO_SS_BITMAP(_rx_msdu_start)\ 39 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\ 40 RX_MSDU_START_5_MIMO_SS_BITMAP_OFFSET)), \ 41 RX_MSDU_START_5_MIMO_SS_BITMAP_MASK, \ 42 RX_MSDU_START_5_MIMO_SS_BITMAP_LSB)) 43 44 /* 45 * hal_rx_msdu_start_nss_get_6390(): API to get the NSS 46 * Interval from rx_msdu_start 47 * 48 * @buf: pointer to the start of RX PKT TLV header 49 * Return: uint32_t(nss) 50 */ 51 static uint32_t 52 hal_rx_msdu_start_nss_get_6390(uint8_t *buf) 53 { 54 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 55 struct rx_msdu_start *msdu_start = 56 &pkt_tlvs->msdu_start_tlv.rx_msdu_start; 57 uint8_t mimo_ss_bitmap; 58 uint32_t ss_index; 59 60 mimo_ss_bitmap = HAL_RX_MSDU_START_MIMO_SS_BITMAP(msdu_start); 61 ss_index = qdf_get_hweight8(mimo_ss_bitmap); 62 63 /* Hot fix only, maxinum nss number for MCL set to 1 (nss 2)*/ 64 if ((ss_index > 1) && (ss_index <= 3)) 65 ss_index = 1; 66 67 return ss_index; 68 } 69 70 /** 71 * hal_rx_mon_hw_desc_get_mpdu_status_6390(): Retrieve MPDU status 72 * 73 * @ hw_desc_addr: Start address of Rx HW TLVs 74 * @ rs: Status for monitor mode 75 * 76 * Return: void 77 */ 78 static void hal_rx_mon_hw_desc_get_mpdu_status_6390(void *hw_desc_addr, 79 struct mon_rx_status *rs) 80 { 81 struct rx_msdu_start *rx_msdu_start; 82 struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr; 83 uint32_t reg_value; 84 const uint32_t sgi_hw_to_cdp[] = { 85 CDP_SGI_0_8_US, 86 CDP_SGI_0_4_US, 87 CDP_SGI_1_6_US, 88 CDP_SGI_3_2_US, 89 }; 90 91 rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start; 92 93 HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs); 94 95 rs->ant_signal_db = HAL_RX_GET(rx_msdu_start, 96 RX_MSDU_START_5, USER_RSSI); 97 rs->is_stbc = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, STBC); 98 99 reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, SGI); 100 rs->sgi = sgi_hw_to_cdp[reg_value]; 101 102 reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, RECEPTION_TYPE); 103 rs->beamformed = (reg_value == HAL_RX_RECEPTION_TYPE_MU_MIMO) ? 1 : 0; 104 /* TODO: rs->beamformed should be set for SU beamforming also */ 105 } 106 107 #define LINK_DESC_SIZE (NUM_OF_DWORDS_RX_MSDU_LINK << 2) 108 109 static uint32_t hal_get_link_desc_size_6390(void) 110 { 111 return LINK_DESC_SIZE; 112 } 113 114 /* 115 * hal_rx_get_tlv_6390(): API to get the tlv 116 * 117 * @rx_tlv: TLV data extracted from the rx packet 118 * Return: uint8_t 119 */ 120 static uint8_t hal_rx_get_tlv_6390(void *rx_tlv) 121 { 122 return HAL_RX_GET(rx_tlv, PHYRX_RSSI_LEGACY_0, RECEIVE_BANDWIDTH); 123 } 124 125 /** 126 * hal_rx_proc_phyrx_other_receive_info_tlv_6390() 127 * - process other receive info TLV 128 * @rx_tlv_hdr: pointer to TLV header 129 * @ppdu_info: pointer to ppdu_info 130 * 131 * Return: None 132 */ 133 static 134 void hal_rx_proc_phyrx_other_receive_info_tlv_6390(void *rx_tlv_hdr, 135 void *ppdu_info_handle) 136 { 137 uint32_t tlv_tag, tlv_len; 138 uint32_t temp_len, other_tlv_len, other_tlv_tag; 139 void *rx_tlv = (uint8_t *)rx_tlv_hdr + HAL_RX_TLV32_HDR_SIZE; 140 void *other_tlv_hdr = NULL; 141 void *other_tlv = NULL; 142 143 tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv_hdr); 144 tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv_hdr); 145 temp_len = 0; 146 147 other_tlv_hdr = rx_tlv + HAL_RX_TLV32_HDR_SIZE; 148 149 other_tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(other_tlv_hdr); 150 other_tlv_len = HAL_RX_GET_USER_TLV32_LEN(other_tlv_hdr); 151 temp_len += other_tlv_len; 152 other_tlv = other_tlv_hdr + HAL_RX_TLV32_HDR_SIZE; 153 154 switch (other_tlv_tag) { 155 default: 156 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, 157 "%s unhandled TLV type: %d, TLV len:%d", 158 __func__, other_tlv_tag, other_tlv_len); 159 break; 160 } 161 } 162 163 /** 164 * hal_rx_dump_msdu_start_tlv_6390() : dump RX msdu_start TLV in structured 165 * human readable format. 166 * @ msdu_start: pointer the msdu_start TLV in pkt. 167 * @ dbg_level: log level. 168 * 169 * Return: void 170 */ 171 static void hal_rx_dump_msdu_start_tlv_6390(void *msdustart, uint8_t dbg_level) 172 { 173 struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart; 174 175 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 176 "rx_msdu_start tlv (1/2) - " 177 "rxpcu_mpdu_filter_in_category: %x " 178 "sw_frame_group_id: %x " 179 "phy_ppdu_id: %x " 180 "msdu_length: %x " 181 "ipsec_esp: %x " 182 "l3_offset: %x " 183 "ipsec_ah: %x " 184 "l4_offset: %x " 185 "msdu_number: %x " 186 "decap_format: %x " 187 "ipv4_proto: %x " 188 "ipv6_proto: %x " 189 "tcp_proto: %x " 190 "udp_proto: %x " 191 "ip_frag: %x " 192 "tcp_only_ack: %x " 193 "da_is_bcast_mcast: %x " 194 "ip4_protocol_ip6_next_header: %x " 195 "toeplitz_hash_2_or_4: %x " 196 "flow_id_toeplitz: %x " 197 "user_rssi: %x " 198 "pkt_type: %x " 199 "stbc: %x " 200 "sgi: %x " 201 "rate_mcs: %x " 202 "receive_bandwidth: %x " 203 "reception_type: %x " 204 "ppdu_start_timestamp: %u ", 205 msdu_start->rxpcu_mpdu_filter_in_category, 206 msdu_start->sw_frame_group_id, 207 msdu_start->phy_ppdu_id, 208 msdu_start->msdu_length, 209 msdu_start->ipsec_esp, 210 msdu_start->l3_offset, 211 msdu_start->ipsec_ah, 212 msdu_start->l4_offset, 213 msdu_start->msdu_number, 214 msdu_start->decap_format, 215 msdu_start->ipv4_proto, 216 msdu_start->ipv6_proto, 217 msdu_start->tcp_proto, 218 msdu_start->udp_proto, 219 msdu_start->ip_frag, 220 msdu_start->tcp_only_ack, 221 msdu_start->da_is_bcast_mcast, 222 msdu_start->ip4_protocol_ip6_next_header, 223 msdu_start->toeplitz_hash_2_or_4, 224 msdu_start->flow_id_toeplitz, 225 msdu_start->user_rssi, 226 msdu_start->pkt_type, 227 msdu_start->stbc, 228 msdu_start->sgi, 229 msdu_start->rate_mcs, 230 msdu_start->receive_bandwidth, 231 msdu_start->reception_type, 232 msdu_start->ppdu_start_timestamp); 233 234 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 235 "rx_msdu_start tlv (2/2) - " 236 "sw_phy_meta_data: %x ", 237 msdu_start->sw_phy_meta_data); 238 } 239 240 /** 241 * hal_rx_dump_msdu_end_tlv_6390: dump RX msdu_end TLV in structured 242 * human readable format. 243 * @ msdu_end: pointer the msdu_end TLV in pkt. 244 * @ dbg_level: log level. 245 * 246 * Return: void 247 */ 248 static void hal_rx_dump_msdu_end_tlv_6390(void *msduend, 249 uint8_t dbg_level) 250 { 251 struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend; 252 253 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 254 "rx_msdu_end tlv (1/2) - " 255 "rxpcu_mpdu_filter_in_category: %x " 256 "sw_frame_group_id: %x " 257 "phy_ppdu_id: %x " 258 "ip_hdr_chksum: %x " 259 "tcp_udp_chksum: %x " 260 "key_id_octet: %x " 261 "cce_super_rule: %x " 262 "cce_classify_not_done_truncat: %x " 263 "cce_classify_not_done_cce_dis: %x " 264 "ext_wapi_pn_63_48: %x " 265 "ext_wapi_pn_95_64: %x " 266 "ext_wapi_pn_127_96: %x " 267 "reported_mpdu_length: %x " 268 "first_msdu: %x " 269 "last_msdu: %x " 270 "sa_idx_timeout: %x " 271 "da_idx_timeout: %x " 272 "msdu_limit_error: %x " 273 "flow_idx_timeout: %x " 274 "flow_idx_invalid: %x " 275 "wifi_parser_error: %x " 276 "amsdu_parser_error: %x", 277 msdu_end->rxpcu_mpdu_filter_in_category, 278 msdu_end->sw_frame_group_id, 279 msdu_end->phy_ppdu_id, 280 msdu_end->ip_hdr_chksum, 281 msdu_end->tcp_udp_chksum, 282 msdu_end->key_id_octet, 283 msdu_end->cce_super_rule, 284 msdu_end->cce_classify_not_done_truncate, 285 msdu_end->cce_classify_not_done_cce_dis, 286 msdu_end->ext_wapi_pn_63_48, 287 msdu_end->ext_wapi_pn_95_64, 288 msdu_end->ext_wapi_pn_127_96, 289 msdu_end->reported_mpdu_length, 290 msdu_end->first_msdu, 291 msdu_end->last_msdu, 292 msdu_end->sa_idx_timeout, 293 msdu_end->da_idx_timeout, 294 msdu_end->msdu_limit_error, 295 msdu_end->flow_idx_timeout, 296 msdu_end->flow_idx_invalid, 297 msdu_end->wifi_parser_error, 298 msdu_end->amsdu_parser_error); 299 300 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 301 "rx_msdu_end tlv (2/2)- " 302 "sa_is_valid: %x " 303 "da_is_valid: %x " 304 "da_is_mcbc: %x " 305 "l3_header_padding: %x " 306 "ipv6_options_crc: %x " 307 "tcp_seq_number: %x " 308 "tcp_ack_number: %x " 309 "tcp_flag: %x " 310 "lro_eligible: %x " 311 "window_size: %x " 312 "da_offset: %x " 313 "sa_offset: %x " 314 "da_offset_valid: %x " 315 "sa_offset_valid: %x " 316 "rule_indication_31_0: %x " 317 "rule_indication_63_32: %x " 318 "sa_idx: %x " 319 "da_idx: %x " 320 "msdu_drop: %x " 321 "reo_destination_indication: %x " 322 "flow_idx: %x " 323 "fse_metadata: %x " 324 "cce_metadata: %x " 325 "sa_sw_peer_id: %x ", 326 msdu_end->sa_is_valid, 327 msdu_end->da_is_valid, 328 msdu_end->da_is_mcbc, 329 msdu_end->l3_header_padding, 330 msdu_end->ipv6_options_crc, 331 msdu_end->tcp_seq_number, 332 msdu_end->tcp_ack_number, 333 msdu_end->tcp_flag, 334 msdu_end->lro_eligible, 335 msdu_end->window_size, 336 msdu_end->da_offset, 337 msdu_end->sa_offset, 338 msdu_end->da_offset_valid, 339 msdu_end->sa_offset_valid, 340 msdu_end->rule_indication_31_0, 341 msdu_end->rule_indication_63_32, 342 msdu_end->sa_idx, 343 msdu_end->da_idx_or_sw_peer_id, 344 msdu_end->msdu_drop, 345 msdu_end->reo_destination_indication, 346 msdu_end->flow_idx, 347 msdu_end->fse_metadata, 348 msdu_end->cce_metadata, 349 msdu_end->sa_sw_peer_id); 350 } 351 352 353 /* 354 * Get tid from RX_MPDU_START 355 */ 356 #define HAL_RX_MPDU_INFO_TID_GET(_rx_mpdu_info) \ 357 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \ 358 RX_MPDU_INFO_3_TID_OFFSET)), \ 359 RX_MPDU_INFO_3_TID_MASK, \ 360 RX_MPDU_INFO_3_TID_LSB)) 361 362 static uint32_t hal_rx_mpdu_start_tid_get_6390(uint8_t *buf) 363 { 364 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 365 struct rx_mpdu_start *mpdu_start = 366 &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start; 367 uint32_t tid; 368 369 tid = HAL_RX_MPDU_INFO_TID_GET(&mpdu_start->rx_mpdu_info_details); 370 371 return tid; 372 } 373 374 #define HAL_RX_MSDU_START_RECEPTION_TYPE_GET(_rx_msdu_start) \ 375 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \ 376 RX_MSDU_START_5_RECEPTION_TYPE_OFFSET)), \ 377 RX_MSDU_START_5_RECEPTION_TYPE_MASK, \ 378 RX_MSDU_START_5_RECEPTION_TYPE_LSB)) 379 380 /* 381 * hal_rx_msdu_start_reception_type_get(): API to get the reception type 382 * Interval from rx_msdu_start 383 * 384 * @buf: pointer to the start of RX PKT TLV header 385 * Return: uint32_t(reception_type) 386 */ 387 static 388 uint32_t hal_rx_msdu_start_reception_type_get_6390(uint8_t *buf) 389 { 390 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 391 struct rx_msdu_start *msdu_start = 392 &pkt_tlvs->msdu_start_tlv.rx_msdu_start; 393 uint32_t reception_type; 394 395 reception_type = HAL_RX_MSDU_START_RECEPTION_TYPE_GET(msdu_start); 396 397 return reception_type; 398 } 399 400 #define HAL_RX_MSDU_END_DA_IDX_GET(_rx_msdu_end) \ 401 (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \ 402 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_OFFSET)), \ 403 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_MASK, \ 404 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_LSB)) 405 406 /** 407 * hal_rx_msdu_end_da_idx_get_6390: API to get da_idx 408 * from rx_msdu_end TLV 409 * 410 * @ buf: pointer to the start of RX PKT TLV headers 411 * Return: da index 412 */ 413 static uint16_t hal_rx_msdu_end_da_idx_get_6390(uint8_t *buf) 414 { 415 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 416 struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end; 417 uint16_t da_idx; 418 419 da_idx = HAL_RX_MSDU_END_DA_IDX_GET(msdu_end); 420 421 return da_idx; 422 } 423 424