From: lal.harshita Date: Tue, 22 Jun 2021 11:55:44 +0000 (+0530) Subject: Fix for RAR and DL dedicated PDU length [Issue-Id: ODUHIGH-348] X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=e44180890b286bf1f78cd8f3867092f0914cccec;p=o-du%2Fl2.git Fix for RAR and DL dedicated PDU length [Issue-Id: ODUHIGH-348] Change-Id: Id2706a0105c14e5faabb520905ab6c3b137b8bf4 Signed-off-by: lal.harshita --- diff --git a/src/5gnrmac/mac_msg_hdl.c b/src/5gnrmac/mac_msg_hdl.c index cdfe2951e..09056e8b2 100644 --- a/src/5gnrmac/mac_msg_hdl.c +++ b/src/5gnrmac/mac_msg_hdl.c @@ -210,10 +210,10 @@ uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd) * ****************************************************************/ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData) { - uint8_t pduIdx =0; + uint8_t pduIdx = 0; uint8_t lcIdx = 0; - uint8_t *txPdu =NULLP; - uint16_t tbSize =0,cellIdx=0; + uint8_t *txPdu = NULLP; + uint16_t cellIdx = 0, txPduLen = 0; MacDlData macDlData; MacDlSlot *currDlSlot = NULLP; DlRlcBoInfo dlBoInfo; @@ -240,16 +240,16 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData) currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot]; if(currDlSlot->dlInfo.dlMsgAlloc) { - tbSize = currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg.codeword[0].tbSize; - MAC_ALLOC(txPdu, tbSize); + txPduLen = currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg.codeword[0].tbSize - TX_PAYLOAD_HDR_LEN; + MAC_ALLOC(txPdu, txPduLen); if(!txPdu) { DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcRlcDlData"); return RFAILED; } - macMuxPdu(&macDlData, NULLP, txPdu, tbSize); + macMuxPdu(&macDlData, NULLP, txPdu, txPduLen); - currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPduLen = tbSize; + currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPduLen = txPduLen; currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu = txPdu; } @@ -531,7 +531,7 @@ uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo) if(dlCcchIndInfo->msgType == RRC_SETUP) { dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4 - /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1b byte sub-header) */ + /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */ dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1); /* storing Msg4 Pdu in raCb */ diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c index 18167d701..8659fa5dd 100644 --- a/src/5gnrmac/mac_mux.c +++ b/src/5gnrmac/mac_mux.c @@ -97,8 +97,6 @@ void packBytes(uint8_t *buf, uint16_t *bytePos, uint8_t *bitPos, uint32_t val, u void fillRarPdu(RarInfo *rarInfo) { uint8_t *rarPdu = rarInfo->rarPdu; - uint16_t totalBits = 0; - uint8_t numBytes = 0; uint16_t bytePos= 0; uint8_t bitPos = 0; @@ -137,23 +135,10 @@ void fillRarPdu(RarInfo *rarInfo) timeAdv = rarInfo->ta; ulGrant = 0; /* this will be done when implementing msg3 */ tmpCrnti = rarInfo->tcrnti; - - /* Calulating total number of bytes in buffer */ - totalBits = EBitSize + TBitSize + rapidSize + RBitSize + timeAdvSize \ - + ulGrantSize + tmpCrntiSize; - - /* add padding size */ - totalBits += RBitSize*2 + paddingLcidSize + paddingSize; - - /* Calulating total number of bytes in buffer */ - numBytes = totalBits/8; - if(totalBits % 8) - numBytes += 1; - - rarInfo->rarPduLen = numBytes; + rarInfo->rarPduLen = RAR_PAYLOAD_SIZE; /* Initialize buffer */ - for(bytePos = 0; bytePos < numBytes; bytePos++) + for(bytePos = 0; bytePos < rarInfo->rarPduLen; bytePos++) rarPdu[bytePos] = 0; bytePos = 0; diff --git a/src/5gnrmac/mac_slot_ind.c b/src/5gnrmac/mac_slot_ind.c index 0233223ab..dcbf870b4 100644 --- a/src/5gnrmac/mac_slot_ind.c +++ b/src/5gnrmac/mac_slot_ind.c @@ -125,6 +125,7 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc) { uint8_t ueIdx; uint16_t cellIdx; + uint16_t msg4TxPduLen; MacDlData msg4DlData; MacCeInfo macCeData; @@ -135,45 +136,49 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc) GET_UE_IDX(msg4Alloc->dlMsgInfo.crnti, ueIdx); ueIdx = ueIdx -1; + + if(macCb.macCell[cellIdx] == NULLP) + { + DU_LOG("\nERROR --> MAC: Cell Id[%d] not found", cellId); + return; + } + if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu != NULLP) { - MAC_ALLOC(msg4DlData.pduInfo[ueIdx].dlPdu, \ - macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); + MAC_ALLOC(msg4DlData.pduInfo[ueIdx].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); if(msg4DlData.pduInfo[ueIdx].dlPdu != NULLP) { - fillMsg4DlData(&msg4DlData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen,\ + msg4TxPduLen = macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize - TX_PAYLOAD_HDR_LEN; + + fillMsg4DlData(&msg4DlData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen, \ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu); - fillMacCe(&macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu); - /* Forming Mux Pdu */ - macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu = NULLP; - MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \ - macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize); - if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu != NULLP) - { - memset(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, 0, \ - macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize); - macMuxPdu(&msg4DlData, &macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu,\ - macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize); - - } - else - { - DU_LOG("\nERROR --> MAC: Failed allocating memory for msg4TxPdu"); - } - /* Free memory allocated */ - MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); + fillMacCe(&macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu); + /* Forming Mux Pdu */ + macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu = NULLP; + MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, msg4TxPduLen); + if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu != NULLP) + { + memset(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, 0, msg4TxPduLen); + macMuxPdu(&msg4DlData, &macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, msg4TxPduLen); + } + else + { + DU_LOG("\nERROR --> MAC: Failed allocating memory for msg4TxPdu"); + } + /* Free memory allocated */ + MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); } } /* storing msg4 Pdu in macDlSlot */ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu) { - msg4Alloc->dlMsgInfo.dlMsgPduLen = macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize; + msg4Alloc->dlMsgInfo.dlMsgPduLen = msg4TxPduLen; MAC_ALLOC(msg4Alloc->dlMsgInfo.dlMsgPdu, msg4Alloc->dlMsgInfo.dlMsgPduLen); if(msg4Alloc->dlMsgInfo.dlMsgPdu != NULLP) { - memcpy(msg4Alloc->dlMsgInfo.dlMsgPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \ - msg4Alloc->dlMsgInfo.dlMsgPduLen); + memcpy(msg4Alloc->dlMsgInfo.dlMsgPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \ + msg4Alloc->dlMsgInfo.dlMsgPduLen); } } else diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index 478cc3cf3..21a5ecbfa 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -51,7 +51,6 @@ #define DMRS_ADDITIONAL_POS 0 #define SCH_DEFAULT_K1 1 #define SCH_TQ_SIZE 10 -#define SCH_RAR_PAYLOAD_SIZE 10 /* As per spec 38.321, sections 6.1.5 and 6.2.3, RAR PDU is 8 bytes long and 2 bytes of padding */ #define CRC_FAILED 0 #define CRC_PASSED 1 diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index 819ce1f3c..bd9b65a54 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -364,7 +364,7 @@ bool ssbPresent, bool sib1Present) pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */ pdsch->codeword[cwCount].rvIndex = 0; /* RAR PDU length and FAPI payload header length */ - tbSize = schCalcTbSize(SCH_RAR_PAYLOAD_SIZE + TX_PAYLOAD_HDR_LEN); + tbSize = schCalcTbSize(RAR_PAYLOAD_SIZE + TX_PAYLOAD_HDR_LEN); pdsch->codeword[cwCount].tbSize = tbSize; } pdsch->dataScramblingId = pci; diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index 599b6389e..ec4c91de5 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -92,8 +92,10 @@ #define MAX_NUM_DL_DATA_TO_UL_ACK 15 #define SD_SIZE 3 +#define RAR_PAYLOAD_SIZE 10 /* As per spec 38.321, sections 6.1.5 and 6.2.3, RAR PDU is 8 bytes long and 2 bytes of padding */ #define TX_PAYLOAD_HDR_LEN 32 /* Intel L1 requires adding a 32 byte header to transmitted payload */ + #define ADD_DELTA_TO_TIME(crntTime, toFill, incr) \ { \ if ((crntTime.slot + incr) > (MAX_SLOTS - 1)) \ @@ -716,7 +718,7 @@ typedef struct rarInfo uint16_t ta; FreqDomainAlloc msg3FreqAlloc; uint16_t tcrnti; - uint8_t rarPdu[8]; + uint8_t rarPdu[RAR_PAYLOAD_SIZE]; uint8_t rarPduLen; }RarInfo;