11

Implementing the Reset Section

The reset section of a network device driver contains the code that resets the LAN adapter when there is a network failure and there is a need to restart the device. It resets all of the counters and local variables and can free up and reallocate all of the buffers that the network driver uses.

The if_el device driver implements the following routines in its reset section:

el_reset( ) (Section 11.1)

el_reset_locked( ) (Section 11.2)

11.1Implementing the el_reset Routine

The el_reset( ) routine is a jacket routine that performs the following tasks:

Determines whether the user removes the PCMCIA card from the slot

Sets the IPL and obtains the simple lock

Calls the el_reset_locked( ) routine to reset the device

Releases the simple lock and resets the IPL

The following code shows how this is done:

static void el_reset(int unit)

{

struct el_softc *sc = el_softc[unit]; struct ifnet *ifp = &sc->is_if;

int s;

if (sc->cardout) return; 1 s = splimp(); 2 simple_lock(sc->el_softc_lock);

el_reset_locked(sc, ifp, unit);

3

simple_unlock(sc->el_softc_lock); splx(s);

4

1

2

If the user has removed the PCMCIA card from the slot, returns to the calling routine.

Calls the splimp( ) routine to mask all LAN hardware interrupts before obtaining the simple lock for the el_softc resource.

Implementing the Reset Section 11–1

Page 123
Image 123
Compaq AA-RNG2A-TE manual Implementing the Reset Section, Implementing the elreset Routine