1 /*
2 * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 /**
19 * DOC: Implements PSOC MLME public APIs
20 */
21
22 #include <wlan_objmgr_psoc_obj.h>
23 #include <wlan_mlme_dbg.h>
24 #include <include/wlan_psoc_mlme.h>
25 #include <wlan_psoc_mlme_api.h>
26 #include <qdf_module.h>
27 #include "cfg_ucfg_api.h"
28 #include "wlan_vdev_mgr_tgt_if_rx_api.h"
29 #include <qdf_platform.h>
30
31 QDF_STATUS
wlan_psoc_mlme_get_11be_capab(struct wlan_objmgr_psoc * psoc,bool * val)32 wlan_psoc_mlme_get_11be_capab(struct wlan_objmgr_psoc *psoc, bool *val)
33 {
34 struct psoc_mlme_obj *psoc_mlme;
35
36 psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
37 if (!psoc_mlme) {
38 mlme_err("psoc_mlme is NULL");
39 return QDF_STATUS_E_FAILURE;
40 }
41
42 *val = psoc_mlme->psoc_cfg.phy_config.eht_cap;
43 return QDF_STATUS_SUCCESS;
44 }
45
46 qdf_export_symbol(wlan_psoc_mlme_get_11be_capab);
47
48 QDF_STATUS
wlan_psoc_mlme_set_11be_capab(struct wlan_objmgr_psoc * psoc,bool val)49 wlan_psoc_mlme_set_11be_capab(struct wlan_objmgr_psoc *psoc, bool val)
50 {
51 struct psoc_mlme_obj *psoc_mlme;
52
53 psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
54 if (!psoc_mlme) {
55 mlme_err("psoc_mlme is NULL");
56 return QDF_STATUS_E_FAILURE;
57 }
58
59 psoc_mlme->psoc_cfg.phy_config.eht_cap &= val;
60 return QDF_STATUS_SUCCESS;
61 }
62
63 qdf_export_symbol(wlan_psoc_mlme_set_11be_capab);
64
wlan_psoc_mlme_get_cmpt_obj(struct wlan_objmgr_psoc * psoc)65 struct psoc_mlme_obj *wlan_psoc_mlme_get_cmpt_obj(struct wlan_objmgr_psoc *psoc)
66 {
67 struct psoc_mlme_obj *psoc_mlme;
68
69 psoc_mlme = wlan_objmgr_psoc_get_comp_private_obj(psoc,
70 WLAN_UMAC_COMP_MLME);
71 if (!psoc_mlme) {
72 mlme_err("PSOC MLME component object is NULL");
73 return NULL;
74 }
75
76 return psoc_mlme;
77 }
78
79 qdf_export_symbol(wlan_psoc_mlme_get_cmpt_obj);
80
81 #ifdef WLAN_FEATURE_11BE_MLO_ADV_FEATURE
wlan_mlme_psoc_peer_trans_hist_remove_back(qdf_list_t * peer_history)82 void wlan_mlme_psoc_peer_trans_hist_remove_back(qdf_list_t *peer_history)
83 {
84 struct wlan_peer_tbl_trans_entry *peer_trans_entry;
85 qdf_list_node_t *node;
86
87 qdf_list_remove_back(peer_history, &node);
88 peer_trans_entry = qdf_container_of(node,
89 struct wlan_peer_tbl_trans_entry,
90 node);
91 qdf_mem_free(peer_trans_entry);
92 }
93
94 QDF_STATUS
wlan_mlme_psoc_peer_tbl_trans_add_entry(struct wlan_objmgr_psoc * psoc,struct wlan_peer_tbl_trans_entry * peer_trans_entry)95 wlan_mlme_psoc_peer_tbl_trans_add_entry(struct wlan_objmgr_psoc *psoc,
96 struct wlan_peer_tbl_trans_entry *peer_trans_entry)
97 {
98 struct psoc_mlme_obj *psoc_mlme;
99 qdf_list_t *peer_hist_list;
100
101 psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
102 if (!psoc_mlme) {
103 mlme_err("PSOC MLME component object is NULL");
104 return QDF_STATUS_E_FAILURE;
105 }
106
107 peer_hist_list = &psoc_mlme->peer_history_list;
108 if (qdf_list_size(peer_hist_list) == MAX_PEER_HIST_LIST_SIZE)
109 wlan_mlme_psoc_peer_trans_hist_remove_back(peer_hist_list);
110
111 return qdf_list_insert_front(peer_hist_list, &peer_trans_entry->node);
112 }
113
wlan_mlme_psoc_flush_peer_trans_history(struct wlan_objmgr_psoc * psoc)114 void wlan_mlme_psoc_flush_peer_trans_history(struct wlan_objmgr_psoc *psoc)
115 {
116 struct psoc_mlme_obj *psoc_mlme;
117 qdf_list_t *peer_hist_list;
118
119 psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
120 if (!psoc_mlme) {
121 mlme_err("PSOC MLME component object is NULL");
122 return;
123 }
124
125 peer_hist_list = &psoc_mlme->peer_history_list;
126 while (qdf_list_size(peer_hist_list))
127 wlan_mlme_psoc_peer_trans_hist_remove_back(peer_hist_list);
128
129 qdf_list_destroy(peer_hist_list);
130 }
131 #endif
132
wlan_psoc_mlme_get_ext_hdl(struct wlan_objmgr_psoc * psoc)133 mlme_psoc_ext_t *wlan_psoc_mlme_get_ext_hdl(struct wlan_objmgr_psoc *psoc)
134 {
135 struct psoc_mlme_obj *psoc_mlme;
136
137 psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
138 if (psoc_mlme)
139 return psoc_mlme->ext_psoc_ptr;
140
141 return NULL;
142 }
143
144 qdf_export_symbol(wlan_psoc_mlme_get_ext_hdl);
145
wlan_psoc_mlme_set_ext_hdl(struct psoc_mlme_obj * psoc_mlme,mlme_psoc_ext_t * psoc_ext_hdl)146 void wlan_psoc_mlme_set_ext_hdl(struct psoc_mlme_obj *psoc_mlme,
147 mlme_psoc_ext_t *psoc_ext_hdl)
148 {
149 psoc_mlme->ext_psoc_ptr = psoc_ext_hdl;
150 }
151
wlan_psoc_set_phy_config(struct wlan_objmgr_psoc * psoc,struct psoc_phy_config * phy_config)152 void wlan_psoc_set_phy_config(struct wlan_objmgr_psoc *psoc,
153 struct psoc_phy_config *phy_config)
154 {
155 struct psoc_mlme_obj *mlme_psoc_obj;
156 struct psoc_phy_config *config;
157
158 if (!phy_config) {
159 mlme_err("phy_config is NUll");
160 return;
161 }
162 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
163 if (!mlme_psoc_obj)
164 return;
165
166 config = &mlme_psoc_obj->psoc_cfg.phy_config;
167
168 qdf_mem_copy(config, phy_config, sizeof(*config));
169 }
170
mlme_init_cfg(struct wlan_objmgr_psoc * psoc)171 static void mlme_init_cfg(struct wlan_objmgr_psoc *psoc)
172 {
173 struct psoc_mlme_obj *mlme_psoc_obj;
174
175 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
176
177 if (!mlme_psoc_obj)
178 return;
179
180 wlan_cm_init_score_config(psoc, &mlme_psoc_obj->psoc_cfg.score_config);
181 mlme_psoc_obj->psoc_cfg.phy_config.max_chan_switch_ie =
182 cfg_get(psoc, CFG_MLME_MAX_CHAN_SWITCH_IE_ENABLE);
183 mlme_psoc_obj->psoc_cfg.phy_config.eht_cap =
184 cfg_default(CFG_MLME_11BE_TARGET_CAPAB);
185 mlme_psoc_obj->psoc_cfg.mlo_config.reconfig_reassoc_en =
186 cfg_get(psoc, CFG_MLME_MLO_RECONFIG_REASSOC_ENABLE);
187 }
188
mlme_psoc_open(struct wlan_objmgr_psoc * psoc)189 QDF_STATUS mlme_psoc_open(struct wlan_objmgr_psoc *psoc)
190 {
191 mlme_init_cfg(psoc);
192
193 return QDF_STATUS_SUCCESS;
194 }
195
mlme_psoc_close(struct wlan_objmgr_psoc * psoc)196 QDF_STATUS mlme_psoc_close(struct wlan_objmgr_psoc *psoc)
197 {
198 if (qdf_is_recovering())
199 tgt_vdev_mgr_reset_response_timer_info(psoc);
200 return QDF_STATUS_SUCCESS;
201 }
202
203 qdf_export_symbol(wlan_psoc_mlme_set_ext_hdl);
204