1 /* 2 * Copyright (c) 2016-2018 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 "hal_hw_headers.h" 19 #include "hal_internal.h" 20 #include "cdp_txrx_mon_struct.h" 21 #include "qdf_trace.h" 22 #include "hal_rx.h" 23 #include "hal_tx.h" 24 #include "dp_types.h" 25 #include "hal_api_mon.h" 26 27 #define HAL_RX_MSDU_START_MIMO_SS_BITMAP(_rx_msdu_start)\ 28 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\ 29 RX_MSDU_START_5_MIMO_SS_BITMAP_OFFSET)), \ 30 RX_MSDU_START_5_MIMO_SS_BITMAP_MASK, \ 31 RX_MSDU_START_5_MIMO_SS_BITMAP_LSB)) 32 /* 33 * hal_rx_msdu_start_nss_get_8074v2(): API to get the NSS 34 * Interval from rx_msdu_start 35 * 36 * @buf: pointer to the start of RX PKT TLV header 37 * Return: uint32_t(nss) 38 */ 39 static uint32_t hal_rx_msdu_start_nss_get_8074v2(uint8_t *buf) 40 { 41 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 42 struct rx_msdu_start *msdu_start = 43 &pkt_tlvs->msdu_start_tlv.rx_msdu_start; 44 uint8_t mimo_ss_bitmap; 45 46 mimo_ss_bitmap = HAL_RX_MSDU_START_MIMO_SS_BITMAP(msdu_start); 47 48 return qdf_get_hweight8(mimo_ss_bitmap); 49 } 50 51 /** 52 * hal_rx_mon_hw_desc_get_mpdu_status_8074v2(): Retrieve MPDU status 53 * 54 * @ hw_desc_addr: Start address of Rx HW TLVs 55 * @ rs: Status for monitor mode 56 * 57 * Return: void 58 */ 59 static void hal_rx_mon_hw_desc_get_mpdu_status_8074v2(void *hw_desc_addr, 60 struct mon_rx_status *rs) 61 { 62 struct rx_msdu_start *rx_msdu_start; 63 struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr; 64 uint32_t reg_value; 65 const uint32_t sgi_hw_to_cdp[] = { 66 CDP_SGI_0_8_US, 67 CDP_SGI_0_4_US, 68 CDP_SGI_1_6_US, 69 CDP_SGI_3_2_US, 70 }; 71 72 rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start; 73 74 HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs); 75 76 rs->ant_signal_db = HAL_RX_GET(rx_msdu_start, 77 RX_MSDU_START_5, USER_RSSI); 78 rs->is_stbc = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, STBC); 79 80 reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, SGI); 81 rs->sgi = sgi_hw_to_cdp[reg_value]; 82 reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, RECEPTION_TYPE); 83 rs->beamformed = (reg_value == HAL_RX_RECEPTION_TYPE_MU_MIMO) ? 1 : 0; 84 /* TODO: rs->beamformed should be set for SU beamforming also */ 85 } 86 87 #define LINK_DESC_SIZE (NUM_OF_DWORDS_RX_MSDU_LINK << 2) 88 static uint32_t hal_get_link_desc_size_8074v2(void) 89 { 90 return LINK_DESC_SIZE; 91 } 92 93 /* 94 * hal_rx_get_tlv_8074v2(): API to get the tlv 95 * 96 * @rx_tlv: TLV data extracted from the rx packet 97 * Return: uint8_t 98 */ 99 static uint8_t hal_rx_get_tlv_8074v2(void *rx_tlv) 100 { 101 return HAL_RX_GET(rx_tlv, PHYRX_RSSI_LEGACY_0, RECEIVE_BANDWIDTH); 102 } 103 104 /** 105 * hal_rx_proc_phyrx_other_receive_info_tlv_8074v2() 106 * -process other receive info TLV 107 * @rx_tlv_hdr: pointer to TLV header 108 * @ppdu_info: pointer to ppdu_info 109 * 110 * Return: None 111 */ 112 static 113 void hal_rx_proc_phyrx_other_receive_info_tlv_8074v2(void *rx_tlv_hdr, 114 void *ppdu_info) 115 { 116 } 117 118 119 /** 120 * hal_rx_dump_msdu_start_tlv_8074v2() : dump RX msdu_start TLV in structured 121 * human readable format. 122 * @ msdu_start: pointer the msdu_start TLV in pkt. 123 * @ dbg_level: log level. 124 * 125 * Return: void 126 */ 127 static void hal_rx_dump_msdu_start_tlv_8074v2(void *msdustart, 128 uint8_t dbg_level) 129 { 130 struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart; 131 132 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 133 "rx_msdu_start tlv - " 134 "rxpcu_mpdu_filter_in_category: %d " 135 "sw_frame_group_id: %d " 136 "phy_ppdu_id: %d " 137 "msdu_length: %d " 138 "ipsec_esp: %d " 139 "l3_offset: %d " 140 "ipsec_ah: %d " 141 "l4_offset: %d " 142 "msdu_number: %d " 143 "decap_format: %d " 144 "ipv4_proto: %d " 145 "ipv6_proto: %d " 146 "tcp_proto: %d " 147 "udp_proto: %d " 148 "ip_frag: %d " 149 "tcp_only_ack: %d " 150 "da_is_bcast_mcast: %d " 151 "ip4_protocol_ip6_next_header: %d " 152 "toeplitz_hash_2_or_4: %d " 153 "flow_id_toeplitz: %d " 154 "user_rssi: %d " 155 "pkt_type: %d " 156 "stbc: %d " 157 "sgi: %d " 158 "rate_mcs: %d " 159 "receive_bandwidth: %d " 160 "reception_type: %d " 161 "ppdu_start_timestamp: %d " 162 "sw_phy_meta_data: %d ", 163 msdu_start->rxpcu_mpdu_filter_in_category, 164 msdu_start->sw_frame_group_id, 165 msdu_start->phy_ppdu_id, 166 msdu_start->msdu_length, 167 msdu_start->ipsec_esp, 168 msdu_start->l3_offset, 169 msdu_start->ipsec_ah, 170 msdu_start->l4_offset, 171 msdu_start->msdu_number, 172 msdu_start->decap_format, 173 msdu_start->ipv4_proto, 174 msdu_start->ipv6_proto, 175 msdu_start->tcp_proto, 176 msdu_start->udp_proto, 177 msdu_start->ip_frag, 178 msdu_start->tcp_only_ack, 179 msdu_start->da_is_bcast_mcast, 180 msdu_start->ip4_protocol_ip6_next_header, 181 msdu_start->toeplitz_hash_2_or_4, 182 msdu_start->flow_id_toeplitz, 183 msdu_start->user_rssi, 184 msdu_start->pkt_type, 185 msdu_start->stbc, 186 msdu_start->sgi, 187 msdu_start->rate_mcs, 188 msdu_start->receive_bandwidth, 189 msdu_start->reception_type, 190 msdu_start->ppdu_start_timestamp, 191 msdu_start->sw_phy_meta_data); 192 } 193 194 /** 195 * hal_rx_dump_msdu_end_tlv_8074v2: dump RX msdu_end TLV in structured 196 * human readable format. 197 * @ msdu_end: pointer the msdu_end TLV in pkt. 198 * @ dbg_level: log level. 199 * 200 * Return: void 201 */ 202 static void hal_rx_dump_msdu_end_tlv_8074v2(void *msduend, 203 uint8_t dbg_level) 204 { 205 struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend; 206 207 QDF_TRACE(QDF_MODULE_ID_DP, dbg_level, 208 "rx_msdu_end tlv - " 209 "rxpcu_mpdu_filter_in_category: %d " 210 "sw_frame_group_id: %d " 211 "phy_ppdu_id: %d " 212 "ip_hdr_chksum: %d " 213 "tcp_udp_chksum: %d " 214 "key_id_octet: %d " 215 "cce_super_rule: %d " 216 "cce_classify_not_done_truncat: %d " 217 "cce_classify_not_done_cce_dis: %d " 218 "ext_wapi_pn_63_48: %d " 219 "ext_wapi_pn_95_64: %d " 220 "ext_wapi_pn_127_96: %d " 221 "reported_mpdu_length: %d " 222 "first_msdu: %d " 223 "last_msdu: %d " 224 "sa_idx_timeout: %d " 225 "da_idx_timeout: %d " 226 "msdu_limit_error: %d " 227 "flow_idx_timeout: %d " 228 "flow_idx_invalid: %d " 229 "wifi_parser_error: %d " 230 "amsdu_parser_error: %d " 231 "sa_is_valid: %d " 232 "da_is_valid: %d " 233 "da_is_mcbc: %d " 234 "l3_header_padding: %d " 235 "ipv6_options_crc: %d " 236 "tcp_seq_number: %d " 237 "tcp_ack_number: %d " 238 "tcp_flag: %d " 239 "lro_eligible: %d " 240 "window_size: %d " 241 "da_offset: %d " 242 "sa_offset: %d " 243 "da_offset_valid: %d " 244 "sa_offset_valid: %d " 245 "rule_indication_31_0: %d " 246 "rule_indication_63_32: %d " 247 "sa_idx: %d " 248 "msdu_drop: %d " 249 "reo_destination_indication: %d " 250 "flow_idx: %d " 251 "fse_metadata: %d " 252 "cce_metadata: %d " 253 "sa_sw_peer_id: %d ", 254 msdu_end->rxpcu_mpdu_filter_in_category, 255 msdu_end->sw_frame_group_id, 256 msdu_end->phy_ppdu_id, 257 msdu_end->ip_hdr_chksum, 258 msdu_end->tcp_udp_chksum, 259 msdu_end->key_id_octet, 260 msdu_end->cce_super_rule, 261 msdu_end->cce_classify_not_done_truncate, 262 msdu_end->cce_classify_not_done_cce_dis, 263 msdu_end->ext_wapi_pn_63_48, 264 msdu_end->ext_wapi_pn_95_64, 265 msdu_end->ext_wapi_pn_127_96, 266 msdu_end->reported_mpdu_length, 267 msdu_end->first_msdu, 268 msdu_end->last_msdu, 269 msdu_end->sa_idx_timeout, 270 msdu_end->da_idx_timeout, 271 msdu_end->msdu_limit_error, 272 msdu_end->flow_idx_timeout, 273 msdu_end->flow_idx_invalid, 274 msdu_end->wifi_parser_error, 275 msdu_end->amsdu_parser_error, 276 msdu_end->sa_is_valid, 277 msdu_end->da_is_valid, 278 msdu_end->da_is_mcbc, 279 msdu_end->l3_header_padding, 280 msdu_end->ipv6_options_crc, 281 msdu_end->tcp_seq_number, 282 msdu_end->tcp_ack_number, 283 msdu_end->tcp_flag, 284 msdu_end->lro_eligible, 285 msdu_end->window_size, 286 msdu_end->da_offset, 287 msdu_end->sa_offset, 288 msdu_end->da_offset_valid, 289 msdu_end->sa_offset_valid, 290 msdu_end->rule_indication_31_0, 291 msdu_end->rule_indication_63_32, 292 msdu_end->sa_idx, 293 msdu_end->msdu_drop, 294 msdu_end->reo_destination_indication, 295 msdu_end->flow_idx, 296 msdu_end->fse_metadata, 297 msdu_end->cce_metadata, 298 msdu_end->sa_sw_peer_id); 299 } 300 301 302 /* 303 * Get tid from RX_MPDU_START 304 */ 305 #define HAL_RX_MPDU_INFO_TID_GET(_rx_mpdu_info) \ 306 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \ 307 RX_MPDU_INFO_3_TID_OFFSET)), \ 308 RX_MPDU_INFO_3_TID_MASK, \ 309 RX_MPDU_INFO_3_TID_LSB)) 310 311 static uint32_t hal_rx_mpdu_start_tid_get_8074v2(uint8_t *buf) 312 { 313 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 314 struct rx_mpdu_start *mpdu_start = 315 &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start; 316 uint32_t tid; 317 318 tid = HAL_RX_MPDU_INFO_TID_GET(&mpdu_start->rx_mpdu_info_details); 319 320 return tid; 321 } 322 323 #define HAL_RX_MSDU_START_RECEPTION_TYPE_GET(_rx_msdu_start) \ 324 (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \ 325 RX_MSDU_START_5_RECEPTION_TYPE_OFFSET)), \ 326 RX_MSDU_START_5_RECEPTION_TYPE_MASK, \ 327 RX_MSDU_START_5_RECEPTION_TYPE_LSB)) 328 329 /* 330 * hal_rx_msdu_start_reception_type_get(): API to get the reception type 331 * Interval from rx_msdu_start 332 * 333 * @buf: pointer to the start of RX PKT TLV header 334 * Return: uint32_t(reception_type) 335 */ 336 static uint32_t hal_rx_msdu_start_reception_type_get_8074v2(uint8_t *buf) 337 { 338 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 339 struct rx_msdu_start *msdu_start = 340 &pkt_tlvs->msdu_start_tlv.rx_msdu_start; 341 uint32_t reception_type; 342 343 reception_type = HAL_RX_MSDU_START_RECEPTION_TYPE_GET(msdu_start); 344 345 return reception_type; 346 } 347 348 /* RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_OFFSET */ 349 #define HAL_RX_MSDU_END_DA_IDX_GET(_rx_msdu_end) \ 350 (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \ 351 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_OFFSET)), \ 352 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_MASK, \ 353 RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_LSB)) 354 /** 355 * hal_rx_msdu_end_da_idx_get_8074v2: API to get da_idx 356 * from rx_msdu_end TLV 357 * 358 * @ buf: pointer to the start of RX PKT TLV headers 359 * Return: da index 360 */ 361 static uint16_t hal_rx_msdu_end_da_idx_get_8074v2(uint8_t *buf) 362 { 363 struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf; 364 struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end; 365 uint16_t da_idx; 366 367 da_idx = HAL_RX_MSDU_END_DA_IDX_GET(msdu_end); 368 369 return da_idx; 370 } 371 372