Updating your FreeBSD so it
can run the latest de driver.

This page will help to configure your FreeBSD to support if_media which is required to use the latest version of the "de" driver.


What is this if_media stuff and why do I want it?

if_media was first proposed/designed by BSDI for BSD/OS 3.0. It allows you display the available media choices and allows to select among them. It also allows to change operation modes such as operating in full or half duplex. With a nearly dozen media options available by boards supported by the de driver, the IFF_* hack that it previously used was just no longer supportable.

Where do I get if_media from?

It's available from the NetBSD ftp server.

You need two files: if_media.c and if_media.h. These go in /sys/net on your system. Note that you might need to modify the #ifdef in if_media.h. These files require modifications to sys/net/if.h, sys/sys/sockio.h, and sys/conf/files.

To sys/net/if.h, you will to modify the ifreq structure and add a ifr_media member. You also need to add a ifmediareq struct. These diffs are for a 2.1.0 system:

--- if.h.orig   Tue May 30 08:07:59 1995
+++ if.h        Fri Mar 21 16:45:14 1997
@@ -305,6 +305,7 @@
                int     ifru_metric;
                int     ifru_mtu;
                int     ifru_phys;
+               int     ifru_media;
                caddr_t ifru_data;
        } ifr_ifru;
 #define        ifr_addr        ifr_ifru.ifru_addr      /* address */
@@ -314,6 +315,7 @@
 #define        ifr_metric      ifr_ifru.ifru_metric    /* metric */
 #define        ifr_mtu         ifr_ifru.ifru_mtu       /* mtu */
 #define ifr_phys       ifr_ifru.ifru_phys      /* physical wire */
+#define ifr_media      ifr_ifru.ifru_media     /* network media */
 #define        ifr_data        ifr_ifru.ifru_data      /* for use by interface */
 };
 
@@ -322,6 +324,17 @@
        struct  sockaddr ifra_addr;
        struct  sockaddr ifra_broadaddr;
        struct  sockaddr ifra_mask;
+};
+
+struct ifmediareq {
+       char    ifm_name[IFNAMSIZ];             /* if name, e.g. "en0" */
+       int     ifm_current;                    /* current media options */
+       int     ifm_mask;                       /* don't care mask */
+       int     ifm_status;                     /* media status */
+       int     ifm_active;                     /* active options */
+       int     ifm_count;                      /* # entries in ifm_ulist
+                                                  array */
+       int     *ifm_ulist;                     /* media words */
 };
 
 /*

To sys/sys/sockio.h, you need to add the two ioctls used by if_media (if the numbers are in use, pick the next available ones):

#define SIOCSIFMEDIA    _IOWR('i', 55, struct ifreq)    /* set net media */
#define SIOCGIFMEDIA    _IOWR('i', 56, struct ifmediareq) /* get net media */

Finally you need to add one file to sys/conf/files (add it right after the line for net/if.c):

net/if_media.c          standard

That should be able all the changes needed to compile a kernel with if_media support. You might want to rebuild a kernel at this point to see everything compiles. (If you get a problem compiling if_media.c, you probably need to change the #ifdef in if_media.h)

Now grab the latest de driver

which is composed of three files: if_de.c , if_devar.h , and dc21040reg.h . All these files go in /sys/pci.You will need to rename dc21040reg.h to dc21040.h.

A new ifconfig

Now you will need to build yourself the NetBSD version of ifconfig so you can modify the if_media settings. It's available in ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sbin/ifconfig/ and should compile under FreeBSD. You make have to make "CC=cc -I/sys" since your /sys and /usr/include/sys headers are now out of sync).

You should now have the latest de driver. Give it a shot and let me know how it goes!