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