MityDSP Documentation Index
Public Member Functions | Protected Attributes
tcNetDrvr Class Reference

#include <net/net_drvr/net_drvr.h>

Inheritance diagram for tcNetDrvr:
tcNetDrvr_645x tcNetDrvr_B

List of all members.

Public Member Functions

 tcNetDrvr (unsigned char *apMacAddr, void *apAddress, int anLevel, int anNumMacFilters=1)
 ~tcNetDrvr ()
virtual int open (tfNetRxCallback afRxCb, void *apUser)
virtual int open (tfNetRxCallback afRxCb, tfNetBufCallback afBufCb, void *apUser)
virtual int xmit (void *apBuffer, int anLen, bool abAccumulate=false)
virtual int mac_filter (unsigned char *apMac, bool abAdd)
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 ()

Protected Attributes

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.

Detailed Description

This class is the MityDSP Ethenet driver base class. Your application will create an object of a class derived from this class, then pass that object to the MityDSP net stack during startup, or if you are using raw network packets rather than the MityDSP net stack you may interface directly to the object derived from this class.

Attention:
This is a virtual class, you must derive a class from this class or use one of the class types provided with the MityDSP SDK.

Constructor & Destructor Documentation

tcNetDrvr::tcNetDrvr ( unsigned char *  apMacAddr,
void *  apAddress,
int  anLevel,
int  anNumMacFilters = 1 
)

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]anNumMacFiltersOptional parameter to indicate the number of MAC address filters available in the device (default: 1).
Note:
The driver will not start running until you call the function tcNetDrvr::open.
tcNetDrvr::~tcNetDrvr ( )

Default destructor.


Member Function Documentation

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

This function starts the Ethernet driver.

Parameters:
[in]afRxCbPointer to the packet receive function the driver should call.
[in]apUserData specific to the packet receive function.
Returns:
Zero if successful.

Reimplemented in tcNetDrvr_B, and tcNetDrvr_645x.

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

This routine is used to start the Ethernet driver, 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 in tcNetDrvr_B, and tcNetDrvr_645x.

int tcNetDrvr::xmit ( void *  apBuffer,
int  anLen,
bool  abAccumulate = false 
)
virtual

This function transmits an Ethernet packet over the network.

Note:
This function may block briefly while the hardware completes transmission of the previous packet.
Parameters:
[in]apBufferPointer to the packet to transmit.
[in]anLenNumber of bytes in the Ethernet packet.
[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:
Zero if successful or -1 if error.

Reimplemented in tcNetDrvr_B, and tcNetDrvr_645x.

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

This function is the base class version of mac_filter. Unless overridden, there is no MAC filtering and -1 is always returned.

Parameters:
[in]apMacPointer to MAC address to filter.
[in]abAddIf true, the filter is added, otherwise it is removed (if it existed).
Returns:
Index of filter added/removed, or -1 on error.

Reimplemented in tcNetDrvr_B, and tcNetDrvr_645x.

const unsigned char * tcNetDrvr::mac_addr ( int  anFilter = 0)

This function retrieves the MAC address of the Ethernet driver.

Returns:
A pointer to this interface's 6 byte MAC address.

Example

void format_mac_as_text(tcNetDrvr *drvr, char *text)
{
unsigned char *mac;
mac = drvr->mac_addr();
sprintf(text, "%02X:%02X:%02X:%02X:%02X:%02X",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
void tcNetDrvr::get_stats ( tsNetDrvrStats apStats)

This function retrieves the driver stats.

Parameters:
[out]apStatsPointer to structure to receive the stats.
Returns:
None.

Example

void format_stats (tcNetDrvr *drvr, char *text)
{
drvr->get_stats (&stats);
sprintf (text, "ISR Count: %d", stats.isr_cnt);
}
unsigned int tcNetDrvr::PhyProbe ( void  )

This routine probes for valid MII manufacturer registers.

Returns:
Returns register offset (default: 1)
void tcNetDrvr::SetPhy ( tcDspNetPhy apPhy)

This routine sets the member phy device to a phy specified by application code

Parameters:
apPhythe phy for the driver to use
unsigned short tcNetDrvr::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.

Reimplemented in tcNetDrvr_645x.

int tcNetDrvr::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 in tcNetDrvr_645x.

bool tcNetDrvr::LinkUp ( void  )

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

Returns:
Boolean indicating whether or not link is up.

Reimplemented in tcNetDrvr_645x.

teNetPhyType tcNetDrvr::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 in tcNetDrvr_645x.

bool tcNetDrvr::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 in tcNetDrvr_645x.

tcDspNetPhy* tcNetDrvr::GetPhy ( )
inline

Member Data Documentation

volatile unsigned int* tcNetDrvr::mpBaseAddr
protected

firmware base address.

unsigned short tcNetDrvr::mnMyIntMask
protected

core interrupt mask.

int tcNetDrvr::mnMyIntLevel
protected

core interrupt level.

int tcNetDrvr::mnMyIntVector
protected

core interrupt vector.

int tcNetDrvr::mnNumMacFilters
protected

number of MAC filters available

unsigned char** tcNetDrvr::maMacAddr
protected

MAC address for the network interface.

bool tcNetDrvr::mbOpen
protected

Set to true when the device is open.

tsNetDrvrStats tcNetDrvr::msStats
protected

Driver stats.

tfNetRxCallback tcNetDrvr::mfRxCallback
protected

Pointer to packet receive function.

tfNetBufCallback tcNetDrvr::mfRxBufCallback
protected

Pointer to receive buffer allocation function.

void* tcNetDrvr::mpUserArg
protected

Receive callback specific data.

tcDspNetPhy* tcNetDrvr::mpPhy
protected

PHY device in use.


  
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.