/* The set will be rejected if the last BD of the set does not mark the end of a packet (see XEmacPs_BdSetLast()). */
LONG XEmacPs_BdRingToHw(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
/* The set will be rejected if the last BD of the set does not mark the end of a packet (see XEmacPs_BdSetLast()). */
LONG XEmacPs_BdRingToHw(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
{
    XEmacPs_Bd *CurBdPtr;
    u32 i;
    LONG Status;
    if (0U == NumBd){
        Status = (LONG)(XST_SUCCESS);
    } else {
    if ((RingPtr->PreCnt < NumBd) || (RingPtr->PreHead != BdSetPtr)) {
            Status = (LONG)(XST_DMA_SG_LIST_ERROR);
        } else {
    CurBdPtr = BdSetPtr;
            for (i = 0U; i < NumBd; i++) {
                CurBdPtr = (XEmacPs_Bd *)((void *)XEmacPs_BdRingNext(RingPtr, CurBdPtr));
    }
    XEMACPS_RING_SEEKAHEAD(RingPtr, RingPtr->PreHead, NumBd);
    RingPtr->PreCnt -= NumBd;
    RingPtr->HwTail = CurBdPtr;
    RingPtr->HwCnt += NumBd;
            Status = (LONG)(XST_SUCCESS);
        }
    }
    return Status;
}