xref: /wlan-driver/qcacld-3.0/components/pmo/dispatcher/src/wlan_pmo_tgt_wow.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2018, 2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022, 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 /**
21  * DOC: Implements public API for pmo to interact with target/WMI
22  */
23 
24 #include "wlan_pmo_tgt_api.h"
25 #include "wlan_pmo_wow.h"
26 #include "wlan_pmo_obj_mgmt_public_struct.h"
27 #include "wlan_pmo_main.h"
28 
pmo_tgt_enable_wow_wakeup_event(struct wlan_objmgr_vdev * vdev,uint32_t * bitmap)29 QDF_STATUS pmo_tgt_enable_wow_wakeup_event(
30 		struct wlan_objmgr_vdev *vdev,
31 		uint32_t *bitmap)
32 {
33 	QDF_STATUS status;
34 	struct wlan_objmgr_psoc *psoc;
35 	struct wlan_pmo_tx_ops pmo_tx_ops;
36 	int vdev_id;
37 
38 	psoc = pmo_vdev_get_psoc(vdev);
39 	vdev_id = pmo_vdev_get_id(vdev);
40 
41 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
42 	if (!pmo_tx_ops.send_enable_wow_wakeup_event_req) {
43 		pmo_err("send_enable_wow_wakeup_event_req is null");
44 		status = QDF_STATUS_E_NULL_VALUE;
45 		goto out;
46 	}
47 
48 	pmo_debug("Enable wakeup events 0x%08x%08x%08x%08x for vdev_id %d",
49 		  bitmap[3], bitmap[2], bitmap[1], bitmap[0], vdev_id);
50 
51 	status = pmo_tx_ops.send_enable_wow_wakeup_event_req(vdev, bitmap);
52 	if (status != QDF_STATUS_SUCCESS)
53 		pmo_err("Failed to enable wow wakeup event");
54 out:
55 
56 	return status;
57 }
58 
pmo_tgt_disable_wow_wakeup_event(struct wlan_objmgr_vdev * vdev,uint32_t * bitmap)59 QDF_STATUS pmo_tgt_disable_wow_wakeup_event(
60 		struct wlan_objmgr_vdev *vdev,
61 		uint32_t *bitmap)
62 {
63 	QDF_STATUS status;
64 	struct wlan_objmgr_psoc *psoc;
65 	struct wlan_pmo_tx_ops pmo_tx_ops;
66 	int vdev_id;
67 
68 	psoc = pmo_vdev_get_psoc(vdev);
69 	vdev_id = pmo_vdev_get_id(vdev);
70 
71 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
72 	if (!pmo_tx_ops.send_disable_wow_wakeup_event_req) {
73 		pmo_err("send_disable_wow_wakeup_event_req is null");
74 		status = QDF_STATUS_E_NULL_VALUE;
75 		goto out;
76 	}
77 
78 	pmo_debug("Disable wakeup events 0x%x%x%x%x for vdev_id %d",
79 		  bitmap[3], bitmap[2], bitmap[1], bitmap[0], vdev_id);
80 
81 	status = pmo_tx_ops.send_disable_wow_wakeup_event_req(vdev, bitmap);
82 	if (status != QDF_STATUS_SUCCESS)
83 		pmo_err("Failed to disable wow wakeup event");
84 out:
85 
86 	return status;
87 }
88 
pmo_tgt_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)89 QDF_STATUS pmo_tgt_send_wow_patterns_to_fw(
90 		struct wlan_objmgr_vdev *vdev, uint8_t ptrn_id,
91 		const uint8_t *ptrn, uint8_t ptrn_len,
92 		uint8_t ptrn_offset, const uint8_t *mask,
93 		uint8_t mask_len, bool user)
94 {
95 	QDF_STATUS status;
96 	struct pmo_vdev_priv_obj *vdev_ctx;
97 	struct wlan_objmgr_psoc *psoc;
98 	struct wlan_pmo_tx_ops pmo_tx_ops;
99 
100 	psoc = pmo_vdev_get_psoc(vdev);
101 
102 	vdev_ctx = pmo_vdev_get_priv(vdev);
103 
104 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
105 	if (!pmo_tx_ops.send_add_wow_pattern) {
106 		pmo_err("send_add_wow_pattern is null");
107 		status = QDF_STATUS_E_NULL_VALUE;
108 		goto out;
109 	}
110 	status = pmo_tx_ops.send_add_wow_pattern(
111 				vdev, ptrn_id, ptrn,
112 				ptrn_len, ptrn_offset, mask,
113 				mask_len, user);
114 	if (status != QDF_STATUS_SUCCESS) {
115 		if (!user)
116 			pmo_decrement_wow_default_ptrn(vdev_ctx);
117 		pmo_err("Failed to send wow pattern event");
118 		goto out;
119 	}
120 
121 	if (user)
122 		pmo_increment_wow_user_ptrn(vdev_ctx);
123 out:
124 
125 	return status;
126 }
127 
pmo_tgt_del_wow_pattern(struct wlan_objmgr_vdev * vdev,uint8_t ptrn_id,bool user)128 QDF_STATUS pmo_tgt_del_wow_pattern(
129 		struct wlan_objmgr_vdev *vdev, uint8_t ptrn_id,
130 		bool user)
131 {
132 	QDF_STATUS status;
133 	struct pmo_vdev_priv_obj *vdev_ctx;
134 	struct wlan_objmgr_psoc *psoc;
135 	struct wlan_pmo_tx_ops pmo_tx_ops;
136 
137 	psoc = pmo_vdev_get_psoc(vdev);
138 	vdev_ctx = pmo_vdev_get_priv(vdev);
139 
140 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
141 	if (!pmo_tx_ops.del_wow_pattern) {
142 		pmo_err("del_wow_pattern is null");
143 		status = QDF_STATUS_E_NULL_VALUE;
144 		goto out;
145 	}
146 	status = pmo_tx_ops.del_wow_pattern(vdev, ptrn_id);
147 	if (status) {
148 		status = QDF_STATUS_E_FAILURE;
149 		goto out;
150 	}
151 
152 	if (user)
153 		pmo_decrement_wow_user_ptrn(vdev_ctx);
154 	else
155 		pmo_decrement_wow_default_ptrn(vdev_ctx);
156 out:
157 
158 	return status;
159 }
160 
161