1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for SCH */
20 #include "common_def.h"
27 #include "du_app_mac_inf.h"
28 #include "mac_sch_interface.h"
31 #include "sch_utils.h"
36 /*******************************************************************
38 * @brief Fill and send UE cfg response to MAC
42 * Function : SchSendUeCfgRspToMac
44 * Functionality: Fill and send UE cfg response to MAC
47 * @return ROK - success
50 * ****************************************************************/
51 void SchSendUeCfgRspToMac(SchUeCfgReq *ueCfg, Inst inst,\
52 SchMacRsp result, SchUeCfgRsp *cfgRsp)
56 cfgRsp->cellId = ueCfg->cellId;
57 cfgRsp->crnti = ueCfg->crnti;
60 /* Filling response post */
61 memset(&rspPst, 0, sizeof(Pst));
62 FILL_PST_SCH_TO_MAC(rspPst, inst);
63 rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
64 DU_LOG("\nINFO --> SCH : Sending UE Config response to MAC");
65 MacMessageRouter(&rspPst, (void *)cfgRsp);
68 /*******************************************************************
70 * @brief Fill and send UE Recfg response to MAC
74 * Function : SchSendUeRecfgRspToMac
76 * Functionality: Fill and send UE Recfg response to MAC
79 * @return ROK - success
82 * ****************************************************************/
83 void SchSendUeRecfgRspToMac(SchUeRecfgReq *ueRecfgReq, Inst inst,\
84 SchMacRsp result, SchUeRecfgRsp *reCfgRsp)
88 reCfgRsp->cellId = ueRecfgReq->cellId;
89 reCfgRsp->crnti = ueRecfgReq->crnti;
90 reCfgRsp->rsp = result;
92 /* Filling response post */
93 memset(&rspPst, 0, sizeof(Pst));
94 FILL_PST_SCH_TO_MAC(rspPst, inst);
95 rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
96 DU_LOG("\nINFO --> SCH : Sending UE Reconfig response to MAC");
97 MacMessageRouter(&rspPst, (void *)reCfgRsp);
100 /*******************************************************************
103 * @brief Function to fill Dl Lc Context in SCH Ue Cb
107 * Function : fillSchDlLcCtxt
109 * Functionality: Function to fill Dl Lc Context in SCH Ue Cb
111 * @params[in] SchDlLcCtxt pointer,
115 * ****************************************************************/
117 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
119 ueCbLcCfg->lcId = lcCfg->lcId;
120 ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
121 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
125 ueCbLcCfg->pduSessionId = lcCfg->drbQos->pduSessionId;
129 if(ueCbLcCfg->snssai == NULLP)/*In CONFIG_MOD case, no need to allocate SNSSAI memory*/
131 SCH_ALLOC(ueCbLcCfg->snssai, sizeof(Snssai));
133 memcpy(ueCbLcCfg->snssai, lcCfg->snssai,sizeof(Snssai));
137 /*******************************************************************
139 * @brief Function to fill Ul Lc Context in SCH Ue Cb
143 * Function : fillSchUlLcCtxt
145 * Functionality: Function to fill Ul Lc Context in SCH Ue Cb
147 * @params[in] SchUlLcCtxt pointer,
151 * ****************************************************************/
153 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
155 ueCbLcCfg->lcId = lcCfg->lcId;
156 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
157 ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
158 ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
159 ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
160 ueCbLcCfg->pbr = lcCfg->ulLcCfg.pbr;
161 ueCbLcCfg->bsd = lcCfg->ulLcCfg.bsd;
165 ueCbLcCfg->pduSessionId = lcCfg->drbQos->pduSessionId;
169 /*In CONFIG_MOD case, no need to allocate SNSSAI memory again*/
170 if(ueCbLcCfg->snssai == NULLP)
172 SCH_ALLOC(ueCbLcCfg->snssai, sizeof(Snssai));
174 memcpy(ueCbLcCfg->snssai, lcCfg->snssai,sizeof(Snssai));
178 /*******************************************************************
180 * @brief Function to update/allocate dedLC Info
184 * Function : updateDedLcInfo
186 * Functionality: Function to fill DLDedLcInfo
188 * @params[arg] scheduler instance,
190 * SchRrmPolicy pointer,
191 * SchLcPrbEstimate pointer , It will be filled
192 * isDedicated pointer,(Address of isDedicated flag in LC Context)
194 * @return ROK >> This LC is part of RRM MemberList.
195 * RFAILED >> FATAL Error
196 * ROKIGNORE >> This LC is not part of this RRM MemberList
198 * ****************************************************************/
200 uint8_t updateDedLcInfo(Inst inst, Snssai *snssai, uint16_t *rsvdDedicatedPRB, bool *isDedicated)
202 CmLList *sliceCfg = schCb[inst].sliceCfg.first;
203 SchRrmPolicyOfSlice *rrmPolicyOfSlices;
207 rrmPolicyOfSlices = (SchRrmPolicyOfSlice*)sliceCfg->node;
208 if(rrmPolicyOfSlices && (memcmp(snssai, &(rrmPolicyOfSlices->snssai), sizeof(Snssai)) == 0))
210 /*Updating latest RrmPolicy*/
211 *rsvdDedicatedPRB = \
212 (uint16_t)(((rrmPolicyOfSlices->rrmPolicyRatioInfo.dedicatedRatio)*(MAX_NUM_RB))/100);
214 DU_LOG("\nINFO --> SCH : Updated RRM policy, reservedPOOL:%d",*rsvdDedicatedPRB);
217 sliceCfg = sliceCfg->next;
219 /*case: This LcCtxt is either a Default LC or this LC is part of someother RRM_MemberList*/
220 if(*isDedicated != TRUE)
222 DU_LOG("\nINFO --> SCH : This SNSSAI is not a part of this RRMPolicy");
227 /*******************************************************************
229 * @brief Function to fill SpCellCfg in SchUeCb From SchUeCfg Req
233 * Function : fillSpCellInSchCb
235 * Functionality: Function to fill SpCellCfg in SchUeCb
237 * @params[in] Scheduler instance,
240 * @return ROK/RFAILED
242 * ****************************************************************/
244 void fillSpCellInSchCb(SchSpCellRecfg *destSpCellCfg, SchSpCellCfg *srcSpCellCfg)
246 destSpCellCfg->servCellIdx = srcSpCellCfg->servCellIdx;
247 memcpy(&destSpCellCfg->servCellRecfg.initDlBwp, &srcSpCellCfg->servCellCfg.initDlBwp, sizeof(SchInitalDlBwp));
248 destSpCellCfg->servCellRecfg.numDlBwpToAddOrMod = srcSpCellCfg->servCellCfg.numDlBwpToAdd;
249 if(destSpCellCfg->servCellRecfg.numDlBwpToAddOrMod > 0)
251 memcpy(destSpCellCfg->servCellRecfg.dlBwpToAddOrModList, srcSpCellCfg->servCellCfg.dlBwpToAddList,\
252 (sizeof(SchDlBwpInfo) * srcSpCellCfg->servCellCfg.numDlBwpToAdd));
254 destSpCellCfg->servCellRecfg.firstActvDlBwpId = srcSpCellCfg->servCellCfg.firstActvDlBwpId;
255 destSpCellCfg->servCellRecfg.defaultDlBwpId = srcSpCellCfg->servCellCfg.defaultDlBwpId;
256 destSpCellCfg->servCellRecfg.bwpInactivityTmr = srcSpCellCfg->servCellCfg.bwpInactivityTmr;
257 memcpy(&destSpCellCfg->servCellRecfg.pdschServCellCfg, &srcSpCellCfg->servCellCfg.pdschServCellCfg, sizeof(SchPdschServCellCfg));
258 memcpy(&destSpCellCfg->servCellRecfg.initUlBwp, &srcSpCellCfg->servCellCfg.initUlBwp, sizeof(SchInitialUlBwp));
260 destSpCellCfg->servCellRecfg.numDlBwpToAddOrMod = srcSpCellCfg->servCellCfg.numDlBwpToAdd;
261 if(destSpCellCfg->servCellRecfg.numDlBwpToAddOrMod > 0)
263 memcpy(destSpCellCfg->servCellRecfg.ulBwpToAddOrModList, srcSpCellCfg->servCellCfg.ulBwpToAddList,\
264 (sizeof(SchUlBwpInfo) * srcSpCellCfg->servCellCfg.numUlBwpToAdd));
266 destSpCellCfg->servCellRecfg.firstActvUlBwpId = srcSpCellCfg->servCellCfg.firstActvUlBwpId;
270 /*******************************************************************
272 * @brief Function to fill SchUeCb From UeCfg Req
276 * Function : fillSchUeCbFrmCfgReq
278 * Functionality: Function to fill SchUeCb
280 * @params[in] Scheduler instance,
283 * @return ROK/RFAILED
285 * ****************************************************************/
287 uint8_t fillSchUeCbFrmCfgReq(Inst inst, SchUeCb *ueCb, SchUeCfgReq *ueCfg)
289 uint8_t lcIdx, ueLcIdx, idx;
290 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
291 SchPdschCfgCmn pdschCfg;
292 SchPucchDlDataToUlAck *dlDataToUlAck;
293 uint8_t retDL = ROK, retUL = ROK;
294 bool isLcIdValid = FALSE;
296 ueCb->ueCfg.cellId = ueCfg->cellId;
297 ueCb->ueCfg.ueId = ueCb->ueId;
298 ueCb->ueCfg.crnti = ueCfg->crnti;
299 if(ueCfg->macCellGrpCfgPres == true)
301 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
302 ueCb->ueCfg.macCellGrpCfgPres = true;
304 if(ueCfg->macCellGrpCfg.drxCfgPresent == true)
306 if(ueCb->ueDrxInfoPres == false)
308 ueCb->ueDrxInfoPres = true;
309 /* intialize the drxUeCb */
310 schInitDrxUeCb(ueCb);
312 /* intialize the Dl drxHarqCb */
313 for(idx =0; idx<ueCb->dlHqEnt.numHqPrcs; idx++)
315 schInitDrxHarqCb(&ueCb->dlHqEnt.procs[idx].dlDrxHarqCb);
317 /* intialize the Ul drxHarqCb */
318 for(idx =0; idx<ueCb->ulHqEnt.numHqPrcs; idx++)
320 schInitDrxHarqCb(&ueCb->ulHqEnt.procs[idx].ulDrxHarqCb);
322 /* convert all the drx configuration recived in ms/subms into number of slots and store into the drxUeCb */
323 schFillDrxUeCb(ueCb->cellCb->numerology, ueCfg->macCellGrpCfg.drxCfg, &ueCb->drxUeCb);
324 /* Calculate the onduration timer and short cycle timer (if shortcycle configuration is present) as soon as we
325 * recived ueCfg request */
326 schAddUeInOndurationList(ueCb->cellCb, ueCb, 0);
331 /* convert all the drx configuration recived in ms/subms into number
332 * of slots and store into the drxUeCb */
333 schFillDrxUeCb(ueCb->cellCb->numerology, ueCfg->macCellGrpCfg.drxCfg, &ueCb->drxUeCb);
335 /* Recalculate/Restart timer based on their presence */
336 schDrxUeReCfgTimer(ueCb->cellCb, ueCb);
342 if(ueCfg->phyCellGrpCfgPres == true)
344 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
345 ueCb->ueCfg.phyCellGrpCfgPres = true;
348 if(ueCfg->spCellCfgPres == true)
350 if(ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
352 if(ueCb->ueCfg.spCellCfgPres && ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
354 for(idx = 0; idx < ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc; idx++)
356 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0 && ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0)
358 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
363 fillSpCellInSchCb(&ueCb->ueCfg.spCellCfg, &ueCfg->spCellCfg);
365 covertFreqDomRsrcMapToIAPIFormat(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc,\
367 memset(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
368 memcpy(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
370 ueCb->ueCfg.spCellCfgPres = true;
371 dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck;
376 BuildK0K1Table(ueCb->cellCb, &ueCb->k0K1InfoTbl, false, pdschCfg,\
377 ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
378 dlDataToUlAck->dlDataToUlAckList);
379 ueCb->k0K1TblPrsnt = true;
380 BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
381 ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
382 NULLP, &ueCb->k2InfoTbl);
383 ueCb->k2TblPrsnt = true;
390 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
391 ueCb->ueCfg.ambrCfg = ueCfg->ambrCfg;
393 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
394 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
395 //Updating SchUlCb and SchDlCb DB in SchUeCb
396 for(lcIdx = 0; lcIdx < ueCfg->numLcsToAdd; lcIdx++)
398 isLcIdValid = FALSE; /*Re-Initializing*/
400 ueLcIdx = ueCfg->schLcCfg[lcIdx].lcId;
401 CHECK_LCID(ueLcIdx, isLcIdValid);
402 if(isLcIdValid == FALSE)
404 DU_LOG("ERROR --> SCH: LCID:%d is not Valid",ueLcIdx);
407 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
408 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
410 /*Checking whether this LC belong to Dedicated S-NSSAI
411 * and Create the Dedicated LC List & Update the Reserve PRB number*/
412 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
414 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
415 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
417 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
419 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
420 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
423 if(retUL == RFAILED || retDL == RFAILED)/*FATAL error*/
425 DU_LOG("\nERROR --> SCH : Failure in updateDedLcInfo");
428 SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo));
429 SCH_FREE(ueCfg->schLcCfg[lcIdx].snssai, sizeof(Snssai));
431 }/* End of outer for loop */
435 /*******************************************************************
437 * @brief Function to fill SchUeCb From UeReconfig Req
441 * Function : fillSchUeCbFrmRecfgReq
443 * Functionality: Function to fill SchUeCb
445 * @params[in] Scheduler instance,
448 * @return ROK/RFAILED
450 * ****************************************************************/
452 uint8_t fillSchUeCbFrmRecfgReq(Inst inst, SchUeCb *ueCb, SchUeRecfgReq *ueRecfg)
454 uint8_t lcIdx, ueLcIdx, idx;
455 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
456 SchPdschCfgCmn pdschCfg;
457 SchPucchDlDataToUlAck *dlDataToUlAck;
458 uint8_t retDL = ROK, retUL = ROK;
459 bool isLcIdValid = FALSE;
462 ueCb->ueCfg.cellId = ueRecfg->cellId;
463 ueCb->ueCfg.crnti = ueRecfg->crnti;
464 GET_UE_ID(ueRecfg->crnti, ueCb->ueCfg.ueId);
465 ueCb->ueCfg.dataTransmissionAction = ueRecfg->dataTransmissionInfo;
466 if(ueRecfg->macCellGrpRecfgPres == true)
468 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueRecfg->macCellGrpRecfg, sizeof(SchMacCellGrpCfg));
469 ueCb->ueCfg.macCellGrpCfgPres = true;
471 if(ueRecfg->macCellGrpRecfg.drxCfgPresent == true)
473 if(ueCb->ueDrxInfoPres == false)
475 ueCb->ueDrxInfoPres = true;
476 /* intialize the drxUeCb */
477 schInitDrxUeCb(ueCb);
479 /* intialize the Dl drxHarqCb */
480 for(idx =0; idx<ueCb->dlHqEnt.numHqPrcs; idx++)
482 schInitDrxHarqCb(&ueCb->dlHqEnt.procs[idx].dlDrxHarqCb);
484 /* intialize the Ul drxHarqCb */
485 for(idx =0; idx<ueCb->ulHqEnt.numHqPrcs; idx++)
487 schInitDrxHarqCb(&ueCb->ulHqEnt.procs[idx].ulDrxHarqCb);
489 /* convert all the drx configuration recived in ms/subms into number of slots and store into the drxUeCb */
490 schFillDrxUeCb(ueCb->cellCb->numerology, ueRecfg->macCellGrpRecfg.drxCfg, &ueCb->drxUeCb);
491 /* Calculate the onduration timer and short cycle timer (if shortcycle configuration is present) as soon as we
492 * recived ueCfg request */
493 schAddUeInOndurationList(ueCb->cellCb, ueCb, 0);
498 /* convert all the drx configuration recived in ms/subms into number
499 * of slots and store into the drxUeCb */
500 schFillDrxUeCb(ueCb->cellCb->numerology, ueRecfg->macCellGrpRecfg.drxCfg, &ueCb->drxUeCb);
502 /* Recalculate/Restart timer based on their presence */
503 schDrxUeReCfgTimer(ueCb->cellCb, ueCb);
510 if(ueRecfg->drxConfigIndicatorRelease == true)
512 if(ueCb->ueDrxInfoPres == true)
514 schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
515 ueCb->ueDrxInfoPres = false;
520 if(ueRecfg->phyCellGrpRecfgPres == true)
522 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueRecfg->phyCellGrpRecfg, sizeof(SchPhyCellGrpCfg));
523 ueCb->ueCfg.phyCellGrpCfgPres = true;
526 if(ueRecfg->spCellRecfgPres == true)
528 if(ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
530 if(ueCb->ueCfg.spCellCfgPres && ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
532 for(idx = 0; idx < ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc; idx++)
534 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0 && ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0)
536 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
541 memcpy(&ueCb->ueCfg.spCellCfg , &ueRecfg->spCellRecfg, sizeof(SchSpCellRecfg));
543 covertFreqDomRsrcMapToIAPIFormat(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc,\
545 memset(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
546 memcpy(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
548 ueCb->ueCfg.spCellCfgPres = true;
549 dlDataToUlAck = ueRecfg->spCellRecfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck;
554 BuildK0K1Table(ueCb->cellCb, &ueCb->k0K1InfoTbl, false, pdschCfg,\
555 ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
556 dlDataToUlAck->dlDataToUlAckList);
557 ueCb->k0K1TblPrsnt = true;
558 BuildK2InfoTable(ueCb->cellCb, ueRecfg->spCellRecfg.servCellRecfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
559 ueRecfg->spCellRecfg.servCellRecfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
560 NULLP, &ueCb->k2InfoTbl);
561 ueCb->k2TblPrsnt = true;
566 if(ueRecfg->ambrRecfg)
568 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
569 ueCb->ueCfg.ambrCfg = ueRecfg->ambrRecfg;
571 memcpy(&ueCb->ueCfg.dlModInfo, &ueRecfg->dlModInfo , sizeof(SchModulationInfo));
572 memcpy(&ueCb->ueCfg.ulModInfo, &ueRecfg->ulModInfo , sizeof(SchModulationInfo));
573 //Updating Num of LC to ADD SchUlCb and SchDlCb DB in SchUeCb
574 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
576 isLcIdValid = FALSE; /*Re-Initializing*/
578 ueLcIdx = ueRecfg->schLcCfgAdd[lcIdx].lcId;
579 CHECK_LCID(ueLcIdx, isLcIdValid);
580 if(isLcIdValid == FALSE)
582 DU_LOG("ERROR --> SCH: LCID:%d is not Valid",ueLcIdx);
585 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueRecfg->schLcCfgAdd[lcIdx]);
586 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueRecfg->schLcCfgAdd[lcIdx]);
588 /*Checking whether this LC belong to Dedicated S-NSSAI
589 * and Create the Dedicated LC List & Update the Reserve PRB number*/
590 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
592 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
593 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
595 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
597 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
598 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
601 if(retUL == RFAILED || retDL == RFAILED)/*FATAL error*/
603 DU_LOG("\nERROR --> SCH : Failure in updateDedLcInfo");
606 SCH_FREE(ueRecfg->schLcCfgAdd[lcIdx].drbQos, sizeof(SchDrbQosInfo));
607 SCH_FREE(ueRecfg->schLcCfgAdd[lcIdx].snssai, sizeof(Snssai));
609 //Updating Num of LC to DEL SchUlCb and SchDlCb DB in SchUeCb
610 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
612 ueLcIdx = ueRecfg->lcIdToDel[lcIdx];
614 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueRecfg->lcIdToDel[lcIdx])
616 /*Delete the LC node from the DL LC List*/
617 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated)
619 /*Remove from HARQ Transmission or retransmission*/
624 SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
625 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
627 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueRecfg->lcIdToDel[lcIdx])
629 /*Delete the LC node from the UL LC List*/
630 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated)
632 /*Remove from HARQ Transmission or retransmission*/
634 else/*Default LC list*/
638 SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
639 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
642 //Updating Num of LC to DEL SchUlCb and SchDlCb DB in SchUeCb
643 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
645 ueLcIdx = ueRecfg->schLcCfgMod[lcIdx].lcId;
647 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueRecfg->schLcCfgMod[lcIdx].lcId)
649 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueRecfg->schLcCfgMod[lcIdx]);
650 /*Updating the RRM reserved pool PRB count*/
651 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
653 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
654 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
658 DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info");
661 }/*End of UL LC Ctxt*/
663 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueRecfg->schLcCfgMod[lcIdx].lcId)
665 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueRecfg->schLcCfgMod[lcIdx]);
666 /*Updating the RRM policy*/
667 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
669 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB), \
670 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
674 DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info");
677 }/*End of DL LC ctxt*/
679 SCH_FREE(ueRecfg->schLcCfgMod[lcIdx].drbQos, sizeof(SchDrbQosInfo));
680 SCH_FREE(ueRecfg->schLcCfgMod[lcIdx].snssai, sizeof(Snssai));
681 }/* End of outer for loop */
685 /*******************************************************************
687 * @brief Function to get SCH Cell Cb
691 * Function : getSchCellCb
693 * Functionality: Function to get SCH Cell Cb
695 * @params[in] event, SchUeCfg pointer
696 * @return schUeCb pointer - success
699 * ****************************************************************/
701 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, uint16_t cellId)
704 SchCellCb *cellCb = NULLP;
706 /* Search of cell cb */
707 for(idx = 0; idx < MAX_NUM_CELL; idx++)
709 cellCb = schCb[inst].cells[idx];
710 if((cellCb != NULLP) && (cellCb->cellId == cellId))
713 if((idx == MAX_NUM_CELL) || (cellCb == NULLP))
715 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", cellId);
719 /* Check if max number of UE configured */
720 if(cellCb->numActvUe > MAX_NUM_UE)
722 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
729 /*******************************************************************
731 * @brief Function to Add Ue Config Request from MAC
735 * Function : SchAddUeConfigReq
737 * Functionality: Function to Add Ue config request from MAC
740 * @return ROK - success
743 * ****************************************************************/
744 uint8_t SchAddUeConfigReq(Pst *pst, SchUeCfgReq *ueCfg)
746 uint8_t lcIdx = 0, ret = ROK, idx = 0;
748 SchCellCb *cellCb = NULLP;
749 SchUeCb *ueCb = NULLP;
751 Inst inst = pst->dstInst - SCH_INST_START;
752 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
756 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at SchAddUeConfigReq()");
759 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
760 cellCb = getSchCellCb(pst->event, inst, ueCfg->cellId);
764 SchSendUeCfgRspToMac(ueCfg, inst, RSP_NOK, &cfgRsp);
767 /* Search if UE already configured */
768 GET_UE_ID(ueCfg->crnti, ueId);
769 ueCb = &cellCb->ueCb[ueId - 1];
771 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
773 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
774 SchSendUeCfgRspToMac(ueCfg, inst, RSP_OK, &cfgRsp);
778 /* Fill received Ue Configuration in UeCb */
779 memset(ueCb, 0, sizeof(SchUeCb));
781 ueCb->crnti = ueCfg->crnti;
782 GET_UE_ID(ueCb->crnti, ueCb->ueId);
783 ueCb->cellCb = cellCb;
784 schUlHqEntInit(cellCb, &cellCb->ueCb[ueCb->ueId-1]);
785 schDlHqEntInit(cellCb, &cellCb->ueCb[ueCb->ueId-1]);
786 SCH_ALLOC(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
787 SCH_ALLOC(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
789 if ( (ueCb->hqDlmap == NULLP) || (ueCb->hqUlmap == NULLP) )
791 DU_LOG("\nINFO --> SCH : Memory Allocation Failed");
794 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
796 SCH_ALLOC(ueCb->hqDlmap[idx], sizeof(SchHqDlMap));
797 SCH_ALLOC(ueCb->hqUlmap[idx], sizeof(SchHqUlMap));
799 if ( (ueCb->hqDlmap[idx] == NULLP) || (ueCb->hqUlmap[idx] == NULLP) )
801 DU_LOG("\nINFO --> SCH : Memory Allocation Failed");
804 cmLListInit(&ueCb->hqDlmap[idx]->hqList);
805 cmLListInit(&ueCb->hqUlmap[idx]->hqList);
807 ret = fillSchUeCbFrmCfgReq(inst, ueCb, ueCfg);
811 /* If UE has initiated RACH and then UE context is created, it means UE is
813 * Else if UE context is created before RACH, this means that UE is being
814 * handed-in from source DU */
815 if(cellCb->raCb[ueCb->ueId-1].tcrnti == ueCb->crnti)
818 SET_ONE_BIT(ueCb->ueId, cellCb->actvUeBitMap);
819 ueCb->state = SCH_UE_STATE_ACTIVE;
823 ueCb->state = SCH_UE_HANDIN_IN_PROGRESS;
826 ueCb->srRcvd = false;
827 ueCb->bsrRcvd = false;
828 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
829 ueCb->bsrInfo[lcIdx].dataVol = 0;
831 SchSendUeCfgRspToMac(ueCfg, inst, RSP_OK, &cfgRsp);
834 cellCb->api->SchAddUeConfigReq(ueCb);
838 /*******************************************************************
840 * @brief Fills PUSCH UL allocation
844 * Function : schFillPuschAlloc
846 * Functionality: fills PUSCH info
848 * @params[in] SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize
849 * @params[in] uint8_t startSymb, uint8_t symbLen, uint16_t startPrb
850 * @params[in] bool isRetx, SchUlHqProcCb *hq
851 * @return ROK - success
854 * ****************************************************************/
855 uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize,
856 uint8_t startSymb, uint8_t symbLen, uint16_t startPrb, bool isRetx, SchUlHqProcCb *hqP)
859 SchCellCb *cellCb = NULLP;
860 SchUlSlotInfo *schUlSlotInfo = NULLP;
861 SchPuschInfo puschInfo;
865 DU_LOG("\nERROR --> SCH: UE CB is empty");
869 cellCb = ueCb->cellCb;
872 DU_LOG("\nERROR --> SCH: CELL CB is empty");
876 tbSize += UL_TX_BUFFER_SIZE; /* 2 bytes header + some buffer */
877 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
878 allocatePrbUl(cellCb, puschTime, startSymb, symbLen, &startPrb, numRb);
882 puschInfo.harqProcId = SCH_HARQ_PROC_ID;
883 puschInfo.fdAlloc.resAllocType = SCH_ALLOC_TYPE_1;
884 puschInfo.fdAlloc.resAlloc.type1.startPrb = startPrb;
885 puschInfo.fdAlloc.resAlloc.type1.numPrb = numRb;
886 puschInfo.tdAlloc.startSymb = startSymb;
887 puschInfo.tdAlloc.numSymb = symbLen;
888 puschInfo.tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
889 puschInfo.tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
890 puschInfo.tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
891 puschInfo.tbInfo.ndi = 1; /* new transmission */
892 puschInfo.tbInfo.rv = 0;
893 puschInfo.tbInfo.tbSize = tbSize;
895 puschInfo.dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
896 puschInfo.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
897 puschInfo.dmrsAddPos = DMRS_ADDITIONAL_POS;
899 hqP->puschResType = puschInfo.fdAlloc.resAllocType;
900 hqP->puschStartPrb = puschInfo.fdAlloc.resAlloc.type1.startPrb;
901 hqP->puschNumPrb = puschInfo.fdAlloc.resAlloc.type1.numPrb;
902 hqP->strtSymbl = puschInfo.tdAlloc.startSymb;
903 hqP->numSymbl = puschInfo.tdAlloc.numSymb;
904 hqP->tbInfo.qamOrder = puschInfo.tbInfo.qamOrder;
905 hqP->tbInfo.iMcs = puschInfo.tbInfo.mcs;
906 hqP->tbInfo.mcsTable = puschInfo.tbInfo.mcsTable;
907 hqP->tbInfo.ndi = puschInfo.tbInfo.ndi;
908 hqP->tbInfo.rv = puschInfo.tbInfo.rv;
909 hqP->tbInfo.rvIdx = 0;
910 hqP->tbInfo.tbSzReq = puschInfo.tbInfo.tbSize;
912 hqP->dmrsMappingType = puschInfo.dmrsMappingType;
913 hqP->nrOfDmrsSymbols = puschInfo.nrOfDmrsSymbols;
914 hqP->dmrsAddPos = puschInfo.dmrsAddPos;
919 puschInfo.harqProcId = hqP->procId;
920 puschInfo.fdAlloc.resAllocType = hqP->puschResType;
921 puschInfo.fdAlloc.resAlloc.type1.startPrb = hqP->puschStartPrb;
922 puschInfo.fdAlloc.resAlloc.type1.numPrb = hqP->puschNumPrb;
923 puschInfo.tdAlloc.startSymb = hqP->strtSymbl;
924 puschInfo.tdAlloc.numSymb = hqP->numSymbl;
925 puschInfo.tbInfo.qamOrder = hqP->tbInfo.qamOrder;
926 puschInfo.tbInfo.mcs = hqP->tbInfo.iMcs;
927 puschInfo.tbInfo.mcsTable = hqP->tbInfo.mcsTable;
928 puschInfo.tbInfo.ndi = hqP->tbInfo.ndi; /* retransmission */
929 hqP->tbInfo.rvIdx = (hqP->tbInfo.rvIdx +1) & 0x3;
930 puschInfo.tbInfo.rv = schCmnDlRvTbl[hqP->tbInfo.rvIdx];
931 puschInfo.tbInfo.tbSize = hqP->tbInfo.tbSzReq;
933 puschInfo.dmrsMappingType = hqP->dmrsMappingType; /* Setting Type-A */
934 puschInfo.nrOfDmrsSymbols = hqP->nrOfDmrsSymbols;
935 puschInfo.dmrsAddPos = hqP->dmrsAddPos;
938 schUlSlotInfo = cellCb->schUlSlotInfo[puschTime.slot];
939 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
940 if(!schUlSlotInfo->schPuschInfo)
942 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
945 memcpy(schUlSlotInfo->schPuschInfo, &puschInfo, sizeof(SchPuschInfo));
949 /*******************************************************************
951 * @brief Fills UL DCI information for MSG3 retransmission
955 * Function : schFillUlDciForMsg3Retx
957 * Functionality: fills UL DCI information for MSG3 retransmission
960 * @return ROK - success
963 * ****************************************************************/
964 uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo *dciInfo)
966 SchCellCb *cellCb = raCb->cell;
968 dciInfo->crnti = raCb->tcrnti;
969 SchUlHqProcCb *msg3HqProc = &raCb->msg3HqProc;
970 if (msg3HqProc == NULLP)
976 dciInfo->bwpCfg.subcarrierSpacing = cellCb->sib1SchCfg.bwp.subcarrierSpacing;
977 dciInfo->bwpCfg.cyclicPrefix = cellCb->sib1SchCfg.bwp.cyclicPrefix;
978 dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb;
979 dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb;
981 /*fill coreset cfg */
982 //Considering number of RBs in coreset1 is same as coreset0
983 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
984 //Considering coreset1 also starts from same symbol as coreset0
985 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
986 dciInfo->coresetCfg.durationSymbols = coresetIdxTable[0][2];
987 memcpy(dciInfo->coresetCfg.freqDomainResource, cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
989 dciInfo->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
990 dciInfo->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */
991 dciInfo->coresetCfg.interleaverSize = 2; /* spec-38.211 sec 7.3.2.2 */
992 dciInfo->coresetCfg.coreSetType = 0;
993 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
994 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
995 dciInfo->coresetCfg.precoderGranularity = 0;
996 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
997 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
999 dciInfo->dciFormatInfo.formatType = FORMAT0_0;
1000 msg3HqProc->tbInfo.rvIdx++;
1001 msg3HqProc->tbInfo.rv = schCmnDlRvTbl[msg3HqProc->tbInfo.rvIdx & 0x03];
1003 dciInfo->dciFormatInfo.format.format0_0.resourceAllocType = msg3HqProc->puschResType;
1004 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAllocType = msg3HqProc->puschResType;
1005 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb = msg3HqProc->puschStartPrb;
1006 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb = msg3HqProc->puschNumPrb;
1007 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.startSymb = msg3HqProc->strtSymbl;
1008 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.numSymb = msg3HqProc->numSymbl;
1009 dciInfo->dciFormatInfo.format.format0_0.rowIndex = 0; /* row Index */
1010 dciInfo->dciFormatInfo.format.format0_0.mcs = msg3HqProc->tbInfo.iMcs;
1011 dciInfo->dciFormatInfo.format.format0_0.harqProcId = msg3HqProc->procId;
1012 dciInfo->dciFormatInfo.format.format0_0.freqHopFlag = FALSE; /* disabled */
1013 dciInfo->dciFormatInfo.format.format0_0.ndi = msg3HqProc->tbInfo.ndi; /* new transmission */
1014 dciInfo->dciFormatInfo.format.format0_0.rvIndex = msg3HqProc->tbInfo.rv;
1015 dciInfo->dciFormatInfo.format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
1016 dciInfo->dciFormatInfo.format.format0_0.sulIndicator = FALSE; /* SUL not configured */
1018 /* Fill DCI Structure */
1019 dciInfo->dciInfo.rnti = raCb->tcrnti;
1020 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
1021 dciInfo->dciInfo.scramblingRnti = 0;
1022 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
1023 dciInfo->dciInfo.aggregLevel = 4;
1024 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
1025 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
1026 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
1027 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
1028 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
1029 dciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0 = 0;
1030 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
1031 memset(&dciInfo->dciInfo.pdschCfg, 0, sizeof(PdschCfg));
1032 msg3HqProc->tbInfo.txCntr++;
1034 puschInfo->harqProcId = msg3HqProc->procId;
1035 puschInfo->fdAlloc.resAllocType = msg3HqProc->puschResType;
1036 puschInfo->fdAlloc.resAlloc.type1.startPrb = msg3HqProc->puschStartPrb;
1037 puschInfo->fdAlloc.resAlloc.type1.numPrb = msg3HqProc->puschNumPrb;
1038 puschInfo->tdAlloc.startSymb = msg3HqProc->strtSymbl;
1039 puschInfo->tdAlloc.numSymb = msg3HqProc->numSymbl;
1040 puschInfo->tbInfo.qamOrder = msg3HqProc->tbInfo.qamOrder;
1041 puschInfo->tbInfo.mcs = msg3HqProc->tbInfo.iMcs;
1042 puschInfo->tbInfo.mcsTable = msg3HqProc->tbInfo.mcsTable;
1043 puschInfo->tbInfo.ndi = msg3HqProc->tbInfo.ndi; /* retransmission */
1044 puschInfo->tbInfo.rv = msg3HqProc->tbInfo.rvIdx;
1045 puschInfo->tbInfo.tbSize = msg3HqProc->tbInfo.tbSzReq;
1047 puschInfo->dmrsMappingType = msg3HqProc->dmrsMappingType; /* Setting Type-A */
1048 puschInfo->nrOfDmrsSymbols = msg3HqProc->nrOfDmrsSymbols;
1049 puschInfo->dmrsAddPos = msg3HqProc->dmrsAddPos;
1054 /*******************************************************************
1056 * @brief Fills DCI for UL grant
1060 * Function : schFillUlDci
1062 * Functionality: fills DCI for UL grant in response to BSR
1064 * @params[in] SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo,
1065 * @params[in] bool isRetx, SchUlHqProcCb *hqP
1066 * @return ROK - success
1069 * ****************************************************************/
1070 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, bool isRetx, SchUlHqProcCb *hqP)
1072 SchCellCb *cellCb = ueCb->cellCb;
1073 SchControlRsrcSet coreset1 ;
1075 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
1076 if(ueCb->ueCfg.spCellCfgPres == true)
1078 coreset1 = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
1081 dciInfo->crnti = ueCb->crnti;
1084 dciInfo->bwpCfg.subcarrierSpacing = cellCb->sib1SchCfg.bwp.subcarrierSpacing;
1085 dciInfo->bwpCfg.cyclicPrefix = cellCb->sib1SchCfg.bwp.cyclicPrefix;
1086 dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb;
1087 dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb;
1089 /*fill coreset cfg */
1090 //Considering number of RBs in coreset1 is same as coreset0
1091 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
1092 //Considering coreset1 also starts from same symbol as coreset0
1093 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
1094 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
1095 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1097 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
1098 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
1099 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
1100 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
1101 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
1102 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
1103 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
1104 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
1106 dciInfo->dciFormatInfo.formatType = FORMAT0_0;
1109 dciInfo->dciFormatInfo.format.format0_0.resourceAllocType = puschInfo->fdAlloc.resAllocType;
1110 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAllocType = puschInfo->fdAlloc.resAllocType;
1111 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb = \
1112 puschInfo->fdAlloc.resAlloc.type1.startPrb;
1113 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb = \
1114 puschInfo->fdAlloc.resAlloc.type1.numPrb;
1115 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.startSymb = puschInfo->tdAlloc.startSymb;
1116 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.numSymb = puschInfo->tdAlloc.numSymb;
1117 dciInfo->dciFormatInfo.format.format0_0.rowIndex = 0; /* row Index */
1118 dciInfo->dciFormatInfo.format.format0_0.mcs = puschInfo->tbInfo.mcs;
1119 dciInfo->dciFormatInfo.format.format0_0.harqProcId = puschInfo->harqProcId;
1120 dciInfo->dciFormatInfo.format.format0_0.freqHopFlag = FALSE; /* disabled */
1121 dciInfo->dciFormatInfo.format.format0_0.ndi = puschInfo->tbInfo.ndi; /* new transmission */
1122 dciInfo->dciFormatInfo.format.format0_0.rvIndex = puschInfo->tbInfo.rv;
1123 dciInfo->dciFormatInfo.format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
1124 dciInfo->dciFormatInfo.format.format0_0.sulIndicator = FALSE; /* SUL not configured */
1126 /* Fill DCI Structure */
1127 dciInfo->dciInfo.rnti = ueCb->crnti;
1128 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
1129 dciInfo->dciInfo.scramblingRnti = 0;
1130 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
1131 dciInfo->dciInfo.aggregLevel = 4;
1132 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
1133 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
1134 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
1135 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
1136 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
1137 dciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0 = 0;
1138 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
1139 memset(&dciInfo->dciInfo.pdschCfg, 0, sizeof(PdschCfg));
1144 /*******************************************************************
1146 * @brief Function to Modify Ue Config request from MAC
1150 * Function : SchModUeConfigReq
1152 * Functionality: Function to modify Ue Config request from MAC
1155 * @return ROK - success
1158 * ****************************************************************/
1159 uint8_t SchModUeConfigReq(Pst *pst, SchUeRecfgReq *ueRecfg)
1161 uint8_t ueId, lcIdx, ret = ROK;
1162 SchCellCb *cellCb = NULLP;
1163 SchUeCb *ueCb = NULLP;
1164 SchUeRecfgRsp recfgRsp;
1165 Inst inst = pst->dstInst - SCH_INST_START;
1166 memset(&recfgRsp, 0, sizeof(SchUeRecfgRsp));
1170 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at SchModUeConfigReq()");
1173 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueRecfg->crnti);
1174 cellCb = getSchCellCb(pst->event, inst, ueRecfg->cellId);
1178 SchSendUeRecfgRspToMac(ueRecfg, inst, RSP_NOK, &recfgRsp);
1182 /* Search if UE already configured */
1183 GET_UE_ID(ueRecfg->crnti, ueId);
1184 ueCb = &cellCb->ueCb[ueId -1];
1188 DU_LOG("\nERROR --> SCH : SchUeCb not found at SchModUeConfigReq() ");
1189 SchSendUeRecfgRspToMac(ueRecfg, inst, RSP_NOK, &recfgRsp);
1192 if((ueCb->crnti == ueRecfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
1194 /* Found the UeCb to Reconfig */
1195 ret = fillSchUeCbFrmRecfgReq(inst, ueCb, ueRecfg);
1198 ueCb->cellCb = cellCb;
1199 ueCb->srRcvd = false;
1200 ueCb->bsrRcvd = false;
1201 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
1202 ueCb->bsrInfo[lcIdx].dataVol = 0;
1204 SchSendUeRecfgRspToMac(ueRecfg, inst, RSP_OK, &recfgRsp);
1211 /*******************************************************************
1213 * @brief Function to delete Sch Pucch ResrcCfg
1217 * Function : deleteSchPucchResrcCfg
1219 * Functionality: Function to delete Sch Pucch ResrcCfg
1221 * @params[in] SchPucchResrcCfg *resrc
1224 * ****************************************************************/
1226 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
1229 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
1231 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
1233 case PUCCH_FORMAT_0:
1235 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
1236 sizeof(SchPucchFormat0));
1239 case PUCCH_FORMAT_1:
1241 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
1242 sizeof(SchPucchFormat1));
1245 case PUCCH_FORMAT_2:
1247 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
1248 sizeof(SchPucchFormat2_3));
1251 case PUCCH_FORMAT_3:
1253 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
1254 sizeof(SchPucchFormat2_3));
1257 case PUCCH_FORMAT_4:
1259 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
1260 sizeof(SchPucchFormat4));
1267 /*******************************************************************
1269 * @brief Function to delete SCH Pdsch ServCellCfg
1273 * Function : deleteSchPdschServCellCfg
1275 * Functionality: Function to delete SCH Pdsch ServCellCfg
1277 * @params[in] SchPdschServCellCfg *pdschServCellCfg
1280 * ****************************************************************/
1282 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
1284 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
1285 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
1286 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
1287 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
1290 /*******************************************************************
1292 * @brief Function to delete SCH UeCb
1296 * Function : deleteSchUeCb
1298 * Functionality: Function to delete SCH UeCb
1301 * @return ROK - success
1304 * ****************************************************************/
1305 void deleteSchUeCb(SchUeCb *ueCb)
1307 uint8_t timeDomRsrcIdx = 0, ueLcIdx = 0, idx =0;
1308 SchPucchCfg *pucchCfg = NULLP;
1309 SchPdschConfig *pdschCfg = NULLP;
1315 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
1317 if(ueCb->hqDlmap[idx])
1319 cmLListDeleteLList(&ueCb->hqDlmap[idx]->hqList);
1320 SCH_FREE(ueCb->hqDlmap[idx], sizeof(SchHqDlMap));
1323 SCH_FREE(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
1328 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
1330 if(ueCb->hqUlmap[idx])
1332 cmLListDeleteLList(&ueCb->hqUlmap[idx]->hqList);
1333 SCH_FREE(ueCb->hqUlmap[idx], sizeof(SchHqUlMap));
1336 SCH_FREE(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
1339 schDlHqEntDelete(ueCb);
1340 schUlHqEntDelete(ueCb);
1342 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
1343 if(ueCb->ueCfg.spCellCfgPres)
1345 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
1347 pdschCfg = &ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg;
1348 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
1349 SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
1352 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfgPres == true)
1354 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg;
1355 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
1358 deleteSchPucchResrcCfg(pucchCfg->resrc);
1359 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
1361 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
1362 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
1363 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
1364 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
1365 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
1366 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1367 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1368 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1369 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
1371 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.bwpInactivityTmr, sizeof(uint8_t));
1372 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellRecfg.pdschServCellCfg);
1374 /*Need to Free the memory allocated for S-NSSAI*/
1375 for(ueLcIdx = 0; ueLcIdx < MAX_NUM_LC; ueLcIdx++)
1377 SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
1378 SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
1381 if(ueCb->ueDrxInfoPres)
1383 /* Removing all the calculated drx configuration timer list */
1384 schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
1385 ueCb->ueDrxInfoPres = false;
1388 memset(ueCb, 0, sizeof(SchUeCb));
1392 /*******************************************************************
1394 * @brief Fill and send UE delete response to MAC
1398 * Function : SchSendUeDeleteRspToMac
1400 * Functionality: Fill and send UE delete response to MAC
1402 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
1403 * CauseOfResult cause
1404 * @return ROK - success
1407 * ****************************************************************/
1408 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, CauseOfResult cause)
1411 SchUeDeleteRsp delRsp;
1413 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
1414 delRsp.cellId = ueDelete->cellId;
1415 delRsp.crnti = ueDelete->crnti;
1416 delRsp.rsp = result;
1417 delRsp.cause = cause;
1419 /* Filling response post */
1420 memset(&rspPst, 0, sizeof(Pst));
1421 FILL_PST_SCH_TO_MAC(rspPst, inst);
1422 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
1423 MacMessageRouter(&rspPst, (void *)&delRsp);
1426 /*******************************************************************
1428 * @brief Function for Ue Delete request from MAC to SCH
1432 * Function : SchProcUeDeleteReq
1434 * Functionality: Function for Ue Delete request from MAC to SCH
1436 * @params[in] Pst *pst, SchUeDelete *ueDelete
1437 * @return ROK - success
1440 * ****************************************************************/
1441 uint8_t SchProcUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
1443 uint8_t idx=0, ueId=0, ret=ROK;
1444 CauseOfResult cause;
1445 SchCellCb *cellCb = NULLP;
1446 Inst inst = pst->dstInst - SCH_INST_START;
1450 DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): Ue Delete request failed");
1453 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
1455 cellCb = schCb[inst].cells[idx];
1457 if(cellCb->cellId != ueDelete->cellId)
1459 DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): cell Id is not available");
1460 cause = CELLID_INVALID;
1464 GET_UE_ID(ueDelete->crnti, ueId);
1465 if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE))
1467 /* Remove UE from ueToBeScheduled list */
1468 cellCb->api->SchUeDeleteReq(&cellCb->ueCb[ueId-1]);
1469 deleteSchUeCb(&cellCb->ueCb[ueId-1]);
1470 cellCb->numActvUe--;
1475 DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): SchUeCb not found");
1476 cause = UEID_INVALID;
1480 if(cause == SUCCESSFUL)
1482 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, cause);
1486 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, cause);
1492 /*******************************************************************
1494 * @brief Function updates DL HARQ Feedback
1498 * Function : schUpdateHarqFdbk
1500 * Functionality: Function updates DL HARQ feedback
1502 * @params[in] SchUeCb *ueCb, UE cb struct pointer
1503 * @params[in] uint8_t numHarq, number of HARQ processes in feedback
1504 * @params[in] uint8_t *harqPayload, harq feedback payload received
1505 * @params[in] SlotTimingInfo *slotInd, slot timing information
1508 * ****************************************************************/
1509 void schUpdateHarqFdbk(SchUeCb *ueCb, uint8_t numHarq, uint8_t *harqPayload, SlotTimingInfo *slotInd)
1512 SchHqDlMap *hqDlMap;
1514 uint8_t fdbkPos = 0;
1516 hqDlMap = ueCb->hqDlmap[slotInd->slot];
1518 if (ueCb->cellCb->raCb[ueCb->ueId-1].raState == SCH_RA_STATE_MSG2_HANDLE)
1522 if (ueCb->cellCb->raCb[ueCb->ueId-1].raState != SCH_RA_STATE_MSG4_PENDING)
1524 node = hqDlMap->hqList.first;
1527 hqP = (SchDlHqProcCb*)node->node;
1529 cmLListDelFrm(&hqDlMap->hqList, &hqP->ulSlotLnk);
1531 Decode harq feedback if needed post FAPI message decoding also or check how to decode this FAPI msg.
1532 case 1 semi static harq Ack/Nack codebook //Supported
1533 case 2 dynamic harq ACK/NACK codebook //Not supported
1535 schDlHqFeedbackUpdate(hqP, harqPayload[fdbkPos++], HQ_TB_ACKED);//Marking 2nd TB as ACKED for now as only one TB to be used
1540 node = hqDlMap->hqList.first;
1541 hqP = (SchDlHqProcCb*)node->node;
1542 cmLListDelFrm(&hqDlMap->hqList, &hqP->ulSlotLnk);
1543 schMsg4FeedbackUpdate(hqP, harqPayload[fdbkPos++]);
1546 /**********************************************************************
1548 **********************************************************************/