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"
33 SchUeCfgRspFunc SchUeCfgRspOpts[] =
35 packSchUeCfgRsp, /* LC */
36 MacProcSchUeCfgRsp, /* TC */
37 packSchUeCfgRsp /* LWLC */
40 SchUeDeleteRspFunc SchUeDeleteRspOpts[] =
42 packSchUeDeleteRsp, /* LC */
43 MacProcSchUeDeleteRsp, /* TC */
44 packSchUeDeleteRsp /* LWLC */
47 SchCellDeleteRspFunc SchCellDeleteRspOpts[]=
49 packSchCellDeleteRsp, /* LC */
50 MacProcSchCellDeleteRsp, /* TC */
51 packSchCellDeleteRsp /* LWLC */
53 /*******************************************************************
55 * @brief Fill and send UE cfg response to MAC
59 * Function : SchSendUeCfgRspToMac
61 * Functionality: Fill and send UE cfg response to MAC
64 * @return ROK - success
67 * ****************************************************************/
68 void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
69 SchMacRsp result, SchUeCfgRsp *cfgRsp)
73 cfgRsp->cellId = ueCfg->cellId;
74 cfgRsp->crnti = ueCfg->crnti;
75 GET_UE_IDX(ueCfg->crnti, cfgRsp->ueIdx);
78 /* Filling response post */
79 memset(&rspPst, 0, sizeof(Pst));
80 FILL_PST_SCH_TO_MAC(rspPst, inst);
81 if(event == EVENT_ADD_UE_CONFIG_REQ_TO_SCH)
83 rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
84 DU_LOG("\nINFO --> SCH : Sending UE Config response to MAC");
86 else if(event == EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH)
88 rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
89 DU_LOG("\nINFO --> SCH : Sending UE Reconfig response to MAC");
91 SchUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
94 /*******************************************************************
97 * @brief Function to fill Dl Lc Context in SCH Ue Cb
101 * Function : fillSchDlLcCtxt
103 * Functionality: Function to fill Dl Lc Context in SCH Ue Cb
105 * @params[in] SchDlLcCtxt pointer,
109 * ****************************************************************/
111 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
113 ueCbLcCfg->lcId = lcCfg->lcId;
114 ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
115 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
119 /*******************************************************************
121 * @brief Function to fill Ul Lc Context in SCH Ue Cb
125 * Function : fillSchUlLcCtxt
127 * Functionality: Function to fill Ul Lc Context in SCH Ue Cb
129 * @params[in] SchUlLcCtxt pointer,
133 * ****************************************************************/
135 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
137 ueCbLcCfg->lcId = lcCfg->lcId;
138 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
139 ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
140 ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
141 ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
142 ueCbLcCfg->pbr = lcCfg->ulLcCfg.pbr;
143 ueCbLcCfg->bsd = lcCfg->ulLcCfg.bsd;
147 /*******************************************************************
149 * @brief Function to update Sch Ul Lc Cb
153 * Function : updateSchUlCb
155 * Functionality: Function to update SCH Ul Lc Cb
159 * ****************************************************************/
161 void updateSchUlCb(uint8_t delIdx, SchUlCb *ulInfo)
165 for(lcIdx = delIdx; lcIdx < ulInfo->numUlLc; lcIdx++)
167 memcpy(&ulInfo->ulLcCtxt[lcIdx], &ulInfo->ulLcCtxt[lcIdx+1], sizeof(SchUlLcCtxt));
168 memset(&ulInfo->ulLcCtxt[lcIdx+1], 0, sizeof(SchUlLcCtxt));
172 /*******************************************************************
174 * @brief Function to update SCH Dl Lc Cb
178 * Function : updateSchDlCb
180 * Functionality: Function to update SCH DL Lc Cb
184 * ****************************************************************/
186 void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo)
190 for(lcIdx = delIdx; lcIdx < dlInfo->numDlLc; lcIdx++)
192 memcpy(&dlInfo->dlLcCtxt[lcIdx], &dlInfo->dlLcCtxt[lcIdx+1], sizeof(SchDlLcCtxt));
193 memset(&dlInfo->dlLcCtxt[lcIdx+1], 0, sizeof(SchDlLcCtxt));
197 /*******************************************************************
199 * @brief Function to fill SchUeCb
203 * Function : fillSchUeCb
205 * Functionality: Function to fill SchUeCb
207 * @params[in] SchUeCb pointer,
209 * @return ROK/RFAILED
211 * ****************************************************************/
213 uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
215 uint8_t lcIdx, ueLcIdx;
217 ueCb->ueCfg.cellId = ueCfg->cellId;
218 ueCb->ueCfg.crnti = ueCfg->crnti;
219 if(ueCfg->macCellGrpCfgPres == true)
221 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
222 ueCb->ueCfg.macCellGrpCfgPres = true;
225 if(ueCfg->phyCellGrpCfgPres == true)
227 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
228 ueCb->ueCfg.phyCellGrpCfgPres = true;
231 if(ueCfg->spCellCfgPres == true)
233 memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
234 ueCb->ueCfg.spCellCfgPres = true;
236 ueCb->state = SCH_UE_STATE_ACTIVE;
237 if(ueCfg->ambrCfg != NULLP)
239 SCH_ALLOC(ueCb->ueCfg.ambrCfg , sizeof(SchAmbrCfg));
240 memcpy(&ueCb->ueCfg.ambrCfg->ulBr , &ueCfg->ambrCfg->ulBr, sizeof(SchAmbrCfg));
243 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
244 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
246 //Updating SchUlCb and SchDlCb DB in SchUeCb
247 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
249 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
251 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
252 ueCb->ulInfo.numUlLc++;
253 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
254 ueCb->dlInfo.numDlLc++;
258 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
260 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
262 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
264 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
265 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
268 if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
270 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
271 ueCb->ulInfo.numUlLc--;
272 updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead
273 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
274 ueCb->dlInfo.numDlLc--;
275 updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
279 }/*End of inner for loop */
281 }/* End of outer for loop */
285 /*******************************************************************
287 * @brief Function to get SCH Cell Cb
291 * Function : getSchCellCb
293 * Functionality: Function to get SCH Cell Cb
295 * @params[in] event, SchUeCfg pointer
296 * @return schUeCb pointer - success
299 * ****************************************************************/
301 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
304 SchCellCb *cellCb = NULLP;
306 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
308 /* Search of cell cb */
309 for(idx = 0; idx < MAX_NUM_CELL; idx++)
311 cellCb = schCb[inst].cells[idx];
312 if(cellCb->cellId == ueCfg->cellId)
315 if(idx == MAX_NUM_CELL)
317 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
318 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
322 /* Check if max number of UE configured */
323 if(cellCb->numActvUe > MAX_NUM_UE)
325 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
326 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
333 /*******************************************************************
335 * @brief Function to Add Ue Config Request from MAC
339 * Function : MacSchAddUeConfigReq
341 * Functionality: Function to Add Ue config request from MAC
344 * @return ROK - success
347 * ****************************************************************/
348 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
350 uint8_t ueIdx, lcIdx, ret = ROK;
351 SchCellCb *cellCb = NULLP;
352 SchUeCb *ueCb = NULLP;
354 Inst inst = pst->dstInst - 1;
355 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
359 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
362 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
363 cellCb = getSchCellCb(pst->event, inst, ueCfg);
365 /* Search if UE already configured */
366 GET_UE_IDX(ueCfg->crnti, ueIdx);
367 ueCb = &cellCb->ueCb[ueIdx -1];
370 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
372 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
373 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
379 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
380 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
384 /* Fill received Ue Configuration in UeCb */
385 memset(ueCb, 0, sizeof(SchUeCb));
386 GET_UE_IDX(ueCfg->crnti, ueIdx);
388 ueCb->crnti = ueCfg->crnti;
389 ueCb->state = SCH_UE_STATE_ACTIVE;
390 ret = fillSchUeCb(ueCb, ueCfg);
394 SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
395 ueCb->cellCb = cellCb;
396 ueCb->srRcvd = false;
397 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
398 ueCb->bsrInfo[lcIdx].dataVol = 0;
400 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
405 /*******************************************************************
407 * @brief Fills PUSCH UL allocation
411 * Function : schFillPuschAlloc
413 * Functionality: fills PUSCH info
416 * @return ROK - success
419 * ****************************************************************/
420 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
422 uint16_t puschSlot = 0;
423 uint16_t startRb = 0;
428 SchCellCb *cellCb = ueCb->cellCb;
429 SchUlSlotInfo *schUlSlotInfo = NULLP;
430 uint8_t k2=0, startSymb=0 , symbLen=11;
432 if(ueCb->ueCfg.spCellCfgPres == true)
434 k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
435 startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
436 symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
438 puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
440 startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
441 tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */
442 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
443 /* increment PUSCH PRB */
445 cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
447 puschInfo->crnti = ueCb->crnti;
448 puschInfo->harqProcId = SCH_HARQ_PROC_ID;
449 puschInfo->resAllocType = SCH_ALLOC_TYPE_1;
450 puschInfo->fdAlloc.startPrb = startRb;
451 puschInfo->fdAlloc.numPrb = numRb;
452 puschInfo->tdAlloc.startSymb = startSymb;
453 puschInfo->tdAlloc.numSymb = symbLen;
454 puschInfo->tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
455 puschInfo->tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
456 puschInfo->tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
457 puschInfo->tbInfo.ndi = 1; /* new transmission */
458 puschInfo->tbInfo.rv = 0;
459 puschInfo->tbInfo.tbSize = tbSize;
460 puschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
461 puschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
462 puschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
464 /* Update pusch in cell */
465 for(idx=startSymb; idx<symbLen; idx++)
467 cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
470 schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
472 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
473 if(!schUlSlotInfo->schPuschInfo)
475 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
478 memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
483 /*******************************************************************
485 * @brief Fills DCI for UL grant
489 * Function : schFillUlDci
491 * Functionality: fills DCI for UL grant in response to BSR
494 * @return ROK - success
497 * ****************************************************************/
498 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
500 SchCellCb *cellCb = ueCb->cellCb;
501 SchControlRsrcSet coreset1 ;
503 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
504 if(ueCb->ueCfg.spCellCfgPres == true)
506 coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
509 dciInfo->cellId = cellCb->cellId;
510 dciInfo->crnti = ueCb->crnti;
513 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
514 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
515 dciInfo->bwpCfg.freqAlloc.startPrb = 0;
516 dciInfo->bwpCfg.freqAlloc.numPrb = MAX_NUM_RB; /* whole of BW */
518 /*fill coreset cfg */
519 //Considering number of RBs in coreset1 is same as coreset0
520 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
521 //Considering coreset1 also starts from same symbol as coreset0
522 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
523 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
524 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
526 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
527 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
528 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
529 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
530 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
531 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
532 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
533 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
535 dciInfo->formatType = FORMAT0_0;
538 dciInfo->format.format0_0.resourceAllocType = puschInfo.resAllocType;
539 dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo.fdAlloc.startPrb;
540 dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo.fdAlloc.numPrb;
541 dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
542 dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo.tdAlloc.numSymb;
543 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
544 dciInfo->format.format0_0.mcs = puschInfo.tbInfo.mcs;
545 dciInfo->format.format0_0.harqProcId = puschInfo.harqProcId;
546 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
547 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
548 dciInfo->format.format0_0.ndi = puschInfo.tbInfo.ndi; /* new transmission */
549 dciInfo->format.format0_0.rv = puschInfo.tbInfo.rv;
550 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
551 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
553 /* Fill DCI Structure */
554 dciInfo->dciInfo.rnti = ueCb->crnti;
555 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
556 dciInfo->dciInfo.scramblingRnti = 0;
557 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
558 dciInfo->dciInfo.aggregLevel = 4;
559 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
560 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
561 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
562 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
563 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
564 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
565 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
566 dciInfo->dciInfo.pdschCfg = NULLP; /* No DL data being sent */
571 /*******************************************************************
573 * @brief Function to Modify Ue Config request from MAC
577 * Function : MacSchModUeConfigReq
579 * Functionality: Function to modify Ue Config request from MAC
582 * @return ROK - success
585 * ****************************************************************/
586 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
588 uint8_t ueIdx, lcIdx, ret = ROK;
589 SchCellCb *cellCb = NULLP;
590 SchUeCb *ueCb = NULLP;
592 Inst inst = pst->dstInst - 1;
593 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
597 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
600 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
601 cellCb = getSchCellCb(pst->event, inst, ueCfg);
603 /* Search if UE already configured */
604 GET_UE_IDX(ueCfg->crnti, ueIdx);
605 ueCb = &cellCb->ueCb[ueIdx -1];
609 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchModUeConfigReq() ");
610 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
613 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
615 /* Found the UeCb to Reconfig */
616 ret = fillSchUeCb(ueCb, ueCfg);
619 ueCb->cellCb = cellCb;
620 ueCb->srRcvd = false;
621 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
622 ueCb->bsrInfo[lcIdx].dataVol = 0;
624 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
630 /*******************************************************************
632 * @brief Fill and send UE delete response to MAC
636 * Function : SchSendUeDeleteRspToMac
638 * Functionality: Fill and send UE delete response to MAC
640 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
642 * @return ROK - success
645 * ****************************************************************/
646 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, ErrorCause cause)
649 SchUeDeleteRsp delRsp;
651 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
652 delRsp.cellId = ueDelete->cellId;
653 delRsp.crnti = ueDelete->crnti;
655 delRsp.cause = cause;
657 /* Filling response post */
658 memset(&rspPst, 0, sizeof(Pst));
659 FILL_PST_SCH_TO_MAC(rspPst, inst);
660 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
661 SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
664 /*******************************************************************
666 * @brief Function to delete Sch Pucch ResrcCfg
670 * Function : deleteSchPucchResrcCfg
672 * Functionality: Function to delete Sch Pucch ResrcCfg
674 * @params[in] SchPucchResrcCfg *resrc
677 * ****************************************************************/
679 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
682 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
684 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
688 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
689 sizeof(SchPucchFormat0));
694 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
695 sizeof(SchPucchFormat1));
700 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
701 sizeof(SchPucchFormat2_3));
706 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
707 sizeof(SchPucchFormat2_3));
712 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
713 sizeof(SchPucchFormat4));
720 /*******************************************************************
722 * @brief Function to delete SCH Pdsch ServCellCfg
726 * Function : deleteSchPdschServCellCfg
728 * Functionality: Function to delete SCH Pdsch ServCellCfg
730 * @params[in] SchPdschServCellCfg *pdschServCellCfg
733 * ****************************************************************/
735 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
737 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
738 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
739 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
740 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
743 /*******************************************************************
745 * @brief Function to delete SCH UeCb
749 * Function : deleteSchUeCb
751 * Functionality: Function to delete SCH UeCb
754 * @return ROK - success
757 * ****************************************************************/
758 void deleteSchUeCb(SchUeCb *ueCb)
760 SchPucchCfg *pucchCfg = NULLP;
763 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
764 if(ueCb->ueCfg.spCellCfgPres)
766 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
768 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
769 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
772 deleteSchPucchResrcCfg(pucchCfg->resrc);
773 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
775 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
776 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
777 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
778 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
779 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
780 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
781 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
782 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
783 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
785 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
786 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
788 memset(ueCb, 0, sizeof(SchUeCb));
792 /*******************************************************************
794 * @brief Function for Ue Delete request from MAC to SCH
798 * Function : MacSchUeDeleteReq
800 * Functionality: Function for Ue Delete request from MAC to SCH
802 * @params[in] Pst *pst, SchUeDelete *ueDelete
803 * @return ROK - success
806 * ****************************************************************/
807 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
809 uint8_t idx=0, ueIdx=0, ret=ROK;
811 SchCellCb *cellCb = NULLP;
812 Inst inst = pst->dstInst - 1;
816 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): Ue Delete request failed");
819 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
821 cellCb = schCb[inst].cells[idx];
823 if(cellCb->cellId != ueDelete->cellId)
825 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): cell Id is not available");
826 result = INVALID_CELLID;
830 GET_UE_IDX(ueDelete->crnti, ueIdx);
831 if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE))
833 deleteSchUeCb(&cellCb->ueCb[ueIdx-1]);
835 result = NOT_APPLICABLE;
839 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): SchUeCb not found");
840 result = INVALID_UEIDX;
844 if(result == NOT_APPLICABLE)
846 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
850 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
856 /*******************************************************************
858 * @brief Fill and send Cell delete response to MAC
862 * Function : SchSendCellDeleteRspToMac
864 * Functionality: Fill and send Cell delete response to MAC
866 * @params[in] SchCellDelete *ueDelete, Inst inst, SchMacRsp result
867 * @return ROK - success
870 * ****************************************************************/
871 uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp result)
876 SchCellDeleteRsp delRsp;
878 DU_LOG("\nINFO --> SCH : Filling Cell Delete response");
879 memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
880 delRsp.cellId = ueDelete->cellId;
883 /* Filling response post */
884 memset(&rspPst, 0, sizeof(Pst));
885 FILL_PST_SCH_TO_MAC(rspPst, inst);
886 rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
887 ret = SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
890 DU_LOG("\nERROR --> SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
896 /*******************************************************************
898 * @brief Function for cellCb Deletion
902 * Function : deleteSchCellCb
904 * Functionality: Function for cellCb Deletion
906 * @params[in] SchCellDelete *cellDelete
907 * @return ROK - success
910 * ****************************************************************/
911 void deleteSchCellCb(SchCellCb *cellCb)
914 if(cellCb->schDlSlotInfo)
916 for(idx=0; idx<cellCb->numSlots; idx++)
918 if(cellCb->schDlSlotInfo[idx])
920 SCH_FREE(cellCb->schDlSlotInfo[idx]->rarInfo, sizeof(RarInfo));
921 if(cellCb->schDlSlotInfo[idx]->dlMsgInfo)
923 SCH_FREE(cellCb->schDlSlotInfo[idx]->dlMsgInfo->dlMsgPdu,\
924 cellCb->schDlSlotInfo[idx]->dlMsgInfo->dlMsgPduLen);
925 SCH_FREE(cellCb->schDlSlotInfo[idx]->dlMsgInfo, sizeof(DlMsgInfo));
927 SCH_FREE(cellCb->schDlSlotInfo[idx], sizeof(SchDlSlotInfo));
930 SCH_FREE(cellCb->schDlSlotInfo, sizeof(SchDlSlotInfo));
932 if(cellCb->schUlSlotInfo)
934 for(idx=0; idx<cellCb->numSlots; idx++)
936 if(cellCb->schUlSlotInfo[idx])
938 SCH_FREE(cellCb->schUlSlotInfo[idx]->schPuschInfo,sizeof(SchPuschInfo));
939 SCH_FREE(cellCb->schUlSlotInfo[idx], sizeof(SchUlSlotInfo));
942 SCH_FREE(cellCb->schUlSlotInfo, sizeof(SchUlSlotInfo));
944 SCH_FREE(cellCb->cellCfg.sib1SchCfg.sib1PdcchCfg.dci.pdschCfg, sizeof(PdschCfg));
945 memset(cellCb, 0, sizeof(SchCellCb));
948 /*******************************************************************
950 * @brief Function for cell Delete request from MAC to SCH
954 * Function : MacSchCellDeleteReq
956 * Functionality: Function for cell Delete request from MAC to SCH
958 * @params[in] Pst *pst, SchCellDelete *cellDelete
959 * @return ROK - success
962 * ****************************************************************/
964 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete *cellDelete)
966 uint8_t cellIdx=0, ret = RFAILED;
967 Inst inst = pst->dstInst - 1;
968 SchMacRsp result= RSP_OK;
972 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): Ue Delete request failed");
976 GET_CELL_IDX(cellDelete->cellId, cellIdx);
977 if(schCb[inst].cells[cellIdx] == NULLP)
979 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
984 if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
986 deleteSchCellCb(schCb[inst].cells[cellIdx]);
989 SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
990 DU_LOG("\nINFO --> SCH : Sending Cell Delete response to MAC");
994 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
999 if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
1001 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
1009 /**********************************************************************
1011 **********************************************************************/