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 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
47 packDuMacCellDeleteRsp, /* packing for loosely coupled */
48 DuProcMacCellDeleteRsp, /* packing for tightly coupled */
49 packDuMacCellDeleteRsp /* packing for light weight loosly coupled */
52 MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
54 packDuMacSliceCfgRsp, /* packing for loosely coupled */
55 DuProcMacSliceCfgRsp, /* packing for tightly coupled */
56 packDuMacSliceCfgRsp /* packing for light weight loosly coupled */
59 MacDuSliceRecfgRspFunc macDuSliceRecfgRspOpts[] =
61 packDuMacSliceRecfgRsp, /* packing for loosely coupled */
62 DuProcMacSliceRecfgRsp, /* packing for tightly coupled */
63 packDuMacSliceRecfgRsp /* packing for light weight loosly coupled */
67 * @brief Layer Manager Configuration request handler for Scheduler
71 * Function : MacSchGenCfgReq
73 * This function receives general configurations for Scheduler
74 * from DU APP and forwards to Scheduler.
76 * @param[in] Pst *pst, the post structure
77 * @param[in] RgMngmt *cfg, the configuration parameter's structure
81 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
85 DU_LOG("\nINFO --> MAC : Received Scheduler gen config at MAC");
86 memset(&schPst, 0, sizeof(Pst));
87 FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
89 return(SchMessageRouter(&schPst, (void *)cfg));
93 * @brief Layer Manager Configuration response from Scheduler
97 * Function : SchSendCfgCfm
99 * This function sends general configurations response from
100 * Scheduler to DU APP.
102 * @param[in] Pst *pst, the post structure
103 * @param[in] RgMngmt *cfm, the configuration confirm structure
107 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
109 DU_LOG("\nDEBUG --> MAC : Sending Scheduler config confirm to DU APP");
110 pst->dstEnt = ENTDUAPP;
113 pst->selector = ODU_SELECTOR_LC;
114 RgMiLrgSchCfgCfm(pst, cfm);
120 * @brief Layer Manager Configuration request handler.
124 * Function : MacProcCellCfgReq
126 * This function handles the gNB and cell configuration
127 * request received from DU APP.
128 * This API unapcks and forwards the config towards SCH
130 * @param[in] Pst *pst
131 * @param[in] MacCellCfg *macCellCfg
135 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
139 uint8_t ret = ROK, plmnIdx = 0,sliceIdx = 0;
140 MacCellCb *macCellCb;
142 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
144 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
145 if(macCellCb == NULLP)
147 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
150 memset(macCellCb, 0, sizeof(MacCellCb));
152 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
153 macCb.macCell[cellIdx] = macCellCb;
154 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
155 macCb.macCell[cellIdx]->numOfSlots = 10 * (1 << macCellCfg->cellCfg.numerology);
156 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
158 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, \
159 macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen);
160 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu == NULLP)
162 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
165 memcpy(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, macCellCfg->cellCfg.sib1Cfg.sib1Pdu, \
166 macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen);
168 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
170 macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = macCellCfg->cellCfg.plmnInfoList[plmnIdx].numSupportedSlice;
171 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice\
173 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP)
175 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
179 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai)
181 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; sliceIdx++)
183 if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
185 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
186 if(!macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
188 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
191 memcpy(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx],\
197 /* Send cell cfg to scheduler */
198 ret = MacSchCellCfgReq(pst, macCellCfg);
201 MacCellCfgCfm macCellCfgCfm;
202 macCellCfgCfm.rsp = RSP_NOK;
203 macCellCfgCfm.cellId = macCellCfg->cellId;
205 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
206 cfmPst.selector = ODU_SELECTOR_LC;
208 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
212 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
215 } /* end of MacProcCellCfgReq */
218 * @brief Layer Manager Configuration request handler.
222 * Function : MacSchCellCfgReq
224 * This function sends cell configuration to SCH
226 * @param[in] Pst *pst
227 * @param[in] MacCellCfg *macCellCfg
231 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
233 SchCellCfg schCellCfg;
235 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, sliceIdx=0, plmnIdx = 0;
237 memset(&cfgPst, 0, sizeof(Pst));
238 memset(&schCellCfg, 0, sizeof(SchCellCfg));
239 schCellCfg.cellId = macCellCfg->cellId;
240 schCellCfg.phyCellId = macCellCfg->cellCfg.phyCellId;
242 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
244 schCellCfg.plmnInfoList[plmnIdx].plmn = macCellCfg->cellCfg.plmnInfoList[plmnIdx].plmn;
245 if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai)
247 schCellCfg.plmnInfoList[plmnIdx].numSliceSupport = macCellCfg->cellCfg.plmnInfoList[plmnIdx].numSupportedSlice;
248 MAC_ALLOC(schCellCfg.plmnInfoList[plmnIdx].snssai, schCellCfg.plmnInfoList[plmnIdx].numSliceSupport * sizeof(Snssai*));
249 if(!schCellCfg.plmnInfoList[plmnIdx].snssai)
251 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
254 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList[plmnIdx].numSliceSupport; sliceIdx++)
256 if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
258 MAC_ALLOC(schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
259 if(!schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
261 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
264 memcpy(schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
270 schCellCfg.dupMode = macCellCfg->cellCfg.dupType;
271 schCellCfg.numerology = macCellCfg->cellCfg.numerology;
272 schCellCfg.dlBandwidth = macCellCfg->carrCfg.dlBw;
273 schCellCfg.ulBandwidth = macCellCfg->carrCfg.ulBw;
275 schCellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
277 /* fill initial DL BWP */
278 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
279 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
280 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
281 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
283 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
284 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
285 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
286 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
287 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
288 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
289 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
290 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
291 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
292 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
293 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
294 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
295 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
296 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
297 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
298 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
299 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
300 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
301 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
302 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
304 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
305 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
307 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
308 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
309 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
310 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
311 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
312 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
313 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
314 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
317 /* fill SIB1 scheduler parameters */
318 schCellCfg.dlCfgCommon.schPcchCfg.numPO = macCellCfg->cellCfg.sib1Cfg.pagingCfg.numPO;
319 schCellCfg.dlCfgCommon.schPcchCfg.poPresent = macCellCfg->cellCfg.sib1Cfg.pagingCfg.poPresent;
320 if(schCellCfg.dlCfgCommon.schPcchCfg.poPresent)
322 memcpy(schCellCfg.dlCfgCommon.schPcchCfg.pagingOcc, macCellCfg->cellCfg.sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
325 /* fill initial UL BWP */
326 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
327 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
328 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
329 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
330 /* fill RACH config params */
331 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
332 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
333 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
334 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.zeroCorrZoneCfg = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
335 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.raRspWindow = macCellCfg->prachCfg.raRspWindow;
337 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble;
338 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
339 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb;
340 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
341 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
342 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
343 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
344 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.msg1SubcSpacing = \
345 macCellCfg->prachCfg.prachSubcSpacing;
347 schCellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon.pucchResourceCommon = \
348 macCellCfg->initialUlBwp.pucchCommon.pucchResourceCommon;
349 schCellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon.pucchGroupHopping = \
350 macCellCfg->initialUlBwp.pucchCommon.pucchGroupHopping;
351 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
352 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
353 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
355 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
356 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
357 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
358 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
359 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
360 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
361 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
362 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
366 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
369 /* fill ssb scheduler parameters */
370 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
372 schCellCfg.ssbPosInBurst[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
374 schCellCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
375 schCellCfg.ssbFrequency = macCellCfg->cellCfg.ssbFreq;
376 schCellCfg.dmrsTypeAPos = macCellCfg->ssbCfg.dmrsTypeAPos;
377 schCellCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
378 schCellCfg.pdcchCfgSib1.coresetZeroIndex = macCellCfg->cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex;
379 schCellCfg.pdcchCfgSib1.searchSpaceZeroIndex = macCellCfg->cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex;
380 schCellCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
381 schCellCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
382 schCellCfg.sib1PduLen = macCellCfg->cellCfg.sib1Cfg.sib1PduLen;
384 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
386 return(SchMessageRouter(&cfgPst, (void *)&schCellCfg));
387 } /* end of MacSchCellCfgReq */
390 /*******************************************************************
392 * @brief Sends Cell config confirm to DU APP
396 * Function : MacSendCellCfgCfm
399 * Sends Cell config confirm to DU APP
401 * @params[in] Response status
404 * ****************************************************************/
405 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
409 MacCellCfgCfm macCellCfgCfm;
411 memset(&pst, 0, sizeof(Pst));
413 GET_CELL_IDX(cellId, cellIdx);
414 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
415 macCellCfgCfm.rsp = response;
418 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
419 pst.selector = ODU_SELECTOR_LC;
421 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
426 * @brief Layer Manager Configuration response handler.
430 * Function : MacProcSchCellCfgCfm
432 * This function processes cell configuration to SCH
434 * @param[in] Pst *pst
435 * @param[in] SchCellCfgCfm *schCellCfgCfm
439 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
441 uint16_t *cellId = NULLP;
443 #ifdef CALL_FLOW_DEBUG_LOG
444 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
447 if(schCellCfgCfm->rsp == RSP_OK)
449 cellId = &schCellCfgCfm->cellId;
450 #ifdef INTEL_TIMER_MODE
451 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
453 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
458 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
463 /*******************************************************************
465 * @brief MAC handler for config response from PHY
469 * Function : fapiMacConfigRsp
472 * Processes config response from PHY and sends cell config
478 * ****************************************************************/
479 void fapiMacConfigRsp(uint16_t cellId)
481 /* TODO : Processing of config response from PHY */
483 /* Send cell config cfm to DU APP */
484 MacSendCellCfgCfm(cellId, RSP_OK);
487 /*******************************************************************
489 * @brief Fill and Send Cell Delete response from MAC to DU APP
493 * Function : MacSendCellDeleteRsp
495 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
497 * @params[in] MAC Cell delete result
498 * SCH Cell delete response
499 * @return ROK - success
502 * ****************************************************************/
503 uint8_t MacSendCellDeleteRsp(CauseOfResult status, uint8_t cellId)
505 MacCellDeleteRsp *deleteRsp=NULLP;
508 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
511 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
515 /* Filling CELL delete response */
517 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
518 deleteRsp->cellId = cellId;
519 deleteRsp->status = status;
521 /* Fill Post structure and send CELL delete response*/
522 memset(&rspPst, 0, sizeof(Pst));
523 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
524 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
527 /*******************************************************************
529 * @brief Processes CELL delete response from scheduler
533 * Function : MacProcSchCellDeleteRsp
536 * Processes CELL delete from scheduler
538 * @params[in] Pst : Post structure
539 * schCellDelRsp : Scheduler CELL delete respons
540 * @return ROK - success
543 * * ****************************************************************/
544 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
546 uint8_t ret = ROK, sliceIdx = 0, plmnIdx = 0;
550 #ifdef CALL_FLOW_DEBUG_LOG
551 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
556 if(schCellDelRsp->rsp == RSP_OK)
558 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
559 schCellDelRsp->cellId);
560 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
561 if(macCb.macCell[cellIdx])
563 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
566 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
568 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai)
570 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; sliceIdx++)
572 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
574 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].\
575 numSupportedSlice * sizeof(Snssai*));
578 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, \
579 macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen);
580 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
584 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
585 cause = CELLID_INVALID;
591 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
592 cause = CELLID_INVALID;
598 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
599 cause = CELLID_INVALID;
602 if(MacSendCellDeleteRsp(cause, schCellDelRsp->cellId) != ROK)
604 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
611 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
617 /*******************************************************************
619 * @brief Sends Cell delete req to Scheduler
623 * Function : sendCellDelReqToSch
625 * Functionality: sends Cell delete req to Scheduler
627 * @params[in] SchCellDelete *schCellDel
628 * @return ROK - success
631 * ****************************************************************/
633 uint8_t sendCellDelReqToSch(SchCellDeleteReq *schCellDelReq)
636 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
637 return(SchMessageRouter(&schPst, (void *)schCellDelReq));
640 /*******************************************************************
642 * @brief Handles CELL Delete requst from DU APP
646 * Function : MacProcCellDeleteReq
648 * Functionality: Handles CELL Delete requst from DU APP
650 * @params[in] Pst *pst, MacCellDelete *cellDelete
651 * @return ROK - success
655 * ****************************************************************/
656 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDeleteReq *cellDelete)
658 uint8_t ret = ROK, cellIdx=0;
659 SchCellDeleteReq schCellDelete;
661 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
665 GET_CELL_IDX(cellDelete->cellId, cellIdx);
666 if(macCb.macCell[cellIdx])
668 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
670 memset(&schCellDelete, 0, sizeof(SchCellDeleteReq ));
671 schCellDelete.cellId = cellDelete->cellId;
672 ret = sendCellDelReqToSch(&schCellDelete);
675 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
681 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
688 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
695 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
696 if(MacSendCellDeleteRsp(CELLID_INVALID, cellDelete->cellId) != ROK)
698 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
703 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDeleteReq));
707 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
714 * @brief free the temporary slice cfg stored in macCb.
718 * Function : freeMacSliceCfgReq
720 * free the temporary slice cfg stored in macCb
726 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
728 uint8_t policyIdx = 0, memberListIdx=0;
730 if(cfgReq->numOfRrmPolicy)
732 if(cfgReq->listOfRrmPolicy)
734 for(policyIdx = 0; policyIdx<cfgReq->numOfRrmPolicy; policyIdx++)
736 if(cfgReq->listOfRrmPolicy[policyIdx])
738 if(cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
740 if(cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
742 for(memberListIdx = 0; memberListIdx<cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
744 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
746 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
747 cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
750 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
753 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy, cfgReq->numOfRrmPolicy * sizeof(MacSliceRrmPolicy*));
760 * @brief send slice cfg response to duapp.
764 * Function : MacSendSliceConfigRsp
766 * sends slice cfg response to duapp
768 * @param[in] MacSliceCfgRsp macSliceCfgRsp
772 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
776 memset(&rspPst, 0, sizeof(Pst));
777 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
778 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
783 * @brief Mac process the slice cfg rsp received from sch.
787 * Function : MacProcSchSliceCfgRsp
789 * This function process the slice cfg rsp received from sch
791 * @param[in] Pst *pst
792 * @param[in] SchSliceCfgRsp *sliceCfgrsp
797 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
799 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
803 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
804 if(macSliceCfgRsp == NULLP)
806 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
809 macSliceCfgRsp->snssai = schSliceCfgRsp->snssai;
810 if(schSliceCfgRsp->rsp == RSP_OK)
811 macSliceCfgRsp->rsp = MAC_DU_APP_RSP_OK;
814 macSliceCfgRsp->rsp = MAC_DU_APP_RSP_NOK;
816 macSliceCfgRsp->cause = schSliceCfgRsp->cause;
817 MacSendSliceConfigRsp(macSliceCfgRsp);
823 * @brief send slice cfg response to duapp.
827 * Function : MacSendSliceReconfigRsp
829 * sends slice cfg response to duapp
831 * @param[in] MacSliceRecfgRsp macSliceRecfgRsp
835 uint8_t MacSendSliceReconfigRsp(MacSliceRecfgRsp *macSliceRecfgRsp)
839 memset(&rspPst, 0, sizeof(Pst));
840 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
841 return (*macDuSliceRecfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
846 * @brief Mac process the slice cfg rsp received from sch.
850 * Function : MacProcSchSliceRecfgRsp
852 * This function process the slice cfg rsp received from sch
854 * @param[in] Pst *pst
855 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
859 uint8_t MacProcSchSliceRecfgRsp(Pst *pst, SchSliceRecfgRsp *schSliceRecfgRsp)
861 MacSliceRecfgRsp *macSliceRecfgRsp = NULLP;
865 MAC_ALLOC_SHRABL_BUF(macSliceRecfgRsp, sizeof(MacSliceRecfgRsp));
866 if(macSliceRecfgRsp == NULLP)
868 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceRecfgRsp");
872 macSliceRecfgRsp->snssai = schSliceRecfgRsp->snssai;
873 if(schSliceRecfgRsp->rsp == RSP_OK)
874 macSliceRecfgRsp->rsp = MAC_DU_APP_RSP_OK;
877 macSliceRecfgRsp->rsp = MAC_DU_APP_RSP_NOK;
879 macSliceRecfgRsp->cause = schSliceRecfgRsp->cause;
880 MacSendSliceReconfigRsp(macSliceRecfgRsp);
886 * @brief Mac process the downlink pcch indication received from DUAPP
890 * Function : MacProcDlPcchInd
892 * This function process the downlink pcch indication received from DUAPP
894 * @param[in] Pst *pst
895 * @param[in] DlPcchInd *pcchInd
899 uint8_t MacProcDlPcchInd(Pst *pst, DlPcchInd *pcchInd)
901 uint8_t ret = RFAILED;
902 uint16_t cellIdx = 0;
904 SchPageInd *schPageInd = NULLP;
908 DU_LOG("\nINFO --> MAC : Received DL PCCH IND from DU_APP for cellId[%d]", pcchInd->cellId);
910 GET_CELL_IDX(pcchInd->cellId, cellIdx);
912 if(macCb.macCell[cellIdx] == NULLP || macCb.macCell[cellIdx]->cellId != pcchInd->cellId)
914 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): CellId[%d] does not exist", pcchInd->cellId);
918 if((pcchInd->pcchPdu == NULLP) || (pcchInd->pduLen <= 0))
920 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Pcch pdu is null");
924 MAC_ALLOC(schPageInd, sizeof(SchPageInd));
925 if(schPageInd == NULLP)
927 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
931 schPageInd->cellId = pcchInd->cellId;
932 schPageInd->pf = pcchInd->pf;
933 schPageInd->i_s = pcchInd->i_s;
934 schPageInd->pduLen = pcchInd->pduLen;
936 MAC_ALLOC(schPageInd->pagePdu, pcchInd->pduLen);
937 if(schPageInd->pagePdu == NULLP)
939 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
940 MAC_FREE(schPageInd, sizeof(SchPageInd));
944 memcpy(schPageInd->pagePdu, pcchInd->pcchPdu, pcchInd->pduLen);
946 FILL_PST_MAC_TO_SCH(schPst, EVENT_PAGING_IND_TO_SCH);
947 ret = SchMessageRouter(&schPst, (void *)schPageInd);
952 if((pcchInd->pcchPdu) && (pcchInd->pduLen > 0))
954 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd->pcchPdu, pcchInd->pduLen);
956 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(DlPcchInd));
960 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Null pointer");
964 /**********************************************************************
966 **********************************************************************/