Pārlūkot izejas kodu

qcacmn: Send oce_subnet_id_weightage_pcnt to firmware

In struct weight_config, "oce_subnet_id_weightage" added newly.
Station uses "oce_subnet_id_weightage" as one of the parameter for
selecting AP candidate during initial connection. Host sends
"oce_subnet_id_weightage" ini value to firmware over WMI command
WMI_ROAM_AP_PROFILE.

Add oce_subnet_id_weightage in scan object scoring param to calculate
weightage based on SUBNET ID and select candidate accordingly.

Change-Id: I6583f46f661eaefabbad858bc7fb34e37443ebae
CRs-Fixed: 2675924
Abhishek Ambure 5 gadi atpakaļ
vecāks
revīzija
101c1fdeda

+ 52 - 0
umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h

@@ -44,6 +44,8 @@
 #define MBO_OCE_OUI_SIZE 4
 #define REDUCED_WAN_METRICS_ATTR 103
 #define AP_TX_PWR_ATTR 107
+#define OCE_SUBNET_ID_ATTR 108
+#define OCE_SUBNET_ID_LEN 6
 
 /* WCN IE */
 /* Microsoft OUI */
@@ -1902,6 +1904,56 @@ wlan_parse_oce_reduced_wan_metrics_ie(uint8_t *mbo_oce_ie,
 	return false;
 }
 
+/**
+ * wlan_parse_oce_subnet_id_ie() - parse oce subnet id IE
+ * @mbo_oce_ie: MBO/OCE IE pointer
+ *
+ * While parsing vendor IE, is_mbo_oce_oui() API does sanity of
+ * length and attribute ID for MBO_OCE_OUI and after passing the
+ * sanity only mbo_oce IE is stored in scan cache.
+ * It is a callers responsiblity to get the mbo_oce_ie pointer
+ * using util_scan_entry_mbo_oce() API, which points to mbo_oce
+ * stored in scan cache. Thus caller is responsible for ensuring
+ * the length of the IE is consistent with the embedded length.
+ *
+ * Return: true if oce subnet id is present, else false
+ */
+static inline bool
+wlan_parse_oce_subnet_id_ie(uint8_t *mbo_oce_ie)
+{
+	uint8_t len, attribute_len, attribute_id;
+	uint8_t *ie;
+
+	if (!mbo_oce_ie)
+		return false;
+
+	ie = mbo_oce_ie;
+	len = ie[1];
+	ie += 2;
+
+	if (len <= MBO_OCE_OUI_SIZE)
+		return false;
+
+	ie += MBO_OCE_OUI_SIZE;
+	len -= MBO_OCE_OUI_SIZE;
+
+	while (len > 2) {
+		attribute_id = ie[0];
+		attribute_len = ie[1];
+		len -= 2;
+		if (attribute_len > len)
+			return false;
+
+		if (attribute_id == OCE_SUBNET_ID_ATTR)
+			return true;
+
+		ie += (attribute_len + 2);
+		len -= attribute_len;
+	}
+
+	return false;
+}
+
 /*
  * wlan_parse_oce_ap_tx_pwr_ie() - parse oce ap tx pwr
  * @mbo_oce_ie: MBO/OCE ie ptr

+ 46 - 14
umac/scan/core/src/wlan_scan_bss_score.c

@@ -540,18 +540,45 @@ static int32_t scm_calculate_oce_wan_score(
 			&score_params->oce_wan_scoring);
 }
 
+/**
+ * scm_calculate_oce_subnet_id_weightage () - Calculate oce subnet id weightage
+ * @entry: bss entry
+ * @score_params: bss score params
+ *
+ * Return : oce subnet id score
+ */
+static uint32_t
+scm_calculate_oce_subnet_id_weightage(struct scan_cache_entry *entry,
+				      struct scoring_config *score_params,
+				      bool *oce_subnet_id_present)
+{
+	uint32_t score = 0;
+	uint8_t *mbo_oce_ie;
+
+	mbo_oce_ie = util_scan_entry_mbo_oce(entry);
+	*oce_subnet_id_present = wlan_parse_oce_subnet_id_ie(mbo_oce_ie);
+
+	if (*oce_subnet_id_present)
+		/* Consider 50% weightage of subnet id */
+		score  = (score_params->weight_cfg.oce_subnet_id_weightage *
+			 (MAX_PCT_SCORE / 2));
+
+	return score;
+}
+
 /**
  * scm_calculate_oce_ap_tx_pwr_weightage () - Calculate oce ap tx pwr weightage
  * @entry: bss entry
  * @score_params: bss score params
+ * @ap_tx_pwr_dbm: pointer to hold ap tx power
  *
  * Return : oce ap tx power score
  */
 static uint32_t
 scm_calculate_oce_ap_tx_pwr_weightage(struct scan_cache_entry *entry,
-				      struct scoring_config *score_params)
+				      struct scoring_config *score_params,
+				      int8_t *ap_tx_pwr_dbm)
 {
-	int8_t ap_tx_pwr_dbm = 0;
 	uint8_t *mbo_oce_ie, ap_tx_pwr_factor;
 	struct rssi_cfg_score *rssi_score_param;
 	int32_t best_rssi_threshold, good_rssi_threshold, bad_rssi_threshold;
@@ -560,7 +587,7 @@ scm_calculate_oce_ap_tx_pwr_weightage(struct scan_cache_entry *entry,
 	bool ap_tx_pwr_cap_present = true;
 
 	mbo_oce_ie = util_scan_entry_mbo_oce(entry);
-	if (!wlan_parse_oce_ap_tx_pwr_ie(mbo_oce_ie, &ap_tx_pwr_dbm)) {
+	if (!wlan_parse_oce_ap_tx_pwr_ie(mbo_oce_ie, ap_tx_pwr_dbm)) {
 		ap_tx_pwr_cap_present = false;
 		/* If no OCE AP TX pwr, consider Uplink RSSI = Downlink RSSI */
 		normalized_ap_tx_pwr = entry->rssi_raw;
@@ -571,7 +598,7 @@ scm_calculate_oce_ap_tx_pwr_weightage(struct scan_cache_entry *entry,
 		 * Currently assuming STA Tx Power to be 20dBm, though later it
 		 * need to fetched from hal-phy API.
 		 */
-		normalized_ap_tx_pwr = (20 - (ap_tx_pwr_dbm - entry->rssi_raw));
+		normalized_ap_tx_pwr = (20 - (*ap_tx_pwr_dbm - entry->rssi_raw));
 	}
 
 	rssi_score_param = &score_params->rssi_score;
@@ -607,10 +634,6 @@ scm_calculate_oce_ap_tx_pwr_weightage(struct scan_cache_entry *entry,
 
 	score  = score_params->weight_cfg.oce_ap_tx_pwr_weightage *
 			ap_tx_pwr_factor;
-	scm_debug("ap_tx_pwr_cap_present %d ap_tx_pwr_dbm %d rssi %d normalize_ap_tx_pwr %d score %d weight %d",
-		  ap_tx_pwr_cap_present, ap_tx_pwr_dbm, entry->rssi_raw,
-		  normalized_ap_tx_pwr, score,
-		  score_params->weight_cfg.oce_ap_tx_pwr_weightage);
 
 	return score;
 }
@@ -697,7 +720,9 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
 	int32_t congestion_score = 0;
 	int32_t congestion_pct = 0;
 	int32_t oce_wan_score = 0;
-	uint8_t oce_ap_tx_pwr_score;
+	uint8_t oce_ap_tx_pwr_score = 0;
+	uint8_t oce_subnet_id_score = 0;
+	bool oce_subnet_id_present = 0;
 	uint8_t prorated_pcnt;
 	bool is_vht = false;
 	int8_t good_rssi_threshold;
@@ -710,6 +735,7 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
 	struct wlan_scan_obj *scan_obj;
 	uint32_t sta_nss;
 	struct wlan_objmgr_pdev *pdev = NULL;
+	int8_t ap_tx_pwr_dbm = 0;
 
 	scan_obj = wlan_psoc_get_scan_obj(psoc);
 	if (!scan_obj) {
@@ -819,8 +845,13 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
 	}
 
 	oce_ap_tx_pwr_score =
-		scm_calculate_oce_ap_tx_pwr_weightage(entry, score_config);
+		scm_calculate_oce_ap_tx_pwr_weightage(entry, score_config,
+						      &ap_tx_pwr_dbm);
 	score += oce_ap_tx_pwr_score;
+	oce_subnet_id_score = scm_calculate_oce_subnet_id_weightage(entry,
+					score_config, &oce_subnet_id_present);
+	score += oce_subnet_id_score;
+
 	pdev = wlan_objmgr_get_pdev_by_id(psoc, entry->pdev_id, WLAN_SCAN_ID);
 	if (!pdev) {
 		scm_err("pdev is NULL");
@@ -848,19 +879,20 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
 		       score_config->beamformee_cap, score_config->cb_mode_24G,
 		       score_config->cb_mode_5G, sta_nss);
 
-	scm_nofl_debug("Candidate(%pM freq %d): rssi %d HT %d VHT %d HE %d su bfer %d phy %d  air time frac %d qbss %d cong_pct %d NSS %d",
+	scm_nofl_debug("Candidate(%pM freq %d): rssi %d HT %d VHT %d HE %d su bfer %d phy %d  air time frac %d qbss %d cong_pct %d NSS %d ap_tx_pwr_dbm %d oce_subnet_id_present %d",
 		       entry->bssid.bytes, entry->channel.chan_freq,
 		       entry->rssi_raw, util_scan_entry_htcap(entry) ? 1 : 0,
 		       util_scan_entry_vhtcap(entry) ? 1 : 0,
 		       util_scan_entry_hecap(entry) ? 1 : 0, ap_su_beam_former,
 		       entry->phy_mode, entry->air_time_fraction,
-		       entry->qbss_chan_load, congestion_pct, entry->nss);
+		       entry->qbss_chan_load, congestion_pct, entry->nss,
+		       ap_tx_pwr_dbm, oce_subnet_id_present);
 
-	scm_nofl_debug("Scores: prorated_pcnt %d rssi %d pcl %d ht %d vht %d he %d bfee %d bw %d band %d congestion %d nss %d oce wan %d oce ap tx pwr %d TOTAL %d",
+	scm_nofl_debug("Scores: prorated_pcnt %d rssi %d pcl %d ht %d vht %d he %d bfee %d bw %d band %d congestion %d nss %d oce wan %d oce ap tx pwr %d subnet id score %d TOTAL %d",
 		       prorated_pcnt, rssi_score, pcl_score, ht_score,
 		       vht_score, he_score, beamformee_score, bandwidth_score,
 		       band_score, congestion_score, nss_score, oce_wan_score,
-		       oce_ap_tx_pwr_score, score);
+		       oce_ap_tx_pwr_score, oce_subnet_id_score, score);
 
 	entry->bss_score = score;
 	return score;

+ 3 - 0
umac/scan/dispatcher/inc/wlan_scan_public_structs.h

@@ -70,6 +70,7 @@ typedef uint32_t wlan_scan_id;
 #define CHANNEL_CONGESTION_WEIGHTAGE 5
 #define OCE_WAN_WEIGHTAGE 2
 #define OCE_AP_TX_POWER_WEIGHTAGE 5
+#define OCE_SUBNET_ID_WEIGHTAGE 3
 #define BEST_CANDIDATE_MAX_WEIGHT 200
 #define MAX_PCT_SCORE 100
 #define MAX_INDEX_PER_INI 4
@@ -481,6 +482,7 @@ struct scan_cache_entry {
  * @channel_congestion_weightage: channel congestion weightage
  * @oce_wan_weightage: OCE WAN metrics weightage
  * @oce_ap_tx_pwr_weightage: OCE AP tx power weigtage
+ * @oce_subnet_id_weightage: OCE subnet id weigtage
  */
 struct  weight_config {
 	uint8_t rssi_weightage;
@@ -495,6 +497,7 @@ struct  weight_config {
 	uint8_t channel_congestion_weightage;
 	uint8_t oce_wan_weightage;
 	uint8_t oce_ap_tx_pwr_weightage;
+	uint8_t oce_subnet_id_weightage;
 };
 
 /**

+ 2 - 0
wmi/inc/wmi_unified_roam_param.h

@@ -376,6 +376,7 @@ struct param_slot_scoring {
  * @pcl_weightage: PCL weightage out of total score in %.
  * @oce_wan_weightage OCE WAN metrics weightage out of total score in %.
  * @oce_ap_tx_pwr_weightage: OCE AP TX power score in %
+ * @oce_subnet_id_weightage: OCE subnet id score in %
  * @bw_index_score: channel BW scoring percentage information.
  *                 BITS 0-7   :- It contains scoring percentage of 20MHz   BW
  *                 BITS 8-15  :- It contains scoring percentage of 40MHz   BW
@@ -418,6 +419,7 @@ struct scoring_param {
 	int32_t pcl_weightage;
 	int32_t oce_wan_weightage;
 	uint32_t oce_ap_tx_pwr_weightage;
+	uint32_t oce_subnet_id_weightage;
 	uint32_t bw_index_score;
 	uint32_t band_index_score;
 	uint32_t nss_index_score;

+ 5 - 2
wmi/src/wmi_unified_roam_tlv.c

@@ -1612,10 +1612,12 @@ send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
 			ap_profile->param.oce_wan_weightage;
 	score_param->oce_ap_tx_pwr_weightage_pcnt =
 				ap_profile->param.oce_ap_tx_pwr_weightage;
+	score_param->oce_ap_subnet_id_weightage_pcnt =
+				ap_profile->param.oce_subnet_id_weightage;
 	score_param->vendor_roam_score_algorithm_id =
 			ap_profile->param.vendor_roam_score_algorithm;
 
-	WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d APTX %d roam score algo %d",
+	WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d APTX %d roam score algo %d subnet id %d",
 		 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
 		 score_param->ht_weightage_pcnt,
 		 score_param->vht_weightage_pcnt,
@@ -1627,7 +1629,8 @@ send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
 		 score_param->pcl_weightage_pcnt,
 		 score_param->oce_wan_weightage_pcnt,
 		 score_param->oce_ap_tx_pwr_weightage_pcnt,
-		 score_param->vendor_roam_score_algorithm_id);
+		 score_param->vendor_roam_score_algorithm_id,
+		 score_param->oce_ap_subnet_id_weightage_pcnt);
 
 	score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
 	score_param->band_scoring.score_pcnt =