Verifying That The Interface Has Shut Down; Obtaining The Simple Lock And Shutting Down The Device - Compaq Tru64 UNIX Installation Manual

Writing network device drivers
Table of Contents

Advertisement

struct el_softc *sc = el_softc[unit];
struct ifnet *ifp = &sc->is_if;
Declares as an argument a pointer to a bus data structure and a
1
controller data structure for this controller. The controller data
structure contains such information as the controller type, the controller
name, and the current status of the controller. This completely identifies
the adapter that is being unattached.
Declares a unit variable and initializes it to the controller number for
2
this controller. This controller number identifies the specific 3Com
3C5x9 controller that is being unattached. The controller number is
contained in the ctlr_num member of the controller data structure
for this device.

7.2 Verifying That the Interface Has Shut Down

The following code verifies that the interface is down. Make sure that other
errors returned by if_detach do not stop interface shutdown.
status = if_detach(ifp);
if (status == EBUSY)
return(status);
else if (status == ESUCCESS)
detachpfilter(sc->is_ed);
ifp->if_flags &= ~IFF_RUNNING;
Calls if_detach to remove this interface from the list of active
1
interfaces.
If the interface is still in use, it cannot be detached, so failure is
2
returned.
If the interface is not in use, detaches it from the list of those that the
3
packet filter monitors.
Marks the interface as no longer running.
4
7.3 Obtaining the Simple Lock and Shutting Down the
Device
The following code shows how the el_unattach( ) routine obtains the
simple lock, shuts down the device, and releases the simple lock:
s = splimp();
simple_lock(&sc->el_softc_lock);
el_shutdown(sc);
simple_unlock(&sc->el_softc_lock);
splx(s);
5
Calls the splimp( ) routine to mask all LAN hardware interrupts.
1
Upon successful completion, splimp( ) stores an integer value in the
7–2 Implementing the unattach Routine
1
2
3
4
1
2
3
4

Advertisement

Table of Contents
loading

Table of Contents