License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 15:07:57 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2018-08-03 16:26:13 +05:30
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-11-05 09:51:25 +00:00
|
|
|
#include "netdev.h"
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-20 19:54:55 +00:00
|
|
|
#define WILC_HIF_SCAN_TIMEOUT_MS 5000
|
2019-02-02 19:17:05 +00:00
|
|
|
#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-07 11:29:01 +00:00
|
|
|
#define WILC_FALSE_FRMWR_CHANNEL 100
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2020-05-04 17:09:11 +02:00
|
|
|
#define WILC_SCAN_WID_LIST_SIZE 6
|
|
|
|
|
2019-01-17 13:21:35 +00:00
|
|
|
struct wilc_rcvd_mac_info {
|
|
|
|
u8 status;
|
2015-09-21 12:16:39 +09:00
|
|
|
};
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:41 +00:00
|
|
|
struct wilc_set_multicast {
|
|
|
|
u32 enabled;
|
2015-10-13 20:02:05 +09:00
|
|
|
u32 cnt;
|
2018-09-04 12:09:26 +05:30
|
|
|
u8 *mc_list;
|
2015-09-21 12:16:52 +09:00
|
|
|
};
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2021-09-16 16:49:18 +00:00
|
|
|
struct host_if_wowlan_trigger {
|
|
|
|
u8 wowlan_trigger;
|
|
|
|
};
|
|
|
|
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_del_all_sta {
|
2015-10-13 19:50:10 +09:00
|
|
|
u8 assoc_sta;
|
2018-12-02 18:02:40 +00:00
|
|
|
u8 mac[WILC_MAX_NUM_STA][ETH_ALEN];
|
2015-09-21 12:16:57 +09:00
|
|
|
};
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-07 11:29:01 +00:00
|
|
|
union wilc_message_body {
|
2019-01-17 13:21:21 +00:00
|
|
|
struct wilc_rcvd_net_info net_info;
|
2019-01-17 13:21:35 +00:00
|
|
|
struct wilc_rcvd_mac_info mac_info;
|
2019-01-17 13:21:41 +00:00
|
|
|
struct wilc_set_multicast mc_info;
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_remain_ch remain_on_ch;
|
2015-10-05 13:50:45 +09:00
|
|
|
char *data;
|
2021-09-16 16:49:18 +00:00
|
|
|
struct host_if_wowlan_trigger wow_trigger;
|
2015-09-21 12:16:34 +09:00
|
|
|
};
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-09-18 18:11:04 +09:00
|
|
|
struct host_if_msg {
|
2019-02-07 11:29:01 +00:00
|
|
|
union wilc_message_body body;
|
2015-12-21 14:18:39 +09:00
|
|
|
struct wilc_vif *vif;
|
2016-06-23 11:11:51 +05:30
|
|
|
struct work_struct work;
|
2018-06-26 11:37:03 +05:30
|
|
|
void (*fn)(struct work_struct *ws);
|
2018-06-26 11:37:06 +05:30
|
|
|
struct completion work_comp;
|
|
|
|
bool is_sync;
|
2015-09-18 18:11:04 +09:00
|
|
|
};
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
/* 'msg' should be free by the caller for syc */
|
2018-06-26 11:37:05 +05:30
|
|
|
static struct host_if_msg*
|
2018-06-26 11:37:06 +05:30
|
|
|
wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
|
|
|
|
bool is_sync)
|
2018-06-26 11:37:05 +05:30
|
|
|
{
|
|
|
|
struct host_if_msg *msg;
|
|
|
|
|
|
|
|
if (!work_fun)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
|
|
|
|
if (!msg)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
msg->fn = work_fun;
|
|
|
|
msg->vif = vif;
|
2018-06-26 11:37:06 +05:30
|
|
|
msg->is_sync = is_sync;
|
|
|
|
if (is_sync)
|
|
|
|
init_completion(&msg->work_comp);
|
2018-06-26 11:37:05 +05:30
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
static int wilc_enqueue_work(struct host_if_msg *msg)
|
2016-06-23 11:11:50 +05:30
|
|
|
{
|
2018-06-26 11:37:05 +05:30
|
|
|
INIT_WORK(&msg->work, msg->fn);
|
2018-09-04 12:09:27 +05:30
|
|
|
|
|
|
|
if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!queue_work(msg->vif->wilc->hif_workqueue, &msg->work))
|
2018-06-26 11:37:05 +05:30
|
|
|
return -EINVAL;
|
2016-06-23 11:11:50 +05:30
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-29 11:36:51 +05:30
|
|
|
/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as
|
2015-12-21 14:18:43 +09:00
|
|
|
* special purpose in wilc device, so we add 1 to the index to starts from 1.
|
|
|
|
* As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
|
|
|
|
*/
|
2015-12-21 14:18:44 +09:00
|
|
|
int wilc_get_vif_idx(struct wilc_vif *vif)
|
2015-08-20 16:32:52 +09:00
|
|
|
{
|
2016-02-04 18:15:39 +09:00
|
|
|
return vif->idx + 1;
|
2015-12-21 14:18:43 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We need to minus 1 from idx which is from wilc device to get real index
|
|
|
|
* of wilc->vif[], because we add 1 when pass to wilc device in the function
|
|
|
|
* wilc_get_vif_idx.
|
2018-07-29 11:36:51 +05:30
|
|
|
* As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1).
|
2015-12-21 14:18:43 +09:00
|
|
|
*/
|
|
|
|
static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
|
|
|
|
{
|
|
|
|
int index = idx - 1;
|
2019-09-26 15:14:59 +00:00
|
|
|
struct wilc_vif *vif;
|
2015-12-21 14:18:43 +09:00
|
|
|
|
2018-11-12 05:45:29 +00:00
|
|
|
if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
|
2015-08-20 16:32:52 +09:00
|
|
|
return NULL;
|
2015-12-21 14:18:43 +09:00
|
|
|
|
2019-09-26 15:14:59 +00:00
|
|
|
list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
|
|
|
|
if (vif->idx == index)
|
|
|
|
return vif;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2015-08-20 16:32:52 +09:00
|
|
|
}
|
|
|
|
|
2018-07-19 04:15:17 +05:30
|
|
|
static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
|
2018-07-19 04:15:13 +05:30
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result = 0;
|
2018-07-19 04:15:13 +05:30
|
|
|
u8 abort_running_scan;
|
|
|
|
struct wid wid;
|
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_user_scan_req *scan_req;
|
2018-07-19 04:15:13 +05:30
|
|
|
|
|
|
|
if (evt == SCAN_EVENT_ABORTED) {
|
|
|
|
abort_running_scan = 1;
|
|
|
|
wid.id = WID_ABORT_RUNNING_SCAN;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.val = (s8 *)&abort_running_scan;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-07-19 04:15:13 +05:30
|
|
|
if (result) {
|
|
|
|
netdev_err(vif->ndev, "Failed to set abort running\n");
|
|
|
|
result = -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hif_drv) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
|
2018-07-19 04:15:13 +05:30
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
scan_req = &hif_drv->usr_scan_req;
|
|
|
|
if (scan_req->scan_result) {
|
2019-01-17 13:21:18 +00:00
|
|
|
scan_req->scan_result(evt, NULL, scan_req->arg);
|
2018-07-19 04:15:13 +05:30
|
|
|
scan_req->scan_result = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:38 +00:00
|
|
|
int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
|
2019-03-25 22:27:26 +00:00
|
|
|
u8 *ch_freq_list, u8 ch_list_len,
|
2019-01-17 13:21:44 +00:00
|
|
|
void (*scan_result_fn)(enum scan_event,
|
|
|
|
struct wilc_rcvd_net_info *, void *),
|
2019-03-25 22:27:26 +00:00
|
|
|
void *user_arg, struct cfg80211_scan_request *request)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result = 0;
|
2020-05-04 17:09:11 +02:00
|
|
|
struct wid wid_list[WILC_SCAN_WID_LIST_SIZE];
|
2016-04-04 20:04:49 +09:00
|
|
|
u32 index = 0;
|
2019-06-20 19:54:55 +00:00
|
|
|
u32 i, scan_timeout;
|
2016-04-04 20:04:50 +09:00
|
|
|
u8 *buffer;
|
2015-06-02 14:16:04 +09:00
|
|
|
u8 valuesize = 0;
|
2019-01-17 13:21:30 +00:00
|
|
|
u8 *search_ssid_vals = NULL;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-01-22 15:52:14 +05:30
|
|
|
if (hif_drv->hif_state >= HOST_IF_SCANNING &&
|
|
|
|
hif_drv->hif_state < HOST_IF_CONNECTED) {
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "Already scan\n");
|
2015-10-19 18:26:08 +09:00
|
|
|
result = -EBUSY;
|
2018-03-07 07:43:52 +05:30
|
|
|
goto error;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-07-25 21:31:34 +00:00
|
|
|
if (vif->connecting) {
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "Don't do obss scan\n");
|
2015-10-19 18:26:08 +09:00
|
|
|
result = -EBUSY;
|
2018-03-07 07:43:52 +05:30
|
|
|
goto error;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-07-29 11:36:55 +05:30
|
|
|
hif_drv->usr_scan_req.ch_cnt = 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-03-25 22:27:26 +00:00
|
|
|
if (request->n_ssids) {
|
|
|
|
for (i = 0; i < request->n_ssids; i++)
|
|
|
|
valuesize += ((request->ssids[i].ssid_len) + 1);
|
2019-01-17 13:21:30 +00:00
|
|
|
search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL);
|
|
|
|
if (search_ssid_vals) {
|
|
|
|
wid_list[index].id = WID_SSID_PROBE_REQ;
|
|
|
|
wid_list[index].type = WID_STR;
|
|
|
|
wid_list[index].val = search_ssid_vals;
|
2018-12-15 02:32:29 +00:00
|
|
|
buffer = wid_list[index].val;
|
|
|
|
|
2019-03-25 22:27:26 +00:00
|
|
|
*buffer++ = request->n_ssids;
|
2018-12-15 02:32:29 +00:00
|
|
|
|
2019-03-25 22:27:26 +00:00
|
|
|
for (i = 0; i < request->n_ssids; i++) {
|
|
|
|
*buffer++ = request->ssids[i].ssid_len;
|
|
|
|
memcpy(buffer, request->ssids[i].ssid,
|
|
|
|
request->ssids[i].ssid_len);
|
|
|
|
buffer += request->ssids[i].ssid_len;
|
2018-12-15 02:32:29 +00:00
|
|
|
}
|
|
|
|
wid_list[index].size = (s32)(valuesize + 1);
|
|
|
|
index++;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-04 20:04:49 +09:00
|
|
|
wid_list[index].id = WID_INFO_ELEMENT_PROBE;
|
|
|
|
wid_list[index].type = WID_BIN_DATA;
|
2019-03-25 22:27:26 +00:00
|
|
|
wid_list[index].val = (s8 *)request->ie;
|
|
|
|
wid_list[index].size = request->ie_len;
|
2016-04-04 20:04:49 +09:00
|
|
|
index++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2016-04-04 20:04:49 +09:00
|
|
|
wid_list[index].id = WID_SCAN_TYPE;
|
|
|
|
wid_list[index].type = WID_CHAR;
|
|
|
|
wid_list[index].size = sizeof(char);
|
2018-12-02 18:03:38 +00:00
|
|
|
wid_list[index].val = (s8 *)&scan_type;
|
2016-04-04 20:04:49 +09:00
|
|
|
index++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-20 19:54:55 +00:00
|
|
|
if (scan_type == WILC_FW_PASSIVE_SCAN && request->duration) {
|
|
|
|
wid_list[index].id = WID_PASSIVE_SCAN_TIME;
|
|
|
|
wid_list[index].type = WID_SHORT;
|
|
|
|
wid_list[index].size = sizeof(u16);
|
|
|
|
wid_list[index].val = (s8 *)&request->duration;
|
|
|
|
index++;
|
|
|
|
|
|
|
|
scan_timeout = (request->duration * ch_list_len) + 500;
|
|
|
|
} else {
|
|
|
|
scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS;
|
|
|
|
}
|
|
|
|
|
2016-04-04 20:04:49 +09:00
|
|
|
wid_list[index].id = WID_SCAN_CHANNEL_LIST;
|
|
|
|
wid_list[index].type = WID_BIN_DATA;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:38 +00:00
|
|
|
if (ch_freq_list && ch_list_len > 0) {
|
|
|
|
for (i = 0; i < ch_list_len; i++) {
|
|
|
|
if (ch_freq_list[i] > 0)
|
|
|
|
ch_freq_list[i] -= 1;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:38 +00:00
|
|
|
wid_list[index].val = ch_freq_list;
|
|
|
|
wid_list[index].size = ch_list_len;
|
2016-04-04 20:04:49 +09:00
|
|
|
index++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2016-04-04 20:04:49 +09:00
|
|
|
wid_list[index].id = WID_START_SCAN_REQ;
|
|
|
|
wid_list[index].type = WID_CHAR;
|
|
|
|
wid_list[index].size = sizeof(char);
|
2018-12-02 18:03:38 +00:00
|
|
|
wid_list[index].val = (s8 *)&scan_source;
|
2016-04-04 20:04:49 +09:00
|
|
|
index++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-03-27 20:28:34 +00:00
|
|
|
hif_drv->usr_scan_req.scan_result = scan_result_fn;
|
|
|
|
hif_drv->usr_scan_req.arg = user_arg;
|
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result) {
|
2018-12-02 18:03:38 +00:00
|
|
|
netdev_err(vif->ndev, "Failed to send scan parameters\n");
|
|
|
|
goto error;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:38 +00:00
|
|
|
hif_drv->scan_timer_vif = vif;
|
|
|
|
mod_timer(&hif_drv->scan_timer,
|
2019-06-20 19:54:55 +00:00
|
|
|
jiffies + msecs_to_jiffies(scan_timeout));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:38 +00:00
|
|
|
error:
|
2019-03-25 22:27:26 +00:00
|
|
|
|
|
|
|
kfree(search_ssid_vals);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:38 +00:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:34 +00:00
|
|
|
static int wilc_send_connect_wid(struct wilc_vif *vif)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result = 0;
|
2019-01-29 18:46:42 +00:00
|
|
|
struct wid wid_list[4];
|
|
|
|
u32 wid_cnt = 0;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2019-01-17 13:21:32 +00:00
|
|
|
struct wilc_conn_info *conn_attr = &hif_drv->conn_info;
|
|
|
|
struct wilc_join_bss_param *bss_param = conn_attr->param;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:54 +05:30
|
|
|
wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE;
|
|
|
|
wid_list[wid_cnt].type = WID_BIN_DATA;
|
2019-01-17 13:21:32 +00:00
|
|
|
wid_list[wid_cnt].val = conn_attr->req_ies;
|
|
|
|
wid_list[wid_cnt].size = conn_attr->req_ies_len;
|
2018-03-07 07:43:54 +05:30
|
|
|
wid_cnt++;
|
|
|
|
|
2018-07-19 04:15:12 +05:30
|
|
|
wid_list[wid_cnt].id = WID_11I_MODE;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_list[wid_cnt].type = WID_CHAR;
|
|
|
|
wid_list[wid_cnt].size = sizeof(char);
|
2018-12-02 18:03:34 +00:00
|
|
|
wid_list[wid_cnt].val = (s8 *)&conn_attr->security;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-19 04:15:12 +05:30
|
|
|
wid_list[wid_cnt].id = WID_AUTH_TYPE;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_list[wid_cnt].type = WID_CHAR;
|
|
|
|
wid_list[wid_cnt].size = sizeof(char);
|
2018-12-02 18:03:34 +00:00
|
|
|
wid_list[wid_cnt].val = (s8 *)&conn_attr->auth_type;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-19 04:15:12 +05:30
|
|
|
wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_list[wid_cnt].type = WID_STR;
|
2019-01-17 13:21:27 +00:00
|
|
|
wid_list[wid_cnt].size = sizeof(*bss_param);
|
|
|
|
wid_list[wid_cnt].val = (u8 *)bss_param;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, wid_cnt);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result) {
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "failed to send config packet\n");
|
2018-03-07 07:43:52 +05:30
|
|
|
goto error;
|
2015-05-11 14:30:56 +09:00
|
|
|
} else {
|
2015-10-29 11:58:24 +09:00
|
|
|
hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:34 +00:00
|
|
|
return 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:34 +00:00
|
|
|
error:
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
kfree(conn_attr->req_ies);
|
|
|
|
conn_attr->req_ies = NULL;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:31 +00:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
static void handle_connect_timeout(struct work_struct *work)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-06-26 11:37:03 +05:30
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
|
|
|
struct wilc_vif *vif = msg->vif;
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2015-10-28 15:59:28 +09:00
|
|
|
struct wid wid;
|
2018-03-02 19:52:47 +05:30
|
|
|
u16 dummy_reason_code = 0;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-12 16:56:05 +09:00
|
|
|
if (!hif_drv) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
|
2018-06-26 11:37:03 +05:30
|
|
|
goto out;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-10-29 11:58:24 +09:00
|
|
|
hif_drv->hif_state = HOST_IF_IDLE;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
if (hif_drv->conn_info.conn_result) {
|
|
|
|
hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
|
|
|
|
WILC_MAC_STATUS_DISCONNECTED,
|
2019-01-17 13:21:38 +00:00
|
|
|
hif_drv->conn_info.arg);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
} else {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-07-19 04:15:12 +05:30
|
|
|
wid.id = WID_DISCONNECT;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.type = WID_CHAR;
|
2018-03-02 19:52:47 +05:30
|
|
|
wid.val = (s8 *)&dummy_reason_code;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.size = sizeof(char);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result)
|
2017-06-27 10:29:06 +01:00
|
|
|
netdev_err(vif->ndev, "Failed to send disconnect\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
hif_drv->conn_info.req_ies_len = 0;
|
|
|
|
kfree(hif_drv->conn_info.req_ies);
|
|
|
|
hif_drv->conn_info.req_ies = NULL;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
out:
|
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
|
|
|
|
struct cfg80211_crypto_settings *crypto)
|
2018-07-19 04:15:15 +05:30
|
|
|
{
|
2019-01-17 13:21:27 +00:00
|
|
|
struct wilc_join_bss_param *param;
|
|
|
|
struct ieee80211_p2p_noa_attr noa_attr;
|
|
|
|
u8 rates_len = 0;
|
|
|
|
const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie;
|
|
|
|
const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie;
|
|
|
|
int ret;
|
2019-02-27 09:52:36 -05:00
|
|
|
const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies);
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
param = kzalloc(sizeof(*param), GFP_KERNEL);
|
|
|
|
if (!param)
|
|
|
|
return NULL;
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-02-26 02:25:56 -05:00
|
|
|
param->beacon_period = cpu_to_le16(bss->beacon_interval);
|
|
|
|
param->cap_info = cpu_to_le16(bss->capability);
|
2019-01-17 13:21:27 +00:00
|
|
|
param->bss_type = WILC_FW_BSS_TYPE_INFRA;
|
|
|
|
param->ch = ieee80211_frequency_to_channel(bss->channel->center_freq);
|
|
|
|
ether_addr_copy(param->bssid, bss->bssid);
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len);
|
|
|
|
if (ssid_elm) {
|
|
|
|
if (ssid_elm[1] <= IEEE80211_MAX_SSID_LEN)
|
|
|
|
memcpy(param->ssid, ssid_elm + 2, ssid_elm[1]);
|
|
|
|
}
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len);
|
|
|
|
if (tim_elm && tim_elm[1] >= 2)
|
|
|
|
param->dtim_period = tim_elm[3];
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
memset(param->p_suites, 0xFF, 3);
|
|
|
|
memset(param->akm_suites, 0xFF, 3);
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len);
|
|
|
|
if (rates_ie) {
|
|
|
|
rates_len = rates_ie[1];
|
2019-10-17 12:18:32 +03:00
|
|
|
if (rates_len > WILC_MAX_RATES_SUPPORTED)
|
|
|
|
rates_len = WILC_MAX_RATES_SUPPORTED;
|
2019-01-17 13:21:27 +00:00
|
|
|
param->supp_rates[0] = rates_len;
|
|
|
|
memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len);
|
|
|
|
}
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-11-07 15:58:54 +00:00
|
|
|
if (rates_len < WILC_MAX_RATES_SUPPORTED) {
|
|
|
|
supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES,
|
|
|
|
ies->data, ies->len);
|
|
|
|
if (supp_rates_ie) {
|
|
|
|
u8 ext_rates = supp_rates_ie[1];
|
|
|
|
|
|
|
|
if (ext_rates > (WILC_MAX_RATES_SUPPORTED - rates_len))
|
|
|
|
param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED;
|
|
|
|
else
|
|
|
|
param->supp_rates[0] += ext_rates;
|
|
|
|
|
|
|
|
memcpy(¶m->supp_rates[rates_len + 1],
|
|
|
|
supp_rates_ie + 2,
|
|
|
|
(param->supp_rates[0] - rates_len));
|
|
|
|
}
|
2019-01-17 13:21:27 +00:00
|
|
|
}
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len);
|
|
|
|
if (ht_ie)
|
|
|
|
param->ht_capable = true;
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
ret = cfg80211_get_p2p_attr(ies->data, ies->len,
|
|
|
|
IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
|
|
|
|
(u8 *)&noa_attr, sizeof(noa_attr));
|
|
|
|
if (ret > 0) {
|
|
|
|
param->tsf_lo = cpu_to_le32(ies->tsf);
|
|
|
|
param->noa_enabled = 1;
|
|
|
|
param->idx = noa_attr.index;
|
|
|
|
if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) {
|
|
|
|
param->opp_enabled = 1;
|
|
|
|
param->opp_en.ct_window = noa_attr.oppps_ctwindow;
|
|
|
|
param->opp_en.cnt = noa_attr.desc[0].count;
|
|
|
|
param->opp_en.duration = noa_attr.desc[0].duration;
|
|
|
|
param->opp_en.interval = noa_attr.desc[0].interval;
|
|
|
|
param->opp_en.start_time = noa_attr.desc[0].start_time;
|
|
|
|
} else {
|
|
|
|
param->opp_enabled = 0;
|
|
|
|
param->opp_dis.cnt = noa_attr.desc[0].count;
|
|
|
|
param->opp_dis.duration = noa_attr.desc[0].duration;
|
|
|
|
param->opp_dis.interval = noa_attr.desc[0].interval;
|
|
|
|
param->opp_dis.start_time = noa_attr.desc[0].start_time;
|
2018-07-19 04:15:15 +05:30
|
|
|
}
|
2019-01-17 13:21:27 +00:00
|
|
|
}
|
|
|
|
wmm_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
|
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WMM,
|
|
|
|
ies->data, ies->len);
|
|
|
|
if (wmm_ie) {
|
|
|
|
struct ieee80211_wmm_param_ie *ie;
|
|
|
|
|
|
|
|
ie = (struct ieee80211_wmm_param_ie *)wmm_ie;
|
|
|
|
if ((ie->oui_subtype == 0 || ie->oui_subtype == 1) &&
|
|
|
|
ie->version == 1) {
|
|
|
|
param->wmm_cap = true;
|
|
|
|
if (ie->qos_info & BIT(7))
|
|
|
|
param->uapsd_cap = true;
|
2018-07-19 04:15:15 +05:30
|
|
|
}
|
2019-01-17 13:21:27 +00:00
|
|
|
}
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
|
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WPA,
|
|
|
|
ies->data, ies->len);
|
|
|
|
if (wpa_ie) {
|
|
|
|
param->mode_802_11i = 1;
|
2018-07-19 04:15:15 +05:30
|
|
|
param->rsn_found = true;
|
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies->data, ies->len);
|
|
|
|
if (rsn_ie) {
|
|
|
|
int offset = 8;
|
2019-01-17 13:21:18 +00:00
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
param->mode_802_11i = 2;
|
|
|
|
param->rsn_found = true;
|
2019-11-05 09:51:30 +00:00
|
|
|
/* extract RSN capabilities */
|
2019-01-17 13:21:27 +00:00
|
|
|
offset += (rsn_ie[offset] * 4) + 2;
|
|
|
|
offset += (rsn_ie[offset] * 4) + 2;
|
|
|
|
memcpy(param->rsn_cap, &rsn_ie[offset], 2);
|
2019-01-17 13:21:18 +00:00
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
if (param->rsn_found) {
|
|
|
|
int i;
|
2019-01-17 13:21:18 +00:00
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
param->rsn_grp_policy = crypto->cipher_group & 0xFF;
|
|
|
|
for (i = 0; i < crypto->n_ciphers_pairwise && i < 3; i++)
|
|
|
|
param->p_suites[i] = crypto->ciphers_pairwise[i] & 0xFF;
|
2018-07-19 04:15:15 +05:30
|
|
|
|
2019-01-17 13:21:27 +00:00
|
|
|
for (i = 0; i < crypto->n_akm_suites && i < 3; i++)
|
|
|
|
param->akm_suites[i] = crypto->akm_suites[i] & 0xFF;
|
|
|
|
}
|
2018-07-19 04:15:15 +05:30
|
|
|
|
|
|
|
return (void *)param;
|
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:21 +00:00
|
|
|
static void handle_rcvd_ntwrk_info(struct work_struct *work)
|
2018-11-01 16:45:23 +00:00
|
|
|
{
|
2019-01-17 13:21:21 +00:00
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
|
|
|
struct wilc_rcvd_net_info *rcvd_info = &msg->body.net_info;
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_user_scan_req *scan_req = &msg->vif->hif_drv->usr_scan_req;
|
2019-01-17 13:21:21 +00:00
|
|
|
const u8 *ch_elm;
|
|
|
|
u8 *ies;
|
|
|
|
int ies_len;
|
2018-11-01 16:45:23 +00:00
|
|
|
size_t offset;
|
|
|
|
|
2019-01-17 13:21:21 +00:00
|
|
|
if (ieee80211_is_probe_resp(rcvd_info->mgmt->frame_control))
|
2018-11-01 16:45:23 +00:00
|
|
|
offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
|
2019-01-17 13:21:21 +00:00
|
|
|
else if (ieee80211_is_beacon(rcvd_info->mgmt->frame_control))
|
2018-11-01 16:45:23 +00:00
|
|
|
offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
|
2019-01-17 13:21:21 +00:00
|
|
|
else
|
|
|
|
goto done;
|
2018-11-01 16:45:23 +00:00
|
|
|
|
2019-01-17 13:21:21 +00:00
|
|
|
ies = rcvd_info->mgmt->u.beacon.variable;
|
|
|
|
ies_len = rcvd_info->frame_len - offset;
|
|
|
|
if (ies_len <= 0)
|
|
|
|
goto done;
|
2018-11-01 16:45:23 +00:00
|
|
|
|
|
|
|
ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len);
|
|
|
|
if (ch_elm && ch_elm[1] > 0)
|
2019-01-17 13:21:21 +00:00
|
|
|
rcvd_info->ch = ch_elm[2];
|
2018-03-02 19:52:48 +05:30
|
|
|
|
2019-01-17 13:21:21 +00:00
|
|
|
if (scan_req->scan_result)
|
|
|
|
scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, rcvd_info,
|
|
|
|
scan_req->arg);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
done:
|
2019-01-17 13:21:21 +00:00
|
|
|
kfree(rcvd_info->mgmt);
|
2018-06-26 11:37:03 +05:30
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-09-25 11:53:21 +05:30
|
|
|
static void host_int_get_assoc_res_info(struct wilc_vif *vif,
|
|
|
|
u8 *assoc_resp_info,
|
|
|
|
u32 max_assoc_resp_info_len,
|
|
|
|
u32 *rcvd_assoc_resp_info_len)
|
2018-07-19 04:15:14 +05:30
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2018-07-19 04:15:14 +05:30
|
|
|
struct wid wid;
|
|
|
|
|
|
|
|
wid.id = WID_ASSOC_RES_INFO;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.val = assoc_resp_info;
|
|
|
|
wid.size = max_assoc_resp_info_len;
|
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
|
2018-07-19 04:15:14 +05:30
|
|
|
if (result) {
|
|
|
|
*rcvd_assoc_resp_info_len = 0;
|
|
|
|
netdev_err(vif->ndev, "Failed to send association response\n");
|
2018-09-25 11:53:21 +05:30
|
|
|
return;
|
2018-07-19 04:15:14 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
*rcvd_assoc_resp_info_len = wid.size;
|
|
|
|
}
|
2015-11-16 15:04:53 +01:00
|
|
|
|
2018-11-01 16:45:23 +00:00
|
|
|
static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
|
2019-01-17 13:21:32 +00:00
|
|
|
struct wilc_conn_info *ret_conn_info)
|
2018-11-01 16:45:23 +00:00
|
|
|
{
|
|
|
|
u8 *ies;
|
|
|
|
u16 ies_len;
|
2020-01-17 10:31:26 +00:00
|
|
|
struct wilc_assoc_resp *res = (struct wilc_assoc_resp *)buffer;
|
2018-11-01 16:45:23 +00:00
|
|
|
|
|
|
|
ret_conn_info->status = le16_to_cpu(res->status_code);
|
|
|
|
if (ret_conn_info->status == WLAN_STATUS_SUCCESS) {
|
|
|
|
ies = &buffer[sizeof(*res)];
|
|
|
|
ies_len = buffer_len - sizeof(*res);
|
|
|
|
|
|
|
|
ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL);
|
|
|
|
if (!ret_conn_info->resp_ies)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ret_conn_info->resp_ies_len = ies_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-26 17:16:02 +05:30
|
|
|
static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif,
|
|
|
|
u8 mac_status)
|
|
|
|
{
|
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2019-01-17 13:21:32 +00:00
|
|
|
struct wilc_conn_info *conn_info = &hif_drv->conn_info;
|
2018-03-26 17:16:02 +05:30
|
|
|
|
2018-11-12 05:45:14 +00:00
|
|
|
if (mac_status == WILC_MAC_STATUS_CONNECTED) {
|
2018-05-11 13:43:08 +05:30
|
|
|
u32 assoc_resp_info_len;
|
2018-03-26 17:16:02 +05:30
|
|
|
|
2018-11-12 05:45:29 +00:00
|
|
|
memset(hif_drv->assoc_resp, 0, WILC_MAX_ASSOC_RESP_FRAME_SIZE);
|
2018-03-26 17:16:02 +05:30
|
|
|
|
2018-09-04 12:09:30 +05:30
|
|
|
host_int_get_assoc_res_info(vif, hif_drv->assoc_resp,
|
2018-11-12 05:45:29 +00:00
|
|
|
WILC_MAX_ASSOC_RESP_FRAME_SIZE,
|
2018-05-11 13:43:08 +05:30
|
|
|
&assoc_resp_info_len);
|
2018-03-26 17:16:02 +05:30
|
|
|
|
2018-05-11 13:43:08 +05:30
|
|
|
if (assoc_resp_info_len != 0) {
|
2018-03-26 17:16:02 +05:30
|
|
|
s32 err = 0;
|
|
|
|
|
2018-09-04 12:09:30 +05:30
|
|
|
err = wilc_parse_assoc_resp_info(hif_drv->assoc_resp,
|
2018-05-11 13:43:08 +05:30
|
|
|
assoc_resp_info_len,
|
2019-01-17 13:21:32 +00:00
|
|
|
conn_info);
|
2018-05-11 13:43:31 +05:30
|
|
|
if (err)
|
2018-03-26 17:16:02 +05:30
|
|
|
netdev_err(vif->ndev,
|
|
|
|
"wilc_parse_assoc_resp_info() returned error %d\n",
|
|
|
|
err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
del_timer(&hif_drv->connect_timer);
|
2019-01-17 13:21:38 +00:00
|
|
|
conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status,
|
2019-01-17 13:21:32 +00:00
|
|
|
hif_drv->conn_info.arg);
|
2018-03-26 17:16:02 +05:30
|
|
|
|
2018-11-12 05:45:14 +00:00
|
|
|
if (mac_status == WILC_MAC_STATUS_CONNECTED &&
|
2019-01-17 13:21:32 +00:00
|
|
|
conn_info->status == WLAN_STATUS_SUCCESS) {
|
|
|
|
ether_addr_copy(hif_drv->assoc_bssid, conn_info->bssid);
|
2018-03-26 17:16:02 +05:30
|
|
|
hif_drv->hif_state = HOST_IF_CONNECTED;
|
|
|
|
} else {
|
|
|
|
hif_drv->hif_state = HOST_IF_IDLE;
|
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
kfree(conn_info->resp_ies);
|
|
|
|
conn_info->resp_ies = NULL;
|
|
|
|
conn_info->resp_ies_len = 0;
|
2018-03-26 17:16:02 +05:30
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
kfree(conn_info->req_ies);
|
|
|
|
conn_info->req_ies = NULL;
|
|
|
|
conn_info->req_ies_len = 0;
|
2018-03-26 17:16:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static inline void host_int_handle_disconnect(struct wilc_vif *vif)
|
|
|
|
{
|
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
|
|
|
|
|
|
|
if (hif_drv->usr_scan_req.scan_result) {
|
|
|
|
del_timer(&hif_drv->scan_timer);
|
|
|
|
handle_scan_done(vif, SCAN_EVENT_ABORTED);
|
|
|
|
}
|
|
|
|
|
2019-07-25 21:31:35 +00:00
|
|
|
if (hif_drv->conn_info.conn_result)
|
2019-01-17 13:21:32 +00:00
|
|
|
hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
|
2019-01-17 13:21:38 +00:00
|
|
|
0, hif_drv->conn_info.arg);
|
2019-07-25 21:31:35 +00:00
|
|
|
else
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
|
2018-03-26 17:16:02 +05:30
|
|
|
|
|
|
|
eth_zero_addr(hif_drv->assoc_bssid);
|
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
hif_drv->conn_info.req_ies_len = 0;
|
|
|
|
kfree(hif_drv->conn_info.req_ies);
|
|
|
|
hif_drv->conn_info.req_ies = NULL;
|
2018-03-26 17:16:02 +05:30
|
|
|
hif_drv->hif_state = HOST_IF_IDLE;
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
static void handle_rcvd_gnrl_async_info(struct work_struct *work)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-06-26 11:37:03 +05:30
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
|
|
|
struct wilc_vif *vif = msg->vif;
|
2019-01-17 13:21:35 +00:00
|
|
|
struct wilc_rcvd_mac_info *mac_info = &msg->body.mac_info;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2015-06-26 16:45:14 +02:00
|
|
|
|
2015-10-12 16:56:05 +09:00
|
|
|
if (!hif_drv) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__);
|
2019-01-17 13:21:35 +00:00
|
|
|
goto free_msg;
|
2015-09-22 14:34:43 +09:00
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:35 +00:00
|
|
|
if (!hif_drv->conn_info.conn_result) {
|
|
|
|
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
|
|
|
|
goto free_msg;
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:35 +00:00
|
|
|
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
|
|
|
|
host_int_parse_assoc_resp_info(vif, mac_info->status);
|
|
|
|
} else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) {
|
|
|
|
if (hif_drv->hif_state == HOST_IF_CONNECTED) {
|
2018-03-26 17:16:02 +05:30
|
|
|
host_int_handle_disconnect(vif);
|
2019-01-17 13:21:35 +00:00
|
|
|
} else if (hif_drv->usr_scan_req.scan_result) {
|
2015-10-29 11:58:34 +09:00
|
|
|
del_timer(&hif_drv->scan_timer);
|
2019-01-17 13:21:35 +00:00
|
|
|
handle_scan_done(vif, SCAN_EVENT_ABORTED);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
free_msg:
|
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:28 +00:00
|
|
|
int wilc_disconnect(struct wilc_vif *vif)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2015-10-28 15:59:28 +09:00
|
|
|
struct wid wid;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_user_scan_req *scan_req;
|
2019-01-17 13:21:32 +00:00
|
|
|
struct wilc_conn_info *conn_info;
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2018-03-02 19:52:49 +05:30
|
|
|
u16 dummy_reason_code = 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-19 04:15:12 +05:30
|
|
|
wid.id = WID_DISCONNECT;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.type = WID_CHAR;
|
2018-03-02 19:52:49 +05:30
|
|
|
wid.val = (s8 *)&dummy_reason_code;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.size = sizeof(char);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result) {
|
2019-04-15 17:33:30 +01:00
|
|
|
netdev_err(vif->ndev, "Failed to send disconnect\n");
|
2018-12-02 18:03:28 +00:00
|
|
|
return result;
|
2018-03-07 07:43:55 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:55 +05:30
|
|
|
scan_req = &hif_drv->usr_scan_req;
|
2019-01-17 13:21:32 +00:00
|
|
|
conn_info = &hif_drv->conn_info;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:55 +05:30
|
|
|
if (scan_req->scan_result) {
|
|
|
|
del_timer(&hif_drv->scan_timer);
|
2019-01-17 13:21:18 +00:00
|
|
|
scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg);
|
2018-03-07 07:43:55 +05:30
|
|
|
scan_req->scan_result = NULL;
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
if (conn_info->conn_result) {
|
2018-03-07 07:43:55 +05:30
|
|
|
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
|
|
|
|
del_timer(&hif_drv->connect_timer);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:38 +00:00
|
|
|
conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0,
|
|
|
|
conn_info->arg);
|
2018-03-07 07:43:55 +05:30
|
|
|
} else {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
|
2018-03-07 07:43:55 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:55 +05:30
|
|
|
hif_drv->hif_state = HOST_IF_IDLE;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:55 +05:30
|
|
|
eth_zero_addr(hif_drv->assoc_bssid);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
conn_info->req_ies_len = 0;
|
|
|
|
kfree(conn_info->req_ies);
|
|
|
|
conn_info->req_ies = NULL;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:28 +00:00
|
|
|
return 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:25 +00:00
|
|
|
int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-01-30 22:20:29 +05:30
|
|
|
struct wid wid_list[5];
|
2018-07-19 04:15:16 +05:30
|
|
|
u32 wid_cnt = 0, result;
|
2018-01-30 22:20:30 +05:30
|
|
|
|
|
|
|
wid_list[wid_cnt].id = WID_LINKSPEED;
|
|
|
|
wid_list[wid_cnt].type = WID_CHAR;
|
|
|
|
wid_list[wid_cnt].size = sizeof(char);
|
2018-02-20 20:27:56 +05:30
|
|
|
wid_list[wid_cnt].val = (s8 *)&stats->link_speed;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
|
|
|
|
|
|
|
wid_list[wid_cnt].id = WID_RSSI;
|
|
|
|
wid_list[wid_cnt].type = WID_CHAR;
|
|
|
|
wid_list[wid_cnt].size = sizeof(char);
|
2018-02-20 20:27:56 +05:30
|
|
|
wid_list[wid_cnt].val = (s8 *)&stats->rssi;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
|
|
|
|
|
|
|
wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT;
|
|
|
|
wid_list[wid_cnt].type = WID_INT;
|
|
|
|
wid_list[wid_cnt].size = sizeof(u32);
|
2018-02-20 20:27:56 +05:30
|
|
|
wid_list[wid_cnt].val = (s8 *)&stats->tx_cnt;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
|
|
|
|
|
|
|
wid_list[wid_cnt].id = WID_RECEIVED_FRAGMENT_COUNT;
|
|
|
|
wid_list[wid_cnt].type = WID_INT;
|
|
|
|
wid_list[wid_cnt].size = sizeof(u32);
|
2018-02-20 20:27:56 +05:30
|
|
|
wid_list[wid_cnt].val = (s8 *)&stats->rx_cnt;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
|
|
|
|
|
|
|
wid_list[wid_cnt].id = WID_FAILED_COUNT;
|
|
|
|
wid_list[wid_cnt].type = WID_INT;
|
|
|
|
wid_list[wid_cnt].size = sizeof(u32);
|
2018-02-20 20:27:56 +05:30
|
|
|
wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt;
|
2018-01-30 22:20:30 +05:30
|
|
|
wid_cnt++;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt);
|
2018-12-02 18:03:25 +00:00
|
|
|
if (result) {
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "Failed to send scan parameters\n");
|
2018-12-02 18:03:25 +00:00
|
|
|
return result;
|
|
|
|
}
|
2015-09-16 18:36:01 +09:00
|
|
|
|
2018-02-20 20:27:56 +05:30
|
|
|
if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
|
|
|
|
stats->link_speed != DEFAULT_LINK_SPEED)
|
2018-09-04 12:09:33 +05:30
|
|
|
wilc_enable_tcp_ack_filter(vif, true);
|
2018-02-20 20:27:56 +05:30
|
|
|
else if (stats->link_speed != DEFAULT_LINK_SPEED)
|
2018-09-04 12:09:33 +05:30
|
|
|
wilc_enable_tcp_ack_filter(vif, false);
|
2016-02-04 18:15:24 +09:00
|
|
|
|
2018-12-02 18:03:25 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void handle_get_statistics(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
|
|
|
struct wilc_vif *vif = msg->vif;
|
|
|
|
struct rf_info *stats = (struct rf_info *)msg->body.data;
|
|
|
|
|
|
|
|
wilc_get_statistics(vif, stats);
|
|
|
|
|
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:02:36 +00:00
|
|
|
static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac,
|
|
|
|
struct station_parameters *params)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:34 +00:00
|
|
|
ether_addr_copy(cur_byte, mac);
|
|
|
|
cur_byte += ETH_ALEN;
|
|
|
|
|
|
|
|
put_unaligned_le16(params->aid, cur_byte);
|
|
|
|
cur_byte += 2;
|
|
|
|
|
|
|
|
*cur_byte++ = params->supported_rates_len;
|
|
|
|
if (params->supported_rates_len > 0)
|
|
|
|
memcpy(cur_byte, params->supported_rates,
|
|
|
|
params->supported_rates_len);
|
|
|
|
cur_byte += params->supported_rates_len;
|
|
|
|
|
|
|
|
if (params->ht_capa) {
|
|
|
|
*cur_byte++ = true;
|
2020-03-02 16:22:35 +00:00
|
|
|
memcpy(cur_byte, params->ht_capa,
|
2018-12-02 18:02:34 +00:00
|
|
|
sizeof(struct ieee80211_ht_cap));
|
|
|
|
} else {
|
|
|
|
*cur_byte++ = false;
|
|
|
|
}
|
2018-01-30 22:20:31 +05:30
|
|
|
cur_byte += sizeof(struct ieee80211_ht_cap);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
put_unaligned_le16(params->sta_flags_mask, cur_byte);
|
|
|
|
cur_byte += 2;
|
|
|
|
put_unaligned_le16(params->sta_flags_set, cur_byte);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-02-19 20:59:39 +05:30
|
|
|
static int handle_remain_on_chan(struct wilc_vif *vif,
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_remain_ch *hif_remain_ch)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2018-03-07 07:43:56 +05:30
|
|
|
u8 remain_on_chan_flag;
|
2015-10-28 15:59:28 +09:00
|
|
|
struct wid wid;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
if (hif_drv->usr_scan_req.scan_result)
|
|
|
|
return -EBUSY;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
|
|
|
|
return -EBUSY;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-07-25 21:31:34 +00:00
|
|
|
if (vif->connecting)
|
2019-02-05 07:15:39 +00:00
|
|
|
return -EBUSY;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:56 +05:30
|
|
|
remain_on_chan_flag = true;
|
2018-07-19 04:15:12 +05:30
|
|
|
wid.id = WID_REMAIN_ON_CHAN;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = 2;
|
|
|
|
wid.val = kmalloc(wid.size, GFP_KERNEL);
|
2019-02-05 07:15:39 +00:00
|
|
|
if (!wid.val)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:56 +05:30
|
|
|
wid.val[0] = remain_on_chan_flag;
|
2018-02-19 20:59:34 +05:30
|
|
|
wid.val[1] = (s8)hif_remain_ch->ch;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-03-26 17:15:59 +05:30
|
|
|
kfree(wid.val);
|
2019-02-05 07:15:39 +00:00
|
|
|
if (result)
|
|
|
|
return -EBUSY;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
hif_drv->remain_on_ch.arg = hif_remain_ch->arg;
|
|
|
|
hif_drv->remain_on_ch.expired = hif_remain_ch->expired;
|
|
|
|
hif_drv->remain_on_ch.ch = hif_remain_ch->ch;
|
|
|
|
hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie;
|
2018-04-25 22:48:24 +05:30
|
|
|
hif_drv->remain_on_ch_timer_vif = vif;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
return 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-06-26 12:40:45 +00:00
|
|
|
static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-03-07 07:43:56 +05:30
|
|
|
u8 remain_on_chan_flag;
|
2015-10-28 15:59:28 +09:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2015-12-21 14:18:41 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2020-02-11 09:57:09 +00:00
|
|
|
if (vif->priv.p2p_listen_state) {
|
2018-03-07 07:43:56 +05:30
|
|
|
remain_on_chan_flag = false;
|
2018-07-19 04:15:12 +05:30
|
|
|
wid.id = WID_REMAIN_ON_CHAN;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = 2;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:40:45 +00:00
|
|
|
wid.val = kmalloc(wid.size, GFP_KERNEL);
|
2016-10-09 22:27:53 +03:00
|
|
|
if (!wid.val)
|
2019-06-26 12:40:45 +00:00
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:56 +05:30
|
|
|
wid.val[0] = remain_on_chan_flag;
|
2019-02-07 11:29:01 +00:00
|
|
|
wid.val[1] = WILC_FALSE_FRMWR_CHANNEL;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-03-26 17:15:59 +05:30
|
|
|
kfree(wid.val);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result != 0) {
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "Failed to set remain channel\n");
|
2019-06-26 12:40:45 +00:00
|
|
|
return -EINVAL;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-10-29 11:58:42 +09:00
|
|
|
if (hif_drv->remain_on_ch.expired) {
|
2015-10-29 11:58:44 +09:00
|
|
|
hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
|
2019-06-26 12:40:45 +00:00
|
|
|
cookie);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
} else {
|
2016-02-04 18:24:30 +09:00
|
|
|
netdev_dbg(vif->ndev, "Not in listen state\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-06-26 12:40:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wilc_handle_listen_state_expired(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
|
|
|
|
|
|
|
wilc_handle_roc_expired(msg->vif, msg->body.remain_on_ch.cookie);
|
2018-06-26 11:37:03 +05:30
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-02-19 20:59:41 +05:30
|
|
|
static void listen_timer_cb(struct timer_list *t)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2017-10-16 16:24:32 -07:00
|
|
|
struct host_if_drv *hif_drv = from_timer(hif_drv, t,
|
|
|
|
remain_on_ch_timer);
|
|
|
|
struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif;
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
2015-10-13 19:49:26 +09:00
|
|
|
|
2015-12-21 14:18:41 +09:00
|
|
|
del_timer(&vif->hif_drv->remain_on_ch_timer);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:40:45 +00:00
|
|
|
msg = wilc_alloc_work(vif, wilc_handle_listen_state_expired, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return;
|
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
msg->body.remain_on_ch.cookie = vif->hif_drv->remain_on_ch.cookie;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
static void handle_set_mcast_filter(struct work_struct *work)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-06-26 11:37:03 +05:30
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
|
|
|
struct wilc_vif *vif = msg->vif;
|
2019-01-17 13:21:41 +00:00
|
|
|
struct wilc_set_multicast *set_mc = &msg->body.mc_info;
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2015-10-28 15:59:28 +09:00
|
|
|
struct wid wid;
|
2018-01-30 22:20:31 +05:30
|
|
|
u8 *cur_byte;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-19 04:15:12 +05:30
|
|
|
wid.id = WID_SETUP_MULTICAST_FILTER;
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.type = WID_BIN;
|
2019-01-17 13:21:41 +00:00
|
|
|
wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN);
|
2015-10-28 15:59:28 +09:00
|
|
|
wid.val = kmalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wid.val)
|
2018-03-07 07:43:52 +05:30
|
|
|
goto error;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-01-30 22:20:31 +05:30
|
|
|
cur_byte = wid.val;
|
2019-01-17 13:21:41 +00:00
|
|
|
put_unaligned_le32(set_mc->enabled, cur_byte);
|
|
|
|
cur_byte += 4;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:41 +00:00
|
|
|
put_unaligned_le32(set_mc->cnt, cur_byte);
|
|
|
|
cur_byte += 4;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:41 +00:00
|
|
|
if (set_mc->cnt > 0 && set_mc->mc_list)
|
|
|
|
memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result)
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "Failed to send setup multicast\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-07 07:43:52 +05:30
|
|
|
error:
|
2019-01-17 13:21:41 +00:00
|
|
|
kfree(set_mc->mc_list);
|
2015-10-28 15:59:28 +09:00
|
|
|
kfree(wid.val);
|
2018-06-26 11:37:03 +05:30
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2021-09-16 16:49:18 +00:00
|
|
|
void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct wid wid;
|
|
|
|
u8 wowlan_trigger = 0;
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
|
wowlan_trigger = 1;
|
|
|
|
|
|
|
|
wid.id = WID_WOWLAN_TRIGGER;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.val = &wowlan_trigger;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
|
|
|
|
ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
|
|
|
if (ret)
|
|
|
|
pr_err("Failed to send wowlan trigger config packet\n");
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
static void handle_scan_timer(struct work_struct *work)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-06-26 11:37:03 +05:30
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
handle_scan_done(msg->vif, SCAN_EVENT_ABORTED);
|
|
|
|
kfree(msg);
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
static void handle_scan_complete(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
del_timer(&msg->vif->hif_drv->scan_timer);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:03 +05:30
|
|
|
handle_scan_done(msg->vif, SCAN_EVENT_DONE);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2016-06-23 11:11:51 +05:30
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-02-19 20:59:40 +05:30
|
|
|
static void timer_scan_cb(struct timer_list *t)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2017-10-16 16:24:32 -07:00
|
|
|
struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer);
|
|
|
|
struct wilc_vif *vif = hif_drv->scan_timer_vif;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
msg = wilc_alloc_work(vif, handle_scan_timer, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result)
|
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-02-19 20:59:40 +05:30
|
|
|
static void timer_connect_cb(struct timer_list *t)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2017-10-16 16:24:32 -07:00
|
|
|
struct host_if_drv *hif_drv = from_timer(hif_drv, t,
|
|
|
|
connect_timer);
|
|
|
|
struct wilc_vif *vif = hif_drv->connect_timer_vif;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
msg = wilc_alloc_work(vif, handle_connect_timeout, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result)
|
|
|
|
kfree(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.id = WID_REMOVE_WEP_KEY;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
wid.val = &index;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-06-26 11:37:06 +05:30
|
|
|
if (result)
|
2018-12-02 18:03:11 +00:00
|
|
|
netdev_err(vif->ndev,
|
|
|
|
"Failed to send remove wep key config packet\n");
|
2015-10-05 19:35:00 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.id = WID_KEY_ID;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
wid.val = &index;
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-06-26 11:37:06 +05:30
|
|
|
if (result)
|
2018-12-02 18:03:11 +00:00
|
|
|
netdev_err(vif->ndev,
|
|
|
|
"Failed to send wep default key config packet\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
|
|
|
|
u8 index)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wid wid;
|
2018-03-26 17:15:58 +05:30
|
|
|
int result;
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wilc_wep_key *wep_key;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.id = WID_ADD_WEP_KEY;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = sizeof(*wep_key) + len;
|
|
|
|
wep_key = kzalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wep_key)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.val = (u8 *)wep_key;
|
2015-10-27 20:40:37 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wep_key->index = index;
|
|
|
|
wep_key->key_len = len;
|
|
|
|
memcpy(wep_key->key, key, len);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result)
|
2018-12-02 18:03:11 +00:00
|
|
|
netdev_err(vif->ndev,
|
|
|
|
"Failed to add wep key config packet\n");
|
2018-06-26 11:37:05 +05:30
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
kfree(wep_key);
|
2018-06-26 11:37:05 +05:30
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
|
2018-07-19 04:15:04 +05:30
|
|
|
u8 index, u8 mode, enum authtype auth_type)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wid wid_list[3];
|
2018-03-26 17:15:58 +05:30
|
|
|
int result;
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wilc_wep_key *wep_key;
|
|
|
|
|
|
|
|
wid_list[0].id = WID_11I_MODE;
|
|
|
|
wid_list[0].type = WID_CHAR;
|
|
|
|
wid_list[0].size = sizeof(char);
|
|
|
|
wid_list[0].val = &mode;
|
|
|
|
|
|
|
|
wid_list[1].id = WID_AUTH_TYPE;
|
|
|
|
wid_list[1].type = WID_CHAR;
|
|
|
|
wid_list[1].size = sizeof(char);
|
|
|
|
wid_list[1].val = (s8 *)&auth_type;
|
|
|
|
|
|
|
|
wid_list[2].id = WID_WEP_KEY_VALUE;
|
|
|
|
wid_list[2].type = WID_STR;
|
|
|
|
wid_list[2].size = sizeof(*wep_key) + len;
|
|
|
|
wep_key = kzalloc(wid_list[2].size, GFP_KERNEL);
|
|
|
|
if (!wep_key)
|
|
|
|
return -ENOMEM;
|
2015-10-28 08:19:27 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid_list[2].val = (u8 *)wep_key;
|
2015-10-13 19:49:26 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wep_key->index = index;
|
|
|
|
wep_key->key_len = len;
|
|
|
|
memcpy(wep_key->key, key, len);
|
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
|
2019-06-26 12:41:04 +00:00
|
|
|
ARRAY_SIZE(wid_list));
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result)
|
2018-12-02 18:03:11 +00:00
|
|
|
netdev_err(vif->ndev,
|
|
|
|
"Failed to add wep ap key config packet\n");
|
2018-06-26 11:37:05 +05:30
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
kfree(wep_key);
|
2018-06-26 11:37:05 +05:30
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
2015-09-16 18:53:20 +09:00
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
|
|
|
|
const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
|
|
|
|
u8 mode, u8 cipher_mode, u8 index)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
int result = 0;
|
2019-02-07 11:29:01 +00:00
|
|
|
u8 t_key_len = ptk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN;
|
2015-10-19 18:26:13 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
if (mode == WILC_AP_MODE) {
|
|
|
|
struct wid wid_list[2];
|
|
|
|
struct wilc_ap_wpa_ptk *key_buf;
|
2015-10-19 18:26:13 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid_list[0].id = WID_11I_MODE;
|
|
|
|
wid_list[0].type = WID_CHAR;
|
|
|
|
wid_list[0].size = sizeof(char);
|
|
|
|
wid_list[0].val = (s8 *)&cipher_mode;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL);
|
|
|
|
if (!key_buf)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
ether_addr_copy(key_buf->mac_addr, mac_addr);
|
|
|
|
key_buf->index = index;
|
|
|
|
key_buf->key_len = t_key_len;
|
|
|
|
memcpy(&key_buf->key[0], ptk, ptk_key_len);
|
|
|
|
|
|
|
|
if (rx_mic)
|
|
|
|
memcpy(&key_buf->key[ptk_key_len], rx_mic,
|
2019-02-07 11:29:01 +00:00
|
|
|
WILC_RX_MIC_KEY_LEN);
|
2018-12-02 18:03:11 +00:00
|
|
|
|
|
|
|
if (tx_mic)
|
2019-02-07 11:29:01 +00:00
|
|
|
memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN],
|
|
|
|
tx_mic, WILC_TX_MIC_KEY_LEN);
|
2018-12-02 18:03:11 +00:00
|
|
|
|
|
|
|
wid_list[1].id = WID_ADD_PTK;
|
|
|
|
wid_list[1].type = WID_STR;
|
|
|
|
wid_list[1].size = sizeof(*key_buf) + t_key_len;
|
|
|
|
wid_list[1].val = (u8 *)key_buf;
|
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
|
2019-06-26 12:41:04 +00:00
|
|
|
ARRAY_SIZE(wid_list));
|
2018-12-02 18:03:11 +00:00
|
|
|
kfree(key_buf);
|
|
|
|
} else if (mode == WILC_STATION_MODE) {
|
|
|
|
struct wid wid;
|
|
|
|
struct wilc_sta_wpa_ptk *key_buf;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL);
|
|
|
|
if (!key_buf)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
ether_addr_copy(key_buf->mac_addr, mac_addr);
|
|
|
|
key_buf->key_len = t_key_len;
|
|
|
|
memcpy(&key_buf->key[0], ptk, ptk_key_len);
|
2016-02-22 13:11:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
if (rx_mic)
|
|
|
|
memcpy(&key_buf->key[ptk_key_len], rx_mic,
|
2019-02-07 11:29:01 +00:00
|
|
|
WILC_RX_MIC_KEY_LEN);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
if (tx_mic)
|
2019-02-07 11:29:01 +00:00
|
|
|
memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN],
|
|
|
|
tx_mic, WILC_TX_MIC_KEY_LEN);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.id = WID_ADD_PTK;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = sizeof(*key_buf) + t_key_len;
|
|
|
|
wid.val = (s8 *)key_buf;
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:03:11 +00:00
|
|
|
kfree(key_buf);
|
2018-03-26 17:16:00 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:05 +05:30
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
|
|
|
|
u8 index, u32 key_rsc_len, const u8 *key_rsc,
|
|
|
|
const u8 *rx_mic, const u8 *tx_mic, u8 mode,
|
|
|
|
u8 cipher_mode)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
int result = 0;
|
|
|
|
struct wilc_gtk_key *gtk_key;
|
2019-02-07 11:29:01 +00:00
|
|
|
int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL);
|
|
|
|
if (!gtk_key)
|
|
|
|
return -ENOMEM;
|
2018-06-26 11:37:05 +05:30
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
/* fill bssid value only in station mode */
|
|
|
|
if (mode == WILC_STATION_MODE &&
|
|
|
|
vif->hif_drv->hif_state == HOST_IF_CONNECTED)
|
|
|
|
memcpy(gtk_key->mac_addr, vif->hif_drv->assoc_bssid, ETH_ALEN);
|
|
|
|
|
|
|
|
if (key_rsc)
|
|
|
|
memcpy(gtk_key->rsc, key_rsc, 8);
|
|
|
|
gtk_key->index = index;
|
|
|
|
gtk_key->key_len = t_key_len;
|
|
|
|
memcpy(>k_key->key[0], rx_gtk, gtk_key_len);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-11-08 16:49:12 +09:00
|
|
|
if (rx_mic)
|
2019-02-07 11:29:01 +00:00
|
|
|
memcpy(>k_key->key[gtk_key_len], rx_mic, WILC_RX_MIC_KEY_LEN);
|
2015-10-19 18:26:13 +09:00
|
|
|
|
2015-11-08 16:49:13 +09:00
|
|
|
if (tx_mic)
|
2019-02-07 11:29:01 +00:00
|
|
|
memcpy(>k_key->key[gtk_key_len + WILC_RX_MIC_KEY_LEN],
|
|
|
|
tx_mic, WILC_TX_MIC_KEY_LEN);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-11-12 05:45:29 +00:00
|
|
|
if (mode == WILC_AP_MODE) {
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wid wid_list[2];
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid_list[0].id = WID_11I_MODE;
|
|
|
|
wid_list[0].type = WID_CHAR;
|
|
|
|
wid_list[0].size = sizeof(char);
|
|
|
|
wid_list[0].val = (s8 *)&cipher_mode;
|
2015-10-19 18:26:13 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid_list[1].id = WID_ADD_RX_GTK;
|
|
|
|
wid_list[1].type = WID_STR;
|
|
|
|
wid_list[1].size = sizeof(*gtk_key) + t_key_len;
|
|
|
|
wid_list[1].val = (u8 *)gtk_key;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
|
2019-06-26 12:41:04 +00:00
|
|
|
ARRAY_SIZE(wid_list));
|
2018-12-02 18:03:11 +00:00
|
|
|
} else if (mode == WILC_STATION_MODE) {
|
|
|
|
struct wid wid;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.id = WID_ADD_RX_GTK;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = sizeof(*gtk_key) + t_key_len;
|
|
|
|
wid.val = (u8 *)gtk_key;
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-03-26 17:16:01 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-22 03:08:15 -06:00
|
|
|
kfree(gtk_key);
|
2018-06-26 11:37:05 +05:30
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:11 +00:00
|
|
|
struct wid wid;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:11 +00:00
|
|
|
wid.id = WID_PMKID_INFO;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1;
|
|
|
|
wid.val = (u8 *)pmkid;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-22 09:49:07 +09:00
|
|
|
int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:03:17 +00:00
|
|
|
struct wid wid;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:17 +00:00
|
|
|
wid.id = WID_MAC_ADDR;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = ETH_ALEN;
|
|
|
|
wid.val = mac_addr;
|
2015-10-13 19:49:26 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
|
2018-06-26 11:37:06 +05:30
|
|
|
if (result)
|
2018-12-02 18:03:17 +00:00
|
|
|
netdev_err(vif->ndev, "Failed to get mac address\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2020-11-25 11:41:08 +00:00
|
|
|
int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr)
|
|
|
|
{
|
|
|
|
struct wid wid;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
wid.id = WID_MAC_ADDR;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = ETH_ALEN;
|
|
|
|
wid.val = mac_addr;
|
|
|
|
|
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
|
|
|
if (result)
|
2021-12-06 23:27:29 +00:00
|
|
|
netdev_err(vif->ndev, "Failed to set mac address\n");
|
2020-11-25 11:41:08 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
|
|
|
|
size_t ies_len)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2015-12-21 14:18:40 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2019-01-17 13:21:32 +00:00
|
|
|
struct wilc_conn_info *conn_info = &hif_drv->conn_info;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
if (bssid)
|
|
|
|
ether_addr_copy(conn_info->bssid, bssid);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-12-24 16:52:24 +09:00
|
|
|
if (ies) {
|
2019-01-17 13:21:32 +00:00
|
|
|
conn_info->req_ies_len = ies_len;
|
|
|
|
conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL);
|
2019-03-22 01:25:55 +05:30
|
|
|
if (!conn_info->req_ies)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:31 +00:00
|
|
|
result = wilc_send_connect_wid(vif);
|
|
|
|
if (result)
|
2018-06-26 11:37:05 +05:30
|
|
|
goto free_ies;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2017-10-16 16:24:32 -07:00
|
|
|
hif_drv->connect_timer_vif = vif;
|
2015-10-29 11:58:35 +09:00
|
|
|
mod_timer(&hif_drv->connect_timer,
|
2019-02-02 19:17:05 +00:00
|
|
|
jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:05 +05:30
|
|
|
return 0;
|
|
|
|
|
|
|
|
free_ies:
|
2019-01-17 13:21:32 +00:00
|
|
|
kfree(conn_info->req_ies);
|
2018-12-02 18:03:31 +00:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:54 +00:00
|
|
|
struct wid wid;
|
2015-10-05 11:07:22 +09:00
|
|
|
int result;
|
2018-06-26 11:37:05 +05:30
|
|
|
|
2018-12-02 18:02:54 +00:00
|
|
|
wid.id = WID_CURRENT_CHANNEL;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
wid.val = &channel;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:54 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to set channel\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:05 +05:30
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-08-01 20:15:11 +00:00
|
|
|
int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
|
|
|
|
u8 ifc_id)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:05 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:03:05 +00:00
|
|
|
struct wilc_drv_handler drv;
|
2015-10-28 15:59:24 +09:00
|
|
|
|
2019-08-01 20:15:11 +00:00
|
|
|
wid.id = WID_SET_OPERATION_MODE;
|
2018-12-02 18:03:05 +00:00
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = sizeof(drv);
|
|
|
|
wid.val = (u8 *)&drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:05 +00:00
|
|
|
drv.handler = cpu_to_le32(index);
|
|
|
|
drv.mode = (ifc_id | (mode << 1));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:03:05 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to set driver handler\n");
|
2018-09-25 11:53:34 +05:30
|
|
|
|
2015-10-05 19:34:47 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:03:08 +00:00
|
|
|
s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:03:08 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
s32 result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:08 +00:00
|
|
|
wid.id = WID_SET_STA_MAC_INACTIVE_TIME;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = ETH_ALEN;
|
|
|
|
wid.val = kzalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wid.val)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:08 +00:00
|
|
|
ether_addr_copy(wid.val, mac);
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:03:08 +00:00
|
|
|
kfree(wid.val);
|
|
|
|
if (result) {
|
|
|
|
netdev_err(vif->ndev, "Failed to set inactive mac\n");
|
|
|
|
return result;
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:08 +00:00
|
|
|
wid.id = WID_GET_INACTIVE_TIME;
|
|
|
|
wid.type = WID_INT;
|
|
|
|
wid.val = (s8 *)out_val;
|
|
|
|
wid.size = sizeof(u32);
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
|
2018-06-26 11:37:06 +05:30
|
|
|
if (result)
|
2018-12-02 18:03:08 +00:00
|
|
|
netdev_err(vif->ndev, "Failed to get inactive time\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
2015-09-16 18:53:20 +09:00
|
|
|
|
2015-12-24 16:52:37 +09:00
|
|
|
int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:59 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
if (!rssi_level) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__);
|
2018-06-26 11:37:06 +05:30
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2018-12-02 18:02:59 +00:00
|
|
|
wid.id = WID_RSSI;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
wid.val = rssi_level;
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
|
2018-12-02 18:02:59 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to get RSSI value\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-25 23:35:31 +01:00
|
|
|
static int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
|
|
|
|
2018-12-02 18:03:25 +00:00
|
|
|
msg = wilc_alloc_work(vif, handle_get_statistics, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return PTR_ERR(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:05 +05:30
|
|
|
msg->body.data = (char *)stats;
|
2015-10-13 19:49:26 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:02:57 +00:00
|
|
|
int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:57 +00:00
|
|
|
struct wid wid_list[4];
|
|
|
|
int i = 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:57 +00:00
|
|
|
if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
|
|
|
|
wid_list[i].id = WID_SHORT_RETRY_LIMIT;
|
|
|
|
wid_list[i].val = (s8 *)¶m->short_retry_limit;
|
|
|
|
wid_list[i].type = WID_SHORT;
|
|
|
|
wid_list[i].size = sizeof(u16);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (param->flag & WILC_CFG_PARAM_RETRY_LONG) {
|
|
|
|
wid_list[i].id = WID_LONG_RETRY_LIMIT;
|
|
|
|
wid_list[i].val = (s8 *)¶m->long_retry_limit;
|
|
|
|
wid_list[i].type = WID_SHORT;
|
|
|
|
wid_list[i].size = sizeof(u16);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) {
|
|
|
|
wid_list[i].id = WID_FRAG_THRESHOLD;
|
|
|
|
wid_list[i].val = (s8 *)¶m->frag_threshold;
|
|
|
|
wid_list[i].type = WID_SHORT;
|
|
|
|
wid_list[i].size = sizeof(u16);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) {
|
|
|
|
wid_list[i].id = WID_RTS_THRESHOLD;
|
|
|
|
wid_list[i].val = (s8 *)¶m->rts_threshold;
|
|
|
|
wid_list[i].type = WID_SHORT;
|
|
|
|
wid_list[i].size = sizeof(u16);
|
|
|
|
i++;
|
2015-09-16 18:36:01 +09:00
|
|
|
}
|
2015-10-13 19:49:26 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-09-04 12:09:28 +05:30
|
|
|
static void get_periodic_rssi(struct timer_list *t)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-09-04 12:09:28 +05:30
|
|
|
struct wilc_vif *vif = from_timer(vif, t, periodic_rssi);
|
2015-06-26 16:45:14 +02:00
|
|
|
|
2015-12-21 14:18:41 +09:00
|
|
|
if (!vif->hif_drv) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-04 18:15:24 +09:00
|
|
|
if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
|
2018-12-02 18:03:25 +00:00
|
|
|
wilc_get_stats_async(vif, &vif->periodic_stat);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-09-04 12:09:28 +05:30
|
|
|
mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2016-01-05 23:06:57 +09:00
|
|
|
int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2015-10-12 16:56:05 +09:00
|
|
|
struct host_if_drv *hif_drv;
|
2018-07-19 04:15:19 +05:30
|
|
|
struct wilc_vif *vif = netdev_priv(dev);
|
2015-10-27 18:27:49 +09:00
|
|
|
|
2016-09-16 16:23:02 +05:30
|
|
|
hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
|
2018-04-23 22:03:31 +05:30
|
|
|
if (!hif_drv)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2015-10-12 16:56:05 +09:00
|
|
|
*hif_drv_handler = hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:40:58 +00:00
|
|
|
vif->hif_drv = hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-09-04 12:09:28 +05:30
|
|
|
timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0);
|
|
|
|
mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
|
|
|
|
|
2018-02-19 20:59:40 +05:30
|
|
|
timer_setup(&hif_drv->scan_timer, timer_scan_cb, 0);
|
|
|
|
timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0);
|
2018-02-19 20:59:41 +05:30
|
|
|
timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-29 11:58:24 +09:00
|
|
|
hif_drv->hif_state = HOST_IF_IDLE;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-29 12:05:39 +09:00
|
|
|
hif_drv->p2p_timeout = 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-04-23 22:03:31 +05:30
|
|
|
return 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2016-02-05 10:35:13 +09:00
|
|
|
int wilc_deinit(struct wilc_vif *vif)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2016-02-05 10:35:13 +09:00
|
|
|
int result = 0;
|
2015-12-21 14:18:40 +09:00
|
|
|
struct host_if_drv *hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-19 04:15:11 +05:30
|
|
|
if (!hif_drv) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
|
2016-02-05 10:35:14 +09:00
|
|
|
return -EFAULT;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_lock(&vif->wilc->deinit_lock);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2016-02-04 18:24:04 +09:00
|
|
|
del_timer_sync(&hif_drv->scan_timer);
|
|
|
|
del_timer_sync(&hif_drv->connect_timer);
|
2018-09-04 12:09:28 +05:30
|
|
|
del_timer_sync(&vif->periodic_rssi);
|
2015-10-29 11:58:36 +09:00
|
|
|
del_timer_sync(&hif_drv->remain_on_ch_timer);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-29 11:58:50 +09:00
|
|
|
if (hif_drv->usr_scan_req.scan_result) {
|
|
|
|
hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
|
2019-01-17 13:21:18 +00:00
|
|
|
hif_drv->usr_scan_req.arg);
|
2015-10-29 11:58:50 +09:00
|
|
|
hif_drv->usr_scan_req.scan_result = NULL;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-10-29 11:58:24 +09:00
|
|
|
hif_drv->hif_state = HOST_IF_IDLE;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-12 16:56:05 +09:00
|
|
|
kfree(hif_drv);
|
2019-02-05 07:15:31 +00:00
|
|
|
vif->hif_drv = NULL;
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_unlock(&vif->wilc->deinit_lock);
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2017-03-07 19:26:41 -05:00
|
|
|
void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
2015-08-20 16:32:52 +09:00
|
|
|
int id;
|
2018-07-19 04:15:16 +05:30
|
|
|
struct host_if_drv *hif_drv;
|
2015-12-21 14:18:43 +09:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:10 +00:00
|
|
|
id = get_unaligned_le32(&buffer[length - 4]);
|
2015-12-21 14:18:43 +09:00
|
|
|
vif = wilc_get_vif_from_idx(wilc, id);
|
|
|
|
if (!vif)
|
|
|
|
return;
|
|
|
|
hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:31 +00:00
|
|
|
if (!hif_drv) {
|
2016-02-22 13:12:02 +09:00
|
|
|
netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv);
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:21 +00:00
|
|
|
msg->body.net_info.frame_len = get_unaligned_le16(&buffer[6]) - 1;
|
|
|
|
msg->body.net_info.rssi = buffer[8];
|
|
|
|
msg->body.net_info.mgmt = kmemdup(&buffer[9],
|
|
|
|
msg->body.net_info.frame_len,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!msg->body.net_info.mgmt) {
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
2018-03-26 17:15:56 +05:30
|
|
|
return;
|
2018-06-26 11:37:05 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-03-26 17:15:56 +05:30
|
|
|
if (result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
|
2019-01-17 13:21:21 +00:00
|
|
|
kfree(msg->body.net_info.mgmt);
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
2018-03-26 17:15:56 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2017-03-07 19:26:44 -05:00
|
|
|
void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
2015-08-20 16:32:52 +09:00
|
|
|
int id;
|
2018-07-19 04:15:16 +05:30
|
|
|
struct host_if_drv *hif_drv;
|
2015-12-21 14:18:43 +09:00
|
|
|
struct wilc_vif *vif;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_lock(&wilc->deinit_lock);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:10 +00:00
|
|
|
id = get_unaligned_le32(&buffer[length - 4]);
|
2015-12-21 14:18:43 +09:00
|
|
|
vif = wilc_get_vif_from_idx(wilc, id);
|
|
|
|
if (!vif) {
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_unlock(&wilc->deinit_lock);
|
2015-12-21 14:18:43 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:31 +00:00
|
|
|
if (!hif_drv) {
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_unlock(&wilc->deinit_lock);
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:32 +00:00
|
|
|
if (!hif_drv->conn_info.conn_result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_unlock(&wilc->deinit_lock);
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg)) {
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_unlock(&wilc->deinit_lock);
|
2018-06-26 11:37:05 +05:30
|
|
|
return;
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:35 +00:00
|
|
|
msg->body.mac_info.status = buffer[7];
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-03-26 17:16:03 +05:30
|
|
|
if (result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
2018-03-26 17:16:03 +05:30
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:54 +00:00
|
|
|
mutex_unlock(&wilc->deinit_lock);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2017-03-07 19:26:37 -05:00
|
|
|
void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:17 +05:30
|
|
|
int result;
|
2015-08-20 16:32:52 +09:00
|
|
|
int id;
|
2018-07-19 04:15:16 +05:30
|
|
|
struct host_if_drv *hif_drv;
|
2015-12-21 14:18:43 +09:00
|
|
|
struct wilc_vif *vif;
|
2015-06-26 16:45:14 +02:00
|
|
|
|
2019-01-17 13:21:10 +00:00
|
|
|
id = get_unaligned_le32(&buffer[length - 4]);
|
2015-12-21 14:18:43 +09:00
|
|
|
vif = wilc_get_vif_from_idx(wilc, id);
|
|
|
|
if (!vif)
|
|
|
|
return;
|
|
|
|
hif_drv = vif->hif_drv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-05 07:15:31 +00:00
|
|
|
if (!hif_drv)
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
|
2015-10-29 11:58:50 +09:00
|
|
|
if (hif_drv->usr_scan_req.scan_result) {
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
msg = wilc_alloc_work(vif, handle_scan_complete, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: enqueue work failed\n",
|
|
|
|
__func__);
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
|
2016-01-03 17:35:36 +09:00
|
|
|
u32 duration, u16 chan,
|
2019-02-05 07:15:39 +00:00
|
|
|
void (*expired)(void *, u64),
|
2016-01-03 17:35:39 +09:00
|
|
|
void *user_arg)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_remain_ch roc;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:03:22 +00:00
|
|
|
roc.ch = chan;
|
|
|
|
roc.expired = expired;
|
|
|
|
roc.arg = user_arg;
|
|
|
|
roc.duration = duration;
|
2019-02-05 07:15:39 +00:00
|
|
|
roc.cookie = cookie;
|
2018-12-02 18:03:22 +00:00
|
|
|
result = handle_remain_on_chan(vif, &roc);
|
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "%s: failed to set remain on channel\n",
|
|
|
|
__func__);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-02-05 07:15:39 +00:00
|
|
|
int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2019-06-26 12:40:45 +00:00
|
|
|
if (!vif->hif_drv) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: hif driver is NULL", __func__);
|
2015-09-16 18:36:01 +09:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:40:45 +00:00
|
|
|
del_timer(&vif->hif_drv->remain_on_ch_timer);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:40:45 +00:00
|
|
|
return wilc_handle_roc_expired(vif, cookie);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-09-25 11:53:16 +05:30
|
|
|
void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:51 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:02:51 +00:00
|
|
|
struct wilc_reg_frame reg_frame;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:51 +00:00
|
|
|
wid.id = WID_REGISTER_FRAME;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = sizeof(reg_frame);
|
|
|
|
wid.val = (u8 *)®_frame;
|
|
|
|
|
|
|
|
memset(®_frame, 0x0, sizeof(reg_frame));
|
2019-11-05 09:51:22 +00:00
|
|
|
|
|
|
|
if (reg)
|
|
|
|
reg_frame.reg = 1;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-12-30 21:15:26 +09:00
|
|
|
switch (frame_type) {
|
2018-11-12 05:45:03 +00:00
|
|
|
case IEEE80211_STYPE_ACTION:
|
2018-12-02 18:02:51 +00:00
|
|
|
reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX;
|
2015-05-11 14:30:56 +09:00
|
|
|
break;
|
|
|
|
|
2018-11-12 05:45:03 +00:00
|
|
|
case IEEE80211_STYPE_PROBE_REQ:
|
2018-12-02 18:02:51 +00:00
|
|
|
reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX;
|
2015-05-11 14:30:56 +09:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-12-02 18:02:51 +00:00
|
|
|
reg_frame.frame_type = cpu_to_le16(frame_type);
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:51 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to frame register\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2016-01-03 17:35:57 +09:00
|
|
|
int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
|
2018-12-02 18:02:48 +00:00
|
|
|
struct cfg80211_beacon_data *params)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:48 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:02:48 +00:00
|
|
|
u8 *cur_byte;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:48 +00:00
|
|
|
wid.id = WID_ADD_BEACON;
|
|
|
|
wid.type = WID_BIN;
|
|
|
|
wid.size = params->head_len + params->tail_len + 16;
|
|
|
|
wid.val = kzalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wid.val)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:48 +00:00
|
|
|
cur_byte = wid.val;
|
|
|
|
put_unaligned_le32(interval, cur_byte);
|
|
|
|
cur_byte += 4;
|
|
|
|
put_unaligned_le32(dtim_period, cur_byte);
|
|
|
|
cur_byte += 4;
|
|
|
|
put_unaligned_le32(params->head_len, cur_byte);
|
|
|
|
cur_byte += 4;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:48 +00:00
|
|
|
if (params->head_len > 0)
|
|
|
|
memcpy(cur_byte, params->head, params->head_len);
|
|
|
|
cur_byte += params->head_len;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:48 +00:00
|
|
|
put_unaligned_le32(params->tail_len, cur_byte);
|
|
|
|
cur_byte += 4;
|
|
|
|
|
|
|
|
if (params->tail_len > 0)
|
|
|
|
memcpy(cur_byte, params->tail, params->tail_len);
|
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2015-10-19 18:26:08 +09:00
|
|
|
if (result)
|
2018-12-02 18:02:48 +00:00
|
|
|
netdev_err(vif->ndev, "Failed to send add beacon\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:48 +00:00
|
|
|
kfree(wid.val);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_del_beacon(struct wilc_vif *vif)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:02:45 +00:00
|
|
|
struct wid wid;
|
|
|
|
u8 del_beacon = 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:45 +00:00
|
|
|
wid.id = WID_DEL_BEACON;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.size = sizeof(char);
|
|
|
|
wid.val = &del_beacon;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:45 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to send delete beacon\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
|
|
|
|
struct station_parameters *params)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:34 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:02:34 +00:00
|
|
|
u8 *cur_byte;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
wid.id = WID_ADD_STA;
|
|
|
|
wid.type = WID_BIN;
|
|
|
|
wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len;
|
|
|
|
wid.val = kmalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wid.val)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
cur_byte = wid.val;
|
2018-12-02 18:02:36 +00:00
|
|
|
wilc_hif_pack_sta_param(cur_byte, mac, params);
|
2018-12-02 18:02:34 +00:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:34 +00:00
|
|
|
if (result != 0)
|
|
|
|
netdev_err(vif->ndev, "Failed to send add station\n");
|
|
|
|
|
|
|
|
kfree(wid.val);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:18:40 +09:00
|
|
|
int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:40 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:40 +00:00
|
|
|
wid.id = WID_REMOVE_STA;
|
|
|
|
wid.type = WID_BIN;
|
|
|
|
wid.size = ETH_ALEN;
|
|
|
|
wid.val = kzalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wid.val)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-11-06 19:11:14 +09:00
|
|
|
if (!mac_addr)
|
2018-12-02 18:02:40 +00:00
|
|
|
eth_broadcast_addr(wid.val);
|
2015-05-11 14:30:56 +09:00
|
|
|
else
|
2018-12-02 18:02:40 +00:00
|
|
|
ether_addr_copy(wid.val, mac_addr);
|
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:40 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to del station\n");
|
|
|
|
|
|
|
|
kfree(wid.val);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
2015-10-13 19:49:26 +09:00
|
|
|
|
2016-01-03 17:35:50 +09:00
|
|
|
int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:40 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2016-01-03 17:35:53 +09:00
|
|
|
int i;
|
2016-01-03 17:35:54 +09:00
|
|
|
u8 assoc_sta = 0;
|
2019-02-07 11:29:01 +00:00
|
|
|
struct wilc_del_all_sta del_sta;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:40 +00:00
|
|
|
memset(&del_sta, 0x0, sizeof(del_sta));
|
2018-11-12 05:45:29 +00:00
|
|
|
for (i = 0; i < WILC_MAX_NUM_STA; i++) {
|
2018-12-02 18:02:43 +00:00
|
|
|
if (!is_zero_ether_addr(mac_addr[i])) {
|
2016-01-03 17:35:54 +09:00
|
|
|
assoc_sta++;
|
2018-12-02 18:02:40 +00:00
|
|
|
ether_addr_copy(del_sta.mac[i], mac_addr[i]);
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
}
|
2018-12-02 18:02:40 +00:00
|
|
|
|
|
|
|
if (!assoc_sta)
|
2018-06-26 11:37:05 +05:30
|
|
|
return 0;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:40 +00:00
|
|
|
del_sta.assoc_sta = assoc_sta;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:40 +00:00
|
|
|
wid.id = WID_DEL_ALL_STA;
|
|
|
|
wid.type = WID_STR;
|
|
|
|
wid.size = (assoc_sta * ETH_ALEN) + 1;
|
|
|
|
wid.val = (u8 *)&del_sta;
|
2018-06-26 11:37:06 +05:30
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:40 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to send delete all station\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
|
|
|
|
struct station_parameters *params)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-12-02 18:02:34 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:02:34 +00:00
|
|
|
u8 *cur_byte;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
wid.id = WID_EDIT_STA;
|
|
|
|
wid.type = WID_BIN;
|
|
|
|
wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len;
|
|
|
|
wid.val = kmalloc(wid.size, GFP_KERNEL);
|
|
|
|
if (!wid.val)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
cur_byte = wid.val;
|
2018-12-02 18:02:36 +00:00
|
|
|
wilc_hif_pack_sta_param(cur_byte, mac, params);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:34 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to send edit station\n");
|
2015-09-16 18:36:01 +09:00
|
|
|
|
2018-12-02 18:02:34 +00:00
|
|
|
kfree(wid.val);
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
2015-09-16 18:53:20 +09:00
|
|
|
|
2015-12-30 21:15:32 +09:00
|
|
|
int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2021-12-10 20:30:22 +00:00
|
|
|
struct wilc *wilc = vif->wilc;
|
2018-12-02 18:02:31 +00:00
|
|
|
struct wid wid;
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-12-02 18:02:31 +00:00
|
|
|
s8 power_mode;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:31 +00:00
|
|
|
if (enabled)
|
|
|
|
power_mode = WILC_FW_MIN_FAST_PS;
|
|
|
|
else
|
|
|
|
power_mode = WILC_FW_NO_POWERSAVE;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-12-02 18:02:31 +00:00
|
|
|
wid.id = WID_POWER_MANAGEMENT;
|
|
|
|
wid.val = &power_mode;
|
|
|
|
wid.size = sizeof(char);
|
2019-06-26 12:41:04 +00:00
|
|
|
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2018-12-02 18:02:31 +00:00
|
|
|
if (result)
|
|
|
|
netdev_err(vif->ndev, "Failed to send power management\n");
|
2021-12-10 20:30:22 +00:00
|
|
|
else
|
|
|
|
wilc->power_save_mode = enabled;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-01-17 13:21:41 +00:00
|
|
|
int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
|
2018-09-04 12:09:26 +05:30
|
|
|
u8 *mc_list)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-07-19 04:15:16 +05:30
|
|
|
int result;
|
2018-06-26 11:37:05 +05:30
|
|
|
struct host_if_msg *msg;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:06 +05:30
|
|
|
msg = wilc_alloc_work(vif, handle_set_mcast_filter, false);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (IS_ERR(msg))
|
|
|
|
return PTR_ERR(msg);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-01-17 13:21:41 +00:00
|
|
|
msg->body.mc_info.enabled = enabled;
|
|
|
|
msg->body.mc_info.cnt = count;
|
|
|
|
msg->body.mc_info.mc_list = mc_list;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-06-26 11:37:08 +05:30
|
|
|
result = wilc_enqueue_work(msg);
|
2018-06-26 11:37:05 +05:30
|
|
|
if (result) {
|
2018-07-29 11:36:53 +05:30
|
|
|
netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__);
|
2018-06-26 11:37:05 +05:30
|
|
|
kfree(msg);
|
|
|
|
}
|
2015-10-19 18:26:08 +09:00
|
|
|
return result;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2016-02-04 18:15:27 +09:00
|
|
|
int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
|
|
|
|
{
|
2018-12-02 18:02:28 +00:00
|
|
|
struct wid wid;
|
2016-02-04 18:15:27 +09:00
|
|
|
|
2018-12-02 18:02:28 +00:00
|
|
|
wid.id = WID_TX_POWER;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.val = &tx_power;
|
|
|
|
wid.size = sizeof(char);
|
2016-02-04 18:15:27 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1);
|
2016-02-04 18:15:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
|
|
|
|
{
|
2018-12-02 18:02:28 +00:00
|
|
|
struct wid wid;
|
2016-02-04 18:15:27 +09:00
|
|
|
|
2018-12-02 18:02:28 +00:00
|
|
|
wid.id = WID_TX_POWER;
|
|
|
|
wid.type = WID_CHAR;
|
|
|
|
wid.val = tx_power;
|
|
|
|
wid.size = sizeof(char);
|
2016-02-04 18:15:27 +09:00
|
|
|
|
2019-06-26 12:41:04 +00:00
|
|
|
return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1);
|
2016-02-04 18:15:27 +09:00
|
|
|
}
|