3c900 NIC statistics

Bill Paul wpaul at FreeBSD.ORG
Thu Aug 7 11:56:48 PDT 2003


> 
> Hi, I would like to dump all possible statistics for my 3Com NIC.
>
> $ sudo /usr/X11R6/bin/scanpci | grep -1 3Com
> pci bus 0x0000 cardnum 0x0d function 0x00: vendor 0x10b7 device 0x9001
>  3Com Corporation 3c900 Combo [Boomerang]
> 
> $ sudo pciconf -l | grep xl0
> xl0 at pci0:13:0:  class=0x020000 card=0x00000000 chip=0x900110b7 rev=0x00 hdr=0x00
> 
> Ideally i'd like to be able to find out firmware version, which interface port is
> active and all the rest of the settings as i've yet to find a FreeBSD program that
> will tell me these details.

ifconfig(8) is supposed to tell you.

If you really want to create a 3Com diag utility, more power to you.
You can obtain copies of the programming manuals for the 3c90x/3c90xB and
3c90xC chips here:

http://support.3com.com/partners/developer/license.html

> This the driver code.
> 
> /usr/src/sys/pci/if_xl.c
> /usr/src/sys/pci/if_xlreg.h
> 
> I would presume it's a case of reading the structure, finding the
> offset and feeding it into pcitweak.  This is the bit where I get
> lost, is my approach correct or am I off? If so why and can anyone
> help me to decode this some more, it's proving to be an interesting
> learning exercise.

There are two ways to do what you want to do: modify the existing
xl(4) driver to allow a user utility to read/write directly to the
NIC's registers, or write a user utility that touches the hardware
directly.

Touching the hardware directly from user space is tricky. First you
have to parse the PCI config registers to find the I/O base address
of the device. Then you have to access the I/O registers. You can
execute inb/outb instructions from a user program, but you have to
open /dev/io first in order to obtain the necesessary privileges.
Most PCI devices allow both I/O space and memory mapped register
access, however some allow memory mapped access only. For these,
you may be forced to grovel around in /dev/mem.

I would recommend using the existing driver instead. You could
add a simple 'read register/write register' interface to the xl_ioctl()
using the SIOCGENERIC ioctl. The manuals for the chips should give
you an idea what registers you need to read. You may end up having
to reprogram the EEPROM to make your changes stick across reboots
though, and for that you have to be very careful since you need
to checksum the EEPROM.

-Bill

--
=============================================================================
-Bill Paul            (510) 749-2329 | Senior Engineer, Master of Unix-Fu
                 wpaul at windriver.com | Wind River Systems
=============================================================================
      "If stupidity were a handicap, you'd have the best parking spot."
=============================================================================


More information about the freebsd-hardware mailing list