From 51bd2af5867794ba058365581a7ad3c2eba0d1c3 Mon Sep 17 00:00:00 2001 From: Balaji Shankaran Date: Fri, 12 Jun 2020 14:26:12 +0530 Subject: [PATCH] Cu ASN changes for DlRrcMessageTransfer and bug fix included for Msg4 transmission Jira Id: ODUHIGH-168 Change-Id: I7e3d4582b64441260485f54aba110806627a3fdf Signed-off-by: Balaji Shankaran --- build/common/cu_stub.mak | 1 + src/5gnrmac/mac_demux.c | 2 +- src/5gnrmac/mac_msg_hdl.c | 20 +- src/5gnrmac/mac_mux.c | 35 +-- src/5gnrmac/mac_slot_ind.c | 22 +- src/5gnrsch/sch.c | 4 +- src/5gnrsch/sch.h | 1 + src/cm/du_app_mac_inf.h | 3 + src/cm/mac_sch_interface.h | 2 +- src/cu_stub/cu_f1ap_msg_hdl.c | 552 ++++++++++++++++++++++++++++++++---------- src/cu_stub/cu_f1ap_msg_hdl.h | 14 +- src/du_app/du_ue_mgr.c | 56 +++-- 12 files changed, 538 insertions(+), 174 deletions(-) diff --git a/build/common/cu_stub.mak b/build/common/cu_stub.mak index 108ccc57c..431398902 100755 --- a/build/common/cu_stub.mak +++ b/build/common/cu_stub.mak @@ -40,6 +40,7 @@ include $(COM_BUILD_DIR)/compile.mak I_OPTS+=-I$(ROOT_DIR)/src/mt I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/common I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/F1AP +I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/RRC #-------------------------------------------------------------# #Linker macros diff --git a/src/5gnrmac/mac_demux.c b/src/5gnrmac/mac_demux.c index 16725f142..bcb3cef80 100644 --- a/src/5gnrmac/mac_demux.c +++ b/src/5gnrmac/mac_demux.c @@ -117,7 +117,7 @@ int unpackRxData(RxDataIndPdu *rxDataIndPdu) idx = idx + length; /* store msg3 pdu in macRaCb for CRI value */ - memcpy(&macCb.macCell->macRaCb[0].msg3Pdu, pdu, length); + memcpy(macCb.macCell->macRaCb[0].msg3Pdu, pdu, length); /* Send UL-CCCH Indication to DU APP */ macSendUlCcchInd(pdu, macCb.macCell->cellId, rxDataIndPdu->rnti); diff --git a/src/5gnrmac/mac_msg_hdl.c b/src/5gnrmac/mac_msg_hdl.c index eed1dad94..fa8b678b6 100644 --- a/src/5gnrmac/mac_msg_hdl.c +++ b/src/5gnrmac/mac_msg_hdl.c @@ -325,7 +325,9 @@ uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo) * ****************************************************************/ uint16_t MacHdlDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo) { + uint16_t idx; DlRlcBOInfo dlBoInfo; + memset(&dlBoInfo, 0, sizeof(DlRlcBOInfo)); DU_LOG("\nMAC : Handling DL CCCH IND"); @@ -336,29 +338,31 @@ uint16_t MacHdlDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo) if(dlCcchIndInfo->msgType == RRC_SETUP) { + dlBoInfo.boInfo[dlBoInfo.numLc].lcId = SRB_ID_0; // SRB ID 0 for msg4 + dlBoInfo.boInfo[SRB_ID_0].dataVolume = \ + dlCcchIndInfo->dlCcchMsgLen; dlBoInfo.numLc++; - dlBoInfo.boInfo[dlBoInfo.numLc].lcId = 0; // SRB 0 for msg4 - dlBoInfo.boInfo[dlBoInfo.numLc].dataVolume = \ - strlen((const char*)dlCcchIndInfo->dlCcchMsg); /* storing Msg4 Pdu in raCb */ if(macCb.macCell->macRaCb[0].crnti == dlCcchIndInfo->crnti) { - macCb.macCell->macRaCb[0].msg4PduLen = strlen((const char*)dlCcchIndInfo\ - ->dlCcchMsg); + macCb.macCell->macRaCb[0].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen; MAC_ALLOC(macCb.macCell->macRaCb[0].msg4Pdu, macCb.macCell->macRaCb[0]\ .msg4PduLen); if(macCb.macCell->macRaCb[0].msg4Pdu) { - memcpy(macCb.macCell->macRaCb[0].msg4Pdu, dlCcchIndInfo->dlCcchMsg,\ - macCb.macCell->macRaCb[0].msg4PduLen); + for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++) + { + macCb.macCell->macRaCb[0].msg4Pdu[idx] =\ + dlCcchIndInfo->dlCcchMsg[idx]; + } } } } sendDlRlcBoInfoMacToSch(&dlBoInfo); MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \ - strlen((const char*)dlCcchIndInfo->dlCcchMsg)); + dlCcchIndInfo->dlCcchMsgLen); MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo)); return ROK; diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c index dcab8fdb8..688afd697 100644 --- a/src/5gnrmac/mac_mux.c +++ b/src/5gnrmac/mac_mux.c @@ -248,11 +248,15 @@ void createMacRaCb(uint16_t cellId, uint16_t crnti) void fillMsg4DlData(MacDlData *dlData) { uint8_t idx = 0; + uint16_t idx2; dlData->numPdu = 1; dlData->pduInfo[idx].lcId = MAC_LCID_CCCH; - dlData->pduInfo[idx].pduLen = macCb.macCell->macRaCb[0].msg4PduLen; - memcpy(dlData->pduInfo[idx].dlPdu, macCb.macCell->macRaCb[0].msg4Pdu,\ - macCb.macCell->macRaCb[0].msg4PduLen); + dlData->pduInfo[idx].pduLen = macCb.macCell->macRaCb[idx].msg4PduLen; + for(idx2 = 0; idx2 < dlData->pduInfo[idx].pduLen; idx2++) + { + dlData->pduInfo[idx].dlPdu[idx2] = \ + macCb.macCell->macRaCb[idx].msg4Pdu[idx2]; + } } /************************************************* @@ -273,8 +277,8 @@ void fillMacCe(MacCeInfo *macCeInfo) for(idx = 0; idx < macCeInfo->numCes; idx++) { macCeInfo->macCe[idx].macCeLcid = MAC_LCID_CRI; - memcpy(&macCeInfo->macCe[idx].macCeValue, \ - &macCb.macCell->macRaCb[idx].msg3Pdu, MAX_CRI_SIZE); + memcpy(macCeInfo->macCe[idx].macCeValue, \ + macCb.macCell->macRaCb[idx].msg3Pdu, MAX_CRI_SIZE); } } @@ -284,7 +288,7 @@ void fillMacCe(MacCeInfo *macCeInfo) * * @details * - * Function : buildMacPdu + * Function : macMuxPdu * * Functionality: * The MAC PDU will be MUXed and formed @@ -306,13 +310,13 @@ void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) uint8_t RBit = 0; /* Reserved bit */ uint8_t FBit; /* Format Indicator */ uint8_t lcid; /* LCID */ - uint8_t lenField = 0; /* Length field */ + uint16_t lenField = 0; /* Length field */ /* subheader field size (in bits) */ uint8_t RBitSize = 1; uint8_t FBitSize = 1; uint8_t lcidSize = 6; - uint8_t lenFieldSize = 0; /* 8-bit or 16-bit L field */ + uint8_t lenFieldSize = 0; /* 8-bit or 16-bit L field */ /* PACK ALL MAC CE */ for(idx = 0; idx < macCeData->numCes; idx++) @@ -323,11 +327,11 @@ void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) case MAC_LCID_CRI: { /* Packing fields into MAC PDU R/R/LCID */ - packBytes(macPdu, &bytePos, &bitPos, RBit, RBitSize); - packBytes(macPdu, &bytePos, &bitPos, RBit, RBitSize); + packBytes(macPdu, &bytePos, &bitPos, RBit, (RBitSize * 2)); packBytes(macPdu, &bytePos, &bitPos, lcid, lcidSize); memcpy(&macPdu[bytePos], macCeData->macCe[idx].macCeValue,\ MAX_CRI_SIZE); + bytePos += MAX_CRI_SIZE; break; } default: @@ -340,11 +344,11 @@ void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) for(idx = 0; idx < dlData->numPdu; idx++) { lcid = dlData->pduInfo[idx].lcId; - lenField = dlData->pduInfo[idx].pduLen; switch(lcid) { case MAC_LCID_CCCH: { + lenField = dlData->pduInfo[idx].pduLen; if(dlData->pduInfo[idx].pduLen > 255) { FBit = 1; @@ -361,7 +365,8 @@ void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) packBytes(macPdu, &bytePos, &bitPos, FBit, FBitSize); packBytes(macPdu, &bytePos, &bitPos, lcid, lcidSize); packBytes(macPdu, &bytePos, &bitPos, lenField, lenFieldSize); - memcpy(&macPdu[bytePos], dlData->pduInfo[idx].dlPdu, lenField); + memcpy(&macPdu[bytePos], dlData->pduInfo[idx].dlPdu, lenField); + bytePos += lenField; break; } @@ -380,11 +385,13 @@ void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize) packBytes(macPdu, &bytePos, &bitPos, lcid, lcidSize); } + /*Storing the muxed pdu in macRaCb */ + macCb.macCell->macRaCb[0].msg4TxPdu = NULLP; MAC_ALLOC(macCb.macCell->macRaCb[0].msg4TxPdu, macCb.macCell->macRaCb[0].msg4TbSize); if(macCb.macCell->macRaCb[0].msg4TxPdu != NULLP) { - memcpy(macCb.macCell->macRaCb[0].msg4TxPdu, macPdu,\ - macCb.macCell->macRaCb[0].msg4TbSize); + memcpy(macCb.macCell->macRaCb[0].msg4TxPdu, macPdu,\ + macCb.macCell->macRaCb[0].msg4TbSize); } } diff --git a/src/5gnrmac/mac_slot_ind.c b/src/5gnrmac/mac_slot_ind.c index 8f686b3f7..794952387 100644 --- a/src/5gnrmac/mac_slot_ind.c +++ b/src/5gnrmac/mac_slot_ind.c @@ -131,13 +131,21 @@ int MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo) macMuxPdu(&msg4DlData, &macCeData, macCb.macCell->macRaCb[0].msg4TbSize); /* storing msg4 Pdu in macDlSlot */ - MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen); - if(msg4Alloc->msg4Info.msg4Pdu != NULLP) - { - msg4Alloc->msg4Info.msg4Pdu = macCb.macCell->macRaCb[0].msg4Pdu; - msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4PduLen; - } - + if(macCb.macCell->macRaCb[0].msg4TxPdu) + { + msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4TbSize; + MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, msg4Alloc->msg4Info.msg4PduLen); + if(msg4Alloc->msg4Info.msg4Pdu != NULLP) + { + memcpy(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4TxPdu, \ + msg4Alloc->msg4Info.msg4PduLen); + } + } + else + { + DU_LOG("\nMAC: Failed at macMuxPdu()"); + return RFAILED; + } /* TODO: Free all allocated memory, after the usage */ /* MAC_FREE(macCb.macCell->macRaCb[0].msg4TxPdu, \ macCb.macCell->macRaCb[0].msg4TbSize); // TODO: To be freed after re-transmission is successful. diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 503a90bff..27ed26cf7 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -701,7 +701,7 @@ uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo) SchCellCb *cell = schCb[inst].cells[inst]; SchDlSlotInfo *schDlSlotInfo = \ - cell->schDlSlotInfo[(cell->slotInfo.slot + SCHED_DELTA + PHY_DELTA) % SCH_NUM_SLOTS]; + cell->schDlSlotInfo[(cell->slotInfo.slot + SCHED_DELTA + PHY_DELTA + MSG4_DELAY) % SCH_NUM_SLOTS]; for(lcIdx = 0; lcIdx < dlBoInfo->numLc; lcIdx++) { @@ -723,7 +723,7 @@ uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo) schDlSlotInfo->msg4Info->harqFeedbackInd = 0; schDlSlotInfo->msg4Info->dciFormatId = 1; } - } + } return ROK; } diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index bb1d39b05..30a206a63 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -35,6 +35,7 @@ #define SCHED_DELTA 1 #define BO_DELTA 1 #define RAR_DELAY 2 +#define MSG4_DELAY 1 #define SCH_MAX_UE 1 #define PUSCH_START_RB 15 #define SI_RNTI 0xFFFF diff --git a/src/cm/du_app_mac_inf.h b/src/cm/du_app_mac_inf.h index ef4eea0c1..a3ff48064 100644 --- a/src/cm/du_app_mac_inf.h +++ b/src/cm/du_app_mac_inf.h @@ -42,6 +42,8 @@ #define SS_MONITORING_SYMBOL 0x2000; /* symbol-0, set 14th bit */ #define SIB1_MCS 4 +#define SRB_ID_0 0 +#define SRB_ID_1 1 /* Macros for coupling */ #define DU_MAC_LC 0 #define DU_MAC_TC 1 @@ -326,6 +328,7 @@ typedef struct dlCcchInd uint16_t cellId; uint16_t crnti; DlCcchMsgType msgType; + uint16_t dlCcchMsgLen; uint8_t *dlCcchMsg; }DlCcchIndInfo; diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index 677e846ef..513fc7e26 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -415,7 +415,7 @@ typedef struct msg4Info uint8_t dciFormatId; uint16_t crnti; uint8_t *msg4Pdu; - uint8_t msg4PduLen; + uint16_t msg4PduLen; }Msg4Info; typedef struct msg4Alloc diff --git a/src/cu_stub/cu_f1ap_msg_hdl.c b/src/cu_stub/cu_f1ap_msg_hdl.c index a7ce195dd..2f0bf5def 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.c +++ b/src/cu_stub/cu_f1ap_msg_hdl.c @@ -39,7 +39,7 @@ * ****************************************************************/ S16 SendF1APMsg(Region region, Pool pool) { - Buffer *mBuf; + Buffer *mBuf = NULLP; if(SGetMsg(region, pool, &mBuf) == ROK) { @@ -637,156 +637,400 @@ S16 BuildAndSendDUUpdateAck() /******************************************************************* * - * @brief Builds and sends the DLRRCMessageTransfer + * @brief Fills Radio Bearer Config * * @details * - * Function : BuildAndSendDLRRCMessageTransfer + * Function : fillRadioBearerConfig * - * Functionality: Constructs the DL RRC Message Transfer and sends - * it to the CU through SCTP. + * Functionality: Fills Radio Bearer Config * - * @params[in] + * @params[in] SRB_ToAddModList * * * @return ROK - success * RFAILED - failure * * ****************************************************************/ -S16 BuildAndSendDLRRCMessageTransfer() +uint8_t fillRadioBearerConfig(SRB_ToAddModList_t *bearerCfg) { - S16 ret; - U8 elementCnt; - U8 ieId; - U8 idx; - F1AP_PDU_t *f1apMsg = NULL; - DLRRCMessageTransfer_t *dlRRCMsg; - asn_enc_rval_t encRetVal; /* Encoder return value */ + uint8_t elementCnt; + uint8_t idx; + uint8_t ied; + if(bearerCfg != NULLP) + { + elementCnt = 1; + bearerCfg->list.count = elementCnt; + bearerCfg->list.size =\ + elementCnt * sizeof(SRB_ToAddMod_t *); + CU_ALLOC(bearerCfg->list.array, bearerCfg->list.size); + if(bearerCfg->list.array != NULLP) + { + for(idx = 0; idx < elementCnt; idx++) + { + CU_ALLOC(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t)); + if(bearerCfg->list.array[idx] == NULLP) + { + for(ied = 0; ied < idx; ied++) + { + CU_FREE(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t)); + } + CU_FREE(bearerCfg->list.array, bearerCfg->list.size); + return RFAILED; + } + } + } + else + { + return RFAILED; + } + idx = 0; + bearerCfg->list.array[idx]->srb_Identity = SRB1; + } + return ROK; +} - DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n"); +/******************************************************************* + * + * @brief Fills Master CellGroup Info + * + * @details + * + * Function : fillMasterCellGroup + * + * Functionality: Fills Master Cell Group IE + * + * @params[in] RRCSetup_IEs_t * + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ - CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t)); - if(f1apMsg == NULLP) +uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup) +{ + uint8_t ret = ROK; + masterCellGroup->buf = NULLP; + if(f1apMsgDb.duToCuContainer.buf) { - DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed"); - RETVALUE(RFAILED); + masterCellGroup->size = f1apMsgDb.duToCuContainer.size; + CU_ALLOC(masterCellGroup->buf, masterCellGroup->size); + if(masterCellGroup->buf != NULLP) + { + memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\ + masterCellGroup->size); + } + else + { + ret = RFAILED; + } } - - f1apMsg->present = F1AP_PDU_PR_initiatingMessage; - CU_ALLOC(f1apMsg->choice.initiatingMessage, - sizeof(InitiatingMessage_t)); - if(f1apMsg->choice.initiatingMessage == NULLP) + else { - DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed"); - CU_FREE(f1apMsg,sizeof(F1AP_PDU_t)); - RETVALUE(RFAILED); - } + ret = RFAILED; + } + return ret; +} - f1apMsg->choice.initiatingMessage->procedureCode = \ - ProcedureCode_id_DLRRCMessageTransfer; - f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore; - f1apMsg->choice.initiatingMessage->value.present = \ - InitiatingMessage__value_PR_DLRRCMessageTransfer; - dlRRCMsg = - &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer; - elementCnt = 3; - dlRRCMsg->protocolIEs.list.count = elementCnt; - dlRRCMsg->protocolIEs.list.size = \ - elementCnt * sizeof(DLRRCMessageTransferIEs_t *); - - /* Initialize the F1Setup members */ - CU_ALLOC(dlRRCMsg->protocolIEs.list.array, \ - elementCnt * sizeof(DLRRCMessageTransferIEs_t *)); - if(dlRRCMsg->protocolIEs.list.array == NULLP) - { - DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed"); - CU_FREE(f1apMsg->choice.initiatingMessage, - sizeof(InitiatingMessage_t)); - CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t)); - RETVALUE(RFAILED); - } +/******************************************************************* + * + * @brief Fills RRC setup IE + * + * @details + * + * Function : fillRRCSetupIE + * + * Functionality: Fills RRC Setup IE + * + * @params[in] RRCSetup_IEs_t * + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ - for(idx=0; idxprotocolIEs.list.array[idx],\ - sizeof(DLRRCMessageTransferIEs_t)); - if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP) +uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) +{ + uint8_t ret = ROK; + if(rrcSetupIE) + { + CU_ALLOC(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t)); + if(rrcSetupIE->radioBearerConfig.srb_ToAddModList != NULLP) { - for(ieId=0; ieIdradioBearerConfig.srb_ToAddModList); + } + if(!ret) + { + ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup); + } + else + { + CU_FREE(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t)); + ret = RFAILED; + } + } + return ret; +} +/******************************************************************* + * + * @brief Builds RRC Container IE required for DLRRCMessageTransfer + * + * @details + * + * Function : BuildDLRRCContainer + * + * Functionality: Builds RRC Container IE required for + * DLRRCMessageTransfer + * + * @params[in] + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t BuildDLRRCContainer(RRCContainer_t *rrcContainer) +{ + uint8_t ret = ROK; + uint16_t idx2; + DL_CCCH_Message_t dl_CCCH_Msg; + asn_enc_rval_t encRetVal; + + if(rrcContainer != NULLP) + { + dl_CCCH_Msg.message.present = DL_CCCH_MessageType_PR_c1; + + CU_ALLOC(dl_CCCH_Msg.message.choice.c1 , sizeof(DL_CCCH_MessageType_t)); + if(dl_CCCH_Msg.message.choice.c1 != NULLP) + { + dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup; + CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t)); + if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP) + { + dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0; + dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\ + present = RRCSetup__criticalExtensions_PR_rrcSetup; + /* Fill RRC Setup IE */ + CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t)); + if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup != NULLP) + { + ret = fillRRCSetupIE(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup); + + if(!ret) + { + /* encode DL-CCCH message into RRC Container */ + xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg); + cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf); + /* Encode results */ + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG( "\n F1AP : Could not encode RRCContainer (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + return RFAILED; + } + else + { + DU_LOG("\n F1AP : Created APER encoded buffer for RRCContainer\n"); + for(int i = 0; i< encBufSize; i++) + { + printf("%x",encBuf[i]); + } + rrcContainer->size = encBufSize; + CU_ALLOC(rrcContainer->buf, rrcContainer->size); + if(rrcContainer->buf != NULLP) + { + memset(rrcContainer->buf, 0, encBufSize); + for(idx2 = 0; idx2 < encBufSize; idx2++) + { + rrcContainer->buf[idx2] = encBuf[idx2]; + } + } + } + } + else + { + ret = RFAILED; + } + } + else + { + DU_LOG("\nF1AP: Memory Alloc failed for RRC Setup Msg"); + ret = RFAILED; + } + } + else { - CU_FREE(dlRRCMsg->protocolIEs.list.array[ieId],\ - sizeof(DLRRCMessageTransferIEs_t)); + DU_LOG("\nF1AP: Memory Alloc failed for RRC Msg"); + ret = RFAILED; } - CU_FREE(dlRRCMsg->protocolIEs.list.array,\ - elementCnt * sizeof(DLRRCMessageTransferIEs_t *)); - CU_FREE(f1apMsg->choice.initiatingMessage,\ - sizeof(InitiatingMessage_t)); - CU_FREE(f1apMsg,sizeof(F1AP_PDU_t)); - RETVALUE(RFAILED); + } + else + { + DU_LOG("\nF1AP: Memory Alloc failed for DL Ccch Msg choice"); + ret = RFAILED; } + } + else + { + DU_LOG("\nF1AP: Memory Alloc failed for DlCcch Msg"); + ret = RFAILED; } + return ret; +} - idx = 0; - - /*GNB CU UE F1AP ID*/ - dlRRCMsg->protocolIEs.list.array[idx]->id = \ - ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; - dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; - dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ - DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID; - - /*GNB DU UE F1AP ID*/ - idx++; - dlRRCMsg->protocolIEs.list.array[idx]->id = \ - ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; - dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; - dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ - DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID; +/******************************************************************* + * + * @brief Builds and sends the DLRRCMessageTransfer + * + * @details + * + * Function : BuildAndSendDLRRCMessageTransfer + * + * Functionality: Constructs the DL RRC Message Transfer and sends + * it to the CU through SCTP. + * + * @params[in] + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 BuildAndSendDLRRCMessageTransfer() +{ + uint8_t ret = ROK ; + uint8_t elementCnt = 0; + uint8_t ieId; + uint8_t idx; + uint16_t idx2; + F1AP_PDU_t *f1apMsg = NULLP; + DLRRCMessageTransfer_t *dlRRCMsg = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ + + DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n"); + + CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t)); + if(f1apMsg == NULLP) + { + DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed"); + return RFAILED; + } - /*SRBID*/ - idx++; - dlRRCMsg->protocolIEs.list.array[idx]->id = \ - ProtocolIE_ID_id_SRBID; - dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; - dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ - DLRRCMessageTransferIEs__value_PR_SRBID; - dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = DL_SRBID; + f1apMsg->present = F1AP_PDU_PR_initiatingMessage; + CU_ALLOC(f1apMsg->choice.initiatingMessage, + sizeof(InitiatingMessage_t)); + if(f1apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed"); + CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + return RFAILED; + } - /*RRCContainer*/ - //YET TO FILL + f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_DLRRCMessageTransfer; + f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore; + f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_DLRRCMessageTransfer; + dlRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer; - xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); + elementCnt = 4; + dlRRCMsg->protocolIEs.list.count = elementCnt; + dlRRCMsg->protocolIEs.list.size = elementCnt * sizeof(DLRRCMessageTransferIEs_t *); - /* Encode the F1SetupRequest type as APER */ - cmMemset((U8 *)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( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\ - encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - RETVALUE(RFAILED); - } - else - { - DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n"); - for(int i=0; i< encBufSize; i++) - { - printf("%x",encBuf[i]); - } - } + /* Initialize the F1Setup members */ + CU_ALLOC(dlRRCMsg->protocolIEs.list.array, dlRRCMsg->protocolIEs.list.size); + if(dlRRCMsg->protocolIEs.list.array == NULLP) + { + DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed"); + CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t)); + CU_FREE(f1apMsg, sizeof(F1AP_PDU_t)); + return RFAILED; + } - /* Sending msg */ - if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK) - { - DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed"); - RETVALUE(RFAILED); - } + for(idx=0; idxprotocolIEs.list.array[idx], sizeof(DLRRCMessageTransferIEs_t)); + if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP) + { + for(ieId=0; ieIdprotocolIEs.list.array[ieId],\ + sizeof(DLRRCMessageTransferIEs_t)); + } + CU_FREE(dlRRCMsg->protocolIEs.list.array,\ + dlRRCMsg->protocolIEs.list.size); + CU_FREE(f1apMsg->choice.initiatingMessage,\ + sizeof(InitiatingMessage_t)); + CU_FREE(f1apMsg,sizeof(F1AP_PDU_t)); + return RFAILED; + } + } - RETVALUE(ROK); + /* GNB CU UE F1AP ID */ + idx = 0; + dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; + dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ + DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID; + + /* GNB DU UE F1AP ID */ + idx++; + dlRRCMsg->protocolIEs.list.array[idx]->id = \ + ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; + dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ + DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID; + + /* SRBID */ + idx++; + dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_SRBID; + dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; + dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ + DLRRCMessageTransferIEs__value_PR_SRBID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = SRB1; + + /* RRCContainer */ + idx++; + dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer; + dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject; + dlRRCMsg->protocolIEs.list.array[idx]->value.present = \ + DLRRCMessageTransferIEs__value_PR_RRCContainer; + BuildDLRRCContainer(&dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer); + + xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); + + /* Encode the F1SetupRequest type as APER */ + cmMemset((U8 *)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( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + RETVALUE(RFAILED); + } + else + { + DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n"); + for(int i=0; i< encBufSize; i++) + { + printf("%x",encBuf[i]); + } + } + + /* Sending msg */ + if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK) + { + DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed"); + return RFAILED; + } + + return ROK; }/* End of BuildAndSendDLRRCMessageTransfer */ @@ -935,6 +1179,63 @@ S16 BuildAndSendUESetRsp() RETVALUE(ROK); }/* End of BuildAndSendUESetRsp */ + + +uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg) +{ + uint8_t idx; + uint8_t ret =ROK; + InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP; + DU_LOG("\n filling the required values in DB in procInitULRRCMsg"); + + initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer; + + for(idx=0; idx < initULRRCMsg->protocolIEs.list.count; idx++) + { + switch(initULRRCMsg->protocolIEs.list.array[idx]->id) + { + case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: + break; + case ProtocolIE_ID_id_NRCGI: + break; + case ProtocolIE_ID_id_C_RNTI: + break; + case ProtocolIE_ID_id_RRCContainer: + break; + case ProtocolIE_ID_id_DUtoCURRCContainer: + { + if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\ + .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP)) + { + DU_LOG("\n Received Du to Cu RRC Container "); + f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.size; + CU_ALLOC(f1apMsgDb.duToCuContainer.buf, \ + f1apMsgDb.duToCuContainer.size); + if(f1apMsgDb.duToCuContainer.buf != NULLP) + { + memcpy(f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.buf, f1apMsgDb\ + .duToCuContainer.size); + } + } + else + { + DU_LOG("\n Failed to receive Du to Cu RRC Container "); + ret = RFAILED; + } + break; + } + default: + DU_LOG("\n Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id); + break; + } + } + if(!ret) + ret = BuildAndSendDLRRCMessageTransfer(); + return ret; +} /******************************************************************* * * @brief Handles received F1AP message and sends back response @@ -958,7 +1259,7 @@ void F1APMsgHdlr(Buffer *mBuf) char *recvBuf; MsgLen copyCnt; MsgLen recvBufLen; - F1AP_PDU_t *f1apMsg; + F1AP_PDU_t *f1apMsg = NULLP; asn_dec_rval_t rval; /* Decoder return value */ F1AP_PDU_t f1apasnmsg ; @@ -1017,7 +1318,12 @@ void F1APMsgHdlr(Buffer *mBuf) BuildAndSendDUUpdateAck(); break; } - + case InitiatingMessage__value_PR_InitialULRRCMessageTransfer: + { + DU_LOG("\nF1AP : Received InitialULRRCMessageTransfer"); + procInitULRRCMsg(f1apMsg); + break; + } default: { DU_LOG("\nF1AP : Invalid type of intiating message [%d]",f1apMsg->choice.initiatingMessage->value.present); diff --git a/src/cu_stub/cu_f1ap_msg_hdl.h b/src/cu_stub/cu_f1ap_msg_hdl.h index d213a9028..c14e6869d 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.h +++ b/src/cu_stub/cu_f1ap_msg_hdl.h @@ -24,6 +24,11 @@ #include "ProtocolExtensionField.h" #include "F1AP-PDU.h" #include "Cells-to-be-Activated-List.h" +#include "DL-CCCH-Message.h" +#include "SRB-ToAddModList.h" +#include "SRB-ToAddMod.h" +#include "RRCSetup-IEs.h" +#include "RRCSetup.h" #include "envopt.h" /* Environment options */ #include "envdep.h" /* Environment dependent */ @@ -53,7 +58,7 @@ #define CU_ID 1 #define CRNTI 17017 #define CELL_INDEX 0 - +#define SRB1 1 /* allocate and zero out a static buffer */ #define CU_ALLOC(_datPtr, _size) \ @@ -74,7 +79,12 @@ (Data *)_datPtr, _size); - +typedef struct f1apDb +{ + OCTET_STRING_t duToCuContainer; +}F1apMsgDb; + +F1apMsgDb f1apMsgDb; void F1APMsgHdlr(Buffer *mBuf); /********************************************************************** diff --git a/src/du_app/du_ue_mgr.c b/src/du_app/du_ue_mgr.c index 40cbdac20..d382622cb 100644 --- a/src/du_app/du_ue_mgr.c +++ b/src/du_app/du_ue_mgr.c @@ -201,12 +201,15 @@ PUBLIC S16 duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf) * RFAILED - failure * * ****************************************************************/ -uint8_t duBuildAndSendDlCcchInd(uint8_t *dlCcchMsg, uint16_t crnti, uint16_t cellId, DlCcchMsgType msgType) +uint8_t duBuildAndSendDlCcchInd(uint16_t cellId, uint16_t crnti, \ + DlCcchMsgType msgType, uint8_t *dlCcchMsg, uint16_t dlCcchMsgSize) { - Pst pst; uint8_t ret = ROK; + uint16_t idx2; DlCcchIndInfo *dlCcchIndInfo = NULLP; - + Pst pst; + + memset(&pst, 0, sizeof(Pst)); DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC"); DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo)); @@ -220,15 +223,20 @@ uint8_t duBuildAndSendDlCcchInd(uint8_t *dlCcchMsg, uint16_t crnti, uint16_t cel dlCcchIndInfo->cellId = cellId; dlCcchIndInfo->crnti = crnti; dlCcchIndInfo->msgType = msgType; - DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, strlen((const char*)dlCcchMsg)); + dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize; + + DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen); if(!dlCcchIndInfo->dlCcchMsg) { DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind"); DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo)); return RFAILED; } - memcpy(dlCcchIndInfo->dlCcchMsg, dlCcchMsg, strlen((const char*)dlCcchMsg)); - DU_FREE(dlCcchMsg, strlen((const char*)dlCcchMsg)); + for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++) + { + dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2]; + } + DU_FREE(dlCcchMsg, dlCcchMsgSize); /* Fill Pst */ pst.selector = DU_MAC_LWLC; @@ -246,8 +254,10 @@ uint8_t duBuildAndSendDlCcchInd(uint8_t *dlCcchMsg, uint16_t crnti, uint16_t cel if(ret != ROK) { DU_LOG("\nDU_APP : Failure in sending DL CCCH to MAC"); - DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg, strlen((const char*)dlCcchMsg)); - DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo)); + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\ + dlCcchIndInfo->dlCcchMsgLen); + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \ + sizeof(DlCcchIndInfo)); ret = RFAILED; } @@ -274,8 +284,8 @@ uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg) { DLRRCMessageTransfer_t *dlRrcMsg = NULLP; uint8_t *dlCcchMsg = NULLP; - uint8_t srbId, idx, ret; - uint16_t crnti, cellId; + uint8_t idx, ret, srbId; + uint16_t idx2, crnti, cellId, dlCcchMsgSize; uint32_t gnbCuUeF1apId, gnbDuUeF1apId; @@ -304,12 +314,26 @@ uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg) srbId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID; break; } + case ProtocolIE_ID_id_ExecuteDuplication: + break; + case ProtocolIE_ID_id_RRCContainer: { - DU_ALLOC(dlCcchMsg, dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size); - memcpy(dlCcchMsg, - dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf, - dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size); + if(dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0) + { + dlCcchMsgSize = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size; + DU_ALLOC(dlCcchMsg, dlCcchMsgSize); + for(idx2 = 0; idx2 < dlCcchMsgSize; idx2++) + { + dlCcchMsg[idx2] = \ + dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf[idx2]; + } + } + else + { + DU_LOG("\nDU_APP : RRC Container Size is invalid:%d",\ + dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size); + } break; } @@ -327,9 +351,9 @@ uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg) cellId = duCb.ueCcchCtxt[idx].cellId; } } - if(srbId == 0) //RRC connection setup + if(srbId == SRB_ID_1) //RRC connection setup { - ret = duBuildAndSendDlCcchInd(dlCcchMsg, crnti, cellId, RRC_SETUP); + ret = duBuildAndSendDlCcchInd(cellId, crnti, RRC_SETUP, dlCcchMsg, dlCcchMsgSize); } return ret; } -- 2.16.6