xref: /wlan-driver/qcacld-3.0/components/target_if/pmo/src/target_if_pmo_wow.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
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  * DOC: target_if_pmo_wow.c
20  *
21  * Target interface file for pmo component to
22  * send wow related cmd and process event.
23  */
24 
25 
26 #include "target_if.h"
27 #include "target_if_pmo.h"
28 #include "wmi_unified_api.h"
29 
target_if_pmo_enable_wow_wakeup_event(struct wlan_objmgr_vdev * vdev,uint32_t * bitmap)30 QDF_STATUS target_if_pmo_enable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev,
31 		uint32_t *bitmap)
32 {
33 	uint8_t vdev_id;
34 	struct wlan_objmgr_psoc *psoc;
35 	QDF_STATUS status;
36 	wmi_unified_t wmi_handle;
37 
38 	if (!vdev) {
39 		target_if_err("vdev ptr passed is NULL");
40 		return QDF_STATUS_E_INVAL;
41 	}
42 
43 	psoc = wlan_vdev_get_psoc(vdev);
44 	vdev_id = wlan_vdev_get_id(vdev);
45 	if (!psoc) {
46 		target_if_err("psoc handle is NULL");
47 		return QDF_STATUS_E_INVAL;
48 	}
49 
50 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
51 	if (!wmi_handle) {
52 		target_if_err("Invalid wmi handle");
53 		return QDF_STATUS_E_INVAL;
54 	}
55 
56 	status = wmi_unified_add_wow_wakeup_event_cmd(wmi_handle, vdev_id,
57 						      bitmap, true);
58 	if (status)
59 		target_if_err("Failed to config wow wakeup event");
60 
61 	return status;
62 }
63 
target_if_pmo_disable_wow_wakeup_event(struct wlan_objmgr_vdev * vdev,uint32_t * bitmap)64 QDF_STATUS target_if_pmo_disable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev,
65 		uint32_t *bitmap)
66 {
67 	uint8_t vdev_id;
68 	struct wlan_objmgr_psoc *psoc;
69 	QDF_STATUS status;
70 	wmi_unified_t wmi_handle;
71 
72 	if (!vdev) {
73 		target_if_err("vdev ptr passed is NULL");
74 		return QDF_STATUS_E_INVAL;
75 	}
76 
77 	psoc = wlan_vdev_get_psoc(vdev);
78 	vdev_id = wlan_vdev_get_id(vdev);
79 	if (!psoc) {
80 		target_if_err("psoc handle is NULL");
81 		return QDF_STATUS_E_INVAL;
82 	}
83 
84 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
85 	if (!wmi_handle) {
86 		target_if_err("Invalid wmi handle");
87 		return QDF_STATUS_E_INVAL;
88 	}
89 
90 	status = wmi_unified_add_wow_wakeup_event_cmd(wmi_handle, vdev_id,
91 						      bitmap, false);
92 	if (status)
93 		target_if_err("Failed to config wow wakeup event");
94 
95 	return status;
96 }
97 
target_if_pmo_send_wow_patterns_to_fw(struct wlan_objmgr_vdev * vdev,uint8_t ptrn_id,const uint8_t * ptrn,uint8_t ptrn_len,uint8_t ptrn_offset,const uint8_t * mask,uint8_t mask_len,bool user)98 QDF_STATUS target_if_pmo_send_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev,
99 		uint8_t ptrn_id,
100 		const uint8_t *ptrn, uint8_t ptrn_len,
101 		uint8_t ptrn_offset, const uint8_t *mask,
102 		uint8_t mask_len, bool user)
103 {
104 	uint8_t vdev_id;
105 	struct wlan_objmgr_psoc *psoc;
106 	QDF_STATUS status;
107 	wmi_unified_t wmi_handle;
108 
109 	if (!vdev) {
110 		target_if_err("vdev ptr passed is NULL");
111 		return QDF_STATUS_E_INVAL;
112 	}
113 
114 	psoc = wlan_vdev_get_psoc(vdev);
115 	vdev_id = wlan_vdev_get_id(vdev);
116 	if (!psoc) {
117 		target_if_err("psoc handle is NULL");
118 		return QDF_STATUS_E_INVAL;
119 	}
120 
121 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
122 	if (!wmi_handle) {
123 		target_if_err("Invalid wmi handle");
124 		return QDF_STATUS_E_INVAL;
125 	}
126 
127 	status = wmi_unified_wow_patterns_to_fw_cmd(wmi_handle,
128 						    vdev_id, ptrn_id, ptrn,
129 						    ptrn_len, ptrn_offset,
130 						    mask, mask_len, user, 0);
131 
132 	return status;
133 }
134 
target_if_pmo_del_wow_patterns_to_fw(struct wlan_objmgr_vdev * vdev,uint8_t ptrn_id)135 QDF_STATUS target_if_pmo_del_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev,
136 		uint8_t ptrn_id)
137 {
138 	uint8_t vdev_id;
139 	struct wlan_objmgr_psoc *psoc;
140 	QDF_STATUS status;
141 	wmi_unified_t wmi_handle;
142 
143 	if (!vdev) {
144 		target_if_err("vdev ptr passed is NULL");
145 		return QDF_STATUS_E_INVAL;
146 	}
147 
148 	psoc = wlan_vdev_get_psoc(vdev);
149 	vdev_id = wlan_vdev_get_id(vdev);
150 	if (!psoc) {
151 		target_if_err("psoc handle is NULL");
152 		return QDF_STATUS_E_INVAL;
153 	}
154 
155 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
156 	if (!wmi_handle) {
157 		target_if_err("Invalid wmi handle");
158 		return QDF_STATUS_E_INVAL;
159 	}
160 
161 	status = wmi_unified_wow_delete_pattern_cmd(wmi_handle, ptrn_id,
162 						    vdev_id);
163 
164 	return status;
165 }
166 
167