Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2003 11:56:47 -0700 (PDT)
From:      wpaul@FreeBSD.ORG (Bill Paul)
To:        darren@dazdaz.org (Darren)
Cc:        freebsd-hardware@FreeBSD.ORG
Subject:   Re: 3c900 NIC statistics
Message-ID:  <20030807185647.C170937B40C@hub.freebsd.org>
In-Reply-To: <3110704552.20030806122139@dazdaz.org> from Darren at "Aug 6, 2003 12:21:39 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> 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@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@windriver.com | Wind River Systems
=============================================================================
      "If stupidity were a handicap, you'd have the best parking spot."
=============================================================================



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030807185647.C170937B40C>