MityDSP Documentation Index
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
tcNetDrvr_645x Class Reference

#include <net/net_drvr/net_drvr_645x.h>

Inheritance diagram for tcNetDrvr_645x:
tcNetDrvr

List of all members.

Public Member Functions

 tcNetDrvr_645x (unsigned char *apMacAddr, int anHWILevel)
 ~tcNetDrvr_645x ()
int open (tfNetRxCallback afRxCb, void *apUser)
int open (tfNetRxCallback afRxCb, tfNetBufCallback afBufCb, void *apUser)
int xmit (void *apBuffer, int anLen, bool abAccumulate=false)
int mac_filter (unsigned char *apMac, bool abAdd)
unsigned short GetMIIRegister (unsigned int anRegAddr, unsigned int anPhyAddr=0xFFFFFFFF)
int SetMIIRegister (unsigned int anRegAddr, unsigned int anValue, unsigned int anPhyAddr=0xFFFFFFFF)
bool LinkUp (void)
teNetPhyType GetPhyType (void)
bool GetPhyStatus (tsNetPhyStatus &arPhyStatus)
- Public Member Functions inherited from tcNetDrvr
 tcNetDrvr (unsigned char *apMacAddr, void *apAddress, int anLevel, int anNumMacFilters=1)
 ~tcNetDrvr ()
const unsigned char * mac_addr (int anFilter=0)
void get_stats (tsNetDrvrStats *apStats)
unsigned int PhyProbe (void)
void SetPhy (tcDspNetPhy *apPhy)
tcDspNetPhyGetPhy ()

Protected Member Functions

int dispatcher (void)
int rxallocator (void)

Static Protected Member Functions

static int dispatch_dispatcher (Arg apThis)
static int dispatch_rxallocator (Arg apThis)

Protected Attributes

unsigned int mnPhyAddr
 connect PHY address found during probe
CACHE_L2Size msL2Mode
 our level 2 cache mode
int mnRxThreadPriority
 Sets RX thread priority (if DMA used)
void * mpWorkingTxDesc
SEM_Handle mhRxPacketSem
 notifies
LCK_Handle mhMutex
- Protected Attributes inherited from tcNetDrvr
volatile unsigned int * mpBaseAddr
 firmware base address.
unsigned short mnMyIntMask
 core interrupt mask.
int mnMyIntLevel
 core interrupt level.
int mnMyIntVector
 core interrupt vector.
int mnNumMacFilters
 number of MAC filters available
unsigned char ** maMacAddr
 MAC address for the network interface.
bool mbOpen
 Set to true when the device is open.
tsNetDrvrStats msStats
 Driver stats.
tfNetRxCallback mfRxCallback
 Pointer to packet receive function.
tfNetBufCallback mfRxBufCallback
 Pointer to receive buffer allocation function.
void * mpUserArg
 Receive callback specific data.
tcDspNetPhympPhy
 PHY device in use.

Static Protected Attributes

static const int gnMAX_XFER_SIZE = TCP_MSS + PBUF_LINK_HLEN + 40
 Max network packet size.
static const int gnETH_HDR_SIZE = PBUF_LINK_HLEN
 Normally 14 bytes for ethernet.
static const int gnCRC_SIZE = 4
 Firmware CRC on end of packet.
static unsigned int mnTicksPerMSec = CLK_countspms() / CLK_getprd()
 Conversion from low res clock ticks to msecs.

Detailed Description

This class is the TMS320645x Ethenet driver class. It is currently an alpha level driver. Support for nominal MDIO querying, transmission and reception of packets for the 100 MBit standard MII interface is available. This class is intended to integrate with the MityDSP lwIP TCP/IP stack implementation.


Constructor & Destructor Documentation

tcNetDrvr_645x::tcNetDrvr_645x ( unsigned char *  apMacAddr,
int  anHWILevel 
)

This constructor creates the Ethernet driver.

Parameters:
[in]apMacAddrThe device's 6 byte MAC address.
[in]anHWILevelThe interrupt level to be mapped for the 6455 ethernet I/O
Note:
the HWI Level must have the dispatcher enabled in the BIOS .tcf file.
Todo:
There is a receive DMA PBUF allocation thread that runs at highest system priority. This priority should be added as a constructor arguement.
Todo:
support for multicast filter must be tested.
See also:
tcNetDrvr::tcNetDrvr

Initialize the MDIO and locate the connected PHY From SPRU975B To have the application software or device driver initialize the MDIO device, perform the following:

  1. Configure the PREAMBLE and CLKDIV bits in the CONTROL register.
  2. Enable the MDIO module by setting the ENABLE bit in the CONTROL register.
  3. The ALIVE register can be read after a delay to determine which PHYs responded, and the LINK register can determine which of those (if any) already have a link.
  4. Set up the appropriate PHY addresses in the USERPHYSEL n register, and set the LINKINTENB bit to enable a link change event interrupt if desirable.
  5. If an interrupt on a general MDIO register access is desired, set the corresponding bit in the USERINTMASKSET register to use the USERACCESS n register. If only one PHY is to be used, the application software can set up one of the USERACCESS n registers to trigger a completion interrupt. The other register is not set up.
tcNetDrvr_645x::~tcNetDrvr_645x ( )

Destructor for the Ethernet driver.

See also:
tcNetDrvr::tcNetDrvr

Member Function Documentation

int tcNetDrvr_645x::open ( tfNetRxCallback  afRxCb,
void *  apUser 
)
virtual

This routine is used to open an ethernet interface. The receive ISR (and receive thread, if DMAs are being used) are installed, the MAC address is set, and the chip is enabled.

Parameters:
[in]afRxCbPointer to the receive data callback function.
[in]apUserUser data (for the callback).
Returns:
0 if successful, -1 otherwise.

From SPRU975

  1. If enabled, clear the device interrupt enable in EWCTL.
  2. Clear the MACCONTROL, RXCONTROL, and TXCONTROL registers (not necessary immediately after reset).
  3. Initialize all 16 Head Descriptor Pointer registers (RX n HDP and TX n HDP) to 0.
  4. Clear all 36 statistics registers by writing 0 (not necessary immediately after reset).
  5. Initialize all 32 receive address RAM locations to 0. Set up the addresses to be matched to the eight receive channels and the addresses to be filtered, through programming the MACINDEX, MACADDRHI, and MACADDRLO registers.
  6. Initialize the RX n FREEBUFFER, RX n FLOWTHRESH, and RXFILTERLOWTHRESH registers, if buffer flow control is to be enabled. Program the FIFOCONTROL register is FIFO flow control is desired.
  7. Most device drivers open with no multicast addresses, so clear the MACHASH1 and MACHASH2 registers.
  8. Write the RXBUFFEROFFSET register value (typically zero).
  9. Initially clear all unicast channels by writing FFh to the RXUNICASTCLEAR register. If unicast is desired, it can be enabled now by writing the RXUNICASTSET register. Some drivers will default to unicast on device open while others will not.

If you desire to transfer jumbo frames, set the RXMAXLEN register to the maximum frame length you want to allow to be received.

  1. Set up the RXMBPENABLE register with an initial configuration. The configuration is based on the current receive filter settings of the device driver. Some drivers may enable things like broadcast and multicast packets immediately, while others may not.
  2. Set the appropriate configuration bits in the MACCONTROL register (do not set the GMIIEN bit yet).
  3. Clear all unused channel interrupt bits by writing RXINTMASKCLEAR and TXINTMASKCLEAR.
  4. Enable the receive and transmit channel interrupt bits in RXINTMASKSET and TXINTMASKSET for the channels to be used, and enable the HOSTMASK and STATMASK bits using the MACINTMASKSET register.
  5. Initialize the receive and transmit descriptor list queues using the 8K descriptor memory block contained in the EMAC control module.
  6. Prepare receive by writing a pointer to the head of the receive buffer descriptor list to RX n HDP.
  7. Enable the receive and transmit DMA controllers by setting the RXEN bit in the RXCONTROL register and the TXEN bit in the TXCONTROL register. Then set the GMIIEN bit in MACCONTROL.
  8. If the gigabit mode is desired (available only if using GMII or RGMII interface), set the GIG bit in the MACCONTROL register.
  9. When using RMII, release the interface logic from reset by clearing the RMII_RST field of the EMAC Configuration register (EMACCFG), found at device level.
  10. Enable the device interrupt in EWCTL.

Reimplemented from tcNetDrvr.

int tcNetDrvr_645x::open ( tfNetRxCallback  afRxCb,
tfNetBufCallback  afBufCb,
void *  apUser 
)
virtual

This routine is used to open an ethernet interface, and register both a receive data callback, and a receive buffer allocation function.

Parameters:
[in]afRxCbPointer to the receive data callback function.
[in]afBufCbPointer to the receive buffer allocation function.
[in]apUserUser data (for the callback).
Returns:
0 if successful, -1 otherwise.

Reimplemented from tcNetDrvr.

int tcNetDrvr_645x::xmit ( void *  apBuffer,
int  anLength,
bool  abAccumulate = false 
)
virtual

This routine is used to transmit a buffer of data out the ethernet interface.

Parameters:
[in]apBufferPointer to the data buffer.
[in]anLengthLength of the buffer.
[in]abAccumulateTrue if this is a part of a larger message, buffer will sent to firmware TX FIFO, but not sent.
Note:
When using abAccumulate, the caller is responsible for ensuring that no other calls to xmit are made before the message is complete.
Returns:
0 if successful, -1 otherwise.

Reimplemented from tcNetDrvr.

int tcNetDrvr_645x::mac_filter ( unsigned char *  apMac,
bool  abAdd 
)
virtual

External method to add/remove a given MAC filter.

Parameters:
[in]apMacPointer to a six-byte MAC address
[in]abAddIf true, the given MAC is added, otherwise it is removed
Returns:
Index of filter, or -1 if no room or not found.

Reimplemented from tcNetDrvr.

unsigned short tcNetDrvr_645x::GetMIIRegister ( unsigned int  anRegAddr,
unsigned int  anPhyAddr = 0xFFFFFFFF 
)

This routine is used to read the current value stored in an MII Register.

Parameters:
[in]anRegAddrThe offset to the desired MII register
[in]anPhyAddrThe address of the PHY (default:0)
Returns:
MII Register contents.

The MDIO module includes a user access register (USERACCESS n ) to directly access a specified PHY device. To read a PHY register, perform the following:

  1. Ensure that the GO bit in the USERACCESS n register is cleared.
  2. Write to the GO, REGADR, and PHYADR bits in USERACCESS n corresponding to the desired PHY and PHY register.
  3. The read data value is available in the DATA bits of USERACCESS n after the module completes the read operation on the serial bus. Completion of the read operation can be determined by polling the GO and ACK bits in USERACCESS n . Once the GO bit has cleared, the ACK bit is set on a successful read.
  4. Completion of the operation sets the corresponding bit in the USERINTRAW register for the USERACCESS n used. If interrupts have been enabled on this bit using the USERINTMASKSET register, then the bit is also set in the USERINTMASKED register and an interrupt is triggered on the DSP.

Reimplemented from tcNetDrvr.

int tcNetDrvr_645x::SetMIIRegister ( unsigned int  anRegAddr,
unsigned int  anValue,
unsigned int  anPhyAddr = 0xFFFFFFFF 
)

This routine is used to set the specified 16-bit value to an MII Register.

Parameters:
[in]anRegAddrThe offset to the desired MII register
[in]anValueValue to write to the register.
[in]anPhyAddrThe address of the PHY (default:0xFFFFFFFF)
Returns:
0.

Reimplemented from tcNetDrvr.

bool tcNetDrvr_645x::LinkUp ( void  )

This routine returns whether or not the ethernet link is up. Register.

Returns:
Boolean indicating whether or not link is up.

Reimplemented from tcNetDrvr.

teNetPhyType tcNetDrvr_645x::GetPhyType ( void  )

This routine is used to get the type of PHY in use.

Returns:
Enumeration representing one of the known PHY types, or eePhyUnknown.

Reimplemented from tcNetDrvr.

bool tcNetDrvr_645x::GetPhyStatus ( tsNetPhyStatus arPhyStatus)

This routine is used to gather certain status information from the PHY.

Parameters:
[out]arPhyStatusReference to a PHY status structure.
Returns:
True if PHY status successfully decoded, false otherwise.

Reimplemented from tcNetDrvr.

int tcNetDrvr_645x::dispatcher ( void  )
protected

Interrupt handler for EMAC transmit or receive.

Upon receipt of interrupt: 1) If receive interrupt, pop the descriptor off active descriptor list, extract receive packet PBUF and pass to the lwIP input thread. Notify rxallocator that a new receive PBUF should be chained in.

2) If a transmit interrupt, check and see if more transmit PBUFS are queued and restart transmit engine.

Todo:
need to handle stats interrupt, and error interrupt and restart the core if they occur...
int tcNetDrvr_645x::dispatch_dispatcher ( Arg  apThis)
staticprotected

Class static interrupt handler dispatch routine.

Parameters:
[in]apThispointer to the driver object
int tcNetDrvr_645x::rxallocator ( void  )
protected

lwIP receive buffer allocation thread.

This thread monitors a counting semaphore from the ISR handler whenever the count increases, a new PBUF must be allocated and added to the receive chain DMA descriptor list for channel 0.

int tcNetDrvr_645x::dispatch_rxallocator ( Arg  apThis)
staticprotected

Dispatch Rx lwIP recieve buffer allocator...

Parameters:
[in]apThispointer to the driver object

Member Data Documentation

const int tcNetDrvr_645x::gnMAX_XFER_SIZE = TCP_MSS + PBUF_LINK_HLEN + 40
staticprotected

Max network packet size.

const int tcNetDrvr_645x::gnETH_HDR_SIZE = PBUF_LINK_HLEN
staticprotected

Normally 14 bytes for ethernet.

const int tcNetDrvr_645x::gnCRC_SIZE = 4
staticprotected

Firmware CRC on end of packet.

unsigned int tcNetDrvr_645x::mnTicksPerMSec = CLK_countspms() / CLK_getprd()
staticprotected

Conversion from low res clock ticks to msecs.

unsigned int tcNetDrvr_645x::mnPhyAddr
protected

connect PHY address found during probe

CACHE_L2Size tcNetDrvr_645x::msL2Mode
protected

our level 2 cache mode

int tcNetDrvr_645x::mnRxThreadPriority
protected

Sets RX thread priority (if DMA used)

void* tcNetDrvr_645x::mpWorkingTxDesc
protected
SEM_Handle tcNetDrvr_645x::mhRxPacketSem
protected

notifies

LCK_Handle tcNetDrvr_645x::mhMutex
protected

  
Generated on Mon Apr 22 2013 11:33:33 for MityDSP Net by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.