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 59 mimo_ss_bitmap = HAL_RX_MSDU_START_MIMO_SS_BITMAP(msdu_start); 60 61 return qdf_get_hweight8(mimo_ss_bitmap); 62 63 } 64 65 /** 66 * hal_rx_mon_hw_desc_get_mpdu_status_6390(): Retrieve MPDU status 67 * 68 * @ hw_desc_addr: Start address of Rx HW TLVs 69 * @ rs: Status for monitor mode 70 * 71 * Return: void 72 */ 73 static void hal_rx_mon_hw_desc_get_mpdu_status_6390(void *hw_desc_addr, 74 struct mon_rx_status *rs) 75 { 76 struct rx_msdu_start *rx_msdu_start; 77 struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr; 78 uint32_t reg_value; 79 const uint32_t sgi_hw_to_cdp[] = { 80 CDP_SGI_0_8_US, 81 CDP_SGI_0_4_US, 82 CDP_SGI_1_6_US, 83 CDP_SGI_3_2_US, 84 }; 85 86 rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start; 87 88 HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs); 89 90 rs->ant_signal_db = HAL_RX_GET(rx_msdu_start, 91 RX_MSDU_START_5, USER_RSSI); 92 rs->is_stbc = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, STBC); 93 94 reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, SGI); 95 rs->sgi = sgi_hw_to_cdp[reg_value]; 96 97 reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, RECEPTION_TYPE); 98 rs->beamformed = (reg_value == HAL_RX_RECEPTION_TYPE_MU_MIMO) ? 1 : 0; 99 /* TODO: rs->beamformed should be set for SU beamforming also */ 100 } 101 102 #define LINK_DESC_SIZE (NUM_OF_DWORDS_RX_MSDU_LINK << 2) 103 104 static uint32_t hal_get_link_desc_size_6390(void) 105 { 106 return LINK_DESC_SIZE; 107 } 108 109 /* 110 * hal_rx_get_tlv_6390(): API to get the tlv 111 * 112 * @rx_tlv: TLV data extracted from the rx packet 113 * Return: uint8_t 114 */ 115 static uint8_t hal_rx_get_tlv_6390(void *rx_tlv) 116 { 117 return HAL_RX_GET(rx_tlv, PHYRX_RSSI_LEGACY_0, RECEIVE_BANDWIDTH); 118 } 119 120 /** 121 * hal_rx_proc_phyrx_other_receive_info_tlv_6390() 122 * - process other receive info TLV 123 * @rx_tlv_hdr: pointer to TLV header 124 * @ppdu_info: pointer to ppdu_info 125 * 126 * Return: None 127 */ 128 static 129 void hal_rx_proc_phyrx_other_receive_info_tlv_6390(void *rx_tlv_hdr, 130 void *ppdu_info_handle) 131 { 132 uint32_t tlv_tag, tlv_len; 133 uint32_t temp_len, other_tlv_len, other_tlv_tag; 134 void *rx_tlv = (uint8_t *)rx_tlv_hdr + HAL_RX_TLV32_HDR_SIZE; 135 void *other_tlv_hdr = NULL; 136 void *other_tlv = NULL; 137 138 tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv_hdr); 139 tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv_hdr); 140 temp_len = 0; 141 142 other_tlv_hdr = rx_tlv + HAL_RX_TLV32_HDR_SIZE; 143 144 other_tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(other_tlv_hdr); 145 other_tlv_len = HAL_RX_GET_USER_TLV32_LEN(other_tlv_hdr); 146 temp_len += other_tlv_len; 147 other_tlv = other_tlv_hdr + HAL_RX_TLV32_HDR_SIZE; 148 149 switch (other_tlv_tag) { 150 default: 151 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, 152 "%s unhandled TLV type: %d, TLV len:%d", 153 __func__, other_tlv_tag, other_tlv_len); 154 break; 155 } 156 } 157 158 /** 159 * hal_rx_dump_msdu_start_tlv_6390() : dump RX msdu_start TLV in structured 160 * human readable format. 161 * @ msdu_start: pointer the msdu_start TLV in pkt. 162 * @ dbg_level: log level. 163 * 164 * Return: void 165 */ 166 static void hal_rx_dump_msdu_start_tlv_6390(void *msdustart, uint8_t dbg_level) 167 { 168 struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart; 169 170 hal_verbose_debug( 171 "rx_msdu_start tlv (1/2) - " 172 "rxpcu_mpdu_filter_in_category: %x " 173 "sw_frame_group_id: %x " 174 "phy_ppdu_id: %x " 175 "msdu_length: %x " 176 "ipsec_esp: %x " 177 "l3_offset: %x " 178 "ipsec_ah: %x " 179 "l4_offset: %x " 180 "msdu_number: %x " 181 "decap_format: %x " 182 "ipv4_proto: %x " 183 "ipv6_proto: %x " 184 "tcp_proto: %x " 185 "udp_proto: %x " 186 "ip_frag: %x " 187 "tcp_only_ack: %x " 188 "da_is_bcast_mcast: %x " 189 "ip4_protocol_ip6_next_header: %x " 190 "toeplitz_hash_2_or_4: %x " 191 "flow_id_toeplitz: %x " 192 "user_rssi: %x " 193 "pkt_type: %x " 194 "stbc: %x " 195 "sgi: %x " 196 "rate_mcs: %x " 197 "receive_bandwidth: %x " 198 "reception_type: %x " 199 "ppdu_start_timestamp: %u ", 200 msdu_start->rxpcu_mpdu_filter_in_category, 201 msdu_start->sw_frame_group_id, 202 msdu_start->phy_ppdu_id, 203 msdu_start->msdu_length, 204 msdu_start->ipsec_esp, 205 msdu_start->l3_offset, 206 msdu_start->ipsec_ah, 207 msdu_start->l4_offset, 208 msdu_start->msdu_number, 209 msdu_start->decap_format, 210 msdu_start->ipv4_proto, 211 msdu_start->ipv6_proto, 212 msdu_start->tcp_proto, 213 msdu_start->udp_proto, 214 msdu_start->ip_frag, 215 msdu_start->tcp_only_ack, 216 msdu_start->da_is_bcast_mcast, 217 msdu_start->ip4_protocol_ip6_next_header, 218 msdu_start->toeplitz_hash_2_or_4, 219 msdu_start->flow_id_toeplitz, 220 msdu_start->user_rssi, 221 msdu_start->pkt_type, 222 msdu_start->stbc, 223 msdu_start->sgi, 224 msdu_start->rate_mcs, 225 msdu_start->receive_bandwidth, 226 msdu_start->reception_type, 227 msdu_start->ppdu_start_timestamp); 228 229 hal_verbose_debug( 230 "rx_msdu_start tlv (2/2) - " 231 "sw_phy_meta_data: %x ", 232 msdu_start->sw_phy_meta_data); 233 } 234 235 /** 236 * hal_rx_dump_msdu_end_tlv_6390: dump RX msdu_end TLV in structured 237 * human readable format. 238 * @ msdu_end: pointer the msdu_end TLV in pkt. 239 * @ dbg_level: log level. 240 * 241 * Return: void 242 */ 243 static void hal_rx_dump_msdu_end_tlv_6390(void *msduend, 244 uint8_t dbg_level) 245 { 246 struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend; 247 248 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 249 "rx_msdu_end tlv (1/2) - " 250 "rxpcu_mpdu_filter_in_category: %x " 251 "sw_frame_group_id: %x " 252 "phy_ppdu_id: %x " 253 "ip_hdr_chksum: %x " 254 "tcp_udp_chksum: %x " 255 "key_id_octet: %x " 256 "cce_super_rule: %x " 257 "cce_classify_not_done_truncat: %x " 258 "cce_classify_not_done_cce_dis: %x " 259 "ext_wapi_pn_63_48: %x " 260 "ext_wapi_pn_95_64: %x " 261 "ext_wapi_pn_127_96: %x " 262 "reported_mpdu_length: %x " 263 "first_msdu: %x " 264 "last_msdu: %x " 265 "sa_idx_timeout: %x " 266 "da_idx_timeout: %x " 267 "msdu_limit_error: %x " 268 "flow_idx_timeout: %x " 269 "flow_idx_invalid: %x " 270 "wifi_parser_error: %x " 271 "amsdu_parser_error: %x", 272 msdu_end->rxpcu_mpdu_filter_in_category, 273 msdu_end->sw_frame_group_id, 274 msdu_end->phy_ppdu_id, 275 msdu_end->ip_hdr_chksum, 276 msdu_end->tcp_udp_chksum, 277 msdu_end->key_id_octet, 278 msdu_end->cce_super_rule, 279 msdu_end->cce_classify_not_done_truncate, 280 msdu_end->cce_classify_not_done_cce_dis, 281 msdu_end->ext_wapi_pn_63_48, 282 msdu_end->ext_wapi_pn_95_64, 283 msdu_end->ext_wapi_pn_127_96, 284 msdu_end->reported_mpdu_length, 285 msdu_end->first_msdu, 286 msdu_end->last_msdu, 287 msdu_end->sa_idx_timeout, 288 msdu_end->da_idx_timeout, 289 msdu_end->msdu_limit_error, 290 msdu_end->flow_idx_timeout, 291 msdu_end->flow_idx_invalid, 292 msdu_end->wifi_parser_error, 293 msdu_end->amsdu_parser_error); 294 295 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 296 "rx_msdu_end tlv (2/2)- " 297 "sa_is_valid: %x " 298 "da_is_valid: %x " 299 "da_is_mcbc: %x " 300 "l3_header_padding: %x " 301 "ipv6_options_crc: %x " 302 "tcp_seq_number: %x " 303 "tcp_ack_number: %x " 304 "tcp_flag: %x " 305 "lro_eligible: %x " 306 "window_size: %x " 307 "da_offset: %x " 308 "sa_offset: %x " 309 "da_offset_valid: %x " 310 "sa_offset_valid: %x " 311 "rule_indication_31_0: %x " 312 "rule_indication_63_32: %x " 313 "sa_idx: %x " 314 "da_idx: %x " 315 "msdu_drop: %x " 316 "reo_destination_indication: %x " 317 "flow_idx: %x " 318 "fse_metadata: %x " 319 "cce_metadata: %x " 320 "sa_sw_peer_id: %x ", 321 msdu_end->sa_is_valid, 322 msdu_end->da_is_valid, 323 msdu_end->da_is_mcbc, 324 msdu_end->l3_header_padding, 325 msdu_end->ipv6_options_crc, 326 msdu_end->tcp_seq_number, 327 msdu_end->tcp_ack_number, 328 msdu_end->tcp_flag, 329 msdu_end->lro_eligible, 330 msdu_end->window_size, 331 msdu_end->da_offset, 332 msdu_end->sa_offset, 333 msdu_end->da_offset_valid, 334 msdu_end->sa_offset_valid, 335 msdu_end->rule_indication_31_0, 336 msdu_end->rule_indication_63_32, 337 msdu_end->sa_idx, 338 msdu_end->da_idx_or_sw_peer_id, 339 msdu_end->msdu_drop, 340 msdu_end->reo_destination_indication, 341 msdu_end->flow_idx, 342 msdu_end->fse_metadata, 343 msdu_end->cce_metadata, 344 msdu_end->sa_sw_peer_id); 345 } 346 347 348 /* 349 * Get tid from RX_MPDU_START 350 */ 351 #define HAL_RX_MPDU_INFO_TID_GET(_rx_mpdu_info) \ 352 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \ 353 RX_MPDU_INFO_3_TID_OFFSET)), \ 354 RX_MPDU_INFO_3_TID_MASK, \ 355 RX_MPDU_INFO_3_TID_LSB)) 356 357 static uint32_t hal_rx_mpdu_start_tid_get_6390(uint8_t *buf) 358 { 359 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 360 struct rx_mpdu_start *mpdu_start = 361 &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start; 362 uint32_t tid; 363 364 tid = HAL_RX_MPDU_INFO_TID_GET(&mpdu_start->rx_mpdu_info_details); 365 366 return tid; 367 } 368 369 #define HAL_RX_MSDU_START_RECEPTION_TYPE_GET(_rx_msdu_start) \ 370 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \ 371 RX_MSDU_START_5_RECEPTION_TYPE_OFFSET)), \ 372 RX_MSDU_START_5_RECEPTION_TYPE_MASK, \ 373 RX_MSDU_START_5_RECEPTION_TYPE_LSB)) 374 375 /* 376 * hal_rx_msdu_start_reception_type_get(): API to get the reception type 377 * Interval from rx_msdu_start 378 * 379 * @buf: pointer to the start of RX PKT TLV header 380 * Return: uint32_t(reception_type) 381 */ 382 static 383 uint32_t hal_rx_msdu_start_reception_type_get_6390(uint8_t *buf) 384 { 385 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 386 struct rx_msdu_start *msdu_start = 387 &pkt_tlvs->msdu_start_tlv.rx_msdu_start; 388 uint32_t reception_type; 389 390 reception_type = HAL_RX_MSDU_START_RECEPTION_TYPE_GET(msdu_start); 391 392 return reception_type; 393 } 394 395 #define HAL_RX_MSDU_END_DA_IDX_GET(_rx_msdu_end) \ 396 (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \ 397 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_OFFSET)), \ 398 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_MASK, \ 399 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_LSB)) 400 401 /** 402 * hal_rx_msdu_end_da_idx_get_6390: API to get da_idx 403 * from rx_msdu_end TLV 404 * 405 * @ buf: pointer to the start of RX PKT TLV headers 406 * Return: da index 407 */ 408 static uint16_t hal_rx_msdu_end_da_idx_get_6390(uint8_t *buf) 409 { 410 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 411 struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end; 412 uint16_t da_idx; 413 414 da_idx = HAL_RX_MSDU_END_DA_IDX_GET(msdu_end); 415 416 return da_idx; 417 } 418 419