Thursday, September 17, 2009

FreeBSD VMware Interfaces

FreeBSD VMware Interfaces

A site hosting news on FreeBSD 7.0 also included several great tips for FreeBSD under VMware. One tip talked about the lnc network interface standard under VMware.

You can see lnc0 in this sample VM. Here's dmesg output:


port 0x1400-0x147f

irq 18 at device 17.0 on pci0

lnc0: Attaching PCNet/PCI Ethernet adapter


lnc0: Ethernet address: 00:0c:29:38:7d:ea

lnc0: if_start running deferred for Giant

lnc0: PCnet-PCI

This is what the interface looks like in VMware:

taosecurity:/root# ifconfig lnc0

lnc0: flags=108843 mtu 1500

        inet6 fe80::20c:29ff:fe38:7dea%lnc0 prefixlen 64 scopeid 0x1

        inet netmask 0xffff0000 broadcast

        ether 00:0c:29:38:7d:ea

The fact that lnc is GIANT-locked is bad for network performance. Furthermore, lnc is deprecated in FreeBSD 7.0, replaced by le.

The site included a tip to replace the lnc0 driver with an emulated em0 driver. I modified my .vmx file by adding the second line.

Ethernet0.present = "TRUE"


With that option, I see em0 in dmesg output:


port 0x1070-0x1077

mem 0xec820000-0xec83ffff,0xec800000-0xec80ffff irq 18

at device 17.0 on pci0

em0: Memory Access and/or Bus Master bits were not set!

em0: Ethernet address: 00:0c:29:fd:f6:1d

Here is the device in ifconfig output:

kbld:/root# ifconfig em0

em0: flags=8843 mtu 1500


        inet6 fe80::20c:29ff:fefd:f61d%em0 prefixlen 64 scopeid 0x1

        inet netmask 0xffff0000 broadcast

        ether 00:0c:29:fd:f6:1d

        media: Ethernet autoselect (1000baseTX )

        status: active

That's really cool, especially since em0 doesn't need the GIANT lock. Performance should be improved. The site I mentioned said this with respect to replacing lnc with le:

le is still a SIMPLEX device but at least it's not GIANT-locked.

It's true that le is not GIANT locked, but I think SIMPLEX is really irrelevant. You'll see SIMPLEX everywhere, like in the above em0 output. As I mentioned here, SIMPLEX "has nothing to do with half or full duplex. SIMPLEX refers to the NIC not being able to transmit and receive while operating on true CSMA/CD Ethernet, which is really not the case with switched networks."

On a related note, you don't have to recompile your kernel to use le. You can load it as a kernel module during boot by entering if_le_load="YES" in /boot/loader.conf as noted in the le man page. In my tests this did not result in using the le driver instead of lnc however, so those wishing to use an lnc0 replacement should use em0.

I also concur with the recommendation to use kern.hz="100" in /boot/loader.conf to deal with VMware timing issues. That helps immensely and doesn't require VMware Tools installation.

VMware Workstation 6.5 now defaults to the e1000 (em0) ethernet adapter when either "FreeBSD" or "FreeBSD 64-bit" is selected as the Guest operating system during the New Virtual Machine Wizard.

No comments: