Changes for Multi-UE support and DL_MSG scheduling using K0 and K1 [Issue-ID: ODUHIGH... 86/6986/9
authorlal.harshita <Harshita.Lal@radisys.com>
Wed, 3 Nov 2021 16:36:52 +0000 (22:06 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Thu, 11 Nov 2021 05:56:30 +0000 (11:26 +0530)
Change-Id: I43374a605a02707d655b174399ce706e5e3f6419
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
17 files changed:
src/5gnrmac/lwr_mac_fsm.c
src/5gnrmac/mac.h
src/5gnrmac/mac_msg_hdl.c
src/5gnrmac/mac_slot_ind.c
src/5gnrrlc/rlc_msg_hdl.c
src/5gnrsch/sch.c
src/5gnrsch/sch.h
src/5gnrsch/sch_common.c
src/5gnrsch/sch_slot_ind.c
src/5gnrsch/sch_ue_mgr.c
src/cm/mac_sch_interface.h
src/cu_stub/cu_f1ap_msg_hdl.c
src/du_app/du_f1ap_msg_hdl.c
src/du_app/du_msg_hdl.c
src/du_app/du_ue_mgr.c
src/du_app/du_ue_mgr.h
src/phy_stub/phy_stub_thread_hdl.c

index eefda58..a5c92b7 100644 (file)
@@ -2922,7 +2922,7 @@ void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\
  * @return ROK
  *
  ******************************************************************/
-uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, \
+uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, int8_t dlMsgSchInfoIdx, \
       RntiType rntiType, uint8_t coreSetType, uint8_t ueIdx)
 {
    if(dlTtiReqPdu != NULLP)
@@ -2945,10 +2945,10 @@ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, \
       }
       else if(rntiType == TC_RNTI_TYPE || rntiType == C_RNTI_TYPE)
       {
-         pdcchInfo = &dlInfo->dlMsgAlloc[ueIdx]->dlMsgPdcchCfg;
-         bwp = &dlInfo->dlMsgAlloc[ueIdx]->bwp;
+         pdcchInfo = &dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[dlMsgSchInfoIdx].dlMsgPdcchCfg;
+         bwp = &dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[dlMsgSchInfoIdx].bwp;
          fillDlMsgDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo,\
-               &dlInfo->dlMsgAlloc[ueIdx]->dlMsgInfo);
+               &dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[dlMsgSchInfoIdx].dlMsgInfo);
       }
       else
       {
@@ -3107,12 +3107,14 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
 
       if(dlInfo->dlMsgAlloc[ueIdx] != NULLP)
       {
+         for(idx=0; idx<dlInfo->dlMsgAlloc[ueIdx]->numSchedInfo; idx++)
+         {
          /* PDCCH and PDSCH PDU is filled */
-         if(dlInfo->dlMsgAlloc[ueIdx]->pduPres == BOTH)
+         if(dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == BOTH)
             count += 2;
-         else
+         else if(dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres != NONE)
             count += 1;
-
+         }
       }
    }
    return count;
@@ -3135,7 +3137,7 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
  * ********************************************************************/
 uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
 {
-   uint8_t count = 0, ueIdx=0;
+   uint8_t idx = 0, count = 0, ueIdx=0;
 
    if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
    {
@@ -3150,8 +3152,12 @@ uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
 
       if(dlInfo->dlMsgAlloc[ueIdx] != NULLP)
       {
-         if(dlInfo->dlMsgAlloc[ueIdx]->pduPres == BOTH || dlInfo->dlMsgAlloc[ueIdx]->pduPres == PDSCH_PDU)
-            count++;
+         for(idx=0; idx<dlInfo->dlMsgAlloc[ueIdx]->numSchedInfo; idx++)
+         {
+            if(dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == BOTH || \
+                  dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == PDSCH_PDU)
+               count++;
+         }
       }
    }
    return count;
@@ -3446,7 +3452,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
                   if(numPduEncoded != nPdu)
                   {
                      rntiType = SI_RNTI_TYPE;
-                     fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
+                     fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo, -1, \
                            rntiType, CORESET_TYPE0, MAX_NUM_UE);
                      numPduEncoded++;
                      fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
@@ -3474,7 +3480,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
                         (currDlSlot->dlInfo.rarAlloc[ueIdx]->pduPres == PDCCH_PDU))
                   {
                      fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                           &currDlSlot->dlInfo, rntiType, CORESET_TYPE0, ueIdx);
+                           &currDlSlot->dlInfo, -1, rntiType, CORESET_TYPE0, ueIdx);
                      numPduEncoded++;
                   }
                   if((currDlSlot->dlInfo.rarAlloc[ueIdx]->pduPres == BOTH) || \
@@ -3495,53 +3501,58 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
 
                if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx] != NULLP)
                {
-                  if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.dlMsgPdu != NULLP)
+                  for(idx=0; idx<currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->numSchedInfo; idx++)
                   {
                      /* Filling Msg4 param */
-                     if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == BOTH) || \
-                           (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == PDCCH_PDU))
+                     if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == BOTH) || \
+                           (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == PDCCH_PDU))
                      {
-                        if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
+                        if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].dlMsgInfo.isMsg4Pdu)
                         {
                            rntiType = TC_RNTI_TYPE;
                            fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                                 &currDlSlot->dlInfo, rntiType, CORESET_TYPE0, ueIdx);
+                                 &currDlSlot->dlInfo, idx, rntiType, CORESET_TYPE0, ueIdx);
                         }
                         else
                         { 
                            /* Filling other DL msg params */
                            rntiType = C_RNTI_TYPE;
                            fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                                 &currDlSlot->dlInfo, rntiType, CORESET_TYPE1, ueIdx);
+                                 &currDlSlot->dlInfo, idx, rntiType, CORESET_TYPE1, ueIdx);
                         }
                         numPduEncoded++;
                      }
 
-                     if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == BOTH) || \
-                           (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == PDSCH_PDU))
+                     if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].dlMsgInfo.dlMsgPdu != NULLP)
                      {
-                        fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg,
-                              currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->bwp, pduIndex);
-                        numPduEncoded++;
-                        pduIndex++;
-
-                        DU_LOG("\033[1;32m");
-                        if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
-                        {
-                           DU_LOG("\nDEBUG  -->  LWR_MAC: MSG4 sent...");
-                        }
-                        else
+                        if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == BOTH) || \
+                              (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].pduPres == PDSCH_PDU))
                         {
-                           DU_LOG("\nDEBUG  -->  LWR_MAC: DL MSG sent...");
+                           fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
+                                 &currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].dlMsgPdschCfg,\
+                                 currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].bwp, pduIndex);
+                           numPduEncoded++;
+                           pduIndex++;
+
+                           DU_LOG("\033[1;32m");
+                           if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[idx].dlMsgInfo.isMsg4Pdu)
+                           {
+                              DU_LOG("\nDEBUG  -->  LWR_MAC: MSG4 sent...");
+                           }
+                           else
+                           {
+                              DU_LOG("\nDEBUG  -->  LWR_MAC: DL MSG sent...");
+                           }
+                           DU_LOG("\033[0m");
                         }
-                        DU_LOG("\033[0m");
-                     }
 
-                  }
-                  else
-                  {
-                     MAC_FREE(currDlSlot->dlInfo.dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
-                     currDlSlot->dlInfo.dlMsgAlloc[ueIdx] = NULLP;
+                     }
+                  /*   else
+                     {
+                        MAC_FREE(currDlSlot->dlInfo.dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
+                        currDlSlot->dlInfo.dlMsgAlloc[ueIdx] = NULLP;
+                     }
+                     */
                   }
                }
             }
@@ -3640,6 +3651,7 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap
 
    uint8_t  nPdu = 0;
    uint8_t  ueIdx=0;
+   uint8_t  schInfoIdx = 0;
    uint16_t cellIdx=0;
    uint16_t pduIndex = 0;
    fapi_tx_data_req_t       *txDataReq =NULLP;
@@ -3690,12 +3702,21 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap
 
          if(dlInfo->dlMsgAlloc[ueIdx] != NULLP)
          {
-            fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->dlMsgAlloc[ueIdx]->dlMsgInfo, \
-               dlInfo->dlMsgAlloc[ueIdx]->dlMsgPdschCfg);
-            pduIndex++;
-            txDataReq->num_pdus++;
-            MAC_FREE(dlInfo->dlMsgAlloc[ueIdx]->dlMsgInfo.dlMsgPdu, dlInfo->dlMsgAlloc[ueIdx]->dlMsgInfo.dlMsgPduLen);
-            dlInfo->dlMsgAlloc[ueIdx]->dlMsgInfo.dlMsgPdu = NULLP;
+            for(schInfoIdx=0; schInfoIdx < dlInfo->dlMsgAlloc[ueIdx]->numSchedInfo; schInfoIdx++)
+            {
+               if((dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH) || \
+                  (dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU))
+               {
+                  fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, \
+                        &dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo, \
+                        dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg);
+                  pduIndex++;
+                  txDataReq->num_pdus++;
+               }
+               MAC_FREE(dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu, \
+                     dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPduLen);
+               dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu = NULLP;
+            }
             MAC_FREE(dlInfo->dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
          }
       }
index 366bc17..68907fa 100644 (file)
@@ -257,7 +257,7 @@ uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize,
 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize);
 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
    uint8_t lcId, uint16_t pduLen, uint8_t *pdu);
-uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo);
+uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx);
 #endif
 /**********************************************************************
   End of file
index f1acbf9..af04edf 100644 (file)
@@ -209,6 +209,8 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
    uint8_t   ueId  = 0;
    uint8_t   lcIdx = 0;
    uint8_t   *txPdu = NULLP;
+   uint8_t   pdschSlot = 0;
+   uint8_t   schInfoIdx = 0 ;
    uint16_t  cellIdx = 0, txPduLen = 0;
    MacDlData macDlData;
    MacDlSlot *currDlSlot = NULLP;
@@ -240,7 +242,15 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
    currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
    if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
    {
-      txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg.codeword[0].tbSize - TX_PAYLOAD_HDR_LEN;
+      for(schInfoIdx=0; schInfoIdx<currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->numSchedInfo; schInfoIdx++)
+      {
+         if((currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
+               (currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH))
+            break;
+      }
+
+      txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize\
+                 - TX_PAYLOAD_HDR_LEN;
       MAC_ALLOC(txPdu, txPduLen);
       if(!txPdu)
       {
@@ -249,8 +259,8 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
       }
       macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
 
-      currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgInfo.dlMsgPduLen = txPduLen;
-      currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgInfo.dlMsgPdu = txPdu;
+      currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPduLen = txPduLen;
+      currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu = txPdu;
    }
 
    for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
@@ -362,7 +372,7 @@ uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
    GET_CRNTI(dlBoInfo.crnti, boStatus->ueIdx);
    dlBoInfo.lcId = boStatus->lcId;
    dlBoInfo.dataVolume = boStatus->bo;
-
+   
    sendDlRlcBoInfoToSch(&dlBoInfo); 
 
    if(pst->selector == ODU_SELECTOR_LWLC)
@@ -388,10 +398,10 @@ uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo)
+uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
 {
    Pst      pst;
-   uint8_t  lcIdx, ueIdx;
+   uint8_t  lcIdx;
    RlcSchedResultRpt  *schedRpt = NULLP;
    
    MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
@@ -406,19 +416,15 @@ uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo)
    schedRpt->slotInfo.sfn = slotInfo.sfn;
    schedRpt->slotInfo.slot = slotInfo.slot;
 
-   for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
+   if(dlInfo.dlMsgAlloc[ueIdx])
    {
-      if(dlInfo.dlMsgAlloc[ueIdx])
+      schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
+      schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].numLc;
+      for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
       {
-         schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
-         schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->numLc;
-         for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
-         {
-            schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->lcSchInfo[lcIdx].lcId;
-            schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->lcSchInfo[lcIdx].schBytes;
-            schedRpt->lcSch[lcIdx].commCh = false;
-         }
-         break;
+         schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].lcId;
+         schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].schBytes;
+         schedRpt->lcSch[lcIdx].commCh = false;
       }
    }
 
index 4068cbe..684dda0 100644 (file)
@@ -54,6 +54,7 @@ MacSchSlotIndFunc macSchSlotIndOpts[] =
  **/
 uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
 {
+   uint8_t   schInfoIdx = 0;
    uint8_t   ueIdx;
    uint16_t  cellIdx;
    MacDlSlot *currDlSlot = NULLP;
@@ -93,18 +94,23 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
             currDlSlot->dlInfo.cellId = dlSchedInfo->cellId;
 
             /* Check if the downlink pdu is msg4 */
-            if(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
+            for(schInfoIdx=0; schInfoIdx < dlSchedInfo->dlMsgAlloc[ueIdx]->numSchedInfo; schInfoIdx++)
             {
-               GET_UE_IDX(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgInfo.crnti, ueIdx);
-               ueIdx = ueIdx -1;
-               macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize = \
-                  dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgPdschCfg.codeword[0].tbSize;
-            }
-            else
-            {
-               memcpy(&currDlSlot->dlInfo.schSlotValue, &dlSchedInfo->schSlotValue, sizeof(SchSlotValue));
-               /* Send LC schedule result to RLC */
-               sendSchedRptToRlc(currDlSlot->dlInfo, dlSchedInfo->schSlotValue.dlMsgTime);
+               if(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.isMsg4Pdu)
+               {
+                  GET_UE_IDX(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.crnti, ueIdx);
+                  ueIdx = ueIdx -1;
+                  macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize = \
+                     dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize;
+               }
+               else
+               {
+                  memcpy(&currDlSlot->dlInfo.schSlotValue, &dlSchedInfo->schSlotValue, sizeof(SchSlotValue));
+                  /* Send LC schedule result to RLC */
+                  if((dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
+                        (dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH))
+                     sendSchedRptToRlc(currDlSlot->dlInfo, dlSchedInfo->schSlotValue.dlMsgTime, ueIdx, schInfoIdx);
+               }
             }
          }
       }
@@ -130,7 +136,7 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
  *  @param[in]  DlMsgAlloc  *msg4Alloc
  *  @return  void
  **/
-void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc)
+void fillMsg4Pdu(uint16_t cellId, DlMsgSchInfo *msg4SchInfo)
 {
    uint8_t   ueIdx;
    uint16_t  cellIdx;
@@ -143,7 +149,7 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc)
    memset(&msg4DlData, 0, sizeof(MacDlData));
    memset(&macCeData, 0, sizeof(MacCeInfo));
 
-   GET_UE_IDX(msg4Alloc->dlMsgInfo.crnti, ueIdx);
+   GET_UE_IDX(msg4SchInfo->dlMsgInfo.crnti, ueIdx);
    ueIdx = ueIdx -1;
 
    if(macCb.macCell[cellIdx] == NULLP)
@@ -183,12 +189,12 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc)
    /* storing msg4 Pdu in macDlSlot */
    if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
    {
-      msg4Alloc->dlMsgInfo.dlMsgPduLen = msg4TxPduLen;
-      MAC_ALLOC(msg4Alloc->dlMsgInfo.dlMsgPdu, msg4Alloc->dlMsgInfo.dlMsgPduLen);
-      if(msg4Alloc->dlMsgInfo.dlMsgPdu != NULLP)
+      msg4SchInfo->dlMsgInfo.dlMsgPduLen = msg4TxPduLen;
+      MAC_ALLOC(msg4SchInfo->dlMsgInfo.dlMsgPdu, msg4SchInfo->dlMsgInfo.dlMsgPduLen);
+      if(msg4SchInfo->dlMsgInfo.dlMsgPdu != NULLP)
       {
-         memcpy(msg4Alloc->dlMsgInfo.dlMsgPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
-               msg4Alloc->dlMsgInfo.dlMsgPduLen);
+         memcpy(msg4SchInfo->dlMsgInfo.dlMsgPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
+               msg4SchInfo->dlMsgInfo.dlMsgPduLen);
       }
    }
    else
@@ -213,6 +219,7 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc)
 void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo)
 {
    uint8_t   ueIdx;
+   uint8_t   schInfoIdx;
    uint16_t  cellIdx;
    MacDlSlot *currDlSlot = NULLP;
    SlotTimingInfo muxTimingInfo;
@@ -227,9 +234,14 @@ void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo)
    {
       if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx])
       {
-         if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
+         for(schInfoIdx=0; schInfoIdx<currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->numSchedInfo; schInfoIdx++)
          {
-            fillMsg4Pdu(currTimingInfo.cellId, currDlSlot->dlInfo.dlMsgAlloc[ueIdx]);
+            if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.isMsg4Pdu) &&
+                  ((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
+                   (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH)))
+            {
+               fillMsg4Pdu(currTimingInfo.cellId, &currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx]);
+            }
          }
       }
    }
index c384068..f4debb6 100644 (file)
@@ -39,7 +39,7 @@
 #include "rlc_mac_inf.h"
 #include "du_app_rlc_inf.h"
 #include "rlc_upr_inf_api.h"
-
+#include "rlc_mgr.h"
 /*******************************************************************
  *
  * @brief Fills RLC UL UE Cfg Rsp from RlcCRsp 
@@ -314,7 +314,7 @@ uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
          DU_LOG("\nERROR  -->  RLC: Failed to fill configuration at RlcProcUeCreateReq()");
          FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_CREATE_RSP);
          fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
-         SendRlcUeCfgRspToDu(&rspPst, cfgRsp);
+         SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
 
       }
       else
@@ -724,7 +724,8 @@ uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg)
       {
          DU_LOG("\nERROR  -->  RLC: Failed to fill configuration at RlcProcUeReconfigReq()");
          FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
-         fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
+         memset(cfgRsp, 0, sizeof(RlcCfgCfmInfo));
+         fillRlcCfgFailureRsp(cfgRsp, ueCfg);
          SendRlcUeCfgRspToDu(&rspPst, cfgRsp);
       }
       else
index fe2b9f1..090d389 100644 (file)
@@ -928,15 +928,9 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
 {
    uint8_t  lcId = 0;
    uint16_t ueId = 0;
-   uint16_t slot = 0;
-#ifdef NR_TDD
-   uint16_t slotIdx = 0;
-#endif
    bool isLcIdValid = false;
-   DlMsgInfo dlMsgInfo;
    SchUeCb *ueCb = NULLP;
    SchCellCb *cell = NULLP;
-   SchDlSlotInfo *schDlSlotInfo = NULLP;
    Inst  inst = pst->dstInst-SCH_INST_START;
    CmLListCp *lcLL = NULLP;
 
@@ -982,24 +976,11 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
       return ROK;
    }
 
-   memset(&dlMsgInfo, 0, sizeof(DlMsgInfo));
-   dlMsgInfo.crnti = dlBoInfo->crnti;
-   dlMsgInfo.ndi = 1;
-   dlMsgInfo.harqProcNum = 0;
-   dlMsgInfo.dlAssignIdx = 0;
-   dlMsgInfo.pucchTpc = 0;
-   dlMsgInfo.pucchResInd = 0;
-   dlMsgInfo.harqFeedbackInd = 0;
-   dlMsgInfo.dciFormatId = 1;
-
    if(lcId == SRB0_LCID)
    {
       cell->raCb[ueId -1].msg4recvd = true;
-      dlMsgInfo.dlMsgPduLen = dlBoInfo->dataVolume;
-      cell->raCb[ueId -1].dlMsgInfo = dlMsgInfo;
+      cell->raCb[ueId -1].dlMsgPduLen = dlBoInfo->dataVolume;
       
-      /* Adding UE Id to list of pending UEs to be scheduled */
-      addUeToBeScheduled(cell, ueId);
    }
    else
    {
@@ -1015,38 +996,10 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
          DU_LOG("ERROR --> SCH: LCID:%d is not configured in SCH Cb",lcId);
          return RFAILED;
       }
-
-      slot = (cell->slotInfo.slot + SCHED_DELTA + PHY_DELTA_DL + BO_DELTA) % cell->numSlots;
-#ifdef NR_TDD
-      while(schGetSlotSymbFrmt(cell->slotFrmtBitMap, slot) != DL_SLOT)
-      {
-         slot = (slot + 1)%cell->numSlots;
-         slotIdx++;
-         if(slotIdx==cell->numSlots)
-         {
-            DU_LOG("\nERROR  -->  SCH : No DL Slot available");
-            return RFAILED;
-         }
-      }
-#endif
-
-      schDlSlotInfo = cell->schDlSlotInfo[slot];
-      if(schDlSlotInfo == NULLP)
-      {
-         DU_LOG("\nERROR  -->  SCH : MacSchDlRlcBoInfo(): schDlSlotInfo does not exists");
-         return RFAILED;
-      }
-
-      SCH_ALLOC(schDlSlotInfo->dlMsgAlloc[ueId-1], sizeof(DlMsgAlloc));
-      if(schDlSlotInfo->dlMsgAlloc[ueId-1] == NULLP)
-      {
-         DU_LOG("\nERROR  -->  SCH : Memory allocation failed for dlMsgInfo");
-         schDlSlotInfo = NULL;
-         return RFAILED;
-      }
-
-      schDlSlotInfo->dlMsgAlloc[ueId-1]->dlMsgInfo = dlMsgInfo;
    }
+   
+   /* Adding UE Id to list of pending UEs to be scheduled */
+   addUeToBeScheduled(cell, ueId);
    return ROK;
 }
 
index e39e1b0..202fc0c 100644 (file)
@@ -149,8 +149,8 @@ typedef struct schDlSlotInfo
 typedef struct schRaCb
 {
    bool      msg4recvd;
-   DlMsgInfo dlMsgInfo;
    uint16_t  tcrnti;
+   uint16_t  dlMsgPduLen;
 }SchRaCb;
 
 /**
@@ -363,14 +363,18 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst
 bool schProcessRaReq(SchCellCb *cellCb, SlotTimingInfo currTime, uint8_t ueId);
 bool schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId);
 uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarAlloc *rarAlloc, uint8_t k0Index);
-uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t crnti,\
-   uint32_t tbSize, DlMsgAlloc *dlMsgAlloc, uint16_t startPRB);
-uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueId, DlMsgAlloc *msg4Alloc, uint8_t k0Idx);
+uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t crnti,
+uint32_t tbSize, DlMsgAlloc *dlMsgAlloc, uint16_t startPRB, uint8_t pdschStartSymbol, uint8_t pdschNumSymbols);
+uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueId, DlMsgAlloc *msg4Alloc,\
+uint8_t pdschStartSymbol, uint8_t pdschNumSymbols);
 uint16_t schAccumalateLcBoSize(SchCellCb *cell, uint16_t ueIdx);
 uint8_t allocatePrbDl(SchCellCb *cell, SlotTimingInfo slotTime, uint8_t startSymbol, uint8_t symbolLength, \
    uint16_t *startPrb, uint16_t numPrb);
 uint16_t searchLargestFreeBlockDL(SchCellCb *cell, SlotTimingInfo slotTime,uint16_t *startPrb);
 void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *accumalatedBOSize);
+void fillDlMsgInfo(DlMsgInfo *dlMsgInfo, uint8_t crnti);
+bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool dedMsg, uint8_t *pdschStartSymbol,\
+uint8_t *pdschSymblLen, SlotTimingInfo *pdcchTime,  SlotTimingInfo *pdschTime, SlotTimingInfo *pucchTime);
 
 /* UL scheduling related function declarations */
 uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
index 859671d..15543a1 100644 (file)
@@ -511,7 +511,8 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueId, DlMsgAlloc *msg4Alloc, uint8_t k0Idx)
+uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueId, DlMsgAlloc *dlMsgAlloc,\
+uint8_t pdschStartSymbol, uint8_t pdschNumSymbols)
 {
    uint8_t coreset0Idx = 0;
    uint8_t firstSymbol = 0;
@@ -524,6 +525,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
    PdcchCfg *pdcch = NULLP;
    PdschCfg *pdsch = NULLP;
    BwpCfg *bwp = NULLP;
+   DlMsgSchInfo *msg4Alloc = NULLP;
 
    if(cell == NULL)
    {
@@ -531,20 +533,22 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
       return RFAILED;
    }
 
-   if(msg4Alloc == NULL)
+   if(dlMsgAlloc == NULL)
    {
-      DU_LOG("\nERROR  -->  SCH: schDlRsrcAllocMsg4() :  msg4Alloc is NULL");
+      DU_LOG("\nERROR  -->  SCH: schDlRsrcAllocMsg4() :  dlMsgAlloc is NULL");
       return RFAILED;
    }
 
+   msg4Alloc = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo];
    initialBwp   = &cell->cellCfg.schInitialDlBwp;
    pdcch = &msg4Alloc->dlMsgPdcchCfg;
    pdsch = &msg4Alloc->dlMsgPdschCfg;
    bwp = &msg4Alloc->bwp;
    coreset0Idx  = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
 
-   msg4Alloc->dlMsgInfo = cell->raCb[ueId-1].dlMsgInfo;
-   msg4Alloc->dlMsgInfo.isMsg4Pdu = true;
+   fillDlMsgInfo(&msg4Alloc->dlMsgInfo, cell->raCb[ueId-1].tcrnti);
+   msg4Alloc->dlMsgInfo.dlMsgPduLen = cell->raCb[ueId-1].dlMsgPduLen;
+
    /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
    numRbs     = coresetIdxTable[coreset0Idx][1];
    numSymbols = coresetIdxTable[coreset0Idx][2];
@@ -623,13 +627,12 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
    pdsch->dmrs.nrOfDmrsSymbols  = NUM_DMRS_SYMBOLS;
    pdsch->dmrs.dmrsAddPos       = DMRS_ADDITIONAL_POS;
 
-   pdsch->pdschTimeAlloc.timeAlloc.startSymb =initialBwp->pdschCommon.timeDomRsrcAllocList[k0Idx].startSymbol; 
-   pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Idx].lengthSymbol;
+   pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschStartSymbol; 
+   pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschNumSymbols;
 
    pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
    pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB;
-   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, \
-   initialBwp->pdschCommon.timeDomRsrcAllocList[k0Idx].lengthSymbol);
+   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, pdschNumSymbols);
    pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
 
    /* Find total symbols occupied including DMRS */
@@ -664,6 +667,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
    pdsch->txPdschPower.powerControlOffset = 0;
    pdsch->txPdschPower.powerControlOffsetSS = 0;
 
+   msg4Alloc->dlMsgInfo.isMsg4Pdu = true;
    return ROK;
 }
  
@@ -716,7 +720,7 @@ uint16_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, uint16
  *
  * ****************************************************************/
 uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t crnti,
-                uint32_t tbSize, DlMsgAlloc *dlMsgAlloc, uint16_t startPRB)
+                uint32_t tbSize, DlMsgAlloc *dlMsgAlloc, uint16_t startPRB, uint8_t pdschStartSymbol, uint8_t pdschNumSymbols)
 {
    uint8_t ueIdx;
    PdcchCfg *pdcch = NULLP;
@@ -727,9 +731,9 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c
    SchPdschConfig pdschCfg;
    uint8_t dmrsStartSymbol, startSymbol, numSymbol;
 
-   pdcch = &dlMsgAlloc->dlMsgPdcchCfg;
-   pdsch = &dlMsgAlloc->dlMsgPdschCfg;
-   bwp = &dlMsgAlloc->bwp;
+   pdcch = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].dlMsgPdcchCfg;
+   pdsch = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].dlMsgPdschCfg;
+   bwp = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].bwp;
 
    GET_UE_IDX(crnti, ueIdx);
    ueCb  = cell->ueCb[ueIdx-1];
@@ -800,14 +804,13 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c
    pdsch->dmrs.nrOfDmrsSymbols  = NUM_DMRS_SYMBOLS;
    pdsch->dmrs.dmrsAddPos       = pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
 
-   pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschCfg.timeDomRsrcAllociList[0].startSymbol;
-   pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschCfg.timeDomRsrcAllociList[0].symbolLength;
+   pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschStartSymbol; 
+   pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschNumSymbols;
 
    pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
    pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
    pdsch->pdschFreqAlloc.freqAlloc.startPrb = startPRB; /*Start PRB will be already known*/
-   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, ueCb.ueCfg.dlModInfo.mcsIndex, \
-                  pdschCfg.timeDomRsrcAllociList[0].symbolLength);
+   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, ueCb.ueCfg.dlModInfo.mcsIndex, pdschNumSymbols);
 
    /* Find total symbols occupied including DMRS */
    dmrsStartSymbol = findDmrsStartSymbol(pdsch->dmrs.dlDmrsSymbPos);
@@ -1512,6 +1515,7 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
 {
    CmLList *node = NULLP, *next = NULLP;
    LcInfo *lcNode = NULLP;
+   DlMsgSchInfo *dlMsgSchInfo = NULLP;
 
    if(lcLL == NULLP)
    {
@@ -1529,6 +1533,8 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
       return;
    }
 
+   dlMsgSchInfo = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo];
+
    /*Traverse List*/
    while(node)
    {
@@ -1541,16 +1547,16 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
 
          /*Add this LC to dlMsgAlloc so that if this LC gets allocated, BO
           * report for allocation can be sent to MAC*/
-         dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].lcId = lcNode->lcId;
-         dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes = lcNode->allocBO;
+         dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].lcId = lcNode->lcId;
+         dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].schBytes = lcNode->allocBO;
 
          /*Calculate the Total Payload/BO size allocated*/
-         *accumalatedBOSize += dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes; 
+         *accumalatedBOSize += dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].schBytes; 
 
          DU_LOG("\nINFO --> SCH: Added in MAC BO report: LCID:%d,reqBO:%d,Idx:%d, TotalBO Size:%d",\
-               lcNode->lcId,lcNode->reqBO, dlMsgAlloc->numLc, *accumalatedBOSize);
+               lcNode->lcId,lcNode->reqBO, dlMsgSchInfo->numLc, *accumalatedBOSize);
 
-         dlMsgAlloc->numLc++;
+         dlMsgSchInfo->numLc++;
          /*The LC has been fully allocated, clean it*/
          if(lcNode->reqBO == 0)
          {
@@ -1562,6 +1568,33 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
    return;
 }
 
+/*******************************************************************
+*
+* @brief fill DL message information for MSG4 and Dedicated DL Msg
+*
+* @details
+*
+*    Function : fillDlMsgInfo
+*
+*    Functionality:
+*       fill DL message information for MSG4 and Dedicated DL Msg
+*
+* @params[in] DlMsgInfo *dlMsgInfo,  uint8_t crnti
+* @return void
+*
+*******************************************************************/
+void fillDlMsgInfo(DlMsgInfo *dlMsgInfo, uint8_t crnti)
+{
+   dlMsgInfo->crnti = crnti;
+   dlMsgInfo->ndi = 1;
+   dlMsgInfo->harqProcNum = 0;
+   dlMsgInfo->dlAssignIdx = 0;
+   dlMsgInfo->pucchTpc = 0;
+   dlMsgInfo->pucchResInd = 0;
+   dlMsgInfo->harqFeedbackInd = 0;
+   dlMsgInfo->dciFormatId = 1;
+}
+
 /*******************************************************************
  *
  * @brief sch Process pending Msg4 Req
@@ -1581,11 +1614,7 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
 
 bool schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId)
 {
-   bool k1Found = FALSE;  
-   uint16_t pdcchSlot = 0, pdschSlot = 0;
-   uint8_t numK0 = 0, k0TblIdx = 0, k0Index = 0, k0Val = 0;
-   uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
-   SchK0K1TimingInfoTbl *k0K1InfoTbl;
+   uint8_t pdschStartSymbol = 0, pdschNumSymbols = 0;
    SlotTimingInfo pdcchTime, pdschTime, pucchTime;
    DlMsgAlloc *dciSlotAlloc = NULLP;    /* Stores info for transmission of PDCCH for Msg4 */
    DlMsgAlloc  *msg4SlotAlloc = NULLP;   /* Stores info for transmission of PDSCH for Msg4 */
@@ -1595,120 +1624,95 @@ bool schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId)
       DU_LOG("\nERROR  -->  SCH: schDlRsrcAllocMsg4() : Cell is NULL");
       return false;
    }
-
-   ADD_DELTA_TO_TIME(currTime, pdcchTime, PHY_DELTA_DL + SCHED_DELTA);
-   pdcchSlot = pdcchTime.slot;
-#ifdef NR_TDD
-   if(schGetSlotSymbFrmt(pdcchSlot, cell->slotFrmtBitMap) != DL_SLOT)
+   
+   if(findValidK0K1Value(cell, currTime, ueId, false, &pdschStartSymbol, &pdschNumSymbols, &pdcchTime, &pdschTime,\
+            &pucchTime) != true )
    {
       return false;
    }
-#endif
-   /* If PDCCH is already scheduled on this slot, cannot schedule PDSCH for
-    * another UE here. */
-   if(cell->schDlSlotInfo[pdcchSlot]->pdcchUe != 0)
-      return false;
 
-   k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl;
-   numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].numK0;
-   for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
+   if(cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] == NULL)
    {
-      k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k0Index;
-      k0Val = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
-
-      ADD_DELTA_TO_TIME(pdcchTime, pdschTime, k0Val);
-      pdschSlot = pdschTime.slot;
-
-#ifdef NR_TDD
-      if(schGetSlotSymbFrmt(pdschSlot, cell->slotFrmtBitMap) != DL_SLOT)
+      SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgAlloc));
+      if(dciSlotAlloc == NULLP)
       {
-         continue;
-      }
-#endif
-      /* If PDSCH is already scheduled on this slot, cannot schedule PDSCH for
-       * another UE here. */
-      if(cell->schDlSlotInfo[pdschSlot]->pdschUe != 0)
-         continue;
-
-      numK1 = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k1TimingInfo.numK1;
-      for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
-      {
-         k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
-         k1Val = defaultUlAckTbl[k1Index];
-
-         ADD_DELTA_TO_TIME(pdschTime, pucchTime, k1Val);
-#ifdef NR_TDD
-         if(schGetSlotSymbFrmt(pucchTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
-         {
-            continue;
-         }
-#endif
-         /* If PUCCH is already scheduled on this slot, another PUCCH
-          * pdu cannot be scheduled here */
-         if(cell->schUlSlotInfo[pucchTime.slot]->pucchUe != 0)
-            continue;
-
-         k1Found = true;
-         break;
+         DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for dciSlotAlloc");
+         return false;
       }
-      if(k1Found)
-         break;
+      cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = dciSlotAlloc;
+      memset(dciSlotAlloc, 0, sizeof(DlMsgAlloc));
+      GET_CRNTI(dciSlotAlloc->crnti, ueId);
    }
-
-   /* If K0-K1 combination not found, no scheduling happens */
-   if(!k1Found)
-      return false;
-
-   SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgAlloc));
-   if(dciSlotAlloc == NULLP)
-   {
-      DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for dciSlotAlloc");
-      return false;
-   }
-   cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc[ueId-1] = dciSlotAlloc;
+   else
+      dciSlotAlloc = cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1];
 
    /* Fill PDCCH and PDSCH scheduling information for Msg4 */
-   if((schDlRsrcAllocMsg4(cell, pdschTime, ueId, dciSlotAlloc, k0Index)) != ROK)
+   if((schDlRsrcAllocMsg4(cell, pdschTime, ueId, dciSlotAlloc, pdschStartSymbol, pdschNumSymbols)) != ROK)
    {
-      DU_LOG("\nERROR  -->  SCH: Scheduling of Msg4 failed in slot [%d]", pdschSlot);
-      SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
-      cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc[ueId-1] = NULLP;
+      DU_LOG("\nERROR  -->  SCH: Scheduling of Msg4 failed in slot [%d]", pdschTime.slot);
+      if(dciSlotAlloc->numSchedInfo == 0)
+      {
+         SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+         cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
+      }
+      else
+         memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
       return false;
    }
 
    /* Check if both DCI and RAR are sent in the same slot.
     * If not, allocate memory RAR PDSCH slot to store RAR info
     */
-   if(pdcchSlot == pdschSlot)
-      dciSlotAlloc->pduPres = BOTH;
+   if(pdcchTime.slot == pdschTime.slot)
+   {
+      dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pduPres = BOTH;
+      dciSlotAlloc->numSchedInfo++;
+   }
    else
    {
       /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */
-      SCH_ALLOC(msg4SlotAlloc, sizeof(DlMsgAlloc));
-      if(msg4SlotAlloc == NULLP)
+      if(cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] == NULL)
       {
-         DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4SlotAlloc");
-         SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
-         cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc[ueId-1] = NULLP;
-         return false;
+         SCH_ALLOC(msg4SlotAlloc, sizeof(DlMsgAlloc));
+         if(msg4SlotAlloc == NULLP)
+         {
+            DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4SlotAlloc");
+            if(dciSlotAlloc->numSchedInfo == 0)
+            {
+               SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+               cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
+            }
+            else
+               memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
+            return false;
+         }
+         cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = msg4SlotAlloc;
+         memset(msg4SlotAlloc, 0, sizeof(DlMsgAlloc));
+         msg4SlotAlloc->crnti = dciSlotAlloc->crnti;
       }
-      cell->schDlSlotInfo[pdschSlot]->dlMsgAlloc[ueId-1] = msg4SlotAlloc;
+      else
+         msg4SlotAlloc = cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1];
 
       /* Copy all RAR info */
-      memcpy(msg4SlotAlloc, dciSlotAlloc, sizeof(DlMsgAlloc));
-      msg4SlotAlloc->dlMsgPdcchCfg.dci.pdschCfg = &msg4SlotAlloc->dlMsgPdschCfg;
+      memcpy(&msg4SlotAlloc->dlMsgSchedInfo[msg4SlotAlloc->numSchedInfo], \
+         &dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], sizeof(DlMsgSchInfo));
+      msg4SlotAlloc->dlMsgSchedInfo[msg4SlotAlloc->numSchedInfo].dlMsgPdcchCfg.dci.pdschCfg = \
+         &msg4SlotAlloc->dlMsgSchedInfo[msg4SlotAlloc->numSchedInfo].dlMsgPdschCfg;
 
       /* Assign correct PDU types in corresponding slots */
-      msg4SlotAlloc->pduPres = PDSCH_PDU;
-      dciSlotAlloc->pduPres = PDCCH_PDU;
-      dciSlotAlloc->pdschSlot = pdschSlot;
+      msg4SlotAlloc->dlMsgSchedInfo[msg4SlotAlloc->numSchedInfo].pduPres = PDSCH_PDU;
+      dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pduPres = PDCCH_PDU;
+      dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pdschSlot = pdschTime.slot;
+
+      dciSlotAlloc->numSchedInfo++;
+      msg4SlotAlloc->numSchedInfo++;
    }
 
    /* PUCCH resource */
    schAllocPucchResource(cell, pucchTime, cell->raCb[ueId-1].tcrnti);
 
-   cell->schDlSlotInfo[pdcchSlot]->pdcchUe = ueId;
-   cell->schDlSlotInfo[pdschSlot]->pdschUe = ueId;
+   cell->schDlSlotInfo[pdcchTime.slot]->pdcchUe = ueId;
+   cell->schDlSlotInfo[pdschTime.slot]->pdschUe = ueId;
    cell->schUlSlotInfo[pucchTime.slot]->puschUe = ueId;
    cell->raCb[ueId-1].msg4recvd = FALSE;
    return true;
index 597c689..07ed7aa 100644 (file)
@@ -187,6 +187,117 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
    return NO_TRANSMISSION;
 }
 
+/*******************************************************************
+ *
+ * @brief find correct combination of k0-k1 value
+ *
+ * @details
+ *
+ *    Function : findValidK0K1Value
+ *
+ *    Functionality:
+ *       find correct combination of k0-k1 value
+ *
+ * @params[in]
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ *******************************************************************/
+bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool dedMsg, uint8_t *pdschStartSymbol, uint8_t *pdschSymblLen, SlotTimingInfo *pdcchTime,  SlotTimingInfo *pdschTime, SlotTimingInfo *pucchTime)
+{
+   uint8_t numK0 = 0, k0TblIdx = 0, k0Val = 0, k0Index =0 ;
+   uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
+   SchUeCb *ueCb = NULLP;
+   SchK0K1TimingInfoTbl *k0K1InfoTbl;
+
+   ADD_DELTA_TO_TIME(currTime, (*pdcchTime), PHY_DELTA_DL + SCHED_DELTA);
+#ifdef NR_TDD
+   if(schGetSlotSymbFrmt(pdcchTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
+   {
+      /* If it is not a DL slot, cannot schedule PDCCH. Return from here. */
+      return false;
+   }
+#endif
+
+   if(cell->schDlSlotInfo[pdcchTime->slot]->pdcchUe != 0)
+   {
+      return false;
+   }
+
+   if(dedMsg == true)
+   {
+      ueCb = &cell->ueCb[ueId-1];
+      k0K1InfoTbl = &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl;
+   }
+   else
+   {
+      k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl;
+   }
+
+   numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].numK0;
+   for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
+   {
+      k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k0Index;
+      if(dedMsg != true)
+      {
+         k0Val = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
+         *pdschStartSymbol = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
+         *pdschSymblLen = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
+      }
+      else
+      {
+         if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0 != NULLP)
+         {
+            k0Val = *(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0);
+            *pdschStartSymbol = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].startSymbol;
+            *pdschSymblLen = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].symbolLength;
+         }
+      }
+
+      ADD_DELTA_TO_TIME((*pdcchTime), (*pdschTime), k0Val);
+#ifdef NR_TDD
+      if(schGetSlotSymbFrmt(pdschTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
+      {
+         continue;
+      }
+#endif
+      if(cell->schDlSlotInfo[pdschTime->slot]->pdschUe != 0)
+      {
+         continue; 
+      }
+
+      numK1 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.numK1;
+      for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
+      {
+         k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
+         if(dedMsg != true)
+         {
+            k1Val = defaultUlAckTbl[k1Index];
+         }
+         else
+         {
+            if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck)
+            {
+               k1Val = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck->dlDataToUlAckList[k1Index];
+            }
+         }
+         ADD_DELTA_TO_TIME((*pdschTime),(*pucchTime), k1Val);
+#ifdef NR_TDD
+         if(schGetSlotSymbFrmt(pucchTime->slot, cell->slotFrmtBitMap) == DL_SLOT)
+         {
+            continue;
+         }
+#endif
+         if(cell->schUlSlotInfo[pucchTime->slot]->pucchUe != 0)
+         {
+            continue; 
+         }
+         return true;
+      }
+   }
+   return false;
+}
+
 /*******************************************************************
  *
  * @brief 
@@ -203,17 +314,17 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlMsgAlloc *dlMsgAlloc)
+bool schFillBoGrantDlSchedInfo(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId)
 {
-   uint8_t ueId = 0, lcIdx = 0, pdschSymbols = 0, k1 = 0;
-   uint16_t slot = 0,  startPrb = 0, maxFreePRB = 0,dlToUlAckIdx =0;
+   uint8_t lcIdx = 0;
+   uint8_t pdschNumSymbols = 0, pdschStartSymbol = 0;
+   uint16_t startPrb = 0, maxFreePRB = 0;
    uint16_t crnti = 0, mcsIdx = 0;
    uint32_t accumalatedSize = 0;
    SchUeCb *ueCb = NULLP;
    CmLListCp *lcLL = NULLP;
-   SchPdschConfig pdschCfg;
-   SlotTimingInfo pucchTime;
-   SchPucchCfg *schPucchCfg;
+   DlMsgAlloc *dciSlotAlloc, *dlMsgAlloc;
+   SlotTimingInfo pdcchTime, pdschTime, pucchTime;
 
    /* TX_PAYLOAD_HDR_LEN: Overhead which is to be Added once for any UE while estimating Accumulated TB Size
     * Following flag added to keep the record whether TX_PAYLOAD_HDR_LEN is added to the first Node getting allocated.
@@ -221,188 +332,244 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
     * else if only Default list is present then first node in this List will add this overhead len*/
    bool isTxPayloadLenAdded = FALSE;
 
-   while(cell->boIndBitMap)
+   GET_CRNTI(crnti,ueId);
+   ueCb = &cell->ueCb[ueId-1];
+
+   if(findValidK0K1Value(cell, currTime, ueId, ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1TblPrsnt,\
+            &pdschStartSymbol, &pdschNumSymbols, &pdcchTime, &pdschTime, &pucchTime) != true )
    {
-      slot = dlSchedInfo->schSlotValue.dlMsgTime.slot;
+      /* If a valid combination of slots to scheduled PDCCH, PDSCH and PUCCH is
+       * not found, do not perform resource allocation. Return from here. */
+      return false;
+   }
 
-      GET_RIGHT_MOST_SET_BIT(cell->boIndBitMap, ueId);
-      GET_CRNTI(crnti,ueId);
-      ueCb = &cell->ueCb[ueId-1];
+   /* allocate PDCCH and PDSCH resources for the ue */
+   if(cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] == NULL)
+   {
 
-      /* allocate PDCCH and PDSCH resources for the ue */
-      SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc));
-      if(!dlMsgAlloc)
+      SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgAlloc));
+      if(!dciSlotAlloc)
       {
          DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for ded DL msg alloc");
-         return RFAILED;
+         return false;
       }
-      memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc));
-      dlSchedInfo->dlMsgAlloc[ueId-1] = dlMsgAlloc;
-      dlMsgAlloc->crnti = crnti;
-
-      pdschCfg = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg; 
-      mcsIdx = ueCb->ueCfg.dlModInfo.mcsIndex;
+      cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = dciSlotAlloc;
+      memset(dciSlotAlloc, 0, sizeof(DlMsgAlloc));
+      dciSlotAlloc->crnti = crnti;
+   }
+   dciSlotAlloc = cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1];
 
-      /*TODO: K0Index must be used instead of 0th Index in
-       * pdschCfg.timeDomRsrcAllociList*/
-      pdschSymbols = pdschCfg.timeDomRsrcAllociList[0].symbolLength;
-      /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
-      memcpy(&dlMsgAlloc->dlMsgInfo, &cell->schDlSlotInfo[slot]->dlMsgAlloc[ueId-1]->dlMsgInfo, \
-           sizeof(DlMsgInfo));
+   /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
+   fillDlMsgInfo(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].dlMsgInfo, dciSlotAlloc->crnti);
 
-      /*Re-Initalization per UE*/
-      /* scheduled LC data fill */
-      dlMsgAlloc->numLc = 0;
-      isTxPayloadLenAdded = FALSE; /*Re-initlaize the flag for every UE*/
-      accumalatedSize = 0;
+   /*Re-Initalization per UE*/
+   /* scheduled LC data fill */
+   dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].numLc = 0;
+   isTxPayloadLenAdded = FALSE; /*Re-initlaize the flag for every UE*/
+   accumalatedSize = 0;
 
-      for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++)
+   for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++)
+   {
+      if(ueCb->dlInfo.dlLcCtxt[lcIdx].bo)
       {
-         if(ueCb->dlInfo.dlLcCtxt[lcIdx].bo)
+         /*Check the LC is Dedicated or default and accordingly LCList will
+          * be used*/
+         if(ueCb->dlInfo.dlLcCtxt[lcIdx].isDedicated)
          {
-            /*Check the LC is Dedicated or default and accordingly LCList will
-             * be used*/
-            if(ueCb->dlInfo.dlLcCtxt[lcIdx].isDedicated)
-            {
-               lcLL = &(ueCb->dlLcPrbEst.dedLcInfo->dedLcList);
-            }
-            else
-            {
-               lcLL = &(ueCb->dlLcPrbEst.defLcList);
-            }
+            lcLL = &(ueCb->dlLcPrbEst.dedLcInfo->dedLcList);
+         }
+         else
+         {
+            lcLL = &(ueCb->dlLcPrbEst.defLcList);
+         }
 
-            /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/
-            if(updateLcListReqPRB(lcLL, ueCb->dlInfo.dlLcCtxt[lcIdx].lcId,\
-                     (ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE)) != ROK)
+         /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/
+         if(updateLcListReqPRB(lcLL, ueCb->dlInfo.dlLcCtxt[lcIdx].lcId,\
+                  (ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE)) != ROK)
+         {
+            DU_LOG("\nERROR  --> SCH : Updation in LC List Failed");
+            /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
+            if(dciSlotAlloc->numSchedInfo == 0)
             {
-               DU_LOG("\nERROR  --> SCH : Updation in LC List Failed");
-               /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
-               SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc));
-               dlSchedInfo->dlMsgAlloc[ueId-1] = NULLP;
-               return RFAILED;
+               SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+               cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
             }
+            else
+               memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
+            return false;
          }
-         ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0;
-      }//End of for loop
+      }
+      ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0;
+   }//End of for loop
 
 
-      if ((ueCb->dlLcPrbEst.defLcList.count == 0) && \
-            ((ueCb->dlLcPrbEst.dedLcInfo != NULL) && (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
+   if ((ueCb->dlLcPrbEst.defLcList.count == 0) && \
+         ((ueCb->dlLcPrbEst.dedLcInfo != NULL) && (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
+   {
+      DU_LOG("\nDEBUG  -->  SCH : No pending BO for any LC id\n");
+      if(*(uint8_t *)cell->ueToBeScheduled.first->node == ueId)
       {
-         DU_LOG("\nDEBUG  -->  SCH : No pending BO for any LC id\n");
-         UNSET_ONE_BIT(ueId, cell->boIndBitMap);
-         /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
-         SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc));
-         dlSchedInfo->dlMsgAlloc[ueId-1] = NULLP;
-         continue;
+         SCH_FREE(cell->ueToBeScheduled.first->node, sizeof(uint8_t));
+         deleteNodeFromLList(&cell->ueToBeScheduled, cell->ueToBeScheduled.first);
       }
+      UNSET_ONE_BIT(ueId, cell->boIndBitMap);
+
+      /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
+      if(dciSlotAlloc->numSchedInfo == 0)
+      {
+         SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+         cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
+      }
+      else
+         memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
+      return false;
+   }
 
-      /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/
-      maxFreePRB = searchLargestFreeBlockDL(cell, dlSchedInfo->schSlotValue.dlMsgTime, &startPrb);
+   /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/
+   maxFreePRB = searchLargestFreeBlockDL(cell, pdschTime, &startPrb);
 
-      /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in
-       * the list based on RRM policy*/
+   /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in
+    * the list based on RRM policy*/
 
-      /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or 
-       * Num of Free PRB available is not enough to reserve Dedicated PRBs*/
-      if(maxFreePRB != 0)
+   /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or 
+    * Num of Free PRB available is not enough to reserve Dedicated PRBs*/
+   if(maxFreePRB != 0)
+   {
+      mcsIdx = ueCb->ueCfg.dlModInfo.mcsIndex;
+      if((ueCb->dlLcPrbEst.dedLcInfo == NULLP) 
+            || ((maxFreePRB <  ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB)))
+      { 
+         ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB;
+         DU_LOG("\nWARNING  --> SCH : Only Default Slice is scheduled, sharedPRB Count:%d",\
+               ueCb->dlLcPrbEst.sharedNumPrb);
+
+         /*PRB Alloc for Default LCs*/
+         prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschNumSymbols,\
+               &(ueCb->dlLcPrbEst.sharedNumPrb), NULLP, &isTxPayloadLenAdded);
+      }
+      else
       {
-         if((ueCb->dlLcPrbEst.dedLcInfo == NULLP) 
-               || ((maxFreePRB <  ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB)))
-         { 
-            ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB;
-            DU_LOG("\nWARNING  --> SCH : Only Default Slice is scheduled, sharedPRB Count:%d",\
-                  ueCb->dlLcPrbEst.sharedNumPrb);
-
-            /*PRB Alloc for Default LCs*/
-            prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschSymbols,\
-                  &(ueCb->dlLcPrbEst.sharedNumPrb), NULLP, &isTxPayloadLenAdded);
-         }
-         else
-         {
-            ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB - ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB;
+         ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB - ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB;
 
-            /*PRB Alloc for Dedicated LCs*/
-            prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), TRUE, mcsIdx, pdschSymbols,\
-                  &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded);
+         /*PRB Alloc for Dedicated LCs*/
+         prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), TRUE, mcsIdx, pdschNumSymbols,\
+               &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded);
 
-            /*PRB Alloc for Default LCs*/
-            prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschSymbols, \
-                  &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded);
-         }
+         /*PRB Alloc for Default LCs*/
+         prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschNumSymbols, \
+               &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded);
       }
+   }
 
-      /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes
-       * using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/ 
-      if(ueCb->dlLcPrbEst.dedLcInfo != NULLP)
-         updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), dlMsgAlloc, &(accumalatedSize));
+   /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes
+    * using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/ 
+   if(ueCb->dlLcPrbEst.dedLcInfo != NULLP)
+      updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), dciSlotAlloc, &(accumalatedSize));
 
-      updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.defLcList), dlMsgAlloc, &(accumalatedSize));
+   updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.defLcList), dciSlotAlloc, &(accumalatedSize));
 
-      /*Below case will hit if NO LC(s) are allocated due to resource crunch*/
-      if (!accumalatedSize)
+   /*Below case will hit if NO LC(s) are allocated due to resource crunch*/
+   if (!accumalatedSize)
+   {
+      if(maxFreePRB == 0)
       {
-         if(maxFreePRB == 0)
-         {
-            DU_LOG("\nERROR  --> SCH : NO FREE PRB!!");
-         }
-         else
-         {
-            /*Schedule the LC for next slot*/
-            DU_LOG("\nDEBUG  -->  SCH : No LC has been scheduled");
-         }
-         /*Not Freeing dlMsgAlloc as ZERO BO REPORT to be sent to RLC so that
-          * Allocation can be done in next slot*/
-         return ROK;
+         DU_LOG("\nERROR  --> SCH : NO FREE PRB!!");
       }
-      
-      /*[Step6]: pdcch and pdsch data is filled */
-      if((schDlRsrcAllocDlMsg(cell, dlSchedInfo->schSlotValue.dlMsgTime, \
-                  crnti, accumalatedSize, dlMsgAlloc, startPrb)) != ROK)
+      else
       {
-         DU_LOG("\nERROR  --> SCH : Scheduling of DL dedicated message failed");
-         /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
-         SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc));
-         dlSchedInfo->dlMsgAlloc[ueId-1] = NULLP;
-         return RFAILED;
+         /*Schedule the LC for next slot*/
+         DU_LOG("\nDEBUG  -->  SCH : No LC has been scheduled");
       }
-      
-      dlMsgAlloc->pduPres = BOTH;
-
-      /* TODO : Update the scheduling byte report for multiple LC based on QCI
-       * and Priority */
-      /* As of now, the total number of bytes scheduled for a slot is divided
-       * equally amongst all LC with pending data. This is avoid starving of any
-       * LC 
-       * */
+      /* Not Freeing dlMsgAlloc as ZERO BO REPORT to be sent to RLC so that
+       * Allocation can be done in next slot*/
+      return false;
+   }
+
+   /*[Step6]: pdcch and pdsch data is filled */
+   if((schDlRsrcAllocDlMsg(cell, pdschTime, crnti, accumalatedSize, dciSlotAlloc, startPrb, pdschStartSymbol, pdschNumSymbols)) != ROK)
+   {
+      DU_LOG("\nERROR  --> SCH : Scheduling of DL dedicated message failed");
+
+      /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
+      if(dciSlotAlloc->numSchedInfo == 0)
+      {
+         SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+         cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
+      }
+      else
+         memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
+      return false;
+   }
+
+   /* TODO : Update the scheduling byte report for multiple LC based on QCI
+    * and Priority */
+   /* As of now, the total number of bytes scheduled for a slot is divided
+    * equally amongst all LC with pending data. This is avoid starving of any
+    * LC 
+    * */
 #if 0
-      accumalatedSize = accumalatedSize/dlMsgAlloc->numLc;
-      for(lcIdx = 0; lcIdx < dlMsgAlloc->numLc; lcIdx ++)
-         dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize;
+   accumalatedSize = accumalatedSize/dlMsgAlloc->numLc;
+   for(lcIdx = 0; lcIdx < dlMsgAlloc->numLc; lcIdx ++)
+      dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize;
 #endif
-      /* PUCCH resource */
-      /* TODO : Correct values of K1 will be used from K0K1 table */ 
-      if(cell->ueCb[ueId-1].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres)
+   
+   /* Check if both DCI and DL_MSG are sent in the same slot.
+    * If not, allocate memory for DL_MSG PDSCH slot to store PDSCH info */
+
+   if(pdcchTime.slot == pdschTime.slot)
+   {
+      dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pduPres = BOTH;
+      dciSlotAlloc->numSchedInfo++;
+   }
+   else
+   {
+      /* Allocate memory to schedule dlMsgAlloc to send DL_Msg, pointer will be checked at schProcessSlotInd() */
+      if(cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] == NULLP)
       {
-         schPucchCfg = &(cell->ueCb[ueId-1].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg);
-         if(schPucchCfg->dlDataToUlAck)
+         SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc));
+         if(dlMsgAlloc == NULLP)
          {
-            for(dlToUlAckIdx = 0; dlToUlAckIdx < schPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; dlToUlAckIdx++)
+            DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for dlMsgAlloc");
+            if(dciSlotAlloc->numSchedInfo == 0)
             {
-               //For now considering only the first value in the list
-               k1 = schPucchCfg->dlDataToUlAck->dlDataToUlAckList[dlToUlAckIdx];
-               break;
+               SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+               cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
             }
+            else
+               memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
+            return false;
          }
+         cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = dlMsgAlloc;
+         memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc));
+         dlMsgAlloc->crnti = dciSlotAlloc->crnti;
       }
-      ADD_DELTA_TO_TIME(dlSchedInfo->schSlotValue.dlMsgTime, pucchTime, k1);
-      schAllocPucchResource(cell, pucchTime, crnti);
-
-      /* after allocation is done, unset the bo bit for that ue */
-      UNSET_ONE_BIT(ueId, cell->boIndBitMap);
+      else
+         dlMsgAlloc = cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1];
+
+      /* Copy all DL_MSG info */
+      memcpy(&dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo], \
+            &dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], sizeof(DlMsgSchInfo));
+      dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].dlMsgPdcchCfg.dci.pdschCfg = \
+            &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].dlMsgPdschCfg;
+
+      /* Assign correct PDU types in corresponding slots */
+      dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].pduPres = PDSCH_PDU;
+      dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pduPres = PDCCH_PDU;
+      dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pdschSlot = pdschTime.slot;
+
+      dciSlotAlloc->numSchedInfo++;
+      dlMsgAlloc->numSchedInfo++;
    }
 
-   return ROK;
+   schAllocPucchResource(cell, pucchTime, crnti);
+   cell->schDlSlotInfo[pdcchTime.slot]->pdcchUe = ueId;
+   cell->schDlSlotInfo[pdschTime.slot]->pdschUe = ueId;
+   cell->schUlSlotInfo[pucchTime.slot]->pucchUe = ueId;
+
+   /* after allocation is done, unset the bo bit for that ue */
+   UNSET_ONE_BIT(ueId, cell->boIndBitMap);
+   return true;
 }
 
 /*******************************************************************
@@ -430,7 +597,6 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
    CmLList       *pendingUeNode;
    DlSchedInfo   dlSchedInfo;
    DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
-   DlMsgAlloc    *dlMsgAlloc = NULLP;
    SchCellCb     *cell = NULLP;
 
    memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
@@ -523,6 +689,15 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
             cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
          }
       }
+      
+      if((cell->boIndBitMap) & (1<<ueId))
+      {
+          if(schFillBoGrantDlSchedInfo(cell, *slotInd, ueId) == true)
+          {
+             SCH_FREE(pendingUeNode->node, sizeof(uint8_t));
+             deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
+          }
+      }
    }
 
    /* Check if any PDU is scheduled at this slot for any UE */
@@ -537,30 +712,15 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
          cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
       }
    
-      /* If MSG4 PDCCH/PDSCH is scheduled for a UE at this slot, fill MSG4
+      /* If DL-Msg PDCCH/PDSCH is scheduled for a UE at this slot, fill 
        * specific interface structure to send to MAC */
-      if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP) &&
-            (cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu))
+      if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP)
       {
          slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
          dlSchedInfo.dlMsgAlloc[ueIdx] = cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx];
          cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx] = NULLP;
       }
 
-      /* Check for pending BO grant for LC */
-      if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP) &&
-            (!cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu))
-      {
-         if((schFillBoGrantDlSchedInfo(cell, &dlSchedInfo, dlMsgAlloc)) != ROK)
-         {
-            DU_LOG("\nERROR  -->  SCH : DL MSG scheduling failed");
-            SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
-            return RFAILED;
-         }
-
-         /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
-         SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
-      }
    }
 
    /* Check if UL grant must be sent in this slot for a SR/BSR that had been received */
index 3e3232c..c8bac5c 100644 (file)
@@ -277,6 +277,7 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
             BuildK0K1Table(ueCb->cellCb, &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl, false, pdschCfg,\
                   ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
                   dlDataToUlAck->dlDataToUlAckList);
+            ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1TblPrsnt = true;
             BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
                   ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
                   NULLP, &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl);
index 4111dcc..7066f5b 100644 (file)
@@ -861,9 +861,8 @@ typedef struct lcSchInfo
    uint32_t  schBytes; /* Number of scheduled bytes */
 }LcSchInfo;
 
-typedef struct dlMsgAlloc
+typedef struct dlMsgSchedInfo
 {
-   uint16_t   crnti;
    uint8_t    numLc;
    LcSchInfo  lcSchInfo[MAX_NUM_LC]; /* Scheduled LC info */
    BwpCfg     bwp;
@@ -872,6 +871,13 @@ typedef struct dlMsgAlloc
    DlPduType  pduPres;
    uint8_t    pdschSlot;
    DlMsgInfo  dlMsgInfo;
+}DlMsgSchInfo;
+
+typedef struct dlMsgAlloc
+{
+   uint16_t     crnti;
+   uint8_t      numSchedInfo;
+   DlMsgSchInfo dlMsgSchedInfo[2];
 }DlMsgAlloc;
 
 typedef struct schSlotValue
@@ -1205,6 +1211,7 @@ typedef struct schInitalDlBwp
    SchPdcchConfig   pdcchCfg;
    bool             pdschCfgPres;
    SchPdschConfig   pdschCfg;
+   bool             k0K1TblPrsnt;
    SchK0K1TimingInfoTbl k0K1InfoTbl;
 }SchInitalDlBwp;
 
index fd8dac4..eafdfaf 100644 (file)
@@ -3854,8 +3854,8 @@ uint8_t BuildBWPUlDedPucchCfg(PUCCH_Config_t *pucchCfg)
    }
 
    arrIdx = 0;
-   *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx++]) = 1;
-   *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx]) = 2;
+   *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx++]) = 4;
+   *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx]) = 5;
 
    return ROK;
 }
@@ -7196,7 +7196,7 @@ uint8_t deleteEgtpTunnel(uint8_t *buf)
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t BuildUlTnlInfoforSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo, uint8_t actionType)
+uint8_t BuildUlTnlInfoforSetupMod(uint8_t ueId, ULUPTNLInformation_ToBeSetup_List_t *ulInfo, uint8_t actionType)
 {
    uint8_t arrIdx;
    uint8_t ulCnt;
@@ -7277,8 +7277,21 @@ uint8_t BuildUlTnlInfoforSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo, u
    {
      /*TODO: DRB context to be stored in CU STUB so that tunnel Id can be easily
       * fetched based on the Drb Id */
-      ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
-         gTP_TEID.buf[3] = 2; /* Tunnel Id for Drb is 2. Hence passing the same TeId */
+     if(ueId == 1)
+     {
+        /* Tunnel Id for DRB 2 of UE 1 is 2. Hence passing the same TeId */
+        ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf[3] = 2;
+     }
+     else if(ueId == 2)
+     {
+        /* Tunnel Id for DRB 2 of UE 2 is 5. Hence passing the same TeId */
+        ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf[3] = 5;
+     }
+     else if(ueId == 3)
+     {
+        /* Tunnel Id for DRB 2 of UE 3 is 8. Hence passing the same TeId */
+        ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf[3] = 8;
+     }
 
    }
    else
@@ -7390,7 +7403,7 @@ void FreeDrbItem(DRBs_ToBeSetupMod_Item_t *drbItem)
 *
 * ****************************************************************/
 
-uint8_t FillDrbItemToSetupMod(uint8_t arrIdx, DRBs_ToBeSetupMod_Item_t *drbItem)
+uint8_t FillDrbItemToSetupMod(uint8_t ueId, uint8_t arrIdx, DRBs_ToBeSetupMod_Item_t *drbItem)
 {
    uint8_t ret = ROK;
 
@@ -7469,7 +7482,8 @@ uint8_t FillDrbItemToSetupMod(uint8_t arrIdx, DRBs_ToBeSetupMod_Item_t *drbItem)
    }
    
    /*ULUPTNLInformation To Be Setup List*/
-   ret = BuildUlTnlInfoforSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List, ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item);
+   ret = BuildUlTnlInfoforSetupMod(ueId, &drbItem->uLUPTNLInformation_ToBeSetup_List, \
+      ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item);
    if(ret != ROK)
    {
       DU_LOG("\nERROR  -->  F1AP : BuildUlTnlInfoforSetupMod failed");
@@ -7498,13 +7512,13 @@ uint8_t FillDrbItemToSetupMod(uint8_t arrIdx, DRBs_ToBeSetupMod_Item_t *drbItem)
 *
 * ****************************************************************/
 
-uint8_t FillDrbItemList(uint8_t arrIdx, struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe)
+uint8_t FillDrbItemList(uint8_t ueId, uint8_t arrIdx, struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe)
 {
    drbItemIe->id = ProtocolIE_ID_id_DRBs_ToBeSetupMod_Item;
    drbItemIe->criticality = Criticality_reject;
    drbItemIe->value.present = DRBs_ToBeSetupMod_ItemIEs__value_PR_DRBs_ToBeSetupMod_Item;
 
-   if(FillDrbItemToSetupMod(arrIdx, (&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item))) != ROK)
+   if(FillDrbItemToSetupMod(ueId, arrIdx, (&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item))) != ROK)
    {
       DU_LOG("\nERROR  -->  F1AP : FillDrbItemToSetupMod failed"); 
       return RFAILED;
@@ -7568,7 +7582,7 @@ void FreeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
 *
 * ****************************************************************/
 
-uint8_t BuildDrbToBeSetupList(DRBs_ToBeSetupMod_List_t *drbSet)
+uint8_t BuildDrbToBeSetupList(uint8_t ueId, DRBs_ToBeSetupMod_List_t *drbSet)
 {
    uint8_t ret = ROK;
    uint8_t arrIdx =0;
@@ -7595,7 +7609,7 @@ uint8_t BuildDrbToBeSetupList(DRBs_ToBeSetupMod_List_t *drbSet)
    }
 
    arrIdx = 0;
-   ret = FillDrbItemList(arrIdx, (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx]);
+   ret = FillDrbItemList(ueId, arrIdx, (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx]);
    if(ret != ROK)
    {
       DU_LOG("\nERROR  -->  F1AP : FillDrbItemList failed");
@@ -7621,7 +7635,7 @@ uint8_t BuildDrbToBeSetupList(DRBs_ToBeSetupMod_List_t *drbSet)
 *
 * ****************************************************************/
 
-uint8_t FillDrbToBeModItem(DRBs_ToBeModified_Item_t *drbItem)
+uint8_t FillDrbToBeModItem(uint8_t ueId, DRBs_ToBeModified_Item_t *drbItem)
 {
    uint8_t ret = ROK;
 
@@ -7705,7 +7719,7 @@ uint8_t FillDrbToBeModItem(DRBs_ToBeModified_Item_t *drbItem)
    }/* End of QoS */
 
    /*ULUPTNLInformation To Be Setup List*/
-   ret = BuildUlTnlInfoforSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List,\
+   ret = BuildUlTnlInfoforSetupMod(ueId, &drbItem->uLUPTNLInformation_ToBeSetup_List,\
             ProtocolIE_ID_id_DRBs_ToBeModified_Item);
    if(ret != ROK)
    {
@@ -7732,12 +7746,12 @@ uint8_t FillDrbToBeModItem(DRBs_ToBeModified_Item_t *drbItem)
 *
 * ****************************************************************/
 
-uint8_t FillDrbToBeModItemList(struct DRBs_ToBeModified_ItemIEs *drbItemIe)
+uint8_t FillDrbToBeModItemList(uint8_t ueId, struct DRBs_ToBeModified_ItemIEs *drbItemIe)
 {
    drbItemIe->id = ProtocolIE_ID_id_DRBs_ToBeModified_Item;
    drbItemIe->criticality = Criticality_reject;
    drbItemIe->value.present = DRBs_ToBeModified_ItemIEs__value_PR_DRBs_ToBeModified_Item;
-   if(FillDrbToBeModItem(&(drbItemIe->value.choice.DRBs_ToBeModified_Item)) != ROK)
+   if(FillDrbToBeModItem(ueId, &(drbItemIe->value.choice.DRBs_ToBeModified_Item)) != ROK)
    {
       DU_LOG("\nERROR  -->  F1AP : FillDrbToBeModItem failed"); 
       return RFAILED;
@@ -7763,7 +7777,7 @@ uint8_t FillDrbToBeModItemList(struct DRBs_ToBeModified_ItemIEs *drbItemIe)
 *
 * ****************************************************************/
 
-uint8_t BuildDrbToBeModifiedList(DRBs_ToBeModified_List_t *drbSet)
+uint8_t BuildDrbToBeModifiedList(uint8_t ueId, DRBs_ToBeModified_List_t *drbSet)
 {
    uint8_t ret = ROK;
    uint8_t arrIdx =0;
@@ -7789,7 +7803,7 @@ uint8_t BuildDrbToBeModifiedList(DRBs_ToBeModified_List_t *drbSet)
    }
 
    arrIdx=0;
-   ret = FillDrbToBeModItemList((DRBs_ToBeModified_ItemIEs_t *)drbSet->list.array[arrIdx]);
+   ret = FillDrbToBeModItemList(ueId, (DRBs_ToBeModified_ItemIEs_t *)drbSet->list.array[arrIdx]);
    if(ret != ROK)
    {
       DU_LOG("\nERROR  -->  F1AP : FillDrbToBeModItemList failed");
@@ -8075,7 +8089,7 @@ uint8_t BuildAndSendUeContextModificationReq(uint8_t ueId)
       ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
       ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present =\
          UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List;
-      ret = BuildDrbToBeSetupList(&(ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
+      ret = BuildDrbToBeSetupList(ueId, &(ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
          value.choice.DRBs_ToBeSetupMod_List));
 
       /* DRB to be modified list */
@@ -8084,7 +8098,7 @@ uint8_t BuildAndSendUeContextModificationReq(uint8_t ueId)
       ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
       ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present =\
          UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List;
-      ret = BuildDrbToBeModifiedList(&(ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
+      ret = BuildDrbToBeModifiedList(ueId, &(ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
          value.choice.DRBs_ToBeModified_List));
 
       /* TODO: DRB to be release list */
index ef4a41c..d1202d9 100644 (file)
@@ -109,6 +109,49 @@ extern StartupConfig g_cfg;
 
 DuCfgParams duCfgParam;
 
+/******************************************************************
+ *
+ * @brief Function to fetch lcId based on DRB Id
+ *
+ * @details
+ *
+ *    Function : fetchLcId
+ *
+ *    @params[in] drbId
+ *
+ *    Functionality: Function to fetch lcId based on DRB Id
+ *
+ * Returns: lcId - SUCCESS
+ *          RFAILED - FAILURE
+ *****************************************************************/
+
+uint8_t fetchLcId(uint8_t drbId)
+{
+   uint8_t cellIdx = 0, ueIdx = 0, lcIdx = 0, numLcs = 0, lcId = 0;
+
+   for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
+   {
+      for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
+      {
+         if(duCb.actvCellLst[cellIdx] != NULLP)
+         {
+            numLcs = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.numLcs;
+            for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
+            {
+               if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbId == drbId && \
+                  duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbType == RB_TYPE_DRB)
+               {
+                  lcId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].lcId;
+                  return lcId;
+               }
+            }
+         }
+      }
+   }
+   DU_LOG("\nERROR   -->  DU_APP: fetchLcId() failed for drbId %d", drbId);
+   return RFAILED;
+}
+
 /************************************************************************
  *
  * @brief Converts enum values into actual value of Poll retransmit timer
index 7a31fa8..9116286 100644 (file)
@@ -1775,13 +1775,14 @@ uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
    /* Fetch EGTP tunnel info */
    for(rbIdx = 0; rbIdx < duCb.numDrb; rbIdx++)
    {
-      if((duCb.upTnlCfg[rbIdx] != NULLP) && (duCb.upTnlCfg[rbIdx]->drbId == ulUserData->rbId))
+      if((duCb.upTnlCfg[rbIdx] != NULLP) && (duCb.upTnlCfg[rbIdx]->ueIdx == ulUserData->ueIdx) && \
+         (duCb.upTnlCfg[rbIdx]->drbId == ulUserData->rbId))
       {
-        if(duCb.upTnlCfg[rbIdx]->tnlCfg1)
-        {
+         if(duCb.upTnlCfg[rbIdx]->tnlCfg1)
+         {
             egtpMsg.msgHdr.teId = duCb.upTnlCfg[rbIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
-           break;
-        }
+            break;
+         }
       }
    }
 
index 09e7d28..6e0cce1 100644 (file)
@@ -102,50 +102,6 @@ DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
    packDuRlcUeDeleteReq        /* Light weight-loose coupling */
 };
 
-
-/******************************************************************
- *
- * @brief Function to fetch lcId based on DRB Id
- *
- * @details
- *
- *    Function : fetchLcId
- *
- *    @params[in] drbId
- *
- *    Functionality: Function to fetch lcId based on DRB Id
- *
- * Returns: lcId - SUCCESS
- *          RFAILED - FAILURE
- *****************************************************************/
-
-uint8_t fetchLcId(uint8_t drbId)
-{
-   uint8_t cellIdx = 0, ueIdx = 0, lcIdx = 0, numLcs = 0, lcId = 0;
-
-   for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
-   {
-      for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
-      {
-         if(duCb.actvCellLst[cellIdx] != NULLP)
-         {
-            numLcs = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.numLcs;
-            for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
-            {
-               if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbId == drbId && \
-                  duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbType == RB_TYPE_DRB)
-               {
-                  lcId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].lcId;
-                  return lcId;
-               }
-            }
-         }
-      }
-   }
-   DU_LOG("\nERROR   -->  DU_APP: fetchLcId() failed for drbId %d", drbId);
-   return RFAILED;
-}
-
 /******************************************************************
  *
  * @brief Function to return Drb LcId
@@ -210,13 +166,13 @@ uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
    {
       if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
       {
-        if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
-       {
-          dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
-          dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
-           dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
-          return ROK;
-       }
+         if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
+         {
+            dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
+            dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
+            dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
+            return ROK;
+         }
       }
    }
    return RFAILED;
@@ -2232,29 +2188,31 @@ uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
       duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
       for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
       {
-        if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
-        {
-           drbFound = true; /* existing DRB */
-           if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
-           {
-              DU_LOG("\nERROR  -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
-              duUeCfg->upTnlInfo[drbIdx].drbId);
-              ret = RFAILED;
-           }
-           break;
-        }
-        else
-           drbFound = false;
+         if((duCb.upTnlCfg[duCbDrbIdx]->ueIdx == duUeCfg->upTnlInfo[drbIdx].ueIdx) && \
+            (duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
+         {
+            drbFound = true; /* existing DRB */
+            if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
+            {
+               DU_LOG("\nERROR  -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
+                     duUeCfg->upTnlInfo[drbIdx].drbId);
+               ret = RFAILED;
+            }
+            break;
+         }
+         else
+            drbFound = false;
       }
+
       if(!drbFound && ret == ROK)/* new DRB to Add */
       {
-        if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
-        {
+         if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
+         {
             DU_LOG("\nERROR  -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
-           duUeCfg->upTnlInfo[drbIdx].drbId);
-           ret = RFAILED;
-           break;
-        }
+                  duUeCfg->upTnlInfo[drbIdx].drbId);
+            ret = RFAILED;
+            break;
+         }
       }
       else
          break;
index 67da7d5..5d2d597 100644 (file)
@@ -33,7 +33,6 @@ void deleteRlcUeCfg(RlcUeCfg *ueCfg);
 void freeF1UeDb(F1UeContextSetupDb *f1UeDb);
 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti);
 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId);
-uint8_t fetchLcId(uint8_t drbId);
 #endif
 
 /**********************************************************************
index 2612530..7094f6a 100644 (file)
@@ -55,10 +55,16 @@ void GenerateTicks()
    float     milisec = 1;          /* 1ms */
 #endif
    struct timespec req = {0};
+   uint8_t ratio = 2;
 
    slotIndicationStarted = true;
    req.tv_sec = 0;
-   req.tv_nsec = milisec * 1000000L;
+
+   /* Currently the code takes longer that one slot indication to execute.
+    * Hence, multiplying slot time interval by 2 in order to give enough time 
+    * for L2 to complete one slot processing.
+    * The ratio must be removed once code optimization is complete */
+   req.tv_nsec = milisec * 1000000L * ratio;
 
    DU_LOG("\nPHY_STUB : GenerateTicks : Starting to generate slot indications");