[Epic-ID: ODUHIGH-538][Issue-ID: ODUHIGH-563] Fixes to read SCTP and EGTP configurati...
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index b30f89d..87c1536 100644 (file)
@@ -1588,91 +1588,6 @@ 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
@@ -1844,13 +1759,19 @@ uint8_t BuildAndSendF1SetupReq()
          
 
       }
-      addOrModifyE2NodeComponent(E2_NODE_COMPONENT_ADD, true, encBufSize, encBuf);
+      
       /* Sending msg */
       if(sendF1APMsg() != ROK)
       {
          DU_LOG("\nERROR  -->  F1AP : Sending F1 Setup request failed");
          break;
       }
+      
+      if(fillE2NodeComponentReqInfo(F1, duCfgParam.duId,  E2_NODE_COMPONENT_ADD, encBufSize, encBuf) !=ROK)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Failed to add the e2 node in the list");
+         break;
+      }
 
       ret=ROK;
       break;
@@ -2843,12 +2764,19 @@ uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
          }
 #endif
       }
+      
       /* Sending msg */
       if(sendF1APMsg() != ROK)
       {
          DU_LOG("\nERROR  -->  F1AP : Sending GNB-DU Config Update failed");
          break;
       }
+      
+      if(fillE2NodeComponentReqInfo(F1, duCfgParam.duId, E2_NODE_COMPONENT_UPDATE, encBufSize, encBuf)!=ROK)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Failed to update the e2 node in the list");
+         break;
+      }
 
       ret = ROK;
       break;
@@ -4026,6 +3954,76 @@ uint8_t BuildControlRSetToAddModList(PdcchConfig *pdcchCfg, struct PDCCH_Config_
    return ROK;
 } /* End BuildControlRSetToAddModList */
 
+/*******************************************************************
+ *
+ * @brief build SlotOffset for SearchSpace
+ *
+ * @details
+ *
+ *    Function : BuildSearchSpcSlotOffset
+ *
+ *    Functionality: Build Slot Offset for search space to add/modify list
+ *
+ * @params[in] SearchSpace__monitoringSlotPeriodicityAndOffset *mSlotPeriodicityAndOffset
+ *             uint16_t slotOffset
+ * @return void
+ *
+ * ****************************************************************/
+void BuildSearchSpcSlotOffset(struct SearchSpace__monitoringSlotPeriodicityAndOffset *mSlotPeriodicityAndOffset,  uint16_t slotOffset)
+{
+   switch(mSlotPeriodicityAndOffset->present)
+   {
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
+         mSlotPeriodicityAndOffset->choice.sl1 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
+         mSlotPeriodicityAndOffset->choice.sl2 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
+         mSlotPeriodicityAndOffset->choice.sl4 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
+         mSlotPeriodicityAndOffset->choice.sl5 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
+         mSlotPeriodicityAndOffset->choice.sl8 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
+         mSlotPeriodicityAndOffset->choice.sl10 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
+         mSlotPeriodicityAndOffset->choice.sl16 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
+         mSlotPeriodicityAndOffset->choice.sl20 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
+         mSlotPeriodicityAndOffset->choice.sl40 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
+         mSlotPeriodicityAndOffset->choice.sl80 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
+         mSlotPeriodicityAndOffset->choice.sl160 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
+         mSlotPeriodicityAndOffset->choice.sl320 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
+         mSlotPeriodicityAndOffset->choice.sl640 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
+         mSlotPeriodicityAndOffset->choice.sl1280 = slotOffset;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
+         mSlotPeriodicityAndOffset->choice.sl2560 = slotOffset;
+         break;
+      default:
+         break;
+   }
+}
+
+
 /*******************************************************************
  *
  * @brief Build search space to add/modify list
@@ -4108,7 +4106,12 @@ uint8_t BuildSearchSpcToAddModList(PdcchConfig *pdcchCfg, struct PDCCH_Config__s
       if(pdcchCfg == NULLP)
          searchSpc->monitoringSlotPeriodicityAndOffset->present = SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
       else
-         searchSpc->monitoringSlotPeriodicityAndOffset->present = pdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
+      {
+         searchSpc->monitoringSlotPeriodicityAndOffset->present = \
+                     pdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset.mSlotPeriodicity;
+         BuildSearchSpcSlotOffset(searchSpc->monitoringSlotPeriodicityAndOffset, \
+                     pdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset.mSlotOffset);
+      }
 
       searchSpc->duration = NULLP;
       searchSpc->monitoringSymbolsWithinSlot = NULLP;
@@ -4254,7 +4257,6 @@ uint8_t BuildBWPDlDedPdcchCfg(PdcchConfig *pdcchCfgDb, struct PDCCH_Config *pdcc
 }
 
 /*******************************************************************
- *
  * @brief Builds DMRS DL PDSCH Mapping type A
  *
  * @details
@@ -10565,7 +10567,7 @@ uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
 #ifdef O1_ENABLE
    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
 #else
-   cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
+   ipv4_du = duCfgParam.egtpParams.localIp.ipV4Addr;
 #endif
 
    for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
@@ -11108,6 +11110,80 @@ void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
   }
 }
 
+/*******************************************************************
+ *
+ * @brief Fills SlotOffset value for SearchSpace received by CU
+ *
+ * @details
+ *
+ *    Function : extractSlotOffset
+ *
+ *    Functionality: Fills SlotOffset received  by CU
+ *
+ * @params[in] SearchSpace__monitoringSlotPeriodicityAndOffset *mSlotPeriodicityOffset,
+ *             uint16_t *slotOffset
+ * @return void
+ *
+ *
+ ****************************************************************/
+void extractSlotOffset(struct SearchSpace__monitoringSlotPeriodicityAndOffset *mSlotPeriodicityAndOffset, uint16_t *slotOffset)
+{
+   switch(mSlotPeriodicityAndOffset->present)
+   {
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_NOTHING:
+         *slotOffset = NULLD;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl1;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl2;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl4;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl5;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl8;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl10;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl16;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl20;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl40;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl80;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl160;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl320;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl640;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl1280;
+         break;
+      case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
+         *slotOffset = mSlotPeriodicityAndOffset->choice.sl2560;
+         break;
+      default:
+         *slotOffset = 0;
+   }
+}
+
+
 /*******************************************************************
  *
  * @brief Fills PdcchCfg received by CU
@@ -11200,8 +11276,10 @@ void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
                                                                     *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
             if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
             {
-               macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
-                                                                                         srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
+               macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset.mSlotPeriodicity =\
+                                               srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
+               extractSlotOffset(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset,\
+                                               &macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset.mSlotOffset);
             }
             if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
             {
@@ -15628,7 +15706,11 @@ uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
    duProcF1SetupRsp();
    freeAperDecodeF1SetupRsp(f1SetRspMsg);
    
-   addOrModifyE2NodeComponent(E2_NODE_COMPONENT_ADD, false, recvBufLen, recvBuf);
+   if(fillE2NodeComponentRspInfo(F1, duCfgParam.duId, E2_NODE_COMPONENT_ADD, recvBufLen, recvBuf) !=ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Failed to add the e2 node in the list");
+      return RFAILED;
+   }
 
    if(BuildAndSendE2SetupReq() != ROK)
    {
@@ -15806,11 +15888,12 @@ uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
 *
 *    Functionality: added free part for the memory allocated by aper_decoder
 *
-* @params[in] F1AP_PDU_t *f1apMsg 
+* @params[in] F1AP_PDU_t *f1apMsg,  MsgLen recvBufLen, char *recvBuf 
 * @return void 
 *
 * ****************************************************************/
-uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
+
+uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
 {
    uint8_t ieIdx=0,transId=0;
    GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
@@ -15853,6 +15936,13 @@ uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
 #endif
 
    freeAperDecodeGnbDuAck(gnbDuAck);
+   
+   if(fillE2NodeComponentRspInfo(F1,duCfgParam.duId, E2_NODE_COMPONENT_UPDATE, recvBufLen, recvBuf) !=ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Failed to update the e2 node in the list");
+      return RFAILED;
+   }
+
    return ROK;
 }
 /******************************************************************
@@ -18035,7 +18125,7 @@ void F1APMsgHdlr(Buffer *mBuf)
 
                case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
                   {
-                     procF1GNBDUCfgUpdAck(f1apMsg);
+                     procF1GNBDUCfgUpdAck(f1apMsg, recvBufLen, recvBuf);
                      break;
                   }