kernels/linux-2.4.0/drivers/net/tlan.c
/***************************************************************
	 *	TLan_ReadAndClearStats
	 *
	 *	Returns:
	 *		Nothing
	 *	Parms:
	 *		dev	Pointer to device structure of adapter
	 *			to which to read stats.
	 *		record	Flag indicating whether to add 
	 *
	 *	This functions reads all the internal status registers
	 *	of the TLAN chip, which clears them as a side effect.
	 *	It then either adds the values to the device's status
	 *	struct, or discards them, depending on whether record
	 *	is TLAN_RECORD (!=0)  or TLAN_IGNORE (==0).
	 *
	 **************************************************************/
TLan_ReadAndClearStats
Returns:
Nothing
Parms:
dev     Pointer to device structure of adapter
to which to read stats.
record  Flag indicating whether to add

This functions reads all the internal status registers
of the TLAN chip, which clears them as a side effect.
It then either adds the values to the device's status
struct, or discards them, depending on whether record
is TLAN_RECORD (!=0)  or TLAN_IGNORE (==0).
TLan_ReadAndClearStats Returns : Nothing Parms : dev Pointer to device structure of adapter to which to read stats . record Flag indicating whether to add This functions reads all the internal status registers of the TLAN chip which clears them as a side effect . It then either adds the values to the device ' s status struct or discards them depending on whether record is TLAN_RECORD ( ! = 0 ) or TLAN_IGNORE ( == 0 ) .
void TLan_ReadAndClearStats( struct net_device *dev, int record )
{
	TLanPrivateInfo	*priv = (TLanPrivateInfo *) dev->priv;
	u32		tx_good, tx_under;
	u32		rx_good, rx_over;
	u32		def_tx, crc, code;
	u32		multi_col, single_col;
	u32		excess_col, late_col, loss;
	outw( TLAN_GOOD_TX_FRMS, dev->base_addr + TLAN_DIO_ADR );
	tx_good  = inb( dev->base_addr + TLAN_DIO_DATA );
	tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
	tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16;
	tx_under = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
	outw( TLAN_GOOD_RX_FRMS, dev->base_addr + TLAN_DIO_ADR );
	rx_good  = inb( dev->base_addr + TLAN_DIO_DATA );
	rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
	rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16;
	rx_over  = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
	outw( TLAN_DEFERRED_TX, dev->base_addr + TLAN_DIO_ADR );
	def_tx  = inb( dev->base_addr + TLAN_DIO_DATA );
	def_tx += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
	crc     = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
	code    = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
	outw( TLAN_MULTICOL_FRMS, dev->base_addr + TLAN_DIO_ADR );
	multi_col   = inb( dev->base_addr + TLAN_DIO_DATA );
	multi_col  += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
	single_col  = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
	single_col += inb( dev->base_addr + TLAN_DIO_DATA + 3 ) << 8;
	outw( TLAN_EXCESSCOL_FRMS, dev->base_addr + TLAN_DIO_ADR );
	excess_col = inb( dev->base_addr + TLAN_DIO_DATA );
	late_col   = inb( dev->base_addr + TLAN_DIO_DATA + 1 );
	loss       = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
	if ( record ) {
		priv->stats.rx_packets += rx_good;
		priv->stats.rx_errors  += rx_over + crc + code;
		priv->stats.tx_packets += tx_good;
		priv->stats.tx_errors  += tx_under + loss;
		priv->stats.collisions += multi_col + single_col + excess_col + late_col;
		priv->stats.rx_over_errors    += rx_over;
		priv->stats.rx_crc_errors     += crc;
		priv->stats.rx_frame_errors   += code;
		priv->stats.tx_aborted_errors += tx_under;
		priv->stats.tx_carrier_errors += loss;
	}
}
void TLan_ReadAndClearStats ( struct net_device * dev , int record ) { TLanPrivateInfo * priv = ( TLanPrivateInfo * ) dev -> priv ; u32 tx_good , tx_under ; u32 rx_good , rx_over ; u32 def_tx , crc , code ; u32 multi_col , single_col ; u32 excess_col , late_col , loss ; outw ( TLAN_GOOD_TX_FRMS , dev -> base_addr + TLAN_DIO_ADR ) ; tx_good = inb ( dev -> base_addr + TLAN_DIO_DATA ) ; tx_good += inb ( dev -> base_addr + TLAN_DIO_DATA + 1 ) << 8 ; tx_good += inb ( dev -> base_addr + TLAN_DIO_DATA + 2 ) << 16 ; tx_under = inb ( dev -> base_addr + TLAN_DIO_DATA + 3 ) ; outw ( TLAN_GOOD_RX_FRMS , dev -> base_addr + TLAN_DIO_ADR ) ; rx_good = inb ( dev -> base_addr + TLAN_DIO_DATA ) ; rx_good += inb ( dev -> base_addr + TLAN_DIO_DATA + 1 ) << 8 ; rx_good += inb ( dev -> base_addr + TLAN_DIO_DATA + 2 ) << 16 ; rx_over = inb ( dev -> base_addr + TLAN_DIO_DATA + 3 ) ; outw ( TLAN_DEFERRED_TX , dev -> base_addr + TLAN_DIO_ADR ) ; def_tx = inb ( dev -> base_addr + TLAN_DIO_DATA ) ; def_tx += inb ( dev -> base_addr + TLAN_DIO_DATA + 1 ) << 8 ; crc = inb ( dev -> base_addr + TLAN_DIO_DATA + 2 ) ; code = inb ( dev -> base_addr + TLAN_DIO_DATA + 3 ) ; outw ( TLAN_MULTICOL_FRMS , dev -> base_addr + TLAN_DIO_ADR ) ; multi_col = inb ( dev -> base_addr + TLAN_DIO_DATA ) ; multi_col += inb ( dev -> base_addr + TLAN_DIO_DATA + 1 ) << 8 ; single_col = inb ( dev -> base_addr + TLAN_DIO_DATA + 2 ) ; single_col += inb ( dev -> base_addr + TLAN_DIO_DATA + 3 ) << 8 ; outw ( TLAN_EXCESSCOL_FRMS , dev -> base_addr + TLAN_DIO_ADR ) ; excess_col = inb ( dev -> base_addr + TLAN_DIO_DATA ) ; late_col = inb ( dev -> base_addr + TLAN_DIO_DATA + 1 ) ; loss = inb ( dev -> base_addr + TLAN_DIO_DATA + 2 ) ; if ( record ) { priv -> stats . rx_packets += rx_good ; priv -> stats . rx_errors += rx_over + crc + code ; priv -> stats . tx_packets += tx_good ; priv -> stats . tx_errors += tx_under + loss ; priv -> stats . collisions += multi_col + single_col + excess_col + late_col ; priv -> stats . rx_over_errors += rx_over ; priv -> stats . rx_crc_errors += crc ; priv -> stats . rx_frame_errors += code ; priv -> stats . tx_aborted_errors += tx_under ; priv -> stats . tx_carrier_errors += loss ; } }
TLan_ReadAndClearStats
      Returns:
              Nothing
      Parms:
              dev     Pointer to device structure of adapter
                      to which to read stats.
TLan_ReadAndClearStats Returns : Nothing Parms : dev Pointer to device structure of adapter to which to read stats .