xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_mlo.h (revision 70a19e16789e308182f63b15c75decec7bf0b342)
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 static inline void cdp_mlo_setup_complete(ol_txrx_soc_handle soc,
109 					  struct cdp_mlo_ctxt *mlo_ctx)
110 {
111 	if (!soc || !soc->ops) {
112 		QDF_BUG(0);
113 		return;
114 	}
115 
116 	if (!soc->ops->mlo_ops ||
117 	    !soc->ops->mlo_ops->mlo_setup_complete)
118 		return;
119 
120 	soc->ops->mlo_ops->mlo_setup_complete(mlo_ctx);
121 }
122 
123 /*
124  * cdp_mlo_update_delta_tsf2 - Update delta_tsf2
125  * @soc: soc handle
126  * @pdev_id: pdev id
127  * @delta_tsf2: delta_tsf2
128  *
129  * return: none
130  */
131 static inline void cdp_mlo_update_delta_tsf2(ol_txrx_soc_handle soc,
132 					     uint8_t pdev_id,
133 					     uint64_t delta_tsf2)
134 {
135 	if (!soc || !soc->ops) {
136 		QDF_BUG(0);
137 		return;
138 	}
139 
140 	if (!soc->ops->mlo_ops ||
141 	    !soc->ops->mlo_ops->mlo_update_delta_tsf2)
142 		return;
143 
144 	soc->ops->mlo_ops->mlo_update_delta_tsf2(soc, pdev_id, delta_tsf2);
145 }
146 
147 /*
148  * cdp_mlo_update_delta_tqm - Update delta_tqm
149  * @soc: soc handle
150  * @delta_tqm: delta_tqm
151  *
152  * return: none
153  */
154 static inline void cdp_mlo_update_delta_tqm(ol_txrx_soc_handle soc,
155 					    uint64_t delta_tqm)
156 {
157 	if (!soc || !soc->ops) {
158 		QDF_BUG(0);
159 		return;
160 	}
161 
162 	if (!soc->ops->mlo_ops ||
163 	    !soc->ops->mlo_ops->mlo_update_delta_tqm)
164 		return;
165 
166 	soc->ops->mlo_ops->mlo_update_delta_tqm(soc, delta_tqm);
167 }
168 #endif /*_CDP_TXRX_MLO_H_*/
169