XilinxProcessorIPLib/drivers/aienginev2/src/dma/xaie_dma_aieml.c
AieRC _XAieMl_TileDmaWriteBd(XAie_DevInst *DevInst , XAie_DmaDesc *DmaDesc,
		XAie_LocType Loc, u8 BdNum)
{
	AieRC RC;
	u64 Addr;
	u64 BdBaseAddr;
	u32 BdWord[XAIEML_TILEDMA_NUM_BD_WORDS];
	const XAie_DmaMod *DmaMod;
	const XAie_DmaBdProp *BdProp;

	DmaMod = DevInst->DevProp.DevMod[DmaDesc->TileType].DmaMod;
	BdProp = DmaMod->BdProp;

	BdBaseAddr = DmaMod->BaseAddr + BdNum * DmaMod->IdxOffset;

	/* Setup BdWord with the right values from DmaDesc */
	BdWord[0U] = XAie_SetField(DmaDesc->AddrDesc.Address,
				BdProp->Buffer->TileDmaBuff.BaseAddr.Lsb,
				BdProp->Buffer->TileDmaBuff.BaseAddr.Mask) |
		XAie_SetField(DmaDesc->AddrDesc.Length,
				BdProp->Buffer->TileDmaBuff.BufferLen.Lsb,
				BdProp->Buffer->TileDmaBuff.BufferLen.Mask);

	BdWord[1U] = XAie_SetField(DmaDesc->EnCompression,
				BdProp->Compression->EnCompression.Lsb,
				BdProp->Compression->EnCompression.Mask) |
		XAie_SetField(DmaDesc->PktDesc.PktEn,
				BdProp->Pkt->EnPkt.Lsb,
				BdProp->Pkt->EnPkt.Mask) |
		XAie_SetField(DmaDesc->PktDesc.PktType,
				BdProp->Pkt->PktType.Lsb,
				BdProp->Pkt->PktType.Mask) |
		XAie_SetField(DmaDesc->PktDesc.PktId, BdProp->Pkt->PktId.Lsb,
				BdProp->Pkt->PktId.Mask) |
		XAie_SetField(DmaDesc->BdEnDesc.OutofOrderBdId,
				BdProp->BdEn->OutofOrderBdId.Lsb,
				BdProp->BdEn->OutofOrderBdId.Mask);

	BdWord[2U] = XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[1U].StepSize - 1U),
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].StepSize.Lsb,
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].StepSize.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[0U].StepSize - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].StepSize.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].StepSize.Mask);

	BdWord[3U] = XAie_SetField(DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[1U].Wrap,
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].Wrap.Lsb,
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].Wrap.Mask) |
		XAie_SetField(DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[0U].Wrap,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].Wrap.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].Wrap.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[2U].StepSize - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[2U].StepSize.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[2U].StepSize.Mask);

	BdWord[4U] = XAie_SetField(DmaDesc->MultiDimDesc.AieMlMultiDimDesc.IterCurr,
			BdProp->AddrMode->AieMlMultiDimAddr.IterCurr.Lsb,
			BdProp->AddrMode->AieMlMultiDimAddr.IterCurr.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.IterDesc.Wrap - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.Wrap.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.Wrap.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.IterDesc.StepSize - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.StepSize.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.StepSize.Mask);

	BdWord[5U] = XAie_SetField(DmaDesc->BdEnDesc.ValidBd,
			BdProp->BdEn->ValidBd.Lsb, BdProp->BdEn->ValidBd.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockRelVal,
				BdProp->Lock->AieMlDmaLock.LckRelVal.Lsb,
				BdProp->Lock->AieMlDmaLock.LckRelVal.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockRelId,
				BdProp->Lock->AieMlDmaLock.LckRelId.Lsb,
				BdProp->Lock->AieMlDmaLock.LckRelId.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockAcqId,
				BdProp->Lock->AieMlDmaLock.LckAcqId.Lsb,
				BdProp->Lock->AieMlDmaLock.LckAcqId.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockAcqVal,
				BdProp->Lock->AieMlDmaLock.LckAcqVal.Lsb,
				BdProp->Lock->AieMlDmaLock.LckAcqVal.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockAcqEn,
				BdProp->Lock->AieMlDmaLock.LckAcqEn.Lsb,
				BdProp->Lock->AieMlDmaLock.LckAcqEn.Mask) |
		XAie_SetField(DmaDesc->BdEnDesc.UseNxtBd,
				BdProp->BdEn->UseNxtBd.Lsb,
				BdProp->BdEn->UseNxtBd.Mask) |
		XAie_SetField(DmaDesc->BdEnDesc.NxtBd, BdProp->BdEn->NxtBd.Lsb,
				BdProp->BdEn->NxtBd.Mask) |
		XAie_SetField(DmaDesc->TlastSuppress,
				BdProp->BdEn->TlastSuppress.Lsb,
				BdProp->BdEn->TlastSuppress.Mask);

	Addr = BdBaseAddr + _XAie_GetTileAddr(DevInst, Loc.Row, Loc.Col);

	for(u8 i = 0U; i < XAIEML_TILEDMA_NUM_BD_WORDS; i++) {
		RC = XAie_Write32(DevInst, Addr + i * 4U, BdWord[i]);
		if(RC != XAIE_OK) {
			return RC;
		}
	}

	return XAIE_OK;
}
/*****************************************************************************/
/**
*
* This API writes a Dma Descriptor which is initialized and setup by other APIs
* into the corresponding registers and register fields in the hardware. This API
* is specific to AIEML Tiles only.
*
* @param	DevInst: Device Instance
* @param	DmaDesc: Initialized Dma Descriptor.
* @param	Loc: Location of AIE Tile
* @param	BdNum: Hardware BD number to be written to.
*
* @return	XAIE_OK on success, Error code on failure.
*
* @note		Internal only. For AIEML Tiles only.
*
******************************************************************************/
This API writes a Dma Descriptor which is initialized and setup by other APIs
into the corresponding registers and register fields in the hardware. This API
is specific to AIEML Tiles only.
This API writes a Dma Descriptor which is initialized and setup by other APIs into the corresponding registers and register fields in the hardware . This API is specific to AIEML Tiles only .
AieRC _XAieMl_TileDmaWriteBd(XAie_DevInst *DevInst , XAie_DmaDesc *DmaDesc,
		XAie_LocType Loc, u8 BdNum)
{
	AieRC RC;
	u64 Addr;
	u64 BdBaseAddr;
	u32 BdWord[XAIEML_TILEDMA_NUM_BD_WORDS];
	const XAie_DmaMod *DmaMod;
	const XAie_DmaBdProp *BdProp;
	DmaMod = DevInst->DevProp.DevMod[DmaDesc->TileType].DmaMod;
	BdProp = DmaMod->BdProp;
	BdBaseAddr = DmaMod->BaseAddr + BdNum * DmaMod->IdxOffset;
	BdWord[0U] = XAie_SetField(DmaDesc->AddrDesc.Address,
				BdProp->Buffer->TileDmaBuff.BaseAddr.Lsb,
				BdProp->Buffer->TileDmaBuff.BaseAddr.Mask) |
		XAie_SetField(DmaDesc->AddrDesc.Length,
				BdProp->Buffer->TileDmaBuff.BufferLen.Lsb,
				BdProp->Buffer->TileDmaBuff.BufferLen.Mask);
	BdWord[1U] = XAie_SetField(DmaDesc->EnCompression,
				BdProp->Compression->EnCompression.Lsb,
				BdProp->Compression->EnCompression.Mask) |
		XAie_SetField(DmaDesc->PktDesc.PktEn,
				BdProp->Pkt->EnPkt.Lsb,
				BdProp->Pkt->EnPkt.Mask) |
		XAie_SetField(DmaDesc->PktDesc.PktType,
				BdProp->Pkt->PktType.Lsb,
				BdProp->Pkt->PktType.Mask) |
		XAie_SetField(DmaDesc->PktDesc.PktId, BdProp->Pkt->PktId.Lsb,
				BdProp->Pkt->PktId.Mask) |
		XAie_SetField(DmaDesc->BdEnDesc.OutofOrderBdId,
				BdProp->BdEn->OutofOrderBdId.Lsb,
				BdProp->BdEn->OutofOrderBdId.Mask);
	BdWord[2U] = XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[1U].StepSize - 1U),
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].StepSize.Lsb,
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].StepSize.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[0U].StepSize - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].StepSize.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].StepSize.Mask);
	BdWord[3U] = XAie_SetField(DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[1U].Wrap,
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].Wrap.Lsb,
			BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[1U].Wrap.Mask) |
		XAie_SetField(DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[0U].Wrap,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].Wrap.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[0U].Wrap.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.DimDesc[2U].StepSize - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[2U].StepSize.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.DmaDimProp[2U].StepSize.Mask);
	BdWord[4U] = XAie_SetField(DmaDesc->MultiDimDesc.AieMlMultiDimDesc.IterCurr,
			BdProp->AddrMode->AieMlMultiDimAddr.IterCurr.Lsb,
			BdProp->AddrMode->AieMlMultiDimAddr.IterCurr.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.IterDesc.Wrap - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.Wrap.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.Wrap.Mask) |
		XAie_SetField((DmaDesc->MultiDimDesc.AieMlMultiDimDesc.IterDesc.StepSize - 1U),
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.StepSize.Lsb,
				BdProp->AddrMode->AieMlMultiDimAddr.Iter.StepSize.Mask);
	BdWord[5U] = XAie_SetField(DmaDesc->BdEnDesc.ValidBd,
			BdProp->BdEn->ValidBd.Lsb, BdProp->BdEn->ValidBd.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockRelVal,
				BdProp->Lock->AieMlDmaLock.LckRelVal.Lsb,
				BdProp->Lock->AieMlDmaLock.LckRelVal.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockRelId,
				BdProp->Lock->AieMlDmaLock.LckRelId.Lsb,
				BdProp->Lock->AieMlDmaLock.LckRelId.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockAcqId,
				BdProp->Lock->AieMlDmaLock.LckAcqId.Lsb,
				BdProp->Lock->AieMlDmaLock.LckAcqId.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockAcqVal,
				BdProp->Lock->AieMlDmaLock.LckAcqVal.Lsb,
				BdProp->Lock->AieMlDmaLock.LckAcqVal.Mask) |
		XAie_SetField(DmaDesc->LockDesc.LockAcqEn,
				BdProp->Lock->AieMlDmaLock.LckAcqEn.Lsb,
				BdProp->Lock->AieMlDmaLock.LckAcqEn.Mask) |
		XAie_SetField(DmaDesc->BdEnDesc.UseNxtBd,
				BdProp->BdEn->UseNxtBd.Lsb,
				BdProp->BdEn->UseNxtBd.Mask) |
		XAie_SetField(DmaDesc->BdEnDesc.NxtBd, BdProp->BdEn->NxtBd.Lsb,
				BdProp->BdEn->NxtBd.Mask) |
		XAie_SetField(DmaDesc->TlastSuppress,
				BdProp->BdEn->TlastSuppress.Lsb,
				BdProp->BdEn->TlastSuppress.Mask);
	Addr = BdBaseAddr + _XAie_GetTileAddr(DevInst, Loc.Row, Loc.Col);
	for(u8 i = 0U; i < XAIEML_TILEDMA_NUM_BD_WORDS; i++) {
		RC = XAie_Write32(DevInst, Addr + i * 4U, BdWord[i]);
		if(RC != XAIE_OK) {
			return RC;
		}
	}
	return XAIE_OK;
}
AieRC _XAieMl_TileDmaWriteBd ( XAie_DevInst * DevInst , XAie_DmaDesc * DmaDesc , XAie_LocType Loc , u8 BdNum ) { AieRC RC ; u64 Addr ; u64 BdBaseAddr ; u32 BdWord [ XAIEML_TILEDMA_NUM_BD_WORDS ] ; const XAie_DmaMod * DmaMod ; const XAie_DmaBdProp * BdProp ; DmaMod = DevInst -> DevProp . DevMod [ DmaDesc -> TileType ] . DmaMod ; BdProp = DmaMod -> BdProp ; BdBaseAddr = DmaMod -> BaseAddr + BdNum * DmaMod -> IdxOffset ; BdWord [ 0U ] = XAie_SetField ( DmaDesc -> AddrDesc . Address , BdProp -> Buffer -> TileDmaBuff . BaseAddr . Lsb , BdProp -> Buffer -> TileDmaBuff . BaseAddr . Mask ) | XAie_SetField ( DmaDesc -> AddrDesc . Length , BdProp -> Buffer -> TileDmaBuff . BufferLen . Lsb , BdProp -> Buffer -> TileDmaBuff . BufferLen . Mask ) ; BdWord [ 1U ] = XAie_SetField ( DmaDesc -> EnCompression , BdProp -> Compression -> EnCompression . Lsb , BdProp -> Compression -> EnCompression . Mask ) | XAie_SetField ( DmaDesc -> PktDesc . PktEn , BdProp -> Pkt -> EnPkt . Lsb , BdProp -> Pkt -> EnPkt . Mask ) | XAie_SetField ( DmaDesc -> PktDesc . PktType , BdProp -> Pkt -> PktType . Lsb , BdProp -> Pkt -> PktType . Mask ) | XAie_SetField ( DmaDesc -> PktDesc . PktId , BdProp -> Pkt -> PktId . Lsb , BdProp -> Pkt -> PktId . Mask ) | XAie_SetField ( DmaDesc -> BdEnDesc . OutofOrderBdId , BdProp -> BdEn -> OutofOrderBdId . Lsb , BdProp -> BdEn -> OutofOrderBdId . Mask ) ; BdWord [ 2U ] = XAie_SetField ( ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . DimDesc [ 1U ] . StepSize - 1U ) , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 1U ] . StepSize . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 1U ] . StepSize . Mask ) | XAie_SetField ( ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . DimDesc [ 0U ] . StepSize - 1U ) , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 0U ] . StepSize . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 0U ] . StepSize . Mask ) ; BdWord [ 3U ] = XAie_SetField ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . DimDesc [ 1U ] . Wrap , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 1U ] . Wrap . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 1U ] . Wrap . Mask ) | XAie_SetField ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . DimDesc [ 0U ] . Wrap , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 0U ] . Wrap . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 0U ] . Wrap . Mask ) | XAie_SetField ( ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . DimDesc [ 2U ] . StepSize - 1U ) , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 2U ] . StepSize . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . DmaDimProp [ 2U ] . StepSize . Mask ) ; BdWord [ 4U ] = XAie_SetField ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . IterCurr , BdProp -> AddrMode -> AieMlMultiDimAddr . IterCurr . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . IterCurr . Mask ) | XAie_SetField ( ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . IterDesc . Wrap - 1U ) , BdProp -> AddrMode -> AieMlMultiDimAddr . Iter . Wrap . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . Iter . Wrap . Mask ) | XAie_SetField ( ( DmaDesc -> MultiDimDesc . AieMlMultiDimDesc . IterDesc . StepSize - 1U ) , BdProp -> AddrMode -> AieMlMultiDimAddr . Iter . StepSize . Lsb , BdProp -> AddrMode -> AieMlMultiDimAddr . Iter . StepSize . Mask ) ; BdWord [ 5U ] = XAie_SetField ( DmaDesc -> BdEnDesc . ValidBd , BdProp -> BdEn -> ValidBd . Lsb , BdProp -> BdEn -> ValidBd . Mask ) | XAie_SetField ( DmaDesc -> LockDesc . LockRelVal , BdProp -> Lock -> AieMlDmaLock . LckRelVal . Lsb , BdProp -> Lock -> AieMlDmaLock . LckRelVal . Mask ) | XAie_SetField ( DmaDesc -> LockDesc . LockRelId , BdProp -> Lock -> AieMlDmaLock . LckRelId . Lsb , BdProp -> Lock -> AieMlDmaLock . LckRelId . Mask ) | XAie_SetField ( DmaDesc -> LockDesc . LockAcqId , BdProp -> Lock -> AieMlDmaLock . LckAcqId . Lsb , BdProp -> Lock -> AieMlDmaLock . LckAcqId . Mask ) | XAie_SetField ( DmaDesc -> LockDesc . LockAcqVal , BdProp -> Lock -> AieMlDmaLock . LckAcqVal . Lsb , BdProp -> Lock -> AieMlDmaLock . LckAcqVal . Mask ) | XAie_SetField ( DmaDesc -> LockDesc . LockAcqEn , BdProp -> Lock -> AieMlDmaLock . LckAcqEn . Lsb , BdProp -> Lock -> AieMlDmaLock . LckAcqEn . Mask ) | XAie_SetField ( DmaDesc -> BdEnDesc . UseNxtBd , BdProp -> BdEn -> UseNxtBd . Lsb , BdProp -> BdEn -> UseNxtBd . Mask ) | XAie_SetField ( DmaDesc -> BdEnDesc . NxtBd , BdProp -> BdEn -> NxtBd . Lsb , BdProp -> BdEn -> NxtBd . Mask ) | XAie_SetField ( DmaDesc -> TlastSuppress , BdProp -> BdEn -> TlastSuppress . Lsb , BdProp -> BdEn -> TlastSuppress . Mask ) ; Addr = BdBaseAddr + _XAie_GetTileAddr ( DevInst , Loc . Row , Loc . Col ) ; for ( u8 i = 0U ; i < XAIEML_TILEDMA_NUM_BD_WORDS ; i ++ ) { RC = XAie_Write32 ( DevInst , Addr + i * 4U , BdWord [ i ] ) ; if ( RC != XAIE_OK ) { return RC ; } } return XAIE_OK ; }
This API writes a Dma Descriptor which is initialized and setup by other APIs
into the corresponding registers and register fields in the hardware.
This API writes a Dma Descriptor which is initialized and setup by other APIs into the corresponding registers and register fields in the hardware .
/* Setup BdWord with the right values from DmaDesc */