Merge "qca-wifi: Add mac filtering support for connection manager"
diff --git a/umac/mlme/conn_mgr/core/src/wlan_cm_blm_main.c b/umac/mlme/conn_mgr/core/src/wlan_cm_blm_main.c
new file mode 100644
index 0000000..2a595b1
--- /dev/null
+++ b/umac/mlme/conn_mgr/core/src/wlan_cm_blm_main.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 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: Implement APIs related to the Blacklist manager
+ */
+
+#include <wlan_objmgr_cmn.h>
+#include <wlan_objmgr_pdev_obj.h>
+#include <wlan_scan_utils_api.h>
+#include <wlan_cm_bss_score_param.h>
+#include <wlan_cm_blm.h>
+#include "wlan_cm_blm_main.h"
+
+static void blm_filter_vdev_mac_cmp(struct wlan_objmgr_pdev *pdev,
+ void *obj, void *args)
+{
+ struct wlan_objmgr_vdev *vdev = (struct wlan_objmgr_vdev *)obj;
+ struct blm_entry_iter_obj *blm_obj = (struct blm_entry_iter_obj *)args;
+ uint8_t *scan_entry_mac;
+
+ if (wlan_vdev_mlme_get_opmode(vdev) == QDF_STA_MODE)
+ blm_obj->sta_vdev = vdev;
+
+ if (blm_obj->match)
+ return;
+
+ scan_entry_mac = util_scan_entry_macaddr(blm_obj->db_entry);
+ if (qdf_mem_cmp(scan_entry_mac,
+ wlan_vdev_mlme_get_macaddr(vdev),
+ QDF_MAC_ADDR_SIZE) == 0) {
+ blm_obj->match = true;
+ }
+}
+
+enum cm_blacklist_action
+wlan_blacklist_action_on_bssid(struct wlan_objmgr_pdev *pdev,
+ struct scan_cache_entry *entry)
+{
+ struct blm_entry_iter_obj blm_iter_obj = {0};
+ uint8_t (*exc_mac_list)[QDF_MAC_ADDR_SIZE] = NULL;
+ uint8_t *scan_entry_mac;
+ struct wlan_objmgr_vdev *sta_vdev;
+ enum cm_blm_exc_mac_mode exc_mac_status;
+ uint8_t num_exc_mac = 0;
+ qdf_time_t bad_ap_timeout = 0;
+ qdf_time_t time_diff = 0;
+ uint8_t idx;
+
+ /*
+ * Avoid scan entry with bssid matching any of the vdev mac
+ */
+ blm_iter_obj.db_entry = entry;
+ blm_iter_obj.match = false;
+
+ wlan_objmgr_pdev_iterate_obj_list(
+ pdev, WLAN_VDEV_OP,
+ blm_filter_vdev_mac_cmp,
+ &blm_iter_obj, 0, WLAN_SCAN_ID);
+
+ if (blm_iter_obj.match) {
+ qdf_info("Ignore entry %pM match vdev mac", entry->bssid.bytes);
+ return CM_BLM_REMOVE;
+ }
+
+ if (!blm_iter_obj.sta_vdev)
+ return CM_BLM_NO_ACTION;
+
+ sta_vdev = blm_iter_obj.sta_vdev;
+
+ /*
+ * Skip scan entry that is marked as BAD AP
+ */
+ bad_ap_timeout = wlan_cm_get_bad_ap_timeout(sta_vdev);
+ if (wlan_cm_blm_scan_mlme_get_status(entry) & AP_STATE_BAD) {
+ time_diff = qdf_system_ticks() -
+ wlan_cm_blm_scan_mlme_get_bad_ap_time(entry);
+ if (!bad_ap_timeout ||
+ (qdf_system_ticks_to_msecs(time_diff) > bad_ap_timeout)) {
+ wlan_cm_blm_scan_mlme_set_bad_ap_time(entry, 0);
+ wlan_cm_blm_scan_mlme_set_status(entry,
+ AP_STATE_GOOD);
+ } else {
+ qdf_info("Ignore bssid entry %pM", entry->bssid.bytes);
+ return CM_BLM_REMOVE;
+ }
+ }
+
+ /*
+ * Skip scan entries in the excluded mac address list
+ */
+ exc_mac_status = wlan_cm_get_exc_mac_addr_list(sta_vdev,
+ &exc_mac_list,
+ &num_exc_mac);
+ if (exc_mac_status == CM_BLM_EXC_MAC_ALL) {
+ qdf_info("Ignore bssid entry %pM", entry->bssid.bytes);
+ return CM_BLM_REMOVE;
+ } else if (exc_mac_status == CM_BLM_EXC_MAC_NONE) {
+ return CM_BLM_NO_ACTION;
+ }
+
+ scan_entry_mac = util_scan_entry_macaddr(entry);
+ for (idx = 0; idx < num_exc_mac; idx++) {
+ if (qdf_mem_cmp(scan_entry_mac,
+ exc_mac_list[idx],
+ QDF_MAC_ADDR_SIZE) == 0) {
+ qdf_info("Ignore bssid entry %pM", entry->bssid.bytes);
+ return CM_BLM_REMOVE;
+ }
+ }
+
+ return CM_BLM_NO_ACTION;
+}
+
diff --git a/umac/mlme/conn_mgr/core/src/wlan_cm_blm_main.h b/umac/mlme/conn_mgr/core/src/wlan_cm_blm_main.h
new file mode 100644
index 0000000..6d9bd0e
--- /dev/null
+++ b/umac/mlme/conn_mgr/core/src/wlan_cm_blm_main.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 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: Define APIs related to the Blacklist manager
+ */
+
+#ifndef _WLAN_CM_BLM_MAIN_H_
+#define _WLAN_CM_BLM_MAIN_H_
+
+#include <wlan_scan_public_structs.h>
+
+/**
+ * blm_entry_iter_obj - Object of blm iter function
+ * @db_entry: scan entry object
+ * @sta_vdev: station's vdev object
+ * @match: Hold the operation result
+ */
+struct blm_entry_iter_obj {
+ struct scan_cache_entry *db_entry;
+ struct wlan_objmgr_vdev *sta_vdev;
+ bool match;
+};
+
+#endif
diff --git a/umac/mlme/conn_mgr/dispatcher/inc/wlan_cm_blm.h b/umac/mlme/conn_mgr/dispatcher/inc/wlan_cm_blm.h
new file mode 100644
index 0000000..78d37da
--- /dev/null
+++ b/umac/mlme/conn_mgr/dispatcher/inc/wlan_cm_blm.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 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: Define APIs related to the Blacklist manager
+ */
+
+#ifndef _WLAN_CM_BLM_H_
+#define _WLAN_CM_BLM_H_
+
+#include <wlan_scan_utils_api.h>
+
+/*
+ * Flags used to set field APState
+ */
+#define AP_STATE_GOOD 0x00
+#define AP_STATE_BAD 0x01
+#define AP_STATE_RETRY 0x10
+
+
+/**
+ * enum cm_blm_exc_mac_mode - Exclude mac list mode
+ * @CM_BLM_EXC_MAC_NONE - No entries in exclude mac list
+ * @CM_BLM_EXC_MAC_FEW - Entries available in exclude mac list
+ * @CM_BLM_EXC_MAC_ALL - Ignore all the mac
+ */
+enum cm_blm_exc_mac_mode {
+ CM_BLM_EXC_MAC_NONE,
+ CM_BLM_EXC_MAC_FEW,
+ CM_BLM_EXC_MAC_ALL,
+};
+
+static inline uint32_t
+wlan_cm_blm_scan_mlme_get_status(struct scan_cache_entry *scan_entry)
+{
+ return util_scan_entry_mlme_info(scan_entry)->status;
+}
+
+static inline void
+wlan_cm_blm_scan_mlme_set_status(struct scan_cache_entry *scan_entry, uint32_t val)
+{
+ util_scan_entry_mlme_info(scan_entry)->status = val;
+}
+
+static inline qdf_time_t
+wlan_cm_blm_scan_mlme_get_bad_ap_time(struct scan_cache_entry *scan_entry)
+{
+ return util_scan_entry_mlme_info(scan_entry)->bad_ap_time;
+}
+
+static inline void
+wlan_cm_blm_scan_mlme_set_bad_ap_time(struct scan_cache_entry *scan_entry, qdf_time_t val)
+{
+ util_scan_entry_mlme_info(scan_entry)->bad_ap_time = val;
+}
+
+/*
+ * wlan_cm_get_exc_mac_addr_list: Get excluded mac address list
+ * @vdev: vdev object
+ * @exc_mac_list: Pointer to the excluded mac address list
+ * @exc_mac_count: Number of entries in the excluded list
+ *
+ * Return: Status of the excluded mac addresses
+ */
+enum cm_blm_exc_mac_mode wlan_cm_get_exc_mac_addr_list(
+ struct wlan_objmgr_vdev *vdev,
+ uint8_t (**exc_mac_list)[QDF_MAC_ADDR_SIZE],
+ uint8_t *exc_mac_count);
+
+/*
+ * wlan_cm_get_bad_ap_timeout: Get bad ap timeout duration
+ * @vdev: vdev object
+ *
+ * Return: Congfigured bad ap timeout value
+ */
+qdf_time_t wlan_cm_get_bad_ap_timeout(struct wlan_objmgr_vdev *vdev);
+
+#endif