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 #include "PLMN-Identity.h"
23 #include "RICeventTriggerDefinition.h"
25 extern DuCfgParams duCfgParam;
27 extern S16 cmPkRgrCfgReq(Pst* pst, RgrCfgTransId transId, \
28 RgrCfgReqInfo *cfgReqInfo);
30 extern S16 duBuildAndSendMacCellCfg();
32 /*******************************************************************
34 * @brief Processes cells to be activated
38 * Function : procCellsToBeActivated
41 * - Processes cells to be activated list received in F1SetupRsp
44 * @return ROK - success
47 * ****************************************************************/
48 S16 procCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
53 for(idx=0; idx<cellsToActivate.list.count; idx++)
57 DuCellCb *cellCb = NULLP;
59 Cells_to_be_Activated_List_Item_t cell = cellsToActivate.list.array[idx]->\
60 value.choice.Cells_to_be_Activated_List_Item;
62 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
67 if(ROK != (cmHashListFind(&(duCb.cellLst), (U8*) &nci, sizeof(nci),
74 DU_LOG("\nDU_APP : HashList Find failed for nci [%d]", nci);
77 cellCb->cellStatus = ACTIVATION_IN_PROGRESS;
78 cellCb->cellInfo.nrPci = pci;
80 /* Now remove this cell from configured list and move to active list */
81 ret = cmHashListDelete(&(duCb.actvCellLst), (PTR)(cellCb));
84 DU_LOG("\nDU_APP : HashListInsert into ActvCellLst failed for [%d]", nci);
86 ret = cmHashListInsert(&(duCb.actvCellLst), (PTR)(cellCb),
87 (U8 *)&(nci), (U16) sizeof(nci));
91 DU_LOG("\nDU_APP : HashListInsert into ActvCellLst failed for [%d]", nci);
96 DU_LOG("\nDU_APP : HashListInsert into ActvCellLst successful for [%d]", nci);
100 /* Start sending scheduler config */
103 //TODO: uncomment later duSendSchGnbCfg();
109 /******************************************************************
111 * @brief Processes E2 Setup Response sent by RIC
115 * Function : procE2SetupRsp
117 * Functionality: Processes E2 Setup Response sent by RIC
119 * @params[in] E2AP_PDU_t ASN decoded E2AP message
120 * @return ROK - success
123 * ****************************************************************/
124 S16 procE2SetupRsp(E2AP_PDU_t *e2apMsg)
126 E2setupResponse_t *e2SetRspMsg;
127 E2apMsgDb e2SetupRspDb;
130 DU_LOG("\nE2AP : E2 Setup Response received");
131 duCb.e2Status = TRUE; //Set E2 status as true
132 e2SetRspMsg = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse;
134 for(idx=0; idx<e2SetRspMsg->protocolIEs.list.count; idx++)
136 switch(e2SetRspMsg->protocolIEs.list.array[idx]->id)
138 case ProtocolIE_IDE2_id_GlobalRIC_ID:
140 /* To store the Ric Id Params */
142 memset(&e2SetupRspDb.plmn, 0, sizeof(PLMN_IdentityE2_t));
144 recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.pLMN_Identity);
146 bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.ric_ID, &e2SetupRspDb.ricId);
148 aper_decode(0, &asn_DEF_PLMN_IdentityE2, (void **)&e2SetupRspDb.plmn, &e2SetRspMsg->protocolIEs.list.array[idx]->value.choice.GlobalRIC_ID.pLMN_Identity, recvBufLen, 0, 0);
149 //xer_fprint(stdout, &asn_DEF_PLMN_IdentityE2, &e2SetupRspDb.plmn);
154 DU_LOG("\nE2AP : Invalid IE received in E2SetupRsp:%ld",
155 e2SetRspMsg->protocolIEs.list.array[idx]->id);
162 /******************************************************************
164 * @brief Processes RIC Subscription Req sent by RIC
168 * Function : procRicSubsReq
170 * Functionality: Processes E2 Setup Response sent by CU
172 * @params[in] E2AP_PDU_t ASN decoded E2AP message
173 * @return ROK - success
176 * ****************************************************************/
178 S16 procRicSubsReq(E2AP_PDU_t *e2apMsg)
183 RICsubscriptionRequest_t *ricSubsReq;
184 RICaction_ToBeSetup_ItemIEs_t *actionItem;
187 DU_LOG("\nE2AP : Ric Subscription request received");
188 ricSubsReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
190 for(idx=0; idx<ricSubsReq->protocolIEs.list.count; idx++)
192 switch(ricSubsReq->protocolIEs.list.array[idx]->id)
194 case ProtocolIE_IDE2_id_RICrequestID:
196 ricReqDb.ricReqId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricRequestorID;
197 ricReqDb.ricInstanceId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICrequestID.ricInstanceID;
200 case ProtocolIE_IDE2_id_RANfunctionID:
202 ricReqDb.ranFuncId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RANfunctionID;
205 case ProtocolIE_IDE2_id_RICsubscriptionDetails:
208 memset(&ricReqDb.ricEventTrigger, 0, sizeof(RICeventTriggerDefinition_t));
210 recvBufLen = sizeof(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition);
212 aper_decode(0, &asn_DEF_RICeventTriggerDefinition, (void **)&ricReqDb.ricEventTrigger, &(ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition), recvBufLen, 0, 0);
213 //xer_fprint(stdout, &asn_DEF_RICeventTriggerDefinition, &ricReqDb.ricEventTrigger);
215 actionItem = *ricSubsReq->protocolIEs.list.array[idx]->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list.array;
217 for(ied = 0; ied < ricSubsReq->protocolIEs.list.array[idx]->value.choice.\
218 RICsubscriptionDetails.ricAction_ToBeSetup_List.list.count; ied++)
220 switch(actionItem->id)
222 case ProtocolIE_IDE2_id_RICaction_ToBeSetup_Item:
224 ricReqDb.ricActionId = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionID;
225 ricReqDb.ricActionType = actionItem->value.choice.RICaction_ToBeSetup_Item.ricActionType;
229 DU_LOG("\nE2AP : Invalid IE received in RicSetupLst:%ld",actionItem->id);
238 DU_LOG("\nE2AP : Invalid IE received in Ric SubsReq:%ld",
239 ricSubsReq->protocolIEs.list.array[idx]->id);
243 ret = BuildAndSendRicSubscriptionRsp();
248 /******************************************************************
250 * @brief Processes F1 Setup Response sent by CU
254 * Function : procF1SetupRsp
256 * Functionality: Processes F1 Setup Response sent by CU
258 * @params[in] F1AP_PDU_t ASN decoded F1AP message
259 * @return ROK - success
262 * ****************************************************************/
263 S16 procF1SetupRsp(F1AP_PDU_t *f1apMsg)
267 F1SetupResponse_t *f1SetRspMsg;
268 F1SetupRsp f1SetRspDb;
269 GNB_CU_Name_t *cuName;
270 RRC_Version_t *rrc_Ver;
273 DU_LOG("\nDU_APP : F1 Setup Response received");
274 printf("\nDU_APP : F1 Setup Response received");
275 duCb.f1Status = TRUE; //Set F1 status as true
276 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
278 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
280 // F1SetupResponseIEs_t f1RspIe = f1SetRspMsg->protocolIEs.list.array[idx];
281 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
283 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
285 procCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
286 value.choice.Cells_to_be_Activated_List);
289 //TODO: where to store and how to use below variables?can they be skipped
290 case ProtocolIE_ID_id_TransactionID:
292 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
293 value.choice.TransactionID;
296 case ProtocolIE_ID_id_gNB_CU_Name:
298 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
299 value.choice.GNB_CU_Name;
300 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
303 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
305 rrc_Ver = &f1SetRspMsg->protocolIEs.list.array[idx]->\
306 value.choice.RRC_Version;
307 strcpy(f1SetRspDb.rrcVersion.rrcVer,
308 (const char*)rrc_Ver->latest_RRC_Version.buf);
312 DU_LOG("\nDU_APP : Invalid IE received in F1SetupRsp:%ld",
313 f1SetRspMsg->protocolIEs.list.array[idx]->id);
317 /* TODO :Check the deallocation */
319 SPutSBuf(DU_APP_MEM_REGION, DU_POOL,(Data *)&(f1SetupRsp->protocolIEs.list.array),\
320 (Size)elementCnt * sizeof(F1SetupResponseIEs_t *));
321 SPutSBuf(DU_APP_MEM_REGION, DU_POOL,(Data *)&(f1apMsg->choice.successfulOutcome),\
322 (Size)sizeof(SuccessfulOutcome_t));
323 SPutSBuf(DU_APP_MEM_REGION, DU_POOL,(Data *)&f1apMsg,(Size)sizeof(F1AP_PDU_t));
326 /* Build and send Mac Cell Cfg Paramaters */
327 //ret = duBuildAndSendMacCellCfg();
328 ret = BuildAndSendDUConfigUpdate();
333 /******************************************************************
335 * @brief Send gNB cfg to scheduler via MAC
339 * Function : duSendSchGnbCfg
341 * Functionality: Send gNB cfg to scheduler via MAC
343 * @return ROK - success
346 * ****************************************************************/
347 S16 duSendSchGnbCfg()
350 RgrCfgReqInfo *cfgReq = NULLP;
351 MacSchedGnbCfg *cfg = NULLP;
354 DU_ALLOC(cfgReq, sizeof(RgrCfgReqInfo));
357 DU_LOG("\nDU_APP : Mem allocation failed in duSendSchGnbCfg");
361 cfgReq->action = SCH_CONFIG;
362 cfgReq->u.cfgInfo.cfgType = MAC_GNB_CFG;
363 cfg = &(cfgReq->u.cfgInfo.u.schedGnbCfg);
364 cfg->numTxAntPorts = duCfgParam.schedCfg.numTxAntPorts;
365 cfg->ulSchdType = duCfgParam.schedCfg.ulSchdType;
366 cfg->dlSchdType = duCfgParam.schedCfg.dlSchdType;
367 cfg->numCells = duCfgParam.schedCfg.numCells;
368 cfg->maxUlUePerTti = duCfgParam.schedCfg.maxUlUePerTti;
369 cfg->maxDlUePerTti = duCfgParam.schedCfg.maxDlUePerTti;
371 if(ROK != duSendSchGnbCfgToMac(cfgReq, transId))
379 /******************************************************************
381 * @brief Send gNB cfg to scheduler via MAC
385 * Function : duSendSchGnbCfgToMac
387 * Functionality: Send gNB cfg to scheduler via MAC
389 * @return ROK - success
392 * ****************************************************************/
393 S16 duSendSchGnbCfgToMac(RgrCfgReqInfo *cfgReq, U32 trans_id)
395 RgrCfgTransId transId;
398 DU_SET_ZERO(&pst, sizeof(Pst));
399 DU_SET_ZERO(&transId, sizeof(RgrCfgTransId));
401 transId.trans[0] = MAC_GNB_CFG;
402 transId.trans[1] = cfgReq->action;
403 transId.trans[7] = trans_id & 0x000000ff; trans_id >>= 8;
404 transId.trans[6] = trans_id & 0x000000ff; trans_id >>= 8;
405 transId.trans[5] = trans_id & 0x000000ff; trans_id >>= 8;
406 transId.trans[4] = trans_id & 0x000000ff; trans_id >>= 8;
408 pst.selector = DU_SELECTOR_LC;
409 pst.srcEnt = ENTDUAPP;
411 pst.dstInst = (Inst)0;
412 pst.dstProcId = DU_PROC;
413 pst.srcProcId = DU_PROC;
414 pst.region = duCb.init.region;
415 pst.event = (Event) EVTMACSCHCFGREQ;
417 cmPkRgrCfgReq(&pst, transId, cfgReq);
422 /**********************************************************************
424 **********************************************************************/