| axipcie Vitis Drivers API Documentation

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

Functions
xaxipcie_rc_cdma_example.c File Reference

## Overview

This file contains a design example for using AXI PCIe IP and its driver.

This is an example to show the usage of driver APIs when AXI PCIe IP is configured as a Root Port. The AXI PCIe can be configured as a Root Port only on the 7 Series Xilinx FPGA families.

The example initialises the AXI PCIe IP, shows how to enumerate the PCIe system and transfer data between endpoint and root complex using Central DMA.

This example assumes that there is an AXI CDMA IP in the system. The user has to specify the Source, Destination and the Length of the DMA transfer which are valid for this system and are defined AXICDMA_SRC_ADDR, AXICDMA_DEST_ADDR and AXICDMA_LENGTH respectively in this example.

Note

This example should be used only when AXI PCIe IP is configured as root complex and AXI CDMA IP in included in system.

This code will illustrate how the XAxiPcie IP and its standalone driver can be used to:

- Initialize a AXI PCIe IP core built as a root complex.
- Enumerate PCIe end points in the system.
- Transfer data between root complex and endpoint using CDMA.

Please note that this example enumerates and initializes PCIe end points only. It does not shows how to deal with PCIe switches (and its virtual P2P bridges)

We tried to use as much of the driver's API calls as possible to show the reader how each call could be used and that probably made the example not the shortest way of doing the tasks shown as they could be done.

      MODIFICATION HISTORY:

      Ver   Who  Date     Changes

      2.00a nm   10/19/11 Initial version of AXI PCIe Root Port example
      3.1   ms   01/23/17 Added 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.

    *

## Functions
int | PcieInitRootComplex (XAxiPcie *AxiPciePtr, u16 DeviceId)
| This function initializes a AXI PCIe IP built as a root complex. More...
void | PCIeEnumerateFabric (XAxiPcie *AxiPciePtr)
| This function enumerates its PCIe system and figures out the nature of each component there like end points,bridges,... More...
int | DmaDataTransfer (u16 DeviceID)
| This function transfers data from Source Address to Destination Address using the AXI CDMA. More...
int | main (void)
| This function is the entry point for PCIe Root Complex Enumeration Example. More...

## Function Documentation

int DmaDataTransfer | ( | u16 | DeviceID | ) |

This function transfers data from Source Address to Destination Address using the AXI CDMA.

User has to specify the Source Address, Destination Address and Transfer Length in AXICDMA_SRC_ADDR, AXICDMA_DEST_ADDR and AXICDMA_LENGTH defines respectively.

Parameters

  DeviceId | is device ID of the XAxiCdma Device.

Returns
  - XST_SUCCESS if successful
  - XST_FAILURE.if unsuccessful.

Note
  If the hardware system is not built correctly this function may never return to the caller.

int main | ( | void |  | ) |

This function is the entry point for PCIe Root Complex Enumeration Example.

Parameters

  None |

Returns
  - XST_SUCCESS if successful
  - XST_FAILURE if unsuccessful.

Note
  None.

References DmaDataTransfer(), PCIeEnumerateFabric(), and PcieInitRootComplex().

void PCIeEnumerateFabric | ( | XAxiPcie * | AxiPciePtr | ) |

This function enumerates its PCIe system and figures out the nature of each component there like end points,bridges,...

Parameters

  AxiPciePtr | is a pointer to an instance of XAxiPcie data structure represents a root complex IP.

Returns
  None.

Note
  None.

References XAxiPcie_GetRootPortStatusCtrl(), XAxiPcie_ReadRemoteConfigSpace(), XAXIPCIE_RPSC_BRIDGE_ENABLE_MASK, XAxiPcie_SetRootPortStatusCtrl(), and XAxiPcie_WriteRemoteConfigSpace().

Referenced by main().

int PcieInitRootComplex | ( | XAxiPcie * | AxiPciePtr,
|  | u16 | DeviceId
| ) |  |

This function initializes a AXI PCIe IP built as a root complex.

Parameters

  AxiPciePtr | is a pointer to an instance of XAxiPcie data structure represents a root complex IP.
  DeviceId | is AXI PCIe IP unique ID

Returns
  - XST_SUCCESS if successful.
  - XST_FAILURE if unsuccessful.

Note
  None.

References XAxiPcie_Config::BaseAddress, XAxiPcie::Config, XAxiPcie_Config::IncludeRootComplex, XAxiPcie_CfgInitialize(), XAxiPcie_ClearPendingInterrupts(), XAxiPcie_DisableInterrupts(), XAxiPcie_GetEnabledInterrupts(), XAxiPcie_GetLocalBusBar2PcieBar(), XAxiPcie_GetPendingInterrupts(), XAxiPcie_GetRequesterId(), XAXIPCIE_ID_CLEAR_ALL_MASK, XAXIPCIE_IM_ENABLE_ALL_MASK, XAxiPcie_IsLinkUp, XAxiPcie_LookupConfig(), XAxiPcie_ReadLocalConfigSpace(), XAxiPcie_SetLocalBusBar2PcieBar(), and XAxiPcie_WriteLocalConfigSpace().

Referenced by main().