summaryrefslogtreecommitdiff
path: root/components/blacklist_mgr/core/inc/wlan_blm_core.h
blob: a89c8e5457e7beb77ddbb295a0f544ba31d8c393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for
 * any purpose with or without fee is hereby granted, provided that the
 * above copyright notice and this permission notice appear in all
 * copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */
/**
 * DOC: declare internal APIs related to the blacklist component
 */

#ifndef _WLAN_BLM_CORE_H_
#define _WLAN_BLM_CORE_H_

#include <wlan_blm_main.h>

#define BLM_IS_AP_AVOIDED_BY_USERSPACE(cur_node) \
			cur_node->userspace_avoidlist

#define BLM_IS_AP_AVOIDED_BY_DRIVER(cur_node) \
		cur_node->driver_avoidlist

#define BLM_IS_AP_BLACKLISTED_BY_USERSPACE(cur_node) \
		cur_node->userspace_blacklist

#define BLM_IS_AP_BLACKLISTED_BY_DRIVER(cur_node) \
		cur_node->driver_blacklist

#define BLM_IS_AP_IN_MONITOR_LIST(cur_node) \
		cur_node->driver_monitorlist

#define BLM_IS_AP_IN_RSSI_REJECT_LIST(cur_node) \
		cur_node->rssi_reject_list

#define BLM_IS_AP_IN_BLACKLIST(cur_node) \
		(BLM_IS_AP_BLACKLISTED_BY_USERSPACE(cur_node) | \
		 BLM_IS_AP_BLACKLISTED_BY_DRIVER(cur_node) | \
		 BLM_IS_AP_IN_RSSI_REJECT_LIST(cur_node))

#define BLM_IS_AP_IN_AVOIDLIST(cur_node) \
		(BLM_IS_AP_AVOIDED_BY_USERSPACE(cur_node) | \
		 BLM_IS_AP_AVOIDED_BY_DRIVER(cur_node))

#define IS_AP_IN_USERSPACE_BLACKLIST_ONLY(cur_node) \
		(BLM_IS_AP_BLACKLISTED_BY_USERSPACE(cur_node) & \
		!(BLM_IS_AP_IN_AVOIDLIST(cur_node) | \
		 BLM_IS_AP_IN_MONITOR_LIST(cur_node) | \
		 BLM_IS_AP_IN_RSSI_REJECT_LIST(cur_node) | \
		 BLM_IS_AP_BLACKLISTED_BY_DRIVER(cur_node)))

#define IS_AP_IN_MONITOR_LIST_ONLY(cur_node) \
		(BLM_IS_AP_IN_MONITOR_LIST(cur_node) & \
		!(BLM_IS_AP_IN_AVOIDLIST(cur_node) | \
		 BLM_IS_AP_IN_BLACKLIST(cur_node)))

#define IS_AP_IN_AVOID_LIST_ONLY(cur_node) \
		(BLM_IS_AP_IN_AVOIDLIST(cur_node) & \
		!(BLM_IS_AP_IN_MONITOR_LIST(cur_node) | \
		 BLM_IS_AP_IN_BLACKLIST(cur_node)))

#define IS_AP_IN_DRIVER_BLACKLIST_ONLY(cur_node) \
		(BLM_IS_AP_BLACKLISTED_BY_DRIVER(cur_node) & \
		!(BLM_IS_AP_IN_AVOIDLIST(cur_node) | \
		 BLM_IS_AP_IN_MONITOR_LIST(cur_node) | \
		 BLM_IS_AP_IN_RSSI_REJECT_LIST(cur_node) | \
		 BLM_IS_AP_BLACKLISTED_BY_USERSPACE(cur_node)))

#define IS_AP_IN_RSSI_REJECT_LIST_ONLY(cur_node) \
		(BLM_IS_AP_IN_RSSI_REJECT_LIST(cur_node) & \
		!(BLM_IS_AP_IN_AVOIDLIST(cur_node) | \
		 BLM_IS_AP_IN_MONITOR_LIST(cur_node) | \
		 BLM_IS_AP_BLACKLISTED_BY_DRIVER(cur_node) | \
		 BLM_IS_AP_BLACKLISTED_BY_USERSPACE(cur_node)))

#define IS_AP_IN_USERSPACE_AVOID_LIST_ONLY(cur_node) \
		(BLM_IS_AP_AVOIDED_BY_USERSPACE(cur_node) & \
		!(BLM_IS_AP_AVOIDED_BY_DRIVER(cur_node) | \
		 BLM_IS_AP_IN_MONITOR_LIST(cur_node) | \
		 BLM_IS_AP_IN_BLACKLIST(cur_node)))

#define IS_AP_IN_DRIVER_AVOID_LIST_ONLY(cur_node) \
		(BLM_IS_AP_AVOIDED_BY_DRIVER(cur_node) & \
		!(BLM_IS_AP_AVOIDED_BY_USERSPACE(cur_node) | \
		 BLM_IS_AP_IN_MONITOR_LIST(cur_node) | \
		 BLM_IS_AP_IN_BLACKLIST(cur_node)))

/**
 * struct blm_reject_ap_timestamp - Structure to store the reject list BSSIDs
 * entry time stamp.
 * @userspace_avoid_timestamp: Time when userspace adds BSSID to avoid list.
 * @driver_avoid_timestamp: Time when driver adds BSSID to avoid list.
 * @userspace_blacklist_timestamp: Time when userspace adds BSSID to black list.
 * @driver_blacklist_timestamp: Time when driver adds BSSID to black list.
 * @rssi_reject_timestamp: Time when driver adds BSSID to rssi reject list.
 * @driver_monitor_timestamp: Time when driver adds BSSID to monitor list.
 */
struct blm_reject_ap_timestamp {
	qdf_time_t userspace_avoid_timestamp;
	qdf_time_t driver_avoid_timestamp;
	qdf_time_t userspace_blacklist_timestamp;
	qdf_time_t driver_blacklist_timestamp;
	qdf_time_t rssi_reject_timestamp;
	qdf_time_t driver_monitor_timestamp;
};

/**
 * struct blm_reject_ap - Structure of a node added to blacklist manager
 * @node: Node of the entry
 * @bssid: Bssid of the AP entry.
 * @rssi_reject_params: Rssi reject params of the AP entry.
 * @bad_bssid_counter: It represent how many times data stall happened.
 * @ap_timestamp: Ap timestamp.
 * @reject_ap_type: what is the type of rejection for the AP (avoid, black etc.)
 * @connect_timestamp: Timestamp when the STA got connected with this BSSID
 */
struct blm_reject_ap {
	qdf_list_node_t node;
	struct qdf_mac_addr bssid;
	struct blm_rssi_disallow_params rssi_reject_params;
	uint8_t bad_bssid_counter;
	struct blm_reject_ap_timestamp ap_timestamp;
	union {
		struct {
			uint8_t userspace_blacklist:1,
				driver_blacklist:1,
				userspace_avoidlist:1,
				driver_avoidlist:1,
				rssi_reject_list:1,
				driver_monitorlist:1;
		};
		uint8_t reject_ap_type;
	};
	qdf_time_t connect_timestamp;
};

/**
 * enum blm_bssid_action - action taken by driver for the scan results
 * @BLM_ACTION_NOP: No operation to be taken for the BSSID in the scan list.
 * @BLM_REMOVE_FROM_LIST: Remove the BSSID from the scan list ( Blacklisted APs)
 * @BLM_MOVE_AT_LAST: Attach the Ap at last of the scan list (Avoided Aps)
 */
enum blm_bssid_action {
	BLM_ACTION_NOP,
	BLM_REMOVE_FROM_LIST,
	BLM_MOVE_AT_LAST,
};

/**
 * blm_filter_bssid() - Filter out the bad Aps from the scan list.
 * @pdev: Pdev object
 * @scan_list: Scan list from the caller
 *
 * This API will filter out the bad Aps, or add the bad APs at the last
 * of the linked list if the APs are to be avoided.
 *
 * Return: QDF status
 */
QDF_STATUS
blm_filter_bssid(struct wlan_objmgr_pdev *pdev, qdf_list_t *scan_list);

/**
 * blm_add_bssid_to_reject_list() - Add BSSID to the specific reject list.
 * @pdev: Pdev object
 * @ap_info: Ap info params such as BSSID, and the type of rejection to be done
 *
 * This API will add the BSSID to the reject AP list maintained by the blacklist
 * manager.
 *
 * Return: QDF status
 */
QDF_STATUS
blm_add_bssid_to_reject_list(struct wlan_objmgr_pdev *pdev,
			     struct reject_ap_info *ap_info);

/**
 * blm_send_reject_ap_list_to_fw() - Send the blacklist BSSIDs to FW
 * @pdev: Pdev object
 * @reject_db_list: List of blacklist BSSIDs
 * @cfg: Blacklist manager cfg
 *
 * This API will send the blacklist BSSIDs to FW for avoiding or blacklisting
 * in roaming scenarios.
 *
 * Return: None
 */
void
blm_send_reject_ap_list_to_fw(struct wlan_objmgr_pdev *pdev,
			      qdf_list_t *reject_db_list,
			      struct blm_config *cfg);

/**
 * blm_add_userspace_black_list() - Clear already existing userspace BSSID, and
 * add the new ones to blacklist manager.
 * @pdev: pdev object
 * @bssid_black_list: BSSIDs to be blacklisted by userspace.
 * @num_of_bssid: num of bssids to be blacklisted.
 *
 * This API will Clear already existing userspace BSSID, and add the new ones
 * to blacklist manager's reject list.
 *
 * Return: QDF status
 */
QDF_STATUS
blm_add_userspace_black_list(struct wlan_objmgr_pdev *pdev,
			     struct qdf_mac_addr *bssid_black_list,
			     uint8_t num_of_bssid);

/**
 * blm_update_bssid_connect_params() - Inform the BLM about connect/disconnect
 * with the current AP.
 * @pdev: pdev object
 * @bssid: BSSID of the AP
 * @con_state: Connection stae (connected/disconnected)
 *
 * This API will inform the BLM about the state with the AP so that if the AP
 * is selected, and the connection went through, and the connection did not
 * face any data stall till the bad bssid reset timer, BLM can remove the
 * AP from the reject ap list maintained by it.
 *
 * Return: None
 */
void
blm_update_bssid_connect_params(struct wlan_objmgr_pdev *pdev,
				struct qdf_mac_addr bssid,
				enum blm_connection_state con_state);

/**
 * blm_flush_reject_ap_list() - Clear away BSSID and destroy the reject ap list
 * @blm_ctx: blacklist manager pdev priv object
 *
 * This API will clear the BSSID info in the reject AP list maintained by the
 * blacklist manager, and will destroy the list as well.
 *
 * Return: None
 */
void
blm_flush_reject_ap_list(struct blm_pdev_priv_obj *blm_ctx);

/**
 * blm_get_bssid_reject_list() - Get the BSSIDs in reject list from BLM
 * @pdev: pdev object
 * @reject_list: reject list to be filled (passed by caller)
 * @max_bssid_to_be_filled: num of bssids filled in reject list by BLM
 * @reject_ap_type: reject ap type of the BSSIDs to be filled.
 *
 * This API will fill the reject ap list requested by caller of type given as
 * argument reject_ap_type, and will return the number of BSSIDs filled.
 *
 * Return: Unsigned integer (number of BSSIDs filled by the blacklist manager)
 */
uint8_t
blm_get_bssid_reject_list(struct wlan_objmgr_pdev *pdev,
			  struct reject_ap_config_params *reject_list,
			  uint8_t max_bssid_to_be_filled,
			  enum blm_reject_ap_type reject_ap_type);

/**
 * blm_get_rssi_blacklist_threshold() - Get rssi blacklist threshold value
 * @pdev: pdev object
 *
 * This API will get the RSSI blacklist threshold info.
 *
 * Return: rssi theshold value
 */
int32_t
blm_get_rssi_blacklist_threshold(struct wlan_objmgr_pdev *pdev);
#endif