From 0d34456980069864f19fe3090ed5a4c968fe2d45 Mon Sep 17 00:00:00 2001 From: Balaji Shankaran Date: Thu, 23 Jul 2020 11:48:04 +0530 Subject: [PATCH] Mux Code Changes JIRA ID: ODUHIGH-195 Change-Id: Ie3fb8db052572c7280ed5ad91cbf7b46f1d778a0 Signed-off-by: Balaji Shankaran --- src/5gnrmac/lwr_mac_fsm.c | 13 +++++-- src/5gnrmac/mac.h | 7 ++-- src/5gnrmac/mac_mux.c | 25 ++++++------- src/5gnrmac/mac_slot_ind.c | 89 ++++++++++++++++++++++++++-------------------- src/5gnrmac/rg_tom.c | 13 ++++++- 5 files changed, 87 insertions(+), 60 deletions(-) diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 494d6a532..be8a4b1f8 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -3051,6 +3051,7 @@ uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo, uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info, uint32_t *msgLen, uint16_t pduIndex) { + uint16_t idx = 0; uint32_t pduLen = 0; uint32_t *msg4TxDataValue = NULLP; @@ -3066,7 +3067,10 @@ uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info, { return RFAILED; } - memcpy(msg4TxDataValue, msg4Info->msg4Pdu, msg4Info->msg4PduLen); + for(idx = 0; idx < msg4Info->msg4PduLen; idx++) + { + msg4TxDataValue[idx] = msg4Info->msg4Pdu[idx]; + } pduDesc[pduIndex].tlvs[0].value = (uint32_t)msg4TxDataValue; /* The total length of the PDU description and PDU data */ @@ -3353,13 +3357,16 @@ uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo) MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc)); dlInfo->rarAlloc = NULLP; } - if(dlInfo->msg4Alloc != NULLP) + if(dlInfo->msg4Alloc != NULLP && dlInfo->msg4Alloc->msg4Info.msg4Pdu != NULLP) { fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\ msg4Info, &msgLen, pduIndex); pduIndex++; txDataReq->numPdus++; - + + MAC_FREE(dlInfo->msg4Alloc->msg4Info.msg4Pdu,\ + dlInfo->msg4Alloc->msg4Info.msg4PduLen); + dlInfo->msg4Alloc->msg4Info.msg4Pdu = NULLP; MAC_FREE(dlInfo->msg4Alloc,sizeof(Msg4Alloc)); dlInfo->msg4Alloc = NULLP; } diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index 82fa48437..99c769d39 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -143,11 +143,12 @@ MacCb macCb; void fillMacToSchPst(Pst *pst); void fillRarPdu(RarInfo *rarInfo); void createMacRaCb(uint16_t cellId, uint16_t crnti); -void fillMsg4DlData(MacDlData *dlData); -void fillMacCe(MacCeInfo *macCeData); -void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize); +void fillMsg4DlData(MacDlData *dlData, uint8_t *msg4Pdu); +void fillMacCe(MacCeInfo *macCeData, uint8_t *msg3Pdu); +void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize); int unpackRxData(RxDataIndPdu *rxDataIndPdu); uint16_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti); +void BuildAndSendMsg4MuxPdu(Msg4Alloc *msg4Alloc); #endif /********************************************************************** diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c index 738e5eee8..ddc2476ed 100644 --- a/src/5gnrmac/mac_mux.c +++ b/src/5gnrmac/mac_mux.c @@ -218,13 +218,14 @@ void createMacRaCb(uint16_t cellId, uint16_t crnti) * @details * * Function : fillMsg4DlData - * This function is a stub which sends Dl Data + * This function sends Dl Data * to form MAC SDUs * * @param[in] MacDlData *dlData + * msg4Pdu pointer ************************************************/ -void fillMsg4DlData(MacDlData *dlData) +void fillMsg4DlData(MacDlData *dlData, uint8_t *msg4Pdu) { uint8_t idx = 0; uint16_t idx2; @@ -233,8 +234,7 @@ void fillMsg4DlData(MacDlData *dlData) dlData->pduInfo[idx].pduLen = macCb.macCell->macRaCb[idx].msg4PduLen; for(idx2 = 0; idx2 < dlData->pduInfo[idx].pduLen; idx2++) { - dlData->pduInfo[idx].dlPdu[idx2] = \ - macCb.macCell->macRaCb[idx].msg4Pdu[idx2]; + dlData->pduInfo[idx].dlPdu[idx2] = msg4Pdu[idx2]; } } @@ -247,9 +247,10 @@ void fillMsg4DlData(MacDlData *dlData) * This function fills Mac ce identities * * @param[in] RlcMacData *dlData + * Msg3Pdu Data ************************************************/ -void fillMacCe(MacCeInfo *macCeInfo) +void fillMacCe(MacCeInfo *macCeInfo, uint8_t *msg3Pdu) { uint8_t idx; macCeInfo->numCes = 1; @@ -257,7 +258,7 @@ void fillMacCe(MacCeInfo *macCeInfo) { macCeInfo->macCe[idx].macCeLcid = MAC_LCID_CRI; memcpy(macCeInfo->macCe[idx].macCeValue, \ - macCb.macCell->macRaCb[idx].msg3Pdu, MAX_CRI_SIZE); + msg3Pdu, MAX_CRI_SIZE); } } @@ -272,12 +273,11 @@ void fillMacCe(MacCeInfo *macCeInfo) * Functionality: * The MAC PDU will be MUXed and formed * - * @params[in] MacDlData *, MacCeInfo *, tbSize + * @params[in] MacDlData *, MacCeInfo *, msg4TxPdu *, tbSize * @return void - * * ****************************************************************/ -void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) +void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize) { uint8_t bytePos = 0; uint8_t bitPos = 7; @@ -365,12 +365,9 @@ void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) } /*Storing the muxed pdu in macRaCb */ - macCb.macCell->macRaCb[0].msg4TxPdu = NULLP; - MAC_ALLOC(macCb.macCell->macRaCb[0].msg4TxPdu, macCb.macCell->macRaCb[0].msg4TbSize); - if(macCb.macCell->macRaCb[0].msg4TxPdu != NULLP) + if(msg4TxPdu != NULLP) { - memcpy(macCb.macCell->macRaCb[0].msg4TxPdu, macPdu,\ - macCb.macCell->macRaCb[0].msg4TbSize); + memcpy(msg4TxPdu, macPdu, tbSize); } } diff --git a/src/5gnrmac/mac_slot_ind.c b/src/5gnrmac/mac_slot_ind.c index cb0b83220..c30b94639 100644 --- a/src/5gnrmac/mac_slot_ind.c +++ b/src/5gnrmac/mac_slot_ind.c @@ -85,58 +85,69 @@ int MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo) if(dlSchedInfo->msg4Alloc != NULLP) { Msg4Alloc *msg4Alloc = NULLP; - MacDlData msg4DlData; - MacCeInfo macCeData; - currDlSlot = &macCb.macCell->dlSlot[dlSchedInfo->schSlotValue.msg4Time.slot]; currDlSlot->dlInfo.msg4Alloc = dlSchedInfo->msg4Alloc; /* copy msg4 alloc pointer in MAC slot info */ msg4Alloc = dlSchedInfo->msg4Alloc; + macCb.macCell->macRaCb[0].msg4TbSize = msg4Alloc->msg4PdschCfg.codeword[0].tbSize; + } + } + return ROK; +} - memset(&msg4DlData, 0, sizeof(MacDlData)); - memset(&macCeData, 0, sizeof(MacCeInfo)); +void BuildAndSendMsg4MuxPdu(Msg4Alloc *msg4Alloc) +{ + MacDlData msg4DlData; + MacCeInfo macCeData; - macCb.macCell->macRaCb[0].msg4TbSize = msg4Alloc->msg4PdschCfg.codeword[0].tbSize; + memset(&msg4DlData, 0, sizeof(MacDlData)); + memset(&macCeData, 0, sizeof(MacCeInfo)); - if(macCb.macCell->macRaCb[0].msg4Pdu != NULLP) + if(macCb.macCell->macRaCb[0].msg4Pdu != NULLP) + { + MAC_ALLOC(msg4DlData.pduInfo[0].dlPdu, \ + macCb.macCell->macRaCb[0].msg4PduLen); + if(msg4DlData.pduInfo[0].dlPdu != NULLP) + { + fillMsg4DlData(&msg4DlData, macCb.macCell->macRaCb[0].msg4Pdu); + fillMacCe(&macCeData, &macCb.macCell->macRaCb[0].msg3Pdu); + /* Forming Mux Pdu */ + macCb.macCell->macRaCb[0].msg4TxPdu = NULLP; + MAC_ALLOC(macCb.macCell->macRaCb[0].msg4TxPdu, macCb.macCell->macRaCb[0].msg4TbSize); + if(macCb.macCell->macRaCb[0].msg4TxPdu != NULLP) { - MAC_ALLOC(msg4DlData.pduInfo[0].dlPdu, \ - macCb.macCell->macRaCb[0].msg4PduLen); - if(msg4DlData.pduInfo[0].dlPdu != NULLP) - { - fillMsg4DlData(&msg4DlData); - } - } - - /* MUXing for msg4 */ - fillMacCe(&macCeData); - macMuxPdu(&msg4DlData, &macCeData, macCb.macCell->macRaCb[0].msg4TbSize); - - /* storing msg4 Pdu in macDlSlot */ - if(macCb.macCell->macRaCb[0].msg4TxPdu) - { - msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4TbSize; - MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, msg4Alloc->msg4Info.msg4PduLen); - if(msg4Alloc->msg4Info.msg4Pdu != NULLP) - { - memcpy(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4TxPdu, \ - msg4Alloc->msg4Info.msg4PduLen); - } + memset(macCb.macCell->macRaCb[0].msg4TxPdu, 0, macCb.macCell->macRaCb[0].msg4TbSize); + macMuxPdu(&msg4DlData, &macCeData, macCb.macCell->macRaCb[0].msg4TxPdu,\ + macCb.macCell->macRaCb[0].msg4TbSize); + } else { - DU_LOG("\nMAC: Failed at macMuxPdu()"); - return RFAILED; + DU_LOG("\nMAC: Failed allocating memory for msg4TxPdu"); } - /* TODO: Free all allocated memory, after the usage */ - /* MAC_FREE(macCb.macCell->macRaCb[0].msg4TxPdu, \ - macCb.macCell->macRaCb[0].msg4TbSize); // TODO: To be freed after re-transmission is successful. - MAC_FREE(dlSchedInfo->msg4Alloc->msg4Info.msg4Pdu,\ - macCb.macCell->macRaCb[0].msg4PduLen); //TODO: To be freed after lower-mac is succesfull - MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell->macRaCb[0].msg4PduLen); - MAC_FREE(macCb.macCell->macRaCb[0].msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen); */ + /* Free memory allocated */ + MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell->macRaCb[0].msg4PduLen); } } - return ROK; + + /* storing msg4 Pdu in macDlSlot */ + if(macCb.macCell->macRaCb[0].msg4TxPdu) + { + msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4TbSize; + MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, msg4Alloc->msg4Info.msg4PduLen); + if(msg4Alloc->msg4Info.msg4Pdu != NULLP) + { + memcpy(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4TxPdu, \ + msg4Alloc->msg4Info.msg4PduLen); + } + } + else + { + DU_LOG("\nMAC: Failed at macMuxPdu()"); + } + /* TODO: Free all allocated memory, after the usage */ + /* MAC_FREE(macCb.macCell->macRaCb[0].msg4TxPdu, \ + macCb.macCell->macRaCb[0].msg4TbSize); // TODO: To be freed after re-transmission is successful. + MAC_FREE(macCb.macCell->macRaCb[0].msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen); */ } /** diff --git a/src/5gnrmac/rg_tom.c b/src/5gnrmac/rg_tom.c index e6b259cbd..f4cd5d944 100755 --- a/src/5gnrmac/rg_tom.c +++ b/src/5gnrmac/rg_tom.c @@ -596,7 +596,18 @@ SlotIndInfo slotInd } #endif - + /* Mux Pdu for Msg4 */ + SlotIndInfo muxTimingInfo; + memset(&muxTimingInfo, 0, sizeof(SlotIndInfo)); + MacDlSlot *currDlSlot = NULLP; + ADD_DELTA_TO_TIME(slotInd, muxTimingInfo, PHY_DELTA); + currDlSlot = &macCb.macCell->dlSlot[muxTimingInfo.slot]; + if(currDlSlot->dlInfo.msg4Alloc) + { + BuildAndSendMsg4MuxPdu(currDlSlot->dlInfo.msg4Alloc); + currDlSlot = NULLP; + } + /* Trigger for DL TTI REQ */ handleDlTtiReq(slotInd); -- 2.16.6