[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-532] RIC Subscription Delete Request
[o-du/l2.git] / src / 5gnrmac / mac_msg_hdl.c
index d36792a..d5544ba 100644 (file)
 
 MacCb  macCb;
 
+MacDuStatsIndFunc macDuStatsIndOpts[] =
+{
+   packDuMacStatsInd,   /* packing for loosely coupled */
+   DuProcMacStatsInd,   /* packing for tightly coupled */
+   packDuMacStatsInd   /* packing for light weight loosly coupled */
+};
+
+
 /*******************************************************************
  *
  * @brief Sends DL BO Info to SCH
@@ -764,7 +772,7 @@ uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
+uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint16_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
 {
    uint16_t harqCounter=0;
    Pst pst;
@@ -807,7 +815,7 @@ uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cell
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
+uint8_t buildAndSendSrInd(UciInd *macUciInd, uint16_t crnti)
 {
    uint16_t cellIdx;
    Pst pst;
@@ -1057,6 +1065,77 @@ uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
    return ret;
 }
 
+/**
+ * @brief Mac process the statistics indication received from sch.
+ *
+ * @details
+ *
+ *     Function : MacProcSchStatsInd
+ *
+ *     This function process the statistics indication received from sch
+ *
+ *  @param[in]  Pst           *pst
+ *  @param[in]  SchStatsInd   *schStatsInd
+ *  @return  int
+ *      -# ROK
+ **/
+uint8_t MacProcSchStatsInd(Pst *pst, SchStatsInd *schStatsInd)
+{
+   uint8_t statsIdx = 0;
+   Pst indPst;
+   MacStatsInd *macStatsInd;
+
+#ifdef DEBUG_PRINT
+   DU_LOG("\nDEBUG  -->  MAC : MacProcSchStatsInd: Received Statistics Indication from SCH");
+#endif   
+
+   if(schStatsInd == NULLP)
+   {
+      DU_LOG("\nERROR  -->  MAC : MacProcSchStatsInd: NULL pointer :schStatsInd");
+      return RFAILED;
+   }
+
+   MAC_ALLOC_SHRABL_BUF(macStatsInd, sizeof(MacStatsInd));
+   if(macStatsInd == NULLP)
+   {
+      DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchStatsInd");
+      return RFAILED;
+   }
+
+   macStatsInd->subscriptionId = schStatsInd->subscriptionId;
+   macStatsInd->groupId = schStatsInd->groupId;
+
+   for(statsIdx = 0; statsIdx < schStatsInd->numStats; statsIdx++)
+   {
+      switch(schStatsInd->measuredStatsList[statsIdx].type)
+      {
+         case SCH_DL_TOTAL_PRB_USAGE:
+            {
+               macStatsInd->measuredStatsList[statsIdx].type = MAC_DL_TOTAL_PRB_USAGE;
+               break;
+            }
+         case SCH_UL_TOTAL_PRB_USAGE:
+            {
+               macStatsInd->measuredStatsList[statsIdx].type = MAC_UL_TOTAL_PRB_USAGE;
+               break;
+            }
+         default:
+            {
+               DU_LOG("\nERROR  -->  MAC : MacProcSchStatsInd: Invalid measurement type [%d]", \
+                     schStatsInd->measuredStatsList[statsIdx].type);
+               MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, macStatsInd, sizeof(MacStatsInd));
+               return RFAILED;
+            }
+      }
+      macStatsInd->measuredStatsList[statsIdx].value = schStatsInd->measuredStatsList[statsIdx].value;
+   }
+   macStatsInd->numStats = schStatsInd->numStats;
+
+   memset(&indPst, 0, sizeof(Pst));
+   FILL_PST_MAC_TO_DUAPP(indPst, EVENT_MAC_STATISTICS_IND);
+   return (*macDuStatsIndOpts[indPst.selector])(&indPst, macStatsInd);
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/