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