Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

beceem: statistics and transmit queue changes

Use standard network statistics variables and routines.
Transmit counters are per queue, and skb mapping is already in
skb and does not need to be recomputed. Move SearchVcId to only
place it is used.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

+41 -76
-9
drivers/staging/bcm/Adapter.h
··· 414 414 // this to keep track of the Tx and Rx MailBox Registers. 415 415 atomic_t CurrNumFreeTxDesc; 416 416 // to keep track the no of byte recieved 417 - atomic_t RxRollOverCount; 418 417 USHORT PrevNumRecvDescs; 419 418 USHORT CurrNumRecvDescs; 420 - atomic_t GoodRxByteCount; 421 - atomic_t GoodRxPktCount; 422 - atomic_t BadRxByteCount; 423 - atomic_t RxPacketDroppedCount; 424 - atomic_t GoodTxByteCount; 425 - atomic_t TxTotalPacketCount; 426 - atomic_t TxDroppedPacketCount; 427 - 428 419 UINT u32TotalDSD; 429 420 PacketInfo PackInfo[NO_OF_QUEUES]; 430 421 S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS];
-20
drivers/staging/bcm/Bcmnet.c
··· 48 48 return 0; 49 49 } 50 50 51 - static struct net_device_stats *bcm_get_stats(struct net_device *dev) 52 - { 53 - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev); 54 - struct net_device_stats* netstats = &dev->stats; 55 - 56 - netstats->rx_packets = atomic_read(&Adapter->RxRollOverCount)*64*1024 57 - + Adapter->PrevNumRecvDescs; 58 - netstats->rx_bytes = atomic_read(&Adapter->GoodRxByteCount) 59 - + atomic_read(&Adapter->BadRxByteCount); 60 - 61 - netstats->rx_dropped = atomic_read(&Adapter->RxPacketDroppedCount); 62 - netstats->rx_errors = atomic_read(&Adapter->RxPacketDroppedCount); 63 - netstats->tx_bytes = atomic_read(&Adapter->GoodTxByteCount); 64 - netstats->tx_packets = atomic_read(&Adapter->TxTotalPacketCount); 65 - netstats->tx_dropped = atomic_read(&Adapter->TxDroppedPacketCount); 66 - 67 - return netstats; 68 - } 69 - 70 51 static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb) 71 52 { 72 53 return ClassifyPacket(netdev_priv(dev), skb); ··· 121 140 static const struct net_device_ops bcmNetDevOps = { 122 141 .ndo_open = bcm_open, 123 142 .ndo_stop = bcm_close, 124 - .ndo_get_stats = bcm_get_stats, 125 143 .ndo_start_xmit = bcm_transmit, 126 144 .ndo_change_mtu = eth_change_mtu, 127 145 .ndo_set_mac_address = eth_mac_addr,
-12
drivers/staging/bcm/CmHost.c
··· 58 58 return NO_OF_QUEUES+1; 59 59 } 60 60 61 - int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid) 62 - { 63 - int iIndex=0; 64 - 65 - for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) 66 - if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) 67 - return iIndex; 68 - return NO_OF_QUEUES+1; 69 - 70 - } 71 - 72 - 73 61 /* 74 62 Function: SearchClsid 75 63 Description: This routinue would search Classifier having specified ClassifierID as input parameter
+16 -5
drivers/staging/bcm/InterfaceRx.c
··· 1 1 #include "headers.h" 2 - extern int SearchVcid(PMINI_ADAPTER , unsigned short); 2 + 3 + static int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid) 4 + { 5 + int iIndex=0; 6 + 7 + for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) 8 + if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) 9 + return iIndex; 10 + return NO_OF_QUEUES+1; 11 + 12 + } 3 13 4 14 5 15 static PUSB_RCB ··· 98 88 if (netif_msg_rx_err(Adapter)) 99 89 pr_info(PFX "%s: corrupted leader length...%d\n", 100 90 Adapter->dev->name, pLeader->PLength); 101 - atomic_inc(&Adapter->RxPacketDroppedCount); 102 - atomic_add(pLeader->PLength, &Adapter->BadRxByteCount); 91 + ++Adapter->dev->stats.rx_dropped; 103 92 atomic_dec(&psIntfAdapter->uNumRcbUsed); 104 93 return; 105 94 } ··· 151 142 skb_put (skb, pLeader->PLength + ETH_HLEN); 152 143 Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength; 153 144 Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes+= pLeader->PLength; 154 - atomic_add(pLeader->PLength, &Adapter->GoodRxByteCount); 155 145 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Recived Data pkt of len :0x%X", pLeader->PLength); 156 146 157 147 if(netif_running(Adapter->dev)) ··· 180 172 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB..."); 181 173 dev_kfree_skb(skb); 182 174 } 183 - atomic_inc(&Adapter->GoodRxPktCount); 175 + 176 + ++Adapter->dev->stats.rx_packets; 177 + Adapter->dev->stats.rx_bytes += pLeader->PLength; 178 + 184 179 for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) 185 180 { 186 181 if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1))
-2
drivers/staging/bcm/Misc.c
··· 1859 1859 1860 1860 dev_kfree_skb(PacketToDrop); 1861 1861 atomic_dec(&Adapter->TotalPacketCount); 1862 - atomic_inc(&Adapter->TxDroppedPacketCount); 1863 - 1864 1862 } 1865 1863 } 1866 1864 spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
-2
drivers/staging/bcm/Prototypes.h
··· 93 93 94 94 int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo); 95 95 96 - int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid); 97 - 98 96 void CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, 99 97 CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex); 100 98
+7 -6
drivers/staging/bcm/Qos.c
··· 359 359 360 360 if(PacketToDrop) 361 361 { 362 + struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, iIndex); 362 363 if (netif_msg_tx_err(Adapter)) 363 364 pr_info(PFX "%s: tx queue %d overlimit\n", 364 365 Adapter->dev->name, iIndex); 365 366 366 - netstats->tx_dropped++; 367 - atomic_inc(&Adapter->TxDroppedPacketCount); 367 + txq->tx_dropped++; 368 + 368 369 DEQUEUEPACKET(Adapter->PackInfo[iIndex].FirstTxQueue, 369 370 Adapter->PackInfo[iIndex].LastTxQueue); 370 371 /// update current bytes and packets count ··· 398 397 { 399 398 INT iQIndex; 400 399 UINT uiTotalPacketLength; 401 - struct sk_buff* PacketToDrop=NULL; 402 - struct net_device_stats* netstats=&Adapter->dev->stats; 400 + struct sk_buff* PacketToDrop=NULL; 403 401 404 402 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); 405 403 406 404 // down(&Adapter->data_packet_queue_lock); 407 405 for(iQIndex=LowPriority; iQIndex<HiPriority; iQIndex++) 408 406 { 407 + struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, iQIndex); 408 + 409 409 spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); 410 410 while(Adapter->PackInfo[iQIndex].FirstTxQueue) 411 411 { ··· 414 412 if(PacketToDrop) 415 413 { 416 414 uiTotalPacketLength = PacketToDrop->len; 417 - netstats->tx_dropped++; 418 - atomic_inc(&Adapter->TxDroppedPacketCount); 415 + txq->tx_dropped++; 419 416 } 420 417 else 421 418 uiTotalPacketLength = 0;
+10 -11
drivers/staging/bcm/Transmit.c
··· 90 90 int status=0; 91 91 BOOLEAN bHeaderSupressionEnabled = FALSE; 92 92 B_UINT16 uiClassifierRuleID; 93 - int QueueIndex = NO_OF_QUEUES + 1; 93 + u16 QueueIndex = skb_get_queue_mapping(Packet); 94 94 LEADER Leader={0}; 95 95 96 96 if(Packet->len > MAX_DEVICE_DESC_SIZE) ··· 101 101 102 102 /* Get the Classifier Rule ID */ 103 103 uiClassifierRuleID = *((UINT32*) (Packet->cb)+SKB_CB_CLASSIFICATION_OFFSET); 104 - QueueIndex = SearchVcid( Adapter,Vcid); 105 - if(QueueIndex < NO_OF_QUEUES) 106 - { 107 - bHeaderSupressionEnabled = 108 - Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled; 109 - bHeaderSupressionEnabled = 110 - bHeaderSupressionEnabled & Adapter->bPHSEnabled; 111 - } 104 + 105 + bHeaderSupressionEnabled = Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled 106 + & Adapter->bPHSEnabled; 107 + 112 108 if(Adapter->device_removed) 113 109 { 114 110 status = STATUS_FAILURE; ··· 158 162 } 159 163 else 160 164 { 165 + struct netdev_queue *txq = netdev_get_tx_queue(Adapter->dev, QueueIndex); 161 166 Adapter->PackInfo[QueueIndex].uiTotalTxBytes += Leader.PLength; 162 - Adapter->dev->stats.tx_bytes += Leader.PLength; 163 - ++Adapter->dev->stats.tx_packets; 167 + 168 + txq->tx_bytes += Leader.PLength; 169 + ++txq->tx_packets; 170 + 164 171 Adapter->PackInfo[QueueIndex].uiCurrentTokenCount -= Leader.PLength << 3; 165 172 Adapter->PackInfo[QueueIndex].uiSentBytes += (Packet->len); 166 173 Adapter->PackInfo[QueueIndex].uiSentPackets++;
+2 -5
drivers/staging/bcm/hostmibs.c
··· 82 82 } 83 83 84 84 85 - 86 85 //copy other Host Statistics parameters 87 - pstHostMibs->stHostInfo.GoodTransmits = 88 - atomic_read(&Adapter->TxTotalPacketCount); 89 - pstHostMibs->stHostInfo.GoodReceives = 90 - atomic_read(&Adapter->GoodRxPktCount); 86 + pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets; 87 + pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets; 91 88 pstHostMibs->stHostInfo.CurrNumFreeDesc = 92 89 atomic_read(&Adapter->CurrNumFreeTxDesc); 93 90 pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;
+6 -4
drivers/staging/bcm/led_control.c
··· 108 108 ulong timeout = 0; 109 109 110 110 /*Read initial value of packets sent/received */ 111 - Initial_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); 112 - Initial_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); 111 + Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets; 112 + Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets; 113 + 113 114 /*Scale the rate of transfer to no of blinks.*/ 114 115 num_of_time_tx= ScaleRateofTransfer((ULONG)rate_of_transfer_tx); 115 116 num_of_time_rx= ScaleRateofTransfer((ULONG)rate_of_transfer_rx); ··· 213 212 * Read the Tx & Rx packets transmission after 1 second and 214 213 * calculate rate of transfer 215 214 */ 216 - Final_num_of_packts_tx = atomic_read(&Adapter->TxTotalPacketCount); 215 + Final_num_of_packts_tx = Adapter->dev->stats.tx_packets; 216 + Final_num_of_packts_rx = Adapter->dev->stats.rx_packets; 217 + 217 218 rate_of_transfer_tx = Final_num_of_packts_tx - Initial_num_of_packts_tx; 218 - Final_num_of_packts_rx = atomic_read(&Adapter->GoodRxPktCount); 219 219 rate_of_transfer_rx = Final_num_of_packts_rx - Initial_num_of_packts_rx; 220 220 221 221 /*Read initial value of packets sent/received */