64-bit network statistics - drivers
RFC PATCH 2/5 64-bit network statistics - drivers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
64-bit network statistics:
Part 2 of 5 - drivers
- --
Don't drink and derive. Alcohol and algebra don't mix.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/BOciwFP0+seVj/4RAk6zAJ0db2Hc02GsOSPkWpklLGf6LYSyYwCg1qHY xllKUhFZogSgQQZyaSF4ARg=
=3/AN
-----END PGP SIGNATURE-----
drivers/net/8139too.c +27 -22
@@ -82,6 +82,8 @@ Robert Kuebel - Save kernel thread from dying on any signal. + Josef "Jeff" Sipek - new network statistics API support + Submitting bug reports:"rtl8139-diag -mmmaaavvveefN" output
@@ -962,6 +964,9 @@ ((u16 *) (dev->dev_addr))[i] =le16_to_cpu (read_eeprom (ioaddr, i +7 , addr_len)); +/* Init net_device_stats struct */ +net_stats_init (&((struct rtl8139_private *) dev->priv)->stats); +/* The Rtl8139-specific entries in the device structure. */ dev->open = rtl8139_open; dev->hard_start_xmit = rtl8139_start_xmit;
@@ -1686,7 +1691,7 @@dev_kfree_skb (skb); }else {dev_kfree_skb (skb); - tp->stats.tx_dropped++; +net_stats_inc (tx_dropped,&tp->stats);return 0 ; }
@@ -1737,27 +1742,27 @@/* There was an major error, log it. */ DPRINTK ("%s: Transmit error, Tx status %8.8x.\n" , dev->name, txstatus); - tp->stats.tx_errors++; +net_stats_inc (tx_errors,&tp->stats);if (txstatus & TxAborted) { - tp->stats.tx_aborted_errors++; +net_stats_inc (tx_aborted_errors,&tp->stats);RTL_W32 (TxConfig, TxClearAbt);RTL_W16 (IntrStatus, TxErr);wmb (); }if (txstatus & TxCarrierLost) - tp->stats.tx_carrier_errors++; +net_stats_inc (tx_carrier_errors,&tp->stats);if (txstatus & TxOutOfWindow) - tp->stats.tx_window_errors++; +net_stats_inc (tx_window_errors,&tp->stats); }else {if (txstatus & TxUnderrun) {/* Add 64 to the Tx FIFO threshold. */ if (tp->tx_flag <0x00300000 ) tp->tx_flag +=0x00020000 ; - tp->stats.tx_fifo_errors++; +net_stats_inc (tx_fifo_errors,&tp->stats); } - tp->stats.collisions += (txstatus >>24 ) &15 ; - tp->stats.tx_bytes += txstatus &0x7ff ; - tp->stats.tx_packets++; +net_stats_add (collisions,&tp->stats,(txstatus >>24 ) &15 ); +net_stats_add (tx_bytes,&tp->stats,txstatus &0x7ff ); +net_stats_inc (tx_packets,&tp->stats); } dirty_tx++;
@@ -1793,7 +1798,7 @@DPRINTK ("%s: Ethernet frame had errors, status %8.8x.\n" , dev->name, rx_status); - tp->stats.rx_errors++; +net_stats_inc (rx_errors,&tp->stats);if (!(rx_status & RxStatusOK)) {if (rx_status & RxTooLong) { DPRINTK ("%s: Oversized Ethernet frame, status %4.4x!\n",
@@ -1801,11 +1806,11 @@/* A.C.: The chip hangs here. */ }if (rx_status & (RxBadSymbol | RxBadAlign)) - tp->stats.rx_frame_errors++; +net_stats_inc (rx_frame_errors,&tp->stats);if (rx_status & (RxRunt | RxTooLong)) - tp->stats.rx_length_errors++; +net_stats_inc (rx_length_errors,&tp->stats);if (rx_status & RxCRCErr) - tp->stats.rx_crc_errors++; +net_stats_inc (rx_crc_errors,&tp->stats); }else { tp->xstats.rx_lost_in_ring++; }
@@ -1951,13 +1956,13 @@ skb->protocol =eth_type_trans (skb, dev);netif_rx (skb); dev->last_rx = jiffies; - tp->stats.rx_bytes += pkt_size; - tp->stats.rx_packets++; +net_stats_add (rx_bytes,&tp->stats,pkt_size); +net_stats_inc (rx_packets,&tp->stats); }else {printk (KERN_WARNING "%s: Memory squeeze, dropping packet.\n" , dev->name); - tp->stats.rx_dropped++; +net_stats_inc (rx_dropped,&tp->stats); } cur_rx = (cur_rx + rx_size +4 +3 ) & ~3 ;
@@ -1989,7 +1994,7 @@assert (ioaddr !=NULL );/* Update the error count. */ - tp->stats.rx_missed_errors +=RTL_R32 (RxMissed); +net_stats_add (rx_missed_errors,&tp->stats,RTL_R32 (RxMissed));RTL_W32 (RxMissed,0 ); if ((status & RxUnderrun) && link_changed &&
@@ -2012,12 +2017,12 @@/* XXX along with rtl8139_rx_err, are we double-counting errors? */ if (status & (RxUnderrun | RxOverflow | RxErr | RxFIFOOver)) - tp->stats.rx_errors++; +net_stats_inc (rx_errors,&tp->stats);if (status & PCSTimeout) - tp->stats.rx_length_errors++; +net_stats_inc (rx_length_errors,&tp->stats);if (status & (RxUnderrun | RxFIFOOver)) - tp->stats.rx_fifo_errors++; +net_stats_inc (rx_fifo_errors,&tp->stats);if (status & PCIErr) {u16 pci_cmd_status;pci_read_config_word (tp->pci_dev,PCI_STATUS , &pci_cmd_status);
@@ -2138,7 +2143,7 @@RTL_W16 (IntrMask,0 );/* Update the error counts. */ - tp->stats.rx_missed_errors +=RTL_R32 (RxMissed); +net_stats_add (rx_missed_errors,&tp->stats,RTL_R32 (RxMissed));RTL_W32 (RxMissed,0 );spin_unlock_irqrestore (&tp->lock, flags);
@@ -2473,7 +2478,7 @@if (netif_running (dev)) {spin_lock_irqsave (&tp->lock, flags); - tp->stats.rx_missed_errors +=RTL_R32 (RxMissed); +net_stats_add (rx_missed_errors,&tp->stats,RTL_R32 (RxMissed));RTL_W32 (RxMissed,0 );spin_unlock_irqrestore (&tp->lock, flags); }
drivers/net/8390.c +37 -33
179 lines not on this page · raw message
drivers/net/dummy.c +8 -2
@@ -26,6 +26,8 @@Nick Holloway, 27th May 1994 [I tweaked this explanation a little but that's all] Alan Cox, 30th May 1994 +Josef "Jeff" Sipek, 2nd July 2003 +added new network statistics API support */ /* To have statistics (just packets sent) define this */
@@ -53,6 +55,9 @@static void __init dummy_setup (struct net_device *dev) { +/* Init net_device_stats struct */ +net_stats_init ((struct net_device_stats *) dev->priv); +/* Initialize the device structure. */ dev->get_stats = dummy_get_stats; dev->hard_start_xmit = dummy_xmit;
@@ -73,8 +78,8 @@ {struct net_device_stats *stats = dev->priv; - stats->tx_packets++; - stats->tx_bytes+=skb->len; +net_stats_inc (tx_packets,stats); +net_stats_add (tx_bytes,stats,skb->len);dev_kfree_skb (skb);return 0 ;
@@ -101,6 +106,7 @@kfree (dev_dummy); dev_dummy =NULL ; } +return err; }
drivers/net/eepro100.c +22 -17
@@ -25,6 +25,8 @@PCI DMA API fixes, adding pci_dma_sync_single calls where neccesary 2000 Aug 31 David Mosberger <[email protected]> rx_align support: enables rx DMA without causing unaligned accesses. +2003 Jul 2 Josef "Jeff" Sipek <[email protected]> +new network statistics API support added */ static const char *version =
@@ -877,6 +879,9 @@if (sp->rx_bug)printk (KERN_INFO " Receiver lock-up workaround activated.\n" ); +/* Init net_device_stats struct */ +net_stats_init (&sp->stats); +/* The Speedo-specific entries in the device structure. */ dev->open = &speedo_open; dev->hard_start_xmit = &speedo_start_xmit;
@@ -1336,7 +1341,7 @@while ((int )(sp->cur_tx - sp->dirty_tx) >0 ) { entry = sp->dirty_tx %TX_RING_SIZE ;if (sp->tx_skbuff[entry]) { - sp->stats.tx_errors++; +net_stats_inc (tx_errors,&sp->stats);pci_unmap_single (sp->pdev,le32_to_cpu (sp->tx_ring[entry].tx_buf_addr0), sp->tx_skbuff[entry]->len,PCI_DMA_TODEVICE );
@@ -1539,8 +1544,8 @@ }/* Free the original skb. */ if (sp->tx_skbuff[entry]) { - sp->stats.tx_packets++;/* Count only user packets. */ - sp->stats.tx_bytes += sp->tx_skbuff[entry]->len; +net_stats_inc (tx_packets,&sp->stats);/* Count only user packets. */ +net_stats_add (tx_bytes,&sp->stats,sp->tx_skbuff[entry]->len);pci_unmap_single (sp->pdev,le32_to_cpu (sp->tx_ring[entry].tx_buf_addr0), sp->tx_skbuff[entry]->len,PCI_DMA_TODEVICE );
@@ -1815,7 +1820,7 @@ "status %8.8x!\n", dev->name, status); else if (! (status & RxOK)) {/* There was a fatal error. This *should* be impossible. */ - sp->stats.rx_errors++; +net_stats_inc (rx_errors,&sp->stats);printk (KERN_ERR "%s: Anomalous event in speedo_rx(), " "status %8.8x.\n" , dev->name, status);
@@ -1860,8 +1865,8 @@ skb->protocol =eth_type_trans (skb, dev);netif_rx (skb); dev->last_rx = jiffies; - sp->stats.rx_packets++; - sp->stats.rx_bytes += pkt_len; +net_stats_inc (rx_packets,&sp->stats); +net_stats_add (rx_bytes,&sp->stats,pkt_len); } entry = (++sp->cur_rx) %RX_RING_SIZE ; sp->rx_ring_state &= ~RrPostponed;
@@ -1967,17 +1972,17 @@/* Update only if the previous dump finished. */ if (sp->lstats->done_marker ==le32_to_cpu (0xA007 )) { - sp->stats.tx_aborted_errors +=le32_to_cpu (sp->lstats->tx_coll16_errs); - sp->stats.tx_window_errors +=le32_to_cpu (sp->lstats->tx_late_colls); - sp->stats.tx_fifo_errors +=le32_to_cpu (sp->lstats->tx_underruns); - sp->stats.tx_fifo_errors +=le32_to_cpu (sp->lstats->tx_lost_carrier); -/*sp->stats.tx_deferred += le32_to_cpu(sp->lstats->tx_deferred);*/ - sp->stats.collisions +=le32_to_cpu (sp->lstats->tx_total_colls); - sp->stats.rx_crc_errors +=le32_to_cpu (sp->lstats->rx_crc_errs); - sp->stats.rx_frame_errors +=le32_to_cpu (sp->lstats->rx_align_errs); - sp->stats.rx_over_errors +=le32_to_cpu (sp->lstats->rx_resource_errs); - sp->stats.rx_fifo_errors +=le32_to_cpu (sp->lstats->rx_overrun_errs); - sp->stats.rx_length_errors +=le32_to_cpu (sp->lstats->rx_runt_errs); +net_stats_add (tx_aborted_errors,&sp->stats,le32_to_cpu (sp->lstats->tx_coll16_errs)); +net_stats_add (tx_window_errors,&sp->stats,le32_to_cpu (sp->lstats->tx_late_colls)); +net_stats_add (tx_fifo_errors,&sp->stats,le32_to_cpu (sp->lstats->tx_underruns)); +net_stats_add (tx_fifo_errors,&sp->stats,le32_to_cpu (sp->lstats->tx_lost_carrier)); +/*net_stats_add(tx_defered,&sp->stats,le32_to_cpu(sp->lstats->tx_deferred));*/ +net_stats_add (collisions,&sp->stats,le32_to_cpu (sp->lstats->tx_total_colls)); +net_stats_add (rx_crc_errors,&sp->stats,le32_to_cpu (sp->lstats->rx_crc_errs)); +net_stats_add (rx_frame_errors,&sp->stats,le32_to_cpu (sp->lstats->rx_align_errs)); +net_stats_add (rx_over_errors,&sp->stats,le32_to_cpu (sp->lstats->rx_resource_errs)); +net_stats_add (rx_fifo_errors,&sp->stats,le32_to_cpu (sp->lstats->rx_overrun_errs)); +net_stats_add (rx_length_errors,&sp->stats,le32_to_cpu (sp->lstats->rx_runt_errs)); sp->lstats->done_marker =0x0000 ;if (netif_running (dev)) {unsigned long flags;
drivers/net/loopback.c +11 -4
@@ -10,6 +10,7 @@* Authors: Ross Biro, <[email protected]> * Fred N. van Kempen, <[email protected]> * Donald Becker, <[email protected]> +* Josef "Jeff" Sipek, <[email protected]> * * Alan Cox : Fixed oddments for NET3.014 * Alan Cox : Rejig for NET3.029 snap #3
@@ -22,6 +23,8 @@* interface. * Alexey Kuznetsov: Potential hang under some extreme * cases removed. +* Josef "Jeff" Sipek: Added support for net network +statistics API * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License
@@ -160,10 +163,10 @@ } dev->last_rx = jiffies; - stats->rx_bytes+=skb->len; - stats->tx_bytes+=skb->len; - stats->rx_packets++; - stats->tx_packets++; +net_stats_add (rx_bytes,stats,skb->len); +net_stats_add (tx_bytes,stats,skb->len); +net_stats_inc (rx_packets,stats); +net_stats_inc (tx_packets,stats);netif_rx (skb);
@@ -200,6 +203,10 @@if (dev->priv ==NULL )return -ENOMEM ;memset (dev->priv,0 ,sizeof (struct net_device_stats )); + +/* Init net_device_stats struct */ +net_stats_init ((struct net_device_stats *) dev->priv); + dev->get_stats = get_stats;/*
drivers/net/pcnet32.c +33 -23
151 lines not on this page · raw message