xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_ctrl.h (revision 99a10d078d8c08bacd095650c5bfcdcef8f8bf20)
1 /*
2  * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27  /**
28  * @file cdp_txrx_ctrl.h
29  * @brief Define the host data path control API functions
30  * called by the host control SW and the OS interface module
31  */
32 
33 #ifndef _CDP_TXRX_CTRL_H_
34 #define _CDP_TXRX_CTRL_H_
35 #include "cdp_txrx_handle.h"
36 
37 static inline int cdp_is_target_ar900b
38 	(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
39 {
40 	if (soc->ops->ctrl_ops->txrx_is_target_ar900b)
41 		return soc->ops->ctrl_ops->txrx_is_target_ar900b(vdev);
42 	return 0;
43 }
44 
45 
46 /* WIN */
47 static inline int
48 cdp_mempools_attach(ol_txrx_soc_handle soc, void *ctrl_pdev)
49 {
50 	if (soc->ops->ctrl_ops->txrx_mempools_attach)
51 		return soc->ops->ctrl_ops->txrx_mempools_attach(ctrl_pdev);
52 	return 0;
53 }
54 
55 static inline int
56 cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc,
57 	struct cdp_pdev *pdev, u_int32_t val)
58 {
59 	if (soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers)
60 		return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers
61 			(pdev, val);
62 	return 0;
63 }
64 /**
65  * @brief set the safemode of the device
66  * @details
67  *  This flag is used to bypass the encrypt and decrypt processes when send and
68  *  receive packets. It works like open AUTH mode, HW will treate all packets
69  *  as non-encrypt frames because no key installed. For rx fragmented frames,
70  *  it bypasses all the rx defragmentaion.
71  *
72  * @param vdev - the data virtual device object
73  * @param val - the safemode state
74  * @return - void
75  */
76 
77 static inline void
78 cdp_set_safemode(ol_txrx_soc_handle soc,
79 	struct cdp_vdev *vdev, u_int32_t val)
80 {
81 	if (soc->ops->ctrl_ops->txrx_set_safemode)
82 		return soc->ops->ctrl_ops->txrx_set_safemode(vdev, val);
83 	return;
84 }
85 /**
86  * @brief configure the drop unencrypted frame flag
87  * @details
88  *  Rx related. When set this flag, all the unencrypted frames
89  *  received over a secure connection will be discarded
90  *
91  * @param vdev - the data virtual device object
92  * @param val - flag
93  * @return - void
94  */
95 static inline void
96 cdp_set_drop_unenc(ol_txrx_soc_handle soc,
97 	struct cdp_vdev *vdev, u_int32_t val)
98 {
99 	if (soc->ops->ctrl_ops->txrx_set_drop_unenc)
100 		return soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val);
101 	return;
102 }
103 
104 
105 /**
106  * @brief set the Tx encapsulation type of the VDEV
107  * @details
108  *  This will be used to populate the HTT desc packet type field during Tx
109  *
110  * @param vdev - the data virtual device object
111  * @param val - the Tx encap type (htt_cmn_pkt_type)
112  * @return - void
113  */
114 static inline void
115 cdp_set_tx_encap_type(ol_txrx_soc_handle soc,
116 	struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
117 {
118 	if (soc->ops->ctrl_ops->txrx_set_tx_encap_type)
119 		return soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val);
120 	return;
121 }
122 
123 /**
124  * @brief set the Rx decapsulation type of the VDEV
125  * @details
126  *  This will be used to configure into firmware and hardware which format to
127  *  decap all Rx packets into, for all peers under the VDEV.
128  *
129  * @param vdev - the data virtual device object
130  * @param val - the Rx decap mode (htt_cmn_pkt_type)
131  * @return - void
132  */
133 static inline void
134 cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc,
135 	struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
136 {
137 	if (soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type)
138 		return soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type
139 			(vdev, val);
140 	return;
141 }
142 
143 /**
144  * @brief get the Rx decapsulation type of the VDEV
145  *
146  * @param vdev - the data virtual device object
147  * @return - the Rx decap type (htt_cmn_pkt_type)
148  */
149 static inline enum htt_cmn_pkt_type
150 cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
151 {
152 	if (soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type)
153 		return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev);
154 	return 0;
155 }
156 
157 /* Is this similar to ol_txrx_peer_state_update() in MCL */
158 /**
159  * @brief Update the authorize peer object at association time
160  * @details
161  *  For the host-based implementation of rate-control, it
162  *  updates the peer/node-related parameters within rate-control
163  *  context of the peer at association.
164  *
165  * @param peer - pointer to the node's object
166  * @authorize - either to authorize or unauthorize peer
167  *
168  * @return none
169  */
170 static inline void
171 cdp_peer_authorize(ol_txrx_soc_handle soc,
172 	struct ol_txrx_peer_t *peer, u_int32_t authorize)
173 {
174 	if (soc->ops->ctrl_ops->txrx_peer_authorize)
175 		return soc->ops->ctrl_ops->txrx_peer_authorize
176 			(peer, authorize);
177 	return;
178 }
179 
180 static inline bool
181 cdp_set_inact_params(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
182 			u_int16_t inact_check_interval,
183 			u_int16_t inact_normal,
184 			u_int16_t inact_overload)
185 {
186 	if (soc->ops->ctrl_ops->txrx_set_inact_params)
187 		return soc->ops->ctrl_ops->txrx_set_inact_params
188 			(pdev, inact_check_interval, inact_normal,
189 			inact_overload);
190 	return false;
191 }
192 static inline bool
193 cdp_start_inact_timer(ol_txrx_soc_handle soc,
194 	struct cdp_pdev *pdev,
195 	bool enable)
196 {
197 	if (soc->ops->ctrl_ops->txrx_start_inact_timer)
198 		return soc->ops->ctrl_ops->txrx_start_inact_timer
199 			(pdev, enable);
200 	return false;
201 }
202 
203 /**
204  * @brief Set the overload status of the radio
205  * @details
206  *   Set the overload status of the radio, updating the inactivity
207  *   threshold and inactivity count for each node.
208  *
209  * @param pdev - the data physical device object
210  * @param overload - whether the radio is overloaded or not
211  */
212 static inline void
213 cdp_set_overload(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
214 	bool overload)
215 {
216 	if (soc->ops->ctrl_ops->txrx_set_overload)
217 		return soc->ops->ctrl_ops->txrx_set_overload(pdev, overload);
218 	return;
219 }
220 
221 /**
222  * @brief Check the inactivity status of the peer/node
223  *
224  * @param peer - pointer to the node's object
225  * @return true if the node is inactive; otherwise return false
226  */
227 static inline bool
228 cdp_peer_is_inact(ol_txrx_soc_handle soc, void *peer)
229 {
230 	if (soc->ops->ctrl_ops->txrx_peer_is_inact)
231 		return soc->ops->ctrl_ops->txrx_peer_is_inact(peer);
232 	return false;
233 }
234 
235 /**
236  * @brief Mark inactivity status of the peer/node
237  * @details
238  *   If it becomes active, reset inactivity count to reload value;
239  *   if the inactivity status changed, notify umac band steering.
240  *
241  * @param peer - pointer to the node's object
242  * @param inactive - whether the node is inactive or not
243  */
244 static inline void
245 cdp_mark_peer_inact(ol_txrx_soc_handle soc,
246 	void *peer,
247 	bool inactive)
248 {
249 	if (soc->ops->ctrl_ops->txrx_mark_peer_inact)
250 		return soc->ops->ctrl_ops->txrx_mark_peer_inact
251 			(peer, inactive);
252 	return;
253 }
254 
255 
256 /* Should be ol_txrx_ctrl_api.h */
257 static inline void cdp_set_mesh_mode
258 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val)
259 {
260 	if (soc->ops->ctrl_ops->txrx_set_mesh_mode)
261 		return soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val);
262 	return;
263 }
264 
265 /**
266  * @brief set mesh rx filter
267  * @details based on the bits enabled in the filter packets has to be dropped.
268  *
269  * @param soc - pointer to the soc
270  * @param vdev - the data virtual device object
271  * @param val - value to be set
272  * @return - void
273  */
274 static inline
275 void cdp_set_mesh_rx_filter(ol_txrx_soc_handle soc,
276 				struct cdp_vdev *vdev, uint32_t val)
277 {
278 	if (soc->ops->ctrl_ops->txrx_set_mesh_rx_filter)
279 		return soc->ops->ctrl_ops->txrx_set_mesh_rx_filter(vdev, val);
280 	return;
281 }
282 
283 static inline void cdp_tx_flush_buffers
284 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
285 {
286 	if (soc->ops->ctrl_ops->tx_flush_buffers)
287 		return soc->ops->ctrl_ops->tx_flush_buffers(vdev);
288 	return;
289 }
290 
291 #endif
292