xref: /wlan-dirver/qca-wifi-host-cmn/target_if/direct_buf_rx/inc/target_if_direct_buf_rx_api.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2017-2020 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 #ifdef WMI_DBR_SUPPORT
79 /**
80  * struct direct_buf_rx_data - direct buffer rx data
81  * @dbr_len: Length of the buffer DMAed
82  * @vaddr: Virtual address of the buffer that has DMAed data
83  * @cookie: Cookie for the buffer rxed from target
84  * @paddr: physical address of buffer corresponding to vaddr
85  * @meta_data_valid: Indicates that metadata is valid
86  * @meta_data: Meta data
87  */
88 struct direct_buf_rx_data {
89 	size_t dbr_len;
90 	void *vaddr;
91 	uint32_t cookie;
92 	qdf_dma_addr_t paddr;
93 	bool meta_data_valid;
94 	struct direct_buf_rx_metadata meta_data;
95 };
96 #endif
97 
98 /**
99  * struct dbr_module_config - module configuration for dbr
100  * @num_resp_per_event: Number of events to be packed together
101  * @event_timeout_in_ms: Timeout until which multiple events can be packed
102  */
103 struct dbr_module_config {
104 	uint32_t num_resp_per_event;
105 	uint32_t event_timeout_in_ms;
106 };
107 
108 /**
109  * direct_buf_rx_init() - Function to initialize direct buf rx module
110  *
111  * Return: QDF status of operation
112  */
113 QDF_STATUS direct_buf_rx_init(void);
114 
115 /**
116  * direct_buf_rx_deinit() - Function to deinitialize direct buf rx module
117  *
118  * Return: QDF status of operation
119  */
120 QDF_STATUS direct_buf_rx_deinit(void);
121 
122 /**
123  * direct_buf_rx_target_attach() - Attach hal_soc,osdev in direct buf rx psoc obj
124  * @psoc: pointer to psoc object
125  * @hal_soc: Opaque HAL SOC handle
126  * @osdev: QDF os device handle
127  *
128  * Return: QDF status of operation
129  */
130 QDF_STATUS direct_buf_rx_target_attach(struct wlan_objmgr_psoc *psoc,
131 				void *hal_soc, qdf_device_t osdev);
132 
133 /**
134  * target_if_direct_buf_rx_register_tx_ops() - Register tx ops for direct buffer
135  *                                             rx module
136  * @tx_ops: pointer to lmac interface tx ops
137  *
138  * Return: None
139  */
140 void target_if_direct_buf_rx_register_tx_ops(
141 				struct wlan_lmac_if_tx_ops *tx_ops);
142 
143 /**
144  * target_if_dbr_cookie_lookup() - Function to retrieve cookie from
145  *                                 buffer address(paddr)
146  * @pdev: pointer to pdev object
147  * @mod_id: module id indicating the module using direct buffer rx framework
148  * @paddr: Physical address of buffer for which cookie info is required
149  * @cookie: cookie will be returned in this param
150  * @srng_id: srng ID
151  *
152  * Return: QDF status of operation
153  */
154 QDF_STATUS target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev,
155 				       uint8_t mod_id, qdf_dma_addr_t paddr,
156 				       uint32_t *cookie, uint8_t srng_id);
157 
158 /**
159  * target_if_dbr_buf_release() - Notify direct buf that a previously provided
160  *                               buffer can be released.
161  * @pdev: pointer to pdev object
162  * @mod_id: module id indicating the module using direct buffer rx framework
163  * @paddr: Physical address of buffer for which cookie info is required
164  * @cookie: cookie value corresponding to the paddr
165  * @srng_id: srng ID
166  *
167  * Return: QDF status of operation
168  */
169 QDF_STATUS target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev,
170 				     uint8_t mod_id, qdf_dma_addr_t paddr,
171 				     uint32_t cookie, uint8_t srng_id);
172 #endif /* _TARGET_IF_DIRECT_BUF_RX_API_H_ */
173