[Task-ID: ODUHIGH-433]Fixed the mismatch between UE ID (calculated from CRNTI) and... 99/7999/7
authorlal.harshita <Harshita.Lal@radisys.com>
Tue, 29 Mar 2022 09:30:56 +0000 (15:00 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Wed, 30 Mar 2022 11:32:18 +0000 (17:02 +0530)
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
Change-Id: I1dcacaa8cd45504f25e43b49f0b986902d6cae86
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
src/5gnrmac/mac_mux.c
src/5gnrmac/mac_utils.c
src/5gnrmac/mac_utils.h
src/cm/common_def.c
src/cm/du_app_mac_inf.c
src/cm/du_app_mac_inf.h
src/cu_stub/cu_f1ap_msg_hdl.c
src/du_app/du_f1ap_msg_hdl.c
src/du_app/du_ue_mgr.c
src/du_app/du_ue_mgr.h

index dc177da..82a63c5 100644 (file)
@@ -226,18 +226,21 @@ void fillRarPdu(RarInfo *rarInfo)
  * ****************************************************************/
 void createMacRaCb(RachIndInfo *rachIndInfo)
 {
-   uint8_t  ueId = 0, ueIdx = 0;
+   int8_t ueIdx = -1;
    uint16_t crnti = 0;
    uint16_t cellIdx = 0;
 
    GET_CELL_IDX(rachIndInfo->cellId, cellIdx);
    
-   crnti = getNewCrnti(&macCb.macCell[cellIdx]->crntiMap);
-   if(crnti == -1)
+   ueIdx = getFreeBitFromUeBitMap(rachIndInfo->cellId);
+   if(ueIdx == -1)
+   {
+      DU_LOG("\nERROR  -->  MAC : Failed to find free UE Idx in UE bit map of cell Id [%d]", rachIndInfo->cellId);
       return;
+   }
 
-   GET_UE_ID(crnti, ueId);
-   ueIdx = ueId -1;
+   /* Calculate CRNTI from UE Index */
+   GET_CRNTI(crnti, ueIdx+1);
 
    /* store in rach ind structure */
    rachIndInfo->crnti  = crnti;
index c661f02..91f421c 100644 (file)
@@ -64,39 +64,6 @@ uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES] = {
    /* TODO Last Buffer Size is reserved [Now set as 0]*/
 };
 
-/*******************************************************************
- *
- * @brief Allocates a crnti for new UE 
- *
- * @details
- *
- *    Function : getNewCrnti
- *
- *    Functionality: Allocates a crnti for new UE
- *
- * @params[in] CRNTI bit map
- * @return ROK     - success
- *         RFAILED - failure
- *
- * ****************************************************************/
-uint16_t getNewCrnti(uint8_t *crntiMap)
-{
-   uint8_t bitIdx = 0;  /* bit position */
-   uint8_t mask = 1;    /* bit mask */
-   uint16_t newCrnti;   /* new crnti */
-
-   while(bitIdx < 8)
-   {
-      /* Find the first unset bit in crntiMap and allocate
-       * this as new crnti */
-      if((*crntiMap & (mask << bitIdx)) == 0)
-      {
-         newCrnti = ODU_START_CRNTI + bitIdx;
-        SET_ONE_BIT(bitIdx, *crntiMap);
-        return newCrnti;
-      }
-      else
-         bitIdx++;
-   }
-   return -1;
-}
+/**********************************************************************
+  End of file
+ **********************************************************************/
index 3ee51df..f982b6a 100644 (file)
 }
 
 /* Function declaration */
-uint16_t getNewCrnti(uint8_t *crntiMap);
 uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
 uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES];
+
 /**********************************************************************
          End of file
 **********************************************************************/
index cfe9cf7..0faff39 100644 (file)
@@ -416,6 +416,7 @@ uint8_t countSetBits(uint32_t num)
    }
    return(count);
 }
+
 /**********************************************************************
          End of file
 **********************************************************************/
index 7e2caf1..21f2dfa 100644 (file)
@@ -1568,6 +1568,69 @@ uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
    ODU_PUT_MSG_BUF(mBuf);
    return RFAILED;
 }
+
+/*******************************************************************
+ *
+ * @brief Searches for first unset bit in ueBitMap
+ *
+ * @details
+ *
+ *    Function : getFreeBitFromUeBitMap
+ *
+ *    Functionality: Searches for first unset bit in ueBitMap of
+ *       a cell. Search starts from LSB to MSB. Returns index of the
+ *       free bit, considering LSB at index 0 and increasing index
+ *       towards MSB.
+ *
+ * @params[in] Cell Id
+ * @return Index of free bit - success 
+ *         -1 - failure
+ *
+ * ****************************************************************/
+int8_t getFreeBitFromUeBitMap(uint16_t cellId)
+{
+   uint8_t  bitIdx = 0;  /* bit position */
+   uint16_t cellIdx = 0; /* Index to acces ueBitMapPerCell[] */
+   uint64_t mask = 1;    /* bit mask */
+
+   GET_CELL_IDX(cellId, cellIdx);
+   while(bitIdx < 64) 
+   {   
+      /* Find the first unset bit in Bit Map */
+      if((ueBitMapPerCell[cellIdx] & (mask << bitIdx)) == 0)
+      {   
+         SET_ONE_BIT(bitIdx, ueBitMapPerCell[cellIdx]);
+         return bitIdx;
+      }   
+      else
+         bitIdx++;
+   }   
+   return -1; 
+}
+
+/*******************************************************************
+ *
+ * @brief Unset a previously set bit in UeBitMap
+ *
+ * @details
+ *
+ *    Function : unsetBitInUeBitMap
+ *
+ *    Functionality: Searches for bit at given index and unset it.
+ *
+ * @params[in] Cell Id
+ *             Bit Index
+ * @return void 
+ *
+ * ****************************************************************/
+void unsetBitInUeBitMap(uint16_t cellId, uint8_t bitPos)
+{
+    uint16_t cellIdx;
+
+   GET_CELL_IDX(cellId, cellIdx);
+   UNSET_ONE_BIT(bitPos, ueBitMapPerCell[cellIdx]);
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/
index abaaab1..d4671f4 100644 (file)
@@ -1471,6 +1471,7 @@ typedef uint8_t (*MacDuSliceReCfgRspFunc) ARGS((
         Pst           *pst,
         MacSliceCfgRsp   *cfgRsp));
 
+uint64_t ueBitMapPerCell[MAX_NUM_CELL]; /* Bit Map to store used/free UE-IDX per Cell */
 
 uint8_t packMacCellUpInd(Pst *pst, OduCellId *cellId);
 uint8_t unpackMacCellUpInd(DuMacCellUpInd func, Pst *pst, Buffer *mBuf);
@@ -1533,7 +1534,8 @@ uint8_t unpackDuMacSliceReCfgRsp(MacDuSliceReCfgRspFunc func, Pst *pst, Buffer *
 uint8_t duHandleSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo);
 uint8_t packMacSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo);
 uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf);
-
+int8_t getFreeBitFromUeBitMap(uint16_t cellId);
+void unsetBitInUeBitMap(uint16_t cellId, uint8_t bitPos);
 #endif
 
 
index 2bf96de..601e18e 100644 (file)
@@ -11415,6 +11415,71 @@ void procF1SetupReq(uint32_t *destDuId, F1AP_PDU_t *f1apMsg)
    }
 }
 
+/****************************************************************
+*
+* @brief processing of UE Context Release Complete
+*
+* @details
+*
+*    Function : procUeContextReleaseComplete
+*
+*    Functionality:
+*         - processing of UE Context Release Complete
+*
+* @params[in] F1AP_PDU_t *f1apMsg
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+void procUeContextReleaseComplete(uint32_t duId, F1AP_PDU_t *f1apMsg)
+{
+   uint8_t duIdx = 0, ieIdx = 0, ueIdx = 0;
+   uint8_t gnbDuUeF1apId = 0, gnbCuUeF1apId = 0;
+   DuDb *duDb = NULLP;
+   CuUeCb *ueCb = NULLP;
+   UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
+
+   SEARCH_DU_DB(duIdx, duId, duDb);
+   if(!duDb)
+   {
+      DU_LOG("\nERROR  -->  F1AP : No entry found for DU ID [%d]", duId);
+      return;
+   }
+
+   ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
+   for(ieIdx=0; ieIdx < ueReleaseComplete->protocolIEs.list.count; ieIdx++)
+   {
+      switch(ueReleaseComplete->protocolIEs.list.array[ieIdx]->id)
+      {
+         case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+            {
+               gnbCuUeF1apId = ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
+               break;
+            }
+         case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+            {
+               gnbDuUeF1apId = ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
+               ueCb = &duDb->ueCb[gnbDuUeF1apId-1];
+               
+               for(ueIdx = 0; ueIdx < ueCb->cellCb->numUe; ueIdx++)
+               {
+                  if((ueCb->cellCb->ueCb[ueIdx]->gnbCuUeF1apId == gnbCuUeF1apId) &&
+                        (ueCb->cellCb->ueCb[ueIdx]->gnbDuUeF1apId == gnbDuUeF1apId))
+                  {
+                     ueCb->cellCb->ueCb[ueIdx] = NULLP;
+                     ueCb->cellCb->numUe--;
+                     break;
+
+                  }
+               }
+               memset(ueCb, 0, sizeof(CuUeCb));
+               duDb->numUe--;
+               break;
+            }
+      }
+   }
+}
+
 /*******************************************************************
  *
  * @brief Handles received F1AP message and sends back response  
@@ -11565,6 +11630,7 @@ void F1APMsgHdlr(uint32_t *duId, Buffer *mBuf)
                case SuccessfulOutcome__value_PR_UEContextReleaseComplete:
                   {
                       DU_LOG("\nINFO  -->  F1AP : UE Context release complete received");
+                      procUeContextReleaseComplete(*duId, f1apMsg);
                       break;
                   }
                default:
index 41d666c..fcff8e8 100644 (file)
@@ -11917,7 +11917,8 @@ void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t   *ueSetReq)
  * ****************************************************************/
 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
 {
-   uint8_t  ret=0, ieIdx=0, ieExtIdx = 0, ueIdx=0, cellIdx=0, servCellIdx = 0;
+   int8_t ueIdx = -1;
+   uint8_t  ret=0, ieIdx=0, ieExtIdx = 0, cellIdx=0, servCellIdx = 0;
    bool ueCbFound = false, hoInProgress = false;
    uint16_t nrCellId = 0;
    uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
@@ -12002,8 +12003,16 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                /* If UE context is not present, but UE is in handover */
                if(!ueCbFound && hoInProgress)
                {
-                  gnbDuUeF1apId = genGnbDuUeF1apId(nrCellId);
-                  duUeCb = &duCb.actvCellLst[cellIdx]->hoUeCb[gnbDuUeF1apId -1];
+                  ueIdx = getFreeBitFromUeBitMap(nrCellId);
+                  if(ueIdx != -1)
+                     gnbDuUeF1apId = ueIdx +1;
+                  else
+                  {
+                     DU_LOG("\nERROR  -->  F1AP : No free UE IDX found in UE bit map of cell Id [%d]", nrCellId);
+                     ret = RFAILED;
+                     break;
+                  }
+                  duUeCb = &duCb.actvCellLst[cellIdx]->hoUeCb[ueIdx];
                   duUeCb->f1UeDb = NULL;
                   duUeCb->gnbCuUeF1apId = gnbCuUeF1apId;
                   duUeCb->gnbDuUeF1apId = gnbDuUeF1apId;
@@ -13625,16 +13634,20 @@ uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
                            {
                               cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
                               bitStringToInt(cellIdentity, &cellId);
+
+                              GET_CELL_IDX(cellId, cellIdx);
+                              if(duCb.actvCellLst[cellIdx] != NULLP)
+                              {
+                                 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
+                              }
                            }
                         }
                      }
 
-                     GET_CELL_IDX(cellId, cellIdx);
                      if(duCb.actvCellLst[cellIdx] != NULLP)
                      {
                         if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
                         {
-                           duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
                            ret = duSendCellDeletReq(cellId);
                            if(ret == RFAILED)
                            {
@@ -14590,7 +14603,7 @@ void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *u
 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
 {
    UEContextModificationRequest_t *ueContextModifyReq = NULLP;
-   uint8_t  ret = ROK, ieIdx = 0, cellIdx=0, ueIdx=0;
+   uint8_t  ret = ROK, ieIdx = 0, cellIdx=0;
    DuUeCb   *duUeCb = NULLP;
    DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
    DRBs_ToBeModified_List_t *drbModifiedCfg;
@@ -14613,20 +14626,17 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
                {
                   if(duCb.actvCellLst[cellIdx])
                   {
-                     for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
+                     if((duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbDuUeF1apId == gnbDuUeF1apId)&&\
+                           (duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbCuUeF1apId == gnbCuUeF1apId))
                      {
-                        if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
-                              (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
+                        duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1];
+                        if(duUeCb->f1UeDb == NULLP)
                         {
-                           duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
-                           if(duUeCb->f1UeDb == NULLP)
-                           {
-                              DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
-                              duUeCb->f1UeDb->cellIdx = cellIdx;
-                              duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
-                           }
-                           break;
+                           DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
+                           duUeCb->f1UeDb->cellIdx = cellIdx;
+                           duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
                         }
+                        break;
                      }
                   }
                }
@@ -15100,9 +15110,9 @@ uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1
       break;
    }while(true);
    
-   if(ret == ROK && duCb.actvCellLst[cellId-1] && (duCb.actvCellLst[cellId-1]->numActvUes == 0))
+   if((ret == ROK) && (duCb.actvCellLst[cellId-1]) && (duCb.actvCellLst[cellId-1]->cellStatus == DELETION_IN_PROGRESS) 
+         && (duCb.actvCellLst[cellId-1]->numActvUes == 0))
    {
-      duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
       ret = duSendCellDeletReq(cellId);
       if(ret != ROK)
       {
index 96a496f..9c660ef 100644 (file)
@@ -514,36 +514,6 @@ uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
    return ret;
 }
 
-/******************************************************************
- *
- * @brief Generates GNB DU Ue F1AP ID
- *
- * @details
- *
- *    Function : genGnbDuUeF1apId
- *
- *    Functionality: Generates GNB DU Ue F1AP ID
- *
- * @params[in] void
- * @return gnbDuF1apId
- *
- * ****************************************************************/
-int32_t genGnbDuUeF1apId(uint8_t cellId)
-{
-    uint8_t cellIdx =0;
-
-    GET_CELL_IDX(cellId, cellIdx);
-    if(duCb.actvCellLst[cellIdx])
-    {
-       return  ++duCb.gnbDuUeF1apIdGenerator;
-    }
-    else
-    {
-       DU_LOG("ERROR  --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
-    }
-    return -1;
-}
-
 /******************************************************************
  *
  * @brief Processes UL CCCH Ind recvd from MAC
@@ -565,14 +535,16 @@ uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
    uint8_t ret = ROK;
    int32_t gnbDuUeF1apId = 0;
 
-   gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
-   
-   if(gnbDuUeF1apId == -1)
+   if(ulCcchIndInfo->crnti)
+   {
+      GET_UE_ID(ulCcchIndInfo->crnti, gnbDuUeF1apId);
+   }
+   else
    {
-      DU_LOG("ERROR  --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
+      DU_LOG("\nERROR  -->  DU_APP : Received invalid CRNTI [%d] ", ulCcchIndInfo->crnti);
       return RFAILED;
    }
-
+   
    /* Store Ue mapping */
    duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
    duCb.ueCcchCtxt[duCb.numUe].crnti         = ulCcchIndInfo->crnti;
@@ -3012,11 +2984,13 @@ void deleteMacUeCfg(MacUeCfg *ueCfg)
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t  deleteUeCfg(uint16_t cellIdx, uint8_t ueId)
+uint8_t  deleteUeCfg(uint16_t cellId, uint8_t ueId)
 {
    uint8_t tnlIdx = 0;
+   uint16_t cellIdx = 0;
    DuUeCb *ueCb = NULLP;
    
+   GET_CELL_IDX(cellId, cellIdx);
    if(duCb.actvCellLst[cellIdx] != NULLP)
    {
       if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
@@ -3039,6 +3013,7 @@ uint8_t  deleteUeCfg(uint16_t cellIdx, uint8_t ueId)
             else
                tnlIdx++;
          }
+         unsetBitInUeBitMap(cellId, ueId-1);
          duCb.actvCellLst[cellIdx]->numActvUes--;
          memset(ueCb, 0, sizeof(DuUeCb));
       }
@@ -3088,9 +3063,9 @@ uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
          {
             duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
             ueId = deleteRsp->ueId;
-            gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
-            gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
-            if(deleteUeCfg(cellIdx, ueId) == ROK)
+            gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
+            gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
+            if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
             {
                ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
                if(ret != ROK)
index c96391b..f8b303d 100644 (file)
@@ -32,7 +32,6 @@ void deleteRlcUeCfg(RlcUeCfg *ueCfg);
 void freeF1UeDb(F1UeContextSetupDb *f1UeDb);
 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti);
 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId);
-int32_t genGnbDuUeF1apId(uint8_t cellId);
 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t duUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg);
 
 #endif