1 /* 2 * Copyright (c) 2016-2020 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 19 #ifndef _DP_HTT_H_ 20 #define _DP_HTT_H_ 21 22 #include <qdf_types.h> 23 #include <qdf_lock.h> 24 #include <qdf_nbuf.h> 25 #include <htc_api.h> 26 27 #include "cdp_txrx_cmn_struct.h" 28 #include "dp_types.h" 29 #ifdef HTT_LOGGER 30 #include "dp_htt_logger.h" 31 #else 32 struct htt_logger; 33 static inline 34 void htt_interface_logging_init(struct htt_logger **htt_logger_handle) 35 { 36 } 37 38 static inline 39 void htt_interface_logging_deinit(struct htt_logger *htt_logger_handle) 40 { 41 } 42 43 static inline 44 int htt_command_record(struct htt_logger *h, uint8_t msg_type, 45 uint8_t *msg_data) 46 { 47 return 0; 48 } 49 50 static inline 51 int htt_event_record(struct htt_logger *h, uint8_t msg_type, 52 uint8_t *msg_data) 53 { 54 return 0; 55 } 56 57 static inline 58 int htt_wbm_event_record(struct htt_logger *h, uint8_t tx_status, 59 uint8_t *msg_data) 60 { 61 return 0; 62 } 63 64 #endif 65 66 void htt_htc_pkt_pool_free(struct htt_soc *soc); 67 68 #define HTT_TX_MUTEX_TYPE qdf_spinlock_t 69 70 #define HTT_TX_MUTEX_INIT(_mutex) \ 71 qdf_spinlock_create(_mutex) 72 73 #define HTT_TX_MUTEX_ACQUIRE(_mutex) \ 74 qdf_spin_lock_bh(_mutex) 75 76 #define HTT_TX_MUTEX_RELEASE(_mutex) \ 77 qdf_spin_unlock_bh(_mutex) 78 79 #define HTT_TX_MUTEX_DESTROY(_mutex) \ 80 qdf_spinlock_destroy(_mutex) 81 82 #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64 83 84 #ifndef HTT_MAC_ADDR_LEN 85 #define HTT_MAC_ADDR_LEN 6 86 #endif 87 88 #define HTT_FRAMECTRL_TYPE_MASK 0x0C 89 #define HTT_GET_FRAME_CTRL_TYPE(_val) \ 90 (((_val) & HTT_FRAMECTRL_TYPE_MASK) >> 2) 91 #define FRAME_CTRL_TYPE_MGMT 0x0 92 #define FRAME_CTRL_TYPE_CTRL 0x1 93 #define FRAME_CTRL_TYPE_DATA 0x2 94 #define FRAME_CTRL_TYPE_RESV 0x3 95 96 #define HTT_FRAMECTRL_DATATYPE 0x08 97 #define HTT_PPDU_DESC_MAX_DEPTH 16 98 #define DP_SCAN_PEER_ID 0xFFFF 99 100 #define HTT_RX_DELBA_WIN_SIZE_M 0x0000FC00 101 #define HTT_RX_DELBA_WIN_SIZE_S 10 102 103 #define HTT_RX_DELBA_WIN_SIZE_GET(word) \ 104 (((word) & HTT_RX_DELBA_WIN_SIZE_M) >> HTT_RX_DELBA_WIN_SIZE_S) 105 106 /* 107 * Set the base misclist size to HTT copy engine source ring size 108 * to guarantee that a packet on the misclist wont be freed while it 109 * is sitting in the copy engine. 110 */ 111 #define DP_HTT_HTC_PKT_MISCLIST_SIZE 2048 112 #define HTT_T2H_MAX_MSG_SIZE 2048 113 114 #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3 115 116 /* 117 * Below offset are based on htt_ppdu_stats_common_tlv 118 * defined in htt_ppdu_stats.h 119 */ 120 #define HTT_PPDU_STATS_COMMON_TLV_TLV_HDR_OFFSET 0 121 #define HTT_PPDU_STATS_COMMON_TLV_PPDU_ID_OFFSET 1 122 #define HTT_PPDU_STATS_COMMON_TLV_RING_ID_SCH_CMD_ID_OFFSET 2 123 #define HTT_PPDU_STATS_COMMON_TLV_QTYPE_FRM_TYPE_OFFSET 3 124 #define HTT_PPDU_STATS_COMMON_TLV_CHAIN_MASK_OFFSET 4 125 #define HTT_PPDU_STATS_COMMON_TLV_FES_DUR_US_OFFSET 5 126 #define HTT_PPDU_STATS_COMMON_TLV_SCH_EVAL_START_TSTMP_L32_US_OFFSET 6 127 #define HTT_PPDU_STATS_COMMON_TLV_SCH_END_TSTMP_US_OFFSET 7 128 #define HTT_PPDU_STATS_COMMON_TLV_START_TSTMP_L32_US_OFFSET 8 129 #define HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_PHY_MODE_OFFSET 9 130 #define HTT_PPDU_STATS_COMMON_TLV_CCA_DELTA_TIME_US_OFFSET 10 131 #define HTT_PPDU_STATS_COMMON_TLV_RXFRM_DELTA_TIME_US_OFFSET 11 132 #define HTT_PPDU_STATS_COMMON_TLV_TXFRM_DELTA_TIME_US_OFFSET 12 133 #define HTT_PPDU_STATS_COMMON_TLV_RESV_NUM_UL_BEAM_OFFSET 13 134 #define HTT_PPDU_STATS_COMMON_TLV_START_TSTMP_U32_US_OFFSET 14 135 136 /* get index for field in htt_ppdu_stats_common_tlv */ 137 #define HTT_GET_STATS_CMN_INDEX(index) \ 138 HTT_PPDU_STATS_COMMON_TLV_##index##_OFFSET 139 140 #define MAX_SCHED_STARVE 100000 141 #define WRAP_DROP_TSF_DELTA 10000 142 #define MAX_TSF_32 0xFFFFFFFF 143 144 /** 145 * enum dp_full_mon_config - enum to enable/disable full monitor mode 146 * 147 * @DP_FULL_MON_DISABLE: Disable full monitor mode 148 * @DP_FULL_MON_ENABLE: Enable full monitor mode 149 */ 150 enum dp_full_mon_config { 151 DP_FULL_MON_DISABLE, 152 DP_FULL_MON_ENABLE, 153 }; 154 155 struct dp_htt_htc_pkt { 156 void *soc_ctxt; 157 qdf_dma_addr_t nbuf_paddr; 158 HTC_PACKET htc_pkt; 159 }; 160 161 struct dp_htt_htc_pkt_union { 162 union { 163 struct dp_htt_htc_pkt pkt; 164 struct dp_htt_htc_pkt_union *next; 165 } u; 166 }; 167 168 struct dp_htt_timestamp { 169 long *umac_ttt; 170 long *lmac_ttt; 171 }; 172 173 struct htt_soc { 174 struct cdp_ctrl_objmgr_psoc *ctrl_psoc; 175 struct dp_soc *dp_soc; 176 hal_soc_handle_t hal_soc; 177 struct dp_htt_timestamp pdevid_tt[MAX_PDEV_CNT]; 178 /* htt_logger handle */ 179 struct htt_logger *htt_logger_handle; 180 HTC_HANDLE htc_soc; 181 qdf_device_t osdev; 182 HTC_ENDPOINT_ID htc_endpoint; 183 struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist; 184 struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist; 185 struct { 186 u_int8_t major; 187 u_int8_t minor; 188 } tgt_ver; 189 struct { 190 u_int8_t major; 191 u_int8_t minor; 192 } wifi_ip_ver; 193 194 struct { 195 int htc_err_cnt; 196 int htc_pkt_free; 197 } stats; 198 199 HTT_TX_MUTEX_TYPE htt_tx_mutex; 200 }; 201 202 /** 203 * struct htt_rx_ring_tlv_filter - Rx ring TLV filter 204 * enable/disable. 205 * @mpdu_start: enable/disable MPDU start TLV 206 * @msdu_start: enable/disable MSDU start TLV 207 * @packet: enable/disable PACKET TLV 208 * @msdu_end: enable/disable MSDU end TLV 209 * @mpdu_end: enable/disable MPDU end TLV 210 * @packet_header: enable/disable PACKET header TLV 211 * @attention: enable/disable ATTENTION TLV 212 * @ppdu_start: enable/disable PPDU start TLV 213 * @ppdu_end: enable/disable PPDU end TLV 214 * @ppdu_end_user_stats: enable/disable PPDU user stats TLV 215 * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV 216 * @ppdu_end_status_done: enable/disable PPDU end status done TLV 217 * @enable_fp: enable/disable FP packet 218 * @enable_md: enable/disable MD packet 219 * @enable_mo: enable/disable MO packet 220 * @enable_mgmt: enable/disable MGMT packet 221 * @enable_ctrl: enable/disable CTRL packet 222 * @enable_data: enable/disable DATA packet 223 * @offset_valid: Flag to indicate if below offsets are valid 224 * @rx_packet_offset: Offset of packet payload 225 * @rx_header_offset: Offset of rx_header tlv 226 * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv 227 * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv 228 * @rx_msdu_end_offset: Offset of rx_msdu_end tlv 229 * @rx_msdu_start_offset: Offset of rx_msdu_start tlv 230 * @rx_attn_offset: Offset of rx_attention tlv 231 * 232 * NOTE: Do not change the layout of this structure 233 */ 234 struct htt_rx_ring_tlv_filter { 235 u_int32_t mpdu_start:1, 236 msdu_start:1, 237 packet:1, 238 msdu_end:1, 239 mpdu_end:1, 240 packet_header:1, 241 attention:1, 242 ppdu_start:1, 243 ppdu_end:1, 244 ppdu_end_user_stats:1, 245 ppdu_end_user_stats_ext:1, 246 ppdu_end_status_done:1, 247 header_per_msdu:1, 248 enable_fp:1, 249 enable_md:1, 250 enable_mo:1; 251 u_int32_t fp_mgmt_filter:16, 252 mo_mgmt_filter:16; 253 u_int32_t fp_ctrl_filter:16, 254 mo_ctrl_filter:16; 255 u_int32_t fp_data_filter:16, 256 mo_data_filter:16; 257 u_int16_t md_data_filter; 258 u_int16_t md_mgmt_filter; 259 u_int16_t md_ctrl_filter; 260 bool offset_valid; 261 uint16_t rx_packet_offset; 262 uint16_t rx_header_offset; 263 uint16_t rx_mpdu_end_offset; 264 uint16_t rx_mpdu_start_offset; 265 uint16_t rx_msdu_end_offset; 266 uint16_t rx_msdu_start_offset; 267 uint16_t rx_attn_offset; 268 }; 269 270 /** 271 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 272 * @pdev_id: DP Pdev identifier 273 * @max_entries: Size of Rx FST in number of entries 274 * @max_search: Number of collisions allowed 275 * @base_addr_lo: lower 32-bit physical address 276 * @base_addr_hi: upper 32-bit physical address 277 * @ip_da_sa_prefix: IPv4 prefix to map to IPv6 address scheme 278 * @hash_key_len: Rx FST hash key size 279 * @hash_key: Rx FST Toeplitz hash key 280 */ 281 struct dp_htt_rx_flow_fst_setup { 282 uint8_t pdev_id; 283 uint32_t max_entries; 284 uint32_t max_search; 285 uint32_t base_addr_lo; 286 uint32_t base_addr_hi; 287 uint32_t ip_da_sa_prefix; 288 uint32_t hash_key_len; 289 uint8_t *hash_key; 290 }; 291 292 /** 293 * enum dp_htt_flow_fst_operation - FST related operations allowed 294 * @DP_HTT_FST_CACHE_OP_NONE: Cache no-op 295 * @DP_HTT_FST_CACHE_INVALIDATE_ENTRY: Invalidate single cache entry 296 * @DP_HTT_FST_CACHE_INVALIDATE_FULL: Invalidate entire cache 297 * @DP_HTT_FST_ENABLE: Bypass FST is enabled 298 * @DP_HTT_FST_DISABLE: Disable bypass FST 299 */ 300 enum dp_htt_flow_fst_operation { 301 DP_HTT_FST_CACHE_OP_NONE, 302 DP_HTT_FST_CACHE_INVALIDATE_ENTRY, 303 DP_HTT_FST_CACHE_INVALIDATE_FULL, 304 DP_HTT_FST_ENABLE, 305 DP_HTT_FST_DISABLE 306 }; 307 308 /** 309 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 310 * @pdev_id: DP Pdev identifier 311 * @op_code: FST operation to be performed by FW/HW 312 * @rx_flow: Rx Flow information on which operation is to be performed 313 */ 314 struct dp_htt_rx_flow_fst_operation { 315 uint8_t pdev_id; 316 enum dp_htt_flow_fst_operation op_code; 317 struct cdp_rx_flow_info *rx_flow; 318 }; 319 320 /** 321 * struct dp_htt_rx_fisa_config - Rx fisa config 322 * @pdev_id: DP Pdev identifier 323 * @fisa_timeout: fisa aggregation timeout 324 */ 325 struct dp_htt_rx_fisa_cfg { 326 uint8_t pdev_id; 327 uint32_t fisa_timeout; 328 }; 329 330 QDF_STATUS dp_htt_rx_fisa_config(struct dp_pdev *pdev, 331 struct dp_htt_rx_fisa_cfg *fisa_config); 332 333 /* 334 * htt_soc_initialize() - SOC level HTT initialization 335 * @htt_soc: Opaque htt SOC handle 336 * @ctrl_psoc: Opaque ctrl SOC handle 337 * @htc_soc: SOC level HTC handle 338 * @hal_soc: Opaque HAL SOC handle 339 * @osdev: QDF device 340 * 341 * Return: HTT handle on success; NULL on failure 342 */ 343 void * 344 htt_soc_initialize(struct htt_soc *htt_soc, 345 struct cdp_ctrl_objmgr_psoc *ctrl_psoc, 346 HTC_HANDLE htc_soc, 347 hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev); 348 349 /* 350 * htt_soc_attach() - attach DP and HTT SOC 351 * @soc: DP SOC handle 352 * @htc_hdl: HTC handle 353 * 354 * Return: htt_soc handle on Success, NULL on Failure 355 */ 356 struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_hdl); 357 358 /* 359 * htt_set_htc_handle_() - set HTC handle 360 * @htt_hdl: HTT handle/SOC 361 * @htc_soc: HTC handle 362 * 363 * Return: None 364 */ 365 void htt_set_htc_handle(struct htt_soc *htt_hdl, HTC_HANDLE htc_soc); 366 367 /* 368 * htt_get_htc_handle_() - set HTC handle 369 * @htt_hdl: HTT handle/SOC 370 * 371 * Return: HTC_HANDLE 372 */ 373 HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_hdl); 374 375 /* 376 * htt_soc_htc_dealloc() - HTC memory de-alloc 377 * @htt_soc: SOC level HTT handle 378 * 379 * Return: None 380 */ 381 void htt_soc_htc_dealloc(struct htt_soc *htt_handle); 382 383 /* 384 * htt_soc_htc_prealloc() - HTC memory prealloc 385 * @htt_soc: SOC level HTT handle 386 * 387 * Return: QDF_STATUS_SUCCESS on success or 388 * QDF_STATUS_E_NO_MEM on allocation failure 389 */ 390 QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc); 391 392 void htt_soc_detach(struct htt_soc *soc); 393 394 int htt_srng_setup(struct htt_soc *htt_soc, int pdev_id, 395 hal_ring_handle_t hal_ring_hdl, 396 int hal_ring_type); 397 398 int htt_soc_attach_target(struct htt_soc *htt_soc); 399 400 /* 401 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter 402 * config message to target 403 * @htt_soc: HTT SOC handle 404 * @pdev_id: PDEV Id 405 * @hal_srng: Opaque HAL SRNG pointer 406 * @hal_ring_type: SRNG ring type 407 * @ring_buf_size: SRNG buffer size 408 * @htt_tlv_filter: Rx SRNG TLV and filter setting 409 * 410 * Return: 0 on success; error code on failure 411 */ 412 int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id, 413 hal_ring_handle_t hal_ring_hdl, 414 int hal_ring_type, int ring_buf_size, 415 struct htt_rx_ring_tlv_filter *htt_tlv_filter); 416 417 /* 418 * htt_t2h_stats_handler() - target to host stats work handler 419 * @context: context (dp soc context) 420 * 421 * Return: void 422 */ 423 void htt_t2h_stats_handler(void *context); 424 425 /** 426 * struct htt_stats_context - htt stats information 427 * @soc: Size of each descriptor in the pool 428 * @msg: T2H Ext stats message queue 429 * @msg_len: T2H Ext stats message length 430 */ 431 struct htt_stats_context { 432 struct dp_soc *soc; 433 qdf_nbuf_queue_t msg; 434 uint32_t msg_len; 435 }; 436 437 int 438 dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap); 439 440 /** 441 * dp_ppdu_desc_user_stats_update(): Function to update TX user stats 442 * @pdev: DP pdev handle 443 * @ppdu_info: per PPDU TLV descriptor 444 * 445 * return: void 446 */ 447 void 448 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev, 449 struct ppdu_info *ppdu_info); 450 451 /** 452 * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW 453 * @pdev: DP pdev handle 454 * @fse_setup_info: FST setup parameters 455 * 456 * Return: Success when HTT message is sent, error on failure 457 */ 458 QDF_STATUS 459 dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev, 460 struct dp_htt_rx_flow_fst_setup *setup_info); 461 462 /** 463 * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to 464 * add/del a flow in HW 465 * @pdev: DP pdev handle 466 * @fse_op_info: Flow entry parameters 467 * 468 * Return: Success when HTT message is sent, error on failure 469 */ 470 QDF_STATUS 471 dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev, 472 struct dp_htt_rx_flow_fst_operation *op_info); 473 474 /** 475 * htt_h2t_full_mon_cfg() - Send full monitor configuarion msg to FW 476 * 477 * @htt_soc: HTT Soc handle 478 * @pdev_id: Radio id 479 * @dp_full_mon_config: enabled/disable configuration 480 * 481 * Return: Success when HTT message is sent, error on failure 482 */ 483 int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc, 484 uint8_t pdev_id, 485 enum dp_full_mon_config); 486 #endif /* _DP_HTT_H_ */ 487