Modified SCH design to process pending RACH Ind when Slot Ind is received [Issue...
[o-du/l2.git] / src / 5gnrmac / mac_rach.c
index 306913c..363f0b9 100644 (file)
@@ -78,29 +78,40 @@ uint8_t fapiMacRachInd(Pst *pst, RachInd *rachInd)
 {
    uint8_t      pduIdx;
    uint8_t      preambleIdx;
-   RachIndInfo  rachIndInfo;
+   RachIndInfo  *rachIndInfo;
 
    DU_LOG("\nINFO  -->  MAC : Received RACH indication");
    /* Considering one pdu and one preamble */
    pduIdx = 0;
    preambleIdx = 0;
 
-   rachIndInfo.cellId = rachInd->cellId;
-   rachIndInfo.timingInfo.sfn = rachInd->timingInfo.sfn;
-   rachIndInfo.timingInfo.slot = rachInd->timingInfo.slot;
-   rachIndInfo.slotIdx = rachInd->rachPdu[pduIdx].slotIdx;
-   rachIndInfo.symbolIdx = rachInd->rachPdu[pduIdx].symbolIdx;
-   rachIndInfo.freqIdx = rachInd->rachPdu[pduIdx].freqIdx;
-   rachIndInfo.preambleIdx = \
+   MAC_ALLOC(rachIndInfo, sizeof(RachIndInfo));
+   if(!rachIndInfo)
+   {
+      DU_LOG("\nERROR  --> MAC : Memory allocation failure in fapiMacRachInd");
+      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rachInd, sizeof(RachInd));
+      return RFAILED;
+   }
+
+   rachIndInfo->cellId = rachInd->cellId;
+   rachIndInfo->timingInfo.sfn = rachInd->timingInfo.sfn;
+   rachIndInfo->timingInfo.slot = rachInd->timingInfo.slot;
+   rachIndInfo->slotIdx = rachInd->rachPdu[pduIdx].slotIdx;
+   rachIndInfo->symbolIdx = rachInd->rachPdu[pduIdx].symbolIdx;
+   rachIndInfo->freqIdx = rachInd->rachPdu[pduIdx].freqIdx;
+   rachIndInfo->preambleIdx = \
       rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].preamIdx;
-   rachIndInfo.timingAdv = \
+   rachIndInfo->timingAdv = \
       rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].timingAdv;
 
-   /* storing the value in macRaCb */
-   createMacRaCb(&rachIndInfo);
+   /* Store the value in macRaCb */
+   createMacRaCb(rachIndInfo);
 
+   /* Free sharable buffer used to send RACH Indication from lower MAC to MAC */
    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rachInd, sizeof(RachInd));
-   return(sendRachIndMacToSch(&rachIndInfo));
+
+   /* Send RACH Indication to SCH */
+   return(sendRachIndMacToSch(rachIndInfo));
 }
 
 /* spec-38.211 Table 6.3.3.1-7 */