From 0f3443e19182284b96f302a545e578cd55225dae Mon Sep 17 00:00:00 2001 From: barveankit Date: Fri, 22 Apr 2022 16:07:31 +0530 Subject: [PATCH] [Epic-ID: ODUHIGH-406] [Task-ID: ODUHIGH-439] Building Paging RRC PDU Signed-off-by: barveankit Change-Id: I7661048ebabb181e8da11a448d0158926589d579 Signed-off-by: lal.harshita Signed-off-by: barveankit --- src/5gnrrlc/rlc_upr_inf_mgr.c | 10 + src/5gnrsch/sch_utils.c | 5 + src/cm/common_def.h | 4 +- src/cm/du_app_mac_inf.h | 11 +- src/cu_stub/cu_stub.h | 4 +- src/du_app/du_cell_mgr.c | 437 +++++++++++++++++++++++------------------- src/du_app/du_cell_mgr.h | 1 + src/du_app/du_cfg.h | 6 +- src/du_app/du_egtp.c | 2 + src/du_app/du_mgr.h | 7 +- src/du_app/du_sctp.c | 2 + src/du_app/du_sys_info_hdl.c | 2 + src/du_app/du_ue_mgr.c | 2 +- src/du_app/du_utils.c | 290 +++++++++++++++++++++++----- src/du_app/du_utils.h | 5 +- src/ric_stub/ric_stub.h | 4 +- 16 files changed, 526 insertions(+), 266 deletions(-) diff --git a/src/5gnrrlc/rlc_upr_inf_mgr.c b/src/5gnrrlc/rlc_upr_inf_mgr.c index 9c99b63a3..ab5c9b9d7 100755 --- a/src/5gnrrlc/rlc_upr_inf_mgr.c +++ b/src/5gnrrlc/rlc_upr_inf_mgr.c @@ -975,6 +975,16 @@ RlcTptPerSnssai* rlcHandleSnssaiTputlist(RlcCb *gCb, Snssai *snssai, ActionTypeL } return NULLP; } + case PRINT: + case TRAVERSE_ALL: + { + break; + } + default: + { + DU_LOG("\nERROR -> RLC: Incorrect ActionType:%d",action); + break; + } } return (snssaiNode); } diff --git a/src/5gnrsch/sch_utils.c b/src/5gnrsch/sch_utils.c index 3c3ff18b9..0b65fb454 100644 --- a/src/5gnrsch/sch_utils.c +++ b/src/5gnrsch/sch_utils.c @@ -1429,6 +1429,11 @@ LcInfo* handleLcLList(CmLListCp *lcLL, uint8_t lcId, ActionTypeLL action) } return NULLP; } + case PRINT: + case TRAVERSE_ALL: + { + break; + } default: { DU_LOG("\nERROR --> SCH: Action type wrong: %d",action); diff --git a/src/cm/common_def.h b/src/cm/common_def.h index ab72caac6..2f2f196d2 100644 --- a/src/cm/common_def.h +++ b/src/cm/common_def.h @@ -288,7 +288,9 @@ typedef enum { SEARCH, CREATE, - DELETE + DELETE, + PRINT, + TRAVERSE_ALL }ActionTypeLL; typedef struct slotTimingInfo diff --git a/src/cm/du_app_mac_inf.h b/src/cm/du_app_mac_inf.h index 16763d9b2..869278cfb 100644 --- a/src/cm/du_app_mac_inf.h +++ b/src/cm/du_app_mac_inf.h @@ -1348,7 +1348,16 @@ typedef struct macSliceCfgRsp MacSliceRsp **listOfSliceCfgRsp; }MacSliceCfgRsp; -/* Functions for slot Ind from MAC to DU APP*/ +typedef struct macPageReq +{ + uint16_t cellId; + uint16_t pf; + uint8_t i_s; + uint16_t pduLen; + uint8_t *pagePdu; +}MacPageReq; + +/* Functions for CellUp Ind from MAC to DU APP*/ typedef uint8_t (*DuMacCellUpInd) ARGS(( Pst *pst, OduCellId *cellId )); diff --git a/src/cu_stub/cu_stub.h b/src/cu_stub/cu_stub.h index ed0adced7..8b20b4dbd 100644 --- a/src/cu_stub/cu_stub.h +++ b/src/cu_stub/cu_stub.h @@ -26,10 +26,10 @@ #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011" #ifndef O1_ENABLE -#define DU_IP_V4_ADDR (char*[]){"192.168.130.81", "192.168.130.83"} +#define DU_IP_V4_ADDR (char*[]){"192.168.130.85", "192.168.130.83"} #define DU_SCTP_PORT (int[]){38472, 38473} -#define CU_IP_V4_ADDR "192.168.130.82" +#define CU_IP_V4_ADDR "192.168.130.86" #define CU_SCTP_PORT_TO_DU (int[]){38472, 38473} #endif 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 diff --git a/src/du_app/du_cell_mgr.h b/src/du_app/du_cell_mgr.h index f3ff66276..6a0736ebd 100644 --- a/src/du_app/du_cell_mgr.h +++ b/src/du_app/du_cell_mgr.h @@ -27,6 +27,7 @@ uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb); uint8_t BuildAndSendSliceConfigReq(RrmPolicy *rrmPolicy[], uint8_t totalRrrmPolicy, uint8_t totalSliceCfgReq); uint8_t BuildAndSendSliceReCfgReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceReCfg); uint8_t processPagingMsg(uint16_t cellId, DuPagingMsg *rcvdF1apPagingParam); +uint8_t buildAndSendPagingReqToMac(uint16_t pf, uint8_t i_s, CmLListCp *pageUeLL); #endif /********************************************************************** End of file diff --git a/src/du_app/du_cfg.h b/src/du_app/du_cfg.h index 2a488d137..59616dbbe 100644 --- a/src/du_app/du_cfg.h +++ b/src/du_app/du_cfg.h @@ -29,9 +29,9 @@ #ifndef O1_ENABLE -#define DU_IP_V4_ADDR "192.168.130.81" -#define CU_IP_V4_ADDR "192.168.130.82" -#define RIC_IP_V4_ADDR "192.168.130.80" +#define DU_IP_V4_ADDR "192.168.130.85" +#define CU_IP_V4_ADDR "192.168.130.86" +#define RIC_IP_V4_ADDR "192.168.130.87" #define DU_PORT 38472 #define CU_PORT 38472 #define RIC_PORT 36421 diff --git a/src/du_app/du_egtp.c b/src/du_app/du_egtp.c index 2a486c639..f5fe77638 100644 --- a/src/du_app/du_egtp.c +++ b/src/du_app/du_egtp.c @@ -27,6 +27,8 @@ #include "du_app_mac_inf.h" #include "du_cfg.h" #include "du_egtp.h" +#include "du_app_rlc_inf.h" +#include "du_mgr.h" #include "du_utils.h" diff --git a/src/du_app/du_mgr.h b/src/du_app/du_mgr.h index a46a3709f..d5a2dda42 100644 --- a/src/du_app/du_mgr.h +++ b/src/du_app/du_mgr.h @@ -57,6 +57,7 @@ #define DU_SET_ZERO(_buf, _size) \ memset((_buf), 0, _size); +/*Refer Spec 38.331 Annexure A: maxNrofPageRec : 32 [Maximum number of page records]*/ #define MAX_PAGING_UE_RECORDS 32 typedef enum @@ -200,9 +201,8 @@ typedef struct pagingMsg typedef struct duPagUeRecord { - uint16_t pagUeId; /*UEID calculated from 5gsTMSI as per Spec 38.304*/ - uint64_t sTmsi; /*UE Paging Identity: 5GS-TMSI*/ - uint8_t pagPriority; /* Paging priority */ + uint16_t pagUeId; /*UEID calculated from 5gsTMSI as per Spec 38.304*/ + uint64_t sTmsi; /* UE Paging Identity: S-TMSI */ }DuPagUeRecord; typedef struct duPagInfo @@ -334,6 +334,7 @@ uint8_t duSendEgtpDatInd(Buffer *mBuf); uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm); uint8_t duBuildAndSendMacCellStart(); uint8_t duBuildAndSendMacCellStop(uint16_t cellId); + #endif /********************************************************************** diff --git a/src/du_app/du_sctp.c b/src/du_app/du_sctp.c index 0f86d6485..e9fdcb8b1 100644 --- a/src/du_app/du_sctp.c +++ b/src/du_app/du_sctp.c @@ -28,6 +28,8 @@ #include "du_cfg.h" #include "du_sctp.h" #include "lsctp.h" +#include "du_app_rlc_inf.h" +#include "du_mgr.h" #include "du_utils.h" /************************************************************************** diff --git a/src/du_app/du_sys_info_hdl.c b/src/du_app/du_sys_info_hdl.c index 9aeced60c..a4c883e66 100644 --- a/src/du_app/du_sys_info_hdl.c +++ b/src/du_app/du_sys_info_hdl.c @@ -24,6 +24,8 @@ #include "legtp.h" #include "du_app_mac_inf.h" #include "du_cfg.h" +#include "du_app_rlc_inf.h" +#include "du_mgr.h" #include "du_utils.h" #include "BCCH-BCH-Message.h" #include "MIB.h" diff --git a/src/du_app/du_ue_mgr.c b/src/du_app/du_ue_mgr.c index 7bfd110b8..3f859cdbd 100644 --- a/src/du_app/du_ue_mgr.c +++ b/src/du_app/du_ue_mgr.c @@ -29,8 +29,8 @@ #include "du_app_mac_inf.h" #include "du_app_rlc_inf.h" #include "du_cfg.h" -#include "du_utils.h" #include "du_mgr.h" +#include "du_utils.h" #include "du_f1ap_msg_hdl.h" #include "du_ue_mgr.h" diff --git a/src/du_app/du_utils.c b/src/du_app/du_utils.c index 342f31c41..608efb79a 100644 --- a/src/du_app/du_utils.c +++ b/src/du_app/du_utils.c @@ -21,10 +21,10 @@ #include "lrg.x" #include "lkw.x" #include "du_app_mac_inf.h" -#include "du_utils.h" #include "du_app_rlc_inf.h" #include "du_cfg.h" #include "du_mgr.h" +#include "du_utils.h" /* Spec Ref-38.214-Table 5.1.2.1-1 */ uint8_t slivCfgIdxTable[MAX_SLIV_CONFIG_IDX][3] = { @@ -245,90 +245,273 @@ uint8_t duDelNodeFromLList(CmLListCp *llist, CmLList *node) return ROK; } -/*Below function for printing will be used in future so disabling it for now*/ -#if 0 -/**************************************************************************** - * - * @brief Print the LC in list for debugging purpose +/******************************************************************* + * @brief Handle the PageUe List * * @details * - * Function : printLcLL + * Function : handlePageUeLL + * + * Functionality: Handling the (SEARCH,CREATE,DELETE) PageUeList + * + * @params[in] DuPagingMsg *pagingParam, CmLListCp *pageUeLL, ActionTypeLL + * action * - * Functionality: - * For debugging purpose, for printing the LC in the order and - * parameters + * @return DuPagUeRecord * - * @params[in] LcList pointer - * - * @return void - * - *************************************************************************/ -void printPageInfoLL(CmLListCp *pageInfoLL) + * ****************************************************************/ +DuPagUeRecord* handlePageUeLL(uint16_t pagUeId, uint64_t sTmsi, CmLListCp *pageUeLL, ActionTypeLL action) { - CmLList *node = NULLP; - DuPagUeList *pageInfoNode = NULLP; + CmLList *node = NULLP; + DuPagUeRecord *ueRecord = NULLP; + bool found = FALSE; - if(pageInfoLL == NULLP) + if((pageUeLL == NULLP) || + ((pageUeLL->first == NULLP) && (action != CREATE))) { - DU_LOG("\nINFO --> DU APP: PageInfo List doesnt exist"); - return; + DU_LOG("\nERROR --> DU APP: UE Page Record LL is empty"); + return NULLP; } - node = pageInfoLL->first; + node = pageUeLL->first; + while(node) { - pageInfoNode = (DuPagUeList *)node->node; - if(pageInfoNode) + ueRecord = (DuPagUeRecord *)node->node; + if(action == PRINT) { - DU_LOG("\nINFO --> DU APP i_s:%d",pageInfoNode->i_s); - printPageUeRecordLL(&(pageInfoNode->pagUeList)); + DU_LOG("\n INFO --> DU APP ueId:%d, sTmsi:%lu",\ + ueRecord->pagUeId, ueRecord->sTmsi); + } + else if(ueRecord && (ueRecord->pagUeId == pagUeId && + ueRecord->sTmsi == sTmsi)) + { + found = TRUE; + break; } - node = node->next; } + + switch(action) + { + case SEARCH: + { + if(!found) + { + ueRecord = NULLP; + } + return ueRecord; + } + + case CREATE: + { + if(node != NULLP) + return ueRecord; + + /*Need to add a new node for this LC*/ + + /*List is empty; Initialize the LL ControlPointer*/ + if(pageUeLL->count == 0) + { + cmLListInit(pageUeLL); + } + + ueRecord = NULLP; + /*Allocate the List*/ + DU_ALLOC(ueRecord, sizeof(DuPagUeRecord)); + if(ueRecord) + { + ueRecord->pagUeId = pagUeId; + ueRecord->sTmsi = sTmsi; + } + else + { + DU_LOG("\nERROR --> DU APP : Allocation of UE Record failed,ueId:%d",pagUeId); + return NULLP; + } + + if(duAddNodeToLList(pageUeLL, ueRecord, NULLP) == RFAILED) + { + DU_LOG("\nERROR --> DU APP : failed to Add Ue Record Node,ueId:%d",pagUeId); + DU_FREE(ueRecord, sizeof(DuPagUeRecord)); + return NULLP; + } + return ueRecord; + } + case DELETE: + { + if(!found || ueRecord == NULLP) + { + DU_LOG("\nERROR --> DU APP: UeId:%d not found; thus Deletion unsuccessful",pagUeId); + } + else + { + if(duDelNodeFromLList(pageUeLL, node) == ROK) + DU_FREE(ueRecord, sizeof(DuPagUeRecord)); + + DU_LOG("\nDEBUG --> DU APP: UeId:%d Deleted successfully",pagUeId); + } + return NULLP; + } + case PRINT: + case TRAVERSE_ALL: + { + break; + } + default: + { + DU_LOG("\nERROR --> DU APP: Incorrect ActionType:%d on UeRecord",action); + } + } + return NULLP; } -/**************************************************************************** - * - * @brief Print the Ue Record against Paging Frame for debugging purpose +/******************************************************************* + * @brief Handle the PageInfo List * * @details * - * Function : printLcLL + * Function : handlePageInfoLL * - * Functionality: - * For debugging purpose, for printing the UE Record in the order and - * parameters + * Functionality: Handling the (SEARCH,CREATE,DELETE) PageInfoList * - * @params[in] ueList pointer - * - * @return void - * - *************************************************************************/ -void printPageUeRecordLL(CmLListCp *ueList) + * @params[in] uint8_t i_s, CmLListCp *pagInfoLL, ActionTypeLL action + * + * @return DuPagUeList + * + * ****************************************************************/ +DuPagUeList* handlePageInfoLL(uint16_t pf, uint8_t i_s, CmLListCp *pagInfoLL, ActionTypeLL action) { - CmLList *node = NULLP; - DuPagUeRecord *ueRecord = NULLP; - - if(ueList == NULLP) + CmLList *node = NULLP, *next = NULLP; + DuPagUeList *pagInfo = NULLP; + bool found = FALSE; + + if((pagInfoLL == NULLP) || + ((pagInfoLL->first == NULLP) && (action != CREATE))) { - DU_LOG("\nINFO --> DU APP: PageUe List doesnt exist"); - return; + DU_LOG("\nERROR --> DU APP: PagInfo LL is empty"); + return NULLP; } - node = ueList->first; + node = pagInfoLL->first; + while(node) { - ueRecord = (DuPagUeRecord *)node->node; - if(ueRecord) + next = node->next; + pagInfo = (DuPagUeList *)node->node; + if(action == PRINT) + { + DU_LOG("\n INFO --> DU APP: Paging Index (i_s):%d",pagInfo->i_s); + handlePageUeLL(NULLD, NULLD, &(pagInfo->pagUeList), PRINT); + } + else if(action == TRAVERSE_ALL) { - DU_LOG("\nINFO --> DU APP ueId:%d, sTmsi:%lu, prio:%d",ueRecord->pagUeId, ueRecord->sTmsi, ueRecord->pagPriority); + return pagInfo; } + else if(pagInfo->i_s == i_s) + { + found = TRUE; + break; + } + node = next; + } - 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: + { + if(!found || pagInfo == NULLP) + { + DU_LOG("\nERROR --> DU APP: i_s:%d not found; thus Deletion unsuccessful",i_s); + } + 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; + } + case PRINT: + case TRAVERSE_ALL: + { + break; + } + default: + { + DU_LOG("\nERROR --> DU APP: Incorrect ActionType:%d on PageInfo List",action); + } } + return NULLP; +} + +/******************************************************************* + * @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); + + return pagInfoLL; } +/*Below function for printing will be used in future so disabling it for now*/ +#if 0 /******************************************************************* * @brief Print the Page Info List and UE Records * @@ -353,14 +536,15 @@ void printPageList(CmHashListCp *pagingInfoMap) ret = cmHashListGetNext(pagingInfoMap, (PTR)prevPageInfoLL, (PTR *)&pagInfoLLFromPF); if(ret == ROK) { - DU_LOG("\nDEBUG --> DUAPP Page List for PF:%d",pagInfoLLFromPF->pf); - printPageInfoLL(&(pagInfoLLFromPF->pagInfoList)); + DU_LOG("\nDEBUG --> DUAPP: Page List for PF:%d",pagInfoLLFromPF->pf); + handlePageInfoLL(NULLD, NULLD, &(pagInfoLLFromPF->pagInfoList), PRINT); prevPageInfoLL = pagInfoLLFromPF; } }while(ret == ROK); } #endif + /********************************************************************** End of file **********************************************************************/ diff --git a/src/du_app/du_utils.h b/src/du_app/du_utils.h index d8fe65620..5d46f099b 100644 --- a/src/du_app/du_utils.h +++ b/src/du_app/du_utils.h @@ -148,9 +148,10 @@ void fillStartSymbolAndLen(uint8_t numRsrcAlloc, PdschConfig *pdschCfg, PuschCfg uint8_t duAddNodeToLList(CmLListCp *llist, void *blockToAdd, CmLList *currNode); uint8_t duDelNodeFromLList(CmLListCp *llist, CmLList *node); +DuPagUeRecord* handlePageUeLL(uint16_t pagUeId, uint64_t sTmsi, CmLListCp *pageUeLL, ActionTypeLL action); +DuPagUeList* handlePageInfoLL(uint16_t pf, uint8_t i_s, CmLListCp *pagInfoLL, ActionTypeLL action); +DuPagInfoList* findPagingInfoFromMap(uint16_t pf, CmHashListCp *pagingInfoMap); #if 0 -void printPageInfoLL(CmLListCp *pageInfoLL); -void printPageUeRecordLL(CmLListCp *pageUeLL); void printPageList(CmHashListCp *pagingInfoMap); #endif diff --git a/src/ric_stub/ric_stub.h b/src/ric_stub/ric_stub.h index b41e9c6da..ffb752639 100644 --- a/src/ric_stub/ric_stub.h +++ b/src/ric_stub/ric_stub.h @@ -26,10 +26,10 @@ #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011" #ifndef O1_ENABLE -#define DU_IP_V4_ADDR (char*[]){"192.168.130.81", "192.168.130.83"} +#define DU_IP_V4_ADDR (char*[]){"192.168.130.85", "192.168.130.83"} #define DU_SCTP_PORT (int[]){36421, 36422} -#define RIC_IP_V4_ADDR "192.168.130.80" +#define RIC_IP_V4_ADDR "192.168.130.87" #define RIC_SCTP_PORT_TO_DU (int[]){36421, 36422} #endif -- 2.16.6