Explorar o código

qcacld-3.0: Enhance BLM infra

Enhance BLM infra to include source,
reason for blacklist, original timeout,
received time for better debug.

Change-Id: Ia705a967a08412824063275f5073c338dabde539
CRs-Fixed: 2744402
gaurank kathpalia %!s(int64=4) %!d(string=hai) anos
pai
achega
324fc0b0c3

+ 19 - 0
components/blacklist_mgr/core/inc/wlan_blm_core.h

@@ -121,6 +121,7 @@ struct blm_reject_ap_timestamp {
  * @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.)
+ * @reject_ap_reason: reason for adding the BSSID to BLM
  * @connect_timestamp: Timestamp when the STA got connected with this BSSID
  */
 struct blm_reject_ap {
@@ -140,6 +141,24 @@ struct blm_reject_ap {
 		};
 		uint8_t reject_ap_type;
 	};
+	union {
+		struct {
+			uint32_t nud_fail:1,
+				 sta_kickout:1,
+				 ho_fail:1,
+				 poor_rssi:1,
+				 oce_assoc_reject:1,
+				 blacklist_userspace:1,
+				 avoid_userspace:1,
+				 btm_disassoc_imminent:1,
+				 btm_bss_termination:1,
+				 btm_mbo_retry:1,
+				 reassoc_rssi_reject:1,
+				 no_more_stas:1;
+		};
+		uint32_t reject_ap_reason;
+	};
+	enum blm_reject_ap_source source;
 	qdf_time_t connect_timestamp;
 };
 

+ 186 - 25
components/blacklist_mgr/core/src/wlan_blm_core.c

@@ -50,6 +50,7 @@ blm_update_ap_info(struct blm_reject_ap *blm_entry, struct blm_config *cfg,
 		     MINUTES_TO_MS(cfg->avoid_list_exipry_time)) {
 			/* Move AP to monitor list as avoid list time is over */
 			blm_entry->userspace_avoidlist = false;
+			blm_entry->avoid_userspace = false;
 			blm_entry->driver_monitorlist = true;
 
 			blm_entry->ap_timestamp.driver_monitor_timestamp =
@@ -66,6 +67,9 @@ blm_update_ap_info(struct blm_reject_ap *blm_entry, struct blm_config *cfg,
 		     MINUTES_TO_MS(cfg->avoid_list_exipry_time)) {
 			/* Move AP to monitor list as avoid list time is over */
 			blm_entry->driver_avoidlist = false;
+			blm_entry->nud_fail = false;
+			blm_entry->sta_kickout = false;
+			blm_entry->ho_fail = false;
 			blm_entry->driver_monitorlist = true;
 
 			blm_entry->ap_timestamp.driver_monitor_timestamp =
@@ -84,7 +88,9 @@ blm_update_ap_info(struct blm_reject_ap *blm_entry, struct blm_config *cfg,
 			/* Move AP to monitor list as black list time is over */
 			blm_entry->driver_blacklist = false;
 			blm_entry->driver_monitorlist = true;
-
+			blm_entry->nud_fail = false;
+			blm_entry->sta_kickout = false;
+			blm_entry->ho_fail = false;
 			blm_entry->ap_timestamp.driver_monitor_timestamp =
 								cur_timestamp;
 			blm_debug("Driver blacklist timer expired, moved to monitor list");
@@ -115,8 +121,15 @@ blm_update_ap_info(struct blm_reject_ap *blm_entry, struct blm_config *cfg,
 			 *    for BTM message will fail (expected), as BTM does
 			 *    not care about the same.
 			 */
+			blm_entry->poor_rssi = false;
+			blm_entry->oce_assoc_reject = false;
+			blm_entry->btm_bss_termination = false;
+			blm_entry->btm_disassoc_imminent = false;
+			blm_entry->btm_mbo_retry = false;
+			blm_entry->no_more_stas = false;
+			blm_entry->reassoc_rssi_reject = false;
 			blm_entry->rssi_reject_list = false;
-			blm_debug("Remove from rssi reject expected RSSI = %d, current RSSI = %d, retry delay required = %d ms, delay = %lu ms",
+			blm_debug("Remove BSSID from rssi reject expected RSSI = %d, current RSSI = %d, retry delay required = %d ms, delay = %lu ms",
 				  blm_entry->rssi_reject_params.expected_rssi,
 				  scan_entry ? scan_entry->rssi_raw : 0,
 				  blm_entry->rssi_reject_params.retry_delay,
@@ -156,22 +169,38 @@ blm_prune_old_entries_and_get_action(struct blm_reject_ap *blm_entry,
 	}
 
 	if (BLM_IS_AP_IN_RSSI_REJECT_LIST(blm_entry) &&
-	    blm_entry->rssi_reject_params.retry_delay > MAX_BL_TIME) {
-		blm_info("Allow BSSID %pM as the retry delay is greater than %d ms, expected RSSI = %d, current RSSI = %d, retry delay = %d ms",
+	    !blm_entry->userspace_blacklist && !blm_entry->driver_blacklist &&
+	    blm_entry->rssi_reject_params.original_timeout > MAX_BL_TIME) {
+		blm_info("Allow BSSID %pM as the retry delay is greater than %u ms, expected RSSI = %d, current RSSI = %d, retry delay = %u ms original timeout %u time added %lu source %d reason %d",
 			 blm_entry->bssid.bytes, MAX_BL_TIME,
 			 blm_entry->rssi_reject_params.expected_rssi,
 			 entry ? entry->rssi_raw : 0,
-			 blm_entry->rssi_reject_params.retry_delay);
+			 blm_entry->rssi_reject_params.retry_delay,
+			 blm_entry->rssi_reject_params.original_timeout,
+			 blm_entry->rssi_reject_params.received_time,
+			 blm_entry->source, blm_entry->reject_ap_reason);
+
+		if (BLM_IS_AP_IN_AVOIDLIST(blm_entry)) {
+			blm_debug("%pM in avoid list, deprioritize it",
+				  blm_entry->bssid.bytes);
+			return CM_BLM_AVOID;
+		}
+
 		return CM_BLM_NO_ACTION;
 	}
-	if (BLM_IS_AP_IN_BLACKLIST(blm_entry))
+	if (BLM_IS_AP_IN_BLACKLIST(blm_entry)) {
+		blm_debug("%pM in blacklist list, reject ap type %d removing from candidate list",
+			  blm_entry->bssid.bytes, blm_entry->reject_ap_type);
 		return CM_BLM_REMOVE;
+	}
 
-	if (BLM_IS_AP_IN_AVOIDLIST(blm_entry))
+	if (BLM_IS_AP_IN_AVOIDLIST(blm_entry)) {
+		blm_debug("%pM in avoid list, deprioritize it",
+			  blm_entry->bssid.bytes);
 		return CM_BLM_AVOID;
+	}
 
 	return CM_BLM_NO_ACTION;
-
 }
 
 static enum cm_blacklist_action
@@ -231,6 +260,29 @@ wlan_blacklist_action_on_bssid(struct wlan_objmgr_pdev *pdev,
 	return blm_action_on_bssid(pdev, entry);
 }
 
+static void
+blm_update_avoidlist_reject_reason(struct blm_reject_ap *entry,
+				   enum blm_reject_ap_reason reject_reason)
+{
+	entry->nud_fail = false;
+	entry->sta_kickout = false;
+	entry->ho_fail = false;
+
+	switch(reject_reason) {
+	case REASON_NUD_FAILURE:
+		entry->nud_fail = true;
+		break;
+	case REASON_STA_KICKOUT:
+		entry->sta_kickout = true;
+		break;
+	case REASON_ROAM_HO_FAILURE:
+		entry->ho_fail = true;
+		break;
+	default:
+		blm_err("Invalid reason passed %d", reject_reason);
+	}
+}
+
 static void
 blm_handle_avoid_list(struct blm_reject_ap *entry,
 		      struct blm_config *cfg,
@@ -240,13 +292,17 @@ blm_handle_avoid_list(struct blm_reject_ap *entry,
 
 	if (ap_info->reject_ap_type == USERSPACE_AVOID_TYPE) {
 		entry->userspace_avoidlist = true;
+		entry->avoid_userspace = true;
 		entry->ap_timestamp.userspace_avoid_timestamp = cur_timestamp;
 	} else if (ap_info->reject_ap_type == DRIVER_AVOID_TYPE) {
 		entry->driver_avoidlist = true;
+		blm_update_avoidlist_reject_reason(entry,
+						   ap_info->reject_reason);
 		entry->ap_timestamp.driver_avoid_timestamp = cur_timestamp;
 	} else {
 		return;
 	}
+	entry->source = ap_info->source;
 	/* Update bssid info for new entry */
 	entry->bssid = ap_info->bssid;
 
@@ -271,9 +327,10 @@ blm_handle_avoid_list(struct blm_reject_ap *entry,
 			  entry->bssid.bytes, entry->bad_bssid_counter);
 		return;
 	}
-	blm_debug("Added %pM to avoid list type %d, counter %d",
+	blm_debug("Added %pM to avoid list type %d, counter %d reason %d updated reject reason %d source %d",
 		  entry->bssid.bytes, ap_info->reject_ap_type,
-		  entry->bad_bssid_counter);
+		  entry->bad_bssid_counter, ap_info->reject_reason,
+		  entry->reject_ap_reason, entry->source);
 
 	entry->connect_timestamp = qdf_mc_timer_get_system_time();
 }
@@ -293,22 +350,77 @@ blm_handle_blacklist(struct blm_reject_ap *entry,
 	entry->ap_timestamp.userspace_blacklist_timestamp =
 						qdf_mc_timer_get_system_time();
 
+	entry->source = ADDED_BY_DRIVER;
+	entry->blacklist_userspace = true;
 	blm_debug("%pM added to userspace blacklist", entry->bssid.bytes);
 }
 
+static void
+blm_update_rssi_reject_reason(struct blm_reject_ap *entry,
+			      enum blm_reject_ap_reason reject_reason)
+{
+	entry->poor_rssi = false;
+	entry->oce_assoc_reject = false;
+	entry->btm_bss_termination = false;
+	entry->btm_disassoc_imminent = false;
+	entry->btm_mbo_retry = false;
+	entry->no_more_stas = false;
+	entry->reassoc_rssi_reject = false;
+
+	switch(reject_reason) {
+	case REASON_ASSOC_REJECT_POOR_RSSI:
+		entry->poor_rssi = true;
+		break;
+	case REASON_ASSOC_REJECT_OCE:
+		entry->oce_assoc_reject = true;
+		break;
+	case REASON_BTM_DISASSOC_IMMINENT:
+		entry->btm_disassoc_imminent = true;
+		break;
+	case REASON_BTM_BSS_TERMINATION:
+		entry->btm_bss_termination = true;
+		break;
+	case REASON_BTM_MBO_RETRY:
+		entry->btm_mbo_retry = true;
+		break;
+	case REASON_REASSOC_RSSI_REJECT:
+		entry->reassoc_rssi_reject = true;
+		break;
+	case REASON_REASSOC_NO_MORE_STAS:
+		entry->no_more_stas = true;
+		break;
+	default:
+		blm_err("Invalid reason passed %d", reject_reason);
+	}
+}
+
 static void
 blm_handle_rssi_reject_list(struct blm_reject_ap *entry,
 			    struct reject_ap_info *ap_info)
 {
-	entry->bssid = ap_info->bssid;
-	entry->rssi_reject_list = true;
+	bool bssid_newly_added;
+
+	if (entry->rssi_reject_list) {
+		bssid_newly_added = false;
+	} else {
+		entry->rssi_reject_params.source = ap_info->source;
+		entry->bssid = ap_info->bssid;
+		entry->rssi_reject_list = true;
+		bssid_newly_added = true;
+	}
+
 	entry->ap_timestamp.rssi_reject_timestamp =
 					qdf_mc_timer_get_system_time();
 	entry->rssi_reject_params = ap_info->rssi_reject_params;
-
-	blm_debug("%pM Added to rssi reject list, expected RSSI %d retry delay %d",
-		  entry->bssid.bytes, entry->rssi_reject_params.expected_rssi,
-		  entry->rssi_reject_params.retry_delay);
+	blm_update_rssi_reject_reason(entry, ap_info->reject_reason);
+	blm_info("%pM %s to rssi reject list, expected RSSI %d retry delay %u source %d original timeout %u received time %lu reject reason %d updated reason %d",
+		 bssid_newly_added ? "ADDED" : "UPDATED",
+		 entry->bssid.bytes, entry->rssi_reject_params.expected_rssi,
+		 entry->rssi_reject_params.retry_delay,
+		 entry->rssi_reject_params.source,
+		 entry->rssi_reject_params.original_timeout,
+		 entry->rssi_reject_params.received_time,
+		 ap_info->reject_reason, entry->reject_ap_reason);
 }
 
 static void
@@ -568,6 +680,48 @@ blm_remove_lowest_delta_entry(qdf_list_t *reject_ap_list,
 	return QDF_STATUS_E_FAILURE;
 }
 
+static enum blm_reject_ap_reason
+blm_get_rssi_reject_reason(struct blm_reject_ap *blm_entry)
+{
+	if (blm_entry->poor_rssi)
+		return REASON_ASSOC_REJECT_POOR_RSSI;
+	else if (blm_entry->oce_assoc_reject)
+		return REASON_ASSOC_REJECT_OCE;
+	else if(blm_entry->btm_bss_termination)
+		return REASON_BTM_BSS_TERMINATION;
+	else if (blm_entry->btm_disassoc_imminent)
+		return REASON_BTM_DISASSOC_IMMINENT;
+	else if (blm_entry->btm_mbo_retry)
+		return REASON_BTM_MBO_RETRY;
+	else if (blm_entry->no_more_stas)
+		return REASON_REASSOC_NO_MORE_STAS;
+	else if (blm_entry->reassoc_rssi_reject)
+		return REASON_REASSOC_RSSI_REJECT;
+
+	return REASON_UNKNOWN;
+}
+
+static void
+blm_fill_rssi_reject_params(struct blm_reject_ap *blm_entry,
+			    enum blm_reject_ap_type reject_ap_type,
+			    struct reject_ap_config_params *blm_reject_list)
+{
+	if (reject_ap_type != DRIVER_RSSI_REJECT_TYPE)
+		return;
+
+	blm_reject_list->source = blm_entry->rssi_reject_params.source;
+	blm_reject_list->original_timeout =
+			blm_entry->rssi_reject_params.original_timeout;
+	blm_reject_list->received_time =
+			blm_entry->rssi_reject_params.received_time;
+	blm_reject_list->reject_reason = blm_get_rssi_reject_reason(blm_entry);
+	blm_debug("%pM source %d original timeout %u received time %lu reject reason %d",
+		   blm_entry->bssid.bytes, blm_reject_list->source,
+		   blm_reject_list->original_timeout,
+		   blm_reject_list->received_time,
+		   blm_reject_list->reject_reason);
+}
+
 static void blm_fill_reject_list(qdf_list_t *reject_db_list,
 				 struct reject_ap_config_params *reject_list,
 				 uint8_t *num_of_reject_bssid,
@@ -602,21 +756,26 @@ static void blm_fill_reject_list(qdf_list_t *reject_db_list,
 		}
 
 		if (blm_is_bssid_of_type(reject_ap_type, blm_entry)) {
-			reject_list[*num_of_reject_bssid].expected_rssi =
+			struct reject_ap_config_params *blm_reject_list;
+
+			blm_reject_list = &reject_list[*num_of_reject_bssid];
+			blm_reject_list->expected_rssi =
 				    blm_entry->rssi_reject_params.expected_rssi;
-			reject_list[*num_of_reject_bssid].reject_duration =
+			blm_reject_list->reject_duration =
 			       blm_get_delta_of_bssid(reject_ap_type, blm_entry,
 						      cfg);
-			reject_list[*num_of_reject_bssid].reject_ap_type =
-								reject_ap_type;
-			reject_list[*num_of_reject_bssid].bssid =
-							blm_entry->bssid;
+
+			blm_fill_rssi_reject_params(blm_entry, reject_ap_type,
+						    blm_reject_list);
+			blm_reject_list->reject_ap_type = reject_ap_type;
+			blm_reject_list->bssid = blm_entry->bssid;
 			(*num_of_reject_bssid)++;
-			blm_debug("Adding BSSID %pM of type %d retry delay %d expected RSSI %d, entries added = %d",
+			blm_debug("Adding BSSID %pM of type %d retry delay %d expected RSSI %d, entries added = %d reject reason %d",
 				  blm_entry->bssid.bytes, reject_ap_type,
 				  reject_list[*num_of_reject_bssid -1].reject_duration,
 				  blm_entry->rssi_reject_params.expected_rssi,
-				  *num_of_reject_bssid);
+				  *num_of_reject_bssid,
+				  blm_entry->reject_ap_reason);
 		}
 		cur_node = next_node;
 		next_node = NULL;
@@ -797,6 +956,7 @@ blm_clear_userspace_blacklist_info(struct wlan_objmgr_pdev *pdev)
 			blm_debug("Clearing userspace blacklist bit for %pM",
 				  blm_entry->bssid.bytes);
 			blm_entry->userspace_blacklist = false;
+			blm_entry->blacklist_userspace = false;
 		}
 		cur_node = next_node;
 		next_node = NULL;
@@ -847,7 +1007,8 @@ blm_add_userspace_black_list(struct wlan_objmgr_pdev *pdev,
 	for (i = 0; i < num_of_bssid; i++) {
 		ap_info.bssid = bssid_black_list[i];
 		ap_info.reject_ap_type = USERSPACE_BLACKLIST_TYPE;
-
+		ap_info.source = ADDED_BY_DRIVER;
+		ap_info.reject_reason = REASON_USERSPACE_BL;
 		status = blm_add_bssid_to_reject_list(pdev, &ap_info);
 		if (QDF_IS_STATUS_ERROR(status)) {
 			blm_err("Failed to add bssid to userspace blacklist");

+ 62 - 1
components/blacklist_mgr/dispatcher/inc/wlan_blm_public_struct.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-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
@@ -28,14 +28,31 @@
 #define MAX_BAD_AP_LIST_SIZE               28
 #define MAX_RSSI_AVOID_BSSID_LIST    10
 #define PDEV_MAX_NUM_BSSID_DISALLOW_LIST  28
+
+/**
+ * enum blm_reject_ap_reason - Rejection reason for adding BSSID to BLM
+ * @ADDED_BY_DRIVER: Source adding this BSSID is driver
+ * @ADDED_BY_TARGET: Source adding this BSSID is target
+ */
+enum blm_reject_ap_source {
+	ADDED_BY_DRIVER = 1,
+	ADDED_BY_TARGET,
+};
+
 /**
  * struct blm_rssi_disallow_params - structure to specify params for RSSI reject
  * @retry_delay: Time before which the AP doesn't expect a connection.
  * @expected_rssi: RSSI less than which only the STA should try association.
+ * @received_time: Time at which the AP was added to blacklist.
+ * @original_timeout: Original timeout which the AP sent while blacklisting.
+ * @source: Source of adding this BSSID to RSSI reject list
  */
 struct blm_rssi_disallow_params {
 	uint32_t retry_delay;
 	int8_t expected_rssi;
+	qdf_time_t received_time;
+	uint32_t original_timeout;
+	enum blm_reject_ap_source source;
 };
 
 /**
@@ -56,6 +73,38 @@ enum blm_reject_ap_type {
 	DRIVER_MONITOR_TYPE =      5
 };
 
+/**
+ * enum blm_reject_ap_reason - Rejection reason for adding BSSID to BLM
+ * @REASON_UNKNOWN: Unknown reason
+ * @REASON_NUD_FAILURE: NUD failure happened with this BSSID
+ * @REASON_STA_KICKOUT: STA kickout happened with this BSSID
+ * @REASON_ROAM_HO_FAILURE: HO failure happenend with this BSSID
+ * @REASON_ASSOC_REJECT_POOR_RSSI: assoc rsp with reason 71 received from AP.
+ * @REASON_ASSOC_REJECT_OCE: OCE assoc reject received from the AP.
+ * @REASON_USERSPACE_BL: Userspace wants to blacklist this AP.
+ * @REASON_USERSPACE_AVOID_LIST: Userspace wants to avoid this AP.
+ * @REASON_BTM_DISASSOC_IMMINENT: BTM IE received with disassoc imminent set.
+ * @REASON_BTM_BSS_TERMINATION: BTM IE received with BSS termination set.
+ * @REASON_BTM_MBO_RETRY: BTM IE received from AP with MBO retry set.
+ * @REASON_REASSOC_RSSI_REJECT: Re-Assoc resp received with reason code 34
+ * @REASON_REASSOC_NO_MORE_STAS: Re-assoc reject received with reason code 17
+ */
+enum blm_reject_ap_reason {
+	REASON_UNKNOWN = 0,
+	REASON_NUD_FAILURE,
+	REASON_STA_KICKOUT,
+	REASON_ROAM_HO_FAILURE,
+	REASON_ASSOC_REJECT_POOR_RSSI,
+	REASON_ASSOC_REJECT_OCE,
+	REASON_USERSPACE_BL,
+	REASON_USERSPACE_AVOID_LIST,
+	REASON_BTM_DISASSOC_IMMINENT,
+	REASON_BTM_BSS_TERMINATION,
+	REASON_BTM_MBO_RETRY,
+	REASON_REASSOC_RSSI_REJECT,
+	REASON_REASSOC_NO_MORE_STAS,
+};
+
 /**
  * enum blm_connection_state - State with AP (Connected, Disconnected)
  * @BLM_AP_CONNECTED: Connected with the AP
@@ -72,12 +121,20 @@ enum blm_connection_state {
  * @reject_ap_type: Type of the rejection done with the BSSID
  * @reject_duration: time left till the AP is in the reject list.
  * @expected_rssi: expected RSSI when the AP expects the connection to be made.
+ * @reject_reason: reason to add the BSSID to BLM
+ * @source: Source of adding the BSSID to BLM
+ * @received_time: Time at which the AP was added to blacklist.
+ * @original_timeout: Original timeout which the AP sent while blacklisting.
  */
 struct reject_ap_config_params {
 	struct qdf_mac_addr bssid;
 	enum blm_reject_ap_type reject_ap_type;
 	uint32_t reject_duration;
 	int32_t expected_rssi;
+	enum blm_reject_ap_reason reject_reason;
+	enum blm_reject_ap_source source;
+	qdf_time_t received_time;
+	uint32_t original_timeout;
 };
 
 /**
@@ -105,11 +162,15 @@ struct wlan_blm_tx_ops {
  * @bssid: BSSID of the AP.
  * @rssi_reject_params: RSSI reject params of the AP is of type RSSI reject
  * @reject_ap_type: Reject type of AP (eg. avoid, blacklist, rssi reject etc.)
+ * @reject_reason: reason to add the BSSID to BLM
+ * @source: Source of adding the BSSID to BLM
  */
 struct reject_ap_info {
 	struct qdf_mac_addr bssid;
 	struct blm_rssi_disallow_params rssi_reject_params;
 	enum blm_reject_ap_type reject_ap_type;
+	enum blm_reject_ap_reason reject_reason;
+	enum blm_reject_ap_source source;
 };
 
 #endif

+ 4 - 0
core/hdd/src/wlan_hdd_cfg80211.c

@@ -4393,6 +4393,10 @@ static int hdd_set_blacklist_bssid(struct hdd_context *hdd_ctx,
 					   tb2[PARAM_SET_BSSID],
 					   QDF_MAC_ADDR_SIZE);
 				ap_info.reject_ap_type = USERSPACE_AVOID_TYPE;
+				ap_info.reject_reason =
+						REASON_USERSPACE_AVOID_LIST;
+				ap_info.source = ADDED_BY_DRIVER;
+
 				/* This BSSID is avoided and not blacklisted */
 				ucfg_blm_add_bssid_to_reject_list(hdd_ctx->pdev,
 								  &ap_info);

+ 2 - 0
core/hdd/src/wlan_hdd_nud_tracking.c

@@ -252,6 +252,8 @@ hdd_handle_nud_fail_sta(struct hdd_context *hdd_ctx,
 
 	ap_info.bssid = sta_ctx->conn_info.bssid;
 	ap_info.reject_ap_type = DRIVER_AVOID_TYPE;
+	ap_info.reject_reason = REASON_NUD_FAILURE;
+	ap_info.source = ADDED_BY_DRIVER;
 	ucfg_blm_add_bssid_to_reject_list(hdd_ctx->pdev, &ap_info);
 
 	if (roaming_offload_enabled(hdd_ctx))

+ 8 - 0
core/mac/inc/sir_api.h

@@ -5556,6 +5556,10 @@ struct sir_peer_set_rx_blocksize {
  * @retry_delay: Retry delay received during last rejection in ms
  * @ expected_rssi: RSSI at which STA can initate
  * @time_during_rejection: Timestamp during last rejection in millisec
+ * @reject_reason: reason to add the BSSID to BLM
+ * @source: Source of adding the BSSID to BLM
+ * @original_timeout: original timeout sent by the AP
+ * @received_time: Timestamp when the AP was added to the Blacklist
  */
 struct sir_rssi_disallow_lst {
 	qdf_list_node_t node;
@@ -5563,6 +5567,10 @@ struct sir_rssi_disallow_lst {
 	uint32_t retry_delay;
 	int8_t expected_rssi;
 	qdf_time_t time_during_rejection;
+	enum blm_reject_ap_reason reject_reason;
+	enum blm_reject_ap_source source;
+	uint32_t original_timeout;
+	qdf_time_t received_time;
 };
 
 /**

+ 2 - 0
core/mac/src/pe/lim/lim_link_monitoring_algo.c

@@ -242,6 +242,8 @@ void lim_delete_sta_context(struct mac_context *mac_ctx,
 			qdf_mem_copy(&ap_info.bssid, msg->addr2,
 				     QDF_MAC_ADDR_SIZE);
 			ap_info.reject_ap_type = DRIVER_AVOID_TYPE;
+			ap_info.reject_reason = REASON_STA_KICKOUT;
+			ap_info.source = ADDED_BY_DRIVER;
 			wlan_blm_add_bssid_to_reject_list(mac_ctx->pdev,
 							  &ap_info);
 

+ 4 - 0
core/mac/src/pe/lim/lim_process_assoc_rsp_frame.c

@@ -818,6 +818,10 @@ lim_process_assoc_rsp_frame(struct mac_context *mac_ctx, uint8_t *rx_pkt_info,
 		ap_info.retry_delay = assoc_rsp->rssi_assoc_rej.retry_delay *
 							QDF_MC_TIMER_TO_MS_UNIT;
 		qdf_mem_copy(ap_info.bssid.bytes, hdr->sa, QDF_MAC_ADDR_SIZE);
+		ap_info.reject_reason = REASON_ASSOC_REJECT_OCE;
+		ap_info.source = ADDED_BY_DRIVER;
+		ap_info.original_timeout = ap_info.retry_delay;
+		ap_info.received_time = qdf_mc_timer_get_system_time();
 		lim_add_bssid_to_reject_list(mac_ctx->pdev, &ap_info);
 	}
 

+ 5 - 0
core/mac/src/pe/lim/lim_process_disassoc_frame.c

@@ -307,6 +307,11 @@ lim_process_disassoc_frame(struct mac_context *mac, uint8_t *pRxPacketInfo,
 		ap_info.expected_rssi = frame_rssi +
 			wlan_blm_get_rssi_blacklist_threshold(mac->pdev);
 		qdf_mem_copy(ap_info.bssid.bytes, pHdr->sa, QDF_MAC_ADDR_SIZE);
+		ap_info.reject_reason = REASON_ASSOC_REJECT_POOR_RSSI;
+		ap_info.source = ADDED_BY_DRIVER;
+		ap_info.original_timeout = ap_info.retry_delay;
+		ap_info.received_time = qdf_mc_timer_get_system_time();
+
 		lim_add_bssid_to_reject_list(mac->pdev, &ap_info);
 	}
 	lim_extract_ies_from_deauth_disassoc(pe_session, (uint8_t *)pHdr,

+ 5 - 0
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -6135,6 +6135,11 @@ void lim_add_roam_blacklist_ap(struct mac_context *mac_ctx,
 
 		entry.bssid = blacklist->bssid;
 		entry.time_during_rejection = blacklist->received_time;
+		entry.reject_reason = blacklist->reject_reason;
+		entry.source = blacklist->source ? blacklist->source :
+						   ADDED_BY_TARGET;
+		entry.original_timeout = blacklist->original_timeout;
+		entry.received_time = blacklist->received_time;
 		/* If timeout = 0 and rssi = 0 ignore the entry */
 		if (!blacklist->timeout && !blacklist->rssi) {
 			continue;

+ 4 - 1
core/mac/src/pe/lim/lim_utils.c

@@ -7590,7 +7590,10 @@ lim_add_bssid_to_reject_list(struct wlan_objmgr_pdev *pdev,
 	ap_info.reject_ap_type = DRIVER_RSSI_REJECT_TYPE;
 	ap_info.rssi_reject_params.expected_rssi = entry->expected_rssi;
 	ap_info.rssi_reject_params.retry_delay = entry->retry_delay;
-
+	ap_info.reject_reason = entry->reject_reason;
+	ap_info.source = entry->source;
+	ap_info.rssi_reject_params.received_time = entry->received_time;
+	ap_info.rssi_reject_params.original_timeout = entry->original_timeout;
 	/* Add this ap info to the rssi reject ap type in blacklist manager */
 	wlan_blm_add_bssid_to_reject_list(pdev, &ap_info);
 }

+ 2 - 0
core/sme/src/csr/csr_api_roam.c

@@ -21522,6 +21522,8 @@ csr_process_roam_sync_callback(struct mac_context *mac_ctx,
 
 		ap_info.bssid = session->connectedProfile.bssid;
 		ap_info.reject_ap_type = DRIVER_AVOID_TYPE;
+		ap_info.reject_reason = REASON_STA_KICKOUT;
+		ap_info.source = ADDED_BY_DRIVER;
 		wlan_blm_add_bssid_to_reject_list(mac_ctx->pdev, &ap_info);
 	}
 

+ 6 - 0
core/wma/inc/wma_if.h

@@ -772,12 +772,18 @@ typedef struct sStatsExtRequest {
  * @timeout - time duration for which the bssid is blacklisted
  * @received_time - boot timestamp at which the firmware event was received
  * @rssi - rssi value for which the bssid is blacklisted
+ * @reject_reason: reason to add the BSSID to BLM
+ * @original_timeout: original timeout sent by the AP
+ * @source: Source of adding the BSSID to BLM
  */
 struct roam_blacklist_timeout {
 	struct qdf_mac_addr bssid;
 	uint32_t timeout;
 	qdf_time_t received_time;
 	int32_t rssi;
+	enum blm_reject_ap_reason reject_reason;
+	uint32_t original_timeout;
+	enum blm_reject_ap_source source;
 };
 
 /*

+ 39 - 3
core/wma/src/wma_scan_roam.c

@@ -4295,6 +4295,8 @@ wma_roam_ho_fail_handler(tp_wma_handle wma, uint32_t vdev_id,
 
 	ap_info.bssid = bssid;
 	ap_info.reject_ap_type = DRIVER_AVOID_TYPE;
+	ap_info.reject_reason = REASON_ROAM_HO_FAILURE;
+	ap_info.source = ADDED_BY_DRIVER;
 	wlan_blm_add_bssid_to_reject_list(wma->pdev, &ap_info);
 
 	ho_failure_ind = qdf_mem_malloc(sizeof(*ho_failure_ind));
@@ -6447,6 +6449,38 @@ QDF_STATUS wma_send_ht40_obss_scanind(tp_wma_handle wma,
 	return status;
 }
 
+static enum blm_reject_ap_reason wma_get_reject_reason(uint32_t reason)
+{
+	switch(reason) {
+	case WMI_BL_REASON_NUD_FAILURE:
+		return REASON_NUD_FAILURE;
+	case WMI_BL_REASON_STA_KICKOUT:
+		return REASON_STA_KICKOUT;
+	case WMI_BL_REASON_ROAM_HO_FAILURE:
+		return REASON_ROAM_HO_FAILURE;
+	case WMI_BL_REASON_ASSOC_REJECT_POOR_RSSI:
+		return REASON_ASSOC_REJECT_POOR_RSSI;
+	case WMI_BL_REASON_ASSOC_REJECT_OCE:
+		return REASON_ASSOC_REJECT_OCE;
+	case WMI_BL_REASON_USERSPACE_BL:
+		return REASON_USERSPACE_BL;
+	case WMI_BL_REASON_USERSPACE_AVOID_LIST:
+		return REASON_USERSPACE_AVOID_LIST;
+	case WMI_BL_REASON_BTM_DIASSOC_IMMINENT:
+		return REASON_BTM_DISASSOC_IMMINENT;
+	case WMI_BL_REASON_BTM_BSS_TERMINATION:
+		return REASON_BTM_BSS_TERMINATION;
+	case WMI_BL_REASON_BTM_MBO_RETRY:
+		return REASON_BTM_MBO_RETRY;
+	case WMI_BL_REASON_REASSOC_RSSI_REJECT:
+		return REASON_REASSOC_RSSI_REJECT;
+	case WMI_BL_REASON_REASSOC_NO_MORE_STAS:
+		return REASON_REASSOC_NO_MORE_STAS;
+	default:
+		return REASON_UNKNOWN;
+	}
+}
+
 int wma_handle_btm_blacklist_event(void *handle, uint8_t *cmd_param_info,
 				   uint32_t len)
 {
@@ -6505,9 +6539,11 @@ int wma_handle_btm_blacklist_event(void *handle, uint8_t *cmd_param_info,
 		WMI_MAC_ADDR_TO_CHAR_ARRAY(&src_list->bssid,
 					   roam_blacklist->bssid.bytes);
 		roam_blacklist->timeout = src_list->timeout;
-		roam_blacklist->received_time =
-			qdf_do_div(qdf_get_monotonic_boottime(),
-				   QDF_MC_TIMER_TO_MS_UNIT);
+		roam_blacklist->received_time = src_list->timestamp;
+		roam_blacklist->original_timeout = src_list->original_timeout;
+		roam_blacklist->reject_reason =
+				wma_get_reject_reason(src_list->reason);
+		roam_blacklist->source = src_list->source;
 		roam_blacklist++;
 		src_list++;
 	}