xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/be/mlo/dp_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 __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 3
30 
31 /*
32  * dp_mlo_ctxt
33  *
34  * @ctrl_ctxt: opaque handle of cp mlo mgr
35  * @ml_soc_list: list of socs which are mlo enabled. This also maintains
36  *               mlo_chip_id to dp_soc mapping
37  * @ml_soc_cnt: number of SOCs
38  * @ml_soc_list_lock: lock to protect ml_soc_list
39  * @mld_peer_hash: peer hash table for ML peers
40  *           Associated peer with this MAC address)
41  * @mld_peer_hash_lock: lock to protect mld_peer_hash
42  * @link_to_pdev_map: link to pdev mapping
43  * @rx_fst: pointer to rx_fst handle
44  * @rx_fst_ref_cnt: ref count of rx_fst
45  */
46 struct dp_mlo_ctxt {
47 	struct cdp_ctrl_mlo_mgr *ctrl_ctxt;
48 	struct dp_soc *ml_soc_list[DP_MAX_MLO_CHIPS];
49 	uint8_t ml_soc_cnt;
50 	qdf_spinlock_t ml_soc_list_lock;
51 	struct {
52 		uint32_t mask;
53 		uint32_t idx_bits;
54 
55 		TAILQ_HEAD(, dp_peer) * bins;
56 	} mld_peer_hash;
57 
58 	qdf_spinlock_t mld_peer_hash_lock;
59 	uint32_t toeplitz_hash_ipv4[LRO_IPV4_SEED_ARR_SZ];
60 	uint32_t toeplitz_hash_ipv6[LRO_IPV6_SEED_ARR_SZ];
61 	struct dp_pdev_be *link_to_pdev_map[WLAN_MAX_MLO_CHIPS *
62 		WLAN_MAX_MLO_LINKS_PER_SOC];
63 	struct dp_rx_fst *rx_fst;
64 	uint8_t rx_fst_ref_cnt;
65 };
66 
67 /**
68  * dp_mlo_ctx_to_cdp() - typecast dp mlo context to CDP context
69  * @mlo_ctxt: DP MLO context
70  *
71  * Return: struct cdp_mlo_ctxt pointer
72  */
73 static inline
74 struct cdp_mlo_ctxt *dp_mlo_ctx_to_cdp(struct dp_mlo_ctxt *mlo_ctxt)
75 {
76 	return (struct cdp_mlo_ctxt *)mlo_ctxt;
77 }
78 
79 /**
80  * cdp_mlo_ctx_to_dp() - typecast cdp_soc_t to
81  * dp soc handle
82  * @psoc: CDP psoc handle
83  *
84  * Return: struct dp_soc pointer
85  */
86 static inline
87 struct dp_mlo_ctxt *cdp_mlo_ctx_to_dp(struct cdp_mlo_ctxt *mlo_ctxt)
88 {
89 	return (struct dp_mlo_ctxt *)mlo_ctxt;
90 }
91 
92 /**
93  * dp_soc_mlo_fill_params() - update SOC mlo params
94  * @soc: DP soc
95  * @params: soc attach params
96  *
97  * Return: struct dp_soc pointer
98  */
99 void dp_soc_mlo_fill_params(struct dp_soc *soc,
100 			    struct cdp_soc_attach_params *params);
101 
102 /**
103  * dp_pdev_mlo_fill_params() - update PDEV mlo params
104  * @pdev: DP PDEV
105  * @params: PDEV attach params
106  *
107  * Return: struct dp_soc pointer
108  */
109 void dp_pdev_mlo_fill_params(struct dp_pdev *pdev,
110 			     struct cdp_pdev_attach_params *params);
111 struct dp_soc*
112 dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt, uint8_t chip_id);
113 
114 /**
115  * dp_mlo_get_rx_hash_key() - Get Rx hash key from MLO context
116  * @soc: DP SOC
117  * @lro_hash: Hash params
118  *
119  */
120 void dp_mlo_get_rx_hash_key(struct dp_soc *soc,
121 			    struct cdp_lro_hash_config *lro_hash);
122 
123 /**
124  * dp_mlo_rx_fst_deref() - decrement rx_fst
125  * @soc: dp soc
126  *
127  * return: soc cnt
128  */
129 uint8_t dp_mlo_rx_fst_deref(struct dp_soc *soc);
130 
131 /**
132  * dp_mlo_rx_fst_ref() - increment ref of rx_fst
133  * @soc: dp soc
134  *
135  */
136 void dp_mlo_rx_fst_ref(struct dp_soc *soc);
137 
138 /**
139  * dp_mlo_get_rx_fst() - Get Rx FST from MLO context
140  * @soc: DP SOC
141  *
142  * Return: struct dp_rx_fst pointer
143  */
144 struct dp_rx_fst *dp_mlo_get_rx_fst(struct dp_soc *soc);
145 
146 /**
147  * dp_mlo_set_rx_fst() - Set Rx FST in MLO context
148  * @soc: DP SOC
149  * @fst: pointer dp_rx_fst
150  *
151  */
152 void dp_mlo_set_rx_fst(struct dp_soc *soc, struct dp_rx_fst *fst);
153 
154 /**
155  * dp_mlo_update_link_to_pdev_map : map link-id to pdev mapping
156  * @soc: DP SOC
157  * @pdev: DP PDEV
158  *
159  * Return: none
160  */
161 void dp_mlo_update_link_to_pdev_map(struct dp_soc *soc, struct dp_pdev *pdev);
162 
163 /**
164  * dp_mlo_update_link_to_pdev_unmap : unmap link-id to pdev mapping
165  * @soc: DP SOC
166  * @pdev: DP PDEV
167  *
168  * Return: none
169  */
170 void dp_mlo_update_link_to_pdev_unmap(struct dp_soc *soc, struct dp_pdev *pdev);
171 
172 /**
173  * dp_mlo_get_delta_tsf2_wrt_mlo_offset() - Get delta between mlo timestamp
174  *                                          offset and delta tsf2
175  * @soc: DP SOC
176  * @hw_link_id: link id
177  *
178  * Return: int32_t
179  */
180 int32_t dp_mlo_get_delta_tsf2_wrt_mlo_offset(struct dp_soc *soc,
181 					     uint8_t hw_link_id);
182 
183 /**
184  * dp_mlo_get_delta_tqm_wrt_mlo_offset() - Get delta between mlo timestamp
185  *                                         offset and delta tqm
186  * @soc: DP SOC
187  *
188  * Return: int32_t
189  */
190 int32_t dp_mlo_get_delta_tqm_wrt_mlo_offset(struct dp_soc *soc);
191 #endif /* __DP_MLO_H */
192