xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/hif_main_legacy.c (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2013-2018, 2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "qdf_lock.h"
21 #include "qdf_status.h"
22 #include "qdf_module.h"
23 #include "hif_main.h"
24 
25 #if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB)
26 #include "ce_api.h"
27 #include "ce_internal.h"
28 #endif
29 
30 #ifdef WLAN_FEATURE_FASTPATH
31 /**
32  * hif_send_fast() - API to access hif specific function ce_send_fast().
33  * @osc: HIF Context
34  * @nbuf: netork buffer to send
35  * @transfer_id: transfer id
36  * @download_len: download length
37  *
38  * Return: No. of packets that could be sent
39  */
40 int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
41 		  uint32_t transfer_id, uint32_t download_len)
42 {
43 	void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE);
44 
45 	return ce_send_fast((struct CE_handle *)ce_tx_hdl, nbuf,
46 			transfer_id, download_len);
47 }
48 
49 qdf_export_symbol(hif_send_fast);
50 
51 /**
52  * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
53  * @hif_ctx: HIF context
54  * @handler: Callback funtcion
55  * @context: handle for callback function
56  *
57  * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
58  */
59 QDF_STATUS hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
60 				       fastpath_msg_handler handler,
61 				       void *context)
62 {
63 	struct CE_state *ce_state;
64 	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
65 	int i;
66 
67 	if (!scn) {
68 		hif_err("scn is NULL");
69 		QDF_ASSERT(0);
70 		return QDF_STATUS_E_FAILURE;
71 	}
72 
73 	if (!scn->fastpath_mode_on) {
74 		hif_warn("Fastpath mode disabled");
75 		return QDF_STATUS_E_FAILURE;
76 	}
77 
78 	for (i = 0; i < scn->ce_count; i++) {
79 		ce_state = scn->ce_id_to_state[i];
80 		if (ce_state->htt_rx_data) {
81 			ce_state->fastpath_handler = handler;
82 			ce_state->context = context;
83 			ce_state->service = ce_per_engine_service_fast;
84 		}
85 	}
86 
87 	return QDF_STATUS_SUCCESS;
88 }
89 
90 qdf_export_symbol(hif_ce_fastpath_cb_register);
91 #endif
92