# Replacing realtek "re" driver



## jjlawren (Apr 14, 2016)

I've installed 10.2 (since upgraded to 10.3) on a low-power integrated board (http://www.asrock.com/mb/Intel/N3150DC-ITX). I want to use it as a backup host, receiving ZFS snapshots from another box and storing to an external USB3 drive. However, the network has been very unstable with poor throughput and many NIC driver restarts (ie, "re0: watchdog timeout"). It has no expansion slots, so a replacement NIC is not an option.

I've read in several posts that the Realtek drivers are more stable than the built-in kernel drivers. However, I'm really not sure how to go about this. This post seems to describe what I'm trying to do, but I cannot compile the driver.

Steps I've taken:

Installed 'base' under /usr/src
Compiled with 'make buildworld' (which took almost a day on this hardware)
Downloaded Realtek drivers and tried to compile (from outside the kernel sources)
This fails with the following errors:

```
root@myhost:~/realtek/rtl_bsd_drv_v190 # make
make: "/sys/conf/kmod.mk" line 461: Could not find bsd.clang-analyze.mk
make: Fatal errors encountered -- cannot continue
make: stopped in /root/realtek/rtl_bsd_drv_v190
```
Do I need to update the makefile to point to the kernel sources?


----------



## wblock@ (Apr 14, 2016)

jjlawren said:


> I've read in several posts that the Realtek drivers are more stable than the built-in kernel drivers.


I would like to know more about that.  But then, it's news to me that Realtek even has their own version of a driver.

bsd.clang-analyze.mk appears to only be present in 11-CURRENT.


----------



## jjlawren (Apr 14, 2016)

wblock@ said:


> bsd.clang-analyze.mk appears to only be present in 11-CURRENT.


Great catch. I switched to the stable/10 branch. I'm now able to build, but not load the module:

```
KLD if_ree.ko: depends on kernel - not available or version mismatch
linker_load_file: Unsupported file type
```
Perhaps I have to use the release/10.3.0 branch explicitly? I'm not using a custom kernel.

Edit: Yep, loads just fine when using the actual release branch. Now to test!


----------



## ondra_knezour (Apr 15, 2016)

wblock@ : Probably driver listed here as FreeBSD 7.x and 8.0, which stated updated about four months ago.


----------



## Kenny Lam (Apr 26, 2016)

I got the same problem too, but I am using pfSense 2.2(FreeBSD 10.1)/2.3(FreeBSD 10.3).

My machine is a Intel n3150 + Realtek GbE too. The problem can be tested by running iperf tests.
http://www.hkepc.com/forum/viewthread.php?fid=12&tid=2285374&page=1&extra=#pid34784312
http://www.hkepc.com/forum/viewthread.php?fid=12&tid=2240827

I found that locking the adaptor to 100M can avoid packet loss and disconnections, however this shouldn't be a solution.

My temporary solution is to get a PCIe 1x to mini-PCIe adaptor, and install an Intel GbE card.


----------



## Kenny Lam (Apr 27, 2016)

I got the official Realtek GbE driver for FreeBSD 9.x complied on FreeBSD 10.3, and installed it on pfSense 2.3 (FreeBSD 10.3).

The disconnection problem is now gone, but the performance still bad. Will try other tunables.

dmesg



 

iperf3 result


----------



## Kenny Lam (Apr 27, 2016)

Okay, I give up the realtek adaptor after I tired all tunables on the realtek official driver, still no luck.

For anyone who wanna try. if_re.ko for FreeBSD 10.3 amd64 is here
https://drive.google.com/folderview?id=0B7KcdFahGcT4dTVfUlMzZEV6UmM&usp=sharing

Should I give it a shoot on FreeBSD11-CURRENT?


----------



## Incanter (Jul 19, 2016)

I have Intel N3050 based board with the following RealTek chipset:


```
re0@pci0:3:0:0: class=0x020000 card=0x81681849 chip=0x816810ec rev=0x11 hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
```

Standard FreeBSD driver times out fairly regularly. I was using RealTek provided driver v.1.88 (http://www.realtek.com.tw/downloads...d=5&Level=5&Conn=4&DownTypeID=3&GetDown=false) all the way through 9-STABLE and 10-STABLE with the pleasant results (990 Mbit/s on iperf, 110-120Mbytes/sec SMB file copy). With the upgrade to 11-STABLE driver would no longer compile, so I had to come up with the attached patch. The patch is against RealTek driver v.1.91. The system serves as the home fileserver and hosts VIMAGE jail with OpenVPN and PF to allow for outside access. So far, so good...


----------



## Botanic (Sep 10, 2016)

I just ordered an Intel NUC5CPYH without knowing about the issues with the NIC driver.
The NUC has the RealTek 8111HN chip, which is not mentioned anywhere on the driver page.
The page above mentioned by Incanter mentions different RTL8111 chips, but not the 8111HN.
In the readme for 1.91 the 8111 is not mentioned at all...

What are the steps to install the RealTek provided driver with all the needed patches?
Do I just follow the instructions in the readme and add the patch by Incanter?

I wish that RealTek would just open source their driver...

Here is the deal explained for linux:
https://unixblogger.com/2016/08/11/how-to-get-your-realtek-rtl8111rtl8168-working-updated-guide/


----------



## kpa (Sep 10, 2016)

Quite honestly put, get something else that uses an Intel NIC or you have an option to install for example a mini pci-express Intel NIC. I wouldn't trust Realtek to provide proper drivers for FreeBSD, FreeBSD is a moving target on the kernel programming level and while they might be able to support let's say 10.3-RELEASE there's no guarantee they will be able to provide the drivers for FreeBSD 11.


----------



## Shadowcaster (Oct 10, 2016)

RealTek is now a default nic chip for a lot of motherboards, NUCs and appliances. I got n3050 motherboard with dual gigabit ports, and both of them hang after some time with "watchdog timeout" message. In case I disable virtually everything like -txcsum -tso and so on, after some time I get packet loss of 80% instead of hangs, but at least I can try to reboot the box. I even wanted to install mini pci-e gigabit adapter, but whatever could be found on aliexpress is realtek based. USB 3.0 is also out of the question, because it's a great change of hitting realtek based adapter and have the best of both worlds - usb and realtek bugs.
I'll try to compile a custom kernel for newly released freebsd 11 with realtek custom driver and patch and report results.

here is pciconf for my adapters, 10.3 stable:

```
re0@pci0:1:0:0: class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x0c hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 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 0x81400000, size 4096, enabled
    bar   [20] = type Prefetchable Memory, range 64, base 0xa0100000, 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) RO 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 1 corrected
    ecap 0002[140] = VC 1 max VC0
    ecap 0003[160] = Serial 1 01000000684ce000
    ecap 0018[170] = LTR 1
     Corrected = Receiver Error
re1@pci0:2:0:0: class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x0c hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
    bar   [10] = type I/O Port, range 32, base 0xd000, size 256, enabled
    bar   [18] = type Memory, range 64, base 0x81300000, size 4096, enabled
    bar   [20] = type Prefetchable Memory, range 64, base 0xa0000000, 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) RO 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 1 corrected
    ecap 0002[140] = VC 1 max VC0
    ecap 0003[160] = Serial 1 01000000684ce000
    ecap 0018[170] = LTR 1
     Corrected = Receiver Error
```


----------



## Shadowcaster (Oct 11, 2016)

Drivers works on 11-stable. So far - so good.
How to build:

```
1. Get kernel sources in /usr/src, driver 1.91 from realtek site and patch from this thread. Apply patch to driver.
2. Modify /usr/src/sys/amd64/conf/GENERIC and delete line "device re" - so if_re no longer be included in kernel itself - module will be build anyway.
3. Edit /boot/loader.conf adding line if_re_load="YES", so external module will be loaded.
4. Go to /usr/src and run "make buildkernel KERNCONF=GENERIC && make installkernel KERNCONF=GENERIC"
5. Reboot with new kernel. System should boot with open-source driver as module. kldstat will show if_re in list of modules.
6. Put patched if_re.c and if_rereg.h into /usr/src/sys/dev/re
7. Build driver (cd /usr/src/sys/modules/re && make clean && make)
8. Backup /boot/kernel/if_re.ko, then cp /usr/src/sys/modules/re/if_re.ko /boot/kernel/if_re.ko && chmod 0555 /boot/kernel/if_re.ko && chown root:wheel /boot/kernel/if_re.ko
9. Reboot
```

result:

```
FreeBSD 11.0-PRERELEASE #25: Tue Oct 11 15:26:52 EEST 2016

re1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=201b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,WOL_MAGIC>
        ether 40:8d:5c:aa:aa:aa
        inet 10.10.10.10 netmask 0xffffff00 broadcast 10.10.10.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active

re1: <Realtek PCIe GBE Family Controller> port 0xd000-0xd0ff mem 0x81300000-0x81300fff,0xa0000000-0xa0003fff irq 17 at device 0.0 on pci2
re1: Using Memory Mapping!
re1: Using 1 MSI-X message
re1: ASPM disabled
re1: version:1.91
re1: Ethernet address: 40:8d:5c:aa:aa:aa

This product is covered by one or more of the following patents:
US6,570,884, US6,115,776, and US6,327,625.
re1: Ethernet address: 40:8d:5c:aa:aa:aa
```


----------



## sde (Nov 6, 2016)

Incanter said:


> I have Intel N3050 based board with the following RealTek chipset:
> 
> 
> ```
> ...


Hey Incanter, do you happen to have that kernel module and would you mind uploading to google drive or elsewhere? I say Kenny's version above but I'm guessing that is v1.92 which he was having issues with throughput. I'd like to try the 1.88 version but the Realtek site no longer has it from what I can see.


----------



## thr3e (Nov 19, 2016)

Hi, I came across this post while researching for the same issue. My Realtek NIC (RTL8111E) does not play well with FreeNAS 9.10-stable (which built on FreeBSD 10.3), keep auto negotiating at 100mb instead of Gigabit. I see that Realtek has released a new driver ver 1.92 on 10/25/2016, package includes the "if_re.c" and "if_rereg.h" files. From what I read I need to compile the ".c" file into a ".ko" but I'm new to Linux and I'm still a little confused about compiling.

If anyone have a copy of the compiled ".ko" with the newest Realtek ver 1.92 driver for a Intel64 cpu I would appreciate it.


----------



## DoBoY (Dec 6, 2016)

Hi guys, seems i am having the same issue with my realtek's and my pfsense box, I am a newb when it comes to freeBSD and was wodnering if anyoen has the pre-compiled fixed drivers listed above int his thread for either 10.3 or 11 ? I still have to figure out how to use the pre-compiled patches but i think that might be easier than tryiing to follow shadowcasters instructions above  at least for me 

thanks


sde said:


> Hey Incanter, do you happen to have that kernel module and would you mind uploading to google drive or elsewhere? I say Kenny's version above but I'm guessing that is v1.92 which he was having issues with throughput. I'd like to try the 1.88 version but the Realtek site no longer has it from what I can see.





thr3e said:


> Hi, I came across this post while researching for the same issue. My Realtek NIC (RTL8111E) does not play well with FreeNAS 9.10-stable (which built on FreeBSD 10.3), keep auto negotiating at 100mb instead of Gigabit. I see that Realtek has released a new driver ver 1.92 on 10/25/2016, package includes the "if_re.c" and "if_rereg.h" files. From what I read I need to compile the ".c" file into a ".ko" but I'm new to Linux and I'm still a little confused about compiling.
> 
> If anyone have a copy of the compiled ".ko" with the newest Realtek ver 1.92 driver for a Intel64 cpu I would appreciate it.


----------



## wblock@ (Dec 6, 2016)

It's really trusting to download random drivers off the web somewhere, but not safe at all.


----------



## DoBoY (Dec 6, 2016)

So i guess what you are saying is that my odds of finding a precompiled driver are slim eh? 

Any idea on a good resource for me to learn how to do it myself? I guess i can run a vm with 10.3 or 11 to compile on? then add that compiled driver to my pfsense box?


----------



## wblock@ (Dec 7, 2016)

The first step would be to ask the pfSense people to set up a way to produce updated drivers.  This is a problem for many people.
Then consider setting up a VM to build your own.
Look at opnSense, the fork of pfSense, which might have support or a more aggressive release schedule or some method of distributing driver updates.
Replacing the motherboard with one that has Intel networking built in or at least has a single PCIE slot is another option.


----------



## Shadowcaster (Dec 7, 2016)

wblock@ said:


> Replacing the motherboard with one that has Intel networking built in or at least has a single PCIE slot is another option.


May you also be so kind to point out what chipset out of Intel network products exactly should I look foor while buying embedded motherboard?  I am having bad luck finding mini-pcie on intel site, and it's not always clear how to identify "proper" motherboards. More to say, whatever intel chips are covered by "em" driver are not so good, next some will say that probably I need to look for "igb" one, and in the end of the day I will end up with a lot of advices and OS without network connectivity at all.


----------



## wblock@ (Dec 8, 2016)

Not mini-PCIE, but full-sized, normal PCIE.  The em(4) and igb(4) drivers support everything I've tried, which admittedly isn't a huge variety.  Recently, that has been i217V, I219, and I210.

Come to think of it, mini-PCIE boards should work, it's just a different form factor.  But a software build-your-own-driver setup is less expensive and more likely to give a good result.

Still, see what opnSense has.  It sounded like they forked off of pfSense because of things moving too slow, and this might be the very sort of thing they would cover.

You know, looking at that motherboard again, it has an X1 PCIE slot on it.


----------



## DoBoY (Dec 8, 2016)

I'm using a ZOTAC C323I Nano so no adding any other NIC's for me.. I will check out OPNsense


----------



## Shadowcaster (Dec 8, 2016)

I'm using latest 11-stable, it won't probably help you. Setting sysctl net.inet.tcp.tso=0 may help mitigate your problem, at least I was able to get 2 month of uninterruptible usage somehow with build-in driver.


----------



## DoBoY (Dec 9, 2016)

I'm also on 11 stable, running pfsense beta 2.4 since i tried to see if ti would help with my issue. It has not  have to limit my NIC to 100Mpbs

I will try and compile my own.. somehow  




Shadowcaster said:


> I'm using latest 11-stable, it won't probably help you. Setting sysctl net.inet.tcp.tso=0 may help mitigate your problem, at least I was able to get 2 month of uninterruptible usage somehow with build-in driver.


----------



## DoBoY (Dec 26, 2016)

Shadowcaster said:


> I'm using latest 11-stable, it won't probably help you. Setting sysctl net.inet.tcp.tso=0 may help mitigate your problem, at least I was able to get 2 month of uninterruptible usage somehow with build-in driver.



So i compiled my own driver in 10.3, copied it over to my pfsense box , used kldload to load it. seems to have loaded with no errors?
*
I cannot get the version* of the driver such as the one posted above to show? 1.91 or 1.92 (the one i am using)



```
FreeBSD 11.0-PRERELEASE #25: Tue Oct 11 15:26:52 EEST 2016

re1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=201b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,WOL_MAGIC>
        ether 40:8d:5c:aa:aa:aa
        inet 10.10.10.10 netmask 0xffffff00 broadcast 10.10.10.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active

re1: <Realtek PCIe GBE Family Controller> port 0xd000-0xd0ff mem 0x81300000-0x81300fff,0xa0000000-0xa0003fff irq 17 at device 0.0 on pci2
re1: Using Memory Mapping!
re1: Using 1 MSI-X message
re1: ASPM disabled
re1: version:1.91
re1: Ethernet address: 40:8d:5c:aa:aa:aa

This product is covered by one or more of the following patents:
US6,570,884, US6,115,776, and US6,327,625.
re1: Ethernet address: 40:8d:5c:aa:aa:aa
```

I added it to my boot/modules then added a line to boot.loader and now when i reboot and check with kldstat it shows it as loaded.. so is that all?


----------



## Shadowcaster (Jan 10, 2017)

Binary (compiled) driver proved itself to be unstable and unuseable under freebsd 11. It ends up flapping "link down/link up" and stalls in "link down" after few hours under load. YMMV, but build-in driver behaves bad, but a little more stable for me.
It's may be pure coincidence, but open-source driver behaves better when I use "compiled" realtek driver and then reboot into kernel with open-source one without shutting down the box.

Also, I use sysctl to disable TSO: (goes into /etc/sysctl.conf )
net.inet.tcp.tso=0

Also, disabling msi, msi-x and turning off powerd may help to mitigate this issues, but may affect performance:
hw.re.msi_disable=1
hw.re.msix_disable=1
or globally
hw.pci.enable_msix=0
hw.pci.enable_msi=0
(this goes to /boot/loader.conf and powerd can be disabled in  /etc/rc.conf by putting powerd_enable="NO" line)


for me 
hw.re.msi_disable=1
hw.re.msix_disable=1
did give about 5% of network performance boost! (measured with iperf3). Stability is yet to be tested.


----------



## DoBoY (Jan 13, 2017)

I'm been up for 18 days with my compiled driver so far. Performance is very good on a 120Mbit WAN link. I push it to the max for hours and still no more "watchdog timeout" errors anymore.


----------



## chrcol (Jan 14, 2017)

guys I managed to purchase a jetway dual port intel i350 mini pcie card for my braswell N3150 NUC.

I did find it odd I only managed to find one retailer worldwide selling it and now its vanished of their website, very odd.  It is listed on jetway's site but they dont sell direct.

For those who are looking tho and do have a mini pcie slot, then the model number is ADMPEIDLA and I see there is one on ebay albeit not cheap.

Mine was £50 for a 2 port card, the one on ebay is even more.

However it has been reliable and the shipped igb drivers are compatible.

minipc.de and mercateo have them also actually.


----------



## mmac (Jan 26, 2017)

Hello everyone! Today i assembled my next DIY home server based on ASRock J4205-ITX running FBSD 11.0-RELEASE-p7. After the installation and initial configuration, i run some first (disappointing) tests on my new hardware. By the way, the machine is pretty good in its power consumption which is about 18 watts in active/idle with two spinning HDDs. The main purpose of the machine should be "headless file serving", therefore it has to feed several gigabytes of AVCHD-Files from my Handycam.

And here is the problem: the NIC is going to say goodbye (watchdog-messages in screen terminal) each time the network traffic goes up by copying large files.

The internal NIC is a:


```
re0@pci0:1:0:0:    class=0x020000 card=0x81681849 chip=0x816810ec rev=0x11 hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device      = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class        = network
    subclass   = ethernet
```

And this is the Reason why i'm now here. I tried to compile the actual driver from Realtek according to the steps described in this thread without success. The point is that the driver version related to the description is v191 but i only found v192 on Realtek's page. Is there any chance that the built-in driver is going to be updated in future FBSD patches, or did i really have to compile the driver by myself? Imho FBSD is currently unusable with Realtek cards, and I dont want to add another (pci-)nic only because there is a software bug. 

Thank you all!


----------



## bole5 (Jan 26, 2017)

The driver v192 compiles without problems on 10.03. If you are on 11.0 you need to apply patch posted in this thread first: https://forums.freebsd.org/threads/55861/#post-324491


----------



## mmac (Jan 27, 2017)

I followed the instructions and build my own kernel with the latest realtek driver "if_re.ko" (v192) as a module. First load tests with some large files (+4 Gigabytes) shows no more watchdog interrupts. This workaround works very well.

Thank you all!


----------



## Shadowcaster (Mar 6, 2017)

New driver version 1.93 seems to include patches required for FreeBSD 11.


----------



## SpaceAdventureCobra (Dec 25, 2017)

Hi. I have just finished building my pfsense firewall with 2x onboard NICs, and having some trouble with the firewall becoming non-responsive from time to time, I have come here to this forum post, because my logs says re0: watchdog timeout. 

I googled before I bought my system and I read that Realtek 8168 NICs was stable. This is my motherboard; https://www.gigabyte.com/Motherboard/GA-J3455N-D3H-rev-10#ov - but it is not stable,, after putting VLANs etc on the LAN side of it and pushing heavy traffic it sometimes requires shutting it off and on due to NICs becoming unresponsive (it does answer ping requests though, but no routing..) 

Anyways;

Reading this forum post, and this one - https://forums.freebsd.org/threads/55306/ I am thinking the solution will be to load the Realtek driver as a module. It has now updated to v1.94, http://www.realtek.com.tw/downloads...d=5&Level=5&Conn=4&DownTypeID=3&GetDown=false - and I am wondering if anyone has success with using that one? I cannot seem to find the other versions of this driver.

Running pfsense with a *2.4.2-RELEASE-p1* (amd64) 
built on Tue Dec 12 13:45:26 CST 2017 
FreeBSD 11.1-RELEASE-p6 


```
[2.4.2-RELEASE][root@pfSense.localdomain]/root: pciconf -v -l
re0@pci0:3:0:0:   class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x0c hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
re1@pci0:4:0:0:   class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x0c hdr=0x00
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
[2.4.2-RELEASE][root@pfSense.localdomain]/root:
```


----------



## SpaceAdventureCobra (Dec 25, 2017)

Anyone else having trouble with this, I found some more information here: in comment #42 the user "franco" stated _(...) Realtek released the FreeBSD driver version 1.93 with built-in support for FreeBSD 11.0. All the more reason to go forward (...)_
https://forum.opnsense.org/index.php?topic=4183.30

And it seems to me that the existing Realtek driver from FreeBSD should have been replaced by version Opnsense 17.1.2,, and downloading it now Opnsense is version 17.7.5, so it should work "out of the box" without any fiddling. 

Hm, already started to know my way around pfsense, such a shame to switch to Opnsense 

Now if someone could just point to to the "doubleclick this" install_new_driver_realtek_setup.exe file to setup the new drivers


----------



## SpaceAdventureCobra (Dec 25, 2017)

And if I have not spammed this post enough, there is a good description here on how to upgrade to the latest v1.94 driver from Realtek. Ill maybe try this tonight - https://forum.pfsense.org/index.php?topic=103841.105


----------



## borjam (Mar 8, 2018)

I have had similar problems with a NUC6AYH, with one of those hideous re GbE interfaces. Unfortunately it's not possible to replace it.

In my case it kinda worked, but I tried to do something a bit stupid (like running an Elasticsearch node on it, and, to make it worse, using a iSCSI volume as its storage) and the interface would die with a watchdog error after a minute or so.

I am running 11.1-STABLE from two or three weeks ago. I reproduced the problem several times and, interestingly, when forcing a reboot with the interface frozen I got this error:


```
<5>re0: link state changed to UP
re0: watchdog timeout
<5>re0: link state changed to DOWN
<5>re0: link state changed to UP
Waiting (max 60 seconds) for system process `vnlru' to stop... done
Waiting (max 60 seconds) for system process `syncer' to stop... g_vfs_done():da0[WRITE(offset=14498955264, length=131072)]error = 6
g_vfs_done():da0[WRITE(offset=14499086336, length=131072)]error = 6
g_vfs_done():da0[WRITE(offset=14499250176, length=131072)]error = 6
g_vfs_done():da0[WRITE(offset=21167616, length=1024)]error = 6
panic: cannot reassign paging buffer
cpuid = 0
KDB: stack backtrace:
#0 0xffffffff806e5bb7 at kdb_backtrace+0x67
#1 0xffffffff8069fb26 at vpanic+0x186
#2 0xffffffff8069f993 at panic+0x43
#3 0xffffffff80762043 at reassignbuf+0x273
#4 0xffffffff8074336e at bdirty+0x2e
#5 0xffffffff807421ca at brelse+0x10a
#6 0xffffffff80744cc7 at bufdone+0x87
#7 0xffffffff805f26b2 at g_io_deliver+0x202
#8 0xffffffff805ef952 at g_disk_done+0x122
#9 0xffffffff802df933 at dadone+0x18a3
```

I have updated to the latest driver downloaded from here,

http://www.realtek.com/downloads/do...d=5&Level=5&Conn=4&DownTypeID=3&GetDown=false

It was simple. Compiling a kernel without the re device, compiling this module and replacing the if_re.ko from the kernel directory with this new one.

It had a silly problem when compiling but it was trivial to fix. It failed to find one of its include files because it searched for a different path.

Other than that it's running solid for several hours now. It is losing a packet now and then (I am keeping a ping to check that), but nothing serious.


----------



## tingo (Mar 9, 2018)

Did you also create a bug report for the bug with the FreeBSD driver related to your hardware?


----------



## borjam (Mar 9, 2018)

Not yet. Besides, it survived for several hours but the driver crashed this morning. 

The machine is alive but the network interface is failing. So, something else to look at :/

I'll create a bug report if I can get more information. And unfortunately it's not possible to replace the bloody Ethernet interface. It's on the motherboard and there's no PCI slots to install a proper card. Sigh.


----------



## tingo (Mar 13, 2018)

usb ethernet adapter as a workaround?


----------



## logic (Dec 11, 2018)

Just an update for this thread for FreeBSD 11.2-RELEASE in December 2018:

At this time, RealTek have reorganized their site. It is no longer possible to create a download link directly to a software download. Instead, you navigate to the download you want, provide your e-mail address, and then receive an e-mail with a link in it. After following the link, my experience was that you get 120 seconds within which to successfully answer a CAPTCHA before which the link becomes permanently invalid (for me it was a simple mathematical question, and the CAPTCHA result was the mathematical answer, not literally the characters from the CAPTCHA -- it says "6 + 3", the CAPTCHA answer is "9"). I have no idea why their FreeBSD driver source code is protected by such a complicated mechanism, but in order to download the latest driver, at the time of writing, you should follow these steps:
Browse to www.realtek.com.
For me, the page loads in Traditional Chinese, but this can be changed to English with a drop-down in the top-right.
Open the hamburger menu and select Downloads -> Computer Network ICs.
Select any 8111 or 8168 item in the list and click "Software". For the FreeBSD driver, they all ultimately direct you to the identical download link.
In the list of downloads, look for the section titled "Unix (Linux)", under which there is an item "FreeBSD 7.x and 8.0".
Click "Download" to begin the dance described above.

The latest driver as I write this is version 1.95, and despite the specific ancient FreeBSD versions listed on their site, it _does not require patching _to build and work as-is on 11.2-RELEASE. It actually contains sections separated off by [FONT=Courier New]#if OS_VER < VERSION(11,0)[/FONT], so the code is fully-aware of the latest kernel versions.
The steps described earlier in this thread by Shadowcaster on October 11, 2016 work, omitting the patching referenced in step 6. Simply place the two files from the 1.95 / 0008 source distribution into the [FONT=Courier New]sys/dev/re[/FONT] directory and build.
After rebooting to a kernel that treated [FONT=Courier New]if_re[/FONT] as a module, I was apparently able to switch from the old module to the new one without rebooting, simply using [FONT=Courier New]kldunload if_re[/FONT] followed by [FONT=Courier New]kldload if_re[/FONT]. The log output from the [FONT=Courier New]kldload[/FONT] command indeed lists the loaded version as being 1.95, whereas the bundled driver did not output a version at all.
For anyone curious, there is rather a substantial difference between the bundled driver and that supplied by Realtek. For starters, the code is literally an order of magnitude larger. Both files are attributed to Bill Paul, with actually a newer year in the smaller file in the FreeBSD source distribution. The larger file from Realtek appears to contain functions that send microcode to the NIC controller chips. I am assuming the older attribution in Realtek's version is simply a result of the code having diverged from an earlier version and then been maintained and upgraded without changes to the attribution.


----------



## opmetal (Jan 7, 2019)

This worked perfectly! Thanks, Logic.



logic said:


> Just an update for this thread for FreeBSD 11.2-RELEASE in December 2018:
> 
> At this time, RealTek have reorganized their site. It is no longer possible to create a download link directly to a software download. Instead, you navigate to the download you want, provide your e-mail address, and then receive an e-mail with a link in it. After following the link, my experience was that you get 120 seconds within which to successfully answer a CAPTCHA before which the link becomes permanently invalid (for me it was a simple mathematical question, and the CAPTCHA result was the mathematical answer, not literally the characters from the CAPTCHA -- it says "6 + 3", the CAPTCHA answer is "9"). I have no idea why their FreeBSD driver source code is protected by such a complicated mechanism, but in order to download the latest driver, at the time of writing, you should follow these steps:
> Browse to www.realtek.com.
> ...


----------



## dsagra (Jan 8, 2019)

has anyone tried Realtek "re" driver on new FreeBSD 12.0, yet?


----------



## xenospn (Jan 27, 2019)

dsagra said:


> has anyone tried Realtek "re" driver on new FreeBSD 12.0, yet?


Seems like it's the same driver from 11.2.

Also, FYI: The RealTek 1.95 driver fails to build on 12.0-RELEASE:


```
/usr/src/sys/dev/re/if_re.c:7507:9: error: no member named 'tqh_first' in 'struct ifmultihead'; did you mean 'cstqh_first'?
        TAILQ_FOREACH(ifma,&ifp->if_multiaddrs,ifma_link)
        ^
/usr/src/sys/sys/queue.h:725:15: note: expanded from macro 'TAILQ_FOREACH'
        for ((var) = TAILQ_FIRST((head));                               \
                     ^
/usr/src/sys/sys/queue.h:722:36: note: expanded from macro 'TAILQ_FIRST'
#define TAILQ_FIRST(head)       ((head)->tqh_first)
                                         ^
/usr/src/sys/net/if_var.h:94:1: note: 'cstqh_first' declared here
CK_STAILQ_HEAD(ifmultihead, ifmultiaddr);
^
/usr/src/sys/contrib/ck/include/ck_queue.h:232:15: note: expanded from macro 'CK_STAILQ_HEAD'
        struct type *cstqh_first;/* first element */                    \
                     ^
/usr/src/sys/dev/re/if_re.c:7507:9: error: no member named 'tqe_next' in 'struct ifmultiaddr::(anonymous at /usr/src/sys/net/if_var.h:554:2)'; did you mean 'cstqe_next'?
        TAILQ_FOREACH(ifma,&ifp->if_multiaddrs,ifma_link)
        ^
/usr/src/sys/sys/queue.h:727:14: note: expanded from macro 'TAILQ_FOREACH'
            (var) = TAILQ_NEXT((var), field))
                    ^
/usr/src/sys/sys/queue.h:831:46: note: expanded from macro 'TAILQ_NEXT'
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
                                             ^
/usr/src/sys/net/if_var.h:554:2: note: 'cstqe_next' declared here
        CK_STAILQ_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */
        ^
/usr/src/sys/contrib/ck/include/ck_queue.h:241:15: note: expanded from macro 'CK_STAILQ_ENTRY'
        struct type *cstqe_next;        /* next element */                      \
```


----------



## RobCrowston (Feb 17, 2019)

xenospn said:


> Also, FYI: The RealTek 1.95 driver fails to build on 12.0-RELEASE:
> 
> 
> ```
> ...



This can be repaired by invoking `sed -i -e 's/TAILQ_FOREACH/CK_STAILQ_FOREACH/g' if_re.c`.


----------



## fkoczan (Mar 15, 2019)

I have made FreeBSD 12 package.





						rtl_bsd_195_fkoczan_mod.tar.bz2
					






					drive.google.com
				



I dont consider it my work - I have just packed it in one archive. It is stable for me on 12.0 p3 more than 
"sed -i -e 's/TAILQ_FOREACH/CK_STAILQ_FOREACH/g' if_re.c" 
trick and I have compared my binary with above binary. Above sims to hang on high load from Intel card at my bench.


----------



## FabricioGuzzy (Apr 18, 2019)

fkoczan said:


> I have made FreeBSD 12 package.
> 
> 
> 
> ...



Hello Fkoczan,
I just compiled your MOD version of it (V1.95) . Now testing (Burn in) - So far, so good.
Is that working fine for you after all?

Thanks Much!
Fabricio.


----------



## meokey (Aug 11, 2020)

can anybody kindly share the compiled kernel files with latest driver v196.04 that works on FreeBSD 11.3 (current pfsense kernel)? Thanks.


----------



## Dystopian (Aug 11, 2020)

meokey said:


> can anybody kindly share the compiled kernel files with latest driver v196.04 that works on FreeBSD 11.3 (current pfsense kernel)? Thanks.


`pkg install realtek-re-kmod`


----------



## meokey (Aug 11, 2020)

sorry for the stupid question as newbie to FreeBSD - but I cannot find the package?

```
[2.4.5-RELEASE]/usr/local/bin: sudo pkg install realtek-re-kmod
Updating pfSense-core repository catalogue...
pfSense-core repository is up to date.
Updating pfSense repository catalogue...
pfSense repository is up to date.
All repositories are up to date.
pkg: No packages available to install matching 'realtek-re-kmod' have been found in the repositories
[2.4.5-RELEASE]/usr/local/bin: ls /etc/pkg
FreeBSD.conf
[2.4.5-RELEASE]/usr/local/bin: cat /etc/pkg/FreeBSD.conf
# $FreeBSD$
#
# To disable this repository, instead of modifying or removing this file,
# create a /usr/local/etc/pkg/repos/FreeBSD.conf file:
#
#   mkdir -p /usr/local/etc/pkg/repos
#   echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.conf
#

FreeBSD: {
  url: "pkg+[URL]http://pkg.FreeBSD.org/$[/URL]{ABI}/latest",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
[2.4.5-RELEASE]/usr/local/bin: pkg info pkg
pkg-1.13.2
Name           : pkg
Version        : 1.13.2
Installed on   : Tue Jun  2 18:10:41 2020 EDT

[2.4.5-RELEASE]/usr/local/bin: uname -a
FreeBSD  11.3-STABLE FreeBSD 11.3-STABLE #243 abfxxxxxxce(RELENG_2_4_5): Tue Jun  2 17:53:37 EDT 2020     [EMAIL]root@buildbot1-nyi.netgate.com[/EMAIL]:/build/ce-crossbuild-245/obj/amd64/YNx4Qq3j/build/ce-crossbuild-245/sources/FreeBSD-src/sys/pfSense  amd64
```


----------



## Jose (Aug 12, 2020)

That is indeed odd. The port definitely exists:





						[ports] Index of /head/net/realtek-re-kmod
					






					svnweb.freebsd.org
				




And it failed to build some weeks ago:


			https://pkg-status.freebsd.org/builds/default:default:head-amd64:p542461_s363297:beefy18
		


Dunno if that means it's now dead in the water or whut.


----------



## SirDice (Aug 12, 2020)

meokey said:


> sorry for the stupid question as newbie to FreeBSD - but I cannot find the package?


pfSense is not supported here.

PC-BSD, FreeNAS, XigmaNAS, and all other FreeBSD Derivatives


----------



## Jose (Aug 12, 2020)

FWIW, it doesn't show up on a `pkg search realtek-re-kmod` on Freebsd 12.1 with quarterly packages.


----------



## SirDice (Aug 12, 2020)

The port is fairly new, it was added _after_ Q3 was branched off. It is available in the latest package repositories.


----------



## sdf_iain (Sep 15, 2020)

meokey said:


> sorry for the stupid question as newbie to FreeBSD - but I cannot find the package?


You'll need to comment out the lines in /usr/local/etc/pkg/repos/FreeBSD.conf and /usr/local/etc/pkg/repos/pfSense.conf that disable the FreeBSD repositories.
Comment them out, install the kernel module, then uncomment them; just in case some other pfSense users manage to find this


----------

