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

#include <net/net_drvr/net_drvr_b.h>

Inheritance diagram for tcNetDrvr_B:
tcNetDrvr

List of all members.

Public Member Functions

 tcNetDrvr_B (unsigned char *apMacAddr, void *apAddress, int anLevel=MityDSP::gnAutoLevel, bool abUseTxQdma=true, bool abUseRxQdma=true, int anRxThreadPriority=gnDefaultRxThreadPriority)
 ~tcNetDrvr_B ()
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)
- 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)
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)
tcDspNetPhyGetPhy ()

Static Public Attributes

static const int gnDefaultRxThreadPriority = 14

Protected Member Functions

void NetB_Isr (void)
void RxDmaThread (void)
int WaitLastPktOut (void)
void ProgramMac (int anIdx, unsigned char *apMac)

Static Protected Member Functions

static int isr_dispatch (Arg ahMyObject)
static int rcvr_dma_dispath (Arg ahMyObject)

Protected Attributes

SEM_Handle mhTxDataReady
 Semaphore for use by TX DMA engine.
SEM_Handle mhRxDataReady
 Semaphore for use by RX DMA engine.
LCK_Handle mhMutex
 Serialize access, where required.
CACHE_L2Mode msL2Mode
bool mbUseTxQdma
 Controls TX DMA usage.
bool mbUseRxQdma
 Controls RX DMA usage.
int mnRxThreadPriority
 Sets RX thread priority (if DMA used)
unsigned int mnPhyAddr
 Default PHY internal address.
unsigned int * maStaging
 DMA staging buffer.
unsigned int * maStagingMem
 Staging buffer pre cache alignment.
int mnTxLength
 Bytes currently in TX FIFO.
- 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 MityDSP Ethenet driver class for a 32 bit wide data bus to the FPGA and a FIFO memory map for the FPGA packet buffers.


Constructor & Destructor Documentation

tcNetDrvr_B::tcNetDrvr_B ( unsigned char *  apMacAddr,
void *  apAddress,
int  anLevel = MityDSP::gnAutoLevel,
bool  abUseTxQdma = true,
bool  abUseRxQdma = true,
int  anRxThreadPriority = gnDefaultRxThreadPriority 
)

This constructor creates the Ethernet driver.

Parameters:
[in]apMacAddrThe device's 6 byte MAC address.
[in]apAddressThe FPGA base address for the Ethernet device.
[in]anLevelOptional parameter to force a chained interrupt at the specified level.
[in]abUseTxQdmaUse QDMA for large packet transmits (default: true)
[in]abUseRxQdmaUse QDMA for receive (default: true)
[in]anRxThreadPrioritySets priority of the receive DMA thread (used only when abUseRxQdma is true, default: 14)
Note:
In general the Receive DMA thread should be the highest priority thread in the system. It simply acknowledges the DMA, call the receive callback (which usually mailboxes the completed buffer to a RX thread), gets a new buffer, and re-enables receive interrupts.
See also:
tcNetDrvr::tcNetDrvr
tcNetDrvr_B::~tcNetDrvr_B ( )

Destructor for the Ethernet driver.

See also:
tcNetDrvr::tcNetDrvr

Member Function Documentation

int tcNetDrvr_B::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.

Reimplemented from tcNetDrvr.

int tcNetDrvr_B::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_B::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_B::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.

int tcNetDrvr_B::isr_dispatch ( Arg  ahMyObject)
staticprotected

Static interrupt dispatch routine. Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.

Parameters:
[in]ahMyObjectThe "this->" pointer for the instance of tcNetDrvr_B associated with this ISR.
Returns:
0
int tcNetDrvr_B::rcvr_dma_dispath ( Arg  ahMyObject)
staticprotected

Static thread dispatch routine. Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the thread dispatcher.

Parameters:
[in]ahMyObjectThe "this->" pointer for the instance of tcNetDrvr_B associated with this thread.
Returns:
0
void tcNetDrvr_B::NetB_Isr ( void  )
protected

This routine is the ISR that services ethernet receive interrupts. If DMA transfers are being used, interrupts are disabled and the rcvr_thread is notified via a semaphore to schedule a DMA. Otherwise, data is copied from the device to a staging buffer.

Returns:
None.
void tcNetDrvr_B::RxDmaThread ( void  )
protected

When using DMA transfers, this thread is started to receive data sent from within the ISR. The ISR sets a semaphore, which wakes up this thread to monitor for completion of the DMA. When the DMA is complete, the buffer is sent to the receive callback.

Returns:
None.
int tcNetDrvr_B::WaitLastPktOut ( void  )
protected

This routine returns whether or not the last packet queued for transmit has been sent.

Returns:
Zero if it's OK to transmit, -1 otherwise.
void tcNetDrvr_B::ProgramMac ( int  anIdx,
unsigned char *  apMac 
)
protected

Internal method to update a particular MAC filter in the core.

Parameters:
[in]anIdxFilter number to program
[in]apMacPointer to a six-byte MAC address
Returns:
None

Member Data Documentation

const int tcNetDrvr_B::gnDefaultRxThreadPriority = 14
static
const int tcNetDrvr_B::gnMAX_XFER_SIZE = TCP_MSS + PBUF_LINK_HLEN + 40
staticprotected

Max network packet size.

const int tcNetDrvr_B::gnETH_HDR_SIZE = PBUF_LINK_HLEN
staticprotected

Normally 14 bytes for ethernet.

const int tcNetDrvr_B::gnCRC_SIZE = 4
staticprotected

Firmware CRC on end of packet.

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

Conversion from low res clock ticks to msecs.

SEM_Handle tcNetDrvr_B::mhTxDataReady
protected

Semaphore for use by TX DMA engine.

SEM_Handle tcNetDrvr_B::mhRxDataReady
protected

Semaphore for use by RX DMA engine.

LCK_Handle tcNetDrvr_B::mhMutex
protected

Serialize access, where required.

CACHE_L2Mode tcNetDrvr_B::msL2Mode
protected
bool tcNetDrvr_B::mbUseTxQdma
protected

Controls TX DMA usage.

bool tcNetDrvr_B::mbUseRxQdma
protected

Controls RX DMA usage.

int tcNetDrvr_B::mnRxThreadPriority
protected

Sets RX thread priority (if DMA used)

unsigned int tcNetDrvr_B::mnPhyAddr
protected

Default PHY internal address.

unsigned int* tcNetDrvr_B::maStaging
protected

DMA staging buffer.

unsigned int* tcNetDrvr_B::maStagingMem
protected

Staging buffer pre cache alignment.

int tcNetDrvr_B::mnTxLength
protected

Bytes currently in TX FIFO.


  
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.