xref: /wlan-driver/qcacld-3.0/components/denylist_mgr/core/inc/wlan_dlm_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
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
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  * DOC: declare internal APIs related to the denylist manager component
21  */
22 
23 #ifndef _WLAN_DLM_MAIN_H_
24 #define _WLAN_DLM_MAIN_H_
25 
26 #include <qdf_time.h>
27 #include <wlan_objmgr_cmn.h>
28 #include <wlan_objmgr_global_obj.h>
29 #include <wlan_dlm_ucfg_api.h>
30 
31 #define dlm_fatal(params...)\
32 		QDF_TRACE_FATAL(QDF_MODULE_ID_DENYLIST_MGR, params)
33 #define dlm_err(params...)\
34 		QDF_TRACE_ERROR(QDF_MODULE_ID_DENYLIST_MGR, params)
35 #define dlm_warn(params...)\
36 		QDF_TRACE_WARN(QDF_MODULE_ID_DENYLIST_MGR, params)
37 #define dlm_info(params...)\
38 		QDF_TRACE_INFO(QDF_MODULE_ID_DENYLIST_MGR, params)
39 #define dlm_debug(params...)\
40 		QDF_TRACE_DEBUG(QDF_MODULE_ID_DENYLIST_MGR, params)
41 #define dlm_nofl_debug(params...)\
42 		QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_DENYLIST_MGR, params)
43 
44 /**
45  * struct dlm_pdev_priv_obj - Pdev priv struct to store list of denylist mgr.
46  * @reject_ap_list_lock: Mutex needed to restrict two threads updating the list.
47  * @reject_ap_list: The reject Ap list which would contain the list of bad APs.
48  * @dlm_tx_ops: tx ops to send reject ap list to FW
49  */
50 struct dlm_pdev_priv_obj {
51 	qdf_mutex_t reject_ap_list_lock;
52 	qdf_list_t reject_ap_list;
53 	struct wlan_dlm_tx_ops dlm_tx_ops;
54 };
55 
56 /**
57  * struct dlm_config - Structure to define the config params for denylist mgr.
58  * @avoid_list_exipry_time: Timer after which transition from avoid->monitor
59  * would happen for the BSSID which is in avoid list.
60  * @deny_list_exipry_time: Timer after which transition from deny->monitor
61  * would happen for the BSSID which is in deny list.
62  * @bad_bssid_counter_reset_time: Timer after which the bssid would be removed
63  * from the reject list when connected, and data stall is not seen with the AP.
64  * @bad_bssid_counter_thresh: This is the threshold count which is incremented
65  * after every NUD fail, and after this much count, the BSSID would be moved to
66  * denylist.
67  * @delta_rssi: This is the rssi threshold, only when rssi
68  * improves by this value the entry for BSSID should be removed from deny
69  * list manager list.
70  */
71 struct dlm_config {
72 	qdf_time_t avoid_list_exipry_time;
73 	qdf_time_t deny_list_exipry_time;
74 	qdf_time_t bad_bssid_counter_reset_time;
75 	uint8_t bad_bssid_counter_thresh;
76 	uint32_t delta_rssi;
77 };
78 
79 /**
80  * struct dlm_psoc_priv_obj - Psoc priv structure of the denylist manager.
81  * @pdev_id: pdev id
82  * @is_suspended: is deny list manager state suspended
83  * @dlm_cfg: These are the config ini params that the user can configure.
84  */
85 struct dlm_psoc_priv_obj {
86 	uint8_t pdev_id;
87 	bool is_suspended;
88 	struct dlm_config dlm_cfg;
89 };
90 
91 /**
92  * dlm_pdev_object_created_notification() - denylist mgr pdev create
93  * handler
94  * @pdev: pdev which is going to be created by objmgr
95  * @arg: argument for pdev create handler
96  *
97  * Register this api with objmgr to detect if pdev is created.
98  *
99  * Return: QDF_STATUS status in case of success else return error
100  */
101 QDF_STATUS
102 dlm_pdev_object_created_notification(struct wlan_objmgr_pdev *pdev,
103 				     void *arg);
104 
105 /**
106  * dlm_pdev_object_destroyed_notification() - denylist mgr pdev delete handler
107  * @pdev: pdev which is going to be deleted by objmgr
108  * @arg: argument for pdev delete handler
109  *
110  * Register this api with objmgr to detect if pdev is deleted.
111  *
112  * Return: QDF_STATUS status in case of success else return error
113  */
114 QDF_STATUS
115 dlm_pdev_object_destroyed_notification(struct wlan_objmgr_pdev *pdev,
116 				       void *arg);
117 
118 /**
119  * dlm_psoc_object_created_notification() - denylist mgr psoc create handler
120  * @psoc: psoc which is going to be created by objmgr
121  * @arg: argument for psoc create handler
122  *
123  * Register this api with objmgr to detect if psoc is created.
124  *
125  * Return: QDF_STATUS status in case of success else return error
126  */
127 QDF_STATUS
128 dlm_psoc_object_created_notification(struct wlan_objmgr_psoc *psoc,
129 				     void *arg);
130 
131 /**
132  * dlm_psoc_object_destroyed_notification() - denylist mgr psoc delete handler
133  * @psoc: psoc which is going to be deleted by objmgr
134  * @arg: argument for psoc delete handler.
135  *
136  * Register this api with objmgr to detect if psoc is deleted.
137  *
138  * Return: QDF_STATUS status in case of success else return error
139  */
140 QDF_STATUS
141 dlm_psoc_object_destroyed_notification(struct wlan_objmgr_psoc *psoc,
142 				       void *arg);
143 
144 /**
145  * dlm_cfg_psoc_open() - denylist mgr psoc open handler
146  * @psoc: psoc which is initialized by objmgr
147  *
148  * This API will initialize the config file, and store the config while in the
149  * psoc priv object of the denylist manager.
150  *
151  * Return: QDF_STATUS status in case of success else return error
152  */
153 QDF_STATUS
154 dlm_cfg_psoc_open(struct wlan_objmgr_psoc *psoc);
155 
156 /**
157  * dlm_get_pdev_obj() - Get the pdev priv object of the denylist manager
158  * @pdev: pdev object
159  *
160  * Get the pdev priv object of the denylist manager
161  *
162  * Return: Pdev priv object if present, else NULL.
163  */
164 struct dlm_pdev_priv_obj *
165 dlm_get_pdev_obj(struct wlan_objmgr_pdev *pdev);
166 
167 /**
168  * dlm_get_psoc_obj() - Get the psoc priv object of the denylist manager
169  * @psoc: psoc object
170  *
171  * Get the psoc priv object of the denylist manager
172  *
173  * Return: Psoc priv object if present, else NULL.
174  */
175 struct dlm_psoc_priv_obj *
176 dlm_get_psoc_obj(struct wlan_objmgr_psoc *psoc);
177 
178 #endif
179