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 message handling functionality for DU APP */
20 #include "du_cell_mgr.h"
22 extern DuCfgParams duCfgParam;
24 extern S16 cmPkRgrCfgReq(Pst* pst, RgrCfgTransId transId, \
25 RgrCfgReqInfo *cfgReqInfo);
27 extern S16 duBuildAndSendMacCellCfg();
29 /*******************************************************************
31 * @brief Processes cells to be activated
35 * Function : procCellsToBeActivated
38 * - Processes cells to be activated list received in F1SetupRsp
41 * @return ROK - success
44 * ****************************************************************/
45 S16 procCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
50 for(idx=0; idx<cellsToActivate.list.count; idx++)
54 DuCellCb *cellCb = NULLP;
56 Cells_to_be_Activated_List_Item_t cell = cellsToActivate.list.array[idx]->\
57 value.choice.Cells_to_be_Activated_List_Item;
59 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
60 if(nci <= 0 || nci > DU_MAX_CELLS)
62 DU_LOG("\nDU APP : Invalid NCI %d", nci);
71 cellCb = duCb.cfgCellLst[nci-1];
75 DU_LOG("\nDU APP : No Cell found for NCI %d", nci);
78 cellCb->cellStatus = ACTIVATION_IN_PROGRESS;
79 cellCb->cellInfo.nrPci = pci;
81 /* Now remove this cell from configured list and move to active list */
82 duCb.cfgCellLst[nci-1] = NULLP;
83 duCb.actvCellLst[nci-1] = cellCb;
86 /* Start sending scheduler config */
89 //TODO: uncomment later duSendSchGnbCfg();
95 /******************************************************************
97 * @brief Processes F1 Setup Response sent by CU
101 * Function : procF1SetupRsp
103 * Functionality: Processes F1 Setup Response sent by CU
105 * @params[in] F1AP_PDU_t ASN decoded F1AP message
106 * @return ROK - success
109 * ****************************************************************/
110 S16 procF1SetupRsp(F1AP_PDU_t *f1apMsg)
114 F1SetupResponse_t *f1SetRspMsg;
115 F1SetupRsp f1SetRspDb;
116 GNB_CU_Name_t *cuName;
117 RRC_Version_t *rrc_Ver;
120 DU_LOG("\nDU_APP : F1 Setup Response received");
121 printf("\nDU_APP : F1 Setup Response received");
122 duCb.f1Status = TRUE; //Set F1 status as true
123 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
125 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
127 // F1SetupResponseIEs_t f1RspIe = f1SetRspMsg->protocolIEs.list.array[idx];
128 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
130 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
132 procCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
133 value.choice.Cells_to_be_Activated_List);
136 //TODO: where to store and how to use below variables?can they be skipped
137 case ProtocolIE_ID_id_TransactionID:
139 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
140 value.choice.TransactionID;
143 case ProtocolIE_ID_id_gNB_CU_Name:
145 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
146 value.choice.GNB_CU_Name;
147 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
150 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
152 rrc_Ver = &f1SetRspMsg->protocolIEs.list.array[idx]->\
153 value.choice.RRC_Version;
154 strcpy(f1SetRspDb.rrcVersion.rrcVer,
155 (const char*)rrc_Ver->latest_RRC_Version.buf);
159 DU_LOG("\nDU_APP : Invalid IE received in F1SetupRsp:%ld",
160 f1SetRspMsg->protocolIEs.list.array[idx]->id);
164 /* TODO :Check the deallocation */
166 SPutSBuf(DU_APP_MEM_REGION, DU_POOL,(Data *)&(f1SetupRsp->protocolIEs.list.array),\
167 (Size)elementCnt * sizeof(F1SetupResponseIEs_t *));
168 SPutSBuf(DU_APP_MEM_REGION, DU_POOL,(Data *)&(f1apMsg->choice.successfulOutcome),\
169 (Size)sizeof(SuccessfulOutcome_t));
170 SPutSBuf(DU_APP_MEM_REGION, DU_POOL,(Data *)&f1apMsg,(Size)sizeof(F1AP_PDU_t));
173 /* Build and send Mac Cell Cfg Paramaters */
174 //ret = duBuildAndSendMacCellCfg();
175 ret = BuildAndSendDUConfigUpdate();
180 /******************************************************************
182 * @brief Send gNB cfg to scheduler via MAC
186 * Function : duSendSchGnbCfg
188 * Functionality: Send gNB cfg to scheduler via MAC
190 * @return ROK - success
193 * ****************************************************************/
194 S16 duSendSchGnbCfg()
197 RgrCfgReqInfo *cfgReq = NULLP;
198 MacSchedGnbCfg *cfg = NULLP;
201 DU_ALLOC(cfgReq, sizeof(RgrCfgReqInfo));
204 DU_LOG("\nDU_APP : Mem allocation failed in duSendSchGnbCfg");
208 cfgReq->action = SCH_CONFIG;
209 cfgReq->u.cfgInfo.cfgType = MAC_GNB_CFG;
210 cfg = &(cfgReq->u.cfgInfo.u.schedGnbCfg);
211 cfg->numTxAntPorts = duCfgParam.schedCfg.numTxAntPorts;
212 cfg->ulSchdType = duCfgParam.schedCfg.ulSchdType;
213 cfg->dlSchdType = duCfgParam.schedCfg.dlSchdType;
214 cfg->numCells = duCfgParam.schedCfg.numCells;
215 cfg->maxUlUePerTti = duCfgParam.schedCfg.maxUlUePerTti;
216 cfg->maxDlUePerTti = duCfgParam.schedCfg.maxDlUePerTti;
218 if(ROK != duSendSchGnbCfgToMac(cfgReq, transId))
226 /******************************************************************
228 * @brief Send gNB cfg to scheduler via MAC
232 * Function : duSendSchGnbCfgToMac
234 * Functionality: Send gNB cfg to scheduler via MAC
236 * @return ROK - success
239 * ****************************************************************/
240 S16 duSendSchGnbCfgToMac(RgrCfgReqInfo *cfgReq, U32 trans_id)
242 RgrCfgTransId transId;
245 DU_SET_ZERO(&pst, sizeof(Pst));
246 DU_SET_ZERO(&transId, sizeof(RgrCfgTransId));
248 transId.trans[0] = MAC_GNB_CFG;
249 transId.trans[1] = cfgReq->action;
250 transId.trans[7] = trans_id & 0x000000ff; trans_id >>= 8;
251 transId.trans[6] = trans_id & 0x000000ff; trans_id >>= 8;
252 transId.trans[5] = trans_id & 0x000000ff; trans_id >>= 8;
253 transId.trans[4] = trans_id & 0x000000ff; trans_id >>= 8;
255 pst.selector = DU_SELECTOR_LC;
256 pst.srcEnt = ENTDUAPP;
258 pst.dstInst = (Inst)0;
259 pst.dstProcId = DU_PROC;
260 pst.srcProcId = DU_PROC;
261 pst.region = duCb.init.region;
262 pst.event = (Event) EVTMACSCHCFGREQ;
264 cmPkRgrCfgReq(&pst, transId, cfgReq);
269 /**********************************************************************
271 **********************************************************************/