2010-03-28 00:38:57 -06:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
* Copyright (c) 1996-2002 Winbond Electronic Corporation
|
|
|
|
*
|
|
|
|
* Module Name:
|
|
|
|
* Wb35Rx.c
|
|
|
|
*
|
|
|
|
* Abstract:
|
|
|
|
* Processing the Rx message from down layer
|
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
2008-10-30 05:04:29 -06:00
|
|
|
#include <linux/usb.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 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2008-10-30 05:04:29 -06:00
|
|
|
|
2008-10-30 08:14:39 -06:00
|
|
|
#include "core.h"
|
2008-10-30 05:04:29 -06:00
|
|
|
#include "wb35rx_f.h"
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
static void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int PacketSize)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2008-10-30 08:14:39 -06:00
|
|
|
struct wbsoft_priv *priv = hw->priv;
|
2008-10-30 11:04:53 -06:00
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ieee80211_rx_status rx_status = {0};
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
if (!priv->enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(PacketSize);
|
|
|
|
if (!skb) {
|
|
|
|
printk("Not enough memory for packet, FIXME\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
memcpy(skb_put(skb, PacketSize), pRxBufferAddress, PacketSize);
|
2008-10-30 11:04:53 -06:00
|
|
|
|
2009-06-17 05:13:00 -06:00
|
|
|
memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
|
|
|
|
ieee80211_rx_irqsafe(hw, skb);
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
|
|
|
|
2009-08-12 02:03:36 -06:00
|
|
|
static void Wb35Rx_adjust(struct wb35_descriptor *pRxDes)
|
2008-10-30 11:04:53 -06:00
|
|
|
{
|
2010-03-28 00:38:57 -06:00
|
|
|
u32 *pRxBufferAddress;
|
2008-10-30 11:04:53 -06:00
|
|
|
u32 DecryptionMethod;
|
|
|
|
u32 i;
|
|
|
|
u16 BufferSize;
|
|
|
|
|
|
|
|
DecryptionMethod = pRxDes->R01.R01_decryption_method;
|
|
|
|
pRxBufferAddress = pRxDes->buffer_address[0];
|
|
|
|
BufferSize = pRxDes->buffer_size[0];
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Adjust the last part of data. Only data left */
|
|
|
|
BufferSize -= 4; /* For CRC-32 */
|
2008-10-30 11:04:53 -06:00
|
|
|
if (DecryptionMethod)
|
|
|
|
BufferSize -= 4;
|
2010-03-28 00:38:57 -06:00
|
|
|
if (DecryptionMethod == 3) /* For CCMP */
|
2008-10-30 11:04:53 -06:00
|
|
|
BufferSize -= 4;
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Adjust the IV field which after 802.11 header and ICV field. */
|
|
|
|
if (DecryptionMethod == 1) { /* For WEP */
|
|
|
|
for (i = 6; i > 0; i--)
|
|
|
|
pRxBufferAddress[i] = pRxBufferAddress[i - 1];
|
2008-10-30 11:04:53 -06:00
|
|
|
pRxDes->buffer_address[0] = pRxBufferAddress + 1;
|
2010-03-28 00:38:57 -06:00
|
|
|
BufferSize -= 4; /* 4 byte for IV */
|
|
|
|
} else if (DecryptionMethod) { /* For TKIP and CCMP */
|
|
|
|
for (i = 7; i > 1; i--)
|
|
|
|
pRxBufferAddress[i] = pRxBufferAddress[i - 2];
|
|
|
|
pRxDes->buffer_address[0] = pRxBufferAddress + 2; /* Update the descriptor, shift 8 byte */
|
|
|
|
BufferSize -= 8; /* 8 byte for IV + ICV */
|
2008-10-30 11:04:53 -06:00
|
|
|
}
|
|
|
|
pRxDes->buffer_size[0] = BufferSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u16 Wb35Rx_indicate(struct ieee80211_hw *hw)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2010-03-28 00:38:57 -06:00
|
|
|
struct wbsoft_priv *priv = hw->priv;
|
|
|
|
struct hw_data *pHwData = &priv->sHwData;
|
2009-08-12 02:03:36 -06:00
|
|
|
struct wb35_descriptor RxDes;
|
2010-03-28 00:38:57 -06:00
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
|
|
|
u8 *pRxBufferAddress;
|
|
|
|
u16 PacketSize;
|
|
|
|
u16 stmp, BufferSize, stmp2 = 0;
|
|
|
|
u32 RxBufferId;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Only one thread be allowed to run into the following */
|
2008-10-30 11:04:53 -06:00
|
|
|
do {
|
|
|
|
RxBufferId = pWb35Rx->RxProcessIndex;
|
2010-03-28 00:38:57 -06:00
|
|
|
if (pWb35Rx->RxOwner[RxBufferId]) /* Owner by VM */
|
2008-10-30 11:04:53 -06:00
|
|
|
break;
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
pWb35Rx->RxProcessIndex++;
|
|
|
|
pWb35Rx->RxProcessIndex %= MAX_USB_RX_BUFFER_NUMBER;
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
pRxBufferAddress = pWb35Rx->pDRx;
|
2010-03-28 00:38:57 -06:00
|
|
|
BufferSize = pWb35Rx->RxBufferSize[RxBufferId];
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Parse the bulkin buffer */
|
2008-10-30 11:04:53 -06:00
|
|
|
while (BufferSize >= 4) {
|
2010-03-28 00:38:57 -06:00
|
|
|
if ((cpu_to_le32(*(u32 *)pRxBufferAddress) & 0x0fffffff) == RX_END_TAG) /* Is ending? */
|
2008-10-30 11:04:53 -06:00
|
|
|
break;
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Get the R00 R01 first */
|
2008-10-30 11:04:53 -06:00
|
|
|
RxDes.R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress);
|
|
|
|
PacketSize = (u16)RxDes.R00.R00_receive_byte_count;
|
2010-03-28 00:38:57 -06:00
|
|
|
RxDes.R01.value = le32_to_cpu(*((u32 *)(pRxBufferAddress + 4)));
|
|
|
|
/* For new DMA 4k */
|
2008-10-30 11:04:53 -06:00
|
|
|
if ((PacketSize & 0x03) > 0)
|
|
|
|
PacketSize -= 4;
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Basic check for Rx length. Is length valid? */
|
2008-10-30 11:04:53 -06:00
|
|
|
if (PacketSize > MAX_PACKET_SIZE) {
|
2010-11-28 14:00:00 -07:00
|
|
|
pr_debug("Serious ERROR : Rx data size too long, size =%d\n", PacketSize);
|
2008-10-30 11:04:53 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_STOP;
|
|
|
|
pWb35Rx->Ep3ErrorCount2++;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/*
|
|
|
|
* Wb35Rx_indicate() is called synchronously so it isn't
|
|
|
|
* necessary to set "RxDes.Desctriptor_ID = RxBufferID;"
|
|
|
|
*/
|
|
|
|
BufferSize -= 8; /* subtract 8 byte for 35's USB header length */
|
2008-10-30 11:04:53 -06:00
|
|
|
pRxBufferAddress += 8;
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
RxDes.buffer_address[0] = pRxBufferAddress;
|
|
|
|
RxDes.buffer_size[0] = PacketSize;
|
|
|
|
RxDes.buffer_number = 1;
|
|
|
|
RxDes.buffer_start_index = 0;
|
|
|
|
RxDes.buffer_total_size = RxDes.buffer_size[0];
|
|
|
|
Wb35Rx_adjust(&RxDes);
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
packet_came(hw, pRxBufferAddress, PacketSize);
|
2008-10-21 03:14:58 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Move RxBuffer point to the next */
|
2008-10-30 11:04:53 -06:00
|
|
|
stmp = PacketSize + 3;
|
2010-03-28 00:38:57 -06:00
|
|
|
stmp &= ~0x03; /* 4n alignment */
|
2008-10-30 11:04:53 -06:00
|
|
|
pRxBufferAddress += stmp;
|
|
|
|
BufferSize -= stmp;
|
|
|
|
stmp2 += stmp;
|
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Reclaim resource */
|
|
|
|
pWb35Rx->RxOwner[RxBufferId] = 1;
|
2008-10-30 11:04:53 -06:00
|
|
|
} while (true);
|
|
|
|
return stmp2;
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
static void Wb35Rx(struct ieee80211_hw *hw);
|
|
|
|
|
|
|
|
static void Wb35Rx_Complete(struct urb *urb)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2010-03-28 00:38:57 -06:00
|
|
|
struct ieee80211_hw *hw = urb->context;
|
|
|
|
struct wbsoft_priv *priv = hw->priv;
|
|
|
|
struct hw_data *pHwData = &priv->sHwData;
|
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
|
|
|
u8 *pRxBufferAddress;
|
|
|
|
u32 SizeCheck;
|
|
|
|
u16 BulkLength;
|
|
|
|
u32 RxBufferId;
|
2010-09-19 03:28:38 -06:00
|
|
|
struct R00_descriptor R00;
|
2010-03-28 00:38:57 -06:00
|
|
|
|
|
|
|
/* Variable setting */
|
2008-10-01 06:36:56 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_COMPLETED;
|
2010-03-28 00:38:57 -06:00
|
|
|
pWb35Rx->EP3VM_status = urb->status; /* Store the last result of Irp */
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-21 03:14:58 -06:00
|
|
|
RxBufferId = pWb35Rx->CurrentRxBufferId;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-21 03:14:58 -06:00
|
|
|
pRxBufferAddress = pWb35Rx->pDRx;
|
2008-10-22 02:01:16 -06:00
|
|
|
BulkLength = (u16)urb->actual_length;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* The IRP is completed */
|
2008-10-21 03:14:58 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_COMPLETED;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-11-01 14:29:30 -06:00
|
|
|
if (pHwData->SurpriseRemove) /* Must be here, or RxBufferId is invalid */
|
2008-10-21 03:14:58 -06:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (pWb35Rx->rx_halt)
|
|
|
|
goto error;
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Start to process the data only in successful condition */
|
|
|
|
pWb35Rx->RxOwner[RxBufferId] = 0; /* Set the owner to driver */
|
2008-10-21 03:14:58 -06:00
|
|
|
R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress);
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* The URB is completed, check the result */
|
2008-10-21 03:14:58 -06:00
|
|
|
if (pWb35Rx->EP3VM_status != 0) {
|
2010-11-28 14:00:00 -07:00
|
|
|
pr_debug("EP3 IoCompleteRoutine return error\n");
|
2008-10-21 03:14:58 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_STOP;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* For recovering. check if operating in single USB mode */
|
2008-10-21 03:14:58 -06:00
|
|
|
if (!HAL_USB_MODE_BURST(pHwData)) {
|
2010-03-28 00:38:57 -06:00
|
|
|
SizeCheck = R00.R00_receive_byte_count;
|
2008-10-21 03:14:58 -06:00
|
|
|
if ((SizeCheck & 0x03) > 0)
|
|
|
|
SizeCheck -= 4;
|
|
|
|
SizeCheck = (SizeCheck + 3) & ~0x03;
|
2010-03-28 00:38:57 -06:00
|
|
|
SizeCheck += 12; /* 8 + 4 badbeef */
|
2008-10-21 03:14:58 -06:00
|
|
|
if ((BulkLength > 1600) ||
|
|
|
|
(SizeCheck > 1600) ||
|
|
|
|
(BulkLength != SizeCheck) ||
|
2010-03-28 00:38:57 -06:00
|
|
|
(BulkLength == 0)) { /* Add for fail Urb */
|
2008-10-01 06:36:56 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_STOP;
|
2008-10-21 03:14:58 -06:00
|
|
|
pWb35Rx->Ep3ErrorCount2++;
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
2008-10-21 03:14:58 -06:00
|
|
|
}
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Indicating the receiving data */
|
2008-10-21 03:14:58 -06:00
|
|
|
pWb35Rx->ByteReceived += BulkLength;
|
2010-03-28 00:38:57 -06:00
|
|
|
pWb35Rx->RxBufferSize[RxBufferId] = BulkLength;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
if (!pWb35Rx->RxOwner[RxBufferId])
|
2008-10-30 08:14:39 -06:00
|
|
|
Wb35Rx_indicate(hw);
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-21 03:14:58 -06:00
|
|
|
kfree(pWb35Rx->pDRx);
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Do the next receive */
|
2008-10-30 08:14:39 -06:00
|
|
|
Wb35Rx(hw);
|
2008-10-21 03:14:58 -06:00
|
|
|
return;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-21 03:14:58 -06:00
|
|
|
error:
|
2010-03-28 00:38:57 -06:00
|
|
|
pWb35Rx->RxOwner[RxBufferId] = 1; /* Set the owner to hardware */
|
2008-10-29 12:10:32 -06:00
|
|
|
atomic_dec(&pWb35Rx->RxFireCounter);
|
2008-10-01 06:36:56 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_STOP;
|
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* This function cannot reentrain */
|
2008-10-30 11:04:53 -06:00
|
|
|
static void Wb35Rx(struct ieee80211_hw *hw)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2010-03-28 00:38:57 -06:00
|
|
|
struct wbsoft_priv *priv = hw->priv;
|
|
|
|
struct hw_data *pHwData = &priv->sHwData;
|
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
|
|
|
u8 *pRxBufferAddress;
|
|
|
|
struct urb *urb = pWb35Rx->RxUrb;
|
|
|
|
int retv;
|
|
|
|
u32 RxBufferId;
|
|
|
|
|
|
|
|
/* Issuing URB */
|
2010-11-01 14:29:30 -06:00
|
|
|
if (pHwData->SurpriseRemove)
|
2008-10-30 11:04:53 -06:00
|
|
|
goto error;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
if (pWb35Rx->rx_halt)
|
|
|
|
goto error;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Get RxBuffer's ID */
|
2008-10-30 11:04:53 -06:00
|
|
|
RxBufferId = pWb35Rx->RxBufferId;
|
|
|
|
if (!pWb35Rx->RxOwner[RxBufferId]) {
|
2010-03-28 00:38:57 -06:00
|
|
|
/* It's impossible to run here. */
|
2010-11-28 14:00:00 -07:00
|
|
|
pr_debug("Rx driver fifo unavailable\n");
|
2008-10-30 11:04:53 -06:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Update buffer point, then start to bulkin the data from USB */
|
2008-10-30 11:04:53 -06:00
|
|
|
pWb35Rx->RxBufferId++;
|
|
|
|
pWb35Rx->RxBufferId %= MAX_USB_RX_BUFFER_NUMBER;
|
|
|
|
|
|
|
|
pWb35Rx->CurrentRxBufferId = RxBufferId;
|
|
|
|
|
|
|
|
pWb35Rx->pDRx = kzalloc(MAX_USB_RX_BUFFER, GFP_ATOMIC);
|
|
|
|
if (!pWb35Rx->pDRx) {
|
|
|
|
printk("w35und: Rx memory alloc failed\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
pRxBufferAddress = pWb35Rx->pDRx;
|
|
|
|
|
2010-11-28 14:00:08 -07:00
|
|
|
usb_fill_bulk_urb(urb, pHwData->udev,
|
|
|
|
usb_rcvbulkpipe(pHwData->udev, 3),
|
2008-10-30 11:04:53 -06:00
|
|
|
pRxBufferAddress, MAX_USB_RX_BUFFER,
|
|
|
|
Wb35Rx_Complete, hw);
|
|
|
|
|
|
|
|
pWb35Rx->EP3vm_state = VM_RUNNING;
|
|
|
|
|
|
|
|
retv = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (retv != 0) {
|
|
|
|
printk("Rx URB sending error\n");
|
|
|
|
goto error;
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
2008-10-30 11:04:53 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
2010-03-28 00:38:57 -06:00
|
|
|
/* VM stop */
|
2008-10-30 11:04:53 -06:00
|
|
|
pWb35Rx->EP3vm_state = VM_STOP;
|
|
|
|
atomic_dec(&pWb35Rx->RxFireCounter);
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
void Wb35Rx_start(struct ieee80211_hw *hw)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2010-03-28 00:38:57 -06:00
|
|
|
struct wbsoft_priv *priv = hw->priv;
|
|
|
|
struct hw_data *pHwData = &priv->sHwData;
|
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Allow only one thread to run into the Wb35Rx() function */
|
2008-10-30 11:04:53 -06:00
|
|
|
if (atomic_inc_return(&pWb35Rx->RxFireCounter) == 1) {
|
|
|
|
pWb35Rx->EP3vm_state = VM_RUNNING;
|
|
|
|
Wb35Rx(hw);
|
|
|
|
} else
|
|
|
|
atomic_dec(&pWb35Rx->RxFireCounter);
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
static void Wb35Rx_reset_descriptor(struct hw_data *pHwData)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2010-03-28 00:38:57 -06:00
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
|
|
|
u32 i;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
|
|
|
pWb35Rx->ByteReceived = 0;
|
|
|
|
pWb35Rx->RxProcessIndex = 0;
|
|
|
|
pWb35Rx->RxBufferId = 0;
|
|
|
|
pWb35Rx->EP3vm_state = VM_STOP;
|
|
|
|
pWb35Rx->rx_halt = 0;
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Initial the Queue. The last buffer is reserved for used if the Rx resource is unavailable. */
|
|
|
|
for (i = 0; i < MAX_USB_RX_BUFFER_NUMBER; i++)
|
2008-10-01 06:36:56 -06:00
|
|
|
pWb35Rx->RxOwner[i] = 1;
|
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
unsigned char Wb35Rx_initial(struct hw_data *pHwData)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2009-01-08 09:32:14 -07:00
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Initial the Buffer Queue */
|
|
|
|
Wb35Rx_reset_descriptor(pHwData);
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
pWb35Rx->RxUrb = usb_alloc_urb(0, GFP_ATOMIC);
|
2010-03-28 00:38:57 -06:00
|
|
|
return !!pWb35Rx->RxUrb;
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
void Wb35Rx_stop(struct hw_data *pHwData)
|
2008-10-30 10:12:05 -06:00
|
|
|
{
|
2009-01-08 09:32:14 -07:00
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
2008-10-30 10:12:05 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Canceling the Irp if already sends it out. */
|
2008-10-30 11:04:53 -06:00
|
|
|
if (pWb35Rx->EP3vm_state == VM_RUNNING) {
|
2010-03-28 00:38:57 -06:00
|
|
|
usb_unlink_urb(pWb35Rx->RxUrb); /* Only use unlink, let Wb35Rx_destroy to free them */
|
2010-11-28 14:00:00 -07:00
|
|
|
pr_debug("EP3 Rx stop\n");
|
2008-10-30 10:12:05 -06:00
|
|
|
}
|
|
|
|
}
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2010-03-28 00:38:57 -06:00
|
|
|
/* Needs process context */
|
|
|
|
void Wb35Rx_destroy(struct hw_data *pHwData)
|
2008-10-01 06:36:56 -06:00
|
|
|
{
|
2009-01-08 09:32:14 -07:00
|
|
|
struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx;
|
2008-10-01 06:36:56 -06:00
|
|
|
|
|
|
|
do {
|
2010-03-28 00:38:57 -06:00
|
|
|
msleep(10); /* Delay for waiting function enter */
|
2008-10-30 11:04:53 -06:00
|
|
|
} while (pWb35Rx->EP3vm_state != VM_STOP);
|
2010-03-28 00:38:57 -06:00
|
|
|
msleep(10); /* Delay for waiting function exit */
|
2008-10-01 06:36:56 -06:00
|
|
|
|
2008-10-30 11:04:53 -06:00
|
|
|
if (pWb35Rx->RxUrb)
|
2010-03-28 00:38:57 -06:00
|
|
|
usb_free_urb(pWb35Rx->RxUrb);
|
2010-11-28 14:00:00 -07:00
|
|
|
pr_debug("Wb35Rx_destroy OK\n");
|
2008-10-01 06:36:56 -06:00
|
|
|
}
|
|
|
|
|