X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrsch%2Fsch_slot_ind.c;h=3542bd0181ffc4f0bdc9dd496ac9bda5e5c6363e;hb=7fb274708be5434e1573315b106c554d5562ac42;hp=98647013ca35568ab4c0a4f8dc022b32bba40daf;hpb=1616921700a3c7541f1df6dd2678f9ee4d8e933b;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 98647013c..3542bd018 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -49,9 +49,7 @@ SchMacDlAllocFunc schMacDlAllocOpts[] = packSchMacDlAlloc }; -extern SchCb schCb[SCH_MAX_INST]; -extern int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t - offsetPointA); +SchCb schCb[SCH_MAX_INST]; /******************************************************************* * @@ -75,13 +73,12 @@ uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) memset(&pst, 0, sizeof(Pst)); FILL_PST_SCH_TO_MAC(pst, inst); - pst.event = EVENT_DL_ALLOC; + pst.event = EVENT_DL_SCH_INFO; return(*schMacDlAllocOpts[pst.selector])(&pst, dlSchedInfo); } - /******************************************************************* * * @brief Handles slot indication at SCH @@ -98,7 +95,7 @@ uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) * RFAILED - failure * * ****************************************************************/ -void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue) +void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue) { /**************************************************************** * PHY_DELTA - the physical layer delta * @@ -113,10 +110,83 @@ 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->dlMsgTime, PHY_DELTA + SCHED_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, PHY_DELTA_DL); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, PHY_DELTA_DL + SCHED_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, PHY_DELTA_DL + SCHED_DELTA); + ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA_DL + SCHED_DELTA); +} + +/******************************************************************* + * + * @brief Checks if a slot is to be scheduled for SSB transmission + * + * @details + * + * Function : schCheckSsbOcc + * + * Functionality: + * Checks if a slot is to be scheduled for SSB transmission + * + * @params[in] SlotTimingInfo slotTime + * SchCellCb *cell + * @return Pdu transmission + * + * ****************************************************************/ +PduTxOccsaion schCheckSsbOcc(SlotTimingInfo slotTime, SchCellCb *cell) +{ + uint8_t ssb_rep; + + ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod; + + /* Identify SSB ocassion*/ + if ((slotTime.sfn % SCH_MIB_TRANS == 0) && (slotTime.slot ==0)) + { + return NEW_TRANSMISSION; + } + else if(cell->firstSsbTransmitted) + { + if((ssb_rep == 5) && ((slotTime.slot == 0 || slotTime.slot == 10))) + return REPEATITION; + else if((slotTime.sfn % (ssb_rep/10) == 0) && slotTime.slot == 0) + return REPEATITION; + } + /* not SSB occassion */ + return NO_TRANSMISSION; +} + +/******************************************************************* + * + * @brief Checks if a slot is to be scheduled for SIB1 transmission + * + * @details + * + * Function : schCheckSib1Occ + * + * Functionality: + * Checks if a slot is to be scheduled for SIB1 transmission + * + * @params[in] SlotTimingInfo slotTime + * SchCellCb *cell + * @return Pdu transmission + * + * ****************************************************************/ +PduTxOccsaion schCheckSib1Occ(SlotTimingInfo slotTime, SchCellCb *cell) +{ + /* Identify SIB1 occasions */ + if((slotTime.sfn % SCH_SIB1_TRANS == 0) && (slotTime.slot ==0)) + { + return NEW_TRANSMISSION; + } + else if(cell->firstSib1Transmitted) + { + if((slotTime.sfn % (cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod/10) == 0) && + (slotTime.slot == 0)) + { + return REPEATITION; + } + } + /* not SIB1 occassion */ + return NO_TRANSMISSION; } /******************************************************************* @@ -140,7 +210,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM uint8_t ueIdx, lcIdx; uint16_t slot; uint16_t crnti = 0; - uint16_t accumalatedSize = 0; + uint32_t accumalatedSize = 0; SchUeCb *ueCb = NULLP; while(cell->boIndBitMap) @@ -155,8 +225,8 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc)); if(!dlMsgAlloc) { - DU_LOG("\nMAC: Memory Allocation failed for ded DL msg alloc"); - return RFAILED; + DU_LOG("\nERROR --> SCH : Memory Allocation failed for ded DL msg alloc"); + return RFAILED; } memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc)); dlSchedInfo->dlMsgAlloc = dlMsgAlloc; @@ -170,21 +240,33 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM 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 + RLC_HDR_SIZE + MAC_HDR_SIZE; - accumalatedSize += dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes; - dlMsgAlloc->numLc++; - } - ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0; + 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; + } + + if (!dlMsgAlloc->numLc) + { + DU_LOG("\nDEBUG --> SCH : No bo for any lcid\n"); + return ROK; } /* pdcch and pdsch data is filled */ - schDlRsrcAllocDlMsg(dlMsgAlloc, cell, crnti, accumalatedSize, slot); + 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); @@ -217,63 +299,45 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM * RFAILED - failure * * ****************************************************************/ -uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) +uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) { - uint8_t ret = ROK; - uint8_t ssb_rep, ueIdx, lcgIdx; - uint16_t slot, sfnSlot = 0; + uint8_t ueIdx, lcgIdx, ret = ROK; + uint16_t slot; DlSchedInfo dlSchedInfo; DlBrdcstAlloc *dlBrdcstAlloc = NULLP; - RarAlloc *rarAlloc = NULLP; DlMsgAlloc *msg4Alloc = NULLP; DlMsgAlloc *dlMsgAlloc = NULLP; SchCellCb *cell = NULLP; memset(&dlSchedInfo,0,sizeof(DlSchedInfo)); + dlSchedInfo.dlMsgAlloc = NULLP; schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue); dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc; - dlBrdcstAlloc->ssbTrans = NO_SSB; - dlBrdcstAlloc->sib1Trans = NO_SIB1; + dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION; + dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION; 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); + if(cell == NULLP) + { + DU_LOG("\nERROR --> SCH : Cell Does not exist"); + return RFAILED; + } + memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo)); + dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED; slot = dlSchedInfo.schSlotValue.currentTime.slot; dlSchedInfo.cellId = cell->cellId; - /* Identify SSB ocassion*/ - if (sfnSlot % SCH_MIB_TRANS == 0) - { - dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION; - } - else if (sfnSlot % ssb_rep == 0) - { - dlBrdcstAlloc->ssbTrans = SSB_REPEAT; - } - else - { - /* not SSB occassion */ - } + /* Check if this slot is SSB occassion */ + dlBrdcstAlloc->ssbTrans = schCheckSsbOcc(dlSchedInfo.schSlotValue.broadcastTime, cell); + if((dlBrdcstAlloc->ssbTrans == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted)) + cell->firstSsbTransmitted = true; - /* Identify SIB1 occasions */ - if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1NewTxPeriod == 0) - { - dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION; - } - else if (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0) - { - dlBrdcstAlloc->sib1Trans = SIB1_REPITITION; - } - else - { - /* not SIB1 occassion */ - } + /* Check if this slot is SIB1 occassion */ + dlBrdcstAlloc->sib1Trans = schCheckSib1Occ(dlSchedInfo.schSlotValue.broadcastTime, cell); + if((dlBrdcstAlloc->sib1Trans == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted)) + cell->firstSib1Transmitted = true; if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans) { @@ -282,35 +346,20 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot); if(ret != ROK) { - DU_LOG("\nschBroadcastAlloc failed"); - return (ret); + DU_LOG("\nERROR --> SCH : schBroadcastAlloc failed"); + return ret; } } + /* Check for Pending RA Requests */ + schProcessRaReq(*slotInd, cell); + /* check for RAR */ - if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP) + if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc != NULLP) { slot = dlSchedInfo.schSlotValue.rarTime.slot; - SCH_ALLOC(rarAlloc, sizeof(RarAlloc)); - if(!rarAlloc) - { - DU_LOG("\nMAC: Memory Allocation failed for RAR alloc"); - return RFAILED; - } - - dlSchedInfo.rarAlloc = rarAlloc; - - /* RAR info is copied, this was earlier filled in schProcessRachInd */ - memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[slot]->rarInfo, sizeof(RarInfo)); - - /* pdcch and pdsch data is filled */ - schFillRar(rarAlloc, - cell->schDlSlotInfo[slot]->rarInfo->raRnti, - cell->cellCfg.phyCellId, - cell->cellCfg.ssbSchCfg.ssbOffsetPointA); - - SCH_FREE(cell->schDlSlotInfo[slot]->rarInfo,sizeof(RarAlloc)); - cell->schDlSlotInfo[slot]->rarInfo = NULLP; + dlSchedInfo.rarAlloc = cell->schDlSlotInfo[slot]->rarAlloc; + cell->schDlSlotInfo[slot]->rarAlloc = NULLP; } /* check for MSG4 */ @@ -322,8 +371,8 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) SCH_ALLOC(msg4Alloc, sizeof(DlMsgAlloc)); if(!msg4Alloc) { - DU_LOG("\nMAC: Memory Allocation failed for msg4 alloc"); - return RFAILED; + DU_LOG("\nERROR --> SCH : Memory Allocation failed for msg4 alloc"); + return RFAILED; } dlSchedInfo.dlMsgAlloc = msg4Alloc; @@ -333,7 +382,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) sizeof(DlMsgInfo)); /* pdcch and pdsch data is filled */ - schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.dlMsgTime.slot); + schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.dlMsgTime.slot, dlBrdcstAlloc->ssbTrans, dlBrdcstAlloc->sib1Trans); /* PUCCH resource */ schAllocPucchResource(cell, msg4Alloc->dlMsgInfo.crnti, dlSchedInfo.schSlotValue.dlMsgTime.slot); @@ -341,6 +390,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) 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++) { @@ -359,28 +409,28 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) for(lcgIdx=0; lcgIdxbsrInfo[lcgIdx].dataVol; - ueCb->bsrInfo[lcgIdx].dataVol = 0; + ueCb->bsrInfo[lcgIdx].dataVol = 0; } if(totDataReq > 0) /* UL grant must be provided for this UE in this slot */ { SchPuschInfo schPuschInfo; memset(&schPuschInfo, 0, sizeof(SchPuschInfo)); - SCH_ALLOC(dciInfo, sizeof(DciInfo)); - if(!dciInfo) - { - DU_LOG("\nMAC: Memory Allocation failed for dciInfo alloc"); - return RFAILED; - } - memset(dciInfo,0,sizeof(DciInfo)); - /* update the SFN and SLOT */ - memcpy(&dlSchedInfo.schSlotValue.ulDciTime, slotInd, sizeof(SlotIndInfo)); - slot = dlSchedInfo.schSlotValue.ulDciTime.slot; - /* Update PUSCH allocation */ - schFillPuschAlloc(ueCb, slot, totDataReq, &schPuschInfo); - /* Fill DCI for UL grant */ - schFillUlDci(ueCb, schPuschInfo, dciInfo); - memcpy(&dciInfo->slotIndInfo, &dlSchedInfo.schSlotValue.ulDciTime, sizeof(SlotIndInfo)); + SCH_ALLOC(dciInfo, sizeof(DciInfo)); + if(!dciInfo) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); + return RFAILED; + } + memset(dciInfo,0,sizeof(DciInfo)); + /* update the SFN and SLOT */ + memcpy(&dlSchedInfo.schSlotValue.ulDciTime, slotInd, sizeof(SlotTimingInfo)); + slot = dlSchedInfo.schSlotValue.ulDciTime.slot; + /* Update PUSCH allocation */ + schFillPuschAlloc(ueCb, slot, totDataReq, &schPuschInfo); + /* Fill DCI for UL grant */ + schFillUlDci(ueCb, schPuschInfo, dciInfo); + memcpy(&dciInfo->slotIndInfo, &dlSchedInfo.schSlotValue.ulDciTime, sizeof(SlotTimingInfo)); dlSchedInfo.ulGrant = dciInfo; } } @@ -396,7 +446,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) ret = sendDlAllocToMac(&dlSchedInfo, schInst); if(ret != ROK) { - DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed"); + DU_LOG("\nERROR --> SCH : Sending DL Broadcast allocation from SCH to MAC failed"); return (ret); }