XilinxProcessorIPLib/drivers/xxvethernet/examples/xxxvethernet_example_intr_mcdma.c
int XxvEthernetSgDmaIntrExample(INTC *IntcInstancePtr,
				XXxvEthernet *XxvEthernetInstancePtr,
				XMcdma *DmaInstancePtr,
				u16 XxvEthernetDeviceId,
				u16 AxiMcDmaDeviceId)
{
	int Status;
	XXxvEthernet_Config *MacCfgPtr;
	XMcdma_Config* DmaConfig;
	u8 ChanId;

	/*************************************/
	/* Setup device for first-time usage */
	/*************************************/

	/*
	 *  Get the configuration of XxvEthernet hardware.
	 */
	MacCfgPtr = XXxvEthernet_LookupConfig(XxvEthernetDeviceId);

	/*
	 * This example assumes a target MCDMA is connected to XXV Ethernet
	 */

	DmaConfig = XMcdma_LookupConfig(AxiMcDmaDeviceId);

	/*
	 * Initialize AXIMCDMA engine. AXIMCDMA engine must be initialized before
	 * XxvEthernet. During AXIMCDMA engine initialization, AXIMCDMA hardware is
	 * reset, and since AXIMCDMA reset line is connected to XxvEthernet, this
	 * would ensure a reset of XxvEthernet.
	 */
	Status = XMcDma_CfgInitialize(DmaInstancePtr, DmaConfig);
	if(Status != XST_SUCCESS) {
		XxvEthernetUtilErrorTrap("Error initializing DMA\r\n");
		return XST_FAILURE;
	}

	/*
	 * Initialize XxvEthernet hardware.
	 */
	Status = XXxvEthernet_CfgInitialize(XxvEthernetInstancePtr, MacCfgPtr,
					MacCfgPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		XxvEthernetUtilErrorTrap("Error in initialize");
		return XST_FAILURE;
	}

	/* When the address < 4GB, the following API sets memory attributes
	 * for a 2MB block. Else the attributes are set for a 1 GB block.
	 * Hence, when the required BD space exceeds 2MB,
	 * call the API for two continuous 2MB blocks.
	 */
#if defined(__aarch64__)
	Xil_SetTlbAttributes((UINTPTR)TxBdSpace, NORM_NONCACHE | INNER_SHAREABLE);
	Xil_SetTlbAttributes((UINTPTR)TxBdSpace + BLOCK_SIZE_2MB, NORM_NONCACHE | INNER_SHAREABLE);
	Xil_SetTlbAttributes((UINTPTR)RxBdSpace, NORM_NONCACHE | INNER_SHAREABLE);
	Xil_SetTlbAttributes((UINTPTR)RxBdSpace + BLOCK_SIZE_2MB, NORM_NONCACHE | INNER_SHAREABLE);
#endif

	RxBdSetup(DmaInstancePtr, XxvEthernetInstancePtr, MacCfgPtr);
	TxBdSetup(DmaInstancePtr, XxvEthernetInstancePtr, MacCfgPtr);

	/* This functions sets Ethernet into local loopback mode
	 * To test in external HW loopback mode, comment this function call
	 * and loop TX and RX externally on your setup.
	 */
	XxvEthernetUtilEnterLocalLoopback(XxvEthernetInstancePtr);
	/****************************/
	/* Run through the examples */
	/****************************/

	for (ChanId = 1 ; ChanId <= XPAR_MCDMA_0_NUM_MM2S_CHANNELS; ChanId++) {

		/*
		 * Run the XxvEthernet DMA Single Frame Interrupt example
		 */

		Status = XxvEthernetSgDmaIntrSingleFrameExample(XxvEthernetInstancePtr,
							  DmaInstancePtr, ChanId);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}
	}

	/*
	 * Stop the device
	 */
	XXxvEthernet_Stop(XxvEthernetInstancePtr);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function demonstrates the usage usage of the Xxv Ethernet by sending
* and receiving frames in interrupt driven MCDMA mode.
*
*
* @param	IntcInstancePtr is a pointer to the instance of the Intc
*		component.
* @param	XxvEthernetInstancePtr is a pointer to the instance of the
*		XxvEthernet component.
* @param	DmaInstancePtr is a pointer to the instance of the AXI MCDMA
*		component.
* @param	XxvEthernetDeviceId is Device ID of the Xxv Ethernet Device ,
*		typically XPAR_<XXVETHERNET_instance>_DEVICE_ID value from
*		xparameters.h.
* @param	AxiMcDmaDeviceId is Device ID of the Axi MCDMA Device ,
*		typically XPAR_<AXIMCDMA_instance>_DEVICE_ID value from
*		xparameters.h.
* @return	-XST_SUCCESS to indicate success
*		-XST_FAILURE to indicate failure
*
* @note		AxiMcdma hardware must be initialized before initializing
*		XxvEthernet. Since AxiMcdma reset line is connected to the
*		XxvEthernet reset line, a reset of AxiMcdma hardware during its
*		initialization would reset XxvEthernet.
*
******************************************************************************/
This function demonstrates the usage usage of the Xxv Ethernet by sending
and receiving frames in interrupt driven MCDMA mode.
This function demonstrates the usage usage of the Xxv Ethernet by sending and receiving frames in interrupt driven MCDMA mode .
int XxvEthernetSgDmaIntrExample(INTC *IntcInstancePtr,
				XXxvEthernet *XxvEthernetInstancePtr,
				XMcdma *DmaInstancePtr,
				u16 XxvEthernetDeviceId,
				u16 AxiMcDmaDeviceId)
{
	int Status;
	XXxvEthernet_Config *MacCfgPtr;
	XMcdma_Config* DmaConfig;
	u8 ChanId;
	MacCfgPtr = XXxvEthernet_LookupConfig(XxvEthernetDeviceId);
	DmaConfig = XMcdma_LookupConfig(AxiMcDmaDeviceId);
	Status = XMcDma_CfgInitialize(DmaInstancePtr, DmaConfig);
	if(Status != XST_SUCCESS) {
		XxvEthernetUtilErrorTrap("Error initializing DMA\r\n");
		return XST_FAILURE;
	}
	Status = XXxvEthernet_CfgInitialize(XxvEthernetInstancePtr, MacCfgPtr,
					MacCfgPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		XxvEthernetUtilErrorTrap("Error in initialize");
		return XST_FAILURE;
	}
#if defined(__aarch64__)
	Xil_SetTlbAttributes((UINTPTR)TxBdSpace, NORM_NONCACHE | INNER_SHAREABLE);
	Xil_SetTlbAttributes((UINTPTR)TxBdSpace + BLOCK_SIZE_2MB, NORM_NONCACHE | INNER_SHAREABLE);
	Xil_SetTlbAttributes((UINTPTR)RxBdSpace, NORM_NONCACHE | INNER_SHAREABLE);
	Xil_SetTlbAttributes((UINTPTR)RxBdSpace + BLOCK_SIZE_2MB, NORM_NONCACHE | INNER_SHAREABLE);
#endif
	RxBdSetup(DmaInstancePtr, XxvEthernetInstancePtr, MacCfgPtr);
	TxBdSetup(DmaInstancePtr, XxvEthernetInstancePtr, MacCfgPtr);
	XxvEthernetUtilEnterLocalLoopback(XxvEthernetInstancePtr);
	for (ChanId = 1 ; ChanId <= XPAR_MCDMA_0_NUM_MM2S_CHANNELS; ChanId++) {
		Status = XxvEthernetSgDmaIntrSingleFrameExample(XxvEthernetInstancePtr,
							  DmaInstancePtr, ChanId);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}
	}
	XXxvEthernet_Stop(XxvEthernetInstancePtr);
	return XST_SUCCESS;
}
int XxvEthernetSgDmaIntrExample ( INTC * IntcInstancePtr , XXxvEthernet * XxvEthernetInstancePtr , XMcdma * DmaInstancePtr , u16 XxvEthernetDeviceId , u16 AxiMcDmaDeviceId ) { int Status ; XXxvEthernet_Config * MacCfgPtr ; XMcdma_Config * DmaConfig ; u8 ChanId ; MacCfgPtr = XXxvEthernet_LookupConfig ( XxvEthernetDeviceId ) ; DmaConfig = XMcdma_LookupConfig ( AxiMcDmaDeviceId ) ; Status = XMcDma_CfgInitialize ( DmaInstancePtr , DmaConfig ) ; if ( Status != XST_SUCCESS ) { XxvEthernetUtilErrorTrap ( " \r \n " ) ; return XST_FAILURE ; } Status = XXxvEthernet_CfgInitialize ( XxvEthernetInstancePtr , MacCfgPtr , MacCfgPtr -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { XxvEthernetUtilErrorTrap ( " " ) ; return XST_FAILURE ; } #if defined ( __aarch64__ ) Xil_SetTlbAttributes ( ( UINTPTR ) TxBdSpace , NORM_NONCACHE | INNER_SHAREABLE ) ; Xil_SetTlbAttributes ( ( UINTPTR ) TxBdSpace + BLOCK_SIZE_2MB , NORM_NONCACHE | INNER_SHAREABLE ) ; Xil_SetTlbAttributes ( ( UINTPTR ) RxBdSpace , NORM_NONCACHE | INNER_SHAREABLE ) ; Xil_SetTlbAttributes ( ( UINTPTR ) RxBdSpace + BLOCK_SIZE_2MB , NORM_NONCACHE | INNER_SHAREABLE ) ; #endif RxBdSetup ( DmaInstancePtr , XxvEthernetInstancePtr , MacCfgPtr ) ; TxBdSetup ( DmaInstancePtr , XxvEthernetInstancePtr , MacCfgPtr ) ; XxvEthernetUtilEnterLocalLoopback ( XxvEthernetInstancePtr ) ; for ( ChanId = 1 ; ChanId <= XPAR_MCDMA_0_NUM_MM2S_CHANNELS ; ChanId ++ ) { Status = XxvEthernetSgDmaIntrSingleFrameExample ( XxvEthernetInstancePtr , DmaInstancePtr , ChanId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } } XXxvEthernet_Stop ( XxvEthernetInstancePtr ) ; return XST_SUCCESS ; }
This function demonstrates the usage usage of the Xxv Ethernet by sending
and receiving frames in interrupt driven MCDMA mode.
This function demonstrates the usage usage of the Xxv Ethernet by sending and receiving frames in interrupt driven MCDMA mode .
/*************************************/ /* Setup device for first-time usage */ /*************************************/ /*
	 *  Get the configuration of XxvEthernet hardware.
	 */ /*
	 * This example assumes a target MCDMA is connected to XXV Ethernet
	 */ /*
	 * Initialize AXIMCDMA engine. AXIMCDMA engine must be initialized before
	 * XxvEthernet. During AXIMCDMA engine initialization, AXIMCDMA hardware is
	 * reset, and since AXIMCDMA reset line is connected to XxvEthernet, this
	 * would ensure a reset of XxvEthernet.
	 */ /*
	 * Initialize XxvEthernet hardware.
	 */ /* When the address < 4GB, the following API sets memory attributes
	 * for a 2MB block. Else the attributes are set for a 1 GB block.
	 * Hence, when the required BD space exceeds 2MB,
	 * call the API for two continuous 2MB blocks.
	 */ /* This functions sets Ethernet into local loopback mode
	 * To test in external HW loopback mode, comment this function call
	 * and loop TX and RX externally on your setup.
	 */ /****************************/ /* Run through the examples */ /****************************/ /*
		 * Run the XxvEthernet DMA Single Frame Interrupt example
		 */ /*
	 * Stop the device
	 */