Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebce224b authored by Abhishek Ambure's avatar Abhishek Ambure Committed by Madan Koyyalamudi
Browse files

qcacmn: Add ini support for SAE-PK roam score

SAE Public Key (SAE-PK) authentication is an extension of SAE. Host adds
support for SAE-PK APs roam score which host uses to select AP for initial
connection and roaming.
User configures SAE-PK APs weightage using INI "sae_pk_ap_weightage".

Change-Id: I9066c483188bcbf01e3ffbcc4c57f04e1a9129f1
CRs-Fixed: 2769373
parent c7d12081
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -709,6 +709,7 @@ struct wlan_rsn_ie {
};

#define WLAN_WAPI_IE_MIN_LEN            20
#define WLAN_RSNX_CAPA_SAE_PK BIT(6)

/**
 * struct wlan_wpa_ie_hdr: wpa ie header
@@ -1847,6 +1848,42 @@ static inline QDF_STATUS wlan_parse_rsn_ie(uint8_t *rsn_ie,
	return QDF_STATUS_SUCCESS;
}

/**
 * wlan_parse_rsnxe_ie() - parse oce RSNXE IE
 * @rsnxe_ie: RSNXE IE pointer
 * @cap_len: pointer to hold len of ext capability
 *
 * While parsing beacon IEs, util_scan_populate_bcn_ie_list() validates
 * length and element ID of RSNXE IE and then stores in scan cache.
 * It is a callers responsiblity to get the rsnxe ie pointer
 * using util_scan_entry_rsnxe() API, which points to rsnxe ie
 * stored in scan cache. Thus caller is responsible for ensuring
 * the length of the IE is consistent with the embedded length.
 *
 * Return: pointer to RSNXE capability or NULL
 */

static inline uint8_t *
wlan_parse_rsnxe_ie(uint8_t *rsnxe_ie, uint8_t *cap_len)
{
	uint8_t len;
	uint8_t *ie;

	if (!rsnxe_ie)
		return NULL;

	ie = rsnxe_ie;
	len = ie[1];
	ie += 2;

	if (!len)
		return NULL;

	*cap_len = ie[0] & 0xf;

	return ie;
}

/**
 * wlan_parse_wpa_ie() - parse wpa ie
 * @wpa_ie: wpa ie ptr
+41 −4
Original line number Diff line number Diff line
@@ -671,6 +671,36 @@ static uint32_t scm_get_sta_nss(struct wlan_objmgr_psoc *psoc,
}
#endif

/**
 * scm_calculate_sae_pk_ap_weightage() - Calculate SAE-PK AP weightage
 * @entry: bss entry
 * @score_params: bss score params
 * @sae_pk_cap_present: sae_pk cap presetn in RSNXE capability field
 *
 * Return: SAE-PK AP weightage score
 */
static uint32_t
scm_calculate_sae_pk_ap_weightage(struct scan_cache_entry *entry,
				  struct scoring_config *score_params,
				  bool *sae_pk_cap_present)
{
	uint8_t *rsnxe_ie, *rsnxe_cap, cap_len;

	rsnxe_ie = util_scan_entry_rsnxe(entry);

	rsnxe_cap = wlan_parse_rsnxe_ie(rsnxe_ie, &cap_len);

	if (!rsnxe_cap)
		return 0;

	*sae_pk_cap_present = *rsnxe_cap & WLAN_RSNX_CAPA_SAE_PK;
	if (*sae_pk_cap_present)
		return score_params->weight_cfg.sae_pk_ap_weightage *
			MAX_INDEX_SCORE;

	return 0;
}

int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
		struct scan_default_params *params,
		struct scan_cache_entry *entry,
@@ -695,6 +725,8 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
	int8_t rssi_pref_5g_rssi_thresh;
	bool same_bucket = false;
	bool ap_su_beam_former = false;
	uint32_t sae_pk_score = 0;
	bool sae_pk_cap_present = 0;
	struct wlan_ie_vhtcaps *vht_cap;
	struct scoring_config *score_config;
	struct weight_config *weight_config;
@@ -805,6 +837,10 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
		score += oce_wan_score;
	}

	sae_pk_score = scm_calculate_sae_pk_ap_weightage(entry, score_config,
							&sae_pk_cap_present);
	score += sae_pk_score;

	pdev = wlan_objmgr_get_pdev_by_id(psoc, entry->pdev_id, WLAN_SCAN_ID);
	if (!pdev) {
		scm_err("pdev is NULL");
@@ -834,20 +870,21 @@ 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("QDF_MAC_ADDR_FMT" 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("QDF_MAC_ADDR_FMT" 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 sae_pk_cap_present %d",
		       QDF_MAC_ADDR_REF(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,
		       sae_pk_cap_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 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 sae_pk %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,
		       score);
		       sae_pk_score, score);

	entry->bss_score = score;
	return score;
+5 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ typedef uint32_t wlan_scan_id;
#define BEST_CANDIDATE_MAX_WEIGHT 100
#define MAX_INDEX_SCORE 100
#define MAX_INDEX_PER_INI 4
#define SAE_PK_AP_WEIGHTAGE 3

#define WLAN_GET_BITS(_val, _index, _num_bits) \
	(((_val) >> (_index)) & ((1 << (_num_bits)) - 1))
@@ -162,6 +163,7 @@ struct element_info {
 * @rnrie: reduced neighbor report IE
 * @adaptive_11r: pointer to adaptive 11r IE
 * @single_pmk: Pointer to sae single pmk IE
 * @rsnxe: Pointer to rsnxe IE
 */
struct ie_list {
	uint8_t *tim;
@@ -214,6 +216,7 @@ struct ie_list {
	uint8_t *extender;
	uint8_t *adaptive_11r;
	uint8_t *single_pmk;
	uint8_t *rsnxe;
};

enum scan_entry_connection_state {
@@ -480,6 +483,7 @@ struct scan_cache_entry {
 * @pcl_weightage: PCL weightage
 * @channel_congestion_weightage: channel congestion weightage
 * @oce_wan_weightage: OCE WAN metrics weightage
 * @sae_pk_ap_weightage: SAE-PK AP weigtage
 */
struct  weight_config {
	uint8_t rssi_weightage;
@@ -493,6 +497,7 @@ struct weight_config {
	uint8_t pcl_weightage;
	uint8_t channel_congestion_weightage;
	uint8_t oce_wan_weightage;
	uint8_t sae_pk_ap_weightage;
};

/**
+14 −0
Original line number Diff line number Diff line
@@ -1600,6 +1600,20 @@ util_scan_entry_mbo_oce(struct scan_cache_entry *scan_entry)
	return scan_entry->ie_list.mbo_oce;
}

/**
 * util_scan_entry_rsnxe() - function to read RSNXE ie
 * @scan_entry: scan entry
 *
 * API, function to read RSNXE ie
 *
 * Return: RSNXE ie
 */
static inline uint8_t *
util_scan_entry_rsnxe(struct scan_cache_entry *scan_entry)
{
	return scan_entry->ie_list.rsnxe;
}

/**
 * util_scan_scm_chan_to_band() - function to tell band for channel number
 * @chan: Channel number
+5 −0
Original line number Diff line number Diff line
@@ -1110,6 +1110,11 @@ util_scan_populate_bcn_ie_list(struct wlan_objmgr_pdev *pdev,
				goto err;
			scan_params->ie_list.fils_indication = (uint8_t *)ie;
			break;
		case WLAN_ELEMID_RSNXE:
			if (!ie->ie_len)
				goto err;
			scan_params->ie_list.rsnxe = (uint8_t *)ie;
			break;
		case WLAN_ELEMID_EXTN_ELEM:
			status = util_scan_parse_extn_ie(scan_params, ie);
			if (QDF_IS_STATUS_ERROR(status))