From 094bc0c9a9b96745d26d2f20e7892baeea30e5da Mon Sep 17 00:00:00 2001 From: svaidhya Date: Tue, 17 Jun 2025 11:35:23 +0000 Subject: [PATCH] MSG2 issue: TBS and TX_Data pdulen matched Change-Id: Ie73168500f53f34eec74af5dbcbfbe09f8ad5896 Signed-off-by: svaidhya --- build/config/tdd_odu_config.xml | 2 +- src/5gnrmac/lwr_mac_fsm.c | 28 +++++++++++++------ src/5gnrmac/mac.h | 1 + src/5gnrmac/mac_mux.c | 60 +++++++++++++++++++++++++++++++++++++---- src/5gnrmac/mac_rach.c | 4 +++ src/5gnrsch/sch_rach.c | 21 ++++++--------- src/cm/cm_mem_wl.c | 2 +- 7 files changed, 90 insertions(+), 28 deletions(-) diff --git a/build/config/tdd_odu_config.xml b/build/config/tdd_odu_config.xml index f85ebc0ed..63101989d 100644 --- a/build/config/tdd_odu_config.xml +++ b/build/config/tdd_odu_config.xml @@ -466,7 +466,7 @@ 1 - 0 + 12 0 0 8192 diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 1552a0781..b332344e6 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -3925,12 +3925,14 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) tbScaling = 0; /* configured to 0 scaling */ reserved = 0; +#ifndef OAI_TESTING /* Reversing bits in each DCI field */ freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize); timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize); VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize); modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize); tbScaling = reverseBits(tbScaling, tbScalingSize); +#endif /* Calulating total number of bytes in buffer */ dlDciPtr[0].payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\ @@ -3947,14 +3949,18 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) } #ifdef OAI_TESTING - dlDciPtr[0].payloadSizeBits = reverseBytes16(39); + dlDciPtr[0].payloadSizeBits = reverseBytes16(dlDciPtr[0].payloadSizeBits); #endif /* Initialize buffer */ for(bytePos = 0; bytePos < numBytes; bytePos++) dlDciPtr[0].payload[bytePos] = 0; bytePos = numBytes - 1; +#ifndef OAI_TESTING bitPos = 0; +#else + bitPos = 1; +#endif /* Packing DCI format fields */ fillDlDciPayload(dlDciPtr[0].payload, &bytePos, &bitPos,\ @@ -3969,7 +3975,6 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) tbScaling, tbScalingSize); fillDlDciPayload(dlDciPtr[0].payload, &bytePos, &bitPos,\ reserved, reservedSize); - dlDciPtr[0].payload[4] = 0x15; } } /* fillRarDlDciPdu */ @@ -4917,6 +4922,11 @@ uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, RarInfo memcpy(pduDesc[pduIndex].tlvs[0].value.direct, rarInfo->rarPdu, rarInfo->rarPduLen); + for(uint8_t bytePos = 0; bytePos < rarInfo->rarPduLen; bytePos++) + { + printf("[%d]:0x%x\n",bytePos, pduDesc[pduIndex].tlvs[0].value.direct[bytePos]); + } + #endif /* FAPI */ return ROK; } @@ -5936,10 +5946,10 @@ void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu ulTtiReqPdu->pdu.pusch_pdu.bwpStart = reverseBytes16(macCellCfg->cellCfg.initialUlBwp.bwp.firstPrb); ulTtiReqPdu->pdu.pusch_pdu.targetCodeRate = reverseBytes16(308); ulTtiReqPdu->pdu.pusch_pdu.dataScramblingId = reverseBytes16(macCellCfg->cellId); - ulTtiReqPdu->pdu.pusch_pdu.ulDmrsSymbPos = reverseBytes16(4); + ulTtiReqPdu->pdu.pusch_pdu.ulDmrsSymbPos = reverseBytes16(1024); ulTtiReqPdu->pdu.pusch_pdu.ulDmrsScramblingId = reverseBytes16(macCellCfg->cellId); ulTtiReqPdu->pdu.pusch_pdu.puschIdentity = reverseBytes16(0); - ulTtiReqPdu->pdu.pusch_pdu.dmrsPorts = reverseBytes16(0); + ulTtiReqPdu->pdu.pusch_pdu.dmrsPorts = reverseBytes16(1); ulTtiReqPdu->pdu.pusch_pdu.rbStart = reverseBytes16(puschInfo->fdAlloc.resAlloc.type1.startPrb); ulTtiReqPdu->pdu.pusch_pdu.rbSize = reverseBytes16(puschInfo->fdAlloc.resAlloc.type1.numPrb); ulTtiReqPdu->pdu.pusch_pdu.txDirectCurrentLocation = reverseBytes16(0); @@ -5973,7 +5983,7 @@ void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu ulTtiReqPdu->pdu.pusch_pdu.nrOfLayers = 1; ulTtiReqPdu->pdu.pusch_pdu.dmrsConfigType = 0; ulTtiReqPdu->pdu.pusch_pdu.scid = 0; - ulTtiReqPdu->pdu.pusch_pdu.numDmrsCdmGrpsNoData = 1; + ulTtiReqPdu->pdu.pusch_pdu.numDmrsCdmGrpsNoData = 2; ulTtiReqPdu->pdu.pusch_pdu.resourceAlloc = \ puschInfo->fdAlloc.resAllocType; ulTtiReqPdu->pdu.pusch_pdu.vrbToPrbMapping = 0; @@ -6008,6 +6018,7 @@ void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu puschInfo->dmrsAddPos; #endif /* UL TTI Vendor PDU */ +#ifndef OAI_TESTING ulTtiVendorPdu->pdu_type = FAPI_PUSCH_PDU_TYPE; ulTtiVendorPdu->pdu.pusch_pdu.nr_of_antenna_ports=1; ulTtiVendorPdu->pdu.pusch_pdu.nr_of_rx_ru=1; @@ -6015,6 +6026,7 @@ void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu { ulTtiVendorPdu->pdu.pusch_pdu.rx_ru_idx[i]=0; } +#endif #endif } } @@ -6065,7 +6077,7 @@ void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu ulTtiReqPdu->pduSize = sizeof(fapi_ul_pucch_pdu_t); ulTtiReqPdu->pdu.pucch_pdu.rnti = pucchInfo->crnti; /* TODO : Fill handle in raCb when scheduling pucch and access here */ - ulTtiReqPdu->pdu.pucch_pdu.handle = reverseBytes32(100; + ulTtiReqPdu->pdu.pucch_pdu.handle = 100; ulTtiReqPdu->pdu.pucch_pdu.bwpSize = macCellCfg->cellCfg.initialUlBwp.bwp.numPrb; ulTtiReqPdu->pdu.pucch_pdu.bwpStart = macCellCfg->cellCfg.initialUlBwp.bwp.firstPrb; ulTtiReqPdu->pdu.pucch_pdu.prbStart = pucchInfo->fdAlloc.startPrb; @@ -6103,6 +6115,7 @@ void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu /* UL TTI Vendor PDU */ +#ifndef OAI_TESTING ulTtiVendorPdu->pdu_type = FAPI_PUCCH_PDU_TYPE; ulTtiVendorPdu->pdu.pucch_pdu.nr_of_rx_ru=1; ulTtiVendorPdu->pdu.pucch_pdu.group_id=0; @@ -6110,6 +6123,7 @@ void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu { ulTtiVendorPdu->pdu.pucch_pdu.rx_ru_idx[i]=0; } +#endif } } @@ -6331,8 +6345,6 @@ uint16_t fillUlTtiReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t pre } } } - ulTtiReq->ueGrpInfo[ulTtiReq->nGroup].nUe = MAX_NUM_UE_PER_TTI; - ulTtiReq->nGroup++; } uint32_t bufferLen=0; uint8_t mBuf[2500]; diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index d4a3f80cf..5b78c8399 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -56,6 +56,7 @@ #define E_BIT_SIZE 1 #define T_BIT_SIZE 1 #define R_BIT_SIZE 1 +#define BI_BIT_SIZE 4 #define RAPID_SIZE 6 #define LC_ID_SIZE 6 #define TIMING_ADVANCE_SIZE 12 diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c index 05ae55caa..ae289adb3 100644 --- a/src/5gnrmac/mac_mux.c +++ b/src/5gnrmac/mac_mux.c @@ -44,12 +44,13 @@ * ****************************************************************/ void packBytes(uint8_t *buf, uint16_t *bytePos, uint8_t *bitPos, uint32_t val, uint8_t valSize) { - uint32_t temp; uint8_t bytePart1; uint32_t bytePart2; uint8_t bytePart1Size; uint32_t bytePart2Size; +#ifndef OAI_TESTING + uint32_t temp; if(*bitPos - valSize + 1 >= 0) { bytePart1 = (uint8_t)val; @@ -77,6 +78,28 @@ void packBytes(uint8_t *buf, uint16_t *bytePos, uint8_t *bitPos, uint32_t val, u *bitPos = 7; packBytes(buf, bytePos, bitPos, bytePart2, bytePart2Size); } +#else + if(*bitPos + valSize <= 8) + { + bytePart1 = (uint8_t)val; + bytePart1 = ((~((~0) << valSize)) & bytePart1)<< (8 - (*bitPos + valSize)); + buf[*bytePos] |= bytePart1; + *bitPos += valSize; + } + else if(*bitPos + valSize > 8) + { + bytePart1Size = 8 - *bitPos; + bytePart2Size = valSize - bytePart1Size; + + bytePart1 = val >> bytePart2Size; + + buf[*bytePos] |= bytePart1; + (*bytePos)++; + *bitPos = 0; + packBytes(buf, bytePos, bitPos, val, bytePart2Size); + } + +#endif } /******************************************************************* @@ -110,6 +133,9 @@ void fillRarPdu(RarInfo *rarInfo) uint8_t RBit = 0; uint16_t msg3FreqResource = 0; uint8_t paddingLcid = 63; +#ifdef OAI_TESTING + uint16_t BIBit = 0; +#endif /* Considering 2 bytes of padding in RAR PDU. * 1st byte is MAC sub-header for padding @@ -117,10 +143,6 @@ void fillRarPdu(RarInfo *rarInfo) */ uint8_t paddingSize = 8; - /* Fill RAR pdu fields */ - EBit = 0; - TBit = 1; - RBit = 0; rarInfo->rarPduLen = RAR_PAYLOAD_SIZE; @@ -129,7 +151,29 @@ void fillRarPdu(RarInfo *rarInfo) rarPdu[bytePos] = 0; bytePos = 0; +#ifdef OAI_TESTING + bitPos = 0; +#else bitPos = 7; +#endif + +#ifdef OAI_TESTING + EBit = 1; + TBit = 0; + RBit = 0; + BIBit = 0; + + packBytes(rarPdu, &bytePos, &bitPos, EBit, E_BIT_SIZE); + packBytes(rarPdu, &bytePos, &bitPos, TBit, T_BIT_SIZE); + packBytes(rarPdu, &bytePos, &bitPos, RBit, R_BIT_SIZE); + packBytes(rarPdu, &bytePos, &bitPos, RBit, R_BIT_SIZE); + packBytes(rarPdu, &bytePos, &bitPos, BIBit, BI_BIT_SIZE); +#endif + + /* Fill RAR pdu fields */ + EBit = 0; + TBit = 1; + RBit = 0; /* Packing fields into RAR PDU */ packBytes(rarPdu, &bytePos, &bitPos, EBit, E_BIT_SIZE); @@ -202,9 +246,15 @@ void fillRarPdu(RarInfo *rarInfo) packBytes(rarPdu, &bytePos, &bitPos, rarInfo->tcrnti, T_CRNTI_SIZE); /* padding of 2 bytes */ +#ifndef OAI_TESTING packBytes(rarPdu, &bytePos, &bitPos, RBit, R_BIT_SIZE*2); packBytes(rarPdu, &bytePos, &bitPos, paddingLcid, LC_ID_SIZE); packBytes(rarPdu, &bytePos, &bitPos, 0, paddingSize); +#endif + + printf("\n SANG: RAR PDU\n"); + for(bytePos = 0; bytePos < rarInfo->rarPduLen; bytePos++) + printf("[%d]:0x%x\n",bytePos, rarPdu[bytePos]); } diff --git a/src/5gnrmac/mac_rach.c b/src/5gnrmac/mac_rach.c index c2196194e..065d87897 100644 --- a/src/5gnrmac/mac_rach.c +++ b/src/5gnrmac/mac_rach.c @@ -118,6 +118,10 @@ uint8_t createMacRaCb(MacCellCb *cellCb, RachIndInfo *rachIndInfo) return RFAILED; } + if(ueIdx >= MAX_NUM_UE) + { + ueIdx = 1; + } /* Calculate CRNTI from UE Index */ GET_CRNTI(crnti, ueIdx+1); diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index e05182438..8cd0bdfcd 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -913,6 +913,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl uint8_t dmrsStartSymbol, startSymbol, numSymbol ; uint16_t numRbs = 0; uint16_t tbSize = 0; + uint16_t offsetToPointA = 0; uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0}; PdschCfg *pdsch; @@ -923,6 +924,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl DU_LOG("\nERROR --> SCH : Memory allocation failed in %s",__func__); return RFAILED; } + offsetToPointA = cell->cellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA; PdcchCfg *pdcch = rarAlloc->rarPdcchCfg; BwpCfg *bwp = &rarAlloc->bwp; @@ -948,8 +950,8 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl bwp->freqAlloc.startPrb = initialBwp->bwp.freqAlloc.startPrb; pdcch->coresetCfg.durationSymbols = numSymbols; #else - bwp->freqAlloc.numPrb = 48; - bwp->freqAlloc.startPrb = 110; + bwp->freqAlloc.numPrb = numRbs; + bwp->freqAlloc.startPrb = ((offsetToPointA >> initialBwp->bwp.scs) - coresetIdxTable[coreset0Idx][3]); pdcch->coresetCfg.durationSymbols = 1; #endif bwp->subcarrierSpacing = initialBwp->bwp.scs; @@ -995,17 +997,14 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdsch->numCodewords = 1; for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++) { - pdsch->codeword[cwCount].targetCodeRate = 1200; + pdsch->codeword[cwCount].targetCodeRate = 1570; pdsch->codeword[cwCount].qamModOrder = 2; - pdsch->codeword[cwCount].mcsIndex = 0; /* mcs configured to 4 */ + pdsch->codeword[cwCount].mcsIndex = 1; /* mcs configured to 4 */ pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */ pdsch->codeword[cwCount].rvIndex = 0; /* RAR PDU length and FAPI payload header length */ tbSize = schCalcTbSize(RAR_PAYLOAD_SIZE + TX_PAYLOAD_HDR_LEN); pdsch->codeword[cwCount].tbSize = tbSize; -#ifdef OAI_TESTING - pdsch->codeword[cwCount].tbSize = 28; -#endif } pdsch->dataScramblingId = cell->cellCfg.phyCellId; pdsch->numLayers = 1; @@ -1030,14 +1029,10 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ - pdsch->pdschFreqAlloc.startPrb = MAX_NUM_RB; + pdsch->pdschFreqAlloc.startPrb = 0; pdsch->pdschFreqAlloc.numPrb = \ schCalcNumPrb(tbSize, mcs, initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol); -#ifdef OAI_TESTING - pdsch->pdschFreqAlloc.startPrb = 0; - pdsch->pdschFreqAlloc.numPrb = 8; -#endif /* Find total symbols occupied including DMRS */ dmrsStartSymbol = findDmrsStartSymbol(pdsch->dmrs.dlDmrsSymbPos); /* If there are no DRMS symbols, findDmrsStartSymbol() returns MAX_SYMB_PER_SLOT, @@ -1065,7 +1060,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdsch->beamPdschInfo.numPrgs = 0; pdsch->beamPdschInfo.prgSize = 0; - pdsch->beamPdschInfo.digBfInterfaces = 0; + pdsch->beamPdschInfo.digBfInterfaces = 1; pdsch->beamPdschInfo.prg[0].pmIdx = 0; pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0; pdsch->txPdschPower.powerControlOffset = 0; diff --git a/src/cm/cm_mem_wl.c b/src/cm/cm_mem_wl.c index 6d6fd4a87..9227f81c0 100755 --- a/src/cm/cm_mem_wl.c +++ b/src/cm/cm_mem_wl.c @@ -1940,7 +1940,7 @@ Data **ptr /* Reference to pointer for which need to be allocate */ #endif if (idx > 512) { - DU_LOG("\nERROR --> CM: cmDynAlloc(): idx value is greater than 512"); + DU_LOG("\nERROR --> CM: cmDynAlloc(): idx:%d,size:%d, regCb->bktQnPwr:%d value is greater than 512",idx, *size, regCb->bktQnPwr); return RFAILED; } /* Dequeue the memory block and return it to the user */ -- 2.16.6