blob: 8c630b803ab058b6051bdd1a329eee4f084fdf0d [file] [log] [blame]
Mukul Sharmad75a6672017-06-22 15:40:53 +05301/*
2 * Copyright (c) 2017 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 * DOC: target_if_pmo_lphb.c
20 *
21 * Target interface file for pmo component to
22 * send lphb offload related cmd and process event.
23 */
24#ifdef FEATURE_WLAN_LPHB
25
26#include "target_if.h"
27#include "target_if_pmo.h"
28#include "wmi_unified_pmo_api.h"
29
30QDF_STATUS target_if_pmo_send_lphb_enable(struct wlan_objmgr_psoc *psoc,
31 struct pmo_lphb_enable_req *ts_lphb_enable)
32{
33 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
34 int status = 0;
35 wmi_hb_set_enable_cmd_fixed_param hb_enable_fp;
36
37 if (ts_lphb_enable == NULL) {
38 target_if_err("LPHB Enable configuration is NULL");
39 return QDF_STATUS_E_FAILURE;
40 }
41
42 target_if_info("PMO_HB_SET_ENABLE enable=%d, item=%d, session=%d",
43 ts_lphb_enable->enable,
44 ts_lphb_enable->item, ts_lphb_enable->session);
45
46 if ((ts_lphb_enable->item != 1) && (ts_lphb_enable->item != 2)) {
47 target_if_err("LPHB configuration wrong item %d",
48 ts_lphb_enable->item);
49 return QDF_STATUS_E_FAILURE;
50 }
51
52 /* fill in values */
53 hb_enable_fp.vdev_id = ts_lphb_enable->session;
54 hb_enable_fp.enable = ts_lphb_enable->enable;
55 hb_enable_fp.item = ts_lphb_enable->item;
56 hb_enable_fp.session = ts_lphb_enable->session;
57
58 status = wmi_unified_lphb_config_hbenable_cmd(
59 GET_WMI_HDL_FROM_PSOC(psoc),
60 &hb_enable_fp);
61 if (status != EOK) {
62 qdf_status = QDF_STATUS_E_FAILURE;
63 goto error;
64 }
65 return QDF_STATUS_SUCCESS;
66error:
67
68 return qdf_status;
69}
70
71QDF_STATUS target_if_pmo_send_lphb_tcp_params(struct wlan_objmgr_psoc *psoc,
72 struct pmo_lphb_tcp_params *ts_lphb_tcp_param)
73{
74 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
75 int status = 0;
76 wmi_hb_set_tcp_params_cmd_fixed_param hb_tcp_params_fp = {0};
77
78 if (ts_lphb_tcp_param == NULL) {
79 target_if_err("TCP params LPHB configuration is NULL");
80 return QDF_STATUS_E_FAILURE;
81 }
82
83 target_if_info("PMO --> WMI_HB_SET_TCP_PARAMS srv_ip=%08x, "
84 "dev_ip=%08x, src_port=%d, dst_port=%d, timeout=%d, "
85 "session=%d, gateway_mac= %pM, time_period_sec=%d,"
86 "tcp_sn=%d", ts_lphb_tcp_param->srv_ip,
87 ts_lphb_tcp_param->dev_ip, ts_lphb_tcp_param->src_port,
88 ts_lphb_tcp_param->dst_port, ts_lphb_tcp_param->timeout,
89 ts_lphb_tcp_param->session,
90 ts_lphb_tcp_param->gateway_mac.bytes,
91 ts_lphb_tcp_param->time_period_sec, ts_lphb_tcp_param->tcp_sn);
92
93 /* fill in values */
94 hb_tcp_params_fp.vdev_id = ts_lphb_tcp_param->session;
95 hb_tcp_params_fp.srv_ip = ts_lphb_tcp_param->srv_ip;
96 hb_tcp_params_fp.dev_ip = ts_lphb_tcp_param->dev_ip;
97 hb_tcp_params_fp.seq = ts_lphb_tcp_param->tcp_sn;
98 hb_tcp_params_fp.src_port = ts_lphb_tcp_param->src_port;
99 hb_tcp_params_fp.dst_port = ts_lphb_tcp_param->dst_port;
100 hb_tcp_params_fp.interval = ts_lphb_tcp_param->time_period_sec;
101 hb_tcp_params_fp.timeout = ts_lphb_tcp_param->timeout;
102 hb_tcp_params_fp.session = ts_lphb_tcp_param->session;
103 WMI_CHAR_ARRAY_TO_MAC_ADDR(ts_lphb_tcp_param->gateway_mac.bytes,
104 &hb_tcp_params_fp.gateway_mac);
105
106 status = wmi_unified_lphb_config_tcp_params_cmd(
107 GET_WMI_HDL_FROM_PSOC(psoc),
108 &hb_tcp_params_fp);
109 if (status != EOK) {
110 qdf_status = QDF_STATUS_E_FAILURE;
111 goto error;
112 }
113
114 return QDF_STATUS_SUCCESS;
115error:
116 return qdf_status;
117}
118
119QDF_STATUS target_if_pmo_send_lphb_tcp_pkt_filter(struct wlan_objmgr_psoc *psoc,
120 struct pmo_lphb_tcp_filter_req *ts_lphb_tcp_filter)
121{
122 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
123 int status = 0;
124 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param hb_tcp_filter_fp = {0};
125
126 if (ts_lphb_tcp_filter == NULL) {
127 target_if_err("TCP PKT FILTER LPHB configuration is NULL");
128 return QDF_STATUS_E_FAILURE;
129 }
130
131 target_if_info("SET_TCP_PKT_FILTER length=%d, offset=%d, session=%d, "
132 "filter=%2x:%2x:%2x:%2x:%2x:%2x ...",
133 ts_lphb_tcp_filter->length, ts_lphb_tcp_filter->offset,
134 ts_lphb_tcp_filter->session, ts_lphb_tcp_filter->filter[0],
135 ts_lphb_tcp_filter->filter[1], ts_lphb_tcp_filter->filter[2],
136 ts_lphb_tcp_filter->filter[3], ts_lphb_tcp_filter->filter[4],
137 ts_lphb_tcp_filter->filter[5]);
138
139 /* fill in values */
140 hb_tcp_filter_fp.vdev_id = ts_lphb_tcp_filter->session;
141 hb_tcp_filter_fp.length = ts_lphb_tcp_filter->length;
142 hb_tcp_filter_fp.offset = ts_lphb_tcp_filter->offset;
143 hb_tcp_filter_fp.session = ts_lphb_tcp_filter->session;
144 memcpy((void *)&hb_tcp_filter_fp.filter,
145 (void *)&ts_lphb_tcp_filter->filter,
146 WMI_WLAN_HB_MAX_FILTER_SIZE);
147
148 status = wmi_unified_lphb_config_tcp_pkt_filter_cmd(
149 GET_WMI_HDL_FROM_PSOC(psoc),
150 &hb_tcp_filter_fp);
151 if (status != EOK) {
152 qdf_status = QDF_STATUS_E_FAILURE;
153 goto error;
154 }
155
156 return QDF_STATUS_SUCCESS;
157error:
158 return qdf_status;
159}
160
161QDF_STATUS target_if_pmo_send_lphb_udp_params(struct wlan_objmgr_psoc *psoc,
162 struct pmo_lphb_udp_params *ts_lphb_udp_param)
163{
164 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
165 int status = 0;
166 wmi_hb_set_udp_params_cmd_fixed_param hb_udp_params_fp = {0};
167
168 if (ts_lphb_udp_param == NULL) {
169 target_if_err("UDP param for LPHB configuration is NULL");
170 return QDF_STATUS_E_FAILURE;
171 }
172
173 target_if_info("HB_SET_UDP_PARAMS srv_ip=%d, dev_ip=%d, src_port=%d, "
174 "dst_port=%d, interval=%d, timeout=%d, session=%d, "
175 "gateway_mac= %pM",
176 ts_lphb_udp_param->srv_ip, ts_lphb_udp_param->dev_ip,
177 ts_lphb_udp_param->src_port, ts_lphb_udp_param->dst_port,
178 ts_lphb_udp_param->interval, ts_lphb_udp_param->timeout,
179 ts_lphb_udp_param->session,
180 ts_lphb_udp_param->gateway_mac.bytes);
181
182 /* fill in values */
183 hb_udp_params_fp.vdev_id = ts_lphb_udp_param->session;
184 hb_udp_params_fp.srv_ip = ts_lphb_udp_param->srv_ip;
185 hb_udp_params_fp.dev_ip = ts_lphb_udp_param->dev_ip;
186 hb_udp_params_fp.src_port = ts_lphb_udp_param->src_port;
187 hb_udp_params_fp.dst_port = ts_lphb_udp_param->dst_port;
188 hb_udp_params_fp.interval = ts_lphb_udp_param->interval;
189 hb_udp_params_fp.timeout = ts_lphb_udp_param->timeout;
190 hb_udp_params_fp.session = ts_lphb_udp_param->session;
191 WMI_CHAR_ARRAY_TO_MAC_ADDR(ts_lphb_udp_param->gateway_mac.bytes,
192 &hb_udp_params_fp.gateway_mac);
193
194 status = wmi_unified_lphb_config_udp_params_cmd(
195 GET_WMI_HDL_FROM_PSOC(psoc),
196 &hb_udp_params_fp);
197 if (status != EOK) {
198 qdf_status = QDF_STATUS_E_FAILURE;
199 goto error;
200 }
201
202 return QDF_STATUS_SUCCESS;
203error:
204 return qdf_status;
205}
206
207/**
208 * target_if_pmo_lphb_send_udp_pkt_filter() - Send LPHB udp pkt filter req
209 * @psoc: objmgr psoc handle
210 * @ts_lphb_udp_filter: lphb udp filter request which needs to configure in fwr
211 *
212 * Return: QDF status
213 */
214QDF_STATUS target_if_pmo_send_lphb_udp_pkt_filter(struct wlan_objmgr_psoc *psoc,
215 struct pmo_lphb_udp_filter_req *ts_lphb_udp_filter)
216{
217 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
218 int status = 0;
219 wmi_hb_set_udp_pkt_filter_cmd_fixed_param hb_udp_filter_fp = {0};
220
221 if (ts_lphb_udp_filter == NULL) {
222 target_if_err("LPHB UDP packet filter configuration is NULL");
223 return QDF_STATUS_E_FAILURE;
224 }
225
226 target_if_info("SET_UDP_PKT_FILTER length=%d, offset=%d, session=%d, "
227 "filter=%2x:%2x:%2x:%2x:%2x:%2x ...",
228 ts_lphb_udp_filter->length, ts_lphb_udp_filter->offset,
229 ts_lphb_udp_filter->session, ts_lphb_udp_filter->filter[0],
230 ts_lphb_udp_filter->filter[1], ts_lphb_udp_filter->filter[2],
231 ts_lphb_udp_filter->filter[3], ts_lphb_udp_filter->filter[4],
232 ts_lphb_udp_filter->filter[5]);
233
234 /* fill in values */
235 hb_udp_filter_fp.vdev_id = ts_lphb_udp_filter->session;
236 hb_udp_filter_fp.length = ts_lphb_udp_filter->length;
237 hb_udp_filter_fp.offset = ts_lphb_udp_filter->offset;
238 hb_udp_filter_fp.session = ts_lphb_udp_filter->session;
239 qdf_mem_copy((void *)&hb_udp_filter_fp.filter,
240 (void *)&ts_lphb_udp_filter->filter,
241 WMI_WLAN_HB_MAX_FILTER_SIZE);
242
243 status = wmi_unified_lphb_config_udp_pkt_filter_cmd(
244 GET_WMI_HDL_FROM_PSOC(psoc),
245 &hb_udp_filter_fp);
246 if (status != EOK) {
247 qdf_status = QDF_STATUS_E_FAILURE;
248 goto error;
249 }
250
251 return QDF_STATUS_SUCCESS;
252error:
253 return qdf_status;
254}
255
256QDF_STATUS target_if_pmo_lphb_evt_handler(struct wlan_objmgr_psoc *psoc,
257 uint8_t *event)
258{
259 wmi_hb_ind_event_fixed_param *hb_fp;
260 struct pmo_lphb_rsp *slphb_indication = NULL;
261 QDF_STATUS qdf_status;
262
263 TARGET_IF_ENTER();
264 if (!psoc) {
265 target_if_err("psoc ptr is NULL");
266 qdf_status = QDF_STATUS_E_NULL_VALUE;
267 goto out;
268 }
269
270 hb_fp = (wmi_hb_ind_event_fixed_param *) event;
271 if (!hb_fp) {
272 target_if_err("Invalid wmi_hb_ind_event_fixed_param buffer");
273 qdf_status = QDF_STATUS_E_INVAL;
274 goto out;
275 }
276
277 target_if_debug("lphb indication received with\n"
278 "vdev_id=%d, session=%d, reason=%d",
279 hb_fp->vdev_id, hb_fp->session, hb_fp->reason);
280
281 slphb_indication = (struct pmo_lphb_rsp *)qdf_mem_malloc(
282 sizeof(struct pmo_lphb_rsp));
283
284 if (!slphb_indication) {
285 target_if_err("Invalid LPHB indication buffer");
286 qdf_status = QDF_STATUS_E_NOMEM;
287 goto out;
288 }
289
290 slphb_indication->session_idx = hb_fp->session;
291 slphb_indication->protocol_type = hb_fp->reason;
292 slphb_indication->event_reason = hb_fp->reason;
293
294 qdf_status = pmo_tgt_lphb_rsp_evt(psoc, slphb_indication);
295 if (qdf_status != QDF_STATUS_SUCCESS)
296 target_if_err("Failed to lphb_rsp_event");
297out:
298 if (slphb_indication)
299 qdf_mem_free(slphb_indication);
300
301 return qdf_status;
302}
303#endif
304