wlan: Providing fix for global PMKIdCache in HDD (STA + STA)
PMKIdCache and PMKIdCacheIndex are currently global in HDD.
This will create issues while supporting STA + STA concurrency.
Moving the PMKIdCache and PMKIdIndex inside pAdapter.
CRs-Fixed: 668610
Change-Id: Ia1fcb2903a9133ddad22f597a1d7578d37591084
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 4326ed5..ae55562 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -8142,17 +8142,13 @@
#ifdef FEATURE_WLAN_LFR
-#define MAX_PMKSAIDS_IN_CACHE 8
-
-static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
-static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
-
static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_pmksa *pmksa)
{
tANI_U32 j=0;
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
+ hdd_station_ctx_t *pHddStaCtx;
tHalHandle halHandle;
eHalStatus result;
int status;
@@ -8180,17 +8176,18 @@
// Retrieve halHandle
halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
+ pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
- for (j = 0; j < PMKIDCacheIndex; j++)
+ for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
{
- if(vos_mem_compare(PMKIDCache[j].BSSID,
+ if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
pmksa->bssid, WNI_CFG_BSSID_LEN))
{
/* BSSID matched previous entry. Overwrite it. */
BSSIDMatched = 1;
- vos_mem_copy(PMKIDCache[j].BSSID,
+ vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
pmksa->bssid, WNI_CFG_BSSID_LEN);
- vos_mem_copy(PMKIDCache[j].PMKID,
+ vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
pmksa->pmkid,
CSR_RSN_PMKID_SIZE);
hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
@@ -8202,35 +8199,37 @@
}
/* Check we compared all entries,if then take the first slot now */
- if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
+ if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0;
if (!BSSIDMatched)
{
// Now, we DON'T have a BSSID match, so take a new entry in the cache.
- vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
+ vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID,
pmksa->bssid, ETHER_ADDR_LEN);
- vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
+ vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID,
pmksa->pmkid,
CSR_RSN_PMKID_SIZE);
- hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
- __func__, PMKIDCacheIndex );
+ hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.",
+ __func__, pHddStaCtx->PMKIDCacheIndex );
dump_bssid(pmksa->bssid);
dump_pmkid(halHandle, pmksa->pmkid);
// Increment the HDD Local Cache index
// The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
- if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
+ if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1))
+ pHddStaCtx->PMKIDCacheIndex++;
+ else
+ pHddStaCtx->PMKIDCacheIndex = 0;
}
// Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
- //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
- // __func__, i );
- hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
- __func__, PMKIDCacheIndex );
+ hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
+ __func__, pHddStaCtx->PMKIDCacheIndex );
+
// Finally set the PMKSA ID Cache in CSR
result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
- PMKIDCache,
- PMKIDCacheIndex);
+ pHddStaCtx->PMKIDCache,
+ pHddStaCtx->PMKIDCacheIndex);
MTRACE(vos_trace(VOS_MODULE_ID_HDD,
TRACE_CODE_HDD_CFG80211_SET_PMKSA,
pAdapter->sessionId, result));
@@ -8244,6 +8243,7 @@
{
tANI_U32 j=0;
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
+ hdd_station_ctx_t *pHddStaCtx;
tHalHandle halHandle;
tANI_U8 BSSIDMatched = 0;
hdd_context_t *pHddCtx;
@@ -8271,51 +8271,50 @@
/*Retrieve halHandle*/
halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
+ pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
/*in case index is 0,no entry to delete*/
- if (0 == PMKIDCacheIndex)
+ if (0 == pHddStaCtx->PMKIDCacheIndex)
{
- hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
- __func__);
- return -EINVAL;
+ hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush"));
+ return 0;
}
/*find the matching PMKSA entry from j=0 to (index-1),
* and delete the matched one
*/
- for (j = 0; j<PMKIDCacheIndex; j++)
+ for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
{
- if (vos_mem_compare(PMKIDCache[j].BSSID,
+ if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
pmksa->bssid,
WNI_CFG_BSSID_LEN))
{
/* BSSID matched entry */
BSSIDMatched = 1;
-
- if (j<PMKIDCacheIndex-1)
+ if (j < pHddStaCtx->PMKIDCacheIndex-1)
{
/*replace the matching entry with the last entry in HDD local cache*/
- vos_mem_copy(PMKIDCache[j].BSSID,
- PMKIDCache[PMKIDCacheIndex-1].BSSID,
- WNI_CFG_BSSID_LEN);
- vos_mem_copy(PMKIDCache[j].PMKID,
- PMKIDCache[PMKIDCacheIndex-1].PMKID,
- CSR_RSN_PMKID_SIZE);
- }
+ vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
+ pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
+ VOS_MAC_ADDR_SIZE);
+ vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
+ pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
+ CSR_RSN_PMKID_SIZE);
+ }
/*clear the last entry in HDD cache ---[index-1]*/
- vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
- vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
-
+ vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
+ VOS_MAC_ADDR_SIZE);
+ vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
+ CSR_RSN_PMKID_SIZE);
/*reduce the PMKID array index*/
- PMKIDCacheIndex--;
-
+ pHddStaCtx->PMKIDCacheIndex--;
/*delete the last PMKID cache in CSR*/
if (eHAL_STATUS_SUCCESS !=
sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
{
hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
- __func__,PMKIDCacheIndex);
+ __func__, pHddStaCtx->PMKIDCacheIndex);
status = -EINVAL;
}
@@ -8345,6 +8344,7 @@
{
tANI_U32 j=0;
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
+ hdd_station_ctx_t *pHddStaCtx;
tHalHandle halHandle;
hdd_context_t *pHddCtx;
tANI_U8 *pBSSId;
@@ -8372,19 +8372,19 @@
/*Retrieve halHandle*/
halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
+ pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
/*in case index is 0,no entry to delete*/
- if (0 == PMKIDCacheIndex)
+ if (0 == pHddStaCtx->PMKIDCacheIndex)
{
hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
- return -EINVAL;
+ return 0;
}
/*delete all the PMKSA one by one */
- for (j = 0; j<PMKIDCacheIndex; j++)
+ for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
{
- pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
-
+ pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID);
/*delete the PMKID in CSR*/
if (eHAL_STATUS_SUCCESS !=
sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
@@ -8394,11 +8394,11 @@
status = -EINVAL;
}
/*clear the entry in HDD cache 0--index-1 */
- vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
- vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
- }
+ vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE);
+ vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
+ }
- PMKIDCacheIndex = 0;
+ pHddStaCtx->PMKIDCacheIndex = 0;
return status;
}
#endif