Commit b61124f9 authored by Matthias Beyer's avatar Matthias Beyer Committed by Greg Kroah-Hartman

Staging: bcm: LeakyBucket.c: Outsourced code chunk into function

Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Acked-by: default avatarKevin McKinney <klmckinney1@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0acfe734
...@@ -146,89 +146,64 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adap ...@@ -146,89 +146,64 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adap
return Status; return Status;
} }
/************************************************************************ static void get_data_packet(struct bcm_mini_adapter *ad,
* Function - CheckAndSendPacketFromIndex() struct bcm_packet_info *ps_sf)
*
* Description - This function dequeues the data/control packet from the
* specified queue for transmission.
*
* Parameters - Adapter : Pointer to the driver control structure.
* - iQIndex : The queue Identifier.
*
* Returns - None.
*
****************************************************************************/
static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter,
struct bcm_packet_info *psSF)
{ {
struct sk_buff *QueuePacket = NULL; int packet_len;
char *pControlPacket = NULL; struct sk_buff *qpacket;
INT Status = 0;
int iPacketLen = 0;
if (!ps_sf->ucDirection)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
"%zd ====>", (psSF-Adapter->PackInfo));
if ((psSF != &Adapter->PackInfo[HiPriority]) &&
Adapter->LinkUpStatus &&
atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */
if (!psSF->ucDirection)
return; return;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
"UpdateTokenCount "); "UpdateTokenCount ");
if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) if (ad->IdleMode || ad->bPreparingForLowPowerMode)
return; /* in idle mode */ return; /* in idle mode */
/* Check for Free Descriptors */ /* Check for Free Descriptors */
if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= if (atomic_read(&ad->CurrNumFreeTxDesc) <=
MINIMUM_PENDING_DESCRIPTORS) { MINIMUM_PENDING_DESCRIPTORS) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
DBG_LVL_ALL,
" No Free Tx Descriptor(%d) is available for Data pkt..", " No Free Tx Descriptor(%d) is available for Data pkt..",
atomic_read(&Adapter->CurrNumFreeTxDesc)); atomic_read(&ad->CurrNumFreeTxDesc));
return; return;
} }
spin_lock_bh(&psSF->SFQueueLock); spin_lock_bh(&ps_sf->SFQueueLock);
QueuePacket = psSF->FirstTxQueue; qpacket = ps_sf->FirstTxQueue;
if (QueuePacket) { if (qpacket) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
DBG_LVL_ALL, "Dequeuing Data Packet"); "Dequeuing Data Packet");
if (psSF->bEthCSSupport) if (ps_sf->bEthCSSupport)
iPacketLen = QueuePacket->len; packet_len = qpacket->len;
else else
iPacketLen = QueuePacket->len-ETH_HLEN; packet_len = qpacket->len - ETH_HLEN;
iPacketLen <<= 3; packet_len <<= 3;
if (iPacketLen <= GetSFTokenCount(Adapter, psSF)) { if (packet_len <= GetSFTokenCount(ad, ps_sf)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
TX_PACKETS, DBG_LVL_ALL, DBG_LVL_ALL, "Allowed bytes %d",
"Allowed bytes %d", (packet_len >> 3));
(iPacketLen >> 3));
DEQUEUEPACKET(ps_sf->FirstTxQueue, ps_sf->LastTxQueue);
DEQUEUEPACKET(psSF->FirstTxQueue, ps_sf->uiCurrentBytesOnHost -= (qpacket->len);
psSF->LastTxQueue); ps_sf->uiCurrentPacketsOnHost--;
psSF->uiCurrentBytesOnHost -= atomic_dec(&ad->TotalPacketCount);
(QueuePacket->len); spin_unlock_bh(&ps_sf->SFQueueLock);
psSF->uiCurrentPacketsOnHost--;
atomic_dec(&Adapter->TotalPacketCount); SendPacketFromQueue(ad, ps_sf, qpacket);
spin_unlock_bh(&psSF->SFQueueLock); ps_sf->uiPendedLast = false;
Status = SendPacketFromQueue(Adapter, psSF,
QueuePacket);
psSF->uiPendedLast = false;
} else { } else {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
TX_PACKETS, DBG_LVL_ALL, DBG_LVL_ALL, "For Queue: %zd\n",
"For Queue: %zd\n", ps_sf - ad->PackInfo);
psSF-Adapter->PackInfo); BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, DBG_LVL_ALL,
TX_PACKETS, DBG_LVL_ALL,
"\nAvailable Tokens = %d required = %d\n", "\nAvailable Tokens = %d required = %d\n",
psSF->uiCurrentTokenCount, iPacketLen); ps_sf->uiCurrentTokenCount,
packet_len);
/* /*
this part indicates that because of this part indicates that because of
non-availability of the tokens non-availability of the tokens
...@@ -236,12 +211,39 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, ...@@ -236,12 +211,39 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter,
pending flag indicating the host to send it out pending flag indicating the host to send it out
first next iteration. first next iteration.
*/ */
psSF->uiPendedLast = TRUE; ps_sf->uiPendedLast = TRUE;
spin_unlock_bh(&psSF->SFQueueLock); spin_unlock_bh(&ps_sf->SFQueueLock);
} }
} else { } else {
spin_unlock_bh(&psSF->SFQueueLock); spin_unlock_bh(&ps_sf->SFQueueLock);
} }
}
/************************************************************************
* Function - CheckAndSendPacketFromIndex()
*
* Description - This function dequeues the data/control packet from the
* specified queue for transmission.
*
* Parameters - Adapter : Pointer to the driver control structure.
* - iQIndex : The queue Identifier.
*
* Returns - None.
*
****************************************************************************/
static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter,
struct bcm_packet_info *psSF)
{
char *pControlPacket = NULL;
INT Status = 0;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
"%zd ====>", (psSF-Adapter->PackInfo));
if ((psSF != &Adapter->PackInfo[HiPriority]) &&
Adapter->LinkUpStatus &&
atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */
get_data_packet(Adapter, psSF);
} else { } else {
if ((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0) && if ((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment