axiethernet
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
xaxiethernet_example_extvlan.c File Reference

Overview

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

This example demonstrates:

  • How to setup VLAN strip/translate/tag in TX and RX direction
  • How the VLAN tags are handled
  • What is the expected VLAN tag(s) after VLAN functions are invoked

Functional guide to example:

  • AxiEthernetSgDmaIntrExtVlanExample demonstrates the extended VLAN capability. The HW must be setup for extended VLAN for this example to execute.
MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.00a asa 4/30/10 First release based on the ll temac driver 1.01a asa 12/10/10 Changes made to enable the AXIDMA Tx/Rx ring interrupts before allocation of Tx/Rx BDs. 3.00a asa 6/25/12 Modified XAxiDma_BdSetLength API call to support new AXI DMA driver version 7.00a. 3.00a bss 10/22/12 Added support for Fast Interrupt Handlers. 3.01a srt 02/14/13 Added support for Zynq (CR 681136) 5.4 ms 01/23/17 Modified xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. ms 04/05/17 Added tabspace for return statements in functions for proper documentation while generating doxygen. 5.7 rsp 19/12/17 Defined Padding and ExternalLoopback variables.

#include "xaxiethernet_example.h"
#include "xparameters.h"
#include "xaxidma.h"
#include "xil_cache.h"
#include "xil_exception.h"
#include "xinterrupt_wrap.h"

Functions

int AxiEthernetExtVlanExample (XAxiEthernet *AxiEthernetInstancePtr, XAxiDma *DmaInstancePtr, UINTPTR AxiEthernetBaseAddress)
 This function demonstrates the usage usage of the Axi Ethernet by sending and receiving frames in interrupt driven SGDMA mode. More...
 
int AxiEthernetSgDmaIntrExtVlanExample (XAxiEthernet *AxiEthernetInstancePtr, XAxiDma *DmaInstancePtr)
 This example sends and receives a single packet in loopback mode with extended VLAN support. More...
 
int main (void)
 This is the main function for the Axi Ethernet example. More...
 

Function Documentation

int AxiEthernetExtVlanExample ( XAxiEthernet AxiEthernetInstancePtr,
XAxiDma *  DmaInstancePtr,
UINTPTR  AxiEthernetBaseAddress 
)

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

Parameters
AxiEthernetInstancePtris a pointer to the instance of the AxiEthernet component.
DmaInstancePtris a pointer to the instance of the AXIDMA component.
AxiEthernetBaseAddressis the base address of the AxiEthernet device.
Returns
-XST_SUCCESS to indicate success. -XST_FAILURE to indicate failure.
Note
AxiDma hardware must be initialized before initializing AxiEthernet. Since AxiDma reset line is connected to the AxiEthernet reset line, a reset of AxiDma hardware during its initialization would reset AxiEthernet.

In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XAxiEthernet_Config::AxiDevBaseAddress, AxiEthernetSgDmaIntrExtVlanExample(), AxiEthernetUtilEnterLoopback(), AxiEthernetUtilErrorTrap(), AxiEthernetUtilPhyDelay(), XAxiEthernet_Config::BaseAddress, XAxiEthernet::Config, XAxiEthernet_Config::IntrId, XAxiEthernet_Config::IntrParent, XAxiEthernet_CfgInitialize(), XAxiEthernet_Get_Phy_Interface(), XAxiEthernet_IsRxVlanStrp, XAxiEthernet_IsRxVlanTag, XAxiEthernet_IsRxVlanTran, XAxiEthernet_IsTxVlanStrp, XAxiEthernet_IsTxVlanTag, XAxiEthernet_IsTxVlanTran, XAxiEthernet_LookupConfig(), XAxiEthernet_SetMacAddress(), XAxiEthernet_SetOperatingSpeed(), and XAxiEthernet_Stop().

Referenced by main().

int AxiEthernetSgDmaIntrExtVlanExample ( XAxiEthernet AxiEthernetInstancePtr,
XAxiDma *  DmaInstancePtr 
)

This example sends and receives a single packet in loopback mode with extended VLAN support.

The transmit frame will have VLAN field populated.

On receive, HW should pass the VLAN field to receive BDs.

Parameters
AxiEthernetInstancePtris a pointer to the instance of the AxiEthernet component.
DmaInstancePtris a pointer to the instance of the Dma component.
Returns
-XST_SUCCESS to indicate success. -XST_FAILURE to indicate failure.
Note
Summary of VLAN tags handling in this example

Frame setup with Tpid1+Cfi1+TxPid => 0x88A83111 Frame translated to TxTransVid => 0x88A83222 Frame tagged to Tpid2+Cfi2+TxTagVid => 0x9100C333 + 0x88A83222 Frame sent and loopbacked.

Frame stripped with RxStrpVid(0x333) => 0x88A83222 Frame translated (key:RxVid:0x222) RxTransVid => 0x88A83444

References AxiEthernetUtilErrorTrap(), AxiEthernetUtilFrameHdrFormatMAC(), AxiEthernetUtilFrameHdrVlanFormatType(), AxiEthernetUtilFrameHdrVlanFormatVid(), AxiEthernetUtilFrameMemClear(), AxiEthernetUtilFrameSetVlanPayloadData(), AxiEthernetUtilFrameVerify(), XAE_EXT_RXVLAN_TRAN_OPTION, XAE_EXT_TXVLAN_TAG_OPTION, XAE_EXT_TXVLAN_TRAN_OPTION, XAE_INT_RECV_ERROR_MASK, XAE_JUMBO_OPTION, XAE_RECEIVER_ENABLE_OPTION, XAE_TRANSMITTER_ENABLE_OPTION, XAxiEthernet_IntEnable, XAxiEthernet_IsRxVlanStrp, XAxiEthernet_IsRxVlanTag, XAxiEthernet_IsRxVlanTran, XAxiEthernet_IsTxVlanStrp, XAxiEthernet_IsTxVlanTag, XAxiEthernet_IsTxVlanTran, XAxiEthernet_SetOptions(), XAxiEthernet_SetTpid(), XAxiEthernet_SetVidTable(), XAxiEthernet_SetVStripMode(), XAxiEthernet_SetVTagMode(), XAxiEthernet_SetVTagValue(), and XAxiEthernet_Start().

Referenced by AxiEthernetExtVlanExample().

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, AxiEthernetExtVlanExample(), and AxiEthernetUtilErrorTrap().