BSD daemon

NetBSD Documentation:

Converting ancient BSD Ethernet drivers to NetBSD-1.2D and later

Preface

With NetBSD-1.2D and later, the traditional IPv4-over-Ethernet-only ARP subsystem was modified to allow IPv4 over any hardware medium. While all NetBSD Ethernet drivers were converted, you might want to contribute a new one, based on some other BSD's code who did not yet make this change. This document outlines the steps necessary to convert your driver to NetBSD.

Naming Conventions

Throughout this document,

	struct ifnet *ifp;
is a pointer to the interface structure of "our" device and

	struct foo_softc *sc;
is a pointer to our softc structure.

Include Files Needed

Instead of

#include <netinet/if_ether.h>
use

#include <net/if_dl.h>		/* for the LLADDR macro */
#include <net/if_ether.h>	/* for real Ethernet stuff */
#include <netinet/if_inarp.h>	/* for IP-specific ARP stuff. */
Sometimes you also need

#include <net/if_arp.h>

Softc Structure

[While you are here: I've seen lots of places, where, at the beginning of a function, a struct ifnet * parameter is converted to a struct foo_softc *, and later there are lots of sc->sc_if.bar or &sc->sc_if accesses. This is ugly, confusing and unnecessary. Depending on the nature of the driver you might want to change this while you're at it.]

Changed functions

You may have noticed by now, that you don't have a hardware address any longer in the softc.

There are two types of accesses to it. One is initialization, in the foo_attach() function (if this is done in the fooprobe()/foomatch() function, your driver is broken for other reasons and should be fixed); the other is runtime reads, and for crazy protocols like XNS, OSI, DECnet, even writes.


Up to NetBSD Documentation: Kernel
NetBSD Home Page
NetBSD Documentation top level

(Contact us) $NetBSD: converting-ethernet-drivers.html,v 1.15 2004/10/30 22:33:26 jschauma Exp $
Copyright © 1994-2003 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.