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 macCb.macCell[cellIdx]->numOfSlots = 10 * (1 << macCellCfg->numerology);
178 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
180 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
181 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
182 if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
184 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
187 memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
188 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
190 macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
191 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
193 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
195 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
199 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
201 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
203 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
205 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
206 if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
208 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
211 memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
217 /* Send cell cfg to scheduler */
218 ret = MacSchCellCfgReq(pst, macCellCfg);
221 MacCellCfgCfm macCellCfgCfm;
222 macCellCfgCfm.rsp = RSP_NOK;
223 macCellCfgCfm.cellId = macCellCfg->cellId;
225 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
226 cfmPst.selector = ODU_SELECTOR_LC;
228 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
232 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
235 } /* end of MacProcCellCfgReq */
238 * @brief Layer Manager Configuration request handler.
242 * Function : MacSchCellCfgReq
244 * This function sends cell configuration to SCH
246 * @param[in] Pst *pst
247 * @param[in] MacCellCfg *macCellCfg
251 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
253 SchCellCfg schCellCfg;
255 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
257 memset(&cfgPst, 0, sizeof(Pst));
258 memset(&schCellCfg, 0, sizeof(SchCellCfg));
259 schCellCfg.cellId = macCellCfg->cellId;
260 schCellCfg.phyCellId = macCellCfg->phyCellId;
261 schCellCfg.numerology = macCellCfg->numerology;
262 schCellCfg.dupMode = macCellCfg->dupType;
263 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
264 schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
265 schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
267 /* fill ssb scheduler parameters */
268 schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
269 schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
270 schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
271 schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
272 schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
273 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
275 schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
277 schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]);
279 /* fill SIB1 scheduler parameters */
280 schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
281 schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
282 schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
283 schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
284 schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
285 schCellCfg.sib1SchCfg.pageCfg.numPO = macCellCfg->sib1Cfg.pagingCfg.numPO;
286 schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent;
288 if(schCellCfg.sib1SchCfg.pageCfg.poPresent)
290 memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
293 /* fill RACH config params */
294 schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
295 schCellCfg.schRachCfg.prachSubcSpacing = \
296 macCellCfg->prachCfg.prachSubcSpacing;
297 schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
298 schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
299 schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen;
300 schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
301 schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
302 schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1;
303 schCellCfg.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble;
304 schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
305 schCellCfg.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb;
306 schCellCfg.schRachCfg.prachMultCarrBand = macCellCfg->prachCfg.prachMultCarrBand;
307 schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
308 schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
309 schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow;
311 /* fill initial DL BWP */
312 schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
313 schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
314 schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
315 schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
316 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
317 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
318 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
319 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
320 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
321 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
322 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
323 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
324 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
325 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
326 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
327 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
328 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
329 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
330 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
331 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
332 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
333 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
334 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
335 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
336 schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
337 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
339 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
340 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
341 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
342 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
343 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
344 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
345 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
346 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
349 /* fill initial UL BWP */
350 schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
351 schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
352 schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
353 schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
354 schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
355 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
356 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
358 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
359 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
360 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
361 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
362 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
363 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
364 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
365 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
368 if(macCellCfg->plmnInfoList.snssai)
370 schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
371 MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
372 if(!schCellCfg.plmnInfoList.snssai)
374 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
377 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
379 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
381 MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
382 if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
384 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
387 memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
393 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
396 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
398 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
400 } /* end of MacSchCellCfgReq */
403 /*******************************************************************
405 * @brief Sends Cell config confirm to DU APP
409 * Function : MacSendCellCfgCfm
412 * Sends Cell config confirm to DU APP
414 * @params[in] Response status
417 * ****************************************************************/
418 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
422 MacCellCfgCfm macCellCfgCfm;
424 memset(&pst, 0, sizeof(Pst));
426 GET_CELL_IDX(cellId, cellIdx);
427 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
428 macCellCfgCfm.rsp = response;
431 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
432 pst.selector = ODU_SELECTOR_LC;
434 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
439 * @brief Layer Manager Configuration response handler.
443 * Function : MacProcSchCellCfgCfm
445 * This function processes cell configuration to SCH
447 * @param[in] Pst *pst
448 * @param[in] SchCellCfgCfm *schCellCfgCfm
452 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
454 uint16_t *cellId = NULLP;
456 #ifdef CALL_FLOW_DEBUG_LOG
457 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
460 if(schCellCfgCfm->rsp == RSP_OK)
462 cellId = &schCellCfgCfm->cellId;
463 #ifdef INTEL_TIMER_MODE
464 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
466 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
471 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
476 /*******************************************************************
478 * @brief MAC handler for config response from PHY
482 * Function : fapiMacConfigRsp
485 * Processes config response from PHY and sends cell config
491 * ****************************************************************/
492 void fapiMacConfigRsp(uint16_t cellId)
494 /* TODO : Processing of config response from PHY */
496 /* Send cell config cfm to DU APP */
497 MacSendCellCfgCfm(cellId, RSP_OK);
500 /*******************************************************************
502 * @brief Fill and Send Cell Delete response from MAC to DU APP
506 * Function : MacSendCellDeleteRsp
508 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
510 * @params[in] MAC Cell delete result
511 * SCH Cell delete response
512 * @return ROK - success
515 * ****************************************************************/
516 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
518 MacCellDeleteRsp *deleteRsp=NULLP;
521 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
524 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
528 /* Filling CELL delete response */
530 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
531 deleteRsp->cellId = cellId;
532 deleteRsp->result = result;
534 /* Fill Post structure and send CELL delete response*/
535 memset(&rspPst, 0, sizeof(Pst));
536 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
537 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
540 /*******************************************************************
542 * @brief Processes CELL delete response from scheduler
546 * Function : MacProcSchCellDeleteRsp
549 * Processes CELL delete from scheduler
551 * @params[in] Pst : Post structure
552 * schCellDelRsp : Scheduler CELL delete respons
553 * @return ROK - success
556 * * ****************************************************************/
557 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
559 uint8_t ret = ROK, sliceIdx = 0;
561 CellDeleteStatus status;
563 #ifdef CALL_FLOW_DEBUG_LOG
564 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
569 if(schCellDelRsp->rsp == RSP_OK)
571 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
572 schCellDelRsp->cellId);
573 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
574 if(macCb.macCell[cellIdx])
576 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
578 status = SUCCESSFUL_RSP;
579 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
581 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
583 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
585 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
586 numSupportedSlice * sizeof(Snssai*));
588 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
589 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
590 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
594 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
595 status = CELL_ID_INVALID;
601 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
602 status = CELL_ID_INVALID;
608 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
609 status = CELL_ID_INVALID;
612 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
614 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
621 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
627 /*******************************************************************
629 * @brief Sends Cell delete req to Scheduler
633 * Function : sendCellDelReqToSch
635 * Functionality: sends Cell delete req to Scheduler
637 * @params[in] SchCellDelete *schCellDel
638 * @return ROK - success
641 * ****************************************************************/
643 uint8_t sendCellDelReqToSch(SchCellDeleteReq *schCellDelReq)
646 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
647 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDelReq);
650 /*******************************************************************
652 * @brief Handles CELL Delete requst from DU APP
656 * Function : MacProcCellDeleteReq
658 * Functionality: Handles CELL Delete requst from DU APP
660 * @params[in] Pst *pst, MacCellDelete *cellDelete
661 * @return ROK - success
665 * ****************************************************************/
666 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDeleteReq *cellDelete)
668 uint8_t ret = ROK, cellIdx=0;
669 SchCellDeleteReq schCellDelete;
671 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
675 GET_CELL_IDX(cellDelete->cellId, cellIdx);
676 if(macCb.macCell[cellIdx])
678 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
680 memset(&schCellDelete, 0, sizeof(SchCellDeleteReq ));
681 schCellDelete.cellId = cellDelete->cellId;
682 ret = sendCellDelReqToSch(&schCellDelete);
685 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
691 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
698 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
705 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
706 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
708 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
713 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDeleteReq));
717 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
724 * @brief free the temporary slice cfg stored in macCb.
728 * Function : freeMacSliceCfgReq
730 * free the temporary slice cfg stored in macCb
736 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
742 if(cfgReq->numOfConfiguredSlice)
744 for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
746 if(cfgReq->listOfSliceCfg[cfgIdx])
748 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
750 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
752 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
754 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
758 * @brief fill Mac Slice Config Rsp
762 * Function : fillMacSliceCfgRsp
764 * This function fill Mac Slice Config Rsp
766 * @param[in] SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
771 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
774 bool sliceFound = false;
777 macSliceCfgRsp->numSliceCfgRsp = schSliceCfgRsp->numSliceCfgRsp;
778 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp, macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
779 if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
781 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
785 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
788 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
793 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
794 if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
796 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
800 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
801 if(sliceFound == true)
802 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_OK;
805 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_NOK;
806 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_PRESENT;
813 * @brief send slice cfg response to duapp.
817 * Function : MacSendSliceConfigRsp
819 * sends slice cfg response to duapp
821 * @param[in] MacSliceCfgRsp macSliceCfgRsp
825 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
829 memset(&rspPst, 0, sizeof(Pst));
830 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
831 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
835 * @brief free the slice cfg rsp received from sch.
839 * Function : freeSchSliceCfgRsp
841 * This free the slice cfg rsp received from sch
843 * @param[in] SchSliceCfgRsp *sliceCfgrsp
847 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
853 if(schSliceCfgRsp->numSliceCfgRsp)
855 for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
857 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
859 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
865 * @brief Mac process the slice cfg rsp received from sch.
869 * Function : MacProcSchSliceCfgRsp
871 * This function process the slice cfg rsp received from sch
873 * @param[in] Pst *pst
874 * @param[in] SchSliceCfgRsp *sliceCfgrsp
878 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
880 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
884 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
885 if(macSliceCfgRsp == NULLP)
887 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
890 if(schSliceCfgRsp->listOfSliceCfgRsp)
892 if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
894 DU_LOG("\nERROR --> MAC : Failed to fill the slice cfg response");
897 MacSendSliceConfigRsp(macSliceCfgRsp);
899 freeSchSliceCfgRsp(schSliceCfgRsp);
905 * @brief send slice cfg response to duapp.
909 * Function : MacSendSliceReconfigRsp
911 * sends slice cfg response to duapp
913 * @param[in] MacSliceRecfgRsp macSliceRecfgRsp
917 uint8_t MacSendSliceReconfigRsp(MacSliceRecfgRsp *macSliceRecfgRsp)
921 memset(&rspPst, 0, sizeof(Pst));
922 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
923 return (*macDuSliceRecfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
928 * @brief Mac process the slice cfg rsp received from sch.
932 * Function : MacProcSchSliceRecfgRsp
934 * This function process the slice cfg rsp received from sch
936 * @param[in] Pst *pst
937 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
941 uint8_t MacProcSchSliceRecfgRsp(Pst *pst, SchSliceRecfgRsp *schSliceRecfgRsp)
943 MacSliceRecfgRsp *macSliceRecfgRsp = NULLP;
947 MAC_ALLOC_SHRABL_BUF(macSliceRecfgRsp, sizeof(MacSliceRecfgRsp));
948 if(macSliceRecfgRsp == NULLP)
950 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceRecfgRsp");
954 if(schSliceRecfgRsp->listOfSliceCfgRsp)
956 if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceRecfgRsp) != ROK)
958 DU_LOG("\nERROR --> MAC : Failed to fill the slice Recfg response");
961 MacSendSliceReconfigRsp(macSliceRecfgRsp);
963 freeSchSliceCfgRsp(schSliceRecfgRsp);
969 * @brief Mac process the downlink pcch indication received from DUAPP
973 * Function : MacProcDlPcchInd
975 * This function process the downlink pcch indication received from DUAPP
977 * @param[in] Pst *pst
978 * @param[in] DlPcchInd *pcchInd
982 uint8_t MacProcDlPcchInd(Pst *pst, DlPcchInd *pcchInd)
984 uint8_t ret = RFAILED;
985 uint16_t cellIdx = 0;
987 SchPageInd *schPageInd = NULLP;
991 DU_LOG("\nINFO --> MAC : Received DL PCCH IND from DU_APP for cellId[%d]", pcchInd->cellId);
993 GET_CELL_IDX(pcchInd->cellId, cellIdx);
995 if(macCb.macCell[cellIdx] == NULLP || macCb.macCell[cellIdx]->cellId != pcchInd->cellId)
997 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): CellId[%d] does not exist", pcchInd->cellId);
1001 if((pcchInd->pcchPdu == NULLP) || (pcchInd->pduLen <= 0))
1003 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Pcch pdu is null");
1007 MAC_ALLOC(schPageInd, sizeof(SchPageInd));
1008 if(schPageInd == NULLP)
1010 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
1014 schPageInd->cellId = pcchInd->cellId;
1015 schPageInd->pf = pcchInd->pf;
1016 schPageInd->i_s = pcchInd->i_s;
1017 schPageInd->pduLen = pcchInd->pduLen;
1019 MAC_ALLOC(schPageInd->pagePdu, pcchInd->pduLen);
1020 if(schPageInd->pagePdu == NULLP)
1022 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
1023 MAC_FREE(schPageInd, sizeof(SchPageInd));
1027 memcpy(schPageInd->pagePdu, pcchInd->pcchPdu, pcchInd->pduLen);
1029 FILL_PST_MAC_TO_SCH(schPst, EVENT_PAGING_IND_TO_SCH);
1030 ret = (*macSchPagingIndOpts[schPst.selector])(&schPst, schPageInd);
1035 if((pcchInd->pcchPdu) && (pcchInd->pduLen > 0))
1037 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd->pcchPdu, pcchInd->pduLen);
1039 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(DlPcchInd));
1043 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Null pointer");
1047 /**********************************************************************
1049 **********************************************************************/