XilinxProcessorIPLib/drivers/axidma/src/xaxidma_bd.c
int XAxiDma_BdSetLength(XAxiDma_Bd *BdPtr, u32 LenBytes, u32 LengthMask)
{
	if (LenBytes <= 0 || (LenBytes > LengthMask)) {

		xdbg_printf(XDBG_DEBUG_ERROR, "invalid length %d\n",
		    (int)LenBytes);

		return XST_INVALID_PARAM;
	}

	XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_CTRL_LEN_OFFSET,
		((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_CTRL_LEN_OFFSET) & \
		~LengthMask)) | LenBytes);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
 * Set the length field for the given BD.
 *
 * Length has to be non-zero and less than LengthMask.
 *
 * For TX channels, the value passed in should be the number of bytes to
 * transmit from the TX buffer associated with the given BD.
 *
 * For RX channels, the value passed in should be the size of the RX buffer
 * associated with the given BD in bytes. This is to notify the RX channel
 * the capability of the RX buffer to avoid buffer overflow.
 *
 * The actual receive length can be equal or smaller than the specified length.
 * The actual transfer length will be updated by the hardware in the
 * XAXIDMA_BD_STS_OFFSET word in the BD.
 *
 * @param	BdPtr is the BD to operate on.
 * @param	LenBytes is the requested transfer length
 * @param	LengthMask is the maximum transfer length
 *
 * @returns
 *		- XST_SUCCESS for success
 *		- XST_INVALID_PARAM for invalid BD length
 *
 * @note	This function can be used only when DMA is in SG mode
 *
 *****************************************************************************/
Set the length field for the given BD.
Length has to be non-zero and less than LengthMask.

For TX channels, the value passed in should be the number of bytes to
transmit from the TX buffer associated with the given BD.

For RX channels, the value passed in should be the size of the RX buffer
associated with the given BD in bytes. This is to notify the RX channel
the capability of the RX buffer to avoid buffer overflow.

The actual receive length can be equal or smaller than the specified length.
The actual transfer length will be updated by the hardware in the
XAXIDMA_BD_STS_OFFSET word in the BD.

@param       BdPtr is the BD to operate on.
@param       LenBytes is the requested transfer length
@param       LengthMask is the maximum transfer length

@returns
- XST_SUCCESS for success
- XST_INVALID_PARAM for invalid BD length

@note        This function can be used only when DMA is in SG mode
Set the length field for the given BD . Length has to be non - zero and less than LengthMask . For TX channels the value passed in should be the number of bytes to transmit from the TX buffer associated with the given BD . For RX channels the value passed in should be the size of the RX buffer associated with the given BD in bytes . This is to notify the RX channel the capability of the RX buffer to avoid buffer overflow . The actual receive length can be equal or smaller than the specified length . The actual transfer length will be updated by the hardware in the XAXIDMA_BD_STS_OFFSET word in the BD . @param BdPtr is the BD to operate on . @param LenBytes is the requested transfer length @param LengthMask is the maximum transfer length @returns - XST_SUCCESS for success - XST_INVALID_PARAM for invalid BD length @note This function can be used only when DMA is in SG mode
int XAxiDma_BdSetLength(XAxiDma_Bd *BdPtr, u32 LenBytes, u32 LengthMask)
{
	if (LenBytes <= 0 || (LenBytes > LengthMask)) {
		xdbg_printf(XDBG_DEBUG_ERROR, "invalid length %d\n",
		    (int)LenBytes);
		return XST_INVALID_PARAM;
	}
	XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_CTRL_LEN_OFFSET,
		((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_CTRL_LEN_OFFSET) & \
		~LengthMask)) | LenBytes);
	return XST_SUCCESS;
}
int XAxiDma_BdSetLength ( XAxiDma_Bd * BdPtr , u32 LenBytes , u32 LengthMask ) { if ( LenBytes <= 0 || ( LenBytes > LengthMask ) ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \n " , ( int ) LenBytes ) ; return XST_INVALID_PARAM ; } XAxiDma_BdWrite ( ( BdPtr ) , XAXIDMA_BD_CTRL_LEN_OFFSET , ( ( XAxiDma_BdRead ( ( BdPtr ) , XAXIDMA_BD_CTRL_LEN_OFFSET ) & ~ LengthMask ) ) | LenBytes ) ; return XST_SUCCESS ; }
Set the length field for the given BD.
Set the length field for the given BD .