1 /* 2 * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _HAL_INTERNAL_H_ 21 #define _HAL_INTERNAL_H_ 22 23 #include "qdf_types.h" 24 #include "qdf_atomic.h" 25 #include "qdf_lock.h" 26 #include "qdf_mem.h" 27 #include "qdf_nbuf.h" 28 #include "pld_common.h" 29 #if defined(FEATURE_HAL_DELAYED_REG_WRITE) 30 #include "qdf_defer.h" 31 #include "qdf_timer.h" 32 #endif 33 34 #define hal_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_HAL, params) 35 #define hal_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_HAL, params) 36 #define hal_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_HAL, params) 37 #define hal_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_HAL, params) 38 #define hal_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params) 39 40 #define hal_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_HAL, params) 41 #define hal_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_HAL, params) 42 #define hal_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_HAL, params) 43 #define hal_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_HAL, params) 44 #define hal_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_HAL, params) 45 46 #ifdef ENABLE_VERBOSE_DEBUG 47 extern bool is_hal_verbose_debug_enabled; 48 #define hal_verbose_debug(params...) \ 49 if (unlikely(is_hal_verbose_debug_enabled)) \ 50 do {\ 51 QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params); \ 52 } while (0) 53 #define hal_verbose_hex_dump(params...) \ 54 if (unlikely(is_hal_verbose_debug_enabled)) \ 55 do {\ 56 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HAL, \ 57 QDF_TRACE_LEVEL_DEBUG, \ 58 params); \ 59 } while (0) 60 #else 61 #define hal_verbose_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HAL, params) 62 #define hal_verbose_hex_dump(params...) \ 63 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HAL, QDF_TRACE_LEVEL_DEBUG, \ 64 params) 65 #endif 66 67 /* 68 * Given the offset of a field in bytes, returns uint8_t * 69 */ 70 #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes) \ 71 (((uint8_t *)(_ptr)) + (_off_in_bytes)) 72 73 /* 74 * Given the offset of a field in bytes, returns uint32_t * 75 */ 76 #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes) \ 77 (((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2)) 78 79 /* 80 * Given the offset of a field in bytes, returns uint64_t * 81 */ 82 #define _OFFSET_TO_QWORD_PTR(_ptr, _off_in_bytes) \ 83 (((uint64_t *)(_ptr)) + ((_off_in_bytes) >> 3)) 84 85 #define _HAL_MS(_word, _mask, _shift) \ 86 (((_word) & (_mask)) >> (_shift)) 87 88 /* 89 * Get number of QWORDS possible for num. 90 * Its the caller's duty to make sure num is a multiple of QWORD (8) 91 */ 92 #define HAL_GET_NUM_QWORDS(num) ((num) >> 3) 93 94 /* 95 * Get number of DWORDS possible for num. 96 * Its the caller's duty to make sure num is a multiple of DWORD (8) 97 */ 98 #define HAL_GET_NUM_DWORDS(num) ((num) >> 2) 99 100 /* 101 * dp_hal_soc - opaque handle for DP HAL soc 102 */ 103 struct hal_soc_handle; 104 typedef struct hal_soc_handle *hal_soc_handle_t; 105 106 /** 107 * hal_ring_desc - opaque handle for DP ring descriptor 108 */ 109 struct hal_ring_desc; 110 typedef struct hal_ring_desc *hal_ring_desc_t; 111 112 /** 113 * hal_link_desc - opaque handle for DP link descriptor 114 */ 115 struct hal_link_desc; 116 typedef struct hal_link_desc *hal_link_desc_t; 117 118 /** 119 * hal_rxdma_desc - opaque handle for DP rxdma dst ring descriptor 120 */ 121 struct hal_rxdma_desc; 122 typedef struct hal_rxdma_desc *hal_rxdma_desc_t; 123 124 /** 125 * hal_buff_addrinfo - opaque handle for DP buffer address info 126 */ 127 struct hal_buff_addrinfo; 128 typedef struct hal_buff_addrinfo *hal_buff_addrinfo_t; 129 130 /** 131 * hal_rx_mon_desc_info - opaque handle for sw monitor ring desc info 132 */ 133 struct hal_rx_mon_desc_info; 134 typedef struct hal_rx_mon_desc_info *hal_rx_mon_desc_info_t; 135 136 struct hal_buf_info; 137 typedef struct hal_buf_info *hal_buf_info_t; 138 139 struct rx_msdu_desc_info; 140 typedef struct rx_msdu_desc_info *rx_msdu_desc_info_t; 141 142 /* TBD: This should be movded to shared HW header file */ 143 enum hal_srng_ring_id { 144 /* UMAC rings */ 145 HAL_SRNG_REO2SW0 = 0, 146 HAL_SRNG_REO2SW1 = 1, 147 HAL_SRNG_REO2SW2 = 2, 148 HAL_SRNG_REO2SW3 = 3, 149 HAL_SRNG_REO2SW4 = 4, 150 HAL_SRNG_REO2SW5 = 5, 151 HAL_SRNG_REO2SW6 = 6, 152 HAL_SRNG_REO2SW7 = 7, 153 HAL_SRNG_REO2SW8 = 8, 154 HAL_SRNG_REO2TCL = 9, 155 HAL_SRNG_REO2PPE = 10, 156 /* 11-15 unused */ 157 HAL_SRNG_SW2REO = 16, 158 HAL_SRNG_SW2REO1 = 17, 159 HAL_SRNG_SW2REO2 = 18, 160 HAL_SRNG_SW2REO3 = 19, 161 HAL_SRNG_REO_CMD = 20, 162 HAL_SRNG_REO_STATUS = 21, 163 /* 22-23 unused */ 164 HAL_SRNG_SW2TCL1 = 24, 165 HAL_SRNG_SW2TCL2 = 25, 166 HAL_SRNG_SW2TCL3 = 26, 167 HAL_SRNG_SW2TCL4 = 27, 168 HAL_SRNG_SW2TCL5 = 28, 169 HAL_SRNG_SW2TCL6 = 29, 170 HAL_SRNG_PPE2TCL1 = 30, 171 /* 31-39 unused */ 172 HAL_SRNG_SW2TCL_CMD = 40, 173 HAL_SRNG_TCL_STATUS = 41, 174 HAL_SRNG_SW2TCL_CREDIT = 42, 175 /* 43-63 unused */ 176 HAL_SRNG_CE_0_SRC = 64, 177 HAL_SRNG_CE_1_SRC = 65, 178 HAL_SRNG_CE_2_SRC = 66, 179 HAL_SRNG_CE_3_SRC = 67, 180 HAL_SRNG_CE_4_SRC = 68, 181 HAL_SRNG_CE_5_SRC = 69, 182 HAL_SRNG_CE_6_SRC = 70, 183 HAL_SRNG_CE_7_SRC = 71, 184 HAL_SRNG_CE_8_SRC = 72, 185 HAL_SRNG_CE_9_SRC = 73, 186 HAL_SRNG_CE_10_SRC = 74, 187 HAL_SRNG_CE_11_SRC = 75, 188 HAL_SRNG_CE_12_SRC = 76, 189 HAL_SRNG_CE_13_SRC = 77, 190 HAL_SRNG_CE_14_SRC = 78, 191 HAL_SRNG_CE_15_SRC = 79, 192 /* 80 */ 193 HAL_SRNG_CE_0_DST = 81, 194 HAL_SRNG_CE_1_DST = 82, 195 HAL_SRNG_CE_2_DST = 83, 196 HAL_SRNG_CE_3_DST = 84, 197 HAL_SRNG_CE_4_DST = 85, 198 HAL_SRNG_CE_5_DST = 86, 199 HAL_SRNG_CE_6_DST = 87, 200 HAL_SRNG_CE_7_DST = 89, 201 HAL_SRNG_CE_8_DST = 90, 202 HAL_SRNG_CE_9_DST = 91, 203 HAL_SRNG_CE_10_DST = 92, 204 HAL_SRNG_CE_11_DST = 93, 205 HAL_SRNG_CE_12_DST = 94, 206 HAL_SRNG_CE_13_DST = 95, 207 HAL_SRNG_CE_14_DST = 96, 208 HAL_SRNG_CE_15_DST = 97, 209 /* 98-99 unused */ 210 HAL_SRNG_CE_0_DST_STATUS = 100, 211 HAL_SRNG_CE_1_DST_STATUS = 101, 212 HAL_SRNG_CE_2_DST_STATUS = 102, 213 HAL_SRNG_CE_3_DST_STATUS = 103, 214 HAL_SRNG_CE_4_DST_STATUS = 104, 215 HAL_SRNG_CE_5_DST_STATUS = 105, 216 HAL_SRNG_CE_6_DST_STATUS = 106, 217 HAL_SRNG_CE_7_DST_STATUS = 107, 218 HAL_SRNG_CE_8_DST_STATUS = 108, 219 HAL_SRNG_CE_9_DST_STATUS = 109, 220 HAL_SRNG_CE_10_DST_STATUS = 110, 221 HAL_SRNG_CE_11_DST_STATUS = 111, 222 HAL_SRNG_CE_12_DST_STATUS = 112, 223 HAL_SRNG_CE_13_DST_STATUS = 113, 224 HAL_SRNG_CE_14_DST_STATUS = 114, 225 HAL_SRNG_CE_15_DST_STATUS = 115, 226 /* 116-119 unused */ 227 HAL_SRNG_WBM_IDLE_LINK = 120, 228 HAL_SRNG_WBM_SW_RELEASE = 121, 229 HAL_SRNG_WBM_SW1_RELEASE = 122, 230 HAL_SRNG_WBM_PPE_RELEASE = 123, 231 /* 124-127 unused */ 232 HAL_SRNG_WBM2SW0_RELEASE = 128, 233 HAL_SRNG_WBM2SW1_RELEASE = 129, 234 HAL_SRNG_WBM2SW2_RELEASE = 130, 235 HAL_SRNG_WBM2SW3_RELEASE = 131, 236 HAL_SRNG_WBM2SW4_RELEASE = 132, 237 HAL_SRNG_WBM2SW5_RELEASE = 133, 238 HAL_SRNG_WBM2SW6_RELEASE = 134, 239 HAL_SRNG_WBM_ERROR_RELEASE = 135, 240 /* 136-158 unused */ 241 HAL_SRNG_UMAC_ID_END = 159, 242 /* Common DMAC rings shared by all LMACs */ 243 HAL_SRNG_SW2RXDMA_BUF0 = 160, 244 HAL_SRNG_SW2RXDMA_BUF1 = 161, 245 HAL_SRNG_SW2RXDMA_BUF2 = 162, 246 /* 163-167 unused */ 247 HAL_SRNG_SW2RXMON_BUF0 = 168, 248 /* 169-175 unused */ 249 /* 177-183 unused */ 250 HAL_SRNG_DMAC_CMN_ID_END = 183, 251 /* LMAC rings - The following set will be replicated for each LMAC */ 252 HAL_SRNG_LMAC1_ID_START = 184, 253 HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 = HAL_SRNG_LMAC1_ID_START, 254 #ifdef IPA_OFFLOAD 255 HAL_SRNG_WMAC1_SW2RXDMA0_BUF1, 256 HAL_SRNG_WMAC1_SW2RXDMA0_BUF2, 257 HAL_SRNG_WMAC1_SW2RXDMA1_BUF, 258 #else 259 HAL_SRNG_WMAC1_SW2RXDMA1_BUF, 260 #endif 261 HAL_SRNG_WMAC1_SW2RXDMA2_BUF, 262 HAL_SRNG_WMAC1_SW2RXDMA0_STATBUF, 263 HAL_SRNG_WMAC1_SW2RXDMA1_STATBUF, 264 HAL_SRNG_WMAC1_RXDMA2SW0, 265 HAL_SRNG_WMAC1_RXDMA2SW1, 266 HAL_SRNG_WMAC1_RXMON2SW0 = HAL_SRNG_WMAC1_RXDMA2SW1, 267 HAL_SRNG_WMAC1_SW2RXDMA1_DESC, 268 #ifdef WLAN_FEATURE_CIF_CFR 269 HAL_SRNG_WIFI_POS_SRC_DMA_RING, 270 HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING, 271 #else 272 HAL_SRNG_DIR_BUF_RX_SRC_DMA_RING, 273 #endif 274 HAL_SRNG_WMAC1_TXMON2SW0, 275 HAL_SRNG_SW2TXMON_BUF0, 276 HAL_SRNG_LMAC1_ID_END = (HAL_SRNG_SW2TXMON_BUF0 + 2), 277 }; 278 279 #define HAL_RXDMA_MAX_RING_SIZE 0xFFFF 280 #define HAL_MAX_LMACS 3 281 #define HAL_MAX_RINGS_PER_LMAC (HAL_SRNG_LMAC1_ID_END - HAL_SRNG_LMAC1_ID_START) 282 #define HAL_MAX_LMAC_RINGS (HAL_MAX_LMACS * HAL_MAX_RINGS_PER_LMAC) 283 284 #define HAL_SRNG_ID_MAX (HAL_SRNG_DMAC_CMN_ID_END + HAL_MAX_LMAC_RINGS) 285 286 /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */ 287 enum hal_ring_type { 288 REO_DST = 0, 289 REO_EXCEPTION = 1, 290 REO_REINJECT = 2, 291 REO_CMD = 3, 292 REO_STATUS = 4, 293 TCL_DATA = 5, 294 TCL_CMD_CREDIT = 6, 295 TCL_STATUS = 7, 296 CE_SRC = 8, 297 CE_DST = 9, 298 CE_DST_STATUS = 10, 299 WBM_IDLE_LINK = 11, 300 SW2WBM_RELEASE = 12, 301 WBM2SW_RELEASE = 13, 302 RXDMA_BUF = 14, 303 RXDMA_DST = 15, 304 RXDMA_MONITOR_BUF = 16, 305 RXDMA_MONITOR_STATUS = 17, 306 RXDMA_MONITOR_DST = 18, 307 RXDMA_MONITOR_DESC = 19, 308 DIR_BUF_RX_DMA_SRC = 20, 309 #ifdef WLAN_FEATURE_CIF_CFR 310 WIFI_POS_SRC, 311 #endif 312 REO2PPE, 313 PPE2TCL, 314 PPE_RELEASE, 315 TX_MONITOR_BUF, 316 TX_MONITOR_DST, 317 SW2RXDMA_NEW, 318 MAX_RING_TYPES 319 }; 320 321 enum SRNG_REGISTERS { 322 DST_HP = 0, 323 DST_TP, 324 DST_ID, 325 DST_MISC, 326 DST_HP_ADDR_LSB, 327 DST_HP_ADDR_MSB, 328 DST_MSI1_BASE_LSB, 329 DST_MSI1_BASE_MSB, 330 DST_MSI1_DATA, 331 #ifdef CONFIG_BERYLLIUM 332 DST_MSI2_BASE_LSB, 333 DST_MSI2_BASE_MSB, 334 DST_MSI2_DATA, 335 #endif 336 DST_BASE_LSB, 337 DST_BASE_MSB, 338 DST_PRODUCER_INT_SETUP, 339 #ifdef CONFIG_BERYLLIUM 340 DST_PRODUCER_INT2_SETUP, 341 #endif 342 343 SRC_HP, 344 SRC_TP, 345 SRC_ID, 346 SRC_MISC, 347 SRC_TP_ADDR_LSB, 348 SRC_TP_ADDR_MSB, 349 SRC_MSI1_BASE_LSB, 350 SRC_MSI1_BASE_MSB, 351 SRC_MSI1_DATA, 352 SRC_BASE_LSB, 353 SRC_BASE_MSB, 354 SRC_CONSUMER_INT_SETUP_IX0, 355 SRC_CONSUMER_INT_SETUP_IX1, 356 SRNG_REGISTER_MAX, 357 }; 358 359 enum hal_srng_dir { 360 HAL_SRNG_SRC_RING, 361 HAL_SRNG_DST_RING 362 }; 363 364 /** 365 * enum hal_reo_remap_reg - REO remap registers 366 * @HAL_REO_REMAP_REG_IX0: reo remap reg IX0 367 * @HAL_REO_REMAP_REG_IX1: reo remap reg IX1 368 * @HAL_REO_REMAP_REG_IX2: reo remap reg IX2 369 * @HAL_REO_REMAP_REG_IX3: reo remap reg IX3 370 */ 371 enum hal_reo_remap_reg { 372 HAL_REO_REMAP_REG_IX0, 373 HAL_REO_REMAP_REG_IX1, 374 HAL_REO_REMAP_REG_IX2, 375 HAL_REO_REMAP_REG_IX3 376 }; 377 378 /* Lock wrappers for SRNG */ 379 #define hal_srng_lock_t qdf_spinlock_t 380 #define SRNG_LOCK_INIT(_lock) qdf_spinlock_create(_lock) 381 #define SRNG_LOCK(_lock) qdf_spin_lock_bh(_lock) 382 #define SRNG_TRY_LOCK(_lock) qdf_spin_trylock_bh(_lock) 383 #define SRNG_UNLOCK(_lock) qdf_spin_unlock_bh(_lock) 384 #define SRNG_LOCK_DESTROY(_lock) qdf_spinlock_destroy(_lock) 385 386 struct hal_soc; 387 388 /** 389 * dp_hal_ring - opaque handle for DP HAL SRNG 390 */ 391 struct hal_ring_handle; 392 typedef struct hal_ring_handle *hal_ring_handle_t; 393 394 #define MAX_SRNG_REG_GROUPS 2 395 396 /* Hal Srng bit mask 397 * HAL_SRNG_FLUSH_EVENT: SRNG HP TP flush in case of link down 398 */ 399 #define HAL_SRNG_FLUSH_EVENT BIT(0) 400 401 #if defined(FEATURE_HAL_DELAYED_REG_WRITE) 402 403 /** 404 * struct hal_reg_write_q_elem - delayed register write queue element 405 * @srng: hal_srng queued for a delayed write 406 * @addr: iomem address of the register 407 * @enqueue_val: register value at the time of delayed write enqueue 408 * @dequeue_val: register value at the time of delayed write dequeue 409 * @valid: whether this entry is valid or not 410 * @enqueue_time: enqueue time (qdf_log_timestamp) 411 * @work_scheduled_time: work scheduled time (qdf_log_timestamp) 412 * @dequeue_time: dequeue time (qdf_log_timestamp) 413 * @cpu_id: record cpuid when schedule work 414 */ 415 struct hal_reg_write_q_elem { 416 struct hal_srng *srng; 417 void __iomem *addr; 418 uint32_t enqueue_val; 419 uint32_t dequeue_val; 420 uint8_t valid; 421 qdf_time_t enqueue_time; 422 qdf_time_t work_scheduled_time; 423 qdf_time_t dequeue_time; 424 int cpu_id; 425 }; 426 427 /** 428 * struct hal_reg_write_srng_stats - srng stats to keep track of register writes 429 * @enqueues: writes enqueued to delayed work 430 * @dequeues: writes dequeued from delayed work (not written yet) 431 * @coalesces: writes not enqueued since srng is already queued up 432 * @direct: writes not enqueued and written to register directly 433 * @dequeue_delay: dequeue operation be delayed 434 */ 435 struct hal_reg_write_srng_stats { 436 uint32_t enqueues; 437 uint32_t dequeues; 438 uint32_t coalesces; 439 uint32_t direct; 440 uint32_t dequeue_delay; 441 }; 442 443 /** 444 * enum hal_reg_sched_delay - ENUM for write sched delay histogram 445 * @REG_WRITE_SCHED_DELAY_SUB_100us: index for delay < 100us 446 * @REG_WRITE_SCHED_DELAY_SUB_1000us: index for delay < 1000us 447 * @REG_WRITE_SCHED_DELAY_SUB_5000us: index for delay < 5000us 448 * @REG_WRITE_SCHED_DELAY_GT_5000us: index for delay >= 5000us 449 * @REG_WRITE_SCHED_DELAY_HIST_MAX: Max value (nnsize of histogram array) 450 */ 451 enum hal_reg_sched_delay { 452 REG_WRITE_SCHED_DELAY_SUB_100us, 453 REG_WRITE_SCHED_DELAY_SUB_1000us, 454 REG_WRITE_SCHED_DELAY_SUB_5000us, 455 REG_WRITE_SCHED_DELAY_GT_5000us, 456 REG_WRITE_SCHED_DELAY_HIST_MAX, 457 }; 458 459 /** 460 * struct hal_reg_write_soc_stats - soc stats to keep track of register writes 461 * @enqueues: writes enqueued to delayed work 462 * @dequeues: writes dequeued from delayed work (not written yet) 463 * @coalesces: writes not enqueued since srng is already queued up 464 * @direct: writes not enqueud and writted to register directly 465 * @prevent_l1_fails: prevent l1 API failed 466 * @q_depth: current queue depth in delayed register write queue 467 * @max_q_depth: maximum queue for delayed register write queue 468 * @sched_delay: = kernel work sched delay + bus wakeup delay, histogram 469 * @dequeue_delay: dequeue operation be delayed 470 */ 471 struct hal_reg_write_soc_stats { 472 qdf_atomic_t enqueues; 473 uint32_t dequeues; 474 qdf_atomic_t coalesces; 475 qdf_atomic_t direct; 476 uint32_t prevent_l1_fails; 477 qdf_atomic_t q_depth; 478 uint32_t max_q_depth; 479 uint32_t sched_delay[REG_WRITE_SCHED_DELAY_HIST_MAX]; 480 uint32_t dequeue_delay; 481 }; 482 #endif 483 484 struct hal_offload_info { 485 uint8_t lro_eligible; 486 uint8_t tcp_proto; 487 uint8_t tcp_pure_ack; 488 uint8_t ipv6_proto; 489 uint8_t tcp_offset; 490 uint16_t tcp_csum; 491 uint16_t tcp_win; 492 uint32_t tcp_seq_num; 493 uint32_t tcp_ack_num; 494 uint32_t flow_id; 495 }; 496 497 /* Common SRNG ring structure for source and destination rings */ 498 struct hal_srng { 499 /* Unique SRNG ring ID */ 500 uint8_t ring_id; 501 502 /* Ring initialization done */ 503 uint8_t initialized; 504 505 /* Interrupt/MSI value assigned to this ring */ 506 int irq; 507 508 /* Physical base address of the ring */ 509 qdf_dma_addr_t ring_base_paddr; 510 511 /* Virtual base address of the ring */ 512 uint32_t *ring_base_vaddr; 513 514 /* virtual address end */ 515 uint32_t *ring_vaddr_end; 516 517 /* Number of entries in ring */ 518 uint32_t num_entries; 519 520 /* Ring size */ 521 uint32_t ring_size; 522 523 /* Ring size mask */ 524 uint32_t ring_size_mask; 525 526 /* Size of ring entry */ 527 uint32_t entry_size; 528 529 /* Interrupt timer threshold – in micro seconds */ 530 uint32_t intr_timer_thres_us; 531 532 /* Interrupt batch counter threshold – in number of ring entries */ 533 uint32_t intr_batch_cntr_thres_entries; 534 535 /* Applicable only for CE dest ring */ 536 uint32_t prefetch_timer; 537 538 /* MSI Address */ 539 qdf_dma_addr_t msi_addr; 540 541 /* MSI data */ 542 uint32_t msi_data; 543 544 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ 545 /* MSI2 Address */ 546 qdf_dma_addr_t msi2_addr; 547 548 /* MSI2 data */ 549 uint32_t msi2_data; 550 #endif 551 552 /* Misc flags */ 553 uint32_t flags; 554 555 /* Lock for serializing ring index updates */ 556 hal_srng_lock_t lock; 557 558 /* Start offset of SRNG register groups for this ring 559 * TBD: See if this is required - register address can be derived 560 * from ring ID 561 */ 562 void *hwreg_base[MAX_SRNG_REG_GROUPS]; 563 564 /* Ring type/name */ 565 enum hal_ring_type ring_type; 566 567 /* Source or Destination ring */ 568 enum hal_srng_dir ring_dir; 569 570 union { 571 struct { 572 /* SW tail pointer */ 573 uint32_t tp; 574 575 /* Shadow head pointer location to be updated by HW */ 576 uint32_t *hp_addr; 577 578 /* Cached head pointer */ 579 uint32_t cached_hp; 580 581 /* Tail pointer location to be updated by SW – This 582 * will be a register address and need not be 583 * accessed through SW structure */ 584 uint32_t *tp_addr; 585 586 /* Current SW loop cnt */ 587 uint32_t loop_cnt; 588 589 /* max transfer size */ 590 uint16_t max_buffer_length; 591 592 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ 593 /* near full IRQ supported */ 594 uint16_t nf_irq_support; 595 596 /* High threshold for Near full IRQ */ 597 uint16_t high_thresh; 598 #endif 599 } dst_ring; 600 601 struct { 602 /* SW head pointer */ 603 uint32_t hp; 604 605 /* SW reap head pointer */ 606 uint32_t reap_hp; 607 608 /* Shadow tail pointer location to be updated by HW */ 609 uint32_t *tp_addr; 610 611 /* Cached tail pointer */ 612 uint32_t cached_tp; 613 614 /* Head pointer location to be updated by SW – This 615 * will be a register address and need not be accessed 616 * through SW structure */ 617 uint32_t *hp_addr; 618 619 /* Low threshold – in number of ring entries */ 620 uint32_t low_threshold; 621 } src_ring; 622 } u; 623 624 struct hal_soc *hal_soc; 625 626 /* Number of times hp/tp updated in runtime resume */ 627 uint32_t flush_count; 628 /* hal srng event flag*/ 629 unsigned long srng_event; 630 /* last flushed time stamp */ 631 uint64_t last_flush_ts; 632 #if defined(CLEAR_SW2TCL_CONSUMED_DESC) 633 /* last ring desc entry cleared */ 634 uint32_t last_desc_cleared; 635 #endif 636 #if defined(FEATURE_HAL_DELAYED_REG_WRITE) 637 /* flag to indicate whether srng is already queued for delayed write */ 638 uint8_t reg_write_in_progress; 639 /* last dequeue elem time stamp */ 640 qdf_time_t last_dequeue_time; 641 642 /* srng specific delayed write stats */ 643 struct hal_reg_write_srng_stats wstats; 644 #endif 645 }; 646 647 /* HW SRNG configuration table */ 648 struct hal_hw_srng_config { 649 int start_ring_id; 650 uint16_t max_rings; 651 uint16_t entry_size; 652 uint32_t reg_start[MAX_SRNG_REG_GROUPS]; 653 uint16_t reg_size[MAX_SRNG_REG_GROUPS]; 654 uint8_t lmac_ring; 655 enum hal_srng_dir ring_dir; 656 uint32_t max_size; 657 bool nf_irq_support; 658 }; 659 660 #define MAX_SHADOW_REGISTERS 40 661 #define MAX_GENERIC_SHADOW_REG 5 662 663 /** 664 * struct shadow_reg_config - Hal soc structure that contains 665 * the list of generic shadow registers 666 * @target_register: target reg offset 667 * @shadow_config_index: shadow config index in shadow config 668 * list sent to FW 669 * @va: virtual addr of shadow reg 670 * 671 * This structure holds the generic registers that are mapped to 672 * the shadow region and holds the mapping of the target 673 * register offset to shadow config index provided to FW during 674 * init 675 */ 676 struct shadow_reg_config { 677 uint32_t target_register; 678 int shadow_config_index; 679 uint64_t va; 680 }; 681 682 /* REO parameters to be passed to hal_reo_setup */ 683 struct hal_reo_params { 684 /** rx hash steering enabled or disabled */ 685 bool rx_hash_enabled; 686 /** reo remap 0 register */ 687 uint32_t remap0; 688 /** reo remap 1 register */ 689 uint32_t remap1; 690 /** reo remap 2 register */ 691 uint32_t remap2; 692 /** fragment destination ring */ 693 uint8_t frag_dst_ring; 694 /* Destination for alternate */ 695 uint8_t alt_dst_ind_0; 696 /** padding */ 697 uint8_t padding[2]; 698 }; 699 700 /** 701 * enum hal_reo_cmd_type: Enum for REO command type 702 * @CMD_GET_QUEUE_STATS: Get REO queue status/stats 703 * @CMD_FLUSH_QUEUE: Flush all frames in REO queue 704 * @CMD_FLUSH_CACHE: Flush descriptor entries in the cache 705 * @CMD_UNBLOCK_CACHE: Unblock a descriptor’s address that was blocked 706 * earlier with a ‘REO_FLUSH_CACHE’ command 707 * @CMD_FLUSH_TIMEOUT_LIST: Flush buffers/descriptors from timeout list 708 * @CMD_UPDATE_RX_REO_QUEUE: Update REO queue settings 709 */ 710 enum hal_reo_cmd_type { 711 CMD_GET_QUEUE_STATS = 0, 712 CMD_FLUSH_QUEUE = 1, 713 CMD_FLUSH_CACHE = 2, 714 CMD_UNBLOCK_CACHE = 3, 715 CMD_FLUSH_TIMEOUT_LIST = 4, 716 CMD_UPDATE_RX_REO_QUEUE = 5 717 }; 718 719 struct hal_rx_pkt_capture_flags { 720 uint8_t encrypt_type; 721 uint8_t fragment_flag; 722 uint8_t fcs_err; 723 uint32_t chan_freq; 724 uint32_t rssi_comb; 725 uint64_t tsft; 726 }; 727 728 struct hal_hw_txrx_ops { 729 /* init and setup */ 730 void (*hal_srng_dst_hw_init)(struct hal_soc *hal, 731 struct hal_srng *srng); 732 void (*hal_srng_src_hw_init)(struct hal_soc *hal, 733 struct hal_srng *srng); 734 void (*hal_get_hw_hptp)(struct hal_soc *hal, 735 hal_ring_handle_t hal_ring_hdl, 736 uint32_t *headp, uint32_t *tailp, 737 uint8_t ring_type); 738 void (*hal_reo_setup)(struct hal_soc *hal_soc, void *reoparams); 739 void (*hal_setup_link_idle_list)( 740 struct hal_soc *hal_soc, 741 qdf_dma_addr_t scatter_bufs_base_paddr[], 742 void *scatter_bufs_base_vaddr[], 743 uint32_t num_scatter_bufs, 744 uint32_t scatter_buf_size, 745 uint32_t last_buf_end_offset, 746 uint32_t num_entries); 747 qdf_iomem_t (*hal_get_window_address)(struct hal_soc *hal_soc, 748 qdf_iomem_t addr); 749 void (*hal_reo_set_err_dst_remap)(void *hal_soc); 750 uint8_t (*hal_reo_enable_pn_in_dest)(void *hal_soc); 751 void (*hal_reo_qdesc_setup)(hal_soc_handle_t hal_soc_hdl, int tid, 752 uint32_t ba_window_size, 753 uint32_t start_seq, void *hw_qdesc_vaddr, 754 qdf_dma_addr_t hw_qdesc_paddr, 755 int pn_type, uint8_t vdev_stats_id); 756 uint32_t (*hal_gen_reo_remap_val)(enum hal_reo_remap_reg, 757 uint8_t *ix0_map); 758 759 /* tx */ 760 void (*hal_tx_desc_set_dscp_tid_table_id)(void *desc, uint8_t id); 761 void (*hal_tx_set_dscp_tid_map)(struct hal_soc *hal_soc, uint8_t *map, 762 uint8_t id); 763 void (*hal_tx_update_dscp_tid)(struct hal_soc *hal_soc, uint8_t tid, 764 uint8_t id, 765 uint8_t dscp); 766 void (*hal_tx_desc_set_lmac_id)(void *desc, uint8_t lmac_id); 767 void (*hal_tx_desc_set_buf_addr)(void *desc, dma_addr_t paddr, 768 uint8_t pool_id, uint32_t desc_id, 769 uint8_t type); 770 void (*hal_tx_desc_set_search_type)(void *desc, uint8_t search_type); 771 void (*hal_tx_desc_set_search_index)(void *desc, uint32_t search_index); 772 void (*hal_tx_desc_set_cache_set_num)(void *desc, uint8_t search_index); 773 void (*hal_tx_comp_get_status)(void *desc, void *ts, 774 struct hal_soc *hal); 775 uint8_t (*hal_tx_comp_get_release_reason)(void *hal_desc); 776 uint8_t (*hal_get_wbm_internal_error)(void *hal_desc); 777 void (*hal_tx_desc_set_mesh_en)(void *desc, uint8_t en); 778 void (*hal_tx_init_cmd_credit_ring)(hal_soc_handle_t hal_soc_hdl, 779 hal_ring_handle_t hal_ring_hdl); 780 uint32_t (*hal_tx_comp_get_buffer_source)(void *hal_desc); 781 782 /* rx */ 783 uint32_t (*hal_rx_msdu_start_nss_get)(uint8_t *); 784 void (*hal_rx_mon_hw_desc_get_mpdu_status)(void *hw_desc_addr, 785 struct mon_rx_status *rs); 786 uint8_t (*hal_rx_get_tlv)(void *rx_tlv); 787 void (*hal_rx_proc_phyrx_other_receive_info_tlv)(void *rx_tlv_hdr, 788 void *ppdu_info_handle); 789 void (*hal_rx_dump_msdu_start_tlv)(void *msdu_start, uint8_t dbg_level); 790 void (*hal_rx_dump_msdu_end_tlv)(void *msdu_end, 791 uint8_t dbg_level); 792 uint32_t (*hal_get_link_desc_size)(void); 793 uint32_t (*hal_rx_mpdu_start_tid_get)(uint8_t *buf); 794 uint32_t (*hal_rx_msdu_start_reception_type_get)(uint8_t *buf); 795 uint16_t (*hal_rx_msdu_end_da_idx_get)(uint8_t *buf); 796 void* (*hal_rx_msdu_desc_info_get_ptr)(void *msdu_details_ptr); 797 void* (*hal_rx_link_desc_msdu0_ptr)(void *msdu_link_ptr); 798 void (*hal_reo_status_get_header)(hal_ring_desc_t ring_desc, int b, 799 void *h); 800 uint32_t (*hal_rx_status_get_tlv_info)(void *rx_tlv_hdr, 801 void *ppdu_info, 802 hal_soc_handle_t hal_soc_hdl, 803 qdf_nbuf_t nbuf); 804 void (*hal_rx_wbm_err_info_get)(void *wbm_desc, 805 void *wbm_er_info); 806 void (*hal_rx_dump_mpdu_start_tlv)(void *mpdustart, 807 uint8_t dbg_level); 808 809 void (*hal_tx_set_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t *map); 810 void (*hal_tx_update_pcp_tid_map)(struct hal_soc *hal_soc, uint8_t pcp, 811 uint8_t id); 812 void (*hal_tx_set_tidmap_prty)(struct hal_soc *hal_soc, uint8_t prio); 813 814 /* rx */ 815 uint8_t (*hal_rx_get_rx_fragment_number)(uint8_t *buf); 816 uint8_t (*hal_rx_msdu_end_da_is_mcbc_get)(uint8_t *buf); 817 uint8_t (*hal_rx_msdu_end_sa_is_valid_get)(uint8_t *buf); 818 uint16_t (*hal_rx_msdu_end_sa_idx_get)(uint8_t *buf); 819 uint32_t (*hal_rx_desc_is_first_msdu)(void *hw_desc_addr); 820 uint32_t (*hal_rx_msdu_end_l3_hdr_padding_get)(uint8_t *buf); 821 uint32_t (*hal_rx_encryption_info_valid)(uint8_t *buf); 822 void (*hal_rx_print_pn)(uint8_t *buf); 823 uint8_t (*hal_rx_msdu_end_first_msdu_get)(uint8_t *buf); 824 uint8_t (*hal_rx_msdu_end_da_is_valid_get)(uint8_t *buf); 825 uint8_t (*hal_rx_msdu_end_last_msdu_get)(uint8_t *buf); 826 bool (*hal_rx_get_mpdu_mac_ad4_valid)(uint8_t *buf); 827 uint32_t (*hal_rx_mpdu_start_sw_peer_id_get)(uint8_t *buf); 828 uint32_t (*hal_rx_mpdu_peer_meta_data_get)(uint8_t *buf); 829 uint32_t (*hal_rx_mpdu_get_to_ds)(uint8_t *buf); 830 uint32_t (*hal_rx_mpdu_get_fr_ds)(uint8_t *buf); 831 uint8_t (*hal_rx_get_mpdu_frame_control_valid)(uint8_t *buf); 832 QDF_STATUS 833 (*hal_rx_mpdu_get_addr1)(uint8_t *buf, uint8_t *mac_addr); 834 QDF_STATUS 835 (*hal_rx_mpdu_get_addr2)(uint8_t *buf, uint8_t *mac_addr); 836 QDF_STATUS 837 (*hal_rx_mpdu_get_addr3)(uint8_t *buf, uint8_t *mac_addr); 838 QDF_STATUS 839 (*hal_rx_mpdu_get_addr4)(uint8_t *buf, uint8_t *mac_addr); 840 uint8_t (*hal_rx_get_mpdu_sequence_control_valid)(uint8_t *buf); 841 bool (*hal_rx_is_unicast)(uint8_t *buf); 842 uint32_t (*hal_rx_tid_get)(hal_soc_handle_t hal_soc_hdl, uint8_t *buf); 843 uint32_t (*hal_rx_hw_desc_get_ppduid_get)(void *rx_tlv_hdr, 844 void *rxdma_dst_ring_desc); 845 uint32_t (*hal_rx_mpdu_start_mpdu_qos_control_valid_get)(uint8_t *buf); 846 uint32_t (*hal_rx_msdu_end_sa_sw_peer_id_get)(uint8_t *buf); 847 void * (*hal_rx_msdu0_buffer_addr_lsb)(void *link_desc_addr); 848 void * (*hal_rx_msdu_desc_info_ptr_get)(void *msdu0); 849 void * (*hal_ent_mpdu_desc_info)(void *hw_addr); 850 void * (*hal_dst_mpdu_desc_info)(void *hw_addr); 851 uint8_t (*hal_rx_get_fc_valid)(uint8_t *buf); 852 uint8_t (*hal_rx_get_to_ds_flag)(uint8_t *buf); 853 uint8_t (*hal_rx_get_mac_addr2_valid)(uint8_t *buf); 854 uint8_t (*hal_rx_get_filter_category)(uint8_t *buf); 855 uint32_t (*hal_rx_get_ppdu_id)(uint8_t *buf); 856 void (*hal_reo_config)(struct hal_soc *soc, 857 uint32_t reg_val, 858 struct hal_reo_params *reo_params); 859 uint32_t (*hal_rx_msdu_flow_idx_get)(uint8_t *buf); 860 bool (*hal_rx_msdu_flow_idx_invalid)(uint8_t *buf); 861 bool (*hal_rx_msdu_flow_idx_timeout)(uint8_t *buf); 862 uint32_t (*hal_rx_msdu_fse_metadata_get)(uint8_t *buf); 863 bool (*hal_rx_msdu_cce_match_get)(uint8_t *buf); 864 uint16_t (*hal_rx_msdu_cce_metadata_get)(uint8_t *buf); 865 void 866 (*hal_rx_msdu_get_flow_params)( 867 uint8_t *buf, 868 bool *flow_invalid, 869 bool *flow_timeout, 870 uint32_t *flow_index); 871 uint16_t (*hal_rx_tlv_get_tcp_chksum)(uint8_t *buf); 872 uint16_t (*hal_rx_get_rx_sequence)(uint8_t *buf); 873 void (*hal_rx_get_bb_info)(void *rx_tlv, void *ppdu_info_handle); 874 void (*hal_rx_get_rtt_info)(void *rx_tlv, void *ppdu_info_handle); 875 void (*hal_rx_msdu_packet_metadata_get)(uint8_t *buf, 876 void *msdu_pkt_metadata); 877 uint16_t (*hal_rx_get_fisa_cumulative_l4_checksum)(uint8_t *buf); 878 uint16_t (*hal_rx_get_fisa_cumulative_ip_length)(uint8_t *buf); 879 bool (*hal_rx_get_udp_proto)(uint8_t *buf); 880 bool (*hal_rx_get_fisa_flow_agg_continuation)(uint8_t *buf); 881 uint8_t (*hal_rx_get_fisa_flow_agg_count)(uint8_t *buf); 882 bool (*hal_rx_get_fisa_timeout)(uint8_t *buf); 883 uint8_t (*hal_rx_mpdu_start_tlv_tag_valid)(void *rx_tlv_hdr); 884 void (*hal_rx_sw_mon_desc_info_get)(hal_ring_desc_t rxdma_dst_ring_desc, 885 hal_rx_mon_desc_info_t mon_desc_info); 886 uint8_t (*hal_rx_wbm_err_msdu_continuation_get)(void *ring_desc); 887 uint32_t (*hal_rx_msdu_end_offset_get)(void); 888 uint32_t (*hal_rx_attn_offset_get)(void); 889 uint32_t (*hal_rx_msdu_start_offset_get)(void); 890 uint32_t (*hal_rx_mpdu_start_offset_get)(void); 891 uint32_t (*hal_rx_mpdu_end_offset_get)(void); 892 uint32_t (*hal_rx_pkt_tlv_offset_get)(void); 893 void * (*hal_rx_flow_setup_fse)(uint8_t *rx_fst, 894 uint32_t table_offset, 895 uint8_t *rx_flow); 896 void * (*hal_rx_flow_get_tuple_info)(uint8_t *rx_fst, 897 uint32_t hal_hash, 898 uint8_t *tuple_info); 899 QDF_STATUS (*hal_rx_flow_delete_entry)(uint8_t *fst, 900 void *fse); 901 uint32_t (*hal_rx_fst_get_fse_size)(void); 902 void (*hal_compute_reo_remap_ix2_ix3)(uint32_t *ring, 903 uint32_t num_rings, 904 uint32_t *remap1, 905 uint32_t *remap2); 906 uint32_t (*hal_rx_flow_setup_cmem_fse)( 907 struct hal_soc *soc, uint32_t cmem_ba, 908 uint32_t table_offset, uint8_t *rx_flow); 909 uint32_t (*hal_rx_flow_get_cmem_fse_ts)(struct hal_soc *soc, 910 uint32_t fse_offset); 911 void (*hal_rx_flow_get_cmem_fse)(struct hal_soc *soc, 912 uint32_t fse_offset, 913 uint32_t *fse, qdf_size_t len); 914 915 void (*hal_cmem_write)(hal_soc_handle_t hal_soc_hdl, uint32_t offset, 916 uint32_t value); 917 918 void (*hal_rx_msdu_get_reo_destination_indication)(uint8_t *buf, 919 uint32_t *reo_destination_indication); 920 uint8_t (*hal_tx_get_num_tcl_banks)(void); 921 uint32_t (*hal_get_reo_qdesc_size)(uint32_t ba_window_size, int tid); 922 923 void (*hal_set_link_desc_addr)(void *desc, uint32_t cookie, 924 qdf_dma_addr_t link_desc_paddr, 925 uint8_t bm_id); 926 void (*hal_tx_init_data_ring)(hal_soc_handle_t hal_soc_hdl, 927 hal_ring_handle_t hal_ring_hdl); 928 void* (*hal_rx_msdu_ext_desc_info_get_ptr)(void *msdu_details_ptr); 929 void (*hal_get_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl, 930 uint8_t ac, uint32_t *value); 931 void (*hal_set_ba_aging_timeout)(hal_soc_handle_t hal_soc_hdl, 932 uint8_t ac, uint32_t value); 933 uint32_t (*hal_get_reo_reg_base_offset)(void); 934 void (*hal_rx_get_tlv_size)(uint16_t *rx_pkt_tlv_size, 935 uint16_t *rx_mon_pkt_tlv_size); 936 uint32_t (*hal_rx_msdu_is_wlan_mcast)(qdf_nbuf_t nbuf); 937 uint32_t (*hal_rx_tlv_decap_format_get)(void *hw_desc_addr); 938 void (*hal_rx_dump_pkt_tlvs)(hal_soc_handle_t hal_soc_hdl, 939 uint8_t *buf, uint8_t dbg_level); 940 int (*hal_rx_tlv_get_offload_info)(uint8_t *rx_tlv, 941 struct hal_offload_info *offload_info); 942 uint16_t (*hal_rx_tlv_phy_ppdu_id_get)(uint8_t *buf); 943 uint32_t (*hal_rx_tlv_msdu_done_get)(uint8_t *buf); 944 uint32_t (*hal_rx_tlv_msdu_len_get)(uint8_t *buf); 945 uint16_t (*hal_rx_get_frame_ctrl_field)(uint8_t *buf); 946 int (*hal_rx_get_proto_params)(uint8_t *buf, void *fisa_params); 947 int (*hal_rx_get_l3_l4_offsets)(uint8_t *buf, uint32_t *l3_hdr_offset, 948 uint32_t *l4_hdr_offset); 949 uint32_t (*hal_rx_tlv_mic_err_get)(uint8_t *buf); 950 uint32_t (*hal_rx_tlv_get_pkt_type)(uint8_t *buf); 951 void (*hal_rx_tlv_get_pn_num)(uint8_t *buf, uint64_t *pn_num); 952 void (*hal_rx_reo_prev_pn_get)(void *ring_desc, uint64_t *prev_pn); 953 uint8_t * (*hal_rx_pkt_hdr_get)(uint8_t *buf); 954 uint32_t (*hal_rx_msdu_reo_dst_ind_get)(hal_soc_handle_t hal_soc_hdl, 955 void *msdu_link_desc); 956 void (*hal_msdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl, 957 void *msdu_desc_info, uint32_t dst_ind, 958 uint32_t nbuf_len); 959 void (*hal_mpdu_desc_info_set)(hal_soc_handle_t hal_soc_hdl, 960 void *mpdu_desc_info, uint32_t seq_no); 961 uint32_t (*hal_rx_tlv_sgi_get)(uint8_t *buf); 962 uint32_t (*hal_rx_tlv_get_freq)(uint8_t *buf); 963 uint8_t (*hal_rx_msdu_get_keyid)(uint8_t *buf); 964 uint32_t (*hal_rx_tlv_rate_mcs_get)(uint8_t *buf); 965 uint32_t (*hal_rx_tlv_decrypt_err_get)(uint8_t *buf); 966 uint32_t (*hal_rx_tlv_first_mpdu_get)(uint8_t *buf); 967 uint32_t (*hal_rx_tlv_bw_get)(uint8_t *buf); 968 uint32_t (*hal_rx_tlv_get_is_decrypted)(uint8_t *buf); 969 970 uint32_t (*hal_rx_wbm_err_src_get)(hal_ring_desc_t ring_desc); 971 uint8_t (*hal_rx_ret_buf_manager_get)(hal_ring_desc_t ring_desc); 972 void (*hal_rx_msdu_link_desc_set)(hal_soc_handle_t hal_soc_hdl, 973 void *src_srng_desc, 974 hal_buff_addrinfo_t buf_addr_info, 975 uint8_t bm_action); 976 977 void (*hal_rx_buf_cookie_rbm_get)(uint32_t *buf_addr_info_hdl, 978 hal_buf_info_t buf_info_hdl); 979 void (*hal_rx_reo_buf_paddr_get)(hal_ring_desc_t rx_desc, 980 struct hal_buf_info *buf_info); 981 void (*hal_rxdma_buff_addr_info_set)(void *rxdma_entry, 982 qdf_dma_addr_t paddr, 983 uint32_t cookie, uint8_t manager); 984 uint32_t (*hal_rx_msdu_flags_get)(rx_msdu_desc_info_t msdu_desc_info_hdl); 985 uint32_t (*hal_rx_get_reo_error_code)(hal_ring_desc_t rx_desc); 986 void (*hal_rx_tlv_csum_err_get)(uint8_t *rx_tlv_hdr, 987 uint32_t *ip_csum_err, 988 uint32_t *tcp_udp_csum_err); 989 void (*hal_rx_mpdu_desc_info_get)(void *desc_addr, 990 void *mpdu_desc_info_hdl); 991 uint8_t (*hal_rx_err_status_get)(hal_ring_desc_t rx_desc); 992 uint8_t (*hal_rx_reo_buf_type_get)(hal_ring_desc_t rx_desc); 993 bool (*hal_rx_mpdu_info_ampdu_flag_get)(uint8_t *buf); 994 uint32_t (*hal_rx_tlv_mpdu_len_err_get)(void *hw_desc_addr); 995 uint32_t (*hal_rx_tlv_mpdu_fcs_err_get)(void *hw_desc_addr); 996 void (*hal_rx_tlv_get_pkt_capture_flags)(uint8_t *rx_tlv_hdr, 997 struct hal_rx_pkt_capture_flags *flags); 998 uint8_t *(*hal_rx_desc_get_80211_hdr)(void *hw_desc_addr); 999 uint32_t (*hal_rx_hw_desc_mpdu_user_id)(void *hw_desc_addr); 1000 void (*hal_rx_priv_info_set_in_tlv)(uint8_t *buf, 1001 uint8_t *priv_data, 1002 uint32_t len); 1003 void (*hal_rx_priv_info_get_from_tlv)(uint8_t *buf, 1004 uint8_t *priv_data, 1005 uint32_t len); 1006 void (*hal_rx_tlv_msdu_len_set)(uint8_t *buf, uint32_t len); 1007 void (*hal_rx_tlv_populate_mpdu_desc_info)(uint8_t *buf, 1008 void *mpdu_desc_info_hdl); 1009 uint8_t *(*hal_get_reo_ent_desc_qdesc_addr)(uint8_t *desc); 1010 uint64_t (*hal_rx_get_qdesc_addr)(uint8_t *dst_ring_desc, 1011 uint8_t *buf); 1012 void (*hal_set_reo_ent_desc_reo_dest_ind)(uint8_t *desc, 1013 uint32_t dst_ind); 1014 1015 /* REO CMD and STATUS */ 1016 int (*hal_reo_send_cmd)(hal_soc_handle_t hal_soc_hdl, 1017 hal_ring_handle_t hal_ring_hdl, 1018 enum hal_reo_cmd_type cmd, 1019 void *params); 1020 QDF_STATUS (*hal_reo_status_update)(hal_soc_handle_t hal_soc_hdl, 1021 hal_ring_desc_t reo_desc, 1022 void *st_handle, 1023 uint32_t tlv, int *num_ref); 1024 uint8_t (*hal_get_tlv_hdr_size)(void); 1025 uint8_t (*hal_get_idle_link_bm_id)(uint8_t chip_id); 1026 1027 /* TX MONITOR */ 1028 #ifdef QCA_MONITOR_2_0_SUPPORT 1029 void (*hal_txmon_status_free_buffer)(qdf_frag_t status_frag); 1030 #endif /* QCA_MONITOR_2_0_SUPPORT */ 1031 void (*hal_reo_shared_qaddr_setup)(hal_soc_handle_t hal_soc_hdl); 1032 void (*hal_reo_shared_qaddr_init)(hal_soc_handle_t hal_soc_hdl); 1033 void (*hal_reo_shared_qaddr_detach)(hal_soc_handle_t hal_soc_hdl); 1034 void (*hal_reo_shared_qaddr_write)(hal_soc_handle_t hal_soc_hdl, 1035 uint16_t peer_id, 1036 int tid, 1037 qdf_dma_addr_t hw_qdesc_paddr); 1038 }; 1039 1040 /** 1041 * struct hal_soc_stats - Hal layer stats 1042 * @reg_write_fail: number of failed register writes 1043 * @wstats: delayed register write stats 1044 * @shadow_reg_write_fail: shadow reg write failure stats 1045 * @shadow_reg_write_succ: shadow reg write success stats 1046 * 1047 * This structure holds all the statistics at HAL layer. 1048 */ 1049 struct hal_soc_stats { 1050 uint32_t reg_write_fail; 1051 #if defined(FEATURE_HAL_DELAYED_REG_WRITE) 1052 struct hal_reg_write_soc_stats wstats; 1053 #endif 1054 #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE 1055 uint32_t shadow_reg_write_fail; 1056 uint32_t shadow_reg_write_succ; 1057 #endif 1058 }; 1059 1060 #ifdef ENABLE_HAL_REG_WR_HISTORY 1061 /* The history size should always be a power of 2 */ 1062 #define HAL_REG_WRITE_HIST_SIZE 8 1063 1064 /** 1065 * struct hal_reg_write_fail_entry - Record of 1066 * register write which failed. 1067 * @timestamp: timestamp of reg write failure 1068 * @reg_offset: offset of register where the write failed 1069 * @write_val: the value which was to be written 1070 * @read_val: the value read back from the register after write 1071 */ 1072 struct hal_reg_write_fail_entry { 1073 uint64_t timestamp; 1074 uint32_t reg_offset; 1075 uint32_t write_val; 1076 uint32_t read_val; 1077 }; 1078 1079 /** 1080 * struct hal_reg_write_fail_history - Hal layer history 1081 * of all the register write failures. 1082 * @index: index to add the new record 1083 * @record: array of all the records in history 1084 * 1085 * This structure holds the history of register write 1086 * failures at HAL layer. 1087 */ 1088 struct hal_reg_write_fail_history { 1089 qdf_atomic_t index; 1090 struct hal_reg_write_fail_entry record[HAL_REG_WRITE_HIST_SIZE]; 1091 }; 1092 #endif 1093 1094 /** 1095 * struct reo_queue_ref_table - Reo qref LUT addr 1096 * @mlo_reo_qref_table_vaddr: MLO table vaddr 1097 * @non_mlo_reo_qref_table_vaddr: Non MLO table vaddr 1098 * @mlo_reo_qref_table_paddr: MLO table paddr 1099 * @non_mlo_reo_qref_table_paddr: Non MLO table paddr 1100 * @reo_qref_table_en: Enable flag 1101 */ 1102 struct reo_queue_ref_table { 1103 uint64_t *mlo_reo_qref_table_vaddr; 1104 uint64_t *non_mlo_reo_qref_table_vaddr; 1105 qdf_dma_addr_t mlo_reo_qref_table_paddr; 1106 qdf_dma_addr_t non_mlo_reo_qref_table_paddr; 1107 uint8_t reo_qref_table_en; 1108 }; 1109 1110 /** 1111 * struct hal_soc - HAL context to be used to access SRNG APIs 1112 * (currently used by data path and 1113 * transport (CE) modules) 1114 * @list_shadow_reg_config: array of generic regs mapped to 1115 * shadow regs 1116 * @num_generic_shadow_regs_configured: number of generic regs 1117 * mapped to shadow regs 1118 */ 1119 struct hal_soc { 1120 /* HIF handle to access HW registers */ 1121 struct hif_opaque_softc *hif_handle; 1122 1123 /* QDF device handle */ 1124 qdf_device_t qdf_dev; 1125 1126 /* Device base address */ 1127 void *dev_base_addr; 1128 /* Device base address for ce - qca5018 target */ 1129 void *dev_base_addr_ce; 1130 1131 /* HAL internal state for all SRNG rings. 1132 * TODO: See if this is required 1133 */ 1134 struct hal_srng srng_list[HAL_SRNG_ID_MAX]; 1135 1136 /* Remote pointer memory for HW/FW updates */ 1137 uint32_t *shadow_rdptr_mem_vaddr; 1138 qdf_dma_addr_t shadow_rdptr_mem_paddr; 1139 1140 /* Shared memory for ring pointer updates from host to FW */ 1141 uint32_t *shadow_wrptr_mem_vaddr; 1142 qdf_dma_addr_t shadow_wrptr_mem_paddr; 1143 1144 /* REO blocking resource index */ 1145 uint8_t reo_res_bitmap; 1146 uint8_t index; 1147 uint32_t target_type; 1148 1149 /* shadow register configuration */ 1150 struct pld_shadow_reg_v2_cfg shadow_config[MAX_SHADOW_REGISTERS]; 1151 int num_shadow_registers_configured; 1152 bool use_register_windowing; 1153 uint32_t register_window; 1154 qdf_spinlock_t register_access_lock; 1155 1156 /* Static window map configuration for multiple window write*/ 1157 bool static_window_map; 1158 1159 /* srng table */ 1160 struct hal_hw_srng_config *hw_srng_table; 1161 int32_t hal_hw_reg_offset[SRNG_REGISTER_MAX]; 1162 struct hal_hw_txrx_ops *ops; 1163 1164 /* Indicate srngs initialization */ 1165 bool init_phase; 1166 /* Hal level stats */ 1167 struct hal_soc_stats stats; 1168 #ifdef ENABLE_HAL_REG_WR_HISTORY 1169 struct hal_reg_write_fail_history *reg_wr_fail_hist; 1170 #endif 1171 #ifdef FEATURE_HAL_DELAYED_REG_WRITE 1172 /* queue(array) to hold register writes */ 1173 struct hal_reg_write_q_elem *reg_write_queue; 1174 /* delayed work to be queued into workqueue */ 1175 qdf_work_t reg_write_work; 1176 /* workqueue for delayed register writes */ 1177 qdf_workqueue_t *reg_write_wq; 1178 /* write index used by caller to enqueue delayed work */ 1179 qdf_atomic_t write_idx; 1180 /* read index used by worker thread to dequeue/write registers */ 1181 uint32_t read_idx; 1182 #endif /*FEATURE_HAL_DELAYED_REG_WRITE */ 1183 qdf_atomic_t active_work_cnt; 1184 #ifdef GENERIC_SHADOW_REGISTER_ACCESS_ENABLE 1185 struct shadow_reg_config 1186 list_shadow_reg_config[MAX_GENERIC_SHADOW_REG]; 1187 int num_generic_shadow_regs_configured; 1188 #endif 1189 /* flag to indicate cmn dmac rings in berryllium */ 1190 bool dmac_cmn_src_rxbuf_ring; 1191 /* Reo queue ref table items */ 1192 struct reo_queue_ref_table reo_qref; 1193 }; 1194 1195 #if defined(FEATURE_HAL_DELAYED_REG_WRITE) 1196 /** 1197 * hal_delayed_reg_write() - delayed regiter write 1198 * @hal_soc: HAL soc handle 1199 * @srng: hal srng 1200 * @addr: iomem address 1201 * @value: value to be written 1202 * 1203 * Return: none 1204 */ 1205 void hal_delayed_reg_write(struct hal_soc *hal_soc, 1206 struct hal_srng *srng, 1207 void __iomem *addr, 1208 uint32_t value); 1209 #endif 1210 1211 void hal_qca6750_attach(struct hal_soc *hal_soc); 1212 void hal_qca6490_attach(struct hal_soc *hal_soc); 1213 void hal_qca6390_attach(struct hal_soc *hal_soc); 1214 void hal_qca6290_attach(struct hal_soc *hal_soc); 1215 void hal_qca8074_attach(struct hal_soc *hal_soc); 1216 void hal_kiwi_attach(struct hal_soc *hal_soc); 1217 void hal_qcn9224_attach(struct hal_soc *hal_soc); 1218 /* 1219 * hal_soc_to_dp_hal_roc - API to convert hal_soc to opaque 1220 * dp_hal_soc handle type 1221 * @hal_soc - hal_soc type 1222 * 1223 * Return: hal_soc_handle_t type 1224 */ 1225 static inline 1226 hal_soc_handle_t hal_soc_to_hal_soc_handle(struct hal_soc *hal_soc) 1227 { 1228 return (hal_soc_handle_t)hal_soc; 1229 } 1230 1231 /* 1232 * hal_srng_to_hal_ring_handle - API to convert hal_srng to opaque 1233 * dp_hal_ring handle type 1234 * @hal_srng - hal_srng type 1235 * 1236 * Return: hal_ring_handle_t type 1237 */ 1238 static inline 1239 hal_ring_handle_t hal_srng_to_hal_ring_handle(struct hal_srng *hal_srng) 1240 { 1241 return (hal_ring_handle_t)hal_srng; 1242 } 1243 1244 /* 1245 * hal_ring_handle_to_hal_srng - API to convert dp_hal_ring to hal_srng handle 1246 * @hal_ring - hal_ring_handle_t type 1247 * 1248 * Return: hal_srng pointer type 1249 */ 1250 static inline 1251 struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring) 1252 { 1253 return (struct hal_srng *)hal_ring; 1254 } 1255 1256 /* Size of REO queue reference table in Host 1257 * 2k peers * 17 tids * 8bytes(rx_reo_queue_reference) 1258 * = 278528 bytes 1259 */ 1260 #define REO_QUEUE_REF_NON_ML_TABLE_SIZE 278528 1261 /* Calculated based on 512 MLO peers */ 1262 #define REO_QUEUE_REF_ML_TABLE_SIZE 69632 1263 #define HAL_ML_PEER_ID_START 0x2000 1264 #define HAL_PEER_ID_IS_MLO(peer_id) ((peer_id) & HAL_ML_PEER_ID_START) 1265 #endif /* _HAL_INTERNAL_H_ */ 1266