MAC and PHY loopback tests entrypoint for NIC controller

Marius Strobl marius at alchemy.franken.de
Wed Aug 17 15:58:40 UTC 2011


On Sat, 6 Aug 2011 23:39:38 +0530
Naresh <gbal.naresh at gmail.com> wrote:

> 
> Hi All,
> 
> I am writing a 10Gb Ethernet driver. We have a requirement to support
> Mac and PHY loopback test for the network controller. In Linux there
> is a ethtool entrypoint which calls this feature.
> 
> I wondering what will be the equivalent entry point in FreeBSD. I
> tried looking in to other drivers, but not lucky enough to find one.
> 
> It is much appreciated if some one could point me to MAC and PHY
> loopback test entry point in FreeBSD.
> 

I don't know what API Linux provides but I think the question is how to
activate loopback mode from userland. Somewhere in your driver you'll
add the supported media similar to the following:
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
If there you also add media variants with option IFM_LOOP f.e. like so:
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_1000_T | IFM_LOOP, 0, NULL);
etc then from userland you can activate loopback mode via ifconfig(8)
like so:
ifconfig youdrv0 1000baseT mediaopt hw-loopback
and deactivate if via:
ifconfig youdrv0 1000baseT -mediaopt hw-loopback
Current versions of FreeBSD also take "loopback" or even just "loop" as
an alias for "hw-loopback".
The media change handler of your driver of course needs to check
whether the selected media has IFM_LOOP set and (de)activate loopback
mode in the hardware as appropriate.

Marius


More information about the freebsd-drivers mailing list