xref: /wlan-driver/qca-wifi-host-cmn/umac/cmn_services/mgmt_txrx/dispatcher/inc/wlan_mgmt_txrx_tgt_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-2018, 2021 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 #ifndef _WLAN_MGMT_TXRX_TGT_API_H_
20 #define _WLAN_MGMT_TXRX_TGT_API_H_
21 
22 /**
23  * DOC:  wlan_mgmt_txrx_tgt_api.h
24  *
25  * management tx/rx layer public API and structures for
26  * umac southbound interface.
27  *
28  */
29 
30 #include "wlan_objmgr_cmn.h"
31 #include <wlan_objmgr_pdev_obj.h>
32 #include "wlan_mgmt_txrx_utils_api.h"
33 #include "qdf_nbuf.h"
34 #include <wlan_lmac_if_def.h>
35 
36 /**
37  * tgt_mgmt_txrx_rx_frame_handler() - handles rx mgmt. frames
38  * @psoc: psoc context
39  * @buf: buffer
40  * @mgmt_rx_params: rx event params
41  *
42  * This function handles mgmt. rx frames and is registered to southbound
43  * interface through rx ops.
44  *
45  * Return: QDF_STATUS_SUCCESS - in case of success
46  */
47 QDF_STATUS tgt_mgmt_txrx_rx_frame_handler(
48 			struct wlan_objmgr_psoc *psoc,
49 			qdf_nbuf_t buf,
50 			struct mgmt_rx_event_params *mgmt_rx_params);
51 
52 /**
53  * tgt_mgmt_txrx_tx_completion_handler() - handles mgmt. tx completions
54  * @pdev: pdev context
55  * @desc_id: mgmt desc. id
56  * @status: status of download of tx packet
57  * @tx_compl_params: tx completion params
58  *
59  * This function handles tx completions of mgmt. frames and is registered to
60  * LMAC_if layer through lmac_if cbs.The cb needs to free the nbuf. In case no
61  * callback is registered, this function will free the nbuf.
62  *
63  * Return: QDF_STATUS_SUCCESS - in case of success
64  */
65 QDF_STATUS tgt_mgmt_txrx_tx_completion_handler(
66 			struct wlan_objmgr_pdev *pdev,
67 			uint32_t desc_id, uint32_t status,
68 			void *tx_compl_params);
69 
70 /**
71  * tgt_mgmt_txrx_get_nbuf_from_desc_id() - extracts nbuf from mgmt desc
72  * @pdev: pdev context
73  * @desc_id: desc_id
74  *
75  * This function extracts nbuf from mgmt desc extracted from desc id.
76  *
77  * Return: nbuf - in case of success
78  *         NULL - in case of failure
79  */
80 qdf_nbuf_t tgt_mgmt_txrx_get_nbuf_from_desc_id(
81 			struct wlan_objmgr_pdev *pdev,
82 			uint32_t desc_id);
83 
84 /**
85  * tgt_mgmt_txrx_get_peer_from_desc_id() - extracts peer from mgmt desc
86  * @pdev: pdev context
87  * @desc_id: desc_id
88  *
89  * This function extracts peer from mgmt desc extracted from desc id.
90  *
91  * Return: peer - in case of success
92  *         NULL - in case of failure
93  */
94 struct wlan_objmgr_peer *
95 tgt_mgmt_txrx_get_peer_from_desc_id(
96 			struct wlan_objmgr_pdev *pdev,
97 			uint32_t desc_id);
98 
99 /**
100  * tgt_mgmt_txrx_get_vdev_id_from_desc_id() - extracts vdev id from mgmt desc
101  * @pdev: pdev context
102  * @desc_id: desc_id
103  *
104  * This function extracts vdev id from mgmt desc extracted from desc id.
105  *
106  * Return: vdev_id - in case of success
107  *         WLAN_UMAC_VDEV_ID_MAX - in case of failure
108  */
109 uint8_t tgt_mgmt_txrx_get_vdev_id_from_desc_id(
110 			struct wlan_objmgr_pdev *pdev,
111 			uint32_t desc_id);
112 
113 /**
114  * tgt_mgmt_txrx_get_free_desc_pool_count() - get free mgmt desc count
115  * @pdev: pdev context
116  *
117  * This function returns the count of free mgmt descriptors.
118  *
119  * Return:  free descpriptor count
120  */
121 uint32_t tgt_mgmt_txrx_get_free_desc_pool_count(
122 			struct wlan_objmgr_pdev *pdev);
123 
124 /**
125  * tgt_mgmt_txrx_register_ev_handler() - Register to mgmt txrx WMI events
126  * @psoc: Pointer to psoc object
127  *
128  * Return: QDF_STATUS of operation
129  */
130 QDF_STATUS
131 tgt_mgmt_txrx_register_ev_handler(struct wlan_objmgr_psoc *psoc);
132 
133 /**
134  * tgt_mgmt_txrx_unregister_ev_handler() - Unregister to mgmt txrx WMI events
135  * @psoc: Pointer to psoc object
136  *
137  * Return: QDF_STATUS of operation
138  */
139 QDF_STATUS
140 tgt_mgmt_txrx_unregister_ev_handler(struct wlan_objmgr_psoc *psoc);
141 
142 /**
143  * wlan_psoc_get_mgmt_txrx_txops() - Get txops of MGMT TxRx module using psoc
144  * @psoc: Pointer to psoc object
145  *
146  * Return: txops of MGMT TxRx module on success, otherwise NULL
147  */
148 static inline struct wlan_lmac_if_mgmt_txrx_tx_ops *
wlan_psoc_get_mgmt_txrx_txops(struct wlan_objmgr_psoc * psoc)149 wlan_psoc_get_mgmt_txrx_txops(struct wlan_objmgr_psoc *psoc)
150 {
151 	struct wlan_lmac_if_tx_ops *tx_ops;
152 
153 	if (!psoc) {
154 		mgmt_txrx_err("psoc is null");
155 		return NULL;
156 	}
157 
158 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
159 	if (!tx_ops) {
160 		mgmt_txrx_err("tx_ops is NULL");
161 		return NULL;
162 	}
163 
164 	return &tx_ops->mgmt_txrx_tx_ops;
165 }
166 
167 /**
168  * wlan_pdev_get_mgmt_txrx_txops() - Get txops of MGMT TxRx module using pdev
169  * @pdev: Pointer to pdev object
170  *
171  * Return: txops of MGMT TxRx module on success, otherwise NULL
172  */
173 static inline struct wlan_lmac_if_mgmt_txrx_tx_ops *
wlan_pdev_get_mgmt_txrx_txops(struct wlan_objmgr_pdev * pdev)174 wlan_pdev_get_mgmt_txrx_txops(struct wlan_objmgr_pdev *pdev)
175 {
176 	if (!pdev) {
177 		mgmt_txrx_err("pdev is null");
178 		return NULL;
179 	}
180 
181 	return wlan_psoc_get_mgmt_txrx_txops(wlan_pdev_get_psoc(pdev));
182 }
183 
184 /**
185  * tgt_mgmt_txrx_process_rx_frame() - Process management rx frames
186  * @pdev: pdev for which this management frame is intended
187  * @buf: buffer
188  * @mgmt_rx_params: rx event params
189  *
190  * This API processes MGMT Rx frames and delivers them to the upper layers.
191  *
192  * Return: QDF_STATUS of operation.
193  */
194 QDF_STATUS tgt_mgmt_txrx_process_rx_frame(
195 			struct wlan_objmgr_pdev *pdev,
196 			qdf_nbuf_t buf,
197 			struct mgmt_rx_event_params *mgmt_rx_params);
198 
199 /**
200  * tgt_mgmt_txrx_rx_frame_entry() - Entry point to the MGMT TxRx module for
201  * management Rx frames.
202  * @pdev: pdev for which this management frame is intended
203  * @buf: buffer
204  * @mgmt_rx_params: rx event params
205  *
206  * Return: QDF_STATUS of operation.
207  */
208 QDF_STATUS tgt_mgmt_txrx_rx_frame_entry(
209 			struct wlan_objmgr_pdev *pdev,
210 			qdf_nbuf_t buf,
211 			struct mgmt_rx_event_params *mgmt_rx_params);
212 #endif
213