xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_mlo.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
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 /*
86  * cdp_update_mlo_ptnr_list - Add vdev to MLO partner list
87  * @soc: soc handle
88  * @vdev_ids: list of partner vdevs
89  * @num_vdevs: number of items in list
90  * @vdev_id: caller's vdev id
91  *
92  * return: QDF_STATUS
93  */
94 static inline QDF_STATUS
95 cdp_update_mlo_ptnr_list(ol_txrx_soc_handle soc, int8_t vdev_ids[],
96 			 uint8_t num_vdevs, uint8_t vdev_id)
97 {
98 	if (!soc || !soc->ops || !soc->ops->mlo_ops)
99 		return QDF_STATUS_E_INVAL;
100 
101 	if (soc->ops->mlo_ops->update_mlo_ptnr_list)
102 		return soc->ops->mlo_ops->update_mlo_ptnr_list(soc, vdev_ids,
103 						num_vdevs, vdev_id);
104 
105 	return QDF_STATUS_SUCCESS;
106 }
107 
108 /*
109  * cdp_clear_mlo_ptnr_list - Remove vdev from MLO partner list
110  * @soc: soc handle
111  * @vdev_id: caller's vdev id
112  *
113  * return: QDF_STATUS
114  */
115 static inline QDF_STATUS
116 cdp_clear_mlo_ptnr_list(ol_txrx_soc_handle soc, uint8_t vdev_id)
117 {
118 	if (!soc || !soc->ops || !soc->ops->mlo_ops)
119 		return QDF_STATUS_E_INVAL;
120 
121 	if (soc->ops->mlo_ops->update_mlo_ptnr_list)
122 		return soc->ops->mlo_ops->clear_mlo_ptnr_list(soc, vdev_id);
123 
124 	return QDF_STATUS_SUCCESS;
125 }
126 
127 static inline void cdp_mlo_setup_complete(ol_txrx_soc_handle soc,
128 					  struct cdp_mlo_ctxt *mlo_ctx)
129 {
130 	if (!soc || !soc->ops) {
131 		QDF_BUG(0);
132 		return;
133 	}
134 
135 	if (!soc->ops->mlo_ops ||
136 	    !soc->ops->mlo_ops->mlo_setup_complete)
137 		return;
138 
139 	soc->ops->mlo_ops->mlo_setup_complete(mlo_ctx);
140 }
141 
142 /*
143  * cdp_mlo_update_delta_tsf2 - Update delta_tsf2
144  * @soc: soc handle
145  * @pdev_id: pdev id
146  * @delta_tsf2: delta_tsf2
147  *
148  * return: none
149  */
150 static inline void cdp_mlo_update_delta_tsf2(ol_txrx_soc_handle soc,
151 					     uint8_t pdev_id,
152 					     uint64_t delta_tsf2)
153 {
154 	if (!soc || !soc->ops) {
155 		QDF_BUG(0);
156 		return;
157 	}
158 
159 	if (!soc->ops->mlo_ops ||
160 	    !soc->ops->mlo_ops->mlo_update_delta_tsf2)
161 		return;
162 
163 	soc->ops->mlo_ops->mlo_update_delta_tsf2(soc, pdev_id, delta_tsf2);
164 }
165 
166 /*
167  * cdp_mlo_update_delta_tqm - Update delta_tqm
168  * @soc: soc handle
169  * @delta_tqm: delta_tqm
170  *
171  * return: none
172  */
173 static inline void cdp_mlo_update_delta_tqm(ol_txrx_soc_handle soc,
174 					    uint64_t delta_tqm)
175 {
176 	if (!soc || !soc->ops) {
177 		QDF_BUG(0);
178 		return;
179 	}
180 
181 	if (!soc->ops->mlo_ops ||
182 	    !soc->ops->mlo_ops->mlo_update_delta_tqm)
183 		return;
184 
185 	soc->ops->mlo_ops->mlo_update_delta_tqm(soc, delta_tqm);
186 }
187 #endif /*_CDP_TXRX_MLO_H_*/
188