xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/hif_main_legacy.c (revision 1397a33f48ea6455be40871470b286e535820eb8)
1 /*
2  * Copyright (c) 2013-2018 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 #include "qdf_lock.h"
20 #include "qdf_status.h"
21 #include "qdf_module.h"
22 #include "hif_main.h"
23 
24 #if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB)
25 #include "ce_api.h"
26 #include "ce_internal.h"
27 #endif
28 
29 #ifdef WLAN_FEATURE_FASTPATH
30 /**
31  * hif_send_fast() - API to access hif specific function
32  * ce_send_fast.
33  * @osc: HIF Context
34  * @msdu : array of msdus to be sent
35  * @num_msdus : number of msdus in an array
36  * @transfer_id: transfer id
37  * @download_len: download length
38  *
39  * Return: No. of packets that could be sent
40  */
41 int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
42 		  uint32_t transfer_id, uint32_t download_len)
43 {
44 	void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE);
45 
46 	return ce_send_fast((struct CE_handle *)ce_tx_hdl, nbuf,
47 			transfer_id, download_len);
48 }
49 
50 qdf_export_symbol(hif_send_fast);
51 
52 /**
53  * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
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 int 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_ERROR("%s: scn is NULL", __func__);
69 		QDF_ASSERT(0);
70 		return QDF_STATUS_E_FAILURE;
71 	}
72 
73 	if (!scn->fastpath_mode_on) {
74 		HIF_WARN("%s: Fastpath mode disabled", __func__);
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