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 defined(HIF_IPCI)
27 #include "ce_api.h"
28 #include "ce_internal.h"
29 #endif
30
31 #ifdef WLAN_FEATURE_FASTPATH
32 /**
33 * hif_send_fast() - API to access hif specific function ce_send_fast().
34 * @osc: HIF Context
35 * @nbuf: netork buffer to send
36 * @transfer_id: transfer id
37 * @download_len: download length
38 *
39 * Return: No. of packets that could be sent
40 */
hif_send_fast(struct hif_opaque_softc * osc,qdf_nbuf_t nbuf,uint32_t transfer_id,uint32_t download_len)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 * @hif_ctx: HIF context
55 * @handler: Callback function
56 * @context: handle for callback function
57 *
58 * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
59 */
hif_ce_fastpath_cb_register(struct hif_opaque_softc * hif_ctx,fastpath_msg_handler handler,void * context)60 QDF_STATUS hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
61 fastpath_msg_handler handler,
62 void *context)
63 {
64 struct CE_state *ce_state;
65 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
66 int i;
67
68 if (!scn) {
69 hif_err("scn is NULL");
70 QDF_ASSERT(0);
71 return QDF_STATUS_E_FAILURE;
72 }
73
74 if (!scn->fastpath_mode_on) {
75 hif_warn("Fastpath mode disabled");
76 return QDF_STATUS_E_FAILURE;
77 }
78
79 for (i = 0; i < scn->ce_count; i++) {
80 ce_state = scn->ce_id_to_state[i];
81 if (ce_state->htt_rx_data) {
82 ce_state->fastpath_handler = handler;
83 ce_state->context = context;
84 ce_state->service = ce_per_engine_service_fast;
85 }
86 }
87
88 return QDF_STATUS_SUCCESS;
89 }
90
91 qdf_export_symbol(hif_ce_fastpath_cb_register);
92 #endif
93