Multi-UE support upto MSG4 handling [Issue-ID: ODUHIGH-387] 80/6980/2
authorlal.harshita <Harshita.Lal@radisys.com>
Wed, 3 Nov 2021 07:03:11 +0000 (12:33 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Wed, 3 Nov 2021 10:47:43 +0000 (16:17 +0530)
Change-Id: I7a9c466e801a631eac853ca7f487595b4d5dc787
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
src/5gnrmac/lwr_mac_fsm.c
src/5gnrmac/mac.h
src/5gnrmac/mac_msg_hdl.c
src/5gnrmac/mac_slot_ind.c
src/5gnrsch/sch.c
src/5gnrsch/sch.h
src/5gnrsch/sch_common.c
src/5gnrsch/sch_slot_ind.c
src/cm/mac_sch_interface.h
src/phy_stub/phy_stub_msg_hdl.c

index 9b305a1..eefda58 100644 (file)
@@ -2670,7 +2670,6 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
 
       /* TODO: Fill values of coreset0Size, rbStart and rbLen */
       coreset0Size= rarPdcchInfo->coresetCfg.coreSetSize;
-      rbStart = 0;              /* For SIB1 */
       rbStart = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb;
       rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
 
@@ -2946,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->dlMsgPdcchCfg;
-         bwp = &dlInfo->dlMsgAlloc->bwp;
+         pdcchInfo = &dlInfo->dlMsgAlloc[ueIdx]->dlMsgPdcchCfg;
+         bwp = &dlInfo->dlMsgAlloc[ueIdx]->bwp;
          fillDlMsgDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo,\
-               &dlInfo->dlMsgAlloc->dlMsgInfo);
+               &dlInfo->dlMsgAlloc[ueIdx]->dlMsgInfo);
       }
       else
       {
@@ -3105,16 +3104,16 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
          else
             count += 1;
       }
-   }
 
-   if(dlInfo->dlMsgAlloc != NULLP)
-   {
-      /* PDCCH and PDSCH PDU is filled */
-      if(dlInfo->dlMsgAlloc->pduPres == BOTH)
-         count += 2;
-      else
-         count += 1;
+      if(dlInfo->dlMsgAlloc[ueIdx] != NULLP)
+      {
+         /* PDCCH and PDSCH PDU is filled */
+         if(dlInfo->dlMsgAlloc[ueIdx]->pduPres == BOTH)
+            count += 2;
+         else
+            count += 1;
 
+      }
    }
    return count;
 }
@@ -3146,17 +3145,18 @@ uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
    for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
    {
       if((dlInfo->rarAlloc[ueIdx] != NULLP) && \
-         ((dlInfo->rarAlloc[ueIdx]->pduPres == BOTH) || (dlInfo->rarAlloc[ueIdx]->pduPres == PDSCH_PDU)))
+            ((dlInfo->rarAlloc[ueIdx]->pduPres == BOTH) || (dlInfo->rarAlloc[ueIdx]->pduPres == PDSCH_PDU)))
          count++;
-   }
 
-   if(dlInfo->dlMsgAlloc != NULLP)
-   {
-      if(dlInfo->dlMsgAlloc->pduPres == BOTH || dlInfo->dlMsgAlloc->pduPres == PDSCH_PDU)
-         count++;
+      if(dlInfo->dlMsgAlloc[ueIdx] != NULLP)
+      {
+         if(dlInfo->dlMsgAlloc[ueIdx]->pduPres == BOTH || dlInfo->dlMsgAlloc[ueIdx]->pduPres == PDSCH_PDU)
+            count++;
+      }
    }
    return count;
 }
+
 /***********************************************************************
  *
  * @brief fills the SIB1 TX-DATA request message
@@ -3492,55 +3492,57 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
                      DU_LOG("\033[0m");
                   }
                }
-            }
-            if(currDlSlot->dlInfo.dlMsgAlloc != NULLP)
-            {
-               if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu != NULLP)
+
+               if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx] != NULLP)
                {
-                  /* Filling Msg4 param */
-                  if((currDlSlot->dlInfo.dlMsgAlloc->pduPres == BOTH) || \
-                  (currDlSlot->dlInfo.dlMsgAlloc->pduPres == PDCCH_PDU))
+                  if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.dlMsgPdu != NULLP)
                   {
-                     if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+                     /* Filling Msg4 param */
+                     if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == BOTH) || \
+                           (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == PDCCH_PDU))
                      {
-                        rntiType = TC_RNTI_TYPE;
-                        fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                              &currDlSlot->dlInfo, rntiType, CORESET_TYPE0, MAX_NUM_UE);
-                     }
-                     else
-                     { 
-                        /* Filling other DL msg params */
-                        rntiType = C_RNTI_TYPE;
-                        fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                              &currDlSlot->dlInfo, rntiType, CORESET_TYPE1, MAX_NUM_UE);
+                        if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
+                        {
+                           rntiType = TC_RNTI_TYPE;
+                           fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+                                 &currDlSlot->dlInfo, rntiType, CORESET_TYPE0, ueIdx);
+                        }
+                        else
+                        { 
+                           /* Filling other DL msg params */
+                           rntiType = C_RNTI_TYPE;
+                           fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+                                 &currDlSlot->dlInfo, rntiType, CORESET_TYPE1, ueIdx);
+                        }
+                        numPduEncoded++;
                      }
-                     numPduEncoded++;
-                  }
 
-                  if((currDlSlot->dlInfo.dlMsgAlloc->pduPres == BOTH) || \
-                        (currDlSlot->dlInfo.dlMsgAlloc->pduPres == PDSCH_PDU))
-                  {
-                     fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg,
-                     currDlSlot->dlInfo.dlMsgAlloc->bwp,pduIndex);
-                     numPduEncoded++;
-                     pduIndex++;
-                     DU_LOG("\033[1;32m");
-                     if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+                     if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == BOTH) || \
+                           (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->pduPres == PDSCH_PDU))
                      {
-                        DU_LOG("\nDEBUG  -->  LWR_MAC: MSG4 sent...");
-                     }
-                     else
-                     {
-                        DU_LOG("\nDEBUG  -->  LWR_MAC: DL MSG sent...");
+                        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
+                        {
+                           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, sizeof(DlMsgAlloc));
-                  currDlSlot->dlInfo.dlMsgAlloc = NULLP;
                }
             }
 
@@ -3685,18 +3687,17 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap
             }
             MAC_FREE(dlInfo->rarAlloc[ueIdx],sizeof(RarAlloc));
          }
-      }
 
-      if(dlInfo->dlMsgAlloc != NULLP)
-      {
-         fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->dlMsgAlloc->dlMsgInfo,\
-         dlInfo->dlMsgAlloc->dlMsgPdschCfg);
-         pduIndex++;
-         txDataReq->num_pdus++;
-         MAC_FREE(dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu,\
-               dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPduLen);
-         dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu = NULLP;
-         MAC_FREE(dlInfo->dlMsgAlloc, sizeof(DlMsgAlloc));
+         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;
+            MAC_FREE(dlInfo->dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
+         }
       }
 
       /* Fill message header */
index b33ec31..366bc17 100644 (file)
@@ -131,6 +131,7 @@ typedef struct macDlInfo
 
 typedef struct macDlData
 {
+   uint8_t  ueId;
    uint16_t numPdu;
    MacDlInfo  pduInfo[MAX_MAC_DL_PDU];
 }MacDlData;
index f34810b..f1acbf9 100644 (file)
@@ -206,6 +206,7 @@ uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
 uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
 {
    uint8_t   pduIdx = 0;
+   uint8_t   ueId  = 0;
    uint8_t   lcIdx = 0;
    uint8_t   *txPdu = NULLP;
    uint16_t  cellIdx = 0, txPduLen = 0;
@@ -216,7 +217,11 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
    memset(&macDlData , 0, sizeof(MacDlData));
    DU_LOG("\nDEBUG  -->  MAC: Received DL data for sfn=%d slot=%d numPdu= %d", \
       dlData->slotInfo.sfn, dlData->slotInfo.slot, dlData->numPdu);
+
+   GET_UE_IDX(dlData->rnti, ueId);   
+
    /* Copy the pdus to be muxed into mac Dl data */
+   macDlData.ueId = ueId;
    macDlData.numPdu = dlData->numPdu;
    for(pduIdx = 0;  pduIdx < dlData->numPdu; pduIdx++)
    {
@@ -233,9 +238,9 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
       return RFAILED;
    }
    currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
-   if(currDlSlot->dlInfo.dlMsgAlloc)
+   if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
    {
-      txPduLen = currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg.codeword[0].tbSize - TX_PAYLOAD_HDR_LEN;
+      txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg.codeword[0].tbSize - TX_PAYLOAD_HDR_LEN;
       MAC_ALLOC(txPdu, txPduLen);
       if(!txPdu)
       {
@@ -244,8 +249,8 @@ uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
       }
       macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
 
-      currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPduLen = txPduLen;
-      currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu = txPdu;
+      currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgInfo.dlMsgPduLen = txPduLen;
+      currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgInfo.dlMsgPdu = txPdu;
    }
 
    for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
@@ -386,7 +391,7 @@ uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo)
 {
    Pst      pst;
-   uint8_t  lcIdx;
+   uint8_t  lcIdx, ueIdx;
    RlcSchedResultRpt  *schedRpt = NULLP;
    
    MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
@@ -398,16 +403,23 @@ uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo)
 
    DU_LOG("\nDEBUG  -->  MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
    schedRpt->cellId = dlInfo.cellId;
-   schedRpt->rnti = dlInfo.dlMsgAlloc->crnti;
-   schedRpt->numLc = dlInfo.dlMsgAlloc->numLc;
    schedRpt->slotInfo.sfn = slotInfo.sfn;
    schedRpt->slotInfo.slot = slotInfo.slot;
 
-   for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
+   for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
    {
-      schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc->lcSchInfo[lcIdx].lcId;
-      schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc->lcSchInfo[lcIdx].schBytes;
-      schedRpt->lcSch[lcIdx].commCh = false;
+      if(dlInfo.dlMsgAlloc[ueIdx])
+      {
+         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;
+      }
    }
 
    /* Fill Pst */
index 78756cf..4068cbe 100644 (file)
@@ -84,28 +84,28 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
             /* MUXing of RAR */
             fillRarPdu(&currDlSlot->dlInfo.rarAlloc[ueIdx]->rarInfo);
          }
-      }
-
-      if(dlSchedInfo->dlMsgAlloc != NULLP)
-      {
-         currDlSlot = &macCb.macCell[cellIdx]->\
-                      dlSlot[dlSchedInfo->schSlotValue.dlMsgTime.slot];
-         currDlSlot->dlInfo.dlMsgAlloc = dlSchedInfo->dlMsgAlloc; /* copy msg4 alloc pointer in MAC slot info */
-         currDlSlot->dlInfo.cellId = dlSchedInfo->cellId;
 
-         /* Check if the downlink pdu is msg4 */
-         if(dlSchedInfo->dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+         if(dlSchedInfo->dlMsgAlloc[ueIdx] != NULLP)
          {
-            GET_UE_IDX(dlSchedInfo->dlMsgAlloc->dlMsgInfo.crnti, ueIdx);
-            ueIdx = ueIdx -1;
-            macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize = \
-               dlSchedInfo->dlMsgAlloc->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);
+            currDlSlot = &macCb.macCell[cellIdx]->\
+                         dlSlot[dlSchedInfo->schSlotValue.dlMsgTime.slot];
+            currDlSlot->dlInfo.dlMsgAlloc[ueIdx] = dlSchedInfo->dlMsgAlloc[ueIdx]; /* copy msg4 alloc pointer in MAC slot info */
+            currDlSlot->dlInfo.cellId = dlSchedInfo->cellId;
+
+            /* Check if the downlink pdu is msg4 */
+            if(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
+            {
+               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);
+            }
          }
       }
 
@@ -212,6 +212,7 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc)
 
 void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo)
 {
+   uint8_t   ueIdx;
    uint16_t  cellIdx;
    MacDlSlot *currDlSlot = NULLP;
    SlotTimingInfo muxTimingInfo;
@@ -221,12 +222,15 @@ void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo)
 
    ADD_DELTA_TO_TIME(currTimingInfo, muxTimingInfo, PHY_DELTA_DL);
    currDlSlot = &macCb.macCell[cellIdx]->dlSlot[muxTimingInfo.slot];
-   if(currDlSlot->dlInfo.dlMsgAlloc)
+
+   for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
    {
-      if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+      if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx])
       {
-         fillMsg4Pdu(currTimingInfo.cellId, currDlSlot->dlInfo.dlMsgAlloc);
-         currDlSlot = NULLP;
+         if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgInfo.isMsg4Pdu)
+         {
+            fillMsg4Pdu(currTimingInfo.cellId, currDlSlot->dlInfo.dlMsgAlloc[ueIdx]);
+         }
       }
    }
 }
index c1c1a43..9153264 100644 (file)
@@ -927,7 +927,7 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
 uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
 {
    uint8_t  lcId = 0;
-   uint16_t ueIdx = 0;
+   uint16_t ueId = 0;
    uint16_t slot = 0;
 #ifdef NR_TDD
    uint16_t slotIdx = 0;
@@ -952,8 +952,8 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
       return RFAILED;
    }
 
-   GET_UE_IDX(dlBoInfo->crnti, ueIdx);
-   ueCb = &cell->ueCb[ueIdx-1];
+   GET_UE_IDX(dlBoInfo->crnti, ueId);
+   ueCb = &cell->ueCb[ueId-1];
    lcId  = dlBoInfo->lcId;
    CHECK_LCID(lcId, isLcIdValid);
    if(isLcIdValid == FALSE)
@@ -974,15 +974,18 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
    
    if(lcId == SRB0_LCID)
    {
-      cell->raCb[ueIdx -1].msg4recvd = true;
+      cell->raCb[ueId -1].msg4recvd = true;
       dlMsgInfo.dlMsgPduLen = dlBoInfo->dataVolume;
-      cell->raCb[ueIdx -1].dlMsgInfo = dlMsgInfo;
+      cell->raCb[ueId -1].dlMsgInfo = dlMsgInfo;
+      
+      /* Adding UE Id to list of pending UEs to be scheduled */
+      addUeToBeScheduled(cell, ueId);
    }
    else
    {
       /* TODO : These part of changes will be corrected during DL scheduling as
        * per K0 - K1 -K2 */
-      SET_ONE_BIT(ueIdx, cell->boIndBitMap);
+      SET_ONE_BIT(ueId, cell->boIndBitMap);
       if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId)
       {
          ueCb->dlInfo.dlLcCtxt[lcId].bo = dlBoInfo->dataVolume;
@@ -1014,15 +1017,15 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
          return RFAILED;
       }
 
-      SCH_ALLOC(schDlSlotInfo->dlMsgAlloc, sizeof(DlMsgAlloc));
-      if(schDlSlotInfo->dlMsgAlloc == NULLP)
+      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->dlMsgInfo = dlMsgInfo;
+      schDlSlotInfo->dlMsgAlloc[ueId-1]->dlMsgInfo = dlMsgInfo;
    }
    return ROK;
 }
index 544e325..e39e1b0 100644 (file)
@@ -143,7 +143,7 @@ typedef struct schDlSlotInfo
    uint8_t      pdcchUe;                  /*!< UE for which PDCCH is scheduled in this slot */
    uint8_t      pdschUe;                  /*!< UE for which PDSCH is scheduled in this slot */
    RarAlloc     *rarAlloc[MAX_NUM_UE];    /*!< RAR allocation per UE*/
-   DlMsgAlloc   *dlMsgAlloc;              /*!< Dl msg allocation */
+   DlMsgAlloc   *dlMsgAlloc[MAX_NUM_UE];  /*!< Dl msg allocation per UE*/
 }SchDlSlotInfo;
 
 typedef struct schRaCb
@@ -361,11 +361,11 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime);
 uint8_t schBroadcastSsbAlloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcstAlloc *dlBrdcstAlloc);
 uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcstAlloc *dlBrdcstAlloc);
 bool schProcessRaReq(SchCellCb *cellCb, SlotTimingInfo currTime, uint8_t ueId);
-uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime);
+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 ueIdx, DlMsgAlloc *msg4Alloc, uint8_t k0Idx);
+uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueId, DlMsgAlloc *msg4Alloc, uint8_t k0Idx);
 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);
index 1871144..859671d 100644 (file)
@@ -511,7 +511,7 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueIdx, DlMsgAlloc *msg4Alloc, uint8_t k0Idx)
+uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueId, DlMsgAlloc *msg4Alloc, uint8_t k0Idx)
 {
    uint8_t coreset0Idx = 0;
    uint8_t firstSymbol = 0;
@@ -543,7 +543,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
    bwp = &msg4Alloc->bwp;
    coreset0Idx  = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
 
-   msg4Alloc->dlMsgInfo = cell->raCb[ueIdx].dlMsgInfo;
+   msg4Alloc->dlMsgInfo = cell->raCb[ueId-1].dlMsgInfo;
    msg4Alloc->dlMsgInfo.isMsg4Pdu = true;
    /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
    numRbs     = coresetIdxTable[coreset0Idx][1];
@@ -579,7 +579,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
    pdcch->coresetCfg.shiftIndex = cell->cellCfg.phyCellId;
    pdcch->coresetCfg.precoderGranularity = 0; /* sameAsRegBundle */
    pdcch->numDlDci = 1;
-   pdcch->dci.rnti = cell->raCb[ueIdx].tcrnti;
+   pdcch->dci.rnti = cell->raCb[ueId-1].tcrnti;
    pdcch->dci.scramblingId = cell->cellCfg.phyCellId;
    pdcch->dci.scramblingRnti = 0;
    pdcch->dci.cceIndex = 4; /* considering SIB1 is sent at cce 0-1-2-3 */
@@ -596,7 +596,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI
    /* fill the PDSCH PDU */
    uint8_t cwCount = 0;
    pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
-   pdsch->rnti = cell->raCb[ueIdx].tcrnti;
+   pdsch->rnti = cell->raCb[ueId-1].tcrnti;
    pdsch->pduIndex = 0;
    pdsch->numCodewords = 1;
    for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
@@ -1579,11 +1579,11 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
  *
  *******************************************************************/
 
-uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime)
+bool schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId)
 {
    bool k1Found = FALSE;  
    uint16_t pdcchSlot = 0, pdschSlot = 0;
-   uint8_t ueIdx = 0, numK0 = 0, k0TblIdx = 0, k0Index = 0, k0Val = 0;
+   uint8_t numK0 = 0, k0TblIdx = 0, k0Index = 0, k0Val = 0;
    uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
    SchK0K1TimingInfoTbl *k0K1InfoTbl;
    SlotTimingInfo pdcchTime, pdschTime, pucchTime;
@@ -1593,117 +1593,125 @@ uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime)
    if(cell == NULL)
    {
       DU_LOG("\nERROR  -->  SCH: schDlRsrcAllocMsg4() : Cell is NULL");
-      return RFAILED;
+      return false;
    }
 
-   while(ueIdx < MAX_NUM_UE)
+   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(cell->raCb[ueIdx].msg4recvd == FALSE)
-      {
-         ueIdx++;
-         continue;
-      }
+      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++)
+   {
+      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;
 
-      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(schGetSlotSymbFrmt(pdschSlot, cell->slotFrmtBitMap) != DL_SLOT)
       {
          continue;
       }
 #endif
-      k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl;
-      numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].numK0;
-      for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
+      /* 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++)
       {
-         k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k0Index;
-         k0Val = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
+         k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
+         k1Val = defaultUlAckTbl[k1Index];
 
-         ADD_DELTA_TO_TIME(pdcchTime, pdschTime, k0Val);
-         pdschSlot = pdschTime.slot;
+         ADD_DELTA_TO_TIME(pdschTime, pucchTime, k1Val);
 #ifdef NR_TDD
-         if(schGetSlotSymbFrmt(pdschSlot, cell->slotFrmtBitMap) != DL_SLOT)
+         if(schGetSlotSymbFrmt(pucchTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
          {
             continue;
          }
 #endif
-         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];
+         /* If PUCCH is already scheduled on this slot, another PUCCH
+          * pdu cannot be scheduled here */
+         if(cell->schUlSlotInfo[pucchTime.slot]->pucchUe != 0)
+            continue;
 
-            ADD_DELTA_TO_TIME(pdschTime, pucchTime, k1Val);
-#ifdef NR_TDD
-            if(schGetSlotSymbFrmt(pucchTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
-            {
-               continue;
-            }
-#endif
-            k1Found = true;
-            break;
-         }
-         if(k1Found)
-            break;
+         k1Found = true;
+         break;
       }
+      if(k1Found)
+         break;
+   }
 
-      /* If K0-K1 combination not found, no scheduling happens */
-      if(!k1Found)
-      {
-         ueIdx++;
-         continue;
-      }
-      
-      SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgAlloc));
-      if(dciSlotAlloc == NULLP)
-      {
-         DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for dciSlotAlloc");
-         return RFAILED;
-      }
-      cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc = dciSlotAlloc;
+   /* If K0-K1 combination not found, no scheduling happens */
+   if(!k1Found)
+      return false;
 
-      /* Fill PDCCH and PDSCH scheduling information for Msg4 */
-      if((schDlRsrcAllocMsg4(cell, pdschTime, ueIdx, dciSlotAlloc, k0Index)) != ROK)
+   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;
+
+   /* Fill PDCCH and PDSCH scheduling information for Msg4 */
+   if((schDlRsrcAllocMsg4(cell, pdschTime, ueId, dciSlotAlloc, k0Index)) != 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;
+      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;
+   else
+   {
+      /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */
+      SCH_ALLOC(msg4SlotAlloc, sizeof(DlMsgAlloc));
+      if(msg4SlotAlloc == NULLP)
       {
-         DU_LOG("\nERROR  -->  SCH: Scheduling of Msg4 failed in slot [%d]", pdschSlot);
+         DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4SlotAlloc");
          SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
-         cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc = NULLP;
-         return RFAILED;
+         cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc[ueId-1] = NULLP;
+         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;
-      else
-      {
-         /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */
-         SCH_ALLOC(msg4SlotAlloc, sizeof(DlMsgAlloc));
-         if(msg4SlotAlloc == NULLP)
-         {
-            DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4SlotAlloc");
-            SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
-            cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc = NULLP;
-            return RFAILED;
-         }
-         cell->schDlSlotInfo[pdschSlot]->dlMsgAlloc = msg4SlotAlloc;
+      cell->schDlSlotInfo[pdschSlot]->dlMsgAlloc[ueId-1] = msg4SlotAlloc;
 
-         /* Copy all RAR info */
-         memcpy(msg4SlotAlloc, dciSlotAlloc, sizeof(DlMsgAlloc));
-         msg4SlotAlloc->dlMsgPdcchCfg.dci.pdschCfg = &msg4SlotAlloc->dlMsgPdschCfg;
+      /* Copy all RAR info */
+      memcpy(msg4SlotAlloc, dciSlotAlloc, sizeof(DlMsgAlloc));
+      msg4SlotAlloc->dlMsgPdcchCfg.dci.pdschCfg = &msg4SlotAlloc->dlMsgPdschCfg;
 
-         /* Assign correct PDU types in corresponding slots */
-         msg4SlotAlloc->pduPres = PDSCH_PDU;
-         dciSlotAlloc->pduPres = PDCCH_PDU;
-         dciSlotAlloc->pdschSlot = pdschSlot;
-      }
-
-      /* PUCCH resource */
-      schAllocPucchResource(cell, pucchTime, cell->raCb[ueIdx].tcrnti);
-      cell->raCb[ueIdx].msg4recvd = FALSE;
-      ueIdx++;
+      /* Assign correct PDU types in corresponding slots */
+      msg4SlotAlloc->pduPres = PDSCH_PDU;
+      dciSlotAlloc->pduPres = PDCCH_PDU;
+      dciSlotAlloc->pdschSlot = pdschSlot;
    }
-   return ROK;
+
+   /* PUCCH resource */
+   schAllocPucchResource(cell, pucchTime, cell->raCb[ueId-1].tcrnti);
+
+   cell->schDlSlotInfo[pdcchSlot]->pdcchUe = ueId;
+   cell->schDlSlotInfo[pdschSlot]->pdschUe = ueId;
+   cell->schUlSlotInfo[pucchTime.slot]->puschUe = ueId;
+   cell->raCb[ueId-1].msg4recvd = FALSE;
+   return true;
 }
 /**********************************************************************
   End of file
index 33e5f2a..597c689 100644 (file)
@@ -205,7 +205,7 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
  * ****************************************************************/
 uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlMsgAlloc *dlMsgAlloc)
 {
-   uint8_t ueIdx = 0, lcIdx = 0, pdschSymbols = 0, k1 = 0;
+   uint8_t ueId = 0, lcIdx = 0, pdschSymbols = 0, k1 = 0;
    uint16_t slot = 0,  startPrb = 0, maxFreePRB = 0,dlToUlAckIdx =0;
    uint16_t crnti = 0, mcsIdx = 0;
    uint32_t accumalatedSize = 0;
@@ -225,9 +225,9 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
    {
       slot = dlSchedInfo->schSlotValue.dlMsgTime.slot;
 
-      GET_RIGHT_MOST_SET_BIT(cell->boIndBitMap, ueIdx);
-      GET_CRNTI(crnti,ueIdx);
-      ueCb = &cell->ueCb[ueIdx-1];
+      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 */
       SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc));
@@ -237,7 +237,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
          return RFAILED;
       }
       memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc));
-      dlSchedInfo->dlMsgAlloc = dlMsgAlloc;
+      dlSchedInfo->dlMsgAlloc[ueId-1] = dlMsgAlloc;
       dlMsgAlloc->crnti = crnti;
 
       pdschCfg = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg; 
@@ -247,7 +247,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
        * 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->dlMsgInfo, \
+      memcpy(&dlMsgAlloc->dlMsgInfo, &cell->schDlSlotInfo[slot]->dlMsgAlloc[ueId-1]->dlMsgInfo, \
            sizeof(DlMsgInfo));
 
       /*Re-Initalization per UE*/
@@ -278,7 +278,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
                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 = NULLP;
+               dlSchedInfo->dlMsgAlloc[ueId-1] = NULLP;
                return RFAILED;
             }
          }
@@ -290,10 +290,10 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
             ((ueCb->dlLcPrbEst.dedLcInfo != NULL) && (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
       {
          DU_LOG("\nDEBUG  -->  SCH : No pending BO for any LC id\n");
-         UNSET_ONE_BIT(ueIdx, cell->boIndBitMap);
+         UNSET_ONE_BIT(ueId, cell->boIndBitMap);
          /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
          SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc));
-         dlSchedInfo->dlMsgAlloc = NULLP;
+         dlSchedInfo->dlMsgAlloc[ueId-1] = NULLP;
          continue;
       }
 
@@ -363,7 +363,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
          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 = NULLP;
+         dlSchedInfo->dlMsgAlloc[ueId-1] = NULLP;
          return RFAILED;
       }
       
@@ -382,9 +382,9 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
 #endif
       /* PUCCH resource */
       /* TODO : Correct values of K1 will be used from K0K1 table */ 
-      if(cell->ueCb[ueIdx].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres)
+      if(cell->ueCb[ueId-1].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres)
       {
-         schPucchCfg = &(cell->ueCb[ueIdx].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg);
+         schPucchCfg = &(cell->ueCb[ueId-1].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg);
          if(schPucchCfg->dlDataToUlAck)
          {
             for(dlToUlAckIdx = 0; dlToUlAckIdx < schPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; dlToUlAckIdx++)
@@ -399,7 +399,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
       schAllocPucchResource(cell, pucchTime, crnti);
 
       /* after allocation is done, unset the bo bit for that ue */
-      UNSET_ONE_BIT(ueIdx, cell->boIndBitMap);
+      UNSET_ONE_BIT(ueId, cell->boIndBitMap);
    }
 
    return ROK;
@@ -425,15 +425,15 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
 {
    uint8_t   ueId, ueIdx, lcgIdx, ret = ROK;
    uint16_t  slot;
-   bool      isRarScheduled = false;
+   bool      isRarPending = false, isRarScheduled = false;
+   bool      isMsg4Pending = false, isMsg4Scheduled = false;
    CmLList       *pendingUeNode;
    DlSchedInfo   dlSchedInfo;
    DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
    DlMsgAlloc    *dlMsgAlloc = NULLP;
    SchCellCb     *cell = NULLP;
 
-   memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
-   dlSchedInfo.dlMsgAlloc = NULLP;
+   memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
    schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue);
    dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
    dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION;
@@ -491,46 +491,76 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
    {
       ueId = *(uint8_t *)(pendingUeNode->node);
 
-      /* Check for Pending RA Requests */
+      /* If RAR is pending for this UE, schedule PDCCH,PDSCH to send RAR and 
+       * PUSCH to receive MSG3 as per k0-k2 configuration*/
       if(cell->raReq[ueId-1] != NULLP)
       {
+         isRarPending = true;
          isRarScheduled = schProcessRaReq(cell, *slotInd, ueId);
-         /* If RAR scheduled for this UE, remove from linked list since no
-          * pending msgs for this UE */
-         if(isRarScheduled)
+      }
+
+      /* If MSG4 is pending for this UE, schedule PDCCH,PDSCH to send MSG4 and
+       * PUCCH to receive UL msg as per k0-k1 configuration  */
+      if(cell->raCb[ueId-1].msg4recvd)
+      {
+         isMsg4Pending = true;
+         isMsg4Scheduled = schProcessMsg4Req(cell, *slotInd, ueId);
+      }
+
+      if(isRarPending || isMsg4Pending)
+      {
+         /* If RAR or MSG is successfully scheduled then
+          * remove UE from linked list since no pending msgs for this UE */
+         if(isRarScheduled || isMsg4Scheduled)
          {
             SCH_FREE(pendingUeNode->node, sizeof(uint8_t));
             deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
          }
-         /* If RAR couldnt be scheduled, put this UE at the end of linked 
-          * list to be scheduled later */
-         else
+         /* If RAR/MSG4 is pending but couldnt be scheduled then,
+          * put this UE at the end of linked list to be scheduled later */
+         else 
          {
             cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
          }
       }
    }
 
-   /* Check for RAR */
+   /* Check if any PDU is scheduled at this slot for any UE */
    for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
    {
+      /* If RAR PDCCH/PDSCH is scheduled for a UE at this slot, fill RAR specific interface 
+       * structure to send to MAC */
       if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP)
       {
          slot = dlSchedInfo.schSlotValue.rarTime.slot;
          dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx];
          cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
       }
-   }
    
-   schProcessMsg4Req(cell, *slotInd);
+      /* If MSG4 PDCCH/PDSCH is scheduled for a UE at this slot, fill MSG4
+       * 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))
+      {
+         slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
+         dlSchedInfo.dlMsgAlloc[ueIdx] = cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx];
+         cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx] = NULLP;
+      }
 
-   /* Check for MSG4 */
-   if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc != NULLP) &&
-      (cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc->dlMsgInfo.isMsg4Pdu))
-   {
-      slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
-      dlSchedInfo.dlMsgAlloc = cell->schDlSlotInfo[slot]->dlMsgAlloc;
-      cell->schDlSlotInfo[slot]->dlMsgAlloc = 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 */
@@ -579,21 +609,6 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
       }
    }
 
-   /* Check for pending BO grant for LC */
-   if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc != NULLP) &&
-      (!cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc->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, sizeof(DlMsgAlloc));
-         return RFAILED;
-      }
-
-      /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
-      SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc, sizeof(DlMsgAlloc));
-   }
-
    /* Send msg to MAC */
    ret = sendDlAllocToMac(&dlSchedInfo, schInst);
    if(ret != ROK)
index 5f6578a..4111dcc 100644 (file)
@@ -952,7 +952,7 @@ typedef struct dlSchedInfo
    DciInfo    *ulGrant;
 
    /* Allocation from dedicated DL msg */
-   DlMsgAlloc *dlMsgAlloc;
+   DlMsgAlloc *dlMsgAlloc[MAX_NUM_UE];
 
 }DlSchedInfo;
 
index a930709..af6a134 100644 (file)
@@ -1042,6 +1042,8 @@ S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
       numPdus--;
    }
 
+   /* TODO: [SFN:SLOT] at which RACH Indication is sent should be calculated
+    * based on PRACH cfg index */
    /* Send RACH Ind to L2 for first UE */
    if(ueDb.ueCb[UE_IDX_0].rachIndSent == false && ulTtiReq->sfn == 16 && ulTtiReq->slot == 6)
    {