xxvethernet
Vitis Drivers API Documentation
xxxvethernet_example_util.c File Reference

Overview

This file implements the utility functions for the Xxv Ethernet and USXGMII example code.

It contains functions to setup USXGMII autonegotiation at desired settings and to bypass autonegotiation.

MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.0 hk 06/16/17 First release hk 02/15/18 Add support for USXGMII 1.5 rsp 06/08/20 Fix Xil_poll_timeout compilation error on microblaze. 1.6 sk 02/18/21 Use UINTPTR instead of u32 for BaseAddress variable.

 

Functions

void XxvEthernetUtilFrameHdrFormatMAC (EthernetFrame *FramePtr, char *DestAddr, char *SrcAddr)
 Set the MAC addresses in the frame. More...
 
void XxvEthernetUtilFrameHdrFormatType (EthernetFrame *FramePtr, u16 FrameType)
 Set the frame type for the specified frame. More...
 
void XxvEthernetUtilFrameSetPayloadData (EthernetFrame *FramePtr, int PayloadSize)
 This function places a pattern in the payload section of a frame. More...
 
int XxvEthernetUtilFrameVerify (EthernetFrame *CheckFrame, EthernetFrame *ActualFrame)
 This function verifies the frame data against a CheckFrame. More...
 
void XxvEthernetUtilFrameMemClear (EthernetFrame *FramePtr)
 This function sets all bytes of a frame to 0. More...
 
int XxvEthernetUtilEnterLocalLoopback (XXxvEthernet *XxvEthernetInstancePtr)
 This function sets 10G ethernet in local loopback. More...
 
int XxvEthernetUtilUsxgmiiSetup (XXxvEthernet *XxvEthernetInstancePtr, u32 Rate, u32 Duplex)
 This function sets up USXGMII at specified speed. More...
 
int XxvEthernetUtilUsxgmiiSetupBypassAN (XXxvEthernet *XxvEthernetInstancePtr, u32 Rate, u32 Duplex)
 This function sets up USXGMII at specified speed. More...
 
void XxvEthernetUtilErrorTrap (char *Message)
 This function is called by example code when an error is detected. More...
 

Function Documentation

int XxvEthernetUtilEnterLocalLoopback ( XXxvEthernet XxvEthernetInstancePtr)

This function sets 10G ethernet in local loopback.

Parameters
XxvEthernetInstancePtris a pointer to the instance of the XxvEthernet component.
Returns
- XST_SUCCESS if successful.
  • XST_FAILURE, in case of failure..
Note
None.

References XXxvEthernet_Config::BaseAddress, XXxvEthernet::Config, XXxvEthernet_ReadReg, and XXxvEthernet_WriteReg.

Referenced by XxvEthernetSgDmaIntrExample().

void XxvEthernetUtilErrorTrap ( char *  Message)

This function is called by example code when an error is detected.

It can be set as a breakpoint with a debugger or it can be used to print out the given message if there is a UART or STDIO device.

Parameters
Messageis the text explaining the error
Returns
None
Note
None

Referenced by main(), XxvEthernetSgDmaIntrExample(), and XxvEthernetSgDmaIntrSingleFrameExample().

void XxvEthernetUtilFrameHdrFormatMAC ( EthernetFrame *  FramePtr,
char *  DestAddr,
char *  SrcAddr 
)

Set the MAC addresses in the frame.

Parameters
FramePtris the pointer to the frame.
DestAddris the Destination MAC address.
Returns
None.
Note
None.

Referenced by XxvEthernetSgDmaIntrSingleFrameExample().

void XxvEthernetUtilFrameHdrFormatType ( EthernetFrame *  FramePtr,
u16  FrameType 
)

Set the frame type for the specified frame.

Parameters
FramePtris the pointer to the frame.
FrameTypeis the Type to set in frame.
Returns
None.
Note
None.

Referenced by XxvEthernetSgDmaIntrSingleFrameExample().

void XxvEthernetUtilFrameMemClear ( EthernetFrame *  FramePtr)

This function sets all bytes of a frame to 0.

Parameters
FramePtris a pointer to the frame itself.
Returns
None.
Note
None.

Referenced by XxvEthernetSgDmaIntrSingleFrameExample().

void XxvEthernetUtilFrameSetPayloadData ( EthernetFrame *  FramePtr,
int  PayloadSize 
)

This function places a pattern in the payload section of a frame.

The pattern is a 8 bit incrementing series of numbers starting with 0. Once the pattern reaches 256, then the pattern changes to a 16 bit incrementing pattern:

  0, 1, 2, ... 254, 255, 00, 00, 00, 01, 00, 02, ...
Parameters
FramePtris a pointer to the frame to change.
PayloadSizeis the number of bytes in the payload that will be set.
Returns
None.
Note
None.

Referenced by XxvEthernetSgDmaIntrSingleFrameExample().

int XxvEthernetUtilFrameVerify ( EthernetFrame *  CheckFrame,
EthernetFrame *  ActualFrame 
)

This function verifies the frame data against a CheckFrame.

Validation occurs by comparing the ActualFrame to the header of the CheckFrame. If the headers match, then the payload of ActualFrame is verified for the same pattern Util_FrameSetPayloadData() generates.

Parameters
CheckFrameis a pointer to a frame containing the 14 byte header that should be present in the ActualFrame parameter.
ActualFrameis a pointer to a frame to validate.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE in case of failure.
Note
None.

Referenced by XxvEthernetSgDmaIntrSingleFrameExample().

int XxvEthernetUtilUsxgmiiSetup ( XXxvEthernet XxvEthernetInstancePtr,
u32  Rate,
u32  Duplex 
)

This function sets up USXGMII at specified speed.

Autonegotiation is enabled with the selected settings. If autonegotiation fails, it is restarted after a timeout. The function returns success after autonegotiation is completed. This function enables RX and performs a GT reset first because USXGMII requires the same.

Parameters
XxvEthernetInstancePtris a pointer to the instance of the XxvEthernet component.
Speed- can be 1G or 2.5G - use RATE_1G or RATE_2G5
Duplex- 1 for full duplex, 0 for half duplex
Returns
- XST_SUCCESS if successful.
  • XST_FAILURE, in case of failure..
Note
None.

References XXxvEthernet_Config::BaseAddress, XXxvEthernet::Config, XXxvEthernet_GetUsxgmiiAnSts, XXxvEthernet_SetOptions(), XXxvEthernet_SetUsxgmiiAnEnable, XXxvEthernet_SetUsxgmiiRateAndDuplex(), XXxvEthernet_UsxgmiiAnMainRestart(), and XXxvEthernet_WriteReg.

int XxvEthernetUtilUsxgmiiSetupBypassAN ( XXxvEthernet XxvEthernetInstancePtr,
u32  Rate,
u32  Duplex 
)

This function sets up USXGMII at specified speed.

Autonegotiation is bypassed and the status is checked for completion before returning successfully. This function enables RX and performs a GT reset first because USXGMII requires the same.

Parameters
XxvEthernetInstancePtris a pointer to the instance of the XxvEthernet component.
Speed- can be 1G or 2.5G - use RATE_1G or RATE_2G5
Duplex- 1 for full duplex, 0 for half duplex
Returns
- XST_SUCCESS if successful.
  • XST_FAILURE, in case of failure..
Note
None.

References XXxvEthernet_Config::BaseAddress, XXxvEthernet::Config, XXxvEthernet_GetUsxgmiiAnSts, XXxvEthernet_SetOptions(), XXxvEthernet_SetUsxgmiiAnBypass, XXxvEthernet_SetUsxgmiiRateAndDuplex(), XXxvEthernet_UsxgmiiAnMainRestart(), and XXxvEthernet_WriteReg.