Commit 6c404f34 authored by Hante Meuleman's avatar Hante Meuleman Committed by Kalle Valo

brcmfmac: Cleanup pmksa cache handling code

Reviewed-by: default avatarArend Van Spriel <arend@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarHante Meuleman <meuleman@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4235edcd
...@@ -3223,26 +3223,22 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, ...@@ -3223,26 +3223,22 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
} }
static __used s32 static __used s32
brcmf_update_pmklist(struct net_device *ndev, brcmf_update_pmklist(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp)
struct brcmf_cfg80211_pmk_list *pmk_list, s32 err)
{ {
int i, j; struct brcmf_pmk_list_le *pmk_list;
u32 pmkid_len; int i;
u32 npmk;
s32 err;
pmkid_len = le32_to_cpu(pmk_list->pmkids.npmkid); pmk_list = &cfg->pmk_list;
npmk = le32_to_cpu(pmk_list->npmk);
brcmf_dbg(CONN, "No of elements %d\n", pmkid_len); brcmf_dbg(CONN, "No of elements %d\n", npmk);
for (i = 0; i < pmkid_len; i++) { for (i = 0; i < npmk; i++)
brcmf_dbg(CONN, "PMKID[%d]: %pM =\n", i, brcmf_dbg(CONN, "PMK[%d]: %pM\n", i, &pmk_list->pmk[i].bssid);
&pmk_list->pmkids.pmkid[i].BSSID);
for (j = 0; j < WLAN_PMKID_LEN; j++)
brcmf_dbg(CONN, "%02x\n",
pmk_list->pmkids.pmkid[i].PMKID[j]);
}
if (!err) err = brcmf_fil_iovar_data_set(ifp, "pmkid_info", pmk_list,
brcmf_fil_iovar_data_set(netdev_priv(ndev), "pmkid_info", sizeof(*pmk_list));
(char *)pmk_list, sizeof(*pmk_list));
return err; return err;
} }
...@@ -3253,34 +3249,37 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev, ...@@ -3253,34 +3249,37 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev,
{ {
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_if *ifp = netdev_priv(ndev);
struct pmkid_list *pmkids = &cfg->pmk_list->pmkids; struct brcmf_pmksa *pmk = &cfg->pmk_list.pmk[0];
s32 err = 0; s32 err;
u32 pmkid_len, i; u32 npmk, i;
brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "Enter\n");
if (!check_vif_up(ifp->vif)) if (!check_vif_up(ifp->vif))
return -EIO; return -EIO;
pmkid_len = le32_to_cpu(pmkids->npmkid); npmk = le32_to_cpu(cfg->pmk_list.npmk);
for (i = 0; i < pmkid_len; i++) for (i = 0; i < npmk; i++)
if (!memcmp(pmksa->bssid, pmkids->pmkid[i].BSSID, ETH_ALEN)) if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
break; break;
if (i < WL_NUM_PMKIDS_MAX) { if (i < BRCMF_MAXPMKID) {
memcpy(pmkids->pmkid[i].BSSID, pmksa->bssid, ETH_ALEN); memcpy(pmk[i].bssid, pmksa->bssid, ETH_ALEN);
memcpy(pmkids->pmkid[i].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); memcpy(pmk[i].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
if (i == pmkid_len) { if (i == npmk) {
pmkid_len++; npmk++;
pmkids->npmkid = cpu_to_le32(pmkid_len); cfg->pmk_list.npmk = cpu_to_le32(npmk);
}
} else {
brcmf_err("Too many PMKSA entries cached %d\n", npmk);
return -EINVAL;
} }
} else
err = -EINVAL;
brcmf_dbg(CONN, "set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n", brcmf_dbg(CONN, "set_pmksa - PMK bssid: %pM =\n", pmk[npmk].bssid);
pmkids->pmkid[pmkid_len].BSSID); for (i = 0; i < WLAN_PMKID_LEN; i += 4)
for (i = 0; i < WLAN_PMKID_LEN; i++) brcmf_dbg(CONN, "%02x %02x %02x %02x\n", pmk[npmk].pmkid[i],
brcmf_dbg(CONN, "%02x\n", pmkids->pmkid[pmkid_len].PMKID[i]); pmk[npmk].pmkid[i + 1], pmk[npmk].pmkid[i + 2],
pmk[npmk].pmkid[i + 3]);
err = brcmf_update_pmklist(ndev, cfg->pmk_list, err); err = brcmf_update_pmklist(cfg, ifp);
brcmf_dbg(TRACE, "Exit\n"); brcmf_dbg(TRACE, "Exit\n");
return err; return err;
...@@ -3292,46 +3291,35 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev, ...@@ -3292,46 +3291,35 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev,
{ {
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_if *ifp = netdev_priv(ndev);
struct pmkid_list pmkid; struct brcmf_pmksa *pmk = &cfg->pmk_list.pmk[0];
s32 err = 0; s32 err;
u32 pmkid_len, i; u32 npmk, i;
brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "Enter\n");
if (!check_vif_up(ifp->vif)) if (!check_vif_up(ifp->vif))
return -EIO; return -EIO;
memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN); brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", &pmksa->bssid);
memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN);
brcmf_dbg(CONN, "del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n",
&pmkid.pmkid[0].BSSID);
for (i = 0; i < WLAN_PMKID_LEN; i++)
brcmf_dbg(CONN, "%02x\n", pmkid.pmkid[0].PMKID[i]);
pmkid_len = le32_to_cpu(cfg->pmk_list->pmkids.npmkid); npmk = le32_to_cpu(cfg->pmk_list.npmk);
for (i = 0; i < pmkid_len; i++) for (i = 0; i < npmk; i++)
if (!memcmp if (!memcmp(&pmksa->bssid, &pmk[i].bssid, ETH_ALEN))
(pmksa->bssid, &cfg->pmk_list->pmkids.pmkid[i].BSSID,
ETH_ALEN))
break; break;
if ((pmkid_len > 0) if ((npmk > 0) && (i < npmk)) {
&& (i < pmkid_len)) { for (; i < (npmk - 1); i++) {
memset(&cfg->pmk_list->pmkids.pmkid[i], 0, memcpy(&pmk[i].bssid, &pmk[i + 1].bssid, ETH_ALEN);
sizeof(struct pmkid)); memcpy(&pmk[i].pmkid, &pmk[i + 1].pmkid,
for (; i < (pmkid_len - 1); i++) {
memcpy(&cfg->pmk_list->pmkids.pmkid[i].BSSID,
&cfg->pmk_list->pmkids.pmkid[i + 1].BSSID,
ETH_ALEN);
memcpy(&cfg->pmk_list->pmkids.pmkid[i].PMKID,
&cfg->pmk_list->pmkids.pmkid[i + 1].PMKID,
WLAN_PMKID_LEN); WLAN_PMKID_LEN);
} }
cfg->pmk_list->pmkids.npmkid = cpu_to_le32(pmkid_len - 1); memset(&pmk[i], 0, sizeof(*pmk));
} else cfg->pmk_list.npmk = cpu_to_le32(npmk - 1);
err = -EINVAL; } else {
brcmf_err("Cache entry not found\n");
return -EINVAL;
}
err = brcmf_update_pmklist(ndev, cfg->pmk_list, err); err = brcmf_update_pmklist(cfg, ifp);
brcmf_dbg(TRACE, "Exit\n"); brcmf_dbg(TRACE, "Exit\n");
return err; return err;
...@@ -3343,14 +3331,14 @@ brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev) ...@@ -3343,14 +3331,14 @@ brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev)
{ {
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_if *ifp = netdev_priv(ndev);
s32 err = 0; s32 err;
brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "Enter\n");
if (!check_vif_up(ifp->vif)) if (!check_vif_up(ifp->vif))
return -EIO; return -EIO;
memset(cfg->pmk_list, 0, sizeof(*cfg->pmk_list)); memset(&cfg->pmk_list, 0, sizeof(cfg->pmk_list));
err = brcmf_update_pmklist(ndev, cfg->pmk_list, err); err = brcmf_update_pmklist(cfg, ifp);
brcmf_dbg(TRACE, "Exit\n"); brcmf_dbg(TRACE, "Exit\n");
return err; return err;
...@@ -5249,8 +5237,6 @@ static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_info *cfg) ...@@ -5249,8 +5237,6 @@ static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_info *cfg)
cfg->escan_ioctl_buf = NULL; cfg->escan_ioctl_buf = NULL;
kfree(cfg->extra_buf); kfree(cfg->extra_buf);
cfg->extra_buf = NULL; cfg->extra_buf = NULL;
kfree(cfg->pmk_list);
cfg->pmk_list = NULL;
} }
static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_info *cfg) static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_info *cfg)
...@@ -5264,9 +5250,6 @@ static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_info *cfg) ...@@ -5264,9 +5250,6 @@ static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_info *cfg)
cfg->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); cfg->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL);
if (!cfg->extra_buf) if (!cfg->extra_buf)
goto init_priv_mem_out; goto init_priv_mem_out;
cfg->pmk_list = kzalloc(sizeof(*cfg->pmk_list), GFP_KERNEL);
if (!cfg->pmk_list)
goto init_priv_mem_out;
return 0; return 0;
...@@ -5971,7 +5954,7 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp) ...@@ -5971,7 +5954,7 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
wiphy->max_scan_ssids = WL_NUM_SCAN_MAX; wiphy->max_scan_ssids = WL_NUM_SCAN_MAX;
wiphy->max_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX; wiphy->max_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX;
wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX; wiphy->max_num_pmkids = BRCMF_MAXPMKID;
err = brcmf_setup_ifmodes(wiphy, ifp); err = brcmf_setup_ifmodes(wiphy, ifp);
if (err) if (err)
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <brcmu_d11.h> #include <brcmu_d11.h>
#define WL_NUM_SCAN_MAX 10 #define WL_NUM_SCAN_MAX 10
#define WL_NUM_PMKIDS_MAX MAXPMKID
#define WL_TLV_INFO_MAX 1024 #define WL_TLV_INFO_MAX 1024
#define WL_BSS_INFO_MAX 2048 #define WL_BSS_INFO_MAX 2048
#define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */ #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
...@@ -196,12 +195,6 @@ struct brcmf_cfg80211_assoc_ielen_le { ...@@ -196,12 +195,6 @@ struct brcmf_cfg80211_assoc_ielen_le {
__le32 resp_len; __le32 resp_len;
}; };
/* wpa2 pmk list */
struct brcmf_cfg80211_pmk_list {
struct pmkid_list pmkids;
struct pmkid foo[MAXPMKID - 1];
};
/* dongle escan state */ /* dongle escan state */
enum wl_escan_state { enum wl_escan_state {
WL_ESCAN_STATE_IDLE, WL_ESCAN_STATE_IDLE,
...@@ -359,7 +352,7 @@ struct brcmf_cfg80211_info { ...@@ -359,7 +352,7 @@ struct brcmf_cfg80211_info {
struct mutex usr_sync; struct mutex usr_sync;
struct wl_cfg80211_bss_info *bss_info; struct wl_cfg80211_bss_info *bss_info;
struct brcmf_cfg80211_connect_info conn_info; struct brcmf_cfg80211_connect_info conn_info;
struct brcmf_cfg80211_pmk_list *pmk_list; struct brcmf_pmk_list_le pmk_list;
unsigned long scan_status; unsigned long scan_status;
struct brcmf_pub *pub; struct brcmf_pub *pub;
u32 channel; u32 channel;
......
...@@ -126,6 +126,8 @@ ...@@ -126,6 +126,8 @@
#define BRCMF_TXBF_SU_BFR_CAP BIT(0) #define BRCMF_TXBF_SU_BFR_CAP BIT(0)
#define BRCMF_TXBF_MU_BFR_CAP BIT(1) #define BRCMF_TXBF_MU_BFR_CAP BIT(1)
#define BRCMF_MAXPMKID 16 /* max # PMKID cache entries */
/* join preference types for join_pref iovar */ /* join preference types for join_pref iovar */
enum brcmf_join_pref_types { enum brcmf_join_pref_types {
BRCMF_JOIN_PREF_RSSI = 1, BRCMF_JOIN_PREF_RSSI = 1,
...@@ -646,4 +648,26 @@ struct brcmf_wowl_wakeind_le { ...@@ -646,4 +648,26 @@ struct brcmf_wowl_wakeind_le {
__le32 ucode_wakeind; __le32 ucode_wakeind;
}; };
/**
* struct brcmf_pmksa - PMK Security Association
*
* @bssid: The AP's BSSID.
* @pmkid: he PMK material itself.
*/
struct brcmf_pmksa {
u8 bssid[ETH_ALEN];
u8 pmkid[WLAN_PMKID_LEN];
};
/**
* struct brcmf_pmk_list_le - List of pmksa's.
*
* @npmk: Number of pmksa's.
* @pmk: PMK SA information.
*/
struct brcmf_pmk_list_le {
__le32 npmk;
struct brcmf_pmksa pmk[BRCMF_MAXPMKID];
};
#endif /* FWIL_TYPES_H_ */ #endif /* FWIL_TYPES_H_ */
...@@ -237,9 +237,6 @@ static inline bool ac_bitmap_tst(u8 bitmap, int prec) ...@@ -237,9 +237,6 @@ static inline bool ac_bitmap_tst(u8 bitmap, int prec)
#define WPA2_AUTH_RESERVED4 0x0400 #define WPA2_AUTH_RESERVED4 0x0400
#define WPA2_AUTH_RESERVED5 0x0800 #define WPA2_AUTH_RESERVED5 0x0800
/* pmkid */
#define MAXPMKID 16
#define DOT11_DEFAULT_RTS_LEN 2347 #define DOT11_DEFAULT_RTS_LEN 2347
#define DOT11_DEFAULT_FRAG_LEN 2346 #define DOT11_DEFAULT_FRAG_LEN 2346
...@@ -251,24 +248,4 @@ static inline bool ac_bitmap_tst(u8 bitmap, int prec) ...@@ -251,24 +248,4 @@ static inline bool ac_bitmap_tst(u8 bitmap, int prec)
#define HT_CAP_RX_STBC_NO 0x0 #define HT_CAP_RX_STBC_NO 0x0
#define HT_CAP_RX_STBC_ONE_STREAM 0x1 #define HT_CAP_RX_STBC_ONE_STREAM 0x1
struct pmkid {
u8 BSSID[ETH_ALEN];
u8 PMKID[WLAN_PMKID_LEN];
};
struct pmkid_list {
__le32 npmkid;
struct pmkid pmkid[1];
};
struct pmkid_cand {
u8 BSSID[ETH_ALEN];
u8 preauth;
};
struct pmkid_cand_list {
u32 npmkid_cand;
struct pmkid_cand pmkid_cand[1];
};
#endif /* _BRCMU_WIFI_H_ */ #endif /* _BRCMU_WIFI_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment