8

Sets the sin_family member of the sockaddr_in data structure to the address family, which in this case is represented by the constant AF_INET. The socket.h file defines this and other address family constants.

6.4 Initializing Simple Lock Information

The following code shows how the el_attach( ) routine sets up simple lock information:

ifp->if_affinity = NETALLCPU; 1 ifp->lk_softc = &sc->el_softc_lock; 2

simple_lock_setup(&sc->el_softc_lock, el_lock_info);

3

1

Sets the if_affinity member of the ifnet data structure for this device to the constant NETALLCPU. The if_affinity member specifies which CPU to run on. You can set this member to one of the following constants defined in if.h:

NETMASTERCPU

Specifies that you want to funnel the network device

 

driver because you have not made it symmetric

 

multiprocessor (SMP) safe. This means that the

 

network driver is forced to execute on a single (the

 

master) CPU. This setting is not recommended. You

 

are encouraged to make your driver SMP safe.

NETALLCPU

Specifies that you do not want to funnel the network

 

device driver because you have made it SMP safe.

 

This means that the network driver can execute

 

on multiple CPUs. You make a network device

 

driver SMP safe by using the simple or complex lock

 

mechanism in all critical sections of the driver.

2

3

The if_el driver uses the simple lock mechanism and is, therefore, SMP safe.

Sets the lk_softc member of the ifnet data structure for this device to the address of the el_softc_lock. Both the if_el driver and the network software above the driver use this lock whenever modifications are made to the shared members of the ifnet data structure. Make sure to supply a lock for the shared portion of the ifnet structure also.

Calls the simple_lock_init( ) routine to initialize the simple lock structure called el_softc_lock. You need to initialize the simple lock structure only once.

Implementing the Autoconfiguration Support Section (attach) 6–5

Page 89
Image 89
Compaq AA-RNG2A-TE manual Initializing Simple Lock Information