From: Balaji Shankaran Date: Sun, 26 Apr 2020 15:37:26 +0000 (+0530) Subject: Rach Indication X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=b490cd1231cfcc837e8bfccc40c6bb106dceef7c;p=o-du%2Fl2.git Rach Indication Change-Id: I431afa5c707c17db1b2a82fba22624246e906730 Signed-off-by: Balaji Shankaran --- diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 47a681e4b..9e286b646 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -1331,7 +1331,7 @@ S16 lwr_mac_handleParamReqEvt(void *msg) if(paramReq != NULLP) { fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen); - DU_LOG("\nLOWER MAC: sending param Req to Phy"); + DU_LOG("\nLOWER MAC: Sending Param Request to Phy"); LwrMacSendToPhy(paramReq->header.message_type_id, sizeof(fapi_param_req_t), (void *)paramReq); MAC_FREE(paramReq, sizeof(fapi_param_req_t)); return ROK; @@ -2792,6 +2792,7 @@ S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo) } msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t); fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen); + DU_LOG("\nLOWER MAC: Sending UL TTI Request"); LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq); MAC_FREE(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t))); } @@ -2800,6 +2801,7 @@ S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo) { msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t); fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen); + DU_LOG("\nLOWER MAC: Sending UL TTI Request"); LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq); } MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t)); diff --git a/src/5gnrmac/lwr_mac_handle_phy.c b/src/5gnrmac/lwr_mac_handle_phy.c index b46739b4c..59301a8b9 100644 --- a/src/5gnrmac/lwr_mac_handle_phy.c +++ b/src/5gnrmac/lwr_mac_handle_phy.c @@ -45,51 +45,71 @@ #include "du_log.h" #include "lwr_mac_fsm.h" #include "lwr_mac_phy.h" +#include "lwr_mac_upr_inf.h" #ifdef FAPI - -/* function pointers for packing macCellCfg Request */ -typedef S16 (*packSlotIndMsg) ARGS(( - Pst *pst, - SlotIndInfo *slotInd -)); - -S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd); -S16 packTcSlotInd (Pst *pst, SlotIndInfo *slotInd); -S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd); - +/* Function pointer for slot indication from lower mac to mac */ packSlotIndMsg packSlotIndOpts[] = { - packLcSlotInd, /* packing for loosely coupled */ + packLcSlotInd, /* packing for loosely coupled */ fapiMacSlotInd, /* packing for tightly coupled */ - packLwlcSlotInd, /* packing for light weight loosly coupled */ + packLwlcSlotInd /* packing for light weight loosly coupled */ }; -S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd) -{ - Buffer *mBuf = NULLP; - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) - { - RETVALUE(RFAILED); - } - - /* pack SFN and slot value */ - CMCHKPK(SPkU16,slotInd->sfn, mBuf); - CMCHKPK(SPkU16,slotInd->slot, mBuf); - - RETVALUE(SPstTsk(pst,mBuf)); -} - -S16 packTcSlotInd (Pst *pst, SlotIndInfo *slotInd) +/* Function pointer for rach indication from lower mac to mac */ +packRachIndMsg sendRachIndOpts[] = { - return ROK; -} + packRachInd, + fapiMacRachInd, + packRachInd +}; -S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd) +/******************************************************************* + * + * @brief Fills post structure + * + * @details + * + * Function : fillLwrMacToMacPst + * + * Functionality: + * Fills post structure used to send message from lower MAC + * to MAC + * + * @params[in] Pst pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void fillLwrMacToMacPst(Pst *pst) { - return ROK; + pst->srcProcId = 0; + pst->dstProcId = 0; + pst->srcEnt = ENTTF; + pst->dstEnt = ENTRG; + pst->srcInst = 0; + pst->dstInst = 0; + pst->region = 0; + pst->pool = 0; + pst->selector = MAC_SELECTOR_TC; } +/******************************************************************* + * + * @brief Processes Slot Indication from PHY and sends to MAC + * + * @details + * + * Function : handleSlotInd + * + * Functionality: + * Processes Slot Indication from PHY and sends to MAC + * + * @params[in] fapi_slot_ind_t pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ U16 handleSlotInd(fapi_slot_ind_t *fapiSlotInd) { /* fill Pst structure to send to lwr_mac to MAC */ @@ -97,16 +117,8 @@ U16 handleSlotInd(fapi_slot_ind_t *fapiSlotInd) uint16_t ret; SlotIndInfo slotInd; - pst.srcProcId = 0; - pst.dstProcId = 0; - pst.srcEnt = ENTTF; - pst.dstEnt = ENTRG; - pst.srcInst = 0; - pst.dstInst = 0; + fillLwrMacToMacPst(&pst); pst.event = EVENT_SLOT_IND_TO_MAC; - pst.region = 0; - pst.pool = 0; - pst.selector = MAC_SELECTOR_TC; slotInd.sfn = fapiSlotInd->sfn; slotInd.slot = fapiSlotInd->slot; @@ -124,7 +136,60 @@ U16 handleSlotInd(fapi_slot_ind_t *fapiSlotInd) return ret; } -#endif + + +/******************************************************************* + * + * @brief Processes Rach Indication from PHY and sends to MAC + * + * @details + * + * Function : handleRachInd + * + * Functionality: + * Processes Rach Indication from PHY and sends to MAC + * + * @params[in] fapi_rach_indication_t pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t handleRachInd(fapi_rach_indication_t *fapiRachInd) +{ + Pst pst; + uint8_t pduIdx; + uint8_t prmbleIdx; + RachPduInfo *rachPdu; + RachInd rachInd; + + rachInd.timingInfo.sfn = fapiRachInd->sfn; + rachInd.timingInfo.slot = fapiRachInd->slot; + rachInd.numPdu = fapiRachInd->numPdus; + for(pduIdx=0; pduIdx < rachInd.numPdu; pduIdx++) + { + rachPdu = &rachInd.rachPdu[pduIdx]; + rachPdu->pci = fapiRachInd->rachPdu[pduIdx].physCellId; + rachPdu->symbolIdx = fapiRachInd->rachPdu[pduIdx].symbolIndex; + rachPdu->slotIdx = fapiRachInd->rachPdu[pduIdx].slotIndex; + rachPdu->freqIdx = fapiRachInd->rachPdu[pduIdx].freqIndex; + rachPdu->numPream = fapiRachInd->rachPdu[pduIdx].numPreamble; + for(prmbleIdx=0; prmbleIdxnumPream; prmbleIdx++) + { + rachPdu->preamInfo[prmbleIdx].preamIdx = \ + fapiRachInd->rachPdu[pduIdx].preambleInfo[prmbleIdx].preambleIndex; + rachPdu->preamInfo[prmbleIdx].timingAdv = \ + fapiRachInd->rachPdu[pduIdx].preambleInfo[prmbleIdx].timingAdvance; + } + } + fillLwrMacToMacPst(&pst); + pst.event = EVENT_RACH_IND_TO_MAC; + + (*sendRachIndOpts[pst.selector])(&pst, &rachInd); + return ROK; + +}/* handleRachInd */ + +#endif /* FAPI */ void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg) { @@ -145,7 +210,7 @@ void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg) { if(clGlobalCp.phyState == PHY_STATE_CONFIGURED) { - DU_LOG("\nLOWER MAC: PHY has moved to running state \n"); + DU_LOG("\nLOWER MAC: PHY has moved to running state"); clGlobalCp.phyState = PHY_STATE_RUNNING; } @@ -176,6 +241,9 @@ void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg) } case FAPI_RACH_INDICATION: { + fapi_rach_indication_t *rachInd; + rachInd = (fapi_rach_indication_t *)msg; + handleRachInd(rachInd); break; } } diff --git a/src/5gnrmac/lwr_mac_phy.c b/src/5gnrmac/lwr_mac_phy.c index 7a1052e8f..17bc911b8 100644 --- a/src/5gnrmac/lwr_mac_phy.c +++ b/src/5gnrmac/lwr_mac_phy.c @@ -34,7 +34,7 @@ #endif EXTERN S16 rgClHndlCfgReq ARGS((void *msg)); -EXTERN void processFapiRequest ARGS((uint8_t msgType, uint32_t msgLen, void *msg)); +EXTERN void l1ProcessFapiRequest ARGS((uint8_t msgType, uint32_t msgLen, void *msg)); #ifdef INTEL_WLS @@ -263,7 +263,7 @@ PUBLIC uint16_t LwrMacSendToPhy(uint8_t msgType, uint32_t msgLen, void *msg) addWlsBlockToFree(msg, msgLen, (slotIndIdx-1)); } #else - processFapiRequest(msgType, msgLen, msg); + l1ProcessFapiRequest(msgType, msgLen, msg); #endif return ROK; } /* LwrMacSendToPhy */ diff --git a/src/5gnrmac/lwr_mac_upr_inf.c b/src/5gnrmac/lwr_mac_upr_inf.c new file mode 100644 index 000000000..46b7a4281 --- /dev/null +++ b/src/5gnrmac/lwr_mac_upr_inf.c @@ -0,0 +1,106 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +#include "lwr_mac_upr_inf.h" + +/******************************************************************* + * + * @brief Packs and Sends RACH Ind to MAC + * + * @details + * + * Function : packRachInd + * + * Functionality: + * Packs and Sends RACH Ind to MAC + * + * @params[in] Post structure pointer + * RACH indication + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t packRachInd(Pst *pst, RachInd *rachInd) +{ + if((pst->selector == MAC_SELECTOR_LC) || (pst->selector == MAC_SELECTOR_LWLC)) + { + return ROK; + } + else + { + return RFAILED; + } +} + +/******************************************************************* + * + * @brief Loose coupled packing of slot indication + * + * @details + * + * Function : packLcSlotInd + * + * Functionality: + * Loose coupled packing of slot indication + * + * @params[in] Post structure + * Slot indication info + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd) +{ + Buffer *mBuf = NULLP; + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + + /* pack SFN and slot value */ + CMCHKPK(SPkU16,slotInd->sfn, mBuf); + CMCHKPK(SPkU16,slotInd->slot, mBuf); + + RETVALUE(SPstTsk(pst,mBuf)); +} + +/******************************************************************* + * + * @brief Light weight loose coupled packing of slot indication + * + * @details + * + * Function : packLwlcSlotInd + * + * Functionality: + * Light weight loose coupled packing of slot indication + * + * @params[in] Post structure + * Slot indication info + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd) +{ + return ROK; +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/lwr_mac_upr_inf.h b/src/5gnrmac/lwr_mac_upr_inf.h new file mode 100644 index 000000000..98327a8cd --- /dev/null +++ b/src/5gnrmac/lwr_mac_upr_inf.h @@ -0,0 +1,60 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* header include files -- defines (.h) */ + +#ifndef __LWR_MAC_UPR_INF_H__ +#define __LWR_MAC_UPR_INF_H__ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ +#include "cm5.h" /* common timers defines */ +#include "cm_hash.h" /* common hash list defines */ +#include "cm_llist.h" /* common linked list defines */ +#include "cm_mblk.h" /* memory management */ +#include "cm_tkns.h" /* common tokens */ +#include "cm_lte.h" /* common tokens */ +#include "tfu.h" + +/* header/extern include files (.x) */ +#include "gen.x" /* general layer typedefs */ +#include "ssi.x" /* system services typedefs */ +#include "cm5.x" /* common timers */ +#include "cm_hash.x" /* common hash list */ +#include "cm_lib.x" /* common library */ +#include "cm_llist.x" /* common linked list */ +#include "cm_mblk.x" /* memory management */ +#include "cm_tkns.x" /* common tokens */ +#include "cm_lte.x" /* common tokens */ +#include "tfu.x" + +typedef S16 (*packSlotIndMsg)(Pst *pst, SlotIndInfo *slotInd); +S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd); +S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd); + +typedef uint16_t (*packRachIndMsg)(Pst *pst, RachInd *rachInd); +uint16_t packRachInd(Pst *pst, RachInd *rachInd); +uint16_t fapiMacRachInd(Pst *pst, RachInd *rachInd); + +#endif +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index 68e02a5d9..e0eebe09c 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -65,6 +65,7 @@ typedef struct macUlSlot typedef struct macCellCb { uint16_t cellId; + RachIndInfo raCb; MacDlSlot dlSlot[MAX_SLOT_SUPPORTED]; MacUlSlot ulSlot[MAX_SLOT_SUPPORTED]; }MacCellCb; @@ -77,6 +78,7 @@ typedef struct macCb /* global variable */ EXTERN MacCb macCb; +void fillMacToSchPst(Pst *pst); #endif /********************************************************************** diff --git a/src/5gnrmac/mac_rach.c b/src/5gnrmac/mac_rach.c index 37893503e..f2d0a71e8 100644 --- a/src/5gnrmac/mac_rach.c +++ b/src/5gnrmac/mac_rach.c @@ -41,8 +41,90 @@ #include "lrg.x" #include "du_app_mac_inf.h" #include "mac.h" +#include "du_log.h" +/* Function pointer for sending rach ind from MAC to SCH */ +MacSchRachIndFunc macSchRachIndOpts[]= +{ + packMacSchRachInd, + macSchRachInd, + packMacSchRachInd +}; + + +/******************************************************************* + * + * @brief Sends RACH indication to SCH + * + * @details + * + * Function : sendRachIndMacToSch + * + * Functionality: + * Sends RACH indication to SCH + * + * @params[in] RACH indication info + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +int sendRachIndMacToSch(RachIndInfo *rachInd) +{ + Pst pst; + + fillMacToSchPst(&pst); + pst.event = EVENT_RACH_IND_TO_SCH; + + return(*macSchRachIndOpts[pst.selector])(&pst, rachInd); +} + +/******************************************************************* + * + * @brief Processes RACH indication from PHY + * + * @details + * + * Function : fapiMacRachInd + * + * Functionality: + * Processes RACH indication from PHY + * + * @params[in] Post structure + * Rach indication message + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t fapiMacRachInd(Pst *pst, RachInd *rachInd) +{ + uint8_t pduIdx; + uint8_t preambleIdx; + RachIndInfo *rachIndInfo; + + DU_LOG("\nMAC : Received RACH indication"); + /* Considering one pdu and one preamble */ + pduIdx = 0; + preambleIdx = 0; + + rachIndInfo = &macCb.macCell->raCb; + + rachIndInfo->cellId = rachInd->rachPdu[pduIdx].pci; + /* TODO : Allocate unique crnti for each ue */ + rachIndInfo->crnti = 100; + rachIndInfo->timingInfo.sfn = rachInd->timingInfo.sfn; + rachIndInfo->timingInfo.slot = rachInd->timingInfo.slot; + rachIndInfo->slotIdx = rachInd->rachPdu[pduIdx].slotIdx; + rachIndInfo->symbolIdx = rachInd->rachPdu[pduIdx].symbolIdx; + rachIndInfo->frequencyIdx = rachInd->rachPdu[pduIdx].freqIdx; + rachIndInfo->preambleIdx = \ + rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].preamIdx; + rachIndInfo->timingAdv = \ + rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].timingAdv; + + return(sendRachIndMacToSch(rachIndInfo)); +} + /* spec-38.211 Table 6.3.3.1-7 */ uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX] = {0, 2, 4, 6, 8, 10, 12, 13, 15, 17, 19, 23, 27, 34, 46, 69}; diff --git a/src/5gnrmac/rg_lim.c b/src/5gnrmac/rg_lim.c index 1897c44a2..424180b41 100755 --- a/src/5gnrmac/rg_lim.c +++ b/src/5gnrmac/rg_lim.c @@ -601,9 +601,55 @@ TfuDelDatReqInfo *delDatReq; } /* rgLIMTfuDatReq*/ #endif /*L2_OPTMZ */ +/******************************************************************* + * + * @brief Fills post structure + * + * @details + * + * Function : fillMacToSchPst + * + * Functionality: + * Fills post structure to be used when sending msg from + * MAC to SCH + * + * @params[in] Post structure pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void fillMacToSchPst(Pst *pst) +{ + pst->srcProcId = 0; + pst->dstProcId = 0; + pst->srcEnt = ENTRG; + pst->dstEnt = ENTRG; + pst->srcInst = 0; + pst->dstInst = 1; + pst->region = 0; + pst->pool = 0; + pst->selector = MAC_SELECTOR_TC; +} + +/******************************************************************* + * + * @brief MAC handler for config response from PHY + * + * @details + * + * Function : fapiMacConfigRsp + * + * Functionality: + * Processes config response from PHY and sends cell config + * confirm to DU APP + * + * @params[in] + * @return void + * + * ****************************************************************/ void fapiMacConfigRsp() { - /* TODO : Processing of conig response from PHY */ + /* TODO : Processing of config response from PHY */ /* Send cell config cfm to DU APP */ MacSendCellCfgCfm(RSP_OK); @@ -627,16 +673,9 @@ int sendSlotIndMacToSch(SlotIndInfo *slotInd) { /* fill Pst structure to send to lwr_mac to MAC */ Pst pst; - pst.srcProcId = 0; - pst.dstProcId = 0; - pst.srcEnt = ENTRG; - pst.dstEnt = ENTRG; - pst.srcInst = 0; - pst.dstInst = 1; + + fillMacToSchPst(&pst); pst.event = EVENT_SLOT_IND_TO_SCH; - pst.region = 0; - pst.pool = 0; - pst.selector = MAC_SELECTOR_TC; return(*macSchSlotIndOpts[pst.selector])(&pst,slotInd); } diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 4d4389562..a37720130 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -306,6 +306,28 @@ SlotIndInfo *slotInd RETVALUE(ROK); } /* macSchSlotInd */ +/******************************************************************* + * + * @brief Processes Rach indication from MAC + * + * @details + * + * Function : macSchRachInd + * + * Functionality: + * Processes Rach indication from MAC + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +int macSchRachInd(Pst *pst, RachIndInfo *rachInd) +{ + DU_LOG("\nSCH : Received Rach indication"); + return ROK; +} + /** * @brief inti cellCb based on cellCfg * diff --git a/src/cm/mac_sch_interface.c b/src/cm/mac_sch_interface.c index c8d12a641..1f6bfb417 100644 --- a/src/cm/mac_sch_interface.c +++ b/src/cm/mac_sch_interface.c @@ -57,6 +57,18 @@ int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd) RETVALUE(SPstTsk(pst,mBuf)); } +int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd) +{ + if((pst->selector == MAC_SELECTOR_LC) || (pst->selector == MAC_SELECTOR_LWLC)) + { + /* TODO */ + } + else + { + return RFAILED; + } + return ROK; +} /** * @brief function to pack DL Broadcast allocation message * from MAC to SCH diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index d9ebed9e7..5f957dcdb 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -311,6 +311,18 @@ typedef struct ulSchInfo PrachSchInfo prachSchInfo; /* Prach scheduling info */ }UlSchInfo; +typedef struct rachIndInfo +{ + uint16_t cellId; + uint16_t crnti; + SlotIndInfo timingInfo; + uint8_t slotIdx; + uint8_t symbolIdx; + uint8_t frequencyIdx; + uint8_t preambleIdx; + uint16_t timingAdv; +}RachIndInfo; + /* function pointers */ typedef int (*SchCellCfgCfmFunc) ARGS(( @@ -347,6 +359,9 @@ EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg); EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason); EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm); EXTERN int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo); +typedef int (*MacSchRachIndFunc)(Pst *pst, RachIndInfo *rachInd); +int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd); +int macSchRachInd(Pst *pst, RachIndInfo *rachInd); /********************************************************************** End of file diff --git a/src/cm/tfu.h b/src/cm/tfu.h index fe573b93b..01f741062 100755 --- a/src/cm/tfu.h +++ b/src/cm/tfu.h @@ -123,8 +123,13 @@ #define EVTTFUNONRTIND 24 /*!< Non-RT indication.*/ #endif #define EVTTFUERRIND 25 /*!< TFU Error Indication */ +#define EVENT_RACH_IND_TO_MAC 26 +#define EVENT_RACH_IND_TO_SCH 27 /** @} */ +#define MAX_PREAM_PER_SLOT 1 /* Max number of preamble per slot */ +#define MAC_RACH_PDU_PER_SLOT 1 /* Max number of rach pdu per slot */ + /* selector(coupling) values */ #define TFU_SEL_TC 1 /*!< Selector for Tight coupling. */ #define TFU_SEL_LC 0 /*!< Selector for Loose coupling. */ diff --git a/src/cm/tfu.x b/src/cm/tfu.x index b2726cdd4..edf2d9c93 100755 --- a/src/cm/tfu.x +++ b/src/cm/tfu.x @@ -2509,6 +2509,29 @@ typedef struct slotIndInfo U16 slot; }SlotIndInfo; +typedef struct rachPreamInfo +{ + uint8_t preamIdx; + uint16_t timingAdv; +}RachPreamInfo; + +typedef struct rachPduInfo +{ + uint16_t pci; + uint8_t symbolIdx; + uint8_t slotIdx; + uint8_t freqIdx; + uint8_t numPream; + RachPreamInfo preamInfo[MAX_PREAM_PER_SLOT]; +}RachPduInfo; + +typedef struct rachInd +{ + SlotIndInfo timingInfo; + uint8_t numPdu; + RachPduInfo rachPdu[MAC_RACH_PDU_PER_SLOT]; +}RachInd; + typedef S16 (*TfuBndReq) ARGS(( Pst* pst, SuId suId, diff --git a/src/phy_stub/l1_bdy1.c b/src/phy_stub/l1_bdy1.c index 79dc9c068..2f3d27a5d 100644 --- a/src/phy_stub/l1_bdy1.c +++ b/src/phy_stub/l1_bdy1.c @@ -33,14 +33,18 @@ #include "fapi.h" #endif #include "lphy_stub.h" +#include "stdbool.h" #include "du_log.h" #include "rg.h" #define MAX_SLOT_VALUE 9 #define MAX_SFN_VALUE 1023 +#define NR_PCI 1 uint16_t sfnValue = 0; uint16_t slotValue = 0; +bool rachIndSent = false; + EXTERN void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg)); #ifdef FAPI EXTERN void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t @@ -249,13 +253,74 @@ PUBLIC void l1HdlConfigReq(uint32_t msgLen, void *msg) } } + +/******************************************************************* + * + * @brief Builds and Sends RACH indication to MAC + * + * @details + * + * Function : l1BuildAndSendRachInd + * + * Functionality: + * Builds and Sends RACH indication to MAC + * + * @params[in] SFN value + * slot value + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn) +{ +#ifdef FAPI + uint8_t rachPduIdx = 0; + uint8_t preamIdx = 0; + fapi_rach_pdu_t *rachPdu; + fapi_rach_indication_t *rachInd; + + /* Building RACH indication */ + if(SGetSBuf(0, 0, (Data **)&rachInd, sizeof(fapi_rach_indication_t)) != ROK) + { + printf("\nPHY_STUB: Memory allocation failed for Rach Indication Message"); + return RFAILED; + } + + rachInd->sfn = sfn; + rachInd->slot = slot; + rachInd->numPdus = 1; + + rachPdu = &rachInd->rachPdu[rachPduIdx]; + rachPdu->physCellId = NR_PCI; + rachPdu->symbolIndex = 0; + rachPdu->slotIndex = slot; + rachPdu->freqIndex = 0; + rachPdu->avgRssi = 0; + rachPdu->avgSnr = 0; + rachPdu->numPreamble = 1; + + rachPdu->preambleInfo[preamIdx].preambleIndex = 3; + rachPdu->preambleInfo[preamIdx].timingAdvance = 0; + rachPdu->preambleInfo[preamIdx].premblePwr = 0; + + fillMsgHeader(&rachInd->header, FAPI_RACH_INDICATION, \ + sizeof(fapi_rach_indication_t)); + + /* Sending RACH indication to MAC */ + DU_LOG("\nPHY STUB: Sending RACH Indication to MAC"); + handlePhyMessages(rachInd->header.message_type_id, sizeof(fapi_rach_indication_t), (void *)rachInd); + SPutSBuf(0, 0, (Data *)rachInd, sizeof(fapi_rach_indication_t)); +#endif + return ROK; +} + /******************************************************************* * * @brief Builds and Send the Slot Indication message to MAC * * @details * - * Function : buildAndSendSlotIndication + * Function : l1BuildAndSendSlotIndication * * Functionality: * -Send the Slot indication Message to MAC @@ -266,7 +331,7 @@ PUBLIC void l1HdlConfigReq(uint32_t msgLen, void *msg) * @return void * * ****************************************************************/ -PUBLIC S16 buildAndSendSlotIndication() +PUBLIC uint16_t l1BuildAndSendSlotIndication() { #ifdef FAPI fapi_slot_ind_t *slotIndMsg; @@ -291,7 +356,7 @@ PUBLIC S16 buildAndSendSlotIndication() slotIndMsg->sfn = sfnValue; slotIndMsg->slot = slotValue; fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, sizeof(fapi_slot_ind_t)); - DU_LOG("\nPHY_STUB [%d:%d] ",sfnValue,slotValue); + DU_LOG("\nPHY_STUB: [%d:%d] ",sfnValue,slotValue); handlePhyMessages(slotIndMsg->header.message_type_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg); SPutSBuf(0, 0, (Data *)slotIndMsg, sizeof(slotIndMsg)); } @@ -329,7 +394,7 @@ PUBLIC S16 l1HdlStartReq(uint32_t msgLen, void *msg) } else { - DU_LOG("\n PHY_STUB: Received Start Req in PHY State %d", clGlobalCp.phyState); + DU_LOG("\nPHY_STUB: Received Start Req in PHY State %d", clGlobalCp.phyState); return RFAILED; } } @@ -357,8 +422,9 @@ PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg) #ifdef FAPI fapi_dl_tti_req_t *dlTtiReq; dlTtiReq = (fapi_dl_tti_req_t *)msg; + + printf("\nPHY STUB: Received DL TTI Request"); #if 0 - printf("\nPHY_STUB: Received DL TTI Request in PHY"); printf("\nPHY_STUB: SFN %d", dlTtiReq->sfn); printf("\nPHY_STUB: SLOT %d", dlTtiReq->slot); printf("\nPHY_STUB: nPdus %d", dlTtiReq->nPdus); @@ -375,16 +441,16 @@ PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg) uint8_t numPdus = dlTtiReq->nPdus; if(numPdus == 0) { - DU_LOG("\nNo PDU \n"); + DU_LOG("\nPHY_STUB: No PDU in DL TTI Request"); } while(numPdus) { if(dlTtiReq->pdus->pduType == 3) //SSB_PDU_TYPE - DU_LOG("\nSSB PDU\n"); + DU_LOG("\nPHY_STUB: SSB PDU"); else if(dlTtiReq->pdus->pduType == 0) - DU_LOG("\nSIB1 PDCCH PDU\n"); + DU_LOG("\nPHY_STUB: SIB1 PDCCH PDU"); else if(dlTtiReq->pdus->pduType == 1) - DU_LOG("\nSIB1 PDSCH PDU\n"); + DU_LOG("\nPHY_STUB: SIB1 PDSCH PDU"); numPdus--; } @@ -415,18 +481,28 @@ PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) { #ifdef FAPI fapi_ul_tti_req_t *ulTtiReq; + + DU_LOG("\nPHY STUB: Received UL TTI Request"); + ulTtiReq = (fapi_ul_tti_req_t *)msg; uint8_t numPdus = ulTtiReq->nPdus; + if(numPdus == 0) { - DU_LOG("\nPHY STUB: No PDU in UL TTI \n"); + DU_LOG("\nPHY STUB: No PDU in UL TTI"); } while(numPdus) { if(ulTtiReq->pdus->pduType == 0) - DU_LOG("\n PHY STUB: PRACH PDU\n"); + DU_LOG("\nPHY STUB: PRACH PDU"); numPdus--; } + if(rachIndSent == false && ulTtiReq->slot == 8) + { + rachIndSent = true; + l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn); + } + MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t)); #endif return ROK; @@ -438,7 +514,7 @@ PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) * * @details * - * Function : processFapiRequest + * Function : l1ProcessFapiRequest * * Functionality: * - Receives message from MAC and calls handler @@ -451,7 +527,7 @@ PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) * * ****************************************************************/ -void processFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg) +void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg) { switch(msgType) { diff --git a/src/phy_stub/l1_bdy2.c b/src/phy_stub/l1_bdy2.c index cfae52e6a..d45ede3a9 100644 --- a/src/phy_stub/l1_bdy2.c +++ b/src/phy_stub/l1_bdy2.c @@ -24,15 +24,17 @@ #include "lphy_stub.h" #include "du_log.h" +uint16_t l1BuildAndSendSlotIndication(); + void *GenerateTicks(void *arg) { uint8_t counter = 100; while(counter) { sleep(1); - DU_LOG("\nPHY_STUB: SLOT indication"); + DU_LOG("\n\nPHY_STUB: SLOT indication"); /* Send Slot indication indication to lower mac */ - buildAndSendSlotIndication(); + l1BuildAndSendSlotIndication(); counter--; } }