From a6c6790b938495ef91ef1e0c6335bc99801546e3 Mon Sep 17 00:00:00 2001 From: Abhishek Ambure Date: Sat, 19 Sep 2020 16:00:32 +0530 Subject: [PATCH] qcacmn: Move RSNXE IE parsing to crypto module Move RSNXE IE parsing to crypto module and add entry of RSNXE IE in util_scan_copy_beacon_data() so that a copy of RSNXE IE remains in scan entry cache and doesn't get free on scan result update. Change-Id: I792c8636d7e1f21c6291158188ab2c1d241151ec CRs-Fixed: 2780832 --- .../cmn_defs/inc/wlan_cmn_ieee80211.h | 37 ------------------- .../crypto/inc/wlan_crypto_global_api.h | 10 +++++ .../crypto/inc/wlan_crypto_global_def.h | 6 +++ .../crypto/src/wlan_crypto_global_api.c | 21 +++++++++++ .../core/src/wlan_cm_bss_scoring.c | 5 ++- .../scan/dispatcher/inc/wlan_scan_utils_api.h | 1 + 6 files changed, 41 insertions(+), 39 deletions(-) diff --git a/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h b/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h index 13691f518e3c..35a91d1f0c1a 100644 --- a/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h +++ b/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h @@ -753,7 +753,6 @@ struct wlan_rsn_ie_hdr { #define WLAN_RSN_IE_MIN_LEN 2 #define WLAN_WAPI_IE_MIN_LEN 20 -#define WLAN_RSNX_CAPA_SAE_PK BIT(6) /** * struct wlan_wpa_ie_hdr: wpa ie header @@ -1796,42 +1795,6 @@ wlan_parse_oce_reduced_wan_metrics_ie(uint8_t *mbo_oce_ie, return false; } -/** - * 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_oce_subnet_id_ie() - parse oce subnet id IE * @mbo_oce_ie: MBO/OCE IE pointer diff --git a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h index ec90362e5f5c..81dd0a5e5262 100644 --- a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h +++ b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h @@ -712,6 +712,16 @@ bool wlan_crypto_check_wpa_match(struct wlan_objmgr_psoc *psoc, uint16_t ie_len, struct wlan_crypto_params * peer_crypto_params); +/** + * wlan_crypto_parse_rsnxe_ie() - parse RSNXE IE + * @rsnxe_ie: RSNXE IE pointer + * @cap_len: pointer to hold len of ext capability + * + * Return: pointer to RSNXE capability or NULL + */ +uint8_t * +wlan_crypto_parse_rsnxe_ie(uint8_t *rsnxe_ie, uint8_t *cap_len); + /** * wlan_set_vdev_crypto_prarams_from_ie - Sets vdev crypto params from IE info * @vdev: vdev pointer diff --git a/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h b/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h index 3b7f4bdbeb54..331982ef038f 100644 --- a/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h +++ b/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h @@ -184,6 +184,12 @@ typedef enum wlan_crypto_rsn_cap { WLAN_CRYPTO_RSN_CAP_OCV_SUPPORTED = 0x4000, } wlan_crypto_rsn_cap; +enum wlan_crypto_rsnx_cap { + WLAN_CRYPTO_RSNX_CAP_PROTECTED_TWT = 0x10, + WLAN_CRYPTO_RSNX_CAP_SAE_H2E = 0x20, + WLAN_CRYPTO_RSNX_CAP_SAE_PK = 0x40, +}; + typedef enum wlan_crypto_key_mgmt { WLAN_CRYPTO_KEY_MGMT_IEEE8021X = 0, WLAN_CRYPTO_KEY_MGMT_PSK = 1, diff --git a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c index 2ef2d78fdd8f..06f5be901606 100644 --- a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c +++ b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c @@ -4261,6 +4261,27 @@ wlan_crypto_reset_prarams(struct wlan_crypto_params *params) params->rsn_caps = 0; } +uint8_t * +wlan_crypto_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; +} + QDF_STATUS wlan_set_vdev_crypto_prarams_from_ie(struct wlan_objmgr_vdev *vdev, uint8_t *ie_ptr, uint16_t ie_len) diff --git a/umac/mlme/connection_mgr/core/src/wlan_cm_bss_scoring.c b/umac/mlme/connection_mgr/core/src/wlan_cm_bss_scoring.c index 70e4b5541be8..3271a0a74c07 100644 --- a/umac/mlme/connection_mgr/core/src/wlan_cm_bss_scoring.c +++ b/umac/mlme/connection_mgr/core/src/wlan_cm_bss_scoring.c @@ -26,6 +26,7 @@ #include "cfg_ucfg_api.h" #include "wlan_cm_bss_score_param.h" #include "wlan_scan_api.h" +#include "wlan_crypto_global_api.h" #define CM_20MHZ_BW_INDEX 0 #define CM_40MHZ_BW_INDEX 1 @@ -675,12 +676,12 @@ cm_calculate_sae_pk_ap_weightage(struct scan_cache_entry *entry, rsnxe_ie = util_scan_entry_rsnxe(entry); - rsnxe_cap = wlan_parse_rsnxe_ie(rsnxe_ie, &cap_len); + rsnxe_cap = wlan_crypto_parse_rsnxe_ie(rsnxe_ie, &cap_len); if (!rsnxe_cap) return 0; - *sae_pk_cap_present = *rsnxe_cap & WLAN_RSNX_CAPA_SAE_PK; + *sae_pk_cap_present = *rsnxe_cap & WLAN_CRYPTO_RSNX_CAP_SAE_PK; if (*sae_pk_cap_present) return score_params->weight_config.sae_pk_ap_weightage * CM_MAX_PCT_SCORE; diff --git a/umac/scan/dispatcher/inc/wlan_scan_utils_api.h b/umac/scan/dispatcher/inc/wlan_scan_utils_api.h index 81a2e0dcf781..5d02dbd1159e 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_utils_api.h +++ b/umac/scan/dispatcher/inc/wlan_scan_utils_api.h @@ -723,6 +723,7 @@ util_scan_copy_beacon_data(struct scan_cache_entry *new_entry, ie_lst->extender = conv_ptr(ie_lst->extender, old_ptr, new_ptr); ie_lst->adaptive_11r = conv_ptr(ie_lst->adaptive_11r, old_ptr, new_ptr); ie_lst->single_pmk = conv_ptr(ie_lst->single_pmk, old_ptr, new_ptr); + ie_lst->rsnxe = conv_ptr(ie_lst->rsnxe, old_ptr, new_ptr); return QDF_STATUS_SUCCESS; }