18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause-Clear */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef ATH11K_DBRING_H 78c2ecf20Sopenharmony_ci#define ATH11K_DBRING_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci#include <linux/idr.h> 118c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 128c2ecf20Sopenharmony_ci#include "dp.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistruct ath11k_dbring_element { 158c2ecf20Sopenharmony_ci dma_addr_t paddr; 168c2ecf20Sopenharmony_ci u8 payload[0]; 178c2ecf20Sopenharmony_ci}; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistruct ath11k_dbring_data { 208c2ecf20Sopenharmony_ci void *data; 218c2ecf20Sopenharmony_ci u32 data_sz; 228c2ecf20Sopenharmony_ci struct wmi_dma_buf_release_meta_data meta; 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistruct ath11k_dbring_buf_release_event { 268c2ecf20Sopenharmony_ci struct ath11k_wmi_dma_buf_release_fixed_param fixed; 278c2ecf20Sopenharmony_ci struct wmi_dma_buf_release_entry *buf_entry; 288c2ecf20Sopenharmony_ci struct wmi_dma_buf_release_meta_data *meta_data; 298c2ecf20Sopenharmony_ci u32 num_buf_entry; 308c2ecf20Sopenharmony_ci u32 num_meta; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct ath11k_dbring_cap { 348c2ecf20Sopenharmony_ci u32 pdev_id; 358c2ecf20Sopenharmony_ci enum wmi_direct_buffer_module id; 368c2ecf20Sopenharmony_ci u32 min_elem; 378c2ecf20Sopenharmony_ci u32 min_buf_sz; 388c2ecf20Sopenharmony_ci u32 min_buf_align; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct ath11k_dbring { 428c2ecf20Sopenharmony_ci struct dp_srng refill_srng; 438c2ecf20Sopenharmony_ci struct idr bufs_idr; 448c2ecf20Sopenharmony_ci /* Protects bufs_idr */ 458c2ecf20Sopenharmony_ci spinlock_t idr_lock; 468c2ecf20Sopenharmony_ci dma_addr_t tp_addr; 478c2ecf20Sopenharmony_ci dma_addr_t hp_addr; 488c2ecf20Sopenharmony_ci int bufs_max; 498c2ecf20Sopenharmony_ci u32 pdev_id; 508c2ecf20Sopenharmony_ci u32 buf_sz; 518c2ecf20Sopenharmony_ci u32 buf_align; 528c2ecf20Sopenharmony_ci u32 num_resp_per_event; 538c2ecf20Sopenharmony_ci u32 event_timeout_ms; 548c2ecf20Sopenharmony_ci int (*handler)(struct ath11k *, struct ath11k_dbring_data *); 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciint ath11k_dbring_set_cfg(struct ath11k *ar, 588c2ecf20Sopenharmony_ci struct ath11k_dbring *ring, 598c2ecf20Sopenharmony_ci u32 num_resp_per_event, 608c2ecf20Sopenharmony_ci u32 event_timeout_ms, 618c2ecf20Sopenharmony_ci int (*handler)(struct ath11k *, 628c2ecf20Sopenharmony_ci struct ath11k_dbring_data *)); 638c2ecf20Sopenharmony_ciint ath11k_dbring_wmi_cfg_setup(struct ath11k *ar, 648c2ecf20Sopenharmony_ci struct ath11k_dbring *ring, 658c2ecf20Sopenharmony_ci enum wmi_direct_buffer_module id); 668c2ecf20Sopenharmony_ciint ath11k_dbring_buf_setup(struct ath11k *ar, 678c2ecf20Sopenharmony_ci struct ath11k_dbring *ring, 688c2ecf20Sopenharmony_ci struct ath11k_dbring_cap *db_cap); 698c2ecf20Sopenharmony_ciint ath11k_dbring_srng_setup(struct ath11k *ar, struct ath11k_dbring *ring, 708c2ecf20Sopenharmony_ci int ring_num, int num_entries); 718c2ecf20Sopenharmony_ciint ath11k_dbring_buffer_release_event(struct ath11k_base *ab, 728c2ecf20Sopenharmony_ci struct ath11k_dbring_buf_release_event *ev); 738c2ecf20Sopenharmony_ciint ath11k_dbring_get_cap(struct ath11k_base *ab, 748c2ecf20Sopenharmony_ci u8 pdev_idx, 758c2ecf20Sopenharmony_ci enum wmi_direct_buffer_module id, 768c2ecf20Sopenharmony_ci struct ath11k_dbring_cap *db_cap); 778c2ecf20Sopenharmony_civoid ath11k_dbring_srng_cleanup(struct ath11k *ar, struct ath11k_dbring *ring); 788c2ecf20Sopenharmony_civoid ath11k_dbring_buf_cleanup(struct ath11k *ar, struct ath11k_dbring *ring); 798c2ecf20Sopenharmony_ci#endif /* ATH11K_DBRING_H */ 80