XilinxProcessorIPLib/drivers/mcdma/src/xmcdma_bd.c
u32 XMcDma_Chan_Sideband_Submit(XMcdma_ChanCtrl *ChanPtr, UINTPTR BufAddr,
				u32 Len, u32 *AppPtr, u16 Tuser, u16 Tid)
{
	u32 BdCount = 1;
	XMcdma_Bd *BdCurPtr = ChanPtr->BdRestart;
	u32 i;
	u32 k;
	u32 Bdlen = Len;

	/* Calculate the Number of BD's required for transferring user
	 * requested Data */
	if (Len > ChanPtr->MaxTransferLen) {
		BdCount = (Len + (ChanPtr->MaxTransferLen - 1)) /
			   ChanPtr->MaxTransferLen;
		Bdlen = ChanPtr->MaxTransferLen;
	}

	if (BdCount > ChanPtr->BdCnt) {
		xil_printf("for transferring len bytes required Bd's is %x\n\r", BdCount);
		xil_printf("User requested only this %x many Bd's\n\r", ChanPtr->BdCnt);

		return XST_FAILURE;
	}

	for (i = 0; i < BdCount; i++) {
		XMcdma_BdClear(BdCurPtr);

		XMcdma_BdSetBufAddr(BdCurPtr, BufAddr);

		if (Len < ChanPtr->MaxTransferLen) {
			Bdlen = Len;
		}

		XMcdma_BdWrite(BdCurPtr, XMCDMA_BD_CTRL_OFFSET, Bdlen);

		/* Program BD sideband and app fields */
		XMcDma_BdSetCtrlSideBand(BdCurPtr, Tid, Tuser);

		if (!ChanPtr->IsRxChan || ChanPtr->HasRxLength) {
			for (k = 0; k <= XMCDMA_LAST_APPWORD; k++) {
				XMcdma_BdWrite(BdCurPtr,
					       XMCDMA_BD_USR0_OFFSET +
					       (k * 4), AppPtr[k]);
			}
		}

		ChanPtr->BdTail = BdCurPtr;
		XMCDMA_CACHE_FLUSH((UINTPTR)(BdCurPtr));
		BdCurPtr = (XMcdma_Bd *)XMcdma_BdChainNextBd(ChanPtr, BdCurPtr);
		BufAddr += Bdlen;
		Len -= Bdlen;
	}

	XMCDMA_CACHE_FLUSH((UINTPTR)(BdCurPtr));
	DATA_SYNC;
	ChanPtr->BdRestart = BdCurPtr;
	ChanPtr->BdPendingCnt += BdCount;
	ChanPtr->BdCnt -= BdCount;

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
* This function populates the BD Chain with the required buffer address, length
* APP(user application), TUSER and TID fields.
*
* User can submit multiple buffers/buffer descriptors by calling this function
* multiple times
*
* @param	ChanPtr is the MCDMA Channel to be worked on..
* @param	BufAddr is the buffer address to which data should send/recv.
* @param	Len is the Amount of data user requested to send/recv.
* @param	AppPtr is the point to APP fields.
* @param	Tuser is the  value presented on the beat that has TLAST.
* @param	Tid is the value value presented on the beat that has TLAST.
*
* @return
*		- XST_SUCCESS if initialization was successful
*		- XST_FAILURE if the BdStartAddress or requested bdlen
*		  doesn't match for the driver requirements.
*
*****************************************************************************/
This function populates the BD Chain with the required buffer address, length
APP(user application), TUSER and TID fields.

User can submit multiple buffers/buffer descriptors by calling this function
multiple times
This function populates the BD Chain with the required buffer address length APP ( user application ) TUSER and TID fields . User can submit multiple buffers / buffer descriptors by calling this function multiple times
u32 XMcDma_Chan_Sideband_Submit(XMcdma_ChanCtrl *ChanPtr, UINTPTR BufAddr,
				u32 Len, u32 *AppPtr, u16 Tuser, u16 Tid)
{
	u32 BdCount = 1;
	XMcdma_Bd *BdCurPtr = ChanPtr->BdRestart;
	u32 i;
	u32 k;
	u32 Bdlen = Len;
	if (Len > ChanPtr->MaxTransferLen) {
		BdCount = (Len + (ChanPtr->MaxTransferLen - 1)) /
			   ChanPtr->MaxTransferLen;
		Bdlen = ChanPtr->MaxTransferLen;
	}
	if (BdCount > ChanPtr->BdCnt) {
		xil_printf("for transferring len bytes required Bd's is %x\n\r", BdCount);
		xil_printf("User requested only this %x many Bd's\n\r", ChanPtr->BdCnt);
		return XST_FAILURE;
	}
	for (i = 0; i < BdCount; i++) {
		XMcdma_BdClear(BdCurPtr);
		XMcdma_BdSetBufAddr(BdCurPtr, BufAddr);
		if (Len < ChanPtr->MaxTransferLen) {
			Bdlen = Len;
		}
		XMcdma_BdWrite(BdCurPtr, XMCDMA_BD_CTRL_OFFSET, Bdlen);
		XMcDma_BdSetCtrlSideBand(BdCurPtr, Tid, Tuser);
		if (!ChanPtr->IsRxChan || ChanPtr->HasRxLength) {
			for (k = 0; k <= XMCDMA_LAST_APPWORD; k++) {
				XMcdma_BdWrite(BdCurPtr,
					       XMCDMA_BD_USR0_OFFSET +
					       (k * 4), AppPtr[k]);
			}
		}
		ChanPtr->BdTail = BdCurPtr;
		XMCDMA_CACHE_FLUSH((UINTPTR)(BdCurPtr));
		BdCurPtr = (XMcdma_Bd *)XMcdma_BdChainNextBd(ChanPtr, BdCurPtr);
		BufAddr += Bdlen;
		Len -= Bdlen;
	}
	XMCDMA_CACHE_FLUSH((UINTPTR)(BdCurPtr));
	DATA_SYNC;
	ChanPtr->BdRestart = BdCurPtr;
	ChanPtr->BdPendingCnt += BdCount;
	ChanPtr->BdCnt -= BdCount;
	return XST_SUCCESS;
}
u32 XMcDma_Chan_Sideband_Submit ( XMcdma_ChanCtrl * ChanPtr , UINTPTR BufAddr , u32 Len , u32 * AppPtr , u16 Tuser , u16 Tid ) { u32 BdCount = 1 ; XMcdma_Bd * BdCurPtr = ChanPtr -> BdRestart ; u32 i ; u32 k ; u32 Bdlen = Len ; if ( Len > ChanPtr -> MaxTransferLen ) { BdCount = ( Len + ( ChanPtr -> MaxTransferLen - 1 ) ) / ChanPtr -> MaxTransferLen ; Bdlen = ChanPtr -> MaxTransferLen ; } if ( BdCount > ChanPtr -> BdCnt ) { xil_printf ( " \n \r " , BdCount ) ; xil_printf ( " \n \r " , ChanPtr -> BdCnt ) ; return XST_FAILURE ; } for ( i = 0 ; i < BdCount ; i ++ ) { XMcdma_BdClear ( BdCurPtr ) ; XMcdma_BdSetBufAddr ( BdCurPtr , BufAddr ) ; if ( Len < ChanPtr -> MaxTransferLen ) { Bdlen = Len ; } XMcdma_BdWrite ( BdCurPtr , XMCDMA_BD_CTRL_OFFSET , Bdlen ) ; XMcDma_BdSetCtrlSideBand ( BdCurPtr , Tid , Tuser ) ; if ( ! ChanPtr -> IsRxChan || ChanPtr -> HasRxLength ) { for ( k = 0 ; k <= XMCDMA_LAST_APPWORD ; k ++ ) { XMcdma_BdWrite ( BdCurPtr , XMCDMA_BD_USR0_OFFSET + ( k * 4 ) , AppPtr [ k ] ) ; } } ChanPtr -> BdTail = BdCurPtr ; XMCDMA_CACHE_FLUSH ( ( UINTPTR ) ( BdCurPtr ) ) ; BdCurPtr = ( XMcdma_Bd * ) XMcdma_BdChainNextBd ( ChanPtr , BdCurPtr ) ; BufAddr += Bdlen ; Len -= Bdlen ; } XMCDMA_CACHE_FLUSH ( ( UINTPTR ) ( BdCurPtr ) ) ; DATA_SYNC ; ChanPtr -> BdRestart = BdCurPtr ; ChanPtr -> BdPendingCnt += BdCount ; ChanPtr -> BdCnt -= BdCount ; return XST_SUCCESS ; }
This function populates the BD Chain with the required buffer address, length
APP(user application), TUSER and TID fields.
This function populates the BD Chain with the required buffer address length APP ( user application ) TUSER and TID fields .
/* Calculate the Number of BD's required for transferring user
	 * requested Data */ /* Program BD sideband and app fields */