Lines Matching refs:srng
250 struct hal_srng *srng, int ring_num) in ath11k_hal_ce_dst_setup() argument
263 srng->u.dst_ring.max_buffer_length); in ath11k_hal_ce_dst_setup()
268 struct hal_srng *srng) in ath11k_hal_srng_dst_hw_init() argument
275 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R0]; in ath11k_hal_srng_dst_hw_init()
277 if (srng->flags & HAL_SRNG_FLAGS_MSI_INTR) { in ath11k_hal_srng_dst_hw_init()
280 srng->msi_addr); in ath11k_hal_srng_dst_hw_init()
283 ((u64)srng->msi_addr >> in ath11k_hal_srng_dst_hw_init()
291 srng->msi_data); in ath11k_hal_srng_dst_hw_init()
294 ath11k_hif_write32(ab, reg_base, srng->ring_base_paddr); in ath11k_hal_srng_dst_hw_init()
297 ((u64)srng->ring_base_paddr >> in ath11k_hal_srng_dst_hw_init()
300 (srng->entry_size * srng->num_entries)); in ath11k_hal_srng_dst_hw_init()
303 val = FIELD_PREP(HAL_REO1_RING_ID_RING_ID, srng->ring_id) | in ath11k_hal_srng_dst_hw_init()
304 FIELD_PREP(HAL_REO1_RING_ID_ENTRY_SIZE, srng->entry_size); in ath11k_hal_srng_dst_hw_init()
309 (srng->intr_timer_thres_us >> 3)); in ath11k_hal_srng_dst_hw_init()
312 (srng->intr_batch_cntr_thres_entries * in ath11k_hal_srng_dst_hw_init()
313 srng->entry_size)); in ath11k_hal_srng_dst_hw_init()
320 ((unsigned long)srng->u.dst_ring.hp_addr - in ath11k_hal_srng_dst_hw_init()
328 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R2]; in ath11k_hal_srng_dst_hw_init()
331 *srng->u.dst_ring.hp_addr = 0; in ath11k_hal_srng_dst_hw_init()
333 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R0]; in ath11k_hal_srng_dst_hw_init()
335 if (srng->flags & HAL_SRNG_FLAGS_DATA_TLV_SWAP) in ath11k_hal_srng_dst_hw_init()
337 if (srng->flags & HAL_SRNG_FLAGS_RING_PTR_SWAP) in ath11k_hal_srng_dst_hw_init()
339 if (srng->flags & HAL_SRNG_FLAGS_MSI_SWAP) in ath11k_hal_srng_dst_hw_init()
347 struct hal_srng *srng) in ath11k_hal_srng_src_hw_init() argument
354 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R0]; in ath11k_hal_srng_src_hw_init()
356 if (srng->flags & HAL_SRNG_FLAGS_MSI_INTR) { in ath11k_hal_srng_src_hw_init()
359 srng->msi_addr); in ath11k_hal_srng_src_hw_init()
362 ((u64)srng->msi_addr >> in ath11k_hal_srng_src_hw_init()
371 srng->msi_data); in ath11k_hal_srng_src_hw_init()
374 ath11k_hif_write32(ab, reg_base, srng->ring_base_paddr); in ath11k_hal_srng_src_hw_init()
377 ((u64)srng->ring_base_paddr >> in ath11k_hal_srng_src_hw_init()
380 (srng->entry_size * srng->num_entries)); in ath11k_hal_srng_src_hw_init()
383 val = FIELD_PREP(HAL_REO1_RING_ID_ENTRY_SIZE, srng->entry_size); in ath11k_hal_srng_src_hw_init()
386 if (srng->ring_id == HAL_SRNG_RING_ID_WBM_IDLE_LINK) { in ath11k_hal_srng_src_hw_init()
387 ath11k_hif_write32(ab, reg_base, (u32)srng->ring_base_paddr); in ath11k_hal_srng_src_hw_init()
389 ((u64)srng->ring_base_paddr >> in ath11k_hal_srng_src_hw_init()
392 (srng->entry_size * srng->num_entries)); in ath11k_hal_srng_src_hw_init()
401 srng->intr_timer_thres_us); in ath11k_hal_srng_src_hw_init()
404 (srng->intr_batch_cntr_thres_entries * in ath11k_hal_srng_src_hw_init()
405 srng->entry_size)); in ath11k_hal_srng_src_hw_init()
412 if (srng->flags & HAL_SRNG_FLAGS_LOW_THRESH_INTR_EN) { in ath11k_hal_srng_src_hw_init()
414 srng->u.src_ring.low_threshold); in ath11k_hal_srng_src_hw_init()
420 if (srng->ring_id != HAL_SRNG_RING_ID_WBM_IDLE_LINK) { in ath11k_hal_srng_src_hw_init()
422 ((unsigned long)srng->u.src_ring.tp_addr - in ath11k_hal_srng_src_hw_init()
433 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R2]; in ath11k_hal_srng_src_hw_init()
436 *srng->u.src_ring.tp_addr = 0; in ath11k_hal_srng_src_hw_init()
438 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R0]; in ath11k_hal_srng_src_hw_init()
440 if (srng->flags & HAL_SRNG_FLAGS_DATA_TLV_SWAP) in ath11k_hal_srng_src_hw_init()
442 if (srng->flags & HAL_SRNG_FLAGS_RING_PTR_SWAP) in ath11k_hal_srng_src_hw_init()
444 if (srng->flags & HAL_SRNG_FLAGS_MSI_SWAP) in ath11k_hal_srng_src_hw_init()
456 struct hal_srng *srng) in ath11k_hal_srng_hw_init() argument
458 if (srng->ring_dir == HAL_SRNG_DIR_SRC) in ath11k_hal_srng_hw_init()
459 ath11k_hal_srng_src_hw_init(ab, srng); in ath11k_hal_srng_hw_init()
461 ath11k_hal_srng_dst_hw_init(ab, srng); in ath11k_hal_srng_hw_init()
510 void ath11k_hal_srng_get_params(struct ath11k_base *ab, struct hal_srng *srng, in ath11k_hal_srng_get_params() argument
513 params->ring_base_paddr = srng->ring_base_paddr; in ath11k_hal_srng_get_params()
514 params->ring_base_vaddr = srng->ring_base_vaddr; in ath11k_hal_srng_get_params()
515 params->num_entries = srng->num_entries; in ath11k_hal_srng_get_params()
516 params->intr_timer_thres_us = srng->intr_timer_thres_us; in ath11k_hal_srng_get_params()
518 srng->intr_batch_cntr_thres_entries; in ath11k_hal_srng_get_params()
519 params->low_threshold = srng->u.src_ring.low_threshold; in ath11k_hal_srng_get_params()
520 params->msi_addr = srng->msi_addr; in ath11k_hal_srng_get_params()
521 params->msi_data = srng->msi_data; in ath11k_hal_srng_get_params()
522 params->flags = srng->flags; in ath11k_hal_srng_get_params()
526 struct hal_srng *srng) in ath11k_hal_srng_get_hp_addr() argument
528 if (!(srng->flags & HAL_SRNG_FLAGS_LMAC_RING)) in ath11k_hal_srng_get_hp_addr()
531 if (srng->ring_dir == HAL_SRNG_DIR_SRC) in ath11k_hal_srng_get_hp_addr()
533 ((unsigned long)srng->u.src_ring.hp_addr - in ath11k_hal_srng_get_hp_addr()
537 ((unsigned long)srng->u.dst_ring.hp_addr - in ath11k_hal_srng_get_hp_addr()
542 struct hal_srng *srng) in ath11k_hal_srng_get_tp_addr() argument
544 if (!(srng->flags & HAL_SRNG_FLAGS_LMAC_RING)) in ath11k_hal_srng_get_tp_addr()
547 if (srng->ring_dir == HAL_SRNG_DIR_SRC) in ath11k_hal_srng_get_tp_addr()
549 ((unsigned long)srng->u.src_ring.tp_addr - in ath11k_hal_srng_get_tp_addr()
553 ((unsigned long)srng->u.dst_ring.tp_addr - in ath11k_hal_srng_get_tp_addr()
621 u32 *ath11k_hal_srng_dst_peek(struct ath11k_base *ab, struct hal_srng *srng) in ath11k_hal_srng_dst_peek() argument
623 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_dst_peek()
625 if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp) in ath11k_hal_srng_dst_peek()
626 return (srng->ring_base_vaddr + srng->u.dst_ring.tp); in ath11k_hal_srng_dst_peek()
632 struct hal_srng *srng) in ath11k_hal_srng_prefetch_desc() argument
637 desc = ath11k_hal_srng_dst_peek(ab, srng); in ath11k_hal_srng_prefetch_desc()
640 (srng->entry_size * sizeof(u32)), in ath11k_hal_srng_prefetch_desc()
647 struct hal_srng *srng) in ath11k_hal_srng_dst_get_next_entry() argument
651 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_dst_get_next_entry()
653 if (srng->u.dst_ring.tp == srng->u.dst_ring.cached_hp) in ath11k_hal_srng_dst_get_next_entry()
656 desc = srng->ring_base_vaddr + srng->u.dst_ring.tp; in ath11k_hal_srng_dst_get_next_entry()
658 srng->u.dst_ring.tp += srng->entry_size; in ath11k_hal_srng_dst_get_next_entry()
661 if (srng->u.dst_ring.tp == srng->ring_size) in ath11k_hal_srng_dst_get_next_entry()
662 srng->u.dst_ring.tp = 0; in ath11k_hal_srng_dst_get_next_entry()
665 if (srng->flags & HAL_SRNG_FLAGS_CACHED) in ath11k_hal_srng_dst_get_next_entry()
666 ath11k_hal_srng_prefetch_desc(ab, srng); in ath11k_hal_srng_dst_get_next_entry()
671 int ath11k_hal_srng_dst_num_free(struct ath11k_base *ab, struct hal_srng *srng, in ath11k_hal_srng_dst_num_free() argument
676 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_dst_num_free()
678 tp = srng->u.dst_ring.tp; in ath11k_hal_srng_dst_num_free()
681 hp = *srng->u.dst_ring.hp_addr; in ath11k_hal_srng_dst_num_free()
682 srng->u.dst_ring.cached_hp = hp; in ath11k_hal_srng_dst_num_free()
684 hp = srng->u.dst_ring.cached_hp; in ath11k_hal_srng_dst_num_free()
688 return (hp - tp) / srng->entry_size; in ath11k_hal_srng_dst_num_free()
690 return (srng->ring_size - tp + hp) / srng->entry_size; in ath11k_hal_srng_dst_num_free()
694 int ath11k_hal_srng_src_num_free(struct ath11k_base *ab, struct hal_srng *srng, in ath11k_hal_srng_src_num_free() argument
699 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_src_num_free()
701 hp = srng->u.src_ring.hp; in ath11k_hal_srng_src_num_free()
704 tp = *srng->u.src_ring.tp_addr; in ath11k_hal_srng_src_num_free()
705 srng->u.src_ring.cached_tp = tp; in ath11k_hal_srng_src_num_free()
707 tp = srng->u.src_ring.cached_tp; in ath11k_hal_srng_src_num_free()
711 return ((tp - hp) / srng->entry_size) - 1; in ath11k_hal_srng_src_num_free()
713 return ((srng->ring_size - hp + tp) / srng->entry_size) - 1; in ath11k_hal_srng_src_num_free()
717 struct hal_srng *srng) in ath11k_hal_srng_src_get_next_entry() argument
722 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_src_get_next_entry()
730 next_hp = (srng->u.src_ring.hp + srng->entry_size) % srng->ring_size; in ath11k_hal_srng_src_get_next_entry()
732 if (next_hp == srng->u.src_ring.cached_tp) in ath11k_hal_srng_src_get_next_entry()
735 desc = srng->ring_base_vaddr + srng->u.src_ring.hp; in ath11k_hal_srng_src_get_next_entry()
736 srng->u.src_ring.hp = next_hp; in ath11k_hal_srng_src_get_next_entry()
744 srng->u.src_ring.reap_hp = next_hp; in ath11k_hal_srng_src_get_next_entry()
750 struct hal_srng *srng) in ath11k_hal_srng_src_reap_next() argument
755 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_src_reap_next()
757 next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) % in ath11k_hal_srng_src_reap_next()
758 srng->ring_size; in ath11k_hal_srng_src_reap_next()
760 if (next_reap_hp == srng->u.src_ring.cached_tp) in ath11k_hal_srng_src_reap_next()
763 desc = srng->ring_base_vaddr + next_reap_hp; in ath11k_hal_srng_src_reap_next()
764 srng->u.src_ring.reap_hp = next_reap_hp; in ath11k_hal_srng_src_reap_next()
770 struct hal_srng *srng) in ath11k_hal_srng_src_get_next_reaped() argument
774 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_src_get_next_reaped()
776 if (srng->u.src_ring.hp == srng->u.src_ring.reap_hp) in ath11k_hal_srng_src_get_next_reaped()
779 desc = srng->ring_base_vaddr + srng->u.src_ring.hp; in ath11k_hal_srng_src_get_next_reaped()
780 srng->u.src_ring.hp = (srng->u.src_ring.hp + srng->entry_size) % in ath11k_hal_srng_src_get_next_reaped()
781 srng->ring_size; in ath11k_hal_srng_src_get_next_reaped()
786 u32 *ath11k_hal_srng_src_peek(struct ath11k_base *ab, struct hal_srng *srng) in ath11k_hal_srng_src_peek() argument
788 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_src_peek()
790 if (((srng->u.src_ring.hp + srng->entry_size) % srng->ring_size) == in ath11k_hal_srng_src_peek()
791 srng->u.src_ring.cached_tp) in ath11k_hal_srng_src_peek()
794 return srng->ring_base_vaddr + srng->u.src_ring.hp; in ath11k_hal_srng_src_peek()
797 void ath11k_hal_srng_access_begin(struct ath11k_base *ab, struct hal_srng *srng) in ath11k_hal_srng_access_begin() argument
799 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_access_begin()
801 if (srng->ring_dir == HAL_SRNG_DIR_SRC) { in ath11k_hal_srng_access_begin()
802 srng->u.src_ring.cached_tp = in ath11k_hal_srng_access_begin()
803 *(volatile u32 *)srng->u.src_ring.tp_addr; in ath11k_hal_srng_access_begin()
805 srng->u.dst_ring.cached_hp = *srng->u.dst_ring.hp_addr; in ath11k_hal_srng_access_begin()
808 if (srng->flags & HAL_SRNG_FLAGS_CACHED) in ath11k_hal_srng_access_begin()
809 ath11k_hal_srng_prefetch_desc(ab, srng); in ath11k_hal_srng_access_begin()
816 void ath11k_hal_srng_access_end(struct ath11k_base *ab, struct hal_srng *srng) in ath11k_hal_srng_access_end() argument
818 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_access_end()
821 if (srng->flags & HAL_SRNG_FLAGS_LMAC_RING) { in ath11k_hal_srng_access_end()
825 if (srng->ring_dir == HAL_SRNG_DIR_SRC) { in ath11k_hal_srng_access_end()
826 srng->u.src_ring.last_tp = in ath11k_hal_srng_access_end()
827 *(volatile u32 *)srng->u.src_ring.tp_addr; in ath11k_hal_srng_access_end()
828 *srng->u.src_ring.hp_addr = srng->u.src_ring.hp; in ath11k_hal_srng_access_end()
830 srng->u.dst_ring.last_hp = *srng->u.dst_ring.hp_addr; in ath11k_hal_srng_access_end()
831 *srng->u.dst_ring.tp_addr = srng->u.dst_ring.tp; in ath11k_hal_srng_access_end()
834 if (srng->ring_dir == HAL_SRNG_DIR_SRC) { in ath11k_hal_srng_access_end()
835 srng->u.src_ring.last_tp = in ath11k_hal_srng_access_end()
836 *(volatile u32 *)srng->u.src_ring.tp_addr; in ath11k_hal_srng_access_end()
838 (unsigned long)srng->u.src_ring.hp_addr - in ath11k_hal_srng_access_end()
840 srng->u.src_ring.hp); in ath11k_hal_srng_access_end()
842 srng->u.dst_ring.last_hp = *srng->u.dst_ring.hp_addr; in ath11k_hal_srng_access_end()
844 (unsigned long)srng->u.dst_ring.tp_addr - in ath11k_hal_srng_access_end()
846 srng->u.dst_ring.tp); in ath11k_hal_srng_access_end()
850 srng->timestamp = jiffies; in ath11k_hal_srng_access_end()
951 struct hal_srng *srng; in ath11k_hal_srng_setup() local
961 srng = &hal->srng_list[ring_id]; in ath11k_hal_srng_setup()
963 srng->ring_id = ring_id; in ath11k_hal_srng_setup()
964 srng->ring_dir = srng_config->ring_dir; in ath11k_hal_srng_setup()
965 srng->ring_base_paddr = params->ring_base_paddr; in ath11k_hal_srng_setup()
966 srng->ring_base_vaddr = params->ring_base_vaddr; in ath11k_hal_srng_setup()
967 srng->entry_size = srng_config->entry_size; in ath11k_hal_srng_setup()
968 srng->num_entries = params->num_entries; in ath11k_hal_srng_setup()
969 srng->ring_size = srng->entry_size * srng->num_entries; in ath11k_hal_srng_setup()
970 srng->intr_batch_cntr_thres_entries = in ath11k_hal_srng_setup()
972 srng->intr_timer_thres_us = params->intr_timer_thres_us; in ath11k_hal_srng_setup()
973 srng->flags = params->flags; in ath11k_hal_srng_setup()
974 srng->msi_addr = params->msi_addr; in ath11k_hal_srng_setup()
975 srng->msi_data = params->msi_data; in ath11k_hal_srng_setup()
976 srng->initialized = 1; in ath11k_hal_srng_setup()
977 spin_lock_init(&srng->lock); in ath11k_hal_srng_setup()
978 lockdep_set_class(&srng->lock, hal->srng_key + ring_id); in ath11k_hal_srng_setup()
981 srng->hwreg_base[i] = srng_config->reg_start[i] + in ath11k_hal_srng_setup()
985 memset(srng->ring_base_vaddr, 0, in ath11k_hal_srng_setup()
986 (srng->entry_size * srng->num_entries) << 2); in ath11k_hal_srng_setup()
990 srng->flags |= HAL_SRNG_FLAGS_MSI_SWAP | HAL_SRNG_FLAGS_DATA_TLV_SWAP | in ath11k_hal_srng_setup()
993 reg_base = srng->hwreg_base[HAL_SRNG_REG_GRP_R2]; in ath11k_hal_srng_setup()
995 if (srng->ring_dir == HAL_SRNG_DIR_SRC) { in ath11k_hal_srng_setup()
996 srng->u.src_ring.hp = 0; in ath11k_hal_srng_setup()
997 srng->u.src_ring.cached_tp = 0; in ath11k_hal_srng_setup()
998 srng->u.src_ring.reap_hp = srng->ring_size - srng->entry_size; in ath11k_hal_srng_setup()
999 srng->u.src_ring.tp_addr = (void *)(hal->rdp.vaddr + ring_id); in ath11k_hal_srng_setup()
1000 srng->u.src_ring.low_threshold = params->low_threshold * in ath11k_hal_srng_setup()
1001 srng->entry_size; in ath11k_hal_srng_setup()
1004 srng->u.src_ring.hp_addr = (void *)(hal->wrp.vaddr + in ath11k_hal_srng_setup()
1006 srng->flags |= HAL_SRNG_FLAGS_LMAC_RING; in ath11k_hal_srng_setup()
1009 srng->u.src_ring.hp_addr = in ath11k_hal_srng_setup()
1016 (unsigned long)srng->u.src_ring.hp_addr - in ath11k_hal_srng_setup()
1028 srng->u.dst_ring.loop_cnt = 1; in ath11k_hal_srng_setup()
1029 srng->u.dst_ring.tp = 0; in ath11k_hal_srng_setup()
1030 srng->u.dst_ring.cached_hp = 0; in ath11k_hal_srng_setup()
1031 srng->u.dst_ring.hp_addr = (void *)(hal->rdp.vaddr + ring_id); in ath11k_hal_srng_setup()
1037 srng->u.dst_ring.tp_addr = (void *)(hal->wrp.vaddr + in ath11k_hal_srng_setup()
1039 srng->flags |= HAL_SRNG_FLAGS_LMAC_RING; in ath11k_hal_srng_setup()
1042 srng->u.dst_ring.tp_addr = in ath11k_hal_srng_setup()
1051 (unsigned long)srng->u.dst_ring.tp_addr - in ath11k_hal_srng_setup()
1059 ath11k_hal_srng_hw_init(ab, srng); in ath11k_hal_srng_setup()
1062 srng->u.dst_ring.max_buffer_length = params->max_buffer_len; in ath11k_hal_srng_setup()
1063 ath11k_hal_ce_dst_setup(ab, srng, ring_num); in ath11k_hal_srng_setup()
1074 struct hal_srng *srng; in ath11k_hal_srng_update_hp_tp_addr() local
1083 srng = &hal->srng_list[ring_id]; in ath11k_hal_srng_update_hp_tp_addr()
1086 srng->u.dst_ring.tp_addr = (u32 *)(HAL_SHADOW_REG(ab, shadow_cfg_idx) + in ath11k_hal_srng_update_hp_tp_addr()
1089 srng->u.src_ring.hp_addr = (u32 *)(HAL_SHADOW_REG(ab, shadow_cfg_idx) + in ath11k_hal_srng_update_hp_tp_addr()
1163 struct hal_srng *srng) in ath11k_hal_srng_shadow_update_hp_tp() argument
1165 lockdep_assert_held(&srng->lock); in ath11k_hal_srng_shadow_update_hp_tp()
1170 if (srng->ring_dir == HAL_SRNG_DIR_SRC && in ath11k_hal_srng_shadow_update_hp_tp()
1171 *srng->u.src_ring.tp_addr != srng->u.src_ring.hp) in ath11k_hal_srng_shadow_update_hp_tp()
1172 ath11k_hal_srng_access_end(ab, srng); in ath11k_hal_srng_shadow_update_hp_tp()
1327 struct hal_srng *srng; in ath11k_hal_dump_srng_stats() local
1353 srng = &ab->hal.srng_list[i]; in ath11k_hal_dump_srng_stats()
1355 if (!srng->initialized) in ath11k_hal_dump_srng_stats()
1358 if (srng->ring_dir == HAL_SRNG_DIR_SRC) in ath11k_hal_dump_srng_stats()
1361 srng->ring_id, srng->u.src_ring.hp, in ath11k_hal_dump_srng_stats()
1362 srng->u.src_ring.reap_hp, in ath11k_hal_dump_srng_stats()
1363 *srng->u.src_ring.tp_addr, srng->u.src_ring.cached_tp, in ath11k_hal_dump_srng_stats()
1364 srng->u.src_ring.last_tp, in ath11k_hal_dump_srng_stats()
1365 jiffies_to_msecs(jiffies - srng->timestamp)); in ath11k_hal_dump_srng_stats()
1366 else if (srng->ring_dir == HAL_SRNG_DIR_DST) in ath11k_hal_dump_srng_stats()
1369 srng->ring_id, srng->u.dst_ring.tp, in ath11k_hal_dump_srng_stats()
1370 *srng->u.dst_ring.hp_addr, in ath11k_hal_dump_srng_stats()
1371 srng->u.dst_ring.cached_hp, in ath11k_hal_dump_srng_stats()
1372 srng->u.dst_ring.last_hp, in ath11k_hal_dump_srng_stats()
1373 jiffies_to_msecs(jiffies - srng->timestamp)); in ath11k_hal_dump_srng_stats()