xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/ipci_api.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7 
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _IPCI_API_H_
18 #define _IPCI_API_H_
19 struct hif_exec_context;
20 
21 /**
22  * hif_ipci_open(): hif_bus_open
23  * @hif_ctx: hif context
24  * @bus_type: bus type
25  *
26  * Return: 0 for success or QDF_STATUS_E_NOMEM
27  */
28 QDF_STATUS hif_ipci_open(struct hif_softc *hif_ctx,
29 			 enum qdf_bus_type bus_type);
30 
31 /**
32  * hif_ipci_close(): hif_bus_close
33  * @hif_ctx: hif context
34  *
35  * Return: n/a
36  */
37 void hif_ipci_close(struct hif_softc *hif_ctx);
38 
39 /**
40  * hif_bus_prevent_linkdown(): allow or permit linkdown
41  * @scn: struct hif_softc
42  * @flag: true prevents linkdown, false allows
43  *
44  * Calls into the platform driver to vote against taking down the
45  * pcie link.
46  *
47  * Return: n/a
48  */
49 void hif_ipci_prevent_linkdown(struct hif_softc *scn, bool flag);
50 
51 /**
52  * hif_ipci_bus_suspend(): prepare hif for suspend
53  * @scn: struct hif_softc
54  *
55  * Return: Errno
56  */
57 int hif_ipci_bus_suspend(struct hif_softc *scn);
58 
59 /**
60  * hif_ipci_bus_suspend_noirq() - ensure there are no pending transactions
61  * @scn: hif context
62  *
63  * Ensure that if we received the wakeup message before the irq
64  * was disabled that the message is pocessed before suspending.
65  *
66  * Return: -EBUSY if we fail to flush the tasklets.
67  */
68 int hif_ipci_bus_suspend_noirq(struct hif_softc *scn);
69 
70 /**
71  * hif_ipci_bus_resume(): prepare hif for resume
72  * @scn: struct hif_softc
73  *
74  * Return: Errno
75  */
76 int hif_ipci_bus_resume(struct hif_softc *scn);
77 
78 /**
79  * hif_ipci_bus_resume_noirq() - ensure there are no pending transactions
80  * @scn: hif context
81  *
82  * Ensure that if we received the wakeup message before the irq
83  * was disabled that the message is pocessed before suspending.
84  *
85  * Return: -EBUSY if we fail to flush the tasklets.
86  */
87 int hif_ipci_bus_resume_noirq(struct hif_softc *scn);
88 
89 /**
90  * hif_ipci_disable_isr(): disable interrupt
91  * @scn: struct hif_softc
92  *
93  * Return: n/a
94  */
95 void hif_ipci_disable_isr(struct hif_softc *scn);
96 
97 /**
98  * hif_ipci_nointrs(): disable IRQ
99  * @scn: struct hif_softc
100  *
101  * This function stops interrupt(s)
102  *
103  * Return: none
104  */
105 void hif_ipci_nointrs(struct hif_softc *scn);
106 
107 /**
108  * hif_ipci_dump_registers(): dump bus debug registers
109  * @scn: struct hif_opaque_softc
110  *
111  * This function dumps hif bus debug registers
112  *
113  * Return: 0 for success or error code
114  */
115 int hif_ipci_dump_registers(struct hif_softc *scn);
116 
117 /**
118  * hif_ipci_enable_bus(): enable bus
119  *
120  * This function enables the bus
121  *
122  * @ol_sc: soft_sc struct
123  * @dev: device pointer
124  * @bdev: bus dev pointer
125  * bid: bus id pointer
126  * type: enum hif_enable_type such as HIF_ENABLE_TYPE_PROBE
127  * Return: QDF_STATUS
128  */
129 QDF_STATUS hif_ipci_enable_bus(
130 			struct hif_softc *scn,
131 			struct device *dev, void *bdev,
132 			const struct hif_bus_id *bid,
133 			enum hif_enable_type type);
134 
135 /**
136  * hif_ipci_disable_bus(): hif_disable_bus
137  *
138  * This function disables the bus
139  *
140  * @scn: struct hif_softc
141  *
142  * Return: none
143  */
144 void hif_ipci_disable_bus(struct hif_softc *scn);
145 
146 #ifdef FEATURE_RUNTIME_PM
147 /**
148  * hif_ipci_get_rpm_ctx() - Map corresponding hif_runtime_pm_ctx
149  * @scn: hif context
150  *
151  * This function will map and return the corresponding
152  * hif_runtime_pm_ctx based on ipcie interface.
153  *
154  * Return: struct hif_runtime_pm_ctx pointer
155  */
156 struct hif_runtime_pm_ctx *hif_ipci_get_rpm_ctx(struct hif_softc *hif_sc);
157 
158 /**
159  * hif_ipci_get_dev() - Map corresponding device structure
160  * @scn: hif context
161  *
162  * This function will map and return the corresponding
163  * device structure based on ipcie interface.
164  *
165  * Return: struct device pointer
166  */
167 struct device *hif_ipci_get_dev(struct hif_softc *hif_sc);
168 #endif
169 
170 /**
171  * hif_ipci_bus_configure() - configure the pcie bus
172  * @hif_sc: pointer to the hif context.
173  *
174  * return: 0 for success. nonzero for failure.
175  */
176 int hif_ipci_bus_configure(struct hif_softc *scn);
177 
178 /**
179  * hif_ipci_enable_power_management() - enable power management
180  * @hif_ctx: hif context
181  * @is_packet_log_enabled: pktlog enabled or disabled
182  *
183  * Return: none
184  */
185 void hif_ipci_enable_power_management(
186 				struct hif_softc *hif_ctx,
187 				bool is_packet_log_enabled);
188 
189 /**
190  * hif_ipci_disable_power_management() - disable power management
191  * @hif_ctx: hif context
192  *
193  * Return: none
194  */
195 void hif_ipci_disable_power_management(struct hif_softc *hif_ctx);
196 
197 /**
198  * hif_ipci_configure_grp_irq() - configure HW block irq
199  * @scn: hif context
200  * @exec: hif exec context
201  *
202  * Return:Errno
203  */
204 int hif_ipci_configure_grp_irq(
205 			struct hif_softc *scn,
206 			struct hif_exec_context *exec);
207 
208 /**
209  * hif_ipci_deconfigure_grp_irq() - deconfigure HW block irq
210  * @scn: hif context
211  *
212  * Return: None
213  */
214 void hif_ipci_deconfigure_grp_irq(struct hif_softc *scn);
215 
216 /**
217  * hif_ipci_display_stats() - display stats
218  * @hif_ctx: hif context
219  *
220  * Return: none
221  */
222 void hif_ipci_display_stats(struct hif_softc *hif_ctx);
223 
224 /**
225  * hif_ipci_clear_stats() - clear stats
226  * @hif_ctx: hif context
227  *
228  * Return: none
229  */
230 void hif_ipci_clear_stats(struct hif_softc *hif_ctx);
231 
232 /**
233  * hif_ipci_needs_bmi() - return true if the soc needs bmi through the driver
234  * @scn: hif context
235  *
236  * Return: true if soc needs driver bmi otherwise false
237  */
238 bool hif_ipci_needs_bmi(struct hif_softc *scn);
239 
240 /**
241  * hif_ipci_get_irq_name() - get irqname
242  * This function gives irqnumber to irqname
243  * mapping.
244  *
245  * @irq_no: irq number
246  *
247  * Return: irq name
248  */
249 const char *hif_ipci_get_irq_name(int irq_no);
250 
251 /**
252  * hif_ipci_enable_grp_irqs(): enable grp IRQs
253  * @scn: struct hif_softc
254  *
255  * This function enables grp irqs
256  *
257  * Return: 0 if success, error code if failure
258  */
259 int hif_ipci_enable_grp_irqs(struct hif_softc *scn);
260 
261 #ifdef HIF_CPU_PERF_AFFINE_MASK
262 /** hif_ipci_config_irq_affinity() - set the irq affinity
263  * @scn: hif context
264  *
265  * set irq affinity hint for wlan irqs to gold cores only for
266  * defconfig builds.
267  *
268  * return: none
269  */
270 void hif_ipci_config_irq_affinity(struct hif_softc *scn);
271 #endif
272 
273 #ifdef HIF_CPU_CLEAR_AFFINITY
274 /**
275  * hif_ipci_config_irq_clear_cpu_affinity() - Remove cpu affinity of IRQ
276  * @scn: HIF handle
277  * @intr_ctxt_id: interrupt group index
278  * @cpu: CPU core to clear
279  *
280  * Return: None
281  */
282 void hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc *scn,
283 					    int intr_ctxt_id, int cpu);
284 #else
285 static inline
286 void hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc *scn,
287 					    int intr_ctxt_id, int cpu)
288 {
289 }
290 #endif
291 
292 /**
293  * hif_ipci_disable_grp_irqs(): disable grp IRQs
294  * @scn: struct hif_softc
295  *
296  * This function disables grp irqs
297  *
298  * Return: 0 if success, error code if failure
299  */
300 int hif_ipci_disable_grp_irqs(struct hif_softc *scn);
301 #endif /* _IPCI_API_H_ */
302