| axiethernet Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xaxiethernet_example_intr_mcdma.c File Reference

## Overview

Implements examples that utilize the Axi Ethernet's interrupt driven MCDMA packet transfer mode to send and receive frames.

These examples demonstrate:

- How to perform simple send and receive
- Checksum offload
- Error handling
- Device reset
- How to perform multiple frames send and receive

Functional guide to example:

- AxiEthernetSgDmaIntrSingleFrameExample demonstrates the simplest way to send and receive frames in interrupt driven mode.
- AxiEthernetSgDmaIntrMultiFrameExample demonstrates the way to send and recv Multiple frames in polling mode.
- AxiEthernetSgDmaPartialChecksumOffloadExample demonstrates the partial checksum offloading. The HW must be setup for partial checksum offloading for this example to execute.
- AxiEthernetSgDmaFullChecksumOffloadExample demonstrates the full checksum offloading. The HW must be setup for full checksum offloading for this example to execute.
- AxiEthernetAxiEthernetErrorHandler() demonstrates how to manage asynchronous errors.
- AxiEthernetResetDevice() demonstrates how to reset the driver/HW without losing all configuration settings.

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    5.5   adk           Initial Release.

## Functions
int | AxiEthernetSgDmaIntrExample (INTC *IntcInstancePtr, XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u16 AxiEthernetDeviceId, u16 AxiMcDmaDeviceId, u16 AxiEthernetIntrId)
| This function demonstrates the usage usage of the Axi Ethernet by sending and receiving frames in interrupt driven MCDMA mode. More...
int | AxiEthernetSgDmaIntrSingleFrameExample (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This function demonstrates the usage of the Axi Ethernet by sending and receiving a single frame in SGDMA interrupt mode. More...
int | AxiEthernetSgDmaIntrMultiFrameExample (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This function demonstrates the usage of the Axi Ethernet by sending and receiving a multiple frames in MCDMA interrupt mode. More...
int | AxiEthernetSgDmaPartialChecksumOffloadExample (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This example sends and receives a single packet in loopback mode with checksum offloading support. More...
int | AxiEthernetSgDmaFullChecksumOffloadExample (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This example sends and receives a single packet in loopback mode with full checksum offloading support. More...
int | main (void)
| This is the main function for the Axi Ethernet example. More...

## Function Documentation

int AxiEthernetSgDmaFullChecksumOffloadExample | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This example sends and receives a single packet in loopback mode with full checksum offloading support.

An Ethernet frame is formed with IP header, TCP header and payload. The hardware calculates the IP Header checksum and populates it at the appropriate location in the IP header. Similarly, the hardware calculates the TCP Pseudo header from IP header and calculates TCP checksum for TCP Pseudo header, TCP header and TCP payload. It then populates the checksum in the TCP header. The Ethernet frame is then looped back and received. The hardware validates the IP header checksum and the TCP checksum. The example retrieves the checksum validation information from the AXI4- Stream Appword2.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the AxiEthernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

An Ethernet frame is formed with IP header, TCP header and payload. The hardware calculates the IP Header checksum and populates it at the appropriate location in the IP header. Similarly, the hardware calculates the TCP Pseudo header from IP header and calculates TCP checksum for TCP Pseudo header, TCP header and TCP payload. It then populates the checksum in the TCP header. The Ethernet frame is then looped back and received. The hardware validates the IP header checksum and the TCP checksum. The example retrieves the checksum validation information from the AXI4- Stream Appword2.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the AxiEthernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrFormatType(), AxiEthernetUtilFrameSetPayloadData(), XAE_INT_RECV_ERROR_MASK, XAE_RECEIVER_ENABLE_OPTION, XAE_TRANSMITTER_ENABLE_OPTION, XAxiEthernet_IntEnable, XAxiEthernet_SetOptions(), XAxiEthernet_Start(), and XAxiEthernet_Stop().

Referenced by AxiEthernetSgDmaIntrExample(), and AxiEthernetSgDmaPollExample().

int AxiEthernetSgDmaIntrExample | ( | INTC * | IntcInstancePtr,
|  | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u16 | AxiEthernetDeviceId,
|  | u16 | AxiMcDmaDeviceId,
|  | u16 | AxiEthernetIntrId
| ) |  |

This function demonstrates the usage usage of the Axi Ethernet by sending and receiving frames in interrupt driven MCDMA mode.

Parameters

  IntcInstancePtr | is a pointer to the instance of the Intc component.
  AxiEthernetInstancePtr | is a pointer to the instance of the AxiEthernet component.
  DmaInstancePtr | is a pointer to the instance of the AXI MCDMA component.
  AxiEthernetDeviceId | is Device ID of the Axi Ethernet Device , typically XPAR_<AXIETHERNET_instance>_DEVICE_ID value from xparameters.h.
  AxiMcDmaDeviceId | is Device ID of the Axi DMAA Device , typically XPAR_<AXIMCDMA_instance>_DEVICE_ID value from xparameters.h.
  AxiEthernetIntrId | is the Interrupt ID and is typically XPAR_<INTC_instance>_<AXIETHERNET_instance>_VEC_ID value from xparameters.h.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  AxiMcdma hardware must be initialized before initializing AxiEthernet. Since AxiMcdma reset line is connected to the AxiEthernet reset line, a reset of AxiMcdma hardware during its initialization would reset AxiEthernet.

References XAxiEthernet_Config::AxiDevBaseAddress, XAxiEthernet_Config::AxiDevType, AxiEthernetSgDmaFullChecksumOffloadExample(), AxiEthernetSgDmaIntrMultiFrameExample(), AxiEthernetSgDmaIntrSingleFrameExample(), AxiEthernetSgDmaPartialChecksumOffloadExample(), AxiEthernetUtilEnterLoopback(), AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameVerify(), AxiEthernetUtilPhyDelay(), XAxiEthernet_Config::AxiMcDmaChan_Cnt, XAxiEthernet_Config::BaseAddress, XAxiEthernet::Config, XAxiEthernet_Config::Enable_1588, XAxiEthernet_Config::Speed, XAE_INT_RXFIFOOVR_MASK, XAE_INT_RXRJECT_MASK, XAxiEthernet_CfgInitialize(), XAxiEthernet_GetPhysicalInterface, XAxiEthernet_IntClear, XAxiEthernet_IntPending, XAxiEthernet_IsRxFullCsum, XAxiEthernet_IsRxPartialCsum, XAxiEthernet_IsRxVlanStrp, XAxiEthernet_IsRxVlanTag, XAxiEthernet_IsRxVlanTran, XAxiEthernet_IsTxFullCsum, XAxiEthernet_IsTxPartialCsum, XAxiEthernet_IsTxVlanStrp, XAxiEthernet_IsTxVlanTag, XAxiEthernet_IsTxVlanTran, XAxiEthernet_LookupConfig(), XAxiEthernet_SetOperatingSpeed(), and XAxiEthernet_Stop().

Referenced by main().

int AxiEthernetSgDmaIntrMultiFrameExample | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This function demonstrates the usage of the Axi Ethernet by sending and receiving a multiple frames in MCDMA interrupt mode.

Each source packet will be described by two descriptors. It will be received into a buffer described by a single descriptor.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the Axi Ethernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrFormatType(), AxiEthernetUtilFrameMemClear(), AxiEthernetUtilFrameSetPayloadData(), XAE_RECEIVER_ENABLE_OPTION, XAE_TRANSMITTER_ENABLE_OPTION, XAxiEthernet_SetMacAddress(), XAxiEthernet_SetOptions(), XAxiEthernet_Start(), and XAxiEthernet_Stop().

Referenced by AxiEthernetSgDmaIntrExample().

int AxiEthernetSgDmaIntrSingleFrameExample | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This function demonstrates the usage of the Axi Ethernet by sending and receiving a single frame in SGDMA interrupt mode.

The source packet will be described by two descriptors. It will be received into a buffer described by a single descriptor.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the Axi Ethernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrFormatType(), AxiEthernetUtilFrameMemClear(), AxiEthernetUtilFrameSetPayloadData(), XAE_RECEIVER_ENABLE_OPTION, XAE_TRANSMITTER_ENABLE_OPTION, XAxiEthernet_SetMacAddress(), XAxiEthernet_SetOptions(), XAxiEthernet_Start(), and XAxiEthernet_Stop().

Referenced by AxiEthernetSgDmaIntrExample().

int AxiEthernetSgDmaPartialChecksumOffloadExample | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This example sends and receives a single packet in loopback mode with checksum offloading support.

The transmit frame will be che cksummed over the entire Ethernet payload and inserted into the last 2 bytes of the frame.

On receive, HW should calculate the Ethernet payload checksum and return a value of 0xFFFF which means the payload data was likely not corrupted.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the AxiEthernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

The transmit frame will be che cksummed over the entire Ethernet payload and inserted into the last 2 bytes of the frame.

On receive, HW should calculate the Ethernet payload checksum and return a value of 0xFFFF which means the payload data was likely not corrupted.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the AxiEthernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.

Returns
  -XST_SUCCESS to indicate success -XST_FAILURE to indicate failure

Note
  None.

References AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrFormatType(), AxiEthernetUtilFrameMemClear(), AxiEthernetUtilFrameSetPayloadData(), XAE_INT_RECV_ERROR_MASK, XAE_RECEIVER_ENABLE_OPTION, XAE_TRANSMITTER_ENABLE_OPTION, XAxiEthernet_IntEnable, XAxiEthernet_IsRxPartialCsum, XAxiEthernet_IsTxPartialCsum, XAxiEthernet_SetOptions(), XAxiEthernet_Start(), and XAxiEthernet_Stop().

Referenced by AxiEthernetSgDmaIntrExample(), and AxiEthernetSgDmaPollExample().

int main | ( | void |  | ) |

This is the main function for the Axi Ethernet example.

This function is not included if the example is generated from the TestAppGen test tool.

Parameters

  None. |

Returns
  - XST_SUCCESS to indicate success.
  - XST_FAILURE to indicate failure

Note
  None.

References AXIETHERNET_DEVICE_ID, AxiEthernetSgDmaIntrExample(), and AxiEthernetUtilErrorTrap().