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 SchPdschCfgCmn pdschCfg;
291 SchPucchDlDataToUlAck *dlDataToUlAck;
292 uint8_t retDL = ROK, retUL = ROK;
293 bool isLcIdValid = FALSE;
295 ueCb->ueCfg.cellId = ueCfg->cellId;
296 ueCb->ueCfg.ueId = ueCb->ueId;
297 ueCb->ueCfg.crnti = ueCfg->crnti;
298 if(ueCfg->macCellGrpCfgPres == true)
300 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
301 ueCb->ueCfg.macCellGrpCfgPres = true;
303 if(ueCfg->macCellGrpCfg.drxCfgPresent == true)
305 if(ueCb->ueDrxInfoPres == false)
307 ueCb->ueDrxInfoPres = true;
308 /* intialize the drxUeCb */
309 schInitDrxUeCb(ueCb);
311 /* intialize the Dl drxHarqCb */
312 for(idx =0; idx<ueCb->dlHqEnt.numHqPrcs; idx++)
314 schInitDrxHarqCb(&ueCb->dlHqEnt.procs[idx].dlDrxHarqCb);
316 /* intialize the Ul drxHarqCb */
317 for(idx =0; idx<ueCb->ulHqEnt.numHqPrcs; idx++)
319 schInitDrxHarqCb(&ueCb->ulHqEnt.procs[idx].ulDrxHarqCb);
321 /* convert all the drx configuration recived in ms/subms into number of slots and store into the drxUeCb */
322 schFillDrxUeCb(ueCb->cellCb->numerology, ueCfg->macCellGrpCfg.drxCfg, &ueCb->drxUeCb);
323 /* Calculate the onduration timer and short cycle timer (if shortcycle configuration is present) as soon as we
324 * recived ueCfg request */
325 schAddUeInOndurationList(ueCb->cellCb, ueCb, 0);
330 /* convert all the drx configuration recived in ms/subms into number
331 * of slots and store into the drxUeCb */
332 schFillDrxUeCb(ueCb->cellCb->numerology, ueCfg->macCellGrpCfg.drxCfg, &ueCb->drxUeCb);
334 /* Recalculate/Restart timer based on their presence */
335 schDrxUeReCfgTimer(ueCb->cellCb, ueCb);
341 if(ueCfg->phyCellGrpCfgPres == true)
343 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
344 ueCb->ueCfg.phyCellGrpCfgPres = true;
347 if(ueCfg->spCellCfgPres == true)
349 if(ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
351 if(ueCb->ueCfg.spCellCfgPres && ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
353 for(idx = 0; idx < ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc; idx++)
355 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0 && ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0)
357 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
362 fillSpCellInSchCb(&ueCb->ueCfg.spCellCfg, &ueCfg->spCellCfg);
364 ueCb->ueCfg.spCellCfgPres = true;
365 dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck;
370 BuildK0K1Table(ueCb->cellCb, &ueCb->k0K1InfoTbl, false, pdschCfg,\
371 ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
372 dlDataToUlAck->dlDataToUlAckList);
373 ueCb->k0K1TblPrsnt = true;
374 BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
375 ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
376 NULLP, &ueCb->k2InfoTbl);
377 ueCb->k2TblPrsnt = true;
384 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
385 ueCb->ueCfg.ambrCfg = ueCfg->ambrCfg;
387 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
388 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
389 //Updating SchUlCb and SchDlCb DB in SchUeCb
390 for(lcIdx = 0; lcIdx < ueCfg->numLcsToAdd; lcIdx++)
392 isLcIdValid = FALSE; /*Re-Initializing*/
394 ueLcIdx = ueCfg->schLcCfg[lcIdx].lcId;
395 CHECK_LCID(ueLcIdx, isLcIdValid);
396 if(isLcIdValid == FALSE)
398 DU_LOG("ERROR --> SCH: LCID:%d is not Valid",ueLcIdx);
401 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
402 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
404 /*Checking whether this LC belong to Dedicated S-NSSAI
405 * and Create the Dedicated LC List & Update the Reserve PRB number*/
406 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
408 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
409 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
411 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
413 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
414 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
417 if(retUL == RFAILED || retDL == RFAILED)/*FATAL error*/
419 DU_LOG("\nERROR --> SCH : Failure in updateDedLcInfo");
422 SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo));
423 SCH_FREE(ueCfg->schLcCfg[lcIdx].snssai, sizeof(Snssai));
425 }/* End of outer for loop */
429 /*******************************************************************
431 * @brief Function to fill SchUeCb From UeReconfig Req
435 * Function : fillSchUeCbFrmRecfgReq
437 * Functionality: Function to fill SchUeCb
439 * @params[in] Scheduler instance,
442 * @return ROK/RFAILED
444 * ****************************************************************/
446 uint8_t fillSchUeCbFrmRecfgReq(Inst inst, SchUeCb *ueCb, SchUeRecfgReq *ueRecfg)
448 uint8_t lcIdx, ueLcIdx, idx;
449 SchPdschCfgCmn pdschCfg;
450 SchPucchDlDataToUlAck *dlDataToUlAck;
451 uint8_t retDL = ROK, retUL = ROK;
452 bool isLcIdValid = FALSE;
455 ueCb->ueCfg.cellId = ueRecfg->cellId;
456 ueCb->ueCfg.crnti = ueRecfg->crnti;
457 GET_UE_ID(ueRecfg->crnti, ueCb->ueCfg.ueId);
458 ueCb->ueCfg.dataTransmissionAction = ueRecfg->dataTransmissionInfo;
459 if(ueRecfg->macCellGrpRecfgPres == true)
461 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueRecfg->macCellGrpRecfg, sizeof(SchMacCellGrpCfg));
462 ueCb->ueCfg.macCellGrpCfgPres = true;
464 if(ueRecfg->macCellGrpRecfg.drxCfgPresent == true)
466 if(ueCb->ueDrxInfoPres == false)
468 ueCb->ueDrxInfoPres = true;
469 /* intialize the drxUeCb */
470 schInitDrxUeCb(ueCb);
472 /* intialize the Dl drxHarqCb */
473 for(idx =0; idx<ueCb->dlHqEnt.numHqPrcs; idx++)
475 schInitDrxHarqCb(&ueCb->dlHqEnt.procs[idx].dlDrxHarqCb);
477 /* intialize the Ul drxHarqCb */
478 for(idx =0; idx<ueCb->ulHqEnt.numHqPrcs; idx++)
480 schInitDrxHarqCb(&ueCb->ulHqEnt.procs[idx].ulDrxHarqCb);
482 /* convert all the drx configuration recived in ms/subms into number of slots and store into the drxUeCb */
483 schFillDrxUeCb(ueCb->cellCb->numerology, ueRecfg->macCellGrpRecfg.drxCfg, &ueCb->drxUeCb);
484 /* Calculate the onduration timer and short cycle timer (if shortcycle configuration is present) as soon as we
485 * recived ueCfg request */
486 schAddUeInOndurationList(ueCb->cellCb, ueCb, 0);
491 /* convert all the drx configuration recived in ms/subms into number
492 * of slots and store into the drxUeCb */
493 schFillDrxUeCb(ueCb->cellCb->numerology, ueRecfg->macCellGrpRecfg.drxCfg, &ueCb->drxUeCb);
495 /* Recalculate/Restart timer based on their presence */
496 schDrxUeReCfgTimer(ueCb->cellCb, ueCb);
503 if(ueRecfg->drxConfigIndicatorRelease == true)
505 if(ueCb->ueDrxInfoPres == true)
507 schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
508 ueCb->ueDrxInfoPres = false;
513 if(ueRecfg->phyCellGrpRecfgPres == true)
515 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueRecfg->phyCellGrpRecfg, sizeof(SchPhyCellGrpCfg));
516 ueCb->ueCfg.phyCellGrpCfgPres = true;
519 if(ueRecfg->spCellRecfgPres == true)
521 if(ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
523 if(ueCb->ueCfg.spCellCfgPres && ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
525 for(idx = 0; idx < ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc; idx++)
527 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0 && ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0)
529 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
534 memcpy(&ueCb->ueCfg.spCellCfg , &ueRecfg->spCellRecfg, sizeof(SchSpCellRecfg));
536 ueCb->ueCfg.spCellCfgPres = true;
537 dlDataToUlAck = ueRecfg->spCellRecfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck;
542 BuildK0K1Table(ueCb->cellCb, &ueCb->k0K1InfoTbl, false, pdschCfg,\
543 ueRecfg->spCellRecfg.servCellRecfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
544 dlDataToUlAck->dlDataToUlAckList);
545 ueCb->k0K1TblPrsnt = true;
546 BuildK2InfoTable(ueCb->cellCb, ueRecfg->spCellRecfg.servCellRecfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
547 ueRecfg->spCellRecfg.servCellRecfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
548 NULLP, &ueCb->k2InfoTbl);
549 ueCb->k2TblPrsnt = true;
554 if(ueRecfg->ambrRecfg)
556 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
557 ueCb->ueCfg.ambrCfg = ueRecfg->ambrRecfg;
559 memcpy(&ueCb->ueCfg.dlModInfo, &ueRecfg->dlModInfo , sizeof(SchModulationInfo));
560 memcpy(&ueCb->ueCfg.ulModInfo, &ueRecfg->ulModInfo , sizeof(SchModulationInfo));
561 //Updating Num of LC to ADD SchUlCb and SchDlCb DB in SchUeCb
562 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
564 isLcIdValid = FALSE; /*Re-Initializing*/
566 ueLcIdx = ueRecfg->schLcCfgAdd[lcIdx].lcId;
567 CHECK_LCID(ueLcIdx, isLcIdValid);
568 if(isLcIdValid == FALSE)
570 DU_LOG("ERROR --> SCH: LCID:%d is not Valid",ueLcIdx);
573 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueRecfg->schLcCfgAdd[lcIdx]);
574 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueRecfg->schLcCfgAdd[lcIdx]);
576 /*Checking whether this LC belong to Dedicated S-NSSAI
577 * and Create the Dedicated LC List & Update the Reserve PRB number*/
578 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
580 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
581 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
583 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
585 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
586 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
589 if(retUL == RFAILED || retDL == RFAILED)/*FATAL error*/
591 DU_LOG("\nERROR --> SCH : Failure in updateDedLcInfo");
594 SCH_FREE(ueRecfg->schLcCfgAdd[lcIdx].drbQos, sizeof(SchDrbQosInfo));
595 SCH_FREE(ueRecfg->schLcCfgAdd[lcIdx].snssai, sizeof(Snssai));
597 //Updating Num of LC to DEL SchUlCb and SchDlCb DB in SchUeCb
598 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
600 ueLcIdx = ueRecfg->lcIdToDel[lcIdx];
602 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueRecfg->lcIdToDel[lcIdx])
604 /*Delete the LC node from the DL LC List*/
605 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated)
607 /*Remove from HARQ Transmission or retransmission*/
612 SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
613 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
615 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueRecfg->lcIdToDel[lcIdx])
617 /*Delete the LC node from the UL LC List*/
618 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated)
620 /*Remove from HARQ Transmission or retransmission*/
622 else/*Default LC list*/
626 SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
627 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
630 //Updating Num of LC to DEL SchUlCb and SchDlCb DB in SchUeCb
631 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
633 ueLcIdx = ueRecfg->schLcCfgMod[lcIdx].lcId;
635 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueRecfg->schLcCfgMod[lcIdx].lcId)
637 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueRecfg->schLcCfgMod[lcIdx]);
638 /*Updating the RRM reserved pool PRB count*/
639 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
641 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
642 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
646 DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info");
649 }/*End of UL LC Ctxt*/
651 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueRecfg->schLcCfgMod[lcIdx].lcId)
653 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueRecfg->schLcCfgMod[lcIdx]);
654 /*Updating the RRM policy*/
655 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
657 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB), \
658 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
662 DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info");
665 }/*End of DL LC ctxt*/
667 SCH_FREE(ueRecfg->schLcCfgMod[lcIdx].drbQos, sizeof(SchDrbQosInfo));
668 SCH_FREE(ueRecfg->schLcCfgMod[lcIdx].snssai, sizeof(Snssai));
669 }/* End of outer for loop */
673 /*******************************************************************
675 * @brief Function to get SCH Cell Cb
679 * Function : getSchCellCb
681 * Functionality: Function to get SCH Cell Cb
683 * @params[in] event, SchUeCfg pointer
684 * @return schUeCb pointer - success
687 * ****************************************************************/
689 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, uint16_t cellId)
692 SchCellCb *cellCb = NULLP;
694 /* Search of cell cb */
695 for(idx = 0; idx < MAX_NUM_CELL; idx++)
697 cellCb = schCb[inst].cells[idx];
698 if((cellCb != NULLP) && (cellCb->cellId == cellId))
701 if((idx == MAX_NUM_CELL) || (cellCb == NULLP))
703 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", cellId);
707 /* Check if max number of UE configured */
708 if(cellCb->numActvUe > MAX_NUM_UE)
710 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
717 /*******************************************************************
719 * @brief Function to Add Ue Config Request from MAC
723 * Function : SchAddUeConfigReq
725 * Functionality: Function to Add Ue config request from MAC
728 * @return ROK - success
731 * ****************************************************************/
732 uint8_t SchAddUeConfigReq(Pst *pst, SchUeCfgReq *ueCfg)
734 uint8_t lcIdx = 0, ret = ROK, idx = 0;
736 SchCellCb *cellCb = NULLP;
737 SchUeCb *ueCb = NULLP;
739 Inst inst = pst->dstInst - SCH_INST_START;
740 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
744 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at SchAddUeConfigReq()");
747 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
748 cellCb = getSchCellCb(pst->event, inst, ueCfg->cellId);
752 SchSendUeCfgRspToMac(ueCfg, inst, RSP_NOK, &cfgRsp);
755 /* Search if UE already configured */
756 GET_UE_ID(ueCfg->crnti, ueId);
757 ueCb = &cellCb->ueCb[ueId - 1];
759 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
761 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
762 SchSendUeCfgRspToMac(ueCfg, inst, RSP_OK, &cfgRsp);
766 /* Fill received Ue Configuration in UeCb */
767 memset(ueCb, 0, sizeof(SchUeCb));
769 ueCb->crnti = ueCfg->crnti;
770 GET_UE_ID(ueCb->crnti, ueCb->ueId);
771 ueCb->cellCb = cellCb;
772 schUlHqEntInit(cellCb, &cellCb->ueCb[ueCb->ueId-1]);
773 schDlHqEntInit(cellCb, &cellCb->ueCb[ueCb->ueId-1]);
774 SCH_ALLOC(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
775 SCH_ALLOC(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
777 if ( (ueCb->hqDlmap == NULLP) || (ueCb->hqUlmap == NULLP) )
779 DU_LOG("\nINFO --> SCH : Memory Allocation Failed");
782 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
784 SCH_ALLOC(ueCb->hqDlmap[idx], sizeof(SchHqDlMap));
785 SCH_ALLOC(ueCb->hqUlmap[idx], sizeof(SchHqUlMap));
787 if ( (ueCb->hqDlmap[idx] == NULLP) || (ueCb->hqUlmap[idx] == NULLP) )
789 DU_LOG("\nINFO --> SCH : Memory Allocation Failed");
792 cmLListInit(&ueCb->hqDlmap[idx]->hqList);
793 cmLListInit(&ueCb->hqUlmap[idx]->hqList);
795 ret = fillSchUeCbFrmCfgReq(inst, ueCb, ueCfg);
797 if(fillUeCoresetAndSsInfo(ueCb) == RFAILED)
799 DU_LOG("\nERROR --> SCH : Memory Allocation Failed");
804 /* If UE has initiated RACH and then UE context is created, it means UE is
806 * Else if UE context is created before RACH, this means that UE is being
807 * handed-in from source DU */
808 if(cellCb->raCb[ueCb->ueId-1].tcrnti == ueCb->crnti)
811 SET_ONE_BIT(ueCb->ueId, cellCb->actvUeBitMap);
812 ueCb->state = SCH_UE_STATE_ACTIVE;
816 ueCb->state = SCH_UE_HANDIN_IN_PROGRESS;
819 ueCb->srRcvd = false;
820 ueCb->bsrRcvd = false;
821 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
822 ueCb->bsrInfo[lcIdx].dataVol = 0;
824 SchSendUeCfgRspToMac(ueCfg, inst, RSP_OK, &cfgRsp);
827 cellCb->api->SchAddUeConfigReq(ueCb);
831 /*******************************************************************
833 * @brief Fills PUSCH UL allocation
837 * Function : schFillPuschAlloc
839 * Functionality: fills PUSCH info
841 * @params[in] SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize
842 * @params[in] uint8_t startSymb, uint8_t symbLen, uint16_t startPrb
843 * @params[in] bool isRetx, SchUlHqProcCb *hq
844 * @return ROK - success
847 * ****************************************************************/
848 uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize,
849 uint8_t startSymb, uint8_t symbLen, uint16_t startPrb, bool isRetx, SchUlHqProcCb *hqP)
852 SchCellCb *cellCb = NULLP;
853 SchUlSlotInfo *schUlSlotInfo = NULLP;
854 SchPuschInfo puschInfo;
858 DU_LOG("\nERROR --> SCH: UE CB is empty");
862 cellCb = ueCb->cellCb;
865 DU_LOG("\nERROR --> SCH: CELL CB is empty");
869 tbSize += UL_TX_BUFFER_SIZE; /* 2 bytes header + some buffer */
870 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
871 allocatePrbUl(cellCb, puschTime, startSymb, symbLen, &startPrb, numRb);
875 puschInfo.harqProcId = SCH_HARQ_PROC_ID;
876 puschInfo.fdAlloc.resAllocType = SCH_ALLOC_TYPE_1;
877 puschInfo.fdAlloc.resAlloc.type1.startPrb = startPrb;
878 puschInfo.fdAlloc.resAlloc.type1.numPrb = numRb;
879 puschInfo.tdAlloc.startSymb = startSymb;
880 puschInfo.tdAlloc.numSymb = symbLen;
881 puschInfo.tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
882 puschInfo.tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
883 puschInfo.tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
884 puschInfo.tbInfo.ndi = 1; /* new transmission */
885 puschInfo.tbInfo.rv = 0;
886 puschInfo.tbInfo.tbSize = tbSize;
888 puschInfo.dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
889 puschInfo.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
890 puschInfo.dmrsAddPos = DMRS_ADDITIONAL_POS;
892 hqP->puschResType = puschInfo.fdAlloc.resAllocType;
893 hqP->puschStartPrb = puschInfo.fdAlloc.resAlloc.type1.startPrb;
894 hqP->puschNumPrb = puschInfo.fdAlloc.resAlloc.type1.numPrb;
895 hqP->strtSymbl = puschInfo.tdAlloc.startSymb;
896 hqP->numSymbl = puschInfo.tdAlloc.numSymb;
897 hqP->tbInfo.qamOrder = puschInfo.tbInfo.qamOrder;
898 hqP->tbInfo.iMcs = puschInfo.tbInfo.mcs;
899 hqP->tbInfo.mcsTable = puschInfo.tbInfo.mcsTable;
900 hqP->tbInfo.ndi = puschInfo.tbInfo.ndi;
901 hqP->tbInfo.rv = puschInfo.tbInfo.rv;
902 hqP->tbInfo.rvIdx = 0;
903 hqP->tbInfo.tbSzReq = puschInfo.tbInfo.tbSize;
905 hqP->dmrsMappingType = puschInfo.dmrsMappingType;
906 hqP->nrOfDmrsSymbols = puschInfo.nrOfDmrsSymbols;
907 hqP->dmrsAddPos = puschInfo.dmrsAddPos;
912 puschInfo.harqProcId = hqP->procId;
913 puschInfo.fdAlloc.resAllocType = hqP->puschResType;
914 puschInfo.fdAlloc.resAlloc.type1.startPrb = hqP->puschStartPrb;
915 puschInfo.fdAlloc.resAlloc.type1.numPrb = hqP->puschNumPrb;
916 puschInfo.tdAlloc.startSymb = hqP->strtSymbl;
917 puschInfo.tdAlloc.numSymb = hqP->numSymbl;
918 puschInfo.tbInfo.qamOrder = hqP->tbInfo.qamOrder;
919 puschInfo.tbInfo.mcs = hqP->tbInfo.iMcs;
920 puschInfo.tbInfo.mcsTable = hqP->tbInfo.mcsTable;
921 puschInfo.tbInfo.ndi = hqP->tbInfo.ndi; /* retransmission */
922 hqP->tbInfo.rvIdx = (hqP->tbInfo.rvIdx +1) & 0x3;
923 puschInfo.tbInfo.rv = schCmnDlRvTbl[hqP->tbInfo.rvIdx];
924 puschInfo.tbInfo.tbSize = hqP->tbInfo.tbSzReq;
926 puschInfo.dmrsMappingType = hqP->dmrsMappingType; /* Setting Type-A */
927 puschInfo.nrOfDmrsSymbols = hqP->nrOfDmrsSymbols;
928 puschInfo.dmrsAddPos = hqP->dmrsAddPos;
931 schUlSlotInfo = cellCb->schUlSlotInfo[puschTime.slot];
932 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
933 if(!schUlSlotInfo->schPuschInfo)
935 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
938 memcpy(schUlSlotInfo->schPuschInfo, &puschInfo, sizeof(SchPuschInfo));
942 /*******************************************************************
944 * @brief Fills UL DCI information for MSG3 retransmission
948 * Function : schFillUlDciForMsg3Retx
950 * Functionality: fills UL DCI information for MSG3 retransmission
953 * @return ROK - success
956 * ****************************************************************/
957 uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo *dciInfo)
959 SchCellCb *cellCb = raCb->cell;
961 dciInfo->crnti = raCb->tcrnti;
962 SchUlHqProcCb *msg3HqProc = &raCb->msg3HqProc;
963 if (msg3HqProc == NULLP)
969 dciInfo->bwpCfg.subcarrierSpacing = cellCb->sib1SchCfg.bwp.subcarrierSpacing;
970 dciInfo->bwpCfg.cyclicPrefix = cellCb->sib1SchCfg.bwp.cyclicPrefix;
971 dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb;
972 dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb;
974 /*fill coreset cfg */
975 //Considering number of RBs in coreset1 is same as coreset0
976 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
977 //Considering coreset1 also starts from same symbol as coreset0
978 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
979 dciInfo->coresetCfg.durationSymbols = coresetIdxTable[0][2];
980 memcpy(dciInfo->coresetCfg.freqDomainResource, cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
982 dciInfo->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
983 dciInfo->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */
984 dciInfo->coresetCfg.interleaverSize = 2; /* spec-38.211 sec 7.3.2.2 */
985 dciInfo->coresetCfg.coreSetType = 0;
986 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
987 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
988 dciInfo->coresetCfg.precoderGranularity = 0;
989 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
990 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
992 dciInfo->dciFormatInfo.formatType = FORMAT0_0;
993 msg3HqProc->tbInfo.rvIdx++;
994 msg3HqProc->tbInfo.rv = schCmnDlRvTbl[msg3HqProc->tbInfo.rvIdx & 0x03];
996 dciInfo->dciFormatInfo.format.format0_0.resourceAllocType = msg3HqProc->puschResType;
997 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAllocType = msg3HqProc->puschResType;
998 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb = msg3HqProc->puschStartPrb;
999 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb = msg3HqProc->puschNumPrb;
1000 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.startSymb = msg3HqProc->strtSymbl;
1001 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.numSymb = msg3HqProc->numSymbl;
1002 dciInfo->dciFormatInfo.format.format0_0.rowIndex = 0; /* row Index */
1003 dciInfo->dciFormatInfo.format.format0_0.mcs = msg3HqProc->tbInfo.iMcs;
1004 dciInfo->dciFormatInfo.format.format0_0.harqProcId = msg3HqProc->procId;
1005 dciInfo->dciFormatInfo.format.format0_0.freqHopFlag = FALSE; /* disabled */
1006 dciInfo->dciFormatInfo.format.format0_0.ndi = msg3HqProc->tbInfo.ndi; /* new transmission */
1007 dciInfo->dciFormatInfo.format.format0_0.rvIndex = msg3HqProc->tbInfo.rv;
1008 dciInfo->dciFormatInfo.format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
1009 dciInfo->dciFormatInfo.format.format0_0.sulIndicator = FALSE; /* SUL not configured */
1011 /* Fill DCI Structure */
1012 dciInfo->dciInfo.rnti = raCb->tcrnti;
1013 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
1014 dciInfo->dciInfo.scramblingRnti = 0;
1015 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
1016 dciInfo->dciInfo.aggregLevel = 4;
1017 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
1018 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
1019 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
1020 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
1021 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
1022 dciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0 = 0;
1023 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
1024 memset(&dciInfo->dciInfo.pdschCfg, 0, sizeof(PdschCfg));
1025 msg3HqProc->tbInfo.txCntr++;
1027 puschInfo->harqProcId = msg3HqProc->procId;
1028 puschInfo->fdAlloc.resAllocType = msg3HqProc->puschResType;
1029 puschInfo->fdAlloc.resAlloc.type1.startPrb = msg3HqProc->puschStartPrb;
1030 puschInfo->fdAlloc.resAlloc.type1.numPrb = msg3HqProc->puschNumPrb;
1031 puschInfo->tdAlloc.startSymb = msg3HqProc->strtSymbl;
1032 puschInfo->tdAlloc.numSymb = msg3HqProc->numSymbl;
1033 puschInfo->tbInfo.qamOrder = msg3HqProc->tbInfo.qamOrder;
1034 puschInfo->tbInfo.mcs = msg3HqProc->tbInfo.iMcs;
1035 puschInfo->tbInfo.mcsTable = msg3HqProc->tbInfo.mcsTable;
1036 puschInfo->tbInfo.ndi = msg3HqProc->tbInfo.ndi; /* retransmission */
1037 puschInfo->tbInfo.rv = msg3HqProc->tbInfo.rvIdx;
1038 puschInfo->tbInfo.tbSize = msg3HqProc->tbInfo.tbSzReq;
1040 puschInfo->dmrsMappingType = msg3HqProc->dmrsMappingType; /* Setting Type-A */
1041 puschInfo->nrOfDmrsSymbols = msg3HqProc->nrOfDmrsSymbols;
1042 puschInfo->dmrsAddPos = msg3HqProc->dmrsAddPos;
1047 /*******************************************************************
1049 * @brief Fills DCI for UL grant
1053 * Function : schFillUlDci
1055 * Functionality: fills DCI for UL grant in response to BSR
1057 * @params[in] SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo,
1058 * @params[in] bool isRetx, SchUlHqProcCb *hqP
1059 * @return ROK - success
1062 * ****************************************************************/
1063 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, bool isRetx, SchUlHqProcCb *hqP)
1065 SchCellCb *cellCb = ueCb->cellCb;
1066 SchControlRsrcSet coreset1 ;
1068 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
1069 if(ueCb->ueCfg.spCellCfgPres == true)
1071 coreset1 = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
1074 dciInfo->crnti = ueCb->crnti;
1077 dciInfo->bwpCfg.subcarrierSpacing = cellCb->sib1SchCfg.bwp.subcarrierSpacing;
1078 dciInfo->bwpCfg.cyclicPrefix = cellCb->sib1SchCfg.bwp.cyclicPrefix;
1079 dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb;
1080 dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb;
1082 /*fill coreset cfg */
1083 //Considering number of RBs in coreset1 is same as coreset0
1084 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
1085 //Considering coreset1 also starts from same symbol as coreset0
1086 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
1087 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
1088 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1090 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
1091 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
1092 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
1093 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
1094 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
1095 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
1096 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
1097 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
1099 dciInfo->dciFormatInfo.formatType = FORMAT0_0;
1102 dciInfo->dciFormatInfo.format.format0_0.resourceAllocType = puschInfo->fdAlloc.resAllocType;
1103 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAllocType = puschInfo->fdAlloc.resAllocType;
1104 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb = \
1105 puschInfo->fdAlloc.resAlloc.type1.startPrb;
1106 dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb = \
1107 puschInfo->fdAlloc.resAlloc.type1.numPrb;
1108 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.startSymb = puschInfo->tdAlloc.startSymb;
1109 dciInfo->dciFormatInfo.format.format0_0.timeAlloc.numSymb = puschInfo->tdAlloc.numSymb;
1110 dciInfo->dciFormatInfo.format.format0_0.rowIndex = 0; /* row Index */
1111 dciInfo->dciFormatInfo.format.format0_0.mcs = puschInfo->tbInfo.mcs;
1112 dciInfo->dciFormatInfo.format.format0_0.harqProcId = puschInfo->harqProcId;
1113 dciInfo->dciFormatInfo.format.format0_0.freqHopFlag = FALSE; /* disabled */
1114 dciInfo->dciFormatInfo.format.format0_0.ndi = puschInfo->tbInfo.ndi; /* new transmission */
1115 dciInfo->dciFormatInfo.format.format0_0.rvIndex = puschInfo->tbInfo.rv;
1116 dciInfo->dciFormatInfo.format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
1117 dciInfo->dciFormatInfo.format.format0_0.sulIndicator = FALSE; /* SUL not configured */
1119 /* Fill DCI Structure */
1120 dciInfo->dciInfo.rnti = ueCb->crnti;
1121 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
1122 dciInfo->dciInfo.scramblingRnti = 0;
1123 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
1124 dciInfo->dciInfo.aggregLevel = 4;
1125 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
1126 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
1127 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
1128 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
1129 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
1130 dciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0 = 0;
1131 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
1132 memset(&dciInfo->dciInfo.pdschCfg, 0, sizeof(PdschCfg));
1137 /*******************************************************************
1139 * @brief Function to Modify Ue Config request from MAC
1143 * Function : SchModUeConfigReq
1145 * Functionality: Function to modify Ue Config request from MAC
1148 * @return ROK - success
1151 * ****************************************************************/
1152 uint8_t SchModUeConfigReq(Pst *pst, SchUeRecfgReq *ueRecfg)
1154 uint8_t ueId, lcIdx, ret = ROK;
1155 SchCellCb *cellCb = NULLP;
1156 SchUeCb *ueCb = NULLP;
1157 SchUeRecfgRsp recfgRsp;
1158 Inst inst = pst->dstInst - SCH_INST_START;
1159 memset(&recfgRsp, 0, sizeof(SchUeRecfgRsp));
1163 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at SchModUeConfigReq()");
1166 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueRecfg->crnti);
1167 cellCb = getSchCellCb(pst->event, inst, ueRecfg->cellId);
1171 SchSendUeRecfgRspToMac(ueRecfg, inst, RSP_NOK, &recfgRsp);
1175 /* Search if UE already configured */
1176 GET_UE_ID(ueRecfg->crnti, ueId);
1177 ueCb = &cellCb->ueCb[ueId -1];
1181 DU_LOG("\nERROR --> SCH : SchUeCb not found at SchModUeConfigReq() ");
1182 SchSendUeRecfgRspToMac(ueRecfg, inst, RSP_NOK, &recfgRsp);
1185 if((ueCb->crnti == ueRecfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
1187 /* Found the UeCb to Reconfig */
1188 ret = fillSchUeCbFrmRecfgReq(inst, ueCb, ueRecfg);
1189 if(fillUeCoresetAndSsInfo(ueCb) == RFAILED)
1191 DU_LOG("\nERROR --> SCH : Memory Allocation Failed");
1196 ueCb->cellCb = cellCb;
1197 ueCb->srRcvd = false;
1198 ueCb->bsrRcvd = false;
1199 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
1200 ueCb->bsrInfo[lcIdx].dataVol = 0;
1202 SchSendUeRecfgRspToMac(ueRecfg, inst, RSP_OK, &recfgRsp);
1209 /*******************************************************************
1211 * @brief Function to delete Sch Pucch ResrcCfg
1215 * Function : deleteSchPucchResrcCfg
1217 * Functionality: Function to delete Sch Pucch ResrcCfg
1219 * @params[in] SchPucchResrcCfg *resrc
1222 * ****************************************************************/
1224 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
1227 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
1229 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
1231 case PUCCH_FORMAT_0:
1233 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
1234 sizeof(SchPucchFormat0));
1237 case PUCCH_FORMAT_1:
1239 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
1240 sizeof(SchPucchFormat1));
1243 case PUCCH_FORMAT_2:
1245 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
1246 sizeof(SchPucchFormat2_3));
1249 case PUCCH_FORMAT_3:
1251 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
1252 sizeof(SchPucchFormat2_3));
1255 case PUCCH_FORMAT_4:
1257 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
1258 sizeof(SchPucchFormat4));
1265 /*******************************************************************
1267 * @brief Function to delete SCH Pdsch ServCellCfg
1271 * Function : deleteSchPdschServCellCfg
1273 * Functionality: Function to delete SCH Pdsch ServCellCfg
1275 * @params[in] SchPdschServCellCfg *pdschServCellCfg
1278 * ****************************************************************/
1280 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
1282 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
1283 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
1284 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
1285 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
1288 /*******************************************************************
1290 * @brief Function to delete SCH UeCb
1294 * Function : deleteSchUeCb
1296 * Functionality: Function to delete SCH UeCb
1299 * @return ROK - success
1302 * ****************************************************************/
1303 void deleteSchUeCb(SchUeCb *ueCb)
1305 uint8_t timeDomRsrcIdx = 0, ueLcIdx = 0, slotIdx =0, cRSetIdx = 0;
1306 SchPucchCfg *pucchCfg = NULLP;
1307 SchPdschConfig *pdschCfg = NULLP;
1313 for (slotIdx = 0; slotIdx<ueCb->cellCb->numSlots; slotIdx++)
1315 if(ueCb->hqDlmap[slotIdx])
1317 cmLListDeleteLList(&ueCb->hqDlmap[slotIdx]->hqList);
1318 SCH_FREE(ueCb->hqDlmap[slotIdx], sizeof(SchHqDlMap));
1321 SCH_FREE(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
1326 for (slotIdx = 0; slotIdx<ueCb->cellCb->numSlots; slotIdx++)
1328 if(ueCb->hqUlmap[slotIdx])
1330 cmLListDeleteLList(&ueCb->hqUlmap[slotIdx]->hqList);
1331 SCH_FREE(ueCb->hqUlmap[slotIdx], sizeof(SchHqUlMap));
1334 SCH_FREE(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
1337 schDlHqEntDelete(ueCb);
1338 schUlHqEntDelete(ueCb);
1340 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
1341 if(ueCb->ueCfg.spCellCfgPres)
1343 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
1345 pdschCfg = &ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg;
1346 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
1347 SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
1350 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfgPres == true)
1352 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg;
1353 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
1356 deleteSchPucchResrcCfg(pucchCfg->resrc);
1357 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
1359 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
1360 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
1361 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
1362 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
1363 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
1364 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1365 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1366 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1367 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
1369 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.bwpInactivityTmr, sizeof(uint8_t));
1370 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellRecfg.pdschServCellCfg);
1372 /*Need to Free the memory allocated for S-NSSAI*/
1373 for(ueLcIdx = 0; ueLcIdx < MAX_NUM_LC; ueLcIdx++)
1375 SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
1376 SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
1379 if(ueCb->ueDrxInfoPres)
1381 /* Removing all the calculated drx configuration timer list */
1382 schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
1383 ueCb->ueDrxInfoPres = false;
1387 for(cRSetIdx=0; cRSetIdx < MAX_NUM_CRSET; cRSetIdx++)
1389 SCH_FREE(ueCb->pdcchInfo[cRSetIdx].y, (sizeof(uint32_t) * ueCb->cellCb->numSlots));
1391 memset(ueCb, 0, sizeof(SchUeCb));
1395 /*******************************************************************
1397 * @brief Fill and send UE delete response to MAC
1401 * Function : SchSendUeDeleteRspToMac
1403 * Functionality: Fill and send UE delete response to MAC
1405 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
1406 * CauseOfResult cause
1407 * @return ROK - success
1410 * ****************************************************************/
1411 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, CauseOfResult cause)
1414 SchUeDeleteRsp delRsp;
1416 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
1417 delRsp.cellId = ueDelete->cellId;
1418 delRsp.crnti = ueDelete->crnti;
1419 delRsp.rsp = result;
1420 delRsp.cause = cause;
1422 /* Filling response post */
1423 memset(&rspPst, 0, sizeof(Pst));
1424 FILL_PST_SCH_TO_MAC(rspPst, inst);
1425 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
1426 MacMessageRouter(&rspPst, (void *)&delRsp);
1429 /*******************************************************************
1431 * @brief Function for Ue Delete request from MAC to SCH
1435 * Function : SchProcUeDeleteReq
1437 * Functionality: Function for Ue Delete request from MAC to SCH
1439 * @params[in] Pst *pst, SchUeDelete *ueDelete
1440 * @return ROK - success
1443 * ****************************************************************/
1444 uint8_t SchProcUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
1446 uint8_t idx=0, ueId=0, ret=ROK;
1447 CauseOfResult cause;
1448 SchCellCb *cellCb = NULLP;
1449 Inst inst = pst->dstInst - SCH_INST_START;
1453 DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): Ue Delete request failed");
1456 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
1458 cellCb = schCb[inst].cells[idx];
1460 if(cellCb->cellId != ueDelete->cellId)
1462 DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): cell Id is not available");
1463 cause = CELLID_INVALID;
1467 GET_UE_ID(ueDelete->crnti, ueId);
1468 if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE))
1470 /* Remove UE from ueToBeScheduled list */
1471 cellCb->api->SchUeDeleteReq(&cellCb->ueCb[ueId-1]);
1472 deleteSchUeCb(&cellCb->ueCb[ueId-1]);
1473 cellCb->numActvUe--;
1478 DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): SchUeCb not found");
1479 cause = UEID_INVALID;
1483 if(cause == SUCCESSFUL)
1485 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, cause);
1489 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, cause);
1495 /*******************************************************************
1497 * @brief Function updates DL HARQ Feedback
1501 * Function : schUpdateHarqFdbk
1503 * Functionality: Function updates DL HARQ feedback
1505 * @params[in] SchUeCb *ueCb, UE cb struct pointer
1506 * @params[in] uint8_t numHarq, number of HARQ processes in feedback
1507 * @params[in] uint8_t *harqPayload, harq feedback payload received
1508 * @params[in] SlotTimingInfo *slotInd, slot timing information
1511 * ****************************************************************/
1512 void schUpdateHarqFdbk(SchUeCb *ueCb, uint8_t numHarq, uint8_t *harqPayload, SlotTimingInfo *slotInd)
1515 SchHqDlMap *hqDlMap;
1517 uint8_t fdbkPos = 0;
1519 hqDlMap = ueCb->hqDlmap[slotInd->slot];
1521 if (ueCb->cellCb->raCb[ueCb->ueId-1].raState == SCH_RA_STATE_MSG2_HANDLE)
1525 if (ueCb->cellCb->raCb[ueCb->ueId-1].raState != SCH_RA_STATE_MSG4_PENDING)
1527 node = hqDlMap->hqList.first;
1530 hqP = (SchDlHqProcCb*)node->node;
1532 cmLListDelFrm(&hqDlMap->hqList, &hqP->ulSlotLnk);
1534 Decode harq feedback if needed post FAPI message decoding also or check how to decode this FAPI msg.
1535 case 1 semi static harq Ack/Nack codebook //Supported
1536 case 2 dynamic harq ACK/NACK codebook //Not supported
1538 schDlHqFeedbackUpdate(hqP, harqPayload[fdbkPos++], HQ_TB_ACKED);//Marking 2nd TB as ACKED for now as only one TB to be used
1543 node = hqDlMap->hqList.first;
1544 hqP = (SchDlHqProcCb*)node->node;
1545 cmLListDelFrm(&hqDlMap->hqList, &hqP->ulSlotLnk);
1546 schMsg4FeedbackUpdate(hqP, harqPayload[fdbkPos++]);
1549 /**********************************************************************
1551 **********************************************************************/