* ****************************************************************/
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;
/* 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
+ **********************************************************************/
}
/* 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
**********************************************************************/
}
return(count);
}
+
/**********************************************************************
End of file
**********************************************************************/
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
**********************************************************************/
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);
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
}
}
+/****************************************************************
+*
+* @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
case SuccessfulOutcome__value_PR_UEContextReleaseComplete:
{
DU_LOG("\nINFO --> F1AP : UE Context release complete received");
+ procUeContextReleaseComplete(*duId, f1apMsg);
break;
}
default:
* ****************************************************************/
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;
/* 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;
{
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)
{
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;
{
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;
}
}
}
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)
{
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
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;
* 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)\
else
tnlIdx++;
}
+ unsetBitInUeBitMap(cellId, ueId-1);
duCb.actvCellLst[cellIdx]->numActvUes--;
memset(ueCb, 0, sizeof(DuUeCb));
}
{
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)
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