From 964fd8f1dc9c969e70caf8885332cc086ff22d74 Mon Sep 17 00:00:00 2001 From: "lal.harshita" Date: Fri, 13 May 2022 20:28:16 +0530 Subject: [PATCH] [Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-448]RACH resource release at target DU and UE release at source DU Signed-off-by: lal.harshita Change-Id: I797c5b52a3fcb30c8cb93d360ab7a4a602bedf31 Signed-off-by: lal.harshita --- src/5gnrmac/mac_msg_router.c | 6 ++++ src/5gnrmac/mac_rach.c | 79 ++++++++++++++++++++++++++++++++++++++++++ src/5gnrsch/sch_rach.c | 79 ++++++++++++++++++++++++++++++++++++++++++ src/cm/du_app_mac_inf.c | 80 +++++++++++++++++++++++++++++++++++++++++++ src/cm/du_app_mac_inf.h | 24 ++++++++++--- src/cm/mac_sch_interface.c | 30 ++++++++++++++++ src/cm/mac_sch_interface.h | 20 +++++++++-- src/cu_stub/cu_f1ap_msg_hdl.c | 40 +++++++++++++++++----- src/du_app/du_f1ap_msg_hdl.c | 18 +++++----- src/du_app/du_f1ap_msg_hdl.h | 2 +- src/du_app/du_msg_hdl.c | 57 +++++++++++++++++++++++++----- src/du_app/du_ue_mgr.c | 54 +++++++++++++++++++++++------ src/du_app/du_ue_mgr.h | 1 + 13 files changed, 445 insertions(+), 45 deletions(-) diff --git a/src/5gnrmac/mac_msg_router.c b/src/5gnrmac/mac_msg_router.c index e55c7096f..a34809dbd 100755 --- a/src/5gnrmac/mac_msg_router.c +++ b/src/5gnrmac/mac_msg_router.c @@ -169,6 +169,12 @@ Buffer *mBuf /* message buffer */ unpackMacRachRsrcReq(MacProcRachRsrcReq, pst, mBuf); break; } + case EVENT_MAC_RACH_RESOURCE_REL: + { + /* Process Rach Resource Release */ + unpackMacRachRsrcRel(MacProcRachRsrcRel, pst, mBuf); + break; + } case EVENT_MAC_DL_PCCH_IND: { /* Process Pcch indication */ diff --git a/src/5gnrmac/mac_rach.c b/src/5gnrmac/mac_rach.c index df230dd23..010063100 100644 --- a/src/5gnrmac/mac_rach.c +++ b/src/5gnrmac/mac_rach.c @@ -49,6 +49,14 @@ MacDuRachRsrcRspFunc macDuRachRsrcRspOpts[] = packDuMacRachRsrcRsp /* packing for light weight loosly coupled */ }; +/* Function pointer for sending RACH resource release from MAC to SCH */ +MacSchRachRsrcRelFunc macSchRachRsrcRelOpts[] = +{ + packMacSchRachRsrcRel, /* packing for loosely coupled */ + MacSchRachRsrcRel, /* packing for tightly coupled */ + packMacSchRachRsrcRel /* packing for light weight loosely coupled */ +}; + /******************************************************************* * * @brief Sends RACH indication to SCH @@ -382,6 +390,77 @@ uint8_t MacProcSchRachRsrcRsp(Pst *pst, SchRachRsrcRsp *schRachRsrcRsp) return (*macDuRachRsrcRspOpts[rspPst.selector])(&rspPst, rachRsrcRsp); } + +/******************************************************************* + * + * @brief Processes RACH Resource release from DU APP + * + * @details + * + * Function : MacProcRachRsrcRel + * + * Functionality: Processes RACH resource release from DU APP. + * Fills and sends RACH resource release towards SCH. + * + * @params[in] Post structure + * RACH resource release + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t MacProcRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel) +{ + uint8_t ret = RFAILED; + uint16_t cellIdx = 0; + Pst schPst; + MacCellCb *cellCb = NULLP; + MacUeCb *ueCb = NULLP; + SchRachRsrcRel *schRachRsrcRel = NULLP; + + DU_LOG("\nINFO --> MAC : Recieved RACH Resource Release for Cell ID [%d] UE ID [%d]",\ + rachRsrcRel->cellId, rachRsrcRel->ueId); + + /* Fetch Cell Cb */ + GET_CELL_IDX(rachRsrcRel->cellId, cellIdx); + if(macCb.macCell[cellIdx] && (macCb.macCell[cellIdx]->cellId == rachRsrcRel->cellId)) + { + cellCb = macCb.macCell[cellIdx]; + + /* Fetch UE Cb */ + if(cellCb->ueCb[rachRsrcRel->ueId-1].ueId == rachRsrcRel->ueId) + { + ueCb = &cellCb->ueCb[rachRsrcRel->ueId-1]; + /* Allocate memory to RACH resource release to be sent to SCH */ + MAC_ALLOC(schRachRsrcRel, sizeof(SchRachRsrcRel)); + if(schRachRsrcRel) + { + /* Fill SCH RACH resource release from information received from DU APP to MAC */ + memset(schRachRsrcRel, 0, sizeof(SchRachRsrcRel)); + schRachRsrcRel->cellId = rachRsrcRel->cellId; + schRachRsrcRel->crnti = ueCb->crnti; + memcpy(&schRachRsrcRel->cfraResource, &ueCb->cfraResource, sizeof(schRachRsrcRel->cfraResource)); + + /* Release RACH resources at MAC */ + memset(&ueCb->cfraResource, 0, sizeof(MacCfraResource)); + + /* Send RACH resource release from MAC to SCH */ + FILL_PST_MAC_TO_SCH(schPst, EVENT_RACH_RESOURCE_RELEASE_TO_SCH); + ret = (*macSchRachRsrcRelOpts[schPst.selector])(&schPst, schRachRsrcRel); + } + else + DU_LOG("\nERROR --> MAC : Memory allocation failed for RACH resource release to SCH"); + } + else + DU_LOG("\nERROR --> MAC : UE ID [%d] not found", rachRsrcRel->ueId); + } + else + DU_LOG("\nERROR --> MAC : Cell ID [%d] not found", rachRsrcRel->cellId); + + /* Free sharable buffer used to send RACH reource release from DU APP to MAC */ + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rachRsrcRel, sizeof(MacRachRsrcRel)); + return ret; +} + /* spec-38.211 Table 6.3.3.1-7 */ uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX] = {0, 2, 4, 6, 8, 10, 12, 13, 15, 17, 19, 23, 27, 34, 46, 69}; diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index 41a8f8a8e..2f3f4f953 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -977,6 +977,85 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl return ROK; } + /* @brief Process RACH resource release after CFRA + * + * @details + * + * Function : MacSchRachRsrcRel + * + * This function processes RACH resorce release + * from MAC after CFRA. It releases the dedicated + * preamble alloted to the UE + * + * @param[in] Post structure + * @param[in] RACH resource release + * @return ROK + * RFAILED + */ +uint8_t MacSchRachRsrcRel(Pst *pst, SchRachRsrcRel *schRachRsrcRel) +{ + uint8_t ret = ROK; + uint8_t ssbIdx = 0, cfraSsbIdx = 0; + uint16_t cellIdx = 0; + Inst inst = pst->dstInst - SCH_INST_START; + SchCellCb *cellCb = NULLP; + SchUeCb *ueCb = NULLP; + + DU_LOG("\nINFO --> SCH : Received RACH resource release for Cell ID [%d] CRNTI [%d]", \ + schRachRsrcRel->cellId, schRachRsrcRel->crnti); + + /* Fetch Cell CB */ + for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++) + { + if((schCb[inst].cells[cellIdx]) && (schCb[inst].cells[cellIdx]->cellId == schRachRsrcRel->cellId)) + { + cellCb = schCb[inst].cells[cellIdx]; + break; + } + } + + if(cellCb) + { + /* Fetch UE CB */ + ueCb = schGetUeCb(cellCb, schRachRsrcRel->crnti); + if(ueCb->crnti != schRachRsrcRel->crnti) + { + DU_LOG("\nERROR --> SCH : CRNTI [%d] not found", schRachRsrcRel->crnti); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> SCH : Cell ID [%d] not found", schRachRsrcRel->cellId); + ret = RFAILED; + } + + /* Free SSB resource if no failure has occurred until this step */ + if(ret == ROK) + { + for(ssbIdx = 0; ssbIdx < schRachRsrcRel->cfraResource.numSsb; ssbIdx++) + { + /* Search each ssbIdx entry in UE Cb */ + for(cfraSsbIdx = 0; cfraSsbIdx < ueCb->cfraResource.numSsb; cfraSsbIdx++) + { + if(ueCb->cfraResource.ssbResource[cfraSsbIdx].ssbIdx == schRachRsrcRel->cfraResource.ssbResource[ssbIdx].ssbIdx) + { + /* If ssbIdx entry is found in UE CB, free dedicated resources + * for this ssbIdx */ + UNSET_ONE_BIT(ueCb->cfraResource.ssbResource[cfraSsbIdx].raPreambleIdx, cellCb->dedPreambleBitMap); + memset(&ueCb->cfraResource.ssbResource[cfraSsbIdx], 0, sizeof(SchCfraSsbResource)); + ueCb->cfraResource.numSsb--; + break; + } + } + } /* End of for */ + } /* End of if */ + + /* Free RACH resource release memory allocated by MAC */ + SCH_FREE(schRachRsrcRel, sizeof(SchRachRsrcRel)); + return ret; +} + /********************************************************************** End of file **********************************************************************/ diff --git a/src/cm/du_app_mac_inf.c b/src/cm/du_app_mac_inf.c index 7b56931d0..775508d82 100644 --- a/src/cm/du_app_mac_inf.c +++ b/src/cm/du_app_mac_inf.c @@ -983,6 +983,86 @@ uint8_t unpackMacRachRsrcReq(DuMacRachRsrcReq func, Pst *pst, Buffer *mBuf) return RFAILED; } +/******************************************************************* + * + * @brief Packs and Sends RACH Resource release from DUAPP to MAC + * + * @details + * + * Function : packDuMacRachRsrcRel + * + * Functionality: + * Packs and Sends RACH Resource release from DU APP to MAC + * + * + * @params[in] Post structure pointer + * MacRachRsrcRel pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packDuMacRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nERROR --> MAC : Memory allocation failed at packDuMacRachRsrcRel"); + return RFAILED; + } + /* pack the address of the structure */ + CMCHKPK(oduPackPointer, (PTR)rachRsrcRel, mBuf); + } + else + { + DU_LOG("\nERROR --> MAC: Only LWLC supported for packDuMacRachRsrcRel"); + return RFAILED; + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks RACH Resource Release received from DU APP + * + * @details + * + * Function : unpackMacRachRsrcRel + * + * Functionality: + * Unpacks RACH Resource Release received from DU APP + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacRachRsrcRel(DuMacRachRsrcRel func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + MacRachRsrcRel *rachRsrcRel; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&rachRsrcRel, mBuf); + ODU_PUT_MSG_BUF(mBuf); + return (*func)(pst, rachRsrcRel); + } + else + { + /* Nothing to do for other selectors */ + DU_LOG("\nERROR --> DU APP : Only LWLC supported for RACH Resource Release "); + ODU_PUT_MSG_BUF(mBuf); + } + + return RFAILED; +} + /******************************************************************* * * @brief Packs and Sends RACH Resource response from MAC to DU APP diff --git a/src/cm/du_app_mac_inf.h b/src/cm/du_app_mac_inf.h index d42617f2e..6221e5b88 100644 --- a/src/cm/du_app_mac_inf.h +++ b/src/cm/du_app_mac_inf.h @@ -82,7 +82,8 @@ #define EVENT_MAC_SLOT_IND 220 #define EVENT_MAC_RACH_RESOURCE_REQ 221 #define EVENT_MAC_RACH_RESOURCE_RSP 222 -#define EVENT_MAC_DL_PCCH_IND 223 +#define EVENT_MAC_RACH_RESOURCE_REL 223 +#define EVENT_MAC_DL_PCCH_IND 224 #define BSR_PERIODIC_TIMER_SF_10 10 #define BSR_RETX_TIMER_SF_320 320 @@ -1325,6 +1326,13 @@ typedef struct macRachRsrcRsp MacCfraResource cfraResource; }MacRachRsrcRsp; +typedef struct macRachRsrcRel +{ + uint16_t cellId; + uint16_t ueId; + uint16_t crnti; +}MacRachRsrcRel; + typedef struct ueDelete { uint16_t cellId; @@ -1453,21 +1461,26 @@ typedef uint8_t (*MacDuUeCfgRspFunc) ARGS(( Pst *pst, MacUeCfgRsp *cfgRsp)); -/* UE Reconfig Request from DU APP to MAC*/ +/* UE Reconfig Request from DU APP to MAC */ typedef uint8_t (*DuMacUeReconfigReq) ARGS(( Pst *pst, MacUeCfg *ueCfg )); -/* RACH Resource Request from DU APP to MAC*/ +/* RACH Resource Request from DU APP to MAC */ typedef uint8_t (*DuMacRachRsrcReq) ARGS(( Pst *pst, MacRachRsrcReq *rachRsrcReq)); -/* RACH Resource Response from MAC to DU APP*/ +/* RACH Resource Response from MAC to DU APP */ typedef uint8_t (*MacDuRachRsrcRspFunc) ARGS(( Pst *pst, MacRachRsrcRsp *rachRsrcRsp)); +/* RACH Resource Release from DU APP to MAC */ +typedef uint8_t (*DuMacRachRsrcRel) ARGS(( + Pst *pst, + MacRachRsrcRel *rachRsrcRel)); + /* UE Delete Request from DU APP to MAC*/ typedef uint8_t (*DuMacUeDeleteReq) ARGS(( Pst *pst, @@ -1555,6 +1568,9 @@ uint8_t MacProcRachRsrcReq(Pst *pst, MacRachRsrcReq *rachRsrcReq); uint8_t packDuMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp); uint8_t unpackDuMacRachRsrcRsp(MacDuRachRsrcRspFunc func, Pst *pst, Buffer *mBuf); uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp); +uint8_t packDuMacRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel); +uint8_t unpackMacRachRsrcRel(DuMacRachRsrcRel func, Pst *pst, Buffer *mBuf); +uint8_t MacProcRachRsrcRel(Pst *pst, MacRachRsrcRel *rachRsrcRel); uint8_t packDuMacUeDeleteReq(Pst *pst, MacUeDelete *ueDelete); uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete); uint8_t unpackMacUeDeleteReq(DuMacUeDeleteReq func, Pst *pst, Buffer *mBuf); diff --git a/src/cm/mac_sch_interface.c b/src/cm/mac_sch_interface.c index 249a8e6ed..ec64f2978 100644 --- a/src/cm/mac_sch_interface.c +++ b/src/cm/mac_sch_interface.c @@ -415,6 +415,36 @@ uint8_t packSchRachRsrcRsp(Pst *pst, SchRachRsrcRsp *schRachRsrcRsp) return ROK; } +/******************************************************************* + * + * @brief Pack and Send RACH resource Release from MAC to SCH + * + * @details + * + * Function : packMacSchRachRsrcRel + * + * Functionality: + * Pack and Send RACH resouece Release from MAC to SCH + * + * @params[in] Post structure + * RACH resource release + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacSchRachRsrcRel(Pst *pst, SchRachRsrcRel *schRachRsrcRel) +{ + if((pst->selector == ODU_SELECTOR_LC) || (pst->selector == ODU_SELECTOR_LC)) + { + /* TODO */ + } + else + { + return RFAILED; + } + return ROK; +} + /******************************************************************* * * @brief Pack and Send UE Delete Request from MAC to SCH diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index c588951c4..ddc0410ed 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -41,10 +41,11 @@ #define EVENT_SLICE_CFG_RSP_TO_MAC 22 #define EVENT_SLICE_RECFG_REQ_TO_SCH 23 #define EVENT_SLICE_RECFG_RSP_TO_MAC 24 -#define EVENT_RACH_RESOURCE_REQUEST_TO_SCH 25 +#define EVENT_RACH_RESOURCE_REQUEST_TO_SCH 25 #define EVENT_RACH_RESOURCE_RESPONSE_TO_MAC 26 -#define EVENT_PAGING_IND_TO_SCH 27 -#define EVENT_DL_PAGING_ALLOC 28 +#define EVENT_RACH_RESOURCE_RELEASE_TO_SCH 27 +#define EVENT_PAGING_IND_TO_SCH 28 +#define EVENT_DL_PAGING_ALLOC 29 /*macros*/ #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */ @@ -1638,6 +1639,13 @@ typedef struct schRachRsrcRsp SchCfraResource cfraResource; }SchRachRsrcRsp; +typedef struct schRachRsrcRel +{ + uint16_t cellId; + uint16_t crnti; + SchCfraResource cfraResource; +}SchRachRsrcRel; + typedef struct schUeDelete { uint16_t cellId; @@ -1804,6 +1812,10 @@ typedef uint8_t (*SchRachRsrcRspFunc) ARGS(( Pst *pst, /* Post structure */ SchRachRsrcRsp *schRachRsrcRsp)); /* RACH resource request to MAC */ +typedef uint8_t (*MacSchRachRsrcRelFunc) ARGS(( + Pst *pst, /* Post structure */ + SchRachRsrcRel *schRachRsrcRel)); /* RACH resource release to SCH */ + typedef uint8_t (*MacSchUeDeleteReqFunc) ARGS(( Pst *pst, /* Post structure */ SchUeDelete *schUeDel)); /*Scheduler UE Del*/ @@ -1879,6 +1891,8 @@ uint8_t packMacSchRachRsrcReq(Pst *pst, SchRachRsrcReq *schRachRsrcReq); uint8_t MacSchRachRsrcReq(Pst *pst, SchRachRsrcReq *schRachRsrcReq); uint8_t packSchRachRsrcRsp(Pst *pst, SchRachRsrcRsp *schRachRsrcRsp); uint8_t MacProcSchRachRsrcRsp(Pst *pst, SchRachRsrcRsp *schRachRsrcRsp); +uint8_t packMacSchRachRsrcRel(Pst *pst, SchRachRsrcRel *schRachRsrcRel); +uint8_t MacSchRachRsrcRel(Pst *pst, SchRachRsrcRel *schRachRsrcRel); uint8_t packMacSchUeDeleteReq(Pst *pst, SchUeDelete *schUeDel); uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete); uint8_t packSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *delRsp); diff --git a/src/cu_stub/cu_f1ap_msg_hdl.c b/src/cu_stub/cu_f1ap_msg_hdl.c index 4f2b34fe2..aef220d44 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.c +++ b/src/cu_stub/cu_f1ap_msg_hdl.c @@ -9411,12 +9411,12 @@ uint8_t procUeContextSetupResponse(uint32_t duId, F1AP_PDU_t *f1apMsg) uint8_t procUlRrcMsg(uint32_t duId, F1AP_PDU_t *f1apMsg) { - uint8_t idx, ret, srbId, rrcMsgType, duIdx=0; - uint8_t cuUeF1apId, duUeF1apId; - uint8_t *rrcContainer = NULLP; - uint16_t rrcContLen; - DuDb *duDb; - CuUeCb *ueCb; + uint8_t idx = 0, ret = ROK, srbId = 0, rrcMsgType = 0, duIdx=0; + uint8_t *rrcContainer = NULLP; + uint16_t rrcContLen = 0; + uint32_t cuUeF1apId = 0, duUeF1apId = 0; + DuDb *duDb = NULLP; + CuUeCb *ueCb = NULLP; ULRRCMessageTransfer_t *ulRrcMsg = NULLP; ret = ROK; @@ -9453,8 +9453,32 @@ uint8_t procUlRrcMsg(uint32_t duId, F1AP_PDU_t *f1apMsg) memcpy(rrcContainer, ulRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf, rrcContLen); if(duDb->ueCb[duUeF1apId-1].state == UE_HANDOVER_IN_PROGRESS) - return; - + { + uint8_t ueIdx = 0; + uint8_t srcDuId = duDb->ueCb[duUeF1apId-1].hoInfo.sourceDuId; + DuDb *srcDuDb = NULLP; + + /* In target DU DB, mark UE as active and delete HO info */ + duDb->ueCb[duUeF1apId-1].state = UE_ACTIVE; + memset(&duDb->ueCb[duUeF1apId-1].hoInfo, 0, sizeof(HandoverInfo)); + + /* Release UE context in source DU because the UE is now + * attached to target DU */ + SEARCH_DU_DB(duIdx, srcDuId, srcDuDb); + for(ueIdx = 0; ueIdx < srcDuDb->numUe; ueIdx++) + { + if(srcDuDb->ueCb[ueIdx].gnbCuUeF1apId == cuUeF1apId) + { + ret = BuildAndSendUeContextReleaseCommand(srcDuId, srcDuDb->ueCb[ueIdx].gnbCuUeF1apId, srcDuDb->ueCb[ueIdx].gnbDuUeF1apId); + if(ret != ROK) + { + DU_LOG("\nINFO --> F1AP: Failed to build and send UE context release command to source DU Id [%d]", srcDuId); + } + break; + } + } + return ret; + } break; } diff --git a/src/du_app/du_f1ap_msg_hdl.c b/src/du_app/du_f1ap_msg_hdl.c index c269242a8..ecd15d2b8 100644 --- a/src/du_app/du_f1ap_msg_hdl.c +++ b/src/du_app/du_f1ap_msg_hdl.c @@ -2533,16 +2533,14 @@ void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg) * RFAILED - failure * * ****************************************************************/ -uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \ +uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb *ueCb, uint8_t lcId, \ uint16_t msgLen, uint8_t *rrcMsg) { - uint8_t elementCnt =0; - uint8_t idx1 =0; - uint8_t idx =0; - F1AP_PDU_t *f1apMsg = NULLP; - ULRRCMessageTransfer_t *ulRRCMsg = NULLP; - asn_enc_rval_t encRetVal; /* Encoder return value */ - uint8_t ret =RFAILED; + uint8_t elementCnt=0, idx1=0, idx=0; + uint8_t ret = RFAILED; + F1AP_PDU_t *f1apMsg = NULLP; + ULRRCMessageTransfer_t *ulRRCMsg = NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ memset(&encRetVal, 0, sizeof(asn_enc_rval_t)); @@ -2597,7 +2595,7 @@ uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \ ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject; ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \ ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId; + ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb->gnbCuUeF1apId; /*GNB DU UE F1AP ID*/ idx1++; @@ -2605,7 +2603,7 @@ uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \ ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject; ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \ ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId; + ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb->gnbDuUeF1apId; /*SRBID*/ idx1++; diff --git a/src/du_app/du_f1ap_msg_hdl.h b/src/du_app/du_f1ap_msg_hdl.h index bccf1cef2..baaf6170c 100644 --- a/src/du_app/du_f1ap_msg_hdl.h +++ b/src/du_app/du_f1ap_msg_hdl.h @@ -32,7 +32,7 @@ uint8_t BuildAndSendF1SetupReq(); uint8_t BuildAndSendDUConfigUpdate(); uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer); -uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, uint16_t msgLen, uint8_t *rrcMsg); +uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb *ueCb, uint8_t lcId, uint16_t msgLen, uint8_t *rrcMsg); uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfg, MacUeCfg *storedMacUeCfg, void *cellGrp); void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg); uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueId); diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index 72e5949cc..c7c9bc3b5 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -1707,22 +1707,63 @@ uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo) * ****************************************************************/ uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo) { + uint8_t ret = ROK; DuCellCb *cellCb = NULLP; - DuUeCb ueCb ={0}; + DuUeCb *ueCb = NULLP; - if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK) - return RFAILED; - if(ulRrcMsgInfo->ueId > 0) + duGetCellCb(ulRrcMsgInfo->cellId, &cellCb); + if(cellCb) { - ueCb = cellCb->ueCb[ulRrcMsgInfo->ueId -1]; + if(ulRrcMsgInfo->ueId > 0) + { + if(cellCb->ueCb[ulRrcMsgInfo->ueId -1].gnbDuUeF1apId == ulRrcMsgInfo->ueId) + ueCb = &cellCb->ueCb[ulRrcMsgInfo->ueId -1]; + if(ueCb) + { + /* If UL message is received for a UE in handover, it signifies that UE is now + * attached to GNB. Hence marking this UE as active and requesting MAC to + * release the dedicated RACH resources */ + if(ueCb->ueState == UE_HANDIN_IN_PROGRESS) + { + ueCb->ueState = UE_ACTIVE; + cellCb->numActvUes++; + + /* Release RACH resources */ + memset(&ueCb->cfraResource, 0, sizeof(MacCfraResource)); + if(duBuildAndSendRachRsrcRelToMac(ulRrcMsgInfo->cellId, ueCb) != ROK) + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to send RACH resource release to MAC"); + } + } - BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg); + if(BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg) != ROK) + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to build and send UL RRC Message Transfer"); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : UE ID [%d] not found", ulRrcMsgInfo->ueId); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Invalid UE ID [%d]", ulRrcMsgInfo->ueId); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Cell ID [%d] not found", ulRrcMsgInfo->cellId); + ret = RFAILED; + } DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen); DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo)); - } - return ROK; + return ret; } /******************************************************************* diff --git a/src/du_app/du_ue_mgr.c b/src/du_app/du_ue_mgr.c index 842e6a060..c2f7f8692 100644 --- a/src/du_app/du_ue_mgr.c +++ b/src/du_app/du_ue_mgr.c @@ -95,6 +95,13 @@ DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] = packRlcDlUserDataToRlc /* Light weight-loose coupling */ }; +DuMacRachRsrcRel packMacRachRsrcRelOpts[] = +{ + packDuMacRachRsrcRel, /* Loose coupling */ + MacProcRachRsrcRel, /* Tight coupling */ + packDuMacRachRsrcRel /* Light weight-loose coupling */ +}; + DuMacUeDeleteReq packMacUeDeleteReqOpts[] = { packDuMacUeDeleteReq, /* Loose coupling */ @@ -3084,25 +3091,50 @@ uint8_t duProcUeContextModReq(DuUeCb *ueCb) /******************************************************************* * -* @brief Function to delete Pdsch ServCellCfg +* @brief Build and send dedicated RACH resource release request to MAC * * @details * -* Function : deletePdschServCellCfg +* Function : duBuildAndSendRachRsrcRelToMac * -* Functionality: Function to delete Pdsch ServCellCfg +* Functionality: Function to Build and send dedicated RACH resource +* release request to MAC * -* @params[in] PdschServCellCfg *pdschServCellCfg -* @return void +* @params[in] Cell ID +* UE CB +* @return ROK - Success +* RFAILED - Failure * * ****************************************************************/ - -void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg) +uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb) { - DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t)); - DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB)); - DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool)); - DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead)); + Pst pst; + MacRachRsrcRel *rachRsrcRel = NULLP; + + DU_ALLOC_SHRABL_BUF(rachRsrcRel, sizeof(MacRachRsrcRel)); + if(!rachRsrcRel) + { + DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Release in \ + duBuildAndSendRachRsrcRelToMac()"); + return RFAILED; + } + + rachRsrcRel->cellId = cellId; + rachRsrcRel->ueId = ueCb->gnbDuUeF1apId; + rachRsrcRel->crnti = ueCb->crnti; + + /* Fill Pst */ + FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REL); + + if(((*packMacRachRsrcRelOpts[pst.selector])(&pst, rachRsrcRel)) != ROK) + { + DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Release to MAC at \ + duBuildAndSendRachRsrcRelToMac()"); + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRel, sizeof(MacRachRsrcRel)); + return RFAILED; + } + + return ROK; } /******************************************************************* diff --git a/src/du_app/du_ue_mgr.h b/src/du_app/du_ue_mgr.h index 529c2ea72..3b741949f 100644 --- a/src/du_app/du_ue_mgr.h +++ b/src/du_app/du_ue_mgr.h @@ -33,6 +33,7 @@ void freeF1UeDb(F1UeContextSetupDb *f1UeDb); uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti); uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId); uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t duUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg); +uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb); #endif -- 2.16.6