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;
216 SchPdschCfgCmn pdschCfg;
217 SchPucchDlDataToUlAck *dlDataToUlAck;
219 ueCb->ueCfg.cellId = ueCfg->cellId;
220 ueCb->ueCfg.crnti = ueCfg->crnti;
221 if(ueCfg->macCellGrpCfgPres == true)
223 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
224 ueCb->ueCfg.macCellGrpCfgPres = true;
227 if(ueCfg->phyCellGrpCfgPres == true)
229 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
230 ueCb->ueCfg.phyCellGrpCfgPres = true;
233 if(ueCfg->spCellCfgPres == true)
235 memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
236 ueCb->ueCfg.spCellCfgPres = true;
237 dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck;
242 BuildK0K1Table(ueCb->cellCb, &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl, false, pdschCfg,\
243 ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
244 dlDataToUlAck->dlDataToUlAckList);
245 BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
246 ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
247 &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl);
252 ueCb->state = SCH_UE_STATE_ACTIVE;
255 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
256 ueCb->ueCfg.ambrCfg = ueCfg->ambrCfg;
258 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
259 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
261 //Updating SchUlCb and SchDlCb DB in SchUeCb
262 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
264 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
266 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
267 ueCb->ulInfo.numUlLc++;
268 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
269 ueCb->dlInfo.numDlLc++;
273 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
275 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
277 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
279 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
280 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
283 if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
285 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
286 ueCb->ulInfo.numUlLc--;
287 updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead
288 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
289 ueCb->dlInfo.numDlLc--;
290 updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
294 }/*End of inner for loop */
297 SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo));
298 SCH_FREE(ueCfg->schLcCfg[lcIdx].snssai, sizeof(SchSnssai));
300 }/* End of outer for loop */
304 /*******************************************************************
306 * @brief Function to get SCH Cell Cb
310 * Function : getSchCellCb
312 * Functionality: Function to get SCH Cell Cb
314 * @params[in] event, SchUeCfg pointer
315 * @return schUeCb pointer - success
318 * ****************************************************************/
320 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
323 SchCellCb *cellCb = NULLP;
325 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
327 /* Search of cell cb */
328 for(idx = 0; idx < MAX_NUM_CELL; idx++)
330 cellCb = schCb[inst].cells[idx];
331 if(cellCb->cellId == ueCfg->cellId)
334 if(idx == MAX_NUM_CELL)
336 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
337 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
341 /* Check if max number of UE configured */
342 if(cellCb->numActvUe > MAX_NUM_UE)
344 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
345 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
352 /*******************************************************************
354 * @brief Function to Add Ue Config Request from MAC
358 * Function : MacSchAddUeConfigReq
360 * Functionality: Function to Add Ue config request from MAC
363 * @return ROK - success
366 * ****************************************************************/
367 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
369 uint8_t ueIdx, lcIdx, ret = ROK;
370 SchCellCb *cellCb = NULLP;
371 SchUeCb *ueCb = NULLP;
373 Inst inst = pst->dstInst - 1;
374 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
376 #ifdef CALL_FLOW_DEBUG_LOG
377 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_ADD_UE_CONFIG_REQ_TO_SCH\n");
382 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
385 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
386 cellCb = getSchCellCb(pst->event, inst, ueCfg);
388 /* Search if UE already configured */
389 GET_UE_IDX(ueCfg->crnti, ueIdx);
390 ueCb = &cellCb->ueCb[ueIdx -1];
393 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
395 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
396 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
402 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
403 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
407 /* Fill received Ue Configuration in UeCb */
408 memset(ueCb, 0, sizeof(SchUeCb));
409 GET_UE_IDX(ueCfg->crnti, ueIdx);
411 ueCb->crnti = ueCfg->crnti;
412 ueCb->state = SCH_UE_STATE_ACTIVE;
413 ret = fillSchUeCb(ueCb, ueCfg);
417 SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
418 ueCb->cellCb = cellCb;
419 ueCb->srRcvd = false;
420 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
421 ueCb->bsrInfo[lcIdx].dataVol = 0;
423 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
428 /*******************************************************************
430 * @brief Fills PUSCH UL allocation
434 * Function : schFillPuschAlloc
436 * Functionality: fills PUSCH info
439 * @return ROK - success
442 * ****************************************************************/
443 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
445 uint16_t puschSlot = 0;
446 uint16_t startRb = 0;
451 SchCellCb *cellCb = ueCb->cellCb;
452 SchUlSlotInfo *schUlSlotInfo = NULLP;
453 uint8_t k2=0, startSymb=0 , symbLen=11;
455 if(ueCb->ueCfg.spCellCfgPres == true)
457 k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
458 startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
459 symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
461 puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
463 startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
464 tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */
465 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
466 /* increment PUSCH PRB */
468 cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
470 puschInfo->crnti = ueCb->crnti;
471 puschInfo->harqProcId = SCH_HARQ_PROC_ID;
472 puschInfo->resAllocType = SCH_ALLOC_TYPE_1;
473 puschInfo->fdAlloc.startPrb = startRb;
474 puschInfo->fdAlloc.numPrb = numRb;
475 puschInfo->tdAlloc.startSymb = startSymb;
476 puschInfo->tdAlloc.numSymb = symbLen;
477 puschInfo->tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
478 puschInfo->tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
479 puschInfo->tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
480 puschInfo->tbInfo.ndi = 1; /* new transmission */
481 puschInfo->tbInfo.rv = 0;
482 puschInfo->tbInfo.tbSize = tbSize;
483 puschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
484 puschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
485 puschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
487 /* Update pusch in cell */
488 for(idx=startSymb; idx<symbLen; idx++)
490 cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
493 schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
495 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
496 if(!schUlSlotInfo->schPuschInfo)
498 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
501 memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
506 /*******************************************************************
508 * @brief Fills DCI for UL grant
512 * Function : schFillUlDci
514 * Functionality: fills DCI for UL grant in response to BSR
517 * @return ROK - success
520 * ****************************************************************/
521 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
523 SchCellCb *cellCb = ueCb->cellCb;
524 SchControlRsrcSet coreset1 ;
526 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
527 if(ueCb->ueCfg.spCellCfgPres == true)
529 coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
532 dciInfo->cellId = cellCb->cellId;
533 dciInfo->crnti = ueCb->crnti;
536 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
537 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
538 dciInfo->bwpCfg.freqAlloc.startPrb = 0;
539 dciInfo->bwpCfg.freqAlloc.numPrb = MAX_NUM_RB; /* whole of BW */
541 /*fill coreset cfg */
542 //Considering number of RBs in coreset1 is same as coreset0
543 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
544 //Considering coreset1 also starts from same symbol as coreset0
545 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
546 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
547 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
549 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
550 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
551 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
552 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
553 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
554 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
555 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
556 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
558 dciInfo->formatType = FORMAT0_0;
561 dciInfo->format.format0_0.resourceAllocType = puschInfo.resAllocType;
562 dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo.fdAlloc.startPrb;
563 dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo.fdAlloc.numPrb;
564 dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
565 dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo.tdAlloc.numSymb;
566 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
567 dciInfo->format.format0_0.mcs = puschInfo.tbInfo.mcs;
568 dciInfo->format.format0_0.harqProcId = puschInfo.harqProcId;
569 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
570 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
571 dciInfo->format.format0_0.ndi = puschInfo.tbInfo.ndi; /* new transmission */
572 dciInfo->format.format0_0.rv = puschInfo.tbInfo.rv;
573 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
574 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
576 /* Fill DCI Structure */
577 dciInfo->dciInfo.rnti = ueCb->crnti;
578 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
579 dciInfo->dciInfo.scramblingRnti = 0;
580 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
581 dciInfo->dciInfo.aggregLevel = 4;
582 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
583 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
584 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
585 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
586 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
587 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
588 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
589 dciInfo->dciInfo.pdschCfg = NULLP; /* No DL data being sent */
594 /*******************************************************************
596 * @brief Function to Modify Ue Config request from MAC
600 * Function : MacSchModUeConfigReq
602 * Functionality: Function to modify Ue Config request from MAC
605 * @return ROK - success
608 * ****************************************************************/
609 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
611 uint8_t ueIdx, lcIdx, ret = ROK;
612 SchCellCb *cellCb = NULLP;
613 SchUeCb *ueCb = NULLP;
615 Inst inst = pst->dstInst - 1;
616 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
618 #ifdef CALL_FLOW_DEBUG_LOG
619 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH\n");
624 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
627 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
628 cellCb = getSchCellCb(pst->event, inst, ueCfg);
630 /* Search if UE already configured */
631 GET_UE_IDX(ueCfg->crnti, ueIdx);
632 ueCb = &cellCb->ueCb[ueIdx -1];
636 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchModUeConfigReq() ");
637 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
640 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
642 /* Found the UeCb to Reconfig */
643 ret = fillSchUeCb(ueCb, ueCfg);
646 ueCb->cellCb = cellCb;
647 ueCb->srRcvd = false;
648 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
649 ueCb->bsrInfo[lcIdx].dataVol = 0;
651 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
657 /*******************************************************************
659 * @brief Fill and send UE delete response to MAC
663 * Function : SchSendUeDeleteRspToMac
665 * Functionality: Fill and send UE delete response to MAC
667 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
669 * @return ROK - success
672 * ****************************************************************/
673 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, ErrorCause cause)
676 SchUeDeleteRsp delRsp;
678 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
679 delRsp.cellId = ueDelete->cellId;
680 delRsp.crnti = ueDelete->crnti;
682 delRsp.cause = cause;
684 /* Filling response post */
685 memset(&rspPst, 0, sizeof(Pst));
686 FILL_PST_SCH_TO_MAC(rspPst, inst);
687 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
688 SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
691 /*******************************************************************
693 * @brief Function to delete Sch Pucch ResrcCfg
697 * Function : deleteSchPucchResrcCfg
699 * Functionality: Function to delete Sch Pucch ResrcCfg
701 * @params[in] SchPucchResrcCfg *resrc
704 * ****************************************************************/
706 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
709 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
711 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
715 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
716 sizeof(SchPucchFormat0));
721 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
722 sizeof(SchPucchFormat1));
727 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
728 sizeof(SchPucchFormat2_3));
733 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
734 sizeof(SchPucchFormat2_3));
739 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
740 sizeof(SchPucchFormat4));
747 /*******************************************************************
749 * @brief Function to delete SCH Pdsch ServCellCfg
753 * Function : deleteSchPdschServCellCfg
755 * Functionality: Function to delete SCH Pdsch ServCellCfg
757 * @params[in] SchPdschServCellCfg *pdschServCellCfg
760 * ****************************************************************/
762 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
764 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
765 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
766 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
767 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
770 /*******************************************************************
772 * @brief Function to delete SCH UeCb
776 * Function : deleteSchUeCb
778 * Functionality: Function to delete SCH UeCb
781 * @return ROK - success
784 * ****************************************************************/
785 void deleteSchUeCb(SchUeCb *ueCb)
787 uint8_t timeDomRsrcIdx;
788 SchPucchCfg *pucchCfg = NULLP;
789 SchPdschConfig *pdschCfg = NULLP;
793 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
794 if(ueCb->ueCfg.spCellCfgPres)
796 if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
798 pdschCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg;
799 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
800 SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
803 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
805 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
806 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
809 deleteSchPucchResrcCfg(pucchCfg->resrc);
810 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
812 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
813 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
814 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
815 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
816 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
817 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
818 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
819 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
820 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
822 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
823 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
825 memset(ueCb, 0, sizeof(SchUeCb));
829 /*******************************************************************
831 * @brief Function for Ue Delete request from MAC to SCH
835 * Function : MacSchUeDeleteReq
837 * Functionality: Function for Ue Delete request from MAC to SCH
839 * @params[in] Pst *pst, SchUeDelete *ueDelete
840 * @return ROK - success
843 * ****************************************************************/
844 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
846 uint8_t idx=0, ueIdx=0, ret=ROK;
848 SchCellCb *cellCb = NULLP;
849 Inst inst = pst->dstInst - 1;
851 #ifdef CALL_FLOW_DEBUG_LOG
852 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UE_DELETE_REQ_TO_SCH\n");
857 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): Ue Delete request failed");
860 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
862 cellCb = schCb[inst].cells[idx];
864 if(cellCb->cellId != ueDelete->cellId)
866 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): cell Id is not available");
867 result = INVALID_CELLID;
871 GET_UE_IDX(ueDelete->crnti, ueIdx);
872 if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE))
874 deleteSchUeCb(&cellCb->ueCb[ueIdx-1]);
876 result = NOT_APPLICABLE;
880 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): SchUeCb not found");
881 result = INVALID_UEIDX;
885 if(result == NOT_APPLICABLE)
887 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
891 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
897 /*******************************************************************
899 * @brief Fill and send Cell delete response to MAC
903 * Function : SchSendCellDeleteRspToMac
905 * Functionality: Fill and send Cell delete response to MAC
907 * @params[in] SchCellDelete *ueDelete, Inst inst, SchMacRsp result
908 * @return ROK - success
911 * ****************************************************************/
912 uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp result)
917 SchCellDeleteRsp delRsp;
919 DU_LOG("\nINFO --> SCH : Filling Cell Delete response");
920 memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
921 delRsp.cellId = ueDelete->cellId;
924 /* Filling response post */
925 memset(&rspPst, 0, sizeof(Pst));
926 FILL_PST_SCH_TO_MAC(rspPst, inst);
927 rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
928 ret = SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
931 DU_LOG("\nERROR --> SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
937 /*******************************************************************
939 * @brief Function for cellCb Deletion
943 * Function : deleteSchCellCb
945 * Functionality: Function for cellCb Deletion
947 * @params[in] SchCellDelete *cellDelete
948 * @return ROK - success
951 * ****************************************************************/
952 void deleteSchCellCb(SchCellCb *cellCb)
955 if(cellCb->schDlSlotInfo)
957 for(idx=0; idx<cellCb->numSlots; idx++)
959 if(cellCb->schDlSlotInfo[idx])
961 SCH_FREE(cellCb->schDlSlotInfo[idx], sizeof(SchDlSlotInfo));
964 SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
966 if(cellCb->schUlSlotInfo)
968 for(idx=0; idx<cellCb->numSlots; idx++)
970 if(cellCb->schUlSlotInfo[idx])
972 SCH_FREE(cellCb->schUlSlotInfo[idx], sizeof(SchUlSlotInfo));
975 SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*));
977 memset(cellCb, 0, sizeof(SchCellCb));
981 /*******************************************************************
983 * @brief Function for cell Delete request from MAC to SCH
987 * Function : MacSchCellDeleteReq
989 * Functionality: Function for cell Delete request from MAC to SCH
991 * @params[in] Pst *pst, SchCellDelete *cellDelete
992 * @return ROK - success
995 * ****************************************************************/
997 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete *cellDelete)
999 uint8_t cellIdx=0, ret = RFAILED;
1000 Inst inst = pst->dstInst - 1;
1001 SchMacRsp result= RSP_OK;
1003 #ifdef CALL_FLOW_DEBUG_LOG
1004 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_CELL_DELETE_REQ_TO_SCH\n");
1009 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): Ue Delete request failed");
1013 GET_CELL_IDX(cellDelete->cellId, cellIdx);
1014 if(schCb[inst].cells[cellIdx] == NULLP)
1016 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
1021 if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
1023 deleteSchCellCb(schCb[inst].cells[cellIdx]);
1026 SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
1027 DU_LOG("\nINFO --> SCH : Sending Cell Delete response to MAC");
1031 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
1036 if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
1038 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
1046 /**********************************************************************
1048 **********************************************************************/