VxWorks Reference Manual : Libraries
if_mbc - Motorola 68EN302 network-interface driver
mbcattach( ) - publish the mbc network interface and initialize the driver
mbcStartOutput( ) - output packet to network interface device
mbcIntr( ) - network interface interrupt handler
This is a driver for the Ethernet controller on the 68EN302 chip. The device supports a 16-bit interface, data rates up to 10 Mbps, a dual-ported RAM, and transparent DMA. The dual-ported RAM is used for a 64-entry CAM table, and a 128-entry buffer descriptor table. The CAM table is used to set the Ethernet address of the Ethernet device or to program multicast addresses. The buffer descriptor table is partitioned into fixed-size transmit and receive tables. The DMA operation is transparent and transfers data between the internal FIFOs and external buffers pointed to by the receive- and transmit-buffer descriptors during transmits and receives.
The driver currently supports one Ethernet module controller, but it can be extended to support multiple controllers when needed. An Ethernet module is initialized by calling mbcattach( ).
The driver supports buffer loaning for performance and input/output hook routines. It does not support multicast addresses.
The driver requires that the memory used for transmit and receive buffers be allocated in cache-safe RAM area.
A glitch in the EN302 Rev 0.1 device causes the Ethernet transmitter to lock up from time to time. The driver uses a watchdog timer to reset the Ethernet device when the device runs out of transmit buffers and cannot recover within 20 clock ticks.
This device is on-chip. No jumpering diagram is necessary.
This driver presents the standard WRS network driver API: first the device unit must be attached with the mbcattach( ) routine, then it must be initialized with the mbcInit( ) routine.
The only user-callable routine is mbcattach( ), which publishes the mbc interface and initializes the driver structures.
- Ethernet module base address
- This parameter is passed to the driver via mbcattach( ).
This parameter is the base address of the Ethernet module. The driver addresses all other Ethernet device registers as offsets from this address.
- interrupt vector number
- This parameter is passed to the driver via mbcattach( ).
The driver configures the Ethernet device to use this parameter while generating interrupt ack cycles. The interrupt service routine mbcIntr( ) is expected to be attached to the corresponding interrupt vector externally, typically in sysHwInit2( ).
- number of transmit and receive buffer descriptors
- These parameters are passed to the driver via mbcattach( ).
The number of transmit and receive buffer descriptors (BDs) used is configurable by the user while attaching the driver. Each BD is 8 bytes in size and resides in the chip's dual-ported memory, while its associated buffer, 1520 bytes in size, resides in cache-safe conventional RAM. A minimum of 2 receive and 2 transmit BDs should be allocated. If this parameter is NULL, a default of 32 BDs will be used. The maximum number of BDs depends on how the dual-ported BD RAM is partitioned. The 128 BDs in the dual-ported BD RAM can partitioned into transmit and receive BD regions with 8, 16, 32, or 64 transmit BDs and corresponding 120, 112, 96, or 64 receive BDs.
- Ethernet DMA parameters
- This parameter is passed to the driver via mbcattach( ).
This parameter is used to specify the settings of burst limit, water-mark, and transmit early, which control the Ethernet DMA, and is used to set the EDMA register.
- base address of the buffer pool
- This parameter is passed to the driver via mbcattach( ).
This parameter is used to notify the driver that space for the transmit and receive buffers need not be allocated, but should be taken from a cache-coherent private memory space provided by the user at the given address. The user should be aware that memory used for buffers must be 4-byte aligned and non-cacheable. All the buffers must fit in the given memory space; no checking will be performed. This includes all transmit and receive buffers (see above) and an additional 16 receive loaner buffers, unless the number of receive BDs is less than 16, in which case that number of loaner buffers will be used. Each buffer is 1520 bytes. If this parameter is "NONE", space for buffers will be obtained by calling cacheDmaMalloc( ) in cpmattach( ).
The driver requires the following support functions:
- STATUS sysEnetAddrGet (int unit, UINT8 * addr)
- The driver expects this routine to provide the six-byte Ethernet hardware address that will be used by unit. This routine must copy the six-byte address to the space provided by addr. This routine is expected to return OK on success, or ERROR. The driver calls this routine, during device initialization, from the cpmInit( ) routine.
The driver requires the following system resource:
- one mutual exclusion semaphore
- one interrupt vector
- one watchdog timer
- 0 bytes in the initialized data section (data)
- 296 bytes in the uninitialized data section (bss)The data and BSS sections are quoted for the CPU32 architecture.
If the driver allocates the memory shared with the Ethernet device unit, it does so by calling the cacheDmaMalloc( ) routine. For the default case of 32 transmit buffers, 32 receive buffers, and 16 loaner buffers, the total size requested is 121,600 bytes. If a non-cacheable memory region is provided by the user, the size of this region should be this amount, unless the user has specified a different number of transmit or receive BDs.
This driver can only operate if the shared memory region is non-cacheable, or if the hardware implements bus snooping. The driver cannot maintain cache coherency for the device because the buffers are asynchronously modified by both the driver and the device, and these fields may share the same cache line. Additionally, the chip's dual-ported RAM must be declared as non-cacheable memory where applicable.
if_mbc, ifLib, Motorola MC68EN302 User's Manual , Motorola MC68EN302 Device Errata, May 30, 1996
mbcattach( ) - publish the mbc network interface and initialize the driver
STATUS mbcattach ( int unit, /* unit number */ void * pEmBase, /* ethernet module base address */ int inum, /* interrupt vector number */ int txBdNum, /* number of transmit buffer descriptors */ int rxBdNum, /* number of receive buffer descriptors */ int dmaParms, /* DMA parameters */ UINT8 * bufBase /* address of memory pool; NONE = malloc it */ )
The routine publishes the mbc interface by adding an mbc Interface Data Record (IDR) to the global network interface list.
The Ethernet controller uses buffer descriptors from an on-chip dual-ported RAM region, while the buffers are allocated in RAM external to the controller. The buffer memory pool can be allocated in a non-cacheable RAM region and passed as parameter bufBase. Otherwise bufBase is NULL and the buffer memory pool is allocated by the routine using cacheDmaMalloc( ). The driver uses this buffer pool to allocate the specified number of 1518-byte buffers for transmit, receive, and loaner pools.
The parameters txBdNum and rxBdNum specify the number of buffers to allocate for transmit and receive. If either of these parameters is NULL, the default value of 2 is used. The number of loaner buffers allocated is the lesser of rxBdNum and 16.
The on-chip dual ported RAM can only be partitioned so that the maximum receive and maximum transmit BDs are:
- Transmit BDs: 8, Receive BDs: 120
- Transmit BDs: 16, Receive BDs: 112
- Transmit BDs: 32, Receive BDs: 96
- Transmit BDs: 64, Receive BDs: 64
ERROR, if unit is out of range> or non-cacheable memory cannot be allocated; otherwise TRUE.
if_mbc, ifLib, Motorola MC68EN302 User's Manual
mbcStartOutput( ) - output packet to network interface device
#ifdef BSD43_DRIVER LOCAL void mbcStartOutput ( int unit /* unit number */ )
mbcStartOutput( ) takes a packet from the network interface output queue, copies the mbuf chain into an interface buffer, and sends the packet over the interface. etherOutputHookRtns are supported.
Collision stats are collected in this routine from previously sent BDs. These BDs will not be examined until after the transmitter has cycled the ring, coming upon the BD after it has been sent. Thus, collision stat collection will be delayed a full cycle through the Tx ring.
This routine is called under several possible scenarios. Each one will be described below.
The first, and most common, is when a user task requests the transmission of data. Under BSD 4.3, this results in a call to mbcOutput( ), which in turn calls ether_output( ). The routine, ether_output( ), will make a call to mbcStartOutput( ) if our interface output queue is not full, otherwise, the outgoing data is discarded. BSD 4.4 uses a slightly different model, in which the generic ether_output( ) routine is called directly, followed by a call to this routine.
The second scenario is when this routine, while executing runs out of free Tx BDs, turns on transmit interrupts and exits. When the next BD is transmitted, an interrupt occurs and the ISR does a netJobAdd of the routine which executes in the context of netTask( ) and continues sending packets from the interface output queue.
The third scenario is when the device is reset, typically when the promiscuous mode is altered; which results in a call to mbcInit( ). This resets the device, does a netJobAdd( ) of this routine to enable transmitting queued packets.
N/A
mbcIntr( ) - network interface interrupt handler
void mbcIntr ( int unit /* unit number */ )
This routine is called at interrupt level. It handles work that requires minimal processing. Interrupt processing that is more extensive gets handled at task level. The network task, netTask( ), is provided for this function. Routines get added to the netTask( ) work queue via the netJobAdd( ) command.
N/A