3.3  Data Link Provider Interface (DLPI) Driver

The Data Link Provider Interface (DLPI) specifies a STREAMS-based interface between the data link provider and the data link user. DLPI enables a Data Link Service (DLS) user to access any DLPI conformant provider without special knowledge of the provider's protocol. For a complete discussion of DLPI, refer to the Data Link Provider Interface Specification (UNIX International) and STREAMS Modules and Drivers Unix SVR4.2 (UNIX Press).

The WindNet STREAMS DLPI library implements the generic Data Link Provider Interface (DLPI) Version 2.0, common for all VxWorks-specific network drivers. Figure 11 illustrates this STREAMS-based interface that provides protocol-independent access between the data link user (network layer or user application) and the data link layer (VxWorks network drivers).

3.3.1  User-Callable Routines

The DLPI interface is initialized by dlpiInit( ), during system initialization, at which point it installs the DLPI STREAMS driver in the VxWorks I/O subsystem.

3.3.2  Implementation

The WindNet STREAMS DLPI library supports up to eight Service Access Points (SAPs). Driver open calls are treated as clone opens, thereby assigning a new stream for each open. Each opened stream is bound to a SAP. There is a one-to-one correspondence between opened streams and SAPs.

The DLPI driver serves as a generic driver under which operates a network driver. The network driver hands over the received packets to the DLPI driver using the network driver's etherInputHook function pointer. This pointer is installed at the time the stream is bound to the SAP, that is, when the DL_BIND_REQ primitive is sent by the DLS user. The network driver must support etherInputHook. For more information on etherInputHook, see the manual entry for etherLib.

DLPI defines two styles of DLS provider. The WindNet STREAMS DLPI driver is a style 2 DLS provider. The style 2 provider requires a DLS user to explicitly identify the desired physical point of attachment (PPA) using the DL_ATTACH_REQ primitive.

The DLPI driver uses the STREAMS buffering mechanism; whereas the generic Wind River network drivers are based on the BSD mbufs buffering mechanism. The WindNet STREAMS DLPI driver reconciles this difference by converting every mbuf-based packet received to a packet based on STREAMS message blocks, and while transmitting, every STREAMS message block is converted to an mbuf-based packet. See the VxWorks BSP Porting Kit for guidelines on the writing of generic VxWorks network drivers.

The attach request primitive DL_ATTACH_REQ, generated by the user, should include in the attach request message the name of the network device to be attached. The attach request primitive implemented in the DLPI driver gets the name of the appropriate network device from the attach request message. It then gets the pointer to the appropriate network controller data structure from that name. The following code shows how the DLS user generates the DL_ATTACH_REQ primitive:

{
int          fd;              /* fd of interface */
char         *ppaName;        /* Name of the interface */
char         buf[64];         /* DL_ATTACH_REQ buffer */
dl_attach_req_t * dlAr = (dl_attach_req_t *)buf;
dlAr->dl_primitive = DL_ATTACH_REQ;

/* Create the DL_ATTACH_REQ primitive */

dlAr->dl_ppa = 0;
strcpy((char *)&dlAr[1], ppa_name);
ctlbuf.len = sizeof(*dlAr) + strlen(ppa_name) + 1;

/* The attach request primitive is sent to the DLPI provider. Here the 
* DLS user is an user application program. If the DLS user is a network 
* protocol module, then the attach request primitive should be sent to 
* DLS provider as an M_PROTO message
*/ 

if ( putmsg(fd, &ctlbuf, nilp(struct strbuf), 0) == -1 ) 
    {
    warn("dl_attach: putmsg failed, %s\n", errmsg(0));
    return false;
    }
...
...

}

After the DLPI driver receives a packet, it sends the packet to the appropriate stream, based on the SAP value. The packet type field in the Ethernet frame contains that SAP value. This DLPI driver supports only Ethernet frame formats. It does not support IEEE 802.3 frame formats.

3.3.3  DLPI Services

This library supports the subset of DLPI services listed in Table 4.

Table 4.   DLPI Primitives


Primitive
Service Provided


DL_ATTACH_REQ
Assign a physical point of attachment (PPA) to a stream.
DL_DETACH_REQ
Request the DLS provider to detach a physical point of attachment (PPA) from a stream.
DL_BIND_REQ
Request the DLS provider to bind a data link SAP (DLSAP) to the stream.
DL_BIND_ACK
Report the successful bind of a data link SAP to a stream, and return the bound DLSAP address to the DLS user.
DL_INFO_REQ
Request information of the DLS provider about the DLPI stream.
DL_INFO_ACK
Convey information about the DLPI stream to the DLS user by sending a message in response to DL_INFO_REQ.
DL_UNBIND_REQ
Request the DLS provider to unbind the DLSAP bound by a previous DL_BIND_REQ from this stream.
DL_ERROR_ACK
Inform the DLS user that a previously issued request or response was invalid.
DL_UNITDATA_REQ
Convey one data link service data unit (DLSDU) from the DLS provider for transmission to a peer DLS user.
DL_UNITDATA_IND
Convey one DLSDU from the DLS provider to the DLS user.
DL_OK_ACK
Acknowledge to the DLS user that a previously issued request primitive was received successfully.

For an extensive reference to DLPI Version 2.0, see the Data Link Provider Interface Specification (UNIX International) and STREAMS Modules and Drivers UNIX SVR4.2 (UNIX Press).