X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcu_stub%2Fcu_xnap_msg_hdl.c;h=4f5cd3b8060f3d10c58c8ae8d4d2dd69864de150;hb=49856df248fd976b4a9882ca4e650fc0bc3e4ee3;hp=436809a51eb3e966436abcf36c254fc93ae3ebf4;hpb=f1f384a125521129ec29c1589b8499010cc4685c;p=o-du%2Fl2.git diff --git a/src/cu_stub/cu_xnap_msg_hdl.c b/src/cu_stub/cu_xnap_msg_hdl.c index 436809a51..4f5cd3b80 100644 --- a/src/cu_stub/cu_xnap_msg_hdl.c +++ b/src/cu_stub/cu_xnap_msg_hdl.c @@ -53,8 +53,8 @@ void BuildAndSendXnSetupReq() { if(ODU_GET_MSG_BUF(1, 1, &mBuf) == ROK) { - CMCHKPK(oduUnpackUInt8,(Data *)CU_ID, mBuf); - CMCHKPK(oduUnpackUInt8,XN_SETUP_REQ, mBuf); + CMCHKPK(oduPackUInt8,(Data *)CU_ID, mBuf); + CMCHKPK(oduPackUInt8,XN_SETUP_REQ, mBuf); ODU_PRINT_MSG(mBuf, 0,0); if(sendOnSctpAssoc(assocCb, mBuf) != ROK) { @@ -87,7 +87,7 @@ void XNAPProcXnSetupReq(uint32_t *destId, Buffer *mBuf) uint8_t cuId; DU_LOG("\nINFO --> CU STUB : Received XN Setup Request"); - CMCHKUNPK(oduPackUInt8, &(cuId), mBuf) + CMCHKUNPK(oduUnpackUInt8, &(cuId), mBuf) *destId = cuId; BuildAndSendXnSetupRsp(*destId); @@ -114,8 +114,8 @@ void BuildAndSendXnSetupRsp(uint32_t destId) if(ODU_GET_MSG_BUF(1, 1, &mBuf) == ROK) { - CMCHKPK(oduUnpackUInt8, CU_ID, mBuf); - CMCHKPK(oduUnpackUInt8, XN_SETUP_RSP, mBuf); + CMCHKPK(oduPackUInt8, CU_ID, mBuf); + CMCHKPK(oduPackUInt8, XN_SETUP_RSP, mBuf); if(sctpSend(XN_INTERFACE, destId, mBuf)) { DU_LOG("\nERROR --> CU_STUB: Failed to send XN setup response to peer CU"); @@ -144,7 +144,7 @@ void XNAPProcXnSetupRsp(uint32_t *destId, Buffer *mBuf) uint8_t cuId; DU_LOG("\nINFO --> CU STUB : Received XN Setup Response"); - CMCHKUNPK(oduPackUInt8, &(cuId), mBuf) + CMCHKUNPK(oduUnpackUInt8, &(cuId), mBuf) *destId = cuId; } @@ -174,9 +174,9 @@ void BuildAndSendHOReq(CuUeCb *ueCb, char *xnMsg, MsgLen xnMsgLen) { if(ODU_ADD_POST_MSG_MULT((Data *)xnMsg, xnMsgLen, mBuf) == ROK) { - CMCHKPK(oduUnpackUInt8, ueCb->hoInfo.cuUeF1apIdSrc, mBuf); - CMCHKPK(oduUnpackUInt32, ueCb->hoInfo.tgtCellId, mBuf); - CMCHKPK(oduUnpackUInt8, HO_REQ, mBuf); + CMCHKPK(oduPackUInt8, ueCb->hoInfo.cuUeF1apIdSrc, mBuf); + CMCHKPK(oduPackUInt32, ueCb->hoInfo.tgtCellId, mBuf); + CMCHKPK(oduPackUInt8, HO_REQ, mBuf); if(sctpSend(XN_INTERFACE, ueCb->hoInfo.tgtNodeId, mBuf) != ROK) { DU_LOG("\nERROR --> CU_STUB: Failed to send handover request to peer CU"); @@ -218,7 +218,7 @@ void XNAPProcHandoverReq(uint32_t destId, Buffer *mBuf) DU_LOG("\nINFO --> CU STUB : Received Handover Request"); /* Find DU Db and Cell Cb from cellId */ - CMCHKUNPK(oduPackUInt32, &(cellId), mBuf); + CMCHKUNPK(oduUnpackUInt32, &(cellId), mBuf); for(duIdx = 0; duIdx < cuCb.numDu; duIdx++) { duDb = &cuCb.duInfo[duIdx]; @@ -233,7 +233,7 @@ void XNAPProcHandoverReq(uint32_t destId, Buffer *mBuf) } /* Fetch CU UE F1AP ID of UE in handover assigned by source CU */ - CMCHKUNPK(oduPackUInt8, &(cuUeF1apIdSrc), mBuf); + CMCHKUNPK(oduUnpackUInt8, &(cuUeF1apIdSrc), mBuf); /* Filling temporary UE context which will be used to create actual UE context at * CU later */ @@ -296,9 +296,9 @@ void BuildAndSendHOReqAck(CuUeCb *ueCb, char *xnMsg, MsgLen xnMsgLen) { if(ODU_ADD_POST_MSG_MULT((Data *)xnMsg, xnMsgLen, mBuf) == ROK) { - CMCHKPK(oduUnpackUInt8, ueCb->gnbCuUeF1apId, mBuf); - CMCHKPK(oduUnpackUInt8, ueCb->hoInfo.cuUeF1apIdSrc, mBuf); - CMCHKPK(oduUnpackUInt8, HO_REQ_ACK, mBuf); + CMCHKPK(oduPackUInt8, ueCb->gnbCuUeF1apId, mBuf); + CMCHKPK(oduPackUInt8, ueCb->hoInfo.cuUeF1apIdSrc, mBuf); + CMCHKPK(oduPackUInt8, HO_REQ_ACK, mBuf); if(sctpSend(XN_INTERFACE, ueCb->hoInfo.srcNodeId, mBuf) != ROK) { DU_LOG("\nERROR --> CU_STUB: Failed to send handover request ack to peer CU"); @@ -316,23 +316,172 @@ void BuildAndSendHOReqAck(CuUeCb *ueCb, char *xnMsg, MsgLen xnMsgLen) * Function : XNAPProcHandoverReqAck * * Functionality: - * 1. Unpack CU UE F1AP ID (by SCU) and search for UE CB and + * 1. Unpack CU UE F1AP ID (by SCU) and fetch UE CB and * the corresponding DU DB (SDU) * 2. Unpack CU UE F1AP ID (by TCU) and fill in UEcb->hoInfo - * 3. Decode the F1AP UE context setup response msg received in - * XNAP message buffer and extract UE configurations - * 4. Create RRC reconfig msg with these configurations - * 5. Send RRC Reconfig msg and Transmission Action = DO NOT TRANSMIT - * in UE context modification request to S DU + * 3. Decode DU to CU RRC Container received in XNAP message + * buffer and extract UE configurations. + * 4. Send UE Context modification response to SDU conatining + * RRC Reconfig Message and command to stop transmission + * to UE in handover. * - * @params[in] Pointer to destination Id + * @params[in] Destination Id * Pointer to message buffer * @return void * ******************************************************************/ void XNAPProcHandoverReqAck(uint32_t destId, Buffer *mBuf) { + uint8_t duIdx, duId, ueIdx; + uint8_t cuUeF1apIdSrc; + uint8_t cuUeF1apIdTgt; + DuDb *duDb; + CuUeCb *ueCb; + DU_LOG("\nINFO --> CU STUB : Received Handover Request Acknowledgement"); + + /* Fetch UE CB and DU DB in Source CU for UE under Inter-CU Handover */ + CMCHKUNPK(oduUnpackUInt8, &(cuUeF1apIdSrc), mBuf); + for(duIdx = 0; duIdx < cuCb.numDu; duIdx++) + { + for(ueIdx = 0; ueIdx < MAX_NUM_CELL * MAX_NUM_UE; ueIdx++) + { + if(cuCb.duInfo[duIdx].ueCb[ueIdx].gnbCuUeF1apId == cuUeF1apIdSrc) + { + duDb = &cuCb.duInfo[duIdx]; + ueCb = &cuCb.duInfo[duIdx].ueCb[ueIdx]; + break; + } + } + if(duDb && ueCb) + break; + } + if(!duDb || !ueCb) + { + DU_LOG("\nERROR --> CU STUB : UE CB not found for CU UE F1AP ID [%d]", cuUeF1apIdSrc); + return; + } + + /* Decode CU UE F1AP ID assigned by Target CU to UE in handover and store + * this in hoInfo block for use during future message exchange between the + * two CUs */ + CMCHKUNPK(oduUnpackUInt8, &(cuUeF1apIdTgt), mBuf); + ueCb->hoInfo.cuUeF1apIdTgt = cuUeF1apIdTgt; + + /* Decode DU to CU RRC Container received in Xn Msg */ + OCTET_STRING_t rrcCont; + MsgLen copyCnt; + + /* Copy mBuf into char array to decode it */ + memset(&rrcCont, 0, sizeof(OCTET_STRING_t)); + ODU_GET_MSG_LEN(mBuf, &rrcCont.size); + CU_ALLOC(rrcCont.buf, rrcCont.size); + if(rrcCont.buf == NULLP) + { + DU_LOG("\nERROR --> XNAP : Memory allocation failed"); + return; + } + if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, rrcCont.size, (Data *)rrcCont.buf, ©Cnt) != ROK) + { + DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt); + return; + } + + /* Extract DU to CU RRC container information and store in UE CB */ + extractDuToCuRrcCont(ueCb, rrcCont); + + CU_FREE(rrcCont.buf, rrcCont.size); + + /* Send UE Context Modification request after filling it using the information received in + * Xn Handover Request Ack */ + if(BuildAndSendUeContextModificationReq(duDb->duId, ueCb, STOP_DATA_TX) != ROK) + { + DU_LOG("\nERROR -> F1AP : Failed at BuildAndSendUeContextModificationReq()"); + return; + } +} + +/******************************************************************* + * + * @brief Build And send dummy UE Context Release to Peer CU + * + * @details + * + * Function : BuildAndSendUeContextRelease + * + * Functionality: + * Build And send dummy UE Context Release to Peer CU + * + * @params[in] Pointer to UE Cb + * @return void + * + ******************************************************************/ +void BuildAndSendUeContextRelease(CuUeCb *ueCb) +{ + Buffer *mBuf = NULLP; + + if(ODU_GET_MSG_BUF(1, 1, &mBuf) == ROK) + { + CMCHKPK(oduPackUInt8, ueCb->hoInfo.cuUeF1apIdSrc, mBuf); + CMCHKPK(oduPackUInt8, UE_CTXT_REL, mBuf); + if(sctpSend(XN_INTERFACE, ueCb->hoInfo.srcNodeId, mBuf) != ROK) + { + DU_LOG("\nERROR --> CU_STUB: Failed to send UE context release to peer CU"); + } + } + + return; +} + +/******************************************************************* + * @brief Process received UE Context Release + * + * @details + * + * Function : XNAPProcUeContextRel + * + * Functionality: + * 1. Unpack CU UE F1AP ID (by SCU) and fetch UE CB and + * the corresponding DU DB (SDU) + * 2. Send UE Context release command to SDU + * + * @params[in] Destination Id + * Pointer to message buffer + * @return void + * + ******************************************************************/ +void XNAPProcUeContextRel(uint32_t destId, Buffer *mBuf) +{ + uint8_t duIdx, duId, ueIdx; + uint8_t cuUeF1apIdSrc; + DuDb *duDb; + CuUeCb *ueCb; + + DU_LOG("\nINFO --> CU STUB : Received UE Context Release"); + + /* Fetch UE CB and DU DB in Source CU for UE under Inter-CU Handover */ + CMCHKUNPK(oduUnpackUInt8, &(cuUeF1apIdSrc), mBuf); + for(duIdx = 0; duIdx < cuCb.numDu; duIdx++) + { + for(ueIdx = 0; ueIdx < MAX_NUM_CELL * MAX_NUM_UE; ueIdx++) + { + if(cuCb.duInfo[duIdx].ueCb[ueIdx].gnbCuUeF1apId == cuUeF1apIdSrc) + { + duDb = &cuCb.duInfo[duIdx]; + ueCb = &duDb->ueCb[ueIdx]; + break; + } + } + if(duDb && ueCb) + break; + } + if(!duDb || !ueCb) + { + DU_LOG("\nERROR --> CU STUB : UE CB not found for CU UE F1AP ID [%d]", cuUeF1apIdSrc); + return; + } + + BuildAndSendUeContextReleaseCommand(duDb->duId, ueCb->gnbCuUeF1apId, ueCb->gnbDuUeF1apId); } /******************************************************************* @@ -356,7 +505,7 @@ void XNAPMsgHdlr(uint32_t *destId, Buffer *mBuf) { XnEventType event; - CMCHKUNPK(oduPackUInt8, &event, mBuf); + CMCHKUNPK(oduUnpackUInt8, &event, mBuf); switch(event) { @@ -383,6 +532,11 @@ void XNAPMsgHdlr(uint32_t *destId, Buffer *mBuf) XNAPProcHandoverReqAck(*destId, mBuf); break; } + case UE_CTXT_REL: + { + XNAPProcUeContextRel(*destId, mBuf); + break; + } default: DU_LOG("\nERROR --> CU_STUB : Invalid event [%d] received at XN interface", event); break;