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 #define direct_buf_rx_alert(params...) \ 27 QDF_TRACE_FATAL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 28 #define direct_buf_rx_err(params...) \ 29 QDF_TRACE_ERROR(QDF_MODULE_ID_DIRECT_BUF_RX, params) 30 #define direct_buf_rx_warn(params...) \ 31 QDF_TRACE_WARN(QDF_MODULE_ID_DIRECT_BUF_RX, params) 32 #define direct_buf_rx_notice(params...) \ 33 QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params) 34 #define direct_buf_rx_info(params...) \ 35 QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params) 36 #define direct_buf_rx_debug(params...) \ 37 QDF_TRACE_DEBUG(QDF_MODULE_ID_DIRECT_BUF_RX, params) 38 #define direct_buf_rx_enter() \ 39 QDF_TRACE_ENTER(QDF_MODULE_ID_DIRECT_BUF_RX, "enter") 40 #define direct_buf_rx_exit() \ 41 QDF_TRACE_EXIT(QDF_MODULE_ID_DIRECT_BUF_RX, "exit") 42 43 #define directbuf_nofl_alert(params...) \ 44 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 45 #define directbuf_nofl_err(params...) \ 46 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 47 #define directbuf_nofl_warn(params...) \ 48 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 49 #define directbuf_nofl_info(params...) \ 50 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 51 #define directbuf_nofl_debug(params...) \ 52 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params) 53 54 #define DBR_MAX_CHAINS (8) 55 56 struct wlan_objmgr_psoc; 57 struct wlan_lmac_if_tx_ops; 58 59 /** 60 * enum DBR_MODULE - Enum containing the modules supporting direct buf rx 61 * @DBR_MODULE_SPECTRAL: Module ID for Spectral 62 * @DBR_MODULE_CFR: Module ID for CFR 63 * @DBR_MODULE_MAX: Max module ID 64 */ 65 enum DBR_MODULE { 66 DBR_MODULE_SPECTRAL = 0, 67 DBR_MODULE_CFR = 1, 68 DBR_MODULE_MAX, 69 }; 70 71 /** 72 * struct direct_buf_rx_data - direct buffer rx data 73 * @dbr_len: Length of the buffer DMAed 74 * @vaddr: Virtual address of the buffer that has DMAed data 75 * @cookie: Cookie for the buffer rxed from target 76 * @paddr: physical address of buffer corresponding to vaddr 77 * @meta_data_valid: Indicates that metadata is valid 78 * @meta_data: Meta data 79 */ 80 struct direct_buf_rx_data { 81 size_t dbr_len; 82 void *vaddr; 83 uint32_t cookie; 84 qdf_dma_addr_t paddr; 85 bool meta_data_valid; 86 struct direct_buf_rx_metadata meta_data; 87 }; 88 89 /** 90 * struct dbr_module_config - module configuration for dbr 91 * @num_resp_per_event: Number of events to be packed together 92 * @event_timeout_in_ms: Timeout until which multiple events can be packed 93 */ 94 struct dbr_module_config { 95 uint32_t num_resp_per_event; 96 uint32_t event_timeout_in_ms; 97 }; 98 99 /** 100 * direct_buf_rx_init() - Function to initialize direct buf rx module 101 * 102 * Return: QDF status of operation 103 */ 104 QDF_STATUS direct_buf_rx_init(void); 105 106 /** 107 * direct_buf_rx_deinit() - Function to deinitialize direct buf rx module 108 * 109 * Return: QDF status of operation 110 */ 111 QDF_STATUS direct_buf_rx_deinit(void); 112 113 /** 114 * direct_buf_rx_target_attach() - Attach hal_soc,osdev in direct buf rx psoc obj 115 * @psoc: pointer to psoc object 116 * @hal_soc: Opaque HAL SOC handle 117 * @osdev: QDF os device handle 118 * 119 * Return: QDF status of operation 120 */ 121 QDF_STATUS direct_buf_rx_target_attach(struct wlan_objmgr_psoc *psoc, 122 void *hal_soc, qdf_device_t osdev); 123 124 /** 125 * target_if_direct_buf_rx_register_tx_ops() - Register tx ops for direct buffer 126 * rx module 127 * @tx_ops: pointer to lmac interface tx ops 128 * 129 * Return: None 130 */ 131 void target_if_direct_buf_rx_register_tx_ops( 132 struct wlan_lmac_if_tx_ops *tx_ops); 133 134 /** 135 * target_if_dbr_cookie_lookup() - Function to retrieve cookie from 136 * buffer address(paddr) 137 * @pdev: pointer to pdev object 138 * @mod_id: module id indicating the module using direct buffer rx framework 139 * @paddr: Physical address of buffer for which cookie info is required 140 * @cookie: cookie will be returned in this param 141 * @srng_id: srng ID 142 * 143 * Return: QDF status of operation 144 */ 145 QDF_STATUS target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev, 146 uint8_t mod_id, qdf_dma_addr_t paddr, 147 uint32_t *cookie, uint8_t srng_id); 148 149 /** 150 * target_if_dbr_buf_release() - Notify direct buf that a previously provided 151 * buffer can be released. 152 * @pdev: pointer to pdev object 153 * @mod_id: module id indicating the module using direct buffer rx framework 154 * @paddr: Physical address of buffer for which cookie info is required 155 * @cookie: cookie value corresponding to the paddr 156 * @srng_id: srng ID 157 * 158 * Return: QDF status of operation 159 */ 160 QDF_STATUS target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev, 161 uint8_t mod_id, qdf_dma_addr_t paddr, 162 uint32_t cookie, uint8_t srng_id); 163 #endif /* _TARGET_IF_DIRECT_BUF_RX_API_H_ */ 164