1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-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: wlan_mgmt_txrx_rx_reo_tgt_api.h
20  *  This file contains mgmt rx re-ordering tgt layer related APIs
21  */
22 
23 #ifndef _WLAN_MGMT_TXRX_RX_REO_TGT_API_H
24 #define _WLAN_MGMT_TXRX_RX_REO_TGT_API_H
25 #include <wlan_objmgr_pdev_obj.h>
26 #include <qdf_types.h>
27 #include <wlan_mgmt_txrx_rx_reo_public_structs.h>
28 #include <wlan_mgmt_txrx_rx_reo_utils_api.h>
29 #include <wlan_mgmt_txrx_tgt_api.h>
30 #include <wlan_lmac_if_def.h>
31 
32 #ifdef WLAN_MGMT_RX_REO_SUPPORT
33 /**
34  * wlan_pdev_get_mgmt_rx_reo_txops() - Get management rx-reorder txops from pdev
35  * @pdev: Pointer to pdev object
36  *
37  * Return: Pointer to management rx-reorder txops in case of success, else NULL
38  */
39 static inline struct wlan_lmac_if_mgmt_rx_reo_tx_ops *
wlan_pdev_get_mgmt_rx_reo_txops(struct wlan_objmgr_pdev * pdev)40 wlan_pdev_get_mgmt_rx_reo_txops(struct wlan_objmgr_pdev *pdev)
41 {
42 	struct wlan_lmac_if_mgmt_txrx_tx_ops *mgmt_txrx_tx_ops;
43 
44 	mgmt_txrx_tx_ops = wlan_pdev_get_mgmt_txrx_txops(pdev);
45 	if (!mgmt_txrx_tx_ops) {
46 		mgmt_txrx_err("txops is null for mgmt txrx module");
47 		return NULL;
48 	}
49 
50 	return &mgmt_txrx_tx_ops->mgmt_rx_reo_tx_ops;
51 }
52 
53 /**
54  * wlan_psoc_get_mgmt_rx_reo_txops() - Get management rx-reorder txops from psoc
55  * @psoc: Pointer to psoc object
56  *
57  * Return: Pointer to management rx-reorder txops in case of success, else NULL
58  */
59 static inline struct wlan_lmac_if_mgmt_rx_reo_tx_ops *
wlan_psoc_get_mgmt_rx_reo_txops(struct wlan_objmgr_psoc * psoc)60 wlan_psoc_get_mgmt_rx_reo_txops(struct wlan_objmgr_psoc *psoc)
61 {
62 	struct wlan_lmac_if_mgmt_txrx_tx_ops *mgmt_txrx_tx_ops;
63 
64 	mgmt_txrx_tx_ops = wlan_psoc_get_mgmt_txrx_txops(psoc);
65 	if (!mgmt_txrx_tx_ops) {
66 		mgmt_txrx_err("txops is null for mgmt txrx module");
67 		return NULL;
68 	}
69 
70 	return &mgmt_txrx_tx_ops->mgmt_rx_reo_tx_ops;
71 }
72 
73 /**
74  * tgt_mgmt_rx_reo_get_num_active_hw_links() - Get number of active MLO HW
75  * links
76  * @psoc: Pointer to psoc object
77  * @num_active_hw_links: pointer to number of active MLO HW links
78  *
79  * Get number of active MLO HW links from the MLO global shared memory arena.
80  *
81  * Return: QDF_STATUS
82  */
83 QDF_STATUS
84 tgt_mgmt_rx_reo_get_num_active_hw_links(struct wlan_objmgr_psoc *psoc,
85 					int8_t *num_active_hw_links);
86 
87 /**
88  * tgt_mgmt_rx_reo_get_valid_hw_link_bitmap() - Get valid MLO HW link bitmap
89  * @psoc: Pointer to psoc object
90  * @valid_hw_link_bitmap: Pointer to valid MLO HW link bitmap
91  *
92  * Get valid MLO HW link bitmap from the MLO global shared memory arena.
93  *
94  * Return: QDF_STATUS
95  */
96 QDF_STATUS
97 tgt_mgmt_rx_reo_get_valid_hw_link_bitmap(struct wlan_objmgr_psoc *psoc,
98 					 uint16_t *valid_hw_link_bitmap);
99 
100 /**
101  * tgt_mgmt_rx_reo_read_snapshot() - Read management rx-reorder snapshot
102  * @pdev: Pointer to pdev object
103  * @snapshot_info: Snapshot info
104  * @id: Snapshot ID
105  * @value: Pointer to the snapshot value where the snapshot
106  * should be written
107  * @raw_snapshot: Raw snapshot data
108  *
109  * Read management rx-reorder snapshots from target.
110  *
111  * Return: QDF_STATUS
112  */
113 QDF_STATUS
114 tgt_mgmt_rx_reo_read_snapshot(
115 			struct wlan_objmgr_pdev *pdev,
116 			struct mgmt_rx_reo_snapshot_info *snapshot_info,
117 			enum mgmt_rx_reo_shared_snapshot_id id,
118 			struct mgmt_rx_reo_snapshot_params *value,
119 			struct mgmt_rx_reo_shared_snapshot (*raw_snapshot)
120 			[MGMT_RX_REO_SNAPSHOT_B2B_READ_SWAR_RETRY_LIMIT]);
121 
122 /**
123  * tgt_mgmt_rx_reo_fw_consumed_event_handler() - MGMT Rx REO FW consumed
124  * event handler
125  * @pdev: pdev for which this event is intended
126  * @params: Pointer to MGMT Rx REO parameters
127  *
128  * Return: QDF_STATUS of operation
129  */
130 QDF_STATUS
131 tgt_mgmt_rx_reo_fw_consumed_event_handler(struct wlan_objmgr_pdev *pdev,
132 					  struct mgmt_rx_reo_params *params);
133 
134 /**
135  * tgt_mgmt_rx_reo_filter_config() - Configure MGMT Rx REO filter
136  * @pdev: Pointer to pdev object
137  * @filter: Pointer to MGMT Rx REO filter
138  *
139  * Return: QDF_STATUS_SUCCESS for success or error code
140  */
141 QDF_STATUS tgt_mgmt_rx_reo_filter_config(struct wlan_objmgr_pdev *pdev,
142 					 struct mgmt_rx_reo_filter *filter);
143 
144 /**
145  * tgt_mgmt_rx_reo_get_snapshot_info() - Get information regarding management
146  * rx-reorder snapshot
147  * @pdev: Pointer to pdev object
148  * @id: Snapshot ID
149  * @snapshot_info: Pointer to snapshot info
150  *
151  * Return: QDF_STATUS
152  */
153 QDF_STATUS
154 tgt_mgmt_rx_reo_get_snapshot_info
155 			(struct wlan_objmgr_pdev *pdev,
156 			 enum mgmt_rx_reo_shared_snapshot_id id,
157 			 struct mgmt_rx_reo_snapshot_info *snapshot_info);
158 
159 /**
160  * tgt_mgmt_rx_reo_frame_handler() - REO handler for management Rx frames.
161  * @pdev: pdev for which this management frame is intended
162  * @buf: buffer
163  * @mgmt_rx_params: rx event params
164  *
165  * Return: QDF_STATUS of operation.
166  */
167 QDF_STATUS tgt_mgmt_rx_reo_frame_handler(
168 			struct wlan_objmgr_pdev *pdev,
169 			qdf_nbuf_t buf,
170 			struct mgmt_rx_event_params *mgmt_rx_params);
171 
172 /**
173  * tgt_mgmt_rx_reo_host_drop_handler() - MGMT Rx REO handler for the
174  * management Rx frames that gets dropped in the Host before entering
175  * MGMT Rx REO algorithm
176  * @pdev: pdev for which this frame was intended
177  * @params: MGMT Rx event parameters
178  *
179  * Return: QDF_STATUS of operation
180  */
181 QDF_STATUS
182 tgt_mgmt_rx_reo_host_drop_handler(struct wlan_objmgr_pdev *pdev,
183 				  struct mgmt_rx_reo_params *params);
184 
185 /**
186  * tgt_mgmt_rx_reo_release_frames() - Release management frames which are ready
187  * for delivery
188  * @psoc: Pointer to psoc object
189  *
190  * Return: QDF_STATUS
191  */
192 QDF_STATUS
193 tgt_mgmt_rx_reo_release_frames(struct wlan_objmgr_psoc *psoc);
194 
195 /**
196  * tgt_mgmt_rx_reo_schedule_delivery() - Helper API to schedule the delivery of
197  * a management frame.
198  * @psoc: Pointer to psoc object
199  *
200  * Return: QDF_STATUS
201  */
202 QDF_STATUS
203 tgt_mgmt_rx_reo_schedule_delivery(struct wlan_objmgr_psoc *psoc);
204 #else
205 /**
206  * tgt_mgmt_rx_reo_frame_handler() - REO handler for management Rx frames.
207  * @pdev: pdev for which this management frame is intended
208  * @buf: buffer
209  * @mgmt_rx_params: rx event params
210  *
211  * Return: QDF_STATUS of operation.
212  */
tgt_mgmt_rx_reo_frame_handler(struct wlan_objmgr_pdev * pdev,qdf_nbuf_t buf,struct mgmt_rx_event_params * mgmt_rx_params)213 static inline QDF_STATUS tgt_mgmt_rx_reo_frame_handler(
214 			struct wlan_objmgr_pdev *pdev,
215 			qdf_nbuf_t buf,
216 			struct mgmt_rx_event_params *mgmt_rx_params)
217 {
218 	/**
219 	 * If MGMT Rx REO feature is not compiled,
220 	 * process the frame right away.
221 	 */
222 	return tgt_mgmt_txrx_process_rx_frame(pdev, buf, mgmt_rx_params);
223 }
224 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
225 #endif /* _WLAN_MGMT_TXRX_RX_REO_TGT_API_H */
226