From nobody@FreeBSD.org  Mon Feb  3 08:13:05 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id AA5FCA01
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Feb 2014 08:13:05 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 953361A23
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Feb 2014 08:13:05 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id s138D5iR027152
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 3 Feb 2014 08:13:05 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id s138D5uh027151;
	Mon, 3 Feb 2014 08:13:05 GMT
	(envelope-from nobody)
Message-Id: <201402030813.s138D5uh027151@oldred.freebsd.org>
Date: Mon, 3 Feb 2014 08:13:05 GMT
From: Marcin Kucharczyk <marcinkk@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Problem with RTL8111/8168B initialization
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         186401
>Category:       kern
>Synopsis:       [re] Problem with RTL8111/8168B initialization
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    yongari
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 03 08:20:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Tue Feb 11 01:40:01 UTC 2014
>Originator:     Marcin Kucharczyk
>Release:        FreeBSD 10.0 RELEASE amd64
>Organization:
Silesian University of Technology
>Environment:
FreeBSD sklab-xx 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The problem is described there: https://forums.freebsd.org/viewtopic.php?f=32&t=22664&p=248509#p248509. I don't know if I can use formating here. The answer on forum sugessts filling bug report, so I've done it.

I've installed FreeBSD 10.0 RELEASE amd64 on new machine: MSI B85M-G43 (MS-7823).

With the following line in rc.conf:

    ifconfig_re0="DHCP"


the Realtek NIC was detected and re(4) driver was initialized but the card can't get IP configuration from DHCP. After boot I can see in ifconfig re0:

    re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
            options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
            ether 44:8a:5b:26:cc:ae
            nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
            media: Ethernet autoselect (1000baseT <full-duplex,master>)
            status: active


The card doesn't have IP and doesn't work. I've tried set IP manually but it didn't help. After reading the posts in mentioned topic I've tried some options. I've logged to the system and make the command ifconfig re0 tso and the card gets IP in few seconds and everything worked fine. So I've changed rc.conf to:

    ifconfig_re0="DHCP tso"


But it didn't help. And I've noticed that any change in one of the 3 parameters suggested on forum to turn off earlier: tso, rxcsum, txcsum changed after login makes the NIC working: ifconfig re0 -rxcsum or ifconfig re0 -txcsum helps too. It could be also -rxcsum inf rc.conf and ifconfig re0 rxcsum after login. And so on...

pciconf says:

    re0@pci0:2:0:0: class=0x020000 card=0x78231462 chip=0x816810ec rev=0x0c hdr=0x00
        vendor     = 'Realtek Semiconductor Co., Ltd.'
        device     = 'RTL8111/8168B PCI Express Gigabit Ethernet controller'
        class      = network
        subclass   = ethernet
        bar   [10] = type I/O Port, range 32, base 0xe000, size 256, enabled
        bar   [18] = type Memory, range 64, base 0xf7c00000, size 4096, enabled
        bar   [20] = type Prefetchable Memory, range 64, base 0xf0000000, size 16384, enabled
        cap 01[40] = powerspec 3  supports D0 D1 D2 D3  current D0
        cap 05[50] = MSI supports 1 message, 64 bit
        cap 10[70] = PCI-Express 2 endpoint IRQ 1 max data 128(128) link x1(x1)
                     speed 2.5(2.5) ASPM disabled(L0s/L1)
        cap 11[b0] = MSI-X supports 4 messages, enabled
                     Table in map 0x20[0x0], PBA in map 0x20[0x800]
        cap 03[d0] = VPD
        ecap 0001[100] = AER 1 0 fatal 0 non-fatal 0 corrected
        ecap 0002[140] = VC 1 max VC0
        ecap 0003[160] = Serial 1 01000000684ce000
        ecap 0018[170] = LTR 1


So I made a little workaround putting to /etc/rc.local line:

    /sbin/ifconfig re0 tso


And I still have problems on start with the initial communication with DHCP but the interface wakes up after rc.local file is processed and seems to work properly afterwards.

The rc.conf has only:

    ifconfig_re0="DHCP"


How to make it better? Is there a problem with driver initialization?

PS. I've had the same problem while trying to install. The system was installed using USB->Ethernet adapter.
>How-To-Repeat:
Boot the system from CD on the MSI B85M-G43 (MS-7823) motherboard...
>Fix:
Change one of the tso, rxcsum and txcsum parameters for the re0 interface after booting. Maybe any change of the possible interface parameters?

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Feb 4 01:46:14 UTC 2014 
Responsible-Changed-Why:  
reclassify. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=186401 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Wed Feb 5 08:07:04 UTC 2014 
State-Changed-Why:  
Would you show me dmesg output(re(4)/rgephy(4) only)? 


Responsible-Changed-From-To: freebsd-net->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Wed Feb 5 08:07:04 UTC 2014 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=186401 

From: Yonghyeon PYUN <pyunyh@gmail.com>
To: Marcin Kucharczyk <marcinkk@gmail.com>
Cc: yongari@freebsd.org, bug-followup@FreeBSD.org
Subject: Re: kern/186401: [re] Problem with RTL8111/8168B initialization
Date: Thu, 6 Feb 2014 09:32:26 +0900

 On Wed, Feb 05, 2014 at 11:25:00AM +0100, Marcin Kucharczyk wrote:
 > I don't know how it works. I've creted bug report and it dissapeared and it
 > came back ...
 > 
 
 Probably
 http://www.freebsd.org/doc/en_US.ISO8859-1/articles/problem-reports/article.html
 shall answer your question.
 I also added bug-followup@FreeBSD.org to CC list in order to make
 GNATS track this mail.
 
 > I found the message: "Would you show me dmesg output(re(4)/rgephy(4)
 > only)?"
 > 
 > As I understood this is required:
 > 
 > # dmesg | grep rgephy0
 > rgephy0: <RTL8251 1000BASE-T media interface> PHY 1 on miibus0
 > rgephy0:  none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX,
 > 100baseTX-FDX, 100baseTX-FDX-flow, 1000baseT-FDX, 1000baseT-FDX-master,
 > 1000baseT-FDX-flow, 1000baseT-FDX-flow-master, auto, auto-flow
 > 
 > # dmesg | grep re0
 > re0: <RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet> port
 > 0xe000-0xe0ff mem 0xf7c00000-0xf7c00fff,0xf0000000-0xf0003fff irq 16 at
 > device 0.0 on pci2
 > re0: Using 1 MSI-X message
 > re0: Chip rev. 0x4c000000
 > re0: MAC rev. 0x00000000
 > miibus0: <MII bus> on re0
 > re0: Ethernet address: 44:8a:5b:26:cc:ae
 > re0: link state changed to DOWN
 > re0: link state changed to UP
 > 
 
 Thanks for the information.  It seems your controller is RTL8168G.
 Recently marius@ committed a fix for several RealTek controllers.
 I guess it's worth to try the fix(r261531).  Because there were
 a couple of style changes to re(4), I guess it would be better
 to grab latest re(4) driver source from HEAD and rebuild the driver
 on 10.0-RELEASE.
 
 Grab if_re.c and if_rlreg.h from the following URLs.
 http://svnweb.freebsd.org/base/head/sys/dev/re/if_re.c
 http://svnweb.freebsd.org/base/head/sys/pci/if_rlreg.h
 Use latest revision of the file.
 Copy if_re.c to /usr/src/sys/dev/re directory.
 and copy if_rlreg.h to /usr/src/sys/pci directory and rebuild
 kernel/reboot.
 Of course you may want to save if_re.c and if_rlreg.h files to safe
 place before overwriting them.
 
 Let me know whether latest driver works or not.
 Thanks.

From: Yonghyeon PYUN <pyunyh@gmail.com>
To: Marcin Kucharczyk <marcinkk@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/186401: [re] Problem with RTL8111/8168B initialization
Date: Fri, 7 Feb 2014 13:47:33 +0900

 --EeQfGwPcQSOJBaQU
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Thu, Feb 06, 2014 at 12:43:28PM +0100, Marcin Kucharczyk wrote:
 > 2014-02-06 1:32 GMT+01:00 Yonghyeon PYUN <pyunyh@gmail.com>:
 > 
 > > Grab if_re.c and if_rlreg.h from the following URLs.
 > > http://svnweb.freebsd.org/base/head/sys/dev/re/if_re.c
 > > http://svnweb.freebsd.org/base/head/sys/pci/if_rlreg.h
 > > Use latest revision of the file.
 > > Copy if_re.c to /usr/src/sys/dev/re directory.
 > > and copy if_rlreg.h to /usr/src/sys/pci directory and rebuild
 > > kernel/reboot.
 > > Of course you may want to save if_re.c and if_rlreg.h files to safe
 > > place before overwriting them.
 > >
 > > Let me know whether latest driver works or not.
 > > Thanks.
 > >
 > 
 > No change: boot, login and no network but after ifconfig re0 tso works
 > fine...
 > 
 
 Thanks for testing.  Could you try attached patch?
 
 > Regards, Marcin
 
 --EeQfGwPcQSOJBaQU
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="re.stopreq.diff"
 
 Index: sys/dev/re/if_re.c
 ===================================================================
 --- sys/dev/re/if_re.c	(revision 261531)
 +++ sys/dev/re/if_re.c	(working copy)
 @@ -3595,8 +3595,7 @@ re_stop(struct rl_softc *sc)
  			    "stopping TX poll timed out!\n");
  		CSR_WRITE_1(sc, RL_COMMAND, 0x00);
  	} else if ((sc->rl_flags & RL_FLAG_CMDSTOP) != 0) {
 -		CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_STOPREQ | RL_CMD_TX_ENB |
 -		    RL_CMD_RX_ENB);
 +		CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_STOPREQ);
  		if ((sc->rl_flags & RL_FLAG_CMDSTOP_WAIT_TXQ) != 0) {
  			for (i = RL_TIMEOUT; i > 0; i--) {
  				if ((CSR_READ_4(sc, RL_TXCFG) &
 
 --EeQfGwPcQSOJBaQU--

From: Richard R <richardr@gmx.co.uk>
To: bug-followup@FreeBSD.org, marcinkk@gmail.com
Cc:  
Subject: Re: kern/186401: [re] Problem with RTL8111/8168B initialization
Date: Tue, 11 Feb 2014 01:31:42 +0000

 I have what I believe is the same problem as Marcin. The interface
 despite being shown in ifconfig does not function until I take it down
 and then bring it back up. I have recompiled my kernel using the re
 driver from HEAD and then again with the patch applied and neither
 solved my problem.
 
 output of pciconf -lbev:
 re0@pci0:1:0:0: class=0x020000 card=0x77211462 chip=0x816810ec rev=0x06
 hdr=0x00
     vendor     = 'Realtek Semiconductor Co., Ltd.'
     device     = 'RTL8111/8168B PCI Express Gigabit Ethernet controller'
     class      = network
     subclass   = ethernet
     bar   [10] = type I/O Port, range 32, base 0xe000, size 256, enabled
     bar   [18] = type Prefetchable Memory, range 64, base 0xd0004000,
 size 4096, enabled
     bar   [20] = type Prefetchable Memory, range 64, base 0xd0000000,
 size 16384, enabled
      Corrected = Advisory Non-Fatal Error
>Unformatted:
