X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrsch%2Fsch_slot_ind.c;h=3a23293550393a4fedbda482bb3ea311420a2172;hb=653aa9a77c383713ea88d4b34759b333576646b4;hp=29869154a86d32e4ec692f4b12d300e2fd7f9c06;hpb=6b44407d464a5a4e060999255233a7cfe78bb0fa;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 29869154a..3a2329355 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -49,8 +49,8 @@ SchMacDlAllocFunc schMacDlAllocOpts[] = packSchMacDlAlloc }; -extern SchCb schCb[SCH_MAX_INST]; -extern int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t +SchCb schCb[SCH_MAX_INST]; +int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t offsetPointA); /******************************************************************* @@ -69,7 +69,7 @@ extern int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t * RFAILED - failure * * ****************************************************************/ -int sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) +uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) { Pst pst; @@ -113,11 +113,98 @@ void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue) * on PHY_DELTA + SCHED_DELTA + BO_DELTA * ****************************************************************/ - ADD_DELTA_TO_TIME(slotInd,schSlotValue->currentTime,PHY_DELTA); - ADD_DELTA_TO_TIME(slotInd,schSlotValue->broadcastTime,PHY_DELTA+SCHED_DELTA); - ADD_DELTA_TO_TIME(slotInd,schSlotValue->rarTime,PHY_DELTA+SCHED_DELTA); - ADD_DELTA_TO_TIME(slotInd,schSlotValue->msg4Time,PHY_DELTA+SCHED_DELTA); - ADD_DELTA_TO_TIME(slotInd,schSlotValue->dlMsgTime,PHY_DELTA+SCHED_DELTA+BO_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, PHY_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, PHY_DELTA + SCHED_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, PHY_DELTA + SCHED_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA + SCHED_DELTA); +} + +/******************************************************************* + * + * @brief + * + * @details + * + * Function : + * + * Functionality: + + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlMsgAlloc *dlMsgAlloc) +{ + uint8_t ueIdx, lcIdx; + uint16_t slot; + uint16_t crnti = 0; + uint32_t accumalatedSize = 0; + SchUeCb *ueCb = NULLP; + + while(cell->boIndBitMap) + { + slot = dlSchedInfo->schSlotValue.dlMsgTime.slot; + + GET_RIGHT_MOST_SET_BIT(cell->boIndBitMap, ueIdx); + GET_CRNTI(crnti,ueIdx); + ueCb = &cell->ueCb[ueIdx-1]; + + /* allocate PDCCH and PDSCH resources for the ue */ + SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc)); + if(!dlMsgAlloc) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for ded DL msg alloc"); + return RFAILED; + } + memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc)); + dlSchedInfo->dlMsgAlloc = dlMsgAlloc; + dlMsgAlloc->crnti = crnti; + + /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */ + memcpy(&dlMsgAlloc->dlMsgInfo, cell->schDlSlotInfo[slot]->dlMsgInfo, \ + sizeof(DlMsgInfo)); + + /* scheduled LC data fill */ + dlMsgAlloc->numLc = 0; + for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++) + { + if(ueCb->dlInfo.dlLcCtxt[lcIdx].bo) + { + dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].lcId = lcIdx; + + /* calculation for BO includse RLC and MAC header size */ + dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes = \ + ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE; + accumalatedSize += dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes; + dlMsgAlloc->numLc++; + } + ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0; + } + + /* pdcch and pdsch data is filled */ + schDlRsrcAllocDlMsg(dlMsgAlloc, cell, crnti, &accumalatedSize, slot); + /* Calculated TB size could be less than the total size requested. + * Hence, updated the scheduled bytes report. Following is valid only for + * one LC. + * TODO : Update the scheduling byte report for multiple LC based on QCI + * and Priority */ + dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc -1].schBytes = accumalatedSize; + + /* PUCCH resource */ + schAllocPucchResource(cell, dlMsgAlloc->crnti, slot); + + /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ + SCH_FREE(cell->schDlSlotInfo[dlSchedInfo->schSlotValue.dlMsgTime.slot]->dlMsgInfo, \ + sizeof(DlMsgInfo)); + cell->schDlSlotInfo[dlSchedInfo->schSlotValue.dlMsgTime.slot]->dlMsgInfo = NULL; + + /* after allocation is done, unset the bo bit for that ue */ + UNSET_ONE_BIT(ueIdx, cell->boIndBitMap); + } + + return ROK; } /******************************************************************* @@ -138,27 +225,29 @@ void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue) * ****************************************************************/ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) { - int ret = ROK; - uint8_t ssb_rep, ueIdx, lcgIdx; + uint8_t ret = ROK; + uint8_t ssb_rep, ueIdx, lcgIdx; uint16_t slot, sfnSlot = 0; DlSchedInfo dlSchedInfo; + DlBrdcstAlloc *dlBrdcstAlloc = NULLP; + RarAlloc *rarAlloc = NULLP; + DlMsgAlloc *msg4Alloc = NULLP; + DlMsgAlloc *dlMsgAlloc = NULLP; + SchCellCb *cell = NULLP; + memset(&dlSchedInfo,0,sizeof(DlSchedInfo)); - DlBrdcstAlloc *dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc; - RarAlloc *rarAlloc = NULLP; - Msg4Alloc *msg4Alloc = NULLP; + schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue); + dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc; dlBrdcstAlloc->ssbTrans = NO_SSB; dlBrdcstAlloc->sib1Trans = NO_SIB1; - SchCellCb *cell = schCb[schInst].cells[schInst]; - - schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue); - + cell = schCb[schInst].cells[schInst]; ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod; memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo)); dlBrdcstAlloc->ssbIdxSupported = 1; - sfnSlot = ((dlSchedInfo.schSlotValue.broadcastTime.sfn * 10) + - dlSchedInfo.schSlotValue.broadcastTime.slot); + sfnSlot = dlSchedInfo.schSlotValue.broadcastTime.sfn * cell->numSlots + + dlSchedInfo.schSlotValue.broadcastTime.slot; slot = dlSchedInfo.schSlotValue.currentTime.slot; @@ -168,8 +257,10 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) if (sfnSlot % SCH_MIB_TRANS == 0) { dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION; + if(!cell->firstSsbTransmitted) + cell->firstSsbTransmitted = true; } - else if (sfnSlot % ssb_rep == 0) + else if (cell->firstSsbTransmitted && (sfnSlot % ssb_rep == 0)) { dlBrdcstAlloc->ssbTrans = SSB_REPEAT; } @@ -182,8 +273,10 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1NewTxPeriod == 0) { dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION; + if(!cell->firstSib1Transmitted) + cell->firstSib1Transmitted = true; } - else if (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0) + else if (cell->firstSib1Transmitted && (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0)) { dlBrdcstAlloc->sib1Trans = SIB1_REPITITION; } @@ -199,8 +292,8 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot); if(ret != ROK) { - DU_LOG("\nschBroadcastAlloc failed"); - RETVALUE(ret); + DU_LOG("\nERROR --> SCH : schBroadcastAlloc failed"); + return (ret); } } @@ -211,7 +304,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) SCH_ALLOC(rarAlloc, sizeof(RarAlloc)); if(!rarAlloc) { - DU_LOG("\nMAC: Memory Allocation failed for RAR alloc"); + DU_LOG("\nERROR --> SCH : Memory Allocation failed for RAR alloc"); return RFAILED; } @@ -231,30 +324,32 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) } /* check for MSG4 */ - if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info != NULLP) + if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo != NULLP) && + (cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo->isMsg4Pdu)) { - slot = dlSchedInfo.schSlotValue.msg4Time.slot; - SCH_ALLOC(msg4Alloc, sizeof(Msg4Alloc)); + slot = dlSchedInfo.schSlotValue.dlMsgTime.slot; + + SCH_ALLOC(msg4Alloc, sizeof(DlMsgAlloc)); if(!msg4Alloc) { - DU_LOG("\nMAC: Memory Allocation failed for msg4 alloc"); + DU_LOG("\nERROR --> SCH : Memory Allocation failed for msg4 alloc"); return RFAILED; } - dlSchedInfo.msg4Alloc = msg4Alloc; + dlSchedInfo.dlMsgAlloc = msg4Alloc; /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */ - memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[slot]->msg4Info, \ - sizeof(Msg4Info)); + memcpy(&msg4Alloc->dlMsgInfo, cell->schDlSlotInfo[slot]->dlMsgInfo, \ + sizeof(DlMsgInfo)); /* pdcch and pdsch data is filled */ - schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.msg4Time.slot); + schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.dlMsgTime.slot); /* PUCCH resource */ - schAllocPucchResource(cell, msg4Alloc->msg4Info.crnti, dlSchedInfo.schSlotValue.msg4Time.slot); + schAllocPucchResource(cell, msg4Alloc->dlMsgInfo.crnti, dlSchedInfo.schSlotValue.dlMsgTime.slot); - SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, sizeof(Msg4Info)); - cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info = NULL; + SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo)); + cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo = NULL; } /* check if UL grant must be sent in this slot for a SR/BSR that had been received */ for(ueIdx=0; ueIdxnumActvUe; ueIdx++) @@ -284,7 +379,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) SCH_ALLOC(dciInfo, sizeof(DciInfo)); if(!dciInfo) { - DU_LOG("\nMAC: Memory Allocation failed for dciInfo alloc"); + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); return RFAILED; } memset(dciInfo,0,sizeof(DciInfo)); @@ -300,12 +395,19 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) } } + /* Check for pending BO grant for LC */ + if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo != NULLP) && + (!cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo->isMsg4Pdu)) + { + schFillBoGrantDlSchedInfo(cell, &dlSchedInfo, dlMsgAlloc); + } + /* send msg to MAC */ ret = sendDlAllocToMac(&dlSchedInfo, schInst); if(ret != ROK) { - DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed"); - RETVALUE(ret); + DU_LOG("\nERROR --> SCH : Sending DL Broadcast allocation from SCH to MAC failed"); + return (ret); } schInitDlSlot(cell->schDlSlotInfo[slot]);