Initializing Simple Lock Information - Compaq Tru64 UNIX Installation Manual

Writing network device drivers
Table of Contents

Advertisement

Sets the sin_family member of the sockaddr_in data structure to
8
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;
ifp->lk_softc = &sc->el_softc_lock;
simple_lock_setup(&sc->el_softc_lock, el_lock_info);
Sets the if_affinity member of the ifnet data structure for this
1
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
NETALLCPU
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
2
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
3
structure called el_softc_lock. You need to initialize the simple
lock structure only once.
1
2
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.
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.
Implementing the Autoconfiguration Support Section (attach) 6–5
3

Advertisement

Table of Contents
loading

Table of Contents