[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-523] KPI reporting per statistics group
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index b9a8f34..b30f89d 100644 (file)
@@ -18,6 +18,7 @@
 
 /* This file contains F1AP message handler functions */
 #include "common_def.h"
+#include "du_tmr.h"
 #include "ckw.h"
 #include "ckw.x"
 #include "kwu.h"
@@ -33,6 +34,8 @@
 #include "du_app_mac_inf.h"
 #include "du_cfg.h"
 #include "du_app_rlc_inf.h"
+#include "du_e2ap_mgr.h"
+#include "du_e2ap_msg_hdl.h"
 #include "du_mgr_main.h"
 #include "du_mgr.h"
 #include "du_utils.h"
 #include "UPTransportLayerInformation.h"
 #include "GTPTunnel.h"
 #include "SupportedSULFreqBandItem.h"
-#include "du_e2ap_msg_hdl.h"
 #include "du_f1ap_conversions.h"
 #include "CNUEPagingIdentity.h"
 #include "PCCH-Config.h"
@@ -1586,6 +1588,91 @@ void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
    }
 }
 
+/*******************************************************************
+ *
+ * @brief add or modify E2NodeComponent list
+ *
+ * @details
+ *
+ *    Function : addOrModifyE2NodeComponent 
+ *
+ * Functionality: add or modify E2NodeComponent list 
+ *
+ * @parameter uint8_t componentactiontype, bool reqPart, uint8_t bufSize, char *bufString
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ******************************************************************/
+uint8_t addOrModifyE2NodeComponent(uint8_t action, bool reqPart, uint8_t bufSize, char *bufString)
+{
+   E2NodeComponent *e2NodeComponentInfo;
+   CmLList  *node = NULLP;
+   
+   if(action == E2_NODE_COMPONENT_ADD)
+   {
+      if(reqPart == true)
+      {
+         DU_ALLOC(e2NodeComponentInfo, sizeof(E2NodeComponent));
+         if(!e2NodeComponentInfo)
+         {
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for e2NodeComponentInfo in %s",__func__);
+            return RFAILED;
+         }
+         e2NodeComponentInfo->interfaceType =F1;
+         e2NodeComponentInfo->componentId=duCfgParam.duId;
+         e2NodeComponentInfo->componentActionType = action;
+         e2NodeComponentInfo->reqBufSize = bufSize;
+
+         DU_ALLOC(e2NodeComponentInfo->componentRequestPart, bufSize);
+         if(e2NodeComponentInfo->componentRequestPart == NULLP)
+         {
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for componentRequestPart");
+            DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
+            return RFAILED;
+         }
+         memcpy(e2NodeComponentInfo->componentRequestPart, bufString, e2NodeComponentInfo->reqBufSize);
+         DU_ALLOC(node, sizeof(CmLList));
+         if(node)
+         {
+            node->node = (PTR) e2NodeComponentInfo;
+            cmLListAdd2Tail(&duCb.e2apDb.e2NodeComponentList, node);
+         }
+         else
+         {
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for e2NodeComponentList node");
+            DU_FREE(e2NodeComponentInfo->componentRequestPart, bufSize);
+            DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
+            return RFAILED;
+         }
+      }
+      else
+      {
+         if(duCb.e2apDb.e2NodeComponentList.count)
+         {
+            CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node);
+            while(node)
+            {
+               e2NodeComponentInfo = (E2NodeComponent*)node->node;
+               if((e2NodeComponentInfo->interfaceType == F1) && (e2NodeComponentInfo->componentActionType == action))
+               {
+                  e2NodeComponentInfo->rspBufSize = bufSize;
+
+                  DU_ALLOC(e2NodeComponentInfo->componentResponsePart, bufSize);
+                  if(e2NodeComponentInfo->componentResponsePart == NULLP)
+                  {
+                     DU_LOG("\nERROR  -->  F1AP : Memory allocation failed to store the encoding of f1setup rsp");
+                     return RFAILED;
+                  }
+                  memcpy(e2NodeComponentInfo->componentResponsePart, bufString, e2NodeComponentInfo->rspBufSize);
+                  break;
+               }
+               node = node->next;
+            }
+         } 
+      }
+   }
+   return ROK;
+}
 /*******************************************************************
  *
  * @brief Builds and Send the F1SetupRequest
@@ -1754,17 +1841,10 @@ uint8_t BuildAndSendF1SetupReq()
             printf("%x",encBuf[ieIdx]);
          }
 #endif
+         
 
-         duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize = encBufSize;
-         DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, encBufSize);
-         if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
-         {
-            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed to store the encoding of f1setup req");
-            return RFAILED;
-         }
-         memcpy(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, &encBuf, duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize);
       }
-
+      addOrModifyE2NodeComponent(E2_NODE_COMPONENT_ADD, true, encBufSize, encBuf);
       /* Sending msg */
       if(sendF1APMsg() != ROK)
       {
@@ -3287,7 +3367,8 @@ uint8_t BuildRlcConfigAm(AmBearerCfg *amCfg, struct RLC_Config *rlcConfig)
    /* Fill default AM UL configuration if input pointer to DU database is NULL */
    if(amCfg == NULLP)
    {
-      *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
+      
+      *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN_12BIT; /*As per Spec 38.331, "Network configures only value size12 in SN-FieldLengthAM for SRB"*/
       rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit  = T_POLL_RETRANSMIT;
       rlcConfig->choice.am->ul_AM_RLC.pollPDU           = POLL_PDU;
       rlcConfig->choice.am->ul_AM_RLC.pollByte          = POLL_BYTE;
@@ -3314,7 +3395,7 @@ uint8_t BuildRlcConfigAm(AmBearerCfg *amCfg, struct RLC_Config *rlcConfig)
    /* Fill default AM DL configuration if input pointer to DU database is NULL */
    if(amCfg == NULLP)
    {
-      *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
+      *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN_12BIT; /*As per Spec 38.331, "Network configures only value size12 in SN-FieldLengthAM for SRB"*/
       rlcConfig->choice.am->dl_AM_RLC.t_Reassembly      = T_REASSEMBLY;
       rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit  = T_STATUS_PROHIBHIT;
    }
@@ -15546,15 +15627,8 @@ uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
    
    duProcF1SetupRsp();
    freeAperDecodeF1SetupRsp(f1SetRspMsg);
-
-   duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize = recvBufLen;
-   DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize);
-   if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
-   {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failed to store the buf of F1setup response");
-      return RFAILED;
-   }
-   memcpy(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, recvBuf, recvBufLen);
+   
+   addOrModifyE2NodeComponent(E2_NODE_COMPONENT_ADD, false, recvBufLen, recvBuf);
 
    if(BuildAndSendE2SetupReq() != ROK)
    {
@@ -16214,6 +16288,13 @@ void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
                         break;
                      case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
                         break;
+                     case ProtocolIE_ID_id_DUtoCURRCInformation:
+                        {
+                           DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCInformation.\
+                              cellGroupConfig.buf, ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.\
+                              DUtoCURRCInformation.cellGroupConfig.size);
+                           break;
+                        }
                      case ProtocolIE_ID_id_DRBs_SetupMod_List:
                         {
                             FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
@@ -16461,6 +16542,7 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
       ret = ROK;
       break;
    }
+
    FreeUeContextModResp(f1apMsg);
    return ret;
 }