1 /*
2 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 /**
21 * DOC: contains NAN INI configurations
22 */
23
24 #include "wlan_objmgr_psoc_obj.h"
25 #include "cfg_nan_api.h"
26 #include "../../core/src/nan_main_i.h"
27 #include "wlan_mlme_ucfg_api.h"
28 #include "cfg_ucfg_api.h"
29 #include "cfg_nan.h"
30
31 static inline struct nan_psoc_priv_obj
cfg_nan_get_priv_obj(struct wlan_objmgr_psoc * psoc)32 *cfg_nan_get_priv_obj(struct wlan_objmgr_psoc *psoc)
33 {
34 if (!psoc) {
35 nan_err("PSOC obj null");
36 return NULL;
37 }
38 return wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_NAN);
39 }
40
cfg_nan_get_enable(struct wlan_objmgr_psoc * psoc)41 bool cfg_nan_get_enable(struct wlan_objmgr_psoc *psoc)
42 {
43 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
44
45 if (!nan_obj) {
46 nan_err("NAN obj null");
47 return false;
48 }
49 return nan_obj->cfg_param.enable;
50 }
51
cfg_nan_get_datapath_enable(struct wlan_objmgr_psoc * psoc)52 bool cfg_nan_get_datapath_enable(struct wlan_objmgr_psoc *psoc)
53 {
54 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
55
56 if (!nan_obj) {
57 nan_err("NAN obj null");
58 return false;
59 }
60 return nan_obj->cfg_param.dp_enable;
61 }
62
cfg_nan_get_ndi_mac_randomize(struct wlan_objmgr_psoc * psoc)63 bool cfg_nan_get_ndi_mac_randomize(struct wlan_objmgr_psoc *psoc)
64 {
65 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
66
67 if (!nan_obj) {
68 nan_err("NAN obj null");
69 return false;
70 }
71 return nan_obj->cfg_param.ndi_mac_randomize;
72 }
73
cfg_nan_get_ndp_inactivity_timeout(struct wlan_objmgr_psoc * psoc,uint16_t * val)74 QDF_STATUS cfg_nan_get_ndp_inactivity_timeout(struct wlan_objmgr_psoc *psoc,
75 uint16_t *val)
76 {
77 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
78
79 if (!nan_obj) {
80 nan_err("NAN obj null");
81 return QDF_STATUS_E_INVAL;
82 }
83
84 *val = nan_obj->cfg_param.ndp_inactivity_timeout;
85 return QDF_STATUS_SUCCESS;
86 }
87
cfg_nan_get_ndp_keepalive_period(struct wlan_objmgr_psoc * psoc,uint16_t * val)88 QDF_STATUS cfg_nan_get_ndp_keepalive_period(struct wlan_objmgr_psoc *psoc,
89 uint16_t *val)
90 {
91 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
92
93 if (!nan_obj) {
94 nan_err("NAN obj null");
95 return QDF_STATUS_E_INVAL;
96 }
97
98 *val = nan_obj->cfg_param.ndp_keep_alive_period;
99 return QDF_STATUS_SUCCESS;
100 }
101
cfg_nan_get_ndp_max_sessions(struct wlan_objmgr_psoc * psoc,uint32_t * val)102 QDF_STATUS cfg_nan_get_ndp_max_sessions(struct wlan_objmgr_psoc *psoc,
103 uint32_t *val)
104 {
105 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
106
107 if (!nan_obj) {
108 nan_err("NAN obj null");
109 *val = cfg_default(CFG_NDP_MAX_SESSIONS);
110 return QDF_STATUS_E_INVAL;
111 }
112
113 *val = nan_obj->cfg_param.max_ndp_sessions;
114 return QDF_STATUS_SUCCESS;
115 }
116
cfg_nan_get_max_ndi(struct wlan_objmgr_psoc * psoc,uint32_t * val)117 QDF_STATUS cfg_nan_get_max_ndi(struct wlan_objmgr_psoc *psoc, uint32_t *val)
118 {
119 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
120
121 if (!nan_obj) {
122 nan_err("NAN obj null");
123 *val = cfg_default(CFG_NDI_MAX_SUPPORT);
124 return QDF_STATUS_E_INVAL;
125 }
126
127 *val = nan_obj->cfg_param.max_ndi;
128 return QDF_STATUS_SUCCESS;
129 }
130
cfg_nan_get_support_mp0_discovery(struct wlan_objmgr_psoc * psoc)131 bool cfg_nan_get_support_mp0_discovery(struct wlan_objmgr_psoc *psoc)
132 {
133 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
134
135 if (!nan_obj) {
136 nan_err("NAN obj null");
137 return false;
138 }
139
140 return nan_obj->cfg_param.support_mp0_discovery;
141 }
142
cfg_nan_is_roam_config_disabled(struct wlan_objmgr_psoc * psoc)143 bool cfg_nan_is_roam_config_disabled(struct wlan_objmgr_psoc *psoc)
144 {
145 uint32_t sta_roam_disable;
146
147 if (ucfg_mlme_get_roam_disable_config(psoc, &sta_roam_disable) ==
148 QDF_STATUS_SUCCESS)
149 return sta_roam_disable & LFR3_STA_ROAM_DISABLE_BY_NAN;
150
151 return false;
152 }
153
cfg_nan_is_eht_cap_enable(struct wlan_objmgr_psoc * psoc)154 bool cfg_nan_is_eht_cap_enable(struct wlan_objmgr_psoc *psoc)
155 {
156 struct nan_psoc_priv_obj *nan_obj = cfg_nan_get_priv_obj(psoc);
157
158 if (!nan_obj) {
159 nan_err("nan psoc priv object is NULL");
160 return cfg_default(CFG_NAN_ENABLE_EHT_CAP);
161 }
162
163 return nan_obj->cfg_param.enable_nan_eht_cap;
164 }
165