JIRA-ID:[ODUHIGH-295]- Tunnel creation in EGTP
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index 0c31605..4213471 100644 (file)
 #include "du_mgr.h"
 #include "du_cell_mgr.h"
 #include "du_f1ap_msg_hdl.h"
+#include "DRBs-Setup-Item.h"
+#include "DLUPTNLInformation-ToBeSetup-List.h"
+#include "DLUPTNLInformation-ToBeSetup-Item.h"
+#include "UPTransportLayerInformation.h"
+#include "GTPTunnel.h"
 
 DuCfgParams duCfgParam;
 
+/************************************************************************
+ *
+ * @brief Converts enum values into actual value of Poll retransmit timer
+ *
+ * @details
+ *
+ *    Function : getPollPdu
+ *
+ *    Functionality: Converts enum values into actual value of poll 
+ *    retransmit timer
+ *
+ * @params[in] Enum value of pollPdu
+ * @return Actual value of pollPdu
+ *
+ * **********************************************************************/
+
+uint16_t getPollRetxTmr(uint8_t pollRetxTmrCfg)
+{
+   uint16_t pollRetxTmr;
+
+   /* All values of poll retx timer are at interval of 5ms.
+    * This is valid upto 250ms
+    * Hence converting the enum value to actual value by multiplying it to 5
+    */
+   if(pollRetxTmrCfg <= T_PollRetransmit_ms250)
+      pollRetxTmr = (pollRetxTmrCfg + 1) * 5;
+   else
+   {
+      switch(pollRetxTmrCfg)
+      {
+         case T_PollRetransmit_ms300:
+            pollRetxTmr = 300;
+            break;
+         case T_PollRetransmit_ms350:
+            pollRetxTmr = 350;
+            break;
+         case T_PollRetransmit_ms400:
+            pollRetxTmr = 400;
+            break;
+         case T_PollRetransmit_ms450:
+            pollRetxTmr = 450;
+            break;
+         case T_PollRetransmit_ms500:
+            pollRetxTmr = 500;
+            break;
+         case T_PollRetransmit_ms800:
+            pollRetxTmr = 800;
+            break;
+         default:
+            DU_LOG("\nERROR  -->  F1AP: Invalid value of Poll Retransmit timer");
+            pollRetxTmr = 0;
+      }
+   }
+   return pollRetxTmr; 
+}
+
+/*******************************************************************
+ *
+ * @brief Converts enum values into actual value of PollPdu
+ *
+ * @details
+ *
+ *    Function : getPollPdu
+ *
+ *    Functionality: Converts enum values into actual value of PollPdu
+ *
+ * @params[in] Enum value of pollPdu
+ * @return Actual value of pollPdu
+ *
+ * ****************************************************************/
+int16_t getPollPdu(uint8_t pollPduCfg)
+{
+   int16_t pollPdu;
+   switch(pollPduCfg)
+   {
+      case PollPDU_p4:
+         pollPdu = 4;
+         break;
+      case PollPDU_p8:
+         pollPdu = 8;
+         break;
+      case PollPDU_p16:
+         pollPdu = 16;
+         break;
+      case PollPDU_p32:
+         pollPdu = 32;
+         break;
+      case PollPDU_p64:
+         pollPdu = 64;
+         break;
+      case PollPDU_p128:
+         pollPdu = 128;
+         break;
+      case PollPDU_p256:
+         pollPdu = 256;
+         break;
+      case PollPDU_p512:
+         pollPdu = 512;
+         break;
+      case PollPDU_p1024:
+         pollPdu = 1024;
+         break;
+      case PollPDU_p2048:
+         pollPdu = 2048;
+         break;
+      case PollPDU_p4096:
+         pollPdu = 4096;
+         break;
+      case PollPDU_p6144:
+         pollPdu = 6144;
+         break;
+      case PollPDU_p8192:
+         pollPdu = 8192;
+         break;
+      case PollPDU_p12288:
+         pollPdu = 12288;
+         break;
+      case PollPDU_p16384:
+         pollPdu = 16384;
+         break;
+      case PollPDU_p20480:
+         pollPdu = 20480;
+         break;
+      case PollPDU_p24576:
+         pollPdu = 24576;
+         break;
+      case PollPDU_p28672:
+         pollPdu = 28672;
+         break;
+      case PollPDU_p32768:
+         pollPdu = 32768;
+         break;
+      case PollPDU_p40960:
+         pollPdu = 40960;
+         break;
+      case PollPDU_p49152:
+         pollPdu = 49152;
+         break;
+      case PollPDU_p57344:
+         pollPdu = 57344;
+         break;
+      case PollPDU_p65536:
+         pollPdu = 65536;
+         break;
+      case PollPDU_infinity:
+         pollPdu = -1;
+        break;
+      default:
+         DU_LOG("\nERROR  -->  F1AP: Invalid value of poll pdu");
+        pollPdu = 0;
+         break;
+   }
+   return pollPdu;
+}
+
+/*******************************************************************
+ *
+ * @brief Converts enum values into actual value of poll bytes
+ *
+ * @details
+ *
+ *    Function : getPollByte
+ *
+ *    Functionality: Converts enum values into actual value of pollBytes
+ *
+ * @params[in] Enum value
+ * @return Actual value
+ *
+ * ****************************************************************/
+int32_t getPollByte(uint16_t pollBytesCfg)
+{
+   int32_t pollBytes;
+   switch(pollBytesCfg)
+   {
+      case PollByte_kB1:
+         pollBytes = 1000;
+         break;
+      case PollByte_kB2:
+         pollBytes = 2000;
+         break;
+      case PollByte_kB5:
+         pollBytes = 5000;
+         break;
+      case PollByte_kB8:
+         pollBytes = 8000;
+         break;
+      case PollByte_kB10:
+         pollBytes = 10000;
+         break;
+      case PollByte_kB15:
+         pollBytes = 15000;
+         break;
+      case PollByte_kB25:
+         pollBytes = 25000;
+         break;
+      case PollByte_kB50:
+         pollBytes = 50000;
+         break;
+      case PollByte_kB75:
+         pollBytes = 75000;
+         break;
+      case PollByte_kB100:
+         pollBytes = 100000;
+         break;
+      case PollByte_kB125:
+         pollBytes = 125000;
+         break;
+      case PollByte_kB250:
+         pollBytes = 250000;
+         break;
+      case PollByte_kB375:
+         pollBytes = 375000;
+         break;
+      case PollByte_kB500:
+         pollBytes = 500000;
+         break;
+      case PollByte_kB750:
+         pollBytes = 750000;
+         break;
+      case PollByte_kB1000:
+         pollBytes = 1000000;
+         break;
+      case PollByte_kB1250:
+         pollBytes = 1250000;
+         break;
+      case PollByte_kB1500:
+         pollBytes = 1500000;
+         break;
+      case PollByte_kB2000:
+         pollBytes = 2000000;
+         break;
+      case PollByte_kB3000:
+         pollBytes = 3000000;
+         break;
+      case PollByte_kB4000:
+         pollBytes = 4000000;
+         break;
+      case PollByte_kB4500:
+         pollBytes = 4500000;
+         break;
+      case PollByte_kB5000:
+         pollBytes = 5000000;
+         break;
+      case PollByte_kB5500:
+         pollBytes = 5500000;
+         break;
+      case PollByte_kB6000:
+         pollBytes = 6000000;
+         break;
+      case PollByte_kB6500:
+         pollBytes = 6500000;
+         break;
+      case PollByte_kB7000:
+         pollBytes = 7000000;
+         break;
+      case PollByte_kB7500:
+         pollBytes = 7500000;
+         break;
+      case PollByte_mB8:
+         pollBytes = 8000000;
+         break;
+      case PollByte_mB9:
+         pollBytes = 9000000;
+         break;
+      case PollByte_mB10:
+         pollBytes = 10000000;
+         break;
+      case PollByte_mB11:
+         pollBytes = 11000000;
+         break;
+      case PollByte_mB12:
+         pollBytes = 12000000;
+         break;
+      case PollByte_mB13:
+         pollBytes = 13000000;
+         break;
+      case PollByte_mB14:
+         pollBytes = 14000000;
+         break;
+      case PollByte_mB15:
+         pollBytes = 15000000;
+         break;
+      case PollByte_mB16:
+         pollBytes = 16000000;
+         break;
+      case PollByte_mB17:
+         pollBytes = 17000000;
+         break;
+      case PollByte_mB18:
+         pollBytes = 18000000;
+         break;
+      case PollByte_mB20:
+         pollBytes = 20000000;
+         break;
+      case PollByte_mB25:
+         pollBytes = 25000000;
+         break;
+      case PollByte_mB30:
+         pollBytes = 30000000;
+         break;
+      case PollByte_mB40:
+         pollBytes = 40000000;
+         break;
+      case PollByte_infinity:
+         pollBytes = -1;
+         break;
+      default:
+         DU_LOG("\nERROR  -->  F1AP: Invalid value of poll bytes");
+         pollBytes = 0;
+   }
+   return pollBytes;
+}
+
+/*******************************************************************
+ *
+ * @brief Converts enum values into actual value of maxRetx
+ *
+ * @details
+ *
+ *    Function : getMaxRetx
+ *
+ *    Functionality: Converts enum values into actual value of maxRetx
+ *
+ * @params[in] Enum value
+ * @return Actual value
+ *
+ * ****************************************************************/
+uint8_t getMaxRetx(uint8_t maxRetxCfg)
+{
+   uint8_t maxRetx;
+   switch(maxRetxCfg)
+   {
+      case UL_AM_RLC__maxRetxThreshold_t1:
+         maxRetx = 1;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t2:
+         maxRetx = 2;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t3:
+         maxRetx = 3;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t4:
+         maxRetx = 4;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t6:
+         maxRetx = 6;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t8:
+         maxRetx = 8;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t16:
+         maxRetx = 16;
+         break;
+      case UL_AM_RLC__maxRetxThreshold_t32:
+         maxRetx = 32;
+         break;
+      default:
+         DU_LOG("\nERROR  -->  F1AP: Invalid configuration for Max retransmission threshold");
+         maxRetx = 0;
+   }
+   return maxRetx;
+}
+
+/*******************************************************************
+ * @brief Converts enum values into actual value of reassembly timer
+ *
+ * @details
+ *
+ *    Function : getReAsmblTmr
+ *
+ *    Functionality: Converts enum values into actual value of reassembly 
+ *    timer
+ *
+ * @params[in] Enum value of reassembly timer
+ * @return Actual value of reassembly timer
+ *
+ * **********************************************************************/
+
+int8_t getReAsmblTmr(uint8_t reAsmblTmrCfg)
+{
+   int8_t reAsmblTmr = 0;
+   
+   if(reAsmblTmrCfg == T_Reassembly_ms0)
+   {
+      reAsmblTmr = 0;
+   }
+   else if(reAsmblTmrCfg >= T_Reassembly_ms5 || reAsmblTmrCfg <= T_Reassembly_ms100)
+   {
+     /* All values of re assembly timer are at interval of 5ms.
+      * This is valid upto 100ms
+      * Hence converting the enum value to actual value by multiplying it to 5
+      */
+      reAsmblTmr = reAsmblTmrCfg * 5;
+   }
+   else if(reAsmblTmrCfg >= T_Reassembly_ms110 || reAsmblTmrCfg <= T_Reassembly_ms200)
+   {
+     /* All values of re assembly timer are at interval of 10ms.
+      * This is valid upto 200ms
+      * since enum value starts from 20 for 100ms, subtracting 10 and
+      * converting the enum value to actual value by multiplying it to 10
+      */
+      reAsmblTmr = ((reAsmblTmrCfg-10) * 10);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  F1AP : Invalid value of Re Assembly timer %d", reAsmblTmrCfg);
+      reAsmblTmr = -1;
+   }
+   return reAsmblTmr; 
+}
+
+/************************************************************************
+ *
+ * @brief Converts enum values into actual value of status prohibit timer
+ *
+ * @details
+ *
+ *    Function : getStatProhTmr
+ *
+ *    Functionality: Converts enum values into actual value of status prohibit 
+ *    timer
+ *
+ * @params[in] Enum value of status prohibit timer
+ * @return Actual value of status prohibit timer
+ *
+ * **********************************************************************/
+
+int16_t getStatProhTmr(uint8_t statProhTmrCfg)
+{
+   int16_t statProhTmr =0;
+   
+   if(statProhTmrCfg == T_StatusProhibit_ms0)
+   {
+      statProhTmr = 0;
+   }
+   else if(statProhTmrCfg >= T_StatusProhibit_ms5 || statProhTmrCfg <= T_StatusProhibit_ms250)
+   {
+      /* All values of re assembly timer are at interval of 5ms.
+       * This is valid upto 250ms
+       * Hence converting the enum value to actual value by multiplying it to 5
+       */
+      statProhTmr = statProhTmrCfg * 5;
+   }
+   else
+   {
+      switch(statProhTmrCfg)
+      {
+         case T_StatusProhibit_ms300:
+            statProhTmr = 300;
+            break;
+         case T_StatusProhibit_ms350:
+            statProhTmr = 350;
+            break;
+         case T_StatusProhibit_ms400:
+            statProhTmr = 400;
+            break;
+         case T_StatusProhibit_ms450:
+            statProhTmr = 450;
+            break;
+         case T_StatusProhibit_ms500:
+            statProhTmr = 500;
+            break;
+         case T_StatusProhibit_ms800:
+            statProhTmr = 800;
+            break;
+         case T_StatusProhibit_ms1000:
+            statProhTmr = 1000;
+            break;
+         case T_StatusProhibit_ms1200:
+            statProhTmr = 1200;
+            break;
+         case T_StatusProhibit_ms1600:
+            statProhTmr = 1600;
+            break;
+         case T_StatusProhibit_ms2000:
+            statProhTmr = 2000;
+            break;
+         case T_StatusProhibit_ms2400:
+            statProhTmr = 2400;
+            break;
+         default:
+            DU_LOG("\nInvalid value of Status Prohibit timer %d", statProhTmrCfg);
+            statProhTmr = -1;
+           break;
+      }
+   }
+   return statProhTmr; 
+}
+
 /*******************************************************************
  *
  * @brief Builds Uplink Info for NR 
@@ -6267,6 +6761,11 @@ void freeDuUeCfg(DuUeCfg *ueCfg)
    {
       freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
    }
+   for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
+   {
+      DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
+      memset(&ueCfg->upTnlInfo[lcIdx], 0, sizeof(UpTnlCfg));
+   }
 }
 
 /*******************************************************************
@@ -6326,7 +6825,8 @@ void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
       if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
       {
         amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
-        amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
+         /*TODO: Check the timer value when sent by real CU */
+        amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly; 
         amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
       }
 
@@ -6643,10 +7143,81 @@ void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCf
    qosToAdd->ulPduSessAggMaxBitRate = 0;
 }
 
-uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, LcCfg *macLcToAdd)
+/*******************************************************************
+ *
+ * @brief Function to extract GTP Tunnel Info from CU
+ *
+ * @details
+ *
+ *    Function : extractUpTnlInfo
+ *
+ *    Functionality: Function to extract GTP Tunnel Info from CU
+ *
+ * @params[in] F1AP message
+ * @return ROK/RFAILED
+ *
+ * ****************************************************************/
+
+uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
+   ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
+{
+   uint8_t tnlIdx;
+   uint32_t ipv4_du = 0;
+   GTPTunnel_t *gtpTunnel = NULLP;
+
+   upTnlInfo->drbId = drbId; 
+   upTnlInfo->configType = configType;
+   cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
+
+   for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
+   {
+      if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
+      {
+        if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
+        {
+           gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
+           DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
+            if(upTnlInfo->tnlCfg1 == NULLP)
+           {
+               DU_LOG("\nERROR  -->  F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
+               return RFAILED;
+           }
+           bitStringToInt(&gtpTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
+           upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
+           if(gtpTunnel->gTP_TEID.size > 0)
+           {
+              teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
+           }
+        }
+        break;
+      }
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to extract DRB info received from CU
+ *
+ * @details
+ *
+ *    Function : extractDrbCfg
+ *
+ *    Functionality: Function to extract DRB info received from CU
+ *
+ * @params[in] F1AP message
+ * @return void
+ *
+ * ****************************************************************/
+uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
 {
    DRB_Information_t *drbInfo = NULLP;
 
+   if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
+      return RFAILED;
+   }
    if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
    {
       if(drbItem->qoSInformation.choice.choice_extension->value.present ==
@@ -6690,17 +7261,21 @@ uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, LcCfg *macLcToAdd)
    return ROK;
 }
 
-uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg)
+uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg,\
+   UpTnlCfg *upTnlInfo)
 {
    uint8_t ret = ROK;
 
    if(drbCfg)
    {
-      ret = extractDrbCfg(drbCfg, lcCfg);
-      if(ret == RFAILED)
+      if(drbCfg != NULLP)
       {
-         DU_LOG("ERROR  -->  F1AP : Failed to build Drb Qos at extractMacRbCfg()");
-        return ret;
+         ret = extractDrbCfg(drbCfg, lcCfg, upTnlInfo);
+         if(ret == RFAILED)
+         {
+            DU_LOG("ERROR  -->  F1AP : Failed to build Drb Qos at extractMacRbCfg()");
+            return ret;
+         }
       }
    }
    else
@@ -6723,7 +7298,7 @@ uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg, LogicalChan
 }
 
 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
-   DRBs_ToBeSetup_Item_t *drbItem, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg)
+   DRBs_ToBeSetup_Item_t *drbItem, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
 {
    uint8_t ret = ROK;
 
@@ -6731,11 +7306,11 @@ uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
    lcCfg->configType = configType;
    if(rbType == RB_TYPE_SRB)
    {
-      ret = extractMacRbCfg(lcId, NULL, ulLcCfg, lcCfg);
+      ret = extractMacRbCfg(lcId, NULL, ulLcCfg, lcCfg, NULL);
    }
    else if(rbType == RB_TYPE_DRB)
    {
-      ret = extractMacRbCfg(lcId, drbItem, ulLcCfg, lcCfg);
+      ret = extractMacRbCfg(lcId, drbItem, ulLcCfg, lcCfg, upTnlInfo);
    }
    return ret;
 }
@@ -6808,7 +7383,7 @@ uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList
      memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
      memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
      procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
-     ret = procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx]);
+     ret = procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL);
      if(ret == RFAILED)
      {
         DU_LOG("\nERROR  -->  DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
@@ -8798,7 +9373,7 @@ uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, R
    procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
 
    /* Filling MAC INFO */
-   ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL, NULL, macLcToAdd);
+   ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL, NULL, macLcToAdd, NULL);
    if(ret == RFAILED)
    { 
       DU_LOG("\nERROR  -->  F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
@@ -8885,7 +9460,8 @@ uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
  *
  * ****************************************************************/
 
-uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
+uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
+   LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
 {
    uint8_t ret = ROK;
 
@@ -8893,10 +9469,10 @@ uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem, LcCfg *
    procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
 
    /* Filling MAC INFO */
-   ret = procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, macLcToAdd);
+   ret = procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, macLcToAdd, upTnlInfo);
    if(ret == RFAILED)
    { 
-      DU_LOG("\nERROR  -->  F1AP : Failed at RLC LC Cfg in extractDrbListToSetup()");
+      DU_LOG("\nERROR  --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
       return ret;
    }
 
@@ -8933,22 +9509,24 @@ uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg, DuUeC
          drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
         if(ueCfgDb->numMacLcs > MAX_NUM_LC)
         { 
-            DU_LOG("\nERROR   -->  F1AP:  MAX LC Reached in MAC ");
+            DU_LOG("\nERROR  -->  F1AP :  MAX LC Reached in MAC at extractDrbListToSetup()");
            ret = RFAILED;
            break;
         }
         if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
         {
-            DU_LOG("\nERROR   -->  F1AP:  MAX LC Reached in RLC");
+            DU_LOG("\nERROR  -->  F1AP :  MAX LC Reached in RLC at extractDrbListToSetup()");
            ret = RFAILED;
            break;
         }
         memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
         memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
          ret = procDrbListToSetup(lcId, drbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
-           &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
+           &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
+
         ueCfgDb->numRlcLcs++;
         ueCfgDb->numMacLcs++;
+        ueCfgDb->numDrb++;
         if(ret == RFAILED)
         {
             DU_LOG("\nERROR  -->  F1AP :  Failed at extractDrbListToSetup()");
@@ -8988,7 +9566,7 @@ uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
       DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
       if(!dlRrcMsg->rrcMsgPdu)
       {
-         DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for RRC Msg in procUeCtxtSetupReq");
+         DU_LOG("\nERROR  --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
          ret = RFAILED;
       }
       else
@@ -9343,7 +9921,6 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                     memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg)); 
                      memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
                     ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
-                     duUeCb->f1UeDb->duUeCfg.ambrCfg->dlBr = 0;
                  }
               }
               else
@@ -9370,6 +9947,57 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
 
 }
 
+/*******************************************************************
+ * @brief Free the memory allocated for Dl Tunnel Info
+ *
+ * @details
+ *
+ *    Function : freeDlTnlInfo
+ *
+ *    Functionality:
+ *       Free the memory allocated for Dl Tunnel Info
+ *
+ * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
+ * @return void
+ *
+ * ****************************************************************/
+
+void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
+{
+   uint8_t arrIdx = 0;
+
+   for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
+   {
+      DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
+   }
+}
+
+/*******************************************************************
+ * @brief Free the memory allocated for DRB setup List
+ *
+ * @details
+ *
+ *    Function : freeDrbSetupList
+ *
+ *    Functionality:
+ *       Free the memory allocated for DRB setup list
+ *
+ * @params[in] DRBs_Setup_List_t *
+ * @return void
+ *
+ * ****************************************************************/
+void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
+{
+   uint8_t arrIdx = 0;
+   DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
+
+   for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
+   {
+      drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
+      freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
+   }
+}
+
 /*******************************************************************
  * @brief Free the memory allocated for UE Setup response
  *
@@ -9420,6 +10048,11 @@ void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
                           }
                           break;
                        }
+                    case ProtocolIE_ID_id_DRBs_Setup_List:
+                       {
+                           freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List); 
+                           break;
+                       }
                     default:
                        DU_LOG("\nERROR  -->  DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
                        ueSetRsp->protocolIEs.list.array[idx]->id);
@@ -9488,6 +10121,158 @@ uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfi
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Fills Dl Gtp tunnel Info
+ *
+ * @details
+ *
+ *    Function : fillGtpTunnelforDl
+ *
+ *    Functionality: Fills Dl Gtp tunnel Info
+ *
+ * @params[in] 
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
+{
+   uint8_t bufSize = 0;
+
+   gtpDl->transportLayerAddress.size   = 4*sizeof(uint8_t);
+   DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
+   if(gtpDl->transportLayerAddress.buf == NULLP)
+   {
+      return RFAILED;
+   }
+   memcpy(gtpDl->transportLayerAddress.buf, &gtpUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
+
+   /*GTP TEID*/
+   gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
+   DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
+   if(gtpDl->gTP_TEID.buf == NULLP)
+   {
+      return RFAILED;
+   }
+   bufSize = 3; /*forming an Octect String*/
+   fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills DL Tunnel Setup List
+ *
+ * @details
+ *
+ *    Function : fillDlTnlSetupList
+ *
+ *    Functionality: Fills the DL Tunnel Setup List
+ *
+ * @params[in] 
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
+{
+   uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
+
+   eleCount = 1;
+   dlTnlInfo->list.count = eleCount; 
+   dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
+
+   /* Initialize the DL Tnl Setup List Members */
+   DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
+   if(dlTnlInfo->list.array == NULLP)
+   {
+      DU_LOG(" ERROR  -->  F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
+      ret = RFAILED;
+   }
+   for(arrIdx=0; arrIdx < eleCount; arrIdx++)
+   {
+      DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
+      if(dlTnlInfo->list.array[arrIdx] == NULLP)
+      {
+         DU_LOG(" ERROR  -->  F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
+         return RFAILED;
+      }
+      dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
+      DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
+      if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
+      {
+         DU_LOG(" ERROR  -->  F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
+         return RFAILED;
+      }
+      ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
+               tnlCfg->tnlCfg1);
+      if(ret != ROK)
+         break;
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills the Drb Setup List for Ue Context Setup Response
+ *
+ * @details
+ *
+ *    Function : fillDrbSetupList
+ *
+ *    Functionality: Fills the Drb Setup List for Ue Context Setup Response
+ *
+ * @params[in] 
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
+{
+   uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
+   DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
+
+   eleCount = ueCfg->numDrb;
+   drbSetupList->list.count = eleCount;
+   drbSetupList->list.size = \
+       (eleCount * sizeof(DRBs_Setup_Item_t *));
+
+   /* Initialize the Drb Setup List Members */
+   DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
+   if(drbSetupList->list.array == NULLP)
+   {
+      DU_LOG(" ERROR  -->  F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
+      ret = RFAILED;
+   }
+
+   for(arrIdx=0; arrIdx < eleCount; arrIdx++)
+   {
+      DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
+      if(drbSetupList->list.array[arrIdx] == NULLP)
+      {
+         DU_LOG(" ERROR  -->  F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
+         return RFAILED;
+      }
+      drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
+      drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
+      drbItemIe->criticality = Criticality_reject;
+      drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
+      drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
+      ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
+          &ueCfg->upTnlInfo[arrIdx]);
+      if(ret != ROK)
+         break;
+   }
+   return ret;
+}
+
 /*******************************************************************
  *
  * @brief Builds and sends the UE Setup Response
@@ -9546,7 +10331,7 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t ueIdx, uint8_t cellId)
 
       ueSetRsp =
         &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
-      elementCnt = 3;
+      elementCnt = 4;
       ueSetRsp->protocolIEs.list.count = elementCnt;
       ueSetRsp->protocolIEs.list.size = \
                                        elementCnt * sizeof(UEContextSetupResponse_t *);
@@ -9611,18 +10396,42 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t ueIdx, uint8_t cellId)
            cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
            ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
                     choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
-           /* Free UeContext Db created during Ue context Req */
-           freeF1UeDb(ueCb->f1UeDb);
-           ueCb->f1UeDb = NULLP;
+            if(ret == RFAILED)
+           {
+               DU_LOG("\nERROR  -->  F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
+               freeF1UeDb(ueCb->f1UeDb);
+               ueCb->f1UeDb = NULLP;
+               break;
+           }
          }
       }
       else
       {
-         DU_LOG("\nERROR  -->  F1AP: Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
+         DU_LOG("\nERROR  -->  F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
          ret = RFAILED;
+         break;
       }
+
+      /* Drb Setup List */
+      idx++;
+      ueSetRsp->protocolIEs.list.array[idx]->id  = \
+                                ProtocolIE_ID_id_DRBs_Setup_List;
+      ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+      ueSetRsp->protocolIEs.list.array[idx]->value.present =\
+                                UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
+      ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
+               &ueCb->f1UeDb->duUeCfg);
       if(ret == RFAILED)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
+         freeF1UeDb(ueCb->f1UeDb);
+         ueCb->f1UeDb = NULLP;
          break;
+      }
+
+       /* Free UeContext Db created during Ue context Req */
+       freeF1UeDb(ueCb->f1UeDb);
+       ueCb->f1UeDb = NULLP;
 
       xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
 
@@ -9634,14 +10443,14 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t ueIdx, uint8_t cellId)
       /* Encode results */
       if(encRetVal.encoded == ENCODE_FAIL)
       {
-        DU_LOG( "\nERROR  -->  F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
+        DU_LOG( "\nERROR  -->  F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
               encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
         ret = RFAILED;
         break;
       }
       else
       {
-        DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UE Context Setup Request\n");
+        DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UE Context Setup Response\n");
         for(int i=0; i< encBufSize; i++)
         {
            printf("%x",encBuf[i]);
@@ -9651,7 +10460,7 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t ueIdx, uint8_t cellId)
       /* Sending  msg  */
       if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL)        != ROK)
       {
-        DU_LOG("\nERROR  -->  F1AP : Sending UE Context Setup Request Failed");
+        DU_LOG("\nERROR  -->  F1AP : Sending UE Context Setup Response failed");
         ret = RFAILED;
         break;
       }