From: sphoorthi Date: Mon, 12 Apr 2021 05:31:01 +0000 (+0530) Subject: Implementation of UE context release request X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F5875%2F4;p=o-du%2Fl2.git Implementation of UE context release request Change-Id: Id9c129f29bf3bd8e3b6e299e737ad67a2c9eb2de Signed-off-by: sphoorthi --- diff --git a/src/cu_stub/cu_f1ap_msg_hdl.c b/src/cu_stub/cu_f1ap_msg_hdl.c index 8ede3eff3..acc2d138c 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.c +++ b/src/cu_stub/cu_f1ap_msg_hdl.c @@ -7427,93 +7427,98 @@ void F1APMsgHdlr(Buffer *mBuf) switch(f1apMsg->present) { case F1AP_PDU_PR_initiatingMessage: - { - switch(f1apMsg->choice.initiatingMessage->value.present) - { - case InitiatingMessage__value_PR_Reset: - { - DU_LOG("\nINFO --> F1AP : F1 reset request received "); - BuildAndSendF1ResetAck(); - break; - } - - case InitiatingMessage__value_PR_F1SetupRequest: - { - DU_LOG("\nINFO --> F1AP : F1 setup request received"); - BuildAndSendF1SetupRsp(); - break; - } - - case InitiatingMessage__value_PR_GNBDUConfigurationUpdate: - { - DU_LOG("\nINFO --> F1AP : GNB-DU config update received"); - BuildAndSendDUUpdateAck(); - DU_LOG("\nINFO --> F1AP : Sending F1 reset request"); - BuildAndSendF1ResetReq(); - break; - } - case InitiatingMessage__value_PR_InitialULRRCMessageTransfer: - { - DU_LOG("\nINFO --> F1AP : Received InitialULRRCMessageTransfer"); - procInitULRRCMsg(f1apMsg); - break; - } - case InitiatingMessage__value_PR_ULRRCMessageTransfer: - { - DU_LOG("\nINFO --> F1AP : Received ULRRCMessageTransfer"); - procUlRrcMsg(f1apMsg); - break; - } - - case InitiatingMessage__value_PR_RRCDeliveryReport: - { - DU_LOG("\nINFO --> F1AP : Received RRC delivery report"); - break; - } - default: - { - DU_LOG("\nERROR --> F1AP : Invalid type of intiating message [%d]",\ - f1apMsg->choice.initiatingMessage->value.present); - return; - } - }/* End of switch(initiatingMessage) */ - break; - } + { + switch(f1apMsg->choice.initiatingMessage->value.present) + { + case InitiatingMessage__value_PR_Reset: + { + DU_LOG("\nINFO --> F1AP : F1 reset request received "); + BuildAndSendF1ResetAck(); + break; + } + + case InitiatingMessage__value_PR_F1SetupRequest: + { + DU_LOG("\nINFO --> F1AP : F1 setup request received"); + BuildAndSendF1SetupRsp(); + break; + } + + case InitiatingMessage__value_PR_GNBDUConfigurationUpdate: + { + DU_LOG("\nINFO --> F1AP : GNB-DU config update received"); + BuildAndSendDUUpdateAck(); + DU_LOG("\nINFO --> F1AP : Sending F1 reset request"); + BuildAndSendF1ResetReq(); + break; + } + case InitiatingMessage__value_PR_InitialULRRCMessageTransfer: + { + DU_LOG("\nINFO --> F1AP : Received InitialULRRCMessageTransfer"); + procInitULRRCMsg(f1apMsg); + break; + } + case InitiatingMessage__value_PR_ULRRCMessageTransfer: + { + DU_LOG("\nINFO --> F1AP : Received ULRRCMessageTransfer"); + procUlRrcMsg(f1apMsg); + break; + } + + case InitiatingMessage__value_PR_RRCDeliveryReport: + { + DU_LOG("\nINFO --> F1AP : Received RRC delivery report"); + break; + } + case InitiatingMessage__value_PR_UEContextReleaseRequest: + { + DU_LOG("\nINFO --> F1AP : Received UE Context Release Request"); + break; + } + default: + { + DU_LOG("\nERROR --> F1AP : Invalid type of intiating message [%d]",\ + f1apMsg->choice.initiatingMessage->value.present); + return; + } + }/* End of switch(initiatingMessage) */ + break; + } case F1AP_PDU_PR_successfulOutcome: - { - switch(f1apMsg->choice.successfulOutcome->value.present) - { - case SuccessfulOutcome__value_PR_ResetAcknowledge: - { - DU_LOG("\nINFO --> F1Reset Acknowledgement is received successfully "); - break; - } - case SuccessfulOutcome__value_PR_UEContextSetupResponse: - { - DU_LOG("\nINFO --> F1AP : UE ContextSetupResponse received"); - f1apMsgDb.dlRrcMsgCount++; /* keeping DL RRC Msg Count */ - break; - } - case SuccessfulOutcome__value_PR_UEContextModificationResponse: - { - DU_LOG("\nINFO --> F1AP : UE Context Modification Response received"); - break; - } - default: - { - DU_LOG("\nERROR --> F1AP : Invalid type of successful outcome message [%d]",\ - f1apMsg->choice.successfulOutcome->value.present); - return; - } - }/* End of switch(successfulOutcome) */ - break; - } + { + switch(f1apMsg->choice.successfulOutcome->value.present) + { + case SuccessfulOutcome__value_PR_ResetAcknowledge: + { + DU_LOG("\nINFO --> F1Reset Acknowledgement is received successfully "); + break; + } + case SuccessfulOutcome__value_PR_UEContextSetupResponse: + { + DU_LOG("\nINFO --> F1AP : UE ContextSetupResponse received"); + f1apMsgDb.dlRrcMsgCount++; /* keeping DL RRC Msg Count */ + break; + } + case SuccessfulOutcome__value_PR_UEContextModificationResponse: + { + DU_LOG("\nINFO --> F1AP : UE Context Modification Response received"); + break; + } + default: + { + DU_LOG("\nERROR --> F1AP : Invalid type of successful outcome message [%d]",\ + f1apMsg->choice.successfulOutcome->value.present); + return; + } + }/* End of switch(successfulOutcome) */ + break; + } default: - { - DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present); - return; - } + { + DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present); + return; + } }/* End of switch(f1apMsg->present) */ } /* End of F1APMsgHdlr */ diff --git a/src/du_app/du_f1ap_msg_hdl.c b/src/du_app/du_f1ap_msg_hdl.c index a6205a53b..01068a8d7 100644 --- a/src/du_app/du_f1ap_msg_hdl.c +++ b/src/du_app/du_f1ap_msg_hdl.c @@ -110,7 +110,6 @@ extern StartupConfig g_cfg; #endif DuCfgParams duCfgParam; - /************************************************************************ * * @brief Converts enum values into actual value of Poll retransmit timer @@ -1203,7 +1202,7 @@ uint8_t BuildRrcVer(RRC_Version_t *rrcVer) * * @details * - * Function : SendF1APMsg + * Function : sendF1APMsg * * Functionality: Sends F1 msg over SCTP * @@ -1213,11 +1212,11 @@ uint8_t BuildRrcVer(RRC_Version_t *rrcVer) * RFAILED - failure * * ****************************************************************/ -uint8_t SendF1APMsg(Region region, Pool pool) +uint8_t sendF1APMsg() { Buffer *mBuf = NULLP; - if(ODU_GET_MSG_BUF(region, pool, &mBuf) == ROK) + if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK) { if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK) { @@ -1244,7 +1243,7 @@ uint8_t SendF1APMsg(Region region, Pool pool) return RFAILED; } return ROK; -} /* SendF1APMsg */ +} /* sendF1APMsg */ /******************************************************************* * @@ -1696,7 +1695,7 @@ uint8_t BuildAndSendF1SetupReq() } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed"); break; @@ -2499,7 +2498,7 @@ uint8_t BuildAndSendDUConfigUpdate() } } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed"); break; @@ -2703,7 +2702,7 @@ uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \ } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed"); break; @@ -5900,7 +5899,7 @@ uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti } } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed"); ret = RFAILED; @@ -10591,7 +10590,7 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t ueIdx, uint8_t cellId) } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed"); ret = RFAILED; @@ -10793,7 +10792,7 @@ uint8_t BuildAndSendF1ResetReq() } } - if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed"); break; @@ -10946,7 +10945,7 @@ uint8_t BuildAndSendF1ResetAck() } } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed"); break; @@ -11213,7 +11212,7 @@ uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \ } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed"); break; @@ -11941,7 +11940,7 @@ uint8_t BuildAndSendUeContextModResp(uint8_t ueIdx, uint8_t cellId) } /* Sending msg */ - if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK) + if(sendF1APMsg() != ROK) { DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed"); ret = RFAILED; @@ -12287,6 +12286,194 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg) return ret; } /*****************************************************************i +* +* @brief Free memory allocated for UE Context Release Request +* +* @details +* +* Function : FreeUeContextReleaseReq +* +* Functionality: +* - Free memory allocated for UE Context Release Request +* +* @params[in] F1AP_PDU_t *f1apMsg +* @return void +* +* *************************************************************/ +void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg) +{ + uint8_t ieIdx; + UEContextReleaseRequest_t *ueReleaseReq = NULLP; + + if(f1apMsg) + { + if(f1apMsg->choice.initiatingMessage) + { + ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest; + if(ueReleaseReq->protocolIEs.list.array) + { + for(ieIdx=0 ; ieIdxprotocolIEs.list.count; ieIdx++) + { + DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t)); + } + DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size); + } + DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t)); + } + DU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + } + +} +/*****************************************************************i +* +* @brief Build and Send UE Context Release Request +* +* @details +* +* Function : BuildAndSendUeContextReleaseReq +* +* Functionality: +* - Build and Send UE Context Release Request +* +* @params[in] +* @return ROK - success +* RFAILED - failure +* +* *************************************************************/ +uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx) +{ + bool memAllocFail = false; + uint8_t ieIdx =0; + uint8_t ret = RFAILED; + uint16_t cellIdx =0; + uint16_t crnti = 0; + uint8_t elementCnt = 0; + uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */ + uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */ + asn_enc_rval_t encRetVal; + F1AP_PDU_t *f1apMsg = NULLP; + UEContextReleaseRequest_t *ueReleaseReq = NULLP; + + DU_LOG("\nINFO --> Building the UE Context Release Request"); + do + { + DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t)); + if(f1apMsg == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg"); + break; + } + + f1apMsg->present = F1AP_PDU_PR_initiatingMessage; + DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t)); + if(f1apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\ + initiatingMessage"); + break; + } + f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest; + f1apMsg->choice.initiatingMessage->criticality = Criticality_reject; + f1apMsg->choice.initiatingMessage->value.present = \ + InitiatingMessage__value_PR_UEContextReleaseRequest; + + ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest; + + elementCnt = 2; + + ueReleaseReq->protocolIEs.list.count = elementCnt; + ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *); + + /* Initialize the F1Setup members */ + DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size); + if(ueReleaseReq->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array"); + break; + } + for(ieIdx=0; ieIdxprotocolIEs.list.array[ieIdx],\ + sizeof(UEContextReleaseRequest_t)); + if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements"); + memAllocFail = true; + break; + } + } + if(memAllocFail == true) + break; + + /* Fetching Ue Cb Info*/ + GET_CELL_IDX(cellId, cellIdx); + if(duCb.actvCellLst[cellIdx] == NULLP) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId); + break; + } + else + { + GET_CRNTI(crnti, ueIdx); + if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti) + { + DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti); + break; + } + gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId; + gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId; + } + + ieIdx=0; + ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject; + ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \ + UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; + ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId; + + ieIdx++; + ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject; + ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\ + UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; + ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId; + + xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); + + /* Encode the F1SetupRequest type as APER */ + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf); + /* Encode results */ + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n"); + for(ieIdx=0; ieIdx< encBufSize; ieIdx++) + { + printf("%x",encBuf[ieIdx]); + } + } + + /* Sending msg */ + if(sendF1APMsg() != ROK) + { + DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed"); + break; + } + ret = ROK; + break; + }while(true); + + FreeUeContextReleaseReq(f1apMsg); + return ret; +} +/************************************************************** * * @brief Handles received F1AP message and sends back response * diff --git a/src/du_app/du_f1ap_msg_hdl.h b/src/du_app/du_f1ap_msg_hdl.h index 65d42e186..ce5e72514 100644 --- a/src/du_app/du_f1ap_msg_hdl.h +++ b/src/du_app/du_f1ap_msg_hdl.h @@ -50,6 +50,7 @@ int16_t getStatProhTmr(uint8_t statProhTmrCfg); uint8_t duProcUeContextModReq(DuUeCb *ueCb); uint8_t BuildAndSendUeContextModResp(uint8_t ueIdx, uint8_t cellId); uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg); +uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx); /********************************************************************** End of file **********************************************************************/