RLC-MAC Interface APIs and Memory configuration Changes
[o-du/l2.git] / src / 5gnrrlc / kw_lim.c
index 7ad2d14..298ecef 100755 (executable)
@@ -209,6 +209,106 @@ U8     status;
    RETVALUE(ROK);
 } /* KwLiRguBndCfm */
 
+/**
+ * @brief Handler to process PDU received from MAC
+ *
+ * @details
+ *    This function receives the PDU from MAC.
+ *    seggregates common and dedicated logical channel
+ *    PDU and call respective handler.
+ *
+ * @param[in] pst     Post structure
+ * @param[in] suId    Service User ID
+ * @param[in] datInd  Data Indication Information 
+ *
+ * @return  S16
+ *    -# ROK 
+ *    -# RFAILED 
+ *
+*/
+
+#ifdef ANSI
+PUBLIC S16 RlcMacProcUlData
+(
+Pst*           pst,
+SuId           suId,
+RlcMacData   *ulData
+)
+#else
+PUBLIC S16 RlcMacProcUlData(pst, suId, ulData)
+Pst*           pst;
+SuId           suId;
+RlcMacData   *ulData;
+#endif
+{
+   U8              idx;
+   U8              lcId;                    /* Logical Channel */
+   U8              numDLch = 0;             /* Number of dedicated logical channel */
+   Bool            dLchPduPres;             /* PDU received on dedicated logical channel */
+   RguLchDatInd    dLchData[RGU_MAX_LC];  /* PDU info on dedicated logical channel */
+   RguDDatIndInfo  dLchUlDat;               /* UL data on dedicated logical channel */
+   RguCDatIndInfo  cLchUlDat;               /* UL data on common logical channel */
+
+   /* Initializing dedicated logical channel Database */
+   for(idx = 0; idx < RGU_MAX_LC; idx++)
+   {
+      dLchData[idx].lcId = idx;
+      dLchData[idx].pdu.numPdu = 0;
+   }
+   
+   dLchPduPres = FALSE;
+  
+   /* Seggregate PDUs received on common and dedicated channels
+    * and call common channel's handler */
+   for(idx = 0; idx< ulData->nmbPdu; idx++)
+   {
+      if(ulData->pduInfo[idx].commCh)
+      {
+         cmMemset((U8*)&cLchUlDat, (U8)0, sizeof(RguCDatIndInfo));
+       
+         cLchUlDat.cellId = ulData->cellId;
+         cLchUlDat.rnti   = ulData->rnti;
+         cLchUlDat.lcId   = ulData->pduInfo[idx].lcId;
+         cLchUlDat.pdu    = ulData->pduInfo[idx].pduBuf;
+         
+         KwLiRguCDatInd(pst, suId, &cLchUlDat);
+      } 
+      else
+      {
+         if(!dLchPduPres)
+         {
+            dLchPduPres = TRUE;
+         }
+
+         lcId = ulData->pduInfo[idx].lcId;
+         dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu] = ulData->pduInfo[idx].pduBuf;
+         dLchData[lcId].pdu.numPdu++; 
+      }
+   }
+   /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
+    * and call its handler */ 
+   if(dLchPduPres)
+   {
+      dLchUlDat.cellId = ulData->cellId;
+      dLchUlDat.rnti   = ulData->rnti;
+
+      for(idx = 0; idx < RGU_MAX_LC; idx++)
+      {
+         if(dLchData[idx].pdu.numPdu)
+         {
+            cmMemcpy((U8 *)&dLchUlDat.lchData[numDLch], (U8 *)&dLchData[idx], sizeof(RguLchDatInd));
+            numDLch++;      
+         }
+      }
+      dLchUlDat.numLch = numDLch;
+      KwLiRguDDatInd(pst, suId, &dLchUlDat);
+   }
+
+   RETVALUE(ROK);
+   
+}/* End of RlcMacProcUlData */
+
 PUBLIC int   rlcDDatIndRcvd;
 PUBLIC int   rlcCDatIndRcvd;
 /**
@@ -362,6 +462,92 @@ RguDDatIndInfo   *datInd;
    RETVALUE(ROK);
 } /* KwLiRguDDatInd */
 
+
+/*******************************************************************
+ *
+ * @brief Handler for extracting common and dedicated channel
+ *      Scheduling result report. 
+ *
+ * @details
+ *
+ *    Function : RlcMacProcSchedRep
+ *
+ *    Functionality:
+ *     Handler for extracting common and dedicated channel
+ *      Scheduling result report
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+#ifdef ANSI
+PUBLIC S16 RlcMacProcSchedRep
+(
+Pst              *pst,
+SuId             suId,
+RlcMacSchedRep   *schRep
+)
+#else
+PUBLIC S16 RlcMacProcSchedRep(pst, suId, schRep)
+Pst              *pst;
+SuId             suId;
+RlcMacSchedRep   *schRep;
+#endif
+{
+   U8 idx;                     /* Iterator */
+   U8 nmbDLch = 0;                 /* Number of dedicated logical channles */
+   RguCStaIndInfo   cLchSchInfo;    /* Common logical channel scheduling result */
+   RguDStaIndInfo   dLchSchInfo;  /* Dedicated logical channel scheduling result */
+
+   for(idx=0; idx < schRep->nmbLch; idx++)
+   {
+       /* If it is common channel, fill status indication information 
+        * and trigger the handler for each common lch separately */
+       if(schRep->lchSta[idx].commCh)
+       {
+          cmMemset((U8*)&cLchSchInfo, (U8)0, sizeof(RguCStaIndInfo)); 
+
+          cLchSchInfo.cellId  = schRep->cellId;
+          cLchSchInfo.lcId    = schRep->lchSta[idx].lchStaInd.lcId;
+          //cLchSchInfo.transId = schRep->timeToTx;  /* TODO : fill transId suing timeToTx */
+          cLchSchInfo.rnti    = schRep->rnti;
+
+          KwLiRguCStaInd(pst, suId, &cLchSchInfo);
+          
+       }
+       else
+       {
+          /* Fill status info structure if at least one dedicated channel 
+           * scheduling report is received */
+          if(nmbDLch == 0)
+          {
+             dLchSchInfo.cellId = schRep->cellId;
+             dLchSchInfo.nmbOfUeGrantPerTti = 1;
+             dLchSchInfo.staInd[0].rnti = schRep->rnti;
+             //dLchSchInfo.staInd[0].transId = schRep->timeToTx;  /* TODO : fill transId suing timeToTx */
+             dLchSchInfo.staInd[0].nmbOfTbs = 1;
+             //dLchSchInfo.staInd[0].fillCrlPdu = /* TODO : Check the value needed to be filled */
+          }
+
+          /* Fill logical channel scheduling info */
+          cmMemcpy((U8 *)&dLchSchInfo.staInd[0].staIndTb[0].lchStaInd[nmbDLch], (U8 *)&schRep->lchSta[idx].lchStaInd, sizeof(RguLchStaInd));
+          nmbDLch++;
+
+       }
+
+   }
+
+   /* Calling handler for all dedicated channels scheduling*/
+   if(nmbDLch)
+   {
+      dLchSchInfo.staInd[0].staIndTb[0].nmbLch = nmbDLch;
+      KwLiRguDStaInd(pst, suId, &dLchSchInfo);
+   }
+
+   RETVALUE(ROK);
+}
+
 /**
  * @brief Handler for trigerring the data transfer from RLC to MAC
  *        for common logical channels.