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 MacSchModUeConfigReqFunc macSchModUeConfigReqOpts[] =
48 packMacSchModUeConfigReq, /* packing for loosely coupled */
49 MacSchModUeConfigReq, /* packing for tightly coupled */
50 packMacSchModUeConfigReq /* packing for light weight loosely coupled */
53 MacSchUeDeleteReqFunc macSchUeDeleteReqOpts[] =
55 packMacSchUeDeleteReq, /* packing for loosely coupled */
56 MacSchUeDeleteReq, /* packing for tightly coupled */
57 packMacSchUeDeleteReq /* packing for light weight loosely coupled */
60 MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] =
62 packDuMacUeDeleteRsp, /* packing for loosely coupled */
63 DuProcMacUeDeleteRsp, /* packing for tightly coupled */
64 packDuMacUeDeleteRsp /* packing for light weight loosly coupled */
67 /*******************************************************************
69 * @brief Fills mac cell group config to be sent to scheduler
73 * Function : fillMacCellGroupCfg
75 * Functionality: Fills mac cell group config to be sent to sch
77 * @params[in] macCellGrp : mac cell group config at MAC
78 * *macCellGrpCfg : mac cell group cfg to be filled
79 * @return ROK - success
82 * ****************************************************************/
83 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
86 SchSchedReqCfg *schedReqCfg;
89 /* Copy scheduling request config */
90 schedReqCfg = &macCellGrpCfg->schedReqCfg;
91 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
92 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
94 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
95 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
98 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
100 schedReqCfg->addModList[idx].schedReqId = \
101 macCellGrp.schReqCfg.addModList[idx].schedReqId;
102 schedReqCfg->addModList[idx].srProhibitTmr = \
103 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
104 schedReqCfg->addModList[idx].srTransMax = \
105 macCellGrp.schReqCfg.addModList[idx].srTransMax;
107 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
109 /* copy TAG config */
110 tagCfg = &macCellGrpCfg->tagCfg;
111 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
112 if(tagCfg->addModListCount > MAX_NUM_TAGS)
114 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
115 tagCfg->addModListCount, MAX_NUM_TAGS);
118 for(idx = 0; idx < tagCfg->addModListCount; idx++)
120 tagCfg->addModList[idx].tagId = \
121 macCellGrp.tagCfg.addModList[idx].tagId;
122 tagCfg->addModList[idx].timeAlignmentTmr = \
123 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
125 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
127 /* Copy PHR config */
128 if(macCellGrp.phrCfgSetupPres)
130 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
131 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
132 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
133 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
134 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
135 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
136 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
140 /* Copy Drx configuration */
142 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs;
143 if(!macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
144 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
145 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
147 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
148 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
149 macCellGrpCfg->drxCfg.drxInactivityTimer = macCellGrp.drxCfg.drxInactivityTimer;
150 macCellGrpCfg->drxCfg.drxHarqRttTimerDl = macCellGrp.drxCfg.drxHarqRttTimerDl;
151 macCellGrpCfg->drxCfg.drxHarqRttTimerUl = macCellGrp.drxCfg.drxHarqRttTimerUl;
152 macCellGrpCfg->drxCfg.drxRetransmissionTimerDl = macCellGrp.drxCfg.drxRetransmissionTimerDl;
153 macCellGrpCfg->drxCfg.drxRetransmissionTimerUl = macCellGrp.drxCfg.drxRetransmissionTimerUl;
154 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellGrp.drxCfg.drxLongCycleStartOffset.\
155 drxLongCycleStartOffsetChoice;
156 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellGrp.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
157 macCellGrpCfg->drxCfg.shortDrxPres = macCellGrp.drxCfg.shortDrxPres;
158 if(macCellGrpCfg->drxCfg.shortDrxPres)
160 macCellGrpCfg->drxCfg.shortDrx.drxShortCycle = macCellGrp.drxCfg.shortDrx.drxShortCycle;
161 macCellGrpCfg->drxCfg.shortDrx.drxShortCycleTimer = macCellGrp.drxCfg.shortDrx.drxShortCycleTimer;
163 macCellGrpCfg->drxCfg.drxSlotOffset = macCellGrp.drxCfg.drxSlotOffset;
168 /*******************************************************************
170 * @brief Fills phy cell group config to be sent to scheduler
174 * Function : fillPhyCellGroupCfg
176 * Functionality: Fills phy cell group config to be sent to sch
178 * @params[in] macUeCfg : Phy cell group config at MAC
179 * *schPhyCellGrp : phy cell group config to be filled
180 * @return ROK - success
183 * ****************************************************************/
184 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
186 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
187 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
192 /*******************************************************************
194 * @brief Fills PDSCh serving cell config to send to scheduler
198 * Function : fillPdschServCellCfg
200 * Functionality: Fills PDSCh serving cell config to send to scheduler
202 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
203 * *schPdschCfg : Pdsch serving cell config to be filled
204 * @return ROK - success
207 * ****************************************************************/
208 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
210 if(macPdschCfg.maxMimoLayers)
212 if(!schPdschCfg->maxMimoLayers)
214 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
215 if(!schPdschCfg->maxMimoLayers)
217 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
221 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
225 schPdschCfg->maxMimoLayers = NULLP;
228 schPdschCfg->numHarqProcForPdsch = \
229 macPdschCfg.numHarqProcForPdsch;
231 if(macPdschCfg.maxCodeBlkGrpPerTb)
233 if(!schPdschCfg->maxCodeBlkGrpPerTb)
235 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
236 if(!schPdschCfg->maxCodeBlkGrpPerTb)
238 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
242 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
246 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
249 if(macPdschCfg.codeBlkGrpFlushInd)
251 if(!schPdschCfg->codeBlkGrpFlushInd)
253 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
254 if(!schPdschCfg->codeBlkGrpFlushInd)
256 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
260 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
264 schPdschCfg->codeBlkGrpFlushInd = NULLP;
267 if(macPdschCfg.xOverhead)
269 if(!schPdschCfg->xOverhead)
271 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
272 if(!schPdschCfg->xOverhead)
274 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
278 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
282 schPdschCfg->xOverhead = NULLP;
288 /*******************************************************************
290 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
294 * Function : fillInitalUlBwpPuschCfg
297 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
299 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
300 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
301 * @return ROK - success
304 * ****************************************************************/
305 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
309 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
310 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
311 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
312 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
313 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
314 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
316 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
317 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
319 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
320 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
323 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
325 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
326 macPuschCfg.timeDomRsrcAllocList[idx].k2;
327 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
328 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
329 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
330 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
331 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
332 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
335 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
339 /*******************************************************************
341 * @brief Function to fillResrcSetList sent by DU
345 * Function : fillResrcSetList
347 * Functionality: Function to fillResrcSetList sent by DU
349 * @params[in] PucchResrcSetCfg pointer,
350 * SchPucchResrcSetCfg pointer
353 * ****************************************************************/
355 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
357 uint8_t arrIdx, rsrcListIdx;
359 /* ResrcSetToAddModList */
360 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
361 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
363 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
364 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
366 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
367 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
369 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
370 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
371 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
372 resrcListCount; rsrcListIdx++)
374 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
375 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
378 /* ResrcSetToRelList */
379 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
380 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
382 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
386 /*******************************************************************
388 * @brief Function to fillResrcList sent by DU
392 * Function : fillResrcList
394 * Functionality: Function to fillResrcList sent by DU
396 * @params[in] PucchResrcCfg pointer,
397 * SchPucchResrcCfg pointer
398 * @return ROK/RFAILED;
400 * ****************************************************************/
401 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
405 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
406 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
408 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
409 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
410 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
411 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
412 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
413 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
414 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
415 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
416 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
417 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
418 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
420 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
421 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
423 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
426 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
427 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
428 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
429 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
430 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
431 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
434 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
436 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
437 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
439 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
442 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
443 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
444 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
445 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
446 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
447 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
448 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
449 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
452 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
454 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
455 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
457 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
460 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
461 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
462 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
463 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
464 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
465 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
468 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
470 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
471 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
473 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
476 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
477 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
478 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
479 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
480 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
481 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
484 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
486 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
487 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
489 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
492 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
493 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
494 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
495 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
496 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
497 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
498 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
499 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
505 /*******************************************************************
507 * @brief Function to fillPucchFormatCfg sent by DU
511 * Function : fillPucchFormatCfg
513 * Functionality: Function to fillPucchFormatCfg
515 * @params[in] PucchFormatCfg pointer,
516 * SchPucchFormatCfg pointer
519 * ****************************************************************/
521 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
523 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
524 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
525 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
526 schFormatCfg->numSlots = macFormatCfg->numSlots;
527 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
528 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
531 /*******************************************************************
533 * @brief Function to fillPucchSchedReqCfg sent by DU
537 * Function : fillPucchSchedReqCfg
539 * Functionality: Function to fillPucchSchedReqCfg
541 * @params[in] PucchSchedReqCfg pointer,
542 * SchPucchSchedReqCfg pointer
545 * ****************************************************************/
546 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
550 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
551 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
553 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
554 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
555 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
556 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
557 schSchedReqCfg->schedAddModList[arrIdx].offset =\
558 macSchedReqCfg->schedAddModList[arrIdx].offset;
559 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
560 macSchedReqCfg->schedAddModList[arrIdx].resrc;
562 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
563 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
565 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
569 /*******************************************************************
571 * @brief Function to fillMultiCsiCfg sent by DU
575 * Function : fillMultiCsiCfg
577 * Functionality: Function to fillMultiCsiCfg
579 * @params[in] PucchMultiCsiCfg pointer,
580 * SchPucchMultiCsiCfg pointer
583 * ****************************************************************/
585 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
589 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
590 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
592 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
596 /*******************************************************************
598 * @brief Function to fillDlToUlAck sent by DU
602 * Function : fillDlToUlAck
604 * Functionality: Function to fillDlToUlAck
606 * @params[in] PucchDlDataToUlAck pointer,
607 * SchPucchDlDataToUlAck pointer
610 * ****************************************************************/
612 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
616 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
617 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
619 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
623 /*******************************************************************
625 * @brief Function to fillPucchPowerControl sent by DU
629 * Function : fillPucchPowerControl
631 * Functionality: Function to fillPucchPowerControl
633 * @params[in] PucchPowerControl pointer,
634 * SchPucchPowerControl pointer
637 * ****************************************************************/
639 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
643 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
644 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
645 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
646 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
647 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
648 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
649 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
651 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
652 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
654 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
655 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
657 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
658 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
662 /*******************************************************************
664 * @brief Function to fillOtherPucchFormatCfg sent by DU
668 * Function : fillOtherPucchFormatCfg
670 * Functionality: Function to fillOtherPucchFormatCfg
672 * @params[in] PucchFormat
673 * PucchFormatCfg pointer,
674 * SchPucchCfg pointer
677 * ****************************************************************/
679 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
688 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
689 if(schPucchCfg->format1 == NULLP)
691 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
694 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
702 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
703 if(schPucchCfg->format2 == NULLP)
705 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
708 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
716 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
717 if(schPucchCfg->format3 == NULLP)
719 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
722 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
730 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
731 if(schPucchCfg->format4 == NULLP)
733 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
736 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
741 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
747 /*******************************************************************
749 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
753 * Function : fillInitalUlBwpPucchCfg
756 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
758 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
759 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
760 * @return ROK - success
763 * ****************************************************************/
764 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
766 if(macPucchCfg->resrcSet)
768 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
769 if(schPucchCfg->resrcSet == NULLP)
771 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
774 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
775 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
778 if(macPucchCfg->resrc)
780 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
781 if(schPucchCfg->resrc == NULLP)
783 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
786 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
787 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
789 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
794 /* valid for format 1, 2, 3, 4 */
795 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
796 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
797 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
798 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
800 if(macPucchCfg->schedReq)
802 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
803 if(schPucchCfg->schedReq == NULLP)
805 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
808 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
809 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
812 if(macPucchCfg->multiCsiCfg)
814 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
815 if(schPucchCfg->multiCsiCfg == NULLP)
817 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
820 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
821 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
824 //TODO: To add the support for spatial Config
825 schPucchCfg->spatialInfo = NULLP;
827 if(macPucchCfg->dlDataToUlAck)
829 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
830 if(schPucchCfg->dlDataToUlAck == NULLP)
832 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
835 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
836 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
840 if(macPucchCfg->powerControl)
842 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
843 if(schPucchCfg->powerControl == NULLP)
845 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
848 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
849 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
855 /*******************************************************************
857 * @brief function to free Pucch Format
861 * Function : freeSchPucchFormat
864 * function to free Pucch Format
866 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
867 * SchPucchResrcInfo pointer
869 * ****************************************************************/
871 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
875 case PUCCH_FORMAT_0 :
876 if(resrcInfo->SchPucchFormat.format0)
878 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
879 resrcInfo->SchPucchFormat.format0 = NULLP;
883 case PUCCH_FORMAT_1 :
884 if(resrcInfo->SchPucchFormat.format1)
886 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
887 resrcInfo->SchPucchFormat.format1 = NULLP;
891 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
892 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
896 case PUCCH_FORMAT_2 :
897 if(resrcInfo->SchPucchFormat.format2)
899 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
900 resrcInfo->SchPucchFormat.format2 = NULLP;
904 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
905 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
909 case PUCCH_FORMAT_3 :
910 if(resrcInfo->SchPucchFormat.format3)
912 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
913 resrcInfo->SchPucchFormat.format3 = NULLP;
917 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
918 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
922 case PUCCH_FORMAT_4 :
923 if(resrcInfo->SchPucchFormat.format4)
925 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
926 resrcInfo->SchPucchFormat.format4 = NULLP;
930 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
931 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
940 /*******************************************************************
942 * @brief function to free Pucch Resrc Cfg
946 * Function : freePucchResrcCfg
949 * function to free Pucch Resrc Cfg
951 * @params[in] SchPucchResrcCfg pointer,
953 * ****************************************************************/
955 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
959 /* free Resrc To AddMod List */
960 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
962 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
963 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
964 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
966 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
967 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
970 /*******************************************************************
972 * @brief function to free Pucch Sched Req Cfg
976 * Function : freePucchSchedReqCfg
979 * function to free Pucch Sched Req Cfg
981 * @params[in] SchPucchSchedReqCfg pointer,
983 * ****************************************************************/
985 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
989 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
991 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
993 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
994 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
997 /*******************************************************************
999 * @brief function to free Ul Bwp Pucch Cfg
1003 * Function : freeUlBwpPucchCfg
1006 * function to free Ul Bwp Pucch Cfg
1008 * @params[in] SchPucchCfg pointer,
1010 * ****************************************************************/
1012 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
1014 if(schPucchCfg->resrcSet)
1016 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1017 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1019 if(schPucchCfg->resrc)
1021 freePucchResrcCfg(schPucchCfg->resrc);
1023 if(schPucchCfg->format1)
1025 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1027 if(schPucchCfg->format2)
1029 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1031 if(schPucchCfg->format3)
1033 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1035 if(schPucchCfg->format4)
1037 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1039 if(schPucchCfg->schedReq)
1041 freePucchSchedReqCfg(schPucchCfg->schedReq);
1043 if(schPucchCfg->spatialInfo)
1045 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1046 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1048 if(schPucchCfg->multiCsiCfg)
1050 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1051 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1053 if(schPucchCfg->dlDataToUlAck)
1055 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1056 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1058 if(schPucchCfg->powerControl)
1060 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1061 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1065 /*******************************************************************
1067 * @brief Fills initail UL BWP config to send to scheduler
1071 * Function : fillInitialUlBwp
1073 * Functionality: Fills initail UL BWP config to send to sch
1075 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1076 * schInitUlBwp : Initial UL BWP cfg to be filled
1077 * @return ROK - success
1080 * ****************************************************************/
1081 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1083 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1084 if(schInitUlBwp->pucchCfgPres)
1086 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1087 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1089 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1090 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1094 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1095 if(schInitUlBwp->puschCfgPres)
1097 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1098 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1100 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1107 /*******************************************************************
1109 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1113 * Function : fillInitDlBwpPdcchCfg
1116 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1118 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1119 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1120 * @return ROK - success
1123 * ****************************************************************/
1124 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1128 /* Fill CORESET info */
1129 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1130 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1132 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1133 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1137 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1139 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1140 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1141 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1142 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1143 schPdcchCfg->cRSetToAddModList[idx].duration = \
1144 macPdcchCfg.cRSetToAddModList[idx].duration;
1145 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1146 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1147 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1148 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1149 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1150 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1153 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1154 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1156 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1157 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1161 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1166 /* Fill Search space info */
1167 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1168 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1170 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1171 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1174 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1176 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1177 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1178 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1179 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1180 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1181 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1182 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1183 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1184 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1185 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1186 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1187 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1188 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1189 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1190 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1191 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1192 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1193 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1194 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1195 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1196 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1197 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1198 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1201 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1202 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1204 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1205 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1208 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1216 /*******************************************************************
1218 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1222 * Function : fillInitDlBwpPdschCfg
1225 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1227 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1228 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1229 * @return ROK - success
1232 * ****************************************************************/
1233 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1237 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1238 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1239 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1240 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1241 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1243 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1244 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1248 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1250 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1252 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1253 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1255 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1258 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1260 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1261 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1262 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1263 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1264 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1265 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1268 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1269 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1270 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1271 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1273 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1275 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1277 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1278 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1283 /*******************************************************************
1285 * @brief Fill Initial DL BWP for SCH UE config
1289 * Function : fillInitialDlBwp
1291 * Functionality: Fill Initial DL BWP for SCH UE config
1293 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1294 * schInitDlBwp : Inital DL BWP cfg to be filled
1295 * @return ROK - success
1298 * ****************************************************************/
1299 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1301 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1302 if(schInitDlBwp->pdcchCfgPres)
1304 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1306 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1311 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1312 if(schInitDlBwp->pdschCfgPres)
1314 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1316 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1323 /*******************************************************************
1325 * @brief Fills Sp Cell config to be sent to scheduler
1329 * Function : fillSpCellCfg
1331 * Functionality: Fills Sp Cell config to be sent to scheduler
1333 * @params[in] macSpCellCfg : SP cell cfg at MAC
1334 * schSpCellCfg : SP cell cfg to be filled
1335 * @return ROK - success
1338 * ****************************************************************/
1339 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1342 SchServCellCfgInfo *servCellCfg;
1344 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1345 servCellCfg = &schSpCellCfg->servCellCfg;
1347 /* Fill initial DL BWP */
1348 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1349 &servCellCfg->initDlBwp) != ROK )
1351 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1355 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1356 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1358 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1359 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1362 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1364 /* TODO : As of now numDlBwpToAdd = 0 */
1367 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1368 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1369 servCellCfg->bwpInactivityTmr = NULL;
1370 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1372 /* TODO : This is an optional parameter, not filled currently */
1375 /* Fill PDSCH serving cell config */
1376 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1377 &servCellCfg->pdschServCellCfg) != ROK)
1379 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1383 /* Fill Initail UL BWP */
1384 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1385 &servCellCfg->initUlBwp) != ROK)
1387 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1391 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1392 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1394 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1395 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1398 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1400 /* TODO : As of now numDlBwpToAdd = 0 */
1402 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1407 /*******************************************************************
1409 * @brief Sends UE configuration to Scheduler
1413 * Function : sendUeReqToSch
1415 * Functionality: sends UE configuration to Scheduler
1417 * @params[in] Pst and Ue configuration
1418 * @return ROK - success
1421 * ****************************************************************/
1423 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
1428 case EVENT_MAC_UE_CREATE_REQ:
1429 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1430 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfg);
1432 case EVENT_MAC_UE_RECONFIG_REQ:
1433 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1434 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeCfg);
1436 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1441 /*******************************************************************
1443 * @brief Fills Sch Drb Qos Information
1447 * Function : fillSchDrbQosInfo
1449 * Functionality: Fills Sch Drb Qos Information
1451 * @params[in] macLcCfg : Logical channel Cfg at MAC
1452 * schLcCfg : LC cfg to fill at scheduler
1453 * @return ROK - success
1456 * ****************************************************************/
1457 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1459 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1460 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1462 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1463 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1464 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1465 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1467 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1469 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1470 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1471 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1472 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1473 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1474 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1475 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1476 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1478 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1479 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1480 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1481 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1482 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1483 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1484 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1485 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1486 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1489 /*******************************************************************
1491 * @brief Fill SCH UL logical channel configuration
1495 * Function : fillSchUlLcCfg
1497 * Functionality: Fills Sch Ul Lc configuration
1499 * @params[in] macLcCfg : Logical channel Cfg at MAC
1500 * schLcCfg : LC cfg to fill at scheduler
1503 * ****************************************************************/
1505 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1507 schUlLcCfg->priority= macUlLcCfg->priority;
1508 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1509 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1510 schUlLcCfg->pbr = macUlLcCfg->pbr;
1511 schUlLcCfg->bsd = macUlLcCfg->bsd;
1514 /*******************************************************************
1516 * @brief Fill logical channel configuration
1520 * Function : fillLogicalChannelCfg
1522 * Functionality: Fill logical channel configuration
1524 * @params[in] macLcCfg : Logical channel Cfg at MAC
1525 * schLcCfg : LC cfg to fill at scheduler
1526 * @return ROK - success
1529 * ****************************************************************/
1530 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1534 schLcCfg->lcId = macLcCfg->lcId;
1535 schLcCfg->configType = macLcCfg->configType;
1536 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1537 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1539 if(macLcCfg->drbQos)
1541 if(!schLcCfg->drbQos)
1543 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1544 if(!schLcCfg->drbQos)
1546 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1552 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1559 schLcCfg->drbQos = NULLP;
1564 if(macLcCfg->snssai)
1566 if(!schLcCfg->snssai)
1568 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1569 if(!schLcCfg->snssai)
1571 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1577 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1578 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1580 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1586 schLcCfg->snssai = NULLP;
1593 /*******************************************************************
1595 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1599 * Function : fillSchLcCfgList
1601 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1603 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1604 * @return ROK - success
1607 * ****************************************************************/
1609 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1613 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1615 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1617 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1625 /*******************************************************************
1627 * @brief Fills and sends UE configuration to Scheduler
1631 * Function : fillSchUeCfg
1633 * Functionality: Fills and sends UE configuration to Scheduler
1635 * @params[in] Ue configuration from DU APP
1636 * @return ROK - success
1639 * ****************************************************************/
1640 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1644 schUeCfg->cellId = ueCfg->cellId;
1645 schUeCfg->ueId = ueCfg->ueId;
1646 schUeCfg->crnti = ueCfg->crnti;
1647 schUeCfg->dataTransmissionInfo = ueCfg->transmissionAction;
1648 /* Copy MAC cell group config */
1649 if(ueCfg->macCellGrpCfgPres == true)
1651 schUeCfg->macCellGrpCfgPres = true;
1652 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1653 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1655 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1659 if(ueCfg->phyCellGrpCfgPres == true)
1661 schUeCfg->phyCellGrpCfgPres = true;
1662 /* Copy Physical cell group config */
1663 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1664 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1666 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1671 if(ueCfg->spCellCfgPres == true)
1673 schUeCfg->spCellCfgPres = true;
1674 /* Copy sp cell config */
1675 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1676 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1678 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1682 if(ueCfg->ambrCfg != NULLP)
1684 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1685 if(!schUeCfg->ambrCfg)
1687 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1690 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1694 schUeCfg->ambrCfg = NULLP;
1696 /* Fill DL modulation infor */
1697 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1698 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1699 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1701 /* Fill UL modulation infor */
1702 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1703 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1704 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1706 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1707 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1710 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1716 /*******************************************************************
1718 * @brief Update UeUlCb Lc List
1722 * Function : updateMacUlCb
1724 * Functionality: Update UeUlCb Lc List
1726 * @params[in] delIdx, UeUlCb pointer
1729 * ****************************************************************/
1731 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1735 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1737 /* Moving the array element to one step ahead */
1738 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1739 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1741 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1743 /*Checking the Memory Leakage of Last Index*/
1744 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
1746 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
1748 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
1752 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
1758 /*******************************************************************
1760 * @brief Update UeDlCb Lc List
1764 * Function : updateMacDlCb
1766 * Functionality: Update UeDlCb Lc List
1768 * @params[in] delIdx, UeDlCb pointer
1771 * ****************************************************************/
1773 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
1777 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
1779 /* Moving the array element to one step ahead */
1780 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
1781 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
1783 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1785 /*Checking the Memory Leakage of Last Index*/
1786 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
1788 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
1790 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
1794 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
1800 /*******************************************************************
1802 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
1806 * Function : updateMacUlLcCtxt
1808 * Functionality: Update UeUlCb Lc List
1810 * @params[in] UeUlCb pointer, ueLcCfg(received from DUAPP)
1813 * ****************************************************************/
1814 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg)
1816 uint8_t ueLcIdx = 0;
1818 /*Traversing UL LC to be updated/Deleted*/
1819 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
1821 if(ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId)
1823 if(ueLcCfg->configType == CONFIG_MOD)
1825 /*Modify UL LC CB */
1826 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
1828 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1830 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
1833 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
1837 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
1839 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
1842 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
1845 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
1846 ueLcCfg->lcId,ueLcIdx);
1849 if(ueLcCfg->configType == CONFIG_DEL)
1851 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1852 (ulInfo->numUlLc)--;
1853 updateMacUlCb(ueLcIdx, ulInfo);
1854 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueLcCfg->lcId);
1861 /*******************************************************************
1863 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
1867 * Function : updateMacDlLcCtxt
1869 * Functionality: Update UeDlCb Lc List
1871 * @params[in] UeDlCb pointer, ueLcCfg(received from DUAPP)
1874 * ****************************************************************/
1875 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg)
1877 uint8_t ueLcIdx = 0;
1879 /*Traversing DL LC to be updated/Deleted*/
1880 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
1882 if(dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId)
1884 if(ueLcCfg->configType == CONFIG_MOD)
1886 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1888 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
1891 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
1895 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
1897 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
1900 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
1903 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
1904 ueLcCfg->lcId,ueLcIdx);
1907 if(ueLcCfg->configType == CONFIG_DEL)
1909 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1910 (dlInfo->numDlLc)--;
1911 updateMacDlCb(ueLcIdx, dlInfo);
1912 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueLcCfg->lcId);
1918 /*******************************************************************
1920 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1924 * Function : fillMacLcCfgList
1926 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1928 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1929 * @return ROK - success
1932 * ****************************************************************/
1934 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
1938 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1940 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1942 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1944 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1946 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
1947 if(ueCfg->lcCfgList[lcIdx].drbQos)
1949 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
1950 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
1952 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
1953 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
1955 if(ueCfg->lcCfgList[lcIdx].snssai)
1957 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
1959 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
1961 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
1963 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
1966 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
1967 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
1969 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
1970 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
1974 /*Filling DL LC CB */
1975 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1976 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1977 ueCb->dlInfo.numDlLc++;
1978 /*Filling UL LC CB */
1979 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1980 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1981 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1982 ueCb->ulInfo.numUlLc++;
1983 }/*End of Add Config */
1986 updateMacUlLcCtxt(&ueCb->ulInfo, &ueCfg->lcCfgList[lcIdx]);
1987 updateMacDlLcCtxt(&ueCb->dlInfo, &ueCfg->lcCfgList[lcIdx]);
1988 }/*End of Mod Config */
1994 /*******************************************************************
1996 * @brief Fills MAC UE Cb Cfg
2000 * Function : fillMacUeCb
2002 * Functionality: Fills MAC UE Cb Cfg
2004 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2006 * @return ROK - success
2009 * ****************************************************************/
2011 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
2015 ueCb->ueId = ueCfg->ueId;
2016 ueCb->crnti = ueCfg->crnti;
2017 ueCb->cellCb = macCb.macCell[cellIdx];
2018 if(ueCfg->spCellCfgPres)
2020 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2021 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2024 /*TODO: To check the bsr value during implementation */
2025 if(ueCfg->macCellGrpCfgPres)
2027 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2028 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2029 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2031 ret = fillMacLcCfgList(ueCb, ueCfg);
2034 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2036 ueCb->transmissionAction = ueCfg->transmissionAction;
2041 /*******************************************************************
2043 * @brief Function to update Mac Ra Cb
2047 * Function : updateMacRaCb
2049 * Functionality: Function to update Mac Ra Cb
2051 * @params[in] cellIdx, Mac Ue Cb
2052 * @return ROK - success
2055 * ****************************************************************/
2057 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2060 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2062 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2066 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2072 /*******************************************************************
2074 * @brief Function to delete Mac Ra Cb
2078 * Function : deleteMacRaCb
2080 * Functionality: Function to delete Mac Ra Cb
2082 * @params[in] cellIdx, Mac Ue Cb
2085 * ****************************************************************/
2087 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2090 MacRaCbInfo *raCb = ueCb->raCb;
2091 DlHarqProcCb *hqProcCb;
2093 if(raCb && (raCb->crnti == ueCb->crnti))
2095 hqProcCb = &raCb->msg4HqInfo;
2096 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2097 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2099 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2100 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
2102 memset(raCb, 0, sizeof(MacRaCbInfo));
2106 /*******************************************************************
2108 * @brief Creates UE Cb
2112 * Function : createUeCb
2114 * Functionality: Creates UE Cb
2116 * @params[in] MAC UE Configuration
2117 * @return ROK - success
2120 * ****************************************************************/
2121 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2124 uint8_t hqProcIdx = 0;
2126 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2127 &&(ueCb->state == UE_STATE_ACTIVE))
2129 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2134 memset(ueCb, 0, sizeof(MacUeCb));
2135 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2138 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2143 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2144 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2146 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2149 /* If UE has not requested for RACH yet, it means UE context is created for a
2151 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2153 ueCb->state = UE_STATE_ACTIVE;
2154 macCb.macCell[cellIdx]->numActvUe++;
2155 updateMacRaCb(cellIdx, ueCb);
2158 ueCb->state = UE_HANDIN_IN_PROGRESS;
2166 /*******************************************************************
2168 * @brief Modify UE Cb Cfg
2172 * Function : modifyUeCb
2174 * Functionality: modify UE Cb
2176 * @params[in] MAC UE Configuration
2177 * @return ROK - success
2180 * ****************************************************************/
2181 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2185 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2186 &&(ueCb->state == UE_STATE_ACTIVE))
2188 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueCfg->crnti);
2189 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2192 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2204 /*******************************************************************
2206 * @brief Creates UE Cb and fills ueCfg
2210 * Function : procMacUeCfgData
2212 * Functionality: Creates UE Cb and fills ueCfg
2214 * @params[in] MAC UE Configuration
2215 * @return ROK - success
2218 * ****************************************************************/
2220 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
2224 MacUeCb *ueCb = NULLP;
2227 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2229 /* Validate cell id */
2230 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
2232 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", ueCfg->cellId);
2236 /* Check if max number of UE configured */
2237 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2239 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2243 /* Check if UE already configured */
2244 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueId -1];
2248 case EVENT_UE_CONFIG_RSP_TO_MAC:
2250 ret = createUeCb(cellIdx, ueCb, ueCfg);
2252 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2256 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2258 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
2260 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2271 /*******************************************************************
2273 * @brief Function to store the UeCfg Data
2277 * Function : copyToTmpData
2279 * Functionality: Function to store the UeCfg Data
2281 * @params[in] MacUeCfg pointer
2282 * @return ROK - success
2285 * ****************************************************************/
2287 uint8_t copyToTmpData(MacUeCfg *ueCfg)
2290 MacUeCfg *tmpData = NULLP;
2292 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2295 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2298 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2299 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2300 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2304 /*******************************************************************
2306 * @brief Handles UE create requst from DU APP
2310 * Function : MacProcUeCreateReq
2312 * Functionality: Handles UE create requst from DU APP
2315 * @return ROK - success
2318 * ****************************************************************/
2319 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2323 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2325 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2329 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2330 * case of UE in handover */
2331 if(ueCfg->crnti == 0)
2333 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2336 /*Storing received ueCfg in ueCfgTmpData */
2337 ret = copyToTmpData(ueCfg);
2340 /*Sending Cfg Req to SCH */
2341 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2343 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2346 /* Fill event and send UE create request to SCH */
2347 ret = sendUeReqToSch(pst, &schUeCfg);
2349 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2354 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2359 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2362 /* FREE shared memory */
2363 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2368 /*******************************************************************
2370 * @brief Fill and Send UE create response from MAC to DU APP
2374 * Function : MacSendUeCreateRsp
2376 * Functionality: Fill and Send UE create response from MAC to DUAPP
2378 * @params[in] MAC UE create result
2379 * SCH UE create response
2380 * @return ROK - success
2383 * ****************************************************************/
2384 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2386 MacUeCfgRsp *cfgRsp;
2389 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2392 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2396 /* Filling UE Config response */
2397 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2398 cfgRsp->cellId = schCfgRsp->cellId;
2399 cfgRsp->ueId = schCfgRsp->ueId;
2400 cfgRsp->result = result;
2402 /* Fill Post structure and send UE Create response*/
2403 memset(&rspPst, 0, sizeof(Pst));
2404 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2405 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2408 /*******************************************************************
2410 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2414 * Function : MacSendUeReconfigRsp
2416 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2418 * @params[in] MAC UE create result
2419 * SCH UE create response
2420 * @return ROK - success
2423 * ****************************************************************/
2424 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2426 MacUeCfgRsp *cfgRsp;
2429 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2432 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2436 /* Filling UE Config response */
2437 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2438 cfgRsp->cellId = schCfgRsp->cellId;
2439 cfgRsp->ueId = schCfgRsp->ueId;
2440 cfgRsp->result = result;
2442 /* Fill Post structure and send UE Create response*/
2443 memset(&rspPst, 0, sizeof(Pst));
2444 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2445 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2448 /*******************************************************************
2450 * @brief Function to return Mac Ue Cfg pointer
2454 * Function : getMacUeCfg
2457 * Function to return Mac Ue Cfg pointer
2459 * @params[in] cellIdx, ueId
2461 * @return MacUeCfg pointer - success
2464 * ****************************************************************/
2466 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2468 MacUeCfg *ueCfg = NULLP;
2469 if(macCb.macCell[cellIdx])
2471 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2475 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2480 /*******************************************************************
2482 * @brief Processes UE create response from scheduler
2486 * Function : MacProcSchUeCfgRsp
2489 * Processes UE create response from scheduler
2490 * Sends UE create response to DU APP
2492 * @params[in] Pst : Post structure
2493 * schCfgRsp : Scheduler UE cfg response
2494 * @return ROK - success
2497 * ****************************************************************/
2498 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2500 uint8_t result = MAC_DU_APP_RSP_NOK;
2503 MacUeCfg *ueCfg = NULLP;
2505 #ifdef CALL_FLOW_DEBUG_LOG
2508 case EVENT_UE_CONFIG_RSP_TO_MAC:
2509 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2511 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2512 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2515 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2520 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2521 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
2524 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2530 case EVENT_UE_CONFIG_RSP_TO_MAC:
2532 if(schCfgRsp->rsp != RSP_NOK)
2534 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2537 ret = procMacUeCfgData(pst, ueCfg);
2540 result = MAC_DU_APP_RSP_OK;
2546 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2548 ret = MacSendUeCreateRsp(result, schCfgRsp);
2552 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2555 if(schCfgRsp->rsp != RSP_NOK)
2557 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
2561 ret = procMacUeCfgData(pst, ueCfg);
2564 result = MAC_DU_APP_RSP_OK;
2570 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
2573 ret = MacSendUeReconfigRsp(result, schCfgRsp);
2577 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2582 /*******************************************************************
2584 * @brief Handles UE Reconfig requst from DU APP
2588 * Function : MacProcUeReconfigReq
2590 * Functionality: Handles UE Reconfig requst from DU APP
2593 * @return ROK - success
2596 * ****************************************************************/
2597 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
2601 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2603 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
2607 /*Storing received ueCfg in ueCfgTmpData */
2608 ret = copyToTmpData(ueCfg);
2611 /*Sending Cfg Req to SCH */
2612 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2614 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
2617 /* Fill event and send UE create request to SCH */
2618 ret = sendUeReqToSch(pst, &schUeCfg);
2620 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
2625 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
2630 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2633 /* FREE shared memory */
2634 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2638 /*******************************************************************
2640 * @brief Fill and Send UE Delete response from MAC to DU APP
2644 * Function : MacSendUeDeleteRsp
2646 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
2648 * @params[in] MAC UE delete result
2649 * SCH UE delete response
2650 * @return ROK - success
2653 * ****************************************************************/
2655 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result)
2657 MacUeDeleteRsp *deleteRsp;
2660 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
2663 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
2667 /* Filling UE delete response */
2668 deleteRsp->cellId = cellId;
2669 GET_UE_ID(crnti, deleteRsp->ueId);
2670 deleteRsp->result = result;
2672 /* Fill Post structure and send UE delete response*/
2673 memset(&rspPst, 0, sizeof(Pst));
2674 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
2675 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
2678 /*******************************************************************
2680 * @brief freeing the Pucch Resrc Cfg
2684 * Function : deletePucchResourcesCfg
2686 * Functionality: freeing the Pucch Resrc Cfg
2688 * @params[in] PucchResrcCfg *resrcCfg
2689 * @return ROK - success
2692 * ****************************************************************/
2694 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
2697 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
2699 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
2701 case PUCCH_FORMAT_0:
2703 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
2706 case PUCCH_FORMAT_1:
2708 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
2711 case PUCCH_FORMAT_2:
2713 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
2716 case PUCCH_FORMAT_3:
2718 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
2721 case PUCCH_FORMAT_4:
2723 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
2731 /*******************************************************************
2733 * @brief Processes UE delete response from scheduler
2737 * Function : MacProcSchUeDeleteRsp
2740 * Processes UE delete from scheduler
2742 * @params[in] Pst : Post structure
2743 * schUeDelRsp : Scheduler UE delete respons
2744 * @return ROK - success
2747 * ****************************************************************/
2749 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
2751 uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
2753 uint8_t ret = RFAILED;
2754 UeDeleteStatus result;
2755 DlHarqEnt *dlHarqEnt;
2757 #ifdef CALL_FLOW_DEBUG_LOG
2758 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
2763 if(schUeDelRsp->rsp == RSP_OK)
2765 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
2766 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
2767 if(macCb.macCell[cellIdx])
2769 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
2772 /*C-RNTI value is out of Acceptable range*/
2773 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
2774 result = UEID_INVALID;
2778 GET_UE_ID(schUeDelRsp->crnti, ueId);
2779 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
2782 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2784 /*Looping around LCs to free S-NSSAI memory*/
2785 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
2787 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
2789 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
2791 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
2794 dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
2795 for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
2798 while(dlHarqEnt->harqProcCb[idx].numTb)
2801 MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
2802 dlHarqEnt->harqProcCb[idx].numTb--;
2806 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
2807 macCb.macCell[cellIdx]->numActvUe--;
2808 result = DEL_SUCCESSFUL;
2813 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
2814 result = UEID_INVALID;
2820 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
2821 result = CELLID_INVALID;
2826 result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEID_INVALID;
2828 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK)
2830 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
2835 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
2841 /*******************************************************************
2843 * @brief Sends UE delete req to Scheduler
2847 * Function : sendUeDelReqToSch
2849 * Functionality: sends UE delete req to Scheduler
2851 * @params[in] Pst *pst, MacUeDelete *ueDelete
2852 * @return ROK - success
2855 * ****************************************************************/
2857 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
2859 if(ueDelete != NULLP)
2862 SchUeDelete schUeDel;
2864 memset(&schUeDel, 0, sizeof(SchUeDelete));
2865 schUeDel.cellId = ueDelete->cellId;
2866 schUeDel.crnti = ueDelete->crnti;
2867 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2868 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
2869 return(*macSchUeDeleteReqOpts[schPst.selector])(&schPst, &schUeDel);
2873 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
2879 /*******************************************************************
2881 * @brief Handles UE Delete requst from DU APP
2885 * Function : MacProcUeDeleteReq
2887 * Functionality: Handles UE Delete requst from DU APP
2889 * @params[in] Pst *pst, MacUeDelete *ueDelete
2890 * @return ROK - success
2893 * ****************************************************************/
2895 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
2899 UeDeleteStatus result=DEL_SUCCESSFUL;
2900 MacUeCb *ueCb = NULLP;
2901 MacCellCb *cellCb = NULLP;
2903 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
2907 GET_CELL_IDX(ueDelete->cellId, cellIdx);
2908 cellCb = macCb.macCell[cellIdx];
2911 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
2912 if(ueCb->crnti == ueDelete->crnti)
2914 ret = sendUeDelReqToSch(pst, ueDelete);
2917 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
2923 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
2924 result = UEID_INVALID;
2929 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
2930 result = CELLID_INVALID;
2933 if(result != DEL_SUCCESSFUL)
2935 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result);
2936 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2942 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
2948 /**********************************************************************
2950 **********************************************************************/