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"
30 #include "sch_utils.h"
36 SchUeCfgRspFunc SchUeCfgRspOpts[] =
38 packSchUeCfgRsp, /* LC */
39 MacProcSchUeCfgRsp, /* TC */
40 packSchUeCfgRsp /* LWLC */
43 SchUeDeleteRspFunc SchUeDeleteRspOpts[] =
45 packSchUeDeleteRsp, /* LC */
46 MacProcSchUeDeleteRsp, /* TC */
47 packSchUeDeleteRsp /* LWLC */
50 SchCellDeleteRspFunc SchCellDeleteRspOpts[]=
52 packSchCellDeleteRsp, /* LC */
53 MacProcSchCellDeleteRsp, /* TC */
54 packSchCellDeleteRsp /* LWLC */
57 /*******************************************************************
59 * @brief Fill and send UE cfg response to MAC
63 * Function : SchSendUeCfgRspToMac
65 * Functionality: Fill and send UE cfg response to MAC
68 * @return ROK - success
71 * ****************************************************************/
72 void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
73 SchMacRsp result, SchUeCfgRsp *cfgRsp)
77 cfgRsp->cellId = ueCfg->cellId;
78 cfgRsp->ueId = ueCfg->ueId;
79 cfgRsp->crnti = ueCfg->crnti;
82 /* Filling response post */
83 memset(&rspPst, 0, sizeof(Pst));
84 FILL_PST_SCH_TO_MAC(rspPst, inst);
85 if(event == EVENT_ADD_UE_CONFIG_REQ_TO_SCH)
87 rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
88 DU_LOG("\nINFO --> SCH : Sending UE Config response to MAC");
90 else if(event == EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH)
92 rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
93 DU_LOG("\nINFO --> SCH : Sending UE Reconfig response to MAC");
95 SchUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
98 /*******************************************************************
101 * @brief Function to fill Dl Lc Context in SCH Ue Cb
105 * Function : fillSchDlLcCtxt
107 * Functionality: Function to fill Dl Lc Context in SCH Ue Cb
109 * @params[in] SchDlLcCtxt pointer,
113 * ****************************************************************/
115 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
117 ueCbLcCfg->lcId = lcCfg->lcId;
118 ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
119 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
123 ueCbLcCfg->pduSessionId = lcCfg->drbQos->pduSessionId;
127 if(ueCbLcCfg->snssai == NULLP)/*In CONFIG_MOD case, no need to allocate SNSSAI memory*/
129 SCH_ALLOC(ueCbLcCfg->snssai, sizeof(Snssai));
131 memcpy(ueCbLcCfg->snssai, lcCfg->snssai,sizeof(Snssai));
135 /*******************************************************************
137 * @brief Function to fill Ul Lc Context in SCH Ue Cb
141 * Function : fillSchUlLcCtxt
143 * Functionality: Function to fill Ul Lc Context in SCH Ue Cb
145 * @params[in] SchUlLcCtxt pointer,
149 * ****************************************************************/
151 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
153 ueCbLcCfg->lcId = lcCfg->lcId;
154 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
155 ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
156 ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
157 ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
158 ueCbLcCfg->pbr = lcCfg->ulLcCfg.pbr;
159 ueCbLcCfg->bsd = lcCfg->ulLcCfg.bsd;
163 ueCbLcCfg->pduSessionId = lcCfg->drbQos->pduSessionId;
167 /*In CONFIG_MOD case, no need to allocate SNSSAI memory again*/
168 if(ueCbLcCfg->snssai == NULLP)
170 SCH_ALLOC(ueCbLcCfg->snssai, sizeof(Snssai));
172 memcpy(ueCbLcCfg->snssai, lcCfg->snssai,sizeof(Snssai));
176 /*******************************************************************
178 * @brief Function to update/allocate dedLC Info
182 * Function : updateDedLcInfo
184 * Functionality: Function to fill DLDedLcInfo
186 * @params[arg] scheduler instance,
188 * SchRrmPolicy pointer,
189 * SchLcPrbEstimate pointer , It will be filled
190 * isDedicated pointer,(Address of isDedicated flag in LC Context)
192 * @return ROK >> This LC is part of RRM MemberList.
193 * RFAILED >> FATAL Error
194 * ROKIGNORE >> This LC is not part of this RRM MemberList
196 * ****************************************************************/
198 uint8_t updateDedLcInfo(Inst inst, Snssai *snssai, uint16_t *rsvdDedicatedPRB, bool *isDedicated)
200 uint8_t sliceCfgIdx =0;
201 SchSliceCfg sliceCfg = schCb[inst].sliceCfg;
203 if(sliceCfg.numOfSliceConfigured)
205 for(sliceCfgIdx = 0; sliceCfgIdx<sliceCfg.numOfSliceConfigured; sliceCfgIdx++)
207 if(memcmp(snssai, &(sliceCfg.listOfConfirguration[sliceCfgIdx]->snssai), sizeof(Snssai)) == 0)
209 if(sliceCfg.listOfConfirguration[sliceCfgIdx]->rrmPolicyRatioInfo)
211 /*Updating latest RrmPolicy*/
212 *rsvdDedicatedPRB = \
213 (uint16_t)(((sliceCfg.listOfConfirguration[sliceCfgIdx]->rrmPolicyRatioInfo->policyDedicatedRatio)*(MAX_NUM_RB))/100);
215 DU_LOG("\nINFO --> SCH : Updated RRM policy, reservedPOOL:%d",*rsvdDedicatedPRB);
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");
228 /*******************************************************************
230 * @brief Function to fill SchUeCb
234 * Function : fillSchUeCb
236 * Functionality: Function to fill SchUeCb
238 * @params[in] Scheduler instance,
241 * @return ROK/RFAILED
243 * ****************************************************************/
245 uint8_t fillSchUeCb(Inst inst, SchUeCb *ueCb, SchUeCfg *ueCfg)
247 uint8_t lcIdx, ueLcIdx, idx;
248 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
249 SchPdschCfgCmn pdschCfg;
250 SchPucchDlDataToUlAck *dlDataToUlAck;
251 uint8_t retDL = ROK, retUL = ROK;
252 bool isLcIdValid = FALSE;
254 ueCb->ueCfg.cellId = ueCfg->cellId;
255 ueCb->ueCfg.ueId = ueCfg->ueId;
256 ueCb->ueCfg.crnti = ueCfg->crnti;
257 ueCb->ueCfg.dataTransmissionAction = ueCfg->dataTransmissionInfo;
258 if(ueCfg->macCellGrpCfgPres == true)
260 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
261 ueCb->ueCfg.macCellGrpCfgPres = true;
263 if(ueCfg->macCellGrpCfg.drxCfgPresent == true)
265 if(ueCb->ueDrxInfoPres == false)
267 ueCb->ueDrxInfoPres = true;
268 /* intialize the drxUeCb */
269 schInitDrxUeCb(ueCb);
271 /* intialize the Dl drxHarqCb */
272 for(idx =0; idx<ueCb->dlHqEnt.numHqPrcs; idx++)
274 schInitDrxHarqCb(&ueCb->dlHqEnt.procs[idx].drxHarqCb);
276 /* intialize the Ul drxHarqCb */
277 for(idx =0; idx<ueCb->ulHqEnt.numHqPrcs; idx++)
279 schInitDrxHarqCb(&ueCb->ulHqEnt.procs[idx].drxHarqCb);
281 /* convert all the drx configuration recived in ms/subms into number of slots and store into the drxUeCb */
282 schFillDrxUeCb(ueCb->cellCb->cellCfg.numerology, ueCfg->macCellGrpCfg.drxCfg, &ueCb->drxUeCb);
283 /* Calculate the onduration timer and short cycle timer (if shortcycle configuration is present) as soon as we
284 * recived ueCfg request */
285 schAddUeInOndurationAndShortCycleList(ueCb->cellCb, ueCb, 0);
290 /* convert all the drx configuration recived in ms/subms into number
291 * of slots and store into the drxUeCb */
292 schFillDrxUeCb(ueCb->cellCb->cellCfg.numerology, ueCfg->macCellGrpCfg.drxCfg, &ueCb->drxUeCb);
294 /* Recalculate/Restart timer based on their presence */
295 schDrxUeReCfgTimer(ueCb->cellCb, ueCb);
302 if(ueCfg->drxConfigIndicatorRelease == true)
304 if(ueCb->ueDrxInfoPres == true)
306 schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
307 ueCb->ueDrxInfoPres = false;
312 if(ueCfg->phyCellGrpCfgPres == true)
314 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
315 ueCb->ueCfg.phyCellGrpCfgPres = true;
318 if(ueCfg->spCellCfgPres == true)
320 if(ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
322 if(ueCb->ueCfg.spCellCfgPres && ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
324 for(idx = 0; idx < ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc; idx++)
326 if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0 && ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0)
328 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
333 memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
335 covertFreqDomRsrcMapToIAPIFormat(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc,\
337 memset(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
338 memcpy(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
340 ueCb->ueCfg.spCellCfgPres = true;
341 dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck;
346 BuildK0K1Table(ueCb->cellCb, &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl, false, pdschCfg,\
347 ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
348 dlDataToUlAck->dlDataToUlAckList);
349 ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1TblPrsnt = true;
350 BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
351 ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
352 NULLP, &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl);
353 ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2TblPrsnt = true;
360 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
361 ueCb->ueCfg.ambrCfg = ueCfg->ambrCfg;
363 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
364 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
365 //Updating SchUlCb and SchDlCb DB in SchUeCb
366 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
368 isLcIdValid = FALSE; /*Re-Initializing*/
370 ueLcIdx = ueCfg->schLcCfg[lcIdx].lcId;
371 CHECK_LCID(ueLcIdx, isLcIdValid);
372 if(isLcIdValid == FALSE)
374 DU_LOG("ERROR --> SCH: LCID:%d is not Valid",ueLcIdx);
377 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
379 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
380 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
382 /*Checking whether this LC belong to Dedicated S-NSSAI
383 * and Create the Dedicated LC List & Update the Reserve PRB number*/
384 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
386 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
387 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
389 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
391 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
392 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
395 if(retUL == RFAILED || retDL == RFAILED)/*FATAL error*/
397 DU_LOG("\nERROR --> SCH : Failure in updateDedLcInfo");
403 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
405 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
407 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
408 /*Updating the RRM reserved pool PRB count*/
409 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
411 retUL = updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].rsvdDedicatedPRB),\
412 &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
416 DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info");
420 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL)
422 /*Delete the LC node from the UL LC List*/
423 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated)
425 /*Remove from HARQ Transmission or retransmission*/
427 else/*Default LC list*/
431 SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
432 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
434 }/*End of UL LC Ctxt*/
436 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
438 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
440 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
441 /*Updating the RRM policy*/
442 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
444 retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].rsvdDedicatedPRB), \
445 &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
449 DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info");
453 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL)
455 /*Delete the LC node from the DL LC List*/
456 if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated)
458 /*Remove from HARQ Transmission or retransmission*/
463 SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
464 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
466 }/*End of DL LC ctxt*/
469 SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo));
470 SCH_FREE(ueCfg->schLcCfg[lcIdx].snssai, sizeof(Snssai));
472 }/* End of outer for loop */
476 /*******************************************************************
478 * @brief Function to get SCH Cell Cb
482 * Function : getSchCellCb
484 * Functionality: Function to get SCH Cell Cb
486 * @params[in] event, SchUeCfg pointer
487 * @return schUeCb pointer - success
490 * ****************************************************************/
492 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
495 SchCellCb *cellCb = NULLP;
497 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
499 /* Search of cell cb */
500 for(idx = 0; idx < MAX_NUM_CELL; idx++)
502 cellCb = schCb[inst].cells[idx];
503 if(cellCb->cellId == ueCfg->cellId)
506 if(idx == MAX_NUM_CELL)
508 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
509 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
513 /* Check if max number of UE configured */
514 if(cellCb->numActvUe > MAX_NUM_UE)
516 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
517 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
524 /*******************************************************************
526 * @brief Function to Add Ue Config Request from MAC
530 * Function : MacSchAddUeConfigReq
532 * Functionality: Function to Add Ue config request from MAC
535 * @return ROK - success
538 * ****************************************************************/
539 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
541 uint8_t lcIdx = 0, ret = ROK, idx = 0;
542 SchCellCb *cellCb = NULLP;
543 SchUeCb *ueCb = NULLP;
545 Inst inst = pst->dstInst - SCH_INST_START;
546 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
548 #ifdef CALL_FLOW_DEBUG_LOG
549 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_ADD_UE_CONFIG_REQ_TO_SCH\n");
554 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
557 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
558 cellCb = getSchCellCb(pst->event, inst, ueCfg);
560 /* Search if UE already configured */
561 ueCb = &cellCb->ueCb[ueCfg->ueId - 1];
563 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
565 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
566 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
570 /* Fill received Ue Configuration in UeCb */
571 memset(ueCb, 0, sizeof(SchUeCb));
573 ueCb->ueId = ueCfg->ueId;
574 ueCb->crnti = ueCfg->crnti;
575 ueCb->cellCb = cellCb;
576 schUlHqEntInit(cellCb, &cellCb->ueCb[ueCfg->ueId-1]);
577 schDlHqEntInit(cellCb, &cellCb->ueCb[ueCfg->ueId-1]);
578 SCH_ALLOC(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
579 SCH_ALLOC(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
581 if ( (ueCb->hqDlmap == NULLP) || (ueCb->hqUlmap == NULLP) )
583 DU_LOG("\nINFO --> SCH : Memory Allocation Failed");
586 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
588 SCH_ALLOC(ueCb->hqDlmap[idx], sizeof(SchHqDlMap));
589 SCH_ALLOC(ueCb->hqUlmap[idx], sizeof(SchHqUlMap));
591 if ( (ueCb->hqDlmap[idx] == NULLP) || (ueCb->hqUlmap[idx] == NULLP) )
593 DU_LOG("\nINFO --> SCH : Memory Allocation Failed");
596 cmLListInit(&ueCb->hqDlmap[idx]->hqList);
597 cmLListInit(&ueCb->hqUlmap[idx]->hqList);
599 ret = fillSchUeCb(inst, ueCb, ueCfg);
603 /* If UE has initiated RACH and then UE context is created, it means UE is
605 * Else if UE context is created before RACH, this means that UE is being
606 * handed-in from source DU */
607 if(cellCb->raCb[ueCb->ueId-1].tcrnti == ueCb->crnti)
610 SET_ONE_BIT(ueCb->ueId, cellCb->actvUeBitMap);
611 ueCb->state = SCH_UE_STATE_ACTIVE;
615 ueCb->state = SCH_UE_HANDIN_IN_PROGRESS;
618 ueCb->srRcvd = false;
619 ueCb->bsrRcvd = false;
620 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
621 ueCb->bsrInfo[lcIdx].dataVol = 0;
623 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
628 /*******************************************************************
630 * @brief Fills PUSCH UL allocation
634 * Function : schFillPuschAlloc
636 * Functionality: fills PUSCH info
638 * @params[in] SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize
639 * @params[in] uint8_t startSymb, uint8_t symbLen, uint16_t startPrb
640 * @params[in] bool isRetx, SchUlHqProcCb *hq
641 * @return ROK - success
644 * ****************************************************************/
645 uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize,
646 uint8_t startSymb, uint8_t symbLen, uint16_t startPrb, bool isRetx, SchUlHqProcCb *hqP)
649 SchCellCb *cellCb = NULLP;
650 SchUlSlotInfo *schUlSlotInfo = NULLP;
651 SchPuschInfo puschInfo;
655 DU_LOG("\nERROR --> SCH: UE CB is empty");
659 cellCb = ueCb->cellCb;
662 DU_LOG("\nERROR --> SCH: CELL CB is empty");
666 tbSize += UL_TX_BUFFER_SIZE; /* 2 bytes header + some buffer */
667 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
668 allocatePrbUl(cellCb, puschTime, startSymb, symbLen, &startPrb, numRb);
672 puschInfo.crnti = ueCb->crnti;
673 puschInfo.harqProcId = SCH_HARQ_PROC_ID;
674 puschInfo.resAllocType = SCH_ALLOC_TYPE_1;
675 puschInfo.fdAlloc.startPrb = startPrb;
676 puschInfo.fdAlloc.numPrb = numRb;
677 puschInfo.tdAlloc.startSymb = startSymb;
678 puschInfo.tdAlloc.numSymb = symbLen;
679 puschInfo.tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
680 puschInfo.tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
681 puschInfo.tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
682 puschInfo.tbInfo.ndi = 1; /* new transmission */
683 puschInfo.tbInfo.rv = 0;
684 puschInfo.tbInfo.tbSize = tbSize;
685 puschInfo.dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
686 puschInfo.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
687 puschInfo.dmrsAddPos = DMRS_ADDITIONAL_POS;
688 hqP->puschResType = puschInfo.resAllocType;
689 hqP->puschStartPrb = puschInfo.fdAlloc.startPrb;
690 hqP->puschNumPrb = puschInfo.fdAlloc.numPrb;
691 hqP->strtSymbl = puschInfo.tdAlloc.startSymb;
692 hqP->numSymbl = puschInfo.tdAlloc.numSymb;
693 hqP->tbInfo.qamOrder = puschInfo.tbInfo.qamOrder;
694 hqP->tbInfo.iMcs = puschInfo.tbInfo.mcs;
695 hqP->tbInfo.mcsTable = puschInfo.tbInfo.mcsTable;
696 hqP->tbInfo.ndi = puschInfo.tbInfo.ndi;
697 hqP->tbInfo.rv = puschInfo.tbInfo.rv;
698 hqP->tbInfo.rvIdx = 0;
699 hqP->tbInfo.tbSzReq = puschInfo.tbInfo.tbSize;
700 hqP->dmrsMappingType = puschInfo.dmrsMappingType;
701 hqP->nrOfDmrsSymbols = puschInfo.nrOfDmrsSymbols;
702 hqP->dmrsAddPos = puschInfo.dmrsAddPos;
706 puschInfo.crnti = ueCb->crnti;
707 puschInfo.harqProcId = hqP->procId;
708 puschInfo.resAllocType = hqP->puschResType;
709 puschInfo.fdAlloc.startPrb = hqP->puschStartPrb;
710 puschInfo.fdAlloc.numPrb = hqP->puschNumPrb;
711 puschInfo.tdAlloc.startSymb = hqP->strtSymbl;
712 puschInfo.tdAlloc.numSymb = hqP->numSymbl;
713 puschInfo.tbInfo.qamOrder = hqP->tbInfo.qamOrder;
714 puschInfo.tbInfo.mcs = hqP->tbInfo.iMcs;
715 puschInfo.tbInfo.mcsTable = hqP->tbInfo.mcsTable;
716 puschInfo.tbInfo.ndi = hqP->tbInfo.ndi; /* retransmission */
717 hqP->tbInfo.rvIdx = (hqP->tbInfo.rvIdx +1) & 0x3;
718 puschInfo.tbInfo.rv = schCmnDlRvTbl[hqP->tbInfo.rvIdx];
719 puschInfo.tbInfo.tbSize = hqP->tbInfo.tbSzReq;
720 puschInfo.dmrsMappingType = hqP->dmrsMappingType; /* Setting Type-A */
721 puschInfo.nrOfDmrsSymbols = hqP->nrOfDmrsSymbols;
722 puschInfo.dmrsAddPos = hqP->dmrsAddPos;
724 schUlSlotInfo = cellCb->schUlSlotInfo[puschTime.slot];
725 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
726 if(!schUlSlotInfo->schPuschInfo)
728 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
731 memcpy(schUlSlotInfo->schPuschInfo, &puschInfo, sizeof(SchPuschInfo));
735 /*******************************************************************
737 * @brief Fills UL DCI information for MSG3 retransmission
741 * Function : schFillUlDciForMsg3Retx
743 * Functionality: fills UL DCI information for MSG3 retransmission
746 * @return ROK - success
749 * ****************************************************************/
750 uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo *dciInfo)
752 SchCellCb *cellCb = raCb->cell;
753 dciInfo->cellId = cellCb->cellId;
754 dciInfo->crnti = raCb->tcrnti;
755 SchUlHqProcCb *msg3HqProc = &raCb->msg3HqProc;
756 if (msg3HqProc == NULLP)
762 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
763 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
764 dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb;
765 dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb;
767 /*fill coreset cfg */
768 //Considering number of RBs in coreset1 is same as coreset0
769 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
770 //Considering coreset1 also starts from same symbol as coreset0
771 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
772 dciInfo->coresetCfg.durationSymbols = coresetIdxTable[0][2];
773 memcpy(dciInfo->coresetCfg.freqDomainResource, cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
775 dciInfo->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
776 dciInfo->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */
777 dciInfo->coresetCfg.interleaverSize = 2; /* spec-38.211 sec 7.3.2.2 */
778 dciInfo->coresetCfg.coreSetType = 0;
779 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
780 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
781 dciInfo->coresetCfg.precoderGranularity = 0;
782 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
783 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
785 dciInfo->formatType = FORMAT0_0;
786 msg3HqProc->tbInfo.rvIdx++;
787 msg3HqProc->tbInfo.rv = schCmnDlRvTbl[msg3HqProc->tbInfo.rvIdx & 0x03];
789 dciInfo->format.format0_0.resourceAllocType = msg3HqProc->puschResType;
790 dciInfo->format.format0_0.freqAlloc.startPrb = msg3HqProc->puschStartPrb;
791 dciInfo->format.format0_0.freqAlloc.numPrb = msg3HqProc->puschNumPrb;
792 dciInfo->format.format0_0.timeAlloc.startSymb = msg3HqProc->strtSymbl;
793 dciInfo->format.format0_0.timeAlloc.numSymb = msg3HqProc->numSymbl;
794 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
795 dciInfo->format.format0_0.mcs = msg3HqProc->tbInfo.iMcs;
796 dciInfo->format.format0_0.harqProcId = msg3HqProc->procId;
797 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
798 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
799 dciInfo->format.format0_0.ndi = msg3HqProc->tbInfo.ndi; /* new transmission */
800 dciInfo->format.format0_0.rv = msg3HqProc->tbInfo.rv;
801 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
802 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
804 /* Fill DCI Structure */
805 dciInfo->dciInfo.rnti = raCb->tcrnti;
806 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
807 dciInfo->dciInfo.scramblingRnti = 0;
808 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
809 dciInfo->dciInfo.aggregLevel = 4;
810 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
811 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
812 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
813 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
814 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
815 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
816 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
817 dciInfo->dciInfo.pdschCfg = NULL; /* No DL data being sent */
818 msg3HqProc->tbInfo.txCntr++;
820 puschInfo->crnti = raCb->tcrnti;
821 puschInfo->harqProcId = msg3HqProc->procId;
822 puschInfo->resAllocType = msg3HqProc->puschResType;
823 puschInfo->fdAlloc.startPrb = msg3HqProc->puschStartPrb;
824 puschInfo->fdAlloc.numPrb = msg3HqProc->puschNumPrb;
825 puschInfo->tdAlloc.startSymb = msg3HqProc->strtSymbl;
826 puschInfo->tdAlloc.numSymb = msg3HqProc->numSymbl;
827 puschInfo->tbInfo.qamOrder = msg3HqProc->tbInfo.qamOrder;
828 puschInfo->tbInfo.mcs = msg3HqProc->tbInfo.iMcs;
829 puschInfo->tbInfo.mcsTable = msg3HqProc->tbInfo.mcsTable;
830 puschInfo->tbInfo.ndi = msg3HqProc->tbInfo.ndi; /* retransmission */
831 puschInfo->tbInfo.rv = msg3HqProc->tbInfo.rvIdx;
832 puschInfo->tbInfo.tbSize = msg3HqProc->tbInfo.tbSzReq;
833 puschInfo->dmrsMappingType = msg3HqProc->dmrsMappingType; /* Setting Type-A */
834 puschInfo->nrOfDmrsSymbols = msg3HqProc->nrOfDmrsSymbols;
835 puschInfo->dmrsAddPos = msg3HqProc->dmrsAddPos;
840 /*******************************************************************
842 * @brief Fills DCI for UL grant
846 * Function : schFillUlDci
848 * Functionality: fills DCI for UL grant in response to BSR
850 * @params[in] SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo,
851 * @params[in] bool isRetx, SchUlHqProcCb *hqP
852 * @return ROK - success
855 * ****************************************************************/
856 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, bool isRetx, SchUlHqProcCb *hqP)
858 SchCellCb *cellCb = ueCb->cellCb;
859 SchControlRsrcSet coreset1 ;
861 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
862 if(ueCb->ueCfg.spCellCfgPres == true)
864 coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
867 dciInfo->cellId = cellCb->cellId;
868 dciInfo->crnti = ueCb->crnti;
871 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
872 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
873 dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb;
874 dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb;
876 /*fill coreset cfg */
877 //Considering number of RBs in coreset1 is same as coreset0
878 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
879 //Considering coreset1 also starts from same symbol as coreset0
880 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
881 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
882 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
884 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
885 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
886 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
887 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
888 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
889 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
890 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
891 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
893 dciInfo->formatType = FORMAT0_0;
896 dciInfo->format.format0_0.resourceAllocType = puschInfo->resAllocType;
897 dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo->fdAlloc.startPrb;
898 dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo->fdAlloc.numPrb;
899 dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo->tdAlloc.startSymb;
900 dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo->tdAlloc.numSymb;
901 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
902 dciInfo->format.format0_0.mcs = puschInfo->tbInfo.mcs;
903 dciInfo->format.format0_0.harqProcId = puschInfo->harqProcId;
904 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
905 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
906 dciInfo->format.format0_0.ndi = puschInfo->tbInfo.ndi; /* new transmission */
907 dciInfo->format.format0_0.rv = puschInfo->tbInfo.rv;
908 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
909 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
911 /* Fill DCI Structure */
912 dciInfo->dciInfo.rnti = ueCb->crnti;
913 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
914 dciInfo->dciInfo.scramblingRnti = 0;
915 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
916 dciInfo->dciInfo.aggregLevel = 4;
917 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
918 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
919 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
920 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
921 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
922 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
923 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
924 dciInfo->dciInfo.pdschCfg = NULL; /* No DL data being sent */
929 /*******************************************************************
931 * @brief Function to Modify Ue Config request from MAC
935 * Function : MacSchModUeConfigReq
937 * Functionality: Function to modify Ue Config request from MAC
940 * @return ROK - success
943 * ****************************************************************/
944 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
946 uint8_t ueId, lcIdx, ret = ROK;
947 SchCellCb *cellCb = NULLP;
948 SchUeCb *ueCb = NULLP;
950 Inst inst = pst->dstInst - SCH_INST_START;
951 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
953 #ifdef CALL_FLOW_DEBUG_LOG
954 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH\n");
959 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
962 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
963 cellCb = getSchCellCb(pst->event, inst, ueCfg);
965 /* Search if UE already configured */
966 GET_UE_ID(ueCfg->crnti, ueId);
967 ueCb = &cellCb->ueCb[ueId -1];
971 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchModUeConfigReq() ");
972 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
975 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
977 /* Found the UeCb to Reconfig */
978 ret = fillSchUeCb(inst, ueCb, ueCfg);
981 ueCb->cellCb = cellCb;
982 ueCb->srRcvd = false;
983 ueCb->bsrRcvd = false;
984 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
985 ueCb->bsrInfo[lcIdx].dataVol = 0;
987 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
993 /*******************************************************************
995 * @brief Fill and send UE delete response to MAC
999 * Function : SchSendUeDeleteRspToMac
1001 * Functionality: Fill and send UE delete response to MAC
1003 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
1005 * @return ROK - success
1008 * ****************************************************************/
1009 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, ErrorCause cause)
1012 SchUeDeleteRsp delRsp;
1014 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
1015 delRsp.cellId = ueDelete->cellId;
1016 delRsp.crnti = ueDelete->crnti;
1017 delRsp.rsp = result;
1018 delRsp.cause = cause;
1020 /* Filling response post */
1021 memset(&rspPst, 0, sizeof(Pst));
1022 FILL_PST_SCH_TO_MAC(rspPst, inst);
1023 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
1024 SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
1027 /*******************************************************************
1029 * @brief Function to delete Sch Pucch ResrcCfg
1033 * Function : deleteSchPucchResrcCfg
1035 * Functionality: Function to delete Sch Pucch ResrcCfg
1037 * @params[in] SchPucchResrcCfg *resrc
1040 * ****************************************************************/
1042 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
1045 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
1047 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
1049 case PUCCH_FORMAT_0:
1051 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
1052 sizeof(SchPucchFormat0));
1055 case PUCCH_FORMAT_1:
1057 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
1058 sizeof(SchPucchFormat1));
1061 case PUCCH_FORMAT_2:
1063 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
1064 sizeof(SchPucchFormat2_3));
1067 case PUCCH_FORMAT_3:
1069 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
1070 sizeof(SchPucchFormat2_3));
1073 case PUCCH_FORMAT_4:
1075 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
1076 sizeof(SchPucchFormat4));
1083 /*******************************************************************
1085 * @brief Function to delete SCH Pdsch ServCellCfg
1089 * Function : deleteSchPdschServCellCfg
1091 * Functionality: Function to delete SCH Pdsch ServCellCfg
1093 * @params[in] SchPdschServCellCfg *pdschServCellCfg
1096 * ****************************************************************/
1098 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
1100 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
1101 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
1102 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
1103 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
1106 /*******************************************************************
1108 * @brief Function to delete SCH UeCb
1112 * Function : deleteSchUeCb
1114 * Functionality: Function to delete SCH UeCb
1117 * @return ROK - success
1120 * ****************************************************************/
1121 void deleteSchUeCb(SchUeCb *ueCb)
1123 uint8_t timeDomRsrcIdx = 0, ueLcIdx = 0, idx =0;
1124 SchPucchCfg *pucchCfg = NULLP;
1125 SchPdschConfig *pdschCfg = NULLP;
1131 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
1133 if(ueCb->hqDlmap[idx])
1135 cmLListDeleteLList(&ueCb->hqDlmap[idx]->hqList);
1136 SCH_FREE(ueCb->hqDlmap[idx], sizeof(SchHqDlMap));
1139 SCH_FREE(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
1144 for (idx = 0; idx<ueCb->cellCb->numSlots; idx++)
1146 if(ueCb->hqUlmap[idx])
1148 cmLListDeleteLList(&ueCb->hqUlmap[idx]->hqList);
1149 SCH_FREE(ueCb->hqUlmap[idx], sizeof(SchHqUlMap));
1152 SCH_FREE(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
1155 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
1156 if(ueCb->ueCfg.spCellCfgPres)
1158 if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
1160 pdschCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg;
1161 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
1162 SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
1165 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
1167 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
1168 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
1171 deleteSchPucchResrcCfg(pucchCfg->resrc);
1172 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
1174 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
1175 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
1176 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
1177 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
1178 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
1179 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1180 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1181 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1182 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
1184 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
1185 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
1187 /*Need to Free the memory allocated for S-NSSAI*/
1188 for(ueLcIdx = 0; ueLcIdx < MAX_NUM_LC; ueLcIdx++)
1190 SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
1191 SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
1194 if(ueCb->ueDrxInfoPres)
1196 /* Removing all the calculated drx configuration timer list */
1197 schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
1198 ueCb->ueDrxInfoPres = false;
1201 memset(ueCb, 0, sizeof(SchUeCb));
1205 /*******************************************************************
1207 * @brief Function for Ue Delete request from MAC to SCH
1211 * Function : MacSchUeDeleteReq
1213 * Functionality: Function for Ue Delete request from MAC to SCH
1215 * @params[in] Pst *pst, SchUeDelete *ueDelete
1216 * @return ROK - success
1219 * ****************************************************************/
1220 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
1222 uint8_t idx=0, ueId=0, ueIdToDel=0, ret=ROK;
1224 SchCellCb *cellCb = NULLP;
1225 Inst inst = pst->dstInst - SCH_INST_START;
1226 CmLList *node = NULL, *next = NULL;
1228 #ifdef CALL_FLOW_DEBUG_LOG
1229 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UE_DELETE_REQ_TO_SCH\n");
1234 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): Ue Delete request failed");
1237 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
1239 cellCb = schCb[inst].cells[idx];
1241 if(cellCb->cellId != ueDelete->cellId)
1243 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): cell Id is not available");
1244 result = INVALID_CELLID;
1248 GET_UE_ID(ueDelete->crnti, ueId);
1249 if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE))
1251 deleteSchUeCb(&cellCb->ueCb[ueId-1]);
1253 /* Remove UE from ueToBeScheduled list */
1254 node = cellCb->ueToBeScheduled.first;
1258 ueId = *(uint8_t *)node->node;
1259 if(ueId == ueIdToDel)
1261 SCH_FREE(node->node, sizeof(uint8_t));
1262 deleteNodeFromLList(&cellCb->ueToBeScheduled, node);
1267 cellCb->numActvUe--;
1268 result = NOT_APPLICABLE;
1272 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): SchUeCb not found");
1273 result = INVALID_UEID;
1277 if(result == NOT_APPLICABLE)
1279 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
1283 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
1289 /*******************************************************************
1291 * @brief Fill and send Cell delete response to MAC
1295 * Function : SchSendCellDeleteRspToMac
1297 * Functionality: Fill and send Cell delete response to MAC
1299 * @params[in] SchCellDelete *ueDelete, Inst inst, SchMacRsp result
1300 * @return ROK - success
1303 * ****************************************************************/
1304 uint8_t SchSendCellDeleteRspToMac(SchCellDeleteReq *ueDelete, Inst inst, SchMacRsp result)
1309 SchCellDeleteRsp delRsp;
1311 DU_LOG("\nINFO --> SCH : Filling Cell Delete response");
1312 memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
1313 delRsp.cellId = ueDelete->cellId;
1314 delRsp.rsp = result;
1316 /* Filling response post */
1317 memset(&rspPst, 0, sizeof(Pst));
1318 FILL_PST_SCH_TO_MAC(rspPst, inst);
1319 rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
1320 ret = SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
1323 DU_LOG("\nERROR --> SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
1329 /*******************************************************************
1331 * @brief Function for cellCb Deletion
1335 * Function : deleteSchCellCb
1337 * Functionality: Function for cellCb Deletion
1339 * @params[in] SchCellDelete *cellDelete
1340 * @return ROK - success
1343 * ****************************************************************/
1344 void deleteSchCellCb(SchCellCb *cellCb)
1346 uint8_t sliceIdx=0, slotIdx=0;
1347 CmLListCp *list=NULL;
1348 CmLList *node=NULL, *next=NULL;
1349 SchPageInfo *tempNode = NULLP;
1351 if(cellCb->schDlSlotInfo)
1353 for(slotIdx=0; slotIdx<cellCb->numSlots; slotIdx++)
1355 list = &cellCb->schDlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList;
1360 SCH_FREE(node->node, sizeof(FreePrbBlock));
1361 deleteNodeFromLList(list, node);
1364 SCH_FREE(cellCb->schDlSlotInfo[slotIdx], sizeof(SchDlSlotInfo));
1366 SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
1369 if(cellCb->schUlSlotInfo)
1371 for(slotIdx=0; slotIdx<cellCb->numSlots; slotIdx++)
1373 list = &cellCb->schUlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList;
1378 SCH_FREE(node->node, sizeof(FreePrbBlock));
1379 deleteNodeFromLList(list, node);
1382 SCH_FREE(cellCb->schUlSlotInfo[slotIdx], sizeof(SchUlSlotInfo));
1384 SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*));
1387 if(cellCb->cellCfg.plmnInfoList.snssai)
1389 for(sliceIdx=0; sliceIdx<cellCb->cellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
1391 SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
1393 SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai, cellCb->cellCfg.plmnInfoList.numSliceSupport*sizeof(Snssai*));
1396 for(uint16_t idx =0; idx<MAX_SFN; idx++)
1398 list = &cellCb->pageCb.pageIndInfoRecord[idx];
1405 tempNode = (SchPageInfo*)(node->node);
1406 SCH_FREE(tempNode->pagePdu, tempNode->msgLen);
1407 SCH_FREE(node->node, sizeof(SchPageInfo));
1409 deleteNodeFromLList(list, node);
1414 /* Remove all UE from ueToBeScheduled list and deallocate */
1415 node = cellCb->ueToBeScheduled.first;
1419 SCH_FREE(node->node, sizeof(uint8_t));
1420 cmLListDelFrm(&cellCb->ueToBeScheduled, node);
1421 SCH_FREE(node, sizeof(CmLList));
1425 memset(cellCb, 0, sizeof(SchCellCb));
1429 /*******************************************************************
1431 * @brief Function for cell Delete request from MAC to SCH
1435 * Function : MacSchCellDeleteReq
1437 * Functionality: Function for cell Delete request from MAC to SCH
1439 * @params[in] Pst *pst, SchCellDelete *cellDelete
1440 * @return ROK - success
1443 * ****************************************************************/
1445 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDeleteReq *cellDelete)
1447 uint8_t cellIdx=0, ret = RFAILED;
1448 Inst inst = pst->dstInst - SCH_INST_START;
1449 SchMacRsp result= RSP_OK;
1451 #ifdef CALL_FLOW_DEBUG_LOG
1452 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_CELL_DELETE_REQ_TO_SCH\n");
1457 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): Ue Delete request failed");
1461 GET_CELL_IDX(cellDelete->cellId, cellIdx);
1462 if(schCb[inst].cells[cellIdx] == NULLP)
1464 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
1469 if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
1471 deleteSchCellCb(schCb[inst].cells[cellIdx]);
1474 SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
1475 DU_LOG("\nINFO --> SCH : Sending Cell Delete response to MAC");
1479 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
1484 if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
1486 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
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 **********************************************************************/