2015-05-11 05:30:56 +00:00
|
|
|
#include "wilc_wfi_cfgoperations.h"
|
2015-11-16 14:04:55 +00:00
|
|
|
#include "host_interface.h"
|
2015-09-16 09:35:59 +00:00
|
|
|
#include <linux/errno.h>
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-16 14:04:57 +00:00
|
|
|
#define NO_ENCRYPT 0
|
|
|
|
#define ENCRYPT_ENABLED BIT(0)
|
|
|
|
#define WEP BIT(1)
|
|
|
|
#define WEP_EXTENDED BIT(2)
|
|
|
|
#define WPA BIT(3)
|
|
|
|
#define WPA2 BIT(4)
|
|
|
|
#define AES BIT(5)
|
|
|
|
#define TKIP BIT(6)
|
|
|
|
|
|
|
|
#define FRAME_TYPE_ID 0
|
|
|
|
#define ACTION_CAT_ID 24
|
|
|
|
#define ACTION_SUBTYPE_ID 25
|
|
|
|
#define P2P_PUB_ACTION_SUBTYPE 30
|
|
|
|
|
|
|
|
#define ACTION_FRAME 0xd0
|
|
|
|
#define GO_INTENT_ATTR_ID 0x04
|
|
|
|
#define CHANLIST_ATTR_ID 0x0b
|
|
|
|
#define OPERCHAN_ATTR_ID 0x11
|
|
|
|
#define PUB_ACTION_ATTR_ID 0x04
|
|
|
|
#define P2PELEM_ATTR_ID 0xdd
|
|
|
|
|
|
|
|
#define GO_NEG_REQ 0x00
|
|
|
|
#define GO_NEG_RSP 0x01
|
|
|
|
#define GO_NEG_CONF 0x02
|
|
|
|
#define P2P_INV_REQ 0x03
|
|
|
|
#define P2P_INV_RSP 0x04
|
|
|
|
#define PUBLIC_ACT_VENDORSPEC 0x09
|
|
|
|
#define GAS_INTIAL_REQ 0x0a
|
|
|
|
#define GAS_INTIAL_RSP 0x0b
|
|
|
|
|
|
|
|
#define INVALID_CHANNEL 0
|
|
|
|
|
|
|
|
#define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
|
|
|
|
#define SCAN_RESULT_EXPIRE (40 * HZ)
|
|
|
|
|
|
|
|
static const u32 cipher_suites[] = {
|
|
|
|
WLAN_CIPHER_SUITE_WEP40,
|
|
|
|
WLAN_CIPHER_SUITE_WEP104,
|
|
|
|
WLAN_CIPHER_SUITE_TKIP,
|
|
|
|
WLAN_CIPHER_SUITE_CCMP,
|
|
|
|
WLAN_CIPHER_SUITE_AES_CMAC,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ieee80211_txrx_stypes
|
|
|
|
wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
|
|
|
|
[NL80211_IFTYPE_STATION] = {
|
|
|
|
.tx = 0xffff,
|
|
|
|
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
|
|
|
|
},
|
|
|
|
[NL80211_IFTYPE_AP] = {
|
|
|
|
.tx = 0xffff,
|
|
|
|
.rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_DISASSOC >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_AUTH >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_DEAUTH >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_ACTION >> 4)
|
|
|
|
},
|
|
|
|
[NL80211_IFTYPE_P2P_CLIENT] = {
|
|
|
|
.tx = 0xffff,
|
|
|
|
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_DISASSOC >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_AUTH >> 4) |
|
|
|
|
BIT(IEEE80211_STYPE_DEAUTH >> 4)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-25 07:35:10 +00:00
|
|
|
static const struct wiphy_wowlan_support wowlan_support = {
|
|
|
|
.flags = WIPHY_WOWLAN_ANY
|
|
|
|
};
|
|
|
|
|
2015-11-16 14:04:57 +00:00
|
|
|
#define WILC_WFI_DWELL_PASSIVE 100
|
|
|
|
#define WILC_WFI_DWELL_ACTIVE 40
|
|
|
|
|
|
|
|
#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
|
|
|
|
#define DEFAULT_LINK_SPEED 72
|
|
|
|
|
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
#define IS_MANAGMEMENT 0x100
|
|
|
|
#define IS_MANAGMEMENT_CALLBACK 0x080
|
|
|
|
#define IS_MGMT_STATUS_SUCCES 0x040
|
|
|
|
#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
|
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
extern int wilc_mac_open(struct net_device *ndev);
|
|
|
|
extern int wilc_mac_close(struct net_device *ndev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:10 +00:00
|
|
|
static struct network_info last_scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
|
2015-11-19 06:56:10 +00:00
|
|
|
static u32 last_scanned_cnt;
|
2015-11-16 14:04:54 +00:00
|
|
|
struct timer_list wilc_during_ip_timer;
|
2015-11-16 14:04:53 +00:00
|
|
|
static struct timer_list hAgingTimer;
|
2015-06-02 05:16:04 +00:00
|
|
|
static u8 op_ifcs;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
u8 wilc_initialized = 1;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
#define CHAN2G(_channel, _freq, _flags) { \
|
|
|
|
.band = IEEE80211_BAND_2GHZ, \
|
|
|
|
.center_freq = (_freq), \
|
|
|
|
.hw_value = (_channel), \
|
|
|
|
.flags = (_flags), \
|
|
|
|
.max_antenna_gain = 0, \
|
|
|
|
.max_power = 30, \
|
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:12 +00:00
|
|
|
static struct ieee80211_channel ieee80211_2ghz_channels[] = {
|
2015-05-11 05:30:56 +00:00
|
|
|
CHAN2G(1, 2412, 0),
|
|
|
|
CHAN2G(2, 2417, 0),
|
|
|
|
CHAN2G(3, 2422, 0),
|
|
|
|
CHAN2G(4, 2427, 0),
|
|
|
|
CHAN2G(5, 2432, 0),
|
|
|
|
CHAN2G(6, 2437, 0),
|
|
|
|
CHAN2G(7, 2442, 0),
|
|
|
|
CHAN2G(8, 2447, 0),
|
|
|
|
CHAN2G(9, 2452, 0),
|
|
|
|
CHAN2G(10, 2457, 0),
|
|
|
|
CHAN2G(11, 2462, 0),
|
|
|
|
CHAN2G(12, 2467, 0),
|
|
|
|
CHAN2G(13, 2472, 0),
|
|
|
|
CHAN2G(14, 2484, 0),
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RATETAB_ENT(_rate, _hw_value, _flags) { \
|
|
|
|
.bitrate = (_rate), \
|
|
|
|
.hw_value = (_hw_value), \
|
|
|
|
.flags = (_flags), \
|
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:13 +00:00
|
|
|
static struct ieee80211_rate ieee80211_bitrates[] = {
|
2015-05-11 05:30:56 +00:00
|
|
|
RATETAB_ENT(10, 0, 0),
|
|
|
|
RATETAB_ENT(20, 1, 0),
|
|
|
|
RATETAB_ENT(55, 2, 0),
|
|
|
|
RATETAB_ENT(110, 3, 0),
|
|
|
|
RATETAB_ENT(60, 9, 0),
|
|
|
|
RATETAB_ENT(90, 6, 0),
|
|
|
|
RATETAB_ENT(120, 7, 0),
|
|
|
|
RATETAB_ENT(180, 8, 0),
|
|
|
|
RATETAB_ENT(240, 9, 0),
|
|
|
|
RATETAB_ENT(360, 10, 0),
|
|
|
|
RATETAB_ENT(480, 11, 0),
|
|
|
|
RATETAB_ENT(540, 12, 0),
|
|
|
|
};
|
|
|
|
|
|
|
|
struct p2p_mgmt_data {
|
|
|
|
int size;
|
|
|
|
u8 *buff;
|
|
|
|
};
|
|
|
|
|
2015-11-19 06:56:14 +00:00
|
|
|
static u8 wlan_channel = INVALID_CHANNEL;
|
2015-11-16 14:04:53 +00:00
|
|
|
static u8 curr_channel;
|
2015-11-19 06:56:15 +00:00
|
|
|
static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09};
|
2015-11-19 06:56:16 +00:00
|
|
|
static u8 p2p_local_random = 0x01;
|
2015-11-19 06:56:17 +00:00
|
|
|
static u8 p2p_recv_random = 0x00;
|
2015-11-19 06:56:18 +00:00
|
|
|
static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
|
2015-11-19 06:56:19 +00:00
|
|
|
static bool wilc_ie;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
|
2015-11-19 06:56:12 +00:00
|
|
|
.channels = ieee80211_2ghz_channels,
|
|
|
|
.n_channels = ARRAY_SIZE(ieee80211_2ghz_channels),
|
2015-11-19 06:56:13 +00:00
|
|
|
.bitrates = ieee80211_bitrates,
|
|
|
|
.n_bitrates = ARRAY_SIZE(ieee80211_bitrates),
|
2015-05-11 05:30:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct add_key_params {
|
|
|
|
u8 key_idx;
|
|
|
|
bool pairwise;
|
|
|
|
u8 *mac_addr;
|
|
|
|
};
|
2015-11-16 14:04:53 +00:00
|
|
|
static struct add_key_params g_add_gtk_key_params;
|
|
|
|
static struct wilc_wfi_key g_key_gtk_params;
|
|
|
|
static struct add_key_params g_add_ptk_key_params;
|
|
|
|
static struct wilc_wfi_key g_key_ptk_params;
|
|
|
|
static struct wilc_wfi_wep_key g_key_wep_params;
|
|
|
|
static bool g_ptk_keys_saved;
|
|
|
|
static bool g_gtk_keys_saved;
|
|
|
|
static bool g_wep_keys_saved;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
#define AGING_TIME (9 * 1000)
|
2015-11-19 06:56:20 +00:00
|
|
|
#define during_ip_time 15000
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:22 +00:00
|
|
|
static void clear_shadow_scan(void)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
int i;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
if (op_ifcs == 0) {
|
2015-08-15 03:11:16 +00:00
|
|
|
del_timer_sync(&hAgingTimer);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++) {
|
2016-02-04 09:24:23 +00:00
|
|
|
if (last_scanned_shadow[last_scanned_cnt].ies) {
|
|
|
|
kfree(last_scanned_shadow[i].ies);
|
|
|
|
last_scanned_shadow[last_scanned_cnt].ies = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2016-02-04 09:24:24 +00:00
|
|
|
kfree(last_scanned_shadow[i].join_params);
|
|
|
|
last_scanned_shadow[i].join_params = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-11-19 06:56:10 +00:00
|
|
|
last_scanned_cnt = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 09:24:10 +00:00
|
|
|
static u32 get_rssi_avg(struct network_info *network_info)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:14 +00:00
|
|
|
u8 i;
|
2015-05-11 05:30:56 +00:00
|
|
|
int rssi_v = 0;
|
2016-02-04 09:24:25 +00:00
|
|
|
u8 num_rssi = (network_info->str_rssi.u8Full) ?
|
|
|
|
NUM_RSSI : (network_info->str_rssi.u8Index);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
for (i = 0; i < num_rssi; i++)
|
2016-02-04 09:24:25 +00:00
|
|
|
rssi_v += network_info->str_rssi.as8RSSI[i];
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
rssi_v /= num_rssi;
|
|
|
|
return rssi_v;
|
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:24 +00:00
|
|
|
static void refresh_scan(void *user_void, u8 all, bool direct_scan)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct wiphy *wiphy;
|
|
|
|
struct cfg80211_bss *bss = NULL;
|
|
|
|
int i;
|
|
|
|
int rssi = 0;
|
|
|
|
|
2015-11-19 06:56:23 +00:00
|
|
|
priv = (struct wilc_priv *)user_void;
|
2015-05-11 05:30:56 +00:00
|
|
|
wiphy = priv->dev->ieee80211_ptr->wiphy;
|
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++) {
|
2016-02-04 09:24:10 +00:00
|
|
|
struct network_info *network_info;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-11-19 06:56:25 +00:00
|
|
|
network_info = &last_scanned_shadow[i];
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:21 +00:00
|
|
|
if (!network_info->found || all) {
|
2015-11-19 06:56:26 +00:00
|
|
|
s32 freq;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct ieee80211_channel *channel;
|
|
|
|
|
2015-11-19 06:56:25 +00:00
|
|
|
if (network_info) {
|
2016-02-04 09:24:18 +00:00
|
|
|
freq = ieee80211_channel_to_frequency((s32)network_info->ch, IEEE80211_BAND_2GHZ);
|
2015-11-19 06:56:26 +00:00
|
|
|
channel = ieee80211_get_channel(wiphy, freq);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:25 +00:00
|
|
|
rssi = get_rssi_avg(network_info);
|
2016-02-04 09:24:13 +00:00
|
|
|
if (memcmp("DIRECT-", network_info->ssid, 7) ||
|
2015-11-19 06:56:24 +00:00
|
|
|
direct_scan) {
|
2016-02-04 09:24:12 +00:00
|
|
|
bss = cfg80211_inform_bss(wiphy,
|
|
|
|
channel,
|
|
|
|
CFG80211_BSS_FTYPE_UNKNOWN,
|
2016-02-04 09:24:15 +00:00
|
|
|
network_info->bssid,
|
2016-02-04 09:24:26 +00:00
|
|
|
network_info->tsf_hi,
|
2016-02-04 09:24:12 +00:00
|
|
|
network_info->cap_info,
|
2016-02-04 09:24:16 +00:00
|
|
|
network_info->beacon_period,
|
2016-02-04 09:24:23 +00:00
|
|
|
(const u8 *)network_info->ies,
|
|
|
|
(size_t)network_info->ies_len,
|
2016-02-04 09:24:12 +00:00
|
|
|
(s32)rssi * 100,
|
|
|
|
GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
cfg80211_put_bss(wiphy, bss);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:27 +00:00
|
|
|
static void reset_shadow_found(void)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
int i;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++)
|
2016-02-04 09:24:21 +00:00
|
|
|
last_scanned_shadow[i].found = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:28 +00:00
|
|
|
static void update_scan_time(void)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
int i;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++)
|
2016-02-04 09:24:19 +00:00
|
|
|
last_scanned_shadow[i].time_scan = jiffies;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 03:28:32 +00:00
|
|
|
static void remove_network_from_shadow(unsigned long arg)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
unsigned long now = jiffies;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++) {
|
2016-02-04 09:24:19 +00:00
|
|
|
if (time_after(now, last_scanned_shadow[i].time_scan +
|
|
|
|
(unsigned long)(SCAN_RESULT_EXPIRE))) {
|
2016-02-04 09:24:13 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Network expired ScanShadow:%s\n",
|
|
|
|
last_scanned_shadow[i].ssid);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:23 +00:00
|
|
|
kfree(last_scanned_shadow[i].ies);
|
|
|
|
last_scanned_shadow[i].ies = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:24 +00:00
|
|
|
kfree(last_scanned_shadow[i].join_params);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (j = i; (j < last_scanned_cnt - 1); j++)
|
2015-11-19 06:56:11 +00:00
|
|
|
last_scanned_shadow[j] = last_scanned_shadow[j + 1];
|
2015-11-19 06:56:10 +00:00
|
|
|
|
|
|
|
last_scanned_cnt--;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n",
|
|
|
|
last_scanned_cnt);
|
|
|
|
if (last_scanned_cnt != 0) {
|
2015-08-17 18:10:55 +00:00
|
|
|
hAgingTimer.data = arg;
|
|
|
|
mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
|
|
|
|
} else {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
|
2015-08-17 18:10:55 +00:00
|
|
|
}
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 03:28:32 +00:00
|
|
|
static void clear_duringIP(unsigned long arg)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_optaining_ip = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2016-02-04 09:24:10 +00:00
|
|
|
static int is_network_in_shadow(struct network_info *pstrNetworkInfo,
|
2015-11-19 06:56:29 +00:00
|
|
|
void *user_void)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-10-02 07:41:17 +00:00
|
|
|
int state = -1;
|
2015-05-11 05:30:56 +00:00
|
|
|
int i;
|
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
if (last_scanned_cnt == 0) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
|
2015-11-19 06:56:29 +00:00
|
|
|
hAgingTimer.data = (unsigned long)user_void;
|
2015-08-17 18:10:55 +00:00
|
|
|
mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
|
2015-05-11 05:30:56 +00:00
|
|
|
state = -1;
|
|
|
|
} else {
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++) {
|
2016-02-04 09:24:15 +00:00
|
|
|
if (memcmp(last_scanned_shadow[i].bssid,
|
|
|
|
pstrNetworkInfo->bssid, 6) == 0) {
|
2015-05-11 05:30:56 +00:00
|
|
|
state = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2016-02-04 09:24:10 +00:00
|
|
|
static void add_network_to_shadow(struct network_info *pstrNetworkInfo,
|
2015-11-19 06:56:30 +00:00
|
|
|
void *user_void, void *pJoinParams)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-11-19 06:56:30 +00:00
|
|
|
int ap_found = is_network_in_shadow(pstrNetworkInfo, user_void);
|
2015-09-15 05:06:16 +00:00
|
|
|
u32 ap_index = 0;
|
2015-09-15 05:06:14 +00:00
|
|
|
u8 rssi_index = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ap_found == -1) {
|
2015-11-19 06:56:10 +00:00
|
|
|
ap_index = last_scanned_cnt;
|
|
|
|
last_scanned_cnt++;
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
|
|
|
ap_index = ap_found;
|
|
|
|
}
|
2016-02-04 09:24:25 +00:00
|
|
|
rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index;
|
|
|
|
last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = pstrNetworkInfo->rssi;
|
2015-05-11 05:30:56 +00:00
|
|
|
if (rssi_index == NUM_RSSI) {
|
|
|
|
rssi_index = 0;
|
2016-02-04 09:24:25 +00:00
|
|
|
last_scanned_shadow[ap_index].str_rssi.u8Full = 1;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2016-02-04 09:24:25 +00:00
|
|
|
last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index;
|
2016-02-04 09:24:11 +00:00
|
|
|
last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi;
|
2016-02-04 09:24:12 +00:00
|
|
|
last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info;
|
2016-02-04 09:24:14 +00:00
|
|
|
last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len;
|
2016-02-04 09:24:13 +00:00
|
|
|
memcpy(last_scanned_shadow[ap_index].ssid,
|
2016-02-04 09:24:14 +00:00
|
|
|
pstrNetworkInfo->ssid, pstrNetworkInfo->ssid_len);
|
2016-02-04 09:24:15 +00:00
|
|
|
memcpy(last_scanned_shadow[ap_index].bssid,
|
|
|
|
pstrNetworkInfo->bssid, ETH_ALEN);
|
2016-02-04 09:24:16 +00:00
|
|
|
last_scanned_shadow[ap_index].beacon_period = pstrNetworkInfo->beacon_period;
|
2016-02-04 09:24:17 +00:00
|
|
|
last_scanned_shadow[ap_index].dtim_period = pstrNetworkInfo->dtim_period;
|
2016-02-04 09:24:18 +00:00
|
|
|
last_scanned_shadow[ap_index].ch = pstrNetworkInfo->ch;
|
2016-02-04 09:24:23 +00:00
|
|
|
last_scanned_shadow[ap_index].ies_len = pstrNetworkInfo->ies_len;
|
2016-02-04 09:24:26 +00:00
|
|
|
last_scanned_shadow[ap_index].tsf_hi = pstrNetworkInfo->tsf_hi;
|
2015-05-11 05:30:56 +00:00
|
|
|
if (ap_found != -1)
|
2016-02-04 09:24:23 +00:00
|
|
|
kfree(last_scanned_shadow[ap_index].ies);
|
|
|
|
last_scanned_shadow[ap_index].ies = kmalloc(pstrNetworkInfo->ies_len,
|
|
|
|
GFP_KERNEL);
|
|
|
|
memcpy(last_scanned_shadow[ap_index].ies,
|
|
|
|
pstrNetworkInfo->ies, pstrNetworkInfo->ies_len);
|
2016-02-04 09:24:19 +00:00
|
|
|
last_scanned_shadow[ap_index].time_scan = jiffies;
|
|
|
|
last_scanned_shadow[ap_index].time_scan_cached = jiffies;
|
2016-02-04 09:24:21 +00:00
|
|
|
last_scanned_shadow[ap_index].found = 1;
|
2015-05-11 05:30:56 +00:00
|
|
|
if (ap_found != -1)
|
2016-02-04 09:24:24 +00:00
|
|
|
kfree(last_scanned_shadow[ap_index].join_params);
|
|
|
|
last_scanned_shadow[ap_index].join_params = pJoinParams;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:31 +00:00
|
|
|
static void CfgScanResult(enum scan_event scan_event,
|
2016-02-04 09:24:10 +00:00
|
|
|
struct network_info *network_info,
|
2015-11-19 06:56:33 +00:00
|
|
|
void *user_void,
|
2015-11-19 06:56:34 +00:00
|
|
|
void *join_params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct wiphy *wiphy;
|
2015-06-11 05:35:59 +00:00
|
|
|
s32 s32Freq;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct ieee80211_channel *channel;
|
|
|
|
struct cfg80211_bss *bss = NULL;
|
|
|
|
|
2015-11-19 06:56:33 +00:00
|
|
|
priv = (struct wilc_priv *)user_void;
|
2015-10-16 15:32:26 +00:00
|
|
|
if (priv->bCfgScanning) {
|
2015-11-19 06:56:31 +00:00
|
|
|
if (scan_event == SCAN_EVENT_NETWORK_FOUND) {
|
2015-05-11 05:30:56 +00:00
|
|
|
wiphy = priv->dev->ieee80211_ptr->wiphy;
|
2015-09-16 09:35:59 +00:00
|
|
|
|
|
|
|
if (!wiphy)
|
|
|
|
return;
|
|
|
|
|
2015-11-19 06:56:32 +00:00
|
|
|
if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
|
2016-02-04 09:24:11 +00:00
|
|
|
(((s32)network_info->rssi * 100) < 0 ||
|
|
|
|
((s32)network_info->rssi * 100) > 100))
|
2015-09-16 09:36:01 +00:00
|
|
|
return;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:32 +00:00
|
|
|
if (network_info) {
|
2016-02-04 09:24:18 +00:00
|
|
|
s32Freq = ieee80211_channel_to_frequency((s32)network_info->ch, IEEE80211_BAND_2GHZ);
|
2015-05-11 05:30:56 +00:00
|
|
|
channel = ieee80211_get_channel(wiphy, s32Freq);
|
|
|
|
|
2015-09-16 09:35:59 +00:00
|
|
|
if (!channel)
|
|
|
|
return;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:12 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "Network Info::"
|
|
|
|
"CHANNEL Frequency: %d,"
|
|
|
|
"RSSI: %d,"
|
|
|
|
"Capability Info: %d,"
|
|
|
|
"Beacon Period: %d\n",
|
|
|
|
channel->center_freq,
|
|
|
|
(s32)network_info->rssi * 100,
|
|
|
|
network_info->cap_info,
|
2016-02-04 09:24:16 +00:00
|
|
|
network_info->beacon_period);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:20 +00:00
|
|
|
if (network_info->new_network) {
|
2015-11-25 02:59:41 +00:00
|
|
|
if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
|
2016-02-04 09:24:13 +00:00
|
|
|
PRINT_D(CFG80211_DBG,
|
|
|
|
"Network %s found\n",
|
|
|
|
network_info->ssid);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->u32RcvdChCount++;
|
|
|
|
|
2015-11-19 06:56:34 +00:00
|
|
|
add_network_to_shadow(network_info, priv, join_params);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:13 +00:00
|
|
|
if (!(memcmp("DIRECT-", network_info->ssid, 7))) {
|
2016-02-04 09:24:12 +00:00
|
|
|
bss = cfg80211_inform_bss(wiphy,
|
|
|
|
channel,
|
|
|
|
CFG80211_BSS_FTYPE_UNKNOWN,
|
2016-02-04 09:24:15 +00:00
|
|
|
network_info->bssid,
|
2016-02-04 09:24:26 +00:00
|
|
|
network_info->tsf_hi,
|
2016-02-04 09:24:12 +00:00
|
|
|
network_info->cap_info,
|
2016-02-04 09:24:16 +00:00
|
|
|
network_info->beacon_period,
|
2016-02-04 09:24:23 +00:00
|
|
|
(const u8 *)network_info->ies,
|
|
|
|
(size_t)network_info->ies_len,
|
2016-02-04 09:24:12 +00:00
|
|
|
(s32)network_info->rssi * 100,
|
|
|
|
GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
cfg80211_put_bss(wiphy, bss);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
for (i = 0; i < priv->u32RcvdChCount; i++) {
|
2016-02-04 09:24:15 +00:00
|
|
|
if (memcmp(last_scanned_shadow[i].bssid, network_info->bssid, 6) == 0) {
|
2016-02-04 09:24:13 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", last_scanned_shadow[i].ssid);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:11 +00:00
|
|
|
last_scanned_shadow[i].rssi = network_info->rssi;
|
2016-02-04 09:24:19 +00:00
|
|
|
last_scanned_shadow[i].time_scan = jiffies;
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 06:56:31 +00:00
|
|
|
} else if (scan_event == SCAN_EVENT_DONE) {
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
|
|
|
|
PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
|
2015-06-12 05:11:44 +00:00
|
|
|
refresh_scan(priv, 1, false);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-08-08 12:11:36 +00:00
|
|
|
if (priv->u32RcvdChCount > 0)
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
|
2015-08-08 12:11:36 +00:00
|
|
|
else
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "No networks found\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-01 19:06:43 +00:00
|
|
|
down(&(priv->hSemScanReq));
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:23 +00:00
|
|
|
if (priv->pstrScanReq) {
|
2015-06-12 05:11:44 +00:00
|
|
|
cfg80211_scan_done(priv->pstrScanReq, false);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->u32RcvdChCount = 0;
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->bCfgScanning = false;
|
2015-06-02 05:11:12 +00:00
|
|
|
priv->pstrScanReq = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-06-01 19:06:43 +00:00
|
|
|
up(&(priv->hSemScanReq));
|
2015-11-19 06:56:31 +00:00
|
|
|
} else if (scan_event == SCAN_EVENT_ABORTED) {
|
2015-06-01 19:06:43 +00:00
|
|
|
down(&(priv->hSemScanReq));
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Scan Aborted\n");
|
2015-12-21 05:18:23 +00:00
|
|
|
if (priv->pstrScanReq) {
|
2015-11-19 06:56:28 +00:00
|
|
|
update_scan_time();
|
2015-06-12 05:11:44 +00:00
|
|
|
refresh_scan(priv, 1, false);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
cfg80211_scan_done(priv->pstrScanReq, false);
|
|
|
|
priv->bCfgScanning = false;
|
2015-06-02 05:11:12 +00:00
|
|
|
priv->pstrScanReq = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-06-01 19:06:43 +00:00
|
|
|
up(&(priv->hSemScanReq));
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
int wilc_connecting;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-12 07:56:01 +00:00
|
|
|
static void CfgConnectResult(enum conn_event enuConnDisconnEvent,
|
2015-05-11 05:30:56 +00:00
|
|
|
tstrConnectInfo *pstrConnectInfo,
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 u8MacStatus,
|
2015-05-11 05:30:56 +00:00
|
|
|
tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
|
|
|
|
void *pUserVoid)
|
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct net_device *dev;
|
2015-10-12 07:55:35 +00:00
|
|
|
struct host_if_drv *pstrWFIDrv;
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 NullBssid[ETH_ALEN] = {0};
|
2015-10-20 08:13:58 +00:00
|
|
|
struct wilc *wl;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_connecting = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
priv = (struct wilc_priv *)pUserVoid;
|
2015-05-11 05:30:56 +00:00
|
|
|
dev = priv->dev;
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
|
|
|
wl = vif->wilc;
|
2016-02-04 09:15:32 +00:00
|
|
|
pstrWFIDrv = (struct host_if_drv *)priv->hif_drv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
|
2015-10-15 08:18:29 +00:00
|
|
|
u16 u16ConnectStatus;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
|
|
|
|
|
|
|
|
if ((u8MacStatus == MAC_DISCONNECTED) &&
|
|
|
|
(pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
|
|
|
|
u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
2016-01-25 07:35:15 +00:00
|
|
|
wilc_wlan_set_bssid(priv->dev, NullBssid,
|
|
|
|
STATION_MODE);
|
2015-11-19 06:56:21 +00:00
|
|
|
eth_zero_addr(wilc_connected_ssid);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:40 +00:00
|
|
|
if (!pstrWFIDrv->p2p_connect)
|
2015-11-19 06:56:14 +00:00
|
|
|
wlan_channel = INVALID_CHANNEL;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Unspecified failure\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
|
2015-06-12 05:11:44 +00:00
|
|
|
bool bNeedScanRefresh = false;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
|
|
|
|
pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++) {
|
2016-02-04 09:24:15 +00:00
|
|
|
if (memcmp(last_scanned_shadow[i].bssid,
|
|
|
|
pstrConnectInfo->au8bssid,
|
|
|
|
ETH_ALEN) == 0) {
|
2015-05-11 05:30:56 +00:00
|
|
|
unsigned long now = jiffies;
|
|
|
|
|
|
|
|
if (time_after(now,
|
2016-02-04 09:24:19 +00:00
|
|
|
last_scanned_shadow[i].time_scan_cached +
|
|
|
|
(unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ))))
|
2015-06-12 05:11:44 +00:00
|
|
|
bNeedScanRefresh = true;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-25 02:59:41 +00:00
|
|
|
if (bNeedScanRefresh)
|
2015-06-12 05:11:44 +00:00
|
|
|
refresh_scan(priv, 1, true);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-02 08:58:17 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
|
|
|
|
|
|
|
|
cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
|
|
|
|
pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
|
|
|
|
pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
|
2015-11-25 02:59:41 +00:00
|
|
|
u16ConnectStatus, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_optaining_ip = false;
|
2015-11-19 06:56:16 +00:00
|
|
|
p2p_local_random = 0x01;
|
2015-11-19 06:56:17 +00:00
|
|
|
p2p_recv_random = 0x00;
|
2015-11-19 06:56:19 +00:00
|
|
|
wilc_ie = false;
|
2015-10-05 11:30:32 +00:00
|
|
|
eth_zero_addr(priv->au8AssociatedBss);
|
2016-01-25 07:35:15 +00:00
|
|
|
wilc_wlan_set_bssid(priv->dev, NullBssid, STATION_MODE);
|
2015-11-19 06:56:21 +00:00
|
|
|
eth_zero_addr(wilc_connected_ssid);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:40 +00:00
|
|
|
if (!pstrWFIDrv->p2p_connect)
|
2015-11-19 06:56:14 +00:00
|
|
|
wlan_channel = INVALID_CHANNEL;
|
2015-12-21 05:18:37 +00:00
|
|
|
if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1]->ndev)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
pstrDisconnectNotifInfo->u16reason = 3;
|
2015-12-21 05:18:37 +00:00
|
|
|
} else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1]->ndev)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
pstrDisconnectNotifInfo->u16reason = 1;
|
|
|
|
}
|
|
|
|
cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
|
2015-06-30 08:21:51 +00:00
|
|
|
pstrDisconnectNotifInfo->ie_len, false,
|
|
|
|
GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:01 +00:00
|
|
|
static int set_channel(struct wiphy *wiphy,
|
|
|
|
struct cfg80211_chan_def *chandef)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 channelnum = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-10-02 07:41:20 +00:00
|
|
|
int result = 0;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
|
|
|
|
|
2015-10-02 07:41:21 +00:00
|
|
|
curr_channel = channelnum;
|
2015-12-21 05:18:40 +00:00
|
|
|
result = wilc_set_mac_chnl_num(vif, channelnum);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-02 07:41:20 +00:00
|
|
|
if (result != 0)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(priv->dev, "Error in setting channel\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-02 07:41:20 +00:00
|
|
|
return result;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:02 +00:00
|
|
|
static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
|
2015-10-05 06:25:37 +00:00
|
|
|
struct hidden_network strHiddenNetwork;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv->pstrScanReq = request;
|
|
|
|
|
|
|
|
priv->u32RcvdChCount = 0;
|
|
|
|
|
2015-11-19 06:56:27 +00:00
|
|
|
reset_shadow_found();
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->bCfgScanning = true;
|
2015-11-25 02:59:41 +00:00
|
|
|
if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
|
2015-05-11 05:30:56 +00:00
|
|
|
for (i = 0; i < request->n_channels; i++) {
|
2015-06-02 05:16:04 +00:00
|
|
|
au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
|
2015-06-02 08:58:17 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
|
|
|
|
|
|
|
|
if (request->n_ssids >= 1) {
|
2016-01-05 04:26:32 +00:00
|
|
|
strHiddenNetwork.net_info = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
|
2016-01-05 04:26:33 +00:00
|
|
|
strHiddenNetwork.n_ssids = request->n_ssids;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < request->n_ssids; i++) {
|
2015-12-21 05:18:23 +00:00
|
|
|
if (request->ssids[i].ssid &&
|
|
|
|
request->ssids[i].ssid_len != 0) {
|
2016-01-05 04:26:32 +00:00
|
|
|
strHiddenNetwork.net_info[i].ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
|
|
|
|
memcpy(strHiddenNetwork.net_info[i].ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
|
|
|
|
strHiddenNetwork.net_info[i].ssid_len = request->ssids[i].ssid_len;
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
|
2016-01-05 04:26:33 +00:00
|
|
|
strHiddenNetwork.n_ssids -= 1;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN,
|
|
|
|
au8ScanChanList,
|
|
|
|
request->n_channels,
|
|
|
|
(const u8 *)request->ie,
|
|
|
|
request->ie_len, CfgScanResult,
|
|
|
|
(void *)priv, &strHiddenNetwork);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN,
|
|
|
|
au8ScanChanList,
|
|
|
|
request->n_channels,
|
|
|
|
(const u8 *)request->ie,
|
|
|
|
request->ie_len, CfgScanResult,
|
|
|
|
(void *)priv, NULL);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(priv->dev, "Requested scanned channels over\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-16 09:36:03 +00:00
|
|
|
if (s32Error != 0) {
|
2015-05-11 05:30:56 +00:00
|
|
|
s32Error = -EBUSY;
|
|
|
|
PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:03 +00:00
|
|
|
static int connect(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
struct cfg80211_connect_params *sme)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 u8security = NO_ENCRYPT;
|
2015-10-05 06:25:39 +00:00
|
|
|
enum AUTHTYPE tenuAuth_type = ANY;
|
2015-06-15 02:58:57 +00:00
|
|
|
char *pcgroup_encrypt_val = NULL;
|
|
|
|
char *pccipher_group = NULL;
|
|
|
|
char *pcwpa_version = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-10-12 07:55:35 +00:00
|
|
|
struct host_if_drv *pstrWFIDrv;
|
2016-02-04 09:24:10 +00:00
|
|
|
struct network_info *pstrNetworkInfo = NULL;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_connecting = 1;
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2016-02-04 09:15:32 +00:00
|
|
|
pstrWFIDrv = (struct host_if_drv *)priv->hif_drv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:15:32 +00:00
|
|
|
PRINT_D(CFG80211_DBG,
|
|
|
|
"Connecting to SSID [%s] on netdev [%p] host if [%p]\n",
|
|
|
|
sme->ssid, dev, priv->hif_drv);
|
2015-08-10 02:33:17 +00:00
|
|
|
if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
|
2015-10-29 03:05:40 +00:00
|
|
|
pstrWFIDrv->p2p_connect = 1;
|
|
|
|
} else {
|
|
|
|
pstrWFIDrv->p2p_connect = 0;
|
|
|
|
}
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
for (i = 0; i < last_scanned_cnt; i++) {
|
2016-02-04 09:24:14 +00:00
|
|
|
if ((sme->ssid_len == last_scanned_shadow[i].ssid_len) &&
|
2016-02-04 09:24:13 +00:00
|
|
|
memcmp(last_scanned_shadow[i].ssid,
|
2015-11-19 06:56:11 +00:00
|
|
|
sme->ssid,
|
|
|
|
sme->ssid_len) == 0) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!sme->bssid) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
|
|
|
|
break;
|
|
|
|
} else {
|
2016-02-04 09:24:15 +00:00
|
|
|
if (memcmp(last_scanned_shadow[i].bssid,
|
2015-11-19 06:56:11 +00:00
|
|
|
sme->bssid,
|
|
|
|
ETH_ALEN) == 0) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-19 06:56:10 +00:00
|
|
|
if (i < last_scanned_cnt) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
|
|
|
|
|
2015-11-19 06:56:11 +00:00
|
|
|
pstrNetworkInfo = &last_scanned_shadow[i];
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:15 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "network BSSID to be associated:"
|
|
|
|
"%x%x%x%x%x%x\n",
|
|
|
|
pstrNetworkInfo->bssid[0], pstrNetworkInfo->bssid[1],
|
|
|
|
pstrNetworkInfo->bssid[2], pstrNetworkInfo->bssid[3],
|
|
|
|
pstrNetworkInfo->bssid[4], pstrNetworkInfo->bssid[5]);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
|
|
|
s32Error = -ENOENT;
|
2015-11-19 06:56:10 +00:00
|
|
|
if (last_scanned_cnt == 0)
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "No Scan results yet\n");
|
|
|
|
else
|
|
|
|
PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
|
2016-02-04 09:15:21 +00:00
|
|
|
wilc_connecting = 0;
|
|
|
|
return s32Error;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-07 00:02:01 +00:00
|
|
|
memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
|
|
|
|
memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
|
|
|
|
PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
|
|
|
|
|
|
|
|
PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
|
|
|
|
|
|
|
|
if (sme->crypto.cipher_group != NO_ENCRYPT) {
|
|
|
|
pcwpa_version = "Default";
|
|
|
|
if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
|
|
|
|
u8security = ENCRYPT_ENABLED | WEP;
|
|
|
|
pcgroup_encrypt_val = "WEP40";
|
|
|
|
pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
|
|
|
|
PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
|
|
|
|
|
|
|
|
priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
g_key_wep_params.key_len = sme->key_len;
|
2015-09-10 03:03:04 +00:00
|
|
|
g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_key_wep_params.key, sme->key, sme->key_len);
|
|
|
|
g_key_wep_params.key_idx = sme->key_idx;
|
2015-06-12 05:11:44 +00:00
|
|
|
g_wep_keys_saved = true;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_set_wep_default_keyid(vif, sme->key_idx);
|
|
|
|
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
|
|
|
|
sme->key_idx);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
|
|
|
|
u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
|
|
|
|
pcgroup_encrypt_val = "WEP104";
|
|
|
|
pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
|
|
|
|
|
|
|
|
priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
g_key_wep_params.key_len = sme->key_len;
|
2015-09-10 03:03:04 +00:00
|
|
|
g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_key_wep_params.key, sme->key, sme->key_len);
|
|
|
|
g_key_wep_params.key_idx = sme->key_idx;
|
2015-06-12 05:11:44 +00:00
|
|
|
g_wep_keys_saved = true;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_set_wep_default_keyid(vif, sme->key_idx);
|
|
|
|
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
|
|
|
|
sme->key_idx);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
|
|
|
|
if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
|
|
|
|
pcgroup_encrypt_val = "WPA2_TKIP";
|
|
|
|
pccipher_group = "TKIP";
|
2015-11-25 02:59:41 +00:00
|
|
|
} else {
|
2015-05-11 05:30:56 +00:00
|
|
|
u8security = ENCRYPT_ENABLED | WPA2 | AES;
|
|
|
|
pcgroup_encrypt_val = "WPA2_AES";
|
|
|
|
pccipher_group = "AES";
|
|
|
|
}
|
|
|
|
pcwpa_version = "WPA_VERSION_2";
|
|
|
|
} else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
|
|
|
|
if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
u8security = ENCRYPT_ENABLED | WPA | TKIP;
|
|
|
|
pcgroup_encrypt_val = "WPA_TKIP";
|
|
|
|
pccipher_group = "TKIP";
|
2015-11-25 02:59:41 +00:00
|
|
|
} else {
|
2015-05-11 05:30:56 +00:00
|
|
|
u8security = ENCRYPT_ENABLED | WPA | AES;
|
|
|
|
pcgroup_encrypt_val = "WPA_AES";
|
|
|
|
pccipher_group = "AES";
|
|
|
|
}
|
|
|
|
pcwpa_version = "WPA_VERSION_1";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
s32Error = -ENOTSUPP;
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Not supported cipher\n");
|
2016-02-04 09:15:21 +00:00
|
|
|
wilc_connecting = 0;
|
|
|
|
return s32Error;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
|
|
|
|
|| (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
|
|
|
|
for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
|
|
|
|
if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
u8security = u8security | TKIP;
|
2015-11-25 02:59:41 +00:00
|
|
|
} else {
|
2015-05-11 05:30:56 +00:00
|
|
|
u8security = u8security | AES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
|
|
|
|
switch (sme->auth_type) {
|
|
|
|
case NL80211_AUTHTYPE_OPEN_SYSTEM:
|
|
|
|
PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
|
|
|
|
tenuAuth_type = OPEN_SYSTEM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NL80211_AUTHTYPE_SHARED_KEY:
|
|
|
|
tenuAuth_type = SHARED_KEY;
|
|
|
|
PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sme->crypto.n_akm_suites) {
|
|
|
|
switch (sme->crypto.akm_suites[0]) {
|
|
|
|
case WLAN_AKM_SUITE_8021X:
|
|
|
|
tenuAuth_type = IEEE8021;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-04 09:24:18 +00:00
|
|
|
PRINT_INFO(CFG80211_DBG, "Required Ch = %d\n", pstrNetworkInfo->ch);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
|
|
|
|
pcgroup_encrypt_val, pccipher_group, pcwpa_version);
|
|
|
|
|
2016-02-04 09:24:18 +00:00
|
|
|
curr_channel = pstrNetworkInfo->ch;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:40 +00:00
|
|
|
if (!pstrWFIDrv->p2p_connect)
|
2016-02-04 09:24:18 +00:00
|
|
|
wlan_channel = pstrNetworkInfo->ch;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:15 +00:00
|
|
|
wilc_wlan_set_bssid(dev, pstrNetworkInfo->bssid, STATION_MODE);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:24:15 +00:00
|
|
|
s32Error = wilc_set_join_req(vif, pstrNetworkInfo->bssid, sme->ssid,
|
2015-12-21 05:18:40 +00:00
|
|
|
sme->ssid_len, sme->ie, sme->ie_len,
|
|
|
|
CfgConnectResult, (void *)priv,
|
|
|
|
u8security, tenuAuth_type,
|
2016-02-04 09:24:18 +00:00
|
|
|
pstrNetworkInfo->ch,
|
2016-02-04 09:24:24 +00:00
|
|
|
pstrNetworkInfo->join_params);
|
2015-09-16 09:36:03 +00:00
|
|
|
if (s32Error != 0) {
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "wilc_set_join_req(): Error\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
s32Error = -ENOENT;
|
2016-02-04 09:15:21 +00:00
|
|
|
wilc_connecting = 0;
|
|
|
|
return s32Error;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:04 +00:00
|
|
|
static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-10-12 07:55:35 +00:00
|
|
|
struct host_if_drv *pstrWFIDrv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-09-15 05:06:14 +00:00
|
|
|
u8 NullBssid[ETH_ALEN] = {0};
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_connecting = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:15:32 +00:00
|
|
|
pstrWFIDrv = (struct host_if_drv *)priv->hif_drv;
|
2015-10-29 03:05:40 +00:00
|
|
|
if (!pstrWFIDrv->p2p_connect)
|
2015-11-19 06:56:14 +00:00
|
|
|
wlan_channel = INVALID_CHANNEL;
|
2016-01-25 07:35:15 +00:00
|
|
|
wilc_wlan_set_bssid(priv->dev, NullBssid, STATION_MODE);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
|
|
|
|
|
2015-11-19 06:56:16 +00:00
|
|
|
p2p_local_random = 0x01;
|
2015-11-19 06:56:17 +00:00
|
|
|
p2p_recv_random = 0x00;
|
2015-11-19 06:56:19 +00:00
|
|
|
wilc_ie = false;
|
2015-10-29 03:05:39 +00:00
|
|
|
pstrWFIDrv->p2p_timeout = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_disconnect(vif, reason_code);
|
2015-09-16 09:36:03 +00:00
|
|
|
if (s32Error != 0) {
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(priv->dev, "Error in disconnecting\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
s32Error = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:05 +00:00
|
|
|
static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
|
|
|
|
bool pairwise,
|
|
|
|
const u8 *mac_addr, struct key_params *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0, KeyLen = params->key_len;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-06-01 19:06:44 +00:00
|
|
|
const u8 *pu8RxMic = NULL;
|
|
|
|
const u8 *pu8TxMic = NULL;
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 u8mode = NO_ENCRYPT;
|
|
|
|
u8 u8gmode = NO_ENCRYPT;
|
|
|
|
u8 u8pmode = NO_ENCRYPT;
|
2015-10-05 06:25:39 +00:00
|
|
|
enum AUTHTYPE tenuAuth_type = ANY;
|
2015-10-20 08:13:59 +00:00
|
|
|
struct wilc *wl;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(netdev);
|
|
|
|
wl = vif->wilc;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
|
|
|
|
|
2015-06-10 08:06:46 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
|
|
|
|
params->key[1],
|
|
|
|
params->key[2]);
|
|
|
|
|
|
|
|
|
|
|
|
switch (params->cipher) {
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
|
|
|
if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
|
|
|
|
priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
|
|
|
|
|
|
|
|
for (i = 0; i < params->key_len; i++)
|
|
|
|
PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
|
|
|
|
|
|
|
|
tenuAuth_type = OPEN_SYSTEM;
|
|
|
|
|
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
|
|
|
|
u8mode = ENCRYPT_ENABLED | WEP;
|
|
|
|
else
|
|
|
|
u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_add_wep_key_bss_ap(vif, params->key,
|
|
|
|
params->key_len, key_index,
|
|
|
|
u8mode, tenuAuth_type);
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-08-07 00:02:03 +00:00
|
|
|
if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
|
|
|
|
if (INFO) {
|
|
|
|
for (i = 0; i < params->key_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
|
|
|
|
}
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_add_wep_key_bss_sta(vif, params->key,
|
|
|
|
params->key_len, key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
|
|
|
if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!priv->wilc_gtk[key_index]) {
|
2015-09-10 03:03:04 +00:00
|
|
|
priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
|
2015-06-02 05:11:12 +00:00
|
|
|
priv->wilc_gtk[key_index]->key = NULL;
|
|
|
|
priv->wilc_gtk[key_index]->seq = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!priv->wilc_ptk[key_index]) {
|
2015-09-10 03:03:04 +00:00
|
|
|
priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
|
2015-06-02 05:11:12 +00:00
|
|
|
priv->wilc_ptk[key_index]->key = NULL;
|
|
|
|
priv->wilc_ptk[key_index]->seq = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-05 06:18:31 +00:00
|
|
|
if (!pairwise) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
|
|
|
|
u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
|
|
|
|
else
|
|
|
|
u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
|
|
|
|
|
|
|
|
priv->wilc_groupkey = u8gmode;
|
|
|
|
|
|
|
|
if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
pu8TxMic = params->key + 24;
|
|
|
|
pu8RxMic = params->key + 16;
|
|
|
|
KeyLen = params->key_len - 16;
|
|
|
|
}
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(priv->wilc_gtk[key_index]->key);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-10 03:03:04 +00:00
|
|
|
priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(priv->wilc_gtk[key_index]->seq);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if ((params->seq_len) > 0) {
|
2015-09-10 03:03:04 +00:00
|
|
|
priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
priv->wilc_gtk[key_index]->cipher = params->cipher;
|
|
|
|
priv->wilc_gtk[key_index]->key_len = params->key_len;
|
|
|
|
priv->wilc_gtk[key_index]->seq_len = params->seq_len;
|
|
|
|
|
|
|
|
if (INFO) {
|
|
|
|
for (i = 0; i < params->key_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
|
|
|
|
for (i = 0; i < params->seq_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_add_rx_gtk(vif, params->key, KeyLen,
|
|
|
|
key_index, params->seq_len,
|
|
|
|
params->seq, pu8RxMic,
|
|
|
|
pu8TxMic, AP_MODE, u8gmode);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]);
|
|
|
|
|
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
|
|
|
|
u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
|
|
|
|
else
|
|
|
|
u8pmode = priv->wilc_groupkey | AES;
|
|
|
|
|
|
|
|
|
|
|
|
if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
pu8TxMic = params->key + 24;
|
|
|
|
pu8RxMic = params->key + 16;
|
|
|
|
KeyLen = params->key_len - 16;
|
|
|
|
}
|
|
|
|
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(priv->wilc_ptk[key_index]->key);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-10 03:03:04 +00:00
|
|
|
priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(priv->wilc_ptk[key_index]->seq);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if ((params->seq_len) > 0)
|
2015-09-10 03:03:04 +00:00
|
|
|
priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if (INFO) {
|
|
|
|
for (i = 0; i < params->key_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
|
|
|
|
|
|
|
|
for (i = 0; i < params->seq_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
|
|
|
|
}
|
|
|
|
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if ((params->seq_len) > 0)
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv->wilc_ptk[key_index]->cipher = params->cipher;
|
|
|
|
priv->wilc_ptk[key_index]->key_len = params->key_len;
|
|
|
|
priv->wilc_ptk[key_index]->seq_len = params->seq_len;
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_add_ptk(vif, params->key, KeyLen,
|
|
|
|
mac_addr, pu8RxMic, pu8TxMic,
|
|
|
|
AP_MODE, u8pmode, key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
u8mode = 0;
|
2015-08-05 06:18:31 +00:00
|
|
|
if (!pairwise) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
pu8RxMic = params->key + 24;
|
|
|
|
pu8TxMic = params->key + 16;
|
|
|
|
KeyLen = params->key_len - 16;
|
|
|
|
}
|
|
|
|
|
2015-12-21 05:18:37 +00:00
|
|
|
if (!g_gtk_keys_saved && netdev == wl->vif[0]->ndev) {
|
2015-05-11 05:30:56 +00:00
|
|
|
g_add_gtk_key_params.key_idx = key_index;
|
|
|
|
g_add_gtk_key_params.pairwise = pairwise;
|
|
|
|
if (!mac_addr) {
|
|
|
|
g_add_gtk_key_params.mac_addr = NULL;
|
|
|
|
} else {
|
2015-09-10 03:03:04 +00:00
|
|
|
g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
|
|
|
|
}
|
|
|
|
g_key_gtk_params.key_len = params->key_len;
|
|
|
|
g_key_gtk_params.seq_len = params->seq_len;
|
2015-09-10 03:03:04 +00:00
|
|
|
g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_key_gtk_params.key, params->key, params->key_len);
|
|
|
|
if (params->seq_len > 0) {
|
2015-09-10 03:03:04 +00:00
|
|
|
g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
|
|
|
|
}
|
|
|
|
g_key_gtk_params.cipher = params->cipher;
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
|
|
|
|
g_key_gtk_params.key[1],
|
|
|
|
g_key_gtk_params.key[2]);
|
2015-06-12 05:11:44 +00:00
|
|
|
g_gtk_keys_saved = true;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_add_rx_gtk(vif, params->key, KeyLen,
|
|
|
|
key_index, params->seq_len,
|
|
|
|
params->seq, pu8RxMic,
|
|
|
|
pu8TxMic, STATION_MODE,
|
|
|
|
u8mode);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
|
|
|
if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
|
|
|
|
pu8RxMic = params->key + 24;
|
|
|
|
pu8TxMic = params->key + 16;
|
|
|
|
KeyLen = params->key_len - 16;
|
|
|
|
}
|
|
|
|
|
2015-12-21 05:18:37 +00:00
|
|
|
if (!g_ptk_keys_saved && netdev == wl->vif[0]->ndev) {
|
2015-05-11 05:30:56 +00:00
|
|
|
g_add_ptk_key_params.key_idx = key_index;
|
|
|
|
g_add_ptk_key_params.pairwise = pairwise;
|
|
|
|
if (!mac_addr) {
|
|
|
|
g_add_ptk_key_params.mac_addr = NULL;
|
|
|
|
} else {
|
2015-09-10 03:03:04 +00:00
|
|
|
g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
|
|
|
|
}
|
|
|
|
g_key_ptk_params.key_len = params->key_len;
|
|
|
|
g_key_ptk_params.seq_len = params->seq_len;
|
2015-09-10 03:03:04 +00:00
|
|
|
g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_key_ptk_params.key, params->key, params->key_len);
|
|
|
|
if (params->seq_len > 0) {
|
2015-09-10 03:03:04 +00:00
|
|
|
g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
|
2015-05-11 05:30:56 +00:00
|
|
|
memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
|
|
|
|
}
|
|
|
|
g_key_ptk_params.cipher = params->cipher;
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
|
|
|
|
g_key_ptk_params.key[1],
|
|
|
|
g_key_ptk_params.key[2]);
|
2015-06-12 05:11:44 +00:00
|
|
|
g_ptk_keys_saved = true;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_add_ptk(vif, params->key, KeyLen,
|
|
|
|
mac_addr, pu8RxMic, pu8TxMic,
|
|
|
|
STATION_MODE, u8mode, key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
|
|
|
|
if (INFO) {
|
|
|
|
for (i = 0; i < params->key_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(netdev, "Not supported cipher\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
s32Error = -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:06 +00:00
|
|
|
static int del_key(struct wiphy *wiphy, struct net_device *netdev,
|
|
|
|
u8 key_index,
|
|
|
|
bool pairwise,
|
|
|
|
const u8 *mac_addr)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-10-20 08:14:00 +00:00
|
|
|
struct wilc *wl;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(netdev);
|
|
|
|
wl = vif->wilc;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:37 +00:00
|
|
|
if (netdev == wl->vif[0]->ndev) {
|
2015-06-12 05:11:44 +00:00
|
|
|
g_ptk_keys_saved = false;
|
|
|
|
g_gtk_keys_saved = false;
|
|
|
|
g_wep_keys_saved = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(g_key_wep_params.key);
|
|
|
|
g_key_wep_params.key = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if ((priv->wilc_gtk[key_index]) != NULL) {
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(priv->wilc_gtk[key_index]->key);
|
|
|
|
priv->wilc_gtk[key_index]->key = NULL;
|
|
|
|
kfree(priv->wilc_gtk[key_index]->seq);
|
|
|
|
priv->wilc_gtk[key_index]->seq = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-08-11 01:32:41 +00:00
|
|
|
kfree(priv->wilc_gtk[key_index]);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->wilc_gtk[key_index] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((priv->wilc_ptk[key_index]) != NULL) {
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(priv->wilc_ptk[key_index]->key);
|
|
|
|
priv->wilc_ptk[key_index]->key = NULL;
|
|
|
|
kfree(priv->wilc_ptk[key_index]->seq);
|
|
|
|
priv->wilc_ptk[key_index]->seq = NULL;
|
2015-08-11 01:32:41 +00:00
|
|
|
kfree(priv->wilc_ptk[key_index]);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->wilc_ptk[key_index] = NULL;
|
|
|
|
}
|
|
|
|
|
2015-10-12 15:19:19 +00:00
|
|
|
kfree(g_key_ptk_params.key);
|
|
|
|
g_key_ptk_params.key = NULL;
|
|
|
|
kfree(g_key_ptk_params.seq);
|
|
|
|
g_key_ptk_params.seq = NULL;
|
|
|
|
|
|
|
|
kfree(g_key_gtk_params.key);
|
|
|
|
g_key_gtk_params.key = NULL;
|
|
|
|
kfree(g_key_gtk_params.seq);
|
|
|
|
g_key_gtk_params.seq = NULL;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_index >= 0 && key_index <= 3) {
|
2015-08-07 00:02:01 +00:00
|
|
|
memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->WILC_WFI_wep_key_len[key_index] = 0;
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_remove_wep_key(vif, key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
|
|
|
PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
|
2016-02-04 09:15:32 +00:00
|
|
|
wilc_remove_key(priv->hif_drv, mac_addr);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 07:55:38 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:07 +00:00
|
|
|
static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
|
|
|
|
bool pairwise,
|
|
|
|
const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct key_params key_params;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
|
|
|
|
|
|
|
|
2015-10-12 20:22:44 +00:00
|
|
|
if (!pairwise) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
|
|
|
|
|
|
|
|
key_params.key = priv->wilc_gtk[key_index]->key;
|
|
|
|
key_params.cipher = priv->wilc_gtk[key_index]->cipher;
|
|
|
|
key_params.key_len = priv->wilc_gtk[key_index]->key_len;
|
|
|
|
key_params.seq = priv->wilc_gtk[key_index]->seq;
|
|
|
|
key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
|
|
|
|
if (INFO) {
|
|
|
|
for (i = 0; i < key_params.key_len; i++)
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
|
|
|
|
|
|
|
|
key_params.key = priv->wilc_ptk[key_index]->key;
|
|
|
|
key_params.cipher = priv->wilc_ptk[key_index]->cipher;
|
|
|
|
key_params.key_len = priv->wilc_ptk[key_index]->key_len;
|
|
|
|
key_params.seq = priv->wilc_ptk[key_index]->seq;
|
|
|
|
key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
callback(cookie, &key_params);
|
|
|
|
|
2015-11-25 02:59:41 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:08 +00:00
|
|
|
static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
|
|
|
|
bool unicast, bool multicast)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:15:28 +00:00
|
|
|
wilc_set_wep_default_keyid(vif, key_index);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-12 07:55:38 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:18 +00:00
|
|
|
static int get_station(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
const u8 *mac, struct station_info *sinfo)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i = 0;
|
|
|
|
u32 associatedsta = 0;
|
|
|
|
u32 inactive_time = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
|
|
|
|
|
|
|
|
PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
|
|
|
|
if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
|
|
|
|
associatedsta = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (associatedsta == -1) {
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "sta required is not associated\n");
|
2015-10-12 07:55:38 +00:00
|
|
|
return -ENOENT;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_get_inactive_time(vif, mac, &inactive_time);
|
2015-05-11 05:30:56 +00:00
|
|
|
sinfo->inactive_time = 1000 * inactive_time;
|
|
|
|
PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
|
|
|
|
}
|
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
if (vif->iftype == STATION_MODE) {
|
2015-10-12 07:55:58 +00:00
|
|
|
struct rf_info strStatistics;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_get_statistics(vif, &strStatistics);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
|
2015-08-05 16:41:57 +00:00
|
|
|
BIT(NL80211_STA_INFO_RX_PACKETS) |
|
2015-05-11 05:30:56 +00:00
|
|
|
BIT(NL80211_STA_INFO_TX_PACKETS) |
|
|
|
|
BIT(NL80211_STA_INFO_TX_FAILED) |
|
|
|
|
BIT(NL80211_STA_INFO_TX_BITRATE);
|
|
|
|
|
2015-10-29 03:05:30 +00:00
|
|
|
sinfo->signal = strStatistics.rssi;
|
2015-10-29 03:05:32 +00:00
|
|
|
sinfo->rx_packets = strStatistics.rx_cnt;
|
2015-10-29 03:05:33 +00:00
|
|
|
sinfo->tx_packets = strStatistics.tx_cnt + strStatistics.tx_fail_cnt;
|
|
|
|
sinfo->tx_failed = strStatistics.tx_fail_cnt;
|
2015-10-29 03:05:29 +00:00
|
|
|
sinfo->txrate.legacy = strStatistics.link_speed * 10;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:29 +00:00
|
|
|
if ((strStatistics.link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH) &&
|
|
|
|
(strStatistics.link_speed != DEFAULT_LINK_SPEED))
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_enable_tcp_ack_filter(true);
|
2015-10-29 03:05:29 +00:00
|
|
|
else if (strStatistics.link_speed != DEFAULT_LINK_SPEED)
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_enable_tcp_ack_filter(false);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-10-12 07:55:38 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:20 +00:00
|
|
|
static int change_bss(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
struct bss_parameters *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:21 +00:00
|
|
|
static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-10-05 06:25:46 +00:00
|
|
|
struct cfg_param_val pstrCfgParamVal;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-12 07:56:07 +00:00
|
|
|
pstrCfgParamVal.flag = 0;
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if (changed & WIPHY_PARAM_RETRY_SHORT) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
|
|
|
|
priv->dev->ieee80211_ptr->wiphy->retry_short);
|
2015-10-12 07:56:07 +00:00
|
|
|
pstrCfgParamVal.flag |= RETRY_SHORT;
|
2015-05-11 05:30:56 +00:00
|
|
|
pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
|
|
|
|
}
|
|
|
|
if (changed & WIPHY_PARAM_RETRY_LONG) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
|
2015-10-12 07:56:07 +00:00
|
|
|
pstrCfgParamVal.flag |= RETRY_LONG;
|
2015-05-11 05:30:56 +00:00
|
|
|
pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
|
|
|
|
}
|
|
|
|
if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
|
2015-10-12 07:56:07 +00:00
|
|
|
pstrCfgParamVal.flag |= FRAG_THRESHOLD;
|
2015-05-11 05:30:56 +00:00
|
|
|
pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
|
|
|
|
|
2015-10-12 07:56:07 +00:00
|
|
|
pstrCfgParamVal.flag |= RTS_THRESHOLD;
|
2015-05-11 05:30:56 +00:00
|
|
|
pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_hif_set_cfg(vif, &pstrCfgParamVal);
|
2015-05-11 05:30:56 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
2015-05-29 20:52:12 +00:00
|
|
|
|
2015-09-14 03:24:22 +00:00
|
|
|
static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
|
|
|
|
struct cfg80211_pmksa *pmksa)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 flag = 0;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
|
2015-08-07 00:02:03 +00:00
|
|
|
if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
|
2015-05-11 05:30:56 +00:00
|
|
|
ETH_ALEN)) {
|
|
|
|
flag = PMKID_FOUND;
|
|
|
|
PRINT_D(CFG80211_DBG, "PMKID already exists\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i < WILC_MAX_NUM_PMKIDS) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
|
2015-05-11 05:30:56 +00:00
|
|
|
ETH_ALEN);
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
|
2015-05-11 05:30:56 +00:00
|
|
|
PMKID_LEN);
|
|
|
|
if (!(flag == PMKID_FOUND))
|
|
|
|
priv->pmkid_list.numpmkid++;
|
|
|
|
} else {
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(netdev, "Invalid PMKID index\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
s32Error = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!s32Error) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_set_pmkid_info(vif, &priv->pmkid_list);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:23 +00:00
|
|
|
static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
|
|
|
|
struct cfg80211_pmksa *pmksa)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
|
|
|
|
|
|
|
|
for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
|
2015-08-07 00:02:03 +00:00
|
|
|
if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
|
2015-05-11 05:30:56 +00:00
|
|
|
ETH_ALEN)) {
|
|
|
|
PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
|
2015-10-05 06:25:45 +00:00
|
|
|
memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
|
|
|
|
for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->pmkid_list.pmkidlist[i].bssid,
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->pmkid_list.pmkidlist[i + 1].bssid,
|
|
|
|
ETH_ALEN);
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->pmkid_list.pmkidlist[i].pmkid,
|
|
|
|
PMKID_LEN);
|
|
|
|
}
|
|
|
|
priv->pmkid_list.numpmkid--;
|
|
|
|
} else {
|
|
|
|
s32Error = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:24 +00:00
|
|
|
static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
|
|
|
|
|
2015-10-05 06:25:44 +00:00
|
|
|
memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr));
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-16 14:04:53 +00:00
|
|
|
static void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 index = 0;
|
|
|
|
u32 i = 0, j = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 op_channel_attr_index = 0;
|
|
|
|
u8 channel_list_attr_index = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
while (index < len) {
|
|
|
|
if (buf[index] == GO_INTENT_ATTR_ID) {
|
|
|
|
buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
|
|
|
|
}
|
|
|
|
|
2015-08-08 12:11:36 +00:00
|
|
|
if (buf[index] == CHANLIST_ATTR_ID)
|
2015-05-11 05:30:56 +00:00
|
|
|
channel_list_attr_index = index;
|
2015-08-08 12:11:36 +00:00
|
|
|
else if (buf[index] == OPERCHAN_ATTR_ID)
|
2015-05-11 05:30:56 +00:00
|
|
|
op_channel_attr_index = index;
|
2015-11-25 02:59:41 +00:00
|
|
|
index += buf[index + 1] + 3;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-11-19 06:56:14 +00:00
|
|
|
if (wlan_channel != INVALID_CHANNEL) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if (channel_list_attr_index) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
|
|
|
|
for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
|
|
|
|
if (buf[i] == 0x51) {
|
|
|
|
for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
|
2015-11-19 06:56:14 +00:00
|
|
|
buf[j] = wlan_channel;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
if (op_channel_attr_index) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
|
|
|
|
buf[op_channel_attr_index + 6] = 0x51;
|
2015-11-19 06:56:14 +00:00
|
|
|
buf[op_channel_attr_index + 7] = wlan_channel;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 14:04:53 +00:00
|
|
|
static void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 index = 0;
|
|
|
|
u32 i = 0, j = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 op_channel_attr_index = 0;
|
|
|
|
u8 channel_list_attr_index = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
while (index < len) {
|
|
|
|
if (buf[index] == GO_INTENT_ATTR_ID) {
|
|
|
|
buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-08 12:11:36 +00:00
|
|
|
if (buf[index] == CHANLIST_ATTR_ID)
|
2015-05-11 05:30:56 +00:00
|
|
|
channel_list_attr_index = index;
|
2015-08-08 12:11:36 +00:00
|
|
|
else if (buf[index] == OPERCHAN_ATTR_ID)
|
2015-05-11 05:30:56 +00:00
|
|
|
op_channel_attr_index = index;
|
2015-11-25 02:59:41 +00:00
|
|
|
index += buf[index + 1] + 3;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-11-19 06:56:14 +00:00
|
|
|
if (wlan_channel != INVALID_CHANNEL && bOperChan) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if (channel_list_attr_index) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
|
|
|
|
for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
|
|
|
|
if (buf[i] == 0x51) {
|
|
|
|
for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
|
2015-11-19 06:56:14 +00:00
|
|
|
buf[j] = wlan_channel;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
if (op_channel_attr_index) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
|
|
|
|
buf[op_channel_attr_index + 6] = 0x51;
|
2015-11-19 06:56:14 +00:00
|
|
|
buf[op_channel_attr_index + 7] = wlan_channel;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 05:06:16 +00:00
|
|
|
void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 header, pkt_offset;
|
2015-10-12 07:55:35 +00:00
|
|
|
struct host_if_drv *pstrWFIDrv;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i = 0;
|
2015-06-11 05:35:59 +00:00
|
|
|
s32 s32Freq;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
|
2016-02-04 09:15:32 +00:00
|
|
|
pstrWFIDrv = (struct host_if_drv *)priv->hif_drv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
pkt_offset = GET_PKT_OFFSET(header);
|
|
|
|
|
|
|
|
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
|
|
|
|
if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Probe response ACK\n");
|
|
|
|
cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
|
|
|
|
buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
|
|
|
|
cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
|
|
|
|
} else {
|
|
|
|
PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
|
|
|
|
buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
|
|
|
|
cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
|
|
|
|
|
2015-10-02 07:41:21 +00:00
|
|
|
s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
|
|
|
|
|
2015-10-29 03:05:39 +00:00
|
|
|
if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->p2p_timeout)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
|
|
|
|
switch (buff[ACTION_SUBTYPE_ID]) {
|
|
|
|
case GAS_INTIAL_REQ:
|
|
|
|
PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GAS_INTIAL_RSP:
|
|
|
|
PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PUBLIC_ACT_VENDORSPEC:
|
2015-11-19 06:56:15 +00:00
|
|
|
if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
|
2015-11-19 06:56:19 +00:00
|
|
|
if (!wilc_ie) {
|
2015-05-11 05:30:56 +00:00
|
|
|
for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
|
2015-11-19 06:56:18 +00:00
|
|
|
if (!memcmp(p2p_vendor_spec, &buff[i], 6)) {
|
2015-11-19 06:56:17 +00:00
|
|
|
p2p_recv_random = buff[i + 6];
|
2015-11-19 06:56:19 +00:00
|
|
|
wilc_ie = true;
|
2015-11-19 06:56:17 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", p2p_recv_random);
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 06:56:17 +00:00
|
|
|
if (p2p_local_random > p2p_recv_random) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
|
|
|
|
|| buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
|
|
|
|
for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
|
2015-11-19 06:56:15 +00:00
|
|
|
if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buff[i + 2], 4))) {
|
2015-05-11 05:30:56 +00:00
|
|
|
WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 06:56:16 +00:00
|
|
|
} else {
|
2015-11-19 06:56:17 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random);
|
2015-11-19 06:56:16 +00:00
|
|
|
}
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-19 06:56:19 +00:00
|
|
|
if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (wilc_ie)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
|
|
|
|
cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 09:15:26 +00:00
|
|
|
cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
|
|
|
|
{
|
|
|
|
struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
|
|
|
|
|
|
|
|
|
|
|
|
kfree(pv_data->buff);
|
|
|
|
kfree(pv_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
|
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
priv = (struct wilc_priv *)pUserVoid;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->bInP2PlistenState = true;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
cfg80211_ready_on_channel(priv->wdev,
|
|
|
|
priv->strRemainOnChanParams.u64ListenCookie,
|
|
|
|
priv->strRemainOnChanParams.pstrListenChan,
|
|
|
|
priv->strRemainOnChanParams.u32ListenDuration,
|
|
|
|
GFP_KERNEL);
|
|
|
|
}
|
|
|
|
|
2015-06-11 05:35:55 +00:00
|
|
|
static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
priv = (struct wilc_priv *)pUserVoid;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->bInP2PlistenState = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
cfg80211_remain_on_channel_expired(priv->wdev,
|
|
|
|
priv->strRemainOnChanParams.u64ListenCookie,
|
|
|
|
priv->strRemainOnChanParams.pstrListenChan,
|
|
|
|
GFP_KERNEL);
|
|
|
|
} else {
|
|
|
|
PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
|
|
|
|
, priv->strRemainOnChanParams.u32ListenSessionID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:25 +00:00
|
|
|
static int remain_on_channel(struct wiphy *wiphy,
|
|
|
|
struct wireless_dev *wdev,
|
|
|
|
struct ieee80211_channel *chan,
|
|
|
|
unsigned int duration, u64 *cookie)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
|
|
|
|
|
|
|
|
|
|
|
|
if (wdev->iftype == NL80211_IFTYPE_AP) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-10-02 07:41:21 +00:00
|
|
|
curr_channel = chan->hw_value;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv->strRemainOnChanParams.pstrListenChan = chan;
|
|
|
|
priv->strRemainOnChanParams.u64ListenCookie = *cookie;
|
|
|
|
priv->strRemainOnChanParams.u32ListenDuration = duration;
|
|
|
|
priv->strRemainOnChanParams.u32ListenSessionID++;
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_remain_on_channel(vif,
|
|
|
|
priv->strRemainOnChanParams.u32ListenSessionID,
|
|
|
|
duration, chan->hw_value,
|
|
|
|
WILC_WFI_RemainOnChannelExpired,
|
|
|
|
WILC_WFI_RemainOnChannelReady, (void *)priv);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:26 +00:00
|
|
|
static int cancel_remain_on_channel(struct wiphy *wiphy,
|
|
|
|
struct wireless_dev *wdev,
|
|
|
|
u64 cookie)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_listen_state_expired(vif, priv->strRemainOnChanParams.u32ListenSessionID);
|
2015-05-11 05:30:56 +00:00
|
|
|
return s32Error;
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-09-22 09:34:51 +00:00
|
|
|
static int mgmt_tx(struct wiphy *wiphy,
|
|
|
|
struct wireless_dev *wdev,
|
|
|
|
struct cfg80211_mgmt_tx_params *params,
|
|
|
|
u64 *cookie)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_channel *chan = params->chan;
|
|
|
|
unsigned int wait = params->wait;
|
|
|
|
const u8 *buf = params->buf;
|
|
|
|
size_t len = params->len;
|
|
|
|
const struct ieee80211_mgmt *mgmt;
|
|
|
|
struct p2p_mgmt_data *mgmt_tx;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-10-12 07:55:35 +00:00
|
|
|
struct host_if_drv *pstrWFIDrv;
|
2015-06-11 05:35:55 +00:00
|
|
|
u32 i;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-11-19 06:56:18 +00:00
|
|
|
u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(wdev->netdev);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2016-02-04 09:15:32 +00:00
|
|
|
pstrWFIDrv = (struct host_if_drv *)priv->hif_drv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
*cookie = (unsigned long)buf;
|
|
|
|
priv->u64tx_cookie = *cookie;
|
|
|
|
mgmt = (const struct ieee80211_mgmt *) buf;
|
|
|
|
|
|
|
|
if (ieee80211_is_mgmt(mgmt->frame_control)) {
|
2015-09-10 03:03:04 +00:00
|
|
|
mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
|
2016-02-04 09:15:55 +00:00
|
|
|
if (!mgmt_tx)
|
2015-09-16 09:36:03 +00:00
|
|
|
return -EFAULT;
|
2016-02-04 09:15:55 +00:00
|
|
|
|
2015-09-10 03:03:04 +00:00
|
|
|
mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
|
2016-02-04 09:15:55 +00:00
|
|
|
if (!mgmt_tx->buff)
|
2015-09-07 10:09:31 +00:00
|
|
|
kfree(mgmt_tx);
|
2015-09-16 09:36:03 +00:00
|
|
|
return -EFAULT;
|
2016-02-04 09:15:55 +00:00
|
|
|
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(mgmt_tx->buff, buf, len);
|
2015-05-11 05:30:56 +00:00
|
|
|
mgmt_tx->size = len;
|
|
|
|
|
|
|
|
|
|
|
|
if (ieee80211_is_probe_resp(mgmt->frame_control)) {
|
|
|
|
PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
|
|
|
|
PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_set_mac_chnl_num(vif, chan->hw_value);
|
2015-10-02 07:41:21 +00:00
|
|
|
curr_channel = chan->hw_value;
|
2015-05-11 05:30:56 +00:00
|
|
|
} else if (ieee80211_is_action(mgmt->frame_control)) {
|
2015-06-11 05:35:54 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
|
|
|
|
if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
|
|
|
|
buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
|
|
|
|
PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_set_mac_chnl_num(vif,
|
|
|
|
chan->hw_value);
|
2015-10-02 07:41:21 +00:00
|
|
|
curr_channel = chan->hw_value;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
switch (buf[ACTION_SUBTYPE_ID]) {
|
|
|
|
case GAS_INTIAL_REQ:
|
|
|
|
{
|
|
|
|
PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GAS_INTIAL_RSP:
|
|
|
|
{
|
|
|
|
PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PUBLIC_ACT_VENDORSPEC:
|
|
|
|
{
|
2015-11-19 06:56:15 +00:00
|
|
|
if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
|
2015-11-19 06:56:17 +00:00
|
|
|
if (p2p_local_random == 1 && p2p_recv_random < p2p_local_random) {
|
2015-11-19 06:56:16 +00:00
|
|
|
get_random_bytes(&p2p_local_random, 1);
|
|
|
|
p2p_local_random++;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
|
|
|
|
|| buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
|
2015-11-19 06:56:17 +00:00
|
|
|
if (p2p_local_random > p2p_recv_random) {
|
|
|
|
PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
|
2015-11-19 06:56:15 +00:00
|
|
|
if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buf[i + 2], 4))) {
|
2015-05-11 05:30:56 +00:00
|
|
|
if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
|
2015-12-21 05:18:36 +00:00
|
|
|
WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, vif->iftype);
|
2015-05-11 05:30:56 +00:00
|
|
|
else
|
2015-12-21 05:18:36 +00:00
|
|
|
WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, vif->iftype);
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
|
2015-11-19 06:56:18 +00:00
|
|
|
memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, sizeof(p2p_vendor_spec));
|
|
|
|
mgmt_tx->buff[len + sizeof(p2p_vendor_spec)] = p2p_local_random;
|
2015-05-11 05:30:56 +00:00
|
|
|
mgmt_tx->size = buf_len;
|
|
|
|
}
|
2015-11-19 06:56:16 +00:00
|
|
|
} else {
|
2015-11-19 06:56:17 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random);
|
2015-11-19 06:56:16 +00:00
|
|
|
}
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
|
2015-10-29 03:05:39 +00:00
|
|
|
pstrWFIDrv->p2p_timeout = (jiffies + msecs_to_jiffies(wait));
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:39 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n",
|
|
|
|
jiffies, pstrWFIDrv->p2p_timeout);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-29 03:18:44 +00:00
|
|
|
wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx,
|
|
|
|
mgmt_tx->buff, mgmt_tx->size,
|
2015-10-01 07:03:43 +00:00
|
|
|
WILC_WFI_mgmt_tx_complete);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
|
|
|
PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
|
|
|
|
}
|
2015-10-12 07:55:38 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-22 09:34:50 +00:00
|
|
|
static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
|
|
|
|
struct wireless_dev *wdev,
|
|
|
|
u64 cookie)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-10-12 07:55:35 +00:00
|
|
|
struct host_if_drv *pstrWFIDrv;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2016-02-04 09:15:32 +00:00
|
|
|
pstrWFIDrv = (struct host_if_drv *)priv->hif_drv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
|
2015-10-29 03:05:39 +00:00
|
|
|
pstrWFIDrv->p2p_timeout = jiffies;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-16 15:32:26 +00:00
|
|
|
if (!priv->bInP2PlistenState) {
|
2015-05-11 05:30:56 +00:00
|
|
|
cfg80211_remain_on_channel_expired(priv->wdev,
|
|
|
|
priv->strRemainOnChanParams.u64ListenCookie,
|
|
|
|
priv->strRemainOnChanParams.pstrListenChan,
|
|
|
|
GFP_KERNEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-20 06:51:16 +00:00
|
|
|
void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|
|
|
u16 frame_type, bool reg)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-10-20 08:14:01 +00:00
|
|
|
struct wilc *wl;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(priv->wdev->netdev);
|
|
|
|
wl = vif->wilc;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
if (!frame_type)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
|
|
|
|
switch (frame_type) {
|
|
|
|
case PROBE_REQ:
|
|
|
|
{
|
2015-12-21 05:18:36 +00:00
|
|
|
vif->g_struct_frame_reg[0].frame_type = frame_type;
|
|
|
|
vif->g_struct_frame_reg[0].reg = reg;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACTION:
|
|
|
|
{
|
2015-12-21 05:18:36 +00:00
|
|
|
vif->g_struct_frame_reg[1].frame_type = frame_type;
|
|
|
|
vif->g_struct_frame_reg[1].reg = reg;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-10-20 08:14:01 +00:00
|
|
|
if (!wl->initialized) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
|
|
|
|
return;
|
|
|
|
}
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_frame_register(vif, frame_type, reg);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-22 09:34:48 +00:00
|
|
|
static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
s32 rssi_thold, u32 rssi_hyst)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-09-14 03:24:19 +00:00
|
|
|
static int dump_station(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
int idx, u8 *mac, struct station_info *sinfo)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Dumping station information\n");
|
|
|
|
|
|
|
|
if (idx != 0)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_get_rssi(vif, &sinfo->signal);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-22 09:34:46 +00:00
|
|
|
static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
bool enabled, int timeout)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
|
|
|
|
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!wiphy)
|
2015-05-11 05:30:56 +00:00
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2016-02-04 09:15:55 +00:00
|
|
|
if (!priv->hif_drv)
|
2015-05-11 05:30:56 +00:00
|
|
|
return -EIO;
|
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
if (wilc_enable_ps)
|
2015-12-21 05:18:40 +00:00
|
|
|
wilc_set_power_mgmt(vif, enabled, timeout);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
2015-09-16 09:36:03 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
2015-09-16 09:53:20 +00:00
|
|
|
|
2015-09-14 03:24:11 +00:00
|
|
|
static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
enum nl80211_iftype type, u32 *flags, struct vif_params *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-10-20 08:13:56 +00:00
|
|
|
struct wilc *wl;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
wl = vif->wilc;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
|
|
|
|
PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
|
2015-11-19 06:56:16 +00:00
|
|
|
p2p_local_random = 0x01;
|
2015-11-19 06:56:17 +00:00
|
|
|
p2p_recv_random = 0x00;
|
2015-11-19 06:56:19 +00:00
|
|
|
wilc_ie = false;
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_optaining_ip = false;
|
|
|
|
del_timer(&wilc_during_ip_timer);
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
switch (type) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_connecting = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
|
|
|
|
|
|
|
|
dev->ieee80211_ptr->iftype = type;
|
|
|
|
priv->wdev->iftype = type;
|
2015-12-21 05:18:36 +00:00
|
|
|
vif->monitor_flag = 0;
|
|
|
|
vif->iftype = STATION_MODE;
|
2016-01-25 07:35:17 +00:00
|
|
|
wilc_set_operation_mode(vif, STATION_MODE);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
|
|
|
|
|
2016-01-25 07:35:17 +00:00
|
|
|
wilc_enable_ps = true;
|
|
|
|
wilc_set_power_mgmt(vif, 1, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_connecting = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
|
|
|
|
|
|
|
|
dev->ieee80211_ptr->iftype = type;
|
|
|
|
priv->wdev->iftype = type;
|
2015-12-21 05:18:36 +00:00
|
|
|
vif->monitor_flag = 0;
|
|
|
|
vif->iftype = CLIENT_MODE;
|
2016-01-25 07:35:17 +00:00
|
|
|
wilc_set_operation_mode(vif, STATION_MODE);
|
2016-01-25 07:35:18 +00:00
|
|
|
|
|
|
|
wilc_enable_ps = false;
|
|
|
|
wilc_set_power_mgmt(vif, 0, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NL80211_IFTYPE_AP:
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_enable_ps = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
|
|
|
|
dev->ieee80211_ptr->iftype = type;
|
|
|
|
priv->wdev->iftype = type;
|
2015-12-21 05:18:36 +00:00
|
|
|
vif->iftype = AP_MODE;
|
2016-01-25 07:35:17 +00:00
|
|
|
|
|
|
|
if (wl->initialized) {
|
2016-02-04 09:15:18 +00:00
|
|
|
wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif),
|
|
|
|
0);
|
2016-01-25 07:35:17 +00:00
|
|
|
wilc_set_operation_mode(vif, AP_MODE);
|
|
|
|
wilc_set_power_mgmt(vif, 0, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
|
|
|
PRINT_D(GENERIC_DBG, "start duringIP timer\n");
|
|
|
|
|
2015-11-16 14:04:54 +00:00
|
|
|
wilc_optaining_ip = true;
|
2015-11-19 06:56:20 +00:00
|
|
|
mod_timer(&wilc_during_ip_timer,
|
|
|
|
jiffies + msecs_to_jiffies(during_ip_time));
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
|
2016-01-25 07:35:17 +00:00
|
|
|
|
|
|
|
wilc_set_operation_mode(vif, AP_MODE);
|
2015-05-11 05:30:56 +00:00
|
|
|
dev->ieee80211_ptr->iftype = type;
|
|
|
|
priv->wdev->iftype = type;
|
2015-12-21 05:18:36 +00:00
|
|
|
vif->iftype = GO_MODE;
|
2016-01-25 07:35:18 +00:00
|
|
|
|
|
|
|
wilc_enable_ps = false;
|
|
|
|
wilc_set_power_mgmt(vif, 0, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Unknown interface type= %d\n", type);
|
2015-10-12 07:55:38 +00:00
|
|
|
return -EINVAL;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 07:55:38 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:12 +00:00
|
|
|
static int start_ap(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
struct cfg80211_ap_settings *settings)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
struct cfg80211_beacon_data *beacon = &(settings->beacon);
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-10-20 08:14:02 +00:00
|
|
|
struct wilc *wl;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
|
|
|
wl = vif ->wilc;
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Starting ap\n");
|
|
|
|
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
|
2015-05-11 05:30:56 +00:00
|
|
|
settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
|
|
|
|
|
2015-09-14 03:24:01 +00:00
|
|
|
s32Error = set_channel(wiphy, &settings->chandef);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-16 09:36:03 +00:00
|
|
|
if (s32Error != 0)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Error in setting channel\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-02-04 09:15:39 +00:00
|
|
|
wilc_wlan_set_bssid(dev, wl->vif[vif->idx]->src_addr, AP_MODE);
|
2016-02-04 09:15:25 +00:00
|
|
|
wilc_set_power_mgmt(vif, 0, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_add_beacon(vif, settings->beacon_interval,
|
|
|
|
settings->dtim_period, beacon->head_len,
|
|
|
|
(u8 *)beacon->head, beacon->tail_len,
|
|
|
|
(u8 *)beacon->tail);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:13 +00:00
|
|
|
static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
struct cfg80211_beacon_data *beacon)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
|
|
|
|
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_add_beacon(vif, 0, 0, beacon->head_len,
|
|
|
|
(u8 *)beacon->head, beacon->tail_len,
|
|
|
|
(u8 *)beacon->tail);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:14 +00:00
|
|
|
static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-06-02 05:16:04 +00:00
|
|
|
u8 NullBssid[ETH_ALEN] = {0};
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-16 09:35:59 +00:00
|
|
|
if (!wiphy)
|
|
|
|
return -EFAULT;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
|
|
|
|
|
2016-01-25 07:35:15 +00:00
|
|
|
wilc_wlan_set_bssid(dev, NullBssid, AP_MODE);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_del_beacon(vif);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-16 09:36:00 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Host delete beacon fail\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:15 +00:00
|
|
|
static int add_station(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
const u8 *mac, struct station_parameters *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-09-21 03:16:46 +00:00
|
|
|
struct add_sta_param strStaParams = { {0} };
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-16 09:35:59 +00:00
|
|
|
if (!wiphy)
|
|
|
|
return -EFAULT;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
|
2015-10-29 03:05:41 +00:00
|
|
|
memcpy(strStaParams.bssid, mac, ETH_ALEN);
|
2015-08-10 02:33:19 +00:00
|
|
|
memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
|
2015-10-29 03:05:42 +00:00
|
|
|
strStaParams.aid = params->aid;
|
2015-10-29 03:05:43 +00:00
|
|
|
strStaParams.rates_len = params->supported_rates_len;
|
2015-10-29 03:05:44 +00:00
|
|
|
strStaParams.rates = params->supported_rates;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4],
|
|
|
|
priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
|
2015-10-29 03:05:42 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid);
|
2015-10-29 03:05:43 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n",
|
|
|
|
strStaParams.rates_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!params->ht_capa) {
|
2015-10-29 03:05:45 +00:00
|
|
|
strStaParams.ht_supported = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
2015-10-29 03:05:45 +00:00
|
|
|
strStaParams.ht_supported = true;
|
2015-10-29 03:05:46 +00:00
|
|
|
strStaParams.ht_capa_info = params->ht_capa->cap_info;
|
2015-10-29 03:05:47 +00:00
|
|
|
strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info;
|
2015-10-29 03:05:48 +00:00
|
|
|
memcpy(strStaParams.ht_supp_mcs_set,
|
|
|
|
¶ms->ht_capa->mcs,
|
|
|
|
WILC_SUPP_MCS_SET_SIZE);
|
2015-10-29 03:05:49 +00:00
|
|
|
strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info;
|
2015-10-29 03:05:50 +00:00
|
|
|
strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info;
|
2015-10-29 03:05:51 +00:00
|
|
|
strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-29 03:05:52 +00:00
|
|
|
strStaParams.flags_mask = params->sta_flags_mask;
|
2015-10-29 03:05:53 +00:00
|
|
|
strStaParams.flags_set = params->sta_flags_set;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:45 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n",
|
|
|
|
strStaParams.ht_supported);
|
2015-10-29 03:05:46 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n",
|
|
|
|
strStaParams.ht_capa_info);
|
2015-10-29 03:05:47 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n",
|
|
|
|
strStaParams.ht_ampdu_params);
|
2015-10-29 03:05:49 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n",
|
|
|
|
strStaParams.ht_ext_params);
|
2015-10-29 03:05:50 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n",
|
|
|
|
strStaParams.ht_tx_bf_cap);
|
2015-10-29 03:05:51 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n",
|
|
|
|
strStaParams.ht_ante_sel);
|
2015-10-29 03:05:52 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n",
|
|
|
|
strStaParams.flags_mask);
|
2015-10-29 03:05:53 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n",
|
|
|
|
strStaParams.flags_set);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_add_station(vif, &strStaParams);
|
2015-09-16 09:36:00 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Host add station fail\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:16 +00:00
|
|
|
static int del_station(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
struct station_del_parameters *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-06-01 19:06:44 +00:00
|
|
|
const u8 *mac = params->mac;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-09-16 09:35:59 +00:00
|
|
|
if (!wiphy)
|
|
|
|
return -EFAULT;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Deleting station\n");
|
|
|
|
|
|
|
|
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!mac) {
|
2015-08-08 12:11:35 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "All associated stations\n");
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_del_allstation(vif,
|
|
|
|
priv->assoc_stainfo.au8Sta_AssociatedBss);
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
|
|
|
PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
|
|
|
}
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_del_station(vif, mac);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-16 09:36:00 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Host delete station fail\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-14 03:24:17 +00:00
|
|
|
static int change_station(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
const u8 *mac, struct station_parameters *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-09-21 03:16:46 +00:00
|
|
|
struct add_sta_param strStaParams = { {0} };
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
|
|
|
|
|
2015-09-16 09:35:59 +00:00
|
|
|
if (!wiphy)
|
|
|
|
return -EFAULT;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) {
|
2015-10-29 03:05:41 +00:00
|
|
|
memcpy(strStaParams.bssid, mac, ETH_ALEN);
|
2015-10-29 03:05:42 +00:00
|
|
|
strStaParams.aid = params->aid;
|
2015-10-29 03:05:43 +00:00
|
|
|
strStaParams.rates_len = params->supported_rates_len;
|
2015-10-29 03:05:44 +00:00
|
|
|
strStaParams.rates = params->supported_rates;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:41 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n",
|
|
|
|
strStaParams.bssid[0], strStaParams.bssid[1],
|
|
|
|
strStaParams.bssid[2], strStaParams.bssid[3],
|
|
|
|
strStaParams.bssid[4], strStaParams.bssid[5]);
|
2015-10-29 03:05:42 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid);
|
2015-10-29 03:05:43 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n",
|
|
|
|
strStaParams.rates_len);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!params->ht_capa) {
|
2015-10-29 03:05:45 +00:00
|
|
|
strStaParams.ht_supported = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
} else {
|
2015-10-29 03:05:45 +00:00
|
|
|
strStaParams.ht_supported = true;
|
2015-10-29 03:05:46 +00:00
|
|
|
strStaParams.ht_capa_info = params->ht_capa->cap_info;
|
2015-10-29 03:05:47 +00:00
|
|
|
strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info;
|
2015-10-29 03:05:48 +00:00
|
|
|
memcpy(strStaParams.ht_supp_mcs_set,
|
|
|
|
¶ms->ht_capa->mcs,
|
|
|
|
WILC_SUPP_MCS_SET_SIZE);
|
2015-10-29 03:05:49 +00:00
|
|
|
strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info;
|
2015-10-29 03:05:50 +00:00
|
|
|
strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info;
|
2015-10-29 03:05:51 +00:00
|
|
|
strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-29 03:05:52 +00:00
|
|
|
strStaParams.flags_mask = params->sta_flags_mask;
|
2015-10-29 03:05:53 +00:00
|
|
|
strStaParams.flags_set = params->sta_flags_set;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-10-29 03:05:45 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n",
|
|
|
|
strStaParams.ht_supported);
|
2015-10-29 03:05:46 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n",
|
|
|
|
strStaParams.ht_capa_info);
|
2015-10-29 03:05:47 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n",
|
|
|
|
strStaParams.ht_ampdu_params);
|
2015-10-29 03:05:49 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n",
|
|
|
|
strStaParams.ht_ext_params);
|
2015-10-29 03:05:50 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n",
|
|
|
|
strStaParams.ht_tx_bf_cap);
|
2015-10-29 03:05:51 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n",
|
|
|
|
strStaParams.ht_ante_sel);
|
2015-10-29 03:05:52 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n",
|
|
|
|
strStaParams.flags_mask);
|
2015-10-29 03:05:53 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n",
|
|
|
|
strStaParams.flags_set);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_edit_station(vif, &strStaParams);
|
2015-09-16 09:36:00 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(dev, "Host edit station fail\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-22 09:34:52 +00:00
|
|
|
static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
|
|
|
|
const char *name,
|
|
|
|
unsigned char name_assign_type,
|
|
|
|
enum nl80211_iftype type,
|
|
|
|
u32 *flags,
|
|
|
|
struct vif_params *params)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-12-21 05:18:36 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct net_device *new_ifc = NULL;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wiphy_priv(wiphy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
|
|
|
|
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(priv->wdev->netdev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (type == NL80211_IFTYPE_MONITOR) {
|
|
|
|
PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
|
2015-12-21 05:18:38 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", vif->ndev);
|
|
|
|
new_ifc = WILC_WFI_init_mon_interface(name, vif->ndev);
|
2015-12-21 05:18:23 +00:00
|
|
|
if (new_ifc) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
|
2015-12-21 05:18:36 +00:00
|
|
|
vif = netdev_priv(priv->wdev->netdev);
|
|
|
|
vif->monitor_flag = 1;
|
2016-02-04 09:15:55 +00:00
|
|
|
}
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
return priv->wdev;
|
|
|
|
}
|
|
|
|
|
2015-09-22 09:34:49 +00:00
|
|
|
static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
|
2015-09-16 09:36:03 +00:00
|
|
|
return 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
|
2016-01-25 07:35:10 +00:00
|
|
|
static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow)
|
|
|
|
{
|
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
|
|
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
|
|
|
|
|
|
|
if (!wow && wilc_wlan_get_num_conn_ifcs(vif->wilc))
|
|
|
|
vif->wilc->suspend_event = true;
|
|
|
|
else
|
|
|
|
vif->wilc->suspend_event = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wilc_resume(struct wiphy *wiphy)
|
|
|
|
{
|
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
|
|
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
|
|
|
|
|
|
|
netdev_info(vif->ndev, "cfg resume\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled)
|
|
|
|
{
|
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
|
|
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
|
|
|
|
|
|
|
netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled);
|
|
|
|
}
|
|
|
|
|
2016-02-04 09:15:27 +00:00
|
|
|
static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|
|
|
enum nl80211_tx_power_setting type, int mbm)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
s32 tx_power = MBM_TO_DBM(mbm);
|
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
|
|
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
|
|
|
|
|
|
|
if (tx_power < 0)
|
|
|
|
tx_power = 0;
|
|
|
|
else if (tx_power > 18)
|
|
|
|
tx_power = 18;
|
|
|
|
ret = wilc_set_tx_power(vif, tx_power);
|
|
|
|
if (ret)
|
|
|
|
netdev_err(vif->ndev, "Failed to set tx power\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
|
|
|
|
int *dbm)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct wilc_priv *priv = wiphy_priv(wiphy);
|
|
|
|
struct wilc_vif *vif = netdev_priv(priv->dev);
|
|
|
|
|
|
|
|
ret = wilc_get_tx_power(vif, (u8 *)dbm);
|
|
|
|
if (ret)
|
|
|
|
netdev_err(vif->ndev, "Failed to get tx power\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-09-15 05:06:12 +00:00
|
|
|
static struct cfg80211_ops wilc_cfg80211_ops = {
|
2015-09-14 03:24:01 +00:00
|
|
|
.set_monitor_channel = set_channel,
|
2015-09-14 03:24:02 +00:00
|
|
|
.scan = scan,
|
2015-09-14 03:24:03 +00:00
|
|
|
.connect = connect,
|
2015-09-14 03:24:04 +00:00
|
|
|
.disconnect = disconnect,
|
2015-09-14 03:24:05 +00:00
|
|
|
.add_key = add_key,
|
2015-09-14 03:24:06 +00:00
|
|
|
.del_key = del_key,
|
2015-09-14 03:24:07 +00:00
|
|
|
.get_key = get_key,
|
2015-09-14 03:24:08 +00:00
|
|
|
.set_default_key = set_default_key,
|
2015-09-14 03:24:09 +00:00
|
|
|
.add_virtual_intf = add_virtual_intf,
|
2015-09-14 03:24:10 +00:00
|
|
|
.del_virtual_intf = del_virtual_intf,
|
2015-09-14 03:24:11 +00:00
|
|
|
.change_virtual_intf = change_virtual_intf,
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-14 03:24:12 +00:00
|
|
|
.start_ap = start_ap,
|
2015-09-14 03:24:13 +00:00
|
|
|
.change_beacon = change_beacon,
|
2015-09-14 03:24:14 +00:00
|
|
|
.stop_ap = stop_ap,
|
2015-09-14 03:24:15 +00:00
|
|
|
.add_station = add_station,
|
2015-09-14 03:24:16 +00:00
|
|
|
.del_station = del_station,
|
2015-09-14 03:24:17 +00:00
|
|
|
.change_station = change_station,
|
2015-09-14 03:24:18 +00:00
|
|
|
.get_station = get_station,
|
2015-09-14 03:24:19 +00:00
|
|
|
.dump_station = dump_station,
|
2015-09-14 03:24:20 +00:00
|
|
|
.change_bss = change_bss,
|
2015-09-14 03:24:21 +00:00
|
|
|
.set_wiphy_params = set_wiphy_params,
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-14 03:24:22 +00:00
|
|
|
.set_pmksa = set_pmksa,
|
2015-09-14 03:24:23 +00:00
|
|
|
.del_pmksa = del_pmksa,
|
2015-09-14 03:24:24 +00:00
|
|
|
.flush_pmksa = flush_pmksa,
|
2015-09-14 03:24:25 +00:00
|
|
|
.remain_on_channel = remain_on_channel,
|
2015-09-14 03:24:26 +00:00
|
|
|
.cancel_remain_on_channel = cancel_remain_on_channel,
|
2015-09-14 03:24:27 +00:00
|
|
|
.mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
|
2015-09-14 03:24:28 +00:00
|
|
|
.mgmt_tx = mgmt_tx,
|
2015-09-20 06:51:16 +00:00
|
|
|
.mgmt_frame_register = wilc_mgmt_frame_register,
|
2015-09-22 09:34:46 +00:00
|
|
|
.set_power_mgmt = set_power_mgmt,
|
2015-09-22 09:34:48 +00:00
|
|
|
.set_cqm_rssi_config = set_cqm_rssi_config,
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2016-01-25 07:35:10 +00:00
|
|
|
.suspend = wilc_suspend,
|
|
|
|
.resume = wilc_resume,
|
|
|
|
.set_wakeup = wilc_set_wakeup,
|
2016-02-04 09:15:27 +00:00
|
|
|
.set_tx_power = set_tx_power,
|
|
|
|
.get_tx_power = get_tx_power,
|
2016-01-25 07:35:10 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
|
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
priv = wiphy_priv(wiphy);
|
|
|
|
switch (changed) {
|
|
|
|
case WILC_WFI_RX_PKT:
|
|
|
|
{
|
|
|
|
priv->netstats.rx_packets++;
|
|
|
|
priv->netstats.rx_bytes += pktlen;
|
|
|
|
priv->netstats.rx_time = get_jiffies_64();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WILC_WFI_TX_PKT:
|
|
|
|
{
|
|
|
|
priv->netstats.tx_packets++;
|
|
|
|
priv->netstats.tx_bytes += pktlen;
|
|
|
|
priv->netstats.tx_time = get_jiffies_64();
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-16 14:04:53 +00:00
|
|
|
static struct wireless_dev *WILC_WFI_CfgAlloc(void)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
|
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
|
2016-02-04 09:15:55 +00:00
|
|
|
if (!wdev)
|
2015-05-11 05:30:56 +00:00
|
|
|
goto _fail_;
|
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
|
2016-02-04 09:15:55 +00:00
|
|
|
if (!wdev->wiphy)
|
2015-05-11 05:30:56 +00:00
|
|
|
goto _fail_mem_;
|
|
|
|
|
|
|
|
WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
|
|
|
|
WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
|
|
|
|
WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
|
|
|
|
WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
|
|
|
|
WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
|
|
|
|
|
|
|
|
wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
|
|
|
|
|
|
|
|
return wdev;
|
|
|
|
|
|
|
|
_fail_mem_:
|
|
|
|
kfree(wdev);
|
|
|
|
_fail_:
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-11-16 14:05:03 +00:00
|
|
|
struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *dev)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
struct wireless_dev *wdev;
|
2015-09-16 09:36:03 +00:00
|
|
|
s32 s32Error = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(CFG80211_DBG, "Registering wifi device\n");
|
|
|
|
|
|
|
|
wdev = WILC_WFI_CfgAlloc();
|
2015-12-21 05:18:23 +00:00
|
|
|
if (!wdev) {
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(net, "wiphy new allocate failed\n");
|
2015-05-11 05:30:56 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = wdev_priv(wdev);
|
2015-06-01 19:06:43 +00:00
|
|
|
sema_init(&(priv->SemHandleUpdateStats), 1);
|
2015-05-11 05:30:56 +00:00
|
|
|
priv->wdev = wdev;
|
|
|
|
wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
|
2016-02-05 09:56:54 +00:00
|
|
|
#ifdef CONFIG_PM
|
2016-01-25 07:35:10 +00:00
|
|
|
wdev->wiphy->wowlan = &wowlan_support;
|
2016-02-05 09:56:54 +00:00
|
|
|
#endif
|
2015-05-11 05:30:56 +00:00
|
|
|
wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
|
|
|
|
|
|
|
|
wdev->wiphy->max_scan_ie_len = 1000;
|
|
|
|
wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
|
|
|
|
wdev->wiphy->cipher_suites = cipher_suites;
|
|
|
|
wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
|
|
|
|
wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
|
|
|
|
|
|
|
|
wdev->wiphy->max_remain_on_channel_duration = 500;
|
|
|
|
wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
|
|
|
|
BIT(NL80211_IFTYPE_P2P_CLIENT);
|
|
|
|
wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
|
|
|
|
wdev->iftype = NL80211_IFTYPE_STATION;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
|
|
|
|
wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
|
|
|
|
wdev->wiphy->interface_modes, wdev->iftype);
|
|
|
|
|
2015-11-16 14:05:03 +00:00
|
|
|
set_wiphy_dev(wdev->wiphy, dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
s32Error = wiphy_register(wdev->wiphy);
|
2016-02-04 09:15:55 +00:00
|
|
|
if (s32Error)
|
|
|
|
netdev_err(net, "Cannot register wiphy device\n");
|
|
|
|
else
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(CFG80211_DBG, "Successful Registering\n");
|
|
|
|
|
|
|
|
priv->dev = net;
|
|
|
|
return wdev;
|
|
|
|
}
|
2015-11-25 02:59:41 +00:00
|
|
|
|
2015-09-20 06:51:25 +00:00
|
|
|
int wilc_init_host_int(struct net_device *net)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-20 06:51:23 +00:00
|
|
|
int s32Error = 0;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
|
|
|
|
priv = wdev_priv(net->ieee80211_ptr);
|
|
|
|
if (op_ifcs == 0) {
|
2015-08-15 03:28:32 +00:00
|
|
|
setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
|
2015-11-16 14:04:54 +00:00
|
|
|
setup_timer(&wilc_during_ip_timer, clear_duringIP, 0);
|
2015-05-11 05:30:56 +00:00
|
|
|
}
|
|
|
|
op_ifcs++;
|
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->gbAutoRateAdjusted = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->bInP2PlistenState = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-01 19:06:43 +00:00
|
|
|
sema_init(&(priv->hSemScanReq), 1);
|
2016-02-04 09:15:32 +00:00
|
|
|
s32Error = wilc_init(net, &priv->hif_drv);
|
2015-09-20 06:51:22 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(net, "Error while initializing hostinterface\n");
|
2015-09-20 06:51:22 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-20 06:51:24 +00:00
|
|
|
int wilc_deinit_host_int(struct net_device *net)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
2015-09-20 06:51:23 +00:00
|
|
|
int s32Error = 0;
|
2015-12-21 05:18:39 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-09-15 05:06:13 +00:00
|
|
|
struct wilc_priv *priv;
|
2015-08-18 14:18:11 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
priv = wdev_priv(net->ieee80211_ptr);
|
2015-12-21 05:18:39 +00:00
|
|
|
vif = netdev_priv(priv->dev);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->gbAutoRateAdjusted = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-06-12 05:11:44 +00:00
|
|
|
priv->bInP2PlistenState = false;
|
2015-05-11 05:30:56 +00:00
|
|
|
|
|
|
|
op_ifcs--;
|
|
|
|
|
2015-12-21 05:18:40 +00:00
|
|
|
s32Error = wilc_deinit(vif);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-11-19 06:56:22 +00:00
|
|
|
clear_shadow_scan();
|
2016-02-04 09:24:03 +00:00
|
|
|
if (op_ifcs == 0)
|
2015-11-16 14:04:54 +00:00
|
|
|
del_timer_sync(&wilc_during_ip_timer);
|
2015-05-11 05:30:56 +00:00
|
|
|
|
2015-09-20 06:51:22 +00:00
|
|
|
if (s32Error)
|
2016-02-04 09:15:55 +00:00
|
|
|
netdev_err(net, "Error while deintializing host interface\n");
|
2015-09-20 06:51:22 +00:00
|
|
|
|
2015-05-11 05:30:56 +00:00
|
|
|
return s32Error;
|
|
|
|
}
|
|
|
|
|
2015-09-20 06:51:08 +00:00
|
|
|
void wilc_free_wiphy(struct net_device *net)
|
2015-05-11 05:30:56 +00:00
|
|
|
{
|
|
|
|
PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
|
|
|
|
|
2015-09-20 06:51:10 +00:00
|
|
|
if (!net) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(INIT_DBG, "net_device is NULL\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-20 06:51:10 +00:00
|
|
|
if (!net->ieee80211_ptr) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-20 06:51:10 +00:00
|
|
|
if (!net->ieee80211_ptr->wiphy) {
|
2015-05-11 05:30:56 +00:00
|
|
|
PRINT_D(INIT_DBG, "wiphy is NULL\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wiphy_unregister(net->ieee80211_ptr->wiphy);
|
|
|
|
|
|
|
|
PRINT_D(INIT_DBG, "Freeing wiphy\n");
|
|
|
|
wiphy_free(net->ieee80211_ptr->wiphy);
|
|
|
|
kfree(net->ieee80211_ptr);
|
|
|
|
}
|