| axiethernet Vitis Drivers API Documentation

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

Macros | Functions
xavb_example.c File Reference

## Overview

This file implements a simple example to show the usage of Audio Video Bridging (AVB) functionality of Axi Ethernet IP in loopback mode.

The example uses the PTP Timer and the PTP Rx interrupts. A PDelay_Req packet is sent and is received back (as we are in loopback mode). . After this loop backed PDelay_Req packet is received, a PDelay_Resp and PDelay_RespFollowUp packets are sent. These packets are also received. Since the source port identity of the received packets matches with our systems's own source port identity there is no further processing done.

Note

This code assumes the processor type is Microblaze, Xilinx interrupt controller (XIntc) is used in the system , and that no operating system is used.

It also assumes that all the relevant AVB interrupts are properly connected to the Intc module.

The Ethernet AVB Endpoint functionality should be enabled in the Xilinx Axi Ethernet core for this example to work.

The Axi Ethernet is used with a GMII interface. The example initializes the GMII interface with 1000 Mbps speed.

IMPORTANT NOTE: The user must define the macro XAVB_CLOCK_LOCK_THRESHOLD in xavb.h to an appropriate value as relevant for the corresponding use case. Presently it is defined to 1000 ns which is typical for telecom industry. This macro is used to compare against the slave error as calculated every time after receiving 2 successive sync/followup frames. Slave error is the difference between master time duration and slave time duration as calculated for the time gap (the time it takes to receive two successive sync/follow up frames). If slave error is greater than the value defined in XAVB_CLOCK_LOCK_THRESHOLD, then master and slave clocks are unlocked. This means the node running this SW assumes that the peer is no more capable of processing 802.1as frames. The node running the SW then waits till it successful calculates the path delay (which essentially means the peer is again capable of processing 802.1as frames.

    MODIFICATION HISTORY:

    Ver   Who      Date     Changes

    1.00a kag/asa  08/25/10 First release
    3.00a asa        04/10/12 Disabled enabling of promiscuous mode. This is
                      required for AxiEthernet cores with version v3_01_a
                      onwards because of a change in the AVB implementation.
    4.0   asa  03/06/14 Fix for CR 740863. Added a #warning message for
                              users of this example to take note of the fact that
                              we have just used a typical value for XAVB_CLOCK_LOCK_THRESHOLD
                    and users may want to change it as per their requirements.
    5.17  ml   11/15/23  Fix compilation errors reported with -std=c2x compiler flag

## Macros
#define | AXIETHERNET_DEVICE_ID XPAR_AXIETHERNET_0_DEVICE_ID
| The following constants map to the XPAR parameters created in the xparameters.h file. More...

## Functions
void | AvbGMDiscontinuityHandler (void *CallBackRef, u32 TimestampsUncertain)
| This function is the handler which will be called if the PTP drivers identify a possible discontinuity in GrandMaster time. More...
int | main ()
| This is the main function for the AVB example. More...

## Macro Definition Documentation

#define AXIETHERNET_DEVICE_ID XPAR_AXIETHERNET_0_DEVICE_ID

The following constants map to the XPAR parameters created in the xparameters.h file.

They are defined here such that a user can easily change all the needed parameters in one place.

Referenced by main().

## Function Documentation

void AvbGMDiscontinuityHandler | ( | void * | CallBackRef,
|  | u32 | TimestampsUncertain
| ) |  |

This function is the handler which will be called if the PTP drivers identify a possible discontinuity in GrandMaster time.

This handler provides an example of how to handle this situation - but this function is application specific.

Parameters

  CallBackRef | contains a callback reference from the driver, in this case it is the instance pointer for the AVB driver.
  TimestampsUncertain | - a value of 1 indicates that there is a possible discontinuity in GrandMaster time. A value of 0 indicates that Timestamps are no longer uncertain.

Returns
  None.

Note
  This Handler need to be defined otherwise the XAvb_StubHandler will generate an error

Referenced by main().

int main | ( | void |  | ) |

This is the main function for the AVB example.

Parameters

  None. |

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

Note
  This example will be in a infinite loop if the HW is not working properly and if the interrupts are not received.

References AvbGMDiscontinuityHandler(), AXIETHERNET_DEVICE_ID, XAvb_Config::BaseAddress, XAxiEthernet_Config::BaseAddress, XAvb_PortIdentity::ClockIdentityLower, XAvb_PortIdentity::ClockIdentityUpper, XAvb::Config, XAvb_Config::DeviceId, XAxiEthernet_Config::DeviceId, XAvb_PortIdentity::PortNumber, XAvb_CfgInitialize(), XAvb_ReorderWord(), XAvb_Reset(), XAvb_SetGMDiscontinuityHandler(), XAvb_SetupSourcePortIdentity(), XAvb_Start(), XAvb_WriteToMultipleTxPtpFrames(), XAxiEthernet_CfgInitialize(), and XAxiEthernet_LookupConfig().