Software Drivers

xaxiethernet.c File Reference


Detailed Description

The APIs in this file takes care of the primary functionalities of the driver. The APIs in this driver take care of the following:

 Ver   Who  Date     Changes
 ----- ---- -------- -------------------------------------------------------
 1.00a asa  6/30/10 First release based on the ll temac driver
 1.02a asa  2/16/11 Made changes in XAxiEthernet_Reset to insert delays.
 3.02a srt  4/13/13 Removed Warnings (CR 704998).

 

#include "xaxiethernet.h"

Functions

 xdbg_stmnt (int indent_on=0;) xdbg_stmnt(u32 _xaxiethernet_rir_value
int XAxiEthernet_CfgInitialize (XAxiEthernet *InstancePtr, XAxiEthernet_Config *CfgPtr, u32 EffectiveAddress)
void XAxiEthernet_Start (XAxiEthernet *InstancePtr)
void XAxiEthernet_Stop (XAxiEthernet *InstancePtr)
void XAxiEthernet_Reset (XAxiEthernet *InstancePtr)
int XAxiEthernet_SetMacAddress (XAxiEthernet *InstancePtr, void *AddressPtr)
void XAxiEthernet_GetMacAddress (XAxiEthernet *InstancePtr, void *AddressPtr)
int XAxiEthernet_SetOptions (XAxiEthernet *InstancePtr, u32 Options)
int XAxiEthernet_ClearOptions (XAxiEthernet *InstancePtr, u32 Options)
u32 XAxiEthernet_GetOptions (XAxiEthernet *InstancePtr)
u16 XAxiEthernet_GetOperatingSpeed (XAxiEthernet *InstancePtr)
int XAxiEthernet_SetOperatingSpeed (XAxiEthernet *InstancePtr, u16 Speed)
void XAxiEthernet_SetBadFrmRcvOption (XAxiEthernet *InstancePtr)
void XAxiEthernet_ClearBadFrmRcvOption (XAxiEthernet *InstancePtr)
void XAxiEthernet_DisableControlFrameLenCheck (XAxiEthernet *InstancePtr)
void XAxiEthernet_EnableControlFrameLenCheck (XAxiEthernet *InstancePtr)
void XAxiEthernet_PhySetMdioDivisor (XAxiEthernet *InstancePtr, u8 Divisor)
void XAxiEthernet_PhyRead (XAxiEthernet *InstancePtr, u32 PhyAddress, u32 RegisterNum, u16 *PhyDataPtr)
void XAxiEthernet_PhyWrite (XAxiEthernet *InstancePtr, u32 PhyAddress, u32 RegisterNum, u16 PhyData)


Function Documentation

int XAxiEthernet_CfgInitialize ( XAxiEthernet InstancePtr,
XAxiEthernet_Config CfgPtr,
u32  EffectiveAddress 
)

XAxiEthernet_CfgInitialize initializes an AXI Ethernet device along with the InstancePtr that references it.

The PHY is setup independently from the Ethernet core. Use the MII or whatever other interface may be present for setup.

Parameters:
InstancePtr references the memory instance to be associated with the AXI Ethernet core instance upon initialization.
CfgPtr references the structure holding the hardware configuration for the Axi Ethernet core to initialize.
EffectiveAddress is the processor address used to access the base address of the AXI Ethernet instance. In systems with an MMU and virtual memory, EffectiveAddress is the virtual address mapped to the physical in ConfigPtr->Config.BaseAddress. In systems without an active MMU, EffectiveAddress should be set to the same value as ConfigPtr->Config.BaseAddress.
Returns:
XST_SUCCESS.
Note:
None.

void XAxiEthernet_ClearBadFrmRcvOption ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_ClearBadFrmRcvOption is used to disable the bad frame receive option.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
None.
Note:
None.

int XAxiEthernet_ClearOptions ( XAxiEthernet InstancePtr,
u32  Options 
)

XAxiEthernet_ClearOptions clears the options, Options for the Axi Ethernet, specified by InstancePtr. Axi Ethernet should be stopped with XAxiEthernet_Stop() before changing options.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Options is a bitmask of OR'd XAE_*_OPTION values for options to clear. Options not specified are not affected.
Returns:
  • XST_SUCCESS on successful completion.
  • XST_DEVICE_IS_STARTED if the device has not been stopped.
Note:
See xaxiethernet.h for a description of the available options.

void XAxiEthernet_DisableControlFrameLenCheck ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_DisableControlFrameLenCheck is used to disable the length check for control frames (pause frames). This means once the API is called, control frames larger than the minimum frame length are accepted.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
None.
Note:
None.

void XAxiEthernet_EnableControlFrameLenCheck ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_EnableControlFrameLenCheck is used to enable the length check for control frames (pause frames). After calling the API, all control frames received will be checked for proper length (less than minimum frame length). By default, upon normal start up, control frame length check is enabled. Hence this API needs to be called only if previously the control frame length check has been disabled by calling the API XAxiEthernet_DisableControlFrameLenCheck.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
None.
Note:
None.

void XAxiEthernet_GetMacAddress ( XAxiEthernet InstancePtr,
void *  AddressPtr 
)

XAxiEthernet_GetMacAddress gets the MAC address for the Axi Ethernet, specified by InstancePtr into the memory buffer specified by AddressPtr.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
AddressPtr references the memory buffer to store the retrieved MAC address. This memory buffer must be at least 6 bytes in length.
Returns:
None.
Note:
This routine also supports the extended/new VLAN and multicast mode. The XAE_RAF_NEWFNCENBL_MASK bit dictates which offset will be configured.

u16 XAxiEthernet_GetOperatingSpeed ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_GetOperatingSpeed gets the current operating link speed. This may be the value set by XAxiEthernet_SetOperatingSpeed() or a hardware default.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
Returns the link speed in units of megabits per second (10 / 100 / 1000). Can return a value of 0, in case it does not get a valid speed from EMMC.
Note:
None.

u32 XAxiEthernet_GetOptions ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_GetOptions returns the current option settings.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
Returns a bitmask of XAE_*_OPTION constants, each bit specifying an option that is currently active.
Note:
See xaxiethernet.h for a description of the available options.

void XAxiEthernet_PhyRead ( XAxiEthernet InstancePtr,
u32  PhyAddress,
u32  RegisterNum,
u16 *  PhyDataPtr 
)

void XAxiEthernet_PhySetMdioDivisor ( XAxiEthernet InstancePtr,
u8  Divisor 
)

XAxiEthernet_PhySetMdioDivisor sets the MDIO clock divisor in the Axi Ethernet,specified by InstancePtr to the value, Divisor. This function must be called once after each reset prior to accessing MII PHY registers.

From the Virtex-6(TM) and Spartan-6 (TM) Embedded Tri-Mode Ethernet MAC User's Guide, the following equation governs the MDIO clock to the PHY:

 			f[HOSTCLK]
	f[MDC] = -----------------------
			(1 + Divisor) * 2
 

where f[HOSTCLK] is the bus clock frequency in MHz, and f[MDC] is the MDIO clock frequency in MHz to the PHY. Typically, f[MDC] should not exceed 2.5 MHz. Some PHYs can tolerate faster speeds which means faster access.

Parameters:
InstancePtr references the Axi Ethernet instance on which to operate.
Divisor is the divisor value to set within the range of 0 to XAE_MDIO_MC_CLK_DVD_MAX.
Note:
None.

void XAxiEthernet_PhyWrite ( XAxiEthernet InstancePtr,
u32  PhyAddress,
u32  RegisterNum,
u16  PhyData 
)

void XAxiEthernet_Reset ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_Reset does not perform a soft reset of the AxiEthernet core. AxiEthernet hardware is reset by the device connected to the AXI4-Stream interface. This function inserts some delay before proceeding to check for MgtRdy bit. The delay is necessary to be at a safe side. It takes a while for the reset process to complete and for any of the AxiEthernet registers to be accessed. It then checks for MgtRdy bit in IS register to know if AxiEthernet reset is completed or not. Subsequently it calls one more driver function to complete the AxiEthernet hardware initialization.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Note:
It is the responsibility of the user to reset the AxiEthernet hardware before using it. AxiEthernet hardware should be reset through the device connected to the AXI4-Stream interface of AxiEthernet.

void XAxiEthernet_SetBadFrmRcvOption ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_SetBadFrmRcvOption is used to enable the bad frame receive option. If enabled, this option ensures that bad receive frames are allowed and passed to the AXI4-Stream interface as if they are good frames.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
None.
Note:
None

int XAxiEthernet_SetMacAddress ( XAxiEthernet InstancePtr,
void *  AddressPtr 
)

XAxiEthernet_SetMacAddress sets the MAC address for the Axi Ethernet device, specified by InstancePtr to the MAC address specified by AddressPtr. The Axi Ethernet device must be stopped before calling this function.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
AddressPtr is a reference to the 6-byte MAC address to set.
Returns:
  • XST_SUCCESS on successful completion.
  • XST_DEVICE_IS_STARTED if the Axi Ethernet device has not stopped,
Note:
This routine also supports the extended/new VLAN and multicast mode. The XAE_RAF_NEWFNCENBL_MASK bit dictates which offset will be configured.

int XAxiEthernet_SetOperatingSpeed ( XAxiEthernet InstancePtr,
u16  Speed 
)

XAxiEthernet_SetOperatingSpeed sets the current operating link speed. For any traffic to be passed, this speed must match the current MII/GMII/SGMII/RGMII link speed.

Parameters:
InstancePtr references the Axi Ethernet on which to operate.
Speed is the speed to set in units of Mbps. Valid values are 10, 100, or 1000.
Returns:
- XST_SUCCESS on successful setting of speed.
  • XST_FAILURE, if the speed cannot be set for the present harwdare configuration.
Note:
None.

int XAxiEthernet_SetOptions ( XAxiEthernet InstancePtr,
u32  Options 
)

XAxiEthernet_SetOptions enables the options, Options for the Axi Ethernet, specified by InstancePtr. Axi Ethernet should be stopped with XAxiEthernet_Stop() before changing options.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Options is a bitmask of OR'd XAE_*_OPTION values for options to set. Options not specified are not affected.
Returns:
  • XST_SUCCESS on successful completion.
  • XST_DEVICE_IS_STARTED if the device has not been stopped.
Note:
See xaxiethernet.h for a description of the available options.

void XAxiEthernet_Start ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_Start starts the Axi Ethernet device as follows:

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
None.
Note:
None.

void XAxiEthernet_Stop ( XAxiEthernet InstancePtr  ) 

XAxiEthernet_Stop gracefully stops the Axi Ethernet device as follows:

XAxiEthernet_Stop does not modify any of the current device options.

Since the transmitter is not disabled, frames currently in internal buffers or in process by a DMA engine are allowed to be transmitted.

Parameters:
InstancePtr is a pointer to the Axi Ethernet instance to be worked on.
Returns:
None
Note:
None.

xdbg_stmnt ( int  indent_on = 0;  ) 

Copyright @ 1995-2014 Xilinx, Inc. All rights reserved.