mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-10-30 07:38:52 +01:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
50
drivers/net/wireless/ath/wil6210/Kconfig
Normal file
50
drivers/net/wireless/ath/wil6210/Kconfig
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
config WIL6210
|
||||
tristate "Wilocity 60g WiFi card wil6210 support"
|
||||
depends on CFG80211
|
||||
depends on PCI
|
||||
default n
|
||||
---help---
|
||||
This module adds support for wireless adapter based on
|
||||
wil6210 chip by Wilocity. It supports operation on the
|
||||
60 GHz band, covered by the IEEE802.11ad standard.
|
||||
|
||||
http://wireless.kernel.org/en/users/Drivers/wil6210
|
||||
|
||||
If you choose to build it as a module, it will be called
|
||||
wil6210
|
||||
|
||||
config WIL6210_ISR_COR
|
||||
bool "Use Clear-On-Read mode for ISR registers for wil6210"
|
||||
depends on WIL6210
|
||||
default y
|
||||
---help---
|
||||
ISR registers on wil6210 chip may operate in either
|
||||
COR (Clear-On-Read) or W1C (Write-1-to-Clear) mode.
|
||||
For production code, use COR (say y); is default since
|
||||
it saves extra target transaction;
|
||||
For ISR debug, use W1C (say n); is allows to monitor ISR
|
||||
registers with debugfs. If COR were used, ISR would
|
||||
self-clear when accessed for debug purposes, it makes
|
||||
such monitoring impossible.
|
||||
Say y unless you debug interrupts
|
||||
|
||||
config WIL6210_TRACING
|
||||
bool "wil6210 tracing support"
|
||||
depends on WIL6210
|
||||
depends on EVENT_TRACING
|
||||
default y
|
||||
---help---
|
||||
Say Y here to enable tracepoints for the wil6210 driver
|
||||
using the kernel tracing infrastructure. Select this
|
||||
option if you are interested in debugging the driver.
|
||||
|
||||
If unsure, say Y to make it easier to debug problems.
|
||||
|
||||
config WIL6210_PLATFORM_MSM
|
||||
bool "wil6210 MSM platform specific support"
|
||||
depends on WIL6210
|
||||
depends on ARCH_MSM
|
||||
default y
|
||||
---help---
|
||||
Say Y here to enable wil6210 driver support for MSM
|
||||
platform specific features
|
||||
23
drivers/net/wireless/ath/wil6210/Makefile
Normal file
23
drivers/net/wireless/ath/wil6210/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
obj-$(CONFIG_WIL6210) += wil6210.o
|
||||
|
||||
wil6210-y := main.o
|
||||
wil6210-y += netdev.o
|
||||
wil6210-y += cfg80211.o
|
||||
wil6210-y += pcie_bus.o
|
||||
wil6210-y += debugfs.o
|
||||
wil6210-y += wmi.o
|
||||
wil6210-y += interrupt.o
|
||||
wil6210-y += txrx.o
|
||||
wil6210-y += debug.o
|
||||
wil6210-y += rx_reorder.o
|
||||
wil6210-y += ioctl.o
|
||||
wil6210-y += fw.o
|
||||
wil6210-$(CONFIG_WIL6210_TRACING) += trace.o
|
||||
wil6210-y += wil_platform.o
|
||||
wil6210-$(CONFIG_WIL6210_PLATFORM_MSM) += wil_platform_msm.o
|
||||
wil6210-y += ethtool.o
|
||||
|
||||
# for tracing framework to find trace.h
|
||||
CFLAGS_trace.o := -I$(src)
|
||||
|
||||
subdir-ccflags-y += -D__CHECK_ENDIAN__
|
||||
905
drivers/net/wireless/ath/wil6210/cfg80211.c
Normal file
905
drivers/net/wireless/ath/wil6210/cfg80211.c
Normal file
|
|
@ -0,0 +1,905 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "wil6210.h"
|
||||
#include "wmi.h"
|
||||
|
||||
#define CHAN60G(_channel, _flags) { \
|
||||
.band = IEEE80211_BAND_60GHZ, \
|
||||
.center_freq = 56160 + (2160 * (_channel)), \
|
||||
.hw_value = (_channel), \
|
||||
.flags = (_flags), \
|
||||
.max_antenna_gain = 0, \
|
||||
.max_power = 40, \
|
||||
}
|
||||
|
||||
static struct ieee80211_channel wil_60ghz_channels[] = {
|
||||
CHAN60G(1, 0),
|
||||
CHAN60G(2, 0),
|
||||
CHAN60G(3, 0),
|
||||
/* channel 4 not supported yet */
|
||||
};
|
||||
|
||||
static struct ieee80211_supported_band wil_band_60ghz = {
|
||||
.channels = wil_60ghz_channels,
|
||||
.n_channels = ARRAY_SIZE(wil_60ghz_channels),
|
||||
.ht_cap = {
|
||||
.ht_supported = true,
|
||||
.cap = 0, /* TODO */
|
||||
.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, /* TODO */
|
||||
.ampdu_density = IEEE80211_HT_MPDU_DENSITY_8, /* TODO */
|
||||
.mcs = {
|
||||
/* MCS 1..12 - SC PHY */
|
||||
.rx_mask = {0xfe, 0x1f}, /* 1..12 */
|
||||
.tx_params = IEEE80211_HT_MCS_TX_DEFINED, /* TODO */
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static const struct ieee80211_txrx_stypes
|
||||
wil_mgmt_stypes[NUM_NL80211_IFTYPES] = {
|
||||
[NL80211_IFTYPE_STATION] = {
|
||||
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
|
||||
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
|
||||
},
|
||||
[NL80211_IFTYPE_AP] = {
|
||||
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
|
||||
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
|
||||
},
|
||||
[NL80211_IFTYPE_P2P_CLIENT] = {
|
||||
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
|
||||
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
|
||||
},
|
||||
[NL80211_IFTYPE_P2P_GO] = {
|
||||
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
|
||||
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
|
||||
BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
|
||||
},
|
||||
};
|
||||
|
||||
static const u32 wil_cipher_suites[] = {
|
||||
WLAN_CIPHER_SUITE_GCMP,
|
||||
};
|
||||
|
||||
int wil_iftype_nl2wmi(enum nl80211_iftype type)
|
||||
{
|
||||
static const struct {
|
||||
enum nl80211_iftype nl;
|
||||
enum wmi_network_type wmi;
|
||||
} __nl2wmi[] = {
|
||||
{NL80211_IFTYPE_ADHOC, WMI_NETTYPE_ADHOC},
|
||||
{NL80211_IFTYPE_STATION, WMI_NETTYPE_INFRA},
|
||||
{NL80211_IFTYPE_AP, WMI_NETTYPE_AP},
|
||||
{NL80211_IFTYPE_P2P_CLIENT, WMI_NETTYPE_P2P},
|
||||
{NL80211_IFTYPE_P2P_GO, WMI_NETTYPE_P2P},
|
||||
{NL80211_IFTYPE_MONITOR, WMI_NETTYPE_ADHOC}, /* FIXME */
|
||||
};
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(__nl2wmi); i++) {
|
||||
if (__nl2wmi[i].nl == type)
|
||||
return __nl2wmi[i].wmi;
|
||||
}
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
|
||||
struct station_info *sinfo)
|
||||
{
|
||||
struct wmi_notify_req_cmd cmd = {
|
||||
.cid = cid,
|
||||
.interval_usec = 0,
|
||||
};
|
||||
struct {
|
||||
struct wil6210_mbox_hdr_wmi wmi;
|
||||
struct wmi_notify_req_done_event evt;
|
||||
} __packed reply;
|
||||
struct wil_net_stats *stats = &wil->sta[cid].stats;
|
||||
int rc;
|
||||
|
||||
rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
|
||||
WMI_NOTIFY_REQ_DONE_EVENTID, &reply, sizeof(reply), 20);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
wil_dbg_wmi(wil, "Link status for CID %d: {\n"
|
||||
" MCS %d TSF 0x%016llx\n"
|
||||
" BF status 0x%08x SNR 0x%08x SQI %d%%\n"
|
||||
" Tx Tpt %d goodput %d Rx goodput %d\n"
|
||||
" Sectors(rx:tx) my %d:%d peer %d:%d\n""}\n",
|
||||
cid, le16_to_cpu(reply.evt.bf_mcs),
|
||||
le64_to_cpu(reply.evt.tsf), reply.evt.status,
|
||||
le32_to_cpu(reply.evt.snr_val),
|
||||
reply.evt.sqi,
|
||||
le32_to_cpu(reply.evt.tx_tpt),
|
||||
le32_to_cpu(reply.evt.tx_goodput),
|
||||
le32_to_cpu(reply.evt.rx_goodput),
|
||||
le16_to_cpu(reply.evt.my_rx_sector),
|
||||
le16_to_cpu(reply.evt.my_tx_sector),
|
||||
le16_to_cpu(reply.evt.other_rx_sector),
|
||||
le16_to_cpu(reply.evt.other_tx_sector));
|
||||
|
||||
sinfo->generation = wil->sinfo_gen;
|
||||
|
||||
sinfo->filled = STATION_INFO_RX_BYTES |
|
||||
STATION_INFO_TX_BYTES |
|
||||
STATION_INFO_RX_PACKETS |
|
||||
STATION_INFO_TX_PACKETS |
|
||||
STATION_INFO_RX_BITRATE |
|
||||
STATION_INFO_TX_BITRATE |
|
||||
STATION_INFO_RX_DROP_MISC |
|
||||
STATION_INFO_TX_FAILED;
|
||||
|
||||
sinfo->txrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
|
||||
sinfo->txrate.mcs = le16_to_cpu(reply.evt.bf_mcs);
|
||||
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
|
||||
sinfo->rxrate.mcs = stats->last_mcs_rx;
|
||||
sinfo->rx_bytes = stats->rx_bytes;
|
||||
sinfo->rx_packets = stats->rx_packets;
|
||||
sinfo->rx_dropped_misc = stats->rx_dropped;
|
||||
sinfo->tx_bytes = stats->tx_bytes;
|
||||
sinfo->tx_packets = stats->tx_packets;
|
||||
sinfo->tx_failed = stats->tx_errors;
|
||||
|
||||
if (test_bit(wil_status_fwconnected, &wil->status)) {
|
||||
sinfo->filled |= STATION_INFO_SIGNAL;
|
||||
sinfo->signal = reply.evt.sqi;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_get_station(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
const u8 *mac, struct station_info *sinfo)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
int rc;
|
||||
|
||||
int cid = wil_find_cid(wil, mac);
|
||||
|
||||
wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
|
||||
if (cid < 0)
|
||||
return cid;
|
||||
|
||||
rc = wil_cid_fill_sinfo(wil, cid, sinfo);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find @idx-th active STA for station dump.
|
||||
*/
|
||||
static int wil_find_cid_by_idx(struct wil6210_priv *wil, int idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
|
||||
if (wil->sta[i].status == wil_sta_unused)
|
||||
continue;
|
||||
if (idx == 0)
|
||||
return i;
|
||||
idx--;
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_dump_station(struct wiphy *wiphy,
|
||||
struct net_device *dev, int idx,
|
||||
u8 *mac, struct station_info *sinfo)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
int rc;
|
||||
int cid = wil_find_cid_by_idx(wil, idx);
|
||||
|
||||
if (cid < 0)
|
||||
return -ENOENT;
|
||||
|
||||
memcpy(mac, wil->sta[cid].addr, ETH_ALEN);
|
||||
wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
|
||||
|
||||
rc = wil_cid_fill_sinfo(wil, cid, sinfo);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_change_iface(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
enum nl80211_iftype type, u32 *flags,
|
||||
struct vif_params *params)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
|
||||
switch (type) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
case NL80211_IFTYPE_AP:
|
||||
case NL80211_IFTYPE_P2P_CLIENT:
|
||||
case NL80211_IFTYPE_P2P_GO:
|
||||
break;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
if (flags)
|
||||
wil->monitor_flags = *flags;
|
||||
else
|
||||
wil->monitor_flags = 0;
|
||||
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
wdev->iftype = type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_scan(struct wiphy *wiphy,
|
||||
struct cfg80211_scan_request *request)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
struct {
|
||||
struct wmi_start_scan_cmd cmd;
|
||||
u16 chnl[4];
|
||||
} __packed cmd;
|
||||
uint i, n;
|
||||
int rc;
|
||||
|
||||
if (wil->scan_request) {
|
||||
wil_err(wil, "Already scanning\n");
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
/* check we are client side */
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
case NL80211_IFTYPE_P2P_CLIENT:
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* FW don't support scan after connection attempt */
|
||||
if (test_bit(wil_status_dontscan, &wil->status)) {
|
||||
wil_err(wil, "Can't scan now\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
wil_dbg_misc(wil, "Start scan_request 0x%p\n", request);
|
||||
wil->scan_request = request;
|
||||
mod_timer(&wil->scan_timer, jiffies + WIL6210_SCAN_TO);
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
cmd.cmd.num_channels = 0;
|
||||
n = min(request->n_channels, 4U);
|
||||
for (i = 0; i < n; i++) {
|
||||
int ch = request->channels[i]->hw_value;
|
||||
|
||||
if (ch == 0) {
|
||||
wil_err(wil,
|
||||
"Scan requested for unknown frequency %dMhz\n",
|
||||
request->channels[i]->center_freq);
|
||||
continue;
|
||||
}
|
||||
/* 0-based channel indexes */
|
||||
cmd.cmd.channel_list[cmd.cmd.num_channels++].channel = ch - 1;
|
||||
wil_dbg_misc(wil, "Scan for ch %d : %d MHz\n", ch,
|
||||
request->channels[i]->center_freq);
|
||||
}
|
||||
|
||||
if (request->ie_len)
|
||||
print_hex_dump_bytes("Scan IE ", DUMP_PREFIX_OFFSET,
|
||||
request->ie, request->ie_len);
|
||||
else
|
||||
wil_dbg_misc(wil, "Scan has no IE's\n");
|
||||
|
||||
rc = wmi_set_ie(wil, WMI_FRAME_PROBE_REQ, request->ie_len,
|
||||
request->ie);
|
||||
if (rc) {
|
||||
wil_err(wil, "Aborting scan, set_ie failed: %d\n", rc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = wmi_send(wil, WMI_START_SCAN_CMDID, &cmd, sizeof(cmd.cmd) +
|
||||
cmd.cmd.num_channels * sizeof(cmd.cmd.channel_list[0]));
|
||||
|
||||
out:
|
||||
if (rc) {
|
||||
del_timer_sync(&wil->scan_timer);
|
||||
wil->scan_request = NULL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void wil_print_connect_params(struct wil6210_priv *wil,
|
||||
struct cfg80211_connect_params *sme)
|
||||
{
|
||||
wil_info(wil, "Connecting to:\n");
|
||||
if (sme->channel) {
|
||||
wil_info(wil, " Channel: %d freq %d\n",
|
||||
sme->channel->hw_value, sme->channel->center_freq);
|
||||
}
|
||||
if (sme->bssid)
|
||||
wil_info(wil, " BSSID: %pM\n", sme->bssid);
|
||||
if (sme->ssid)
|
||||
print_hex_dump(KERN_INFO, " SSID: ", DUMP_PREFIX_OFFSET,
|
||||
16, 1, sme->ssid, sme->ssid_len, true);
|
||||
wil_info(wil, " Privacy: %s\n", sme->privacy ? "secure" : "open");
|
||||
}
|
||||
|
||||
static int wil_cfg80211_connect(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
struct cfg80211_connect_params *sme)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
struct cfg80211_bss *bss;
|
||||
struct wmi_connect_cmd conn;
|
||||
const u8 *ssid_eid;
|
||||
const u8 *rsn_eid;
|
||||
int ch;
|
||||
int rc = 0;
|
||||
|
||||
if (test_bit(wil_status_fwconnecting, &wil->status) ||
|
||||
test_bit(wil_status_fwconnected, &wil->status))
|
||||
return -EALREADY;
|
||||
|
||||
wil_print_connect_params(wil, sme);
|
||||
|
||||
bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
|
||||
sme->ssid, sme->ssid_len,
|
||||
WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
|
||||
if (!bss) {
|
||||
wil_err(wil, "Unable to find BSS\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
|
||||
if (!ssid_eid) {
|
||||
wil_err(wil, "No SSID\n");
|
||||
rc = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rsn_eid = sme->ie ?
|
||||
cfg80211_find_ie(WLAN_EID_RSN, sme->ie, sme->ie_len) :
|
||||
NULL;
|
||||
if (rsn_eid) {
|
||||
if (sme->ie_len > WMI_MAX_IE_LEN) {
|
||||
rc = -ERANGE;
|
||||
wil_err(wil, "IE too large (%td bytes)\n",
|
||||
sme->ie_len);
|
||||
goto out;
|
||||
}
|
||||
/* For secure assoc, send WMI_DELETE_CIPHER_KEY_CMD */
|
||||
rc = wmi_del_cipher_key(wil, 0, bss->bssid);
|
||||
if (rc) {
|
||||
wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD failed\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* WMI_SET_APPIE_CMD. ie may contain rsn info as well as other info
|
||||
* elements. Send it also in case it's empty, to erase previously set
|
||||
* ies in FW.
|
||||
*/
|
||||
rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_REQ, sme->ie_len, sme->ie);
|
||||
if (rc) {
|
||||
wil_err(wil, "WMI_SET_APPIE_CMD failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* WMI_CONNECT_CMD */
|
||||
memset(&conn, 0, sizeof(conn));
|
||||
switch (bss->capability & WLAN_CAPABILITY_DMG_TYPE_MASK) {
|
||||
case WLAN_CAPABILITY_DMG_TYPE_AP:
|
||||
conn.network_type = WMI_NETTYPE_INFRA;
|
||||
break;
|
||||
case WLAN_CAPABILITY_DMG_TYPE_PBSS:
|
||||
conn.network_type = WMI_NETTYPE_P2P;
|
||||
break;
|
||||
default:
|
||||
wil_err(wil, "Unsupported BSS type, capability= 0x%04x\n",
|
||||
bss->capability);
|
||||
goto out;
|
||||
}
|
||||
if (rsn_eid) {
|
||||
conn.dot11_auth_mode = WMI_AUTH11_SHARED;
|
||||
conn.auth_mode = WMI_AUTH_WPA2_PSK;
|
||||
conn.pairwise_crypto_type = WMI_CRYPT_AES_GCMP;
|
||||
conn.pairwise_crypto_len = 16;
|
||||
} else {
|
||||
conn.dot11_auth_mode = WMI_AUTH11_OPEN;
|
||||
conn.auth_mode = WMI_AUTH_NONE;
|
||||
}
|
||||
|
||||
conn.ssid_len = min_t(u8, ssid_eid[1], 32);
|
||||
memcpy(conn.ssid, ssid_eid+2, conn.ssid_len);
|
||||
|
||||
ch = bss->channel->hw_value;
|
||||
if (ch == 0) {
|
||||
wil_err(wil, "BSS at unknown frequency %dMhz\n",
|
||||
bss->channel->center_freq);
|
||||
rc = -EOPNOTSUPP;
|
||||
goto out;
|
||||
}
|
||||
conn.channel = ch - 1;
|
||||
|
||||
memcpy(conn.bssid, bss->bssid, ETH_ALEN);
|
||||
memcpy(conn.dst_mac, bss->bssid, ETH_ALEN);
|
||||
|
||||
set_bit(wil_status_fwconnecting, &wil->status);
|
||||
|
||||
rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn));
|
||||
if (rc == 0) {
|
||||
/* Connect can take lots of time */
|
||||
mod_timer(&wil->connect_timer,
|
||||
jiffies + msecs_to_jiffies(2000));
|
||||
} else {
|
||||
clear_bit(wil_status_fwconnecting, &wil->status);
|
||||
}
|
||||
|
||||
out:
|
||||
cfg80211_put_bss(wiphy, bss);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_disconnect(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
u16 reason_code)
|
||||
{
|
||||
int rc;
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
|
||||
rc = wmi_send(wil, WMI_DISCONNECT_CMDID, NULL, 0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
struct cfg80211_mgmt_tx_params *params,
|
||||
u64 *cookie)
|
||||
{
|
||||
const u8 *buf = params->buf;
|
||||
size_t len = params->len;
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
int rc;
|
||||
bool tx_status = false;
|
||||
struct ieee80211_mgmt *mgmt_frame = (void *)buf;
|
||||
struct wmi_sw_tx_req_cmd *cmd;
|
||||
struct {
|
||||
struct wil6210_mbox_hdr_wmi wmi;
|
||||
struct wmi_sw_tx_complete_event evt;
|
||||
} __packed evt;
|
||||
|
||||
cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL);
|
||||
if (!cmd) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN);
|
||||
cmd->len = cpu_to_le16(len);
|
||||
memcpy(cmd->payload, buf, len);
|
||||
|
||||
rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, sizeof(*cmd) + len,
|
||||
WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000);
|
||||
if (rc == 0)
|
||||
tx_status = !evt.evt.status;
|
||||
|
||||
kfree(cmd);
|
||||
out:
|
||||
cfg80211_mgmt_tx_status(wdev, cookie ? *cookie : 0, buf, len,
|
||||
tx_status, GFP_KERNEL);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_set_channel(struct wiphy *wiphy,
|
||||
struct cfg80211_chan_def *chandef)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
|
||||
wdev->preset_chandef = *chandef;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_add_key(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
u8 key_index, bool pairwise,
|
||||
const u8 *mac_addr,
|
||||
struct key_params *params)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
|
||||
/* group key is not used */
|
||||
if (!pairwise)
|
||||
return 0;
|
||||
|
||||
return wmi_add_cipher_key(wil, key_index, mac_addr,
|
||||
params->key_len, params->key);
|
||||
}
|
||||
|
||||
static int wil_cfg80211_del_key(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
u8 key_index, bool pairwise,
|
||||
const u8 *mac_addr)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
|
||||
/* group key is not used */
|
||||
if (!pairwise)
|
||||
return 0;
|
||||
|
||||
return wmi_del_cipher_key(wil, key_index, mac_addr);
|
||||
}
|
||||
|
||||
/* Need to be present or wiphy_new() will WARN */
|
||||
static int wil_cfg80211_set_default_key(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
u8 key_index, bool unicast,
|
||||
bool multicast)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_remain_on_channel(struct wiphy *wiphy,
|
||||
struct wireless_dev *wdev,
|
||||
struct ieee80211_channel *chan,
|
||||
unsigned int duration,
|
||||
u64 *cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
int rc;
|
||||
|
||||
/* TODO: handle duration */
|
||||
wil_info(wil, "%s(%d, %d ms)\n", __func__, chan->center_freq, duration);
|
||||
|
||||
rc = wmi_set_channel(wil, chan->hw_value);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = wmi_rxon(wil, true);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cancel_remain_on_channel(struct wiphy *wiphy,
|
||||
struct wireless_dev *wdev,
|
||||
u64 cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
int rc;
|
||||
|
||||
wil_info(wil, "%s()\n", __func__);
|
||||
|
||||
rc = wmi_rxon(wil, false);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void wil_print_bcon_data(struct cfg80211_beacon_data *b)
|
||||
{
|
||||
print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET,
|
||||
b->head, b->head_len);
|
||||
print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET,
|
||||
b->tail, b->tail_len);
|
||||
print_hex_dump_bytes("BCON IE ", DUMP_PREFIX_OFFSET,
|
||||
b->beacon_ies, b->beacon_ies_len);
|
||||
print_hex_dump_bytes("PROBE ", DUMP_PREFIX_OFFSET,
|
||||
b->probe_resp, b->probe_resp_len);
|
||||
print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET,
|
||||
b->proberesp_ies, b->proberesp_ies_len);
|
||||
print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET,
|
||||
b->assocresp_ies, b->assocresp_ies_len);
|
||||
}
|
||||
|
||||
static void wil_print_crypto(struct wil6210_priv *wil,
|
||||
struct cfg80211_crypto_settings *c)
|
||||
{
|
||||
wil_dbg_misc(wil, "WPA versions: 0x%08x cipher group 0x%08x\n",
|
||||
c->wpa_versions, c->cipher_group);
|
||||
wil_dbg_misc(wil, "Pairwise ciphers [%d]\n", c->n_ciphers_pairwise);
|
||||
wil_dbg_misc(wil, "AKM suites [%d]\n", c->n_akm_suites);
|
||||
wil_dbg_misc(wil, "Control port : %d, eth_type 0x%04x no_encrypt %d\n",
|
||||
c->control_port, be16_to_cpu(c->control_port_ethertype),
|
||||
c->control_port_no_encrypt);
|
||||
}
|
||||
|
||||
static int wil_fix_bcon(struct wil6210_priv *wil,
|
||||
struct cfg80211_beacon_data *bcon)
|
||||
{
|
||||
struct ieee80211_mgmt *f = (struct ieee80211_mgmt *)bcon->probe_resp;
|
||||
size_t hlen = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
|
||||
int rc = 0;
|
||||
|
||||
if (bcon->probe_resp_len <= hlen)
|
||||
return 0;
|
||||
|
||||
if (!bcon->proberesp_ies) {
|
||||
bcon->proberesp_ies = f->u.probe_resp.variable;
|
||||
bcon->proberesp_ies_len = bcon->probe_resp_len - hlen;
|
||||
rc = 1;
|
||||
}
|
||||
if (!bcon->assocresp_ies) {
|
||||
bcon->assocresp_ies = f->u.probe_resp.variable;
|
||||
bcon->assocresp_ies_len = bcon->probe_resp_len - hlen;
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_change_beacon(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
struct cfg80211_beacon_data *bcon)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
int rc;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
if (wil_fix_bcon(wil, bcon)) {
|
||||
wil_dbg_misc(wil, "Fixed bcon\n");
|
||||
wil_print_bcon_data(bcon);
|
||||
}
|
||||
|
||||
/* FW do not form regular beacon, so bcon IE's are not set
|
||||
* For the DMG bcon, when it will be supported, bcon IE's will
|
||||
* be reused; add something like:
|
||||
* wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->beacon_ies_len,
|
||||
* bcon->beacon_ies);
|
||||
*/
|
||||
rc = wmi_set_ie(wil, WMI_FRAME_PROBE_RESP,
|
||||
bcon->proberesp_ies_len,
|
||||
bcon->proberesp_ies);
|
||||
if (rc) {
|
||||
wil_err(wil, "set_ie(PROBE_RESP) failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP,
|
||||
bcon->assocresp_ies_len,
|
||||
bcon->assocresp_ies);
|
||||
if (rc) {
|
||||
wil_err(wil, "set_ie(ASSOC_RESP) failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_start_ap(struct wiphy *wiphy,
|
||||
struct net_device *ndev,
|
||||
struct cfg80211_ap_settings *info)
|
||||
{
|
||||
int rc = 0;
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
struct wireless_dev *wdev = ndev->ieee80211_ptr;
|
||||
struct ieee80211_channel *channel = info->chandef.chan;
|
||||
struct cfg80211_beacon_data *bcon = &info->beacon;
|
||||
struct cfg80211_crypto_settings *crypto = &info->crypto;
|
||||
u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
if (!channel) {
|
||||
wil_err(wil, "AP: No channel???\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wil_dbg_misc(wil, "AP on Channel %d %d MHz, %s\n", channel->hw_value,
|
||||
channel->center_freq, info->privacy ? "secure" : "open");
|
||||
wil_dbg_misc(wil, "Privacy: %d auth_type %d\n",
|
||||
info->privacy, info->auth_type);
|
||||
wil_dbg_misc(wil, "BI %d DTIM %d\n", info->beacon_interval,
|
||||
info->dtim_period);
|
||||
print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
|
||||
info->ssid, info->ssid_len);
|
||||
wil_print_bcon_data(bcon);
|
||||
wil_print_crypto(wil, crypto);
|
||||
|
||||
if (wil_fix_bcon(wil, bcon)) {
|
||||
wil_dbg_misc(wil, "Fixed bcon\n");
|
||||
wil_print_bcon_data(bcon);
|
||||
}
|
||||
|
||||
wil_set_recovery_state(wil, fw_recovery_idle);
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
|
||||
__wil_down(wil);
|
||||
rc = __wil_up(wil);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
rc = wmi_set_ssid(wil, info->ssid_len, info->ssid);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
/* IE's */
|
||||
/* bcon 'head IE's are not relevant for 60g band */
|
||||
/*
|
||||
* FW do not form regular beacon, so bcon IE's are not set
|
||||
* For the DMG bcon, when it will be supported, bcon IE's will
|
||||
* be reused; add something like:
|
||||
* wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->beacon_ies_len,
|
||||
* bcon->beacon_ies);
|
||||
*/
|
||||
wmi_set_ie(wil, WMI_FRAME_PROBE_RESP, bcon->proberesp_ies_len,
|
||||
bcon->proberesp_ies);
|
||||
wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, bcon->assocresp_ies_len,
|
||||
bcon->assocresp_ies);
|
||||
|
||||
wil->secure_pcp = info->privacy;
|
||||
|
||||
rc = wmi_pcp_start(wil, info->beacon_interval, wmi_nettype,
|
||||
channel->hw_value);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
netif_carrier_on(ndev);
|
||||
|
||||
out:
|
||||
mutex_unlock(&wil->mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
|
||||
struct net_device *ndev)
|
||||
{
|
||||
int rc, rc1;
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
wil_set_recovery_state(wil, fw_recovery_idle);
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
|
||||
rc = wmi_pcp_stop(wil);
|
||||
|
||||
__wil_down(wil);
|
||||
rc1 = __wil_up(wil);
|
||||
|
||||
mutex_unlock(&wil->mutex);
|
||||
|
||||
return min(rc, rc1);
|
||||
}
|
||||
|
||||
static int wil_cfg80211_del_station(struct wiphy *wiphy,
|
||||
struct net_device *dev, const u8 *mac)
|
||||
{
|
||||
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
wil6210_disconnect(wil, mac);
|
||||
mutex_unlock(&wil->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct cfg80211_ops wil_cfg80211_ops = {
|
||||
.scan = wil_cfg80211_scan,
|
||||
.connect = wil_cfg80211_connect,
|
||||
.disconnect = wil_cfg80211_disconnect,
|
||||
.change_virtual_intf = wil_cfg80211_change_iface,
|
||||
.get_station = wil_cfg80211_get_station,
|
||||
.dump_station = wil_cfg80211_dump_station,
|
||||
.remain_on_channel = wil_remain_on_channel,
|
||||
.cancel_remain_on_channel = wil_cancel_remain_on_channel,
|
||||
.mgmt_tx = wil_cfg80211_mgmt_tx,
|
||||
.set_monitor_channel = wil_cfg80211_set_channel,
|
||||
.add_key = wil_cfg80211_add_key,
|
||||
.del_key = wil_cfg80211_del_key,
|
||||
.set_default_key = wil_cfg80211_set_default_key,
|
||||
/* AP mode */
|
||||
.change_beacon = wil_cfg80211_change_beacon,
|
||||
.start_ap = wil_cfg80211_start_ap,
|
||||
.stop_ap = wil_cfg80211_stop_ap,
|
||||
.del_station = wil_cfg80211_del_station,
|
||||
};
|
||||
|
||||
static void wil_wiphy_init(struct wiphy *wiphy)
|
||||
{
|
||||
/* TODO: set real value */
|
||||
wiphy->max_scan_ssids = 10;
|
||||
wiphy->max_scan_ie_len = WMI_MAX_IE_LEN;
|
||||
wiphy->max_num_pmkids = 0 /* TODO: */;
|
||||
wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
|
||||
BIT(NL80211_IFTYPE_AP) |
|
||||
BIT(NL80211_IFTYPE_MONITOR);
|
||||
/* TODO: enable P2P when integrated with supplicant:
|
||||
* BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO)
|
||||
*/
|
||||
wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
|
||||
WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
|
||||
dev_dbg(wiphy_dev(wiphy), "%s : flags = 0x%08x\n",
|
||||
__func__, wiphy->flags);
|
||||
wiphy->probe_resp_offload =
|
||||
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
|
||||
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
|
||||
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
|
||||
|
||||
wiphy->bands[IEEE80211_BAND_60GHZ] = &wil_band_60ghz;
|
||||
|
||||
/* TODO: figure this out */
|
||||
wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
|
||||
|
||||
wiphy->cipher_suites = wil_cipher_suites;
|
||||
wiphy->n_cipher_suites = ARRAY_SIZE(wil_cipher_suites);
|
||||
wiphy->mgmt_stypes = wil_mgmt_stypes;
|
||||
}
|
||||
|
||||
struct wireless_dev *wil_cfg80211_init(struct device *dev)
|
||||
{
|
||||
int rc = 0;
|
||||
struct wireless_dev *wdev;
|
||||
|
||||
dev_dbg(dev, "%s()\n", __func__);
|
||||
|
||||
wdev = kzalloc(sizeof(*wdev), GFP_KERNEL);
|
||||
if (!wdev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
wdev->wiphy = wiphy_new(&wil_cfg80211_ops,
|
||||
sizeof(struct wil6210_priv));
|
||||
if (!wdev->wiphy) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
set_wiphy_dev(wdev->wiphy, dev);
|
||||
wil_wiphy_init(wdev->wiphy);
|
||||
|
||||
rc = wiphy_register(wdev->wiphy);
|
||||
if (rc < 0)
|
||||
goto out_failed_reg;
|
||||
|
||||
return wdev;
|
||||
|
||||
out_failed_reg:
|
||||
wiphy_free(wdev->wiphy);
|
||||
out:
|
||||
kfree(wdev);
|
||||
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
void wil_wdev_free(struct wil6210_priv *wil)
|
||||
{
|
||||
struct wireless_dev *wdev = wil_to_wdev(wil);
|
||||
|
||||
dev_dbg(wil_to_dev(wil), "%s()\n", __func__);
|
||||
|
||||
if (!wdev)
|
||||
return;
|
||||
|
||||
wiphy_unregister(wdev->wiphy);
|
||||
wiphy_free(wdev->wiphy);
|
||||
kfree(wdev);
|
||||
}
|
||||
61
drivers/net/wireless/ath/wil6210/debug.c
Normal file
61
drivers/net/wireless/ath/wil6210/debug.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "wil6210.h"
|
||||
#include "trace.h"
|
||||
|
||||
void wil_err(struct wil6210_priv *wil, const char *fmt, ...)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct va_format vaf = {
|
||||
.fmt = fmt,
|
||||
};
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vaf.va = &args;
|
||||
netdev_err(ndev, "%pV", &vaf);
|
||||
trace_wil6210_log_err(&vaf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void wil_info(struct wil6210_priv *wil, const char *fmt, ...)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct va_format vaf = {
|
||||
.fmt = fmt,
|
||||
};
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vaf.va = &args;
|
||||
netdev_info(ndev, "%pV", &vaf);
|
||||
trace_wil6210_log_info(&vaf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void wil_dbg_trace(struct wil6210_priv *wil, const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf = {
|
||||
.fmt = fmt,
|
||||
};
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vaf.va = &args;
|
||||
trace_wil6210_log_dbg(&vaf);
|
||||
va_end(args);
|
||||
}
|
||||
1309
drivers/net/wireless/ath/wil6210/debugfs.c
Normal file
1309
drivers/net/wireless/ath/wil6210/debugfs.c
Normal file
File diff suppressed because it is too large
Load diff
103
drivers/net/wireless/ath/wil6210/ethtool.c
Normal file
103
drivers/net/wireless/ath/wil6210/ethtool.c
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <net/cfg80211.h>
|
||||
|
||||
#include "wil6210.h"
|
||||
|
||||
static int wil_ethtoolops_begin(struct net_device *ndev)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wil_ethtoolops_complete(struct net_device *ndev)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
mutex_unlock(&wil->mutex);
|
||||
}
|
||||
|
||||
static int wil_ethtoolops_get_coalesce(struct net_device *ndev,
|
||||
struct ethtool_coalesce *cp)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
u32 itr_en, itr_val = 0;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
itr_en = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
|
||||
if (itr_en & BIT_DMA_ITR_CNT_CRL_EN)
|
||||
itr_val = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
|
||||
|
||||
cp->rx_coalesce_usecs = itr_val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_ethtoolops_set_coalesce(struct net_device *ndev,
|
||||
struct ethtool_coalesce *cp)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
wil_dbg_misc(wil, "%s(%d usec)\n", __func__, cp->rx_coalesce_usecs);
|
||||
|
||||
if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR) {
|
||||
wil_dbg_misc(wil, "No IRQ coalescing in monitor mode\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* only @rx_coalesce_usecs supported, ignore
|
||||
* other parameters
|
||||
*/
|
||||
|
||||
if (cp->rx_coalesce_usecs > WIL6210_ITR_TRSH_MAX)
|
||||
goto out_bad;
|
||||
|
||||
wil->itr_trsh = cp->rx_coalesce_usecs;
|
||||
wil_set_itr_trsh(wil);
|
||||
|
||||
return 0;
|
||||
|
||||
out_bad:
|
||||
wil_dbg_misc(wil, "Unsupported coalescing params. Raw command:\n");
|
||||
print_hex_dump_debug("DBG[MISC] coal ", DUMP_PREFIX_OFFSET, 16, 4,
|
||||
cp, sizeof(*cp), false);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static const struct ethtool_ops wil_ethtool_ops = {
|
||||
.begin = wil_ethtoolops_begin,
|
||||
.complete = wil_ethtoolops_complete,
|
||||
.get_drvinfo = cfg80211_get_drvinfo,
|
||||
.get_coalesce = wil_ethtoolops_get_coalesce,
|
||||
.set_coalesce = wil_ethtoolops_set_coalesce,
|
||||
};
|
||||
|
||||
void wil_set_ethtoolops(struct net_device *ndev)
|
||||
{
|
||||
ndev->ethtool_ops = &wil_ethtool_ops;
|
||||
}
|
||||
45
drivers/net/wireless/ath/wil6210/fw.c
Normal file
45
drivers/net/wireless/ath/wil6210/fw.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/crc32.h>
|
||||
#include "wil6210.h"
|
||||
#include "fw.h"
|
||||
|
||||
MODULE_FIRMWARE(WIL_FW_NAME);
|
||||
|
||||
/* target operations */
|
||||
/* register read */
|
||||
#define R(a) ioread32(wil->csr + HOSTADDR(a))
|
||||
/* register write. wmb() to make sure it is completed */
|
||||
#define W(a, v) do { iowrite32(v, wil->csr + HOSTADDR(a)); wmb(); } while (0)
|
||||
/* register set = read, OR, write */
|
||||
#define S(a, v) W(a, R(a) | v)
|
||||
/* register clear = read, AND with inverted, write */
|
||||
#define C(a, v) W(a, R(a) & ~v)
|
||||
|
||||
static
|
||||
void wil_memset_toio_32(volatile void __iomem *dst, u32 val,
|
||||
size_t count)
|
||||
{
|
||||
volatile u32 __iomem *d = dst;
|
||||
|
||||
for (count += 4; count > 4; count -= 4)
|
||||
__raw_writel(val, d++);
|
||||
}
|
||||
|
||||
#include "fw_inc.c"
|
||||
149
drivers/net/wireless/ath/wil6210/fw.h
Normal file
149
drivers/net/wireless/ath/wil6210/fw.h
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
|
||||
#define WIL_FW_FMT_VERSION (1) /* format version driver supports */
|
||||
|
||||
enum wil_fw_record_type {
|
||||
wil_fw_type_comment = 1,
|
||||
wil_fw_type_data = 2,
|
||||
wil_fw_type_fill = 3,
|
||||
wil_fw_type_action = 4,
|
||||
wil_fw_type_verify = 5,
|
||||
wil_fw_type_file_header = 6,
|
||||
wil_fw_type_direct_write = 7,
|
||||
wil_fw_type_gateway_data = 8,
|
||||
wil_fw_type_gateway_data4 = 9,
|
||||
};
|
||||
|
||||
struct wil_fw_record_head {
|
||||
__le16 type; /* enum wil_fw_record_type */
|
||||
__le16 flags; /* to be defined */
|
||||
__le32 size; /* whole record, bytes after head */
|
||||
} __packed;
|
||||
|
||||
/* data block. write starting from @addr
|
||||
* data_size inferred from the @head.size. For this case,
|
||||
* data_size = @head.size - offsetof(struct wil_fw_record_data, data)
|
||||
*/
|
||||
struct wil_fw_record_data { /* type == wil_fw_type_data */
|
||||
__le32 addr;
|
||||
__le32 data[0]; /* [data_size], see above */
|
||||
} __packed;
|
||||
|
||||
/* fill with constant @value, @size bytes starting from @addr */
|
||||
struct wil_fw_record_fill { /* type == wil_fw_type_fill */
|
||||
__le32 addr;
|
||||
__le32 value;
|
||||
__le32 size;
|
||||
} __packed;
|
||||
|
||||
/* free-form comment
|
||||
* for informational purpose, data_size is @head.size from record header
|
||||
*/
|
||||
struct wil_fw_record_comment { /* type == wil_fw_type_comment */
|
||||
u8 data[0]; /* free-form data [data_size], see above */
|
||||
} __packed;
|
||||
|
||||
/* perform action
|
||||
* data_size = @head.size - offsetof(struct wil_fw_record_action, data)
|
||||
*/
|
||||
struct wil_fw_record_action { /* type == wil_fw_type_action */
|
||||
__le32 action; /* action to perform: reset, wait for fw ready etc. */
|
||||
__le32 data[0]; /* action specific, [data_size], see above */
|
||||
} __packed;
|
||||
|
||||
/* data block for struct wil_fw_record_direct_write */
|
||||
struct wil_fw_data_dwrite {
|
||||
__le32 addr;
|
||||
__le32 value;
|
||||
__le32 mask;
|
||||
} __packed;
|
||||
|
||||
/* write @value to the @addr,
|
||||
* preserve original bits accordingly to the @mask
|
||||
* data_size is @head.size where @head is record header
|
||||
*/
|
||||
struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
|
||||
struct wil_fw_data_dwrite data[0];
|
||||
} __packed;
|
||||
|
||||
/* verify condition: [@addr] & @mask == @value
|
||||
* if condition not met, firmware download fails
|
||||
*/
|
||||
struct wil_fw_record_verify { /* type == wil_fw_verify */
|
||||
__le32 addr; /* read from this address */
|
||||
__le32 value; /* reference value */
|
||||
__le32 mask; /* mask for verification */
|
||||
} __packed;
|
||||
|
||||
/* file header
|
||||
* First record of every file
|
||||
*/
|
||||
struct wil_fw_record_file_header {
|
||||
__le32 signature ; /* Wilocity signature */
|
||||
__le32 reserved;
|
||||
__le32 crc; /* crc32 of the following data */
|
||||
__le32 version; /* format version */
|
||||
__le32 data_len; /* total data in file, including this record */
|
||||
u8 comment[32]; /* short description */
|
||||
} __packed;
|
||||
|
||||
/* 1-dword gateway */
|
||||
/* data block for the struct wil_fw_record_gateway_data */
|
||||
struct wil_fw_data_gw {
|
||||
__le32 addr;
|
||||
__le32 value;
|
||||
} __packed;
|
||||
|
||||
/* gateway write block.
|
||||
* write starting address and values from the data buffer
|
||||
* through the gateway
|
||||
* data_size inferred from the @head.size. For this case,
|
||||
* data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
|
||||
*/
|
||||
struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
|
||||
__le32 gateway_addr_addr;
|
||||
__le32 gateway_value_addr;
|
||||
__le32 gateway_cmd_addr;
|
||||
__le32 gateway_ctrl_address;
|
||||
#define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
|
||||
#define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
|
||||
__le32 command;
|
||||
struct wil_fw_data_gw data[0]; /* total size [data_size], see above */
|
||||
} __packed;
|
||||
|
||||
/* 4-dword gateway */
|
||||
/* data block for the struct wil_fw_record_gateway_data4 */
|
||||
struct wil_fw_data_gw4 {
|
||||
__le32 addr;
|
||||
__le32 value[4];
|
||||
} __packed;
|
||||
|
||||
/* gateway write block.
|
||||
* write starting address and values from the data buffer
|
||||
* through the gateway
|
||||
* data_size inferred from the @head.size. For this case,
|
||||
* data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
|
||||
*/
|
||||
struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
|
||||
__le32 gateway_addr_addr;
|
||||
__le32 gateway_value_addr[4];
|
||||
__le32 gateway_cmd_addr;
|
||||
__le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
|
||||
__le32 command;
|
||||
struct wil_fw_data_gw4 data[0]; /* total size [data_size], see above */
|
||||
} __packed;
|
||||
495
drivers/net/wireless/ath/wil6210/fw_inc.c
Normal file
495
drivers/net/wireless/ath/wil6210/fw_inc.c
Normal file
|
|
@ -0,0 +1,495 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Algorithmic part of the firmware download.
|
||||
* To be included in the container file providing framework
|
||||
*/
|
||||
|
||||
#define wil_err_fw(wil, fmt, arg...) wil_err(wil, "ERR[ FW ]" fmt, ##arg)
|
||||
#define wil_dbg_fw(wil, fmt, arg...) wil_dbg(wil, "DBG[ FW ]" fmt, ##arg)
|
||||
#define wil_hex_dump_fw(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii) \
|
||||
print_hex_dump_debug("DBG[ FW ]" prefix_str, \
|
||||
prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii)
|
||||
|
||||
#define FW_ADDR_CHECK(ioaddr, val, msg) do { \
|
||||
ioaddr = wmi_buffer(wil, val); \
|
||||
if (!ioaddr) { \
|
||||
wil_err_fw(wil, "bad " msg ": 0x%08x\n", \
|
||||
le32_to_cpu(val)); \
|
||||
return -EINVAL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* wil_fw_verify - verify firmware file validity
|
||||
*
|
||||
* perform various checks for the firmware file header.
|
||||
* records are not validated.
|
||||
*
|
||||
* Return file size or negative error
|
||||
*/
|
||||
static int wil_fw_verify(struct wil6210_priv *wil, const u8 *data, size_t size)
|
||||
{
|
||||
const struct wil_fw_record_head *hdr = (const void *)data;
|
||||
struct wil_fw_record_file_header fh;
|
||||
const struct wil_fw_record_file_header *fh_;
|
||||
u32 crc;
|
||||
u32 dlen;
|
||||
|
||||
if (size % 4) {
|
||||
wil_err_fw(wil, "image size not aligned: %zu\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* have enough data for the file header? */
|
||||
if (size < sizeof(*hdr) + sizeof(fh)) {
|
||||
wil_err_fw(wil, "file too short: %zu bytes\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* start with the file header? */
|
||||
if (le16_to_cpu(hdr->type) != wil_fw_type_file_header) {
|
||||
wil_err_fw(wil, "no file header\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* data_len */
|
||||
fh_ = (struct wil_fw_record_file_header *)&hdr[1];
|
||||
dlen = le32_to_cpu(fh_->data_len);
|
||||
if (dlen % 4) {
|
||||
wil_err_fw(wil, "data length not aligned: %lu\n", (ulong)dlen);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (size < dlen) {
|
||||
wil_err_fw(wil, "file truncated at %zu/%lu\n",
|
||||
size, (ulong)dlen);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (dlen < sizeof(*hdr) + sizeof(fh)) {
|
||||
wil_err_fw(wil, "data length too short: %lu\n", (ulong)dlen);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* signature */
|
||||
if (le32_to_cpu(fh_->signature) != WIL_FW_SIGNATURE) {
|
||||
wil_err_fw(wil, "bad header signature: 0x%08x\n",
|
||||
le32_to_cpu(fh_->signature));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* version */
|
||||
if (le32_to_cpu(fh_->version) > WIL_FW_FMT_VERSION) {
|
||||
wil_err_fw(wil, "unsupported header version: %d\n",
|
||||
le32_to_cpu(fh_->version));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* checksum. ~crc32(~0, data, size) when fh.crc set to 0*/
|
||||
fh = *fh_;
|
||||
fh.crc = 0;
|
||||
|
||||
crc = crc32_le(~0, (unsigned char const *)hdr, sizeof(*hdr));
|
||||
crc = crc32_le(crc, (unsigned char const *)&fh, sizeof(fh));
|
||||
crc = crc32_le(crc, (unsigned char const *)&fh_[1],
|
||||
dlen - sizeof(*hdr) - sizeof(fh));
|
||||
crc = ~crc;
|
||||
|
||||
if (crc != le32_to_cpu(fh_->crc)) {
|
||||
wil_err_fw(wil, "checksum mismatch:"
|
||||
" calculated for %lu bytes 0x%08x != 0x%08x\n",
|
||||
(ulong)dlen, crc, le32_to_cpu(fh_->crc));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return (int)dlen;
|
||||
}
|
||||
|
||||
static int fw_handle_comment(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
wil_hex_dump_fw("", DUMP_PREFIX_OFFSET, 16, 1, data, size, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fw_handle_data(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct wil_fw_record_data *d = data;
|
||||
void __iomem *dst;
|
||||
size_t s = size - sizeof(*d);
|
||||
|
||||
if (size < sizeof(*d) + sizeof(u32)) {
|
||||
wil_err_fw(wil, "data record too short: %zu\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
FW_ADDR_CHECK(dst, d->addr, "address");
|
||||
wil_dbg_fw(wil, "write [0x%08x] <== %zu bytes\n", le32_to_cpu(d->addr),
|
||||
s);
|
||||
wil_memcpy_toio_32(dst, d->data, s);
|
||||
wmb(); /* finish before processing next record */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fw_handle_fill(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct wil_fw_record_fill *d = data;
|
||||
void __iomem *dst;
|
||||
u32 v;
|
||||
size_t s = (size_t)le32_to_cpu(d->size);
|
||||
|
||||
if (size != sizeof(*d)) {
|
||||
wil_err_fw(wil, "bad size for fill record: %zu\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (s < sizeof(u32)) {
|
||||
wil_err_fw(wil, "fill size too short: %zu\n", s);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (s % sizeof(u32)) {
|
||||
wil_err_fw(wil, "fill size not aligned: %zu\n", s);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
FW_ADDR_CHECK(dst, d->addr, "address");
|
||||
|
||||
v = le32_to_cpu(d->value);
|
||||
wil_dbg_fw(wil, "fill [0x%08x] <== 0x%08x, %zu bytes\n",
|
||||
le32_to_cpu(d->addr), v, s);
|
||||
wil_memset_toio_32(dst, v, s);
|
||||
wmb(); /* finish before processing next record */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fw_handle_file_header(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct wil_fw_record_file_header *d = data;
|
||||
|
||||
if (size != sizeof(*d)) {
|
||||
wil_err_fw(wil, "file header length incorrect: %zu\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wil_dbg_fw(wil, "new file, ver. %d, %i bytes\n",
|
||||
d->version, d->data_len);
|
||||
wil_hex_dump_fw("", DUMP_PREFIX_OFFSET, 16, 1, d->comment,
|
||||
sizeof(d->comment), true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fw_handle_direct_write(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct wil_fw_record_direct_write *d = data;
|
||||
const struct wil_fw_data_dwrite *block = d->data;
|
||||
int n, i;
|
||||
|
||||
if (size % sizeof(*block)) {
|
||||
wil_err_fw(wil, "record size not aligned on %zu: %zu\n",
|
||||
sizeof(*block), size);
|
||||
return -EINVAL;
|
||||
}
|
||||
n = size / sizeof(*block);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
void __iomem *dst;
|
||||
u32 m = le32_to_cpu(block[i].mask);
|
||||
u32 v = le32_to_cpu(block[i].value);
|
||||
u32 x, y;
|
||||
|
||||
FW_ADDR_CHECK(dst, block[i].addr, "address");
|
||||
|
||||
x = ioread32(dst);
|
||||
y = (x & m) | (v & ~m);
|
||||
wil_dbg_fw(wil, "write [0x%08x] <== 0x%08x "
|
||||
"(old 0x%08x val 0x%08x mask 0x%08x)\n",
|
||||
le32_to_cpu(block[i].addr), y, x, v, m);
|
||||
iowrite32(y, dst);
|
||||
wmb(); /* finish before processing next record */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gw_write(struct wil6210_priv *wil, void __iomem *gwa_addr,
|
||||
void __iomem *gwa_cmd, void __iomem *gwa_ctl, u32 gw_cmd,
|
||||
u32 a)
|
||||
{
|
||||
unsigned delay = 0;
|
||||
|
||||
iowrite32(a, gwa_addr);
|
||||
iowrite32(gw_cmd, gwa_cmd);
|
||||
wmb(); /* finish before activate gw */
|
||||
|
||||
iowrite32(WIL_FW_GW_CTL_RUN, gwa_ctl); /* activate gw */
|
||||
do {
|
||||
udelay(1); /* typical time is few usec */
|
||||
if (delay++ > 100) {
|
||||
wil_err_fw(wil, "gw timeout\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
} while (ioread32(gwa_ctl) & WIL_FW_GW_CTL_BUSY); /* gw done? */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fw_handle_gateway_data(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct wil_fw_record_gateway_data *d = data;
|
||||
const struct wil_fw_data_gw *block = d->data;
|
||||
void __iomem *gwa_addr;
|
||||
void __iomem *gwa_val;
|
||||
void __iomem *gwa_cmd;
|
||||
void __iomem *gwa_ctl;
|
||||
u32 gw_cmd;
|
||||
int n, i;
|
||||
|
||||
if (size < sizeof(*d) + sizeof(*block)) {
|
||||
wil_err_fw(wil, "gateway record too short: %zu\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((size - sizeof(*d)) % sizeof(*block)) {
|
||||
wil_err_fw(wil, "gateway record data size"
|
||||
" not aligned on %zu: %zu\n",
|
||||
sizeof(*block), size - sizeof(*d));
|
||||
return -EINVAL;
|
||||
}
|
||||
n = (size - sizeof(*d)) / sizeof(*block);
|
||||
|
||||
gw_cmd = le32_to_cpu(d->command);
|
||||
|
||||
wil_dbg_fw(wil, "gw write record [%3d] blocks, cmd 0x%08x\n",
|
||||
n, gw_cmd);
|
||||
|
||||
FW_ADDR_CHECK(gwa_addr, d->gateway_addr_addr, "gateway_addr_addr");
|
||||
FW_ADDR_CHECK(gwa_val, d->gateway_value_addr, "gateway_value_addr");
|
||||
FW_ADDR_CHECK(gwa_cmd, d->gateway_cmd_addr, "gateway_cmd_addr");
|
||||
FW_ADDR_CHECK(gwa_ctl, d->gateway_ctrl_address, "gateway_ctrl_address");
|
||||
|
||||
wil_dbg_fw(wil, "gw addresses: addr 0x%08x val 0x%08x"
|
||||
" cmd 0x%08x ctl 0x%08x\n",
|
||||
le32_to_cpu(d->gateway_addr_addr),
|
||||
le32_to_cpu(d->gateway_value_addr),
|
||||
le32_to_cpu(d->gateway_cmd_addr),
|
||||
le32_to_cpu(d->gateway_ctrl_address));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
int rc;
|
||||
u32 a = le32_to_cpu(block[i].addr);
|
||||
u32 v = le32_to_cpu(block[i].value);
|
||||
|
||||
wil_dbg_fw(wil, " gw write[%3d] [0x%08x] <== 0x%08x\n",
|
||||
i, a, v);
|
||||
|
||||
iowrite32(v, gwa_val);
|
||||
rc = gw_write(wil, gwa_addr, gwa_cmd, gwa_ctl, gw_cmd, a);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fw_handle_gateway_data4(struct wil6210_priv *wil, const void *data,
|
||||
size_t size)
|
||||
{
|
||||
const struct wil_fw_record_gateway_data4 *d = data;
|
||||
const struct wil_fw_data_gw4 *block = d->data;
|
||||
void __iomem *gwa_addr;
|
||||
void __iomem *gwa_val[ARRAY_SIZE(block->value)];
|
||||
void __iomem *gwa_cmd;
|
||||
void __iomem *gwa_ctl;
|
||||
u32 gw_cmd;
|
||||
int n, i, k;
|
||||
|
||||
if (size < sizeof(*d) + sizeof(*block)) {
|
||||
wil_err_fw(wil, "gateway4 record too short: %zu\n", size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((size - sizeof(*d)) % sizeof(*block)) {
|
||||
wil_err_fw(wil, "gateway4 record data size"
|
||||
" not aligned on %zu: %zu\n",
|
||||
sizeof(*block), size - sizeof(*d));
|
||||
return -EINVAL;
|
||||
}
|
||||
n = (size - sizeof(*d)) / sizeof(*block);
|
||||
|
||||
gw_cmd = le32_to_cpu(d->command);
|
||||
|
||||
wil_dbg_fw(wil, "gw4 write record [%3d] blocks, cmd 0x%08x\n",
|
||||
n, gw_cmd);
|
||||
|
||||
FW_ADDR_CHECK(gwa_addr, d->gateway_addr_addr, "gateway_addr_addr");
|
||||
for (k = 0; k < ARRAY_SIZE(block->value); k++)
|
||||
FW_ADDR_CHECK(gwa_val[k], d->gateway_value_addr[k],
|
||||
"gateway_value_addr");
|
||||
FW_ADDR_CHECK(gwa_cmd, d->gateway_cmd_addr, "gateway_cmd_addr");
|
||||
FW_ADDR_CHECK(gwa_ctl, d->gateway_ctrl_address, "gateway_ctrl_address");
|
||||
|
||||
wil_dbg_fw(wil, "gw4 addresses: addr 0x%08x cmd 0x%08x ctl 0x%08x\n",
|
||||
le32_to_cpu(d->gateway_addr_addr),
|
||||
le32_to_cpu(d->gateway_cmd_addr),
|
||||
le32_to_cpu(d->gateway_ctrl_address));
|
||||
wil_hex_dump_fw("val addresses: ", DUMP_PREFIX_NONE, 16, 4,
|
||||
d->gateway_value_addr, sizeof(d->gateway_value_addr),
|
||||
false);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
int rc;
|
||||
u32 a = le32_to_cpu(block[i].addr);
|
||||
u32 v[ARRAY_SIZE(block->value)];
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(block->value); k++)
|
||||
v[k] = le32_to_cpu(block[i].value[k]);
|
||||
|
||||
wil_dbg_fw(wil, " gw4 write[%3d] [0x%08x] <==\n", i, a);
|
||||
wil_hex_dump_fw(" val ", DUMP_PREFIX_NONE, 16, 4, v,
|
||||
sizeof(v), false);
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(block->value); k++)
|
||||
iowrite32(v[k], gwa_val[k]);
|
||||
rc = gw_write(wil, gwa_addr, gwa_cmd, gwa_ctl, gw_cmd, a);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
int type;
|
||||
int (*handler)(struct wil6210_priv *wil, const void *data, size_t size);
|
||||
} wil_fw_handlers[] = {
|
||||
{wil_fw_type_comment, fw_handle_comment},
|
||||
{wil_fw_type_data, fw_handle_data},
|
||||
{wil_fw_type_fill, fw_handle_fill},
|
||||
/* wil_fw_type_action */
|
||||
/* wil_fw_type_verify */
|
||||
{wil_fw_type_file_header, fw_handle_file_header},
|
||||
{wil_fw_type_direct_write, fw_handle_direct_write},
|
||||
{wil_fw_type_gateway_data, fw_handle_gateway_data},
|
||||
{wil_fw_type_gateway_data4, fw_handle_gateway_data4},
|
||||
};
|
||||
|
||||
static int wil_fw_handle_record(struct wil6210_priv *wil, int type,
|
||||
const void *data, size_t size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wil_fw_handlers); i++) {
|
||||
if (wil_fw_handlers[i].type == type)
|
||||
return wil_fw_handlers[i].handler(wil, data, size);
|
||||
}
|
||||
|
||||
wil_err_fw(wil, "unknown record type: %d\n", type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* wil_fw_load - load FW into device
|
||||
*
|
||||
* Load the FW and uCode code and data to the corresponding device
|
||||
* memory regions
|
||||
*
|
||||
* Return error code
|
||||
*/
|
||||
static int wil_fw_load(struct wil6210_priv *wil, const void *data, size_t size)
|
||||
{
|
||||
int rc = 0;
|
||||
const struct wil_fw_record_head *hdr;
|
||||
size_t s, hdr_sz;
|
||||
|
||||
for (hdr = data;; hdr = (const void *)hdr + s, size -= s) {
|
||||
if (size < sizeof(*hdr))
|
||||
break;
|
||||
hdr_sz = le32_to_cpu(hdr->size);
|
||||
s = sizeof(*hdr) + hdr_sz;
|
||||
if (s > size)
|
||||
break;
|
||||
if (hdr_sz % 4) {
|
||||
wil_err_fw(wil, "unaligned record size: %zu\n",
|
||||
hdr_sz);
|
||||
return -EINVAL;
|
||||
}
|
||||
rc = wil_fw_handle_record(wil, le16_to_cpu(hdr->type),
|
||||
&hdr[1], hdr_sz);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (size) {
|
||||
wil_err_fw(wil, "unprocessed bytes: %zu\n", size);
|
||||
if (size >= sizeof(*hdr)) {
|
||||
wil_err_fw(wil, "Stop at offset %ld"
|
||||
" record type %d [%zd bytes]\n",
|
||||
(const void *)hdr - data,
|
||||
le16_to_cpu(hdr->type), hdr_sz);
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Mark FW as loaded from host */
|
||||
S(RGF_USER_USAGE_6, 1);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* wil_request_firmware - Request firmware and load to device
|
||||
*
|
||||
* Request firmware image from the file and load it to device
|
||||
*
|
||||
* Return error code
|
||||
*/
|
||||
int wil_request_firmware(struct wil6210_priv *wil, const char *name)
|
||||
{
|
||||
int rc, rc1;
|
||||
const struct firmware *fw;
|
||||
size_t sz;
|
||||
const void *d;
|
||||
|
||||
rc = request_firmware(&fw, name, wil_to_pcie_dev(wil));
|
||||
if (rc) {
|
||||
wil_err_fw(wil, "Failed to load firmware %s\n", name);
|
||||
return rc;
|
||||
}
|
||||
wil_dbg_fw(wil, "Loading <%s>, %zu bytes\n", name, fw->size);
|
||||
|
||||
for (sz = fw->size, d = fw->data; sz; sz -= rc1, d += rc1) {
|
||||
rc1 = wil_fw_verify(wil, d, sz);
|
||||
if (rc1 < 0) {
|
||||
rc = rc1;
|
||||
goto out;
|
||||
}
|
||||
rc = wil_fw_load(wil, d, rc1);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
release_firmware(fw);
|
||||
return rc;
|
||||
}
|
||||
550
drivers/net/wireless/ath/wil6210/interrupt.c
Normal file
550
drivers/net/wireless/ath/wil6210/interrupt.c
Normal file
|
|
@ -0,0 +1,550 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include "wil6210.h"
|
||||
#include "trace.h"
|
||||
|
||||
/**
|
||||
* Theory of operation:
|
||||
*
|
||||
* There is ISR pseudo-cause register,
|
||||
* dma_rgf->DMA_RGF.PSEUDO_CAUSE.PSEUDO_CAUSE
|
||||
* Its bits represents OR'ed bits from 3 real ISR registers:
|
||||
* TX, RX, and MISC.
|
||||
*
|
||||
* Registers may be configured to either "write 1 to clear" or
|
||||
* "clear on read" mode
|
||||
*
|
||||
* When handling interrupt, one have to mask/unmask interrupts for the
|
||||
* real ISR registers, or hardware may malfunction.
|
||||
*
|
||||
*/
|
||||
|
||||
#define WIL6210_IRQ_DISABLE (0xFFFFFFFFUL)
|
||||
#define WIL6210_IMC_RX BIT_DMA_EP_RX_ICR_RX_DONE
|
||||
#define WIL6210_IMC_TX (BIT_DMA_EP_TX_ICR_TX_DONE | \
|
||||
BIT_DMA_EP_TX_ICR_TX_DONE_N(0))
|
||||
#define WIL6210_IMC_MISC (ISR_MISC_FW_READY | \
|
||||
ISR_MISC_MBOX_EVT | \
|
||||
ISR_MISC_FW_ERROR)
|
||||
|
||||
#define WIL6210_IRQ_PSEUDO_MASK (u32)(~(BIT_DMA_PSEUDO_CAUSE_RX | \
|
||||
BIT_DMA_PSEUDO_CAUSE_TX | \
|
||||
BIT_DMA_PSEUDO_CAUSE_MISC))
|
||||
|
||||
#if defined(CONFIG_WIL6210_ISR_COR)
|
||||
/* configure to Clear-On-Read mode */
|
||||
#define WIL_ICR_ICC_VALUE (0xFFFFFFFFUL)
|
||||
|
||||
static inline void wil_icr_clear(u32 x, void __iomem *addr)
|
||||
{
|
||||
}
|
||||
#else /* defined(CONFIG_WIL6210_ISR_COR) */
|
||||
/* configure to Write-1-to-Clear mode */
|
||||
#define WIL_ICR_ICC_VALUE (0UL)
|
||||
|
||||
static inline void wil_icr_clear(u32 x, void __iomem *addr)
|
||||
{
|
||||
iowrite32(x, addr);
|
||||
}
|
||||
#endif /* defined(CONFIG_WIL6210_ISR_COR) */
|
||||
|
||||
static inline u32 wil_ioread32_and_clear(void __iomem *addr)
|
||||
{
|
||||
u32 x = ioread32(addr);
|
||||
|
||||
wil_icr_clear(x, addr);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
static void wil6210_mask_irq_tx(struct wil6210_priv *wil)
|
||||
{
|
||||
iowrite32(WIL6210_IRQ_DISABLE, wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, IMS));
|
||||
}
|
||||
|
||||
static void wil6210_mask_irq_rx(struct wil6210_priv *wil)
|
||||
{
|
||||
iowrite32(WIL6210_IRQ_DISABLE, wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, IMS));
|
||||
}
|
||||
|
||||
static void wil6210_mask_irq_misc(struct wil6210_priv *wil)
|
||||
{
|
||||
iowrite32(WIL6210_IRQ_DISABLE, wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, IMS));
|
||||
}
|
||||
|
||||
static void wil6210_mask_irq_pseudo(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_dbg_irq(wil, "%s()\n", __func__);
|
||||
|
||||
iowrite32(WIL6210_IRQ_DISABLE, wil->csr +
|
||||
HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW));
|
||||
|
||||
clear_bit(wil_status_irqen, &wil->status);
|
||||
}
|
||||
|
||||
void wil6210_unmask_irq_tx(struct wil6210_priv *wil)
|
||||
{
|
||||
iowrite32(WIL6210_IMC_TX, wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, IMC));
|
||||
}
|
||||
|
||||
void wil6210_unmask_irq_rx(struct wil6210_priv *wil)
|
||||
{
|
||||
iowrite32(WIL6210_IMC_RX, wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, IMC));
|
||||
}
|
||||
|
||||
static void wil6210_unmask_irq_misc(struct wil6210_priv *wil)
|
||||
{
|
||||
iowrite32(WIL6210_IMC_MISC, wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, IMC));
|
||||
}
|
||||
|
||||
static void wil6210_unmask_irq_pseudo(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_dbg_irq(wil, "%s()\n", __func__);
|
||||
|
||||
set_bit(wil_status_irqen, &wil->status);
|
||||
|
||||
iowrite32(WIL6210_IRQ_PSEUDO_MASK, wil->csr +
|
||||
HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW));
|
||||
}
|
||||
|
||||
void wil_mask_irq(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_dbg_irq(wil, "%s()\n", __func__);
|
||||
|
||||
wil6210_mask_irq_tx(wil);
|
||||
wil6210_mask_irq_rx(wil);
|
||||
wil6210_mask_irq_misc(wil);
|
||||
wil6210_mask_irq_pseudo(wil);
|
||||
}
|
||||
|
||||
void wil_unmask_irq(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_dbg_irq(wil, "%s()\n", __func__);
|
||||
|
||||
iowrite32(WIL_ICR_ICC_VALUE, wil->csr + HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICC));
|
||||
iowrite32(WIL_ICR_ICC_VALUE, wil->csr + HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICC));
|
||||
iowrite32(WIL_ICR_ICC_VALUE, wil->csr + HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, ICC));
|
||||
|
||||
/* interrupt moderation parameters */
|
||||
wil_set_itr_trsh(wil);
|
||||
|
||||
wil6210_unmask_irq_pseudo(wil);
|
||||
wil6210_unmask_irq_tx(wil);
|
||||
wil6210_unmask_irq_rx(wil);
|
||||
wil6210_unmask_irq_misc(wil);
|
||||
}
|
||||
|
||||
static irqreturn_t wil6210_irq_rx(int irq, void *cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = cookie;
|
||||
u32 isr = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
|
||||
trace_wil6210_irq_rx(isr);
|
||||
wil_dbg_irq(wil, "ISR RX 0x%08x\n", isr);
|
||||
|
||||
if (!isr) {
|
||||
wil_err(wil, "spurious IRQ: RX\n");
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
wil6210_mask_irq_rx(wil);
|
||||
|
||||
if (isr & BIT_DMA_EP_RX_ICR_RX_DONE) {
|
||||
wil_dbg_irq(wil, "RX done\n");
|
||||
isr &= ~BIT_DMA_EP_RX_ICR_RX_DONE;
|
||||
if (test_bit(wil_status_reset_done, &wil->status)) {
|
||||
if (test_bit(wil_status_napi_en, &wil->status)) {
|
||||
wil_dbg_txrx(wil, "NAPI(Rx) schedule\n");
|
||||
napi_schedule(&wil->napi_rx);
|
||||
} else {
|
||||
wil_err(wil, "Got Rx interrupt while "
|
||||
"stopping interface\n");
|
||||
}
|
||||
} else {
|
||||
wil_err(wil, "Got Rx interrupt while in reset\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (isr)
|
||||
wil_err(wil, "un-handled RX ISR bits 0x%08x\n", isr);
|
||||
|
||||
/* Rx IRQ will be enabled when NAPI processing finished */
|
||||
|
||||
atomic_inc(&wil->isr_count_rx);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t wil6210_irq_tx(int irq, void *cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = cookie;
|
||||
u32 isr = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
|
||||
trace_wil6210_irq_tx(isr);
|
||||
wil_dbg_irq(wil, "ISR TX 0x%08x\n", isr);
|
||||
|
||||
if (!isr) {
|
||||
wil_err(wil, "spurious IRQ: TX\n");
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
wil6210_mask_irq_tx(wil);
|
||||
|
||||
if (isr & BIT_DMA_EP_TX_ICR_TX_DONE) {
|
||||
wil_dbg_irq(wil, "TX done\n");
|
||||
isr &= ~BIT_DMA_EP_TX_ICR_TX_DONE;
|
||||
/* clear also all VRING interrupts */
|
||||
isr &= ~(BIT(25) - 1UL);
|
||||
if (test_bit(wil_status_reset_done, &wil->status)) {
|
||||
wil_dbg_txrx(wil, "NAPI(Tx) schedule\n");
|
||||
napi_schedule(&wil->napi_tx);
|
||||
} else {
|
||||
wil_err(wil, "Got Tx interrupt while in reset\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (isr)
|
||||
wil_err(wil, "un-handled TX ISR bits 0x%08x\n", isr);
|
||||
|
||||
/* Tx IRQ will be enabled when NAPI processing finished */
|
||||
|
||||
atomic_inc(&wil->isr_count_tx);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void wil_notify_fw_error(struct wil6210_priv *wil)
|
||||
{
|
||||
struct device *dev = &wil_to_ndev(wil)->dev;
|
||||
char *envp[3] = {
|
||||
[0] = "SOURCE=wil6210",
|
||||
[1] = "EVENT=FW_ERROR",
|
||||
[2] = NULL,
|
||||
};
|
||||
wil_err(wil, "Notify about firmware error\n");
|
||||
kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
|
||||
}
|
||||
|
||||
static void wil_cache_mbox_regs(struct wil6210_priv *wil)
|
||||
{
|
||||
/* make shadow copy of registers that should not change on run time */
|
||||
wil_memcpy_fromio_32(&wil->mbox_ctl, wil->csr + HOST_MBOX,
|
||||
sizeof(struct wil6210_mbox_ctl));
|
||||
wil_mbox_ring_le2cpus(&wil->mbox_ctl.rx);
|
||||
wil_mbox_ring_le2cpus(&wil->mbox_ctl.tx);
|
||||
}
|
||||
|
||||
static irqreturn_t wil6210_irq_misc(int irq, void *cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = cookie;
|
||||
u32 isr = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
|
||||
trace_wil6210_irq_misc(isr);
|
||||
wil_dbg_irq(wil, "ISR MISC 0x%08x\n", isr);
|
||||
|
||||
if (!isr) {
|
||||
wil_err(wil, "spurious IRQ: MISC\n");
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
wil6210_mask_irq_misc(wil);
|
||||
|
||||
if (isr & ISR_MISC_FW_ERROR) {
|
||||
wil_err(wil, "Firmware error detected\n");
|
||||
clear_bit(wil_status_fwready, &wil->status);
|
||||
/*
|
||||
* do not clear @isr here - we do 2-nd part in thread
|
||||
* there, user space get notified, and it should be done
|
||||
* in non-atomic context
|
||||
*/
|
||||
}
|
||||
|
||||
if (isr & ISR_MISC_FW_READY) {
|
||||
wil_dbg_irq(wil, "IRQ: FW ready\n");
|
||||
wil_cache_mbox_regs(wil);
|
||||
set_bit(wil_status_reset_done, &wil->status);
|
||||
/**
|
||||
* Actual FW ready indicated by the
|
||||
* WMI_FW_READY_EVENTID
|
||||
*/
|
||||
isr &= ~ISR_MISC_FW_READY;
|
||||
}
|
||||
|
||||
wil->isr_misc = isr;
|
||||
|
||||
if (isr) {
|
||||
return IRQ_WAKE_THREAD;
|
||||
} else {
|
||||
wil6210_unmask_irq_misc(wil);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
static irqreturn_t wil6210_irq_misc_thread(int irq, void *cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = cookie;
|
||||
u32 isr = wil->isr_misc;
|
||||
|
||||
trace_wil6210_irq_misc_thread(isr);
|
||||
wil_dbg_irq(wil, "Thread ISR MISC 0x%08x\n", isr);
|
||||
|
||||
if (isr & ISR_MISC_FW_ERROR) {
|
||||
wil_notify_fw_error(wil);
|
||||
isr &= ~ISR_MISC_FW_ERROR;
|
||||
wil_fw_error_recovery(wil);
|
||||
}
|
||||
|
||||
if (isr & ISR_MISC_MBOX_EVT) {
|
||||
wil_dbg_irq(wil, "MBOX event\n");
|
||||
wmi_recv_cmd(wil);
|
||||
isr &= ~ISR_MISC_MBOX_EVT;
|
||||
}
|
||||
|
||||
if (isr)
|
||||
wil_dbg_irq(wil, "un-handled MISC ISR bits 0x%08x\n", isr);
|
||||
|
||||
wil->isr_misc = 0;
|
||||
|
||||
wil6210_unmask_irq_misc(wil);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* thread IRQ handler
|
||||
*/
|
||||
static irqreturn_t wil6210_thread_irq(int irq, void *cookie)
|
||||
{
|
||||
struct wil6210_priv *wil = cookie;
|
||||
|
||||
wil_dbg_irq(wil, "Thread IRQ\n");
|
||||
/* Discover real IRQ cause */
|
||||
if (wil->isr_misc)
|
||||
wil6210_irq_misc_thread(irq, cookie);
|
||||
|
||||
wil6210_unmask_irq_pseudo(wil);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/* DEBUG
|
||||
* There is subtle bug in hardware that causes IRQ to raise when it should be
|
||||
* masked. It is quite rare and hard to debug.
|
||||
*
|
||||
* Catch irq issue if it happens and print all I can.
|
||||
*/
|
||||
static int wil6210_debug_irq_mask(struct wil6210_priv *wil, u32 pseudo_cause)
|
||||
{
|
||||
if (!test_bit(wil_status_irqen, &wil->status)) {
|
||||
u32 icm_rx = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICM));
|
||||
u32 icr_rx = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
u32 imv_rx = ioread32(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, IMV));
|
||||
u32 icm_tx = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICM));
|
||||
u32 icr_tx = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
u32 imv_tx = ioread32(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, IMV));
|
||||
u32 icm_misc = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, ICM));
|
||||
u32 icr_misc = wil_ioread32_and_clear(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
u32 imv_misc = ioread32(wil->csr +
|
||||
HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, IMV));
|
||||
wil_err(wil, "IRQ when it should be masked: pseudo 0x%08x\n"
|
||||
"Rx icm:icr:imv 0x%08x 0x%08x 0x%08x\n"
|
||||
"Tx icm:icr:imv 0x%08x 0x%08x 0x%08x\n"
|
||||
"Misc icm:icr:imv 0x%08x 0x%08x 0x%08x\n",
|
||||
pseudo_cause,
|
||||
icm_rx, icr_rx, imv_rx,
|
||||
icm_tx, icr_tx, imv_tx,
|
||||
icm_misc, icr_misc, imv_misc);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static irqreturn_t wil6210_hardirq(int irq, void *cookie)
|
||||
{
|
||||
irqreturn_t rc = IRQ_HANDLED;
|
||||
struct wil6210_priv *wil = cookie;
|
||||
u32 pseudo_cause = ioread32(wil->csr + HOSTADDR(RGF_DMA_PSEUDO_CAUSE));
|
||||
|
||||
/**
|
||||
* pseudo_cause is Clear-On-Read, no need to ACK
|
||||
*/
|
||||
if ((pseudo_cause == 0) || ((pseudo_cause & 0xff) == 0xff))
|
||||
return IRQ_NONE;
|
||||
|
||||
/* FIXME: IRQ mask debug */
|
||||
if (wil6210_debug_irq_mask(wil, pseudo_cause))
|
||||
return IRQ_NONE;
|
||||
|
||||
trace_wil6210_irq_pseudo(pseudo_cause);
|
||||
wil_dbg_irq(wil, "Pseudo IRQ 0x%08x\n", pseudo_cause);
|
||||
|
||||
wil6210_mask_irq_pseudo(wil);
|
||||
|
||||
/* Discover real IRQ cause
|
||||
* There are 2 possible phases for every IRQ:
|
||||
* - hard IRQ handler called right here
|
||||
* - threaded handler called later
|
||||
*
|
||||
* Hard IRQ handler reads and clears ISR.
|
||||
*
|
||||
* If threaded handler requested, hard IRQ handler
|
||||
* returns IRQ_WAKE_THREAD and saves ISR register value
|
||||
* for the threaded handler use.
|
||||
*
|
||||
* voting for wake thread - need at least 1 vote
|
||||
*/
|
||||
if ((pseudo_cause & BIT_DMA_PSEUDO_CAUSE_RX) &&
|
||||
(wil6210_irq_rx(irq, cookie) == IRQ_WAKE_THREAD))
|
||||
rc = IRQ_WAKE_THREAD;
|
||||
|
||||
if ((pseudo_cause & BIT_DMA_PSEUDO_CAUSE_TX) &&
|
||||
(wil6210_irq_tx(irq, cookie) == IRQ_WAKE_THREAD))
|
||||
rc = IRQ_WAKE_THREAD;
|
||||
|
||||
if ((pseudo_cause & BIT_DMA_PSEUDO_CAUSE_MISC) &&
|
||||
(wil6210_irq_misc(irq, cookie) == IRQ_WAKE_THREAD))
|
||||
rc = IRQ_WAKE_THREAD;
|
||||
|
||||
/* if thread is requested, it will unmask IRQ */
|
||||
if (rc != IRQ_WAKE_THREAD)
|
||||
wil6210_unmask_irq_pseudo(wil);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil6210_request_3msi(struct wil6210_priv *wil, int irq)
|
||||
{
|
||||
int rc;
|
||||
/*
|
||||
* IRQ's are in the following order:
|
||||
* - Tx
|
||||
* - Rx
|
||||
* - Misc
|
||||
*/
|
||||
|
||||
rc = request_irq(irq, wil6210_irq_tx, IRQF_SHARED,
|
||||
WIL_NAME"_tx", wil);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = request_irq(irq + 1, wil6210_irq_rx, IRQF_SHARED,
|
||||
WIL_NAME"_rx", wil);
|
||||
if (rc)
|
||||
goto free0;
|
||||
|
||||
rc = request_threaded_irq(irq + 2, wil6210_irq_misc,
|
||||
wil6210_irq_misc_thread,
|
||||
IRQF_SHARED, WIL_NAME"_misc", wil);
|
||||
if (rc)
|
||||
goto free1;
|
||||
|
||||
return 0;
|
||||
/* error branch */
|
||||
free1:
|
||||
free_irq(irq + 1, wil);
|
||||
free0:
|
||||
free_irq(irq, wil);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* can't use wil_ioread32_and_clear because ICC value is not set yet */
|
||||
static inline void wil_clear32(void __iomem *addr)
|
||||
{
|
||||
u32 x = ioread32(addr);
|
||||
|
||||
iowrite32(x, addr);
|
||||
}
|
||||
|
||||
void wil6210_clear_irq(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_clear32(wil->csr + HOSTADDR(RGF_DMA_EP_RX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
wil_clear32(wil->csr + HOSTADDR(RGF_DMA_EP_TX_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
wil_clear32(wil->csr + HOSTADDR(RGF_DMA_EP_MISC_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR));
|
||||
wmb(); /* make sure write completed */
|
||||
}
|
||||
|
||||
int wil6210_init_irq(struct wil6210_priv *wil, int irq)
|
||||
{
|
||||
int rc;
|
||||
|
||||
wil_dbg_misc(wil, "%s() n_msi=%d\n", __func__, wil->n_msi);
|
||||
|
||||
if (wil->n_msi == 3)
|
||||
rc = wil6210_request_3msi(wil, irq);
|
||||
else
|
||||
rc = request_threaded_irq(irq, wil6210_hardirq,
|
||||
wil6210_thread_irq,
|
||||
wil->n_msi ? 0 : IRQF_SHARED,
|
||||
WIL_NAME, wil);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void wil6210_fini_irq(struct wil6210_priv *wil, int irq)
|
||||
{
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
wil_mask_irq(wil);
|
||||
free_irq(irq, wil);
|
||||
if (wil->n_msi == 3) {
|
||||
free_irq(irq + 1, wil);
|
||||
free_irq(irq + 2, wil);
|
||||
}
|
||||
}
|
||||
173
drivers/net/wireless/ath/wil6210/ioctl.c
Normal file
173
drivers/net/wireless/ath/wil6210/ioctl.c
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include "wil6210.h"
|
||||
#include <uapi/linux/wil6210_uapi.h>
|
||||
|
||||
#define wil_hex_dump_ioctl(prefix_str, buf, len) \
|
||||
print_hex_dump_debug("DBG[IOC ]" prefix_str, \
|
||||
DUMP_PREFIX_OFFSET, 16, 1, buf, len, true)
|
||||
#define wil_dbg_ioctl(wil, fmt, arg...) wil_dbg(wil, "DBG[IOC ]" fmt, ##arg)
|
||||
|
||||
static void __iomem *wil_ioc_addr(struct wil6210_priv *wil, uint32_t addr,
|
||||
uint32_t size, enum wil_memio_op op)
|
||||
{
|
||||
void __iomem *a;
|
||||
u32 off;
|
||||
|
||||
switch (op & wil_mmio_addr_mask) {
|
||||
case wil_mmio_addr_linker:
|
||||
a = wmi_buffer(wil, cpu_to_le32(addr));
|
||||
break;
|
||||
case wil_mmio_addr_ahb:
|
||||
a = wmi_addr(wil, addr);
|
||||
break;
|
||||
case wil_mmio_addr_bar:
|
||||
a = wmi_addr(wil, addr + WIL6210_FW_HOST_OFF);
|
||||
break;
|
||||
default:
|
||||
wil_err(wil, "Unsupported address mode, op = 0x%08x\n", op);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
off = a - wil->csr;
|
||||
if (size >= WIL6210_MEM_SIZE - off) {
|
||||
wil_err(wil, "Requested block does not fit into memory: "
|
||||
"off = 0x%08x size = 0x%08x\n", off, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
static int wil_ioc_memio_dword(struct wil6210_priv *wil, void __user *data)
|
||||
{
|
||||
struct wil_memio io;
|
||||
void __iomem *a;
|
||||
bool need_copy = false;
|
||||
|
||||
if (copy_from_user(&io, data, sizeof(io)))
|
||||
return -EFAULT;
|
||||
|
||||
wil_dbg_ioctl(wil, "IO: addr = 0x%08x val = 0x%08x op = 0x%08x\n",
|
||||
io.addr, io.val, io.op);
|
||||
|
||||
a = wil_ioc_addr(wil, io.addr, sizeof(u32), io.op);
|
||||
if (!a) {
|
||||
wil_err(wil, "invalid address 0x%08x, op = 0x%08x\n", io.addr,
|
||||
io.op);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* operation */
|
||||
switch (io.op & wil_mmio_op_mask) {
|
||||
case wil_mmio_read:
|
||||
io.val = ioread32(a);
|
||||
need_copy = true;
|
||||
break;
|
||||
case wil_mmio_write:
|
||||
iowrite32(io.val, a);
|
||||
wmb(); /* make sure write propagated to HW */
|
||||
break;
|
||||
default:
|
||||
wil_err(wil, "Unsupported operation, op = 0x%08x\n", io.op);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (need_copy) {
|
||||
wil_dbg_ioctl(wil, "IO done: addr = 0x%08x"
|
||||
" val = 0x%08x op = 0x%08x\n",
|
||||
io.addr, io.val, io.op);
|
||||
if (copy_to_user(data, &io, sizeof(io)))
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_ioc_memio_block(struct wil6210_priv *wil, void __user *data)
|
||||
{
|
||||
struct wil_memio_block io;
|
||||
void *block;
|
||||
void __iomem *a;
|
||||
int rc = 0;
|
||||
|
||||
if (copy_from_user(&io, data, sizeof(io)))
|
||||
return -EFAULT;
|
||||
|
||||
wil_dbg_ioctl(wil, "IO: addr = 0x%08x size = 0x%08x op = 0x%08x\n",
|
||||
io.addr, io.size, io.op);
|
||||
|
||||
/* size */
|
||||
if (io.size % 4) {
|
||||
wil_err(wil, "size is not multiple of 4: 0x%08x\n", io.size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
a = wil_ioc_addr(wil, io.addr, io.size, io.op);
|
||||
if (!a) {
|
||||
wil_err(wil, "invalid address 0x%08x, op = 0x%08x\n", io.addr,
|
||||
io.op);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
block = kmalloc(io.size, GFP_USER);
|
||||
if (!block)
|
||||
return -ENOMEM;
|
||||
|
||||
/* operation */
|
||||
switch (io.op & wil_mmio_op_mask) {
|
||||
case wil_mmio_read:
|
||||
wil_memcpy_fromio_32(block, a, io.size);
|
||||
wil_hex_dump_ioctl("Read ", block, io.size);
|
||||
if (copy_to_user(io.block, block, io.size)) {
|
||||
rc = -EFAULT;
|
||||
goto out_free;
|
||||
}
|
||||
break;
|
||||
case wil_mmio_write:
|
||||
if (copy_from_user(block, io.block, io.size)) {
|
||||
rc = -EFAULT;
|
||||
goto out_free;
|
||||
}
|
||||
wil_memcpy_toio_32(a, block, io.size);
|
||||
wmb(); /* make sure write propagated to HW */
|
||||
wil_hex_dump_ioctl("Write ", block, io.size);
|
||||
break;
|
||||
default:
|
||||
wil_err(wil, "Unsupported operation, op = 0x%08x\n", io.op);
|
||||
rc = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
out_free:
|
||||
kfree(block);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int wil_ioctl(struct wil6210_priv *wil, void __user *data, int cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case WIL_IOCTL_MEMIO:
|
||||
return wil_ioc_memio_dword(wil, data);
|
||||
case WIL_IOCTL_MEMIO_BLOCK:
|
||||
return wil_ioc_memio_block(wil, data);
|
||||
default:
|
||||
wil_dbg_ioctl(wil, "Unsupported IOCTL 0x%04x\n", cmd);
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
}
|
||||
778
drivers/net/wireless/ath/wil6210/main.c
Normal file
778
drivers/net/wireless/ath/wil6210/main.c
Normal file
|
|
@ -0,0 +1,778 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include "wil6210.h"
|
||||
#include "txrx.h"
|
||||
#include "wmi.h"
|
||||
|
||||
#define WAIT_FOR_DISCONNECT_TIMEOUT_MS 2000
|
||||
#define WAIT_FOR_DISCONNECT_INTERVAL_MS 10
|
||||
|
||||
bool no_fw_recovery;
|
||||
module_param(no_fw_recovery, bool, S_IRUGO | S_IWUSR);
|
||||
MODULE_PARM_DESC(no_fw_recovery, " disable automatic FW error recovery");
|
||||
|
||||
static bool no_fw_load = true;
|
||||
module_param(no_fw_load, bool, S_IRUGO | S_IWUSR);
|
||||
MODULE_PARM_DESC(no_fw_load, " do not download FW, use one in on-card flash.");
|
||||
|
||||
static unsigned int itr_trsh = WIL6210_ITR_TRSH_DEFAULT;
|
||||
|
||||
module_param(itr_trsh, uint, S_IRUGO);
|
||||
MODULE_PARM_DESC(itr_trsh, " Interrupt moderation threshold, usecs.");
|
||||
|
||||
#define RST_DELAY (20) /* msec, for loop in @wil_target_reset */
|
||||
#define RST_COUNT (1 + 1000/RST_DELAY) /* round up to be above 1 sec total */
|
||||
|
||||
/*
|
||||
* Due to a hardware issue,
|
||||
* one has to read/write to/from NIC in 32-bit chunks;
|
||||
* regular memcpy_fromio and siblings will
|
||||
* not work on 64-bit platform - it uses 64-bit transactions
|
||||
*
|
||||
* Force 32-bit transactions to enable NIC on 64-bit platforms
|
||||
*
|
||||
* To avoid byte swap on big endian host, __raw_{read|write}l
|
||||
* should be used - {read|write}l would swap bytes to provide
|
||||
* little endian on PCI value in host endianness.
|
||||
*/
|
||||
void wil_memcpy_fromio_32(void *dst, const volatile void __iomem *src,
|
||||
size_t count)
|
||||
{
|
||||
u32 *d = dst;
|
||||
const volatile u32 __iomem *s = src;
|
||||
|
||||
/* size_t is unsigned, if (count%4 != 0) it will wrap */
|
||||
for (count += 4; count > 4; count -= 4)
|
||||
*d++ = __raw_readl(s++);
|
||||
}
|
||||
|
||||
void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
|
||||
size_t count)
|
||||
{
|
||||
volatile u32 __iomem *d = dst;
|
||||
const u32 *s = src;
|
||||
|
||||
for (count += 4; count > 4; count -= 4)
|
||||
__raw_writel(*s++, d++);
|
||||
}
|
||||
|
||||
static void wil_disconnect_cid(struct wil6210_priv *wil, int cid)
|
||||
{
|
||||
uint i;
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
struct wil_sta_info *sta = &wil->sta[cid];
|
||||
|
||||
wil_dbg_misc(wil, "%s(CID %d, status %d)\n", __func__, cid,
|
||||
sta->status);
|
||||
|
||||
sta->data_port_open = false;
|
||||
if (sta->status != wil_sta_unused) {
|
||||
wmi_disconnect_sta(wil, sta->addr, WLAN_REASON_DEAUTH_LEAVING);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_AP:
|
||||
case NL80211_IFTYPE_P2P_GO:
|
||||
/* AP-like interface */
|
||||
cfg80211_del_sta(ndev, sta->addr, GFP_KERNEL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sta->status = wil_sta_unused;
|
||||
}
|
||||
|
||||
for (i = 0; i < WIL_STA_TID_NUM; i++) {
|
||||
struct wil_tid_ampdu_rx *r;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&sta->tid_rx_lock, flags);
|
||||
|
||||
r = sta->tid_rx[i];
|
||||
sta->tid_rx[i] = NULL;
|
||||
wil_tid_ampdu_rx_free(wil, r);
|
||||
|
||||
spin_unlock_irqrestore(&sta->tid_rx_lock, flags);
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) {
|
||||
if (wil->vring2cid_tid[i][0] == cid)
|
||||
wil_vring_fini_tx(wil, i);
|
||||
}
|
||||
memset(&sta->stats, 0, sizeof(sta->stats));
|
||||
}
|
||||
|
||||
static void _wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid)
|
||||
{
|
||||
int cid = -ENOENT;
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
|
||||
might_sleep();
|
||||
if (bssid) {
|
||||
cid = wil_find_cid(wil, bssid);
|
||||
wil_dbg_misc(wil, "%s(%pM, CID %d)\n", __func__, bssid, cid);
|
||||
} else {
|
||||
wil_dbg_misc(wil, "%s(all)\n", __func__);
|
||||
}
|
||||
|
||||
if (cid >= 0) /* disconnect 1 peer */
|
||||
wil_disconnect_cid(wil, cid);
|
||||
else /* disconnect all */
|
||||
for (cid = 0; cid < WIL6210_MAX_CID; cid++)
|
||||
wil_disconnect_cid(wil, cid);
|
||||
|
||||
/* link state */
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
case NL80211_IFTYPE_P2P_CLIENT:
|
||||
wil_link_off(wil);
|
||||
if (test_bit(wil_status_fwconnected, &wil->status)) {
|
||||
clear_bit(wil_status_fwconnected, &wil->status);
|
||||
cfg80211_disconnected(ndev,
|
||||
WLAN_STATUS_UNSPECIFIED_FAILURE,
|
||||
NULL, 0, GFP_KERNEL);
|
||||
} else if (test_bit(wil_status_fwconnecting, &wil->status)) {
|
||||
cfg80211_connect_result(ndev, bssid, NULL, 0, NULL, 0,
|
||||
WLAN_STATUS_UNSPECIFIED_FAILURE,
|
||||
GFP_KERNEL);
|
||||
}
|
||||
clear_bit(wil_status_fwconnecting, &wil->status);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void wil_disconnect_worker(struct work_struct *work)
|
||||
{
|
||||
struct wil6210_priv *wil = container_of(work,
|
||||
struct wil6210_priv, disconnect_worker);
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
_wil6210_disconnect(wil, NULL);
|
||||
mutex_unlock(&wil->mutex);
|
||||
}
|
||||
|
||||
static void wil_connect_timer_fn(ulong x)
|
||||
{
|
||||
struct wil6210_priv *wil = (void *)x;
|
||||
|
||||
wil_dbg_misc(wil, "Connect timeout\n");
|
||||
|
||||
/* reschedule to thread context - disconnect won't
|
||||
* run from atomic context
|
||||
*/
|
||||
schedule_work(&wil->disconnect_worker);
|
||||
}
|
||||
|
||||
static void wil_scan_timer_fn(ulong x)
|
||||
{
|
||||
struct wil6210_priv *wil = (void *)x;
|
||||
|
||||
clear_bit(wil_status_fwready, &wil->status);
|
||||
wil_err(wil, "Scan timeout detected, start fw error recovery\n");
|
||||
schedule_work(&wil->fw_error_worker);
|
||||
}
|
||||
|
||||
static int wil_wait_for_recovery(struct wil6210_priv *wil)
|
||||
{
|
||||
if (wait_event_interruptible(wil->wq, wil->recovery_state !=
|
||||
fw_recovery_pending)) {
|
||||
wil_err(wil, "Interrupt, canceling recovery\n");
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
if (wil->recovery_state != fw_recovery_running) {
|
||||
wil_info(wil, "Recovery cancelled\n");
|
||||
return -EINTR;
|
||||
}
|
||||
wil_info(wil, "Proceed with recovery\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wil_set_recovery_state(struct wil6210_priv *wil, int state)
|
||||
{
|
||||
wil_dbg_misc(wil, "%s(%d -> %d)\n", __func__,
|
||||
wil->recovery_state, state);
|
||||
|
||||
wil->recovery_state = state;
|
||||
wake_up_interruptible(&wil->wq);
|
||||
}
|
||||
|
||||
static void wil_fw_error_worker(struct work_struct *work)
|
||||
{
|
||||
struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
|
||||
fw_error_worker);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
|
||||
wil_dbg_misc(wil, "fw error worker\n");
|
||||
|
||||
/* increment @recovery_count if less then WIL6210_FW_RECOVERY_TO
|
||||
* passed since last recovery attempt
|
||||
*/
|
||||
if (time_is_after_jiffies(wil->last_fw_recovery +
|
||||
WIL6210_FW_RECOVERY_TO))
|
||||
wil->recovery_count++;
|
||||
else
|
||||
wil->recovery_count = 1; /* fw was alive for a long time */
|
||||
|
||||
if (wil->recovery_count > WIL6210_FW_RECOVERY_RETRIES) {
|
||||
wil_err(wil, "too many recovery attempts (%d), giving up\n",
|
||||
wil->recovery_count);
|
||||
return;
|
||||
}
|
||||
|
||||
wil->last_fw_recovery = jiffies;
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
case NL80211_IFTYPE_P2P_CLIENT:
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
wil_info(wil, "fw error recovery requested (try %d)...\n",
|
||||
wil->recovery_count);
|
||||
if (!no_fw_recovery)
|
||||
wil->recovery_state = fw_recovery_running;
|
||||
if (0 != wil_wait_for_recovery(wil))
|
||||
break;
|
||||
|
||||
__wil_down(wil);
|
||||
__wil_up(wil);
|
||||
break;
|
||||
case NL80211_IFTYPE_AP:
|
||||
case NL80211_IFTYPE_P2P_GO:
|
||||
/* recovery in these modes is done by upper layers */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&wil->mutex);
|
||||
}
|
||||
|
||||
static int wil_find_free_vring(struct wil6210_priv *wil)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < WIL6210_MAX_TX_RINGS; i++) {
|
||||
if (!wil->vring_tx[i].va)
|
||||
return i;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void wil_connect_worker(struct work_struct *work)
|
||||
{
|
||||
int rc;
|
||||
struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
|
||||
connect_worker);
|
||||
int cid = wil->pending_connect_cid;
|
||||
int ringid = wil_find_free_vring(wil);
|
||||
|
||||
if (cid < 0) {
|
||||
wil_err(wil, "No connection pending\n");
|
||||
return;
|
||||
}
|
||||
|
||||
wil_dbg_wmi(wil, "Configure for connection CID %d\n", cid);
|
||||
|
||||
rc = wil_vring_init_tx(wil, ringid, WIL6210_TX_RING_SIZE, cid, 0);
|
||||
wil->pending_connect_cid = -1;
|
||||
if (rc == 0) {
|
||||
wil->sta[cid].status = wil_sta_connected;
|
||||
wil_link_on(wil);
|
||||
} else {
|
||||
wil->sta[cid].status = wil_sta_unused;
|
||||
}
|
||||
}
|
||||
|
||||
int wil_priv_init(struct wil6210_priv *wil)
|
||||
{
|
||||
uint i;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
memset(wil->sta, 0, sizeof(wil->sta));
|
||||
for (i = 0; i < WIL6210_MAX_CID; i++)
|
||||
spin_lock_init(&wil->sta[i].tid_rx_lock);
|
||||
|
||||
mutex_init(&wil->mutex);
|
||||
mutex_init(&wil->wmi_mutex);
|
||||
|
||||
init_completion(&wil->wmi_ready);
|
||||
init_completion(&wil->wmi_call);
|
||||
|
||||
wil->pending_connect_cid = -1;
|
||||
setup_timer(&wil->connect_timer, wil_connect_timer_fn, (ulong)wil);
|
||||
setup_timer(&wil->scan_timer, wil_scan_timer_fn, (ulong)wil);
|
||||
|
||||
INIT_WORK(&wil->connect_worker, wil_connect_worker);
|
||||
INIT_WORK(&wil->disconnect_worker, wil_disconnect_worker);
|
||||
INIT_WORK(&wil->wmi_event_worker, wmi_event_worker);
|
||||
INIT_WORK(&wil->fw_error_worker, wil_fw_error_worker);
|
||||
|
||||
INIT_LIST_HEAD(&wil->pending_wmi_ev);
|
||||
spin_lock_init(&wil->wmi_ev_lock);
|
||||
init_waitqueue_head(&wil->wq);
|
||||
|
||||
wil->wmi_wq = create_singlethread_workqueue(WIL_NAME"_wmi");
|
||||
if (!wil->wmi_wq)
|
||||
return -EAGAIN;
|
||||
|
||||
wil->wmi_wq_conn = create_singlethread_workqueue(WIL_NAME"_connect");
|
||||
if (!wil->wmi_wq_conn) {
|
||||
destroy_workqueue(wil->wmi_wq);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
wil->last_fw_recovery = jiffies;
|
||||
wil->itr_trsh = itr_trsh;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid)
|
||||
{
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
del_timer_sync(&wil->connect_timer);
|
||||
_wil6210_disconnect(wil, bssid);
|
||||
}
|
||||
|
||||
void wil_priv_deinit(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
wil_set_recovery_state(wil, fw_recovery_idle);
|
||||
del_timer_sync(&wil->scan_timer);
|
||||
cancel_work_sync(&wil->disconnect_worker);
|
||||
cancel_work_sync(&wil->fw_error_worker);
|
||||
mutex_lock(&wil->mutex);
|
||||
wil6210_disconnect(wil, NULL);
|
||||
mutex_unlock(&wil->mutex);
|
||||
wmi_event_flush(wil);
|
||||
destroy_workqueue(wil->wmi_wq_conn);
|
||||
destroy_workqueue(wil->wmi_wq);
|
||||
}
|
||||
|
||||
/* target operations */
|
||||
/* register read */
|
||||
#define R(a) ioread32(wil->csr + HOSTADDR(a))
|
||||
/* register write. wmb() to make sure it is completed */
|
||||
#define W(a, v) do { iowrite32(v, wil->csr + HOSTADDR(a)); wmb(); } while (0)
|
||||
/* register set = read, OR, write */
|
||||
#define S(a, v) W(a, R(a) | v)
|
||||
/* register clear = read, AND with inverted, write */
|
||||
#define C(a, v) W(a, R(a) & ~v)
|
||||
|
||||
static inline void wil_halt_cpu(struct wil6210_priv *wil)
|
||||
{
|
||||
W(RGF_USER_USER_CPU_0, BIT_USER_USER_CPU_MAN_RST);
|
||||
W(RGF_USER_MAC_CPU_0, BIT_USER_MAC_CPU_MAN_RST);
|
||||
}
|
||||
|
||||
static inline void wil_release_cpu(struct wil6210_priv *wil)
|
||||
{
|
||||
/* Start CPU */
|
||||
W(RGF_USER_USER_CPU_0, 1);
|
||||
}
|
||||
|
||||
static int wil_target_reset(struct wil6210_priv *wil)
|
||||
{
|
||||
int delay = 0;
|
||||
u32 hw_state;
|
||||
u32 rev_id;
|
||||
bool is_sparrow = (wil->board->board == WIL_BOARD_SPARROW);
|
||||
|
||||
wil_dbg_misc(wil, "Resetting \"%s\"...\n", wil->board->name);
|
||||
|
||||
wil->hw_version = R(RGF_USER_FW_REV_ID);
|
||||
rev_id = wil->hw_version & 0xff;
|
||||
|
||||
/* Clear MAC link up */
|
||||
S(RGF_HP_CTRL, BIT(15));
|
||||
S(RGF_USER_CLKS_CTL_SW_RST_MASK_0, BIT_HPAL_PERST_FROM_PAD);
|
||||
S(RGF_USER_CLKS_CTL_SW_RST_MASK_0, BIT_CAR_PERST_RST);
|
||||
|
||||
wil_halt_cpu(wil);
|
||||
C(RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_CAR_AHB_SW_SEL); /* 40 MHz */
|
||||
|
||||
if (is_sparrow) {
|
||||
W(RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0, 0x3ff81f);
|
||||
W(RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1, 0xf);
|
||||
}
|
||||
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0xFE000000);
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_1, 0x0000003F);
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, is_sparrow ? 0x000000f0 : 0x00000170);
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_0, 0xFFE7FE00);
|
||||
|
||||
if (is_sparrow) {
|
||||
W(RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0, 0x0);
|
||||
W(RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1, 0x0);
|
||||
}
|
||||
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, 0);
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0);
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_1, 0);
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_0, 0);
|
||||
|
||||
if (is_sparrow) {
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, 0x00000003);
|
||||
/* reset A2 PCIE AHB */
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00008000);
|
||||
} else {
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, 0x00000001);
|
||||
if (rev_id == 1) {
|
||||
/* reset A1 BOTH PCIE AHB & PCIE RGF */
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00000080);
|
||||
} else {
|
||||
W(RGF_PCIE_LOS_COUNTER_CTL, BIT(6) | BIT(8));
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00008000);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: check order here!!! Erez code is different */
|
||||
W(RGF_USER_CLKS_CTL_SW_RST_VEC_0, 0);
|
||||
|
||||
/* wait until device ready. typical time is 200..250 msec */
|
||||
do {
|
||||
msleep(RST_DELAY);
|
||||
hw_state = R(RGF_USER_HW_MACHINE_STATE);
|
||||
if (delay++ > RST_COUNT) {
|
||||
wil_err(wil, "Reset not completed, hw_state 0x%08x\n",
|
||||
hw_state);
|
||||
return -ETIME;
|
||||
}
|
||||
} while (hw_state != HW_MACHINE_BOOT_DONE);
|
||||
|
||||
/* TODO: Erez check rev_id != 1 */
|
||||
if (!is_sparrow && (rev_id != 1))
|
||||
W(RGF_PCIE_LOS_COUNTER_CTL, BIT(8));
|
||||
|
||||
C(RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD);
|
||||
|
||||
wil_dbg_misc(wil, "Reset completed in %d ms\n", delay * RST_DELAY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* wil_set_itr_trsh: - apply interrupt coalescing params
|
||||
*/
|
||||
void wil_set_itr_trsh(struct wil6210_priv *wil)
|
||||
{
|
||||
/* disable, use usec resolution */
|
||||
W(RGF_DMA_ITR_CNT_CRL, BIT_DMA_ITR_CNT_CRL_EXT_TICK);
|
||||
|
||||
/* disable interrupt moderation for monitor
|
||||
* to get better timestamp precision
|
||||
*/
|
||||
if (wil->wdev->iftype == NL80211_IFTYPE_MONITOR)
|
||||
return;
|
||||
|
||||
wil_info(wil, "set ITR_TRSH = %d usec\n", wil->itr_trsh);
|
||||
W(RGF_DMA_ITR_CNT_TRSH, wil->itr_trsh);
|
||||
W(RGF_DMA_ITR_CNT_CRL, BIT_DMA_ITR_CNT_CRL_EN |
|
||||
BIT_DMA_ITR_CNT_CRL_EXT_TICK); /* start it */
|
||||
}
|
||||
|
||||
#undef R
|
||||
#undef W
|
||||
#undef S
|
||||
#undef C
|
||||
|
||||
void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r)
|
||||
{
|
||||
le32_to_cpus(&r->base);
|
||||
le16_to_cpus(&r->entry_size);
|
||||
le16_to_cpus(&r->size);
|
||||
le32_to_cpus(&r->tail);
|
||||
le32_to_cpus(&r->head);
|
||||
}
|
||||
|
||||
static int wil_wait_for_fw_ready(struct wil6210_priv *wil)
|
||||
{
|
||||
ulong to = msecs_to_jiffies(1000);
|
||||
ulong left = wait_for_completion_timeout(&wil->wmi_ready, to);
|
||||
|
||||
if (0 == left) {
|
||||
wil_err(wil, "Firmware not ready\n");
|
||||
return -ETIME;
|
||||
} else {
|
||||
wil_info(wil, "FW ready after %d ms. HW version 0x%08x\n",
|
||||
jiffies_to_msecs(to-left), wil->hw_version);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* We reset all the structures, and we reset the UMAC.
|
||||
* After calling this routine, you're expected to reload
|
||||
* the firmware.
|
||||
*/
|
||||
int wil_reset(struct wil6210_priv *wil)
|
||||
{
|
||||
int rc;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
WARN_ON(!mutex_is_locked(&wil->mutex));
|
||||
WARN_ON(test_bit(wil_status_napi_en, &wil->status));
|
||||
|
||||
cancel_work_sync(&wil->disconnect_worker);
|
||||
wil6210_disconnect(wil, NULL);
|
||||
|
||||
wil->status = 0; /* prevent NAPI from being scheduled */
|
||||
|
||||
if (wil->scan_request) {
|
||||
wil_dbg_misc(wil, "Abort scan_request 0x%p\n",
|
||||
wil->scan_request);
|
||||
del_timer_sync(&wil->scan_timer);
|
||||
cfg80211_scan_done(wil->scan_request, true);
|
||||
wil->scan_request = NULL;
|
||||
}
|
||||
|
||||
wil_mask_irq(wil);
|
||||
|
||||
wmi_event_flush(wil);
|
||||
|
||||
flush_workqueue(wil->wmi_wq_conn);
|
||||
flush_workqueue(wil->wmi_wq);
|
||||
|
||||
rc = wil_target_reset(wil);
|
||||
wil_rx_fini(wil);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (!no_fw_load) {
|
||||
wil_info(wil, "Use firmware <%s>\n", WIL_FW_NAME);
|
||||
wil_halt_cpu(wil);
|
||||
/* Loading f/w from the file */
|
||||
rc = wil_request_firmware(wil, WIL_FW_NAME);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
/* clear any interrupts which on-card-firmware may have set */
|
||||
wil6210_clear_irq(wil);
|
||||
{ /* CAF_ICR - clear and mask */
|
||||
u32 a = HOSTADDR(RGF_CAF_ICR) +
|
||||
offsetof(struct RGF_ICR, ICR);
|
||||
u32 m = HOSTADDR(RGF_CAF_ICR) +
|
||||
offsetof(struct RGF_ICR, IMV);
|
||||
u32 icr = ioread32(wil->csr + a);
|
||||
|
||||
iowrite32(icr, wil->csr + a); /* W1C */
|
||||
iowrite32(~0, wil->csr + m);
|
||||
wmb(); /* wait for completion */
|
||||
}
|
||||
wil_release_cpu(wil);
|
||||
} else {
|
||||
wil_info(wil, "Use firmware from on-card flash\n");
|
||||
}
|
||||
|
||||
/* init after reset */
|
||||
wil->pending_connect_cid = -1;
|
||||
reinit_completion(&wil->wmi_ready);
|
||||
reinit_completion(&wil->wmi_call);
|
||||
|
||||
wil_unmask_irq(wil);
|
||||
|
||||
/* we just started MAC, wait for FW ready */
|
||||
rc = wil_wait_for_fw_ready(wil);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void wil_fw_error_recovery(struct wil6210_priv *wil)
|
||||
{
|
||||
wil_dbg_misc(wil, "starting fw error recovery\n");
|
||||
wil->recovery_state = fw_recovery_pending;
|
||||
schedule_work(&wil->fw_error_worker);
|
||||
}
|
||||
|
||||
void wil_link_on(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
netif_carrier_on(ndev);
|
||||
wil_dbg_misc(wil, "netif_tx_wake : link on\n");
|
||||
netif_tx_wake_all_queues(ndev);
|
||||
}
|
||||
|
||||
void wil_link_off(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
netif_tx_stop_all_queues(ndev);
|
||||
wil_dbg_misc(wil, "netif_tx_stop : link off\n");
|
||||
netif_carrier_off(ndev);
|
||||
}
|
||||
|
||||
int __wil_up(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct wireless_dev *wdev = wil->wdev;
|
||||
int rc;
|
||||
|
||||
WARN_ON(!mutex_is_locked(&wil->mutex));
|
||||
|
||||
rc = wil_reset(wil);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
/* Rx VRING. After MAC and beacon */
|
||||
rc = wil_rx_init(wil);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
wil_dbg_misc(wil, "type: STATION\n");
|
||||
ndev->type = ARPHRD_ETHER;
|
||||
break;
|
||||
case NL80211_IFTYPE_AP:
|
||||
wil_dbg_misc(wil, "type: AP\n");
|
||||
ndev->type = ARPHRD_ETHER;
|
||||
break;
|
||||
case NL80211_IFTYPE_P2P_CLIENT:
|
||||
wil_dbg_misc(wil, "type: P2P_CLIENT\n");
|
||||
ndev->type = ARPHRD_ETHER;
|
||||
break;
|
||||
case NL80211_IFTYPE_P2P_GO:
|
||||
wil_dbg_misc(wil, "type: P2P_GO\n");
|
||||
ndev->type = ARPHRD_ETHER;
|
||||
break;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
wil_dbg_misc(wil, "type: Monitor\n");
|
||||
ndev->type = ARPHRD_IEEE80211_RADIOTAP;
|
||||
/* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_RADIOTAP ? */
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* MAC address - pre-requisite for other commands */
|
||||
wmi_set_mac_address(wil, ndev->dev_addr);
|
||||
|
||||
wil_dbg_misc(wil, "NAPI enable\n");
|
||||
napi_enable(&wil->napi_rx);
|
||||
napi_enable(&wil->napi_tx);
|
||||
set_bit(wil_status_napi_en, &wil->status);
|
||||
|
||||
if (wil->platform_ops.bus_request)
|
||||
wil->platform_ops.bus_request(wil->platform_handle,
|
||||
WIL_MAX_BUS_REQUEST_KBPS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wil_up(struct wil6210_priv *wil)
|
||||
{
|
||||
int rc;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
mutex_lock(&wil->mutex);
|
||||
rc = __wil_up(wil);
|
||||
mutex_unlock(&wil->mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int __wil_down(struct wil6210_priv *wil)
|
||||
{
|
||||
int iter = WAIT_FOR_DISCONNECT_TIMEOUT_MS /
|
||||
WAIT_FOR_DISCONNECT_INTERVAL_MS;
|
||||
|
||||
WARN_ON(!mutex_is_locked(&wil->mutex));
|
||||
|
||||
if (wil->platform_ops.bus_request)
|
||||
wil->platform_ops.bus_request(wil->platform_handle, 0);
|
||||
|
||||
wil_disable_irq(wil);
|
||||
if (test_and_clear_bit(wil_status_napi_en, &wil->status)) {
|
||||
napi_disable(&wil->napi_rx);
|
||||
napi_disable(&wil->napi_tx);
|
||||
wil_dbg_misc(wil, "NAPI disable\n");
|
||||
}
|
||||
wil_enable_irq(wil);
|
||||
|
||||
if (wil->scan_request) {
|
||||
wil_dbg_misc(wil, "Abort scan_request 0x%p\n",
|
||||
wil->scan_request);
|
||||
del_timer_sync(&wil->scan_timer);
|
||||
cfg80211_scan_done(wil->scan_request, true);
|
||||
wil->scan_request = NULL;
|
||||
}
|
||||
|
||||
if (test_bit(wil_status_fwconnected, &wil->status) ||
|
||||
test_bit(wil_status_fwconnecting, &wil->status))
|
||||
wmi_send(wil, WMI_DISCONNECT_CMDID, NULL, 0);
|
||||
|
||||
/* make sure wil is idle (not connected) */
|
||||
mutex_unlock(&wil->mutex);
|
||||
while (iter--) {
|
||||
int idle = !test_bit(wil_status_fwconnected, &wil->status) &&
|
||||
!test_bit(wil_status_fwconnecting, &wil->status);
|
||||
if (idle)
|
||||
break;
|
||||
msleep(WAIT_FOR_DISCONNECT_INTERVAL_MS);
|
||||
}
|
||||
mutex_lock(&wil->mutex);
|
||||
|
||||
if (!iter)
|
||||
wil_err(wil, "timeout waiting for idle FW/HW\n");
|
||||
|
||||
wil_rx_fini(wil);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wil_down(struct wil6210_priv *wil)
|
||||
{
|
||||
int rc;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
wil_set_recovery_state(wil, fw_recovery_idle);
|
||||
mutex_lock(&wil->mutex);
|
||||
rc = __wil_down(wil);
|
||||
mutex_unlock(&wil->mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int wil_find_cid(struct wil6210_priv *wil, const u8 *mac)
|
||||
{
|
||||
int i;
|
||||
int rc = -ENOENT;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
|
||||
if ((wil->sta[i].status != wil_sta_unused) &&
|
||||
ether_addr_equal(wil->sta[i].addr, mac)) {
|
||||
rc = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
232
drivers/net/wireless/ath/wil6210/netdev.c
Normal file
232
drivers/net/wireless/ath/wil6210/netdev.c
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
#include "wil6210.h"
|
||||
#include "txrx.h"
|
||||
|
||||
static int wil_open(struct net_device *ndev)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
return wil_up(wil);
|
||||
}
|
||||
|
||||
static int wil_stop(struct net_device *ndev)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
return wil_down(wil);
|
||||
}
|
||||
|
||||
static int wil_change_mtu(struct net_device *ndev, int new_mtu)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
if (new_mtu < 68 || new_mtu > (TX_BUF_LEN - ETH_HLEN)) {
|
||||
wil_err(wil, "invalid MTU %d\n", new_mtu);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wil_dbg_misc(wil, "change MTU %d -> %d\n", ndev->mtu, new_mtu);
|
||||
ndev->mtu = new_mtu;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_do_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
|
||||
{
|
||||
struct wil6210_priv *wil = ndev_to_wil(ndev);
|
||||
|
||||
int ret = wil_ioctl(wil, ifr->ifr_data, cmd);
|
||||
|
||||
wil_dbg_misc(wil, "ioctl(0x%04x) -> %d\n", cmd, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct net_device_ops wil_netdev_ops = {
|
||||
.ndo_open = wil_open,
|
||||
.ndo_stop = wil_stop,
|
||||
.ndo_start_xmit = wil_start_xmit,
|
||||
.ndo_set_mac_address = eth_mac_addr,
|
||||
.ndo_validate_addr = eth_validate_addr,
|
||||
.ndo_change_mtu = wil_change_mtu,
|
||||
.ndo_do_ioctl = wil_do_ioctl,
|
||||
};
|
||||
|
||||
static int wil6210_netdev_poll_rx(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct wil6210_priv *wil = container_of(napi, struct wil6210_priv,
|
||||
napi_rx);
|
||||
int quota = budget;
|
||||
int done;
|
||||
|
||||
wil_rx_handle(wil, "a);
|
||||
done = budget - quota;
|
||||
|
||||
if (done <= 1) { /* burst ends - only one packet processed */
|
||||
napi_complete(napi);
|
||||
wil6210_unmask_irq_rx(wil);
|
||||
wil_dbg_txrx(wil, "NAPI RX complete\n");
|
||||
}
|
||||
|
||||
wil_dbg_txrx(wil, "NAPI RX poll(%d) done %d\n", budget, done);
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
static int wil6210_netdev_poll_tx(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct wil6210_priv *wil = container_of(napi, struct wil6210_priv,
|
||||
napi_tx);
|
||||
int tx_done = 0;
|
||||
uint i;
|
||||
|
||||
/* always process ALL Tx complete, regardless budget - it is fast */
|
||||
for (i = 0; i < WIL6210_MAX_TX_RINGS; i++) {
|
||||
struct vring *vring = &wil->vring_tx[i];
|
||||
|
||||
if (!vring->va)
|
||||
continue;
|
||||
|
||||
tx_done += wil_tx_complete(wil, i);
|
||||
}
|
||||
|
||||
if (tx_done <= 1) { /* burst ends - only one packet processed */
|
||||
napi_complete(napi);
|
||||
wil6210_unmask_irq_tx(wil);
|
||||
wil_dbg_txrx(wil, "NAPI TX complete\n");
|
||||
}
|
||||
|
||||
wil_dbg_txrx(wil, "NAPI TX poll(%d) done %d\n", budget, tx_done);
|
||||
|
||||
return min(tx_done, budget);
|
||||
}
|
||||
|
||||
void *wil_if_alloc(struct device *dev, void __iomem *csr)
|
||||
{
|
||||
struct net_device *ndev;
|
||||
struct wireless_dev *wdev;
|
||||
struct wil6210_priv *wil;
|
||||
struct ieee80211_channel *ch;
|
||||
int rc = 0;
|
||||
|
||||
wdev = wil_cfg80211_init(dev);
|
||||
if (IS_ERR(wdev)) {
|
||||
dev_err(dev, "wil_cfg80211_init failed\n");
|
||||
return wdev;
|
||||
}
|
||||
|
||||
wil = wdev_to_wil(wdev);
|
||||
wil->csr = csr;
|
||||
wil->wdev = wdev;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
rc = wil_priv_init(wil);
|
||||
if (rc) {
|
||||
dev_err(dev, "wil_priv_init failed\n");
|
||||
goto out_wdev;
|
||||
}
|
||||
|
||||
wdev->iftype = NL80211_IFTYPE_STATION; /* TODO */
|
||||
/* default monitor channel */
|
||||
ch = wdev->wiphy->bands[IEEE80211_BAND_60GHZ]->channels;
|
||||
cfg80211_chandef_create(&wdev->preset_chandef, ch, NL80211_CHAN_NO_HT);
|
||||
|
||||
ndev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, ether_setup);
|
||||
if (!ndev) {
|
||||
dev_err(dev, "alloc_netdev_mqs failed\n");
|
||||
rc = -ENOMEM;
|
||||
goto out_priv;
|
||||
}
|
||||
|
||||
ndev->netdev_ops = &wil_netdev_ops;
|
||||
wil_set_ethtoolops(ndev);
|
||||
ndev->ieee80211_ptr = wdev;
|
||||
ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
|
||||
NETIF_F_SG | NETIF_F_GRO;
|
||||
ndev->features |= ndev->hw_features;
|
||||
SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
|
||||
wdev->netdev = ndev;
|
||||
|
||||
netif_napi_add(ndev, &wil->napi_rx, wil6210_netdev_poll_rx,
|
||||
WIL6210_NAPI_BUDGET);
|
||||
netif_napi_add(ndev, &wil->napi_tx, wil6210_netdev_poll_tx,
|
||||
WIL6210_NAPI_BUDGET);
|
||||
|
||||
wil_link_off(wil);
|
||||
|
||||
return wil;
|
||||
|
||||
out_priv:
|
||||
wil_priv_deinit(wil);
|
||||
|
||||
out_wdev:
|
||||
wil_wdev_free(wil);
|
||||
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
void wil_if_free(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
if (!ndev)
|
||||
return;
|
||||
|
||||
wil_priv_deinit(wil);
|
||||
|
||||
wil_to_ndev(wil) = NULL;
|
||||
free_netdev(ndev);
|
||||
|
||||
wil_wdev_free(wil);
|
||||
}
|
||||
|
||||
int wil_if_add(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
int rc;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
rc = register_netdev(ndev);
|
||||
if (rc < 0) {
|
||||
dev_err(&ndev->dev, "Failed to register netdev: %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
wil_link_off(wil);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wil_if_remove(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
unregister_netdev(ndev);
|
||||
}
|
||||
301
drivers/net/wireless/ath/wil6210/pcie_bus.c
Normal file
301
drivers/net/wireless/ath/wil6210/pcie_bus.c
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include "wil6210.h"
|
||||
|
||||
static int use_msi = 1;
|
||||
module_param(use_msi, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(use_msi,
|
||||
" Use MSI interrupt: "
|
||||
"0 - don't, 1 - (default) - single, or 3");
|
||||
|
||||
static bool debug_fw; /* = false; */
|
||||
module_param(debug_fw, bool, S_IRUGO);
|
||||
MODULE_PARM_DESC(debug_fw, " load driver if FW not ready. For FW debug");
|
||||
|
||||
void wil_disable_irq(struct wil6210_priv *wil)
|
||||
{
|
||||
int irq = wil->pdev->irq;
|
||||
|
||||
disable_irq(irq);
|
||||
if (wil->n_msi == 3) {
|
||||
disable_irq(irq + 1);
|
||||
disable_irq(irq + 2);
|
||||
}
|
||||
}
|
||||
|
||||
void wil_enable_irq(struct wil6210_priv *wil)
|
||||
{
|
||||
int irq = wil->pdev->irq;
|
||||
|
||||
enable_irq(irq);
|
||||
if (wil->n_msi == 3) {
|
||||
enable_irq(irq + 1);
|
||||
enable_irq(irq + 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Bus ops */
|
||||
static int wil_if_pcie_enable(struct wil6210_priv *wil)
|
||||
{
|
||||
struct pci_dev *pdev = wil->pdev;
|
||||
int rc;
|
||||
/* on platforms with buggy ACPI, pdev->msi_enabled may be set to
|
||||
* allow pci_enable_device to work. This indicates INTx was not routed
|
||||
* and only MSI should be used
|
||||
*/
|
||||
int msi_only = pdev->msi_enabled;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
pdev->msi_enabled = 0;
|
||||
|
||||
pci_set_master(pdev);
|
||||
|
||||
/*
|
||||
* how many MSI interrupts to request?
|
||||
*/
|
||||
switch (use_msi) {
|
||||
case 3:
|
||||
case 1:
|
||||
wil_dbg_misc(wil, "Setup %d MSI interrupts\n", use_msi);
|
||||
break;
|
||||
case 0:
|
||||
wil_dbg_misc(wil, "MSI interrupts disabled, use INTx\n");
|
||||
break;
|
||||
default:
|
||||
wil_err(wil, "Invalid use_msi=%d, default to 1\n", use_msi);
|
||||
use_msi = 1;
|
||||
}
|
||||
|
||||
if (use_msi == 3 && pci_enable_msi_range(pdev, 3, 3) < 0) {
|
||||
wil_err(wil, "3 MSI mode failed, try 1 MSI\n");
|
||||
use_msi = 1;
|
||||
}
|
||||
|
||||
if (use_msi == 1 && pci_enable_msi(pdev)) {
|
||||
wil_err(wil, "pci_enable_msi failed, use INTx\n");
|
||||
use_msi = 0;
|
||||
}
|
||||
|
||||
wil->n_msi = use_msi;
|
||||
|
||||
if ((wil->n_msi == 0) && msi_only) {
|
||||
wil_err(wil, "Interrupt pin not routed, unable to use INTx\n");
|
||||
rc = -ENODEV;
|
||||
goto stop_master;
|
||||
}
|
||||
|
||||
rc = wil6210_init_irq(wil, pdev->irq);
|
||||
if (rc)
|
||||
goto stop_master;
|
||||
|
||||
/* need reset here to obtain MAC */
|
||||
mutex_lock(&wil->mutex);
|
||||
rc = wil_reset(wil);
|
||||
mutex_unlock(&wil->mutex);
|
||||
if (debug_fw)
|
||||
rc = 0;
|
||||
if (rc)
|
||||
goto release_irq;
|
||||
|
||||
return 0;
|
||||
|
||||
release_irq:
|
||||
wil6210_fini_irq(wil, pdev->irq);
|
||||
/* safe to call if no MSI */
|
||||
pci_disable_msi(pdev);
|
||||
stop_master:
|
||||
pci_clear_master(pdev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int wil_if_pcie_disable(struct wil6210_priv *wil)
|
||||
{
|
||||
struct pci_dev *pdev = wil->pdev;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
pci_clear_master(pdev);
|
||||
/* disable and release IRQ */
|
||||
wil6210_fini_irq(wil, pdev->irq);
|
||||
/* safe to call if no MSI */
|
||||
pci_disable_msi(pdev);
|
||||
/* TODO: disable HW */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
{
|
||||
struct wil6210_priv *wil;
|
||||
struct device *dev = &pdev->dev;
|
||||
void __iomem *csr;
|
||||
struct wil_board *board = (struct wil_board *)id->driver_data;
|
||||
int rc;
|
||||
|
||||
/* check HW */
|
||||
dev_info(&pdev->dev, WIL_NAME
|
||||
" \"%s\" device found [%04x:%04x] (rev %x)\n", board->name,
|
||||
(int)pdev->vendor, (int)pdev->device, (int)pdev->revision);
|
||||
|
||||
if (pci_resource_len(pdev, 0) != WIL6210_MEM_SIZE) {
|
||||
dev_err(&pdev->dev, "Not " WIL_NAME "? "
|
||||
"BAR0 size is %lu while expecting %lu\n",
|
||||
(ulong)pci_resource_len(pdev, 0), WIL6210_MEM_SIZE);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rc = pci_enable_device(pdev);
|
||||
if (rc) {
|
||||
dev_err(&pdev->dev,
|
||||
"pci_enable_device failed, retry with MSI only\n");
|
||||
/* Work around for platforms that can't allocate IRQ:
|
||||
* retry with MSI only
|
||||
*/
|
||||
pdev->msi_enabled = 1;
|
||||
rc = pci_enable_device(pdev);
|
||||
}
|
||||
if (rc)
|
||||
return -ENODEV;
|
||||
/* rollback to err_disable_pdev */
|
||||
|
||||
rc = pci_request_region(pdev, 0, WIL_NAME);
|
||||
if (rc) {
|
||||
dev_err(&pdev->dev, "pci_request_region failed\n");
|
||||
goto err_disable_pdev;
|
||||
}
|
||||
/* rollback to err_release_reg */
|
||||
|
||||
csr = pci_ioremap_bar(pdev, 0);
|
||||
if (!csr) {
|
||||
dev_err(&pdev->dev, "pci_ioremap_bar failed\n");
|
||||
rc = -ENODEV;
|
||||
goto err_release_reg;
|
||||
}
|
||||
/* rollback to err_iounmap */
|
||||
dev_info(&pdev->dev, "CSR at %pR -> 0x%p\n", &pdev->resource[0], csr);
|
||||
|
||||
wil = wil_if_alloc(dev, csr);
|
||||
if (IS_ERR(wil)) {
|
||||
rc = (int)PTR_ERR(wil);
|
||||
dev_err(dev, "wil_if_alloc failed: %d\n", rc);
|
||||
goto err_iounmap;
|
||||
}
|
||||
/* rollback to if_free */
|
||||
|
||||
pci_set_drvdata(pdev, wil);
|
||||
wil->pdev = pdev;
|
||||
wil->board = board;
|
||||
|
||||
wil6210_clear_irq(wil);
|
||||
|
||||
wil->platform_handle =
|
||||
wil_platform_init(&pdev->dev, &wil->platform_ops);
|
||||
|
||||
/* FW should raise IRQ when ready */
|
||||
rc = wil_if_pcie_enable(wil);
|
||||
if (rc) {
|
||||
wil_err(wil, "Enable device failed\n");
|
||||
goto if_free;
|
||||
}
|
||||
/* rollback to bus_disable */
|
||||
|
||||
rc = wil_if_add(wil);
|
||||
if (rc) {
|
||||
wil_err(wil, "wil_if_add failed: %d\n", rc);
|
||||
goto bus_disable;
|
||||
}
|
||||
|
||||
wil6210_debugfs_init(wil);
|
||||
|
||||
/* check FW is alive */
|
||||
wmi_echo(wil);
|
||||
|
||||
return 0;
|
||||
|
||||
bus_disable:
|
||||
wil_if_pcie_disable(wil);
|
||||
if_free:
|
||||
if (wil->platform_ops.uninit)
|
||||
wil->platform_ops.uninit(wil->platform_handle);
|
||||
wil_if_free(wil);
|
||||
err_iounmap:
|
||||
pci_iounmap(pdev, csr);
|
||||
err_release_reg:
|
||||
pci_release_region(pdev, 0);
|
||||
err_disable_pdev:
|
||||
pci_disable_device(pdev);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void wil_pcie_remove(struct pci_dev *pdev)
|
||||
{
|
||||
struct wil6210_priv *wil = pci_get_drvdata(pdev);
|
||||
void __iomem *csr = wil->csr;
|
||||
|
||||
wil_dbg_misc(wil, "%s()\n", __func__);
|
||||
|
||||
wil6210_debugfs_remove(wil);
|
||||
wil_if_remove(wil);
|
||||
wil_if_pcie_disable(wil);
|
||||
if (wil->platform_ops.uninit)
|
||||
wil->platform_ops.uninit(wil->platform_handle);
|
||||
wil_if_free(wil);
|
||||
pci_iounmap(pdev, csr);
|
||||
pci_release_region(pdev, 0);
|
||||
pci_disable_device(pdev);
|
||||
}
|
||||
|
||||
static const struct wil_board wil_board_marlon = {
|
||||
.board = WIL_BOARD_MARLON,
|
||||
.name = "marlon",
|
||||
};
|
||||
|
||||
static const struct wil_board wil_board_sparrow = {
|
||||
.board = WIL_BOARD_SPARROW,
|
||||
.name = "sparrow",
|
||||
};
|
||||
|
||||
static const struct pci_device_id wil6210_pcie_ids[] = {
|
||||
{ PCI_DEVICE(0x1ae9, 0x0301),
|
||||
.driver_data = (kernel_ulong_t)&wil_board_marlon },
|
||||
{ PCI_DEVICE(0x1ae9, 0x0310),
|
||||
.driver_data = (kernel_ulong_t)&wil_board_sparrow },
|
||||
{ PCI_DEVICE(0x1ae9, 0x0302), /* same as above, firmware broken */
|
||||
.driver_data = (kernel_ulong_t)&wil_board_sparrow },
|
||||
{ /* end: all zeroes */ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, wil6210_pcie_ids);
|
||||
|
||||
static struct pci_driver wil6210_driver = {
|
||||
.probe = wil_pcie_probe,
|
||||
.remove = wil_pcie_remove,
|
||||
.id_table = wil6210_pcie_ids,
|
||||
.name = WIL_NAME,
|
||||
};
|
||||
|
||||
module_pci_driver(wil6210_driver);
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_AUTHOR("Qualcomm Atheros <wil6210@qca.qualcomm.com>");
|
||||
MODULE_DESCRIPTION("Driver for 60g WiFi WIL6210 card");
|
||||
221
drivers/net/wireless/ath/wil6210/rx_reorder.c
Normal file
221
drivers/net/wireless/ath/wil6210/rx_reorder.c
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "wil6210.h"
|
||||
#include "txrx.h"
|
||||
|
||||
#define SEQ_MODULO 0x1000
|
||||
#define SEQ_MASK 0xfff
|
||||
|
||||
static inline int seq_less(u16 sq1, u16 sq2)
|
||||
{
|
||||
return ((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1);
|
||||
}
|
||||
|
||||
static inline u16 seq_inc(u16 sq)
|
||||
{
|
||||
return (sq + 1) & SEQ_MASK;
|
||||
}
|
||||
|
||||
static inline u16 seq_sub(u16 sq1, u16 sq2)
|
||||
{
|
||||
return (sq1 - sq2) & SEQ_MASK;
|
||||
}
|
||||
|
||||
static inline int reorder_index(struct wil_tid_ampdu_rx *r, u16 seq)
|
||||
{
|
||||
return seq_sub(seq, r->ssn) % r->buf_size;
|
||||
}
|
||||
|
||||
static void wil_release_reorder_frame(struct wil6210_priv *wil,
|
||||
struct wil_tid_ampdu_rx *r,
|
||||
int index)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct sk_buff *skb = r->reorder_buf[index];
|
||||
|
||||
if (!skb)
|
||||
goto no_frame;
|
||||
|
||||
/* release the frame from the reorder ring buffer */
|
||||
r->stored_mpdu_num--;
|
||||
r->reorder_buf[index] = NULL;
|
||||
wil_netif_rx_any(skb, ndev);
|
||||
|
||||
no_frame:
|
||||
r->head_seq_num = seq_inc(r->head_seq_num);
|
||||
}
|
||||
|
||||
static void wil_release_reorder_frames(struct wil6210_priv *wil,
|
||||
struct wil_tid_ampdu_rx *r,
|
||||
u16 hseq)
|
||||
{
|
||||
int index;
|
||||
|
||||
/* note: this function is never called with
|
||||
* hseq preceding r->head_seq_num, i.e it is always true
|
||||
* !seq_less(hseq, r->head_seq_num)
|
||||
* and thus on loop exit it should be
|
||||
* r->head_seq_num == hseq
|
||||
*/
|
||||
while (seq_less(r->head_seq_num, hseq) && r->stored_mpdu_num) {
|
||||
index = reorder_index(r, r->head_seq_num);
|
||||
wil_release_reorder_frame(wil, r, index);
|
||||
}
|
||||
r->head_seq_num = hseq;
|
||||
}
|
||||
|
||||
static void wil_reorder_release(struct wil6210_priv *wil,
|
||||
struct wil_tid_ampdu_rx *r)
|
||||
{
|
||||
int index = reorder_index(r, r->head_seq_num);
|
||||
|
||||
while (r->reorder_buf[index]) {
|
||||
wil_release_reorder_frame(wil, r, index);
|
||||
index = reorder_index(r, r->head_seq_num);
|
||||
}
|
||||
}
|
||||
|
||||
void wil_rx_reorder(struct wil6210_priv *wil, struct sk_buff *skb)
|
||||
{
|
||||
struct net_device *ndev = wil_to_ndev(wil);
|
||||
struct vring_rx_desc *d = wil_skb_rxdesc(skb);
|
||||
int tid = wil_rxdesc_tid(d);
|
||||
int cid = wil_rxdesc_cid(d);
|
||||
int mid = wil_rxdesc_mid(d);
|
||||
u16 seq = wil_rxdesc_seq(d);
|
||||
struct wil_sta_info *sta = &wil->sta[cid];
|
||||
struct wil_tid_ampdu_rx *r;
|
||||
u16 hseq;
|
||||
int index;
|
||||
unsigned long flags;
|
||||
|
||||
wil_dbg_txrx(wil, "MID %d CID %d TID %d Seq 0x%03x\n",
|
||||
mid, cid, tid, seq);
|
||||
|
||||
spin_lock_irqsave(&sta->tid_rx_lock, flags);
|
||||
|
||||
r = sta->tid_rx[tid];
|
||||
if (!r) {
|
||||
spin_unlock_irqrestore(&sta->tid_rx_lock, flags);
|
||||
wil_netif_rx_any(skb, ndev);
|
||||
return;
|
||||
}
|
||||
|
||||
hseq = r->head_seq_num;
|
||||
|
||||
/** Due to the race between WMI events, where BACK establishment
|
||||
* reported, and data Rx, few packets may be pass up before reorder
|
||||
* buffer get allocated. Catch up by pretending SSN is what we
|
||||
* see in the 1-st Rx packet
|
||||
*/
|
||||
if (r->first_time) {
|
||||
r->first_time = false;
|
||||
if (seq != r->head_seq_num) {
|
||||
wil_err(wil, "Error: 1-st frame with wrong sequence"
|
||||
" %d, should be %d. Fixing...\n", seq,
|
||||
r->head_seq_num);
|
||||
r->head_seq_num = seq;
|
||||
r->ssn = seq;
|
||||
}
|
||||
}
|
||||
|
||||
/* frame with out of date sequence number */
|
||||
if (seq_less(seq, r->head_seq_num)) {
|
||||
r->ssn_last_drop = seq;
|
||||
dev_kfree_skb(skb);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* If frame the sequence number exceeds our buffering window
|
||||
* size release some previous frames to make room for this one.
|
||||
*/
|
||||
if (!seq_less(seq, r->head_seq_num + r->buf_size)) {
|
||||
hseq = seq_inc(seq_sub(seq, r->buf_size));
|
||||
/* release stored frames up to new head to stack */
|
||||
wil_release_reorder_frames(wil, r, hseq);
|
||||
}
|
||||
|
||||
/* Now the new frame is always in the range of the reordering buffer */
|
||||
|
||||
index = reorder_index(r, seq);
|
||||
|
||||
/* check if we already stored this frame */
|
||||
if (r->reorder_buf[index]) {
|
||||
dev_kfree_skb(skb);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the current MPDU is in the right order and nothing else
|
||||
* is stored we can process it directly, no need to buffer it.
|
||||
* If it is first but there's something stored, we may be able
|
||||
* to release frames after this one.
|
||||
*/
|
||||
if (seq == r->head_seq_num && r->stored_mpdu_num == 0) {
|
||||
r->head_seq_num = seq_inc(r->head_seq_num);
|
||||
wil_netif_rx_any(skb, ndev);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* put the frame in the reordering buffer */
|
||||
r->reorder_buf[index] = skb;
|
||||
r->reorder_time[index] = jiffies;
|
||||
r->stored_mpdu_num++;
|
||||
wil_reorder_release(wil, r);
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&sta->tid_rx_lock, flags);
|
||||
}
|
||||
|
||||
struct wil_tid_ampdu_rx *wil_tid_ampdu_rx_alloc(struct wil6210_priv *wil,
|
||||
int size, u16 ssn)
|
||||
{
|
||||
struct wil_tid_ampdu_rx *r = kzalloc(sizeof(*r), GFP_KERNEL);
|
||||
|
||||
if (!r)
|
||||
return NULL;
|
||||
|
||||
r->reorder_buf =
|
||||
kcalloc(size, sizeof(struct sk_buff *), GFP_KERNEL);
|
||||
r->reorder_time =
|
||||
kcalloc(size, sizeof(unsigned long), GFP_KERNEL);
|
||||
if (!r->reorder_buf || !r->reorder_time) {
|
||||
kfree(r->reorder_buf);
|
||||
kfree(r->reorder_time);
|
||||
kfree(r);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r->ssn = ssn;
|
||||
r->head_seq_num = ssn;
|
||||
r->buf_size = size;
|
||||
r->stored_mpdu_num = 0;
|
||||
r->first_time = true;
|
||||
return r;
|
||||
}
|
||||
|
||||
void wil_tid_ampdu_rx_free(struct wil6210_priv *wil,
|
||||
struct wil_tid_ampdu_rx *r)
|
||||
{
|
||||
if (!r)
|
||||
return;
|
||||
wil_release_reorder_frames(wil, r, r->head_seq_num + r->buf_size);
|
||||
kfree(r->reorder_buf);
|
||||
kfree(r->reorder_time);
|
||||
kfree(r);
|
||||
}
|
||||
20
drivers/net/wireless/ath/wil6210/trace.c
Normal file
20
drivers/net/wireless/ath/wil6210/trace.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include "trace.h"
|
||||
239
drivers/net/wireless/ath/wil6210/trace.h
Normal file
239
drivers/net/wireless/ath/wil6210/trace.h
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM wil6210
|
||||
#if !defined(WIL6210_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define WIL6210_TRACE_H
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
#include "wil6210.h"
|
||||
#include "txrx.h"
|
||||
|
||||
/* create empty functions when tracing is disabled */
|
||||
#if !defined(CONFIG_WIL6210_TRACING) || defined(__CHECKER__)
|
||||
|
||||
#undef TRACE_EVENT
|
||||
#define TRACE_EVENT(name, proto, ...) \
|
||||
static inline void trace_ ## name(proto) {}
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(...)
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(evt_class, name, proto, ...) \
|
||||
static inline void trace_ ## name(proto) {}
|
||||
#endif /* !CONFIG_WIL6210_TRACING || defined(__CHECKER__) */
|
||||
|
||||
DECLARE_EVENT_CLASS(wil6210_wmi,
|
||||
TP_PROTO(struct wil6210_mbox_hdr_wmi *wmi, void *buf, u16 buf_len),
|
||||
|
||||
TP_ARGS(wmi, buf, buf_len),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(u8, mid)
|
||||
__field(u16, id)
|
||||
__field(u32, timestamp)
|
||||
__field(u16, buf_len)
|
||||
__dynamic_array(u8, buf, buf_len)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->mid = wmi->mid;
|
||||
__entry->id = le16_to_cpu(wmi->id);
|
||||
__entry->timestamp = le32_to_cpu(wmi->timestamp);
|
||||
__entry->buf_len = buf_len;
|
||||
memcpy(__get_dynamic_array(buf), buf, buf_len);
|
||||
),
|
||||
|
||||
TP_printk(
|
||||
"MID %d id 0x%04x len %d timestamp %d",
|
||||
__entry->mid, __entry->id, __entry->buf_len, __entry->timestamp
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_wmi, wil6210_wmi_cmd,
|
||||
TP_PROTO(struct wil6210_mbox_hdr_wmi *wmi, void *buf, u16 buf_len),
|
||||
TP_ARGS(wmi, buf, buf_len)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_wmi, wil6210_wmi_event,
|
||||
TP_PROTO(struct wil6210_mbox_hdr_wmi *wmi, void *buf, u16 buf_len),
|
||||
TP_ARGS(wmi, buf, buf_len)
|
||||
);
|
||||
|
||||
#define WIL6210_MSG_MAX (200)
|
||||
|
||||
DECLARE_EVENT_CLASS(wil6210_log_event,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf),
|
||||
TP_STRUCT__entry(
|
||||
__dynamic_array(char, msg, WIL6210_MSG_MAX)
|
||||
),
|
||||
TP_fast_assign(
|
||||
WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
|
||||
WIL6210_MSG_MAX,
|
||||
vaf->fmt,
|
||||
*vaf->va) >= WIL6210_MSG_MAX);
|
||||
),
|
||||
TP_printk("%s", __get_str(msg))
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_log_event, wil6210_log_err,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_log_event, wil6210_log_info,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_log_event, wil6210_log_dbg,
|
||||
TP_PROTO(struct va_format *vaf),
|
||||
TP_ARGS(vaf)
|
||||
);
|
||||
|
||||
#define wil_pseudo_irq_cause(x) __print_flags(x, "|", \
|
||||
{BIT_DMA_PSEUDO_CAUSE_RX, "Rx" }, \
|
||||
{BIT_DMA_PSEUDO_CAUSE_TX, "Tx" }, \
|
||||
{BIT_DMA_PSEUDO_CAUSE_MISC, "Misc" })
|
||||
|
||||
TRACE_EVENT(wil6210_irq_pseudo,
|
||||
TP_PROTO(u32 x),
|
||||
TP_ARGS(x),
|
||||
TP_STRUCT__entry(
|
||||
__field(u32, x)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->x = x;
|
||||
),
|
||||
TP_printk("cause 0x%08x : %s", __entry->x,
|
||||
wil_pseudo_irq_cause(__entry->x))
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(wil6210_irq,
|
||||
TP_PROTO(u32 x),
|
||||
TP_ARGS(x),
|
||||
TP_STRUCT__entry(
|
||||
__field(u32, x)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->x = x;
|
||||
),
|
||||
TP_printk("cause 0x%08x", __entry->x)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_irq, wil6210_irq_rx,
|
||||
TP_PROTO(u32 x),
|
||||
TP_ARGS(x)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_irq, wil6210_irq_tx,
|
||||
TP_PROTO(u32 x),
|
||||
TP_ARGS(x)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_irq, wil6210_irq_misc,
|
||||
TP_PROTO(u32 x),
|
||||
TP_ARGS(x)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wil6210_irq, wil6210_irq_misc_thread,
|
||||
TP_PROTO(u32 x),
|
||||
TP_ARGS(x)
|
||||
);
|
||||
|
||||
TRACE_EVENT(wil6210_rx,
|
||||
TP_PROTO(u16 index, struct vring_rx_desc *d),
|
||||
TP_ARGS(index, d),
|
||||
TP_STRUCT__entry(
|
||||
__field(u16, index)
|
||||
__field(unsigned int, len)
|
||||
__field(u8, mid)
|
||||
__field(u8, cid)
|
||||
__field(u8, tid)
|
||||
__field(u8, type)
|
||||
__field(u8, subtype)
|
||||
__field(u16, seq)
|
||||
__field(u8, mcs)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->index = index;
|
||||
__entry->len = d->dma.length;
|
||||
__entry->mid = wil_rxdesc_mid(d);
|
||||
__entry->cid = wil_rxdesc_cid(d);
|
||||
__entry->tid = wil_rxdesc_tid(d);
|
||||
__entry->type = wil_rxdesc_ftype(d);
|
||||
__entry->subtype = wil_rxdesc_subtype(d);
|
||||
__entry->seq = wil_rxdesc_seq(d);
|
||||
__entry->mcs = wil_rxdesc_mcs(d);
|
||||
),
|
||||
TP_printk("index %d len %d mid %d cid %d tid %d mcs %d seq 0x%03x"
|
||||
" type 0x%1x subtype 0x%1x", __entry->index, __entry->len,
|
||||
__entry->mid, __entry->cid, __entry->tid, __entry->mcs,
|
||||
__entry->seq, __entry->type, __entry->subtype)
|
||||
);
|
||||
|
||||
TRACE_EVENT(wil6210_tx,
|
||||
TP_PROTO(u8 vring, u16 index, unsigned int len, u8 frags),
|
||||
TP_ARGS(vring, index, len, frags),
|
||||
TP_STRUCT__entry(
|
||||
__field(u8, vring)
|
||||
__field(u8, frags)
|
||||
__field(u16, index)
|
||||
__field(unsigned int, len)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->vring = vring;
|
||||
__entry->frags = frags;
|
||||
__entry->index = index;
|
||||
__entry->len = len;
|
||||
),
|
||||
TP_printk("vring %d index %d len %d frags %d",
|
||||
__entry->vring, __entry->index, __entry->len, __entry->frags)
|
||||
);
|
||||
|
||||
TRACE_EVENT(wil6210_tx_done,
|
||||
TP_PROTO(u8 vring, u16 index, unsigned int len, u8 err),
|
||||
TP_ARGS(vring, index, len, err),
|
||||
TP_STRUCT__entry(
|
||||
__field(u8, vring)
|
||||
__field(u8, err)
|
||||
__field(u16, index)
|
||||
__field(unsigned int, len)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->vring = vring;
|
||||
__entry->index = index;
|
||||
__entry->len = len;
|
||||
__entry->err = err;
|
||||
),
|
||||
TP_printk("vring %d index %d len %d err 0x%02x",
|
||||
__entry->vring, __entry->index, __entry->len,
|
||||
__entry->err)
|
||||
);
|
||||
|
||||
#endif /* WIL6210_TRACE_H || TRACE_HEADER_MULTI_READ*/
|
||||
|
||||
#if defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__)
|
||||
/* we don't want to use include/trace/events */
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH .
|
||||
#undef TRACE_INCLUDE_FILE
|
||||
#define TRACE_INCLUDE_FILE trace
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
#endif /* defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__) */
|
||||
1193
drivers/net/wireless/ath/wil6210/txrx.c
Normal file
1193
drivers/net/wireless/ath/wil6210/txrx.c
Normal file
File diff suppressed because it is too large
Load diff
443
drivers/net/wireless/ath/wil6210/txrx.h
Normal file
443
drivers/net/wireless/ath/wil6210/txrx.h
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WIL6210_TXRX_H
|
||||
#define WIL6210_TXRX_H
|
||||
|
||||
#define BUF_SW_OWNED (1)
|
||||
#define BUF_HW_OWNED (0)
|
||||
|
||||
/* size of max. Tx/Rx buffers, as supported by FW */
|
||||
#define RX_BUF_LEN (2242)
|
||||
#define TX_BUF_LEN (2242)
|
||||
/* how many bytes to reserve for rtap header? */
|
||||
#define WIL6210_RTAP_SIZE (128)
|
||||
|
||||
/* Tx/Rx path */
|
||||
|
||||
/*
|
||||
* Common representation of physical address in Vring
|
||||
*/
|
||||
struct vring_dma_addr {
|
||||
__le32 addr_low;
|
||||
__le16 addr_high;
|
||||
} __packed;
|
||||
|
||||
static inline dma_addr_t wil_desc_addr(struct vring_dma_addr *addr)
|
||||
{
|
||||
return le32_to_cpu(addr->addr_low) |
|
||||
((u64)le16_to_cpu(addr->addr_high) << 32);
|
||||
}
|
||||
|
||||
static inline void wil_desc_addr_set(struct vring_dma_addr *addr,
|
||||
dma_addr_t pa)
|
||||
{
|
||||
addr->addr_low = cpu_to_le32(lower_32_bits(pa));
|
||||
addr->addr_high = cpu_to_le16((u16)upper_32_bits(pa));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tx descriptor - MAC part
|
||||
* [dword 0]
|
||||
* bit 0.. 9 : lifetime_expiry_value:10
|
||||
* bit 10 : interrup_en:1
|
||||
* bit 11 : status_en:1
|
||||
* bit 12..13 : txss_override:2
|
||||
* bit 14 : timestamp_insertion:1
|
||||
* bit 15 : duration_preserve:1
|
||||
* bit 16..21 : reserved0:6
|
||||
* bit 22..26 : mcs_index:5
|
||||
* bit 27 : mcs_en:1
|
||||
* bit 28..29 : reserved1:2
|
||||
* bit 30 : reserved2:1
|
||||
* bit 31 : sn_preserved:1
|
||||
* [dword 1]
|
||||
* bit 0.. 3 : pkt_mode:4
|
||||
* bit 4 : pkt_mode_en:1
|
||||
* bit 5.. 7 : reserved0:3
|
||||
* bit 8..13 : reserved1:6
|
||||
* bit 14 : reserved2:1
|
||||
* bit 15 : ack_policy_en:1
|
||||
* bit 16..19 : dst_index:4
|
||||
* bit 20 : dst_index_en:1
|
||||
* bit 21..22 : ack_policy:2
|
||||
* bit 23 : lifetime_en:1
|
||||
* bit 24..30 : max_retry:7
|
||||
* bit 31 : max_retry_en:1
|
||||
* [dword 2]
|
||||
* bit 0.. 7 : num_of_descriptors:8
|
||||
* bit 8..17 : reserved:10
|
||||
* bit 18..19 : l2_translation_type:2
|
||||
* bit 20 : snap_hdr_insertion_en:1
|
||||
* bit 21 : vlan_removal_en:1
|
||||
* bit 22..31 : reserved0:10
|
||||
* [dword 3]
|
||||
* bit 0.. 31: ucode_cmd:32
|
||||
*/
|
||||
struct vring_tx_mac {
|
||||
u32 d[3];
|
||||
u32 ucode_cmd;
|
||||
} __packed;
|
||||
|
||||
/* TX MAC Dword 0 */
|
||||
#define MAC_CFG_DESC_TX_0_LIFETIME_EXPIRY_VALUE_POS 0
|
||||
#define MAC_CFG_DESC_TX_0_LIFETIME_EXPIRY_VALUE_LEN 10
|
||||
#define MAC_CFG_DESC_TX_0_LIFETIME_EXPIRY_VALUE_MSK 0x3FF
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_INTERRUP_EN_POS 10
|
||||
#define MAC_CFG_DESC_TX_0_INTERRUP_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_0_INTERRUP_EN_MSK 0x400
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_STATUS_EN_POS 11
|
||||
#define MAC_CFG_DESC_TX_0_STATUS_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_0_STATUS_EN_MSK 0x800
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_TXSS_OVERRIDE_POS 12
|
||||
#define MAC_CFG_DESC_TX_0_TXSS_OVERRIDE_LEN 2
|
||||
#define MAC_CFG_DESC_TX_0_TXSS_OVERRIDE_MSK 0x3000
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_TIMESTAMP_INSERTION_POS 14
|
||||
#define MAC_CFG_DESC_TX_0_TIMESTAMP_INSERTION_LEN 1
|
||||
#define MAC_CFG_DESC_TX_0_TIMESTAMP_INSERTION_MSK 0x4000
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_DURATION_PRESERVE_POS 15
|
||||
#define MAC_CFG_DESC_TX_0_DURATION_PRESERVE_LEN 1
|
||||
#define MAC_CFG_DESC_TX_0_DURATION_PRESERVE_MSK 0x8000
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_MCS_INDEX_POS 22
|
||||
#define MAC_CFG_DESC_TX_0_MCS_INDEX_LEN 5
|
||||
#define MAC_CFG_DESC_TX_0_MCS_INDEX_MSK 0x7C00000
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_MCS_EN_POS 27
|
||||
#define MAC_CFG_DESC_TX_0_MCS_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_0_MCS_EN_MSK 0x8000000
|
||||
|
||||
#define MAC_CFG_DESC_TX_0_SN_PRESERVED_POS 31
|
||||
#define MAC_CFG_DESC_TX_0_SN_PRESERVED_LEN 1
|
||||
#define MAC_CFG_DESC_TX_0_SN_PRESERVED_MSK 0x80000000
|
||||
|
||||
/* TX MAC Dword 1 */
|
||||
#define MAC_CFG_DESC_TX_1_PKT_MODE_POS 0
|
||||
#define MAC_CFG_DESC_TX_1_PKT_MODE_LEN 4
|
||||
#define MAC_CFG_DESC_TX_1_PKT_MODE_MSK 0xF
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_PKT_MODE_EN_POS 4
|
||||
#define MAC_CFG_DESC_TX_1_PKT_MODE_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_1_PKT_MODE_EN_MSK 0x10
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_ACK_POLICY_EN_POS 15
|
||||
#define MAC_CFG_DESC_TX_1_ACK_POLICY_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_1_ACK_POLICY_EN_MSK 0x8000
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_DST_INDEX_POS 16
|
||||
#define MAC_CFG_DESC_TX_1_DST_INDEX_LEN 4
|
||||
#define MAC_CFG_DESC_TX_1_DST_INDEX_MSK 0xF0000
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_DST_INDEX_EN_POS 20
|
||||
#define MAC_CFG_DESC_TX_1_DST_INDEX_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_1_DST_INDEX_EN_MSK 0x100000
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_ACK_POLICY_POS 21
|
||||
#define MAC_CFG_DESC_TX_1_ACK_POLICY_LEN 2
|
||||
#define MAC_CFG_DESC_TX_1_ACK_POLICY_MSK 0x600000
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_LIFETIME_EN_POS 23
|
||||
#define MAC_CFG_DESC_TX_1_LIFETIME_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_1_LIFETIME_EN_MSK 0x800000
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_MAX_RETRY_POS 24
|
||||
#define MAC_CFG_DESC_TX_1_MAX_RETRY_LEN 7
|
||||
#define MAC_CFG_DESC_TX_1_MAX_RETRY_MSK 0x7F000000
|
||||
|
||||
#define MAC_CFG_DESC_TX_1_MAX_RETRY_EN_POS 31
|
||||
#define MAC_CFG_DESC_TX_1_MAX_RETRY_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_1_MAX_RETRY_EN_MSK 0x80000000
|
||||
|
||||
/* TX MAC Dword 2 */
|
||||
#define MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS 0
|
||||
#define MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_LEN 8
|
||||
#define MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_MSK 0xFF
|
||||
|
||||
#define MAC_CFG_DESC_TX_2_RESERVED_POS 8
|
||||
#define MAC_CFG_DESC_TX_2_RESERVED_LEN 10
|
||||
#define MAC_CFG_DESC_TX_2_RESERVED_MSK 0x3FF00
|
||||
|
||||
#define MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_POS 18
|
||||
#define MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_LEN 2
|
||||
#define MAC_CFG_DESC_TX_2_L2_TRANSLATION_TYPE_MSK 0xC0000
|
||||
|
||||
#define MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_POS 20
|
||||
#define MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_2_SNAP_HDR_INSERTION_EN_MSK 0x100000
|
||||
|
||||
#define MAC_CFG_DESC_TX_2_VLAN_REMOVAL_EN_POS 21
|
||||
#define MAC_CFG_DESC_TX_2_VLAN_REMOVAL_EN_LEN 1
|
||||
#define MAC_CFG_DESC_TX_2_VLAN_REMOVAL_EN_MSK 0x200000
|
||||
|
||||
/* TX MAC Dword 3 */
|
||||
#define MAC_CFG_DESC_TX_3_UCODE_CMD_POS 0
|
||||
#define MAC_CFG_DESC_TX_3_UCODE_CMD_LEN 32
|
||||
#define MAC_CFG_DESC_TX_3_UCODE_CMD_MSK 0xFFFFFFFF
|
||||
|
||||
/* TX DMA Dword 0 */
|
||||
#define DMA_CFG_DESC_TX_0_L4_LENGTH_POS 0
|
||||
#define DMA_CFG_DESC_TX_0_L4_LENGTH_LEN 8
|
||||
#define DMA_CFG_DESC_TX_0_L4_LENGTH_MSK 0xFF
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_CMD_EOP_POS 8
|
||||
#define DMA_CFG_DESC_TX_0_CMD_EOP_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_CMD_EOP_MSK 0x100
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_CMD_MARK_WB_POS 9
|
||||
#define DMA_CFG_DESC_TX_0_CMD_MARK_WB_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_CMD_MARK_WB_MSK 0x200
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_CMD_DMA_IT_POS 10
|
||||
#define DMA_CFG_DESC_TX_0_CMD_DMA_IT_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_CMD_DMA_IT_MSK 0x400
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_SEGMENT_BUF_DETAILS_POS 11
|
||||
#define DMA_CFG_DESC_TX_0_SEGMENT_BUF_DETAILS_LEN 2
|
||||
#define DMA_CFG_DESC_TX_0_SEGMENT_BUF_DETAILS_MSK 0x1800
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_TCP_SEG_EN_POS 13
|
||||
#define DMA_CFG_DESC_TX_0_TCP_SEG_EN_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_TCP_SEG_EN_MSK 0x2000
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_IPV4_CHECKSUM_EN_POS 14
|
||||
#define DMA_CFG_DESC_TX_0_IPV4_CHECKSUM_EN_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_IPV4_CHECKSUM_EN_MSK 0x4000
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_POS 15
|
||||
#define DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_MSK 0x8000
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_QID_POS 16
|
||||
#define DMA_CFG_DESC_TX_0_QID_LEN 5
|
||||
#define DMA_CFG_DESC_TX_0_QID_MSK 0x1F0000
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_POS 21
|
||||
#define DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_LEN 1
|
||||
#define DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_MSK 0x200000
|
||||
|
||||
#define DMA_CFG_DESC_TX_0_L4_TYPE_POS 30
|
||||
#define DMA_CFG_DESC_TX_0_L4_TYPE_LEN 2
|
||||
#define DMA_CFG_DESC_TX_0_L4_TYPE_MSK 0xC0000000 /* L4 type: 0-UDP, 2-TCP */
|
||||
|
||||
#define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_POS 0
|
||||
#define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_LEN 7
|
||||
#define DMA_CFG_DESC_TX_OFFLOAD_CFG_MAC_LEN_MSK 0x7F /* MAC hdr len */
|
||||
|
||||
#define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_POS 7
|
||||
#define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_LEN 1
|
||||
#define DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_MSK 0x80 /* 1-IPv4, 0-IPv6 */
|
||||
|
||||
#define TX_DMA_STATUS_DU BIT(0)
|
||||
|
||||
struct vring_tx_dma {
|
||||
u32 d0;
|
||||
struct vring_dma_addr addr;
|
||||
u8 ip_length;
|
||||
u8 b11; /* 0..6: mac_length; 7:ip_version */
|
||||
u8 error; /* 0..2: err; 3..7: reserved; */
|
||||
u8 status; /* 0: used; 1..7; reserved */
|
||||
__le16 length;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Rx descriptor - MAC part
|
||||
* [dword 0]
|
||||
* bit 0.. 3 : tid:4 The QoS (b3-0) TID Field
|
||||
* bit 4.. 6 : connection_id:3 :The Source index that was found during
|
||||
* Parsing the TA. This field is used to define the source of the packet
|
||||
* bit 7 : reserved:1
|
||||
* bit 8.. 9 : mac_id:2 : The MAC virtual Ring number (always zero)
|
||||
* bit 10..11 : frame_type:2 : The FC Control (b3-2) - MPDU Type
|
||||
* (management, data, control and extension)
|
||||
* bit 12..15 : frame_subtype:4 : The FC Control (b7-4) - Frame Subtype
|
||||
* bit 16..27 : seq_number:12 The received Sequence number field
|
||||
* bit 28..31 : extended:4 extended subtype
|
||||
* [dword 1]
|
||||
* bit 0.. 3 : reserved
|
||||
* bit 4.. 5 : key_id:2
|
||||
* bit 6 : decrypt_bypass:1
|
||||
* bit 7 : security:1
|
||||
* bit 8.. 9 : ds_bits:2
|
||||
* bit 10 : a_msdu_present:1 from qos header
|
||||
* bit 11 : a_msdu_type:1 from qos header
|
||||
* bit 12 : a_mpdu:1 part of AMPDU aggregation
|
||||
* bit 13 : broadcast:1
|
||||
* bit 14 : mutlicast:1
|
||||
* bit 15 : reserved:1
|
||||
* bit 16..20 : rx_mac_qid:5 The Queue Identifier that the packet
|
||||
* is received from
|
||||
* bit 21..24 : mcs:4
|
||||
* bit 25..28 : mic_icr:4
|
||||
* bit 29..31 : reserved:3
|
||||
* [dword 2]
|
||||
* bit 0.. 2 : time_slot:3 The timeslot that the MPDU is received
|
||||
* bit 3 : fc_protocol_ver:1 The FC Control (b0) - Protocol Version
|
||||
* bit 4 : fc_order:1 The FC Control (b15) -Order
|
||||
* bit 5.. 7 : qos_ack_policy:3 The QoS (b6-5) ack policy Field
|
||||
* bit 8 : esop:1 The QoS (b4) ESOP field
|
||||
* bit 9 : qos_rdg_more_ppdu:1 The QoS (b9) RDG field
|
||||
* bit 10..14 : qos_reserved:5 The QoS (b14-10) Reserved field
|
||||
* bit 15 : qos_ac_constraint:1
|
||||
* bit 16..31 : pn_15_0:16 low 2 bytes of PN
|
||||
* [dword 3]
|
||||
* bit 0..31 : pn_47_16:32 high 4 bytes of PN
|
||||
*/
|
||||
struct vring_rx_mac {
|
||||
u32 d0;
|
||||
u32 d1;
|
||||
u16 w4;
|
||||
u16 pn_15_0;
|
||||
u32 pn_47_16;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Rx descriptor - DMA part
|
||||
* [dword 0]
|
||||
* bit 0.. 7 : l4_length:8 layer 4 length
|
||||
* bit 8.. 9 : reserved:2
|
||||
* bit 10 : cmd_dma_it:1
|
||||
* bit 11..15 : reserved:5
|
||||
* bit 16..29 : phy_info_length:14
|
||||
* bit 30..31 : l4_type:2 valid if the L4I bit is set in the status field
|
||||
* [dword 1]
|
||||
* bit 0..31 : addr_low:32 The payload buffer low address
|
||||
* [dword 2]
|
||||
* bit 0..15 : addr_high:16 The payload buffer high address
|
||||
* bit 16..23 : ip_length:8
|
||||
* bit 24..30 : mac_length:7
|
||||
* bit 31 : ip_version:1
|
||||
* [dword 3]
|
||||
* [byte 12] error
|
||||
* [byte 13] status
|
||||
* bit 0 : du:1
|
||||
* bit 1 : eop:1
|
||||
* bit 2 : error:1
|
||||
* bit 3 : mi:1
|
||||
* bit 4 : l3_identified:1
|
||||
* bit 5 : l4_identified:1
|
||||
* bit 6 : phy_info_included:1
|
||||
* bit 7 : reserved:1
|
||||
* [word 7] length
|
||||
*
|
||||
*/
|
||||
|
||||
#define RX_DMA_D0_CMD_DMA_IT BIT(10)
|
||||
|
||||
/* Error field, offload bits */
|
||||
#define RX_DMA_ERROR_L3_ERR BIT(4)
|
||||
#define RX_DMA_ERROR_L4_ERR BIT(5)
|
||||
|
||||
/* Status field */
|
||||
#define RX_DMA_STATUS_DU BIT(0)
|
||||
#define RX_DMA_STATUS_ERROR BIT(2)
|
||||
|
||||
#define RX_DMA_STATUS_L3_IDENT BIT(4)
|
||||
#define RX_DMA_STATUS_L4_IDENT BIT(5)
|
||||
#define RX_DMA_STATUS_PHY_INFO BIT(6)
|
||||
|
||||
struct vring_rx_dma {
|
||||
u32 d0;
|
||||
struct vring_dma_addr addr;
|
||||
u8 ip_length;
|
||||
u8 b11;
|
||||
u8 error;
|
||||
u8 status;
|
||||
__le16 length;
|
||||
} __packed;
|
||||
|
||||
struct vring_tx_desc {
|
||||
struct vring_tx_mac mac;
|
||||
struct vring_tx_dma dma;
|
||||
} __packed;
|
||||
|
||||
struct vring_rx_desc {
|
||||
struct vring_rx_mac mac;
|
||||
struct vring_rx_dma dma;
|
||||
} __packed;
|
||||
|
||||
union vring_desc {
|
||||
struct vring_tx_desc tx;
|
||||
struct vring_rx_desc rx;
|
||||
} __packed;
|
||||
|
||||
static inline int wil_rxdesc_tid(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 0, 3);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_cid(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 4, 6);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_mid(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 8, 9);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_ftype(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 10, 11);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_subtype(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 12, 15);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_seq(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 16, 27);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_ext_subtype(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d0, 28, 31);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_ds_bits(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d1, 8, 9);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_mcs(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->mac.d1, 21, 24);
|
||||
}
|
||||
|
||||
static inline int wil_rxdesc_phy_length(struct vring_rx_desc *d)
|
||||
{
|
||||
return WIL_GET_BITS(d->dma.d0, 16, 29);
|
||||
}
|
||||
|
||||
static inline struct vring_rx_desc *wil_skb_rxdesc(struct sk_buff *skb)
|
||||
{
|
||||
return (void *)skb->cb;
|
||||
}
|
||||
|
||||
void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev);
|
||||
void wil_rx_reorder(struct wil6210_priv *wil, struct sk_buff *skb);
|
||||
struct wil_tid_ampdu_rx *wil_tid_ampdu_rx_alloc(struct wil6210_priv *wil,
|
||||
int size, u16 ssn);
|
||||
void wil_tid_ampdu_rx_free(struct wil6210_priv *wil,
|
||||
struct wil_tid_ampdu_rx *r);
|
||||
|
||||
#endif /* WIL6210_TXRX_H */
|
||||
601
drivers/net/wireless/ath/wil6210/wil6210.h
Normal file
601
drivers/net/wireless/ath/wil6210/wil6210.h
Normal file
|
|
@ -0,0 +1,601 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __WIL6210_H__
|
||||
#define __WIL6210_H__
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <net/cfg80211.h>
|
||||
#include <linux/timex.h>
|
||||
#include "wil_platform.h"
|
||||
|
||||
extern bool no_fw_recovery;
|
||||
|
||||
#define WIL_NAME "wil6210"
|
||||
#define WIL_FW_NAME "wil6210.fw"
|
||||
|
||||
#define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */
|
||||
|
||||
struct wil_board {
|
||||
int board;
|
||||
#define WIL_BOARD_MARLON (1)
|
||||
#define WIL_BOARD_SPARROW (2)
|
||||
const char * const name;
|
||||
};
|
||||
|
||||
/**
|
||||
* extract bits [@b0:@b1] (inclusive) from the value @x
|
||||
* it should be @b0 <= @b1, or result is incorrect
|
||||
*/
|
||||
static inline u32 WIL_GET_BITS(u32 x, int b0, int b1)
|
||||
{
|
||||
return (x >> b0) & ((1 << (b1 - b0 + 1)) - 1);
|
||||
}
|
||||
|
||||
#define WIL6210_MEM_SIZE (2*1024*1024UL)
|
||||
|
||||
#define WIL6210_RX_RING_SIZE (128)
|
||||
#define WIL6210_TX_RING_SIZE (512)
|
||||
#define WIL6210_MAX_TX_RINGS (24) /* HW limit */
|
||||
#define WIL6210_MAX_CID (8) /* HW limit */
|
||||
#define WIL6210_NAPI_BUDGET (16) /* arbitrary */
|
||||
/* Max supported by wil6210 value for interrupt threshold is 5sec. */
|
||||
#define WIL6210_ITR_TRSH_MAX (5000000)
|
||||
#define WIL6210_ITR_TRSH_DEFAULT (300) /* usec */
|
||||
#define WIL6210_FW_RECOVERY_RETRIES (5) /* try to recover this many times */
|
||||
#define WIL6210_FW_RECOVERY_TO msecs_to_jiffies(5000)
|
||||
#define WIL6210_SCAN_TO msecs_to_jiffies(10000)
|
||||
|
||||
/* Hardware definitions begin */
|
||||
|
||||
/*
|
||||
* Mapping
|
||||
* RGF File | Host addr | FW addr
|
||||
* | |
|
||||
* user_rgf | 0x000000 | 0x880000
|
||||
* dma_rgf | 0x001000 | 0x881000
|
||||
* pcie_rgf | 0x002000 | 0x882000
|
||||
* | |
|
||||
*/
|
||||
|
||||
/* Where various structures placed in host address space */
|
||||
#define WIL6210_FW_HOST_OFF (0x880000UL)
|
||||
|
||||
#define HOSTADDR(fwaddr) (fwaddr - WIL6210_FW_HOST_OFF)
|
||||
|
||||
/*
|
||||
* Interrupt control registers block
|
||||
*
|
||||
* each interrupt controlled by the same bit in all registers
|
||||
*/
|
||||
struct RGF_ICR {
|
||||
u32 ICC; /* Cause Control, RW: 0 - W1C, 1 - COR */
|
||||
u32 ICR; /* Cause, W1C/COR depending on ICC */
|
||||
u32 ICM; /* Cause masked (ICR & ~IMV), W1C/COR depending on ICC */
|
||||
u32 ICS; /* Cause Set, WO */
|
||||
u32 IMV; /* Mask, RW+S/C */
|
||||
u32 IMS; /* Mask Set, write 1 to set */
|
||||
u32 IMC; /* Mask Clear, write 1 to clear */
|
||||
} __packed;
|
||||
|
||||
/* registers - FW addresses */
|
||||
#define RGF_USER_USAGE_1 (0x880004)
|
||||
#define RGF_USER_USAGE_6 (0x880018)
|
||||
#define RGF_USER_HW_MACHINE_STATE (0x8801dc)
|
||||
#define HW_MACHINE_BOOT_DONE (0x3fffffd)
|
||||
#define RGF_USER_USER_CPU_0 (0x8801e0)
|
||||
#define BIT_USER_USER_CPU_MAN_RST BIT(1) /* user_cpu_man_rst */
|
||||
#define RGF_USER_MAC_CPU_0 (0x8801fc)
|
||||
#define BIT_USER_MAC_CPU_MAN_RST BIT(1) /* mac_cpu_man_rst */
|
||||
#define RGF_USER_USER_SCRATCH_PAD (0x8802bc)
|
||||
#define RGF_USER_FW_REV_ID (0x880a8c) /* chip revision */
|
||||
#define RGF_USER_CLKS_CTL_0 (0x880abc)
|
||||
#define BIT_USER_CLKS_CAR_AHB_SW_SEL BIT(1) /* ref clk/PLL */
|
||||
#define BIT_USER_CLKS_RST_PWGD BIT(11) /* reset on "power good" */
|
||||
#define RGF_USER_CLKS_CTL_SW_RST_VEC_0 (0x880b04)
|
||||
#define RGF_USER_CLKS_CTL_SW_RST_VEC_1 (0x880b08)
|
||||
#define RGF_USER_CLKS_CTL_SW_RST_VEC_2 (0x880b0c)
|
||||
#define RGF_USER_CLKS_CTL_SW_RST_VEC_3 (0x880b10)
|
||||
#define RGF_USER_CLKS_CTL_SW_RST_MASK_0 (0x880b14)
|
||||
#define BIT_HPAL_PERST_FROM_PAD BIT(6)
|
||||
#define BIT_CAR_PERST_RST BIT(7)
|
||||
#define RGF_USER_USER_ICR (0x880b4c) /* struct RGF_ICR */
|
||||
#define BIT_USER_USER_ICR_SW_INT_2 BIT(18)
|
||||
#define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0 (0x880c18)
|
||||
#define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1 (0x880c2c)
|
||||
|
||||
#define RGF_DMA_EP_TX_ICR (0x881bb4) /* struct RGF_ICR */
|
||||
#define BIT_DMA_EP_TX_ICR_TX_DONE BIT(0)
|
||||
#define BIT_DMA_EP_TX_ICR_TX_DONE_N(n) BIT(n+1) /* n = [0..23] */
|
||||
#define RGF_DMA_EP_RX_ICR (0x881bd0) /* struct RGF_ICR */
|
||||
#define BIT_DMA_EP_RX_ICR_RX_DONE BIT(0)
|
||||
#define RGF_DMA_EP_MISC_ICR (0x881bec) /* struct RGF_ICR */
|
||||
#define BIT_DMA_EP_MISC_ICR_RX_HTRSH BIT(0)
|
||||
#define BIT_DMA_EP_MISC_ICR_TX_NO_ACT BIT(1)
|
||||
#define BIT_DMA_EP_MISC_ICR_FW_INT(n) BIT(28+n) /* n = [0..3] */
|
||||
|
||||
/* Interrupt moderation control */
|
||||
#define RGF_DMA_ITR_CNT_TRSH (0x881c5c)
|
||||
#define RGF_DMA_ITR_CNT_DATA (0x881c60)
|
||||
#define RGF_DMA_ITR_CNT_CRL (0x881c64)
|
||||
#define BIT_DMA_ITR_CNT_CRL_EN BIT(0)
|
||||
#define BIT_DMA_ITR_CNT_CRL_EXT_TICK BIT(1)
|
||||
#define BIT_DMA_ITR_CNT_CRL_FOREVER BIT(2)
|
||||
#define BIT_DMA_ITR_CNT_CRL_CLR BIT(3)
|
||||
#define BIT_DMA_ITR_CNT_CRL_REACH_TRSH BIT(4)
|
||||
|
||||
#define RGF_DMA_PSEUDO_CAUSE (0x881c68)
|
||||
#define RGF_DMA_PSEUDO_CAUSE_MASK_SW (0x881c6c)
|
||||
#define RGF_DMA_PSEUDO_CAUSE_MASK_FW (0x881c70)
|
||||
#define BIT_DMA_PSEUDO_CAUSE_RX BIT(0)
|
||||
#define BIT_DMA_PSEUDO_CAUSE_TX BIT(1)
|
||||
#define BIT_DMA_PSEUDO_CAUSE_MISC BIT(2)
|
||||
|
||||
#define RGF_HP_CTRL (0x88265c)
|
||||
#define RGF_PCIE_LOS_COUNTER_CTL (0x882dc4)
|
||||
|
||||
/* MAC timer, usec, for packet lifetime */
|
||||
#define RGF_MAC_MTRL_COUNTER_0 (0x886aa8)
|
||||
|
||||
#define RGF_CAF_ICR (0x88946c) /* struct RGF_ICR */
|
||||
|
||||
/* popular locations */
|
||||
#define HOST_MBOX HOSTADDR(RGF_USER_USER_SCRATCH_PAD)
|
||||
#define HOST_SW_INT (HOSTADDR(RGF_USER_USER_ICR) + \
|
||||
offsetof(struct RGF_ICR, ICS))
|
||||
#define SW_INT_MBOX BIT_USER_USER_ICR_SW_INT_2
|
||||
|
||||
/* ISR register bits */
|
||||
#define ISR_MISC_FW_READY BIT_DMA_EP_MISC_ICR_FW_INT(0)
|
||||
#define ISR_MISC_MBOX_EVT BIT_DMA_EP_MISC_ICR_FW_INT(1)
|
||||
#define ISR_MISC_FW_ERROR BIT_DMA_EP_MISC_ICR_FW_INT(3)
|
||||
|
||||
/* Hardware definitions end */
|
||||
struct fw_map {
|
||||
u32 from; /* linker address - from, inclusive */
|
||||
u32 to; /* linker address - to, exclusive */
|
||||
u32 host; /* PCI/Host address - BAR0 + 0x880000 */
|
||||
const char *name; /* for debugfs */
|
||||
};
|
||||
|
||||
/* array size should be in sync with actual definition in the wmi.c */
|
||||
extern const struct fw_map fw_mapping[7];
|
||||
|
||||
/**
|
||||
* mk_cidxtid - construct @cidxtid field
|
||||
* @cid: CID value
|
||||
* @tid: TID value
|
||||
*
|
||||
* @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
|
||||
*/
|
||||
static inline u8 mk_cidxtid(u8 cid, u8 tid)
|
||||
{
|
||||
return ((tid & 0xf) << 4) | (cid & 0xf);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse_cidxtid - parse @cidxtid field
|
||||
* @cid: store CID value here
|
||||
* @tid: store TID value here
|
||||
*
|
||||
* @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
|
||||
*/
|
||||
static inline void parse_cidxtid(u8 cidxtid, u8 *cid, u8 *tid)
|
||||
{
|
||||
*cid = cidxtid & 0xf;
|
||||
*tid = (cidxtid >> 4) & 0xf;
|
||||
}
|
||||
|
||||
struct wil6210_mbox_ring {
|
||||
u32 base;
|
||||
u16 entry_size; /* max. size of mbox entry, incl. all headers */
|
||||
u16 size;
|
||||
u32 tail;
|
||||
u32 head;
|
||||
} __packed;
|
||||
|
||||
struct wil6210_mbox_ring_desc {
|
||||
__le32 sync;
|
||||
__le32 addr;
|
||||
} __packed;
|
||||
|
||||
/* at HOST_OFF_WIL6210_MBOX_CTL */
|
||||
struct wil6210_mbox_ctl {
|
||||
struct wil6210_mbox_ring tx;
|
||||
struct wil6210_mbox_ring rx;
|
||||
} __packed;
|
||||
|
||||
struct wil6210_mbox_hdr {
|
||||
__le16 seq;
|
||||
__le16 len; /* payload, bytes after this header */
|
||||
__le16 type;
|
||||
u8 flags;
|
||||
u8 reserved;
|
||||
} __packed;
|
||||
|
||||
#define WIL_MBOX_HDR_TYPE_WMI (0)
|
||||
|
||||
/* max. value for wil6210_mbox_hdr.len */
|
||||
#define MAX_MBOXITEM_SIZE (240)
|
||||
|
||||
/**
|
||||
* struct wil6210_mbox_hdr_wmi - WMI header
|
||||
*
|
||||
* @mid: MAC ID
|
||||
* 00 - default, created by FW
|
||||
* 01..0f - WiFi ports, driver to create
|
||||
* 10..fe - debug
|
||||
* ff - broadcast
|
||||
* @id: command/event ID
|
||||
* @timestamp: FW fills for events, free-running msec timer
|
||||
*/
|
||||
struct wil6210_mbox_hdr_wmi {
|
||||
u8 mid;
|
||||
u8 reserved;
|
||||
__le16 id;
|
||||
__le32 timestamp;
|
||||
} __packed;
|
||||
|
||||
struct pending_wmi_event {
|
||||
struct list_head list;
|
||||
struct {
|
||||
struct wil6210_mbox_hdr hdr;
|
||||
struct wil6210_mbox_hdr_wmi wmi;
|
||||
u8 data[0];
|
||||
} __packed event;
|
||||
};
|
||||
|
||||
enum { /* for wil_ctx.mapped_as */
|
||||
wil_mapped_as_none = 0,
|
||||
wil_mapped_as_single = 1,
|
||||
wil_mapped_as_page = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wil_ctx - software context for Vring descriptor
|
||||
*/
|
||||
struct wil_ctx {
|
||||
struct sk_buff *skb;
|
||||
u8 nr_frags;
|
||||
u8 mapped_as;
|
||||
};
|
||||
|
||||
union vring_desc;
|
||||
|
||||
struct vring {
|
||||
dma_addr_t pa;
|
||||
volatile union vring_desc *va; /* vring_desc[size], WriteBack by DMA */
|
||||
u16 size; /* number of vring_desc elements */
|
||||
u32 swtail;
|
||||
u32 swhead;
|
||||
u32 hwtail; /* write here to inform hw */
|
||||
struct wil_ctx *ctx; /* ctx[size] - software context */
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional data for Tx Vring
|
||||
*/
|
||||
struct vring_tx_data {
|
||||
int enabled;
|
||||
cycles_t idle, last_idle, begin;
|
||||
};
|
||||
|
||||
enum { /* for wil6210_priv.status */
|
||||
wil_status_fwready = 0,
|
||||
wil_status_fwconnecting,
|
||||
wil_status_fwconnected,
|
||||
wil_status_dontscan,
|
||||
wil_status_reset_done,
|
||||
wil_status_irqen, /* FIXME: interrupts enabled - for debug */
|
||||
wil_status_napi_en, /* NAPI enabled protected by wil->mutex */
|
||||
};
|
||||
|
||||
struct pci_dev;
|
||||
|
||||
/**
|
||||
* struct tid_ampdu_rx - TID aggregation information (Rx).
|
||||
*
|
||||
* @reorder_buf: buffer to reorder incoming aggregated MPDUs
|
||||
* @reorder_time: jiffies when skb was added
|
||||
* @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
|
||||
* @reorder_timer: releases expired frames from the reorder buffer.
|
||||
* @last_rx: jiffies of last rx activity
|
||||
* @head_seq_num: head sequence number in reordering buffer.
|
||||
* @stored_mpdu_num: number of MPDUs in reordering buffer
|
||||
* @ssn: Starting Sequence Number expected to be aggregated.
|
||||
* @buf_size: buffer size for incoming A-MPDUs
|
||||
* @timeout: reset timer value (in TUs).
|
||||
* @dialog_token: dialog token for aggregation session
|
||||
* @rcu_head: RCU head used for freeing this struct
|
||||
*
|
||||
* This structure's lifetime is managed by RCU, assignments to
|
||||
* the array holding it must hold the aggregation mutex.
|
||||
*
|
||||
*/
|
||||
struct wil_tid_ampdu_rx {
|
||||
struct sk_buff **reorder_buf;
|
||||
unsigned long *reorder_time;
|
||||
struct timer_list session_timer;
|
||||
struct timer_list reorder_timer;
|
||||
unsigned long last_rx;
|
||||
u16 head_seq_num;
|
||||
u16 stored_mpdu_num;
|
||||
u16 ssn;
|
||||
u16 buf_size;
|
||||
u16 timeout;
|
||||
u16 ssn_last_drop;
|
||||
u8 dialog_token;
|
||||
bool first_time; /* is it 1-st time this buffer used? */
|
||||
};
|
||||
|
||||
enum wil_sta_status {
|
||||
wil_sta_unused = 0,
|
||||
wil_sta_conn_pending = 1,
|
||||
wil_sta_connected = 2,
|
||||
};
|
||||
|
||||
#define WIL_STA_TID_NUM (16)
|
||||
|
||||
struct wil_net_stats {
|
||||
unsigned long rx_packets;
|
||||
unsigned long tx_packets;
|
||||
unsigned long rx_bytes;
|
||||
unsigned long tx_bytes;
|
||||
unsigned long tx_errors;
|
||||
unsigned long rx_dropped;
|
||||
u16 last_mcs_rx;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wil_sta_info - data for peer
|
||||
*
|
||||
* Peer identified by its CID (connection ID)
|
||||
* NIC performs beam forming for each peer;
|
||||
* if no beam forming done, frame exchange is not
|
||||
* possible.
|
||||
*/
|
||||
struct wil_sta_info {
|
||||
u8 addr[ETH_ALEN];
|
||||
enum wil_sta_status status;
|
||||
struct wil_net_stats stats;
|
||||
bool data_port_open; /* can send any data, not only EAPOL */
|
||||
/* Rx BACK */
|
||||
struct wil_tid_ampdu_rx *tid_rx[WIL_STA_TID_NUM];
|
||||
spinlock_t tid_rx_lock; /* guarding tid_rx array */
|
||||
unsigned long tid_rx_timer_expired[BITS_TO_LONGS(WIL_STA_TID_NUM)];
|
||||
unsigned long tid_rx_stop_requested[BITS_TO_LONGS(WIL_STA_TID_NUM)];
|
||||
};
|
||||
|
||||
enum {
|
||||
fw_recovery_idle = 0,
|
||||
fw_recovery_pending = 1,
|
||||
fw_recovery_running = 2,
|
||||
};
|
||||
|
||||
struct wil6210_priv {
|
||||
struct pci_dev *pdev;
|
||||
int n_msi;
|
||||
struct wireless_dev *wdev;
|
||||
void __iomem *csr;
|
||||
ulong status;
|
||||
u32 fw_version;
|
||||
u32 hw_version;
|
||||
struct wil_board *board;
|
||||
u8 n_mids; /* number of additional MIDs as reported by FW */
|
||||
u32 recovery_count; /* num of FW recovery attempts in a short time */
|
||||
u32 recovery_state; /* FW recovery state machine */
|
||||
unsigned long last_fw_recovery; /* jiffies of last fw recovery */
|
||||
wait_queue_head_t wq; /* for all wait_event() use */
|
||||
/* profile */
|
||||
u32 monitor_flags;
|
||||
u32 secure_pcp; /* create secure PCP? */
|
||||
int sinfo_gen;
|
||||
u32 itr_trsh;
|
||||
/* cached ISR registers */
|
||||
u32 isr_misc;
|
||||
/* mailbox related */
|
||||
struct mutex wmi_mutex;
|
||||
struct wil6210_mbox_ctl mbox_ctl;
|
||||
struct completion wmi_ready;
|
||||
struct completion wmi_call;
|
||||
u16 wmi_seq;
|
||||
u16 reply_id; /**< wait for this WMI event */
|
||||
void *reply_buf;
|
||||
u16 reply_size;
|
||||
struct workqueue_struct *wmi_wq; /* for deferred calls */
|
||||
struct work_struct wmi_event_worker;
|
||||
struct workqueue_struct *wmi_wq_conn; /* for connect worker */
|
||||
struct work_struct connect_worker;
|
||||
struct work_struct disconnect_worker;
|
||||
struct work_struct fw_error_worker; /* for FW error recovery */
|
||||
struct timer_list connect_timer;
|
||||
struct timer_list scan_timer; /* detect scan timeout */
|
||||
int pending_connect_cid;
|
||||
struct list_head pending_wmi_ev;
|
||||
/*
|
||||
* protect pending_wmi_ev
|
||||
* - fill in IRQ from wil6210_irq_misc,
|
||||
* - consumed in thread by wmi_event_worker
|
||||
*/
|
||||
spinlock_t wmi_ev_lock;
|
||||
struct napi_struct napi_rx;
|
||||
struct napi_struct napi_tx;
|
||||
/* DMA related */
|
||||
struct vring vring_rx;
|
||||
struct vring vring_tx[WIL6210_MAX_TX_RINGS];
|
||||
struct vring_tx_data vring_tx_data[WIL6210_MAX_TX_RINGS];
|
||||
u8 vring2cid_tid[WIL6210_MAX_TX_RINGS][2]; /* [0] - CID, [1] - TID */
|
||||
struct wil_sta_info sta[WIL6210_MAX_CID];
|
||||
/* scan */
|
||||
struct cfg80211_scan_request *scan_request;
|
||||
|
||||
struct mutex mutex; /* for wil6210_priv access in wil_{up|down} */
|
||||
/* statistics */
|
||||
atomic_t isr_count_rx, isr_count_tx;
|
||||
/* debugfs */
|
||||
struct dentry *debug;
|
||||
struct debugfs_blob_wrapper blobs[ARRAY_SIZE(fw_mapping)];
|
||||
|
||||
void *platform_handle;
|
||||
struct wil_platform_ops platform_ops;
|
||||
};
|
||||
|
||||
#define wil_to_wiphy(i) (i->wdev->wiphy)
|
||||
#define wil_to_dev(i) (wiphy_dev(wil_to_wiphy(i)))
|
||||
#define wiphy_to_wil(w) (struct wil6210_priv *)(wiphy_priv(w))
|
||||
#define wil_to_wdev(i) (i->wdev)
|
||||
#define wdev_to_wil(w) (struct wil6210_priv *)(wdev_priv(w))
|
||||
#define wil_to_ndev(i) (wil_to_wdev(i)->netdev)
|
||||
#define ndev_to_wil(n) (wdev_to_wil(n->ieee80211_ptr))
|
||||
#define wil_to_pcie_dev(i) (&i->pdev->dev)
|
||||
|
||||
void wil_dbg_trace(struct wil6210_priv *wil, const char *fmt, ...);
|
||||
void wil_err(struct wil6210_priv *wil, const char *fmt, ...);
|
||||
void wil_info(struct wil6210_priv *wil, const char *fmt, ...);
|
||||
#define wil_dbg(wil, fmt, arg...) do { \
|
||||
netdev_dbg(wil_to_ndev(wil), fmt, ##arg); \
|
||||
wil_dbg_trace(wil, fmt, ##arg); \
|
||||
} while (0)
|
||||
|
||||
#define wil_dbg_irq(wil, fmt, arg...) wil_dbg(wil, "DBG[ IRQ]" fmt, ##arg)
|
||||
#define wil_dbg_txrx(wil, fmt, arg...) wil_dbg(wil, "DBG[TXRX]" fmt, ##arg)
|
||||
#define wil_dbg_wmi(wil, fmt, arg...) wil_dbg(wil, "DBG[ WMI]" fmt, ##arg)
|
||||
#define wil_dbg_misc(wil, fmt, arg...) wil_dbg(wil, "DBG[MISC]" fmt, ##arg)
|
||||
|
||||
#if defined(CONFIG_DYNAMIC_DEBUG)
|
||||
#define wil_hex_dump_txrx(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii) \
|
||||
print_hex_dump_debug("DBG[TXRX]" prefix_str,\
|
||||
prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii)
|
||||
|
||||
#define wil_hex_dump_wmi(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii) \
|
||||
print_hex_dump_debug("DBG[ WMI]" prefix_str,\
|
||||
prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii)
|
||||
#else /* defined(CONFIG_DYNAMIC_DEBUG) */
|
||||
static inline
|
||||
void wil_hex_dump_txrx(const char *prefix_str, int prefix_type, int rowsize,
|
||||
int groupsize, const void *buf, size_t len, bool ascii)
|
||||
{
|
||||
}
|
||||
|
||||
static inline
|
||||
void wil_hex_dump_wmi(const char *prefix_str, int prefix_type, int rowsize,
|
||||
int groupsize, const void *buf, size_t len, bool ascii)
|
||||
{
|
||||
}
|
||||
#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
|
||||
|
||||
void wil_memcpy_fromio_32(void *dst, const volatile void __iomem *src,
|
||||
size_t count);
|
||||
void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
|
||||
size_t count);
|
||||
|
||||
void *wil_if_alloc(struct device *dev, void __iomem *csr);
|
||||
void wil_if_free(struct wil6210_priv *wil);
|
||||
int wil_if_add(struct wil6210_priv *wil);
|
||||
void wil_if_remove(struct wil6210_priv *wil);
|
||||
int wil_priv_init(struct wil6210_priv *wil);
|
||||
void wil_priv_deinit(struct wil6210_priv *wil);
|
||||
int wil_reset(struct wil6210_priv *wil);
|
||||
void wil_set_itr_trsh(struct wil6210_priv *wil);
|
||||
void wil_fw_error_recovery(struct wil6210_priv *wil);
|
||||
void wil_set_recovery_state(struct wil6210_priv *wil, int state);
|
||||
void wil_link_on(struct wil6210_priv *wil);
|
||||
void wil_link_off(struct wil6210_priv *wil);
|
||||
int wil_up(struct wil6210_priv *wil);
|
||||
int __wil_up(struct wil6210_priv *wil);
|
||||
int wil_down(struct wil6210_priv *wil);
|
||||
int __wil_down(struct wil6210_priv *wil);
|
||||
void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
|
||||
int wil_find_cid(struct wil6210_priv *wil, const u8 *mac);
|
||||
void wil_set_ethtoolops(struct net_device *ndev);
|
||||
|
||||
void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr);
|
||||
void __iomem *wmi_addr(struct wil6210_priv *wil, u32 ptr);
|
||||
int wmi_read_hdr(struct wil6210_priv *wil, __le32 ptr,
|
||||
struct wil6210_mbox_hdr *hdr);
|
||||
int wmi_send(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len);
|
||||
void wmi_recv_cmd(struct wil6210_priv *wil);
|
||||
int wmi_call(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len,
|
||||
u16 reply_id, void *reply, u8 reply_size, int to_msec);
|
||||
void wmi_event_worker(struct work_struct *work);
|
||||
void wmi_event_flush(struct wil6210_priv *wil);
|
||||
int wmi_set_ssid(struct wil6210_priv *wil, u8 ssid_len, const void *ssid);
|
||||
int wmi_get_ssid(struct wil6210_priv *wil, u8 *ssid_len, void *ssid);
|
||||
int wmi_set_channel(struct wil6210_priv *wil, int channel);
|
||||
int wmi_get_channel(struct wil6210_priv *wil, int *channel);
|
||||
int wmi_del_cipher_key(struct wil6210_priv *wil, u8 key_index,
|
||||
const void *mac_addr);
|
||||
int wmi_add_cipher_key(struct wil6210_priv *wil, u8 key_index,
|
||||
const void *mac_addr, int key_len, const void *key);
|
||||
int wmi_echo(struct wil6210_priv *wil);
|
||||
int wmi_set_ie(struct wil6210_priv *wil, u8 type, u16 ie_len, const void *ie);
|
||||
int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring);
|
||||
int wmi_p2p_cfg(struct wil6210_priv *wil, int channel);
|
||||
int wmi_rxon(struct wil6210_priv *wil, bool on);
|
||||
int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r);
|
||||
int wmi_disconnect_sta(struct wil6210_priv *wil, const u8 *mac, u16 reason);
|
||||
|
||||
void wil6210_clear_irq(struct wil6210_priv *wil);
|
||||
int wil6210_init_irq(struct wil6210_priv *wil, int irq);
|
||||
void wil6210_fini_irq(struct wil6210_priv *wil, int irq);
|
||||
void wil_mask_irq(struct wil6210_priv *wil);
|
||||
void wil_unmask_irq(struct wil6210_priv *wil);
|
||||
void wil_disable_irq(struct wil6210_priv *wil);
|
||||
void wil_enable_irq(struct wil6210_priv *wil);
|
||||
int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
struct cfg80211_mgmt_tx_params *params,
|
||||
u64 *cookie);
|
||||
|
||||
int wil6210_debugfs_init(struct wil6210_priv *wil);
|
||||
void wil6210_debugfs_remove(struct wil6210_priv *wil);
|
||||
int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
|
||||
struct station_info *sinfo);
|
||||
|
||||
struct wireless_dev *wil_cfg80211_init(struct device *dev);
|
||||
void wil_wdev_free(struct wil6210_priv *wil);
|
||||
|
||||
int wmi_set_mac_address(struct wil6210_priv *wil, void *addr);
|
||||
int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype, u8 chan);
|
||||
int wmi_pcp_stop(struct wil6210_priv *wil);
|
||||
void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid);
|
||||
|
||||
int wil_rx_init(struct wil6210_priv *wil);
|
||||
void wil_rx_fini(struct wil6210_priv *wil);
|
||||
|
||||
/* TX API */
|
||||
int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
|
||||
int cid, int tid);
|
||||
void wil_vring_fini_tx(struct wil6210_priv *wil, int id);
|
||||
|
||||
netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev);
|
||||
int wil_tx_complete(struct wil6210_priv *wil, int ringid);
|
||||
void wil6210_unmask_irq_tx(struct wil6210_priv *wil);
|
||||
|
||||
/* RX API */
|
||||
void wil_rx_handle(struct wil6210_priv *wil, int *quota);
|
||||
void wil6210_unmask_irq_rx(struct wil6210_priv *wil);
|
||||
|
||||
int wil_iftype_nl2wmi(enum nl80211_iftype type);
|
||||
|
||||
int wil_ioctl(struct wil6210_priv *wil, void __user *data, int cmd);
|
||||
int wil_request_firmware(struct wil6210_priv *wil, const char *name);
|
||||
|
||||
#endif /* __WIL6210_H__ */
|
||||
49
drivers/net/wireless/ath/wil6210/wil_platform.c
Normal file
49
drivers/net/wireless/ath/wil6210/wil_platform.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "linux/device.h"
|
||||
#include "wil_platform.h"
|
||||
|
||||
#ifdef CONFIG_WIL6210_PLATFORM_MSM
|
||||
#include "wil_platform_msm.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* wil_platform_init() - wil6210 platform module init
|
||||
*
|
||||
* The function must be called before all other functions in this module.
|
||||
* It returns a handle which is used with the rest of the API
|
||||
*
|
||||
*/
|
||||
void *wil_platform_init(struct device *dev, struct wil_platform_ops *ops)
|
||||
{
|
||||
void *handle = NULL;
|
||||
|
||||
if (!ops) {
|
||||
dev_err(dev, "Invalid parameter. Cannot init platform module\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WIL6210_PLATFORM_MSM
|
||||
handle = wil_platform_msm_init(dev, ops);
|
||||
if (handle)
|
||||
return handle;
|
||||
#endif
|
||||
|
||||
/* other platform specific init functions should be called here */
|
||||
|
||||
return handle;
|
||||
}
|
||||
34
drivers/net/wireless/ath/wil6210/wil_platform.h
Normal file
34
drivers/net/wireless/ath/wil6210/wil_platform.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __WIL_PLATFORM_H__
|
||||
#define __WIL_PLATFORM_H__
|
||||
|
||||
struct device;
|
||||
|
||||
/**
|
||||
* struct wil_platform_ops - wil platform module callbacks
|
||||
*/
|
||||
struct wil_platform_ops {
|
||||
int (*bus_request)(void *handle, uint32_t kbps /* KBytes/Sec */);
|
||||
int (*suspend)(void *handle);
|
||||
int (*resume)(void *handle);
|
||||
void (*uninit)(void *handle);
|
||||
};
|
||||
|
||||
void *wil_platform_init(struct device *dev, struct wil_platform_ops *ops);
|
||||
|
||||
#endif /* __WIL_PLATFORM_H__ */
|
||||
257
drivers/net/wireless/ath/wil6210/wil_platform_msm.c
Normal file
257
drivers/net/wireless/ath/wil6210/wil_platform_msm.c
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/of.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/msm-bus.h>
|
||||
|
||||
#include "wil_platform.h"
|
||||
#include "wil_platform_msm.h"
|
||||
|
||||
/**
|
||||
* struct wil_platform_msm - wil6210 msm platform module info
|
||||
*
|
||||
* @dev: device object
|
||||
* @msm_bus_handle: handle for using msm_bus API
|
||||
* @pdata: bus scale info retrieved from DT
|
||||
*/
|
||||
struct wil_platform_msm {
|
||||
struct device *dev;
|
||||
uint32_t msm_bus_handle;
|
||||
struct msm_bus_scale_pdata *pdata;
|
||||
};
|
||||
|
||||
#define KBTOB(a) (a * 1000ULL)
|
||||
|
||||
/**
|
||||
* wil_platform_get_pdata() - Generate bus client data from device tree
|
||||
* provided by clients.
|
||||
*
|
||||
* dev: device object
|
||||
* of_node: Device tree node to extract information from
|
||||
*
|
||||
* The function returns a valid pointer to the allocated bus-scale-pdata
|
||||
* if the vectors were correctly read from the client's device node.
|
||||
* Any error in reading or parsing the device node will return NULL
|
||||
* to the caller.
|
||||
*/
|
||||
static struct msm_bus_scale_pdata *wil_platform_get_pdata(
|
||||
struct device *dev,
|
||||
struct device_node *of_node)
|
||||
{
|
||||
struct msm_bus_scale_pdata *pdata;
|
||||
struct msm_bus_paths *usecase;
|
||||
int i, j, ret, len;
|
||||
unsigned int num_usecases, num_paths, mem_size;
|
||||
const uint32_t *vec_arr;
|
||||
struct msm_bus_vectors *vectors;
|
||||
|
||||
/* first read num_usecases and num_paths so we can calculate
|
||||
* amount of memory to allocate
|
||||
*/
|
||||
ret = of_property_read_u32(of_node, "qcom,msm-bus,num-cases",
|
||||
&num_usecases);
|
||||
if (ret) {
|
||||
dev_err(dev, "Error: num-usecases not found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(of_node, "qcom,msm-bus,num-paths",
|
||||
&num_paths);
|
||||
if (ret) {
|
||||
dev_err(dev, "Error: num_paths not found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* pdata memory layout:
|
||||
* msm_bus_scale_pdata
|
||||
* msm_bus_paths[num_usecases]
|
||||
* msm_bus_vectors[num_usecases][num_paths]
|
||||
*/
|
||||
mem_size = sizeof(struct msm_bus_scale_pdata) +
|
||||
sizeof(struct msm_bus_paths) * num_usecases +
|
||||
sizeof(struct msm_bus_vectors) * num_usecases * num_paths;
|
||||
|
||||
pdata = kzalloc(mem_size, GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return NULL;
|
||||
|
||||
ret = of_property_read_string(of_node, "qcom,msm-bus,name",
|
||||
&pdata->name);
|
||||
if (ret) {
|
||||
dev_err(dev, "Error: Client name not found\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (of_property_read_bool(of_node, "qcom,msm-bus,active-only")) {
|
||||
pdata->active_only = 1;
|
||||
} else {
|
||||
dev_info(dev, "active_only flag absent.\n");
|
||||
dev_info(dev, "Using dual context by default\n");
|
||||
}
|
||||
|
||||
pdata->num_usecases = num_usecases;
|
||||
pdata->usecase = (struct msm_bus_paths *)(pdata + 1);
|
||||
|
||||
vec_arr = of_get_property(of_node, "qcom,msm-bus,vectors-KBps", &len);
|
||||
if (vec_arr == NULL) {
|
||||
dev_err(dev, "Error: Vector array not found\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (len != num_usecases * num_paths * sizeof(uint32_t) * 4) {
|
||||
dev_err(dev, "Error: Length-error on getting vectors\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
vectors = (struct msm_bus_vectors *)(pdata->usecase + num_usecases);
|
||||
for (i = 0; i < num_usecases; i++) {
|
||||
usecase = &pdata->usecase[i];
|
||||
usecase->num_paths = num_paths;
|
||||
usecase->vectors = &vectors[i];
|
||||
|
||||
for (j = 0; j < num_paths; j++) {
|
||||
int index = ((i * num_paths) + j) * 4;
|
||||
|
||||
usecase->vectors[j].src = be32_to_cpu(vec_arr[index]);
|
||||
usecase->vectors[j].dst =
|
||||
be32_to_cpu(vec_arr[index + 1]);
|
||||
usecase->vectors[j].ab = (uint64_t)
|
||||
KBTOB(be32_to_cpu(vec_arr[index + 2]));
|
||||
usecase->vectors[j].ib = (uint64_t)
|
||||
KBTOB(be32_to_cpu(vec_arr[index + 3]));
|
||||
}
|
||||
}
|
||||
|
||||
return pdata;
|
||||
|
||||
err:
|
||||
kfree(pdata);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* wil_platform API (callbacks) */
|
||||
|
||||
static int wil_platform_bus_request(void *handle,
|
||||
uint32_t kbps /* KBytes/Sec */)
|
||||
{
|
||||
int rc, i;
|
||||
struct wil_platform_msm *msm = (struct wil_platform_msm *)handle;
|
||||
int vote = 0; /* vote 0 in case requested kbps cannot be satisfied */
|
||||
struct msm_bus_paths *usecase;
|
||||
uint32_t usecase_kbps;
|
||||
uint32_t min_kbps = ~0;
|
||||
|
||||
/* find the lowest usecase that is bigger than requested kbps */
|
||||
for (i = 0; i < msm->pdata->num_usecases; i++) {
|
||||
usecase = &msm->pdata->usecase[i];
|
||||
/* assume we have single path (vectors[0]). If we ever
|
||||
* have multiple paths, need to define the behavior */
|
||||
usecase_kbps = div64_u64(usecase->vectors[0].ib, 1000);
|
||||
if (usecase_kbps >= kbps && usecase_kbps < min_kbps) {
|
||||
min_kbps = usecase_kbps;
|
||||
vote = i;
|
||||
}
|
||||
}
|
||||
|
||||
rc = msm_bus_scale_client_update_request(msm->msm_bus_handle, vote);
|
||||
if (rc)
|
||||
dev_err(msm->dev, "Failed msm_bus voting. kbps=%d vote=%d, rc=%d\n",
|
||||
kbps, vote, rc);
|
||||
else
|
||||
/* TOOD: remove */
|
||||
dev_info(msm->dev, "msm_bus_scale_client_update_request succeeded. kbps=%d vote=%d\n",
|
||||
kbps, vote);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void wil_platform_uninit(void *handle)
|
||||
{
|
||||
struct wil_platform_msm *msm = (struct wil_platform_msm *)handle;
|
||||
|
||||
dev_info(msm->dev, "wil_platform_uninit\n");
|
||||
|
||||
if (msm->msm_bus_handle)
|
||||
msm_bus_scale_unregister_client(msm->msm_bus_handle);
|
||||
|
||||
kfree(msm->pdata);
|
||||
kfree(msm);
|
||||
}
|
||||
|
||||
static int wil_platform_msm_bus_register(struct wil_platform_msm *msm,
|
||||
struct device_node *node)
|
||||
{
|
||||
msm->pdata = wil_platform_get_pdata(msm->dev, node);
|
||||
if (!msm->pdata) {
|
||||
dev_err(msm->dev, "Failed getting DT info\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
msm->msm_bus_handle = msm_bus_scale_register_client(msm->pdata);
|
||||
if (!msm->msm_bus_handle) {
|
||||
dev_err(msm->dev, "Failed msm_bus registration\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_info(msm->dev, "msm_bus registration succeeded! handle 0x%x\n",
|
||||
msm->msm_bus_handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* wil_platform_msm_init() - wil6210 msm platform module init
|
||||
*
|
||||
* The function must be called before all other functions in this module.
|
||||
* It returns a handle which is used with the rest of the API
|
||||
*
|
||||
*/
|
||||
void *wil_platform_msm_init(struct device *dev, struct wil_platform_ops *ops)
|
||||
{
|
||||
struct device_node *of_node;
|
||||
struct wil_platform_msm *msm;
|
||||
int rc;
|
||||
|
||||
of_node = of_find_compatible_node(NULL, NULL, "qcom,wil6210");
|
||||
if (!of_node) {
|
||||
/* this could mean non-msm platform */
|
||||
dev_err(dev, "DT node not found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msm = kzalloc(sizeof(*msm), GFP_KERNEL);
|
||||
if (!msm)
|
||||
return NULL;
|
||||
|
||||
msm->dev = dev;
|
||||
|
||||
/* register with msm_bus module for scaling requests */
|
||||
rc = wil_platform_msm_bus_register(msm, of_node);
|
||||
if (rc)
|
||||
goto cleanup;
|
||||
|
||||
memset(ops, 0, sizeof(*ops));
|
||||
ops->bus_request = wil_platform_bus_request;
|
||||
ops->uninit = wil_platform_uninit;
|
||||
|
||||
return (void *)msm;
|
||||
|
||||
cleanup:
|
||||
kfree(msm);
|
||||
return NULL;
|
||||
}
|
||||
24
drivers/net/wireless/ath/wil6210/wil_platform_msm.h
Normal file
24
drivers/net/wireless/ath/wil6210/wil_platform_msm.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Qualcomm Atheros, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __WIL_PLATFORM__MSM_H__
|
||||
#define __WIL_PLATFORM_MSM_H__
|
||||
|
||||
#include "wil_platform.h"
|
||||
|
||||
void *wil_platform_msm_init(struct device *dev, struct wil_platform_ops *ops);
|
||||
|
||||
#endif /* __WIL_PLATFORM__MSM_H__ */
|
||||
1217
drivers/net/wireless/ath/wil6210/wmi.c
Normal file
1217
drivers/net/wireless/ath/wil6210/wmi.c
Normal file
File diff suppressed because it is too large
Load diff
1279
drivers/net/wireless/ath/wil6210/wmi.h
Normal file
1279
drivers/net/wireless/ath/wil6210/wmi.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue