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
return Status;
}
/************************************************************************
* 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)
static void get_data_packet(struct bcm_mini_adapter *ad,
struct bcm_packet_info *ps_sf)
{
struct sk_buff *QueuePacket = NULL;
char *pControlPacket = NULL;
INT Status = 0;
int iPacketLen = 0;
int packet_len;
struct sk_buff *qpacket;
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)
if (!ps_sf->ucDirection)
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 ");
if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode)
if (ad->IdleMode || ad->bPreparingForLowPowerMode)
return; /* in idle mode */
/* Check for Free Descriptors */
if (atomic_read(&Adapter->CurrNumFreeTxDesc) <=
if (atomic_read(&ad->CurrNumFreeTxDesc) <=
MINIMUM_PENDING_DESCRIPTORS) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS,
DBG_LVL_ALL,
BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
" No Free Tx Descriptor(%d) is available for Data pkt..",
atomic_read(&Adapter->CurrNumFreeTxDesc));
atomic_read(&ad->CurrNumFreeTxDesc));
return;
}
spin_lock_bh(&psSF->SFQueueLock);
QueuePacket = psSF->FirstTxQueue;
spin_lock_bh(&ps_sf->SFQueueLock);
qpacket = ps_sf->FirstTxQueue;
if (QueuePacket) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS,
DBG_LVL_ALL, "Dequeuing Data Packet");
if (qpacket) {
BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL,
"Dequeuing Data Packet");
if (psSF->bEthCSSupport)
iPacketLen = QueuePacket->len;
if (ps_sf->bEthCSSupport)
packet_len = qpacket->len;
else
iPacketLen = QueuePacket->len-ETH_HLEN;
iPacketLen <<= 3;
if (iPacketLen <= GetSFTokenCount(Adapter, psSF)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX,
TX_PACKETS, DBG_LVL_ALL,
"Allowed bytes %d",
(iPacketLen >> 3));
DEQUEUEPACKET(psSF->FirstTxQueue,
psSF->LastTxQueue);
psSF->uiCurrentBytesOnHost -=
(QueuePacket->len);
psSF->uiCurrentPacketsOnHost--;
atomic_dec(&Adapter->TotalPacketCount);
spin_unlock_bh(&psSF->SFQueueLock);
Status = SendPacketFromQueue(Adapter, psSF,
QueuePacket);
psSF->uiPendedLast = false;
packet_len = qpacket->len - ETH_HLEN;
packet_len <<= 3;
if (packet_len <= GetSFTokenCount(ad, ps_sf)) {
BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
DBG_LVL_ALL, "Allowed bytes %d",
(packet_len >> 3));
DEQUEUEPACKET(ps_sf->FirstTxQueue, ps_sf->LastTxQueue);
ps_sf->uiCurrentBytesOnHost -= (qpacket->len);
ps_sf->uiCurrentPacketsOnHost--;
atomic_dec(&ad->TotalPacketCount);
spin_unlock_bh(&ps_sf->SFQueueLock);
SendPacketFromQueue(ad, ps_sf, qpacket);
ps_sf->uiPendedLast = false;
} else {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX,
TX_PACKETS, DBG_LVL_ALL,
"For Queue: %zd\n",
psSF-Adapter->PackInfo);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX,
TX_PACKETS, DBG_LVL_ALL,
BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
DBG_LVL_ALL, "For Queue: %zd\n",
ps_sf - ad->PackInfo);
BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS,
DBG_LVL_ALL,
"\nAvailable Tokens = %d required = %d\n",
psSF->uiCurrentTokenCount, iPacketLen);
ps_sf->uiCurrentTokenCount,
packet_len);
/*
this part indicates that because of
non-availability of the tokens
......@@ -236,12 +211,39 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter,
pending flag indicating the host to send it out
first next iteration.
*/
psSF->uiPendedLast = TRUE;
spin_unlock_bh(&psSF->SFQueueLock);
ps_sf->uiPendedLast = TRUE;
spin_unlock_bh(&ps_sf->SFQueueLock);
}
} 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 {
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