xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlme/psoc_mgr/dispatcher/src/wlan_psoc_mlme_api.c (revision 8b3dca18206e1a0461492f082fa6e270b092c035)
1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 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
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_STATUS
47 wlan_psoc_mlme_set_11be_capab(struct wlan_objmgr_psoc *psoc, bool val)
48 {
49 	struct psoc_mlme_obj *psoc_mlme;
50 
51 	psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
52 	if (!psoc_mlme) {
53 		mlme_err("psoc_mlme is NULL");
54 		return QDF_STATUS_E_FAILURE;
55 	}
56 
57 	psoc_mlme->psoc_cfg.phy_config.eht_cap &= val;
58 	return QDF_STATUS_SUCCESS;
59 }
60 
61 struct psoc_mlme_obj *wlan_psoc_mlme_get_cmpt_obj(struct wlan_objmgr_psoc *psoc)
62 {
63 	struct psoc_mlme_obj *psoc_mlme;
64 
65 	psoc_mlme = wlan_objmgr_psoc_get_comp_private_obj(psoc,
66 							  WLAN_UMAC_COMP_MLME);
67 	if (!psoc_mlme) {
68 		mlme_err("PSOC MLME component object is NULL");
69 		return NULL;
70 	}
71 
72 	return psoc_mlme;
73 }
74 
75 qdf_export_symbol(wlan_psoc_mlme_get_cmpt_obj);
76 
77 mlme_psoc_ext_t *wlan_psoc_mlme_get_ext_hdl(struct wlan_objmgr_psoc *psoc)
78 {
79 	struct psoc_mlme_obj *psoc_mlme;
80 
81 	psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
82 	if (psoc_mlme)
83 		return psoc_mlme->ext_psoc_ptr;
84 
85 	return NULL;
86 }
87 
88 qdf_export_symbol(wlan_psoc_mlme_get_ext_hdl);
89 
90 void wlan_psoc_mlme_set_ext_hdl(struct psoc_mlme_obj *psoc_mlme,
91 				mlme_psoc_ext_t *psoc_ext_hdl)
92 {
93 	psoc_mlme->ext_psoc_ptr = psoc_ext_hdl;
94 }
95 
96 void wlan_psoc_set_phy_config(struct wlan_objmgr_psoc *psoc,
97 			      struct psoc_phy_config *phy_config)
98 {
99 	struct psoc_mlme_obj *mlme_psoc_obj;
100 	struct psoc_phy_config *config;
101 
102 	if (!phy_config) {
103 		mlme_err("phy_config is NUll");
104 		return;
105 	}
106 	mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
107 	if (!mlme_psoc_obj)
108 		return;
109 
110 	config = &mlme_psoc_obj->psoc_cfg.phy_config;
111 
112 	qdf_mem_copy(config, phy_config, sizeof(*config));
113 }
114 
115 static void mlme_init_cfg(struct wlan_objmgr_psoc *psoc)
116 {
117 	struct psoc_mlme_obj *mlme_psoc_obj;
118 
119 	mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
120 
121 	if (!mlme_psoc_obj)
122 		return;
123 
124 	wlan_cm_init_score_config(psoc, &mlme_psoc_obj->psoc_cfg.score_config);
125 	mlme_psoc_obj->psoc_cfg.phy_config.max_chan_switch_ie =
126 		cfg_get(psoc, CFG_MLME_MAX_CHAN_SWITCH_IE_ENABLE);
127 	mlme_psoc_obj->psoc_cfg.phy_config.eht_cap =
128 		cfg_default(CFG_MLME_11BE_TARGET_CAPAB);
129 }
130 
131 QDF_STATUS mlme_psoc_open(struct wlan_objmgr_psoc *psoc)
132 {
133 	mlme_init_cfg(psoc);
134 
135 	return QDF_STATUS_SUCCESS;
136 }
137 
138 QDF_STATUS mlme_psoc_close(struct wlan_objmgr_psoc *psoc)
139 {
140 	if (qdf_is_recovering())
141 		tgt_vdev_mgr_reset_response_timer_info(psoc);
142 	return QDF_STATUS_SUCCESS;
143 }
144 
145 qdf_export_symbol(wlan_psoc_mlme_set_ext_hdl);
146