From cbb5d8d83a41cbf191347d447a66c9cd062d4d81 Mon Sep 17 00:00:00 2001 From: sphoorthi Date: Wed, 23 Jun 2021 13:03:02 +0530 Subject: [PATCH] Using TAPA Task to generated PHY Stub's slot indication [Issue-Id: ODUHIGH-348] Change-Id: I3622d5e3a2d5cb3276067206a337e12828a4780b Signed-off-by: lal.harshita --- src/5gnrmac/lwr_mac_ex_ms.c | 99 +++++++++++++++++++++++++++----------- src/5gnrmac/lwr_mac_handle_phy.c | 2 + src/cm/lphy_stub.h | 3 -- src/cm/lwr_mac_phy_stub_inf.h | 24 +++++++++ src/cm/ssi.h | 4 ++ src/du_app/du_mgr_main.c | 65 ++++++++++++++++++++++++- src/du_app/du_msg_hdl.c | 1 - src/mt/mt_ss.c | 44 +++++++++++++++++ src/mt/mt_ss.h | 4 ++ src/phy_stub/phy_stub.h | 24 +++++---- src/phy_stub/phy_stub_ex_ms.c | 91 +++++++++++++++++++++++++++++++++++ src/phy_stub/phy_stub_msg_hdl.c | 65 +++++++++++++++++++------ src/phy_stub/phy_stub_thread_hdl.c | 52 ++++++++++++++------ src/phy_stub/phy_stub_utils.h | 61 +++++++++++++++++++++++ 14 files changed, 467 insertions(+), 72 deletions(-) delete mode 100644 src/cm/lphy_stub.h create mode 100644 src/cm/lwr_mac_phy_stub_inf.h create mode 100644 src/phy_stub/phy_stub_ex_ms.c create mode 100644 src/phy_stub/phy_stub_utils.h diff --git a/src/5gnrmac/lwr_mac_ex_ms.c b/src/5gnrmac/lwr_mac_ex_ms.c index 052e450c9..fd7dedfbc 100644 --- a/src/5gnrmac/lwr_mac_ex_ms.c +++ b/src/5gnrmac/lwr_mac_ex_ms.c @@ -19,8 +19,16 @@ /* This file is the entry point for Lower MAC */ #include "common_def.h" +#include "mac_utils.h" #include "lwr_mac_fsm.h" #include "lwr_mac_phy.h" +#ifdef INTEL_FAPI +#include "fapi.h" +#include "fapi_vendor_extension.h" +#endif +#ifndef INTEL_WLS_MEM +#include "lwr_mac_phy_stub_inf.h" +#endif /************************************************************************** * @brief Task Initiation callback function. @@ -74,38 +82,75 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf) switch(pst->srcEnt) { case ENTLWRMAC: - { - switch(pst->event) - { + { + switch(pst->event) + { #ifdef INTEL_WLS_MEM - case EVT_START_WLS_RCVR: - { - ODU_PUT_MSG_BUF(mBuf); + case EVT_START_WLS_RCVR: + { + ODU_PUT_MSG_BUF(mBuf); - /* Allocate memory for intial UL transmission */ - LwrMacEnqueueWlsBlock(); + /* Allocate memory for intial UL transmission */ + LwrMacEnqueueWlsBlock(); - /* Start thread to receive from L1 */ - DU_LOG("\nINFO --> LWR MAC: Starting WLS receiver thread"); - LwrMacRecvPhyMsg(); - break; - } + /* Start thread to receive from L1 */ + DU_LOG("\nINFO --> LWR MAC: Starting WLS receiver thread"); + LwrMacRecvPhyMsg(); + break; + } #endif - default: - { - SPutMsg(mBuf); - DU_LOG("\nERROR --> LWR MAC: Invalid event %d received", pst->event); - ret = RFAILED; - } - } - break; - } + default: + { + SPutMsg(mBuf); + DU_LOG("\nERROR --> LWR MAC: Invalid event %d received", pst->event); + ret = RFAILED; + } + } + break; + } + +#ifndef INTEL_WLS_MEM + case ENTPHYSTUB: + { + switch(pst->event) + { + case EVT_PHY_STUB_SLOT_IND: + { + fapi_slot_ind_t *slotIndMsg; + + CMCHKUNPK(oduUnpackPointer, (PTR *)&slotIndMsg, mBuf); + ODU_PUT_MSG_BUF(mBuf); + + procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg); + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotIndMsg, sizeof(fapi_slot_ind_t)); + break; + } + + case EVT_PHY_STUB_STOP_IND: + { + fapi_stop_ind_t *stopIndMsg; + CMCHKUNPK(oduUnpackPointer, (PTR *)&stopIndMsg, mBuf); + ODU_PUT_MSG_BUF(mBuf); + + procPhyMessages(stopIndMsg->header.msg_id, sizeof(fapi_stop_ind_t), (void*)stopIndMsg); + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, stopIndMsg, sizeof(fapi_stop_ind_t)); + break; + } + default: + { + DU_LOG("\nERROR --> LWR_MAC: Invalid event %d received from PHY STUB", pst->event); + } + } + break; + } +#endif + default: - { - SPutMsg(mBuf); - DU_LOG("\nERROR --> LWR MAC: Message from invalid source entity %d", pst->srcEnt); - ret = RFAILED; - } + { + SPutMsg(mBuf); + DU_LOG("\nERROR --> LWR MAC: Message from invalid source entity %d", pst->srcEnt); + ret = RFAILED; + } } return ret; } diff --git a/src/5gnrmac/lwr_mac_handle_phy.c b/src/5gnrmac/lwr_mac_handle_phy.c index d8d1dd84a..7e9d54e89 100644 --- a/src/5gnrmac/lwr_mac_handle_phy.c +++ b/src/5gnrmac/lwr_mac_handle_phy.c @@ -116,6 +116,7 @@ uint8_t procSlotInd(fapi_slot_ind_t *fapiSlotInd) slotInd->slot = fapiSlotInd->slot; FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_SLOT_IND_TO_MAC); + pst.selector = ODU_SELECTOR_LWLC; ret = (*sendSlotIndOpts[pst.selector])(&pst, slotInd); } else @@ -159,6 +160,7 @@ uint8_t procStopInd() DU_LOG("\nINFO --> LWR_MAC: PHY has moved to configured state"); FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_STOP_IND_TO_MAC); + pst.selector = ODU_SELECTOR_LWLC; return (*sendStopIndOpts[pst.selector])(&pst, cellId); } diff --git a/src/cm/lphy_stub.h b/src/cm/lphy_stub.h deleted file mode 100644 index 7b5156f0e..000000000 --- a/src/cm/lphy_stub.h +++ /dev/null @@ -1,3 +0,0 @@ -void l1HdlSlotIndicaion(bool); -uint8_t buildAndSendSlotIndication(); -uint8_t duSendEgtpSlotInd(); diff --git a/src/cm/lwr_mac_phy_stub_inf.h b/src/cm/lwr_mac_phy_stub_inf.h new file mode 100644 index 000000000..a15ef1716 --- /dev/null +++ b/src/cm/lwr_mac_phy_stub_inf.h @@ -0,0 +1,24 @@ +/******************************************************************************* +################################################################################ +# 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. # +################################################################################ +*******************************************************************************/ + +#define EVT_PHY_STUB_SLOT_IND 1 +#define EVT_PHY_STUB_STOP_IND 2 + +/********************************************************************** + End of file +***********************************************************************/ diff --git a/src/cm/ssi.h b/src/cm/ssi.h index eaeff336e..3379caeab 100755 --- a/src/cm/ssi.h +++ b/src/cm/ssi.h @@ -1338,7 +1338,11 @@ #define ENTUZ 0xd2 /* S1AP User */ /* ssi_h_001.main_134 : Adtion for eGTP protocol */ #define ENTEG 0xd3 /* EGTP Layer */ +#ifndef INTEL_WLS_MEM +#define ENTPHYSTUB 0xd4 +#else #define ENTEU 0xd4 /* EGTP USER */ +#endif /* ssi_h_001.main_135 : addition of LTE related entities */ #define ENTLWRMAC 0xd5 /* LTE-PHY */ #define ENTMAC 0xd6 /* LTE-MAC */ diff --git a/src/du_app/du_mgr_main.c b/src/du_app/du_mgr_main.c index 76066dafe..d4988301c 100644 --- a/src/du_app/du_mgr_main.c +++ b/src/du_app/du_mgr_main.c @@ -45,6 +45,10 @@ uint8_t rgActvTsk (Pst *, Buffer *); uint8_t rgActvInit (Ent, Inst, Region, Reason); uint8_t lwrMacActvTsk(Pst *, Buffer *); uint8_t lwrMacActvInit(Ent, Inst, Region, Reason); +#ifndef INTEL_WLS_MEM +uint8_t phyStubActvTsk(Pst *, Buffer *); +uint8_t phyStubActvInit(Ent, Inst, Region, Reason); +#endif /* Global variable */ DuCfgParams duCfgParam; @@ -105,6 +109,8 @@ uint8_t duAppInit(SSTskId sysTskId) bool bringCellUp(uint16_t cellId) { + duProcCfgComplete(); + BuildAndSendF1SetupReq(); return true; } @@ -127,6 +133,7 @@ bool bringCellUp(uint16_t cellId) bool bringCellDown(uint16_t cellId) { + BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE); return true; } #endif @@ -318,6 +325,44 @@ uint8_t lwrMacInit(SSTskId sysTskId) return ROK; } +#ifndef INTEL_WLS_MEM +/******************************************************************* + * + * @brief Initializes Phy stub slot indication generator task + * + * @details + * + * Function : phyStubInit + * + * Functionality: + * - Registers and attaches TAPA tasks for Phy stub's slot + * indication generator + * + * @params[in] system task ID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t phyStubInit(SSTskId sysTskId) +{ + /* Register PHY stub slot indication TAPA Task */ + if(ODU_REG_TTSK((Ent)ENTPHYSTUB, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, + phyStubActvInit, (ActvTsk)phyStubActvTsk) != ROK) + { + return RFAILED; + } + /* Attach Phy stub slot indication TAPA Task */ + if (ODU_ATTACH_TTSK((Ent)ENTPHYSTUB, (Inst)0, sysTskId)!= ROK) + { + return RFAILED; + } + + DU_LOG("\nINFO --> DU_APP : PHY stub slot indication TAPA task created and registered to %d sys task", + sysTskId); + return ROK; +} +#endif + /******************************************************************* * * @brief Initializes system and TAPA tasks @@ -337,7 +382,7 @@ uint8_t lwrMacInit(SSTskId sysTskId) uint8_t commonInit() { /* Declare system task Ids */ - SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, lwr_mac_stsk; + SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, lwr_mac_stsk, phy_stub_slot_ind_stsk; pthread_attr_t attr; @@ -394,6 +439,16 @@ uint8_t commonInit() } ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0); +#ifndef INTEL_WLS_MEM + /* system task for phy stub's slot indication generator thread */ + if(ODU_CREATE_TASK(PRIOR0, &phy_stub_slot_ind_stsk) != ROK) + { + DU_LOG("\nERROR --> DU_APP : System Task creation for Phy stub slot indication generator failed. MAX STSK [%d]", SS_MAX_STSKS); + return RFAILED; + } + +#endif + /* Create TAPA tasks */ if(duAppInit(du_app_stsk) != ROK) { @@ -431,6 +486,14 @@ uint8_t commonInit() return RFAILED; } +#ifndef INTEL_WLS_MEM + if(phyStubInit(phy_stub_slot_ind_stsk) != ROK) + { + DU_LOG("\nERROR --> DU_APP : PHY stub slot indication Tapa Task initialization failed"); + return RFAILED; + } +#endif + return ROK; } diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index d1731ad33..85579c54d 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -36,7 +36,6 @@ #include "du_ue_mgr.h" #include "lsctp.h" #include "legtp.h" -#include "lphy_stub.h" #include "du_utils.h" #include "du_cell_mgr.h" diff --git a/src/mt/mt_ss.c b/src/mt/mt_ss.c index 840cb7c9b..dc3c0b310 100644 --- a/src/mt/mt_ss.c +++ b/src/mt/mt_ss.c @@ -515,6 +515,20 @@ SsRegCfg cfgRegInfo[SS_MAX_REGS] = { SS_POOL_STATIC, 0 } } } +#ifndef INTEL_WLS_MEM + , + { + SS_DFLT_REGION + 7, SS_MAX_POOLS_PER_REG - 1, + { + { SS_POOL_DYNAMIC, MT_POOL_0_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_1_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_2_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_3_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_4_DSIZE }, + { SS_POOL_STATIC, 0 } + } + } +#endif #endif /* SS_LOCKLESS_MEMORY */ }; @@ -611,6 +625,21 @@ MtDynMemCfg mtDynMemoCfg = {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} } } +#ifndef INTEL_WLS_MEM + , + { + SS_DFLT_REGION + 7, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + { + /* block size, no. of blocks, Upper threshold, lower threshold */ + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} + } + } +#endif #if ((defined (SPLIT_RLC_DL_TASK)) && (!defined (L2_L3_SPLIT))) , { @@ -777,6 +806,21 @@ MtMemCfg mtMemoCfg = {MT_BKT_4_DSIZE, MT_BKT_4_STATIC_NUMBLKS} /* block size, no. of blocks */ } } +#ifndef INTEL_WLS_MEM + , + { + SS_DFLT_REGION + 7, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + MT_HEAP_SIZE, /* heap size */ + { + {MT_BKT_0_DSIZE, MT_BKT_0_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_1_DSIZE, MT_BKT_1_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_2_DSIZE, MT_BKT_2_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_3_DSIZE, MT_BKT_3_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_4_DSIZE, MT_BKT_4_STATIC_NUMBLKS} /* block size, no. of blocks */ + } + } +#endif #endif /* SS_LOCKLESS_MEMORY */ STATIC_MEM_CFG } diff --git a/src/mt/mt_ss.h b/src/mt/mt_ss.h index 2dc42fa86..8e6f9ebd3 100755 --- a/src/mt/mt_ss.h +++ b/src/mt/mt_ss.h @@ -63,7 +63,11 @@ #define SS_MAX_STSKS 5 #endif #else +#ifndef INTEL_WLS_MEM +#define SS_MAX_STSKS 8 +#else #define SS_MAX_STSKS 7 +#endif #endif #endif /* SS_MULTICORE_SUPPORT */ diff --git a/src/phy_stub/phy_stub.h b/src/phy_stub/phy_stub.h index 4d78c49dd..afb8b2233 100644 --- a/src/phy_stub/phy_stub.h +++ b/src/phy_stub/phy_stub.h @@ -26,16 +26,18 @@ #define NR_PCI 1 #define SLOT_DELAY 3 -uint16_t sfnValue = 0; -uint16_t slotValue = 0; -bool rachIndSent = false; -bool msg3Sent = false; -bool msg5ShortBsrSent = false; -bool msg5Sent = false; -bool dlDedMsg = false; -bool msgSecurityModeComp = false; -bool msgRrcReconfiguration = false; -bool msgRegistrationComp = false; +bool slotIndicationStarted; +uint16_t sfnValue; +uint16_t slotValue; +bool rachIndSent; +bool msg3Sent; +bool msg5ShortBsrSent; +bool msg5Sent; +bool dlDedMsg; +bool msgSecurityModeComp; +bool msgRrcReconfiguration; +bool msgRegistrationComp; + typedef enum { MSG_TYPE_MSG3, @@ -54,6 +56,8 @@ void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)); #endif void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg); void l1StartConsoleHandler(); +void l1HdlSlotIndicaion(bool); +void GenerateTicks(); /********************************************************************** End of file diff --git a/src/phy_stub/phy_stub_ex_ms.c b/src/phy_stub/phy_stub_ex_ms.c new file mode 100644 index 000000000..4bbdbe1e2 --- /dev/null +++ b/src/phy_stub/phy_stub_ex_ms.c @@ -0,0 +1,91 @@ +/******************************************************************************* +################################################################################ +# 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. # +################################################################################ +*******************************************************************************/ + +#include "common_def.h" +#include "phy_stub_utils.h" +#ifdef INTEL_FAPI +#include "fapi.h" +#include "fapi_vendor_extension.h" +#endif +#include "phy_stub.h" + +/******************************************************************* +* +* @brief Initializes Phy stub slot indication generator task +* +* @details +* +* Function : phyStubActvInit +* +* Functionality: +* - Initializes Phy stub slot indication generator task +* +* @params[in] +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t phyStubActvInit(Ent ent, Inst inst, Region reg, Reason reason) +{ + slotIndicationStarted = false; + sfnValue = 0; + slotValue = 0; + + return ROK; +} + + +/******************************************************************* +* +* @brief Receives messages for Phy stub slot indication generator task +* +* @details +* +* Function : phyStubActvTsk +* +* Functionality: +* - Receives messages for Phy stub slot indication generator task +* +* @params[in] +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t phyStubActvTsk(Pst *pst, Buffer *mBuf) +{ + DU_LOG("\nPHY_STUB: Received Event [%d]", pst->event); + switch(pst->srcEnt) + { + case ENTPHYSTUB: + { + switch(pst->event) + { + case EVT_PHY_START_SLOT_IND: + { + ODU_PUT_MSG_BUF(mBuf); + GenerateTicks(); + } + } + } + } + return ROK; +} + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/phy_stub/phy_stub_msg_hdl.c b/src/phy_stub/phy_stub_msg_hdl.c index 8ee5d1bfa..56b85be93 100644 --- a/src/phy_stub/phy_stub_msg_hdl.c +++ b/src/phy_stub/phy_stub_msg_hdl.c @@ -30,10 +30,11 @@ #include "fapi.h" #include "fapi_vendor_extension.h" #endif -#include "lphy_stub.h" #include "lwr_mac_upr_inf.h" #include "mac_utils.h" #include "phy_stub.h" +#include "phy_stub_utils.h" +#include "lwr_mac_phy_stub_inf.h" /******************************************************************* * @@ -244,6 +245,15 @@ 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; + #ifdef INTEL_FAPI p_fapi_api_queue_elem_t configReqElem = (p_fapi_api_queue_elem_t)msg; fapi_config_req_t *configReq = (fapi_config_req_t *)(configReqElem +1); @@ -639,10 +649,13 @@ uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn) * ****************************************************************/ uint16_t l1BuildAndSendSlotIndication() { + Pst pst; + Buffer *mBuf; + #ifdef INTEL_FAPI fapi_slot_ind_t *slotIndMsg; - MAC_ALLOC(slotIndMsg, sizeof(fapi_slot_ind_t)); + MAC_ALLOC_SHRABL_BUF(slotIndMsg, sizeof(fapi_slot_ind_t)); if(!slotIndMsg) { DU_LOG("\nERROR --> PHY_STUB: Memory allocation failed for slot Indication Message"); @@ -655,24 +668,36 @@ uint16_t l1BuildAndSendSlotIndication() slotIndMsg->slot = slotValue; #ifdef ODU_SLOT_IND_DEBUG_LOG - DU_LOG("\n\nDEBUG --> PHY_STUB: SLOT indication [%d:%d]",sfnValue,slotValue); + DU_LOG("\n\nDEBUG --> PHY_STUB: Sending Slot Indication [%d : %d] to MAC", sfnValue, slotValue); #endif + /* increment for the next TTI */ slotValue++; if(sfnValue >= MAX_SFN_VALUE && slotValue > MAX_SLOT_VALUE) { - sfnValue = 0; - slotValue = 0; + sfnValue = 0; + slotValue = 0; } else if(slotValue > MAX_SLOT_VALUE) { - sfnValue++; - slotValue = 0; + sfnValue++; + slotValue = 0; } fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, \ - sizeof(fapi_slot_ind_t) - sizeof(fapi_msg_t)); - procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg); - MAC_FREE(slotIndMsg, sizeof(fapi_slot_ind_t)); + sizeof(fapi_slot_ind_t) - sizeof(fapi_msg_t)); + + memset(&pst, 0, sizeof(Pst)); + FILL_PST_PHY_STUB_TO_LWR_MAC(pst, EVT_PHY_STUB_SLOT_IND); + + ODU_GET_MSG_BUF(pst.region, pst.pool, &mBuf); + if(!mBuf) + { + DU_LOG("\nERROR --> PHY_STUB: Failed to allocate memory for slot indication buffer"); + MAC_FREE_SHRABL_BUF(pst.region, pst.pool, slotIndMsg, sizeof(fapi_slot_ind_t)); + return RFAILED; + } + CMCHKPK(oduPackPointer, (PTR)slotIndMsg, mBuf); + ODU_POST_TASK(&pst, mBuf); } #endif return ROK; @@ -1053,10 +1078,12 @@ S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) uint16_t l1BuildAndSendStopInd() { #ifdef INTEL_FAPI + Pst pst; + Buffer *mBuf = NULLP; fapi_stop_ind_t *stopIndMsg = NULLP; uint32_t msgLen = 0; - MAC_ALLOC(stopIndMsg, sizeof(fapi_stop_ind_t)); + MAC_ALLOC_SHRABL_BUF(stopIndMsg, sizeof(fapi_stop_ind_t)); if(!stopIndMsg) { DU_LOG("\nERROR --> PHY_STUB: Memory allocation failed for stop Indication Message"); @@ -1066,9 +1093,18 @@ uint16_t l1BuildAndSendStopInd() { fillMsgHeader(&stopIndMsg->header, FAPI_STOP_INDICATION, msgLen); DU_LOG("\n\nINFO --> PHY_STUB: Processing Stop indication to MAC"); - procPhyMessages(stopIndMsg->header.msg_id,\ - sizeof(fapi_stop_ind_t), (void*)stopIndMsg); - MAC_FREE(stopIndMsg, sizeof(fapi_stop_ind_t)); + + memset(&pst, 0, sizeof(Pst)); + FILL_PST_PHY_STUB_TO_LWR_MAC(pst, EVT_PHY_STUB_STOP_IND); + ODU_GET_MSG_BUF(pst.region, pst.pool, &mBuf); + if(!mBuf) + { + DU_LOG("\nERROR --> PHY_STUB: Failed to allocate memory for slot indication buffer"); + MAC_FREE_SHRABL_BUF(pst.region, pst.pool, stopIndMsg, sizeof(fapi_stop_ind_t)); + return RFAILED; + } + CMCHKPK(oduPackPointer, (PTR)stopIndMsg, mBuf); + ODU_POST_TASK(&pst, mBuf); } #endif return ROK; @@ -1099,7 +1135,6 @@ S16 l1HdlStopReq(uint32_t msgLen, void *msg) { l1HdlSlotIndicaion(TRUE); DU_LOG("\nINFO --> PHY_STUB: Slot Indication is stopped successfully"); - l1BuildAndSendStopInd(); MAC_FREE(msg, msgLen); } else diff --git a/src/phy_stub/phy_stub_thread_hdl.c b/src/phy_stub/phy_stub_thread_hdl.c index f320001d5..29a4b0100 100644 --- a/src/phy_stub/phy_stub_thread_hdl.c +++ b/src/phy_stub/phy_stub_thread_hdl.c @@ -19,8 +19,12 @@ /* This file handles slot indication */ #include "common_def.h" -#include "lphy_stub.h" -#include "du_log.h" +#include "phy_stub_utils.h" +#ifdef INTEL_FAPI +#include "fapi.h" +#include "fapi_vendor_extension.h" +#endif +#include "phy_stub.h" uint8_t l1SendUlUserData(); uint8_t l1SendStatusPdu(); @@ -42,7 +46,7 @@ pthread_t thread = 0; * RFAILED - failure * * ****************************************************************/ -void *GenerateTicks(void *arg) +void GenerateTicks() { #ifdef NR_TDD int milisec = 0.5; /* 0.5ms */ @@ -51,16 +55,36 @@ void *GenerateTicks(void *arg) #endif struct timespec req = {0}; + slotIndicationStarted = true; req.tv_sec = 0; req.tv_nsec = milisec * 1000000L; - while(1) + DU_LOG("\nPHY_STUB : GenerateTicks : Starting to generate slot indications"); + + while(slotIndicationStarted) { clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL); /* Send Slot indication indication to lower mac */ l1BuildAndSendSlotIndication(); } - return((void *)NULLP); + + DU_LOG("\nINFO --> PHY_STUB : Slot indication stopped"); + + /* Initialize all global variables */ + sfnValue = 0; + slotValue = 0; + rachIndSent = false; + msg3Sent = false; + msg5ShortBsrSent = false; + msg5Sent = false; + dlDedMsg = false; + msgSecurityModeComp = false; + msgRrcReconfiguration = false; + msgRegistrationComp = false; + + /* Send Stop indication to MAC */ + sleep(1); + l1BuildAndSendStopInd(); } /******************************************************************* @@ -80,23 +104,21 @@ void *GenerateTicks(void *arg) * ****************************************************************/ void l1HdlSlotIndicaion(bool stopSlotInd) { + Pst pst; int ret; + Buffer *mBuf = NULLP; if(!stopSlotInd) { - ret = pthread_create(&thread, NULL, GenerateTicks, NULL); - if(ret) - { - DU_LOG("\nERROR --> PHY_STUB: Unable to create thread"); - } + DU_LOG("\nPHY_STUB: Sending start slot indication event to self"); + memset(&pst, 0, sizeof(Pst)); + FILL_PST_PHY_TO_PHY(pst, EVT_PHY_START_SLOT_IND); + ODU_GET_MSG_BUF(pst.region, pst.pool, &mBuf); + ODU_POST_TASK(&pst, mBuf); } else { - ret = pthread_cancel(thread); - if(ret) - { - DU_LOG("\nERROR --> PHY_STUB: Unable to stop thread"); - } + slotIndicationStarted = false; } } diff --git a/src/phy_stub/phy_stub_utils.h b/src/phy_stub/phy_stub_utils.h new file mode 100644 index 000000000..3e3405cb6 --- /dev/null +++ b/src/phy_stub/phy_stub_utils.h @@ -0,0 +1,61 @@ +/******************************************************************************* +################################################################################ +# 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. # +################################################################################ +*******************************************************************************/ + +#define PHY_STUB_MEM_REGION 0 +#define PHY_STUB_POOL 0 + +#define EVT_PHY_START_SLOT_IND 1 + +/* Fill Pst structure for sending msg from phy stub to self */ +#define FILL_PST_PHY_TO_PHY(_pst, _event) \ +{ \ + _pst.selector = ODU_SELECTOR_LWLC; \ + _pst.srcEnt = ENTPHYSTUB; \ + _pst.dstEnt = ENTPHYSTUB; \ + _pst.dstInst = 0; \ + _pst.srcInst = 0; \ + _pst.dstProcId = ODU_GET_PROCID(); \ + _pst.srcProcId = ODU_GET_PROCID(); \ + _pst.region = PHY_STUB_MEM_REGION; \ + _pst.pool = PHY_STUB_POOL; \ + _pst.event = _event; \ + _pst.route = 0; \ + _pst.prior = 0; \ + _pst.intfVer = 0; \ +} + +/* Fill Pst structure for sending msg from PHY stub to Lower MAC */ +#define FILL_PST_PHY_STUB_TO_LWR_MAC(_pst, _event) \ +{ \ + _pst.selector = ODU_SELECTOR_LWLC; \ + _pst.srcEnt = ENTPHYSTUB; \ + _pst.dstEnt = ENTLWRMAC; \ + _pst.dstInst = 0; \ + _pst.srcInst = 0; \ + _pst.dstProcId = ODU_GET_PROCID(); \ + _pst.srcProcId = ODU_GET_PROCID(); \ + _pst.region = PHY_STUB_MEM_REGION; \ + _pst.pool = PHY_STUB_POOL; \ + _pst.event = _event; \ + _pst.route = 0; \ + _pst.prior = 0; \ + _pst.intfVer = 0; \ +} +/********************************************************************** + End of file + **********************************************************************/ -- 2.16.6