[Epic-ID: ODUHIGH-488][Task-ID: ODUHIGH-501] WG8 Alignment | DL Broadcast Request
[o-du/l2.git] / src / du_app / du_cell_mgr.c
index 4762d65..286d2db 100644 (file)
@@ -60,6 +60,12 @@ DuMacDlPcchInd packMacDlPcchIndOpts[] =
    packDuMacDlPcchInd        /* Light weight-loose coupling */
 };
 
+DuMacDlBroadcastReq packMacDlBroadcastReqOpts[] =
+{
+   packDuMacDlBroadcastReq,       /* Loose coupling */
+   MacProcDlBroadcastReq,         /* TIght coupling */
+   packDuMacDlBroadcastReq        /* Light weight-loose coupling */
+};
 /*******************************************************************
  *
  * @brief Processes cells to be activated
@@ -192,7 +198,7 @@ uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb)
 * 
 *  @params[in] DuCellCb *cellCb
 *
-*  @return void 
+*  @return ROK/RFAILURE (uint8_t return)
 * 
 * 
 ******************************************************************************/
@@ -212,7 +218,7 @@ uint8_t checkPagingRecord(DuCellCb *cellCb)
       /*No Page is present for pf thus exiting*/
       return ROK;
    }
-
+  
    do
    {
       pagInfo = handlePageInfoLL(pf, NULLD, &(pagInfoLLFromPF->pagInfoList), TRAVERSE_ALL);
@@ -225,6 +231,10 @@ uint8_t checkPagingRecord(DuCellCb *cellCb)
          }
          handlePageInfoLL(pf, pagInfo->i_s, &(pagInfoLLFromPF->pagInfoList), DELETE);
       }
+      if(pagInfoLLFromPF->pagInfoList.first == NULLP)
+      {
+         break;
+      }
    }while(pagInfo != NULLP);
    
    cmHashListDelete(&(cellCb->pagingInfoMap), (PTR)pagInfoLLFromPF);
@@ -242,13 +252,13 @@ uint8_t checkPagingRecord(DuCellCb *cellCb)
  *
  *    Functionality: Send pcch indication to MAC
  *
- * @Params[in] MacPcchInd *pcchInd
+ * @Params[in] DlPcchInd *pcchInd
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
 
-uint8_t sendDlPcchIndToMac(MacPcchInd *pcchInd)
+uint8_t sendDlPcchIndToMac(DlPcchInd *pcchInd)
 {
    uint8_t ret = ROK;
    Pst pst;
@@ -258,7 +268,6 @@ uint8_t sendDlPcchIndToMac(MacPcchInd *pcchInd)
       /* Fill Pst */
       FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_PCCH_IND);
       
-      DU_LOG("\nDEBUG   -->  DU_APP: Sending DL PCCH indication to MAC for cellId[%d]", pcchInd->cellId);
       ret = (*packMacDlPcchIndOpts[pst.selector])(&pst, pcchInd);
       if(ret == RFAILED)
       {
@@ -267,7 +276,7 @@ uint8_t sendDlPcchIndToMac(MacPcchInd *pcchInd)
    }
    else
    {
-      DU_LOG("\nERROR  -->  DU_APP: sendDlPcchIndToMac(): Received pcchInd is NULLP");
+      DU_LOG("\nERROR  -->  DU APP: sendDlPcchIndToMac(): Received pcchInd is NULLP");
       ret = RFAILED;
    }
    return ret;
@@ -357,14 +366,15 @@ uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId)
       cellCb->cellStatus = ACTIVATED;
       gCellStatus = CELL_UP;
 
-      if(duCfgParam.tempSliceCfg.rrmPolicy)
-         BuildAndSendSliceConfigReq(duCfgParam.tempSliceCfg.rrmPolicy, duCfgParam.tempSliceCfg.totalRrmPolicy, duCfgParam.tempSliceCfg.totalSliceCount);
+      if(duCfgParam.tempSliceCfg.numOfRrmPolicy)
+         BuildAndSendSliceConfigReq();
 #ifdef O1_ENABLE
       DU_LOG("\nINFO   -->  DU APP : Raise cell UP alarm for cell id=%d", cellId->cellId);
       raiseCellAlrm(CELL_UP_ALARM_ID, cellId->cellId);
       setCellOpState(cellId->cellId, ENABLED, ACTIVE);
 #endif
-
+       duCfgParam.macCellCfg.cellCfg.opState = OP_ENABLED;
+       duCfgParam.macCellCfg.cellCfg.cellState = CELL_ACTIVE;
    }
 
    if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
@@ -396,7 +406,7 @@ uint8_t DuProcMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *deleteRsp)
 
    if(deleteRsp)
    {
-      if(deleteRsp->result == SUCCESSFUL_RSP)
+      if(deleteRsp->status == SUCCESSFUL)
       {
          GET_CELL_IDX(deleteRsp->cellId, cellIdx);
          DU_LOG("\nINFO   -->  DU APP : MAC CELL Delete Response : SUCCESS [CELL IDX : %d]", deleteRsp->cellId);
@@ -470,9 +480,9 @@ uint8_t sendCellDeleteReqToMac(uint16_t cellId)
 {
    Pst pst;
    uint8_t ret=ROK;
-   MacCellDelete *cellDelete = NULLP;
+   MacCellDeleteReq *cellDelete = NULLP;
    
-   DU_ALLOC_SHRABL_BUF(cellDelete, sizeof(MacCellDelete));
+   DU_ALLOC_SHRABL_BUF(cellDelete, sizeof(MacCellDeleteReq));
    if(cellDelete)
    {
       cellDelete->cellId = cellId;
@@ -484,7 +494,7 @@ uint8_t sendCellDeleteReqToMac(uint16_t cellId)
       if(ret == RFAILED)
       {
          DU_LOG("\nERROR  -->  DU APP : sendCellDeleteReqToMac(): Failed to send Cell delete Req to MAC");
-         DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellDelete, sizeof(MacCellDelete));
+         DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellDelete, sizeof(MacCellDeleteReq));
       }
    }
    else
@@ -621,7 +631,7 @@ uint8_t BuildAndSendDlPcchIndToMac(uint16_t cellId, uint16_t pf, uint8_t i_s, Cm
    PCCH_Message_t *pcchMsg = NULLP;
    asn_enc_rval_t encRetVal;
    PagingRrc_t    *pagingMsg = NULLP;
-   MacPcchInd     *macPcchInd = NULLP;
+   DlPcchInd     *macPcchInd = NULLP;
    uint8_t        recordIdx = 0, ret = RFAILED;
    
    /*As per 38.473 Sec 9.3.1.39,5G-S-TMSI :48 Bits >>  Bytes and 0 UnusedBits */
@@ -726,7 +736,7 @@ uint8_t BuildAndSendDlPcchIndToMac(uint16_t cellId, uint16_t pf, uint8_t i_s, Cm
       memset(encBuf, 0, ENC_BUF_MAX_LEN);
       encBufSize = 0;
        /* Encode the PCCH RRC PDU as APER */
-      encRetVal = aper_encode(&asn_DEF_PCCH_Message, 0, pcchMsg, PrepFinalEncBuf,\
+      encRetVal = uper_encode(&asn_DEF_PCCH_Message, 0, pcchMsg, PrepFinalEncBuf,\
             encBuf);
 
       if(encRetVal.encoded == ENCODE_FAIL)
@@ -739,7 +749,7 @@ uint8_t BuildAndSendDlPcchIndToMac(uint16_t cellId, uint16_t pf, uint8_t i_s, Cm
       {
          DU_LOG("\nDEBUG  -->  F1AP : Created APER encoded buffer for RRC PDU for Pcch indication \n");
          
-         DU_ALLOC_SHRABL_BUF(macPcchInd, sizeof(MacPcchInd));
+         DU_ALLOC_SHRABL_BUF(macPcchInd, sizeof(DlPcchInd));
          if(macPcchInd == NULLP)
          {
             DU_LOG("\nERROR  -->  DU APP: BuildAndSendDlPcchIndToMac(); (macPcchInd) Memory Alloction failed!");
@@ -761,7 +771,7 @@ uint8_t BuildAndSendDlPcchIndToMac(uint16_t cellId, uint16_t pf, uint8_t i_s, Cm
          if(ret != ROK)
          {
             DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macPcchInd->pcchPdu, macPcchInd->pduLen);
-            DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macPcchInd, sizeof(MacPcchInd));
+            DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macPcchInd, sizeof(DlPcchInd));
             break;
          }
       }
@@ -866,7 +876,7 @@ uint8_t insertPagingRecord(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPagingParam, u
 #if 0
    printPageList(&(cellCb->pagingInfoMap));
 #endif
-   
+
    return ROK;
 
 
@@ -1007,7 +1017,6 @@ uint8_t calcAndFillPagingInfoInCellCb(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPag
       rcvdF1apPagingParam->pagingFrame =  (sfn % MAX_SFN);
       rcvdF1apPagingParam->i_s = ((uint32_t)(floor(rcvdF1apPagingParam->pagUeId / N)) % ns);
 
-      DU_LOG("\nINFO   --> DU APP : Successfully filled paging parameter in DuCellCb");
       memcpy(&cellCb->tmpPagingInfoOfUe, rcvdF1apPagingParam, sizeof(DuPagingMsg));
    }
    else
@@ -1059,6 +1068,56 @@ uint8_t processPagingMsg(uint16_t cellId, DuPagingMsg *rcvdF1apPagingParam)
    return ROK;
 
 }
+
+/*******************************************************************
+ *
+ * @brief DU build and send dl broacast req  and send it to MAC
+ *
+ * @details
+ *
+ *    Function : duBuildAndSendDlBroadcastReq
+ *
+ *    Functionality: DU build and send dl broacast req and send to MAC
+ *                   
+ *
+ * @params[in] cellId, crnti 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendDlBroadcastReq()
+{
+   Pst pst;
+   uint8_t ret =ROK;
+   MacDlBroadcastReq *dlBroadcast=NULLP;
+
+   DU_LOG("\nDEBUG  -->  DU_APP : Building Dl broadcast request");
+
+   DU_ALLOC_SHRABL_BUF(dlBroadcast, sizeof(MacDlBroadcastReq));
+   if(dlBroadcast)
+   {
+      /*TODO - fill MAC DL Broadcast Request*/
+      
+      FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_BROADCAST_REQ);
+
+      DU_LOG("\nDEBUG  -->  DU_APP: Sending Dl broadcast  Request to MAC ");
+      ret = (*packMacDlBroadcastReqOpts[pst.selector])(&pst, dlBroadcast);
+      if(ret == RFAILED)
+      {
+         DU_LOG("\nERROR  -->  DU_APP: sendDlBroadcastReqToMac(): Failed to send Dl broadcast  Req to MAC");
+         DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlBroadcast, sizeof(MacDlBroadcastReq));
+      }
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->   DU_APP: sendDlBroadcastReqToMac(): Failed to allocate memory"); 
+      ret =  RFAILED;
+   }
+
+   return ret;
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/