mirror of
https://github.com/torvalds/linux
synced 2024-10-20 18:28:21 +00:00
Staging: bcm: InterfaceRx.c: Lines shortened
Acked-by: Kevin McKinney <klmckinney1@gmail.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9fe109c153
commit
f5c86ab9b6
|
@ -24,8 +24,9 @@ GetBulkInRcb(struct bcm_interface_adapter *psIntfAdapter)
|
||||||
pRcb = &psIntfAdapter->asUsbRcb[index];
|
pRcb = &psIntfAdapter->asUsbRcb[index];
|
||||||
pRcb->bUsed = TRUE;
|
pRcb->bUsed = TRUE;
|
||||||
pRcb->psIntfAdapter = psIntfAdapter;
|
pRcb->psIntfAdapter = psIntfAdapter;
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Got Rx desc %d used %d",
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC,
|
||||||
index, atomic_read(&psIntfAdapter->uNumRcbUsed));
|
DBG_LVL_ALL, "Got Rx desc %d used %d", index,
|
||||||
|
atomic_read(&psIntfAdapter->uNumRcbUsed));
|
||||||
index = (index + 1) % MAXIMUM_USB_RCB;
|
index = (index + 1) % MAXIMUM_USB_RCB;
|
||||||
atomic_set(&psIntfAdapter->uCurrRcb, index);
|
atomic_set(&psIntfAdapter->uCurrRcb, index);
|
||||||
atomic_inc(&psIntfAdapter->uNumRcbUsed);
|
atomic_inc(&psIntfAdapter->uNumRcbUsed);
|
||||||
|
@ -63,7 +64,10 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
Adapter->bEndPointHalted = TRUE;
|
Adapter->bEndPointHalted = TRUE;
|
||||||
wake_up(&Adapter->tx_packet_wait_queue);
|
wake_up(&Adapter->tx_packet_wait_queue);
|
||||||
} else {
|
} else {
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Rx URB has got cancelled. status :%d", urb->status);
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC,
|
||||||
|
DBG_LVL_ALL,
|
||||||
|
"Rx URB has got cancelled. status :%d",
|
||||||
|
urb->status);
|
||||||
}
|
}
|
||||||
pRcb->bUsed = false;
|
pRcb->bUsed = false;
|
||||||
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
||||||
|
@ -72,17 +76,22 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) {
|
if (Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) {
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "device is going in low power mode while PMU option selected..hence rx packet should not be process");
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
|
||||||
|
"device is going in low power mode while PMU option selected..hence rx packet should not be process");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Read back done len %d\n", pLeader->PLength);
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
|
||||||
|
"Read back done len %d\n", pLeader->PLength);
|
||||||
if (!pLeader->PLength) {
|
if (!pLeader->PLength) {
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Length 0");
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
|
||||||
|
"Leader Length 0");
|
||||||
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", pLeader->Status, pLeader->PLength, pLeader->Vcid);
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,
|
||||||
|
"Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX",
|
||||||
|
pLeader->Status, pLeader->PLength, pLeader->Vcid);
|
||||||
if (MAX_CNTL_PKT_SIZE < pLeader->PLength) {
|
if (MAX_CNTL_PKT_SIZE < pLeader->PLength) {
|
||||||
if (netif_msg_rx_err(Adapter))
|
if (netif_msg_rx_err(Adapter))
|
||||||
pr_info(PFX "%s: corrupted leader length...%d\n",
|
pr_info(PFX "%s: corrupted leader length...%d\n",
|
||||||
|
@ -100,23 +109,27 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
bHeaderSupressionEnabled & Adapter->bPHSEnabled;
|
bHeaderSupressionEnabled & Adapter->bPHSEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
skb = dev_alloc_skb(pLeader->PLength + SKB_RESERVE_PHS_BYTES + SKB_RESERVE_ETHERNET_HEADER);
|
skb = dev_alloc_skb(pLeader->PLength + SKB_RESERVE_PHS_BYTES +
|
||||||
|
SKB_RESERVE_ETHERNET_HEADER);
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "NO SKBUFF!!! Dropping the Packet");
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
|
||||||
|
"NO SKBUFF!!! Dropping the Packet");
|
||||||
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* If it is a control Packet, then call handle_bcm_packet ()*/
|
/* If it is a control Packet, then call handle_bcm_packet ()*/
|
||||||
if ((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) ||
|
if ((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) ||
|
||||||
(!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F))) {
|
(!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F))) {
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Received control pkt...");
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_CTRL,
|
||||||
|
DBG_LVL_ALL, "Received control pkt...");
|
||||||
*(PUSHORT)skb->data = pLeader->Status;
|
*(PUSHORT)skb->data = pLeader->Status;
|
||||||
memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer +
|
memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer +
|
||||||
(sizeof(struct bcm_leader)), pLeader->PLength);
|
(sizeof(struct bcm_leader)), pLeader->PLength);
|
||||||
skb->len = pLeader->PLength + sizeof(USHORT);
|
skb->len = pLeader->PLength + sizeof(USHORT);
|
||||||
|
|
||||||
spin_lock(&Adapter->control_queue_lock);
|
spin_lock(&Adapter->control_queue_lock);
|
||||||
ENQUEUEPACKET(Adapter->RxControlHead, Adapter->RxControlTail, skb);
|
ENQUEUEPACKET(Adapter->RxControlHead, Adapter->RxControlTail,
|
||||||
|
skb);
|
||||||
spin_unlock(&Adapter->control_queue_lock);
|
spin_unlock(&Adapter->control_queue_lock);
|
||||||
|
|
||||||
atomic_inc(&Adapter->cntrlpktCnt);
|
atomic_inc(&Adapter->cntrlpktCnt);
|
||||||
|
@ -126,16 +139,22 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
* Data Packet, Format a proper Ethernet Header
|
* Data Packet, Format a proper Ethernet Header
|
||||||
* and give it to the stack
|
* and give it to the stack
|
||||||
*/
|
*/
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt...");
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA,
|
||||||
|
DBG_LVL_ALL, "Received Data pkt...");
|
||||||
skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
|
skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
|
||||||
memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(struct bcm_leader), pLeader->PLength);
|
memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer +
|
||||||
|
sizeof(struct bcm_leader), pLeader->PLength);
|
||||||
skb->dev = Adapter->dev;
|
skb->dev = Adapter->dev;
|
||||||
|
|
||||||
/* currently skb->len has extra ETH_HLEN bytes in the beginning */
|
/* currently skb->len has extra ETH_HLEN bytes in the beginning */
|
||||||
skb_put(skb, pLeader->PLength + ETH_HLEN);
|
skb_put(skb, pLeader->PLength + ETH_HLEN);
|
||||||
Adapter->PackInfo[QueueIndex].uiTotalRxBytes += pLeader->PLength;
|
Adapter->PackInfo[QueueIndex].uiTotalRxBytes +=
|
||||||
Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes += pLeader->PLength;
|
pLeader->PLength;
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt of len :0x%X", pLeader->PLength);
|
Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes +=
|
||||||
|
pLeader->PLength;
|
||||||
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA,
|
||||||
|
DBG_LVL_ALL, "Received Data pkt of len :0x%X",
|
||||||
|
pLeader->PLength);
|
||||||
|
|
||||||
if (netif_running(Adapter->dev)) {
|
if (netif_running(Adapter->dev)) {
|
||||||
/* Moving ahead by ETH_HLEN to the data ptr as received from FW */
|
/* Moving ahead by ETH_HLEN to the data ptr as received from FW */
|
||||||
|
@ -157,7 +176,9 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
skb->protocol = eth_type_trans(skb, Adapter->dev);
|
skb->protocol = eth_type_trans(skb, Adapter->dev);
|
||||||
process_done = netif_rx(skb);
|
process_done = netif_rx(skb);
|
||||||
} else {
|
} else {
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB...");
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX,
|
||||||
|
RX_DATA, DBG_LVL_ALL,
|
||||||
|
"i/f not up hance freeing SKB...");
|
||||||
dev_kfree_skb(skb);
|
dev_kfree_skb(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,8 +186,11 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
Adapter->dev->stats.rx_bytes += pLeader->PLength;
|
Adapter->dev->stats.rx_bytes += pLeader->PLength;
|
||||||
|
|
||||||
for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) {
|
for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) {
|
||||||
if ((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) &&
|
if ((pLeader->PLength <=
|
||||||
(pLeader->PLength > MIBS_PKTSIZEHIST_RANGE*(uiIndex)))
|
MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) &&
|
||||||
|
(pLeader->PLength >
|
||||||
|
MIBS_PKTSIZEHIST_RANGE*(uiIndex)))
|
||||||
|
|
||||||
Adapter->aRxPktSizeHist[uiIndex]++;
|
Adapter->aRxPktSizeHist[uiIndex]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,20 +199,29 @@ static void read_bulk_callback(struct urb *urb)
|
||||||
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
atomic_dec(&psIntfAdapter->uNumRcbUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ReceiveRcb(struct bcm_interface_adapter *psIntfAdapter, struct bcm_usb_rcb *pRcb)
|
static int ReceiveRcb(struct bcm_interface_adapter *psIntfAdapter,
|
||||||
|
struct bcm_usb_rcb *pRcb)
|
||||||
{
|
{
|
||||||
struct urb *urb = pRcb->urb;
|
struct urb *urb = pRcb->urb;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
usb_fill_bulk_urb(urb, psIntfAdapter->udev, usb_rcvbulkpipe(psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_endpointAddr),
|
usb_fill_bulk_urb(urb, psIntfAdapter->udev,
|
||||||
urb->transfer_buffer, BCM_USB_MAX_READ_LENGTH, read_bulk_callback, pRcb);
|
usb_rcvbulkpipe(psIntfAdapter->udev,
|
||||||
|
psIntfAdapter->sBulkIn.bulk_in_endpointAddr),
|
||||||
|
urb->transfer_buffer,
|
||||||
|
BCM_USB_MAX_READ_LENGTH,
|
||||||
|
read_bulk_callback, pRcb);
|
||||||
|
|
||||||
if (false == psIntfAdapter->psAdapter->device_removed &&
|
if (false == psIntfAdapter->psAdapter->device_removed &&
|
||||||
false == psIntfAdapter->psAdapter->bEndPointHalted &&
|
false == psIntfAdapter->psAdapter->bEndPointHalted &&
|
||||||
false == psIntfAdapter->bSuspended &&
|
false == psIntfAdapter->bSuspended &&
|
||||||
false == psIntfAdapter->bPreparingForBusSuspend) {
|
false == psIntfAdapter->bPreparingForBusSuspend) {
|
||||||
retval = usb_submit_urb(urb, GFP_ATOMIC);
|
retval = usb_submit_urb(urb, GFP_ATOMIC);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "failed submitting read urb, error %d", retval);
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX,
|
||||||
|
RX_DPC, DBG_LVL_ALL,
|
||||||
|
"failed submitting read urb, error %d",
|
||||||
|
retval);
|
||||||
/* if this return value is because of pipe halt. need to clear this. */
|
/* if this return value is because of pipe halt. need to clear this. */
|
||||||
if (retval == -EPIPE) {
|
if (retval == -EPIPE) {
|
||||||
psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
|
psIntfAdapter->psAdapter->bEndPointHalted = TRUE;
|
||||||
|
@ -216,13 +249,17 @@ Return: TRUE - If Rx was successful.
|
||||||
|
|
||||||
bool InterfaceRx(struct bcm_interface_adapter *psIntfAdapter)
|
bool InterfaceRx(struct bcm_interface_adapter *psIntfAdapter)
|
||||||
{
|
{
|
||||||
USHORT RxDescCount = NUM_RX_DESC - atomic_read(&psIntfAdapter->uNumRcbUsed);
|
USHORT RxDescCount = NUM_RX_DESC -
|
||||||
|
atomic_read(&psIntfAdapter->uNumRcbUsed);
|
||||||
|
|
||||||
struct bcm_usb_rcb *pRcb = NULL;
|
struct bcm_usb_rcb *pRcb = NULL;
|
||||||
|
|
||||||
while (RxDescCount) {
|
while (RxDescCount) {
|
||||||
pRcb = GetBulkInRcb(psIntfAdapter);
|
pRcb = GetBulkInRcb(psIntfAdapter);
|
||||||
if (pRcb == NULL) {
|
if (pRcb == NULL) {
|
||||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "Unable to get Rcb pointer");
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
|
||||||
|
DBG_TYPE_PRINTK, 0, 0,
|
||||||
|
"Unable to get Rcb pointer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ReceiveRcb(psIntfAdapter, pRcb);
|
ReceiveRcb(psIntfAdapter, pRcb);
|
||||||
|
|
Loading…
Reference in a new issue