From 4fc13842d17b3cce83876c95cba9eef4b2a413dd Mon Sep 17 00:00:00 2001 From: Balaji Shankaran Date: Sun, 26 Apr 2020 19:30:39 +0530 Subject: [PATCH 1/1] Fix for seg fault at 5th and 20th slot and SIB1 Change-Id: I2ffee5452c3223971544f947de2041bdbcb71048 Signed-off-by: Balaji Shankaran --- src/5gnrmac/lwr_mac_fsm.c | 171 ++++++++++++++++++++++++++-------------------- src/5gnrsch/sch_common.c | 13 ++-- 2 files changed, 104 insertions(+), 80 deletions(-) diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 77e5447ef..47a681e4b 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -2486,96 +2486,119 @@ uint8_t calculatePduCount(DlBrdcstAlloc *cellBroadcastInfo) S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo) { #ifdef FAPI - uint8_t idx; + uint8_t idx; uint8_t nPdu = 0; - uint32_t msgLen = 0; - fapi_dl_tti_req_t *dlTtiReq = NULLP; - fapi_dl_tti_req_pdu_t *dlTtiReqPdu = NULLP; - RgCellCb *cellCbParams = NULLP; + uint8_t numPduEncoded = 0; + uint32_t msgLen = 0; + fapi_dl_tti_req_t *dlTtiReq = NULLP; + fapi_dl_tti_req_pdu_t *dlTtiReqPdu = NULLP; + RgCellCb *cellCbParams = NULLP; MacDlSlot *currDlSlot = NULLP; - MacCellCfg macCellCfg; + MacCellCfg macCellCfg; memset(&macCellCfg, 0, sizeof(MacCellCfg)); - Inst inst = 0; + Inst inst = 0; - if(clGlobalCp.phyState == PHY_STATE_RUNNING) - { - cellCbParams = rgCb[inst].cell; - macCellCfg = cellCbParams->macCellCfg; + if(clGlobalCp.phyState == PHY_STATE_RUNNING) + { + cellCbParams = rgCb[inst].cell; + macCellCfg = cellCbParams->macCellCfg; - if(dlTtiReqtimingInfo != NULLP) - { + if(dlTtiReqtimingInfo != NULLP) + { #ifdef INTEL_WLS - WLS_MEM_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); + WLS_MEM_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); #else - MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); + MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); #endif - if(dlTtiReq != NULLP) - { - dlTtiReq->sfn = dlTtiReqtimingInfo->sfn; - dlTtiReq->slot = dlTtiReqtimingInfo->slot; + if(dlTtiReq != NULLP) + { + dlTtiReq->sfn = dlTtiReqtimingInfo->sfn; + dlTtiReq->slot = dlTtiReqtimingInfo->slot; currDlSlot = &macCb.macCell->dlSlot[dlTtiReq->slot % MAX_SLOT_SUPPORTED]; dlTtiReq->nPdus = calculatePduCount(&currDlSlot->cellBroadcastInfo); /* get total Pdus */ nPdu = dlTtiReq->nPdus; - dlTtiReq->nGroup = 0; - if(dlTtiReq->nPdus > 0) - { + dlTtiReq->nGroup = 0; + if(dlTtiReq->nPdus > 0) + { #ifdef INTEL_WLS - WLS_MEM_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); + WLS_MEM_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); #else - MAC_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); + MAC_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); #endif - if(currDlSlot->cellBroadcastInfo.ssbTrans) - { - if(dlTtiReqPdu != NULLP) - { - for(idx = 0; idx < currDlSlot->cellBroadcastInfo.ssbIdxSupported; idx++) - { - if(idx > 0) - dlTtiReq->pdus++; - fillSsbPdu(dlTtiReqPdu, &macCellCfg, currDlSlot, &msgLen, idx); - dlTtiReq->pdus = dlTtiReqPdu; - } - } - } - if(currDlSlot->cellBroadcastInfo.sib1Trans) - { - /* Filling SIB1 param */ - if(dlTtiReqPdu != NULLP) - { - dlTtiReq->pdus++; - fillPdcchPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.sib1Alloc.sib1PdcchCfg, &msgLen); - dlTtiReq->pdus = dlTtiReqPdu; - dlTtiReq->pdus++; - fillPdschPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.sib1Alloc.sib1PdschCfg, &msgLen); - dlTtiReq->pdus = dlTtiReqPdu; - } - } - msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t); - fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen); - /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ - LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq); + if(currDlSlot->cellBroadcastInfo.ssbTrans) + { + if(dlTtiReqPdu != NULLP) + { + for(idx = 0; idx < currDlSlot->cellBroadcastInfo.ssbIdxSupported; idx++) + { + if(idx > 0) + dlTtiReq->pdus++; + fillSsbPdu(dlTtiReqPdu, &macCellCfg, currDlSlot, &msgLen, idx); + dlTtiReq->pdus = dlTtiReqPdu; + numPduEncoded++; + } + } + } if(currDlSlot->cellBroadcastInfo.sib1Trans) { - MAC_FREE(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t)); - } - MAC_FREE(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); - } - else - { - msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t); - fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen); - /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ - LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq); - } - MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t)); - return ROK; - } - else - { - DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request"); - return RFAILED; - } - } + /* Filling SIB1 param */ + if(dlTtiReqPdu != NULLP) + { + if(numPduEncoded != nPdu) + { + dlTtiReq->pdus++; + dlTtiReqPdu = dlTtiReq->pdus; + fillPdcchPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.\ + sib1Alloc.sib1PdcchCfg, &msgLen); + dlTtiReq->pdus = dlTtiReqPdu; + numPduEncoded++; + dlTtiReq->pdus++; + dlTtiReqPdu = dlTtiReq->pdus; + fillPdschPdu(dlTtiReqPdu,&currDlSlot->cellBroadcastInfo.\ + sib1Alloc.sib1PdschCfg, &msgLen); + dlTtiReq->pdus = dlTtiReqPdu; + numPduEncoded++; + } + } + } + msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t); + fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen); + /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ + LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq); + if(currDlSlot->cellBroadcastInfo.sib1Trans) + { + if(currDlSlot->cellBroadcastInfo.ssbTrans) + { + + MAC_FREE(dlTtiReq->pdus[1].u.pdcch_pdu.dlDci, + sizeof(fapi_dl_dci_t)); + } + else + { + + MAC_FREE(dlTtiReq->pdus[0].u.pdcch_pdu.dlDci, + sizeof(fapi_dl_dci_t)); + } + } + + MAC_FREE(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); + } + else + { + msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t); + fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen); + /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ + LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq); + } + MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t)); + return ROK; + } + else + { + DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request"); + return RFAILED; + } + } else { DU_LOG("\nLOWER MAC: Current TTI Info is NULL"); diff --git a/src/5gnrsch/sch_common.c b/src/5gnrsch/sch_common.c index 05037858a..697b82045 100644 --- a/src/5gnrsch/sch_common.c +++ b/src/5gnrsch/sch_common.c @@ -213,11 +213,11 @@ int sendUlSchInfoToMac(UlSchInfo *ulSchInfo, Inst inst) **/ int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo) { - uint8_t numPrachRb; - uint8_t numRa; - uint8_t freqStart; - uint16_t sfn; - uint16_t slot; + uint8_t numPrachRb = 0; + uint8_t numRa = 0; + uint8_t freqStart = 0; + uint16_t sfn = 0; + uint16_t slot = 0; uint8_t prachCfgIdx = 0; uint8_t prachFormat = 0; uint8_t x = 0; @@ -265,6 +265,7 @@ int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo) break; } numPrachRb = numRbForPrachTable[idx][3]; + dataType |= SCH_DATATYPE_PRACH; /* Considering first slot in the frame for PRACH */ idx = 0; ulAlloc->assignedPrb[idx] = freqStart+numPrachRb; @@ -274,7 +275,7 @@ int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo) ulSchInfo->cellId = cell->cellId; ulSchInfo->slotIndInfo.sfn = sfn; ulSchInfo->slotIndInfo.slot = slot; - ulSchInfo->dataType = dataType | SCH_DATATYPE_PRACH; + ulSchInfo->dataType = dataType; /* prach info */ ulSchInfo->prachSchInfo.numPrachOcas = prachOcas; ulSchInfo->prachSchInfo.prachFormat = prachFormat; -- 2.16.6