XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_sg_poll.c
static int SendPacket(XAxiDma * AxiDmaInstPtr)
{
	XAxiDma_BdRing *TxRingPtr;
	u8 *TxPacket;
	u8 Value;
	XAxiDma_Bd *BdPtr;
	int Status;
	int Index;

	TxRingPtr = XAxiDma_GetTxRing(AxiDmaInstPtr);

	/* Create pattern in the packet to transmit */
	TxPacket = (u8 *) Packet;

	Value = TEST_START_VALUE;

	for(Index = 0; Index < MAX_PKT_LEN; Index ++) {
		TxPacket[Index] = Value;

		Value = (Value + 1) & 0xFF;
	}

	/* Flush the buffers before the DMA transfer, in case the Data Cache
	 * is enabled
	 */
	Xil_DCacheFlushRange((UINTPTR)TxPacket, MAX_PKT_LEN);
	Xil_DCacheFlushRange((UINTPTR)RX_BUFFER_BASE, MAX_PKT_LEN);

	/* Allocate a BD */
	Status = XAxiDma_BdRingAlloc(TxRingPtr, 1, &BdPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Set up the BD using the information of the packet to transmit */
	Status = XAxiDma_BdSetBufAddr(BdPtr, (UINTPTR) Packet);
	if (Status != XST_SUCCESS) {
		xil_printf("Tx set buffer addr %x on BD %x failed %d\r\n",
		    (UINTPTR)Packet, (UINTPTR)BdPtr, Status);

		return XST_FAILURE;
	}

	Status = XAxiDma_BdSetLength(BdPtr, MAX_PKT_LEN,
				TxRingPtr->MaxTransferLen);
	if (Status != XST_SUCCESS) {
		xil_printf("Tx set length %d on BD %x failed %d\r\n",
		    MAX_PKT_LEN, (UINTPTR)BdPtr, Status);

		return XST_FAILURE;
	}

#if (XPAR_AXIDMA_0_SG_INCLUDE_STSCNTRL_STRM == 1)
	Status = XAxiDma_BdSetAppWord(BdPtr,
	    XAXIDMA_LAST_APPWORD, MAX_PKT_LEN);

	/* If Set app length failed, it is not fatal
	 */
	if (Status != XST_SUCCESS) {
		xil_printf("Set app word failed with %d\r\n", Status);
	}
#endif

	/* For single packet, both SOF and EOF are to be set
	 */
	XAxiDma_BdSetCtrl(BdPtr, XAXIDMA_BD_CTRL_TXEOF_MASK |
						XAXIDMA_BD_CTRL_TXSOF_MASK);

	XAxiDma_BdSetId(BdPtr, (UINTPTR)Packet);

	/* Give the BD to DMA to kick off the transmission. */
	Status = XAxiDma_BdRingToHw(TxRingPtr, 1, BdPtr);
	if (Status != XST_SUCCESS) {
		xil_printf("to hw failed %d\r\n", Status);
		return XST_FAILURE;
	}



	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function transmits one packet non-blockingly through the DMA engine.
*
* @param	AxiDmaInstPtr points to the DMA engine instance
*
* @return	- XST_SUCCESS if the DMA accepts the packet successfully,
*		- XST_FAILURE otherwise.
*
* @note     None.
*
******************************************************************************/
This function transmits one packet non-blockingly through the DMA engine.
This function transmits one packet non - blockingly through the DMA engine .
static int SendPacket(XAxiDma * AxiDmaInstPtr)
{
	XAxiDma_BdRing *TxRingPtr;
	u8 *TxPacket;
	u8 Value;
	XAxiDma_Bd *BdPtr;
	int Status;
	int Index;
	TxRingPtr = XAxiDma_GetTxRing(AxiDmaInstPtr);
	TxPacket = (u8 *) Packet;
	Value = TEST_START_VALUE;
	for(Index = 0; Index < MAX_PKT_LEN; Index ++) {
		TxPacket[Index] = Value;
		Value = (Value + 1) & 0xFF;
	}
	Xil_DCacheFlushRange((UINTPTR)TxPacket, MAX_PKT_LEN);
	Xil_DCacheFlushRange((UINTPTR)RX_BUFFER_BASE, MAX_PKT_LEN);
	Status = XAxiDma_BdRingAlloc(TxRingPtr, 1, &BdPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XAxiDma_BdSetBufAddr(BdPtr, (UINTPTR) Packet);
	if (Status != XST_SUCCESS) {
		xil_printf("Tx set buffer addr %x on BD %x failed %d\r\n",
		    (UINTPTR)Packet, (UINTPTR)BdPtr, Status);
		return XST_FAILURE;
	}
	Status = XAxiDma_BdSetLength(BdPtr, MAX_PKT_LEN,
				TxRingPtr->MaxTransferLen);
	if (Status != XST_SUCCESS) {
		xil_printf("Tx set length %d on BD %x failed %d\r\n",
		    MAX_PKT_LEN, (UINTPTR)BdPtr, Status);
		return XST_FAILURE;
	}
#if (XPAR_AXIDMA_0_SG_INCLUDE_STSCNTRL_STRM == 1)
	Status = XAxiDma_BdSetAppWord(BdPtr,
	    XAXIDMA_LAST_APPWORD, MAX_PKT_LEN);
	if (Status != XST_SUCCESS) {
		xil_printf("Set app word failed with %d\r\n", Status);
	}
#endif
	XAxiDma_BdSetCtrl(BdPtr, XAXIDMA_BD_CTRL_TXEOF_MASK |
						XAXIDMA_BD_CTRL_TXSOF_MASK);
	XAxiDma_BdSetId(BdPtr, (UINTPTR)Packet);
	Status = XAxiDma_BdRingToHw(TxRingPtr, 1, BdPtr);
	if (Status != XST_SUCCESS) {
		xil_printf("to hw failed %d\r\n", Status);
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
static int SendPacket ( XAxiDma * AxiDmaInstPtr ) { XAxiDma_BdRing * TxRingPtr ; u8 * TxPacket ; u8 Value ; XAxiDma_Bd * BdPtr ; int Status ; int Index ; TxRingPtr = XAxiDma_GetTxRing ( AxiDmaInstPtr ) ; TxPacket = ( u8 * ) Packet ; Value = TEST_START_VALUE ; for ( Index = 0 ; Index < MAX_PKT_LEN ; Index ++ ) { TxPacket [ Index ] = Value ; Value = ( Value + 1 ) & 0xFF ; } Xil_DCacheFlushRange ( ( UINTPTR ) TxPacket , MAX_PKT_LEN ) ; Xil_DCacheFlushRange ( ( UINTPTR ) RX_BUFFER_BASE , MAX_PKT_LEN ) ; Status = XAxiDma_BdRingAlloc ( TxRingPtr , 1 , & BdPtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XAxiDma_BdSetBufAddr ( BdPtr , ( UINTPTR ) Packet ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " , ( UINTPTR ) Packet , ( UINTPTR ) BdPtr , Status ) ; return XST_FAILURE ; } Status = XAxiDma_BdSetLength ( BdPtr , MAX_PKT_LEN , TxRingPtr -> MaxTransferLen ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " , MAX_PKT_LEN , ( UINTPTR ) BdPtr , Status ) ; return XST_FAILURE ; } #if ( XPAR_AXIDMA_0_SG_INCLUDE_STSCNTRL_STRM == 1 ) Status = XAxiDma_BdSetAppWord ( BdPtr , XAXIDMA_LAST_APPWORD , MAX_PKT_LEN ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " , Status ) ; } #endif XAxiDma_BdSetCtrl ( BdPtr , XAXIDMA_BD_CTRL_TXEOF_MASK | XAXIDMA_BD_CTRL_TXSOF_MASK ) ; XAxiDma_BdSetId ( BdPtr , ( UINTPTR ) Packet ) ; Status = XAxiDma_BdRingToHw ( TxRingPtr , 1 , BdPtr ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " , Status ) ; return XST_FAILURE ; } return XST_SUCCESS ; }
This function transmits one packet non-blockingly through the DMA engine.
This function transmits one packet non - blockingly through the DMA engine .
/* Create pattern in the packet to transmit */ /* Flush the buffers before the DMA transfer, in case the Data Cache
	 * is enabled
	 */ /* Allocate a BD */ /* Set up the BD using the information of the packet to transmit */ /* If Set app length failed, it is not fatal
	 */ /* For single packet, both SOF and EOF are to be set
	 */ /* Give the BD to DMA to kick off the transmission. */