From 287632f09119435e0bf1ea16e4e11fc6447c1eee Mon Sep 17 00:00:00 2001 From: "lal.harshita" Date: Thu, 22 Jul 2021 19:49:20 +0530 Subject: [PATCH] Fixes in current code for Multi-UE support [Issue-ID: ODUHIGH-354] Change-Id: I21f3889fde302b329ffcc077535eb89faebb82b5 Signed-off-by: lal.harshita --- src/5gnrmac/mac_mux.c | 10 +- src/5gnrmac/mac_slot_ind.c | 13 +- src/cm/common_def.h | 2 +- src/cu_stub/cu_f1ap_msg_hdl.c | 321 ++++++++++++++++++++----------------- src/cu_stub/cu_f1ap_msg_hdl.h | 11 +- src/cu_stub/cu_stub.c | 1 + src/cu_stub/cu_stub.h | 1 + src/du_app/du_f1ap_msg_hdl.c | 12 +- src/phy_stub/phy_stub.h | 32 +++- src/phy_stub/phy_stub_msg_hdl.c | 73 +++++---- src/phy_stub/phy_stub_thread_hdl.c | 9 +- 11 files changed, 267 insertions(+), 218 deletions(-) diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c index 8659fa5dd..f55fb08bf 100644 --- a/src/5gnrmac/mac_mux.c +++ b/src/5gnrmac/mac_mux.c @@ -214,12 +214,10 @@ void createMacRaCb(RachIndInfo *rachIndInfo) void fillMsg4DlData(MacDlData *dlData, uint16_t msg4PduLen, uint8_t *msg4Pdu) { - uint8_t idx = 0; - - dlData->numPdu = 1; - dlData->pduInfo[idx].lcId = MAC_LCID_CCCH; - dlData->pduInfo[idx].pduLen = msg4PduLen; - memcpy(dlData->pduInfo[idx].dlPdu, msg4Pdu, msg4PduLen); + dlData->pduInfo[dlData->numPdu].lcId = MAC_LCID_CCCH; + dlData->pduInfo[dlData->numPdu].pduLen = msg4PduLen; + memcpy(dlData->pduInfo[dlData->numPdu].dlPdu, msg4Pdu, msg4PduLen); + dlData->numPdu++; } /************************************************* diff --git a/src/5gnrmac/mac_slot_ind.c b/src/5gnrmac/mac_slot_ind.c index 27088ed02..ab7c36c79 100644 --- a/src/5gnrmac/mac_slot_ind.c +++ b/src/5gnrmac/mac_slot_ind.c @@ -54,6 +54,7 @@ MacSchSlotIndFunc macSchSlotIndOpts[] = **/ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo) { + uint8_t ueIdx; uint16_t cellIdx; MacDlSlot *currDlSlot = NULLP; @@ -90,7 +91,10 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo) /* Check if the downlink pdu is msg4 */ if(dlSchedInfo->dlMsgAlloc->dlMsgInfo.isMsg4Pdu) { - macCb.macCell[cellIdx]->macRaCb[0].msg4TbSize = dlSchedInfo->dlMsgAlloc->dlMsgPdschCfg.codeword[0].tbSize; + GET_UE_IDX(dlSchedInfo->dlMsgAlloc->dlMsgInfo.crnti, ueIdx); + ueIdx = ueIdx -1; + macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize = \ + dlSchedInfo->dlMsgAlloc->dlMsgPdschCfg.codeword[0].tbSize; } else { @@ -145,8 +149,8 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc) if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu != NULLP) { - MAC_ALLOC(msg4DlData.pduInfo[ueIdx].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); - if(msg4DlData.pduInfo[ueIdx].dlPdu != NULLP) + MAC_ALLOC(msg4DlData.pduInfo[msg4DlData.numPdu].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); + if(msg4DlData.pduInfo[msg4DlData.numPdu].dlPdu != NULLP) { msg4TxPduLen = macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize - TX_PAYLOAD_HDR_LEN; @@ -166,7 +170,8 @@ void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc) DU_LOG("\nERROR --> MAC: Failed allocating memory for msg4TxPdu"); } /* Free memory allocated */ - MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); + MAC_FREE(msg4DlData.pduInfo[msg4DlData.numPdu-1].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); + msg4DlData.numPdu--; } } diff --git a/src/cm/common_def.h b/src/cm/common_def.h index 58fda11a9..9681393f0 100644 --- a/src/cm/common_def.h +++ b/src/cm/common_def.h @@ -56,7 +56,7 @@ #define RADIO_FRAME_DURATION 10 /* Time duration of a radio frame in ms */ /* MAX values */ #define MAX_NUM_CELL 1 -#define MAX_NUM_UE 1 +#define MAX_NUM_UE 2 #define MAX_NUM_UE_PER_TTI 1 #define MAX_NUM_LC 11 #define MAX_NUM_SRB 3 /* Max. no of Srbs */ diff --git a/src/cu_stub/cu_f1ap_msg_hdl.c b/src/cu_stub/cu_f1ap_msg_hdl.c index 819063d57..3751ae234 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.c +++ b/src/cu_stub/cu_f1ap_msg_hdl.c @@ -1019,18 +1019,18 @@ uint8_t fillSrbCfg(uint8_t srbId, SRB_ToAddModList_t *bearerCfg) * * ****************************************************************/ -uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup) +uint8_t fillMasterCellGroup(uint8_t ueId, OCTET_STRING_t *masterCellGroup) { uint8_t ret = ROK; masterCellGroup->buf = NULLP; - if(f1apMsgDb.duToCuContainer.buf) + if(ueCb[ueId-1].f1apMsgDb.duToCuContainer.buf) { - masterCellGroup->size = f1apMsgDb.duToCuContainer.size; + masterCellGroup->size = ueCb[ueId-1].f1apMsgDb.duToCuContainer.size; CU_ALLOC(masterCellGroup->buf, masterCellGroup->size); if(masterCellGroup->buf != NULLP) { - memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\ - masterCellGroup->size); + memcpy(masterCellGroup->buf, ueCb[ueId-1].f1apMsgDb.duToCuContainer.buf,\ + masterCellGroup->size); } else { @@ -1061,7 +1061,7 @@ uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup) * * ****************************************************************/ -uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) +uint8_t fillRRCSetupIE(uint8_t ueId, RRCSetup_IEs_t *rrcSetupIE) { uint8_t ret = ROK; if(rrcSetupIE) @@ -1073,7 +1073,7 @@ uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) } if(ret == ROK) { - ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup); + ret = fillMasterCellGroup(ueId, &rrcSetupIE->masterCellGroup); } else { @@ -1101,7 +1101,7 @@ uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE) * * ****************************************************************/ -uint8_t fillDlCcchRrcMsg(RRCContainer_t *rrcContainer) +uint8_t fillDlCcchRrcMsg(uint8_t ueId, RRCContainer_t *rrcContainer) { uint8_t ret = ROK; uint16_t idx2; @@ -1115,71 +1115,71 @@ uint8_t fillDlCcchRrcMsg(RRCContainer_t *rrcContainer) 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); + 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(ueId, dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\ + criticalExtensions.choice.rrcSetup); - if(ret == ROK) - { - /* encode DL-CCCH message into RRC Container */ - xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg); - memset(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( "\nERROR --> F1AP : Could not encode RRCContainer for DL-CCCH Msg(at %s)\n",\ - encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); - return RFAILED; - } - else - { - DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRCContainer for DL-CCCH Msg\n"); - for(int i = 0; i< encBufSize; i++) - { - DU_LOG("%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("\nERROR --> F1AP: Memory Alloc failed for RRC Setup Msg at fillDlCcchRrcMsg()"); - ret = RFAILED; - } - } - else - { - DU_LOG("\nERROR --> F1AP: Memory Alloc failed for RRC Msg at fillDlCcchRrcMsg()"); - ret = RFAILED; - } + if(ret == ROK) + { + /* encode DL-CCCH message into RRC Container */ + xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg); + memset(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( "\nERROR --> F1AP : Could not encode RRCContainer for DL-CCCH Msg(at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + return RFAILED; + } + else + { + DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRCContainer for DL-CCCH Msg\n"); + for(int i = 0; i< encBufSize; i++) + { + DU_LOG("%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("\nERROR --> F1AP: Memory Alloc failed for RRC Setup Msg at fillDlCcchRrcMsg()"); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> F1AP: Memory Alloc failed for RRC Msg at fillDlCcchRrcMsg()"); + ret = RFAILED; + } } else { @@ -1527,14 +1527,14 @@ uint8_t fillDlDcchRrcMsg(RRCContainer_t *rrcContainer) * * ****************************************************************/ -uint8_t BuildDLRRCContainer(uint8_t rrcMsgType, RRCContainer_t *rrcContainer) +uint8_t BuildDLRRCContainer(uint8_t ueId, uint8_t rrcMsgType, RRCContainer_t *rrcContainer) { uint8_t ret, bufLen; ret =ROK; if(rrcMsgType == RRC_SETUP) { - ret = fillDlCcchRrcMsg(rrcContainer); + ret = fillDlCcchRrcMsg(ueId, rrcContainer); if(ret == RFAILED) DU_LOG("\nERROR --> F1AP: Failed to fill DL-CCCH Msg at RRC SETUP"); } @@ -1598,7 +1598,7 @@ uint8_t BuildDLRRCContainer(uint8_t rrcMsgType, RRCContainer_t *rrcContainer) * RFAILED - failure * * ****************************************************************/ -uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) +uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t ueId, uint8_t srbId, uint8_t rrcMsgType) { uint8_t elementCnt = 0; uint8_t ieId; @@ -1669,8 +1669,8 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) 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; + DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = ueId; /* GNB DU UE F1AP ID */ idx++; @@ -1678,8 +1678,8 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) 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; + DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; + dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = ueId; /* SRBID */ idx++; @@ -1694,8 +1694,8 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) 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(rrcMsgType, &dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer); + DLRRCMessageTransferIEs__value_PR_RRCContainer; + BuildDLRRCContainer(ueId, rrcMsgType, &dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer); xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg); @@ -1748,10 +1748,10 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType) * * ****************************************************************/ -uint8_t setDlRRCMsgType() +uint8_t setDlRRCMsgType(uint8_t ueId) { uint8_t rrcMsgType = 0; - switch(f1apMsgDb.dlRrcMsgCount) + switch(ueCb[ueId -1].f1apMsgDb.dlRrcMsgCount) { case RRC_SETUP: rrcMsgType = RRC_SETUP; @@ -1796,7 +1796,7 @@ uint8_t setDlRRCMsgType() uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg) { - uint8_t idx, rrcMsgType; + uint8_t idx, rrcMsgType, gnbDuUeF1apId; uint8_t ret =ROK; InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP; DU_LOG("\nINFO --> F1AP : filling the required values in DB in procInitULRRCMsg"); @@ -1807,49 +1807,51 @@ uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg) { 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("\nINFO --> 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("\nERROR --> Failed to receive Du to Cu RRC Container "); - ret = RFAILED; - } - break; - } - default: - DU_LOG("\nERROR --> Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id); - break; + case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: + gnbDuUeF1apId = initULRRCMsg->protocolIEs.list.array[idx]->value.choice.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("\nINFO --> Received Du to Cu RRC Container "); + ueCb[gnbDuUeF1apId-1].ueId = gnbDuUeF1apId; + ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.size; + CU_ALLOC(ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.buf, \ + ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.size); + if(ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.buf != NULLP) + { + memcpy(ueCb[gnbDuUeF1apId-1].f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\ + .list.array[idx]->value.choice.DUtoCURRCContainer.buf, ueCb[gnbDuUeF1apId-1].f1apMsgDb\ + .duToCuContainer.size); + } + } + else + { + DU_LOG("\nERROR --> Failed to receive Du to Cu RRC Container "); + ret = RFAILED; + } + break; + } + default: + DU_LOG("\nERROR --> Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id); + break; } } if(ret == ROK) { - f1apMsgDb.dlRrcMsgCount++; - rrcMsgType = setDlRRCMsgType(); - ret = BuildAndSendDLRRCMessageTransfer(SRB0, rrcMsgType); + ueCb[gnbDuUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; + rrcMsgType = setDlRRCMsgType(gnbDuUeF1apId); + ret = BuildAndSendDLRRCMessageTransfer(gnbDuUeF1apId, SRB0, rrcMsgType); } return ret; } @@ -2236,7 +2238,7 @@ uint8_t BuildULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo) ulInfo->list.array[idx]->uLUPTNLInformation.choice.gTPTunnel->\ gTP_TEID.buf[2] = 0; ulInfo->list.array[idx]->uLUPTNLInformation.choice.gTPTunnel->\ - gTP_TEID.buf[3] = 1; + gTP_TEID.buf[3] = cuCfgParams.egtpParams.currTunnelId++; return ROK; }/*End of BuildULTnlInfo*/ @@ -6465,6 +6467,27 @@ uint8_t BuildAndSendUeContextSetupReq(uint8_t cuUeF1apId, uint8_t duUeF1apId, \ return ret; }/* End of BuildAndSendUeContextSetupReq*/ + +uint8_t procUeContextSetupResponse(F1AP_PDU_t *f1apMsg) +{ + uint8_t idx, duUeF1apId; + UEContextSetupResponse_t *ueCtxtSetupRsp; + ueCtxtSetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse; + + for(idx=0; idx < ueCtxtSetupRsp->protocolIEs.list.count; idx++) + { + switch(ueCtxtSetupRsp->protocolIEs.list.array[idx]->id) + { + case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID: + { + duUeF1apId = ueCtxtSetupRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID; + break; + } + } + } + ueCb[duUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; /* keeping DL RRC Msg Count */ +} + /**************************************************************** * @brief Function to process Ul Rrc Msg received from DU * @@ -6530,12 +6553,12 @@ uint8_t procUlRrcMsg(F1AP_PDU_t *f1apMsg) } if(srbId == 1) { - f1apMsgDb.dlRrcMsgCount++; - rrcMsgType = setDlRRCMsgType(); + ueCb[duUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; + rrcMsgType = setDlRRCMsgType(duUeF1apId); if(rrcMsgType == REGISTRATION_ACCEPT) { - DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Registration Accept"); - ret = BuildAndSendDLRRCMessageTransfer(srbId, rrcMsgType); + DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Registration Accept"); + ret = BuildAndSendDLRRCMessageTransfer(duUeF1apId, srbId, rrcMsgType); } if(rrcMsgType == UE_CONTEXT_SETUP_REQ) { @@ -6545,19 +6568,19 @@ uint8_t procUlRrcMsg(F1AP_PDU_t *f1apMsg) } if(rrcMsgType == SECURITY_MODE_COMPLETE) { - /* To trigger the DL RRC Msg for RRC Reconfig */ - f1apMsgDb.dlRrcMsgCount++; - rrcMsgType = setDlRRCMsgType(); - if(rrcMsgType == RRC_RECONFIG) - { - DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Reconfig"); - BuildAndSendDLRRCMessageTransfer(srbId, rrcMsgType); - } + /* To trigger the DL RRC Msg for RRC Reconfig */ + ueCb[duUeF1apId-1].f1apMsgDb.dlRrcMsgCount++; + rrcMsgType = setDlRRCMsgType(duUeF1apId); + if(rrcMsgType == RRC_RECONFIG) + { + DU_LOG("\nINFO --> F1AP: Sending DL RRC MSG for RRC Reconfig"); + BuildAndSendDLRRCMessageTransfer(duUeF1apId, srbId, rrcMsgType); + } } if(rrcMsgType == UE_CONTEXT_MOD_REQ) { DU_LOG("\nINFO --> F1AP: Sending UE Context Modification Request"); - BuildAndSendUeContextModificationReq(); + BuildAndSendUeContextModificationReq(duUeF1apId); } } return ret; @@ -6845,7 +6868,7 @@ uint8_t BuildUlTnlInfoforDrb2(ULUPTNLInformation_ToBeSetup_List_t *ulInfo) ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\ gTP_TEID.buf[2] = 0; ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\ - gTP_TEID.buf[3] = 2; + gTP_TEID.buf[3] = cuCfgParams.egtpParams.currTunnelId++; return ROK; }/*End of BuildULTnlInfo*/ @@ -7239,7 +7262,7 @@ void FreeUeContextModicationRequest(F1AP_PDU_t *f1apMsg) * RFAILED - failure * * ****************************************************************/ -uint8_t BuildAndSendUeContextModificationReq() +uint8_t BuildAndSendUeContextModificationReq(uint8_t ueId) { uint8_t ieIdx = 0; uint8_t elementCnt = 0; @@ -7300,16 +7323,16 @@ uint8_t BuildAndSendUeContextModificationReq() ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject; ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present = \ - UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; - ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =CU_ID; + UEContextModificationRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; + ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = ueId; ieIdx++; ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject; ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present=\ - UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; - ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =DU_ID; - + UEContextModificationRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; + ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = ueId; + ieIdx++; ueContextModifyReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_ToBeSetupMod_List; ueContextModifyReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject; @@ -7618,7 +7641,7 @@ uint8_t procUeContextReleaseReq(F1AP_PDU_t *f1apMsg) uint8_t procGnbDuUpdate(F1AP_PDU_t *f1apMsg) { bool cellToBeDelete = false; - uint8_t ieIdx = 0; + uint8_t ieIdx = 0, ueIdx = 0; GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP; duCfgUpdate = &f1apMsg->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate; @@ -7657,7 +7680,11 @@ uint8_t procGnbDuUpdate(F1AP_PDU_t *f1apMsg) } else { - memset(&f1apMsgDb, 0, sizeof(F1apMsgDb)); + for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++) + { + CU_FREE(ueCb[ueIdx].f1apMsgDb.duToCuContainer.buf, ueCb[ueIdx].f1apMsgDb.duToCuContainer.size); + memset(&ueCb[ueIdx], 0, sizeof(UeCb)); + } } return ROK; @@ -7800,7 +7827,7 @@ void F1APMsgHdlr(Buffer *mBuf) case SuccessfulOutcome__value_PR_UEContextSetupResponse: { DU_LOG("\nINFO --> F1AP : UE ContextSetupResponse received"); - f1apMsgDb.dlRrcMsgCount++; /* keeping DL RRC Msg Count */ + procUeContextSetupResponse(f1apMsg); break; } case SuccessfulOutcome__value_PR_UEContextModificationResponse: diff --git a/src/cu_stub/cu_f1ap_msg_hdl.h b/src/cu_stub/cu_f1ap_msg_hdl.h index 042780e65..ba7092709 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.h +++ b/src/cu_stub/cu_f1ap_msg_hdl.h @@ -73,9 +73,16 @@ typedef struct f1apDb OCTET_STRING_t duToCuContainer; }F1apMsgDb; -F1apMsgDb f1apMsgDb; +typedef struct ueInfo +{ + uint8_t ueId; + F1apMsgDb f1apMsgDb; +}UeCb; + +UeCb ueCb[MAX_NUM_UE]; + void F1APMsgHdlr(Buffer *mBuf); -uint8_t BuildAndSendUeContextModificationReq(); +uint8_t BuildAndSendUeContextModificationReq(uint8_t ueId); uint8_t BuildAndSendUeContextReleaseCommand(uint8_t cuUeF1apId, uint8_t duUeF1apId); uint8_t BuildAndSendF1ResetReq(); /********************************************************************** diff --git a/src/cu_stub/cu_stub.c b/src/cu_stub/cu_stub.c index 6c5980047..ff9da8e90 100644 --- a/src/cu_stub/cu_stub.c +++ b/src/cu_stub/cu_stub.c @@ -216,6 +216,7 @@ void readCuCfg() cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du; cuCfgParams.egtpParams.destPort = DU_EGTP_PORT; cuCfgParams.egtpParams.minTunnelId = 0; + cuCfgParams.egtpParams.currTunnelId = cuCfgParams.egtpParams.minTunnelId; cuCfgParams.egtpParams.maxTunnelId = 10; } /* End of readCuCfg */ diff --git a/src/cu_stub/cu_stub.h b/src/cu_stub/cu_stub.h index 342a68040..74d684718 100644 --- a/src/cu_stub/cu_stub.h +++ b/src/cu_stub/cu_stub.h @@ -66,6 +66,7 @@ typedef struct egtpParams uint16_t localPort; SctpIpAddr destIp; uint16_t destPort; + uint32_t currTunnelId; uint32_t minTunnelId; uint32_t maxTunnelId; }EgtpParams; diff --git a/src/du_app/du_f1ap_msg_hdl.c b/src/du_app/du_f1ap_msg_hdl.c index 36a9c6cfb..67c382fea 100644 --- a/src/du_app/du_f1ap_msg_hdl.c +++ b/src/du_app/du_f1ap_msg_hdl.c @@ -10098,6 +10098,7 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg) DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()"); ret = RFAILED; } + break; } else ueCbFound = false; @@ -12567,12 +12568,13 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg) } } } + break; } - else - { - DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId "); - ret = RFAILED; - } + } + if(ueIdx >= duCb.actvCellLst[cellIdx]->numActvUes) + { + DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId "); + ret = RFAILED; } } break; diff --git a/src/phy_stub/phy_stub.h b/src/phy_stub/phy_stub.h index afb8b2233..577a5ab23 100644 --- a/src/phy_stub/phy_stub.h +++ b/src/phy_stub/phy_stub.h @@ -29,14 +29,30 @@ bool slotIndicationStarted; uint16_t sfnValue; uint16_t slotValue; -bool rachIndSent; -bool msg3Sent; -bool msg5ShortBsrSent; -bool msg5Sent; -bool dlDedMsg; -bool msgSecurityModeComp; -bool msgRrcReconfiguration; -bool msgRegistrationComp; + +/* UE specific information */ +typedef struct ueCb +{ + uint8_t ueId; + uint16_t crnti; + bool rachIndSent; + bool msg3Sent; + bool msg5ShortBsrSent; + bool msg5Sent; + bool dlDedMsg; + bool msgSecurityModeComp; + bool msgRrcReconfiguration; + bool msgRegistrationComp; +}UeCb; + +/* Database to store information for all UE */ +typedef struct ueDb +{ + uint8_t numActvUe; + UeCb ueCb[MAX_NUM_UE]; +}UeDb; + +UeDb ueDb; typedef enum { diff --git a/src/phy_stub/phy_stub_msg_hdl.c b/src/phy_stub/phy_stub_msg_hdl.c index 502f3a302..dd361405c 100644 --- a/src/phy_stub/phy_stub_msg_hdl.c +++ b/src/phy_stub/phy_stub_msg_hdl.c @@ -245,14 +245,7 @@ void l1HdlParamReq(uint32_t msgLen, void *msg) void l1HdlConfigReq(uint32_t msgLen, void *msg) { - rachIndSent = false; - msg3Sent = false; - msg5ShortBsrSent = false; - msg5Sent = false; - dlDedMsg = false; - msgSecurityModeComp = false; - msgRrcReconfiguration = false; - msgRegistrationComp = false; + memset(&ueDb, 0, sizeof(UeDb)); #ifdef INTEL_FAPI p_fapi_api_queue_elem_t configReqElem = (p_fapi_api_queue_elem_t)msg; @@ -348,7 +341,7 @@ uint16_t l1BuildAndSendCrcInd(uint16_t slot, uint16_t sfn) * ****************************************************************/ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_t puschPdu) { - uint8_t idx = 0; + uint8_t idx = 0, ueId = 0; fapi_rx_data_indication_t *rxDataInd =NULLP; fapi_pdu_ind_info_t *pduInfo =NULLP; uint8_t *pdu = NULLP; @@ -356,35 +349,38 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_ uint32_t msgLen = 0; MsgType type = 0; - if(!msg3Sent) + GET_UE_IDX(puschPdu.rnti, ueId); + if(!ueDb.ueCb[ueId-1].msg3Sent) { - msg3Sent = true; + ueDb.ueCb[ueId-1].ueId = ueId; + ueDb.ueCb[ueId-1].crnti = puschPdu.rnti; + ueDb.ueCb[ueId-1].msg3Sent = true; type = MSG_TYPE_MSG3; sleep(2); } - else if(!msg5ShortBsrSent) + else if(!ueDb.ueCb[ueId-1].msg5ShortBsrSent) { - msg5ShortBsrSent = true; + ueDb.ueCb[ueId-1].msg5ShortBsrSent = true; type = MSG_TYPE_SHORT_BSR; } - else if(!msg5Sent) + else if(!ueDb.ueCb[ueId-1].msg5Sent) { - msg5Sent = true; + ueDb.ueCb[ueId-1].msg5Sent = true; type = MSG_TYPE_MSG5; } - else if(!msgRegistrationComp) + else if(!ueDb.ueCb[ueId-1].msgRegistrationComp) { - msgRegistrationComp = true; + ueDb.ueCb[ueId-1].msgRegistrationComp = true; type = MSG_TYPE_REGISTRATION_COMPLETE; } - else if(!msgSecurityModeComp) + else if(!ueDb.ueCb[ueId-1].msgSecurityModeComp) { - msgSecurityModeComp = true; + ueDb.ueCb[ueId-1].msgSecurityModeComp = true; type = MSG_TYPE_SECURITY_MODE_COMPLETE; } - else if(!msgRrcReconfiguration) + else if(!ueDb.ueCb[ueId-1].msgRrcReconfiguration) { - msgRrcReconfiguration = true; + ueDb.ueCb[ueId-1].msgRrcReconfiguration = true; type = MSG_TYPE_RRC_RECONFIG_COMPLETE; } else @@ -785,12 +781,7 @@ S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg) } else if(dlTtiReq->pdus[pduCount].pduType == 0) { - DU_LOG("\nINFO --> PHY_STUB: PDCCH PDU"); - if(dlTtiReq->pdus[pduCount].pdu.pdcch_pdu.\ - coreSetType == 1) - { - dlDedMsg = true; - } + DU_LOG("\nINFO --> PHY_STUB: PDCCH PDU"); } else if(dlTtiReq->pdus[pduCount].pduType == 1) { @@ -829,11 +820,13 @@ S16 l1HdlTxDataReq(uint16_t msgLen, void *msg) fapi_tx_data_req_t *txDataReq = (fapi_tx_data_req_t *)(txDataElem +1); DU_LOG("\nINFO --> PHY STUB: TX DATA Request at sfn=%d slot=%d",txDataReq->sfn,txDataReq->slot); +/* if(dlDedMsg) { DU_LOG("\nINFO --> PHY_STUB: TxDataPdu for DED MSG sent"); dlDedMsg = false; } +*/ MAC_FREE(msg, msgLen); #endif return ROK; @@ -1049,11 +1042,22 @@ S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) numPdus--; } - if(rachIndSent == false && ulTtiReq->sfn == 16 && ulTtiReq->slot == 6) + if(ueDb.ueCb[ueDb.numActvUe].rachIndSent == false && ulTtiReq->sfn == 16 && ulTtiReq->slot == 6) + { + ueDb.ueCb[ueDb.numActvUe].rachIndSent = true; + l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn); + ueDb.numActvUe++; + } + + //Following can be enabled to test with a second UE +#if 0 + if(ueDb.ueCb[ueDb.numActvUe].rachIndSent == false && ulTtiReq->sfn == 304 && ulTtiReq->slot == 0) { - rachIndSent = true; + ueDb.ueCb[ueDb.numActvUe].rachIndSent = true; l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn); + ueDb.numActvUe++; } +#endif MAC_FREE(msg, msgLen); #endif @@ -1138,14 +1142,7 @@ S16 l1HdlStopReq(uint32_t msgLen, void *msg) /* Initialize all global variables */ sfnValue = 0; slotValue = 0; - rachIndSent = false; - msg3Sent = false; - msg5ShortBsrSent = false; - msg5Sent = false; - dlDedMsg = false; - msgSecurityModeComp = false; - msgRrcReconfiguration = false; - msgRegistrationComp = false; + memset(&ueDb, 0, sizeof(UeDb)); DU_LOG("\nINFO --> PHY_STUB: Slot Indication is stopped successfully"); MAC_FREE(msg, msgLen); @@ -1160,6 +1157,7 @@ S16 l1HdlStopReq(uint32_t msgLen, void *msg) return ROK; } +#if 0 /******************************************************************* * * @brief Build And Send Rx Data Ind for Msg5 @@ -1263,6 +1261,7 @@ uint8_t l1BuildAndSendMsg5(uint16_t sfn, uint16_t slot) #endif return ROK; } +#endif /******************************************************************* * diff --git a/src/phy_stub/phy_stub_thread_hdl.c b/src/phy_stub/phy_stub_thread_hdl.c index 0eed378c4..4bdea8106 100644 --- a/src/phy_stub/phy_stub_thread_hdl.c +++ b/src/phy_stub/phy_stub_thread_hdl.c @@ -78,14 +78,7 @@ void GenerateTicks() /* Initialize all global variables */ sfnValue = 0; slotValue = 0; - rachIndSent = false; - msg3Sent = false; - msg5ShortBsrSent = false; - msg5Sent = false; - dlDedMsg = false; - msgSecurityModeComp = false; - msgRrcReconfiguration = false; - msgRegistrationComp = false; + memset(&ueDb, 0, sizeof(UeDb)); /* Send Stop indication to MAC */ sleep(1); -- 2.16.6