1 /*
2  * Copyright (c) 2017-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 /**
20  * DOC: Implements public API for pmo low power hear beat feature
21  * to interact with target/WMI.
22  */
23 
24 #include "wlan_pmo_tgt_api.h"
25 #include "wlan_pmo_lphb_public_struct.h"
26 #include "wlan_pmo_obj_mgmt_public_struct.h"
27 #include "wlan_pmo_main.h"
28 
pmo_tgt_send_lphb_enable(struct wlan_objmgr_psoc * psoc,struct pmo_lphb_enable_req * ts_lphb_enable)29 QDF_STATUS pmo_tgt_send_lphb_enable(struct wlan_objmgr_psoc *psoc,
30 		struct pmo_lphb_enable_req *ts_lphb_enable)
31 {
32 	QDF_STATUS status;
33 	struct wlan_pmo_tx_ops pmo_tx_ops;
34 
35 	pmo_enter();
36 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
37 	if (!pmo_tx_ops.send_lphb_enable) {
38 		pmo_err("send_lphb_enable is null");
39 		status = QDF_STATUS_E_NULL_VALUE;
40 		goto out;
41 	}
42 	status = pmo_tx_ops.send_lphb_enable(psoc, ts_lphb_enable);
43 	if (status != QDF_STATUS_SUCCESS)
44 		pmo_err("Failed to send lphb enable");
45 out:
46 	pmo_exit();
47 
48 	return status;
49 }
50 
pmo_tgt_send_lphb_tcp_params(struct wlan_objmgr_psoc * psoc,struct pmo_lphb_tcp_params * ts_lphb_tcp_param)51 QDF_STATUS pmo_tgt_send_lphb_tcp_params(struct wlan_objmgr_psoc *psoc,
52 		struct pmo_lphb_tcp_params *ts_lphb_tcp_param)
53 {
54 	QDF_STATUS status;
55 	struct wlan_pmo_tx_ops pmo_tx_ops;
56 
57 	pmo_enter();
58 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
59 	if (!pmo_tx_ops.send_lphb_tcp_params) {
60 		pmo_err("send_lphb_tcp_params is null");
61 		status = QDF_STATUS_E_NULL_VALUE;
62 		goto out;
63 	}
64 	status = pmo_tx_ops.send_lphb_tcp_params(psoc, ts_lphb_tcp_param);
65 	if (status != QDF_STATUS_SUCCESS)
66 		pmo_err("Failed to send lphb tcp params");
67 out:
68 	pmo_exit();
69 
70 	return status;
71 }
72 
pmo_tgt_send_lphb_tcp_pkt_filter(struct wlan_objmgr_psoc * psoc,struct pmo_lphb_tcp_filter_req * ts_lphb_tcp_filter)73 QDF_STATUS pmo_tgt_send_lphb_tcp_pkt_filter(struct wlan_objmgr_psoc *psoc,
74 		struct pmo_lphb_tcp_filter_req *ts_lphb_tcp_filter)
75 {
76 	QDF_STATUS status;
77 	struct wlan_pmo_tx_ops pmo_tx_ops;
78 
79 	pmo_enter();
80 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
81 	if (!pmo_tx_ops.send_lphb_tcp_filter_req) {
82 		pmo_err("send_lphb_tcp_filter_req is null");
83 		status = QDF_STATUS_E_NULL_VALUE;
84 		goto out;
85 	}
86 	status = pmo_tx_ops.send_lphb_tcp_filter_req(psoc, ts_lphb_tcp_filter);
87 	if (status != QDF_STATUS_SUCCESS)
88 		pmo_err("Failed to send lphb tcp filter req");
89 out:
90 	pmo_exit();
91 
92 	return status;
93 }
94 
pmo_tgt_send_lphb_udp_params(struct wlan_objmgr_psoc * psoc,struct pmo_lphb_udp_params * ts_lphb_udp_param)95 QDF_STATUS pmo_tgt_send_lphb_udp_params(struct wlan_objmgr_psoc *psoc,
96 		struct pmo_lphb_udp_params *ts_lphb_udp_param)
97 {
98 	QDF_STATUS status;
99 	struct wlan_pmo_tx_ops pmo_tx_ops;
100 
101 	pmo_enter();
102 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
103 	if (!pmo_tx_ops.send_lphb_upd_params) {
104 		pmo_err("send_lphb_upd_params is null");
105 		status = QDF_STATUS_E_NULL_VALUE;
106 		goto out;
107 	}
108 	status = pmo_tx_ops.send_lphb_upd_params(psoc, ts_lphb_udp_param);
109 	if (status != QDF_STATUS_SUCCESS)
110 		pmo_err("Failed to send lphb udp param");
111 out:
112 	pmo_exit();
113 
114 	return status;
115 }
116 
pmo_tgt_send_lphb_udp_pkt_filter(struct wlan_objmgr_psoc * psoc,struct pmo_lphb_udp_filter_req * ts_lphb_udp_filter)117 QDF_STATUS pmo_tgt_send_lphb_udp_pkt_filter(struct wlan_objmgr_psoc *psoc,
118 		struct pmo_lphb_udp_filter_req *ts_lphb_udp_filter)
119 {
120 	QDF_STATUS status;
121 	struct wlan_pmo_tx_ops pmo_tx_ops;
122 
123 	pmo_enter();
124 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
125 	if (!pmo_tx_ops.send_lphb_udp_filter_req) {
126 		pmo_err("send_lphb_udp_filter_req is null");
127 		status = QDF_STATUS_E_NULL_VALUE;
128 		goto out;
129 	}
130 	status = pmo_tx_ops.send_lphb_udp_filter_req(psoc, ts_lphb_udp_filter);
131 	if (status != QDF_STATUS_SUCCESS)
132 		pmo_err("Failed to send lphb udp filter req");
133 out:
134 	pmo_exit();
135 
136 	return status;
137 }
138 
pmo_tgt_lphb_rsp_evt(struct wlan_objmgr_psoc * psoc,struct pmo_lphb_rsp * rsp_param)139 QDF_STATUS pmo_tgt_lphb_rsp_evt(struct wlan_objmgr_psoc *psoc,
140 			struct pmo_lphb_rsp *rsp_param)
141 {
142 	struct pmo_psoc_priv_obj *psoc_ctx;
143 
144 	psoc_ctx = pmo_psoc_get_priv(psoc);
145 	if (psoc_ctx->wow.lphb_cb && psoc_ctx->wow.lphb_cb_ctx) {
146 		psoc_ctx->wow.lphb_cb(psoc_ctx->wow.lphb_cb_ctx, rsp_param);
147 	} else {
148 		pmo_err("lphb rsp callback/context is null for psoc %pK",
149 			psoc);
150 	}
151 
152 	return QDF_STATUS_SUCCESS;
153 }
154 
155