xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/be/mlo/dp_mlo.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2021-2022 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_list_lock: lock to protect ml_soc_list
38  * @mld_peer_hash: peer hash table for ML peers
39  *           Associated peer with this MAC address)
40  * @mld_peer_hash_lock: lock to protect mld_peer_hash
41  * @link_to_pdev_map: link to pdev mapping
42  */
43 struct dp_mlo_ctxt {
44 	struct cdp_ctrl_mlo_mgr *ctrl_ctxt;
45 	struct dp_soc *ml_soc_list[DP_MAX_MLO_CHIPS];
46 	qdf_spinlock_t ml_soc_list_lock;
47 	struct {
48 		uint32_t mask;
49 		uint32_t idx_bits;
50 
51 		TAILQ_HEAD(, dp_peer) * bins;
52 	} mld_peer_hash;
53 
54 	qdf_spinlock_t mld_peer_hash_lock;
55 	uint32_t toeplitz_hash_ipv4[LRO_IPV4_SEED_ARR_SZ];
56 	uint32_t toeplitz_hash_ipv6[LRO_IPV6_SEED_ARR_SZ];
57 	struct dp_pdev_be *link_to_pdev_map[WLAN_MAX_MLO_CHIPS *
58 		WLAN_MAX_MLO_LINKS_PER_SOC];
59 };
60 
61 /**
62  * dp_mlo_ctx_to_cdp() - typecast dp mlo context to CDP context
63  * @mlo_ctxt: DP MLO context
64  *
65  * Return: struct cdp_mlo_ctxt pointer
66  */
67 static inline
68 struct cdp_mlo_ctxt *dp_mlo_ctx_to_cdp(struct dp_mlo_ctxt *mlo_ctxt)
69 {
70 	return (struct cdp_mlo_ctxt *)mlo_ctxt;
71 }
72 
73 /**
74  * cdp_mlo_ctx_to_dp() - typecast cdp_soc_t to
75  * dp soc handle
76  * @psoc: CDP psoc handle
77  *
78  * Return: struct dp_soc pointer
79  */
80 static inline
81 struct dp_mlo_ctxt *cdp_mlo_ctx_to_dp(struct cdp_mlo_ctxt *mlo_ctxt)
82 {
83 	return (struct dp_mlo_ctxt *)mlo_ctxt;
84 }
85 
86 /**
87  * dp_soc_mlo_fill_params() - update SOC mlo params
88  * @soc: DP soc
89  * @params: soc attach params
90  *
91  * Return: struct dp_soc pointer
92  */
93 void dp_soc_mlo_fill_params(struct dp_soc *soc,
94 			    struct cdp_soc_attach_params *params);
95 
96 /**
97  * dp_pdev_mlo_fill_params() - update PDEV mlo params
98  * @pdev: DP PDEV
99  * @params: PDEV attach params
100  *
101  * Return: struct dp_soc pointer
102  */
103 void dp_pdev_mlo_fill_params(struct dp_pdev *pdev,
104 			     struct cdp_pdev_attach_params *params);
105 struct dp_soc*
106 dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt, uint8_t chip_id);
107 
108 /**
109  * dp_mlo_get_rx_hash_key() - Get Rx hash key from MLO context
110  * @soc: DP SOC
111  * @lro_hash: Hash params
112  *
113  */
114 void dp_mlo_get_rx_hash_key(struct dp_soc *soc,
115 			    struct cdp_lro_hash_config *lro_hash);
116 
117 /**
118  * dp_mlo_update_link_to_pdev_map : map link-id to pdev mapping
119  * @soc: DP SOC
120  * @pdev: DP PDEV
121  *
122  * Return: none
123  */
124 void dp_mlo_update_link_to_pdev_map(struct dp_soc *soc, struct dp_pdev *pdev);
125 
126 /**
127  * dp_mlo_update_link_to_pdev_unmap : unmap link-id to pdev mapping
128  * @soc: DP SOC
129  * @pdev: DP PDEV
130  *
131  * Return: none
132  */
133 void dp_mlo_update_link_to_pdev_unmap(struct dp_soc *soc, struct dp_pdev *pdev);
134 
135 /**
136  * dp_mlo_get_delta_tsf2_wrt_mlo_offset() - Get delta between mlo timestamp
137  *                                          offset and delta tsf2
138  * @soc: DP SOC
139  * @hw_link_id: link id
140  *
141  * Return: int32_t
142  */
143 int32_t dp_mlo_get_delta_tsf2_wrt_mlo_offset(struct dp_soc *soc,
144 					     uint8_t hw_link_id);
145 
146 /**
147  * dp_mlo_get_delta_tqm_wrt_mlo_offset() - Get delta between mlo timestamp
148  *                                         offset and delta tqm
149  * @soc: DP SOC
150  *
151  * Return: int32_t
152  */
153 int32_t dp_mlo_get_delta_tqm_wrt_mlo_offset(struct dp_soc *soc);
154 #endif /* __DP_MLO_H */
155