From: Matthias Beyer Date: Mon, 30 Jun 2014 08:25:19 +0000 (+0200) Subject: Staging: bcm: LeakyBucket.c: Outsourced code chunk into function X-Git-Tag: v3.17-rc1~123^2~1161 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b61124f99da7b1fa9a6a052d894e90419363cbb0;p=karo-tx-linux.git Staging: bcm: LeakyBucket.c: Outsourced code chunk into function Signed-off-by: Matthias Beyer Acked-by: Kevin McKinney Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index 1151c835a32f..0d1a6e5adebb 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -146,6 +146,79 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**ucDirection) + return; + + BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, + "UpdateTokenCount "); + if (ad->IdleMode || ad->bPreparingForLowPowerMode) + return; /* in idle mode */ + + /* Check for Free Descriptors */ + if (atomic_read(&ad->CurrNumFreeTxDesc) <= + MINIMUM_PENDING_DESCRIPTORS) { + BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, + " No Free Tx Descriptor(%d) is available for Data pkt..", + atomic_read(&ad->CurrNumFreeTxDesc)); + return; + } + + spin_lock_bh(&ps_sf->SFQueueLock); + qpacket = ps_sf->FirstTxQueue; + + if (qpacket) { + BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, + "Dequeuing Data Packet"); + + if (ps_sf->bEthCSSupport) + packet_len = qpacket->len; + else + 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(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", + ps_sf->uiCurrentTokenCount, + packet_len); + /* + this part indicates that because of + non-availability of the tokens + pkt has not been send out hence setting the + pending flag indicating the host to send it out + first next iteration. + */ + ps_sf->uiPendedLast = TRUE; + spin_unlock_bh(&ps_sf->SFQueueLock); + } + } else { + spin_unlock_bh(&ps_sf->SFQueueLock); + } +} + /************************************************************************ * Function - CheckAndSendPacketFromIndex() * @@ -161,87 +234,16 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**", (psSF-Adapter->PackInfo)); if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */ - if (!psSF->ucDirection) - return; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "UpdateTokenCount "); - if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) - return; /* in idle mode */ - - /* Check for Free Descriptors */ - if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= - MINIMUM_PENDING_DESCRIPTORS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, - " No Free Tx Descriptor(%d) is available for Data pkt..", - atomic_read(&Adapter->CurrNumFreeTxDesc)); - return; - } - - spin_lock_bh(&psSF->SFQueueLock); - QueuePacket = psSF->FirstTxQueue; - - if (QueuePacket) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, "Dequeuing Data Packet"); - - if (psSF->bEthCSSupport) - iPacketLen = QueuePacket->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; - } 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, - "\nAvailable Tokens = %d required = %d\n", - psSF->uiCurrentTokenCount, iPacketLen); - /* - this part indicates that because of - non-availability of the tokens - pkt has not been send out hence setting the - pending flag indicating the host to send it out - first next iteration. - */ - psSF->uiPendedLast = TRUE; - spin_unlock_bh(&psSF->SFQueueLock); - } - } else { - spin_unlock_bh(&psSF->SFQueueLock); - } + get_data_packet(Adapter, psSF); } else { if ((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0) &&