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 MacSchUeCreateReqFunc macSchUeCreateReqOpts[] =
34 packMacSchUeCreateReq, /* packing for loosely coupled */
35 MacSchUeCreateReq, /* packing for tightly coupled */
36 packMacSchUeCreateReq /* 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 MacSchUeReconfigReqFunc macSchUeReconfigReqOpts[] =
48 packMacSchUeReconfigReq, /* packing for loosely coupled */
49 MacSchUeReconfigReq, /* packing for tightly coupled */
50 packMacSchUeReconfigReq /* packing for light weight loosely coupled */
53 /*******************************************************************
55 * @brief Fills mac cell group config to be sent to scheduler
59 * Function : fillMacCellGroupCfg
61 * Functionality: Fills mac cell group config to be sent to sch
63 * @params[in] macCellGrp : mac cell group config at MAC
64 * *macCellGrpCfg : mac cell group cfg to be filled
65 * @return ROK - success
68 * ****************************************************************/
69 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
72 SchSchedReqCfg *schedReqCfg;
75 /* Copy scheduling request config */
76 schedReqCfg = &macCellGrpCfg->schedReqCfg;
77 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
78 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
80 DU_LOG("\nMAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
81 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
84 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
86 schedReqCfg->addModList[idx].schedReqId = \
87 macCellGrp.schReqCfg.addModList[idx].schedReqId;
88 schedReqCfg->addModList[idx].srProhibitTmr = \
89 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
90 schedReqCfg->addModList[idx].srTransMax = \
91 macCellGrp.schReqCfg.addModList[idx].srTransMax;
93 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
96 tagCfg = &macCellGrpCfg->tagCfg;
97 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
98 if(tagCfg->addModListCount > MAX_NUM_TAGS)
100 DU_LOG("\nMAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
101 tagCfg->addModListCount, MAX_NUM_TAGS);
104 for(idx = 0; idx < tagCfg->addModListCount; idx++)
106 tagCfg->addModList[idx].tagId = \
107 macCellGrp.tagCfg.addModList[idx].tagId;
108 tagCfg->addModList[idx].timeAlignmentTmr = \
109 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
111 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
113 /* Copy PHR config */
114 if(macCellGrp.phrCfgSetupPres)
116 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
117 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
118 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
119 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
120 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
121 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
122 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
128 /*******************************************************************
130 * @brief Fills phy cell group config to be sent to scheduler
134 * Function : fillPhyCellGroupCfg
136 * Functionality: Fills phy cell group config to be sent to sch
138 * @params[in] macUeCfg : Phy cell group config at MAC
139 * *schPhyCellGrp : phy cell group config to be filled
140 * @return ROK - success
143 * ****************************************************************/
144 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
146 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
147 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
152 /*******************************************************************
154 * @brief Fills PDSCh serving cell config to send to scheduler
158 * Function : fillPdschServCellCfg
160 * Functionality: Fills PDSCh serving cell config to send to scheduler
162 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
163 * *schPdschCfg : Pdsch serving cell config to be filled
164 * @return ROK - success
167 * ****************************************************************/
168 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
170 if(macPdschCfg.maxMimoLayers)
172 if(!schPdschCfg->maxMimoLayers)
174 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
175 if(!schPdschCfg->maxMimoLayers)
177 DU_LOG("\nMAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
181 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
185 schPdschCfg->maxMimoLayers = NULLP;
188 schPdschCfg->numHarqProcForPdsch = \
189 macPdschCfg.numHarqProcForPdsch;
191 if(macPdschCfg.maxCodeBlkGrpPerTb)
193 if(!schPdschCfg->maxCodeBlkGrpPerTb)
195 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
196 if(!schPdschCfg->maxCodeBlkGrpPerTb)
198 DU_LOG("\nMAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
202 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
206 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
209 if(macPdschCfg.codeBlkGrpFlushInd)
211 if(!schPdschCfg->codeBlkGrpFlushInd)
213 MAC_ALLOC_SHRABL_BUF(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
214 if(!schPdschCfg->codeBlkGrpFlushInd)
216 DU_LOG("\nMAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
220 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
224 schPdschCfg->codeBlkGrpFlushInd = NULLP;
227 if(macPdschCfg.xOverhead)
229 if(!schPdschCfg->xOverhead)
231 MAC_ALLOC_SHRABL_BUF(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
232 if(!schPdschCfg->xOverhead)
234 DU_LOG("\nMAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
238 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
242 schPdschCfg->xOverhead = NULLP;
248 /*******************************************************************
250 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
254 * Function : fillInitalUlBwpPuschCfg
257 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
259 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
260 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
261 * @return ROK - success
264 * ****************************************************************/
265 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
269 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
270 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
271 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
272 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
273 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
274 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
276 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
277 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
279 DU_LOG("\nMAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
280 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
283 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
285 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
286 macPuschCfg.timeDomRsrcAllocList[idx].k2;
287 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
288 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
289 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
290 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
291 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
292 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
295 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
299 /*******************************************************************
301 * @brief Fills initail UL BWP config to send to scheduler
305 * Function : fillInitialUlBwp
307 * Functionality: Fills initail UL BWP config to send to sch
309 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
310 * schInitUlBwp : Initial UL BWP cfg to be filled
311 * @return ROK - success
314 * ****************************************************************/
315 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
317 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
318 if(schInitUlBwp->pucchCfgPres)
320 /* TODO : Optional parameter */
323 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
324 if(schInitUlBwp->puschCfgPres)
326 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
328 DU_LOG("\nMAC : fillInitalUlBwpPuschCfg() failed");
335 /*******************************************************************
337 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
341 * Function : fillInitDlBwpPdcchCfg
344 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
346 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
347 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
348 * @return ROK - success
351 * ****************************************************************/
352 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
356 /* Fill CORESET info */
357 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
358 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
360 DU_LOG("\nMAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
361 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
365 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
367 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
368 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
369 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
370 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
371 schPdcchCfg->cRSetToAddModList[idx].duration = \
372 macPdcchCfg.cRSetToAddModList[idx].duration;
373 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
374 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
375 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
376 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
377 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
378 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
381 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
382 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
384 DU_LOG("\nMAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
385 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
389 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
394 /* Fill Search space info */
395 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
396 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
398 DU_LOG("\nMAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
399 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
402 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
404 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
405 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
406 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
407 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
408 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
409 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
410 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
411 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
412 MONITORING_SYMB_WITHIN_SLOT_SIZE);
413 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
414 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
415 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
416 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
417 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
418 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
419 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
420 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
421 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
422 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
423 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
424 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
425 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
426 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
429 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
430 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
432 DU_LOG("\nMAC : Number of search space to release [%d] exceeds max [%d]", \
433 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
436 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
444 /*******************************************************************
446 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
450 * Function : fillInitDlBwpPdschCfg
453 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
455 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
456 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
457 * @return ROK - success
460 * ****************************************************************/
461 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
465 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
466 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
467 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
468 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
469 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
471 DU_LOG("\nMAC : Number of time domain resource allocation [%d], exceeds\
472 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
476 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
478 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
479 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
480 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
481 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
482 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
483 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
486 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
487 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
488 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
489 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
491 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
493 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
495 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
496 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
501 /*******************************************************************
503 * @brief Fill Initial DL BWP for SCH UE config
507 * Function : fillInitialDlBwp
509 * Functionality: Fill Initial DL BWP for SCH UE config
511 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
512 * schInitDlBwp : Inital DL BWP cfg to be filled
513 * @return ROK - success
516 * ****************************************************************/
517 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
519 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
520 if(schInitDlBwp->pdcchCfgPres)
522 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
524 DU_LOG("\nMAC : fillInitDlBwpPdcchCfg() failed");
529 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
530 if(schInitDlBwp->pdschCfgPres)
532 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
534 DU_LOG("\nMAC : fillInitDlBwpPdschCfg() failed");
541 /*******************************************************************
543 * @brief Fills Sp Cell config to be sent to scheduler
547 * Function : fillSpCellCfg
549 * Functionality: Fills Sp Cell config to be sent to scheduler
551 * @params[in] macSpCellCfg : SP cell cfg at MAC
552 * schSpCellCfg : SP cell cfg to be filled
553 * @return ROK - success
556 * ****************************************************************/
557 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
560 SchServCellCfgInfo *servCellCfg;
562 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
563 servCellCfg = &schSpCellCfg->servCellCfg;
565 /* Fill initial DL BWP */
566 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
567 &servCellCfg->initDlBwp) != ROK )
569 DU_LOG("\nMAC : fillInitialDlBwp() failed");
573 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
574 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
576 DU_LOG("\nMAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
577 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
580 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
582 /* TODO : As of now numDlBwpToAdd = 0 */
585 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
586 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
587 servCellCfg->bwpInactivityTmr = NULL;
588 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
590 /* TODO : This is an optional parameter, not filled currently */
593 /* Fill PDSCH serving cell config */
594 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
595 &servCellCfg->pdschServCellCfg) != ROK)
597 DU_LOG("\nMAC : fillPdschServCellCfg() failed");
601 /* Fill Initail UL BWP */
602 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
603 &servCellCfg->initUlBwp) != ROK)
605 DU_LOG("\nMAC : fillInitialUlBwp() failed");
609 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
610 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
612 DU_LOG("\nMAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
613 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
616 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
618 /* TODO : As of now numDlBwpToAdd = 0 */
620 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
625 /*******************************************************************
627 * @brief Sends UE configuration to Scheduler
631 * Function : sendUeReqToSch
633 * Functionality: sends UE configuration to Scheduler
635 * @params[in] Pst and Ue configuration
636 * @return ROK - success
639 * ****************************************************************/
641 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
646 case EVENT_MAC_UE_CREATE_REQ:
647 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_CREATE_REQ_TO_SCH);
648 return(*macSchUeCreateReqOpts[schPst.selector])(&schPst, schUeCfg);
650 case EVENT_MAC_UE_RECONFIG_REQ:
651 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_RECONFIG_REQ_TO_SCH);
652 return(*macSchUeReconfigReqOpts[schPst.selector])(&schPst,schUeCfg);
654 DU_LOG("\n Invalid Pst received %d", pst->event);
659 /*******************************************************************
661 * @brief Fills Sch Drb Qos Information
665 * Function : fillSchDrbQosInfo
667 * Functionality: Fills Sch Drb Qos Information
669 * @params[in] macLcCfg : Logical channel Cfg at MAC
670 * schLcCfg : LC cfg to fill at scheduler
671 * @return ROK - success
674 * ****************************************************************/
675 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
677 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
678 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
680 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
681 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
682 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
683 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
685 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
687 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
688 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
689 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
690 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
691 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
692 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
693 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
694 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
696 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
697 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
698 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
699 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
700 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
701 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
702 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
703 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
704 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
707 /*******************************************************************
709 * @brief Fill SCH UL logical channel configuration
713 * Function : fillSchUlLcCfg
715 * Functionality: Fills Sch Ul Lc configuration
717 * @params[in] macLcCfg : Logical channel Cfg at MAC
718 * schLcCfg : LC cfg to fill at scheduler
721 * ****************************************************************/
723 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
725 schUlLcCfg->priority= macUlLcCfg->priority;
726 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
727 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
728 schUlLcCfg->pbr = macUlLcCfg->pbr;
729 schUlLcCfg->bsd = macUlLcCfg->bsd;
732 /*******************************************************************
734 * @brief Fill logical channel configuration
738 * Function : fillLogicalChannelCfg
740 * Functionality: Fill logical channel configuration
742 * @params[in] macLcCfg : Logical channel Cfg at MAC
743 * schLcCfg : LC cfg to fill at scheduler
744 * @return ROK - success
747 * ****************************************************************/
748 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
752 schLcCfg->lcId = macLcCfg->lcId;
753 schLcCfg->configType = macLcCfg->configType;
754 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
755 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
759 if(!schLcCfg->drbQos)
761 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
762 if(!schLcCfg->drbQos)
764 DU_LOG("\nMAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
770 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
777 schLcCfg->drbQos = NULLP;
784 if(!schLcCfg->snssai)
786 MAC_ALLOC(schLcCfg->snssai, sizeof(SchSnssai));
787 if(!schLcCfg->snssai)
789 DU_LOG("\nMAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
795 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
796 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
798 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
803 schLcCfg->snssai = NULLP;
804 /*Freeing the previously allocated buffer in case of failure */
807 MAC_FREE(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
808 schLcCfg->drbQos = NULLP;
815 schLcCfg->snssai = NULLP;
822 /*******************************************************************
824 * @brief Fills Logical channel Cfg List to Add/Mod/Del
828 * Function : fillSchLcCfgList
830 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
832 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
833 * @return ROK - success
836 * ****************************************************************/
838 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
842 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
844 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
846 DU_LOG("\nMAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
854 /*******************************************************************
856 * @brief Fills and sends UE configuration to Scheduler
860 * Function : fillSchUeCfg
862 * Functionality: Fills and sends UE configuration to Scheduler
864 * @params[in] Ue configuration from DU APP
865 * @return ROK - success
868 * ****************************************************************/
869 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
873 schUeCfg->cellId = ueCfg->cellId;
874 schUeCfg->crnti = ueCfg->crnti;
876 /* Copy MAC cell group config */
877 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
878 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
880 DU_LOG("\nMAC : fillMacCellGroupCfg() failed");
884 /* Copy Physical cell group config */
885 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
886 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
888 DU_LOG("\nMAC : fillPhyCellGroupCfg() failed");
892 /* Copy sp cell config */
893 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
894 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
896 DU_LOG("\nMAC : fillSpCellCfg() failed");
900 schUeCfg->aggrMaxBitRate = NULL;
901 if(ueCfg->maxAggrBitRate != NULL)
903 MAC_ALLOC(schUeCfg->aggrMaxBitRate, sizeof(SchAggrMaxBitRate));
904 if(!schUeCfg->aggrMaxBitRate)
906 DU_LOG("\nMAC : Memory allocation failed in sendReconfigReqToSch");
909 schUeCfg->aggrMaxBitRate->ulBitRate = ueCfg->maxAggrBitRate->ulBits;
910 schUeCfg->aggrMaxBitRate->dlBitRate = ueCfg->maxAggrBitRate->dlBits;
913 /* Fill sch Lc Cfg to Add/ Mod/ Del */
914 ret = fillSchLcCfgList(schUeCfg, ueCfg);
917 DU_LOG("\nMAC : Failed to copy LCs at fillSchUeCfg()");
923 /*******************************************************************
925 * @brief Update UeUlCb Lc List
929 * Function : updateMacUlCb
931 * Functionality: Update UeUlCb Lc List
933 * @params[in] delIdx, UeUlCb pointer
936 * ****************************************************************/
938 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
942 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
944 /* Moving the array element to one step ahead */
945 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
946 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
950 /*******************************************************************
952 * @brief Update UeDlCb Lc List
956 * Function : updateMacDlCb
958 * Functionality: Update UeDlCb Lc List
960 * @params[in] delIdx, UeDlCb pointer
963 * ****************************************************************/
965 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
969 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
971 /* Moving the array element to one step ahead */
972 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
973 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
977 /*******************************************************************
979 * @brief Fills Logical channel Cfg List to Add/Mod/Del
983 * Function : fillMacLcCfgList
985 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
987 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
988 * @return ROK - success
991 * ****************************************************************/
993 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
995 uint8_t lcIdx, ueLcIdx;
997 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
999 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1001 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1003 /*Filling DL LC CB */
1004 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1005 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1006 ueCb->dlInfo.numDlLc++;
1007 /*Filling UL LC CB */
1008 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1009 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1010 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1011 ueCb->ulInfo.numUlLc++;
1012 }/*End of Add Config */
1015 //searching for Lc to be Mod
1016 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++)
1018 if(ueCb->ulInfo.lcCb[ueLcIdx].lcId == ueCfg->lcCfgList[lcIdx].lcId)
1020 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
1022 /*Nothing to Modify in DL LC CB */
1023 /*Modify UL LC CB */
1024 ueCb->ulInfo.lcCb[ueLcIdx].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1025 DU_LOG("\nMAC: Successfully Modified LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1028 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
1030 memset(&ueCb->dlInfo.lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1031 (ueCb->dlInfo.numDlLc)--;
1032 updateMacDlCb(ueLcIdx, &ueCb->dlInfo);
1034 memset(&ueCb->ulInfo.lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1035 (ueCb->ulInfo.numUlLc)--;
1036 updateMacUlCb(ueLcIdx, &ueCb->ulInfo);
1037 DU_LOG("\nMAC: Successfully Deleted LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1042 }/*End of Mod Config */
1048 /*******************************************************************
1050 * @brief Fills MAC UE Cb Cfg
1054 * Function : fillMacUeCb
1056 * Functionality: Fills MAC UE Cb Cfg
1058 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1060 * @return ROK - success
1063 * ****************************************************************/
1065 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
1069 ueCb->ueIdx = ueCfg->ueIdx;
1070 ueCb->crnti = ueCfg->crnti;
1071 ueCb->cellCb = macCb.macCell[cellIdx];
1072 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
1073 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
1074 ueCb->state = UE_STATE_ACTIVE;
1075 /*TODO: To check the bsr value during implementation */
1076 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
1077 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
1078 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
1079 ret = fillMacLcCfgList(ueCb, ueCfg);
1082 DU_LOG("\nMAC: Failed while filing MAC LC List at fillMacUeCb()");
1087 /*******************************************************************
1089 * @brief Function to update Mac Ra Cb
1093 * Function : updateMacRaCb
1095 * Functionality: Function to update Mac Ra Cb
1097 * @params[in] cellIdx, Mac Ue Cb
1098 * @return ROK - success
1101 * ****************************************************************/
1103 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1107 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1109 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1111 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
1118 /*******************************************************************
1120 * @brief Function to delete Mac Ra Cb
1124 * Function : deleteMacRaCb
1126 * Functionality: Function to delete Mac Ra Cb
1128 * @params[in] cellIdx, Mac Ue Cb
1131 * ****************************************************************/
1133 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1137 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1139 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1141 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
1143 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
1144 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
1146 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
1148 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
1149 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
1151 memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
1158 /*******************************************************************
1160 * @brief Creates UE Cb
1164 * Function : createUeCb
1166 * Functionality: Creates UE Cb
1168 * @params[in] MAC UE Configuration
1169 * @return ROK - success
1172 * ****************************************************************/
1173 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1177 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1178 &&(ueCb->state == UE_STATE_ACTIVE))
1180 DU_LOG("\n MAC : CRNTI %d already configured ", ueCfg->crnti);
1185 memset(ueCb, 0, sizeof(MacUeCb));
1186 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1189 DU_LOG("\nMAC : Failed to create Ue Cb at createUeCb()");
1194 macCb.macCell[cellIdx]->numActvUe++;
1195 updateMacRaCb(cellIdx, ueCb);
1203 /*******************************************************************
1205 * @brief Modify UE Cb Cfg
1209 * Function : modifyUeCb
1211 * Functionality: modify UE Cb
1213 * @params[in] MAC UE Configuration
1214 * @return ROK - success
1217 * ****************************************************************/
1218 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1222 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1223 &&(ueCb->state == UE_STATE_ACTIVE))
1225 DU_LOG("\n MAC : Reconfig Req received for CRNTI %d ", ueCfg->crnti);
1226 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1229 DU_LOG("\nMAC : Failed to modify Ue Cb at modifyUeCb()");
1234 deleteMacRaCb(cellIdx, ueCb);
1242 /*******************************************************************
1244 * @brief Creates UE Cb and fills ueCfg
1248 * Function : procMacUeCfgData
1250 * Functionality: Creates UE Cb and fills ueCfg
1252 * @params[in] MAC UE Configuration
1253 * @return ROK - success
1256 * ****************************************************************/
1258 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
1262 MacUeCb *ueCb = NULLP;
1265 GET_CELL_IDX(ueCfg->cellId, cellIdx);
1267 /* Validate cell id */
1268 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
1270 DU_LOG("\nMAC : Cell Id %d not configured", ueCfg->cellId);
1274 /* Check if max number of UE configured */
1275 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
1277 DU_LOG("MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
1281 /* Check if UE already configured */
1282 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
1285 case EVENT_UE_CREATE_RSP_TO_MAC:
1286 ret = createUeCb(cellIdx, ueCb, ueCfg);
1288 case EVENT_UE_RECONFIG_RSP_TO_MAC:
1289 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
1298 /*******************************************************************
1300 * @brief Function to store the UeCfg Data
1304 * Function : copyToTmpData
1306 * Functionality: Function to store the UeCfg Data
1308 * @params[in] MacUeCfg pointer
1309 * @return ROK - success
1312 * ****************************************************************/
1314 uint8_t copyToTmpData(MacUeCfg *ueCfg)
1317 MacUeCfg *tmpData = NULLP;
1319 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
1322 DU_LOG("\nMAC: Memory Alloc Failed at copyToTmpData()");
1325 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
1326 GET_CELL_IDX(ueCfg->cellId, cellIdx);
1327 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueIdx-1] = tmpData;
1331 /*******************************************************************
1333 * @brief Handles UE create requst from DU APP
1337 * Function : MacProcUeCreateReq
1339 * Functionality: Handles UE create requst from DU APP
1342 * @return ROK - success
1345 * ****************************************************************/
1346 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
1350 memset(&schUeCfg, 0, sizeof(SchUeCfg));
1352 DU_LOG("\nMAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
1356 /*Storing received ueCfg in ueCfgTmpData */
1357 ret = copyToTmpData(ueCfg);
1360 /*Sending Cfg Req to SCH */
1361 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
1363 DU_LOG("\nMAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
1366 /* Fill event and send UE create request to SCH */
1367 ret = sendUeReqToSch(pst, &schUeCfg);
1369 DU_LOG("\nMAC : Failed to send UE Create request to SCH");
1374 DU_LOG("\nMAC : Failed to store MAC UE CFG ");
1379 DU_LOG("\nMAC : MAC UE Create request processing failed");
1382 /* FREE shared memory */
1383 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
1388 /*******************************************************************
1390 * @brief Fill and Send UE create response from MAC to DU APP
1394 * Function : MacSendUeCreateRsp
1396 * Functionality: Fill and Send UE create response from MAC to DUAPP
1398 * @params[in] MAC UE create result
1399 * SCH UE create response
1400 * @return ROK - success
1403 * ****************************************************************/
1404 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
1406 MacUeCfgRsp *cfgRsp;
1409 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
1412 DU_LOG("\nMAC: Memory allocation for UE config response failed");
1416 /* Filling UE Config response */
1417 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
1418 cfgRsp->cellId = schCfgRsp->cellId;
1419 cfgRsp->ueIdx = schCfgRsp->ueIdx;
1420 cfgRsp->result = result;
1422 /* Fill Post structure and send UE Create response*/
1423 memset(&rspPst, 0, sizeof(Pst));
1424 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
1425 return MacDuUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
1428 /*******************************************************************
1430 * @brief Fill and Send UE Reconfig response from MAC to DU APP
1434 * Function : MacSendUeReconfigRsp
1436 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
1438 * @params[in] MAC UE create result
1439 * SCH UE create response
1440 * @return ROK - success
1443 * ****************************************************************/
1444 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
1446 MacUeCfgRsp *cfgRsp;
1449 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
1452 DU_LOG("\nMAC: Memory allocation for UE Reconfig response failed");
1456 /* Filling UE Config response */
1457 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
1458 cfgRsp->cellId = schCfgRsp->cellId;
1459 cfgRsp->ueIdx = schCfgRsp->ueIdx;
1460 cfgRsp->result = result;
1462 /* Fill Post structure and send UE Create response*/
1463 memset(&rspPst, 0, sizeof(Pst));
1464 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
1465 return MacDuUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
1468 /*******************************************************************
1470 * @brief Function to return Mac Ue Cfg pointer
1474 * Function : getMacUeCfg
1477 * Function to return Mac Ue Cfg pointer
1479 * @params[in] cellIdx, ueIdx
1481 * @return MacUeCfg pointer - success
1484 * ****************************************************************/
1486 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueIdx)
1488 MacUeCfg *ueCfg = NULLP;
1489 if(macCb.macCell[cellIdx])
1491 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueIdx-1];
1495 DU_LOG("\nMAC: Failed to get macCellCb in getMacUeCfg()");
1500 /*******************************************************************
1502 * @brief Processes UE create response from scheduler
1506 * Function : MacProcSchUeCfgRsp
1509 * Processes UE create response from scheduler
1510 * Sends UE create response to DU APP
1512 * @params[in] Pst : Post structure
1513 * schCfgRsp : Scheduler UE cfg response
1514 * @return ROK - success
1517 * ****************************************************************/
1518 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
1520 uint8_t result = MAC_DU_APP_RSP_NOK;
1523 MacUeCfg *ueCfg = NULLP;
1525 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
1526 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueIdx);
1530 if(schCfgRsp->rsp == RSP_NOK)
1532 DU_LOG("\nMAC : SCH UE Config Response : FAILURE [CRNTI %d] for event %d", schCfgRsp->crnti, pst->event);
1536 DU_LOG("\nMAC : SCH UE Config Response : SUCCESS [CRNTI %d]", schCfgRsp->crnti);
1537 ret = procMacUeCfgData(pst, ueCfg);
1540 result = MAC_DU_APP_RSP_OK;
1543 MAC_FREE(ueCfg, sizeof(MacUeCfg));
1546 if(pst->event == EVENT_UE_CREATE_RSP_TO_MAC)
1548 ret = MacSendUeCreateRsp(result, schCfgRsp);
1550 if(pst->event == EVENT_UE_RECONFIG_RSP_TO_MAC)
1552 ret = MacSendUeReconfigRsp(result, schCfgRsp);
1558 /*******************************************************************
1560 * @brief Handles UE Reconfig requst from DU APP
1564 * Function : MacProcUeReconfigReq
1566 * Functionality: Handles UE Reconfig requst from DU APP
1569 * @return ROK - success
1572 * ****************************************************************/
1573 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
1577 memset(&schUeCfg, 0, sizeof(SchUeCfg));
1579 DU_LOG("\nMAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
1583 /*Storing received ueCfg in ueCfgTmpData */
1584 ret = copyToTmpData(ueCfg);
1587 /*Sending Cfg Req to SCH */
1588 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
1590 DU_LOG("\nMAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
1593 /* Fill event and send UE create request to SCH */
1594 ret = sendUeReqToSch(pst, &schUeCfg);
1596 DU_LOG("\nMAC : Failed to send UE Reconfig Request to SCH");
1601 DU_LOG("\nMAC : Failed to store MAC UE Cb ");
1606 DU_LOG("\nMAC : MAC UE Create request processing failed");
1609 /* FREE shared memory */
1610 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
1615 /**********************************************************************
1617 **********************************************************************/