RAR and MSG3 scheduling in TDD [Issue-ID: ODUHIGH-342]
[o-du/l2.git] / src / 5gnrmac / lwr_mac_fsm.c
index 5b787a3..6f4f8a8 100644 (file)
@@ -3100,7 +3100,10 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
    if(dlInfo->rarAlloc != NULLP)
    {
       /* PDCCH and PDSCH PDU is filled */
-      count += 2;
+      if(dlInfo->rarAlloc->pduPres == BOTH)
+         count += 2;
+      else
+         count += 1;
    }
    if(dlInfo->dlMsgAlloc != NULLP)
    {
@@ -3424,6 +3427,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
                   DU_LOG("\nDEBUG  -->  LWR_MAC: MIB sent..");
                   DU_LOG("\033[0m");
                }
+
                if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
                {
                   /* Filling SIB1 param */
@@ -3447,24 +3451,34 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
                   DU_LOG("\033[0m");
                }
             }
+
             if(currDlSlot->dlInfo.rarAlloc != NULLP)
             {
                /* Filling RAR param */
                rntiType = RA_RNTI_TYPE;
-               fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                     &currDlSlot->dlInfo, rntiType, CORESET_TYPE0);
-               numPduEncoded++;
-               fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
-                     &currDlSlot->dlInfo.rarAlloc->rarPdschCfg,
-                     currDlSlot->dlInfo.rarAlloc->bwp,
-                     pduIndex);
-               numPduEncoded++;
-               pduIndex++;
+               if((currDlSlot->dlInfo.rarAlloc->pduPres == BOTH) || \
+                     (currDlSlot->dlInfo.rarAlloc->pduPres == PDCCH_PDU))
+               {
+                  fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+                        &currDlSlot->dlInfo, rntiType, CORESET_TYPE0);
+                  numPduEncoded++;
+               }
+               if((currDlSlot->dlInfo.rarAlloc->pduPres == BOTH) || \
+                     (currDlSlot->dlInfo.rarAlloc->pduPres == PDSCH_PDU))
+               {
+                  fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
+                        &currDlSlot->dlInfo.rarAlloc->rarPdschCfg,
+                        currDlSlot->dlInfo.rarAlloc->bwp,
+                        pduIndex);
+                  numPduEncoded++;
+                  pduIndex++;
 
-               DU_LOG("\033[1;32m");
-               DU_LOG("\nDEBUG  -->  LWR_MAC: RAR sent...");
-               DU_LOG("\033[0m");
+                  DU_LOG("\033[1;32m");
+                  DU_LOG("\nDEBUG  -->  LWR_MAC: RAR sent...");
+                  DU_LOG("\033[0m");
+               }
             }
+
             if(currDlSlot->dlInfo.dlMsgAlloc != NULLP)
             {
                if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu != NULLP)
@@ -3629,16 +3643,19 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap
         pduIndex++;
         txDataReq->num_pdus++;
       }
+
       if(dlInfo->rarAlloc != NULLP)
       {
-        fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->rarAlloc->rarInfo,\
-           dlInfo->rarAlloc->rarPdschCfg);
-        pduIndex++;
-        txDataReq->num_pdus++;
-
-        MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc));
-        dlInfo->rarAlloc = NULLP;
+         if((dlInfo->rarAlloc->pduPres == BOTH) || (dlInfo->rarAlloc->pduPres == PDSCH_PDU))
+         {
+            fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->rarAlloc->rarInfo,\
+                  dlInfo->rarAlloc->rarPdschCfg);
+            pduIndex++;
+            txDataReq->num_pdus++;
+         }
+         MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc));
       }
+
       if(dlInfo->dlMsgAlloc != NULLP)
       {
          fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->dlMsgAlloc->dlMsgInfo,\
@@ -3650,7 +3667,6 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap
             dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPduLen);
          dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu = NULLP;
          MAC_FREE(dlInfo->dlMsgAlloc, sizeof(DlMsgAlloc));
-         dlInfo->dlMsgAlloc = NULLP;
       }
 
       /* Fill message header */