From nobody@FreeBSD.org  Tue Feb 26 00:50:50 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 1B9D437B41E
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Feb 2002 00:50:19 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g1Q8oJP08843;
	Tue, 26 Feb 2002 00:50:19 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200202260850.g1Q8oJP08843@freefall.freebsd.org>
Date: Tue, 26 Feb 2002 00:50:19 -0800 (PST)
From: Pavel Plesov <mclap@ulstu.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Increase of the counter of collisions at use of the device rl0
X-Send-Pr-Version: www-1.0

>Number:         35339
>Category:       kern
>Synopsis:       Increase of the counter of collisions at use of the device rl0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    danny
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 26 01:00:08 PST 2002
>Closed-Date:    Thu Mar 14 21:09:53 PST 2002
>Last-Modified:  Thu Mar 14 21:09:53 PST 2002
>Originator:     Pavel Plesov
>Release:        4.5-RELEASE
>Organization:
Ulyanovsk State Technical University, ICC420
>Environment:
FreeBSD sp.simtts.mv.ru 4.5-RELEASE FreeBSD 4.5-RELEASE #1: Wed Feb  6 17:48:58 MSK 2002 root@install.tts.local:/usr/src/sys/compile/O1/i386              
>Description:
      I use network card D-Link DFE-530TX+. After network traffic (file transfer) I get collision counter to fast increase (in output of netstat -ni) with no "Oerrs" reported. media 10baseT/UTP.

For first look, as can I suppose, /usr/src/sys/pci/if_rl.c do incorrect count collisions.
For example, in linux driver (ftp://ftp.dlink.com/NIC/dfe530tx/Driver/dfe530tx_driver_101601.exe,
or
ftp://ftp.dlink.com/NIC/dfe530tx+/Driver/dfe530TX+_linux_driver_051801.zip)
 for this card:
---cut---
/* rtl8139.c: A RealTek RTL8129/8139 Fast Ethernet driver for Linux. */
/*
	Written 1997-1999 by Donald Becker.

...
			while (tp->cur_tx - dirty_tx > 0) {
				int entry = dirty_tx % NUM_TX_DESC;
				int txstatus = inl(ioaddr + TxStatus0 + entry*4);

				if ( ! (txstatus & (TxStatOK | TxUnderrun | TxAborted)))
					break;			/* It still hasn't been Txed */

				/* Note: TxCarrierLost is always asserted at 100mbps. */
				if (txstatus & (TxOutOfWindow | TxAborted)) {
					/* There was an major error, log it. */
					if (rtl8129_debug > 1)
						printk(KERN_NOTICE"%s: Transmit error, Tx status %8.8x.\n",
							   dev->name, txstatus);
					tp->stats.tx_errors++;
					if (txstatus&TxAborted) {
						tp->stats.tx_aborted_errors++;
						outl((TX_DMA_BURST<<8)|0x03000001, ioaddr + TxConfig);
					}
					if (txstatus&TxCarrierLost) tp->stats.tx_carrier_errors++;
					if (txstatus&TxOutOfWindow) tp->stats.tx_window_errors++;
#ifdef ETHER_STATS
					if ((txstatus & 0x0f000000) == 0x0f000000)
						tp->stats.collisions16++;
#endif
				} 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++;
					}
					tp->stats.collisions += (txstatus >> 24) & 15;
#if LINUX_VERSION_CODE > 0x20119
					tp->stats.tx_bytes += txstatus & 0x7ff;
#endif
					tp->stats.tx_packets++;
				}

				/* Free the original skb. */
				dev_free_skb(tp->tx_skbuff[entry]);
				tp->tx_skbuff[entry] = 0;
				if (test_bit(0, &tp->tx_full)) {
					/* The ring is no longer full, clear tbusy. */
					clear_bit(0, &tp->tx_full);
					clear_bit(0, (void*)&dev->tbusy);
					mark_bh(NET_BH);
				}
				dirty_tx++;
			}
---cut---

And, under FreeBSD, in /usr/src/sys/pci/if_rl.c
We get:

---cut---
	do {
		txstat = CSR_READ_4(sc, RL_LAST_TXSTAT(sc));
		if (!(txstat & (RL_TXSTAT_TX_OK|
		    RL_TXSTAT_TX_UNDERRUN|RL_TXSTAT_TXABRT)))
			break;

		ifp->if_collisions += (txstat & RL_TXSTAT_COLLCNT) >> 24;

---cut---
>How-To-Repeat:
      FTP/Samba file transfer.
>Fix:
      
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: silby 
State-Changed-When: Tue Mar 5 23:06:50 PST 2002 
State-Changed-Why:  
Please see if updating to rlphy.c rev 1.6 fixes this problem. 
If PR 35435 is correct, those collisions probably are really 
happening. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35339 
Responsible-Changed-From-To: freebsd-bugs->danny 
Responsible-Changed-By: silby 
Responsible-Changed-When: Tue Mar 5 23:13:31 PST 2002 
Responsible-Changed-Why:  
I already assigned two related PRs to danny, I might as well 
do so for all of them. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35339 
State-Changed-From-To: feedback->closed 
State-Changed-By: silby 
State-Changed-When: Thu Mar 14 21:08:53 PST 2002 
State-Changed-Why:  
Pavel reports that the recent patch to rlphy fixes his problem, 
closing the PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35339 
>Unformatted:
