# RTL8111/8168B Network Card & FreeBSD



## danny (Nov 3, 2013)

Hello, 

We are trying to install FreeBSD on a computer that uses the network card mentioned above. The network card is running under linux without problems. 

The card is neither detected by the FreeBSD installer when attempting to setup the network, nor after the system installation when booting from HD. We've tested FreeBSD 8.x, 9.x and 10.x; same issues with this card. 

We cannot use a different network card (this one is onboard. The micro ATX mainboard has no room left for any other device)

`pciconf -l -v`

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

`dmesg`

```
re0: <RealTek 8168/8111 B/C/CP/D/DP/E/F PCIe Gigabit Ethernet> port 0xd000-0xd0ff mem 0xf3204000-0xf3204fff,0xf3200000-0xf3203fff irq 19 at device 0.0 on pci3
re0: Using 1 MSI-X message
re0: Chip rev. 0x4c000000
re0: MAC rev. 0x00000000
re0: Unknown H/W revision: 0x4c000000
device_attach: re0 attach returned 6
```

`ifconfig -a`

```
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 
	inet 127.0.0.1 netmask 0xff000000 
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
```

Even though `dmesg` shows the device re0, it remains unknown to `ifconfig`.


Best Regards
Danny


----------



## Beeblebrox (Nov 3, 2013)

You need to load the NIC driver: `# kldload if_re`. If you get message: 
	
	



```
kldload: can't load if_re: File exists
```
Then you need to check whether the hardware (NIC) is damaged. Do further diagnostics and make sure that


> The network card is running under linux without problems.


Is actually a rigorous statement and not a trivial working appearance. The source code for FreeBSD and linux for almost all hardware drivers is the same.


----------



## kpa (Nov 3, 2013)

```
re0: Unknown H/W revision: 0x4c000000
```

This is a sure sign that this version of the card is not supported by the driver. Realtek has a nasty habit of changing the internals of their network cards in incompatible ways while keeping the hardware vendor and product IDs the same. You'll have to ask this on the freebsd-net mailing list to get further assistance.


----------



## danny (Nov 3, 2013)

We've tested the NIC on linux for several days now, transfering several GB of data. The NIC is working on linux without any issues. 


```
kldload: can't load if_re: File exists
```
I assume this message pops up, because if_re is already loaded in the generic kernel so that it can't be loaded again as a module.

Any patches or workarounds? What about USB NICs on FreeBSD?


What is the best way to address this bug?


----------



## kpa (Nov 3, 2013)

Like I said post on the mailing list or file a PR. This issue has to be brought into the attention of a developer who can take a look at the problem and then patch the driver to support this unsupported version of the NIC.


----------



## Beeblebrox (Nov 4, 2013)

I just got my Mainboard back from warranty service, with a clean bill of health. the if_re kernel module seems to be the problem at this point.
http://forums.freebsd.org/showthread.php?t=42541


----------



## danny (Nov 4, 2013)

*[Solved] RTL8111/8168B Network Card & FreeBSD*

After describing the problem via mailing-list, I was told there is already the following patch available:

http://lists.freebsd.org/pipermail/freebsd-net/attachments/20131023/e1d480e3/attachment.bin

After correcting a little typo in the containing header-file, and recompiling the if_re module, the device went up and works like a charm on FreeBSD 9.1.

I will upgrade the system to FreeBSD 9.2 next weekend and see if the patch works there as well. 

Problem solved. 


Greetings
Danny


----------



## Beeblebrox (Nov 4, 2013)

I re-built my world/kernel (9.2) and the problem seems corrected (ping response).


----------



## p.j (Apr 18, 2016)

I have dealt with similar issues and finally solved them.
I found the two following posts a bit misleading:


Beeblebrox said:


> You need to load the NIC driver: `# kldload if_re`. If you get message:
> 
> 
> 
> ...





kpa said:


> ```
> re0: Unknown H/W revision: 0x4c000000
> ```
> 
> This is a sure sign that this version of the card is not supported by the driver. Realtek has a nasty habit of changing the internals of their network cards in incompatible ways while keeping the hardware vendor and product IDs the same. You'll have to ask this on the freebsd-net mailing list to get further assistance.


It actually turned out that there where more than one "if_re.ko"-driver files. After a quick
`find / -name if_re.ko` and overwriting all occurrences, the issue was finally solved.


----------

