X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdu_app%2Fdu_cell_mgr.c;h=c689685d34926fa38aad46b9e17ab79ada4692a2;hb=0f3443e19182284b96f302a545e578cd55225dae;hp=324b556b883a4cce760204ae29c49df7fb1170fc;hpb=0d85ce70f63a02a38930c728a58702f9c8505e04;p=o-du%2Fl2.git diff --git a/src/du_app/du_cell_mgr.c b/src/du_app/du_cell_mgr.c index 324b556b8..c689685d3 100644 --- a/src/du_app/du_cell_mgr.c +++ b/src/du_app/du_cell_mgr.c @@ -31,6 +31,13 @@ #include "du_utils.h" #include "du_cell_mgr.h" #include "PCCH-Config.h" +#include "PagingUE-Identity.h" +#include "PagingRecord.h" +#include "PagingRecordList.h" +#include "PagingRrc.h" +#include "PCCH-MessageType.h" +#include "PCCH-Message.h" +#include "odu_common_codec.h" #ifdef O1_ENABLE @@ -166,6 +173,57 @@ uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb) return ROK; } +/****************************************************************************** +* @brief Check Paging Record for a Particular Paging Frame +* +* @details +* +* Function : checkPagingRecord +* +* Functionality: +* Check Paging Record for a Particular Paging Frame +* +* @params[in] DuCellCb *cellCb +* +* @return void +* +* +******************************************************************************/ +uint8_t checkPagingRecord(DuCellCb *cellCb) +{ + uint16_t pf = 0; + DuPagInfoList *pagInfoLLFromPF = NULLP; + DuPagUeList *pagInfo = NULLP; + + /*DUAPP may send PagingReq to MAC for future SFN so that Schedular can + * schedule Paging on the exact occurence of the Slot.*/ + pf = (cellCb->currSlotInfo.sfn + PAGING_SCHED_DELTA) % MAX_SFN; + + pagInfoLLFromPF = findPagingInfoFromMap(pf, &(cellCb->pagingInfoMap)); + if(pagInfoLLFromPF == NULLP) + { + /*No Page is present for pf thus exiting*/ + return ROK; + } + + do + { + pagInfo = handlePageInfoLL(pf, NULLD, &(pagInfoLLFromPF->pagInfoList), TRAVERSE_ALL); + if(pagInfo != NULLP) + { + if(buildAndSendPagingReqToMac(pf, pagInfo->i_s, &(pagInfo->pagUeList)) != ROK) + { + DU_LOG("\nERROR --> DU APP: Issue in Building Page RRC PDU i_s:%d",pagInfo->i_s); + return RFAILED; + } + handlePageInfoLL(pf, pagInfo->i_s, &(pagInfoLLFromPF->pagInfoList), DELETE); + } + }while(pagInfo != NULLP); + + cmHashListDelete(&(cellCb->pagingInfoMap), (PTR)pagInfoLLFromPF); + return ROK; +} + /***************************************************************** * @brief Handles slot indication from MAC * @@ -186,7 +244,7 @@ uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb) uint8_t duHandleSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo) { uint8_t cellIdx = 0, ret = ROK; - DuCellCb *duCellCb; + DuCellCb *duCellCb = NULLP; if(slotIndInfo) { @@ -197,6 +255,7 @@ uint8_t duHandleSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo) { duCellCb->currSlotInfo.sfn = slotIndInfo->sfn; duCellCb->currSlotInfo.slot = slotIndInfo->slot; + checkPagingRecord(duCellCb); } else { @@ -428,245 +487,221 @@ uint8_t duSendCellDeletReq(uint16_t cellId) } /******************************************************************* - * @brief Find the PageInfo List from HashMap - * - * @details - * - * Function : findPagingInfoFromMap - * - * Functionality: Search for the PageInfoList for a PF from HashMap - * - * @params[in] uint16_t pf, CmHashListCp *pagingInfoMap - * - * @return DuPagInfoList - * - * ****************************************************************/ -DuPagInfoList* findPagingInfoFromMap(uint16_t pf, CmHashListCp *pagingInfoMap) -{ - DuPagInfoList *pagInfoLL = NULLP; - - cmHashListFind(pagingInfoMap, (uint8_t *)&(pf), sizeof(uint16_t), 0, (PTR *)&pagInfoLL); - if(pagInfoLL == NULLP) - { - DU_LOG("\nDEBUG --> DU APP: PF:%d doesnt exist in Map",pf); - } - return pagInfoLL; -} - -/******************************************************************* - * @brief Handle the PageInfo List + * @brief Free PCCH PDU structure * * @details * - * Function : handlePageInfoLL + * Function : freePcchPdu * - * Functionality: Handling the (SEARCH,CREATE,DELETE) PageInfoList + * Functionality: Free PCCH PDU structure * - * @params[in] uint8_t i_s, CmLListCp *pagInfoLL, ActionTypeLL action + * @params[in] PCCH_Message_t *pcchMsg * - * @return DuPagUeList + * @return void * * ****************************************************************/ -DuPagUeList* handlePageInfoLL(uint8_t i_s, CmLListCp *pagInfoLL, ActionTypeLL action) +void freePcchPdu(PCCH_Message_t *pcchMsg) { - CmLList *node = NULLP; - DuPagUeList *pagInfo = NULLP; - bool found = FALSE; + PagingRrc_t *pagingMsg = NULLP; + uint8_t recordIdx = 0; - if(pagInfoLL == NULLP) + if(pcchMsg != NULLP) { - DU_LOG("\nERROR --> DU APP: PagInfo LL is empty"); - return NULLP; - } - node = pagInfoLL->first; - - while(node) - { - pagInfo = (DuPagUeList *)node->node; - if(pagInfo->i_s == i_s) + if(pcchMsg->message.choice.c1 != NULLP) { - found = TRUE; - break; - } - node = node->next; - } - - switch(action) - { - case SEARCH: - { - if(!found) - { - pagInfo = NULLP; - } - return pagInfo; - } - - case CREATE: - { - if(node != NULLP) - return pagInfo; - - /*Need to add a new node for this LC*/ - - /*List is empty; Initialize the LL ControlPointer*/ - if(pagInfoLL->count == 0) - { - cmLListInit(pagInfoLL); - } - - pagInfo = NULLP; - /*Allocate the List*/ - DU_ALLOC(pagInfo, sizeof(DuPagUeList)); - if(pagInfo) - { - pagInfo->i_s = i_s; - } - else - { - DU_LOG("\nERROR --> DU APP : Allocation of List failed,i_s:%d",i_s); - return NULLP; - } - - if(duAddNodeToLList(pagInfoLL, pagInfo, NULLP) == RFAILED) - { - DU_LOG("\nERROR --> DU APP : failed to Add Node,i_s:%d",i_s); - DU_FREE(pagInfo, sizeof(DuPagUeList)); - return NULLP; - } - return pagInfo; - } - case DELETE: + pagingMsg = pcchMsg->message.choice.c1->choice.paging; + if(pagingMsg != NULLP) { - if(!found || pagInfo == NULLP) + if(pagingMsg->pagingRecordList) { - DU_LOG("\nERROR --> DU APP: i_s:%d not found; thus Deletion unsuccessful",i_s); + if(pagingMsg->pagingRecordList->list.array == NULLP) + { + for(recordIdx = 0; recordIdx < pagingMsg->pagingRecordList->list.count; recordIdx++) + { + if(pagingMsg->pagingRecordList->list.array[recordIdx] != NULLP) + { + DU_FREE(pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.buf,\ + pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.size); + DU_FREE(pagingMsg->pagingRecordList->list.array[recordIdx], sizeof(PagingRecord_t)); + } + } + DU_FREE(pagingMsg->pagingRecordList->list.array, pagingMsg->pagingRecordList->list.size); + } + DU_FREE(pagingMsg->pagingRecordList, sizeof(PagingRecordList_t)); } - else - { - if(duDelNodeFromLList(pagInfoLL, node) == ROK) - DU_FREE(pagInfo, sizeof(DuPagUeList)); - - DU_LOG("\nDEBUG --> DU APP: i_s:%d Deleted successfully",i_s); - } - return NULLP; - } - default: - { - DU_LOG("\nERROR --> DU APP: Incorrect ActionType:%d on PageInfo List",action); + DU_FREE(pcchMsg->message.choice.c1->choice.paging, sizeof(PagingRrc_t)); } + DU_FREE(pcchMsg->message.choice.c1 , sizeof(PCCH_MessageType_t)); + } + DU_FREE(pcchMsg , sizeof(PCCH_Message_t)); } - return NULLP; } /******************************************************************* - * @brief Handle the PageUe List + * @brief Builds the Paging RRC PDU and forwards it to MAC * * @details * - * Function : handlePageUeLL + * Function : buildAndSendPagingReqToMac * - * Functionality: Handling the (SEARCH,CREATE,DELETE) PageUeList + * Functionality: Builds the Paging RRC PDU[As per Spec 38.331, Annexure A] + * and forwards it to MAC as Buffer along with PF and i_s * - * @params[in] DuPagingMsg *pagingParam, CmLListCp *pageUeLL, ActionTypeLL - * action + * @params[in] uint16_t pf, uint8_t i_s,CmLListCp *pageUeLL * - * @return DuPagUeRecord + * @return ROK - success + * RFAILED - failure * * ****************************************************************/ -DuPagUeRecord* handlePageUeLL(DuPagingMsg *pagingParam, CmLListCp *pageUeLL, ActionTypeLL action) +uint8_t buildAndSendPagingReqToMac(uint16_t pf, uint8_t i_s, CmLListCp *pageUeLL) { - CmLList *node = NULLP; - DuPagUeRecord *ueRecord = NULLP; - bool found = FALSE; + CmLList *node = NULLP, *next = NULLP; + DuPagUeRecord *ueRecord = NULLP; + PCCH_Message_t *pcchMsg = NULLP; + asn_enc_rval_t encRetVal; + PagingRrc_t *pagingMsg = NULLP; + MacPageReq *macPageReq = NULLP; + uint16_t bufIdx = 0; + uint8_t recordIdx = 0, ret = RFAILED; + + /*As per 38.473 Sec 9.3.1.39,5G-S-TMSI :48 Bits >> Bytes and 0 UnusedBits */ + uint8_t totalByteInTmsi = 6, unusedBitsInTmsi = 0; - if(pageUeLL == NULLP) + if(pageUeLL == NULLP || pageUeLL->count == 0) { DU_LOG("\nERROR --> DU APP: UE Page Record LL is empty"); - return NULLP; + return RFAILED; } - node = pageUeLL->first; - while(node) + while(true) { - ueRecord = (DuPagUeRecord *)node->node; - if(ueRecord && (ueRecord->pagUeId == pagingParam->pagUeId && - ueRecord->sTmsi == pagingParam->sTmsi)) + memset(&encRetVal, 0, sizeof(asn_enc_rval_t)); + DU_ALLOC(pcchMsg , sizeof(PCCH_Message_t)); + if(pcchMsg == NULLP) { - found = TRUE; + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(): (pccchMsg) Memory Alloction failed!"); break; } - node = node->next; - } - - switch(action) - { - case SEARCH: - { - if(!found) - { - ueRecord = NULLP; - } - return ueRecord; - } - - case CREATE: - { - if(node != NULLP) - return ueRecord; + pcchMsg->message.present = PCCH_MessageType_PR_c1; + DU_ALLOC(pcchMsg->message.choice.c1 , sizeof(PCCH_MessageType_t)); + if(pcchMsg->message.choice.c1 == NULLP) + { + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (C1) Memory Alloction failed!"); + break; + } + pcchMsg->message.choice.c1->present = PCCH_MessageType__c1_PR_paging; + DU_ALLOC(pcchMsg->message.choice.c1->choice.paging, sizeof(PagingRrc_t)); - /*Need to add a new node for this LC*/ + pagingMsg = pcchMsg->message.choice.c1->choice.paging; + if(pagingMsg == NULLP) + { + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (Paging) Memory Alloction failed!"); + break; + } + DU_ALLOC(pagingMsg->pagingRecordList, sizeof(PagingRecordList_t)); + if(pagingMsg->pagingRecordList == NULLP) + { + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (Paging Record List) Memory Alloction failed!"); + break; + } - /*List is empty; Initialize the LL ControlPointer*/ - if(pageUeLL->count == 0) - { - cmLListInit(pageUeLL); - } + pagingMsg->pagingRecordList->list.count = pageUeLL->count; - ueRecord = NULLP; - /*Allocate the List*/ - DU_ALLOC(ueRecord, sizeof(DuPagUeRecord)); - if(ueRecord) - { - ueRecord->pagUeId = pagingParam->pagUeId; - ueRecord->sTmsi = pagingParam->sTmsi; - ueRecord->pagPriority = pagingParam->pagPriority; - } - else - { - DU_LOG("\nERROR --> DU APP : Allocation of UE Record failed,ueId:%d",pagingParam->pagUeId); - return NULLP; - } + /*As per Spec 38.331, maxNrofPageRec : 32 [Maximum number of page records]*/ + if(pageUeLL->count > MAX_PAGING_UE_RECORDS) + { + pagingMsg->pagingRecordList->list.count = MAX_PAGING_UE_RECORDS; + } - if(duAddNodeToLList(pageUeLL, ueRecord, NULLP) == RFAILED) - { - DU_LOG("\nERROR --> DU APP : failed to Add Ue Record Node,ueId:%d",pagingParam->pagUeId); - DU_FREE(ueRecord, sizeof(DuPagUeRecord)); - return NULLP; - } - return ueRecord; + pagingMsg->pagingRecordList->list.size = pageUeLL->count * (sizeof(PagingRecord_t *)); + DU_ALLOC(pagingMsg->pagingRecordList->list.array, pagingMsg->pagingRecordList->list.size); + if(pagingMsg->pagingRecordList->list.array == NULLP) + { + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (Array) Memory Alloction failed!"); + break; + } + for(recordIdx = 0; recordIdx < pageUeLL->count; recordIdx++) + { + DU_ALLOC(pagingMsg->pagingRecordList->list.array[recordIdx], sizeof(PagingRecord_t)); + if(pagingMsg->pagingRecordList->list.array[recordIdx] == NULLP) + { + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (Record) Memory Alloction failed!"); + break; } - case DELETE: + } + recordIdx = 0; + node = pageUeLL->first; + while(node && (recordIdx < MAX_PAGING_UE_RECORDS)) + { + next = node->next; + ueRecord = (DuPagUeRecord *)node->node; + if(ueRecord) { - if(!found || ueRecord == NULLP) + /*TODO : When Connected Mode Paging will be supported then I_RNTI will be introduced*/ + pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.present = PagingUE_Identity_PR_ng_5G_S_TMSI; + pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.size = totalByteInTmsi*sizeof(uint8_t); + DU_ALLOC(pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.buf,\ + pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.size); + if(pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.buf == NULLP) { - DU_LOG("\nERROR --> DU APP: UeId:%d not found; thus Deletion unsuccessful",pagingParam->pagUeId); + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (5gsTmsi buffer) Memory Allocation failed!"); + break; } - else - { - if(duDelNodeFromLList(pageUeLL, node) == ROK) - DU_FREE(ueRecord, sizeof(DuPagUeRecord)); + fillBitString(&pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI,\ + unusedBitsInTmsi, totalByteInTmsi, ueRecord->sTmsi); + recordIdx++; + } - DU_LOG("\nDEBUG --> DU APP: UeId:%d Deleted successfully",pagingParam->pagUeId); - } - return NULLP; + if(duDelNodeFromLList(pageUeLL, node) == ROK) + DU_FREE(ueRecord, sizeof(DuPagUeRecord)); + node = next; + } + if(node != NULLP && (recordIdx < MAX_PAGING_UE_RECORDS)) + { + /*This leg is hit because Whole UE REcord List was not traversed as + * some issue happened thus exiting the main while*/ + break; + } + xer_fprint(stdout, &asn_DEF_PCCH_Message, pcchMsg); + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + /* Encode the PCCH RRC PDU as APER */ + encRetVal = aper_encode(&asn_DEF_PCCH_Message, 0, pcchMsg, PrepFinalEncBuf,\ + encBuf); + + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> F1AP : Could not encode Paging structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRCPDU for PagingMsg \n"); + + DU_ALLOC_SHRABL_BUF(macPageReq, sizeof(MacPageReq)); + if(macPageReq == NULLP) + { + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (macPageReq) Memory Alloction failed!"); + break; } - default: + + macPageReq->pf = pf; + macPageReq->i_s = i_s; + macPageReq->pduLen = encBufSize; + DU_ALLOC_SHRABL_BUF(macPageReq->pagePdu, macPageReq->pduLen); + if(macPageReq->pagePdu == NULLP) { - DU_LOG("\nERROR --> DU APP: Incorrect ActionType:%d on UeRecord",action); + DU_LOG("\nERROR --> DU APP: buildAndSendPagingToMac(); (PagePDU) Memory Alloction failed!"); + break; } + memcpy(macPageReq->pagePdu, encBuf, macPageReq->pduLen); + } + ret = ROK; + break; } - return NULLP; + freePcchPdu(pcchMsg); + return ret; } /******************************************************************* @@ -692,7 +727,9 @@ uint8_t insertPagingRecord(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPagingParam, u DuPagUeList *pageUeLL = NULLP; DuPagUeRecord *ueRecord = NULLP; - //printPageList(&(cellCb->pagingInfoMap)); +#if 0 + printPageList(&(cellCb->pagingInfoMap)); +#endif /*MAX Iteration : A UE can be paged at every T frames thus MAX determines *how many Paging Frame(s) can be considered for Paging this UE*/ @@ -708,15 +745,17 @@ uint8_t insertPagingRecord(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPagingParam, u if(pagInfoLLFromPF != NULLP) { /*[Step2]: Extracting the PageInfo List for the Paging Indices(i_s)*/ - pageUeLL = handlePageInfoLL(rcvdF1apPagingParam->i_s, &(pagInfoLLFromPF->pagInfoList), CREATE); + pageUeLL = handlePageInfoLL(rcvdF1apPagingParam->pagingFrame, rcvdF1apPagingParam->i_s, \ + &(pagInfoLLFromPF->pagInfoList), CREATE); if(pageUeLL != NULLP) { - /*[Step3]: Check whether MAX UE Record against this PF and i_s has reached*/ + /*[Step3]: Check whether MAX UE Record against this PF and i_s has reached(Spec 38.331, Annexure A)*/ if(pageUeLL->pagUeList.count < MAX_PAGING_UE_RECORDS) { /*[Step4]: Insert the Paging Record to the end of the UE record List*/ - ueRecord = handlePageUeLL(rcvdF1apPagingParam, &(pageUeLL->pagUeList), CREATE); + ueRecord = handlePageUeLL(rcvdF1apPagingParam->pagUeId, rcvdF1apPagingParam->sTmsi,\ + &(pageUeLL->pagUeList), CREATE); if(ueRecord == NULLP) { @@ -749,14 +788,17 @@ uint8_t insertPagingRecord(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPagingParam, u return RFAILED; } pagInfoLLFromPF->pf = rcvdF1apPagingParam->pagingFrame; - pageUeLL = handlePageInfoLL(rcvdF1apPagingParam->i_s, &(pagInfoLLFromPF->pagInfoList), CREATE); - ueRecord = handlePageUeLL(rcvdF1apPagingParam, &(pageUeLL->pagUeList), CREATE); + pageUeLL = handlePageInfoLL(rcvdF1apPagingParam->pagingFrame, rcvdF1apPagingParam->i_s, &(pagInfoLLFromPF->pagInfoList), CREATE); + ueRecord = handlePageUeLL(rcvdF1apPagingParam->pagUeId, rcvdF1apPagingParam->sTmsi, &(pageUeLL->pagUeList), CREATE); if(cmHashListInsert(&(cellCb->pagingInfoMap), (PTR)pagInfoLLFromPF, (uint8_t *)&(pagInfoLLFromPF->pf), sizeof(uint16_t)) == RFAILED) { DU_LOG("\nERROR --> DU APP: Hash Map Insertion Failed for PF:%d.",rcvdF1apPagingParam->pagingFrame); } - //printPageList(&(cellCb->pagingInfoMap)); +#if 0 + printPageList(&(cellCb->pagingInfoMap)); +#endif + return ROK; @@ -786,7 +828,6 @@ uint8_t calcAndFillPagingInfoInCellCb(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPag uint16_t currentSfn = 0, sfn = 0, newSfn = 0; PcchCfg duPcchCfg; - DU_LOG("\nINFO --> DU APP : Start filling paging parameters in DuCellCb"); if(cellCb) { /* calculate paging frame and paging offset */ @@ -898,7 +939,7 @@ uint8_t calcAndFillPagingInfoInCellCb(DuCellCb* cellCb, DuPagingMsg *rcvdF1apPag rcvdF1apPagingParam->pagingFrame = (sfn % MAX_SFN); rcvdF1apPagingParam->i_s = ((uint32_t)(floor(rcvdF1apPagingParam->pagUeId / N)) % ns); - DU_LOG("\nINFO --> DU APP : Successfully filled paging parameter in DuCellCb"); + DU_LOG("\nINFO --> DU APP : Successfully filled paging parameter in DuCellCb"); memcpy(&cellCb->tmpPagingInfoOfUe, rcvdF1apPagingParam, sizeof(DuPagingMsg)); } else