xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlme/psoc_mgr/dispatcher/src/wlan_psoc_mlme_api.c (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021 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 struct psoc_mlme_obj *wlan_psoc_mlme_get_cmpt_obj(struct wlan_objmgr_psoc *psoc)
32 {
33 	struct psoc_mlme_obj *psoc_mlme;
34 
35 	psoc_mlme = wlan_objmgr_psoc_get_comp_private_obj(psoc,
36 							  WLAN_UMAC_COMP_MLME);
37 	if (!psoc_mlme) {
38 		mlme_err("PSOC MLME component object is NULL");
39 		return NULL;
40 	}
41 
42 	return psoc_mlme;
43 }
44 
45 qdf_export_symbol(wlan_psoc_mlme_get_cmpt_obj);
46 
47 mlme_psoc_ext_t *wlan_psoc_mlme_get_ext_hdl(struct wlan_objmgr_psoc *psoc)
48 {
49 	struct psoc_mlme_obj *psoc_mlme;
50 
51 	psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc);
52 	if (psoc_mlme)
53 		return psoc_mlme->ext_psoc_ptr;
54 
55 	return NULL;
56 }
57 
58 qdf_export_symbol(wlan_psoc_mlme_get_ext_hdl);
59 
60 void wlan_psoc_mlme_set_ext_hdl(struct psoc_mlme_obj *psoc_mlme,
61 				mlme_psoc_ext_t *psoc_ext_hdl)
62 {
63 	psoc_mlme->ext_psoc_ptr = psoc_ext_hdl;
64 }
65 
66 void wlan_psoc_set_phy_config(struct wlan_objmgr_psoc *psoc,
67 			      struct psoc_phy_config *phy_config)
68 {
69 	struct psoc_mlme_obj *mlme_psoc_obj;
70 	struct psoc_phy_config *config;
71 
72 	if (!phy_config) {
73 		mlme_err("phy_config is NUll");
74 		return;
75 	}
76 	mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
77 	if (!mlme_psoc_obj)
78 		return;
79 
80 	config = &mlme_psoc_obj->psoc_cfg.phy_config;
81 
82 	qdf_mem_copy(config, phy_config, sizeof(*config));
83 }
84 
85 static void mlme_init_cfg(struct wlan_objmgr_psoc *psoc)
86 {
87 	struct psoc_mlme_obj *mlme_psoc_obj;
88 
89 	mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
90 
91 	if (!mlme_psoc_obj)
92 		return;
93 
94 	wlan_cm_init_score_config(psoc, &mlme_psoc_obj->psoc_cfg.score_config);
95 	mlme_psoc_obj->psoc_cfg.phy_config.max_chan_switch_ie =
96 		cfg_get(psoc, CFG_MLME_MAX_CHAN_SWITCH_IE_ENABLE);
97 }
98 
99 QDF_STATUS mlme_psoc_open(struct wlan_objmgr_psoc *psoc)
100 {
101 	mlme_init_cfg(psoc);
102 
103 	return QDF_STATUS_SUCCESS;
104 }
105 
106 QDF_STATUS mlme_psoc_close(struct wlan_objmgr_psoc *psoc)
107 {
108 	if (qdf_is_recovering())
109 		tgt_vdev_mgr_reset_response_timer_info(psoc);
110 	return QDF_STATUS_SUCCESS;
111 }
112 
113 qdf_export_symbol(wlan_psoc_mlme_set_ext_hdl);
114