From 0fccb83e55b237d60cf451bab71a0c7242cc6e66 Mon Sep 17 00:00:00 2001 From: Balaji Shankaran Date: Fri, 8 May 2020 11:36:40 +0530 Subject: [PATCH] Stop Req and Stop Ind code changes Change-Id: I98414bb7a3dac063ec3899f029b10341f72b680c Signed-off-by: Balaji Shankaran --- src/5gnrmac/lwr_mac_fsm.c | 36 +++++++++++++++- src/5gnrmac/lwr_mac_handle_phy.c | 42 +++++++++++++++++- src/5gnrmac/lwr_mac_upr_inf.c | 28 ++++++++++++ src/5gnrmac/lwr_mac_upr_inf.h | 4 +- src/5gnrmac/mac_msg_hdl.c | 10 +++-- src/5gnrmac/mac_stop_ind.c | 63 +++++++++++++++++++++++++++ src/5gnrmac/mac_upr_inf_api.c | 28 ++++++++++++ src/5gnrmac/mac_upr_inf_api.h | 2 +- src/5gnrmac/rg_lim.c | 55 ++++++++++++++++++++++++ src/cm/du_app_mac_inf.c | 92 ++++++++++++++++++++++++++++++++++++++++ src/cm/du_app_mac_inf.h | 12 +++++- src/cm/lphy_stub.h | 3 +- src/cm/tfu.h | 1 + src/du_app/du_mgr.h | 16 +++++++ src/du_app/du_mgr_ex_ms.c | 5 +++ src/du_app/du_msg_hdl.c | 45 ++++++++++++++++++-- src/phy_stub/l1_bdy1.c | 85 ++++++++++++++++++++++++++++++++++++- src/phy_stub/l1_bdy2.c | 22 +++++++--- 18 files changed, 528 insertions(+), 21 deletions(-) create mode 100644 src/5gnrmac/mac_stop_ind.c diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 29d458aa2..4b722e5b1 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -2138,11 +2138,40 @@ S16 lwr_mac_handleStartReqEvt(void *msg) return ROK; } /* lwr_mac_handleStartReqEvt */ + /******************************************************************* + * + * @brief Sends FAPI Stop Req to PHY + * + * @details + * + * Function : lwr_mac_handleStopReqEvt + * + * Functionality: + * -Sends FAPI Stop Req to PHY + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + ********************************************************************/ + S16 lwr_mac_handleStopReqEvt(void *msg) { #ifdef FAPI - /* stop TX and RX operation return PHy to configured State - send stop.indication to l2/l3 */ + uint32_t msgLen = 0; + fapi_stop_req_t *stopReq = NULLP; + LWR_MAC_ALLOC(stopReq, sizeof(fapi_stop_req_t)); + if(stopReq != NULLP) + { + fillMsgHeader(&stopReq->header, FAPI_STOP_REQUEST, msgLen); + DU_LOG("\nLOWER MAC: Sending Stop Request to PHY"); + LwrMacSendToPhy(stopReq->header.message_type_id, sizeof(fapi_stop_req_t), (void *)stopReq); + } + else + { + DU_LOG("\nLOWER MAC: Failed to allocate memory for Stop Request"); + return RFAILED; + } #endif return ROK; } @@ -3287,6 +3316,7 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = lwr_mac_handleConfigReqEvt, lwr_mac_handleConfigRspEvt, lwr_mac_handleInvalidEvt, + lwr_mac_handleInvalidEvt, }, { /* PHY_STATE_CONFIGURED */ @@ -3295,6 +3325,7 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = lwr_mac_handleConfigReqEvt, lwr_mac_handleConfigRspEvt, lwr_mac_handleStartReqEvt, + lwr_mac_handleInvalidEvt, }, { /* PHY_STATE_RUNNING */ @@ -3303,6 +3334,7 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = lwr_mac_handleConfigReqEvt, lwr_mac_handleConfigRspEvt, lwr_mac_handleInvalidEvt, + lwr_mac_handleStopReqEvt, } }; diff --git a/src/5gnrmac/lwr_mac_handle_phy.c b/src/5gnrmac/lwr_mac_handle_phy.c index 736aca2ed..0c4027835 100644 --- a/src/5gnrmac/lwr_mac_handle_phy.c +++ b/src/5gnrmac/lwr_mac_handle_phy.c @@ -80,7 +80,13 @@ packRxDataIndMsg sendRxDataIndOpts[] = packRxDataInd }; - +/* Function pointer for stop indication from lower mac to mac */ +packStopIndMsg sendStopIndOpts[] = +{ + packStopInd, + fapiMacStopInd, + packStopInd +}; /******************************************************************* * * @brief Fills post structure @@ -154,7 +160,35 @@ U16 handleSlotInd(fapi_slot_ind_t *fapiSlotInd) return ret; } +/******************************************************************* + * + * @brief Handles stop indication recived from PHY + * + * @details + * + * Function : handleStopInd + * + * Functionality: + * Handles Stop Indication received from PHY + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t handleStopInd() +{ + uint8_t ret; + Pst pst; + + clGlobalCp.phyState = PHY_STATE_CONFIGURED; + DU_LOG("\nLWR_MAC: PHY has moved to configured state"); + + fillLwrMacToMacPst(&pst); + pst.event = EVENT_STOP_IND_TO_MAC; + ret = (*sendStopIndOpts[pst.selector])(&pst); + return ret; +} /******************************************************************* * * @brief Processes Rach Indication from PHY and sends to MAC @@ -372,6 +406,12 @@ void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg) rachInd = (fapi_rach_indication_t *)msg; handleRachInd(rachInd); break; + } + case FAPI_STOP_INDICATION: + { + DU_LOG("\nLWR_MAC: Handling Stop Indication"); + handleStopInd(); + break; } } #ifdef INTEL_WLS diff --git a/src/5gnrmac/lwr_mac_upr_inf.c b/src/5gnrmac/lwr_mac_upr_inf.c index b17ca9579..0c91610ce 100644 --- a/src/5gnrmac/lwr_mac_upr_inf.c +++ b/src/5gnrmac/lwr_mac_upr_inf.c @@ -160,6 +160,34 @@ S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd) return ROK; } +/******************************************************************* + * + * @brief Packs and Sends Stop Ind to MAC + * + * @details + * + * Function : packStopInd + * + * Functionality: + * Packs and Sends Stop Ind to MAC + * + * @params[in] Post structure pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t packStopInd(Pst *pst) +{ + if((pst->selector == MAC_SELECTOR_LC) || (pst->selector == MAC_SELECTOR_LWLC)) + { + return ROK; + } + else + { + return RFAILED; + } +} + /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/lwr_mac_upr_inf.h b/src/5gnrmac/lwr_mac_upr_inf.h index a33978697..9ed2b7d41 100644 --- a/src/5gnrmac/lwr_mac_upr_inf.h +++ b/src/5gnrmac/lwr_mac_upr_inf.h @@ -54,7 +54,6 @@ typedef uint16_t (*packRachIndMsg)(Pst *pst, RachInd *rachInd); uint16_t packRachInd(Pst *pst, RachInd *rachInd); uint16_t fapiMacRachInd(Pst *pst, RachInd *rachInd); - typedef uint16_t (*packCrcIndMsg)(Pst *pst, CrcInd *crcInd); uint16_t packCrcInd(Pst *pst, CrcInd *crcInd); uint16_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd); @@ -64,6 +63,9 @@ typedef uint16_t (*packRxDataIndMsg)(Pst *pst, RxDataInd *rxDataInd); uint16_t packRxDataInd(Pst *pst, RxDataInd *rxDataInd); uint16_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd); +typedef uint16_t (*packStopIndMsg)(Pst *pst); +uint16_t packStopInd(Pst *pst); +uint16_t fapiMacStopInd(Pst *pst); #endif /********************************************************************** End of file diff --git a/src/5gnrmac/mac_msg_hdl.c b/src/5gnrmac/mac_msg_hdl.c index 92eb13a9f..a1e4c20e5 100644 --- a/src/5gnrmac/mac_msg_hdl.c +++ b/src/5gnrmac/mac_msg_hdl.c @@ -128,7 +128,7 @@ uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo) DU_LOG("\nMAC : Handling cell start request"); sendToLowerMac(START_REQUEST, 0, cellStartInfo); - MAC_FREE_MEM(pst->region, pst->pool, cellStartInfo, \ + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStartInfo, \ sizeof(MacCellStartInfo)); return ROK; @@ -153,10 +153,12 @@ uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo) * ****************************************************************/ uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo) { - DU_LOG("\nMAC : Handling cell stop request"); - sendToLowerMac(STOP_REQUEST, 0, cellStopInfo); + #ifdef FAPI + DU_LOG("\nMAC : Sending cell stop request to Lower Mac"); + sendToLowerMac(FAPI_STOP_REQUEST, 0, cellStopInfo); + #endif - MAC_FREE_MEM(pst->region, pst->pool, cellStopInfo, \ + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopInfo, \ sizeof(MacCellStopInfo)); return ROK; diff --git a/src/5gnrmac/mac_stop_ind.c b/src/5gnrmac/mac_stop_ind.c new file mode 100644 index 000000000..3249eb1e2 --- /dev/null +++ b/src/5gnrmac/mac_stop_ind.c @@ -0,0 +1,63 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + *******************************************************************************/ +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_tkns.h" /* Common Token Defines */ +#include "cm_llist.h" /* Common Link List Defines */ +#include "cm_hash.h" /* Common Hash List Defines */ +#include "cm_mblk.h" /* common memory link list library */ +#include "cm_lte.h" /* Common LTE Defines */ +#include "tfu.h" /* RGU Interface includes */ +#include "lrg.h" +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm5.x" /* system services */ +#include "cm_tkns.x" /* Common Token Definitions */ +#include "cm_llist.x" /* Common Link List Definitions */ +#include "cm_lib.x" /* Common Library Definitions */ +#include "cm_hash.x" /* Common Hash List Definitions */ +#include "cm_mblk.x" /* common memory link list library */ +#include "cm_lte.x" /* Common LTE Defines */ +#include "tfu.x" /* RGU Interface includes */ +#include "lrg.x" +#include "du_app_mac_inf.h" +#include "mac.h" +#include "du_log.h" + +/******************************************************************* + * @brief process Stop indication to MAC + * + * @details + * + * Function : fapiMacStopInd + * + * @param[in] Pst *pst + * @return S16 + * -# ROK + * -# RFAILED + ******************************************************************/ +PUBLIC S16 fapiMacStopInd(Pst *pst) +{ + uint8_t ret = ROK; + ret = sendStopIndMacToDuApp(); + return ret; +} diff --git a/src/5gnrmac/mac_upr_inf_api.c b/src/5gnrmac/mac_upr_inf_api.c index fb212da64..b37b6ab13 100644 --- a/src/5gnrmac/mac_upr_inf_api.c +++ b/src/5gnrmac/mac_upr_inf_api.c @@ -28,6 +28,13 @@ DuMacSlotInd packMacSlotIndOpts[] = duHandleSlotInd, packMacSlotInd }; +/* Funtion pointer options for stop indication */ +DuMacStopInd packMacStopIndOpts[] = +{ + packMacStopInd, + duHandleStopInd, + packMacStopInd +}; /******************************************************************* * @@ -52,6 +59,27 @@ uint16_t MacDuAppSlotInd(Pst *pst, SlotInfo *slotInfo) return (*packMacSlotIndOpts[pst->selector])(pst, slotInfo); } +/******************************************************************* + * + * @brief Send stop indication to MAC + * + * @details + * + * Function : MacDuAppStopInd + * + * Functionality: + * Sends Stop Indication to MAC + * + * @params[in] Post structure pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t MacDuAppStopInd(Pst *pst, MacCellStopInfo *cellStopId) +{ + return (*packMacStopIndOpts[pst->selector])(pst, cellStopId); +} + /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/mac_upr_inf_api.h b/src/5gnrmac/mac_upr_inf_api.h index 37300457f..75a396341 100644 --- a/src/5gnrmac/mac_upr_inf_api.h +++ b/src/5gnrmac/mac_upr_inf_api.h @@ -46,7 +46,7 @@ uint16_t MacDuAppSlotInd(Pst *pst, SlotInfo *slotInfo); - +uint16_t MacDuAppStopInd(Pst *pst, MacCellStopInfo *cellStopId); /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/rg_lim.c b/src/5gnrmac/rg_lim.c index d710c4f22..a1a7ff122 100755 --- a/src/5gnrmac/rg_lim.c +++ b/src/5gnrmac/rg_lim.c @@ -740,6 +740,61 @@ int sendSlotIndMacToDuApp(SlotIndInfo *slotInd) return ret; } +/******************************************************************* + * + * @brief Send stop indication to DU APP + * + * @details + * + * Function : sendStopIndMacToDuApp + * + * Functionality: + * Send stop indication to DU APP + * + * @params[in] Pst info + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t sendStopIndMacToDuApp() +{ + Pst pst; + uint8_t ret = ROK; + + MacCellStopInfo *cellStopId; + + /* Allocate sharable memory */ + MAC_ALLOC_SHRABL_BUF(cellStopId, sizeof(MacCellStopInfo)); + if(!cellStopId) + { + DU_LOG("\nMAC : Stop Indication memory allocation failed"); + return RFAILED; + } + cellStopId->cellId = macCb.macCell->cellId; + + /* Fill Pst */ + pst.selector = DU_MAC_LWLC; + pst.srcEnt = ENTRG; + pst.dstEnt = ENTDUAPP; + pst.dstInst = 0; + pst.srcInst = macCb.macInst; + pst.dstProcId = rgCb[pst.srcInst].rgInit.procId; + pst.srcProcId = rgCb[pst.srcInst].rgInit.procId; + pst.region = MAC_MEM_REGION; + pst.pool = MAC_POOL; + pst.event = EVENT_MAC_STOP_IND; + pst.route = 0; + pst.prior = 0; + pst.intfVer = 0; + + ret = MacDuAppStopInd(&pst, cellStopId); + if(ret != ROK) + { + DU_LOG("\nMAC: Failed to send stop indication to DU APP"); + MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, cellStopId, sizeof(MacCellStopInfo)); + } + return ROK; +} #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD) /** * @brief Transmission of non-rt indication from CL. diff --git a/src/cm/du_app_mac_inf.c b/src/cm/du_app_mac_inf.c index 05b5662b4..2af744dc1 100644 --- a/src/cm/du_app_mac_inf.c +++ b/src/cm/du_app_mac_inf.c @@ -457,6 +457,98 @@ uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf) return ROK; } +/******************************************************************* + * + * @brief Packs and Sends stop ind from MAC to DUAPP + * + * @details + * + * Function : packMacStopInd + * + * Functionality: + * Packs and Sends stop ind from MAC to DUAPP + * + * @params[in] Post structure pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellStopId) +{ + Buffer *mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nDU APP : Memory allocation failed for stop Ind pack"); + return RFAILED; + } + + if(pst->selector == DU_SELECTOR_LC) + { + /*pack the payload here*/ + DU_LOG("\nDU APP : Packed CellId"); + CMCHKPK(SPkU16, cellStopId->cellId, mBuf); + CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopId, sizeof(MacCellStopInfo)); + cellStopId = NULL; + } + else if(pst->selector == DU_SELECTOR_LWLC) + { + /* pack the address of the structure */ + CMCHKPK(cmPkPtr,(PTR)cellStopId, mBuf); + } + else + { + SPutMsg(mBuf); + } + + return SPstTsk(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks stop indication from MAC + * + * @details + * + * Function : unpackMacStopInd + * + * Functionality: + * Unpacks stop indication from MAC + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == DU_SELECTOR_LWLC) + { + MacCellStopInfo *cellStopId; + /* unpack the address of the structure */ + CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopId, mBuf); + SPutMsg(mBuf); + return (*func)(pst, cellStopId); + } + else if(pst->selector == DU_SELECTOR_LC) + { + MacCellStopInfo cellStopId; + CMCHKUNPK(SUnpkU16, &(cellStopId.cellId), mBuf); + + SPutMsg(mBuf); + return (*func)(pst, &cellStopId); + + } + else + { + /* Nothing to do for loose coupling */ + SPutMsg(mBuf); + return ROK; + } + return ROK; +} /********************************************************************** End of file **********************************************************************/ diff --git a/src/cm/du_app_mac_inf.h b/src/cm/du_app_mac_inf.h index b8a50563f..9e4b759e3 100644 --- a/src/cm/du_app_mac_inf.h +++ b/src/cm/du_app_mac_inf.h @@ -46,6 +46,7 @@ #define EVENT_MAC_CELL_START_REQ 202 #define EVENT_MAC_CELL_STOP_REQ 203 #define EVENT_MAC_SLOT_IND 204 +#define EVENT_MAC_STOP_IND 205 typedef enum { @@ -276,6 +277,15 @@ extern uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo ); extern uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf); extern uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo); +/* Functions for stop Ind from MAC to DU APP*/ +typedef uint16_t (*DuMacStopInd) ARGS(( + Pst *pst, + MacCellStopInfo *cellId )); + +extern uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellId); +extern uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf); +extern uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellId); + /* Functions for mac cell start req */ typedef uint16_t (*DuMacCellStartReq) ARGS(( Pst *pst, @@ -316,7 +326,7 @@ extern int MacHdlCellCfgReq(Pst *pst, MacCellCfg *macCellCfg); extern void cmUnpackLwLcMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf); extern int unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf); extern int duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm); - +uint8_t sendStopIndMacToDuApp(); #endif /********************************************************************** diff --git a/src/cm/lphy_stub.h b/src/cm/lphy_stub.h index a6818dd93..995912d50 100644 --- a/src/cm/lphy_stub.h +++ b/src/cm/lphy_stub.h @@ -1,4 +1,5 @@ #include "stdio.h" +#include "stdbool.h" #include "envopt.h" /* Environment options */ #include "envdep.h" /* Environment dependent */ #include "envind.h" /* Environment independent */ @@ -9,6 +10,6 @@ #include "gen.x" /* General */ #include "ssi.x" /* System services */ -void duStartSlotIndicaion(); +void l1HdlSlotIndicaion(bool); S16 buildAndSendSlotIndication(); S16 duSendEgtpSlotInd(); diff --git a/src/cm/tfu.h b/src/cm/tfu.h index e6b9b705a..dac320244 100755 --- a/src/cm/tfu.h +++ b/src/cm/tfu.h @@ -128,6 +128,7 @@ #define EVENT_CRC_IND_TO_MAC 28 #define EVENT_CRC_IND_TO_SCH 29 #define EVENT_RX_DATA_IND_TO_MAC 30 +#define EVENT_STOP_IND_TO_MAC 31 /** @} */ #define MAX_PREAM_PER_SLOT 1 /* Max number of preamble per slot */ diff --git a/src/du_app/du_mgr.h b/src/du_app/du_mgr.h index d2d8c7bcd..99ceeeb62 100644 --- a/src/du_app/du_mgr.h +++ b/src/du_app/du_mgr.h @@ -139,6 +139,21 @@ SPutSBuf(DU_APP_MEM_REGION, DU_POOL, \ (Data *)_datPtr, _size); +/* Allocate shared memory to be used for LWLC + * during inter-layer communication */ +#define DU_ALLOC_SHRABL_BUF(_buf, _size) \ +{ \ + if(SGetStaticBuffer(DU_APP_MEM_REGION, DU_POOL, \ + (Data **)&_buf, (Size) _size, 0) == ROK) \ + { \ + cmMemset((U8 *)(_buf), 0, _size); \ + } \ + else \ + { \ + (_buf) = NULLP; \ + } \ +} + /* Free shared memory, received through LWLC */ #define DU_FREE_SHRABL_BUF(_region, _pool,_buf, _size) \ { \ @@ -259,6 +274,7 @@ S16 duSendEgtpTestData(); S16 duSendEgtpDatInd(Buffer *mBuf); S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm); uint16_t duBuildAndSendMacCellStartReq(); +uint16_t duBuildAndSendMacCellStopReq(); #endif diff --git a/src/du_app/du_mgr_ex_ms.c b/src/du_app/du_mgr_ex_ms.c index 21d752b0d..3cecb3790 100644 --- a/src/du_app/du_mgr_ex_ms.c +++ b/src/du_app/du_mgr_ex_ms.c @@ -198,6 +198,11 @@ S16 duActvTsk(Pst *pst, Buffer *mBuf) ret = unpackMacSlotInd(duHandleSlotInd, pst, mBuf); break; } + case EVENT_MAC_STOP_IND: + { + ret = unpackMacStopInd(duHandleStopInd, pst, mBuf); + break; + } default: { DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTRG"); diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index 191c87dd9..305af8b07 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -1697,7 +1697,7 @@ uint16_t duBuildAndSendMacCellStartReq() DU_LOG("\nDU APP : Building and Sending cell start request to MAC"); /* Send Cell Start Request to MAC */ - DU_ALLOC(cellStartInfo, sizeof(MacCellStartInfo)); + DU_ALLOC_SHRABL_BUF(cellStartInfo, sizeof(MacCellStartInfo)); if(!cellStartInfo) { DU_LOG("\nDU APP : Memory alloc failed while building cell start request"); @@ -1745,7 +1745,7 @@ uint16_t duBuildAndSendMacCellStartReq() * RFAILED - failure * * ****************************************************************/ -S16 duBuildAndSendMacCellStopReq() +uint16_t duBuildAndSendMacCellStopReq() { Pst pst; MacCellStopInfo *cellStopInfo = NULL; @@ -1753,7 +1753,7 @@ S16 duBuildAndSendMacCellStopReq() DU_LOG("\nDU APP : Building and Sending cell stop request to MAC"); /* Send Cell Stop Request to MAC */ - DU_ALLOC(cellStopInfo, sizeof(MacCellStopInfo)); + DU_ALLOC_SHRABL_BUF(cellStopInfo, sizeof(MacCellStopInfo)); if(!cellStopInfo) { DU_LOG("\nDU APP : Memory alloc failed while building cell stop request"); @@ -1776,7 +1776,46 @@ S16 duBuildAndSendMacCellStopReq() return (*packMacCellStopReqOpts[pst.selector])(&pst, cellStopInfo); } +/******************************************************************* + * + * @brief Handles stop indication from MAC + * + * @details + * + * Function : duHandleStopInd + * + * Functionality: + * Handles stop indication from MAC + * + * @params[in] Post structure pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t duHandleStopInd(Pst *pst, MacCellStopInfo *cellStopId) +{ + if(cellStopId->cellId <=0 || cellStopId->cellId > DU_MAX_CELLS) + { + DU_LOG("\nDU APP : Invalid Cell Id %d", cellStopId->cellId); + } + if(duCb.actvCellLst[cellStopId->cellId-1] != NULL) + { + if(duCb.actvCellLst[cellStopId->cellId-1]->firstSlotIndRcvd) + { + duCb.actvCellLst[cellStopId->cellId-1]->firstSlotIndRcvd = false; + if((duCb.actvCellLst[cellStopId->cellId-1]->cellStatus == \ + ACTIVATED)) + { + DU_LOG("\nDU APP : 5G-NR Cell %d is DOWN", cellStopId->cellId); + duCb.actvCellLst[cellStopId->cellId-1]->cellStatus = DELETION_IN_PROGRESS; + } + } + } + if((pst->selector == DU_SELECTOR_LWLC) || (pst->selector == DU_SELECTOR_TC)) + DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellStopId, sizeof(MacCellStopInfo)); + return ROK; +} /********************************************************************** End of file **********************************************************************/ diff --git a/src/phy_stub/l1_bdy1.c b/src/phy_stub/l1_bdy1.c index b5d40a3ac..814bb3939 100644 --- a/src/phy_stub/l1_bdy1.c +++ b/src/phy_stub/l1_bdy1.c @@ -532,8 +532,8 @@ PUBLIC S16 l1HdlStartReq(uint32_t msgLen, void *msg) if(clGlobalCp.phyState == PHY_STATE_CONFIGURED) { - duStartSlotIndicaion(); - MAC_FREE(startReq, msgLen); + l1HdlSlotIndicaion(FALSE); + MAC_FREE(startReq, sizeof(fapi_start_req_t)); } else { @@ -685,6 +685,84 @@ PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) return ROK; } +/******************************************************************* + * + * @brief Builds and Send the stop Indication message to MAC + * + * @details + * + * Function : l1BuildAndSendStopInd + * + * Functionality: + * -Send the Stop indication Message to MAC + * + * + * @return void + * + * ****************************************************************/ +PUBLIC uint16_t l1BuildAndSendStopInd() +{ +#ifdef FAPI + fapi_stop_ind_t *stopIndMsg = NULLP; + uint32_t msgLen = 0; + + MAC_ALLOC(stopIndMsg, sizeof(fapi_stop_ind_t)); + if(!stopIndMsg) + { + DU_LOG("\nPHY_STUB: Memory allocation failed for stop Indication Message"); + return RFAILED; + } + else + { + fillMsgHeader(&stopIndMsg->header, FAPI_STOP_INDICATION, msgLen); + DU_LOG("\n\nPHY_STUB: Processing Stop indication to MAC"); + handlePhyMessages(stopIndMsg->header.message_type_id,\ + sizeof(fapi_stop_ind_t), (void*)stopIndMsg); + MAC_FREE(stopIndMsg, sizeof(fapi_stop_ind_t)); + } +#endif + return ROK; +} + +/******************************************************************* + * + * @brief Handles stop request received from MAC + * + * @details + * + * Function : l1HdlStopReq + * + * Functionality: + * -Handles stop request received from MAC + * + * @params[in] Message length + * stop request message pointer + * + * @return void + * + * ****************************************************************/ + +PUBLIC S16 l1HdlStopReq(uint32_t msgLen, void *msg) +{ +#ifdef FAPI + fapi_stop_req_t *stopReq = (fapi_stop_req_t *)msg; + + if(clGlobalCp.phyState == PHY_STATE_RUNNING) + { + l1HdlSlotIndicaion(TRUE); + DU_LOG("\nPHY_STUB: Slot Indication is stopped successfully"); + l1BuildAndSendStopInd(); + MAC_FREE(stopReq, msgLen); + } + else + { + DU_LOG("\nPHY_STUB: Received Stop Req in PHY State %d", clGlobalCp.phyState); + return RFAILED; + } +#endif + return ROK; +} + /******************************************************************* * * @brief Receives message from MAC @@ -727,6 +805,9 @@ void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg) case FAPI_UL_TTI_REQUEST: l1HdlUlTtiReq(msgLen, msg); break; + case FAPI_STOP_REQUEST: + l1HdlStopReq(msgLen, msg); + break; default: DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType); break; diff --git a/src/phy_stub/l1_bdy2.c b/src/phy_stub/l1_bdy2.c index 67f66f886..ebca8428f 100644 --- a/src/phy_stub/l1_bdy2.c +++ b/src/phy_stub/l1_bdy2.c @@ -19,6 +19,7 @@ /* This file handles slot indication */ #include +#include #include #include #include @@ -26,6 +27,7 @@ #include "du_log.h" uint16_t l1BuildAndSendSlotIndication(); +pthread_t thread = 0; void *GenerateTicks(void *arg) { @@ -45,15 +47,25 @@ void *GenerateTicks(void *arg) return((void *)NULLP); } -void duStartSlotIndicaion() +void l1HdlSlotIndicaion(bool stopSlotInd) { - pthread_t thread; int ret; - ret = pthread_create(&thread, NULL, GenerateTicks, NULL); - if(ret) + if(!stopSlotInd) { - DU_LOG("\nPHY_STUB: Unable to create thread"); + ret = pthread_create(&thread, NULL, GenerateTicks, NULL); + if(ret) + { + DU_LOG("\nPHY_STUB: Unable to create thread"); + } + } + else + { + ret = pthread_cancel(thread); + if(ret) + { + DU_LOG("\nPHY_STUB: Unable to stop thread"); + } } } -- 2.16.6