JIRA ID:[ODUHIGH-296]-Dl Data Changes from DUAPP to RLC
[o-du/l2.git] / src / 5gnrrlc / kw_utl_dl.c
index 609be1f..7a21f27 100755 (executable)
@@ -221,40 +221,37 @@ Void PrintRLCStats(Void)
  * ****************************************************************/
 uint8_t rlcSendDedLcDlData(Pst *post, SpId spId, RguDDatReqInfo *datReqInfo)
 {
-   uint8_t          ueIdx;      /* UE info list iterator */ 
-   uint8_t          tbIdx;      /* TB info list iterator */
-   uint8_t          lchIdx;     /* Lch info list iterator */
-   uint8_t          pduIdx;     /* RLC PDU list iterator */
-   RguDDatReqPerUe  datPerUe;   /* DL data info per UE */
-   RguDatReqTb      datPerTb;   /* DL data info per TB */
-   RguLchDatReq     datPerLch;  /* DL data info per Lch */
-   RlcData          *dlData;    /* DL data to be sent to MAC */
-   RlcDlRrcMsgRsp   *dlRrcMsgRsp;/* DL Data Msg Rsp sent to DU */
-   Pst              pst;        /* Post structure */
-   uint16_t         pduLen;     /* PDU length */
-   uint16_t         copyLen;    /* Number of bytes copied */
-
-   dlData = NULLP;
-   dlRrcMsgRsp = NULLP;
+   uint8_t          ueIdx;                /* UE info list iterator */ 
+   uint8_t          tbIdx;                /* TB info list iterator */
+   uint8_t          lchIdx;               /* Lch info list iterator */
+   uint8_t          pduIdx;               /* RLC PDU list iterator */
+   RguDDatReqPerUe  datPerUe;             /* DL data info per UE */
+   RguDatReqTb      datPerTb;             /* DL data info per TB */
+   RguLchDatReq     datPerLch;            /* DL data info per Lch */
+   RlcData          *dlData = NULLP;      /* DL data to be sent to MAC */
+   RlcDlRrcMsgRsp   *dlRrcMsgRsp = NULLP; /*DL RRC Rsp to be sent to DU*/
+   Pst              pst;                  /* Post structure */
+   uint16_t         pduLen;               /* PDU length */
+   uint16_t         copyLen;              /* Number of bytes copied */
+   uint8_t          lcId = 0;
+
    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
                        dlData, sizeof(RlcData));
-   if ( dlData == NULLP )
+   if(dlData == NULLP)
    {
       DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Memory allocation failed for dl data");
       RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
           datReqInfo, sizeof(RguDDatReqInfo));
       return RFAILED;
    }
+   memset(dlData, 0, sizeof(RlcData));
 
    for(ueIdx = 0; ueIdx < datReqInfo->nmbOfUeGrantPerTti; ueIdx++)
    {
       datPerUe = datReqInfo->datReq[ueIdx];
 
-      memset(dlData, 0, sizeof(RlcData));
-
       dlData->cellId = datReqInfo->cellId;
       dlData->rnti = datPerUe.rnti;
-
       /* Retrieving sfn/slot from transId. It was filled in RlcProcSchedResultRpt */
       dlData->slotInfo.sfn = datPerUe.transId >> 16;
       dlData->slotInfo.slot = datPerUe.transId & 0xffff;
@@ -267,6 +264,7 @@ uint8_t rlcSendDedLcDlData(Pst *post, SpId spId, RguDDatReqInfo *datReqInfo)
          for(lchIdx = 0; lchIdx < datPerTb.nmbLch; lchIdx++)
          {
             datPerLch = datPerTb.lchData[lchIdx];
+            lcId = datPerLch.lcId;
             for(pduIdx = 0; pduIdx < datPerLch.pdu.numPdu; pduIdx++)
             {
                dlData->pduInfo[dlData->numPdu].commCh = FALSE;
@@ -310,9 +308,8 @@ uint8_t rlcSendDedLcDlData(Pst *post, SpId spId, RguDDatReqInfo *datReqInfo)
          }/* For Data per Lch */
       }/* For Data per Tb */
 
-      RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
-                     dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
-      if( dlRrcMsgRsp == NULLP )
+      RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
+      if(dlRrcMsgRsp == NULLP)
       {
          DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Memory allocation failed for dlRrcMsgRsp");
          for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
@@ -325,37 +322,41 @@ uint8_t rlcSendDedLcDlData(Pst *post, SpId spId, RguDDatReqInfo *datReqInfo)
              datReqInfo, sizeof(RguDDatReqInfo));
          return RFAILED;
       }
-
       dlRrcMsgRsp->cellId = dlData->cellId;
       dlRrcMsgRsp->crnti = dlData->rnti;
 
       /* Sending DL Data per UE to MAC */
-      memset(&pst, 0, sizeof(Pst));
       FILL_PST_RLC_TO_MAC(pst, RLC_DL_INST, EVENT_DL_DATA_TO_MAC);
       if(RlcSendDlDataToMac(&pst, dlData) != ROK)
       {
+         DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Failed to send Dl RRC Msg To Mac");
+         dlRrcMsgRsp->state = TRANSMISSION_FAILED;
          for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
-        {
-           RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
-              dlData->pduInfo[pduIdx].pduLen);
-        }
+         {
+            RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
+               dlData->pduInfo[pduIdx].pduLen);
+         }
          RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData, sizeof(RlcData));
-        /* Update DL RRC MSG Rsp State */
-         dlRrcMsgRsp->state = TRANSMISSION_FAILED;
+         RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
+         RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
+         return RFAILED;
       }
       else
          dlRrcMsgRsp->state = TRANSMISSION_COMPLETE;
 
-      /* Send Dl RRC Msg Rsp to DU APP */
       FILL_PST_RLC_TO_DUAPP(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_RSP_TO_DU);
-      if(rlcSendDlRrcMsgRspToDu(&pst, dlRrcMsgRsp) != ROK)
+      if(lcId >= SRB1_LCID && lcId <= SRB3_LCID) /* Valid for all RRC messages i.e. SRB1, SRB2, SRB3 */
       {
-         RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
+         if(rlcSendDlRrcMsgRspToDu(&pst, dlRrcMsgRsp) != ROK)
+         {
+            DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Failed to send Dl RRC Msg Rsp To Du");
+            RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
+            RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
+            return RFAILED;
+         }
       }
    } /* For Data per UE */
-
-   RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
-            datReqInfo, sizeof(RguDDatReqInfo));
+   RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
    
    return ROK;
 }/* End of rlcSendDedLcDlData */