1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file stores handler for MAC and SCH configuration requests */
19 /* header include files (.h) */
20 #include "common_def.h"
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "lwr_mac_upr_inf.h"
27 #include "rlc_mac_inf.h"
28 #include "mac_upr_inf_api.h"
30 #include "lwr_mac_fsm.h"
31 #include "mac_utils.h"
32 #include "lwr_mac_phy.h"
34 uint8_t ssbPeriodicity[6] = {5, 10, 20, 40, 80, 160};
36 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
38 packMacCellCfgConfirm packMacCellCfmOpts[] =
40 packMacCellCfgCfm, /* packing for loosely coupled */
41 duHandleMacCellCfgCfm, /* packing for tightly coupled */
42 packMacCellCfgCfm, /* packing for light weight loosly coupled */
45 SchCellCfgFunc SchCellCfgOpts[] =
47 packSchCellCfg, /* packing for loosely coupled */
48 SchHdlCellCfgReq, /* packing for tightly coupled */
49 packSchCellCfg /* packing for light weight loosly coupled */
52 MacSchCellDeleteReqFunc macSchCellDeleteReqOpts[]=
54 packMacSchCellDeleteReq, /* packing for loosely coupled */
55 MacSchCellDeleteReq, /* packing for tightly coupled */
56 packMacSchCellDeleteReq /* packing for light weight loosely coupled */
59 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
61 packDuMacCellDeleteRsp, /* packing for loosely coupled */
62 DuProcMacCellDeleteRsp, /* packing for tightly coupled */
63 packDuMacCellDeleteRsp /* packing for light weight loosly coupled */
66 MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
68 packDuMacSliceCfgRsp, /* packing for loosely coupled */
69 DuProcMacSliceCfgRsp, /* packing for tightly coupled */
70 packDuMacSliceCfgRsp /* packing for light weight loosly coupled */
73 MacDuSliceReCfgRspFunc macDuSliceReCfgRspOpts[] =
75 packDuMacSliceReCfgRsp, /* packing for loosely coupled */
76 DuProcMacSliceReCfgRsp, /* packing for tightly coupled */
77 packDuMacSliceReCfgRsp /* packing for light weight loosly coupled */
80 MacSchPagingIndFunc macSchPagingIndOpts[] =
82 packMacSchPagingInd, /* packing for loosely coupled */
83 MacSchPagingInd, /* packing for tightly coupled */
84 packMacSchPagingInd /* packing for light weight loosely coupled */
88 * @brief Layer Manager Configuration request handler for Scheduler
92 * Function : MacSchGenCfgReq
94 * This function receives general configurations for Scheduler
95 * from DU APP and forwards to Scheduler.
97 * @param[in] Pst *pst, the post structure
98 * @param[in] RgMngmt *cfg, the configuration parameter's structure
102 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
106 printf("\nReceived Scheduler gen config at MAC");
107 memset(&schPst, 0, sizeof(Pst));
108 FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
109 SchProcGenCfgReq(&schPst, cfg);
115 * @brief Layer Manager Configuration response from Scheduler
119 * Function : SchSendCfgCfm
121 * This function sends general configurations response from
122 * Scheduler to DU APP.
124 * @param[in] Pst *pst, the post structure
125 * @param[in] RgMngmt *cfm, the configuration confirm structure
129 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
131 DU_LOG("\nDEBUG --> Sending Scheduler config confirm to DU APP");
132 pst->dstEnt = ENTDUAPP;
135 pst->selector = ODU_SELECTOR_LC;
136 RgMiLrgSchCfgCfm(pst, cfm);
142 * @brief Layer Manager Configuration request handler.
146 * Function : MacProcCellCfgReq
148 * This function handles the gNB and cell configuration
149 * request received from DU APP.
150 * This API unapcks and forwards the config towards SCH
152 * @param[in] Pst *pst
153 * @param[in] MacCellCfg *macCellCfg
157 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
161 uint8_t ret = ROK, sliceIdx = 0;
162 MacCellCb *macCellCb;
164 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
166 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
167 if(macCellCb == NULLP)
169 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
172 memset(macCellCb, 0, sizeof(MacCellCb));
174 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
175 macCb.macCell[cellIdx] = macCellCb;
176 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
177 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
179 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
180 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
181 if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
183 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
186 memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
187 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
189 macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
190 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
192 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
194 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
198 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
200 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
202 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
204 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
205 if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
207 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
210 memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
216 /* Send cell cfg to scheduler */
217 ret = MacSchCellCfgReq(pst, macCellCfg);
220 MacCellCfgCfm macCellCfgCfm;
221 macCellCfgCfm.rsp = RSP_NOK;
222 macCellCfgCfm.cellId = macCellCfg->cellId;
224 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
225 cfmPst.selector = ODU_SELECTOR_LC;
227 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
231 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
234 } /* end of MacProcCellCfgReq */
237 * @brief Layer Manager Configuration request handler.
241 * Function : MacSchCellCfgReq
243 * This function sends cell configuration to SCH
245 * @param[in] Pst *pst
246 * @param[in] MacCellCfg *macCellCfg
250 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
252 SchCellCfg schCellCfg;
254 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
256 memset(&cfgPst, 0, sizeof(Pst));
257 memset(&schCellCfg, 0, sizeof(SchCellCfg));
258 schCellCfg.cellId = macCellCfg->cellId;
259 schCellCfg.phyCellId = macCellCfg->phyCellId;
260 schCellCfg.numerology = macCellCfg->numerology;
261 schCellCfg.dupMode = macCellCfg->dupType;
262 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
263 schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
264 schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
266 /* fill ssb scheduler parameters */
267 schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
268 schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
269 schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
270 schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
271 schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
272 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
274 schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
276 schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]);
278 /* fill SIB1 scheduler parameters */
279 schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
280 schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
281 schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
282 schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
283 schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
284 schCellCfg.sib1SchCfg.pageCfg.numPO = macCellCfg->sib1Cfg.pagingCfg.numPO;
285 schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent;
287 if(schCellCfg.sib1SchCfg.pageCfg.poPresent)
289 memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
292 /* fill RACH config params */
293 schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
294 schCellCfg.schRachCfg.prachSubcSpacing = \
295 macCellCfg->prachCfg.prachSubcSpacing;
296 schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
297 schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
298 schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen;
299 schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
300 schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
301 schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1;
302 schCellCfg.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble;
303 schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
304 schCellCfg.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb;
305 schCellCfg.schRachCfg.prachMultCarrBand = macCellCfg->prachCfg.prachMultCarrBand;
306 schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
307 schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
308 schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow;
310 /* fill initial DL BWP */
311 schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
312 schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
313 schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
314 schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
315 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
316 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
317 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
318 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
319 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
320 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
321 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
322 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
323 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
324 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
325 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
326 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
327 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
328 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
329 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
330 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
331 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
332 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
333 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
334 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
335 schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
336 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
338 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
339 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
340 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
341 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
342 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
343 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
344 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
345 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
348 /* fill initial UL BWP */
349 schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
350 schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
351 schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
352 schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
353 schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
354 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
355 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
357 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
358 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
359 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
360 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
361 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
362 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
363 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
364 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
367 if(macCellCfg->plmnInfoList.snssai)
369 schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
370 MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
371 if(!schCellCfg.plmnInfoList.snssai)
373 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
376 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
378 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
380 MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
381 if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
383 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
386 memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
391 /* Drx configuration */
393 schCellCfg.drxInfo.drxOnDurationTimer.onDurationTimerValInMs = macCellCfg->drxInfo.drxOnDurationTimer.onDurationTimerValInMs;
394 if(!macCellCfg->drxInfo.drxOnDurationTimer.onDurationTimerValInMs)
395 schCellCfg.drxInfo.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
396 macCellCfg->drxInfo.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
398 schCellCfg.drxInfo.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
399 macCellCfg->drxInfo.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
400 schCellCfg.drxInfo.drxInactivityTimer = macCellCfg->drxInfo.drxInactivityTimer;
401 schCellCfg.drxInfo.drxHarqRttTimerDl = macCellCfg->drxInfo.drxHarqRttTimerDl;
402 schCellCfg.drxInfo.drxHarqRttTimerUl = macCellCfg->drxInfo.drxHarqRttTimerUl;
403 schCellCfg.drxInfo.drxRetransmissionTimerDl = macCellCfg->drxInfo.drxRetransmissionTimerDl;
404 schCellCfg.drxInfo.drxRetransmissionTimerUl = macCellCfg->drxInfo.drxRetransmissionTimerUl;
405 schCellCfg.drxInfo.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellCfg->drxInfo.drxLongCycleStartOffset.\
406 drxLongCycleStartOffsetChoice;
407 schCellCfg.drxInfo.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellCfg->drxInfo.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
408 schCellCfg.drxInfo.shortDrx.drxShortCycle = macCellCfg->drxInfo.shortDrx.drxShortCycle;
409 schCellCfg.drxInfo.shortDrx.drxShortCycleTimer = macCellCfg->drxInfo.shortDrx.drxShortCycleTimer;
410 schCellCfg.drxInfo.drxSlotOffset = macCellCfg->drxInfo.drxSlotOffset;
414 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
417 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
419 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
421 } /* end of MacSchCellCfgReq */
424 /*******************************************************************
426 * @brief Sends Cell config confirm to DU APP
430 * Function : MacSendCellCfgCfm
433 * Sends Cell config confirm to DU APP
435 * @params[in] Response status
438 * ****************************************************************/
439 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
443 MacCellCfgCfm macCellCfgCfm;
445 memset(&pst, 0, sizeof(Pst));
447 GET_CELL_IDX(cellId, cellIdx);
448 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
449 macCellCfgCfm.rsp = response;
452 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
453 pst.selector = ODU_SELECTOR_LC;
455 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
460 * @brief Layer Manager Configuration response handler.
464 * Function : MacProcSchCellCfgCfm
466 * This function processes cell configuration to SCH
468 * @param[in] Pst *pst
469 * @param[in] SchCellCfgCfm *schCellCfgCfm
473 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
475 uint16_t *cellId = NULLP;
477 #ifdef CALL_FLOW_DEBUG_LOG
478 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
481 if(schCellCfgCfm->rsp == RSP_OK)
483 cellId = &schCellCfgCfm->cellId;
484 #ifdef INTEL_TIMER_MODE
485 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
487 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
492 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
497 /*******************************************************************
499 * @brief MAC handler for config response from PHY
503 * Function : fapiMacConfigRsp
506 * Processes config response from PHY and sends cell config
512 * ****************************************************************/
513 void fapiMacConfigRsp(uint16_t cellId)
515 /* TODO : Processing of config response from PHY */
517 /* Send cell config cfm to DU APP */
518 MacSendCellCfgCfm(cellId, RSP_OK);
521 /*******************************************************************
523 * @brief Fill and Send Cell Delete response from MAC to DU APP
527 * Function : MacSendCellDeleteRsp
529 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
531 * @params[in] MAC Cell delete result
532 * SCH Cell delete response
533 * @return ROK - success
536 * ****************************************************************/
537 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
539 MacCellDeleteRsp *deleteRsp=NULLP;
542 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
545 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
549 /* Filling CELL delete response */
551 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
552 deleteRsp->cellId = cellId;
553 deleteRsp->result = result;
555 /* Fill Post structure and send CELL delete response*/
556 memset(&rspPst, 0, sizeof(Pst));
557 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
558 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
561 /*******************************************************************
563 * @brief Processes CELL delete response from scheduler
567 * Function : MacProcSchCellDeleteRsp
570 * Processes CELL delete from scheduler
572 * @params[in] Pst : Post structure
573 * schCellDelRsp : Scheduler CELL delete respons
574 * @return ROK - success
577 * * ****************************************************************/
578 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
580 uint8_t ret = ROK, sliceIdx = 0;
582 CellDeleteStatus status;
584 #ifdef CALL_FLOW_DEBUG_LOG
585 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
590 if(schCellDelRsp->rsp == RSP_OK)
592 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
593 schCellDelRsp->cellId);
594 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
595 if(macCb.macCell[cellIdx])
597 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
599 status = SUCCESSFUL_RSP;
600 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
602 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
604 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
606 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
607 numSupportedSlice * sizeof(Snssai*));
609 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
610 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
611 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
615 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
616 status = CELL_ID_INVALID;
622 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
623 status = CELL_ID_INVALID;
629 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
630 status = CELL_ID_INVALID;
633 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
635 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
642 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
648 /*******************************************************************
650 * @brief Sends Cell delete req to Scheduler
654 * Function : sendCellDelReqToSch
656 * Functionality: sends Cell delete req to Scheduler
658 * @params[in] SchCellDelete *schCellDel
659 * @return ROK - success
662 * ****************************************************************/
664 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
667 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
668 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
671 /*******************************************************************
673 * @brief Handles CELL Delete requst from DU APP
677 * Function : MacProcCellDeleteReq
679 * Functionality: Handles CELL Delete requst from DU APP
681 * @params[in] Pst *pst, MacCellDelete *cellDelete
682 * @return ROK - success
686 * ****************************************************************/
687 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
689 uint8_t ret = ROK, cellIdx=0;
690 SchCellDelete schCellDelete;
692 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
696 GET_CELL_IDX(cellDelete->cellId, cellIdx);
697 if(macCb.macCell[cellIdx])
699 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
701 memset(&schCellDelete, 0, sizeof(SchCellDelete));
702 schCellDelete.cellId = cellDelete->cellId;
703 ret = sendCellDelReqToSch(&schCellDelete);
706 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
712 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
719 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
726 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
727 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
729 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
734 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
738 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
745 * @brief free the temporary slice cfg stored in macCb.
749 * Function : freeMacSliceCfgReq
751 * free the temporary slice cfg stored in macCb
757 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
763 if(cfgReq->numOfConfiguredSlice)
765 for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
767 if(cfgReq->listOfSliceCfg[cfgIdx])
769 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
771 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
773 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
775 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
779 * @brief fill Mac Slice Config Rsp
783 * Function : fillMacSliceCfgRsp
785 * This function fill Mac Slice Config Rsp
787 * @param[in] SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
792 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
795 bool sliceFound = false;
798 macSliceCfgRsp->numSliceCfgRsp = schSliceCfgRsp->numSliceCfgRsp;
799 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp, macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
800 if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
802 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
806 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
809 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
814 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
815 if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
817 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
821 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
822 if(sliceFound == true)
823 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_OK;
826 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_NOK;
827 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_PRESENT;
834 * @brief send slice cfg response to duapp.
838 * Function : MacSendSliceConfigRsp
840 * sends slice cfg response to duapp
842 * @param[in] MacSliceCfgRsp macSliceCfgRsp
846 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
850 memset(&rspPst, 0, sizeof(Pst));
851 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
852 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
856 * @brief free the slice cfg rsp received from sch.
860 * Function : freeSchSliceCfgRsp
862 * This free the slice cfg rsp received from sch
864 * @param[in] SchSliceCfgRsp *sliceCfgrsp
868 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
874 if(schSliceCfgRsp->numSliceCfgRsp)
876 for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
878 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
880 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
886 * @brief Mac process the slice cfg rsp received from sch.
890 * Function : MacProcSchSliceCfgRsp
892 * This function process the slice cfg rsp received from sch
894 * @param[in] Pst *pst
895 * @param[in] SchSliceCfgRsp *sliceCfgrsp
899 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
901 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
905 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
906 if(macSliceCfgRsp == NULLP)
908 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
911 if(schSliceCfgRsp->listOfSliceCfgRsp)
913 if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
915 DU_LOG("\nERROR --> MAC : Failed to fill the slice cfg response");
918 MacSendSliceConfigRsp(macSliceCfgRsp);
920 freeSchSliceCfgRsp(schSliceCfgRsp);
926 * @brief send slice cfg response to duapp.
930 * Function : MacSendSliceReconfigRsp
932 * sends slice cfg response to duapp
934 * @param[in] MacSliceCfgRsp macSliceRecfgRsp
938 uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
942 memset(&rspPst, 0, sizeof(Pst));
943 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
944 return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
949 * @brief Mac process the slice cfg rsp received from sch.
953 * Function : MacProcSchSliceReCfgRsp
955 * This function process the slice cfg rsp received from sch
957 * @param[in] Pst *pst
958 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
962 uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
964 MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
968 MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
969 if(macSliceReCfgRsp == NULLP)
971 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
975 if(schSliceRecfgRsp->listOfSliceCfgRsp)
977 if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
979 DU_LOG("\nERROR --> MAC : Failed to fill the slice Recfg response");
982 MacSendSliceReconfigRsp(macSliceReCfgRsp);
984 freeSchSliceCfgRsp(schSliceRecfgRsp);
990 * @brief Mac process the downlink pcch indication received from DUAPP
994 * Function : MacProcDlPcchInd
996 * This function process the downlink pcch indication received from DUAPP
998 * @param[in] Pst *pst
999 * @param[in] MacPcchInd *pcchInd
1003 uint8_t MacProcDlPcchInd(Pst *pst, MacPcchInd *pcchInd)
1005 uint8_t ret = RFAILED;
1006 uint16_t cellIdx = 0;
1008 SchPageInd *schPageInd = NULLP;
1012 DU_LOG("\nINFO --> MAC : Received DL PCCH IND from DU_APP for cellId[%d]", pcchInd->cellId);
1014 GET_CELL_IDX(pcchInd->cellId, cellIdx);
1016 if(macCb.macCell[cellIdx] == NULLP || macCb.macCell[cellIdx]->cellId != pcchInd->cellId)
1018 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): CellId[%d] does not exist", pcchInd->cellId);
1022 if((pcchInd->pcchPdu == NULLP) || (pcchInd->pduLen <= 0))
1024 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Pcch pdu is null");
1028 MAC_ALLOC(schPageInd, sizeof(SchPageInd));
1029 if(schPageInd == NULLP)
1031 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
1035 schPageInd->cellId = pcchInd->cellId;
1036 schPageInd->pf = pcchInd->pf;
1037 schPageInd->i_s = pcchInd->i_s;
1038 schPageInd->pduLen = pcchInd->pduLen;
1040 MAC_ALLOC(schPageInd->pagePdu, pcchInd->pduLen);
1041 if(schPageInd->pagePdu == NULLP)
1043 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
1044 MAC_FREE(schPageInd, sizeof(SchPageInd));
1048 memcpy(schPageInd->pagePdu, pcchInd->pcchPdu, pcchInd->pduLen);
1050 FILL_PST_MAC_TO_SCH(schPst, EVENT_PAGING_IND_TO_SCH);
1051 ret = (*macSchPagingIndOpts[schPst.selector])(&schPst, schPageInd);
1056 if((pcchInd->pcchPdu) && (pcchInd->pduLen > 0))
1058 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd->pcchPdu, pcchInd->pduLen);
1060 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(MacPcchInd));
1064 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Null pointer");
1068 /**********************************************************************
1070 **********************************************************************/