xref: /wlan-driver/qcacld-3.0/components/pkt_capture/dispatcher/src/wlan_pkt_capture_tgt_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021, 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: This file contains packet capture south bound interface definitions
20  */
21 
22 #include "wlan_pkt_capture_tgt_api.h"
23 
24 QDF_STATUS
tgt_pkt_capture_register_ev_handler(struct wlan_objmgr_vdev * vdev)25 tgt_pkt_capture_register_ev_handler(struct wlan_objmgr_vdev *vdev)
26 {
27 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
28 	struct pkt_psoc_priv *psoc_priv;
29 	struct wlan_pkt_capture_rx_ops *rx_ops;
30 	struct wlan_objmgr_psoc *psoc;
31 
32 	psoc = wlan_vdev_get_psoc(vdev);
33 	if (!psoc) {
34 		pkt_capture_err("psoc is NULL");
35 		return status;
36 	}
37 
38 	psoc_priv = pkt_capture_psoc_get_priv(psoc);
39 	if (!psoc_priv) {
40 		pkt_capture_err("psoc_priv is NULL");
41 		return status;
42 	}
43 
44 	rx_ops = &psoc_priv->rx_ops;
45 
46 	if (!rx_ops->pkt_capture_register_ev_handlers)
47 		return status;
48 
49 	status = rx_ops->pkt_capture_register_ev_handlers(psoc);
50 	if (QDF_IS_STATUS_ERROR(status))
51 		pkt_capture_err("Unable to register mgmt offload handler");
52 
53 	status = rx_ops->pkt_capture_register_smart_monitor_event(psoc);
54 	if (QDF_IS_STATUS_ERROR(status))
55 		pkt_capture_err("Unable to register smart monitor handler");
56 
57 	return status;
58 }
59 
60 QDF_STATUS
tgt_pkt_capture_unregister_ev_handler(struct wlan_objmgr_vdev * vdev)61 tgt_pkt_capture_unregister_ev_handler(struct wlan_objmgr_vdev *vdev)
62 {
63 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
64 	struct pkt_psoc_priv *psoc_priv;
65 	struct wlan_pkt_capture_rx_ops *rx_ops;
66 	struct wlan_objmgr_psoc *psoc;
67 
68 	psoc = wlan_vdev_get_psoc(vdev);
69 	if (!psoc) {
70 		pkt_capture_err("psoc is NULL");
71 		return status;
72 	}
73 
74 	psoc_priv = pkt_capture_psoc_get_priv(psoc);
75 	if (!psoc_priv) {
76 		pkt_capture_err("psoc_priv is NULL");
77 		return status;
78 	}
79 
80 	rx_ops = &psoc_priv->rx_ops;
81 
82 	if (!rx_ops->pkt_capture_unregister_ev_handlers)
83 		return status;
84 
85 	status = rx_ops->pkt_capture_unregister_ev_handlers(psoc);
86 	if (QDF_IS_STATUS_ERROR(status))
87 		pkt_capture_err("Unable to register mgmt offload handler");
88 
89 	status = rx_ops->pkt_capture_unregister_smart_monitor_event(psoc);
90 	if (QDF_IS_STATUS_ERROR(status))
91 		pkt_capture_err("Unable to unregister smart monitor handler");
92 
93 	return status;
94 }
95 
96 QDF_STATUS
tgt_pkt_capture_send_mode(struct wlan_objmgr_vdev * vdev,enum pkt_capture_mode mode)97 tgt_pkt_capture_send_mode(struct wlan_objmgr_vdev *vdev,
98 			  enum pkt_capture_mode mode)
99 {
100 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
101 	struct pkt_psoc_priv *psoc_priv;
102 	struct wlan_pkt_capture_tx_ops *tx_ops;
103 	struct wlan_objmgr_psoc *psoc;
104 
105 	psoc = wlan_vdev_get_psoc(vdev);
106 	if (!psoc) {
107 		pkt_capture_err("psoc is NULL");
108 		return status;
109 	}
110 
111 	psoc_priv = pkt_capture_psoc_get_priv(psoc);
112 	if (!psoc_priv) {
113 		pkt_capture_err("psoc_priv is NULL");
114 		return status;
115 	}
116 
117 	tx_ops = &psoc_priv->tx_ops;
118 
119 	if (!tx_ops->pkt_capture_send_mode)
120 		return status;
121 
122 	status = tx_ops->pkt_capture_send_mode(psoc, wlan_vdev_get_id(vdev),
123 					       mode);
124 	if (QDF_IS_STATUS_ERROR(status))
125 		pkt_capture_err("Unable to send packet capture mode to fw");
126 
127 	return status;
128 }
129 
130 QDF_STATUS
tgt_pkt_capture_send_beacon_interval(struct wlan_objmgr_vdev * vdev,uint32_t nth_value)131 tgt_pkt_capture_send_beacon_interval(struct wlan_objmgr_vdev *vdev,
132 				     uint32_t nth_value)
133 {
134 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
135 	struct pkt_psoc_priv *psoc_priv;
136 	struct wlan_pkt_capture_tx_ops *tx_ops;
137 	struct wlan_objmgr_psoc *psoc;
138 
139 	psoc = wlan_vdev_get_psoc(vdev);
140 	if (!psoc) {
141 		pkt_capture_err("psoc is NULL");
142 		return status;
143 	}
144 
145 	psoc_priv = pkt_capture_psoc_get_priv(psoc);
146 	if (!psoc_priv) {
147 		pkt_capture_err("psoc_priv is NULL");
148 		return status;
149 	}
150 
151 	tx_ops = &psoc_priv->tx_ops;
152 
153 	if (!tx_ops->pkt_capture_send_beacon_interval)
154 		return status;
155 
156 	status = tx_ops->pkt_capture_send_beacon_interval
157 						(psoc,
158 						 wlan_vdev_get_id(vdev),
159 						 nth_value);
160 	if (QDF_IS_STATUS_ERROR(status))
161 		pkt_capture_err("Unable to send beacon interval to fw");
162 
163 	return status;
164 }
165 
166 QDF_STATUS
tgt_pkt_capture_send_config(struct wlan_objmgr_vdev * vdev,enum pkt_capture_config config)167 tgt_pkt_capture_send_config(struct wlan_objmgr_vdev *vdev,
168 			    enum pkt_capture_config config)
169 {
170 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
171 	struct pkt_psoc_priv *psoc_priv;
172 	struct wlan_pkt_capture_tx_ops *tx_ops;
173 	struct wlan_objmgr_psoc *psoc;
174 
175 	psoc = wlan_vdev_get_psoc(vdev);
176 	if (!psoc) {
177 		pkt_capture_err("psoc is NULL");
178 		return status;
179 	}
180 
181 	psoc_priv = pkt_capture_psoc_get_priv(psoc);
182 	if (!psoc_priv) {
183 		pkt_capture_err("psoc_priv is NULL");
184 		return status;
185 	}
186 
187 	tx_ops = &psoc_priv->tx_ops;
188 
189 	if (!tx_ops->pkt_capture_send_config)
190 		return status;
191 
192 	status = tx_ops->pkt_capture_send_config(psoc, wlan_vdev_get_id(vdev),
193 						 config);
194 	if (QDF_IS_STATUS_ERROR(status))
195 		pkt_capture_err("Unable to send packet capture config to fw");
196 
197 	return status;
198 }
199 
200 #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
201 QDF_STATUS
tgt_pkt_capture_smu_event(struct wlan_objmgr_psoc * psoc,struct smu_event_params * param)202 tgt_pkt_capture_smu_event(struct wlan_objmgr_psoc *psoc,
203 			  struct smu_event_params *param)
204 {
205 	struct pkt_capture_vdev_priv *vdev_priv;
206 	struct wlan_objmgr_vdev *vdev;
207 	uint8_t vdev_id;
208 
209 	vdev_id = param->vdev_id;
210 
211 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
212 						    WLAN_PKT_CAPTURE_ID);
213 	if (!vdev) {
214 		pkt_capture_err("failed to get vdev");
215 		return QDF_STATUS_E_FAILURE;
216 	}
217 
218 	vdev_priv = pkt_capture_vdev_get_priv(vdev);
219 	if (!vdev_priv) {
220 		pkt_capture_err("vdev priv is NULL");
221 		pkt_capture_vdev_put_ref(vdev);
222 		return QDF_STATUS_E_FAILURE;
223 	}
224 
225 	vdev_priv->rx_vht_sgi = param->rx_vht_sgi;
226 
227 	pkt_capture_vdev_put_ref(vdev);
228 
229 	return QDF_STATUS_SUCCESS;
230 }
231 #endif
232