X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Fmac_ue_mgr.c;h=cea930536b26e49eca0ea738935897691f527ef5;hb=ab13dee0decf8731b1d95f943d13a6e7a4a2ead5;hp=018244cc1353805f21913169dd5a2229d7160c8e;hpb=ca0353e5cb5699aecb6840efe9572934a1150e2b;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_ue_mgr.c b/src/5gnrmac/mac_ue_mgr.c index 018244cc1..cea930536 100644 --- a/src/5gnrmac/mac_ue_mgr.c +++ b/src/5gnrmac/mac_ue_mgr.c @@ -28,19 +28,11 @@ #include "mac.h" #include "mac_utils.h" -/* function pointers for packing slot ind from mac to sch */ -MacSchAddUeConfigReqFunc macSchAddUeConfigReqOpts[] = +MacDuUeCreateRspFunc macDuUeCreateRspOpts[] = { - packMacSchAddUeConfigReq, /* packing for loosely coupled */ - MacSchAddUeConfigReq, /* packing for tightly coupled */ - packMacSchAddUeConfigReq /* packing for light weight loosely coupled */ -}; - -MacDuUeCfgRspFunc macDuUeCfgRspOpts[] = -{ - packDuMacUeCfgRsp, /* packing for loosely coupled */ - DuProcMacUeCfgRsp, /* packing for tightly coupled */ - packDuMacUeCfgRsp /* packing for light weight loosly coupled */ + packDuMacUeCreateRsp, /* packing for loosely coupled */ + DuProcMacUeCreateRsp, /* packing for tightly coupled */ + packDuMacUeCreateRsp /* packing for light weight loosly coupled */ }; MacDuUeRecfgRspFunc macDuUeRecfgRspOpts[] = @@ -50,27 +42,66 @@ MacDuUeRecfgRspFunc macDuUeRecfgRspOpts[] = packDuMacUeRecfgRsp /* packing for light weight loosly coupled */ }; -MacSchModUeConfigReqFunc macSchModUeConfigReqOpts[] = +MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] = { - packMacSchModUeConfigReq, /* packing for loosely coupled */ - MacSchModUeConfigReq, /* packing for tightly coupled */ - packMacSchModUeConfigReq /* packing for light weight loosely coupled */ + packDuMacUeDeleteRsp, /* packing for loosely coupled */ + DuProcMacUeDeleteRsp, /* packing for tightly coupled */ + packDuMacUeDeleteRsp /* packing for light weight loosly coupled */ }; -MacSchUeDeleteReqFunc macSchUeDeleteReqOpts[] = +MacDuUeResetRspFunc macDuUeResetRspOpts[] = { - packMacSchUeDeleteReq, /* packing for loosely coupled */ - MacSchUeDeleteReq, /* packing for tightly coupled */ - packMacSchUeDeleteReq /* packing for light weight loosely coupled */ + packDuMacUeResetRsp, /* packing for loosely coupled */ + DuProcMacUeResetRsp, /* packing for tightly coupled */ + packDuMacUeResetRsp /* packing for light weight loosly coupled */ }; -MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] = +MacDuUeSyncStatusIndFunc macDuUeSyncStatusIndOpts[] = { - packDuMacUeDeleteRsp, /* packing for loosely coupled */ - DuProcMacUeDeleteRsp, /* packing for tightly coupled */ - packDuMacUeDeleteRsp /* packing for light weight loosly coupled */ + packDuMacUeSyncStatusInd, /* packing for loosely coupled */ + DuProcMacUeSyncStatusInd, /* packing for tightly coupled */ + packDuMacUeSyncStatusInd /* packing for light weight loosly coupled */ }; +/******************************************************************* +* +* @brief Fill and Send UE Sync Status Indication from MAC to DU APP +* +* @details +* +* Function : MacSendUeSyncStatusInd +* +* Functionality: Fill and Send UE Sync Status Indication from MAC to DUAPP +* +* @params[in] uint16_t cellId, uint16_t ueId, SyncStatus status +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ + +uint8_t MacSendUeSyncStatusInd(uint16_t cellId, uint16_t ueId, SyncStatus status) +{ + MacUeSyncStatusInd *ueSyncStatusInd; + Pst rspPst; + + MAC_ALLOC_SHRABL_BUF(ueSyncStatusInd, sizeof(MacUeSyncStatusInd)); + if(!ueSyncStatusInd) + { + DU_LOG("\nERROR --> MAC : Memory allocation for UE Sync Status Indication failed"); + return RFAILED; + } + + /* Filling UE Sync Status Indication */ + ueSyncStatusInd->cellId = cellId; + ueSyncStatusInd->ueId = ueId; + ueSyncStatusInd->status = status; + + /* Fill Post structure and send UE Sync Status Indication */ + memset(&rspPst, 0, sizeof(Pst)); + FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_SYNC_STATUS_IND); + return (*macDuUeSyncStatusIndOpts[rspPst.selector])(&rspPst, ueSyncStatusInd); +} + /******************************************************************* * * @brief Fills mac cell group config to be sent to scheduler @@ -1541,14 +1572,14 @@ uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg) SchUeCfgReq *schUeCfgReq = NULLP; schUeCfgReq = (SchUeCfgReq *)schUeCfg; FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH); - return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfgReq); + return(SchMessageRouter(&schPst, (void *)schUeCfgReq)); } case EVENT_MAC_UE_RECONFIG_REQ: { SchUeRecfgReq *schUeRecfgReq = NULLP; schUeRecfgReq = (SchUeRecfgReq *)schUeCfg; FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH); - return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeRecfgReq); + return(SchMessageRouter(&schPst, (void *)schUeRecfgReq)); } default: { @@ -1725,7 +1756,7 @@ uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg) * * ****************************************************************/ -uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg) +uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg) { uint8_t lcIdx; @@ -1805,7 +1836,7 @@ uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg) * RFAILED - failure * * ****************************************************************/ -uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg) +uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg) { uint8_t ret = ROK; @@ -2194,7 +2225,7 @@ void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel) * * ****************************************************************/ -uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg) +uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCreateReq *ueCfg) { uint8_t lcIdx = 0; @@ -2347,7 +2378,7 @@ uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg) * * ****************************************************************/ -uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx) +uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCreateReq *ueCfg, uint8_t cellIdx) { uint8_t ret = ROK; @@ -2500,7 +2531,7 @@ void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb) * RFAILED - failure * * ****************************************************************/ -uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg) +uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCreateReq *ueCfg) { uint8_t ret = ROK; uint8_t hqProcIdx = 0; @@ -2599,7 +2630,7 @@ uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg) * * ****************************************************************/ -uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg) +uint8_t procMacUeCfgData(Pst *pst, MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg) { uint8_t ret = ROK, ueId = 0; uint16_t cellIdx, cellId; @@ -2671,27 +2702,27 @@ uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg) * * Functionality: Function to store the UeCfg Data * - * @params[in] MacUeCfg pointer + * @params[in] MacUeCreateReq pointer * @return ROK - success * RFAILED - failure * * ****************************************************************/ -uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg) +uint8_t copyToTmpData(MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg) { uint8_t cellIdx; if(ueCfg != NULLP) { - MacUeCfg *tmpData = NULLP; + MacUeCreateReq *tmpData = NULLP; - MAC_ALLOC(tmpData, sizeof(MacUeCfg)); + MAC_ALLOC(tmpData, sizeof(MacUeCreateReq)); if(!tmpData) { DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()"); return RFAILED; } - memcpy(tmpData, ueCfg, sizeof(MacUeCfg)); + memcpy(tmpData, ueCfg, sizeof(MacUeCreateReq)); GET_CELL_IDX(ueCfg->cellId, cellIdx); macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData; } @@ -2727,7 +2758,7 @@ uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg) * RFAILED - failure * * ****************************************************************/ -uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg) +uint8_t MacProcUeCreateReq(Pst *pst, MacUeCreateReq *ueCfg) { uint8_t ret = ROK; SchUeCfgReq schUeCfg; @@ -2771,7 +2802,7 @@ uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg) ret = RFAILED; } /* FREE shared memory */ - MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg)); + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCreateReq)); return ret; } @@ -2794,10 +2825,10 @@ uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg) * ****************************************************************/ uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp) { - MacUeCfgRsp *cfgRsp; + MacUeCreateRsp *cfgRsp; Pst rspPst; - MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp)); + MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCreateRsp)); if(!cfgRsp) { DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed"); @@ -2805,7 +2836,7 @@ uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp) } /* Filling UE Config response */ - memset(cfgRsp, 0, sizeof(MacUeCfgRsp)); + memset(cfgRsp, 0, sizeof(MacUeCreateRsp)); cfgRsp->cellId = schCfgRsp->cellId; cfgRsp->ueId = schCfgRsp->ueId; cfgRsp->result = result; @@ -2813,7 +2844,7 @@ uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp) /* Fill Post structure and send UE Create response*/ memset(&rspPst, 0, sizeof(Pst)); FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP); - return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp); + return (*macDuUeCreateRspOpts[rspPst.selector])(&rspPst, cfgRsp); } /******************************************************************* @@ -2869,14 +2900,14 @@ uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp) * * @params[in] cellIdx, ueId * - * @return MacUeCfg pointer - success + * @return MacUeCreateReq pointer - success * NULLP - failure * * ****************************************************************/ -MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId) +MacUeCreateReq *getMacUeCfg(uint16_t cellIdx, uint8_t ueId) { - MacUeCfg *ueCfg = NULLP; + MacUeCreateReq *ueCfg = NULLP; if(macCb.macCell[cellIdx]) { ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1]; @@ -2943,7 +2974,7 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp) uint8_t result = MAC_DU_APP_RSP_NOK; uint8_t ret = ROK; uint16_t cellIdx; - MacUeCfg *ueCfg = NULLP; + MacUeCreateReq *ueCfg = NULLP; #ifdef CALL_FLOW_DEBUG_LOG switch(pst->event) @@ -2985,7 +3016,7 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp) DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti); } ret = MacSendUeCreateRsp(result, schCfgRsp); - MAC_FREE(ueCfg, sizeof(MacUeCfg)); + MAC_FREE(ueCfg, sizeof(MacUeCreateReq)); ueCfg = NULLP; return ret; } @@ -3014,7 +3045,7 @@ uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp) uint8_t ret = ROK; uint16_t cellIdx; MacUeRecfg *ueRecfg = NULLP; - + #ifdef CALL_FLOW_DEBUG_LOG switch(pst->event) { @@ -3133,7 +3164,7 @@ uint8_t MacProcUeReconfigReq(Pst *pst, MacUeRecfg *ueRecfg) * * ****************************************************************/ -uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result) +uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, CauseOfResult status) { MacUeDeleteRsp *deleteRsp; Pst rspPst; @@ -3148,7 +3179,7 @@ uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus resul /* Filling UE delete response */ deleteRsp->cellId = cellId; GET_UE_ID(crnti, deleteRsp->ueId); - deleteRsp->result = result; + deleteRsp->status = status; /* Fill Post structure and send UE delete response*/ memset(&rspPst, 0, sizeof(Pst)); @@ -3232,7 +3263,7 @@ uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp) uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0; uint16_t cellIdx=0; uint8_t ret = RFAILED; - UeDeleteStatus result; + CauseOfResult status; DlHarqEnt *dlHarqEnt; #ifdef CALL_FLOW_DEBUG_LOG @@ -3252,7 +3283,7 @@ uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp) { /*C-RNTI value is out of Acceptable range*/ DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti); - result = UEID_INVALID; + status = UEID_INVALID; } else { @@ -3286,29 +3317,29 @@ uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp) } memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb)); macCb.macCell[cellIdx]->numActvUe--; - result = DEL_SUCCESSFUL; + status = SUCCESSFUL; ret = ROK; } else { DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti); - result = UEID_INVALID; + status = UEID_INVALID; } } } else { DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId); - result = CELLID_INVALID; + status = CELLID_INVALID; } } else - { - result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEID_INVALID; - } - if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK) + status = schUeDelRsp->cause; + + if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, status) != ROK) { DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response"); + ret = RFAILED; } } else @@ -3347,7 +3378,7 @@ uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete) schUeDel.crnti = ueDelete->crnti; MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete)); FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH); - return(*macSchUeDeleteReqOpts[schPst.selector])(&schPst, &schUeDel); + return(SchMessageRouter(&schPst, (void *)&schUeDel)); } else { @@ -3377,7 +3408,7 @@ uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete) { uint8_t ret = ROK; uint8_t cellIdx=0; - UeDeleteStatus result=DEL_SUCCESSFUL; + CauseOfResult status =SUCCESSFUL; MacUeCb *ueCb = NULLP; MacCellCb *cellCb = NULLP; @@ -3402,18 +3433,18 @@ uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete) else { DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched"); - result = UEID_INVALID; + status = UEID_INVALID; } } else { DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId); - result = CELLID_INVALID; + status = CELLID_INVALID; } - if(result != DEL_SUCCESSFUL) + if(status!= SUCCESSFUL) { - MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result); + MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, status); MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete)); ret = RFAILED; } @@ -3426,6 +3457,104 @@ uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete) return ret; } +/******************************************************************* +* +* @brief Fill and Send UE Reset response from MAC to DU APP +* +* @details +* +* Function : MacSendUeResetRsp +* +* Functionality: Fill and Send UE Reset response from MAC to DUAPP +* +* @params[in] MAC UE Reset result +* SCH UE Reset response +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ + +uint8_t MacSendUeResetRsp(uint16_t cellId, uint16_t ueId, CauseOfResult status) +{ + MacUeResetRsp *ResetRsp; + Pst rspPst; + + MAC_ALLOC_SHRABL_BUF(ResetRsp, sizeof(MacUeResetRsp)); + if(!ResetRsp) + { + DU_LOG("\nERROR --> MAC : Memory allocation for UE Reset response failed"); + return RFAILED; + } + + /* Filling UE Reset response */ + ResetRsp->cellId = cellId; + ResetRsp->ueId = ueId; + ResetRsp->status = status; + + /* Fill Post structure and send UE Reset response*/ + memset(&rspPst, 0, sizeof(Pst)); + FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RESET_RSP); + return (*macDuUeResetRspOpts[rspPst.selector])(&rspPst, ResetRsp); +} + +/******************************************************************* + * + * @brief Handles UE Reset request from DU APP + * + * @details + * + * Function : MacProcUeResetReq + * + * Functionality: Handles UE Reset requst from DU APP + * + * @params[in] Pst *pst, MacUeResetReq *ueReset + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t MacProcUeResetReq(Pst *pst, MacUeResetReq *ueReset) +{ + uint8_t cellIdx=0; + CauseOfResult status =SUCCESSFUL; + MacUeCb *ueCb = NULLP; + MacCellCb *cellCb = NULLP; + + DU_LOG("\nINFO --> MAC : UE Reset Request received for ueId[%d]", ueReset->ueId); + + if(ueReset) + { + GET_CELL_IDX(ueReset->cellId, cellIdx); + cellCb = macCb.macCell[cellIdx]; + if(cellCb) + { + ueCb = &cellCb->ueCb[ueReset->ueId-1]; + if(ueCb->ueId == ueReset->ueId) + { + /* TODO := complete the processing of UE reset request*/ + } + else + { + DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): UE ID [%d] not found in Cell Id [%d]", ueCb->ueId , ueReset->cellId); + status = UEID_INVALID; + } + } + else + { + DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): Cell Id [%d] not found ",ueReset->cellId); + status = CELLID_INVALID; + } + + MacSendUeResetRsp(ueReset->cellId, ueReset->ueId, status); + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReset, sizeof(MacUeResetReq)); + } + else + { + DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): MAC UE reset request processing failed"); + return RFAILED; + } + return ROK; +} /********************************************************************** End of file **********************************************************************/