dbring.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2. /*
  3. * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef ATH11K_DBRING_H
  6. #define ATH11K_DBRING_H
  7. #include <linux/types.h>
  8. #include <linux/idr.h>
  9. #include <linux/spinlock.h>
  10. #include "dp.h"
  11. struct ath11k_dbring_element {
  12. dma_addr_t paddr;
  13. u8 *payload;
  14. };
  15. struct ath11k_dbring_data {
  16. void *data;
  17. u32 data_sz;
  18. struct wmi_dma_buf_release_meta_data meta;
  19. };
  20. struct ath11k_dbring_buf_release_event {
  21. struct ath11k_wmi_dma_buf_release_fixed_param fixed;
  22. struct wmi_dma_buf_release_entry *buf_entry;
  23. struct wmi_dma_buf_release_meta_data *meta_data;
  24. u32 num_buf_entry;
  25. u32 num_meta;
  26. };
  27. struct ath11k_dbring_cap {
  28. u32 pdev_id;
  29. enum wmi_direct_buffer_module id;
  30. u32 min_elem;
  31. u32 min_buf_sz;
  32. u32 min_buf_align;
  33. };
  34. struct ath11k_dbring {
  35. struct dp_srng refill_srng;
  36. struct idr bufs_idr;
  37. /* Protects bufs_idr */
  38. spinlock_t idr_lock;
  39. dma_addr_t tp_addr;
  40. dma_addr_t hp_addr;
  41. int bufs_max;
  42. u32 pdev_id;
  43. u32 buf_sz;
  44. u32 buf_align;
  45. u32 num_resp_per_event;
  46. u32 event_timeout_ms;
  47. int (*handler)(struct ath11k *, struct ath11k_dbring_data *);
  48. };
  49. int ath11k_dbring_set_cfg(struct ath11k *ar,
  50. struct ath11k_dbring *ring,
  51. u32 num_resp_per_event,
  52. u32 event_timeout_ms,
  53. int (*handler)(struct ath11k *,
  54. struct ath11k_dbring_data *));
  55. int ath11k_dbring_wmi_cfg_setup(struct ath11k *ar,
  56. struct ath11k_dbring *ring,
  57. enum wmi_direct_buffer_module id);
  58. int ath11k_dbring_buf_setup(struct ath11k *ar,
  59. struct ath11k_dbring *ring,
  60. struct ath11k_dbring_cap *db_cap);
  61. int ath11k_dbring_srng_setup(struct ath11k *ar, struct ath11k_dbring *ring,
  62. int ring_num, int num_entries);
  63. int ath11k_dbring_buffer_release_event(struct ath11k_base *ab,
  64. struct ath11k_dbring_buf_release_event *ev);
  65. int ath11k_dbring_get_cap(struct ath11k_base *ab,
  66. u8 pdev_idx,
  67. enum wmi_direct_buffer_module id,
  68. struct ath11k_dbring_cap *db_cap);
  69. void ath11k_dbring_srng_cleanup(struct ath11k *ar, struct ath11k_dbring *ring);
  70. void ath11k_dbring_buf_cleanup(struct ath11k *ar, struct ath11k_dbring *ring);
  71. int ath11k_dbring_validate_buffer(struct ath11k *ar, void *data, u32 size);
  72. #endif /* ATH11K_DBRING_H */