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