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 *******************************************************************************/
19 /* This file contains UE management handling functionality for MAC */
21 /* header include files (.h) */
22 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "mac_sch_interface.h"
27 #include "lwr_mac_upr_inf.h"
29 #include "mac_utils.h"
31 /* function pointers for packing slot ind from mac to sch */
32 MacSchAddUeConfigReqFunc macSchAddUeConfigReqOpts[] =
34 packMacSchAddUeConfigReq, /* packing for loosely coupled */
35 MacSchAddUeConfigReq, /* packing for tightly coupled */
36 packMacSchAddUeConfigReq /* packing for light weight loosely coupled */
39 MacDuUeCfgRspFunc macDuUeCfgRspOpts[] =
41 packDuMacUeCfgRsp, /* packing for loosely coupled */
42 DuProcMacUeCfgRsp, /* packing for tightly coupled */
43 packDuMacUeCfgRsp /* packing for light weight loosly coupled */
46 MacDuUeRecfgRspFunc macDuUeRecfgRspOpts[] =
48 packDuMacUeRecfgRsp, /* packing for loosely coupled */
49 DuProcMacUeRecfgRsp, /* packing for tightly coupled */
50 packDuMacUeRecfgRsp /* packing for light weight loosly coupled */
53 MacSchModUeConfigReqFunc macSchModUeConfigReqOpts[] =
55 packMacSchModUeConfigReq, /* packing for loosely coupled */
56 MacSchModUeConfigReq, /* packing for tightly coupled */
57 packMacSchModUeConfigReq /* packing for light weight loosely coupled */
60 MacSchUeDeleteReqFunc macSchUeDeleteReqOpts[] =
62 packMacSchUeDeleteReq, /* packing for loosely coupled */
63 MacSchUeDeleteReq, /* packing for tightly coupled */
64 packMacSchUeDeleteReq /* packing for light weight loosely coupled */
67 MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] =
69 packDuMacUeDeleteRsp, /* packing for loosely coupled */
70 DuProcMacUeDeleteRsp, /* packing for tightly coupled */
71 packDuMacUeDeleteRsp /* packing for light weight loosly coupled */
74 /*******************************************************************
76 * @brief Fills mac cell group config to be sent to scheduler
80 * Function : fillMacCellGroupCfg
82 * Functionality: Fills mac cell group config to be sent to sch
84 * @params[in] macCellGrp : mac cell group config at MAC
85 * *macCellGrpCfg : mac cell group cfg to be filled
86 * @return ROK - success
89 * ****************************************************************/
90 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
93 SchSchedReqCfg *schedReqCfg;
96 /* Copy scheduling request config */
97 schedReqCfg = &macCellGrpCfg->schedReqCfg;
98 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
99 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
101 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
102 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
105 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
107 schedReqCfg->addModList[idx].schedReqId = \
108 macCellGrp.schReqCfg.addModList[idx].schedReqId;
109 schedReqCfg->addModList[idx].srProhibitTmr = \
110 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
111 schedReqCfg->addModList[idx].srTransMax = \
112 macCellGrp.schReqCfg.addModList[idx].srTransMax;
114 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
116 /* copy TAG config */
117 tagCfg = &macCellGrpCfg->tagCfg;
118 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
119 if(tagCfg->addModListCount > MAX_NUM_TAGS)
121 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
122 tagCfg->addModListCount, MAX_NUM_TAGS);
125 for(idx = 0; idx < tagCfg->addModListCount; idx++)
127 tagCfg->addModList[idx].tagId = \
128 macCellGrp.tagCfg.addModList[idx].tagId;
129 tagCfg->addModList[idx].timeAlignmentTmr = \
130 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
132 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
134 /* Copy PHR config */
135 if(macCellGrp.phrCfgSetupPres)
137 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
138 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
139 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
140 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
141 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
142 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
143 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
147 /* Copy Drx configuration */
148 macCellGrpCfg->drxCfgPresent = true;
149 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs;
150 if(!macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
151 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
152 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
154 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
155 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
156 macCellGrpCfg->drxCfg.drxInactivityTimer = macCellGrp.drxCfg.drxInactivityTimer;
157 macCellGrpCfg->drxCfg.drxHarqRttTimerDl = macCellGrp.drxCfg.drxHarqRttTimerDl;
158 macCellGrpCfg->drxCfg.drxHarqRttTimerUl = macCellGrp.drxCfg.drxHarqRttTimerUl;
159 macCellGrpCfg->drxCfg.drxRetransmissionTimerDl = macCellGrp.drxCfg.drxRetransmissionTimerDl;
160 macCellGrpCfg->drxCfg.drxRetransmissionTimerUl = macCellGrp.drxCfg.drxRetransmissionTimerUl;
161 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellGrp.drxCfg.drxLongCycleStartOffset.\
162 drxLongCycleStartOffsetChoice;
163 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellGrp.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
164 macCellGrpCfg->drxCfg.shortDrxPres = macCellGrp.drxCfg.shortDrxPres;
165 if(macCellGrpCfg->drxCfg.shortDrxPres)
167 macCellGrpCfg->drxCfg.shortDrx.drxShortCycle = macCellGrp.drxCfg.shortDrx.drxShortCycle;
168 macCellGrpCfg->drxCfg.shortDrx.drxShortCycleTimer = macCellGrp.drxCfg.shortDrx.drxShortCycleTimer;
170 macCellGrpCfg->drxCfg.drxSlotOffset = macCellGrp.drxCfg.drxSlotOffset;
175 /*******************************************************************
177 * @brief Fills phy cell group config to be sent to scheduler
181 * Function : fillPhyCellGroupCfg
183 * Functionality: Fills phy cell group config to be sent to sch
185 * @params[in] macUeCfg : Phy cell group config at MAC
186 * *schPhyCellGrp : phy cell group config to be filled
187 * @return ROK - success
190 * ****************************************************************/
191 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
193 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
194 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
199 /*******************************************************************
201 * @brief Fills PDSCh serving cell config to send to scheduler
205 * Function : fillPdschServCellCfg
207 * Functionality: Fills PDSCh serving cell config to send to scheduler
209 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
210 * *schPdschCfg : Pdsch serving cell config to be filled
211 * @return ROK - success
214 * ****************************************************************/
215 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
217 if(macPdschCfg.maxMimoLayers)
219 if(!schPdschCfg->maxMimoLayers)
221 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
222 if(!schPdschCfg->maxMimoLayers)
224 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
228 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
232 schPdschCfg->maxMimoLayers = NULLP;
235 schPdschCfg->numHarqProcForPdsch = \
236 macPdschCfg.numHarqProcForPdsch;
238 if(macPdschCfg.maxCodeBlkGrpPerTb)
240 if(!schPdschCfg->maxCodeBlkGrpPerTb)
242 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
243 if(!schPdschCfg->maxCodeBlkGrpPerTb)
245 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
249 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
253 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
256 if(macPdschCfg.codeBlkGrpFlushInd)
258 if(!schPdschCfg->codeBlkGrpFlushInd)
260 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
261 if(!schPdschCfg->codeBlkGrpFlushInd)
263 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
267 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
271 schPdschCfg->codeBlkGrpFlushInd = NULLP;
274 if(macPdschCfg.xOverhead)
276 if(!schPdschCfg->xOverhead)
278 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
279 if(!schPdschCfg->xOverhead)
281 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
285 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
289 schPdschCfg->xOverhead = NULLP;
295 /*******************************************************************
297 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
301 * Function : fillInitalUlBwpPuschCfg
304 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
306 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
307 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
308 * @return ROK - success
311 * ****************************************************************/
312 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
316 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
317 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
318 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
319 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
320 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
321 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
323 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
324 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
326 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
327 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
330 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
332 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
333 macPuschCfg.timeDomRsrcAllocList[idx].k2;
334 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
335 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
336 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
337 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
338 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
339 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
342 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
346 /*******************************************************************
348 * @brief Function to fillResrcSetList sent by DU
352 * Function : fillResrcSetList
354 * Functionality: Function to fillResrcSetList sent by DU
356 * @params[in] PucchResrcSetCfg pointer,
357 * SchPucchResrcSetCfg pointer
360 * ****************************************************************/
362 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
364 uint8_t arrIdx, rsrcListIdx;
366 /* ResrcSetToAddModList */
367 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
368 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
370 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
371 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
373 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
374 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
376 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
377 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
378 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
379 resrcListCount; rsrcListIdx++)
381 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
382 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
385 /* ResrcSetToRelList */
386 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
387 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
389 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
393 /*******************************************************************
395 * @brief Function to fillResrcList sent by DU
399 * Function : fillResrcList
401 * Functionality: Function to fillResrcList sent by DU
403 * @params[in] PucchResrcCfg pointer,
404 * SchPucchResrcCfg pointer
405 * @return ROK/RFAILED;
407 * ****************************************************************/
408 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
412 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
413 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
415 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
416 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
417 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
418 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
419 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
420 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
421 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
422 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
423 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
424 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
425 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
427 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
428 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
430 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
433 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
434 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
435 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
436 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
437 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
438 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
441 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
443 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
444 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
446 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
449 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
450 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
451 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
452 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
453 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
454 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
455 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
456 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
459 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
461 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
462 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
464 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
467 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
468 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
469 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
470 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
471 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
472 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
475 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
477 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
478 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
480 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
483 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
484 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
485 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
486 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
487 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
488 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
491 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
493 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
494 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
496 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
499 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
500 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
501 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
502 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
503 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
504 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
505 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
506 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
512 /*******************************************************************
514 * @brief Function to fillPucchFormatCfg sent by DU
518 * Function : fillPucchFormatCfg
520 * Functionality: Function to fillPucchFormatCfg
522 * @params[in] PucchFormatCfg pointer,
523 * SchPucchFormatCfg pointer
526 * ****************************************************************/
528 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
530 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
531 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
532 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
533 schFormatCfg->numSlots = macFormatCfg->numSlots;
534 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
535 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
538 /*******************************************************************
540 * @brief Function to fillPucchSchedReqCfg sent by DU
544 * Function : fillPucchSchedReqCfg
546 * Functionality: Function to fillPucchSchedReqCfg
548 * @params[in] PucchSchedReqCfg pointer,
549 * SchPucchSchedReqCfg pointer
552 * ****************************************************************/
553 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
557 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
558 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
560 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
561 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
562 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
563 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
564 schSchedReqCfg->schedAddModList[arrIdx].offset =\
565 macSchedReqCfg->schedAddModList[arrIdx].offset;
566 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
567 macSchedReqCfg->schedAddModList[arrIdx].resrc;
569 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
570 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
572 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
576 /*******************************************************************
578 * @brief Function to fillMultiCsiCfg sent by DU
582 * Function : fillMultiCsiCfg
584 * Functionality: Function to fillMultiCsiCfg
586 * @params[in] PucchMultiCsiCfg pointer,
587 * SchPucchMultiCsiCfg pointer
590 * ****************************************************************/
592 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
596 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
597 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
599 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
603 /*******************************************************************
605 * @brief Function to fillDlToUlAck sent by DU
609 * Function : fillDlToUlAck
611 * Functionality: Function to fillDlToUlAck
613 * @params[in] PucchDlDataToUlAck pointer,
614 * SchPucchDlDataToUlAck pointer
617 * ****************************************************************/
619 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
623 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
624 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
626 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
630 /*******************************************************************
632 * @brief Function to fillPucchPowerControl sent by DU
636 * Function : fillPucchPowerControl
638 * Functionality: Function to fillPucchPowerControl
640 * @params[in] PucchPowerControl pointer,
641 * SchPucchPowerControl pointer
644 * ****************************************************************/
646 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
650 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
651 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
652 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
653 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
654 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
655 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
656 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
658 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
659 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
661 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
662 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
664 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
665 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
669 /*******************************************************************
671 * @brief Function to fillOtherPucchFormatCfg sent by DU
675 * Function : fillOtherPucchFormatCfg
677 * Functionality: Function to fillOtherPucchFormatCfg
679 * @params[in] PucchFormat
680 * PucchFormatCfg pointer,
681 * SchPucchCfg pointer
684 * ****************************************************************/
686 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
695 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
696 if(schPucchCfg->format1 == NULLP)
698 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
701 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
709 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
710 if(schPucchCfg->format2 == NULLP)
712 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
715 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
723 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
724 if(schPucchCfg->format3 == NULLP)
726 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
729 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
737 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
738 if(schPucchCfg->format4 == NULLP)
740 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
743 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
748 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
754 /*******************************************************************
756 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
760 * Function : fillInitalUlBwpPucchCfg
763 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
765 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
766 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
767 * @return ROK - success
770 * ****************************************************************/
771 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
773 if(macPucchCfg->resrcSet)
775 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
776 if(schPucchCfg->resrcSet == NULLP)
778 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
781 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
782 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
785 if(macPucchCfg->resrc)
787 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
788 if(schPucchCfg->resrc == NULLP)
790 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
793 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
794 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
796 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
801 /* valid for format 1, 2, 3, 4 */
802 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
803 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
804 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
805 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
807 if(macPucchCfg->schedReq)
809 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
810 if(schPucchCfg->schedReq == NULLP)
812 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
815 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
816 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
819 if(macPucchCfg->multiCsiCfg)
821 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
822 if(schPucchCfg->multiCsiCfg == NULLP)
824 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
827 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
828 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
831 //TODO: To add the support for spatial Config
832 schPucchCfg->spatialInfo = NULLP;
834 if(macPucchCfg->dlDataToUlAck)
836 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
837 if(schPucchCfg->dlDataToUlAck == NULLP)
839 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
842 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
843 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
847 if(macPucchCfg->powerControl)
849 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
850 if(schPucchCfg->powerControl == NULLP)
852 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
855 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
856 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
862 /*******************************************************************
864 * @brief function to free Pucch Format
868 * Function : freeSchPucchFormat
871 * function to free Pucch Format
873 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
874 * SchPucchResrcInfo pointer
876 * ****************************************************************/
878 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
882 case PUCCH_FORMAT_0 :
883 if(resrcInfo->SchPucchFormat.format0)
885 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
886 resrcInfo->SchPucchFormat.format0 = NULLP;
890 case PUCCH_FORMAT_1 :
891 if(resrcInfo->SchPucchFormat.format1)
893 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
894 resrcInfo->SchPucchFormat.format1 = NULLP;
898 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
899 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
903 case PUCCH_FORMAT_2 :
904 if(resrcInfo->SchPucchFormat.format2)
906 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
907 resrcInfo->SchPucchFormat.format2 = NULLP;
911 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
912 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
916 case PUCCH_FORMAT_3 :
917 if(resrcInfo->SchPucchFormat.format3)
919 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
920 resrcInfo->SchPucchFormat.format3 = NULLP;
924 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
925 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
929 case PUCCH_FORMAT_4 :
930 if(resrcInfo->SchPucchFormat.format4)
932 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
933 resrcInfo->SchPucchFormat.format4 = NULLP;
937 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
938 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
947 /*******************************************************************
949 * @brief function to free Pucch Resrc Cfg
953 * Function : freePucchResrcCfg
956 * function to free Pucch Resrc Cfg
958 * @params[in] SchPucchResrcCfg pointer,
960 * ****************************************************************/
962 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
966 /* free Resrc To AddMod List */
967 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
969 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
970 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
971 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
973 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
974 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
977 /*******************************************************************
979 * @brief function to free Pucch Sched Req Cfg
983 * Function : freePucchSchedReqCfg
986 * function to free Pucch Sched Req Cfg
988 * @params[in] SchPucchSchedReqCfg pointer,
990 * ****************************************************************/
992 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
996 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
998 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
1000 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
1001 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
1004 /*******************************************************************
1006 * @brief function to free Ul Bwp Pucch Cfg
1010 * Function : freeUlBwpPucchCfg
1013 * function to free Ul Bwp Pucch Cfg
1015 * @params[in] SchPucchCfg pointer,
1017 * ****************************************************************/
1019 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
1021 if(schPucchCfg->resrcSet)
1023 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1024 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1026 if(schPucchCfg->resrc)
1028 freePucchResrcCfg(schPucchCfg->resrc);
1030 if(schPucchCfg->format1)
1032 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1034 if(schPucchCfg->format2)
1036 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1038 if(schPucchCfg->format3)
1040 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1042 if(schPucchCfg->format4)
1044 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1046 if(schPucchCfg->schedReq)
1048 freePucchSchedReqCfg(schPucchCfg->schedReq);
1050 if(schPucchCfg->spatialInfo)
1052 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1053 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1055 if(schPucchCfg->multiCsiCfg)
1057 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1058 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1060 if(schPucchCfg->dlDataToUlAck)
1062 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1063 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1065 if(schPucchCfg->powerControl)
1067 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1068 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1072 /*******************************************************************
1074 * @brief Fills initail UL BWP config to send to scheduler
1078 * Function : fillInitialUlBwp
1080 * Functionality: Fills initail UL BWP config to send to sch
1082 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1083 * schInitUlBwp : Initial UL BWP cfg to be filled
1084 * @return ROK - success
1087 * ****************************************************************/
1088 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1090 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1091 if(schInitUlBwp->pucchCfgPres)
1093 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1094 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1096 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1097 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1101 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1102 if(schInitUlBwp->puschCfgPres)
1104 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1105 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1107 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1114 /*******************************************************************
1116 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1120 * Function : fillInitDlBwpPdcchCfg
1123 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1125 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1126 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1127 * @return ROK - success
1130 * ****************************************************************/
1131 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1135 /* Fill CORESET info */
1136 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1137 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1139 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1140 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1144 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1146 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1147 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1148 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1149 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1150 schPdcchCfg->cRSetToAddModList[idx].duration = \
1151 macPdcchCfg.cRSetToAddModList[idx].duration;
1152 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1153 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1154 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1155 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1156 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1157 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1160 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1161 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1163 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1164 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1168 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1173 /* Fill Search space info */
1174 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1175 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1177 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1178 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1181 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1183 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1184 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1185 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1186 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1187 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1188 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1189 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1190 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1191 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1192 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1193 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1194 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1195 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1196 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1197 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1198 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1199 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1200 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1201 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1202 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1203 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1204 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1205 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1208 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1209 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1211 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1212 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1215 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1223 /*******************************************************************
1225 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1229 * Function : fillInitDlBwpPdschCfg
1232 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1234 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1235 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1236 * @return ROK - success
1239 * ****************************************************************/
1240 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1244 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1245 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1246 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1247 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1248 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1250 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1251 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1255 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1257 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1259 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1260 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1262 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1265 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1267 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1268 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1269 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1270 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1271 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1272 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1275 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1276 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1277 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1278 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1280 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1282 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1284 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1285 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1290 /*******************************************************************
1292 * @brief Fill Initial DL BWP for SCH UE config
1296 * Function : fillInitialDlBwp
1298 * Functionality: Fill Initial DL BWP for SCH UE config
1300 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1301 * schInitDlBwp : Inital DL BWP cfg to be filled
1302 * @return ROK - success
1305 * ****************************************************************/
1306 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1308 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1309 if(schInitDlBwp->pdcchCfgPres)
1311 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1313 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1318 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1319 if(schInitDlBwp->pdschCfgPres)
1321 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1323 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1330 /*******************************************************************
1332 * @brief Fills Sp Cell config to be sent to scheduler
1336 * Function : fillSpCellCfg
1338 * Functionality: Fills Sp Cell config to be sent to scheduler
1340 * @params[in] macSpCellCfg : SP cell cfg at MAC
1341 * schSpCellCfg : SP cell cfg to be filled
1342 * @return ROK - success
1345 * ****************************************************************/
1346 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1349 SchServCellCfgInfo *servCellCfg;
1351 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1352 servCellCfg = &schSpCellCfg->servCellCfg;
1354 /* Fill initial DL BWP */
1355 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1356 &servCellCfg->initDlBwp) != ROK )
1358 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1362 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1363 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1365 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD [%d] exceeds max limit [%d]",\
1366 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1369 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1371 memcpy(&servCellCfg->dlBwpToAddList[idx], &macSpCellCfg.servCellCfg.dlBwpToAddList[idx], sizeof(DlBwpInfo));
1373 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1374 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1375 servCellCfg->bwpInactivityTmr = NULL;
1376 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1378 /* TODO : This is an optional parameter, not filled currently */
1381 /* Fill PDSCH serving cell config */
1382 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1383 &servCellCfg->pdschServCellCfg) != ROK)
1385 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1389 /* Fill Initail UL BWP */
1390 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1391 &servCellCfg->initUlBwp) != ROK)
1393 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1397 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1398 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1400 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD [%d] exceeds max limit [%d]",\
1401 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1404 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1406 memcpy(&servCellCfg->ulBwpToAddList[idx], &macSpCellCfg.servCellCfg.ulBwpToAddList[idx], sizeof(UlBwpInfo));
1408 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1413 /*******************************************************************
1415 * @brief Fills Sp Cell Reconfig to be sent to scheduler
1419 * Function : fillSpCellRecfg
1421 * Functionality: Fills Sp Cell Reconfig to be sent to scheduler
1423 * @params[in] macSpCellRecfg : SP cell Recfg at MAC
1424 * schSpCellRecfg : SP cell Recfg to be filled
1425 * @return ROK - success
1428 * ****************************************************************/
1429 uint8_t fillSpCellRecfg(SpCellRecfg macSpCellRecfg, SchSpCellRecfg *schSpCellRecfg)
1432 SchServCellRecfgInfo *servCellRecfg;
1434 schSpCellRecfg->servCellIdx = macSpCellRecfg.servCellIdx;
1435 servCellRecfg = &schSpCellRecfg->servCellRecfg;
1437 /* Fill initial DL BWP */
1438 if(fillInitialDlBwp(macSpCellRecfg.servCellCfg.initDlBwp, \
1439 &servCellRecfg->initDlBwp) != ROK )
1441 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1445 servCellRecfg->numDlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numDlBwpToAddOrMod;
1446 if(servCellRecfg->numDlBwpToAddOrMod > MAX_NUM_BWP)
1448 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1449 servCellRecfg->numDlBwpToAddOrMod, MAX_NUM_BWP);
1452 for(idx = 0; idx < servCellRecfg->numDlBwpToAddOrMod; idx++)
1454 memcpy(&servCellRecfg->dlBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.dlBwpToAddOrModList[idx], sizeof(DlBwpInfo));
1456 servCellRecfg->numDlBwpToRel = macSpCellRecfg.servCellCfg.numDlBwpToRel;
1457 if(servCellRecfg->numDlBwpToRel > MAX_NUM_BWP)
1459 DU_LOG("\nERROR --> MAC : Number of DL BWP to RELEASE [%d] exceeds max limit [%d]",\
1460 servCellRecfg->numDlBwpToRel, MAX_NUM_BWP);
1463 for(idx = 0; idx < servCellRecfg->numDlBwpToRel; idx++)
1465 memcpy(&servCellRecfg->dlBwpToRelList[idx], &macSpCellRecfg.servCellCfg.dlBwpToRelList[idx], sizeof(DlBwpInfo));
1467 servCellRecfg->firstActvDlBwpId = macSpCellRecfg.servCellCfg.firstActvDlBwpId;
1468 servCellRecfg->defaultDlBwpId = macSpCellRecfg.servCellCfg.defaultDlBwpId;
1469 servCellRecfg->bwpInactivityTmr = NULL;
1470 if(macSpCellRecfg.servCellCfg.bwpInactivityTmr)
1472 /* TODO : This is an optional parameter, not filled currently */
1475 /* Fill PDSCH serving cell config */
1476 if(fillPdschServCellCfg(macSpCellRecfg.servCellCfg.pdschServCellCfg, \
1477 &servCellRecfg->pdschServCellCfg) != ROK)
1479 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1483 /* Fill Initail UL BWP */
1484 if(fillInitialUlBwp(macSpCellRecfg.servCellCfg.initUlBwp, \
1485 &servCellRecfg->initUlBwp) != ROK)
1487 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1491 servCellRecfg->numUlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numUlBwpToAddOrMod;
1492 if(servCellRecfg->numUlBwpToAddOrMod > MAX_NUM_BWP)
1494 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1495 servCellRecfg->numUlBwpToAddOrMod, MAX_NUM_BWP);
1498 for(idx = 0; idx < servCellRecfg->numUlBwpToAddOrMod; idx++)
1500 memcpy(&servCellRecfg->ulBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.ulBwpToAddOrModList[idx], sizeof(UlBwpInfo));
1502 servCellRecfg->numUlBwpToRel = macSpCellRecfg.servCellCfg.numUlBwpToRel;
1503 if(servCellRecfg->numUlBwpToRel > MAX_NUM_BWP)
1505 DU_LOG("\nERROR --> MAC : Number of UL BWP to RELEASE [%d] exceeds max limit [%d]",\
1506 servCellRecfg->numUlBwpToRel, MAX_NUM_BWP);
1509 for(idx = 0; idx < servCellRecfg->numUlBwpToRel; idx++)
1511 memcpy(&servCellRecfg->ulBwpToRelList[idx], &macSpCellRecfg.servCellCfg.ulBwpToRelList[idx], sizeof(UlBwpInfo));
1513 servCellRecfg->firstActvUlBwpId = macSpCellRecfg.servCellCfg.firstActvUlBwpId;
1518 /*******************************************************************
1520 * @brief Sends UE configuration to Scheduler
1524 * Function : sendUeReqToSch
1526 * Functionality: sends UE configuration to Scheduler
1528 * @params[in] Pst and Ue configuration
1529 * @return ROK - success
1532 * ****************************************************************/
1534 uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg)
1539 case EVENT_MAC_UE_CREATE_REQ:
1541 SchUeCfgReq *schUeCfgReq = NULLP;
1542 schUeCfgReq = (SchUeCfgReq *)schUeCfg;
1543 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1544 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfgReq);
1546 case EVENT_MAC_UE_RECONFIG_REQ:
1548 SchUeRecfgReq *schUeRecfgReq = NULLP;
1549 schUeRecfgReq = (SchUeRecfgReq *)schUeCfg;
1550 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1551 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeRecfgReq);
1555 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1561 /*******************************************************************
1563 * @brief Fills Sch Drb Qos Information
1567 * Function : fillSchDrbQosInfo
1569 * Functionality: Fills Sch Drb Qos Information
1571 * @params[in] macLcCfg : Logical channel Cfg at MAC
1572 * schLcCfg : LC cfg to fill at scheduler
1573 * @return ROK - success
1576 * ****************************************************************/
1577 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1579 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1580 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1582 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1583 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1584 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1585 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1587 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1589 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1590 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1591 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1592 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1593 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1594 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1595 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1596 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1598 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1599 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1600 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1601 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1602 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1603 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1604 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1605 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1606 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1609 /*******************************************************************
1611 * @brief Fill SCH UL logical channel configuration
1615 * Function : fillSchUlLcCfg
1617 * Functionality: Fills Sch Ul Lc configuration
1619 * @params[in] macLcCfg : Logical channel Cfg at MAC
1620 * schLcCfg : LC cfg to fill at scheduler
1623 * ****************************************************************/
1625 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1627 schUlLcCfg->priority= macUlLcCfg->priority;
1628 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1629 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1630 schUlLcCfg->pbr = macUlLcCfg->pbr;
1631 schUlLcCfg->bsd = macUlLcCfg->bsd;
1634 /*******************************************************************
1636 * @brief Fill logical channel configuration
1640 * Function : fillLogicalChannelCfg
1642 * Functionality: Fill logical channel configuration
1644 * @params[in] macLcCfg : Logical channel Cfg at MAC
1645 * schLcCfg : LC cfg to fill at scheduler
1646 * @return ROK - success
1649 * ****************************************************************/
1650 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1654 schLcCfg->lcId = macLcCfg->lcId;
1655 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1656 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1658 if(macLcCfg->drbQos)
1660 if(!schLcCfg->drbQos)
1662 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1663 if(!schLcCfg->drbQos)
1665 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1671 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1678 schLcCfg->drbQos = NULLP;
1683 if(macLcCfg->snssai)
1685 if(!schLcCfg->snssai)
1687 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1688 if(!schLcCfg->snssai)
1690 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1696 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1697 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1699 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1705 schLcCfg->snssai = NULLP;
1712 /*******************************************************************
1714 * @brief Fills Logical channel Cfg List to Add
1718 * Function : fillSchLcCfgList
1720 * Functionality: Fills Logical channel Cfg List to Add
1722 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1723 * @return ROK - success
1726 * ****************************************************************/
1728 uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1732 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1734 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1736 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1739 schUeCfg->numLcsToAdd++;
1744 /*******************************************************************
1746 * @brief Fills Logical channel Recfg List to Add/Mod/Del
1750 * Function : fillSchLcRecfgList
1752 * Functionality: Fills Logical channel Recfg List to Add/Mod/Del
1754 * @params[in] MAC UE Cb Recfg , MAC UE ReConfiguration
1755 * @return ROK - success
1758 * ****************************************************************/
1760 uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1765 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
1767 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgAdd[lcIdx], &ueRecfg->lcCfgAdd[lcIdx]) != ROK)
1769 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1772 schUeRecfg->numLcsToAdd++;
1775 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
1777 schUeRecfg->lcIdToDel[lcIdx] = ueRecfg->lcIdToDel[lcIdx];
1778 schUeRecfg->numLcsToDel++;
1781 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
1783 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgMod[lcIdx], &ueRecfg->lcCfgMod[lcIdx]) != ROK)
1785 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1788 schUeRecfg->numLcsToMod++;
1793 /*******************************************************************
1795 * @brief Fills and sends UE configuration to Scheduler
1799 * Function : fillSchUeCfg
1801 * Functionality: Fills and sends UE configuration to Scheduler
1803 * @params[in] Ue configuration from DU APP
1804 * @return ROK - success
1807 * ****************************************************************/
1808 uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1812 schUeCfg->cellId = ueCfg->cellId;
1813 schUeCfg->ueId = ueCfg->ueId;
1814 schUeCfg->crnti = ueCfg->crnti;
1815 /* Copy MAC cell group config */
1816 if(ueCfg->macCellGrpCfgPres == true)
1818 schUeCfg->macCellGrpCfgPres = true;
1819 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1820 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1822 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1826 if(ueCfg->phyCellGrpCfgPres == true)
1828 schUeCfg->phyCellGrpCfgPres = true;
1829 /* Copy Physical cell group config */
1830 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1831 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1833 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1838 if(ueCfg->spCellCfgPres == true)
1840 schUeCfg->spCellCfgPres = true;
1841 /* Copy sp cell config */
1842 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1843 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1845 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1849 if(ueCfg->ambrCfg != NULLP)
1851 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1852 if(!schUeCfg->ambrCfg)
1854 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1857 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1861 schUeCfg->ambrCfg = NULLP;
1863 /* Fill DL modulation infor */
1864 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1865 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1866 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1868 /* Fill UL modulation infor */
1869 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1870 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1871 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1873 /* Fill sch Lc Cfg to Add*/
1874 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1877 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1884 /*******************************************************************
1886 * @brief Fills and sends UE Re-configuration to Scheduler
1890 * Function : fillSchUeRecfg
1892 * Functionality: Fills and sends UE Reconfiguration to Scheduler
1894 * @params[in] Ue configuration from DU APP
1895 * @return ROK - success
1898 * ****************************************************************/
1899 uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1903 schUeRecfg->cellId = ueRecfg->cellId;
1904 schUeRecfg->ueId = ueRecfg->ueId;
1905 schUeRecfg->crnti = ueRecfg->crnti;
1906 schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
1907 /* Copy MAC cell group config */
1908 if(ueRecfg->macCellGrpRecfgPres == true)
1910 schUeRecfg->macCellGrpRecfgPres = true;
1911 memset(&schUeRecfg->macCellGrpRecfg, 0, sizeof(SchMacCellGrpCfg));
1912 if(fillMacCellGroupCfg(ueRecfg->macCellGrpRecfg, &schUeRecfg->macCellGrpRecfg) != ROK)
1914 DU_LOG("\nERROR --> MAC : fillMacCellGroupRecfg() failed");
1918 if(ueRecfg->phyCellGrpRecfgPres == true)
1920 schUeRecfg->phyCellGrpRecfgPres = true;
1921 /* Copy Physical cell group config */
1922 memset(&schUeRecfg->phyCellGrpRecfg, 0,sizeof(SchPhyCellGrpCfg));
1923 if(fillPhyCellGroupCfg(ueRecfg->phyCellGrpRecfg, &schUeRecfg->phyCellGrpRecfg) != ROK)
1925 DU_LOG("\nERROR --> MAC : fillPhyCellGroupRecfg() failed");
1930 if(ueRecfg->spCellRecfgPres == true)
1932 schUeRecfg->spCellRecfgPres = true;
1933 /* Copy sp cell config */
1934 memset(&schUeRecfg->spCellRecfg, 0, sizeof(SchSpCellCfg));
1935 if(fillSpCellRecfg(ueRecfg->spCellRecfg, &schUeRecfg->spCellRecfg) != ROK)
1937 DU_LOG("\nERROR --> MAC : fillSpCellRecfg() failed");
1941 if(ueRecfg->ambrRecfg != NULLP)
1943 MAC_ALLOC(schUeRecfg->ambrRecfg, sizeof(SchAmbrCfg));
1944 if(!schUeRecfg->ambrRecfg)
1946 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1949 schUeRecfg->ambrRecfg->ulBr = ueRecfg->ambrRecfg->ulBr;
1953 schUeRecfg->ambrRecfg = NULLP;
1955 /* Fill DL modulation infor */
1956 schUeRecfg->dlModInfo.modOrder = ueRecfg->dlModInfo.modOrder;
1957 schUeRecfg->dlModInfo.mcsIndex = ueRecfg->dlModInfo.mcsIndex;
1958 schUeRecfg->dlModInfo.mcsTable = ueRecfg->dlModInfo.mcsTable;
1960 /* Fill UL modulation infor */
1961 schUeRecfg->ulModInfo.modOrder = ueRecfg->ulModInfo.modOrder;
1962 schUeRecfg->ulModInfo.mcsIndex = ueRecfg->ulModInfo.mcsIndex;
1963 schUeRecfg->ulModInfo.mcsTable = ueRecfg->ulModInfo.mcsTable;
1965 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1966 ret = fillSchLcRecfgList(schUeRecfg, ueRecfg);
1969 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeRecfg()");
1974 schUeRecfg->drxConfigIndicatorRelease = ueRecfg->drxConfigIndicatorRelease;;
1980 /*******************************************************************
1982 * @brief Update UeUlCb Lc List
1986 * Function : updateMacUlCb
1988 * Functionality: Update UeUlCb Lc List
1990 * @params[in] delIdx, UeUlCb pointer
1993 * ****************************************************************/
1995 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1999 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
2001 /* Moving the array element to one step ahead */
2002 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
2003 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
2005 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2007 /*Checking the Memory Leakage of Last Index*/
2008 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
2010 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
2012 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
2016 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
2022 /*******************************************************************
2024 * @brief Update UeDlCb Lc List
2028 * Function : updateMacDlCb
2030 * Functionality: Update UeDlCb Lc List
2032 * @params[in] delIdx, UeDlCb pointer
2035 * ****************************************************************/
2037 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
2041 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
2043 /* Moving the array element to one step ahead */
2044 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
2045 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
2047 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2049 /*Checking the Memory Leakage of Last Index*/
2050 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
2052 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
2054 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
2058 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
2064 /*******************************************************************
2066 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
2070 * Function : updateMacUlLcCtxt
2072 * Functionality: Update UeUlCb Lc List
2074 * @params[in] UeUlCb pointer [For DEL case, NULL is passed]
2075 * ueLcCfg(received from DUAPP)
2076 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2079 * ****************************************************************/
2080 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2082 uint8_t ueLcIdx = 0;
2084 /*Traversing UL LC to be updated/Deleted*/
2085 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
2087 if((ueLcCfg != NULLP) && (ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2089 /*Modify UL LC CB */
2090 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
2092 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2094 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2097 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2101 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
2103 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2106 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2109 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2110 ueLcCfg->lcId,ueLcIdx);
2113 else if(lcIdToDel != MAX_NUM_LC && (ulInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2115 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
2116 (ulInfo->numUlLc)--;
2117 updateMacUlCb(ueLcIdx, ulInfo);
2118 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2124 /*******************************************************************
2126 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
2130 * Function : updateMacDlLcCtxt
2132 * Functionality: Update UeDlCb Lc List
2134 * @params[in] UeDlCb pointer [For DEL case, NULL is passed]
2135 * ueLcCfg(received from DUAPP)
2136 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2139 * ****************************************************************/
2140 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2142 uint8_t ueLcIdx = 0;
2144 /*Traversing DL LC to be updated/Deleted*/
2145 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
2147 if((ueLcCfg != NULLP) && (dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2149 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2151 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2154 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2158 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
2160 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2163 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2166 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2167 ueLcCfg->lcId,ueLcIdx);
2170 else if(lcIdToDel != MAX_NUM_LC && (dlInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2172 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
2173 (dlInfo->numDlLc)--;
2174 updateMacDlCb(ueLcIdx, dlInfo);
2175 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2181 /*******************************************************************
2183 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2187 * Function : fillMacLcCfgList
2189 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2191 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2192 * @return ROK - success
2195 * ****************************************************************/
2197 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
2201 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
2203 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2205 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2207 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2208 if(ueCfg->lcCfgList[lcIdx].drbQos)
2210 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2211 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2213 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2214 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2216 if(ueCfg->lcCfgList[lcIdx].snssai)
2218 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2220 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2222 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2224 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2227 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2228 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2230 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2231 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2235 /*Filling DL LC CB */
2236 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2237 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2238 ueCb->dlInfo.numDlLc++;
2239 /*Filling UL LC CB */
2240 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2241 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
2242 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2243 ueCb->ulInfo.numUlLc++;
2249 /*******************************************************************
2251 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2255 * Function : updateMacLcCfgList
2257 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2259 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2260 * @return ROK - success
2263 * ****************************************************************/
2265 uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2269 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
2271 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2273 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2275 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2276 if(ueRecfg->lcCfgList[lcIdx].drbQos)
2278 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2279 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2281 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2282 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2284 if(ueRecfg->lcCfgList[lcIdx].snssai)
2286 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2288 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2290 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2292 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2295 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2296 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2298 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2299 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2303 /*Filling DL LC CB */
2304 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2305 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2306 ueCb->dlInfo.numDlLc++;
2307 /*Filling UL LC CB */
2308 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2309 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueRecfg->lcCfgAdd[lcIdx].ulLcCfg.lcGroup;
2310 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2311 ueCb->ulInfo.numUlLc++;
2312 }/*End of Add Config */
2314 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
2316 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2318 updateMacUlLcCtxt(&ueCb->ulInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2319 updateMacDlLcCtxt(&ueCb->dlInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2322 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
2324 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2326 updateMacUlLcCtxt(&ueCb->ulInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2327 updateMacDlLcCtxt(&ueCb->dlInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2333 /*******************************************************************
2335 * @brief Fills MAC UE Cb Cfg
2339 * Function : fillMacUeCb
2341 * Functionality: Fills MAC UE Cb Cfg
2343 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2345 * @return ROK - success
2348 * ****************************************************************/
2350 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
2354 ueCb->ueId = ueCfg->ueId;
2355 ueCb->crnti = ueCfg->crnti;
2356 ueCb->cellCb = macCb.macCell[cellIdx];
2357 if(ueCfg->spCellCfgPres)
2359 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2360 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2363 /*TODO: To check the bsr value during implementation */
2364 if(ueCfg->macCellGrpCfgPres)
2366 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2367 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2368 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2370 ret = fillMacLcCfgList(ueCb, ueCfg);
2373 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2378 /*******************************************************************
2380 * @brief Fills MAC UE Cb Cfg
2384 * Function : updateMacUeCb
2386 * Functionality: updateMacUeCbs MAC UE Cb Cfg
2388 * @params[in] MAC UE Cb Recfg , MAC UE Configuration
2390 * @return ROK - success
2393 * ****************************************************************/
2395 uint8_t updateMacUeCb(MacUeCb *ueCb, MacUeRecfg *ueRecfg, uint8_t cellIdx)
2399 ueCb->ueId = ueRecfg->ueId;
2400 ueCb->crnti = ueRecfg->crnti;
2401 ueCb->cellCb = macCb.macCell[cellIdx];
2402 if(ueRecfg->spCellRecfgPres)
2404 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2405 ueRecfg->spCellRecfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2408 /*TODO: To check the bsr value during implementation */
2409 if(ueRecfg->macCellGrpRecfgPres)
2411 ueCb->bsrTmrCfg.periodicTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.periodicTimer;
2412 ueCb->bsrTmrCfg.retxTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.retxTimer;
2413 ueCb->bsrTmrCfg.srDelayTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.srDelayTimer;
2415 ret = updateMacLcCfgList(ueCb, ueRecfg);
2418 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at updateMacUeCb()");
2420 ueCb->transmissionAction = ueRecfg->transmissionAction;
2425 /*******************************************************************
2427 * @brief Function to update Mac Ra Cb
2431 * Function : updateMacRaCb
2433 * Functionality: Function to update Mac Ra Cb
2435 * @params[in] cellIdx, Mac Ue Cb
2436 * @return ROK - success
2439 * ****************************************************************/
2441 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2444 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2446 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2450 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2456 /*******************************************************************
2458 * @brief Function to delete Mac Ra Cb
2462 * Function : deleteMacRaCb
2464 * Functionality: Function to delete Mac Ra Cb
2466 * @params[in] cellIdx, Mac Ue Cb
2469 * ****************************************************************/
2471 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2474 MacRaCbInfo *raCb = ueCb->raCb;
2476 if(raCb && (raCb->crnti == ueCb->crnti))
2478 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2479 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2481 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2482 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
2484 memset(raCb, 0, sizeof(MacRaCbInfo));
2488 /*******************************************************************
2490 * @brief Creates UE Cb
2494 * Function : createUeCb
2496 * Functionality: Creates UE Cb
2498 * @params[in] MAC UE Configuration
2499 * @return ROK - success
2502 * ****************************************************************/
2503 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2506 uint8_t hqProcIdx = 0;
2508 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2509 &&(ueCb->state == UE_STATE_ACTIVE))
2511 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2516 memset(ueCb, 0, sizeof(MacUeCb));
2517 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2520 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2525 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2526 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2528 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2531 /* If UE has not requested for RACH yet, it means UE context is created for a
2533 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2535 ueCb->state = UE_STATE_ACTIVE;
2536 macCb.macCell[cellIdx]->numActvUe++;
2537 updateMacRaCb(cellIdx, ueCb);
2540 ueCb->state = UE_HANDIN_IN_PROGRESS;
2548 /*******************************************************************
2550 * @brief Modify UE Cb Cfg
2554 * Function : modifyUeCb
2556 * Functionality: modify UE Cb
2558 * @params[in] MAC UE Configuration
2559 * @return ROK - success
2562 * ****************************************************************/
2563 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2567 if((ueCb->ueId == ueRecfg->ueId) && (ueCb->crnti == ueRecfg->crnti)\
2568 &&(ueCb->state == UE_STATE_ACTIVE))
2570 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueRecfg->crnti);
2571 ret = updateMacUeCb(ueCb, ueRecfg, cellIdx);
2574 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2586 /*******************************************************************
2588 * @brief Creates UE Cb and fills ueCfg
2592 * Function : procMacUeCfgData
2594 * Functionality: Creates UE Cb and fills ueCfg
2596 * @params[in] MAC UE Configuration
2597 * @return ROK - success
2600 * ****************************************************************/
2602 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2604 uint8_t ret = ROK, ueId = 0;
2605 uint16_t cellIdx, cellId;
2606 MacUeCb *ueCb = NULLP;
2610 cellId = ueCfg->cellId;
2613 else if(ueRecfg != NULLP)
2615 cellId = ueRecfg->cellId;
2616 ueId = ueRecfg->ueId;
2620 GET_CELL_IDX(cellId, cellIdx);
2622 /* Validate cell id */
2623 if(macCb.macCell[cellIdx]->cellId != cellId)
2625 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", cellId);
2629 /* Check if max number of UE configured */
2630 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2632 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2636 /* Check if UE already configured */
2637 ueCb = &macCb.macCell[cellIdx]->ueCb[ueId -1];
2641 case EVENT_UE_CONFIG_RSP_TO_MAC:
2643 ret = createUeCb(cellIdx, ueCb, ueCfg);
2645 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2649 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2651 ret = modifyUeCb(cellIdx, ueCb, ueRecfg);
2653 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2664 /*******************************************************************
2666 * @brief Function to store the UeCfg Data
2670 * Function : copyToTmpData
2672 * Functionality: Function to store the UeCfg Data
2674 * @params[in] MacUeCfg pointer
2675 * @return ROK - success
2678 * ****************************************************************/
2680 uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2686 MacUeCfg *tmpData = NULLP;
2688 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2691 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2694 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2695 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2696 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2698 else if(ueRecfg != NULLP)
2700 MacUeRecfg *tmpData = NULLP;
2702 MAC_ALLOC(tmpData, sizeof(MacUeRecfg));
2705 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2708 memcpy(tmpData, ueRecfg, sizeof(MacUeRecfg));
2709 GET_CELL_IDX(ueRecfg->cellId, cellIdx);
2710 macCb.macCell[cellIdx]->ueRecfgTmpData[ueRecfg->ueId-1] = tmpData;
2715 /*******************************************************************
2717 * @brief Handles UE create requst from DU APP
2721 * Function : MacProcUeCreateReq
2723 * Functionality: Handles UE create requst from DU APP
2726 * @return ROK - success
2729 * ****************************************************************/
2730 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2733 SchUeCfgReq schUeCfg;
2734 memset(&schUeCfg, 0, sizeof(SchUeCfgReq));
2736 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2740 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2741 * case of UE in handover */
2742 if(ueCfg->crnti == 0)
2744 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2747 /*Storing received ueCfg in ueCfgTmpData */
2748 ret = copyToTmpData(ueCfg, NULLP);
2751 /*Sending Cfg Req to SCH */
2752 ret = fillSchUeCfg(&schUeCfg, ueCfg);
2754 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2757 /* Fill event and send UE create request to SCH */
2758 ret = sendUeReqToSch(pst, &schUeCfg);
2760 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2765 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2770 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2773 /* FREE shared memory */
2774 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2779 /*******************************************************************
2781 * @brief Fill and Send UE create response from MAC to DU APP
2785 * Function : MacSendUeCreateRsp
2787 * Functionality: Fill and Send UE create response from MAC to DUAPP
2789 * @params[in] MAC UE create result
2790 * SCH UE create response
2791 * @return ROK - success
2794 * ****************************************************************/
2795 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2797 MacUeCfgRsp *cfgRsp;
2800 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2803 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2807 /* Filling UE Config response */
2808 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2809 cfgRsp->cellId = schCfgRsp->cellId;
2810 cfgRsp->ueId = schCfgRsp->ueId;
2811 cfgRsp->result = result;
2813 /* Fill Post structure and send UE Create response*/
2814 memset(&rspPst, 0, sizeof(Pst));
2815 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2816 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2819 /*******************************************************************
2821 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2825 * Function : MacSendUeReconfigRsp
2827 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2829 * @params[in] MAC UE create result
2830 * SCH UE create response
2831 * @return ROK - success
2834 * ****************************************************************/
2835 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
2837 MacUeRecfgRsp *recfgRsp;
2840 MAC_ALLOC_SHRABL_BUF(recfgRsp, sizeof(MacUeRecfgRsp));
2843 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2847 /* Filling UE Config response */
2848 memset(recfgRsp, 0, sizeof(MacUeRecfgRsp));
2849 recfgRsp->cellId = schCfgRsp->cellId;
2850 recfgRsp->ueId = schCfgRsp->ueId;
2851 recfgRsp->result = result;
2853 /* Fill Post structure and send UE Create response*/
2854 memset(&rspPst, 0, sizeof(Pst));
2855 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2856 return (*macDuUeRecfgRspOpts[rspPst.selector])(&rspPst, recfgRsp);
2859 /*******************************************************************
2861 * @brief Function to return Mac Ue Cfg pointer
2865 * Function : getMacUeCfg
2868 * Function to return Mac Ue Cfg pointer
2870 * @params[in] cellIdx, ueId
2872 * @return MacUeCfg pointer - success
2875 * ****************************************************************/
2877 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2879 MacUeCfg *ueCfg = NULLP;
2880 if(macCb.macCell[cellIdx])
2882 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2886 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2891 /*******************************************************************
2893 * @brief Function to return Mac Ue Recfg pointer
2897 * Function : getMacUeRecfg
2900 * Function to return Mac Ue Recfg pointer
2902 * @params[in] cellIdx, ueId
2904 * @return MacUeRecfg pointer - success
2907 * ****************************************************************/
2909 MacUeRecfg *getMacUeRecfg(uint16_t cellIdx, uint8_t ueId)
2911 MacUeRecfg *ueRecfg = NULLP;
2912 if(macCb.macCell[cellIdx])
2914 ueRecfg = macCb.macCell[cellIdx]->ueRecfgTmpData[ueId-1];
2918 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeRecfg()");
2923 /*******************************************************************
2925 * @brief Processes UE create response from scheduler
2929 * Function : MacProcSchUeCfgRsp
2932 * Processes UE create response from scheduler
2933 * Sends UE create response to DU APP
2935 * @params[in] Pst : Post structure
2936 * schCfgRsp : Scheduler UE cfg response
2937 * @return ROK - success
2940 * ****************************************************************/
2941 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2943 uint8_t result = MAC_DU_APP_RSP_NOK;
2946 MacUeCfg *ueCfg = NULLP;
2948 #ifdef CALL_FLOW_DEBUG_LOG
2951 case EVENT_UE_CONFIG_RSP_TO_MAC:
2952 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2954 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2955 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2958 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2963 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2964 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
2967 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2971 if(schCfgRsp->rsp != RSP_NOK)
2973 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2976 ret = procMacUeCfgData(pst, ueCfg, NULLP);
2979 result = MAC_DU_APP_RSP_OK;
2985 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2987 ret = MacSendUeCreateRsp(result, schCfgRsp);
2988 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2993 /*******************************************************************
2995 * @brief Processes UE create response from scheduler
2999 * Function : MacProcSchUeRecfgRsp
3002 * Processes UE ReConfig response from scheduler
3003 * Sends UE Reconfig response to DU APP
3005 * @params[in] Pst : Post structure
3006 * schRecfgRsp : Scheduler UE Recfg response
3007 * @return ROK - success
3010 * ****************************************************************/
3011 uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
3013 uint8_t result = MAC_DU_APP_RSP_NOK;
3016 MacUeRecfg *ueRecfg = NULLP;
3018 #ifdef CALL_FLOW_DEBUG_LOG
3021 case EVENT_UE_RECONFIG_RSP_TO_MAC:
3022 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
3025 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
3030 GET_CELL_IDX(schRecfgRsp->cellId, cellIdx);
3031 ueRecfg = getMacUeRecfg(cellIdx, schRecfgRsp->ueId);
3032 if(ueRecfg == NULLP)
3034 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3039 if(schRecfgRsp->rsp != RSP_NOK)
3041 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
3042 schRecfgRsp->crnti);
3045 ret = procMacUeCfgData(pst, NULLP, ueRecfg);
3048 result = MAC_DU_APP_RSP_OK;
3054 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
3055 schRecfgRsp->crnti);
3057 ret = MacSendUeReconfigRsp(result, schRecfgRsp);
3058 MAC_FREE(ueRecfg, sizeof(MacUeRecfg));
3063 /*******************************************************************
3065 * @brief Handles UE Reconfig requst from DU APP
3069 * Function : MacProcUeReconfigReq
3071 * Functionality: Handles UE Reconfig requst from DU APP
3074 * @return ROK - success
3077 * ****************************************************************/
3078 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeRecfg *ueRecfg)
3081 SchUeRecfgReq schUeRecfg;
3082 memset(&schUeRecfg, 0, sizeof(SchUeRecfgReq));
3084 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueRecfg->crnti);
3088 /*Storing received ueRecfg in ueCfgTmpData */
3089 ret = copyToTmpData(NULLP, ueRecfg);
3092 /*Sending Cfg Req to SCH */
3093 ret = fillSchUeRecfg(&schUeRecfg, ueRecfg);
3095 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
3098 /* Fill event and send UE Reconfiguration request to SCH */
3099 ret = sendUeReqToSch(pst, &schUeRecfg);
3101 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
3106 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
3111 DU_LOG("\nERROR --> MAC : MAC UE Reconfiguration request processing failed");
3114 /* FREE shared memory */
3115 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(MacUeRecfg));
3119 /*******************************************************************
3121 * @brief Fill and Send UE Delete response from MAC to DU APP
3125 * Function : MacSendUeDeleteRsp
3127 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
3129 * @params[in] MAC UE delete result
3130 * SCH UE delete response
3131 * @return ROK - success
3134 * ****************************************************************/
3136 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result)
3138 MacUeDeleteRsp *deleteRsp;
3141 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
3144 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
3148 /* Filling UE delete response */
3149 deleteRsp->cellId = cellId;
3150 GET_UE_ID(crnti, deleteRsp->ueId);
3151 deleteRsp->result = result;
3153 /* Fill Post structure and send UE delete response*/
3154 memset(&rspPst, 0, sizeof(Pst));
3155 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
3156 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
3159 /*******************************************************************
3161 * @brief freeing the Pucch Resrc Cfg
3165 * Function : deletePucchResourcesCfg
3167 * Functionality: freeing the Pucch Resrc Cfg
3169 * @params[in] PucchResrcCfg *resrcCfg
3170 * @return ROK - success
3173 * ****************************************************************/
3175 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
3178 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
3180 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
3182 case PUCCH_FORMAT_0:
3184 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
3187 case PUCCH_FORMAT_1:
3189 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
3192 case PUCCH_FORMAT_2:
3194 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
3197 case PUCCH_FORMAT_3:
3199 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
3202 case PUCCH_FORMAT_4:
3204 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
3212 /*******************************************************************
3214 * @brief Processes UE delete response from scheduler
3218 * Function : MacProcSchUeDeleteRsp
3221 * Processes UE delete from scheduler
3223 * @params[in] Pst : Post structure
3224 * schUeDelRsp : Scheduler UE delete respons
3225 * @return ROK - success
3228 * ****************************************************************/
3230 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
3232 uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
3234 uint8_t ret = RFAILED;
3235 UeDeleteStatus result;
3236 DlHarqEnt *dlHarqEnt;
3238 #ifdef CALL_FLOW_DEBUG_LOG
3239 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
3244 if(schUeDelRsp->rsp == RSP_OK)
3246 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
3247 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
3248 if(macCb.macCell[cellIdx])
3250 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
3253 /*C-RNTI value is out of Acceptable range*/
3254 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
3255 result = UEID_INVALID;
3259 GET_UE_ID(schUeDelRsp->crnti, ueId);
3260 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
3263 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
3265 /*Looping around LCs to free S-NSSAI memory*/
3266 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
3268 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3270 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
3272 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3275 dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
3276 for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
3279 while(dlHarqEnt->harqProcCb[idx].numTb)
3282 MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
3283 dlHarqEnt->harqProcCb[idx].numTb--;
3287 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
3288 macCb.macCell[cellIdx]->numActvUe--;
3289 result = DEL_SUCCESSFUL;
3294 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
3295 result = UEID_INVALID;
3301 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
3302 result = CELLID_INVALID;
3307 result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEID_INVALID;
3309 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK)
3311 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
3316 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
3322 /*******************************************************************
3324 * @brief Sends UE delete req to Scheduler
3328 * Function : sendUeDelReqToSch
3330 * Functionality: sends UE delete req to Scheduler
3332 * @params[in] Pst *pst, MacUeDelete *ueDelete
3333 * @return ROK - success
3336 * ****************************************************************/
3338 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
3340 if(ueDelete != NULLP)
3343 SchUeDelete schUeDel;
3345 memset(&schUeDel, 0, sizeof(SchUeDelete));
3346 schUeDel.cellId = ueDelete->cellId;
3347 schUeDel.crnti = ueDelete->crnti;
3348 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3349 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
3350 return(*macSchUeDeleteReqOpts[schPst.selector])(&schPst, &schUeDel);
3354 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
3360 /*******************************************************************
3362 * @brief Handles UE Delete requst from DU APP
3366 * Function : MacProcUeDeleteReq
3368 * Functionality: Handles UE Delete requst from DU APP
3370 * @params[in] Pst *pst, MacUeDelete *ueDelete
3371 * @return ROK - success
3374 * ****************************************************************/
3376 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
3380 UeDeleteStatus result=DEL_SUCCESSFUL;
3381 MacUeCb *ueCb = NULLP;
3382 MacCellCb *cellCb = NULLP;
3384 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
3388 GET_CELL_IDX(ueDelete->cellId, cellIdx);
3389 cellCb = macCb.macCell[cellIdx];
3392 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
3393 if(ueCb->crnti == ueDelete->crnti)
3395 ret = sendUeDelReqToSch(pst, ueDelete);
3398 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
3404 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
3405 result = UEID_INVALID;
3410 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
3411 result = CELLID_INVALID;
3414 if(result != DEL_SUCCESSFUL)
3416 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result);
3417 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3423 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
3429 /**********************************************************************
3431 **********************************************************************/