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 =
int s;
if
el_reset_locked(sc, ifp, unit);
3
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