Merge "[EPIC-ID: ODUHIGH-488][TASK-ID: ODUHIGH-494]SCH framework update to support...
[o-du/l2.git] / src / 5gnrmac / mac_cfg_hdl.c
index f354fa4..23c1bf7 100644 (file)
@@ -42,20 +42,6 @@ packMacCellCfgConfirm packMacCellCfmOpts[] =
    packMacCellCfgCfm,    /* packing for light weight loosly coupled */
 };
 
-SchCellCfgFunc SchCellCfgOpts[] =
-{
-   packSchCellCfg,   /* packing for loosely coupled */
-   SchHdlCellCfgReq, /* packing for tightly coupled */
-   packSchCellCfg    /* packing for light weight loosly coupled */
-};
-
-MacSchCellDeleteReqFunc macSchCellDeleteReqOpts[]=
-{
-   packMacSchCellDeleteReq,    /* packing for loosely coupled */
-   MacSchCellDeleteReq,        /* packing for tightly coupled */
-   packMacSchCellDeleteReq     /* packing for light weight loosely coupled */
-};
-
 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
 {
    packDuMacCellDeleteRsp,   /* packing for loosely coupled */
@@ -70,18 +56,11 @@ MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
    packDuMacSliceCfgRsp   /* packing for light weight loosly coupled */
 };
 
-MacDuSliceReCfgRspFunc macDuSliceReCfgRspOpts[] =
-{
-   packDuMacSliceReCfgRsp,   /* packing for loosely coupled */
-   DuProcMacSliceReCfgRsp,   /* packing for tightly coupled */
-   packDuMacSliceReCfgRsp   /* packing for light weight loosly coupled */
-};
-
-MacSchPagingIndFunc macSchPagingIndOpts[] = 
+MacDuSliceRecfgRspFunc macDuSliceRecfgRspOpts[] =
 {
-   packMacSchPagingInd,   /* packing for loosely coupled */
-   MacSchPagingInd,       /* packing for tightly coupled */
-   packMacSchPagingInd    /* packing for light weight loosely coupled */
+   packDuMacSliceRecfgRsp,   /* packing for loosely coupled */
+   DuProcMacSliceRecfgRsp,   /* packing for tightly coupled */
+   packDuMacSliceRecfgRsp    /* packing for light weight loosly coupled */
 };
 
 /**
@@ -103,12 +82,11 @@ uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
 {
    Pst schPst;
 
-   printf("\nReceived Scheduler gen config at MAC");
+   DU_LOG("\nINFO  -->  MAC : Received Scheduler gen config at MAC");
    memset(&schPst, 0, sizeof(Pst));
    FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
-   SchProcGenCfgReq(&schPst, cfg);
-
-   return ROK;
+   
+   return(SchMessageRouter(&schPst, (void *)cfg));
 }
 
 /**
@@ -128,7 +106,7 @@ uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
  **/
 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt  *cfm)
 {
-   DU_LOG("\nDEBUG  -->  Sending Scheduler config confirm to DU APP");
+   DU_LOG("\nDEBUG  -->  MAC : Sending Scheduler config confirm to DU APP");
    pst->dstEnt = ENTDUAPP;
    pst->dstInst = 0;
    pst->srcInst = 0;
@@ -174,6 +152,7 @@ uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
    GET_CELL_IDX(macCellCfg->cellId, cellIdx);
    macCb.macCell[cellIdx] = macCellCb;
    macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
+   macCb.macCell[cellIdx]->numOfSlots = 10 * (1 << macCellCfg->numerology);
    memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
 
    MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
@@ -251,7 +230,7 @@ uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
 {
    SchCellCfg schCellCfg;
    Pst        cfgPst;
-   uint8_t    ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
+   uint8_t    ssbMaskIdx = 0, rsrcListIdx = 0, sliceIdx=0;
 
    memset(&cfgPst, 0, sizeof(Pst));
    memset(&schCellCfg, 0, sizeof(SchCellCfg));
@@ -394,8 +373,7 @@ uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
 
    FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
 
-   ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
-   return ret;
+   return(SchMessageRouter(&cfgPst, (void *)&schCellCfg));
 } /* end of MacSchCellCfgReq */
 
 
@@ -639,11 +617,11 @@ uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
  *
  * ****************************************************************/
 
-uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
+uint8_t sendCellDelReqToSch(SchCellDeleteReq *schCellDelReq)
 {
    Pst schPst;
    FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
-   return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
+   return(SchMessageRouter(&schPst, (void *)schCellDelReq));
 }
 
 /*******************************************************************
@@ -662,10 +640,10 @@ uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
  *
  *
  * ****************************************************************/
-uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
+uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDeleteReq *cellDelete)
 {
    uint8_t ret = ROK, cellIdx=0;
-   SchCellDelete schCellDelete;
+   SchCellDeleteReq schCellDelete;
 
    DU_LOG("\nINFO   -->  MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
 
@@ -676,7 +654,7 @@ uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
       {
          if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
          {
-            memset(&schCellDelete, 0, sizeof(SchCellDelete));
+            memset(&schCellDelete, 0, sizeof(SchCellDeleteReq ));
             schCellDelete.cellId =  cellDelete->cellId;
             ret = sendCellDelReqToSch(&schCellDelete);
             if(ret != ROK)
@@ -709,7 +687,7 @@ uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
           }
 
       }
-      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
+      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDeleteReq));
    }
    else
    {
@@ -734,24 +712,35 @@ uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
  **/
 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
 {
-   uint8_t cfgIdx = 0;
-   
-   if(cfgReq)
-   {
-      if(cfgReq->numOfConfiguredSlice)
-      {
-         for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
-         {
-            if(cfgReq->listOfSliceCfg[cfgIdx])
-            {
-               MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio)); 
-            }
-            MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
-         }
-         MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
-      }
-      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
-   }
+    uint8_t policyIdx = 0, memberListIdx=0;
+
+    if(cfgReq->numOfRrmPolicy)
+    {
+       if(cfgReq->listOfRrmPolicy)
+       {
+          for(policyIdx = 0; policyIdx<cfgReq->numOfRrmPolicy; policyIdx++)
+          {
+             if(cfgReq->listOfRrmPolicy[policyIdx])
+             {
+                if(cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
+                {
+                   if(cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
+                   {
+                      for(memberListIdx = 0; memberListIdx<cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
+                      {
+                         MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
+                      }
+                      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
+                      cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
+                   }
+                }
+                MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
+             }
+          }
+          MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy, cfgReq->numOfRrmPolicy  * sizeof(MacSliceRrmPolicy*));
+       }
+    }
+
 }
 /**
  * @brief fill Mac Slice Config Rsp
@@ -909,17 +898,17 @@ uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
 *
 *   sends  slice cfg response to duapp
 *
-*  @param[in] MacSliceCfgRsp macSliceRecfgRsp
+*  @param[in] MacSliceRecfgRsp macSliceRecfgRsp
 *  @return  int
 *      -# ROK
 **/
-uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
+uint8_t MacSendSliceReconfigRsp(MacSliceRecfgRsp *macSliceRecfgRsp)
 {
    Pst  rspPst;
 
    memset(&rspPst, 0, sizeof(Pst));
    FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
-   return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
+   return (*macDuSliceRecfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
 
 }
 
@@ -928,7 +917,7 @@ uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
  *
  * @details
  *
- *     Function : MacProcSchSliceReCfgRsp 
+ *     Function : MacProcSchSliceRecfgRsp 
  *
  *     This function  process the slice cfg rsp received from sch
  *
@@ -937,27 +926,27 @@ uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
  *  @return  int
  *      -# ROK
  **/
-uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
+uint8_t MacProcSchSliceRecfgRsp(Pst *pst, SchSliceRecfgRsp *schSliceRecfgRsp)
 {
-   MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
+   MacSliceRecfgRsp *macSliceRecfgRsp = NULLP;
 
    if(schSliceRecfgRsp)
    {
-      MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
-      if(macSliceReCfgRsp == NULLP)
+      MAC_ALLOC_SHRABL_BUF(macSliceRecfgRsp, sizeof(MacSliceRecfgRsp));
+      if(macSliceRecfgRsp == NULLP)
       {
-          DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
+          DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchSliceRecfgRsp");
           return RFAILED;
       }
 
       if(schSliceRecfgRsp->listOfSliceCfgRsp)
       {
-         if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
+         if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceRecfgRsp) != ROK)
          {
             DU_LOG("\nERROR  -->  MAC : Failed to fill the slice Recfg response");
             return RFAILED;
          }
-         MacSendSliceReconfigRsp(macSliceReCfgRsp);
+         MacSendSliceReconfigRsp(macSliceRecfgRsp);
       }
       freeSchSliceCfgRsp(schSliceRecfgRsp);
    }
@@ -974,11 +963,11 @@ uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
  *     This function process the downlink pcch indication received from DUAPP
  *
  *  @param[in]  Pst           *pst
- *  @param[in]  MacPcchInd    *pcchInd 
+ *  @param[in]  DlPcchInd    *pcchInd 
  *  @return  int
  *      -# ROK
  **/
-uint8_t MacProcDlPcchInd(Pst *pst, MacPcchInd *pcchInd)
+uint8_t MacProcDlPcchInd(Pst *pst, DlPcchInd *pcchInd)
 {
    uint8_t ret = RFAILED;
    uint16_t cellIdx = 0;
@@ -1026,7 +1015,7 @@ uint8_t MacProcDlPcchInd(Pst *pst, MacPcchInd *pcchInd)
                   memcpy(schPageInd->pagePdu, pcchInd->pcchPdu, pcchInd->pduLen);
 
                   FILL_PST_MAC_TO_SCH(schPst, EVENT_PAGING_IND_TO_SCH);
-                  ret = (*macSchPagingIndOpts[schPst.selector])(&schPst, schPageInd);
+                  ret = SchMessageRouter(&schPst, (void *)schPageInd);
                }
             }
          }
@@ -1035,7 +1024,7 @@ uint8_t MacProcDlPcchInd(Pst *pst, MacPcchInd *pcchInd)
       {
          MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd->pcchPdu, pcchInd->pduLen);
       }
-      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(MacPcchInd));
+      MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(DlPcchInd));
    }
    else
    {