Using TAPA Task to generated PHY Stub's slot indication [Issue-Id: ODUHIGH-348] 90/6390/1
authorsphoorthi <sphoorthi.dayanand@radisys.com>
Wed, 23 Jun 2021 07:33:02 +0000 (13:03 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Wed, 23 Jun 2021 07:34:01 +0000 (13:04 +0530)
Change-Id: I3622d5e3a2d5cb3276067206a337e12828a4780b
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
14 files changed:
src/5gnrmac/lwr_mac_ex_ms.c
src/5gnrmac/lwr_mac_handle_phy.c
src/cm/lphy_stub.h [deleted file]
src/cm/lwr_mac_phy_stub_inf.h [new file with mode: 0644]
src/cm/ssi.h
src/du_app/du_mgr_main.c
src/du_app/du_msg_hdl.c
src/mt/mt_ss.c
src/mt/mt_ss.h
src/phy_stub/phy_stub.h
src/phy_stub/phy_stub_ex_ms.c [new file with mode: 0644]
src/phy_stub/phy_stub_msg_hdl.c
src/phy_stub/phy_stub_thread_hdl.c
src/phy_stub/phy_stub_utils.h [new file with mode: 0644]

index 052e450..fd7dedf 100644 (file)
 /* This file is the entry point for Lower MAC */\r
 \r
 #include "common_def.h"\r
+#include "mac_utils.h"\r
 #include "lwr_mac_fsm.h"\r
 #include "lwr_mac_phy.h"\r
+#ifdef INTEL_FAPI\r
+#include "fapi.h"\r
+#include "fapi_vendor_extension.h"\r
+#endif\r
+#ifndef INTEL_WLS_MEM\r
+#include "lwr_mac_phy_stub_inf.h"\r
+#endif\r
 \r
 /**************************************************************************\r
  * @brief Task Initiation callback function. \r
@@ -74,38 +82,75 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf)
    switch(pst->srcEnt)\r
    {\r
       case ENTLWRMAC:\r
-        {\r
-           switch(pst->event)\r
-           {\r
+         {\r
+            switch(pst->event)\r
+            {\r
 #ifdef INTEL_WLS_MEM\r
-              case EVT_START_WLS_RCVR:\r
-                 {\r
-                    ODU_PUT_MSG_BUF(mBuf);\r
+               case EVT_START_WLS_RCVR:\r
+                  {\r
+                     ODU_PUT_MSG_BUF(mBuf);\r
 \r
-                    /* Allocate memory for intial UL transmission */\r
-                    LwrMacEnqueueWlsBlock();\r
+                     /* Allocate memory for intial UL transmission */\r
+                     LwrMacEnqueueWlsBlock();\r
 \r
-                    /* Start thread to receive from L1 */\r
-                    DU_LOG("\nINFO  -->  LWR MAC: Starting WLS receiver thread");\r
-                    LwrMacRecvPhyMsg();\r
-                    break;\r
-                 }\r
+                     /* Start thread to receive from L1 */\r
+                     DU_LOG("\nINFO  -->  LWR MAC: Starting WLS receiver thread");\r
+                     LwrMacRecvPhyMsg();\r
+                     break;\r
+                  }\r
 #endif\r
-              default:\r
-                 {\r
-                    SPutMsg(mBuf);\r
-                    DU_LOG("\nERROR  -->  LWR MAC: Invalid event %d received", pst->event);\r
-                    ret = RFAILED;\r
-                 }\r
-           }\r
-           break;\r
-        }\r
+               default:\r
+                  {\r
+                     SPutMsg(mBuf);\r
+                     DU_LOG("\nERROR  -->  LWR MAC: Invalid event %d received", pst->event);\r
+                     ret = RFAILED;\r
+                  }\r
+            }\r
+            break;\r
+         }\r
+\r
+#ifndef INTEL_WLS_MEM\r
+      case ENTPHYSTUB:\r
+         {\r
+            switch(pst->event)\r
+            {\r
+               case EVT_PHY_STUB_SLOT_IND:\r
+                  {\r
+                     fapi_slot_ind_t *slotIndMsg;\r
+\r
+                     CMCHKUNPK(oduUnpackPointer, (PTR *)&slotIndMsg, mBuf);\r
+                     ODU_PUT_MSG_BUF(mBuf);\r
+\r
+                     procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);\r
+                     MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotIndMsg, sizeof(fapi_slot_ind_t));\r
+                     break;\r
+                  }\r
+\r
+               case EVT_PHY_STUB_STOP_IND:\r
+                 {\r
+                    fapi_stop_ind_t *stopIndMsg;\r
+                    CMCHKUNPK(oduUnpackPointer, (PTR *)&stopIndMsg, mBuf);\r
+                    ODU_PUT_MSG_BUF(mBuf);\r
+\r
+                    procPhyMessages(stopIndMsg->header.msg_id, sizeof(fapi_stop_ind_t), (void*)stopIndMsg);\r
+                    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, stopIndMsg, sizeof(fapi_stop_ind_t));\r
+                    break;\r
+                 }\r
+               default:\r
+                  {\r
+                     DU_LOG("\nERROR  -->  LWR_MAC: Invalid event %d received from PHY STUB", pst->event);\r
+                  }\r
+            }\r
+            break;\r
+         }\r
+#endif\r
+\r
       default:\r
-        {\r
-           SPutMsg(mBuf);\r
-           DU_LOG("\nERROR  -->  LWR MAC: Message from invalid source entity %d", pst->srcEnt);\r
-           ret = RFAILED;\r
-        }\r
+         {\r
+            SPutMsg(mBuf);\r
+            DU_LOG("\nERROR  -->  LWR MAC: Message from invalid source entity %d", pst->srcEnt);\r
+            ret = RFAILED;\r
+         }\r
    }\r
    return ret;\r
 }\r
index d8d1dd8..7e9d54e 100644 (file)
@@ -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 (file)
index 7b5156f..0000000
+++ /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 (file)
index 0000000..a15ef17
--- /dev/null
@@ -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
+***********************************************************************/
index eaeff33..3379cae 100755 (executable)
 #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 */
index 76066da..d498830 100644 (file)
@@ -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;
 }
 
index d1731ad..85579c5 100644 (file)
@@ -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" 
 
index 840cb7c..dc3c0b3 100644 (file)
@@ -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
    }
index 2dc42fa..8e6f9eb 100755 (executable)
 #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 */
 
index 4d78c49..afb8b22 100644 (file)
 #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 (file)
index 0000000..4bbdbe1
--- /dev/null
@@ -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
+ **********************************************************************/
index 8ee5d1b..56b85be 100644 (file)
 #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
index f320001..29a4b01 100644 (file)
 /* 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 (file)
index 0000000..3e3405c
--- /dev/null
@@ -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
+ **********************************************************************/