Memory handling fixes [Issue-ID: ODUHIGH-337]
[o-du/l2.git] / src / 5gnrmac / rg_lmm.c
index 186599d..fc59447 100755 (executable)
 #endif
 #include "ss_rbuf.h"
 #include "ss_rbuf.x"
-#include "lwr_mac.h"         /* MAC CL defines */
 #include "mac_sch_interface.h"
 #include "lwr_mac_upr_inf.h"
 #include "mac.h"
-#include "lwr_mac_phy.h"
 #include "lwr_mac_fsm.h"
+#include "lwr_mac_phy.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -77,7 +76,6 @@ Void rgGetSId ARGS((SystemId *s));
 #endif /* __cplusplus */
 
 /* Public variable declaration */
-LwrMacCb   lwrMacCb;
 MacCb  macCb;
 
 /* forward references */
@@ -186,19 +184,11 @@ Reason reason          /* reason */
    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
 #endif
 
-   /* Initializing CL control block */
-   memset(&lwrMacCb, 0, sizeof(LwrMacCb));
-   lwrMacCb.region = region;
-   lwrMacCb.pool = 0;
-   lwrMacCb.clCfgDone = TRUE;
-   lwrMacCb.numCell = 0;
-   lwrMacCb.phyState = PHY_STATE_IDLE; 
-
    /* Initialize Scheduler as well */
    schActvInit(ENTMAC, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
 
    /* Initialize lower mac */
-   lwrMacLayerInit();
+   lwrMacLayerInit(region, 0);
 
    return ROK;
 
@@ -258,8 +248,6 @@ RgMngmt  *cfg     /* config structure  */
 #ifdef INTEL_WLS_MEM
          /* Start WLS message receiver thread */
          LwrMacStartWlsRcvr();
-         /* Allocate memory for UL transmissions */
-         LwrMacEnqueueWlsBlock();
 #endif
         reason = rgLMMGenCfg(inst,&cfg->t.cfg); 
         break;
@@ -848,6 +836,7 @@ RgCfg *cfg            /* Configuaration information */
    rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
    rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
 
+   macCb.tmrRes = cfg->s.genCfg.tmrRes;
    macCb.macInst = rgCb[inst].rgInit.inst;
    macCb.procId = rgCb[inst].rgInit.procId;
 
@@ -878,16 +867,15 @@ RgCfg *cfg            /* Configuaration information */
    }
    rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
    /* Initialize the timer blocks */
-   cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
+   cmInitTimers(macCb.tmrBlk, MAX_NUM_TIMER);
    /* Initialzie the timer queue */   
-   memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
+   memset(&macCb.tmrTq, 0, sizeof(CmTqType) * MAC_TQ_SIZE);
    /* Initialize the timer control point */
-   memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
-   rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
-#if 0
+   memset(&macCb.tmrTqCp, 0, sizeof(CmTqCp));
+   macCb.tmrTqCp.tmrLen = MAC_TQ_SIZE;
+
    /* Timer Registration request to SSI */
-   if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
-           (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
+   if(ODU_REG_TMR_MT(ENTMAC, macCb.macInst, macCb.tmrRes, macActvTmr) != ROK)
    {
 
       DU_LOG("\nERROR  -->  MAC : Failed to register timer");
@@ -899,7 +887,7 @@ RgCfg *cfg            /* Configuaration information */
 
       return (LCM_REASON_MEM_NOAVAIL);
    }
-#endif
+
    /* Set Config done in TskInit */
    rgCb[inst].rgInit.cfgDone = TRUE;
 
@@ -968,7 +956,7 @@ static Void rgLMMShutdown(Inst inst)
 
    /* De-register the Timer Service */
    (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
-        (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr); 
+        (S16)rgCb[inst].genCfg.tmrRes, macActvTmr); 
 
    /* call back the task initialization function to intialize
     * the global RgCb Struct */
@@ -1756,31 +1744,6 @@ uint8_t status               /* Status */
    return (ret);
 }
 
-\f
-/**
- * @brief LTE MAC timer call back function registered with SSI. 
- *
- * @details
- *
- *     Function :  rgActvTmr
- *     
- *     This function is invoked by SSI for every timer activation
- *     period expiry.
- *     
- *  @return  S16
- *      -# ROK
- **/
-S16 rgActvTmr(Ent ent,Inst inst)
-{
-   Inst macInst = (inst  - RG_INST_START);
-
-   /* Check if any MAC timer has expired */ 
-   cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
-
-   return ROK;
-
-} /* end of rgActvTmr */
-
 /**********************************************************************
 
   End of file