2009-04-30 04:33:31 +08:00
|
|
|
/*
|
2009-06-12 19:17:39 +08:00
|
|
|
* This file is part of wl1251
|
2009-04-30 04:33:31 +08:00
|
|
|
*
|
|
|
|
* Copyright (c) 1998-2007 Texas Instruments Incorporated
|
|
|
|
* Copyright (C) 2008 Nokia Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/skbuff.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/gfp.h>
|
2009-04-30 04:33:31 +08:00
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
2009-06-12 19:17:25 +08:00
|
|
|
#include "wl1251.h"
|
2010-10-10 16:28:32 +08:00
|
|
|
#include "reg.h"
|
|
|
|
#include "io.h"
|
|
|
|
#include "rx.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
#include "acx.h"
|
2009-04-30 04:33:31 +08:00
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
static void wl1251_rx_header(struct wl1251 *wl,
|
|
|
|
struct wl1251_rx_descriptor *desc)
|
2009-04-30 04:33:31 +08:00
|
|
|
{
|
|
|
|
u32 rx_packet_ring_addr;
|
|
|
|
|
|
|
|
rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr;
|
|
|
|
if (wl->rx_current_buffer)
|
|
|
|
rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
|
|
|
|
|
2009-08-07 18:32:56 +08:00
|
|
|
wl1251_mem_read(wl, rx_packet_ring_addr, desc, sizeof(*desc));
|
2009-04-30 04:33:31 +08:00
|
|
|
}
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
static void wl1251_rx_status(struct wl1251 *wl,
|
|
|
|
struct wl1251_rx_descriptor *desc,
|
2009-04-30 04:33:31 +08:00
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
u8 beacon)
|
|
|
|
{
|
2009-06-12 19:14:19 +08:00
|
|
|
u64 mactime;
|
|
|
|
int ret;
|
|
|
|
|
2009-04-30 04:33:31 +08:00
|
|
|
memset(status, 0, sizeof(struct ieee80211_rx_status));
|
|
|
|
|
|
|
|
status->band = IEEE80211_BAND_2GHZ;
|
|
|
|
status->mactime = desc->timestamp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The rx status timestamp is a 32 bits value while the TSF is a
|
|
|
|
* 64 bits one.
|
|
|
|
* For IBSS merging, TSF is mandatory, so we have to get it
|
|
|
|
* somehow, so we ask for ACX_TSF_INFO.
|
|
|
|
* That could be moved to the get_tsf() hook, but unfortunately,
|
|
|
|
* this one must be atomic, while our SPI routines can sleep.
|
|
|
|
*/
|
|
|
|
if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) {
|
2009-06-12 19:17:39 +08:00
|
|
|
ret = wl1251_acx_tsf_info(wl, &mactime);
|
2009-06-12 19:14:19 +08:00
|
|
|
if (ret == 0)
|
|
|
|
status->mactime = mactime;
|
2009-04-30 04:33:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
status->signal = desc->rssi;
|
|
|
|
|
2010-07-29 03:23:30 +08:00
|
|
|
/*
|
|
|
|
* FIXME: guessing that snr needs to be divided by two, otherwise
|
|
|
|
* the values don't make any sense
|
|
|
|
*/
|
|
|
|
wl->noise = desc->rssi - desc->snr / 2;
|
|
|
|
|
2011-01-17 12:37:28 +08:00
|
|
|
status->freq = ieee80211_channel_to_frequency(desc->channel,
|
|
|
|
status->band);
|
2009-04-30 04:33:31 +08:00
|
|
|
|
2011-02-23 22:06:08 +08:00
|
|
|
status->flag |= RX_FLAG_MACTIME_MPDU;
|
2009-04-30 04:33:31 +08:00
|
|
|
|
|
|
|
if (desc->flags & RX_DESC_ENCRYPTION_MASK) {
|
|
|
|
status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED;
|
|
|
|
|
|
|
|
if (likely(!(desc->flags & RX_DESC_DECRYPT_FAIL)))
|
|
|
|
status->flag |= RX_FLAG_DECRYPTED;
|
|
|
|
|
|
|
|
if (unlikely(desc->flags & RX_DESC_MIC_FAIL))
|
|
|
|
status->flag |= RX_FLAG_MMIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(!(desc->flags & RX_DESC_VALID_FCS)))
|
|
|
|
status->flag |= RX_FLAG_FAILED_FCS_CRC;
|
|
|
|
|
2011-01-31 03:11:10 +08:00
|
|
|
switch (desc->rate) {
|
|
|
|
/* skip 1 and 12 Mbps because they have same value 0x0a */
|
|
|
|
case RATE_2MBPS:
|
|
|
|
status->rate_idx = 1;
|
|
|
|
break;
|
|
|
|
case RATE_5_5MBPS:
|
|
|
|
status->rate_idx = 2;
|
|
|
|
break;
|
|
|
|
case RATE_11MBPS:
|
|
|
|
status->rate_idx = 3;
|
|
|
|
break;
|
|
|
|
case RATE_6MBPS:
|
|
|
|
status->rate_idx = 4;
|
|
|
|
break;
|
|
|
|
case RATE_9MBPS:
|
|
|
|
status->rate_idx = 5;
|
|
|
|
break;
|
|
|
|
case RATE_18MBPS:
|
|
|
|
status->rate_idx = 7;
|
|
|
|
break;
|
|
|
|
case RATE_24MBPS:
|
|
|
|
status->rate_idx = 8;
|
|
|
|
break;
|
|
|
|
case RATE_36MBPS:
|
|
|
|
status->rate_idx = 9;
|
|
|
|
break;
|
|
|
|
case RATE_48MBPS:
|
|
|
|
status->rate_idx = 10;
|
|
|
|
break;
|
|
|
|
case RATE_54MBPS:
|
|
|
|
status->rate_idx = 11;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for 1 and 12 Mbps we have to check the modulation */
|
|
|
|
if (desc->rate == RATE_1MBPS) {
|
|
|
|
if (!(desc->mod_pre & OFDM_RATE_BIT))
|
|
|
|
/* CCK -> RATE_1MBPS */
|
|
|
|
status->rate_idx = 0;
|
|
|
|
else
|
|
|
|
/* OFDM -> RATE_12MBPS */
|
|
|
|
status->rate_idx = 6;
|
|
|
|
}
|
2009-04-30 04:33:31 +08:00
|
|
|
|
2011-01-31 03:11:10 +08:00
|
|
|
if (desc->mod_pre & SHORT_PREAMBLE_BIT)
|
|
|
|
status->flag |= RX_FLAG_SHORTPRE;
|
2009-04-30 04:33:31 +08:00
|
|
|
}
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
static void wl1251_rx_body(struct wl1251 *wl,
|
|
|
|
struct wl1251_rx_descriptor *desc)
|
2009-04-30 04:33:31 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ieee80211_rx_status status;
|
|
|
|
u8 *rx_buffer, beacon = 0;
|
|
|
|
u16 length, *fc;
|
|
|
|
u32 curr_id, last_id_inc, rx_packet_ring_addr;
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
length = WL1251_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH);
|
2009-04-30 04:33:31 +08:00
|
|
|
curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT;
|
|
|
|
last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1);
|
|
|
|
|
|
|
|
if (last_id_inc != curr_id) {
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_warning("curr ID:%d, last ID inc:%d",
|
2009-04-30 04:33:31 +08:00
|
|
|
curr_id, last_id_inc);
|
|
|
|
wl->rx_last_id = curr_id;
|
|
|
|
} else {
|
|
|
|
wl->rx_last_id = last_id_inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr +
|
2009-06-12 19:17:39 +08:00
|
|
|
sizeof(struct wl1251_rx_descriptor) + 20;
|
2009-04-30 04:33:31 +08:00
|
|
|
if (wl->rx_current_buffer)
|
|
|
|
rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
|
|
|
|
|
2009-11-30 16:18:12 +08:00
|
|
|
skb = __dev_alloc_skb(length, GFP_KERNEL);
|
2009-04-30 04:33:31 +08:00
|
|
|
if (!skb) {
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_error("Couldn't allocate RX frame");
|
2009-04-30 04:33:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rx_buffer = skb_put(skb, length);
|
2009-08-07 18:32:56 +08:00
|
|
|
wl1251_mem_read(wl, rx_packet_ring_addr, rx_buffer, length);
|
2009-04-30 04:33:31 +08:00
|
|
|
|
2011-03-31 09:57:33 +08:00
|
|
|
/* The actual length doesn't include the target's alignment */
|
2009-04-30 04:33:31 +08:00
|
|
|
skb->len = desc->length - PLCP_HEADER_LENGTH;
|
|
|
|
|
|
|
|
fc = (u16 *)skb->data;
|
|
|
|
|
|
|
|
if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
|
|
|
|
beacon = 1;
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_rx_status(wl, desc, &status, beacon);
|
2009-04-30 04:33:31 +08:00
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len,
|
2009-04-30 04:33:31 +08:00
|
|
|
beacon ? "beacon" : "");
|
|
|
|
|
2009-06-17 19:13:00 +08:00
|
|
|
memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
|
2009-10-14 01:33:21 +08:00
|
|
|
ieee80211_rx_ni(wl->hw, skb);
|
2009-04-30 04:33:31 +08:00
|
|
|
}
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
static void wl1251_rx_ack(struct wl1251 *wl)
|
2009-04-30 04:33:31 +08:00
|
|
|
{
|
|
|
|
u32 data, addr;
|
|
|
|
|
|
|
|
if (wl->rx_current_buffer) {
|
|
|
|
addr = ACX_REG_INTERRUPT_TRIG_H;
|
|
|
|
data = INTR_TRIG_RX_PROC1;
|
|
|
|
} else {
|
|
|
|
addr = ACX_REG_INTERRUPT_TRIG;
|
|
|
|
data = INTR_TRIG_RX_PROC0;
|
|
|
|
}
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_reg_write32(wl, addr, data);
|
2009-04-30 04:33:31 +08:00
|
|
|
|
|
|
|
/* Toggle buffer ring */
|
|
|
|
wl->rx_current_buffer = !wl->rx_current_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
void wl1251_rx(struct wl1251 *wl)
|
2009-04-30 04:33:31 +08:00
|
|
|
{
|
2009-06-12 19:17:39 +08:00
|
|
|
struct wl1251_rx_descriptor *rx_desc;
|
2009-04-30 04:33:31 +08:00
|
|
|
|
2009-06-12 19:17:39 +08:00
|
|
|
if (wl->state != WL1251_STATE_ON)
|
2009-04-30 04:33:31 +08:00
|
|
|
return;
|
|
|
|
|
2009-06-12 19:15:08 +08:00
|
|
|
rx_desc = wl->rx_descriptor;
|
|
|
|
|
2009-04-30 04:33:31 +08:00
|
|
|
/* We first read the frame's header */
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_rx_header(wl, rx_desc);
|
2009-04-30 04:33:31 +08:00
|
|
|
|
|
|
|
/* Now we can read the body */
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_rx_body(wl, rx_desc);
|
2009-04-30 04:33:31 +08:00
|
|
|
|
|
|
|
/* Finally, we need to ACK the RX */
|
2009-06-12 19:17:39 +08:00
|
|
|
wl1251_rx_ack(wl);
|
2009-04-30 04:33:31 +08:00
|
|
|
}
|