staging: wilc1000: remove the use of scan shadow buffer
Remove scan shadow buffer, which is used to store a copy of scan results. Instead, use cfg80211 provided API's to retrieve required info. Remove the helper functions which are operating on shadow buffer, as it's not require now. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
8ffcedd6f4
Коммит
6c2cfb4e87
|
@ -210,7 +210,7 @@ static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
|
||||||
|
|
||||||
scan_req = &hif_drv->usr_scan_req;
|
scan_req = &hif_drv->usr_scan_req;
|
||||||
if (scan_req->scan_result) {
|
if (scan_req->scan_result) {
|
||||||
scan_req->scan_result(evt, NULL, scan_req->arg, NULL);
|
scan_req->scan_result(evt, NULL, scan_req->arg);
|
||||||
scan_req->scan_result = NULL;
|
scan_req->scan_result = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,10 +564,10 @@ out:
|
||||||
kfree(msg);
|
kfree(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies,
|
static void host_int_fill_join_bss_param(struct join_bss_param *param,
|
||||||
u16 *out_index, u8 *pcipher_tc,
|
const u8 *ies, u16 *out_index,
|
||||||
u8 *auth_total_cnt, u32 tsf_lo,
|
u8 *pcipher_tc, u8 *auth_total_cnt,
|
||||||
u8 *rates_no)
|
u32 tsf_lo, u8 *rates_no)
|
||||||
{
|
{
|
||||||
u8 ext_rates_no;
|
u8 ext_rates_no;
|
||||||
u16 offset;
|
u16 offset;
|
||||||
|
@ -700,31 +700,44 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies,
|
||||||
*out_index = index;
|
*out_index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *host_int_parse_join_bss_param(struct network_info *info)
|
void *wilc_parse_join_bss_param(struct cfg80211_bss *bss)
|
||||||
{
|
{
|
||||||
struct join_bss_param *param;
|
struct join_bss_param *param;
|
||||||
u16 index = 0;
|
u16 index = 0;
|
||||||
u8 rates_no = 0;
|
u8 rates_no = 0;
|
||||||
u8 pcipher_total_cnt = 0;
|
u8 pcipher_total_cnt = 0;
|
||||||
u8 auth_total_cnt = 0;
|
u8 auth_total_cnt = 0;
|
||||||
|
const u8 *tim_elm, *ssid_elm;
|
||||||
|
const struct cfg80211_bss_ies *ies = bss->ies;
|
||||||
|
|
||||||
param = kzalloc(sizeof(*param), GFP_KERNEL);
|
param = kzalloc(sizeof(*param), GFP_KERNEL);
|
||||||
if (!param)
|
if (!param)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
param->dtim_period = info->dtim_period;
|
param->beacon_period = bss->beacon_interval;
|
||||||
param->beacon_period = info->beacon_period;
|
param->cap_info = bss->capability;
|
||||||
param->cap_info = info->cap_info;
|
ether_addr_copy(param->bssid, bss->bssid);
|
||||||
memcpy(param->bssid, info->bssid, 6);
|
|
||||||
memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1);
|
ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len);
|
||||||
param->ssid_len = info->ssid_len;
|
if (ssid_elm) {
|
||||||
|
param->ssid_len = ssid_elm[1];
|
||||||
|
if (param->ssid_len <= IEEE80211_MAX_SSID_LEN)
|
||||||
|
memcpy(param->ssid, ssid_elm + 2, param->ssid_len);
|
||||||
|
else
|
||||||
|
param->ssid_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len);
|
||||||
|
if (tim_elm && tim_elm[1] >= 2)
|
||||||
|
param->dtim_period = tim_elm[3];
|
||||||
|
|
||||||
memset(param->rsn_pcip_policy, 0xFF, 3);
|
memset(param->rsn_pcip_policy, 0xFF, 3);
|
||||||
memset(param->rsn_auth_policy, 0xFF, 3);
|
memset(param->rsn_auth_policy, 0xFF, 3);
|
||||||
|
|
||||||
while (index < info->ies_len)
|
while (index < ies->len)
|
||||||
host_int_fill_join_bss_param(param, info->ies, &index,
|
host_int_fill_join_bss_param(param, ies->data, &index,
|
||||||
&pcipher_total_cnt,
|
&pcipher_total_cnt,
|
||||||
&auth_total_cnt, info->tsf_lo,
|
&auth_total_cnt, ies->tsf,
|
||||||
&rates_no);
|
&rates_no);
|
||||||
|
|
||||||
return (void *)param;
|
return (void *)param;
|
||||||
|
@ -829,57 +842,20 @@ static void handle_rcvd_ntwrk_info(struct work_struct *work)
|
||||||
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
||||||
struct wilc_vif *vif = msg->vif;
|
struct wilc_vif *vif = msg->vif;
|
||||||
struct rcvd_net_info *rcvd_info = &msg->body.net_info;
|
struct rcvd_net_info *rcvd_info = &msg->body.net_info;
|
||||||
u32 i;
|
|
||||||
bool found;
|
|
||||||
struct network_info *info = NULL;
|
struct network_info *info = NULL;
|
||||||
void *params;
|
struct user_scan_req *scan_req = &vif->hif_drv->usr_scan_req;
|
||||||
struct host_if_drv *hif_drv = vif->hif_drv;
|
|
||||||
struct user_scan_req *scan_req = &hif_drv->usr_scan_req;
|
|
||||||
|
|
||||||
found = true;
|
|
||||||
|
|
||||||
if (!scan_req->scan_result)
|
if (!scan_req->scan_result)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
wilc_parse_network_info(rcvd_info->buffer, &info);
|
wilc_parse_network_info(rcvd_info->buffer, &info);
|
||||||
if (!info || !scan_req->scan_result) {
|
if (!info) {
|
||||||
netdev_err(vif->ndev, "%s: info or scan result NULL\n",
|
netdev_err(vif->ndev, "%s: info is NULL\n",
|
||||||
__func__);
|
__func__);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < scan_req->ch_cnt; i++) {
|
scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info, scan_req->arg);
|
||||||
if (memcmp(scan_req->net_info[i].bssid, info->bssid, 6) == 0) {
|
|
||||||
if (info->rssi <= scan_req->net_info[i].rssi) {
|
|
||||||
goto done;
|
|
||||||
} else {
|
|
||||||
scan_req->net_info[i].rssi = info->rssi;
|
|
||||||
found = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
if (scan_req->ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
|
|
||||||
scan_req->net_info[scan_req->ch_cnt].rssi = info->rssi;
|
|
||||||
|
|
||||||
memcpy(scan_req->net_info[scan_req->ch_cnt].bssid,
|
|
||||||
info->bssid, 6);
|
|
||||||
|
|
||||||
scan_req->ch_cnt++;
|
|
||||||
|
|
||||||
info->new_network = true;
|
|
||||||
params = host_int_parse_join_bss_param(info);
|
|
||||||
|
|
||||||
scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info,
|
|
||||||
scan_req->arg, params);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
info->new_network = false;
|
|
||||||
scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, info,
|
|
||||||
scan_req->arg, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
kfree(rcvd_info->buffer);
|
kfree(rcvd_info->buffer);
|
||||||
|
@ -1150,8 +1126,7 @@ int wilc_disconnect(struct wilc_vif *vif)
|
||||||
|
|
||||||
if (scan_req->scan_result) {
|
if (scan_req->scan_result) {
|
||||||
del_timer(&hif_drv->scan_timer);
|
del_timer(&hif_drv->scan_timer);
|
||||||
scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg,
|
scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg);
|
||||||
NULL);
|
|
||||||
scan_req->scan_result = NULL;
|
scan_req->scan_result = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2131,8 +2106,7 @@ int wilc_deinit(struct wilc_vif *vif)
|
||||||
|
|
||||||
if (hif_drv->usr_scan_req.scan_result) {
|
if (hif_drv->usr_scan_req.scan_result) {
|
||||||
hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
|
hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
|
||||||
hif_drv->usr_scan_req.arg,
|
hif_drv->usr_scan_req.arg);
|
||||||
NULL);
|
|
||||||
hif_drv->usr_scan_req.scan_result = NULL;
|
hif_drv->usr_scan_req.scan_result = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ enum {
|
||||||
|
|
||||||
#define WILC_MAX_NUM_STA 9
|
#define WILC_MAX_NUM_STA 9
|
||||||
#define MAX_NUM_SCANNED_NETWORKS 100
|
#define MAX_NUM_SCANNED_NETWORKS 100
|
||||||
#define MAX_NUM_SCANNED_NETWORKS_SHADOW 130
|
|
||||||
#define WILC_MAX_NUM_PROBED_SSID 10
|
#define WILC_MAX_NUM_PROBED_SSID 10
|
||||||
|
|
||||||
#define TX_MIC_KEY_LEN 8
|
#define TX_MIC_KEY_LEN 8
|
||||||
|
@ -29,8 +28,6 @@ enum {
|
||||||
#define WILC_ADD_STA_LENGTH 40
|
#define WILC_ADD_STA_LENGTH 40
|
||||||
#define WILC_NUM_CONCURRENT_IFC 2
|
#define WILC_NUM_CONCURRENT_IFC 2
|
||||||
|
|
||||||
#define NUM_RSSI 5
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WILC_SET_CFG = 0,
|
WILC_SET_CFG = 0,
|
||||||
WILC_GET_CFG
|
WILC_GET_CFG
|
||||||
|
@ -38,12 +35,6 @@ enum {
|
||||||
|
|
||||||
#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256
|
#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256
|
||||||
|
|
||||||
struct rssi_history_buffer {
|
|
||||||
bool full;
|
|
||||||
u8 index;
|
|
||||||
s8 samples[NUM_RSSI];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct network_info {
|
struct network_info {
|
||||||
s8 rssi;
|
s8 rssi;
|
||||||
u16 cap_info;
|
u16 cap_info;
|
||||||
|
@ -53,15 +44,9 @@ struct network_info {
|
||||||
u16 beacon_period;
|
u16 beacon_period;
|
||||||
u8 dtim_period;
|
u8 dtim_period;
|
||||||
u8 ch;
|
u8 ch;
|
||||||
unsigned long time_scan_cached;
|
|
||||||
unsigned long time_scan;
|
|
||||||
bool new_network;
|
|
||||||
u8 found;
|
|
||||||
u32 tsf_lo;
|
u32 tsf_lo;
|
||||||
u8 *ies;
|
u8 *ies;
|
||||||
u16 ies_len;
|
u16 ies_len;
|
||||||
void *join_params;
|
|
||||||
struct rssi_history_buffer rssi_history;
|
|
||||||
u64 tsf;
|
u64 tsf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,11 +114,6 @@ enum cfg_param {
|
||||||
WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
|
WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct found_net_info {
|
|
||||||
u8 bssid[6];
|
|
||||||
s8 rssi;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum scan_event {
|
enum scan_event {
|
||||||
SCAN_EVENT_NETWORK_FOUND = 0,
|
SCAN_EVENT_NETWORK_FOUND = 0,
|
||||||
SCAN_EVENT_DONE = 1,
|
SCAN_EVENT_DONE = 1,
|
||||||
|
@ -148,7 +128,7 @@ enum conn_event {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*wilc_scan_result)(enum scan_event, struct network_info *,
|
typedef void (*wilc_scan_result)(enum scan_event, struct network_info *,
|
||||||
void *, void *);
|
void *);
|
||||||
|
|
||||||
typedef void (*wilc_connect_result)(enum conn_event,
|
typedef void (*wilc_connect_result)(enum conn_event,
|
||||||
struct connect_info *,
|
struct connect_info *,
|
||||||
|
@ -178,7 +158,6 @@ struct user_scan_req {
|
||||||
wilc_scan_result scan_result;
|
wilc_scan_result scan_result;
|
||||||
void *arg;
|
void *arg;
|
||||||
u32 ch_cnt;
|
u32 ch_cnt;
|
||||||
struct found_net_info net_info[MAX_NUM_SCANNED_NETWORKS];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct user_conn_req {
|
struct user_conn_req {
|
||||||
|
@ -307,4 +286,5 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
|
||||||
void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
|
void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
|
||||||
void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
|
void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
|
||||||
void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
|
void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
|
||||||
|
void *wilc_parse_join_bss_param(struct cfg80211_bss *bss);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
|
|
||||||
#define INVALID_CHANNEL 0
|
#define INVALID_CHANNEL 0
|
||||||
|
|
||||||
#define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
|
|
||||||
#define SCAN_RESULT_EXPIRE (40 * HZ)
|
|
||||||
|
|
||||||
static const struct ieee80211_txrx_stypes
|
static const struct ieee80211_txrx_stypes
|
||||||
wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
|
wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
|
||||||
[NL80211_IFTYPE_STATION] = {
|
[NL80211_IFTYPE_STATION] = {
|
||||||
|
@ -75,115 +72,8 @@ static u8 curr_channel;
|
||||||
static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
|
static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
|
||||||
static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
|
static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
|
||||||
|
|
||||||
#define AGING_TIME (9 * 1000)
|
|
||||||
#define DURING_IP_TIME_OUT 15000
|
#define DURING_IP_TIME_OUT 15000
|
||||||
|
|
||||||
static void clear_shadow_scan(struct wilc_priv *priv)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++) {
|
|
||||||
kfree(priv->scanned_shadow[i].ies);
|
|
||||||
priv->scanned_shadow[i].ies = NULL;
|
|
||||||
|
|
||||||
kfree(priv->scanned_shadow[i].join_params);
|
|
||||||
priv->scanned_shadow[i].join_params = NULL;
|
|
||||||
}
|
|
||||||
priv->scanned_cnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u32 get_rssi_avg(struct network_info *network_info)
|
|
||||||
{
|
|
||||||
u8 i;
|
|
||||||
int rssi_v = 0;
|
|
||||||
u8 num_rssi = (network_info->rssi_history.full) ?
|
|
||||||
NUM_RSSI : (network_info->rssi_history.index);
|
|
||||||
|
|
||||||
for (i = 0; i < num_rssi; i++)
|
|
||||||
rssi_v += network_info->rssi_history.samples[i];
|
|
||||||
|
|
||||||
rssi_v /= num_rssi;
|
|
||||||
return rssi_v;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void refresh_scan(struct wilc_priv *priv, bool direct_scan)
|
|
||||||
{
|
|
||||||
struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++) {
|
|
||||||
struct network_info *network_info;
|
|
||||||
s32 freq;
|
|
||||||
struct ieee80211_channel *channel;
|
|
||||||
int rssi;
|
|
||||||
struct cfg80211_bss *bss;
|
|
||||||
|
|
||||||
network_info = &priv->scanned_shadow[i];
|
|
||||||
|
|
||||||
if (!memcmp("DIRECT-", network_info->ssid, 7) && !direct_scan)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
freq = ieee80211_channel_to_frequency((s32)network_info->ch,
|
|
||||||
NL80211_BAND_2GHZ);
|
|
||||||
channel = ieee80211_get_channel(wiphy, freq);
|
|
||||||
rssi = get_rssi_avg(network_info);
|
|
||||||
bss = cfg80211_inform_bss(wiphy,
|
|
||||||
channel,
|
|
||||||
CFG80211_BSS_FTYPE_UNKNOWN,
|
|
||||||
network_info->bssid,
|
|
||||||
network_info->tsf,
|
|
||||||
network_info->cap_info,
|
|
||||||
network_info->beacon_period,
|
|
||||||
(const u8 *)network_info->ies,
|
|
||||||
(size_t)network_info->ies_len,
|
|
||||||
(s32)rssi * 100,
|
|
||||||
GFP_KERNEL);
|
|
||||||
cfg80211_put_bss(wiphy, bss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset_shadow_found(struct wilc_priv *priv)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++)
|
|
||||||
priv->scanned_shadow[i].found = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_scan_time(struct wilc_priv *priv)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++)
|
|
||||||
priv->scanned_shadow[i].time_scan = jiffies;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void remove_network_from_shadow(struct timer_list *t)
|
|
||||||
{
|
|
||||||
struct wilc_priv *priv = from_timer(priv, t, aging_timer);
|
|
||||||
unsigned long now = jiffies;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++) {
|
|
||||||
if (!time_after(now, priv->scanned_shadow[i].time_scan +
|
|
||||||
(unsigned long)(SCAN_RESULT_EXPIRE)))
|
|
||||||
continue;
|
|
||||||
kfree(priv->scanned_shadow[i].ies);
|
|
||||||
priv->scanned_shadow[i].ies = NULL;
|
|
||||||
|
|
||||||
kfree(priv->scanned_shadow[i].join_params);
|
|
||||||
|
|
||||||
for (j = i; (j < priv->scanned_cnt - 1); j++)
|
|
||||||
priv->scanned_shadow[j] = priv->scanned_shadow[j + 1];
|
|
||||||
|
|
||||||
priv->scanned_cnt--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->scanned_cnt != 0)
|
|
||||||
mod_timer(&priv->aging_timer,
|
|
||||||
jiffies + msecs_to_jiffies(AGING_TIME));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clear_during_ip(struct timer_list *t)
|
static void clear_during_ip(struct timer_list *t)
|
||||||
{
|
{
|
||||||
struct wilc_vif *vif = from_timer(vif, t, during_ip_timer);
|
struct wilc_vif *vif = from_timer(vif, t, during_ip_timer);
|
||||||
|
@ -191,87 +81,15 @@ static void clear_during_ip(struct timer_list *t)
|
||||||
vif->obtaining_ip = false;
|
vif->obtaining_ip = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_network_in_shadow(struct network_info *nw_info,
|
|
||||||
struct wilc_priv *priv)
|
|
||||||
{
|
|
||||||
int state = -1;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (priv->scanned_cnt == 0) {
|
|
||||||
mod_timer(&priv->aging_timer,
|
|
||||||
jiffies + msecs_to_jiffies(AGING_TIME));
|
|
||||||
state = -1;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++) {
|
|
||||||
if (memcmp(priv->scanned_shadow[i].bssid,
|
|
||||||
nw_info->bssid, 6) == 0) {
|
|
||||||
state = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void add_network_to_shadow(struct network_info *nw_info,
|
|
||||||
struct wilc_priv *priv, void *join_params)
|
|
||||||
{
|
|
||||||
int ap_found = is_network_in_shadow(nw_info, priv);
|
|
||||||
u32 ap_index = 0;
|
|
||||||
u8 rssi_index = 0;
|
|
||||||
struct network_info *shadow_nw_info;
|
|
||||||
|
|
||||||
if (priv->scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ap_found == -1) {
|
|
||||||
ap_index = priv->scanned_cnt;
|
|
||||||
priv->scanned_cnt++;
|
|
||||||
} else {
|
|
||||||
ap_index = ap_found;
|
|
||||||
}
|
|
||||||
shadow_nw_info = &priv->scanned_shadow[ap_index];
|
|
||||||
rssi_index = shadow_nw_info->rssi_history.index;
|
|
||||||
shadow_nw_info->rssi_history.samples[rssi_index++] = nw_info->rssi;
|
|
||||||
if (rssi_index == NUM_RSSI) {
|
|
||||||
rssi_index = 0;
|
|
||||||
shadow_nw_info->rssi_history.full = true;
|
|
||||||
}
|
|
||||||
shadow_nw_info->rssi_history.index = rssi_index;
|
|
||||||
shadow_nw_info->rssi = nw_info->rssi;
|
|
||||||
shadow_nw_info->cap_info = nw_info->cap_info;
|
|
||||||
shadow_nw_info->ssid_len = nw_info->ssid_len;
|
|
||||||
memcpy(shadow_nw_info->ssid, nw_info->ssid, nw_info->ssid_len);
|
|
||||||
memcpy(shadow_nw_info->bssid, nw_info->bssid, ETH_ALEN);
|
|
||||||
shadow_nw_info->beacon_period = nw_info->beacon_period;
|
|
||||||
shadow_nw_info->dtim_period = nw_info->dtim_period;
|
|
||||||
shadow_nw_info->ch = nw_info->ch;
|
|
||||||
shadow_nw_info->tsf = nw_info->tsf;
|
|
||||||
if (ap_found != -1)
|
|
||||||
kfree(shadow_nw_info->ies);
|
|
||||||
shadow_nw_info->ies = kmemdup(nw_info->ies, nw_info->ies_len,
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (shadow_nw_info->ies)
|
|
||||||
shadow_nw_info->ies_len = nw_info->ies_len;
|
|
||||||
else
|
|
||||||
shadow_nw_info->ies_len = 0;
|
|
||||||
shadow_nw_info->time_scan = jiffies;
|
|
||||||
shadow_nw_info->time_scan_cached = jiffies;
|
|
||||||
shadow_nw_info->found = 1;
|
|
||||||
if (ap_found != -1)
|
|
||||||
kfree(shadow_nw_info->join_params);
|
|
||||||
shadow_nw_info->join_params = join_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cfg_scan_result(enum scan_event scan_event,
|
static void cfg_scan_result(enum scan_event scan_event,
|
||||||
struct network_info *network_info,
|
struct network_info *network_info,
|
||||||
void *user_void, void *join_params)
|
void *user_void)
|
||||||
{
|
{
|
||||||
struct wilc_priv *priv;
|
struct wilc_priv *priv;
|
||||||
struct wiphy *wiphy;
|
struct wiphy *wiphy;
|
||||||
s32 freq;
|
s32 freq;
|
||||||
struct ieee80211_channel *channel;
|
struct ieee80211_channel *channel;
|
||||||
struct cfg80211_bss *bss = NULL;
|
struct cfg80211_bss *bss;
|
||||||
|
|
||||||
priv = user_void;
|
priv = user_void;
|
||||||
if (!priv->cfg_scanning)
|
if (!priv->cfg_scanning)
|
||||||
|
@ -291,51 +109,22 @@ static void cfg_scan_result(enum scan_event scan_event,
|
||||||
freq = ieee80211_channel_to_frequency((s32)network_info->ch,
|
freq = ieee80211_channel_to_frequency((s32)network_info->ch,
|
||||||
NL80211_BAND_2GHZ);
|
NL80211_BAND_2GHZ);
|
||||||
channel = ieee80211_get_channel(wiphy, freq);
|
channel = ieee80211_get_channel(wiphy, freq);
|
||||||
|
|
||||||
if (!channel)
|
if (!channel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (network_info->new_network) {
|
bss = cfg80211_inform_bss(wiphy,
|
||||||
if (priv->rcvd_ch_cnt >= MAX_NUM_SCANNED_NETWORKS)
|
channel,
|
||||||
return;
|
CFG80211_BSS_FTYPE_UNKNOWN,
|
||||||
|
network_info->bssid,
|
||||||
priv->rcvd_ch_cnt++;
|
network_info->tsf,
|
||||||
|
network_info->cap_info,
|
||||||
add_network_to_shadow(network_info, priv, join_params);
|
network_info->beacon_period,
|
||||||
|
(const u8 *)network_info->ies,
|
||||||
if (memcmp("DIRECT-", network_info->ssid, 7))
|
(size_t)network_info->ies_len,
|
||||||
return;
|
(s32)network_info->rssi * 100,
|
||||||
|
GFP_KERNEL);
|
||||||
bss = cfg80211_inform_bss(wiphy,
|
cfg80211_put_bss(wiphy, bss);
|
||||||
channel,
|
|
||||||
CFG80211_BSS_FTYPE_UNKNOWN,
|
|
||||||
network_info->bssid,
|
|
||||||
network_info->tsf,
|
|
||||||
network_info->cap_info,
|
|
||||||
network_info->beacon_period,
|
|
||||||
(const u8 *)network_info->ies,
|
|
||||||
(size_t)network_info->ies_len,
|
|
||||||
(s32)network_info->rssi * 100,
|
|
||||||
GFP_KERNEL);
|
|
||||||
cfg80211_put_bss(wiphy, bss);
|
|
||||||
} else {
|
|
||||||
u32 i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->rcvd_ch_cnt; i++) {
|
|
||||||
if (memcmp(priv->scanned_shadow[i].bssid,
|
|
||||||
network_info->bssid, 6) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i >= priv->rcvd_ch_cnt)
|
|
||||||
return;
|
|
||||||
|
|
||||||
priv->scanned_shadow[i].rssi = network_info->rssi;
|
|
||||||
priv->scanned_shadow[i].time_scan = jiffies;
|
|
||||||
}
|
|
||||||
} else if (scan_event == SCAN_EVENT_DONE) {
|
} else if (scan_event == SCAN_EVENT_DONE) {
|
||||||
refresh_scan(priv, false);
|
|
||||||
|
|
||||||
mutex_lock(&priv->scan_req_lock);
|
mutex_lock(&priv->scan_req_lock);
|
||||||
|
|
||||||
if (priv->scan_req) {
|
if (priv->scan_req) {
|
||||||
|
@ -344,7 +133,6 @@ static void cfg_scan_result(enum scan_event scan_event,
|
||||||
};
|
};
|
||||||
|
|
||||||
cfg80211_scan_done(priv->scan_req, &info);
|
cfg80211_scan_done(priv->scan_req, &info);
|
||||||
priv->rcvd_ch_cnt = 0;
|
|
||||||
priv->cfg_scanning = false;
|
priv->cfg_scanning = false;
|
||||||
priv->scan_req = NULL;
|
priv->scan_req = NULL;
|
||||||
}
|
}
|
||||||
|
@ -357,9 +145,6 @@ static void cfg_scan_result(enum scan_event scan_event,
|
||||||
.aborted = false,
|
.aborted = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
update_scan_time(priv);
|
|
||||||
refresh_scan(priv, false);
|
|
||||||
|
|
||||||
cfg80211_scan_done(priv->scan_req, &info);
|
cfg80211_scan_done(priv->scan_req, &info);
|
||||||
priv->cfg_scanning = false;
|
priv->cfg_scanning = false;
|
||||||
priv->scan_req = NULL;
|
priv->scan_req = NULL;
|
||||||
|
@ -368,17 +153,6 @@ static void cfg_scan_result(enum scan_event scan_event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool wilc_cfg_scan_time_expired(struct wilc_priv *priv, int i)
|
|
||||||
{
|
|
||||||
unsigned long now = jiffies;
|
|
||||||
|
|
||||||
if (time_after(now, priv->scanned_shadow[i].time_scan_cached +
|
|
||||||
(unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ))))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cfg_connect_result(enum conn_event conn_disconn_evt,
|
static void cfg_connect_result(enum conn_event conn_disconn_evt,
|
||||||
struct connect_info *conn_info,
|
struct connect_info *conn_info,
|
||||||
u8 mac_status,
|
u8 mac_status,
|
||||||
|
@ -409,28 +183,10 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt,
|
||||||
netdev_err(dev, "Unspecified failure\n");
|
netdev_err(dev, "Unspecified failure\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect_status == WLAN_STATUS_SUCCESS) {
|
if (connect_status == WLAN_STATUS_SUCCESS)
|
||||||
bool scan_refresh = false;
|
|
||||||
u32 i;
|
|
||||||
|
|
||||||
memcpy(priv->associated_bss, conn_info->bssid,
|
memcpy(priv->associated_bss, conn_info->bssid,
|
||||||
ETH_ALEN);
|
ETH_ALEN);
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++) {
|
|
||||||
if (memcmp(priv->scanned_shadow[i].bssid,
|
|
||||||
conn_info->bssid,
|
|
||||||
ETH_ALEN) == 0) {
|
|
||||||
if (wilc_cfg_scan_time_expired(priv, i))
|
|
||||||
scan_refresh = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scan_refresh)
|
|
||||||
refresh_scan(priv, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg80211_connect_result(dev, conn_info->bssid,
|
cfg80211_connect_result(dev, conn_info->bssid,
|
||||||
conn_info->req_ies,
|
conn_info->req_ies,
|
||||||
conn_info->req_ies_len,
|
conn_info->req_ies_len,
|
||||||
|
@ -531,10 +287,6 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
|
||||||
|
|
||||||
priv->scan_req = request;
|
priv->scan_req = request;
|
||||||
|
|
||||||
priv->rcvd_ch_cnt = 0;
|
|
||||||
|
|
||||||
reset_shadow_found(priv);
|
|
||||||
|
|
||||||
priv->cfg_scanning = true;
|
priv->cfg_scanning = true;
|
||||||
if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
|
if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
|
||||||
for (i = 0; i < request->n_channels; i++) {
|
for (i = 0; i < request->n_channels; i++) {
|
||||||
|
@ -583,13 +335,13 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
|
||||||
struct wilc_priv *priv = wiphy_priv(wiphy);
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
||||||
struct wilc_vif *vif = netdev_priv(priv->dev);
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
||||||
struct host_if_drv *wfi_drv = priv->hif_drv;
|
struct host_if_drv *wfi_drv = priv->hif_drv;
|
||||||
struct network_info *nw_info;
|
|
||||||
int ret;
|
int ret;
|
||||||
u32 i;
|
u32 i;
|
||||||
u32 sel_bssi_idx = UINT_MAX;
|
|
||||||
u8 security = WILC_FW_SEC_NO;
|
u8 security = WILC_FW_SEC_NO;
|
||||||
enum authtype auth_type = WILC_FW_AUTH_ANY;
|
enum authtype auth_type = WILC_FW_AUTH_ANY;
|
||||||
u32 cipher_group;
|
u32 cipher_group;
|
||||||
|
struct cfg80211_bss *bss;
|
||||||
|
void *join_params;
|
||||||
|
|
||||||
vif->connecting = true;
|
vif->connecting = true;
|
||||||
|
|
||||||
|
@ -598,39 +350,6 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
|
||||||
else
|
else
|
||||||
wfi_drv->p2p_connect = 0;
|
wfi_drv->p2p_connect = 0;
|
||||||
|
|
||||||
for (i = 0; i < priv->scanned_cnt; i++) {
|
|
||||||
if (sme->ssid_len == priv->scanned_shadow[i].ssid_len &&
|
|
||||||
memcmp(priv->scanned_shadow[i].ssid,
|
|
||||||
sme->ssid,
|
|
||||||
sme->ssid_len) == 0) {
|
|
||||||
if (!sme->bssid) {
|
|
||||||
if (sel_bssi_idx == UINT_MAX ||
|
|
||||||
priv->scanned_shadow[i].rssi >
|
|
||||||
priv->scanned_shadow[sel_bssi_idx].rssi)
|
|
||||||
sel_bssi_idx = i;
|
|
||||||
} else {
|
|
||||||
if (memcmp(priv->scanned_shadow[i].bssid,
|
|
||||||
sme->bssid,
|
|
||||||
ETH_ALEN) == 0) {
|
|
||||||
sel_bssi_idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sel_bssi_idx < priv->scanned_cnt) {
|
|
||||||
nw_info = &priv->scanned_shadow[sel_bssi_idx];
|
|
||||||
} else {
|
|
||||||
ret = -ENOENT;
|
|
||||||
goto out_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ether_addr_equal_unaligned(vif->bssid, nw_info->bssid)) {
|
|
||||||
ret = -EALREADY;
|
|
||||||
goto out_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(priv->wep_key, 0, sizeof(priv->wep_key));
|
memset(priv->wep_key, 0, sizeof(priv->wep_key));
|
||||||
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
|
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
|
||||||
|
|
||||||
|
@ -704,29 +423,54 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
|
||||||
auth_type = WILC_FW_AUTH_IEEE8021;
|
auth_type = WILC_FW_AUTH_IEEE8021;
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_channel = nw_info->ch;
|
bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid,
|
||||||
|
sme->ssid_len, IEEE80211_BSS_TYPE_ANY,
|
||||||
|
IEEE80211_PRIVACY(sme->privacy));
|
||||||
|
if (!bss) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ether_addr_equal_unaligned(vif->bssid, bss->bssid)) {
|
||||||
|
ret = -EALREADY;
|
||||||
|
goto out_put_bss;
|
||||||
|
}
|
||||||
|
|
||||||
|
join_params = wilc_parse_join_bss_param(bss);
|
||||||
|
if (!join_params) {
|
||||||
|
netdev_err(dev, "%s: failed to construct join param\n",
|
||||||
|
__func__);
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto out_put_bss;
|
||||||
|
}
|
||||||
|
|
||||||
|
curr_channel = ieee80211_frequency_to_channel(bss->channel->center_freq);
|
||||||
|
|
||||||
if (!wfi_drv->p2p_connect)
|
if (!wfi_drv->p2p_connect)
|
||||||
wlan_channel = nw_info->ch;
|
wlan_channel = curr_channel;
|
||||||
|
|
||||||
wilc_wlan_set_bssid(dev, nw_info->bssid, WILC_STATION_MODE);
|
wilc_wlan_set_bssid(dev, bss->bssid, WILC_STATION_MODE);
|
||||||
|
|
||||||
ret = wilc_set_join_req(vif, nw_info->bssid, sme->ssid,
|
ret = wilc_set_join_req(vif, bss->bssid, sme->ssid,
|
||||||
sme->ssid_len, sme->ie, sme->ie_len,
|
sme->ssid_len, sme->ie, sme->ie_len,
|
||||||
cfg_connect_result, (void *)priv,
|
cfg_connect_result, (void *)priv,
|
||||||
security, auth_type,
|
security, auth_type, curr_channel, join_params);
|
||||||
nw_info->ch,
|
|
||||||
nw_info->join_params);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
netdev_err(dev, "wilc_set_join_req(): Error\n");
|
netdev_err(dev, "wilc_set_join_req(): Error\n");
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
if (!wfi_drv->p2p_connect)
|
if (!wfi_drv->p2p_connect)
|
||||||
wlan_channel = INVALID_CHANNEL;
|
wlan_channel = INVALID_CHANNEL;
|
||||||
wilc_wlan_set_bssid(dev, NULL, WILC_STATION_MODE);
|
wilc_wlan_set_bssid(dev, NULL, WILC_STATION_MODE);
|
||||||
goto out_error;
|
kfree(join_params);
|
||||||
|
goto out_put_bss;
|
||||||
}
|
}
|
||||||
|
kfree(join_params);
|
||||||
|
cfg80211_put_bss(wiphy, bss);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_put_bss:
|
||||||
|
cfg80211_put_bss(wiphy, bss);
|
||||||
|
|
||||||
out_error:
|
out_error:
|
||||||
vif->connecting = false;
|
vif->connecting = false;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2096,7 +1840,6 @@ int wilc_init_host_int(struct net_device *net)
|
||||||
struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr);
|
struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr);
|
||||||
struct wilc_vif *vif = netdev_priv(priv->dev);
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
||||||
|
|
||||||
timer_setup(&priv->aging_timer, remove_network_from_shadow, 0);
|
|
||||||
timer_setup(&vif->during_ip_timer, clear_during_ip, 0);
|
timer_setup(&vif->during_ip_timer, clear_during_ip, 0);
|
||||||
|
|
||||||
priv->p2p_listen_state = false;
|
priv->p2p_listen_state = false;
|
||||||
|
@ -2120,8 +1863,6 @@ void wilc_deinit_host_int(struct net_device *net)
|
||||||
mutex_destroy(&priv->scan_req_lock);
|
mutex_destroy(&priv->scan_req_lock);
|
||||||
ret = wilc_deinit(vif);
|
ret = wilc_deinit(vif);
|
||||||
|
|
||||||
del_timer_sync(&priv->aging_timer);
|
|
||||||
clear_shadow_scan(priv);
|
|
||||||
del_timer_sync(&vif->during_ip_timer);
|
del_timer_sync(&vif->during_ip_timer);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -137,7 +137,6 @@ struct wilc_priv {
|
||||||
u64 tx_cookie;
|
u64 tx_cookie;
|
||||||
|
|
||||||
bool cfg_scanning;
|
bool cfg_scanning;
|
||||||
u32 rcvd_ch_cnt;
|
|
||||||
|
|
||||||
u8 associated_bss[ETH_ALEN];
|
u8 associated_bss[ETH_ALEN];
|
||||||
struct sta_info assoc_stainfo;
|
struct sta_info assoc_stainfo;
|
||||||
|
@ -155,8 +154,6 @@ struct wilc_priv {
|
||||||
/* mutexes */
|
/* mutexes */
|
||||||
struct mutex scan_req_lock;
|
struct mutex scan_req_lock;
|
||||||
bool p2p_listen_state;
|
bool p2p_listen_state;
|
||||||
struct timer_list aging_timer;
|
|
||||||
struct network_info scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
|
|
||||||
int scanned_cnt;
|
int scanned_cnt;
|
||||||
struct wilc_p2p_var p2p;
|
struct wilc_p2p_var p2p;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче