| 1 |
/* SPDX-License-Identifier: BSD-3-Clause-Clear */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved. |
| 4 |
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef ATH12K_DBRING_H |
| 8 |
#define ATH12K_DBRING_H |
| 9 |
|
| 10 |
#include <linux/types.h> |
| 11 |
#include <linux/idr.h> |
| 12 |
#include <linux/spinlock.h> |
| 13 |
#include "dp.h" |
| 14 |
|
| 15 |
struct ath12k_dbring_element { |
| 16 |
dma_addr_t paddr; |
| 17 |
u8 payload[]; |
| 18 |
}; |
| 19 |
|
| 20 |
struct ath12k_dbring_data { |
| 21 |
void *data; |
| 22 |
u32 data_sz; |
| 23 |
struct ath12k_wmi_dma_buf_release_meta_data_params meta; |
| 24 |
}; |
| 25 |
|
| 26 |
struct ath12k_dbring_buf_release_event { |
| 27 |
struct ath12k_wmi_dma_buf_release_fixed_params fixed; |
| 28 |
const struct ath12k_wmi_dma_buf_release_entry_params *buf_entry; |
| 29 |
const struct ath12k_wmi_dma_buf_release_meta_data_params *meta_data; |
| 30 |
u32 num_buf_entry; |
| 31 |
u32 num_meta; |
| 32 |
}; |
| 33 |
|
| 34 |
struct ath12k_dbring_cap { |
| 35 |
u32 pdev_id; |
| 36 |
enum wmi_direct_buffer_module id; |
| 37 |
u32 min_elem; |
| 38 |
u32 min_buf_sz; |
| 39 |
u32 min_buf_align; |
| 40 |
}; |
| 41 |
|
| 42 |
struct ath12k_dbring { |
| 43 |
struct dp_srng refill_srng; |
| 44 |
struct idr bufs_idr; |
| 45 |
/* Protects bufs_idr */ |
| 46 |
spinlock_t idr_lock; |
| 47 |
dma_addr_t tp_addr; |
| 48 |
dma_addr_t hp_addr; |
| 49 |
int bufs_max; |
| 50 |
u32 pdev_id; |
| 51 |
u32 buf_sz; |
| 52 |
u32 buf_align; |
| 53 |
u32 num_resp_per_event; |
| 54 |
u32 event_timeout_ms; |
| 55 |
int (*handler)(struct ath12k *ar, struct ath12k_dbring_data *data); |
| 56 |
}; |
| 57 |
|
| 58 |
int ath12k_dbring_set_cfg(struct ath12k *ar, |
| 59 |
struct ath12k_dbring *ring, |
| 60 |
u32 num_resp_per_event, |
| 61 |
u32 event_timeout_ms, |
| 62 |
int (*handler)(struct ath12k *, |
| 63 |
struct ath12k_dbring_data *)); |
| 64 |
int ath12k_dbring_wmi_cfg_setup(struct ath12k *ar, |
| 65 |
struct ath12k_dbring *ring, |
| 66 |
enum wmi_direct_buffer_module id); |
| 67 |
int ath12k_dbring_buf_setup(struct ath12k *ar, |
| 68 |
struct ath12k_dbring *ring, |
| 69 |
struct ath12k_dbring_cap *db_cap); |
| 70 |
int ath12k_dbring_srng_setup(struct ath12k *ar, struct ath12k_dbring *ring, |
| 71 |
int ring_num, int num_entries); |
| 72 |
int ath12k_dbring_buffer_release_event(struct ath12k_base *ab, |
| 73 |
struct ath12k_dbring_buf_release_event *ev); |
| 74 |
int ath12k_dbring_get_cap(struct ath12k_base *ab, |
| 75 |
u8 pdev_idx, |
| 76 |
enum wmi_direct_buffer_module id, |
| 77 |
struct ath12k_dbring_cap *db_cap); |
| 78 |
void ath12k_dbring_srng_cleanup(struct ath12k *ar, struct ath12k_dbring *ring); |
| 79 |
void ath12k_dbring_buf_cleanup(struct ath12k *ar, struct ath12k_dbring *ring); |
| 80 |
#endif /* ATH12K_DBRING_H */ |