1 /* 2 * Copyright (c) 2016-2021 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 #define HTT_PPDU_STATS_COMMON_TLV_BSSCOLOR_OBSS_PSR_OFFSET 15 137 138 /* get index for field in htt_ppdu_stats_common_tlv */ 139 #define HTT_GET_STATS_CMN_INDEX(index) \ 140 HTT_PPDU_STATS_COMMON_TLV_##index##_OFFSET 141 142 #define MAX_SCHED_STARVE 100000 143 #define WRAP_DROP_TSF_DELTA 10000 144 #define MAX_TSF_32 0xFFFFFFFF 145 146 #define dp_htt_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_HTT, params) 147 #define dp_htt_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_HTT, params) 148 #define dp_htt_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_HTT, params) 149 #define dp_htt_info(params...) \ 150 __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_HTT, ## params) 151 #define dp_htt_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_HTT, params) 152 153 #define dp_htt_tx_stats_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_HTT_TX_STATS, params) 154 #define dp_htt_tx_stats_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_HTT_TX_STATS, params) 155 #define dp_htt_tx_stats_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_HTT_TX_STATS, params) 156 #define dp_htt_tx_stats_info(params...) \ 157 __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_HTT_TX_STATS, ## params) 158 #define dp_htt_tx_stats_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_HTT_TX_STATS, params) 159 160 /** 161 * enum dp_full_mon_config - enum to enable/disable full monitor mode 162 * 163 * @DP_FULL_MON_DISABLE: Disable full monitor mode 164 * @DP_FULL_MON_ENABLE: Enable full monitor mode 165 */ 166 enum dp_full_mon_config { 167 DP_FULL_MON_DISABLE, 168 DP_FULL_MON_ENABLE, 169 }; 170 171 struct dp_htt_htc_pkt { 172 void *soc_ctxt; 173 qdf_dma_addr_t nbuf_paddr; 174 HTC_PACKET htc_pkt; 175 }; 176 177 struct dp_htt_htc_pkt_union { 178 union { 179 struct dp_htt_htc_pkt pkt; 180 struct dp_htt_htc_pkt_union *next; 181 } u; 182 }; 183 184 struct dp_htt_timestamp { 185 long *umac_ttt; 186 long *lmac_ttt; 187 }; 188 189 struct htt_soc { 190 struct cdp_ctrl_objmgr_psoc *ctrl_psoc; 191 struct dp_soc *dp_soc; 192 hal_soc_handle_t hal_soc; 193 struct dp_htt_timestamp pdevid_tt[MAX_PDEV_CNT]; 194 /* htt_logger handle */ 195 struct htt_logger *htt_logger_handle; 196 HTC_HANDLE htc_soc; 197 qdf_device_t osdev; 198 HTC_ENDPOINT_ID htc_endpoint; 199 struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist; 200 struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist; 201 struct { 202 u_int8_t major; 203 u_int8_t minor; 204 } tgt_ver; 205 struct { 206 u_int8_t major; 207 u_int8_t minor; 208 } wifi_ip_ver; 209 210 struct { 211 int htc_err_cnt; 212 int htc_pkt_free; 213 int skip_count; 214 int fail_count; 215 /* rtpm put skip count for ver req msg */ 216 int htt_ver_req_put_skip; 217 } stats; 218 219 HTT_TX_MUTEX_TYPE htt_tx_mutex; 220 }; 221 222 /** 223 * struct htt_rx_ring_tlv_filter - Rx ring TLV filter 224 * enable/disable. 225 * @mpdu_start: enable/disable MPDU start TLV 226 * @msdu_start: enable/disable MSDU start TLV 227 * @packet: enable/disable PACKET TLV 228 * @msdu_end: enable/disable MSDU end TLV 229 * @mpdu_end: enable/disable MPDU end TLV 230 * @packet_header: enable/disable PACKET header TLV 231 * @attention: enable/disable ATTENTION TLV 232 * @ppdu_start: enable/disable PPDU start TLV 233 * @ppdu_end: enable/disable PPDU end TLV 234 * @ppdu_end_user_stats: enable/disable PPDU user stats TLV 235 * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV 236 * @ppdu_end_status_done: enable/disable PPDU end status done TLV 237 * @enable_fp: enable/disable FP packet 238 * @enable_md: enable/disable MD packet 239 * @enable_mo: enable/disable MO packet 240 * @enable_mgmt: enable/disable MGMT packet 241 * @enable_ctrl: enable/disable CTRL packet 242 * @enable_data: enable/disable DATA packet 243 * @offset_valid: Flag to indicate if below offsets are valid 244 * @rx_packet_offset: Offset of packet payload 245 * @rx_header_offset: Offset of rx_header tlv 246 * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv 247 * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv 248 * @rx_msdu_end_offset: Offset of rx_msdu_end tlv 249 * @rx_msdu_start_offset: Offset of rx_msdu_start tlv 250 * @rx_attn_offset: Offset of rx_attention tlv 251 * 252 * NOTE: Do not change the layout of this structure 253 */ 254 struct htt_rx_ring_tlv_filter { 255 u_int32_t mpdu_start:1, 256 msdu_start:1, 257 packet:1, 258 msdu_end:1, 259 mpdu_end:1, 260 packet_header:1, 261 attention:1, 262 ppdu_start:1, 263 ppdu_end:1, 264 ppdu_end_user_stats:1, 265 ppdu_end_user_stats_ext:1, 266 ppdu_end_status_done:1, 267 header_per_msdu:1, 268 enable_fp:1, 269 enable_md:1, 270 enable_mo:1; 271 u_int32_t fp_mgmt_filter:16, 272 mo_mgmt_filter:16; 273 u_int32_t fp_ctrl_filter:16, 274 mo_ctrl_filter:16; 275 u_int32_t fp_data_filter:16, 276 mo_data_filter:16; 277 u_int16_t md_data_filter; 278 u_int16_t md_mgmt_filter; 279 u_int16_t md_ctrl_filter; 280 bool offset_valid; 281 uint16_t rx_packet_offset; 282 uint16_t rx_header_offset; 283 uint16_t rx_mpdu_end_offset; 284 uint16_t rx_mpdu_start_offset; 285 uint16_t rx_msdu_end_offset; 286 uint16_t rx_msdu_start_offset; 287 uint16_t rx_attn_offset; 288 }; 289 290 /** 291 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 292 * @pdev_id: DP Pdev identifier 293 * @max_entries: Size of Rx FST in number of entries 294 * @max_search: Number of collisions allowed 295 * @base_addr_lo: lower 32-bit physical address 296 * @base_addr_hi: upper 32-bit physical address 297 * @ip_da_sa_prefix: IPv4 prefix to map to IPv6 address scheme 298 * @hash_key_len: Rx FST hash key size 299 * @hash_key: Rx FST Toeplitz hash key 300 */ 301 struct dp_htt_rx_flow_fst_setup { 302 uint8_t pdev_id; 303 uint32_t max_entries; 304 uint32_t max_search; 305 uint32_t base_addr_lo; 306 uint32_t base_addr_hi; 307 uint32_t ip_da_sa_prefix; 308 uint32_t hash_key_len; 309 uint8_t *hash_key; 310 }; 311 312 /** 313 * enum dp_htt_flow_fst_operation - FST related operations allowed 314 * @DP_HTT_FST_CACHE_OP_NONE: Cache no-op 315 * @DP_HTT_FST_CACHE_INVALIDATE_ENTRY: Invalidate single cache entry 316 * @DP_HTT_FST_CACHE_INVALIDATE_FULL: Invalidate entire cache 317 * @DP_HTT_FST_ENABLE: Bypass FST is enabled 318 * @DP_HTT_FST_DISABLE: Disable bypass FST 319 */ 320 enum dp_htt_flow_fst_operation { 321 DP_HTT_FST_CACHE_OP_NONE, 322 DP_HTT_FST_CACHE_INVALIDATE_ENTRY, 323 DP_HTT_FST_CACHE_INVALIDATE_FULL, 324 DP_HTT_FST_ENABLE, 325 DP_HTT_FST_DISABLE 326 }; 327 328 /** 329 * struct dp_htt_rx_flow_fst_setup - Rx FST setup message 330 * @pdev_id: DP Pdev identifier 331 * @op_code: FST operation to be performed by FW/HW 332 * @rx_flow: Rx Flow information on which operation is to be performed 333 */ 334 struct dp_htt_rx_flow_fst_operation { 335 uint8_t pdev_id; 336 enum dp_htt_flow_fst_operation op_code; 337 struct cdp_rx_flow_info *rx_flow; 338 }; 339 340 /** 341 * struct dp_htt_rx_fisa_config - Rx fisa config 342 * @pdev_id: DP Pdev identifier 343 * @fisa_timeout: fisa aggregation timeout 344 */ 345 struct dp_htt_rx_fisa_cfg { 346 uint8_t pdev_id; 347 uint32_t fisa_timeout; 348 }; 349 350 QDF_STATUS dp_htt_rx_fisa_config(struct dp_pdev *pdev, 351 struct dp_htt_rx_fisa_cfg *fisa_config); 352 353 /* 354 * htt_soc_initialize() - SOC level HTT initialization 355 * @htt_soc: Opaque htt SOC handle 356 * @ctrl_psoc: Opaque ctrl SOC handle 357 * @htc_soc: SOC level HTC handle 358 * @hal_soc: Opaque HAL SOC handle 359 * @osdev: QDF device 360 * 361 * Return: HTT handle on success; NULL on failure 362 */ 363 void * 364 htt_soc_initialize(struct htt_soc *htt_soc, 365 struct cdp_ctrl_objmgr_psoc *ctrl_psoc, 366 HTC_HANDLE htc_soc, 367 hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev); 368 369 /* 370 * htt_soc_attach() - attach DP and HTT SOC 371 * @soc: DP SOC handle 372 * @htc_hdl: HTC handle 373 * 374 * Return: htt_soc handle on Success, NULL on Failure 375 */ 376 struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_hdl); 377 378 /* 379 * htt_set_htc_handle_() - set HTC handle 380 * @htt_hdl: HTT handle/SOC 381 * @htc_soc: HTC handle 382 * 383 * Return: None 384 */ 385 void htt_set_htc_handle(struct htt_soc *htt_hdl, HTC_HANDLE htc_soc); 386 387 /* 388 * htt_get_htc_handle_() - set HTC handle 389 * @htt_hdl: HTT handle/SOC 390 * 391 * Return: HTC_HANDLE 392 */ 393 HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_hdl); 394 395 /* 396 * htt_soc_htc_dealloc() - HTC memory de-alloc 397 * @htt_soc: SOC level HTT handle 398 * 399 * Return: None 400 */ 401 void htt_soc_htc_dealloc(struct htt_soc *htt_handle); 402 403 /* 404 * htt_soc_htc_prealloc() - HTC memory prealloc 405 * @htt_soc: SOC level HTT handle 406 * 407 * Return: QDF_STATUS_SUCCESS on success or 408 * QDF_STATUS_E_NO_MEM on allocation failure 409 */ 410 QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc); 411 412 void htt_soc_detach(struct htt_soc *soc); 413 414 int htt_srng_setup(struct htt_soc *htt_soc, int pdev_id, 415 hal_ring_handle_t hal_ring_hdl, 416 int hal_ring_type); 417 418 int htt_soc_attach_target(struct htt_soc *htt_soc); 419 420 /* 421 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter 422 * config message to target 423 * @htt_soc: HTT SOC handle 424 * @pdev_id: PDEV Id 425 * @hal_srng: Opaque HAL SRNG pointer 426 * @hal_ring_type: SRNG ring type 427 * @ring_buf_size: SRNG buffer size 428 * @htt_tlv_filter: Rx SRNG TLV and filter setting 429 * 430 * Return: 0 on success; error code on failure 431 */ 432 int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id, 433 hal_ring_handle_t hal_ring_hdl, 434 int hal_ring_type, int ring_buf_size, 435 struct htt_rx_ring_tlv_filter *htt_tlv_filter); 436 437 /* 438 * htt_t2h_stats_handler() - target to host stats work handler 439 * @context: context (dp soc context) 440 * 441 * Return: void 442 */ 443 void htt_t2h_stats_handler(void *context); 444 445 /** 446 * struct htt_stats_context - htt stats information 447 * @soc: Size of each descriptor in the pool 448 * @msg: T2H Ext stats message queue 449 * @msg_len: T2H Ext stats message length 450 */ 451 struct htt_stats_context { 452 struct dp_soc *soc; 453 qdf_nbuf_queue_t msg; 454 uint32_t msg_len; 455 }; 456 457 int 458 dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap); 459 460 /** 461 * dp_ppdu_desc_user_stats_update(): Function to update TX user stats 462 * @pdev: DP pdev handle 463 * @ppdu_info: per PPDU TLV descriptor 464 * 465 * return: void 466 */ 467 void 468 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev, 469 struct ppdu_info *ppdu_info); 470 471 /** 472 * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW 473 * @pdev: DP pdev handle 474 * @fse_setup_info: FST setup parameters 475 * 476 * Return: Success when HTT message is sent, error on failure 477 */ 478 QDF_STATUS 479 dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev, 480 struct dp_htt_rx_flow_fst_setup *setup_info); 481 482 /** 483 * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to 484 * add/del a flow in HW 485 * @pdev: DP pdev handle 486 * @fse_op_info: Flow entry parameters 487 * 488 * Return: Success when HTT message is sent, error on failure 489 */ 490 QDF_STATUS 491 dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev, 492 struct dp_htt_rx_flow_fst_operation *op_info); 493 494 /** 495 * htt_h2t_full_mon_cfg() - Send full monitor configuarion msg to FW 496 * 497 * @htt_soc: HTT Soc handle 498 * @pdev_id: Radio id 499 * @dp_full_mon_config: enabled/disable configuration 500 * 501 * Return: Success when HTT message is sent, error on failure 502 */ 503 int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc, 504 uint8_t pdev_id, 505 enum dp_full_mon_config); 506 #endif /* _DP_HTT_H_ */ 507