BigW Consortium Gitlab

Commit 4cb4b66d by David Clark

Updates to get MT7697 WiFi working on Wp76

parent 12440482
......@@ -26,19 +26,26 @@ static int mt7697_uart_rx_poll(struct mt7697_uart_info* uart_info)
int mask;
int ret = 0;
WARN_ON(!uart_info->fd_hndl->f_op->poll);
poll_initwait(&table);
while (1) {
if (!uart_info->fd_hndl->f_op->poll) {
dev_err(uart_info->dev,
"%s(): no poll function\n", __func__);
ret = -EINVAL;
mask = uart_info->fd_hndl->f_op->poll(uart_info->fd_hndl, &table.pt);
if (mask & POLLERR) {
dev_warn(uart_info->dev,
"%s(): poll error\n", __func__);
ret = -EIO;
goto cleanup;
}
mask = uart_info->fd_hndl->f_op->poll(uart_info->fd_hndl, &table.pt);
if (mask & (POLLRDNORM | POLLRDBAND | POLLIN |POLLHUP | POLLERR)) {
dev_dbg(uart_info->dev, "%s(): Rx data\n", __func__);
else if (mask & POLLHUP) {
dev_warn(uart_info->dev,
"%s(): poll hangup\n", __func__);
ret = -EPIPE;
goto cleanup;
}
else if (mask & (POLLRDNORM | POLLRDBAND | POLLIN)) {
dev_dbg(uart_info->dev, "%s(): Rx data mask(0x%08x)\n",
__func__, mask);
break;
}
......@@ -68,6 +75,7 @@ static void mt7697_uart_rx_work(struct work_struct *rx_work)
struct mt7697_uart_info* uart_info = container_of(rx_work,
struct mt7697_uart_info, rx_work);
size_t ret;
int err;
while (1) {
ret = mt7697_uart_rx_poll(uart_info);
......@@ -78,7 +86,7 @@ static void mt7697_uart_rx_work(struct work_struct *rx_work)
goto cleanup;
}
if (uart_info->close) {
if (atomic_read(&uart_info->close)) {
dev_warn(uart_info->dev, "%s(): closed\n", __func__);
goto cleanup;
}
......@@ -107,18 +115,19 @@ static void mt7697_uart_rx_work(struct work_struct *rx_work)
}
WARN_ON(!uart_info->rx_fcn);
ret = uart_info->rx_fcn((const struct mt7697_rsp_hdr*)&uart_info->rsp,
err = uart_info->rx_fcn((const struct mt7697_rsp_hdr*)&uart_info->rsp,
uart_info->rx_hndl);
if (ret < 0) {
dev_dbg(uart_info->dev, "%s(): rx_fcn ret(%d)\n", __func__, err);
if (err < 0) {
dev_err(uart_info->dev,
"%s(): rx_fcn() failed(%d)\n",
__func__, ret);
__func__, err);
}
}
cleanup:
dev_warn(uart_info->dev, "%s(): task ended\n", __func__);
uart_info->close = 0;
atomic_set(&uart_info->close, 0);
wake_up_interruptible(&uart_info->close_wq);
return;
}
......@@ -167,6 +176,7 @@ void* mt7697_uart_open(rx_hndlr rx_fcn, void* rx_hndl)
uart_info->rx_fcn = rx_fcn;
uart_info->rx_hndl = rx_hndl;
atomic_set(&uart_info->close, 0);
schedule_work(&uart_info->rx_work);
ret = uart_info;
......@@ -186,9 +196,14 @@ int mt7697_uart_close(void *arg)
dev_dbg(uart_info->dev, "%s(): fd_hndl(%p)\n",
__func__, uart_info->fd_hndl);
WARN_ON (!uart_info->fd_hndl);
uart_info->close = 1;
if (uart_info->fd_hndl == MT7697_UART_INVALID_FD ||
IS_ERR(uart_info->fd_hndl)) {
dev_warn(uart_info->dev, "%s(): device closed\n", __func__);
goto cleanup;
}
atomic_set(&uart_info->close, 1);
ret = filp_close(uart_info->fd_hndl, 0);
if (ret < 0) {
dev_err(uart_info->dev, "%s(): filp_close() failed(%d)\n",
......@@ -196,7 +211,7 @@ int mt7697_uart_close(void *arg)
goto cleanup;
}
wait_event_interruptible(uart_info->close_wq, !uart_info->close);
wait_event_interruptible(uart_info->close_wq, !atomic_read(&uart_info->close));
cancel_work_sync(&uart_info->rx_work);
uart_info->fd_hndl = MT7697_UART_INVALID_FD;
......@@ -211,10 +226,8 @@ size_t mt7697_uart_read(void *arg, u32 *buf, size_t len)
mm_segment_t oldfs;
struct mt7697_uart_info *uart_info = arg;
u8* ptr = (u8*)buf;
loff_t offset = 0;
size_t ret = 0;
unsigned long count = len * sizeof(u32);
unsigned long end = count;
int err;
oldfs = get_fs();
......@@ -226,8 +239,8 @@ size_t mt7697_uart_read(void *arg, u32 *buf, size_t len)
}
dev_dbg(uart_info->dev, "%s(): len(%u)\n", __func__, len * sizeof(u32));
while (offset < end) {
err = kernel_read(uart_info->fd_hndl, offset, ptr, count);
while (1) {
err = kernel_read(uart_info->fd_hndl, 0, ptr, count);
dev_dbg(uart_info->dev, "%s(): read(%d)\n", __func__, err);
if (err < 0) {
dev_err(uart_info->dev, "%s(): kernel_read() failed(%d)\n",
......@@ -240,8 +253,9 @@ size_t mt7697_uart_read(void *arg, u32 *buf, size_t len)
}
count -= err;
if (!count) break;
ptr += err;
offset += err;
}
ret = len;
......@@ -257,8 +271,7 @@ EXPORT_SYMBOL(mt7697_uart_read);
size_t mt7697_uart_write(void *arg, const u32 *buf, size_t len)
{
mm_segment_t oldfs;
loff_t pos = 0;
size_t num_write;
ssize_t num_write;
size_t end = len * sizeof(u32);
size_t left = end;
size_t ret = 0;
......@@ -274,20 +287,26 @@ size_t mt7697_uart_write(void *arg, const u32 *buf, size_t len)
}
dev_dbg(uart_info->dev, "%s(): len(%u)\n", __func__, len);
while (pos < end) {
num_write = kernel_write(uart_info->fd_hndl, ptr, left, pos);
while (1) {
num_write = kernel_write(uart_info->fd_hndl, ptr, left, 0);
dev_dbg(uart_info->dev, "%s(): written(%u)\n", __func__, num_write);
if (!num_write) {
dev_dbg(uart_info->dev, "%s(): WRITE no data\n", __func__);
if (num_write < 0) {
dev_err(uart_info->dev, "%s(): kernel_write() failed(%d)\n",
__func__, num_write);
goto cleanup;
}
else if (!num_write) {
dev_warn(uart_info->dev, "%s(): CLOSED\n", __func__);
goto cleanup;
}
ptr += num_write;
pos += num_write;
left -= num_write;
if (!left) break;
ptr += num_write;
}
ret = LEN_TO_WORD(pos);
ret = len;
cleanup:
dev_dbg(uart_info->dev, "%s(): return(%u)\n", __func__, ret);
......
......@@ -26,6 +26,9 @@
#define MT7697_UART_DEVICE "/dev/ttyHS0"
#define MT7697_UART_INVALID_FD NULL
#define mt7697_uart_reset_req mt7697_cmd_hdr
#define mt7697_uart_reset_rsp mt7697_rsp_hdr
struct mt7697_uart_info {
struct platform_device *pdev;
struct device *dev;
......@@ -39,7 +42,7 @@ struct mt7697_uart_info {
void *rx_hndl;
wait_queue_head_t close_wq;
int close;
atomic_t close;
};
#endif
......@@ -269,9 +269,16 @@ static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
dev_dbg(cfg->dev, "%s(): band(%u) chan(%u)\n",
__func__, chan->band, chan->center_freq);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
bss = cfg80211_get_bss(cfg->wiphy, chan, bssid,
vif->ssid, vif->ssid_len,
CFG80211_BSS_FTYPE_UNKNOWN,
IEEE80211_PRIVACY_ANY);
#else
bss = cfg80211_get_bss(cfg->wiphy, chan, bssid,
vif->ssid, vif->ssid_len,
WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
#endif
if (!bss) {
/*
* Since cfg80211 may not yet know about the BSS,
......@@ -295,10 +302,18 @@ static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
print_hex_dump(KERN_DEBUG, DRVNAME" inform bss BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
bss = cfg80211_inform_bss(cfg->wiphy, chan,
CFG80211_BSS_FTYPE_UNKNOWN,
bssid, 0, WLAN_CAPABILITY_ESS, 100,
ie, 2 + vif->ssid_len,
0, GFP_KERNEL);
#else
bss = cfg80211_inform_bss(cfg->wiphy, chan,
bssid, 0, WLAN_CAPABILITY_ESS, 100,
ie, 2 + vif->ssid_len,
0, GFP_KERNEL);
#endif
if (!bss) {
dev_err(cfg->dev,
"%s(): cfg80211_inform_bss() failed\n",
......@@ -768,10 +783,17 @@ static int mt7697_cfg80211_change_beacon(struct wiphy *wiphy,
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_add_station(struct wiphy *wiphy,
struct net_device *ndev,
const u8 *mac,
struct station_parameters *params)
#else
static int mt7697_cfg80211_add_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac,
struct station_parameters *params)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s(): ADD STATION\n", __func__);
......@@ -784,10 +806,17 @@ static int mt7697_cfg80211_add_station(struct wiphy *wiphy,
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_get_station(struct wiphy *wiphy,
struct net_device *ndev,
const u8 *mac,
struct station_info *sinfo)
#else
static int mt7697_cfg80211_get_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac,
struct station_info *sinfo)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s(): CHANGE STATION\n", __func__);
......@@ -800,25 +829,39 @@ static int mt7697_cfg80211_get_station(struct wiphy *wiphy,
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_del_station(struct wiphy *wiphy,
struct net_device *ndev,
struct station_del_parameters *params)
#else
static int mt7697_cfg80211_del_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s(): DEL STATION\n", __func__);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,44)
if (mac) {
print_hex_dump(KERN_DEBUG, DRVNAME" MAC ",
DUMP_PREFIX_OFFSET, 16, 1, mac, ETH_ALEN, 0);
}
#endif
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_change_station(struct wiphy *wiphy,
struct net_device *ndev,
const u8 *mac,
struct station_parameters *params)
#else
static int mt7697_cfg80211_change_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac,
struct station_parameters *params)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
......@@ -993,7 +1036,12 @@ int mt7697_cfg80211_stop(struct mt7697_vif *vif)
GFP_KERNEL);
break;
case SME_CONNECTED:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
cfg80211_disconnected(vif->ndev, 0, NULL, 0,
vif->locally_generated, GFP_KERNEL);
#else
cfg80211_disconnected(vif->ndev, 0, NULL, 0, GFP_KERNEL);
#endif
break;
}
}
......@@ -1082,27 +1130,6 @@ int mt7697_cfg80211_stop(struct mt7697_vif *vif)
vif->cfg->radio_state = MT7697_RADIO_STATE_OFF;
}
if (vif->cfg->hif_ops->shutdown) {
ret = vif->cfg->hif_ops->shutdown(&vif->cfg->txq_hdl, &vif->cfg->rxq_hdl);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): shutdown() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
else {
ret = vif->cfg->hif_ops->close(vif->cfg->txq_hdl);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): shutdown() failed(%d)\n",
__func__, ret);
goto cleanup;
}
vif->cfg->rxq_hdl = NULL;
}
/* Stop netdev queues, needed during recovery */
netif_stop_queue(vif->ndev);
netif_carrier_off(vif->ndev);
......@@ -1167,12 +1194,32 @@ cleanup:
static void mt7697_cleanup_vif(struct mt7697_cfg80211_info *cfg)
{
struct mt7697_vif *vif, *vif_next = NULL;
int ret;
spin_lock_bh(&cfg->vif_list_lock);
list_for_each_entry_safe(vif, vif_next, &cfg->vif_list, next) {
dev_dbg(cfg->dev, "%s(): remove vif(%u)\n",
__func__, vif->fw_vif_idx);
if (vif->cfg->hif_ops->shutdown) {
ret = vif->cfg->hif_ops->shutdown(&vif->cfg->txq_hdl, &vif->cfg->rxq_hdl);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): shutdown() failed(%d)\n",
__func__, ret);
}
}
else {
ret = vif->cfg->hif_ops->close(vif->cfg->txq_hdl);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): shutdown() failed(%d)\n",
__func__, ret);
}
vif->cfg->rxq_hdl = NULL;
}
list_del(&vif->next);
WARN_ON(vif->sta_count > 0);
spin_unlock_bh(&cfg->vif_list_lock);
......@@ -1378,6 +1425,10 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
spin_lock_bh(&vif->if_lock);
set_bit(CONNECTED, &vif->flags);
clear_bit(CONNECT_PEND, &vif->flags);
dev_dbg(cfg->dev, "%s(): vif flags(0x%08lx)\n", __func__, vif->flags);
if ((channel > 0) && (channel <= MT7697_CH_MAX_2G_CHANNEL))
band = wiphy->bands[IEEE80211_BAND_2GHZ];
else if ((channel >= MT7697_CH_MIN_5G_CHANNEL) &&
......@@ -1435,10 +1486,6 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
GFP_KERNEL);
}
set_bit(CONNECTED, &vif->flags);
clear_bit(CONNECT_PEND, &vif->flags);
dev_dbg(cfg->dev, "%s(): vif flags(0x%08lx)\n", __func__, vif->flags);
netif_wake_queue(vif->ndev);
netif_carrier_on(vif->ndev);
......
......@@ -17,6 +17,7 @@
#ifndef _MT7697_CORE_H_
#define _MT7697_CORE_H_
#include <linux/version.h>
#include <net/cfg80211.h>
#include <net/iw_handler.h> /* New driver API */
#include "mt7697_i.h"
......@@ -189,6 +190,9 @@ struct mt7697_vif {
u8 listen_intvl_t;
struct net_device_stats net_stats;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
bool locally_generated;
#endif
};
static inline struct wiphy *cfg_to_wiphy(struct mt7697_cfg80211_info *cfg)
......
......@@ -35,6 +35,7 @@ static int mt7697_wext_siwfreq(struct net_device *ndev,
struct wireless_dev *wdev = ndev->ieee80211_ptr;
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
int chan = -1;
int ret = 0;
if ((frq->e == 0) && (frq->m <= 1000)) {
/* Setting by channel number */
......@@ -42,6 +43,30 @@ static int mt7697_wext_siwfreq(struct net_device *ndev,
dev_dbg(cfg->dev, "%s(): freq(%u)\n", __func__, frq->m);
} else {
/* Setting by frequency */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
if (frq->e == 1 &&
frq->m / 100000 >= freq_list[0] &&
frq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
int ch;
int fr = frq->m / 100000;
for (ch = 0; ch < FREQ_COUNT; ch++) {
if (fr == freq_list[ch]) {
frq->e = 0;
frq->m = ch + 1;
break;
}
}
}
if (frq->e != 0 || frq->m < 1 || frq->m > FREQ_COUNT) {
dev_err(cfg->dev, "%s(): unsupported frequency(%u/%u)\n",
__func__, frq->e, frq->m);
ret = -EINVAL;
goto cleanup;
}
chan = frq->m;
#else
int denom = 1;
int i;
......@@ -50,11 +75,16 @@ static int mt7697_wext_siwfreq(struct net_device *ndev,
denom *= 10;
chan = ieee80211_freq_to_dsss_chan(frq->m / denom);
#endif
dev_dbg(cfg->dev, "%s(): chan(%u)\n", __func__, chan);
}
vif->ch_hint = chan;
return 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
cleanup:
#endif
return ret;
}
static int mt7697_wext_giwfreq(struct net_device *ndev,
......
......@@ -19,6 +19,10 @@
#include <net/iw_handler.h> /* New driver API */
static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484 };
#define FREQ_COUNT ARRAY_SIZE(freq_list)
#define SUPPORTED_WIRELESS_EXT 19
extern const struct iw_handler_def mt7697_wireless_hndlrs;
......
......@@ -378,6 +378,11 @@ int mt7697_disconnect(struct mt7697_vif *vif)
int ret = 0;
dev_dbg(vif->cfg->dev, "%s(): disconnect\n", __func__);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
vif->locally_generated = true;
#endif
if (test_bit(CONNECTED, &vif->flags) ||
test_bit(CONNECT_PEND, &vif->flags)) {
if (vif->sme_state == SME_CONNECTING)
......@@ -387,8 +392,14 @@ int mt7697_disconnect(struct mt7697_vif *vif)
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
else if (vif->sme_state == SME_CONNECTED) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
cfg80211_disconnected(vif->ndev, 0,
NULL, 0, vif->locally_generated,
GFP_KERNEL);
#else
cfg80211_disconnected(vif->ndev, 0,
NULL, 0, GFP_KERNEL);
#endif
}
ret = mt7697_wr_disconnect_req(vif->cfg, NULL);
......
......@@ -5,7 +5,7 @@
# MediaTek WIFI IoT board is managed by SPI bus.
mt_wifi_start() {
if [ `echo $1 | tr -s '[:upper:]' '[:lower:]` = `echo "uart" | tr -s '[:upper:]' '[:lower:]` ] ; then
if [ `echo $1 | tr -s '[:upper:]' '[:lower:]'` = `echo "uart" | tr -s '[:upper:]' '[:lower:]'` ] ; then
echo "Setup MT7697 UART";
stty -F /dev/ttyHS0 raw || exit 127
stty -F /dev/ttyHS0 921600 || exit 127
......@@ -25,7 +25,7 @@ mt_wifi_start() {
hw_itf=`echo $1 | tr '[A-Z]' '[a-z]'`
insmod /legato/systems/current/modules/2-mt7697wifi_core.ko hw_itf=$hw_itf itf_idx_start=$2 || exit 127
echo "Initialized MT7697 WiFi core";
sleep 2
sleep 5
fi
ifconfig -a | grep wlan$2 >/dev/null
......
......@@ -29,7 +29,7 @@ static int mt7697_proc_mac_addr(const struct mt7697_rsp_hdr* rsp,
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
char iname[MT7697_IFACE_NAME_LEN];
struct wireless_dev *wdev;
int ret = 0;
int ret;
dev_dbg(cfg->dev, "%s(): --> GET MAC ADDRESS RSP\n", __func__);
if (rsp->cmd.len != sizeof(struct mt7697_mac_addr_rsp)) {
......@@ -72,6 +72,7 @@ static int mt7697_proc_mac_addr(const struct mt7697_rsp_hdr* rsp,
dev_dbg(cfg->dev, "%s(): name/type('%s'/%u) netdev(0x%p), cfg(0x%p)\n",
__func__, wdev->netdev->name, wdev->iftype, wdev->netdev, cfg);
ret = 0;
cleanup:
return ret;
......@@ -81,7 +82,7 @@ static int mt7697_proc_get_wireless_mode(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 wireless_mode;
int ret = 0;
int ret;
dev_dbg(cfg->dev, "%s(): --> GET WIRELESS MODE RSP\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(u32)) {
......@@ -107,6 +108,7 @@ static int mt7697_proc_get_wireless_mode(const struct mt7697_rsp_hdr* rsp,
dev_dbg(cfg->dev, "%s(): wireless mode(%u)\n",
__func__, wireless_mode);
cfg->hw_wireless_mode = wireless_mode;
ret = 0;
cleanup:
return ret;
......@@ -117,7 +119,7 @@ static int mt7697_proc_get_cfg(const struct mt7697_rsp_hdr* rsp,
{
struct mt7697_wifi_config_t *wifi_cfg;
u8* rd_buf = NULL;
int ret = 0;
int ret;
dev_dbg(cfg->dev, "%s(): --> GET CONFIG RSP\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) !=
......@@ -259,6 +261,8 @@ static int mt7697_proc_get_cfg(const struct mt7697_rsp_hdr* rsp,
goto cleanup;
}
ret = 0;
cleanup:
if (rd_buf) kfree(rd_buf);
return ret;
......@@ -268,7 +272,7 @@ static int mt7697_proc_get_radio_state(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 state;
int ret = 0;
int ret;
dev_dbg(cfg->dev, "%s(): --> GET RADIO STATE RSP\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(u32)) {
......@@ -293,6 +297,7 @@ static int mt7697_proc_get_radio_state(const struct mt7697_rsp_hdr* rsp,
cfg->radio_state = state;
dev_dbg(cfg->dev, "%s(): radio state(%u)\n",
__func__, cfg->radio_state);
ret = 0;
cleanup:
return ret;
......@@ -302,7 +307,7 @@ static int mt7697_proc_get_listen_interval(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 interval;
int ret = 0;
int ret;
dev_dbg(cfg->dev, "%s(): --> GET LISTEN INTERVAL RSP\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(u32)) {
......@@ -327,6 +332,7 @@ static int mt7697_proc_get_listen_interval(const struct mt7697_rsp_hdr* rsp,
cfg->listen_interval = interval;
dev_dbg(cfg->dev, "%s(): listen interval(%u)\n",
__func__, cfg->listen_interval);
ret = 0;
cleanup:
return ret;
......@@ -339,7 +345,7 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
s32 rssi;
u32 ch;
u32 probe_rsp_len;
int ret = 0;
int ret;
__le16 fc;
dev_dbg(cfg->dev, "%s(): --> SCAN IND\n", __func__);
......@@ -467,6 +473,8 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
......@@ -506,6 +514,8 @@ static int mt7697_proc_scan_rsp(const struct mt7697_rsp_hdr* rsp,
vif->scan_req = NULL;
}
ret = 0;
cleanup:
return ret;
}
......@@ -539,6 +549,7 @@ static int mt7697_proc_scan_complete_ind(struct mt7697_cfg80211_info *cfg)
dev_dbg(cfg->dev, "%s(): vif(%u)\n", __func__, vif->fw_vif_idx);
cfg80211_scan_done(vif->scan_req, false);
vif->scan_req = NULL;
ret = 0;
cleanup:
return ret;
......@@ -646,6 +657,8 @@ static int mt7697_proc_connect_ind(const struct mt7697_rsp_hdr* rsp,
spin_unlock_bh(&vif->if_lock);
}
ret = 0;
cleanup:
return ret;
}
......@@ -653,6 +666,7 @@ cleanup:
static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
{
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)] = {0};
struct mt7697_vif *vif;
u32 if_idx;
u16 proto_reason = 0;
......@@ -698,7 +712,7 @@ static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
dev_dbg(cfg->dev, "%s(): vif(%u)\n", __func__, vif->fw_vif_idx);
if (vif->sme_state == SME_CONNECTING) {
ret = mt7697_wr_disconnect_req(vif->cfg, bssid);
ret = mt7697_wr_disconnect_req(vif->cfg, vif->bssid);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): mt7697_wr_disconnect_req() failed(%d)\n",
......@@ -706,23 +720,36 @@ static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
goto cleanup;
}
cfg80211_connect_result(vif->ndev, bssid,
cfg80211_connect_result(vif->ndev, vif->bssid,
NULL, 0,
NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
}
else if (vif->sme_state == SME_CONNECTED) {
ret = mt7697_wr_disconnect_req(vif->cfg, bssid);
ret = mt7697_wr_set_ssid_req(cfg, IEEE80211_MAX_SSID_LEN, ssid);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): mt7697_wr_disconnect_req() failed(%d)\n",
dev_err(cfg->dev,
"%s(): mt7697_wr_set_ssid_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = mt7697_wr_reload_settings_req(cfg, vif->fw_vif_idx);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_reload_settings_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
cfg80211_disconnected(vif->ndev, proto_reason,
NULL, 0, vif->locally_generated, GFP_KERNEL);
#else
cfg80211_disconnected(vif->ndev, proto_reason,
NULL, 0, GFP_KERNEL);
#endif
}
}
else {
......@@ -754,6 +781,8 @@ static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
__func__, vif->sme_state, vif->flags);
spin_unlock_bh(&vif->if_lock);
ret = 0;
cleanup:
return ret;
}
......@@ -807,6 +836,8 @@ static int mt7697_rx_raw(const struct mt7697_rsp_hdr* rsp,
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
......@@ -922,7 +953,6 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_rx_raw() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
......@@ -982,6 +1012,11 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
}
cleanup:
if (ret < 0) {
print_hex_dump(KERN_WARNING, DRVNAME" RSP ", DUMP_PREFIX_OFFSET,
16, 1, rsp, sizeof(struct mt7697_rsp_hdr), 0);
}
return ret;
}
......@@ -1041,9 +1076,9 @@ cleanup:
return ret;
}
int mt7697_wr_set_pmk_req(const struct mt7697_cfg80211_info *cfg,
const u8 pmk[MT7697_WIFI_LENGTH_PMK])
int mt7697_wr_set_pmk_req(const struct mt7697_cfg80211_info *cfg, const u8 *pmk)
{
u8 tmp[2*sizeof(u8) + 1];
struct mt7697_set_pmk_req req;
int i, ret;
......@@ -1052,8 +1087,10 @@ int mt7697_wr_set_pmk_req(const struct mt7697_cfg80211_info *cfg,
req.cmd.type = MT7697_CMD_SET_PMK_REQ;
req.port = cfg->port_type;
for (i = 0; i < MT7697_WIFI_LENGTH_PASSPHRASE / 2; i++)
sprintf(&req.pmk[i*2], "%02x", pmk[i]);
for (i = 0; i < MT7697_WIFI_LENGTH_PMK; i++) {
snprintf(tmp, sizeof(tmp), "%02x", pmk[i]);
memcpy(&req.pmk[i*2], tmp, 2*sizeof(u8));
}
dev_dbg(cfg->dev, "%s(): <-- SET PMK port(%u) len(%u)\n",
__func__, req.port, req.cmd.len);
......
......@@ -276,8 +276,7 @@ struct mt7697_rx_raw_packet {
int mt7697_wr_set_wireless_mode_req(const struct mt7697_cfg80211_info*, u8);
int mt7697_wr_get_wireless_mode_req(const struct mt7697_cfg80211_info*);
int mt7697_wr_set_pmk_req(const struct mt7697_cfg80211_info*,
const u8[MT7697_WIFI_LENGTH_PMK]);
int mt7697_wr_set_pmk_req(const struct mt7697_cfg80211_info*, const u8*);
int mt7697_wr_set_channel_req(const struct mt7697_cfg80211_info*, u8);
int mt7697_wr_set_bssid_req(const struct mt7697_cfg80211_info*, const u8[ETH_ALEN]);
int mt7697_wr_set_ssid_req(const struct mt7697_cfg80211_info*, u8, const u8[]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment