[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-425] Fixes in the CU stub for memory-related... 89/7889/4
authorbarveankit <anbarve@radisys.com>
Sat, 5 Mar 2022 09:09:20 +0000 (14:39 +0530)
committerbarveankit <anbarve@radisys.com>
Tue, 8 Mar 2022 07:49:42 +0000 (13:19 +0530)
Signed-off-by: barveankit <anbarve@radisys.com>
Change-Id: I288279ba80b1d3f0023cfc4145b1fe2b4b707e8f
Signed-off-by: barveankit <anbarve@radisys.com>
src/cu_stub/cu_f1ap_msg_hdl.c
src/cu_stub/cu_stub.c
src/cu_stub/cu_stub.h

index b913055..e5bbb6e 100644 (file)
@@ -1873,7 +1873,7 @@ uint8_t setDlRRCMsgType(CuUeCb *ueCb)
 
 uint8_t procInitULRRCMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
 {
-   uint8_t idx, rrcMsgType, gnbDuUeF1apId;
+   uint8_t idx,cellIdx=0, duIdx=0, rrcMsgType, gnbDuUeF1apId;
    uint8_t ret =ROK;
    uint32_t nrCellId, crnti;
    DuDb     *duDb;
@@ -1882,8 +1882,8 @@ uint8_t procInitULRRCMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
    InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
 
    DU_LOG("\nINFO   -->  F1AP : filling the required values in DB in procInitULRRCMsg");
-
-   duDb = getDuDb(duId);
+   
+   SEARCH_DU_DB(duIdx, duId, duDb); 
    initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
 
    for(idx=0; idx < initULRRCMsg->protocolIEs.list.count; idx++)
@@ -1897,7 +1897,7 @@ uint8_t procInitULRRCMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
          case ProtocolIE_ID_id_NRCGI:
             nrCellId = initULRRCMsg->protocolIEs.list.array[idx]->value.choice.NRCGI.nRCellIdentity.buf[4] >>
                initULRRCMsg->protocolIEs.list.array[idx]->value.choice.NRCGI.nRCellIdentity.bits_unused;
-            cellCb = getCellCb(duDb, nrCellId);
+            SEARCH_CELL_DB(cellIdx, duDb, nrCellId, cellCb);
             if(cellCb == NULLP)
                return RFAILED;
             break;
@@ -1912,7 +1912,7 @@ uint8_t procInitULRRCMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
                ueCb->crnti = crnti;
                ueCb->gnbDuUeF1apId = gnbDuUeF1apId;
                ueCb->gnbCuUeF1apId = ++cuCb.gnbCuUeF1apIdGenerator;
-               ueCb->state = ATTACH_IN_PROGRESS;
+               ueCb->state = UE_ATTACH_IN_PROGRESS;
                (duDb->numUe)++;
 
                cellCb->ueCb[cellCb->numUe] = ueCb;
@@ -7044,12 +7044,12 @@ uint8_t procDrbSetupList(DRBs_Setup_List_t *drbSetupList)
  * ****************************************************************/
 uint8_t procUeContextSetupResponse(uint32_t duId, F1AP_PDU_t *f1apMsg)
 {
-   uint8_t idx, duUeF1apId;
+   uint8_t duIdx=0, idx, duUeF1apId;
    DuDb *duDb;
    CuUeCb *ueCb;
    UEContextSetupResponse_t *ueCtxtSetupRsp = NULLP;
 
-   duDb = getDuDb(duId);
+   SEARCH_DU_DB(duIdx, duId, duDb);
    ueCtxtSetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
    
    for(idx=0; idx < ueCtxtSetupRsp->protocolIEs.list.count; idx++)
@@ -7093,7 +7093,7 @@ uint8_t procUeContextSetupResponse(uint32_t duId, F1AP_PDU_t *f1apMsg)
 
 uint8_t procUlRrcMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
 {
-   uint8_t idx, ret, srbId, rrcMsgType;
+   uint8_t idx, ret, srbId, rrcMsgType, duIdx=0;
    uint8_t cuUeF1apId, duUeF1apId;
    uint8_t *rrcContainer = NULLP;
    uint16_t rrcContLen;
@@ -7102,7 +7102,7 @@ uint8_t procUlRrcMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
    ULRRCMessageTransfer_t *ulRrcMsg = NULLP;
 
    ret = ROK;
-   duDb = getDuDb(duId);
+   SEARCH_DU_DB(duIdx, duId, duDb);
    ulRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
 
    for(idx=0; idx < ulRrcMsg->protocolIEs.list.count; idx++)
@@ -7170,7 +7170,7 @@ uint8_t procUlRrcMsg(uint32_t duId, F1AP_PDU_t *f1apMsg)
       }
       if(rrcMsgType == RRC_RECONFIG_COMPLETE)
       {
-         ueCb->state = ACTIVE;
+         ueCb->state = UE_ACTIVE;
          ueCb->f1apMsgDb.dlRrcMsgCount++;
          rrcMsgType = setDlRRCMsgType(ueCb);
          if(rrcMsgType == UE_CONTEXT_MOD_REQ)
@@ -8643,8 +8643,8 @@ uint8_t procUeContextReleaseReq(uint32_t duId, F1AP_PDU_t *f1apMsg)
 uint8_t procGnbDuUpdate(uint32_t duId, F1AP_PDU_t *f1apMsg)
 {
    bool cellToBeDelete = false;
-   uint8_t ieIdx = 0, ueIdx = 0;
-   uint16_t cellId;
+   uint8_t ieIdx = 0, ueIdx = 0, duIdx = 0, cellIdx=0;
+   uint16_t nrCellId;
    DuDb *duDb;
    CuCellCb *cellCb;
    GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
@@ -8663,7 +8663,7 @@ uint8_t procGnbDuUpdate(uint32_t duId, F1AP_PDU_t *f1apMsg)
                struct Served_Cells_To_Delete_ItemIEs *deleteItemIe = \
                   (struct Served_Cells_To_Delete_ItemIEs *)duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
                   Served_Cells_To_Delete_List.list.array[0];
-               cellId = deleteItemIe->value.choice.Served_Cells_To_Delete_Item.oldNRCGI.nRCellIdentity.buf[4] >>\
+               nrCellId = deleteItemIe->value.choice.Served_Cells_To_Delete_Item.oldNRCGI.nRCellIdentity.buf[4] >>\
                   deleteItemIe->value.choice.Served_Cells_To_Delete_Item.oldNRCGI.nRCellIdentity.bits_unused;
                cellToBeDelete = true;
                break;
@@ -8693,8 +8693,8 @@ uint8_t procGnbDuUpdate(uint32_t duId, F1AP_PDU_t *f1apMsg)
 #endif
    if(cellToBeDelete == true) 
    {
-      duDb = getDuDb(duId);
-      cellCb = getCellCb(duDb, cellId);
+      SEARCH_DU_DB(duIdx, duId, duDb);
+      SEARCH_CELL_DB(cellIdx, duDb, nrCellId, cellCb);
       for(ueIdx = 0; ueIdx < cellCb->numUe; ueIdx++)
       {
          CU_FREE(cellCb->ueCb[ueIdx]->f1apMsgDb.duToCuContainer.buf, cellCb->ueCb[ueIdx]->f1apMsgDb.duToCuContainer.size);
@@ -8879,12 +8879,12 @@ uint8_t procServedCellPlmnList(ServedPLMNs_List_t *srvPlmn)
  * ****************************************************************/
 uint8_t procUeContextModificationResponse(uint32_t duId, F1AP_PDU_t *f1apMsg)
 {
-   uint8_t idx, duUeF1apId;
+   uint8_t idx=0, duIdx=0, duUeF1apId;
    DuDb *duDb;
    CuUeCb *ueCb;
-       UEContextModificationResponse_t *ueCtxtModRsp = NULLP;
+   UEContextModificationResponse_t *ueCtxtModRsp = NULLP;
 
-   duDb = getDuDb(duId);
+   SEARCH_DU_DB(duIdx, duId, duDb);
    ueCtxtModRsp = &f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
    
    for(idx=0; idx < ueCtxtModRsp->protocolIEs.list.count; idx++)
@@ -8895,7 +8895,7 @@ uint8_t procUeContextModificationResponse(uint32_t duId, F1AP_PDU_t *f1apMsg)
              {
                 duUeF1apId = ueCtxtModRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
                 ueCb = &duDb->ueCb[duUeF1apId-1];
-                if(ueCb->state == HANDOVER_IN_PROGRESS)
+                if(ueCb->state == UE_HANDOVER_IN_PROGRESS)
                 {
                    /* TODO : Next procedure i.e. UE context setup request to
                     * target DU should be triggerred here */
@@ -8935,7 +8935,7 @@ uint8_t procUeContextModificationResponse(uint32_t duId, F1AP_PDU_t *f1apMsg)
 void procF1SetupReq(uint32_t *destDuId, F1AP_PDU_t *f1apMsg)
 {
    uint8_t ieIdx = 0, plmnidx=0, duIdx = 0, ret=ROK, cellIdx = 0;
-   uint32_t duId, cellId;
+   uint32_t duId = 0, nrCellId = 0;
    DuDb     *duDb = NULLP;
    CuCellCb *cellCb = NULLP;
    BIT_STRING_t nrcellIdentity;
@@ -8951,7 +8951,7 @@ void procF1SetupReq(uint32_t *destDuId, F1AP_PDU_t *f1apMsg)
          case ProtocolIE_ID_id_gNB_DU_ID:
            {
               duId = f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0];
-              duDb = getDuDb(duId);
+              SEARCH_DU_DB(duIdx, duId, duDb); 
               if(duDb == NULLP)
               {
                  duDb = &cuCb.duInfo[cuCb.numDu];
@@ -8986,13 +8986,13 @@ void procF1SetupReq(uint32_t *destDuId, F1AP_PDU_t *f1apMsg)
                               ret = procServedCellPlmnList(&srvCellItem->served_Cell_Information.servedPLMNs);
                               memcpy(&nrcellIdentity, &srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity, sizeof(BIT_STRING_t));
 
-                              cellId = nrcellIdentity.buf[4] >> nrcellIdentity.bits_unused;
-                              cellCb = getCellCb(duDb, cellId);
+                              nrCellId = nrcellIdentity.buf[4] >> nrcellIdentity.bits_unused;
+                              SEARCH_CELL_DB(cellIdx, duDb, nrCellId, cellCb);
                               if(cellCb == NULLP)
                               {
                                  cellCb = &duDb->cellCb[duDb->numCells];
                                  memset(cellCb, 0, sizeof(CuCellCb));
-                                 cellCb->nrCellId = cellId;
+                                 cellCb->nrCellId = nrCellId;
                                  duDb->numCells++;
                               }
                            }
index 1694a14..7a62215 100644 (file)
 extern StartupConfig g_cfg;
 #endif
 
-/*******************************************************************
- *
- * @brief Fetches pointer to DU Database
- *
- * @details
- *
- *    Function : getDuDb
- *
- *    Functionality:
- *      Searches and returns pointer to DU structure based on DU Id
- *
- * @params[in] DU Id
- * @return Pointer to DU Db
- *
- ******************************************************************/
-DuDb* getDuDb(uint32_t duId)
-{
-   uint8_t duIdx;
-   for(duIdx=0; duIdx < cuCb.numDu; duIdx++)
-   {
-      if(cuCb.duInfo[duIdx].duId == duId)
-         return (&cuCb.duInfo[duIdx]);
-   }
-   return NULLP;
-}
-
-/*******************************************************************
- *
- * @brief Fetches pointer to Cell Cb
- *
- * @details
- *
- *    Function : getCellCb
- *
- *    Functionality:
- *       Searches for a cell within a DU based on NR cell Id
- *       Returns pointer to this cell Cb structure
- *
- * @params[in] Pointer to DU Db
- *             NR Cell ID
- * @return Pointer to cell Cb
- *
- ******************************************************************/
-CuCellCb* getCellCb(DuDb *duDb, uint32_t cellId)
-{
-   uint8_t cellIdx;
-   for(cellIdx=0; cellIdx < duDb->numCells; cellIdx++)
-   {
-      if(duDb->cellCb[cellIdx].nrCellId == cellId)
-         return &(duDb->cellCb[cellIdx]);
-   }
-   return NULLP;
-}
-
 /*******************************************************************
  *
  * @brief Handles SCTP notification 
@@ -283,14 +229,15 @@ void readCuCfg()
  * ****************************************************************/
 void initiateInterDuHandover(uint32_t sourceDuId, uint32_t targetDuId, uint32_t ueId)
 {
+    uint8_t duIdx = 0;
     DuDb *duDb = NULLP;
     CuUeCb *ueCb = NULLP;
-
-    duDb = getDuDb(sourceDuId);
+   
+    SEARCH_DU_DB(duIdx, sourceDuId, duDb); 
     if(duDb)
        ueCb = &duDb->ueCb[ueId-1];
     if(ueCb)
-       ueCb->state = HANDOVER_IN_PROGRESS;
+       ueCb->state = UE_HANDOVER_IN_PROGRESS;
 
     DU_LOG("\nINFO  --> CU_STUB: Inter-DU Handover Started for ueId [%d] from DU ID [%d] to DU ID [%d]", \
           ueId, sourceDuId, targetDuId);
index 69f0954..d2c3f88 100644 (file)
    SPutSBuf(CU_APP_MEM_REG, CU_POOL,                         \
          (Data *)_datPtr, _size);
 
+#define SEARCH_DU_DB(_duIdx, _duId, _duDb){\
+   _duDb = NULLP; \
+   for(_duIdx=0; _duIdx < cuCb.numDu; _duIdx++)\
+   {\
+      if(cuCb.duInfo[_duIdx].duId == _duId)\
+      {\
+         _duDb =  (&cuCb.duInfo[_duIdx]);\
+              break; \
+     }\
+   }\
+}
+
+#define SEARCH_CELL_DB(_cellIdx, _duDb, _nrCellId, _cellCb){\
+   _cellCb = NULLP; \
+   for(_cellIdx=0; _cellIdx < _duDb->numCells; _cellIdx++)\
+   {\
+      if(_duDb->cellCb[_cellIdx].nrCellId == _nrCellId)\
+      {\
+         _cellCb = (&(_duDb->cellCb[_cellIdx]));\
+         break;\
+      }\
+   }\
+}
+
+
 typedef enum
 {
-   IDLE,
-   ATTACH_IN_PROGRESS,
-   ACTIVE,
-   HANDOVER_IN_PROGRESS
+   UE_IDLE,
+   UE_ATTACH_IN_PROGRESS,
+   UE_ACTIVE,
+   UE_HANDOVER_IN_PROGRESS
 }UeState;
 
 typedef struct RrcVersion