xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlo_mgr/inc/wlan_mlo_mgr_public_structs.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. 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 
17 /*
18  * DOC: contains mlo manager structure definitions
19  */
20 #ifndef __MLO_MGR_PUBLIC_STRUCTS_H
21 #define __MLO_MGR_PUBLIC_STRUCTS_H
22 
23 #include <wlan_objmgr_cmn.h>
24 #include <qdf_list.h>
25 #include <qdf_atomic.h>
26 #include <qdf_nbuf.h>
27 #include <wlan_cmn_ieee80211.h>
28 #include <wlan_cmn.h>
29 #include <wlan_objmgr_global_obj.h>
30 
31 /* MAX MLO dev support */
32 #define WLAN_UMAC_MLO_MAX_VDEVS 3
33 
34 /* MAX instances of ML devices */
35 #define WLAN_UMAC_MLO_MAX_DEV 2
36 
37 /* Max PEER support */
38 #define MAX_MLO_PEER 512
39 
40 struct mlo_mlme_ext_ops;
41 struct vdev_mlme_obj;
42 
43 /* Max LINK PEER support */
44 #define MAX_MLO_LINK_PEERS WLAN_UMAC_MLO_MAX_VDEVS
45 
46 #define MAX_MLO_PEER_ID 2048
47 #define MLO_INVALID_PEER_ID 0xFFFF
48 
49 /* IE nomenclature */
50 #define ID_POS 0
51 #define TAG_LEN_POS 1
52 #define IDEXT_POS 2
53 #define MIN_IE_LEN 2
54 #define MULTI_LINK_CTRL_1 3
55 #define MULTI_LINK_CTRL_2 4
56 #define STA_CTRL_1 2
57 #define STA_CTRL_2 3
58 #define STA_PROFILE_SUB_ELEM_ID 0
59 #define PER_STA_PROF_MAC_ADDR_START 4
60 
61 /*
62  * struct mlo_setup_info
63  * To store the MLO setup related information
64  */
65 struct mlo_setup_info {
66 };
67 
68 /*
69  * struct mlo_mgr_context - MLO manager context
70  * @ml_dev_list_lock: ML DEV list lock
71  * @aid_lock: AID global lock
72  * @ml_peerid_lock: ML peer ID global lock
73  * @context: Array of MLO device context
74  * @mlo_peer_id_bmap: bitmap to allocate MLO Peer ID
75  * @max_mlo_peer_id: Max MLO Peer ID
76  * @info: MLO setup info
77  * @mlme_ops: MLO MLME callback function pointers
78  * @msgq_ctx: Context switch mgr
79  * @mlo_is_force_primary_umac: Force Primary UMAC enable
80  * @mlo_forced_primary_umac_id: Force Primary UMAC ID
81  */
82 struct mlo_mgr_context {
83 #ifdef WLAN_MLO_USE_SPINLOCK
84 	qdf_spinlock_t ml_dev_list_lock;
85 	qdf_spinlock_t aid_lock;
86 	qdf_spinlock_t ml_peerid_lock;
87 #else
88 	qdf_mutex_t ml_dev_list_lock;
89 	qdf_mutex_t aid_lock;
90 	qdf_mutex_t ml_peerid_lock;
91 #endif
92 	qdf_list_t ml_dev_list;
93 	qdf_bitmap(mlo_peer_id_bmap, MAX_MLO_PEER_ID);
94 	uint16_t max_mlo_peer_id;
95 	struct mlo_setup_info info;
96 	struct mlo_mlme_ext_ops *mlme_ops;
97 	struct ctxt_switch_mgr *msgq_ctx;
98 	bool mlo_is_force_primary_umac;
99 	uint8_t mlo_forced_primary_umac_id;
100 };
101 
102 /*
103  * struct wlan_ml_vdev_aid_mgr – ML AID manager
104  * @aid_bitmap: AID bitmap array
105  * @max_aid: Max allowed AID
106  * @aid_mgr[]:  Array of link vdev aid mgr
107  */
108 struct wlan_ml_vdev_aid_mgr {
109 	qdf_bitmap(aid_bitmap, WLAN_UMAC_MAX_AID);
110 	uint16_t max_aid;
111 	struct wlan_vdev_aid_mgr *aid_mgr[WLAN_UMAC_MLO_MAX_VDEVS];
112 };
113 
114 /*
115  * struct wlan_mlo_key_mgmt - MLO key management
116  * @link_mac_address: list of vdevs selected for connection with the MLAP
117  * @ptk: Pairwise transition keys
118  * @gtk: Group transition key
119  */
120 struct wlan_mlo_key_mgmt {
121 	struct qdf_mac_addr link_mac_address;
122 	uint32_t ptk;
123 	uint32_t gtk;
124 };
125 
126 /*
127  * struct wlan_mlo_sta - MLO sta additional info
128  * @wlan_connect_req_links: list of vdevs selected for connection with the MLAP
129  * @wlan_connected_links: list of vdevs associated with this MLO connection
130  * @connect req: connect params
131  * @orig_conn_req: original connect req
132  * @assoc_rsp: Raw assoc response frame
133  */
134 struct wlan_mlo_sta {
135 	qdf_bitmap(wlan_connect_req_links, WLAN_UMAC_MLO_MAX_VDEVS);
136 	qdf_bitmap(wlan_connected_links, WLAN_UMAC_MLO_MAX_VDEVS);
137 	struct wlan_mlo_key_mgmt key_mgmt[WLAN_UMAC_MLO_MAX_VDEVS - 1];
138 	struct wlan_cm_connect_req *connect_req;
139 	struct wlan_cm_connect_req *orig_conn_req;
140 	struct element_info assoc_rsp;
141 };
142 
143 /*
144  * struct wlan_mlo_ap - MLO AP related info
145  * @num_ml_vdevs: number of vdevs to form MLD
146  * @ml_aid_mgr: ML AID mgr
147  * @mlo_vdev_quiet_bmap: Bitmap of vdevs for which quiet ie needs to enabled
148  */
149 struct wlan_mlo_ap {
150 	uint8_t num_ml_vdevs;
151 	struct wlan_ml_vdev_aid_mgr *ml_aid_mgr;
152 	qdf_bitmap(mlo_vdev_quiet_bmap, WLAN_UMAC_MLO_MAX_VDEVS);
153 };
154 
155 /*
156  * struct wlan_mlo_peer_list - MLO peer list entry
157  * @peer_hash: MLO peer hash code
158  * @peer_list_lock: lock to access members of structure
159  */
160 struct wlan_mlo_peer_list {
161 	qdf_list_t peer_hash[WLAN_PEER_HASHSIZE];
162 #ifdef WLAN_MLO_USE_SPINLOCK
163 	qdf_spinlock_t peer_list_lock;
164 #else
165 	qdf_mutex_t peer_list_lock;
166 #endif
167 };
168 
169 /*
170  * struct wlan_mlo_dev_context - MLO device context
171  * @node: QDF list node member
172  * @mld_id: MLD id
173  * @mld_addr: MLO device MAC address
174  * @wlan_vdev_list: list of vdevs associated with this MLO connection
175  * @wlan_vdev_count: number of elements in the vdev list
176  * @mlo_peer: list peers in this MLO connection
177  * @wlan_max_mlo_peer_count: peer count across the links of specific MLO
178  * @mlo_dev_lock: lock to access struct
179  * @ref_cnt: reference count
180  * @ref_id_dbg: Reference count debug information
181  * @sta_ctx: MLO STA related information
182  * @ap_ctx: AP related information
183  */
184 struct wlan_mlo_dev_context {
185 	qdf_list_node_t node;
186 	uint8_t mld_id;
187 	struct qdf_mac_addr mld_addr;
188 	struct wlan_objmgr_vdev *wlan_vdev_list[WLAN_UMAC_MLO_MAX_VDEVS];
189 	uint16_t wlan_vdev_count;
190 	struct wlan_mlo_peer_list mlo_peer_list;
191 	uint16_t wlan_max_mlo_peer_count;
192 #ifdef WLAN_MLO_USE_SPINLOCK
193 	qdf_spinlock_t mlo_dev_lock;
194 #else
195 	qdf_mutex_t mlo_dev_lock;
196 #endif
197 	qdf_atomic_t ref_cnt;
198 	qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX];
199 	struct wlan_mlo_sta *sta_ctx;
200 	struct wlan_mlo_ap *ap_ctx;
201 };
202 
203 /*
204  * struct wlan_mlo_link_peer_entry – Link peer entry
205  * @link_peer: Object manager peer
206  * @link_addr: MAC address of link peer
207  * @link_ix: Link index
208  * @is_primary: sets true if the peer is primary UMAC’s peer
209  * @hw_link_id: HW Link id of peer
210  */
211 struct wlan_mlo_link_peer_entry {
212 	struct wlan_objmgr_peer *link_peer;
213 	struct qdf_mac_addr link_addr;
214 	uint8_t link_ix;
215 	bool is_primary;
216 	uint8_t hw_link_id;
217 };
218 
219 /*
220  * enum mlo_peer_state – MLO peer state
221  * @ML_PEER_CREATED:     Initial state
222  * @ML_PEER_ASSOC_DONE:  ASSOC sent on assoc link
223  * @ML_PEER_DISCONN_INITIATED: Disconnect initiated on one of the links
224  */
225 enum mlo_peer_state {
226 	ML_PEER_CREATED,
227 	ML_PEER_ASSOC_DONE,
228 	ML_PEER_DISCONN_INITIATED,
229 };
230 
231 /*
232  * struct wlan_mlo_peer_context - MLO peer context
233  *
234  * @peer_node:     peer list node for ml_dev qdf list
235  * @peer_list: list of peers on the MLO link
236  * @link_peer_cnt: Number of link peers attached
237  * @max_links: Max links for this ML peer
238  * @mlo_peer_id: unique ID for the peer
239  * @peer_mld_addr: MAC address of MLD link
240  * @mlo_ie: MLO IE struct
241  * @mlo_peer_lock: lock to access peer strucutre
242  * @assoc_id: Assoc ID derived by MLO manager
243  * @ref_cnt: Reference counter to avoid use after free
244  * @ml_dev: MLO dev context
245  * @mlpeer_state: MLO peer state
246  */
247 struct wlan_mlo_peer_context {
248 	qdf_list_node_t peer_node;
249 	struct wlan_mlo_link_peer_entry peer_list[MAX_MLO_LINK_PEERS];
250 	uint8_t link_peer_cnt;
251 	uint8_t max_links;
252 	uint32_t mlo_peer_id;
253 	struct qdf_mac_addr peer_mld_addr;
254 	uint8_t *mlo_ie;
255 #ifdef WLAN_MLO_USE_SPINLOCK
256 	qdf_spinlock_t mlo_peer_lock;
257 #else
258 	qdf_mutex_t mlo_peer_lock;
259 #endif
260 	uint16_t assoc_id;
261 	uint8_t primary_umac_psoc_id;
262 	qdf_atomic_t ref_cnt;
263 	struct wlan_mlo_dev_context *ml_dev;
264 	enum mlo_peer_state mlpeer_state;
265 };
266 
267 /*
268  * struct mlo_link_info – ML link info
269  * @link_addr: link mac address
270  * @link_id: link index
271  */
272 struct mlo_link_info {
273 	struct qdf_mac_addr link_addr;
274 	uint8_t link_id;
275 };
276 
277 /*
278  * struct mlo_partner_info – mlo partner link info
279  * @num_partner_links: no. of partner links
280  * @partner_link_info: per partner link info
281  */
282 struct mlo_partner_info {
283 	uint8_t num_partner_links;
284 	struct mlo_link_info partner_link_info[WLAN_UMAC_MLO_MAX_VDEVS];
285 };
286 
287 /*
288  * struct mlo_mlme_ext_ops - MLME callback functions
289  * @mlo_mlme_ext_validate_conn_req: Callback to validate connect request
290  * @mlo_mlme_ext_create_link_vdev: Callback to create link vdev for ML STA
291  * @mlo_mlme_ext_peer_create: Callback to create link peer
292  * @mlo_mlme_ext_peer_assoc: Callback to initiate peer assoc
293  * @mlo_mlme_ext_peer_assoc_fail: Callback to notify peer assoc failure
294  * @mlo_mlme_ext_peer_delete: Callback to initiate link peer delete
295  * @mlo_mlme_ext_assoc_resp: Callback to initiate assoc resp
296  */
297 struct mlo_mlme_ext_ops {
298 	QDF_STATUS (*mlo_mlme_ext_validate_conn_req)(
299 		    struct vdev_mlme_obj *vdev_mlme, void *ext_data);
300 	QDF_STATUS (*mlo_mlme_ext_create_link_vdev)(
301 		    struct vdev_mlme_obj *vdev_mlme, void *ext_data);
302 	void (*mlo_mlme_ext_peer_create)(struct wlan_objmgr_vdev *vdev,
303 					 struct wlan_mlo_peer_context *ml_peer,
304 					 struct qdf_mac_addr *addr,
305 					 qdf_nbuf_t frm_buf);
306 	void (*mlo_mlme_ext_peer_assoc)(struct wlan_objmgr_peer *peer);
307 	void (*mlo_mlme_ext_peer_assoc_fail)(struct wlan_objmgr_peer *peer);
308 	void (*mlo_mlme_ext_peer_delete)(struct wlan_objmgr_peer *peer);
309 	void (*mlo_mlme_ext_assoc_resp)(struct wlan_objmgr_peer *peer);
310 };
311 #endif
312