1 /* 2 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _TARGET_IF_DIRECT_BUF_RX_API_H_ 20 #define _TARGET_IF_DIRECT_BUF_RX_API_H_ 21 22 #include "qdf_nbuf.h" 23 #include "qdf_atomic.h" 24 #include "wmi_unified_api.h" 25 26 #ifdef WLAN_DEBUGFS 27 #ifdef DIRECT_BUF_RX_DEBUG 28 /* Base debugfs entry for DBR module */ 29 extern qdf_dentry_t dbr_debugfs_entry; 30 #endif /* DIRECT_BUF_RX_DEBUG */ 31 #endif /* WLAN_DEBUGFS */ 32 33 #define direct_buf_rx_alert(params...) \ 34 QDF_TRACE_FATAL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 35 #define direct_buf_rx_err(params...) \ 36 QDF_TRACE_ERROR(QDF_MODULE_ID_DIRECT_BUF_RX, params) 37 #define direct_buf_rx_warn(params...) \ 38 QDF_TRACE_WARN(QDF_MODULE_ID_DIRECT_BUF_RX, params) 39 #define direct_buf_rx_notice(params...) \ 40 QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params) 41 #define direct_buf_rx_info(params...) \ 42 QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params) 43 #define direct_buf_rx_debug(params...) \ 44 QDF_TRACE_DEBUG(QDF_MODULE_ID_DIRECT_BUF_RX, params) 45 #define direct_buf_rx_enter() \ 46 QDF_TRACE_ENTER(QDF_MODULE_ID_DIRECT_BUF_RX, "enter") 47 #define direct_buf_rx_exit() \ 48 QDF_TRACE_EXIT(QDF_MODULE_ID_DIRECT_BUF_RX, "exit") 49 50 #define directbuf_nofl_alert(params...) \ 51 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 52 #define directbuf_nofl_err(params...) \ 53 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 54 #define directbuf_nofl_warn(params...) \ 55 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 56 #define directbuf_nofl_info(params...) \ 57 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 58 #define directbuf_nofl_debug(params...) \ 59 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 60 61 #define DBR_MAX_CHAINS (8) 62 63 struct wlan_objmgr_psoc; 64 struct wlan_lmac_if_tx_ops; 65 66 /** 67 * enum DBR_MODULE - Enum containing the modules supporting direct buf rx 68 * @DBR_MODULE_SPECTRAL: Module ID for Spectral 69 * @DBR_MODULE_CFR: Module ID for CFR 70 * @DBR_MODULE_MAX: Max module ID 71 */ 72 enum DBR_MODULE { 73 DBR_MODULE_SPECTRAL = 0, 74 DBR_MODULE_CFR = 1, 75 DBR_MODULE_MAX, 76 }; 77 78 /** 79 * struct direct_buf_rx_data - direct buffer rx data 80 * @dbr_len: Length of the buffer DMAed 81 * @vaddr: Virtual address of the buffer that has DMAed data 82 * @cookie: Cookie for the buffer rxed from target 83 * @paddr: physical address of buffer corresponding to vaddr 84 * @meta_data_valid: Indicates that metadata is valid 85 * @meta_data: Meta data 86 */ 87 struct direct_buf_rx_data { 88 size_t dbr_len; 89 void *vaddr; 90 uint32_t cookie; 91 qdf_dma_addr_t paddr; 92 bool meta_data_valid; 93 struct direct_buf_rx_metadata meta_data; 94 }; 95 96 /** 97 * struct dbr_module_config - module configuration for dbr 98 * @num_resp_per_event: Number of events to be packed together 99 * @event_timeout_in_ms: Timeout until which multiple events can be packed 100 */ 101 struct dbr_module_config { 102 uint32_t num_resp_per_event; 103 uint32_t event_timeout_in_ms; 104 }; 105 106 /** 107 * direct_buf_rx_init() - Function to initialize direct buf rx module 108 * 109 * Return: QDF status of operation 110 */ 111 QDF_STATUS direct_buf_rx_init(void); 112 113 /** 114 * direct_buf_rx_deinit() - Function to deinitialize direct buf rx module 115 * 116 * Return: QDF status of operation 117 */ 118 QDF_STATUS direct_buf_rx_deinit(void); 119 120 /** 121 * direct_buf_rx_target_attach() - Attach hal_soc,osdev in direct buf rx psoc obj 122 * @psoc: pointer to psoc object 123 * @hal_soc: Opaque HAL SOC handle 124 * @osdev: QDF os device handle 125 * 126 * Return: QDF status of operation 127 */ 128 QDF_STATUS direct_buf_rx_target_attach(struct wlan_objmgr_psoc *psoc, 129 void *hal_soc, qdf_device_t osdev); 130 131 /** 132 * target_if_direct_buf_rx_register_tx_ops() - Register tx ops for direct buffer 133 * rx module 134 * @tx_ops: pointer to lmac interface tx ops 135 * 136 * Return: None 137 */ 138 void target_if_direct_buf_rx_register_tx_ops( 139 struct wlan_lmac_if_tx_ops *tx_ops); 140 141 /** 142 * target_if_dbr_cookie_lookup() - Function to retrieve cookie from 143 * buffer address(paddr) 144 * @pdev: pointer to pdev object 145 * @mod_id: module id indicating the module using direct buffer rx framework 146 * @paddr: Physical address of buffer for which cookie info is required 147 * @cookie: cookie will be returned in this param 148 * @srng_id: srng ID 149 * 150 * Return: QDF status of operation 151 */ 152 QDF_STATUS target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev, 153 uint8_t mod_id, qdf_dma_addr_t paddr, 154 uint32_t *cookie, uint8_t srng_id); 155 156 /** 157 * target_if_dbr_buf_release() - Notify direct buf that a previously provided 158 * buffer can be released. 159 * @pdev: pointer to pdev object 160 * @mod_id: module id indicating the module using direct buffer rx framework 161 * @paddr: Physical address of buffer for which cookie info is required 162 * @cookie: cookie value corresponding to the paddr 163 * @srng_id: srng ID 164 * 165 * Return: QDF status of operation 166 */ 167 QDF_STATUS target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev, 168 uint8_t mod_id, qdf_dma_addr_t paddr, 169 uint32_t cookie, uint8_t srng_id); 170 #endif /* _TARGET_IF_DIRECT_BUF_RX_API_H_ */ 171