Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem with XAxiDma_BdGetActualLength in Multichannel AXI DMA?

Status
Not open for further replies.

Port Map

Advanced Member level 4
Joined
Aug 24, 2013
Messages
118
Helped
15
Reputation
30
Reaction score
14
Trophy points
1,298
Activity points
2,089
Hi.
is any one familiar with multichannel AXI Dma On Zynq?

I'm trying to run multichannel AXI DMA. My work is done on SDK default Example by some changes on code.

now I want to use XAxiDma_BdGetActualLength function to get the received packet length. but this function always returns zero!

plz, any one can help me?

Code:
static void RxCallBack(XAxiDma *AxiDmaPtr)
{
	int BdCount;
	XAxiDma_Bd *BdPtr;
	XAxiDma_Bd *BdCurPtr;
	u32 BdSts;
	int Index;
	int RingIndex;
	XAxiDma_BdRing *RxRingPtr;

	u8 *RxPacket;


	for (RingIndex = 0;
			RingIndex < AxiDmaPtr->RxNumChannels; RingIndex++) 
	{

		RxRingPtr = XAxiDma_GetRxIndexRing(AxiDmaPtr, RingIndex);
		BdCount = XAxiDma_BdRingFromHw(RxRingPtr, XAXIDMA_ALL_BDS, &BdPtr);

		BdCurPtr = BdPtr;
		for (Index = 0; Index < BdCount; Index++) {

			/*
			 * Check the flags set by the hardware for status
			 * If error happens, processing stops, because the DMA engine
			 * is halted after this BD.
			 */
			BdSts = XAxiDma_BdGetSts(BdCurPtr);
			if ((BdSts & XAXIDMA_BD_STS_ALL_ERR_MASK) ||
			    (!(BdSts & XAXIDMA_BD_STS_COMPLETE_MASK))) {
				Error = 1;
				break;
			}

			//Consume RxPacket Here
			int PackLength=0;
			RxPacket = (u8 *) XAxiDma_BdGetBufAddr(BdCurPtr) ;
			/* Invalidate the DestBuffer before receiving the data, in case the
			 * Data Cache is enabled
			 */
			Xil_DCacheInvalidateRange((u32)RxPacket, MAX_PKT_LEN);

			PackLength=XAxiDma_BdGetActualLength(BdCurPtr,MAX_PKT_Mask);
			//look here  --@@--, PackLength is zero always
			//PackLength=512;



			/* Find the next processed BD */
			BdCurPtr = XAxiDma_BdRingNext(RxRingPtr, BdCurPtr);
			RxDone[RingIndex] += 1;
		}

		if(BdCount!=0)
		{
			//@@// added for test to free RX BDs
			/* Free all processed BDs for future transmission */
			int Status = XAxiDma_BdRingFree(RxRingPtr, BdCount, BdPtr);
			if (Status != XST_SUCCESS) {
				Error = 1;
			}
			/* Return processed BDs to RX channel so we are ready to receive new
			 * packets:
			 *    - Allocate all free RX BDs
			 *    - Pass the BDs to RX channel
			 */
			int FreeBdCount = XAxiDma_BdRingGetFreeCnt(RxRingPtr);
			Status = XAxiDma_BdRingAlloc(RxRingPtr, FreeBdCount, &BdPtr);
			if (Status != XST_SUCCESS) {
				xil_printf("bd alloc failed\r\n");
				return XST_FAILURE;
			}

			Status = XAxiDma_BdRingToHw(RxRingPtr, FreeBdCount, BdPtr);
			if (Status != XST_SUCCESS) {
				xil_printf("Submit %d rx BDs failed %d\r\n", FreeBdCount, Status);
				return XST_FAILURE;
			}

		}

	}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top