VxWorks Reference Manual : Libraries
if_fei - Intel 82557 Ethernet network interface driver
feiattach( ) - publish the fei network interface
This module implements the Intel 82557 Ethernet network interface driver.
This driver is designed to be moderately generic, operating unmodified across the entire range of architectures and targets supported by VxWorks. This driver must be given several target-specific parameters, and some external support routines must be provided. These parameters, and the mechanisms used to communicate them to the driver, are detailed below.
This driver supports up to four individual units.
The user-callable routine is feiattach( ), which publishes the fei interface and performs some initialization.
After calling feiattach( ) to publish the interface, an initialization routine must be called to bring the device up to an operational state. The initialization routine is not a user-callable routine; upper layers call it when the interface flag is set to UP, or when the interface's IP address is set.
There is a global variable feiIntConnect which specifies the interrupt connect routine to be used depending on the BSP. This is by default set to intConnect( ) and the user can override this to use any other interrupt connect routine ( say pciIntConnect( ) ) in sysHwInit( ) or any device specific initialization routine called in sysHwInit( ).
- shared memory address
- This parameter is passed to the driver via feiattach( ).
The Intel 82557 device is a DMA-type device and typically shares access to some region of memory with the CPU. This driver is designed for systems that directly share memory between the CPU and the 82557.
This parameter can be used to specify an explicit memory region for use by the 82557. This should be done on targets that restrict the 82557 to a particular memory region. The constant NONE can be used to indicate that there are no memory limitations, in which case the driver attempts to allocate the shared memory from the system space.
- number of Command, Receive, and Loanable-Receive Frame Descriptors
- These parameters are passed to the driver via feiattach( ).
The Intel 82557 accesses frame descriptors (and their associated buffers) in memory for each frame transmitted or received. The number of frame descriptors can be configured at run-time using these parameters.
- Ethernet address
- This parameter is obtained by a call to an external support routine.
This driver requires the following external support function:
STATUS sys557Init (int unit, BOARD_INFO *pBoard)This routine performs any target-specific initialization required before the 82557 device is initialized by the driver. The driver calls this routine every time it wants to [re]initialize the device. This routine returns OK, or ERROR if it fails.
The driver uses cacheDmaMalloc( ) to allocate memory to share with the 82557. The size of this area is affected by the configuration parameters specified in the feiattach( ) call. The size of one RFD (Receive Frame Descriptor) is is the same as one CFD (Command Frame Descriptor): 1536 bytes. For more information about RFDs and CFDs, see the Intel 82557 User's Manual.
Either the shared memory region must be non-cacheable, or else the hardware must implement bus snooping. The driver cannot maintain cache coherency for the device because fields within the command structures are asynchronously modified by both the driver and the device, and these fields may share the same cache line.
Additionally, this version of the driver does not handle virtual-to-physical or physical-to-virtual memory mapping.
The only adjustable parameters are the number of Frame Descriptors that will be created at run-time. These parameters are given to the driver when feiattach( ) is called. There is one CFD and one RFD associated with each transmitted frame and each received frame, respectively. For memory-limited applications, decreasing the number of CFDs and RFDs may be desirable. Increasing the number of CFDs will provide no performance benefit after a certain point. Increasing the number of RFDs will provide more buffering before packets are dropped. This can be useful if there are tasks running at a higher priority than the net task.
if_fei, ifLib, Intel 82557 User's Manual
feiattach( ) - publish the fei network interface
STATUS feiattach ( int unit, /* unit number */ char * memBase, /* address of shared memory (NONE = malloc) */ int nCFD, /* command frames (0 = default) */ int nRFD, /* receive frames (0 = default) */ int nRFDLoan /* loanable rx frames (0 = default, -1 = 0) */ )
This routine publishes the fei interface by filling in a network interface record and adding the record to the system list.
The 82557 shares a region of main memory with the CPU. The caller of this routine can specify the address of this shared memory region through the memBase parameter; if memBase is set to the constant NONE, the driver will allocate the shared memory region.
If the caller provides the shared memory region, the driver assumes that this region does not require cache coherency operations.
If the caller indicates that feiattach( ) must allocate the shared memory region, feiattach( ) will use cacheDmaMalloc( ) to obtain a block of non-cacheable memory. The attributes of this memory will be checked, and if the memory is not both read and write coherent, feiattach( ) will abort and return ERROR.
A default number of 32 command (transmit) and 32 receive frames can be selected by passing zero in the parameters nCFD and nRFD, respectively. If nCFD or nRFD is used to select the number of frames, the values should be greater than two.
A default number of 8 loanable receive frames can be selected by passing zero in the parameters nRFDLoan, else set nRFDLoan to the desired number of loanable receive frames. If nRFDLoan is set to -1, no loanable receive frames will be allocated/used.
OK, or ERROR if the driver could not be published and initialized.