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;
142 /*******************************************************************
144 * @brief Fills phy cell group config to be sent to scheduler
148 * Function : fillPhyCellGroupCfg
150 * Functionality: Fills phy cell group config to be sent to sch
152 * @params[in] macUeCfg : Phy cell group config at MAC
153 * *schPhyCellGrp : phy cell group config to be filled
154 * @return ROK - success
157 * ****************************************************************/
158 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
160 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
161 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
166 /*******************************************************************
168 * @brief Fills PDSCh serving cell config to send to scheduler
172 * Function : fillPdschServCellCfg
174 * Functionality: Fills PDSCh serving cell config to send to scheduler
176 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
177 * *schPdschCfg : Pdsch serving cell config to be filled
178 * @return ROK - success
181 * ****************************************************************/
182 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
184 if(macPdschCfg.maxMimoLayers)
186 if(!schPdschCfg->maxMimoLayers)
188 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
189 if(!schPdschCfg->maxMimoLayers)
191 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
195 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
199 schPdschCfg->maxMimoLayers = NULLP;
202 schPdschCfg->numHarqProcForPdsch = \
203 macPdschCfg.numHarqProcForPdsch;
205 if(macPdschCfg.maxCodeBlkGrpPerTb)
207 if(!schPdschCfg->maxCodeBlkGrpPerTb)
209 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
210 if(!schPdschCfg->maxCodeBlkGrpPerTb)
212 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
216 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
220 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
223 if(macPdschCfg.codeBlkGrpFlushInd)
225 if(!schPdschCfg->codeBlkGrpFlushInd)
227 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
228 if(!schPdschCfg->codeBlkGrpFlushInd)
230 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
234 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
238 schPdschCfg->codeBlkGrpFlushInd = NULLP;
241 if(macPdschCfg.xOverhead)
243 if(!schPdschCfg->xOverhead)
245 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
246 if(!schPdschCfg->xOverhead)
248 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
252 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
256 schPdschCfg->xOverhead = NULLP;
262 /*******************************************************************
264 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
268 * Function : fillInitalUlBwpPuschCfg
271 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
273 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
274 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
275 * @return ROK - success
278 * ****************************************************************/
279 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
283 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
284 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
285 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
286 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
287 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
288 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
290 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
291 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
293 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
294 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
297 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
299 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
300 macPuschCfg.timeDomRsrcAllocList[idx].k2;
301 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
302 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
303 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
304 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
305 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
306 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
309 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
313 /*******************************************************************
315 * @brief Function to fillResrcSetList sent by DU
319 * Function : fillResrcSetList
321 * Functionality: Function to fillResrcSetList sent by DU
323 * @params[in] PucchResrcSetCfg pointer,
324 * SchPucchResrcSetCfg pointer
327 * ****************************************************************/
329 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
331 uint8_t arrIdx, rsrcListIdx;
333 /* ResrcSetToAddModList */
334 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
335 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
337 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
338 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
340 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
341 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
343 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
344 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
345 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
346 resrcListCount; rsrcListIdx++)
348 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
349 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
352 /* ResrcSetToRelList */
353 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
354 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
356 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
360 /*******************************************************************
362 * @brief Function to fillResrcList sent by DU
366 * Function : fillResrcList
368 * Functionality: Function to fillResrcList sent by DU
370 * @params[in] PucchResrcCfg pointer,
371 * SchPucchResrcCfg pointer
372 * @return ROK/RFAILED;
374 * ****************************************************************/
375 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
379 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
380 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
382 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
383 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
384 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
385 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
386 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
387 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
388 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
389 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
390 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
391 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
392 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
394 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
395 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
397 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
400 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
401 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
402 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
403 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
404 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
405 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
408 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
410 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
411 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
413 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
416 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
417 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
418 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
419 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
420 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
421 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
422 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
423 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
426 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
428 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
429 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
431 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
434 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
435 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
436 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
437 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
438 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
439 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
442 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
444 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
445 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
447 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
450 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
451 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
452 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
453 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
454 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
455 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
458 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
460 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
461 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
463 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
466 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
467 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
468 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
469 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
470 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
471 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
472 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
473 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
479 /*******************************************************************
481 * @brief Function to fillPucchFormatCfg sent by DU
485 * Function : fillPucchFormatCfg
487 * Functionality: Function to fillPucchFormatCfg
489 * @params[in] PucchFormatCfg pointer,
490 * SchPucchFormatCfg pointer
493 * ****************************************************************/
495 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
497 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
498 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
499 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
500 schFormatCfg->numSlots = macFormatCfg->numSlots;
501 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
502 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
505 /*******************************************************************
507 * @brief Function to fillPucchSchedReqCfg sent by DU
511 * Function : fillPucchSchedReqCfg
513 * Functionality: Function to fillPucchSchedReqCfg
515 * @params[in] PucchSchedReqCfg pointer,
516 * SchPucchSchedReqCfg pointer
519 * ****************************************************************/
520 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
524 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
525 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
527 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
528 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
529 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
530 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
531 schSchedReqCfg->schedAddModList[arrIdx].offset =\
532 macSchedReqCfg->schedAddModList[arrIdx].offset;
533 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
534 macSchedReqCfg->schedAddModList[arrIdx].resrc;
536 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
537 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
539 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
543 /*******************************************************************
545 * @brief Function to fillMultiCsiCfg sent by DU
549 * Function : fillMultiCsiCfg
551 * Functionality: Function to fillMultiCsiCfg
553 * @params[in] PucchMultiCsiCfg pointer,
554 * SchPucchMultiCsiCfg pointer
557 * ****************************************************************/
559 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
563 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
564 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
566 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
570 /*******************************************************************
572 * @brief Function to fillDlToUlAck sent by DU
576 * Function : fillDlToUlAck
578 * Functionality: Function to fillDlToUlAck
580 * @params[in] PucchDlDataToUlAck pointer,
581 * SchPucchDlDataToUlAck pointer
584 * ****************************************************************/
586 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
590 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
591 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
593 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
597 /*******************************************************************
599 * @brief Function to fillPucchPowerControl sent by DU
603 * Function : fillPucchPowerControl
605 * Functionality: Function to fillPucchPowerControl
607 * @params[in] PucchPowerControl pointer,
608 * SchPucchPowerControl pointer
611 * ****************************************************************/
613 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
617 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
618 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
619 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
620 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
621 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
622 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
623 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
625 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
626 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
628 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
629 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
631 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
632 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
636 /*******************************************************************
638 * @brief Function to fillOtherPucchFormatCfg sent by DU
642 * Function : fillOtherPucchFormatCfg
644 * Functionality: Function to fillOtherPucchFormatCfg
646 * @params[in] PucchFormat
647 * PucchFormatCfg pointer,
648 * SchPucchCfg pointer
651 * ****************************************************************/
653 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
662 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
663 if(schPucchCfg->format1 == NULLP)
665 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
668 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
676 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
677 if(schPucchCfg->format2 == NULLP)
679 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
682 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
690 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
691 if(schPucchCfg->format3 == NULLP)
693 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
696 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
704 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
705 if(schPucchCfg->format4 == NULLP)
707 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
710 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
715 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
721 /*******************************************************************
723 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
727 * Function : fillInitalUlBwpPucchCfg
730 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
732 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
733 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
734 * @return ROK - success
737 * ****************************************************************/
738 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
740 if(macPucchCfg->resrcSet)
742 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
743 if(schPucchCfg->resrcSet == NULLP)
745 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
748 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
749 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
752 if(macPucchCfg->resrc)
754 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
755 if(schPucchCfg->resrc == NULLP)
757 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
760 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
761 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
763 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
768 /* valid for format 1, 2, 3, 4 */
769 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
770 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
771 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
772 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
774 if(macPucchCfg->schedReq)
776 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
777 if(schPucchCfg->schedReq == NULLP)
779 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
782 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
783 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
786 if(macPucchCfg->multiCsiCfg)
788 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
789 if(schPucchCfg->multiCsiCfg == NULLP)
791 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
794 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
795 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
798 //TODO: To add the support for spatial Config
799 schPucchCfg->spatialInfo = NULLP;
801 if(macPucchCfg->dlDataToUlAck)
803 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
804 if(schPucchCfg->dlDataToUlAck == NULLP)
806 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
809 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
810 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
814 if(macPucchCfg->powerControl)
816 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
817 if(schPucchCfg->powerControl == NULLP)
819 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
822 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
823 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
829 /*******************************************************************
831 * @brief function to free Pucch Format
835 * Function : freeSchPucchFormat
838 * function to free Pucch Format
840 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
841 * SchPucchResrcInfo pointer
843 * ****************************************************************/
845 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
849 case PUCCH_FORMAT_0 :
850 if(resrcInfo->SchPucchFormat.format0)
852 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
853 resrcInfo->SchPucchFormat.format0 = NULLP;
857 case PUCCH_FORMAT_1 :
858 if(resrcInfo->SchPucchFormat.format1)
860 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
861 resrcInfo->SchPucchFormat.format1 = NULLP;
865 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
866 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
870 case PUCCH_FORMAT_2 :
871 if(resrcInfo->SchPucchFormat.format2)
873 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
874 resrcInfo->SchPucchFormat.format2 = NULLP;
878 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
879 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
883 case PUCCH_FORMAT_3 :
884 if(resrcInfo->SchPucchFormat.format3)
886 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
887 resrcInfo->SchPucchFormat.format3 = NULLP;
891 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
892 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
896 case PUCCH_FORMAT_4 :
897 if(resrcInfo->SchPucchFormat.format4)
899 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
900 resrcInfo->SchPucchFormat.format4 = NULLP;
904 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
905 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
914 /*******************************************************************
916 * @brief function to free Pucch Resrc Cfg
920 * Function : freePucchResrcCfg
923 * function to free Pucch Resrc Cfg
925 * @params[in] SchPucchResrcCfg pointer,
927 * ****************************************************************/
929 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
933 /* free Resrc To AddMod List */
934 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
936 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
937 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
938 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
940 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
941 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
944 /*******************************************************************
946 * @brief function to free Pucch Sched Req Cfg
950 * Function : freePucchSchedReqCfg
953 * function to free Pucch Sched Req Cfg
955 * @params[in] SchPucchSchedReqCfg pointer,
957 * ****************************************************************/
959 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
963 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
965 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
967 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
968 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
971 /*******************************************************************
973 * @brief function to free Ul Bwp Pucch Cfg
977 * Function : freeUlBwpPucchCfg
980 * function to free Ul Bwp Pucch Cfg
982 * @params[in] SchPucchCfg pointer,
984 * ****************************************************************/
986 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
988 if(schPucchCfg->resrcSet)
990 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
991 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
993 if(schPucchCfg->resrc)
995 freePucchResrcCfg(schPucchCfg->resrc);
997 if(schPucchCfg->format1)
999 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1001 if(schPucchCfg->format2)
1003 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1005 if(schPucchCfg->format3)
1007 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1009 if(schPucchCfg->format4)
1011 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1013 if(schPucchCfg->schedReq)
1015 freePucchSchedReqCfg(schPucchCfg->schedReq);
1017 if(schPucchCfg->spatialInfo)
1019 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1020 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1022 if(schPucchCfg->multiCsiCfg)
1024 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1025 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1027 if(schPucchCfg->dlDataToUlAck)
1029 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1030 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1032 if(schPucchCfg->powerControl)
1034 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1035 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1039 /*******************************************************************
1041 * @brief Fills initail UL BWP config to send to scheduler
1045 * Function : fillInitialUlBwp
1047 * Functionality: Fills initail UL BWP config to send to sch
1049 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1050 * schInitUlBwp : Initial UL BWP cfg to be filled
1051 * @return ROK - success
1054 * ****************************************************************/
1055 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1057 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1058 if(schInitUlBwp->pucchCfgPres)
1060 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1061 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1063 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1064 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1068 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1069 if(schInitUlBwp->puschCfgPres)
1071 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1072 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1074 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1081 /*******************************************************************
1083 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1087 * Function : fillInitDlBwpPdcchCfg
1090 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1092 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1093 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1094 * @return ROK - success
1097 * ****************************************************************/
1098 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1102 /* Fill CORESET info */
1103 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1104 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1106 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1107 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1111 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1113 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1114 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1115 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1116 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1117 schPdcchCfg->cRSetToAddModList[idx].duration = \
1118 macPdcchCfg.cRSetToAddModList[idx].duration;
1119 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1120 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1121 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1122 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1123 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1124 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1127 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1128 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1130 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1131 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1135 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1140 /* Fill Search space info */
1141 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1142 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1144 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1145 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1148 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1150 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1151 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1152 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1153 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1154 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1155 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1156 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1157 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1158 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1159 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1160 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1161 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1162 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1163 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1164 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1165 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1166 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1167 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1168 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1169 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1170 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1171 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1172 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1175 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1176 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1178 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1179 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1182 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1190 /*******************************************************************
1192 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1196 * Function : fillInitDlBwpPdschCfg
1199 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1201 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1202 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1203 * @return ROK - success
1206 * ****************************************************************/
1207 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1211 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1212 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1213 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1214 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1215 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1217 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1218 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1222 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1224 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1226 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1227 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1229 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1232 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1234 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1235 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1236 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1237 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1238 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1239 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1242 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1243 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1244 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1245 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1247 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1249 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1251 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1252 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1257 /*******************************************************************
1259 * @brief Fill Initial DL BWP for SCH UE config
1263 * Function : fillInitialDlBwp
1265 * Functionality: Fill Initial DL BWP for SCH UE config
1267 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1268 * schInitDlBwp : Inital DL BWP cfg to be filled
1269 * @return ROK - success
1272 * ****************************************************************/
1273 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1275 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1276 if(schInitDlBwp->pdcchCfgPres)
1278 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1280 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1285 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1286 if(schInitDlBwp->pdschCfgPres)
1288 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1290 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1297 /*******************************************************************
1299 * @brief Fills Sp Cell config to be sent to scheduler
1303 * Function : fillSpCellCfg
1305 * Functionality: Fills Sp Cell config to be sent to scheduler
1307 * @params[in] macSpCellCfg : SP cell cfg at MAC
1308 * schSpCellCfg : SP cell cfg to be filled
1309 * @return ROK - success
1312 * ****************************************************************/
1313 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1316 SchServCellCfgInfo *servCellCfg;
1318 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1319 servCellCfg = &schSpCellCfg->servCellCfg;
1321 /* Fill initial DL BWP */
1322 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1323 &servCellCfg->initDlBwp) != ROK )
1325 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1329 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1330 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1332 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1333 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1336 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1338 /* TODO : As of now numDlBwpToAdd = 0 */
1341 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1342 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1343 servCellCfg->bwpInactivityTmr = NULL;
1344 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1346 /* TODO : This is an optional parameter, not filled currently */
1349 /* Fill PDSCH serving cell config */
1350 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1351 &servCellCfg->pdschServCellCfg) != ROK)
1353 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1357 /* Fill Initail UL BWP */
1358 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1359 &servCellCfg->initUlBwp) != ROK)
1361 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1365 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1366 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1368 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1369 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1372 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1374 /* TODO : As of now numDlBwpToAdd = 0 */
1376 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1381 /*******************************************************************
1383 * @brief Sends UE configuration to Scheduler
1387 * Function : sendUeReqToSch
1389 * Functionality: sends UE configuration to Scheduler
1391 * @params[in] Pst and Ue configuration
1392 * @return ROK - success
1395 * ****************************************************************/
1397 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
1402 case EVENT_MAC_UE_CREATE_REQ:
1403 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1404 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfg);
1406 case EVENT_MAC_UE_RECONFIG_REQ:
1407 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1408 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeCfg);
1410 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1415 /*******************************************************************
1417 * @brief Fills Sch Drb Qos Information
1421 * Function : fillSchDrbQosInfo
1423 * Functionality: Fills Sch Drb Qos Information
1425 * @params[in] macLcCfg : Logical channel Cfg at MAC
1426 * schLcCfg : LC cfg to fill at scheduler
1427 * @return ROK - success
1430 * ****************************************************************/
1431 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1433 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1434 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1436 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1437 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1438 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1439 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1441 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1443 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1444 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1445 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1446 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1447 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1448 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1449 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1450 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1452 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1453 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1454 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1455 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1456 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1457 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1458 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1459 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1460 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1463 /*******************************************************************
1465 * @brief Fill SCH UL logical channel configuration
1469 * Function : fillSchUlLcCfg
1471 * Functionality: Fills Sch Ul Lc configuration
1473 * @params[in] macLcCfg : Logical channel Cfg at MAC
1474 * schLcCfg : LC cfg to fill at scheduler
1477 * ****************************************************************/
1479 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1481 schUlLcCfg->priority= macUlLcCfg->priority;
1482 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1483 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1484 schUlLcCfg->pbr = macUlLcCfg->pbr;
1485 schUlLcCfg->bsd = macUlLcCfg->bsd;
1488 /*******************************************************************
1490 * @brief Fill logical channel configuration
1494 * Function : fillLogicalChannelCfg
1496 * Functionality: Fill logical channel configuration
1498 * @params[in] macLcCfg : Logical channel Cfg at MAC
1499 * schLcCfg : LC cfg to fill at scheduler
1500 * @return ROK - success
1503 * ****************************************************************/
1504 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1508 schLcCfg->lcId = macLcCfg->lcId;
1509 schLcCfg->configType = macLcCfg->configType;
1510 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1511 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1513 if(macLcCfg->drbQos)
1515 if(!schLcCfg->drbQos)
1517 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1518 if(!schLcCfg->drbQos)
1520 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1526 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1533 schLcCfg->drbQos = NULLP;
1538 if(macLcCfg->snssai)
1540 if(!schLcCfg->snssai)
1542 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1543 if(!schLcCfg->snssai)
1545 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1551 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1552 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1554 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1560 schLcCfg->snssai = NULLP;
1567 /*******************************************************************
1569 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1573 * Function : fillSchLcCfgList
1575 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1577 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1578 * @return ROK - success
1581 * ****************************************************************/
1583 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1587 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1589 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1591 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1599 /*******************************************************************
1601 * @brief Fills and sends UE configuration to Scheduler
1605 * Function : fillSchUeCfg
1607 * Functionality: Fills and sends UE configuration to Scheduler
1609 * @params[in] Ue configuration from DU APP
1610 * @return ROK - success
1613 * ****************************************************************/
1614 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1618 schUeCfg->cellId = ueCfg->cellId;
1619 schUeCfg->duUeF1apId = ueCfg->duUeF1apId;
1620 schUeCfg->crnti = ueCfg->crnti;
1622 /* Copy MAC cell group config */
1623 if(ueCfg->macCellGrpCfgPres == true)
1625 schUeCfg->macCellGrpCfgPres = true;
1626 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1627 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1629 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1633 if(ueCfg->phyCellGrpCfgPres == true)
1635 schUeCfg->phyCellGrpCfgPres = true;
1636 /* Copy Physical cell group config */
1637 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1638 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1640 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1645 if(ueCfg->spCellCfgPres == true)
1647 schUeCfg->spCellCfgPres = true;
1648 /* Copy sp cell config */
1649 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1650 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1652 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1656 if(ueCfg->ambrCfg != NULLP)
1658 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1659 if(!schUeCfg->ambrCfg)
1661 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1664 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1668 schUeCfg->ambrCfg = NULLP;
1670 /* Fill DL modulation infor */
1671 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1672 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1673 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1675 /* Fill UL modulation infor */
1676 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1677 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1678 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1680 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1681 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1684 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1690 /*******************************************************************
1692 * @brief Update UeUlCb Lc List
1696 * Function : updateMacUlCb
1698 * Functionality: Update UeUlCb Lc List
1700 * @params[in] delIdx, UeUlCb pointer
1703 * ****************************************************************/
1705 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1709 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1711 /* Moving the array element to one step ahead */
1712 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1713 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1715 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1717 /*Checking the Memory Leakage of Last Index*/
1718 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
1720 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
1722 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
1726 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
1732 /*******************************************************************
1734 * @brief Update UeDlCb Lc List
1738 * Function : updateMacDlCb
1740 * Functionality: Update UeDlCb Lc List
1742 * @params[in] delIdx, UeDlCb pointer
1745 * ****************************************************************/
1747 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
1751 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
1753 /* Moving the array element to one step ahead */
1754 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
1755 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
1757 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1759 /*Checking the Memory Leakage of Last Index*/
1760 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
1762 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
1764 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
1768 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
1774 /*******************************************************************
1776 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
1780 * Function : updateMacUlLcCtxt
1782 * Functionality: Update UeUlCb Lc List
1784 * @params[in] UeUlCb pointer, ueLcCfg(received from DUAPP)
1787 * ****************************************************************/
1788 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg)
1790 uint8_t ueLcIdx = 0;
1792 /*Traversing UL LC to be updated/Deleted*/
1793 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
1795 if(ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId)
1797 if(ueLcCfg->configType == CONFIG_MOD)
1799 /*Modify UL LC CB */
1800 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
1802 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1804 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
1807 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
1811 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
1813 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
1816 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
1819 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
1820 ueLcCfg->lcId,ueLcIdx);
1823 if(ueLcCfg->configType == CONFIG_DEL)
1825 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1826 (ulInfo->numUlLc)--;
1827 updateMacUlCb(ueLcIdx, ulInfo);
1828 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueLcCfg->lcId);
1835 /*******************************************************************
1837 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
1841 * Function : updateMacDlLcCtxt
1843 * Functionality: Update UeDlCb Lc List
1845 * @params[in] UeDlCb pointer, ueLcCfg(received from DUAPP)
1848 * ****************************************************************/
1849 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg)
1851 uint8_t ueLcIdx = 0;
1853 /*Traversing DL LC to be updated/Deleted*/
1854 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
1856 if(dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId)
1858 if(ueLcCfg->configType == CONFIG_MOD)
1860 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1862 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
1865 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
1869 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
1871 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
1874 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
1877 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
1878 ueLcCfg->lcId,ueLcIdx);
1881 if(ueLcCfg->configType == CONFIG_DEL)
1883 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1884 (dlInfo->numDlLc)--;
1885 updateMacDlCb(ueLcIdx, dlInfo);
1886 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueLcCfg->lcId);
1892 /*******************************************************************
1894 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1898 * Function : fillMacLcCfgList
1900 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1902 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1903 * @return ROK - success
1906 * ****************************************************************/
1908 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
1912 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1914 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1916 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1918 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1920 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
1921 if(ueCfg->lcCfgList[lcIdx].drbQos)
1923 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
1924 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
1926 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
1927 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
1929 if(ueCfg->lcCfgList[lcIdx].snssai)
1931 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
1933 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
1935 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
1937 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
1940 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
1941 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
1943 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
1944 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
1948 /*Filling DL LC CB */
1949 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1950 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1951 ueCb->dlInfo.numDlLc++;
1952 /*Filling UL LC CB */
1953 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1954 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1955 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1956 ueCb->ulInfo.numUlLc++;
1957 }/*End of Add Config */
1960 updateMacUlLcCtxt(&ueCb->ulInfo, &ueCfg->lcCfgList[lcIdx]);
1961 updateMacDlLcCtxt(&ueCb->dlInfo, &ueCfg->lcCfgList[lcIdx]);
1962 }/*End of Mod Config */
1968 /*******************************************************************
1970 * @brief Fills MAC UE Cb Cfg
1974 * Function : fillMacUeCb
1976 * Functionality: Fills MAC UE Cb Cfg
1978 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1980 * @return ROK - success
1983 * ****************************************************************/
1985 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
1989 ueCb->ueId = ueCfg->ueId;
1990 ueCb->crnti = ueCfg->crnti;
1991 ueCb->cellCb = macCb.macCell[cellIdx];
1992 if(ueCfg->spCellCfgPres)
1994 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
1995 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
1999 ueCb->state = UE_STATE_ACTIVE;
2001 ueCb->state = UE_HANDIN_IN_PROGRESS;
2003 /*TODO: To check the bsr value during implementation */
2004 if(ueCfg->macCellGrpCfgPres)
2006 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2007 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2008 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2010 ret = fillMacLcCfgList(ueCb, ueCfg);
2013 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2018 /*******************************************************************
2020 * @brief Function to update Mac Ra Cb
2024 * Function : updateMacRaCb
2026 * Functionality: Function to update Mac Ra Cb
2028 * @params[in] cellIdx, Mac Ue Cb
2029 * @return ROK - success
2032 * ****************************************************************/
2034 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2038 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
2040 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
2042 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
2049 /*******************************************************************
2051 * @brief Function to delete Mac Ra Cb
2055 * Function : deleteMacRaCb
2057 * Functionality: Function to delete Mac Ra Cb
2059 * @params[in] cellIdx, Mac Ue Cb
2062 * ****************************************************************/
2064 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2068 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
2070 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
2072 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
2074 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
2075 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
2077 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
2079 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
2080 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
2082 memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
2089 /*******************************************************************
2091 * @brief Creates UE Cb
2095 * Function : createUeCb
2097 * Functionality: Creates UE Cb
2099 * @params[in] MAC UE Configuration
2100 * @return ROK - success
2103 * ****************************************************************/
2104 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2108 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2109 &&(ueCb->state == UE_STATE_ACTIVE))
2111 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2116 memset(ueCb, 0, sizeof(MacUeCb));
2117 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2120 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2125 if(ueCb->state == UE_STATE_ACTIVE)
2127 macCb.macCell[cellIdx]->numActvUe++;
2128 updateMacRaCb(cellIdx, ueCb);
2137 /*******************************************************************
2139 * @brief Modify UE Cb Cfg
2143 * Function : modifyUeCb
2145 * Functionality: modify UE Cb
2147 * @params[in] MAC UE Configuration
2148 * @return ROK - success
2151 * ****************************************************************/
2152 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2156 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2157 &&(ueCb->state == UE_STATE_ACTIVE))
2159 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueCfg->crnti);
2160 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2163 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2168 deleteMacRaCb(cellIdx, ueCb);
2176 /*******************************************************************
2178 * @brief Creates UE Cb and fills ueCfg
2182 * Function : procMacUeCfgData
2184 * Functionality: Creates UE Cb and fills ueCfg
2186 * @params[in] MAC UE Configuration
2187 * @return ROK - success
2190 * ****************************************************************/
2192 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
2196 MacUeCb *ueCb = NULLP;
2199 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2201 /* Validate cell id */
2202 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
2204 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", ueCfg->cellId);
2208 /* Check if max number of UE configured */
2209 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2211 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2215 /* Check if UE already configured */
2217 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueId -1];
2219 ueCb = &macCb.macCell[cellIdx]->hoUeCb[ueCfg->duUeF1apId -1];
2223 case EVENT_UE_CONFIG_RSP_TO_MAC:
2225 ret = createUeCb(cellIdx, ueCb, ueCfg);
2227 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2231 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2233 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
2235 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2246 /*******************************************************************
2248 * @brief Function to store the UeCfg Data
2252 * Function : copyToTmpData
2254 * Functionality: Function to store the UeCfg Data
2256 * @params[in] MacUeCfg pointer
2257 * @return ROK - success
2260 * ****************************************************************/
2262 uint8_t copyToTmpData(MacUeCfg *ueCfg)
2265 MacUeCfg *tmpData = NULLP;
2267 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2270 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2273 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2274 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2275 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->duUeF1apId-1] = tmpData;
2279 /*******************************************************************
2281 * @brief Handles UE create requst from DU APP
2285 * Function : MacProcUeCreateReq
2287 * Functionality: Handles UE create requst from DU APP
2290 * @return ROK - success
2293 * ****************************************************************/
2294 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2298 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2300 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2304 /*Storing received ueCfg in ueCfgTmpData */
2305 ret = copyToTmpData(ueCfg);
2308 /*Sending Cfg Req to SCH */
2309 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2311 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2314 /* Fill event and send UE create request to SCH */
2315 ret = sendUeReqToSch(pst, &schUeCfg);
2317 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2322 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2327 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2330 /* FREE shared memory */
2331 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2336 /*******************************************************************
2338 * @brief Fill and Send UE create response from MAC to DU APP
2342 * Function : MacSendUeCreateRsp
2344 * Functionality: Fill and Send UE create response from MAC to DUAPP
2346 * @params[in] MAC UE create result
2347 * SCH UE create response
2348 * @return ROK - success
2351 * ****************************************************************/
2352 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2354 MacUeCfgRsp *cfgRsp;
2357 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2360 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2364 /* Filling UE Config response */
2365 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2366 cfgRsp->cellId = schCfgRsp->cellId;
2367 cfgRsp->duUeF1apId = schCfgRsp->duUeF1apId;
2368 cfgRsp->result = result;
2370 /* Fill Post structure and send UE Create response*/
2371 memset(&rspPst, 0, sizeof(Pst));
2372 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2373 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2376 /*******************************************************************
2378 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2382 * Function : MacSendUeReconfigRsp
2384 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2386 * @params[in] MAC UE create result
2387 * SCH UE create response
2388 * @return ROK - success
2391 * ****************************************************************/
2392 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2394 MacUeCfgRsp *cfgRsp;
2397 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2400 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2404 /* Filling UE Config response */
2405 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2406 cfgRsp->cellId = schCfgRsp->cellId;
2407 cfgRsp->duUeF1apId = schCfgRsp->duUeF1apId;
2408 cfgRsp->result = result;
2410 /* Fill Post structure and send UE Create response*/
2411 memset(&rspPst, 0, sizeof(Pst));
2412 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2413 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2416 /*******************************************************************
2418 * @brief Function to return Mac Ue Cfg pointer
2422 * Function : getMacUeCfg
2425 * Function to return Mac Ue Cfg pointer
2427 * @params[in] cellIdx, ueId
2429 * @return MacUeCfg pointer - success
2432 * ****************************************************************/
2434 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t duUeF1apId)
2436 MacUeCfg *ueCfg = NULLP;
2437 if(macCb.macCell[cellIdx])
2439 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[duUeF1apId-1];
2443 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2448 /*******************************************************************
2450 * @brief Processes UE create response from scheduler
2454 * Function : MacProcSchUeCfgRsp
2457 * Processes UE create response from scheduler
2458 * Sends UE create response to DU APP
2460 * @params[in] Pst : Post structure
2461 * schCfgRsp : Scheduler UE cfg response
2462 * @return ROK - success
2465 * ****************************************************************/
2466 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2468 uint8_t result = MAC_DU_APP_RSP_NOK;
2471 MacUeCfg *ueCfg = NULLP;
2473 #ifdef CALL_FLOW_DEBUG_LOG
2476 case EVENT_UE_CONFIG_RSP_TO_MAC:
2477 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2479 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2480 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2483 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2488 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2489 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->duUeF1apId);
2492 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2498 case EVENT_UE_CONFIG_RSP_TO_MAC:
2500 if(schCfgRsp->rsp != RSP_NOK)
2502 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2505 ret = procMacUeCfgData(pst, ueCfg);
2508 result = MAC_DU_APP_RSP_OK;
2514 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2516 ret = MacSendUeCreateRsp(result, schCfgRsp);
2520 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2523 if(schCfgRsp->rsp != RSP_NOK)
2525 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
2529 ret = procMacUeCfgData(pst, ueCfg);
2532 result = MAC_DU_APP_RSP_OK;
2538 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
2541 ret = MacSendUeReconfigRsp(result, schCfgRsp);
2545 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2550 /*******************************************************************
2552 * @brief Handles UE Reconfig requst from DU APP
2556 * Function : MacProcUeReconfigReq
2558 * Functionality: Handles UE Reconfig requst from DU APP
2561 * @return ROK - success
2564 * ****************************************************************/
2565 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
2569 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2571 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
2575 /*Storing received ueCfg in ueCfgTmpData */
2576 ret = copyToTmpData(ueCfg);
2579 /*Sending Cfg Req to SCH */
2580 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2582 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
2585 /* Fill event and send UE create request to SCH */
2586 ret = sendUeReqToSch(pst, &schUeCfg);
2588 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
2593 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
2598 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2601 /* FREE shared memory */
2602 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2606 /*******************************************************************
2608 * @brief Fill and Send UE Delete response from MAC to DU APP
2612 * Function : MacSendUeDeleteRsp
2614 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
2616 * @params[in] MAC UE delete result
2617 * SCH UE delete response
2618 * @return ROK - success
2621 * ****************************************************************/
2623 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result)
2625 MacUeDeleteRsp *deleteRsp;
2628 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
2631 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
2635 /* Filling UE delete response */
2636 deleteRsp->cellId = cellId;
2637 GET_UE_ID(crnti, deleteRsp->ueId);
2638 deleteRsp->result = result;
2640 /* Fill Post structure and send UE delete response*/
2641 memset(&rspPst, 0, sizeof(Pst));
2642 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
2643 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
2646 /*******************************************************************
2648 * @brief freeing the Pucch Resrc Cfg
2652 * Function : deletePucchResourcesCfg
2654 * Functionality: freeing the Pucch Resrc Cfg
2656 * @params[in] PucchResrcCfg *resrcCfg
2657 * @return ROK - success
2660 * ****************************************************************/
2662 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
2665 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
2667 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
2669 case PUCCH_FORMAT_0:
2671 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
2674 case PUCCH_FORMAT_1:
2676 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
2679 case PUCCH_FORMAT_2:
2681 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
2684 case PUCCH_FORMAT_3:
2686 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
2689 case PUCCH_FORMAT_4:
2691 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
2699 /*******************************************************************
2701 * @brief Processes UE delete response from scheduler
2705 * Function : MacProcSchUeCfgRsp
2708 * Processes UE create delete from scheduler
2710 * @params[in] Pst : Post structure
2711 * schUeDelRsp : Scheduler UE delete respons
2712 * @return ROK - success
2715 * ****************************************************************/
2717 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
2719 uint8_t ueId =0, isCrntiValid = 0;
2721 uint8_t ret = RFAILED;
2722 UeDeleteStatus result;
2724 #ifdef CALL_FLOW_DEBUG_LOG
2725 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
2730 if(schUeDelRsp->rsp == RSP_OK)
2732 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
2733 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
2734 if(macCb.macCell[cellIdx])
2736 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
2739 /*C-RNTI value is out of Acceptable range*/
2740 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
2741 result = UEID_INVALID;
2745 GET_UE_ID(schUeDelRsp->crnti, ueId);
2746 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
2749 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2751 /*Looping around LCs to free S-NSSAI memory*/
2752 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
2754 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
2756 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
2758 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
2761 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
2762 macCb.macCell[cellIdx]->numActvUe--;
2768 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
2769 result = UEID_INVALID;
2775 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
2776 result = CELLID_INVALID;
2781 result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEID_INVALID;
2783 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK)
2785 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
2790 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
2796 /*******************************************************************
2798 * @brief Sends UE delete req to Scheduler
2802 * Function : sendUeDelReqToSch
2804 * Functionality: sends UE delete req to Scheduler
2806 * @params[in] Pst *pst, MacUeDelete *ueDelete
2807 * @return ROK - success
2810 * ****************************************************************/
2812 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
2814 if(ueDelete != NULLP)
2817 SchUeDelete schUeDel;
2819 memset(&schUeDel, 0, sizeof(SchUeDelete));
2820 schUeDel.cellId = ueDelete->cellId;
2821 schUeDel.crnti = ueDelete->crnti;
2822 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2823 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
2824 return(*macSchUeDeleteReqOpts[schPst.selector])(&schPst, &schUeDel);
2828 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
2834 /*******************************************************************
2836 * @brief Handles UE Delete requst from DU APP
2840 * Function : MacProcUeDeleteReq
2842 * Functionality: Handles UE Delete requst from DU APP
2844 * @params[in] Pst *pst, MacUeDelete *ueDelete
2845 * @return ROK - success
2848 * ****************************************************************/
2850 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
2854 UeDeleteStatus result=SUCCESS;
2855 MacUeCb *ueCb = NULLP;
2856 MacCellCb *cellCb = NULLP;
2858 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
2862 GET_CELL_IDX(ueDelete->cellId, cellIdx);
2863 cellCb = macCb.macCell[cellIdx];
2866 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
2867 if(ueCb->crnti == ueDelete->crnti)
2869 ret = sendUeDelReqToSch(pst, ueDelete);
2872 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
2878 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
2879 result = UEID_INVALID;
2884 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
2885 result = CELLID_INVALID;
2888 if(result != SUCCESS)
2890 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result);
2891 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2897 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
2903 /**********************************************************************
2905 **********************************************************************/