xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/be/mlo/dp_mlo.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
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 __DP_MLO_H
17 #define __DP_MLO_H
18 
19 #include <dp_types.h>
20 #include <dp_peer.h>
21 
22 /* Max number of chips that can participate in MLO */
23 #define DP_MAX_MLO_CHIPS WLAN_MAX_MLO_CHIPS
24 
25 /* Max number of peers supported */
26 #define DP_MAX_MLO_PEER 512
27 
28 /* Max number of chips supported */
29 #define DP_MLO_MAX_DEST_CHIP_ID 4
30 
31 /*
32  * NB: intentionally not using kernel-doc comment because the kernel-doc
33  *     script does not handle the TAILQ_HEAD macro
34  * struct dp_mlo_ctxt - datapath MLO context
35  *
36  * @ctrl_ctxt: opaque handle of cp mlo mgr
37  * @ml_soc_list: list of socs which are mlo enabled. This also maintains
38  *               mlo_chip_id to dp_soc mapping
39  * @ml_soc_cnt: number of SOCs
40  * @ml_soc_list_lock: lock to protect ml_soc_list
41  * @mld_peer_hash: peer hash table for ML peers
42  *           Associated peer with this MAC address)
43  * @mld_peer_hash_lock: lock to protect mld_peer_hash
44  * @toeplitz_hash_ipv4:
45  * @toeplitz_hash_ipv6:
46  * @link_to_pdev_map: link to pdev mapping
47  * @rx_fst: pointer to rx_fst handle
48  * @rx_fst_ref_cnt: ref count of rx_fst
49  * @grp_umac_reset_ctx: UMAC reset context at mlo group level
50  * @mlo_dev_list: list of MLO device context
51  * @mlo_dev_list_lock: lock to protect MLO device ctxt
52  */
53 struct dp_mlo_ctxt {
54 	struct cdp_ctrl_mlo_mgr *ctrl_ctxt;
55 	struct dp_soc *ml_soc_list[DP_MAX_MLO_CHIPS];
56 	uint8_t ml_soc_cnt;
57 	qdf_spinlock_t ml_soc_list_lock;
58 	struct {
59 		uint32_t mask;
60 		uint32_t idx_bits;
61 
62 		TAILQ_HEAD(, dp_peer) * bins;
63 	} mld_peer_hash;
64 
65 	qdf_spinlock_t mld_peer_hash_lock;
66 	uint32_t toeplitz_hash_ipv4[LRO_IPV4_SEED_ARR_SZ];
67 	uint32_t toeplitz_hash_ipv6[LRO_IPV6_SEED_ARR_SZ];
68 	struct dp_pdev_be *link_to_pdev_map[WLAN_MAX_MLO_CHIPS *
69 		WLAN_MAX_MLO_LINKS_PER_SOC];
70 #ifdef DP_UMAC_HW_RESET_SUPPORT
71 	struct dp_soc_mlo_umac_reset_ctx grp_umac_reset_ctx;
72 #endif
73 	/* MLO device ctxt list */
74 	TAILQ_HEAD(, dp_mlo_dev_ctxt) mlo_dev_list;
75 	qdf_spinlock_t mlo_dev_list_lock;
76 };
77 
78 /**
79  * dp_mlo_ctx_to_cdp() - typecast dp mlo context to CDP context
80  * @mlo_ctxt: DP MLO context
81  *
82  * Return: struct cdp_mlo_ctxt pointer
83  */
84 static inline
dp_mlo_ctx_to_cdp(struct dp_mlo_ctxt * mlo_ctxt)85 struct cdp_mlo_ctxt *dp_mlo_ctx_to_cdp(struct dp_mlo_ctxt *mlo_ctxt)
86 {
87 	return (struct cdp_mlo_ctxt *)mlo_ctxt;
88 }
89 
90 /**
91  * cdp_mlo_ctx_to_dp() - typecast CDP MLO context to DP MLO context
92  * @mlo_ctxt: CDP MLO context
93  *
94  * Return: struct dp_soc pointer
95  */
96 static inline
cdp_mlo_ctx_to_dp(struct cdp_mlo_ctxt * mlo_ctxt)97 struct dp_mlo_ctxt *cdp_mlo_ctx_to_dp(struct cdp_mlo_ctxt *mlo_ctxt)
98 {
99 	return (struct dp_mlo_ctxt *)mlo_ctxt;
100 }
101 
102 /**
103  * dp_soc_mlo_fill_params() - update SOC mlo params
104  * @soc: DP soc
105  * @params: soc attach params
106  *
107  * Return: struct dp_soc pointer
108  */
109 void dp_soc_mlo_fill_params(struct dp_soc *soc,
110 			    struct cdp_soc_attach_params *params);
111 
112 /**
113  * dp_pdev_mlo_fill_params() - update PDEV mlo params
114  * @pdev: DP PDEV
115  * @params: PDEV attach params
116  *
117  * Return: struct dp_soc pointer
118  */
119 void dp_pdev_mlo_fill_params(struct dp_pdev *pdev,
120 			     struct cdp_pdev_attach_params *params);
121 
122 /**
123  * dp_mlo_get_soc_ref_by_chip_id() - Get DP soc from DP ML context.
124  * @ml_ctxt: DP ML context handle
125  * @chip_id: MLO chip id
126  *
127  * This API will increment a reference count for DP soc. Caller has
128  * to take care for decrementing refcount.
129  *
130  * Return: dp_soc
131  */
132 struct dp_soc*
133 dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt, uint8_t chip_id);
134 
135 /**
136  * dp_mlo_get_rx_hash_key() - Get Rx hash key from MLO context
137  * @soc: DP SOC
138  * @lro_hash: Hash params
139  *
140  */
141 void dp_mlo_get_rx_hash_key(struct dp_soc *soc,
142 			    struct cdp_lro_hash_config *lro_hash);
143 
144 /**
145  * dp_mlo_rx_fst_deref() - decrement rx_fst
146  * @soc: dp soc
147  *
148  * return: soc cnt
149  */
150 uint8_t dp_mlo_rx_fst_deref(struct dp_soc *soc);
151 
152 /**
153  * dp_mlo_rx_fst_ref() - increment ref of rx_fst
154  * @soc: dp soc
155  *
156  */
157 void dp_mlo_rx_fst_ref(struct dp_soc *soc);
158 
159 /**
160  * dp_mlo_get_rx_fst() - Get Rx FST from MLO context
161  * @soc: DP SOC
162  *
163  * Return: struct dp_rx_fst pointer
164  */
165 struct dp_rx_fst *dp_mlo_get_rx_fst(struct dp_soc *soc);
166 
167 /**
168  * dp_mlo_set_rx_fst() - Set Rx FST in MLO context
169  * @soc: DP SOC
170  * @fst: pointer dp_rx_fst
171  *
172  */
173 void dp_mlo_set_rx_fst(struct dp_soc *soc, struct dp_rx_fst *fst);
174 
175 /**
176  * dp_mlo_update_link_to_pdev_map() - map link-id to pdev mapping
177  * @soc: DP SOC
178  * @pdev: DP PDEV
179  *
180  * Return: none
181  */
182 void dp_mlo_update_link_to_pdev_map(struct dp_soc *soc, struct dp_pdev *pdev);
183 
184 /**
185  * dp_mlo_update_link_to_pdev_unmap() - unmap link-id to pdev mapping
186  * @soc: DP SOC
187  * @pdev: DP PDEV
188  *
189  * Return: none
190  */
191 void dp_mlo_update_link_to_pdev_unmap(struct dp_soc *soc, struct dp_pdev *pdev);
192 
193 /**
194  * dp_mlo_get_delta_tsf2_wrt_mlo_offset() - Get delta between mlo timestamp
195  *                                          offset and delta tsf2
196  * @soc: DP SOC
197  * @hw_link_id: link id
198  *
199  * Return: int32_t
200  */
201 int32_t dp_mlo_get_delta_tsf2_wrt_mlo_offset(struct dp_soc *soc,
202 					     uint8_t hw_link_id);
203 
204 /**
205  * dp_mlo_get_delta_tqm_wrt_mlo_offset() - Get delta between mlo timestamp
206  *                                         offset and delta tqm
207  * @soc: DP SOC
208  *
209  * Return: int32_t
210  */
211 int32_t dp_mlo_get_delta_tqm_wrt_mlo_offset(struct dp_soc *soc);
212 
213 /**
214  * dp_get_interface_stats_be() - get vdev stats for ath interface
215  * @soc_hdl: CDP SoC handle
216  * @vdev_id: vdev Id
217  * @buf: buffer for vdev stats
218  * @is_aggregate: for aggregation
219  *
220  * Return: QDF_STATUS
221  */
222 QDF_STATUS
223 dp_get_interface_stats_be(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
224 			  void *buf, bool is_aggregate);
225 
226 /*
227  * dp_mlo_debug_print_ptnr_info() - print partner info
228  * @vdev: DP VDEV
229  *
230  * Return: none
231  */
232 void dp_mlo_debug_print_ptnr_info(struct dp_vdev *vdev);
233 
234 /*
235  * dp_mlo_get_chip_id() - return MLO chip id
236  * @soc: DP soc
237  *
238  * Return: chip_id
239  */
240 uint8_t dp_mlo_get_chip_id(struct dp_soc *soc);
241 
242 /*
243  * dp_mlo_link_peer_hash_find_by_chip_id() - returns mlo link peer on chip_id
244  *			      peer_hash_table matching vdev_id and mac_address
245  * @soc: partner soc handle in MLO
246  * @peer_mac_addr: peer mac address
247  * @mac_addr_is_aligned: is mac addr aligned
248  * @vdev_id: vdev_id
249  * @chip_id: mlo_chip_id
250  * @mod_id: id of module requesting reference
251  *
252  * return: peer in success
253  *         NULL in failure
254  */
255 struct dp_peer *
256 dp_mlo_link_peer_hash_find_by_chip_id(struct dp_soc *soc,
257 				      uint8_t *peer_mac_addr,
258 				      int mac_addr_is_aligned,
259 				      uint8_t vdev_id,
260 				      uint8_t chip_id,
261 				      enum dp_mod_id mod_id);
262 #endif /* __DP_MLO_H */
263