[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-428]Slot Indication at DUAPP
[o-du/l2.git] / src / 5gnrrlc / rlc_msg_hdl.c
index 90cfcd2..9fbb0d7 100644 (file)
@@ -64,7 +64,7 @@ uint8_t fillRlcUeCfgRsp(RlcUeCfgRsp *rlcCfgRsp, RlcCfgCfmInfo *rlcCRsp)
    uint8_t ret = ROK;
  
    rlcCfgRsp->cellId = rlcCRsp->cellId;
-   rlcCfgRsp->ueIdx  = rlcCRsp->ueId;
+   rlcCfgRsp->ueId   = rlcCRsp->ueId;
    for(idx = 0; idx < rlcCRsp->numEnt; idx++)
    {
       if(rlcCRsp->entCfgCfm[idx].status.status == CKW_CFG_CFM_OK)
@@ -184,14 +184,14 @@ uint8_t fillLcCfg(RlcCb *gCb, RlcEntCfgInfo *rlcUeCfg, RlcBearerCfg *duRlcUeCfg)
             rlcUeCfg->lCh[lChRbIdx].type     = duRlcUeCfg->lcType;
             rlcUeCfg->m.amInfo.ul.snLen      = duRlcUeCfg->u.amCfg->ulAmCfg.snLenUl; 
             rlcUeCfg->m.amInfo.ul.staProhTmr = duRlcUeCfg->u.amCfg->ulAmCfg.statProhTmr;
-            rlcUeCfg->m.amInfo.ul.reAsmblTmr   = duRlcUeCfg->u.amCfg->ulAmCfg.reAssemTmr * RLC_REASSEMBLY_TMR_BASE;
+            rlcUeCfg->m.amInfo.ul.reAsmblTmr   = duRlcUeCfg->u.amCfg->ulAmCfg.reAssemTmr;
             break;
          }
       case RLC_MODE_UM:
          {
             /* UL UM CONFIG */
             rlcUeCfg->m.umInfo.ul.snLen      = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm; 
-            rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr * RLC_REASSEMBLY_TMR_BASE;
+            rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
 
             /* DL UM CONFIG */
             rlcUeCfg->m.umInfo.dl.snLen = duRlcUeCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm; 
@@ -226,7 +226,7 @@ uint8_t fillRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeCfg *ueCfg)
 {
    uint8_t lcIdx;
    
-   rlcUeCfg->ueId    = ueCfg->ueIdx;
+   rlcUeCfg->ueId    = ueCfg->ueId;
    rlcUeCfg->cellId  = ueCfg->cellId;
    rlcUeCfg->numEnt  = ueCfg->numLcs;
    rlcUeCfg->transId = getTransId();
@@ -262,7 +262,7 @@ void fillRlcCfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg)
 {
    uint8_t cfgIdx =0;
 
-   cfgRsp->ueId = ueCfg->ueIdx;
+   cfgRsp->ueId = ueCfg->ueId;
    cfgRsp->cellId = ueCfg->cellId;
    cfgRsp->numEnt = ueCfg->numLcs;
    for(cfgIdx =0; cfgIdx<ueCfg->numLcs; cfgIdx++)
@@ -353,7 +353,7 @@ uint8_t BuildAndSendRrcDeliveryReportToDu( RlcDlRrcMsgInfo *dlRrcMsgInfo )
     if(rrcDelivery)
     {
        rrcDelivery->cellId = dlRrcMsgInfo->cellId;
-       rrcDelivery->ueIdx  = dlRrcMsgInfo->ueIdx;
+       rrcDelivery->ueId  = dlRrcMsgInfo->ueId;
        rrcDelivery->srbId  = dlRrcMsgInfo->lcId ;
        rrcDelivery->rrcDeliveryStatus.deliveryStatus    = PDCP_SN;
        rrcDelivery->rrcDeliveryStatus.triggeringMessage = PDCP_SN;
@@ -402,7 +402,7 @@ uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
 
    datReqInfo->rlcId.rbType = dlRrcMsgInfo->rbType;
    datReqInfo->rlcId.rbId = dlRrcMsgInfo->rbId;
-   datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueIdx;
+   datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueId;
    datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
    datReqInfo->lcType = dlRrcMsgInfo->lcType;
    datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
@@ -491,7 +491,7 @@ uint8_t RlcProcUlData(Pst *pst, RlcData *ulData)
          memset(cLchUlDat, 0, sizeof(RguCDatIndInfo));
 
          cLchUlDat->cellId = ulData->cellId;
-         GET_UE_IDX(ulData->rnti, cLchUlDat->rnti);
+         GET_UE_ID(ulData->rnti, cLchUlDat->rnti);
          cLchUlDat->lcId   = ulData->pduInfo[idx].lcId;
 
          /* Copy fixed buffer to message */
@@ -553,7 +553,7 @@ uint8_t RlcProcUlData(Pst *pst, RlcData *ulData)
       if(dLchPduPres)
       {
          dLchUlDat->cellId = ulData->cellId;
-         GET_UE_IDX(ulData->rnti, dLchUlDat->rnti);
+         GET_UE_ID(ulData->rnti, dLchUlDat->rnti);
 
          for(idx = 0; idx < MAX_NUM_LC; idx++)
          {
@@ -704,10 +704,10 @@ uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg)
    uint8_t ret = ROK;
    RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
    RlcCb *rlcUeCb = NULLP;
-   RlcCfgCfmInfo *cfgRsp; 
+   RlcCfgCfmInfo cfgRsp; 
    Pst rspPst;
 
-   DU_LOG("\nDEBUG  -->  RLC: UE reconfig request received. CellID[%d] UEIDX[%d]",ueCfg->cellId, ueCfg->ueIdx);
+   DU_LOG("\nDEBUG  -->  RLC: UE reconfig request received. CellID[%d] UEID[%d]",ueCfg->cellId, ueCfg->ueId);
 
    rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
    RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
@@ -724,9 +724,8 @@ uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg)
       {
          DU_LOG("\nERROR  -->  RLC: Failed to fill configuration at RlcProcUeReconfigReq()");
          FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
-         memset(cfgRsp, 0, sizeof(RlcCfgCfmInfo));
-         fillRlcCfgFailureRsp(cfgRsp, ueCfg);
-         SendRlcUeCfgRspToDu(&rspPst, cfgRsp);
+         fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
+         SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
       }
       else
       {
@@ -777,7 +776,7 @@ uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
 
    datReqInfo->rlcId.rbType = RB_TYPE_DRB;
    datReqInfo->rlcId.rbId   = dlDataMsgInfo->rbId;
-   datReqInfo->rlcId.ueId   = dlDataMsgInfo->ueIdx;
+   datReqInfo->rlcId.ueId   = dlDataMsgInfo->ueId;
    datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
    datReqInfo->lcType       = LCH_DTCH;
    datReqInfo->sduId        = ++(rlcCb[pst->dstInst]->dlSduId);
@@ -804,7 +803,7 @@ uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
  *    Functionality:
  *      sending UE delete response to DU 
  *
- * @params[in] uint8_t cellId, uint8_t ueIdx, UeDeleteResult result 
+ * @params[in] uint8_t cellId, uint8_t ueId, UeDeleteResult result 
  *
  * @return ROK     - success
  *         RFAILED - failure
@@ -912,6 +911,169 @@ uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
    return ret;
 }
 
+/*******************************************************************
+*
+* @brief Send the Slice Metrics to  DU APP
+*
+* @details
+*
+*    Function : sendSlicePmToDu
+*
+*    Functionality:
+*      Handles the sending of Slice Metrics to  DU APP
+*
+* @params[in] Post structure pointer
+*             SlicePmList *sliceStats pointer
+*
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
+{
+   Pst pst;  
+   
+   FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
+
+   if(!sliceStats)
+   {
+      DU_LOG("\nERROR  -->  RLC: sendSlicePmToDu(): Memory allocation failed ");
+      return RFAILED;
+   }
+   else
+   {
+      if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
+      {
+         DU_LOG("\nDEBUG  -->  RLC: Slice PM send successfully");
+      }
+      else
+      {
+         DU_LOG("\nERROR  -->  RLC: sendSlicePmToDu():Failed to send Slice PM to DU");
+         RLC_FREE_SHRABL_BUF(pst.region, pst.pool, sliceStats, sizeof(SlicePmList));
+         return RFAILED;
+      }
+   }
+   return ROK;
+}
+
+/**
+ * @brief 
+ *    Handler for searching the Slice Entry in Slice Metrics structure
+ *
+ * @details
+ *    This func finds the slice entry in the SliceMetric record structure and
+ *    return the index of the slice sot hat Tput entries can be done
+ *
+ * @param[in] snssaiVal : Snssai Val to be searched
+ *            *snssaiIdx : O/P : Index of the Slice in Slice Metrics record
+ *            sliceStats : Pointer of Slice metrics record list
+ *
+ * @return bool: True: If slice found in the record
+ *               False: If Slice not found; thus parent function will create the
+ *               recpord of this snssai
+ *   
+ */
+bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
+{
+   uint8_t cntSlices = sliceStats->numSlice;
+
+   for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
+   {
+      if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
+            (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
+      {
+         return TRUE;
+      }
+   }
+   return FALSE;
+}
+
+
+/*******************************************************************
+*
+* @brief Builds the Slice Performance Metrics structure to be sent to DU
+*
+* @details
+*
+*    Function : BuildSliceReportToDu
+*
+*    Functionality:
+*      Builds the Slice Performance Metrics structure to be sent to DU
+*
+* @params[in] uint8_t snssaiCnt
+*             
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
+{
+   CmLList  *node = NULLP;
+   RlcTptPerSnssai *snssaiNode = NULLP;
+   Direction dir = DIR_UL;
+   SlicePmList *sliceStats = NULLP;   /*Slice metric */
+   SliceIdentifier snssaiVal ;
+   uint8_t snssaiIdx = 0;
+
+   if(snssaiCnt == 0)
+   {
+      DU_LOG("\nERROR  -->  RLC: No SNSSAI to send the SLice PM");
+      return RFAILED;
+   }
+
+   RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
+   if(sliceStats == NULLP)
+   {
+      DU_LOG("\nERROR  -->  RLC: Memory Allocation Failed");
+      return RFAILED;
+   }
+   RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
+
+   if(sliceStats->sliceRecord == NULLP)
+   {
+      DU_LOG("\nERROR  -->  RLC: Memory Allocation Failed");
+      RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
+      return RFAILED;
+   }
+   while(dir < DIR_BOTH)
+   {
+      node = arrTputPerSnssai[dir]->first;
+      if(node == NULLP)
+      {
+         DU_LOG("\nERROR  -->  RLC: No SNSSAI in list");
+         RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
+         RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, (snssaiCnt * (sizeof(SlicePm))));
+         return RFAILED;
+      }
+
+      while(node)
+      {
+         snssaiIdx = 0;
+         snssaiNode = (RlcTptPerSnssai *)node->node;
+
+         snssaiVal.sst = snssaiNode->snssai->sst;
+         snssaiVal.sd = snssaiNode->snssai->sd[2]+snssaiNode->snssai->sd[1]*10+snssaiNode->snssai->sd[0]*100;
+         if(rlcFindSliceEntry(snssaiVal, &snssaiIdx, sliceStats) == FALSE)
+         {
+            sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
+            sliceStats->numSlice++;
+         }
+         if(dir == DIR_UL)
+         {
+            sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
+         }
+         else
+         {
+            sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
+         }
+         node = node->next;
+      }
+      dir++;
+   }
+
+   sendSlicePmToDu(sliceStats);
+   return ROK;
+}
 /**********************************************************************
          End of file
 **********************************************************************/