MAC Clean-up [Issue-ID: ODUHIGH-212]
[o-du/l2.git] / src / 5gnrsch / rg_sch_lmm.c
index b94a6f5..c5539f9 100755 (executable)
@@ -39,16 +39,7 @@ static int RLOG_MODULE_ID=4096;
 static int RLOG_FILE_ID=167;
 
 /* 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 "common_def.h"
 #include "rg_env.h"        /* MAC Environment Defines */
 #include "rgr.h"           /* RGR Interface defines */
 #include "tfu.h"           /* RGU Interface defines */
@@ -64,15 +55,6 @@ static int RLOG_FILE_ID=167;
 #include "rl_common.h"
 
 /* header/extern include files (.x) */
-#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 "rgr.x"           /* RGR Interface includes */
 #include "rgm.x"           /* RGM Interface includes */
 #include "tfu.x"           /* RGU Interface includes */
@@ -86,15 +68,15 @@ static int RLOG_FILE_ID=167;
 PUBLIC Void rgSCHCmnInit ARGS((Void));
 #endif 
 /* forward references */
-
-
+extern int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
+#ifdef UNUSE_FUN
 PRIVATE U16 rgSCHLmmSapCfg ARGS((
    Inst           inst,
    RgCfg          *cfg,
    U8             sapIdx,
    Elmnt          sapType
 ));
-
+#endif
 PRIVATE Void rgSCHLmmShutdown ARGS((
    Inst inst
 ));
@@ -117,76 +99,6 @@ PUBLIC void printSchCellInfo(void)
    }
 }
 
-\f
-/**
- * @brief Task Initiation callback function. 
- *
- * @details
- *
- *     Function : schActvInit
- *     
- *     This function is supplied as one of parameters during MAC's 
- *     task registration. SSI will invoke this function once, after
- *     it creates and attaches this TAPA Task to a system task.
- *     
- *  @param[in]  Ent Entity, the entity ID of this task.     
- *  @param[in]  Inst Inst, the instance ID of this task.
- *  @param[in]  Region Region, the region ID registered for memory 
- *              usage of this task.
- *  @param[in]  Reason Reason.
- *  @return  S16
- *      -# ROK
- **/
-#ifdef ANSI
-PUBLIC S16 schActvInit
-(
-Ent    entity,            /* entity */
-Inst   instId,             /* instance */
-Region region,         /* region */
-Reason reason          /* reason */
-)
-#else
-PUBLIC S16 schActvInit(entity, instId, region, reason)
-Ent    entity;            /* entity */
-Inst   instId;             /* instance */
-Region region;         /* region */
-Reason reason;         /* reason */
-#endif
-{
-   Inst inst = (instId  - SCH_INST_START);
-
-   TRC2(schActvInit);
-
-   /* Initialize the MAC TskInit structure to zero */
-   cmMemset ((U8 *)&rgSchCb[inst], 0, sizeof(RgSchCb));
-
-   /* Initialize the MAC TskInit with received values */
-   rgSchCb[inst].rgSchInit.ent = entity;
-   rgSchCb[inst].rgSchInit.inst = inst;
-   rgSchCb[inst].rgSchInit.region = region;
-   rgSchCb[inst].rgSchInit.pool = 0;
-   rgSchCb[inst].rgSchInit.reason = reason;
-   rgSchCb[inst].rgSchInit.cfgDone = FALSE;
-   rgSchCb[inst].rgSchInit.acnt = FALSE;
-   rgSchCb[inst].rgSchInit.usta = FALSE;
-   rgSchCb[inst].rgSchInit.trc = FALSE;
-#ifdef DEBUGP
-#ifdef RG_DEBUG
-   /*  disabling debugs by default */
-   /* rgSchCb[inst].rgSchInit.dbgMask = 0xffffffff; */
-#endif
-#endif /* DEBUGP */
-   rgSchCb[inst].rgSchInit.procId = SFndProcId();
-
-   rgSchCb[inst].rgrSap = NULLP;
-   rgSchCb[inst].tfuSap = NULLP;
-   rgSchCb[inst].rgmSap = NULLP;
-   rgSCHCmnInit();
-
-   RETVALUE(ROK);
-} /* schActvInit */
-\f
-\f
 /**
  * @brief SAP Configuration Handler. 
  *
@@ -194,7 +106,7 @@ Reason reason;         /* reason */
  *
  *     Function : rgSCHLmmSapCfg
  *     
- *     This function in called by HandleSchGenCfgReq(). It handles the
+ *     This function in called by SchProcGenCfgReq(). It handles the
  *     interface SAP configuration of the scheduler instance. It 
  *     initializes the sapState to LRG_UNBND. Returns
  *     reason for success/failure of this function.
@@ -205,6 +117,7 @@ Reason reason;         /* reason */
  *      -# LCM_REASON_INVALID_SAP
  *      -# LCM_REASON_NOT_APPL
  **/
+#ifdef UNUSE_FUN
 #ifdef ANSI
 PRIVATE U16 rgSCHLmmSapCfg
 (
@@ -234,8 +147,8 @@ Elmnt sapType;            /* SAP Type */
    {   
       case STRGRSAP:
 #ifndef CL_MAC_LWLC
-         if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != RGR_SEL_TC) &&
-             (cfg->s.schInstCfg.rgrSap[sapIdx].selector != RGR_SEL_LC))
+         if ((cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_TC) &&
+             (cfg->s.schInstCfg.rgrSap[sapIdx].selector != ODU_SELECTOR_LC))
          {
             ret = LCM_REASON_INVALID_PAR_VAL;
             RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
@@ -268,8 +181,8 @@ Elmnt sapType;            /* SAP Type */
          break;
       case STTFUSAP:
 #ifndef CL_MAC_LWLC
-         if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != TFU_SEL_TC) &&
-             (cfg->s.schInstCfg.tfuSap[sapIdx].selector != TFU_SEL_LC))
+         if ((cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_TC) &&
+             (cfg->s.schInstCfg.tfuSap[sapIdx].selector != ODU_SELECTOR_LC))
          {
             ret = LCM_REASON_INVALID_PAR_VAL;
             RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "rgSCHLmmSapCfg(): unsupported"
@@ -346,166 +259,7 @@ Elmnt sapType;            /* SAP Type */
    }
    RETVALUE(ret);
 }
-
-\f
-/**
- * @brief Scheduler instance Configuration Handler. 
- *
- * @details
- *
- *     Function : SchInstCfg
- *     
- *     This function in called by HandleSchGenCfgReq(). It handles the
- *     general and SAP configurations of the scheduler instance. It initializes
- *     the hash lists of rgSchCb. Returns
- *     reason for success/failure of this function.
- *     
- *  @param[in]  RgCfg *cfg, the Configuaration information 
- *  @return  U16
- *      -# LCM_REASON_NOT_APPL 
- *      -# LCM_REASON_INVALID_MSGTYPE
- *      -# LCM_REASON_MEM_NOAVAIL
- **/
-#ifdef ANSI
-PUBLIC U16 SchInstCfg
-(
-RgCfg *cfg,            /* Configuaration information */
-Inst  dInst
-)
-#else
-PUBLIC U16 SchInstCfg(cfg,dInst)
-RgCfg *cfg;            /* Configuaration information */
-Inst  dInst;
-#endif
-{
-   U16    ret = LCM_REASON_NOT_APPL;
-   Inst   inst = (dInst - SCH_INST_START);
-
-   TRC2(SchInstCfg)
-
-   printf("\nEntered SchInstCfg()");
-   /* Check if Instance Configuration is done already */
-   if (rgSchCb[inst].rgSchInit.cfgDone == TRUE)
-   {
-      RETVALUE(LCM_REASON_INVALID_MSGTYPE);
-   }
-   if ((cfg->s.schInstCfg.genCfg.lmPst.selector != LRG_SEL_TC) &&
-       (cfg->s.schInstCfg.genCfg.lmPst.selector != LRG_SEL_LC))
-   {
-      RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg(): unsupported "
-                 "Selector value for lmPst.");
-      RETVALUE(LCM_REASON_INVALID_PAR_VAL);
-   }
-   /* Update the Pst structure for LM interface */
-   cmMemcpy((U8 *)&rgSchCb[inst].rgSchInit.lmPst,
-            (U8 *)&cfg->s.schInstCfg.genCfg.lmPst,
-             sizeof(Pst));
-   
-   rgSchCb[inst].rgSchInit.inst = inst;
-   rgSchCb[inst].rgSchInit.lmPst.srcProcId = rgSchCb[inst].rgSchInit.procId;
-   rgSchCb[inst].rgSchInit.lmPst.srcEnt = rgSchCb[inst].rgSchInit.ent;
-   rgSchCb[inst].rgSchInit.lmPst.srcInst = rgSchCb[inst].rgSchInit.inst +
-   SCH_INST_START;
-   rgSchCb[inst].rgSchInit.lmPst.event = EVTNONE;
-
-   rgSchCb[inst].rgSchInit.region = cfg->s.schInstCfg.genCfg.mem.region;
-   rgSchCb[inst].rgSchInit.pool = cfg->s.schInstCfg.genCfg.mem.pool;
-   rgSchCb[inst].genCfg.tmrRes = cfg->s.schInstCfg.genCfg.tmrRes;
-#ifdef LTE_ADV
-   rgSchCb[inst].genCfg.forceCntrlSrbBoOnPCel =  cfg->s.schInstCfg.genCfg.forceCntrlSrbBoOnPCel;
-   rgSchCb[inst].genCfg.isSCellActDeactAlgoEnable =  cfg->s.schInstCfg.genCfg.isSCellActDeactAlgoEnable;
-#endif
-   rgSchCb[inst].genCfg.startCellId    = cfg->s.schInstCfg.genCfg.startCellId;
-
-/* Not adding any SAPs towards SCH now */
-#if 0
-   /* allocate RGR saps */
-   if (SGetSBuf(rgSchCb[inst].rgSchInit.region,
-                rgSchCb[inst].rgSchInit.pool,
-                (Data **)&rgSchCb[inst].rgrSap,
-                (sizeof(RgSchUpSapCb) * cfg->s.schInstCfg.numSaps)) != ROK)
-   {
-      RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg: SGetSBuf for "
-                   "RGR saps failed");
-      RETVALUE(RFAILED);
-   }
-   /* allocate RGM saps */
-   if (SGetSBuf(rgSchCb[inst].rgSchInit.region,
-                rgSchCb[inst].rgSchInit.pool,
-                (Data **)&rgSchCb[inst].rgmSap,
-                (sizeof(RgSchUpSapCb) * cfg->s.schInstCfg.numSaps)) != ROK)
-   {
-      RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg: SGetSBuf for "
-                   "RGM saps failed");
-      RETVALUE(RFAILED);
-   }
-
-
-   /* allocate TFU saps */
-   if (SGetSBuf(rgSchCb[inst].rgSchInit.region,
-                rgSchCb[inst].rgSchInit.pool,
-                (Data **)&rgSchCb[inst].tfuSap,
-                (sizeof(RgSchLowSapCb) * cfg->s.schInstCfg.numSaps)) != ROK)
-   {
-      RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg: SGetSBuf for TFU "
-                 "saps failed");
-      RETVALUE(RFAILED);
-   }
-
-   /* allocate for bndCfmResponses */
-   if (SGetSBuf(rgSchCb[inst].rgSchInit.region,
-                rgSchCb[inst].rgSchInit.pool,
-                (Data **)&rgSchCb[inst].genCfg.bndCfmResp,
-                (sizeof(RgSchLmResponse) * cfg->s.schInstCfg.numSaps)) != ROK)
-   {
-      RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg: SGetSBuf for bind"
-           " confirm responses failed");
-      RETVALUE(RFAILED);
-   }
-#ifdef LTE_ADV
-   rgSCHLaaInitEnbCb(&rgSchCb[inst]);
 #endif
-   rgSchCb[inst].numSaps = cfg->s.schInstCfg.numSaps;
-   for (idx = 0; idx < cfg->s.schInstCfg.numSaps; idx++)
-   {
-      /* Initialize SAP State and configure SAP */
-      rgSchCb[inst].rgrSap[idx].sapSta.sapState = LRG_NOT_CFG;
-      rgSchCb[inst].rgrSap[idx].cell = NULLP;
-      rgSCHLmmSapCfg(dInst, cfg, idx, STRGRSAP);
-
-      rgSchCb[inst].rgmSap[idx].sapSta.sapState = LRG_NOT_CFG;
-      rgSchCb[inst].rgmSap[idx].cell = NULLP;
-      rgSCHLmmSapCfg(dInst, cfg, idx, STRGMSAP);
-
-      rgSchCb[inst].tfuSap[idx].sapSta.sapState = LRG_NOT_CFG;
-      rgSchCb[inst].tfuSap[idx].cell = NULLP;
-      rgSCHLmmSapCfg(dInst, cfg, idx, STTFUSAP);
-      rgSchCb[inst].tfuSap[idx].numBndRetries = 0;
-   }
-#endif
-   /* Initialzie the timer queue */   
-   cmMemset((U8 *)&rgSchCb[inst].tmrTq, 0, sizeof(CmTqType)*RGSCH_TQ_SIZE);
-   /* Initialize the timer control point */
-   cmMemset((U8 *)&rgSchCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
-   rgSchCb[inst].tmrTqCp.tmrLen = RGSCH_TQ_SIZE;
-
-   /* SS_MT_TMR needs to be enabled as schActvTmr needs instance information */
-   /* Timer Registration request to SSI */
-   if (SRegTmrMt(rgSchCb[inst].rgSchInit.ent, dInst,
-      (S16)rgSchCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
-   {
-      RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg(): Failed to "
-             "register timer.");
-      RETVALUE(LCM_REASON_MEM_NOAVAIL);
-   }   
-                    
-   /* Set Config done in TskInit */
-   rgSchCb[inst].rgSchInit.cfgDone = TRUE;
-   printf("\nScheduler gen config done");
-   
-   RETVALUE(ret);
-}
-
 \f
 /***********************************************************
  *
@@ -1026,16 +780,14 @@ RgMngmt       *cfm;
 
    inst = (reqPst->dstInst - SCH_INST_START);
 
-   cfmPst->srcEnt    = rgSchCb[inst].rgSchInit.ent;
-   cfmPst->srcInst   = (Inst) 0;
+   cfmPst->srcEnt    = ENTRG;
+   cfmPst->srcInst   = (Inst) 1;
    cfmPst->srcProcId = rgSchCb[inst].rgSchInit.procId;
-   cfmPst->dstEnt    = reqPst->srcEnt;
+   cfmPst->dstEnt    = ENTRG;
    cfmPst->dstInst   = (Inst) 0;
    cfmPst->dstProcId = reqPst->srcProcId;
 
    cfmPst->selector  = cfm->hdr.response.selector;
-   cfmPst->prior     = cfm->hdr.response.prior;
-   cfmPst->route     = cfm->hdr.response.route;
    cfmPst->region    = cfm->hdr.response.mem.region;
    cfmPst->pool      = cfm->hdr.response.mem.pool;