xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_mlo.h (revision 319d20734f036a4aaa5929e86558c347bb13707e)
1 /*
2  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 #ifndef _CDP_TXRX_MLO_H_
17 #define _CDP_TXRX_MLO_H_
18 #include "cdp_txrx_ops.h"
19 
20 struct cdp_mlo_ctxt;
21 
22 static inline
23 struct cdp_mlo_ctxt *cdp_mlo_ctxt_attach(ol_txrx_soc_handle soc,
24 					 struct cdp_ctrl_mlo_mgr *ctrl_ctxt)
25 {
26 	if (!soc || !soc->ops) {
27 		QDF_BUG(0);
28 		return NULL;
29 	}
30 
31 	if (!soc->ops->mlo_ops ||
32 	    !soc->ops->mlo_ops->mlo_ctxt_attach)
33 		return NULL;
34 
35 	return soc->ops->mlo_ops->mlo_ctxt_attach(ctrl_ctxt);
36 }
37 
38 static inline
39 void cdp_mlo_ctxt_detach(ol_txrx_soc_handle soc,
40 			 struct cdp_mlo_ctxt *ml_ctxt)
41 {
42 	if (!soc || !soc->ops) {
43 		QDF_BUG(0);
44 		return;
45 	}
46 
47 	if (!soc->ops->mlo_ops ||
48 	    !soc->ops->mlo_ops->mlo_ctxt_detach)
49 		return;
50 
51 	soc->ops->mlo_ops->mlo_ctxt_detach(ml_ctxt);
52 }
53 
54 static inline void cdp_soc_mlo_soc_setup(ol_txrx_soc_handle soc,
55 					 struct cdp_mlo_ctxt *mlo_ctx)
56 {
57 	if (!soc || !soc->ops) {
58 		QDF_BUG(0);
59 		return;
60 	}
61 
62 	if (!soc->ops->mlo_ops ||
63 	    !soc->ops->mlo_ops->mlo_soc_setup)
64 		return;
65 
66 	soc->ops->mlo_ops->mlo_soc_setup(soc, mlo_ctx);
67 }
68 
69 static inline void cdp_soc_mlo_soc_teardown(ol_txrx_soc_handle soc,
70 					    struct cdp_mlo_ctxt *mlo_ctx,
71 					    bool is_force_down)
72 {
73 	if (!soc || !soc->ops) {
74 		QDF_BUG(0);
75 		return;
76 	}
77 
78 	if (!soc->ops->mlo_ops ||
79 	    !soc->ops->mlo_ops->mlo_soc_teardown)
80 		return;
81 
82 	soc->ops->mlo_ops->mlo_soc_teardown(soc, mlo_ctx, is_force_down);
83 }
84 
85 static inline void cdp_mlo_setup_complete(ol_txrx_soc_handle soc,
86 					  struct cdp_mlo_ctxt *mlo_ctx)
87 {
88 	if (!soc || !soc->ops) {
89 		QDF_BUG(0);
90 		return;
91 	}
92 
93 	if (!soc->ops->mlo_ops ||
94 	    !soc->ops->mlo_ops->mlo_setup_complete)
95 		return;
96 
97 	soc->ops->mlo_ops->mlo_setup_complete(mlo_ctx);
98 }
99 
100 /*
101  * cdp_mlo_update_delta_tsf2 - Update delta_tsf2
102  * @soc: soc handle
103  * @pdev_id: pdev id
104  * @delta_tsf2: delta_tsf2
105  *
106  * return: none
107  */
108 static inline void cdp_mlo_update_delta_tsf2(ol_txrx_soc_handle soc,
109 					     uint8_t pdev_id,
110 					     uint64_t delta_tsf2)
111 {
112 	if (!soc || !soc->ops) {
113 		QDF_BUG(0);
114 		return;
115 	}
116 
117 	if (!soc->ops->mlo_ops ||
118 	    !soc->ops->mlo_ops->mlo_update_delta_tsf2)
119 		return;
120 
121 	soc->ops->mlo_ops->mlo_update_delta_tsf2(soc, pdev_id, delta_tsf2);
122 }
123 
124 /*
125  * cdp_mlo_update_delta_tqm - Update delta_tqm
126  * @soc: soc handle
127  * @delta_tqm: delta_tqm
128  *
129  * return: none
130  */
131 static inline void cdp_mlo_update_delta_tqm(ol_txrx_soc_handle soc,
132 					    uint64_t delta_tqm)
133 {
134 	if (!soc || !soc->ops) {
135 		QDF_BUG(0);
136 		return;
137 	}
138 
139 	if (!soc->ops->mlo_ops ||
140 	    !soc->ops->mlo_ops->mlo_update_delta_tqm)
141 		return;
142 
143 	soc->ops->mlo_ops->mlo_update_delta_tqm(soc, delta_tqm);
144 }
145 
146 /*
147  * cdp_mlo_get_mld_vdev_stats - Get MLD vdev stats
148  * @soc: soc handle
149  * @vdev_id: vdev_id of one of the vdev's of the MLD group
150  * @buf: buffer to hold vdev_stats
151  * @link_vdev_only: flag to indicate if stats are required for specific vdev
152  *
153  * return: QDF_STATUS
154  */
155 static inline QDF_STATUS
156 cdp_mlo_get_mld_vdev_stats(ol_txrx_soc_handle soc,
157 			   uint8_t vdev_id, struct cdp_vdev_stats *buf,
158 			   bool link_vdev_only)
159 {
160 	if (!soc || !soc->ops) {
161 		QDF_BUG(0);
162 		return QDF_STATUS_E_FAILURE;
163 	}
164 
165 	if (!soc->ops->mlo_ops || !soc->ops->mlo_ops->mlo_get_mld_vdev_stats)
166 		return QDF_STATUS_E_FAILURE;
167 
168 	return soc->ops->mlo_ops->mlo_get_mld_vdev_stats(soc,
169 							 vdev_id,
170 							 buf,
171 							 link_vdev_only);
172 }
173 #endif /*_CDP_TXRX_MLO_H_*/
174