Commit 75494966 authored by Sukesh Srikakula's avatar Sukesh Srikakula Committed by Greg Kroah-Hartman

staging: brcm80211: Optimized wl_inform_single_bss function in brcmfmac driver

Earlier verion of wl_inform_single_bss function is using
'cfg80211_inform_bss_frame' API for sending bss info to cfg80211.
With this patch same will be done through a more optimal
'cfg80211_inform_bss' API.

Cc: devel@linuxdriverproject.org
Cc: linux-wireless@vger.kernel.org
Reviewed-by: default avatarFranky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: default avatarBrett Rudley <brudley@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7b2cb57f
...@@ -182,15 +182,15 @@ static void wl_init_prof(struct wl_profile *prof); ...@@ -182,15 +182,15 @@ static void wl_init_prof(struct wl_profile *prof);
** cfg80211 connect utilites ** cfg80211 connect utilites
*/ */
static s32 wl_set_wpa_version(struct net_device *dev, static s32 wl_set_wpa_version(struct net_device *dev,
struct cfg80211_connect_params *sme); struct cfg80211_connect_params *sme);
static s32 wl_set_auth_type(struct net_device *dev, static s32 wl_set_auth_type(struct net_device *dev,
struct cfg80211_connect_params *sme); struct cfg80211_connect_params *sme);
static s32 wl_set_set_cipher(struct net_device *dev, static s32 wl_set_set_cipher(struct net_device *dev,
struct cfg80211_connect_params *sme); struct cfg80211_connect_params *sme);
static s32 wl_set_key_mgmt(struct net_device *dev, static s32 wl_set_key_mgmt(struct net_device *dev,
struct cfg80211_connect_params *sme); struct cfg80211_connect_params *sme);
static s32 wl_set_set_sharedkey(struct net_device *dev, static s32 wl_set_set_sharedkey(struct net_device *dev,
struct cfg80211_connect_params *sme); struct cfg80211_connect_params *sme);
static s32 wl_get_assoc_ies(struct wl_priv *wl); static s32 wl_get_assoc_ies(struct wl_priv *wl);
static void wl_ch_to_chanspec(int ch, static void wl_ch_to_chanspec(int ch,
struct wl_join_params *join_params, size_t *join_params_size); struct wl_join_params *join_params, size_t *join_params_size);
...@@ -198,25 +198,17 @@ static void wl_ch_to_chanspec(int ch, ...@@ -198,25 +198,17 @@ static void wl_ch_to_chanspec(int ch,
/* /*
** information element utilities ** information element utilities
*/ */
static void wl_rst_ie(struct wl_priv *wl);
static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v); static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v);
static s32 wl_mrg_ie(struct wl_priv *wl, u8 *ie_stream, u16 ie_size);
static s32 wl_cp_ie(struct wl_priv *wl, u8 *dst, u16 dst_size);
static u32 wl_get_ielen(struct wl_priv *wl);
static s32 wl_mode_to_nl80211_iftype(s32 mode); static s32 wl_mode_to_nl80211_iftype(s32 mode);
static struct wireless_dev *wl_alloc_wdev(s32 sizeof_iface, static struct wireless_dev *wl_alloc_wdev(s32 sizeof_iface,
struct device *dev); struct device *dev);
static void wl_free_wdev(struct wl_priv *wl); static void wl_free_wdev(struct wl_priv *wl);
static s32 wl_inform_bss(struct wl_priv *wl); static s32 wl_inform_bss(struct wl_priv *wl);
static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi); static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi);
static s32 wl_update_bss_info(struct wl_priv *wl); static s32 wl_update_bss_info(struct wl_priv *wl);
static s32 wl_add_keyext(struct wiphy *wiphy, struct net_device *dev, static s32 wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
u8 key_idx, const u8 *mac_addr, u8 key_idx, const u8 *mac_addr,
struct key_params *params); struct key_params *params);
/* /*
** key indianess swap utilities ** key indianess swap utilities
...@@ -2310,89 +2302,63 @@ static s32 wl_inform_bss(struct wl_priv *wl) ...@@ -2310,89 +2302,63 @@ static s32 wl_inform_bss(struct wl_priv *wl)
return err; return err;
} }
static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi) static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi)
{ {
struct wiphy *wiphy = wl_to_wiphy(wl); struct wiphy *wiphy = wl_to_wiphy(wl);
struct ieee80211_mgmt *mgmt; struct ieee80211_channel *notify_channel;
struct ieee80211_channel *channel; struct cfg80211_bss *bss;
struct ieee80211_supported_band *band; struct ieee80211_supported_band *band;
struct wl_cfg80211_bss_info *notif_bss_info;
struct wl_scan_req *sr = wl_to_sr(wl);
struct beacon_proberesp *beacon_proberesp;
s32 mgmt_type;
u32 signal;
u32 freq;
s32 err = 0; s32 err = 0;
u16 channel;
u32 freq;
u64 notify_timestamp;
u16 notify_capability;
u16 notify_interval;
u8 *notify_ie;
size_t notify_ielen;
s32 notify_signal;
if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) { if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) {
WL_DBG("Beacon is larger than buffer. Discarding\n"); WL_ERR("Bss info is larger than buffer. Discarding\n");
return err; return 0;
}
notif_bss_info =
kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
WL_BSS_INFO_MAX, GFP_KERNEL);
if (unlikely(!notif_bss_info)) {
WL_ERR("notif_bss_info alloc failed\n");
return -ENOMEM;
} }
mgmt = (struct ieee80211_mgmt *)notif_bss_info->frame_buf;
notif_bss_info->channel =
bi->ctl_ch ? bi->ctl_ch : CHSPEC_CHANNEL(bi->chanspec);
if (notif_bss_info->channel <= CH_MAX_2G_CHANNEL) channel = bi->ctl_ch ? bi->ctl_ch :
CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec));
if (channel <= CH_MAX_2G_CHANNEL)
band = wiphy->bands[IEEE80211_BAND_2GHZ]; band = wiphy->bands[IEEE80211_BAND_2GHZ];
else else
band = wiphy->bands[IEEE80211_BAND_5GHZ]; band = wiphy->bands[IEEE80211_BAND_5GHZ];
notif_bss_info->rssi = bi->RSSI;
memcpy(mgmt->bssid, &bi->BSSID, ETH_ALEN); freq = ieee80211_channel_to_frequency(channel, band->band);
mgmt_type = wl->active_scan ? notify_channel = ieee80211_get_channel(wiphy, freq);
IEEE80211_STYPE_PROBE_RESP : IEEE80211_STYPE_BEACON;
if (!memcmp(bi->SSID, sr->ssid.SSID, bi->SSID_len)) { notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | notify_capability = le16_to_cpu(bi->capability);
mgmt_type); notify_interval = le16_to_cpu(bi->beacon_period);
} notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
beacon_proberesp = wl->active_scan ? notify_ielen = le16_to_cpu(bi->ie_length);
(struct beacon_proberesp *)&mgmt->u.probe_resp : notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100;
(struct beacon_proberesp *)&mgmt->u.beacon;
beacon_proberesp->timestamp = 0; WL_DBG("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
beacon_proberesp->beacon_int = cpu_to_le16(bi->beacon_period); bi->BSSID[0], bi->BSSID[1], bi->BSSID[2],
beacon_proberesp->capab_info = cpu_to_le16(bi->capability); bi->BSSID[3], bi->BSSID[4], bi->BSSID[5]);
wl_rst_ie(wl); WL_DBG("Channel: %d(%d)\n", channel, freq);
/* WL_DBG("Capability: %X\n", notify_capability);
* wl_add_ie is not necessary because it can only add duplicated WL_DBG("Beacon interval: %d\n", notify_interval);
* SSID, rate information to frame_buf WL_DBG("Signal: %d\n", notify_signal);
*/ WL_DBG("notify_timestamp: %#018llx\n", notify_timestamp);
/*
* wl_add_ie(wl, WLAN_EID_SSID, bi->SSID_len, bi->SSID); bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID,
* wl_add_ie(wl, WLAN_EID_SUPP_RATES, bi->rateset.count, notify_timestamp, notify_capability, notify_interval, notify_ie,
* bi->rateset.rates); notify_ielen, notify_signal, GFP_KERNEL);
*/
wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length); if (unlikely(!bss)) {
wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
offsetof(struct wl_cfg80211_bss_info, frame_buf));
notif_bss_info->frame_len =
offsetof(struct ieee80211_mgmt,
u.beacon.variable) + wl_get_ielen(wl);
freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
band->band);
channel = ieee80211_get_channel(wiphy, freq);
WL_DBG("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
bi->SSID,
notif_bss_info->rssi, notif_bss_info->channel,
mgmt->u.beacon.capab_info, &bi->BSSID);
signal = notif_bss_info->rssi * 100;
if (unlikely(!cfg80211_inform_bss_frame(wiphy, channel, mgmt,
le16_to_cpu
(notif_bss_info->frame_len),
signal, GFP_KERNEL))) {
WL_ERR("cfg80211_inform_bss_frame error\n"); WL_ERR("cfg80211_inform_bss_frame error\n");
kfree(notif_bss_info);
return -EINVAL; return -EINVAL;
} }
kfree(notif_bss_info);
return err; return err;
} }
...@@ -4036,13 +4002,6 @@ static bool wl_is_ibssstarter(struct wl_priv *wl) ...@@ -4036,13 +4002,6 @@ static bool wl_is_ibssstarter(struct wl_priv *wl)
return wl->ibss_starter; return wl->ibss_starter;
} }
static void wl_rst_ie(struct wl_priv *wl)
{
struct wl_ie *ie = wl_to_ie(wl);
ie->offset = 0;
}
static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v) static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v)
{ {
struct wl_ie *ie = wl_to_ie(wl); struct wl_ie *ie = wl_to_ie(wl);
...@@ -4060,41 +4019,6 @@ static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v) ...@@ -4060,41 +4019,6 @@ static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v)
return err; return err;
} }
static s32 wl_mrg_ie(struct wl_priv *wl, u8 *ie_stream, u16 ie_size)
{
struct wl_ie *ie = wl_to_ie(wl);
s32 err = 0;
if (unlikely(ie->offset + ie_size > WL_TLV_INFO_MAX)) {
WL_ERR("ei_stream crosses buffer boundary\n");
return -ENOSPC;
}
memcpy(&ie->buf[ie->offset], ie_stream, ie_size);
ie->offset += ie_size;
return err;
}
static s32 wl_cp_ie(struct wl_priv *wl, u8 *dst, u16 dst_size)
{
struct wl_ie *ie = wl_to_ie(wl);
s32 err = 0;
if (unlikely(ie->offset > dst_size)) {
WL_ERR("dst_size is not enough\n");
return -ENOSPC;
}
memcpy(dst, &ie->buf[0], ie->offset);
return err;
}
static u32 wl_get_ielen(struct wl_priv *wl)
{
struct wl_ie *ie = wl_to_ie(wl);
return ie->offset;
}
static void wl_link_up(struct wl_priv *wl) static void wl_link_up(struct wl_priv *wl)
{ {
......
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