From: lal.harshita Date: Tue, 28 Feb 2023 16:16:10 +0000 (+0530) Subject: [EPIC-ID: ODUHIGH-488][TASK-ID: ODUHIGH-494] Rebasing this branch upto master branch... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=ae89c4b4054667ddc1a18d4181d8da7b767465c3;p=o-du%2Fl2.git [EPIC-ID: ODUHIGH-488][TASK-ID: ODUHIGH-494] Rebasing this branch upto master branch change Id I2994193099433f376ab7eba8cf5c72a57f697a29 Signed-off-by: lal.harshita Change-Id: Ifdd6513f771273c0bb9c81e7320d73e582e5db02 --- diff --git a/INFO.yaml b/INFO.yaml index eea6c39b5..6a5079e9b 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -34,11 +34,6 @@ repositories: - o-du/l2 committers: - <<: *oran_o_du_l2_ptl - - name: 'Sphoorthi Dayanand' - email: 'sphoorthi.dayanand@radisys.com' - company: 'Radisys' - id: 'sphoorthi' - timezone: 'Asia/Kolkata' - name: 'Harshita Lal' email: 'harshita.lal@radisys.com' company: 'Radisys' @@ -59,6 +54,21 @@ committers: company: 'Radisys' id: 'barveankit' timezone: 'Asia/Kolkata' + - name: 'Sangeeta Vaidhyanathan' + email: 'svaidhya@radisys.com' + company: 'Radisys' + id: 'svaidhya' + timezone: 'Asia/Kolkata' + - name: 'Priyanka Borla' + email: 'pborla@radisys.com' + company: 'Radisys' + id: 'pborla' + timezone: 'Asia/Kolkata' + - name: 'Ray-Guang Cheng' + email: 'crg@mail.ntust.edu.tw' + company: 'NTUST' + id: 'crg' + timezone: 'Asia/Taipei' tsc: # yamllint disable rule:line-length approval: 'missing' diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index cb8c02e56..85f97bcfd 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -2015,7 +2015,7 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) p_fapi_api_queue_elem_t cfgReqQElem; DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, \ - lwrMacCb.phyState); + lwrMacCb.phyState); cellId = (uint16_t *)msg; GET_CELL_IDX(*cellId, cellIdx); @@ -2024,7 +2024,7 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) /* Fill Cell Configuration in lwrMacCb */ memset(&lwrMacCb.cellCb[lwrMacCb.numCell], 0, sizeof(LwrMacCellCb)); lwrMacCb.cellCb[lwrMacCb.numCell].cellId = macCfgParams.cellId; - lwrMacCb.cellCb[lwrMacCb.numCell].phyCellId = macCfgParams.phyCellId; + lwrMacCb.cellCb[lwrMacCb.numCell].phyCellId = macCfgParams.cellCfg.phyCellId; lwrMacCb.numCell++; /* Allocte And fill Vendor msg */ @@ -2064,7 +2064,7 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) return RFAILED; } FILL_FAPI_LIST_ELEM(cfgReqQElem, vendorMsgQElem, FAPI_CONFIG_REQUEST, 1, \ - sizeof(fapi_config_req_t)); + sizeof(fapi_config_req_t)); configReq = (fapi_config_req_t *)(cfgReqQElem + 1); memset(configReq, 0, sizeof(fapi_config_req_t)); @@ -2077,70 +2077,64 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) msgLen = sizeof(configReq->number_of_tlvs); - if(macCfgParams.dlCarrCfg.pres) - { - fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \ - sizeof(uint32_t), macCfgParams.dlCarrCfg.bw, &msgLen); - fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \ - sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen); - /* Due to bug in Intel FT code, commenting TLVs that are are not - * needed to avoid error. Must be uncommented when FT bug is fixed */ - //fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \ - sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen); - //fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \ - sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen); - fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \ - sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen); - } - if(macCfgParams.ulCarrCfg.pres) - { - fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \ - sizeof(uint32_t), macCfgParams.ulCarrCfg.bw, &msgLen); - fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \ - sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen); - //fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \ - sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen); - //fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \ - sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen); - fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \ - sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen); - } + fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \ + sizeof(uint32_t), macCfgParams.carrCfg.dlBw, &msgLen); + fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \ + sizeof(uint32_t), macCfgParams.carrCfg.dlFreq, &msgLen); + /* Due to bug in Intel FT code, commenting TLVs that are are not + * needed to avoid error. Must be uncommented when FT bug is fixed */ + //fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \ + sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen); + //fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \ + sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen); + fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \ + sizeof(uint16_t), macCfgParams.carrCfg.numTxAnt, &msgLen); + fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \ + sizeof(uint32_t), macCfgParams.carrCfg.ulBw, &msgLen); + fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \ + sizeof(uint32_t), macCfgParams.carrCfg.ulFreq, &msgLen); + //fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \ + sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen); + //fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \ + sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen); + fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \ + sizeof(uint16_t), macCfgParams.carrCfg.numRxAnt, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, \ sizeof(uint8_t), macCfgParams.freqShft, &msgLen); /* fill cell config */ fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, \ - sizeof(uint8_t), macCfgParams.phyCellId, &msgLen); + sizeof(uint8_t), macCfgParams.cellCfg.phyCellId, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, \ - sizeof(uint8_t), macCfgParams.dupType, &msgLen); + sizeof(uint8_t), macCfgParams.cellCfg.dupType, &msgLen); /* fill SSB configuration */ fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, \ - sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen); + sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, \ sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, \ - sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen); + sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen); /* fill PRACH configuration */ //fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, \ sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, \ - sizeof(uint8_t), convertScsValToScsEnum(macCfgParams.prachCfg.prachSubcSpacing), &msgLen); + sizeof(uint8_t), convertScsValToScsEnum(macCfgParams.prachCfg.prachSubcSpacing), &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, \ - sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen); + sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG, - sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen); + sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_CONFIG_INDEX_TAG, - sizeof(uint8_t), macCfgParams.prachCfg.prachCfgIdx, &msgLen); + sizeof(uint8_t), macCfgParams.prachCfg.prachCfgIdx, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, \ - sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen); + sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, \ sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, \ - sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen); + sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , \ - sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen); + sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, \ sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen); /* if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq) @@ -2156,28 +2150,28 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) }*/ fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, \ - sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen); + sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \ sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen); /* fill SSB table */ fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, \ - sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen); + sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, \ sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, \ - sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen); + sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, \ - sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen); + sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen); setMibPdu(macCfgParams.ssbCfg.mibPdu, &mib, 0); fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , \ - sizeof(uint32_t), mib, &msgLen); + sizeof(uint32_t), mib, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, \ - sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen); + sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, \ - sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen); + sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \ sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen); //fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, \ @@ -2186,24 +2180,45 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) #ifdef NR_TDD /* fill TDD table */ fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, \ - sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen); - for(slotIdx =0 ;slotIdx< MAX_TDD_PERIODICITY_SLOTS; slotIdx++) + sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen); + + for(slotIdx =0 ;slotIdx < MAX_TDD_PERIODICITY_SLOTS; slotIdx++) { - for(symbolIdx = 0; symbolIdx< MAX_SYMB_PER_SLOT; symbolIdx++) + for(symbolIdx = 0; symbolIdx < MAX_SYMB_PER_SLOT; symbolIdx++) { - fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \ - sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[slotIdx][symbolIdx], &msgLen); + /*Fill Full-DL Slots as well as DL symbols ini 1st Flexi Slo*/ + if(slotIdx < macCfgParams.tddCfg.nrOfDlSlots || \ + (slotIdx == macCfgParams.tddCfg.nrOfDlSlots && symbolIdx < macCfgParams.tddCfg.nrOfDlSymbols)) + { + fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \ + sizeof(uint8_t), DL_SYMBOL, &msgLen); + } + + /*Fill Full-FLEXI SLOT and as well as Flexi Symbols in 1 slot preceding FULL-UL slot*/ + else if(slotIdx < (MAX_TDD_PERIODICITY_SLOTS - macCfgParams.tddCfg.nrOfUlSlots -1) || \ + (slotIdx == (MAX_TDD_PERIODICITY_SLOTS - macCfgParams.tddCfg.nrOfUlSlots -1) && \ + symbolIdx < (MAX_SYMB_PER_SLOT - macCfgParams.tddCfg.nrOfUlSymbols))) + { + fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \ + sizeof(uint8_t), FLEXI_SYMBOL, &msgLen); + } + /*Fill Partial UL symbols and Full-UL slot*/ + else + { + fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \ + sizeof(uint8_t), UL_SYMBOL, &msgLen); + } } } #endif - + /* fill measurement config */ //fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MEASUREMENT_TAG, \ sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen); /* fill DMRS Type A Pos */ fillTlvs(&configReq->tlvs[index++], FAPI_DMRS_TYPE_A_POS_TAG, \ - sizeof(uint8_t), macCfgParams.dmrsTypeAPos, &msgLen); + sizeof(uint8_t), macCfgParams.ssbCfg.dmrsTypeAPos, &msgLen); /* Fill message header */ LWR_MAC_ALLOC(headerElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_msg_header_t))); @@ -2215,7 +2230,7 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) return RFAILED; } FILL_FAPI_LIST_ELEM(headerElem, cfgReqQElem, FAPI_VENDOR_MSG_HEADER_IND, 1, \ - sizeof(fapi_msg_header_t)); + sizeof(fapi_msg_header_t)); msgHeader = (fapi_msg_header_t *)(headerElem + 1); msgHeader->num_msg = 2; /* Config req msg and vendor specific msg */ msgHeader->handle = 0; @@ -2443,12 +2458,12 @@ uint8_t fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg, if(dlTtiReqPdu != NULL) { dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */ - dlTtiReqPdu->pdu.ssb_pdu.physCellId = macCellCfg->phyCellId; + dlTtiReqPdu->pdu.ssb_pdu.physCellId = macCellCfg->cellCfg.phyCellId; dlTtiReqPdu->pdu.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss; dlTtiReqPdu->pdu.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx; - dlTtiReqPdu->pdu.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset; + dlTtiReqPdu->pdu.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;; /* ssbOfPdufstA to be filled in ssbCfg */ - dlTtiReqPdu->pdu.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA; + dlTtiReqPdu->pdu.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;; dlTtiReqPdu->pdu.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag; /* Bit manipulation for SFN */ setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload, sfn); @@ -2460,7 +2475,6 @@ uint8_t fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg, dlTtiReqPdu->pdu.ssb_pdu.preCodingAndBeamforming. \ pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0]; dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */ - return ROK; } return RFAILED; @@ -2522,7 +2536,7 @@ void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo) dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces; dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx; dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0]; - dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue; + dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.beta_pdcch_1_0; dlDciPtr->powerControlOffsetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS; /* Calculating freq domain resource allocation field value and size @@ -2532,8 +2546,8 @@ void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo) * Spec 38.214 Sec 5.1.2.2.2 */ coreset0Size= sib1PdcchInfo->coresetCfg.coreSetSize; - rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; - rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb; + rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.startPrb; + rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.numPrb; if((rbLen >=1) && (rbLen <= coreset0Size - rbStart)) { @@ -2621,7 +2635,7 @@ void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo) * ******************************************************************/ -void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc) +void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc, MacCellCfg *macCellCfg) { if(dlDciPtr != NULLP) { @@ -2652,18 +2666,18 @@ void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc) uint8_t tbScalingSize = 2; uint8_t reservedSize = 6; - dlDciPtr->rnti = dlPageAlloc->pagePdcchCfg.dci.rnti; - dlDciPtr->scramblingId = dlPageAlloc->pagePdcchCfg.dci.scramblingId; - dlDciPtr->scramblingRnti = dlPageAlloc->pagePdcchCfg.dci.scramblingRnti; - dlDciPtr->cceIndex = dlPageAlloc->pagePdcchCfg.dci.cceIndex; - dlDciPtr->aggregationLevel = dlPageAlloc->pagePdcchCfg.dci.aggregLevel; - dlDciPtr->pc_and_bform.numPrgs = dlPageAlloc->pagePdcchCfg.dci.beamPdcchInfo.numPrgs; - dlDciPtr->pc_and_bform.prgSize = dlPageAlloc->pagePdcchCfg.dci.beamPdcchInfo.prgSize; - dlDciPtr->pc_and_bform.digBfInterfaces = dlPageAlloc->pagePdcchCfg.dci.beamPdcchInfo.digBfInterfaces; - dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = dlPageAlloc->pagePdcchCfg.dci.beamPdcchInfo.prg[0].pmIdx; - dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = dlPageAlloc->pagePdcchCfg.dci.beamPdcchInfo.prg[0].beamIdx[0]; - dlDciPtr->beta_pdcch_1_0 = dlPageAlloc->pagePdcchCfg.dci.txPdcchPower.powerValue; - dlDciPtr->powerControlOffsetSS = dlPageAlloc->pagePdcchCfg.dci.txPdcchPower.powerControlOffsetSS; + dlDciPtr->rnti = P_RNTI; + dlDciPtr->scramblingId = macCellCfg->cellCfg.phyCellId; + dlDciPtr->scramblingRnti = 0; + dlDciPtr->cceIndex = dlPageAlloc->pageDlDci.cceIndex; + dlDciPtr->aggregationLevel = dlPageAlloc->pageDlDci.aggregLevel; + dlDciPtr->pc_and_bform.numPrgs = 1; + dlDciPtr->pc_and_bform.prgSize = 1; + dlDciPtr->pc_and_bform.digBfInterfaces = 0; + dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = 0; + dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = 0; + dlDciPtr->beta_pdcch_1_0 = 0; + dlDciPtr->powerControlOffsetSS = 0; /* Calculating freq domain resource allocation field value and size * coreset0Size = Size of coreset 0 @@ -2671,9 +2685,9 @@ void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc) * RBLen = length of contiguously allocted RBs * Spec 38.214 Sec 5.1.2.2.2 */ - coreset0Size = dlPageAlloc->pagePdcchCfg.coresetCfg.coreSetSize; - rbStart = dlPageAlloc->pagePdcchCfg.dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; - rbLen = dlPageAlloc->pagePdcchCfg.dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb; + coreset0Size = dlPageAlloc->pageDlDci.coreSetSize; + rbStart = dlPageAlloc->pageDlSch.freqAlloc.startPrb; + rbLen = dlPageAlloc->pageDlSch.freqAlloc.numPrb; if((rbLen >=1) && (rbLen <= coreset0Size - rbStart)) { @@ -2698,7 +2712,7 @@ void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc) else { /*Short Msg is Present*/ - if(dlPageAlloc->dlPagePduLen == 0 || dlPageAlloc->dlPagePdu == NULLP) + if(dlPageAlloc->pageDlSch.dlPagePduLen == 0 || dlPageAlloc->pageDlSch.dlPagePdu == NULLP) { /*When Paging Msg is absent*/ shortMsgInd = 2; @@ -2711,9 +2725,9 @@ void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc) shortMsg = dlPageAlloc->shortMsg; } - timeDomResAssign = dlPageAlloc->pagePdcchCfg.dci.pdschCfg->pdschTimeAlloc.rowIndex -1; - VRB2PRBMap = dlPageAlloc->pagePdcchCfg.dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping; - modNCodScheme = dlPageAlloc->pagePdcchCfg.dci.pdschCfg->codeword[0].mcsIndex; + timeDomResAssign = 0; + VRB2PRBMap = dlPageAlloc->pageDlSch.vrbPrbMapping; + modNCodScheme = dlPageAlloc->pageDlSch.tbInfo.mcs; tbScaling = 0; reserved = 0; @@ -2815,7 +2829,7 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) uint8_t modNCodSchemeSize = 5; uint8_t tbScalingSize = 2; uint8_t reservedSize = 16; - + dlDciPtr->rnti = rarPdcchInfo->dci.rnti; dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId; dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti; @@ -2826,7 +2840,7 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces; dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx; dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0]; - dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue; + dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.beta_pdcch_1_0; dlDciPtr->powerControlOffsetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS; /* Calculating freq domain resource allocation field value and size @@ -2838,8 +2852,8 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) /* TODO: Fill values of coreset0Size, rbStart and rbLen */ coreset0Size= rarPdcchInfo->coresetCfg.coreSetSize; - rbStart = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; - rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb; + rbStart = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.startPrb; + rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.numPrb; if((rbLen >=1) && (rbLen <= coreset0Size - rbStart)) { @@ -2968,7 +2982,7 @@ void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\ dlDciPtr->pc_and_bform.digBfInterfaces = pdcchInfo->dci.beamPdcchInfo.digBfInterfaces; dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = pdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx; dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = pdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0]; - dlDciPtr->beta_pdcch_1_0 = pdcchInfo->dci.txPdcchPower.powerValue; + dlDciPtr->beta_pdcch_1_0 = pdcchInfo->dci.txPdcchPower.beta_pdcch_1_0; dlDciPtr->powerControlOffsetSS = pdcchInfo->dci.txPdcchPower.powerControlOffsetSS; /* Calculating freq domain resource allocation field value and size @@ -2978,8 +2992,8 @@ void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\ * Spec 38.214 Sec 5.1.2.2.2 */ coresetSize = pdcchInfo->coresetCfg.coreSetSize; - rbStart = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; - rbLen = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb; + rbStart = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.startPrb; + rbLen = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.numPrb; if((rbLen >=1) && (rbLen <= coresetSize - rbStart)) { @@ -3073,6 +3087,62 @@ void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\ } } +/******************************************************************* + * + * @brief fills Dl PDCCH Info from DL PageAlloc + * + * @details + * + * Function : fillPdcchInfoFrmPageAlloc + * + * Functionality: + * -Fills the PdcchInfo + * + * @params[in] Pointer to DlPageAlloc + * Pointer to PdcchCfg + * @return ROK + * + ******************************************************************/ +void fillPagePdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu_t *dlTtiVendorPdu, DlPageAlloc *pageAlloc, MacCellCfg *macCellCfg) +{ + if(dlTtiReqPdu != NULLP) + { + BwpCfg *bwp = NULLP; + + memset(&dlTtiReqPdu->pdu.pdcch_pdu, 0, sizeof(fapi_dl_pdcch_pdu_t)); + bwp = &pageAlloc->bwp; + fillPageDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pageAlloc, macCellCfg); + + dlTtiReqPdu->pduType = PDCCH_PDU_TYPE; + + dlTtiReqPdu->pdu.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb; + dlTtiReqPdu->pdu.pdcch_pdu.bwpStart = bwp->freqAlloc.startPrb; + dlTtiReqPdu->pdu.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing; + dlTtiReqPdu->pdu.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix; + + dlTtiReqPdu->pdu.pdcch_pdu.startSymbolIndex = pageAlloc->pageDlDci.ssStartSymbolIndex; + dlTtiReqPdu->pdu.pdcch_pdu.durationSymbols = pageAlloc->pageDlDci.durationSymbols; + memcpy(dlTtiReqPdu->pdu.pdcch_pdu.freqDomainResource, pageAlloc->pageDlDci.freqDomainResource, 6*sizeof(uint8_t)); + dlTtiReqPdu->pdu.pdcch_pdu.cceRegMappingType = pageAlloc->pageDlDci.cceRegMappingType; + dlTtiReqPdu->pdu.pdcch_pdu.regBundleSize = pageAlloc->pageDlDci.cceReg.interleaved.regBundleSize; + dlTtiReqPdu->pdu.pdcch_pdu.interleaverSize = pageAlloc->pageDlDci.cceReg.interleaved.interleaverSize; + dlTtiReqPdu->pdu.pdcch_pdu.shiftIndex = pageAlloc->pageDlDci.cceReg.interleaved.shiftIndex; + dlTtiReqPdu->pdu.pdcch_pdu.precoderGranularity = pageAlloc->pageDlDci.precoderGranularity; + dlTtiReqPdu->pdu.pdcch_pdu.numDlDci = 1; + dlTtiReqPdu->pdu.pdcch_pdu.coreSetType = CORESET_TYPE0; + + /* Calculating PDU length. Considering only one dl dci pdu for now */ + dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t); + + /* Filling Vendor message PDU */ + dlTtiVendorPdu->pdu_type = FAPI_PDCCH_PDU_TYPE; + dlTtiVendorPdu->pdu_size = sizeof(fapi_vendor_dl_pdcch_pdu_t); + dlTtiVendorPdu->pdu.pdcch_pdu.num_dl_dci = dlTtiReqPdu->pdu.pdcch_pdu.numDlDci; + dlTtiVendorPdu->pdu.pdcch_pdu.dl_dci[0].epre_ratio_of_pdcch_to_ssb = 0; + dlTtiVendorPdu->pdu.pdcch_pdu.dl_dci[0].epre_ratio_of_dmrs_to_ssb = 0; + } +} + /******************************************************************* * * @brief fills PDCCH PDU required for DL TTI info in MAC @@ -3105,12 +3175,6 @@ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_ bwp = &dlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp; fillSib1DlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo); } - else if(rntiType == P_RNTI_TYPE) - { - pdcchInfo = &dlSlot->pageAllocInfo->pagePdcchCfg; - bwp = &dlSlot->pageAllocInfo->bwp; - fillPageDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, dlSlot->pageAllocInfo); - } else if(rntiType == RA_RNTI_TYPE) { pdcchInfo = &dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdcchCfg; @@ -3134,6 +3198,7 @@ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_ dlTtiReqPdu->pdu.pdcch_pdu.bwpStart = bwp->freqAlloc.startPrb; dlTtiReqPdu->pdu.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing; dlTtiReqPdu->pdu.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix; + dlTtiReqPdu->pdu.pdcch_pdu.startSymbolIndex = pdcchInfo->coresetCfg.startSymbolIndex; dlTtiReqPdu->pdu.pdcch_pdu.durationSymbols = pdcchInfo->coresetCfg.durationSymbols; memcpy(dlTtiReqPdu->pdu.pdcch_pdu.freqDomainResource, pdcchInfo->coresetCfg.freqDomainResource, 6); @@ -3159,6 +3224,91 @@ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_ return ROK; } +/******************************************************************* + * + * @brief fills PDSCH PDU from PageAlloc required for DL TTI info in MAC + * + * @details + * + * Function : fillPagePdschPdu + * + * Functionality: + * -Fills the Pdsch PDU info + * stored in MAC + * + * @params[in] Pointer to FAPI DL TTI Req + * Pointer to PdschCfg + * Pointer to msgLen of DL TTI Info + * @return ROK + * + ******************************************************************/ +void fillPagePdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu_t *dlTtiVendorPdu, DlPageAlloc *pageAlloc, + uint16_t pduIndex, MacCellCfg *macCellCfg) +{ + uint8_t idx; + + if(dlTtiReqPdu != NULLP) + { + dlTtiReqPdu->pduType = PDSCH_PDU_TYPE; + memset(&dlTtiReqPdu->pdu.pdsch_pdu, 0, sizeof(fapi_dl_pdsch_pdu_t)); + dlTtiReqPdu->pdu.pdsch_pdu.pduBitMap = 0; /* PTRS and CBG params are excluded */ + dlTtiReqPdu->pdu.pdsch_pdu.rnti = P_RNTI; + dlTtiReqPdu->pdu.pdsch_pdu.pdu_index = pduIndex; + dlTtiReqPdu->pdu.pdsch_pdu.bwpSize = pageAlloc->bwp.freqAlloc.numPrb; + dlTtiReqPdu->pdu.pdsch_pdu.bwpStart = pageAlloc->bwp.freqAlloc.startPrb; + dlTtiReqPdu->pdu.pdsch_pdu.subCarrierSpacing = pageAlloc->bwp.subcarrierSpacing; + dlTtiReqPdu->pdu.pdsch_pdu.cyclicPrefix = pageAlloc->bwp.cyclicPrefix; + dlTtiReqPdu->pdu.pdsch_pdu.nrOfCodeWords = 1; + for(idx = 0; idx < MAX_CODEWORDS ; idx++) + { + dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].targetCodeRate = 308; + dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].qamModOrder = 2; + dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsIndex = pageAlloc->pageDlSch.tbInfo.mcs; + dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsTable = 0; + dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].rvIndex = 0; + dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].tbSize = pageAlloc->pageDlSch.tbInfo.tbSize; + } + dlTtiReqPdu->pdu.pdsch_pdu.dataScramblingId = macCellCfg->cellCfg.phyCellId; + dlTtiReqPdu->pdu.pdsch_pdu.nrOfLayers = 1; + dlTtiReqPdu->pdu.pdsch_pdu.transmissionScheme = 0; + dlTtiReqPdu->pdu.pdsch_pdu.refPoint = 0; + dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsSymbPos = DL_DMRS_SYMBOL_POS; + dlTtiReqPdu->pdu.pdsch_pdu.dmrsConfigType = pageAlloc->pageDlSch.dmrs.dmrsType; + dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsScramblingId = macCellCfg->cellCfg.phyCellId; + dlTtiReqPdu->pdu.pdsch_pdu.scid = 0; + dlTtiReqPdu->pdu.pdsch_pdu.numDmrsCdmGrpsNoData = 1; + dlTtiReqPdu->pdu.pdsch_pdu.dmrsPorts = 0x0001; + dlTtiReqPdu->pdu.pdsch_pdu.resourceAlloc = 1; + /* since we are using type-1, hence rbBitmap excluded */ + dlTtiReqPdu->pdu.pdsch_pdu.rbStart = pageAlloc->pageDlSch.freqAlloc.startPrb; + dlTtiReqPdu->pdu.pdsch_pdu.rbSize = pageAlloc->pageDlSch.freqAlloc.numPrb; + dlTtiReqPdu->pdu.pdsch_pdu.vrbToPrbMapping = pageAlloc->pageDlSch.vrbPrbMapping; + dlTtiReqPdu->pdu.pdsch_pdu.startSymbIndex = pageAlloc->pageDlSch.timeAlloc.startSymb; + dlTtiReqPdu->pdu.pdsch_pdu.nrOfSymbols = pageAlloc->pageDlSch.timeAlloc.numSymb; + dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.numPrgs = 1; + dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.prgSize = 0; + dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = 0; + dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0; + dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0].beamIdx[0].beamidx = 0; + dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffset = 0; + dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffsetSS = 0; + dlTtiReqPdu->pdu.pdsch_pdu.mappingType = pageAlloc->pageDlSch.timeAlloc.mappingType; + dlTtiReqPdu->pdu.pdsch_pdu.nrOfDmrsSymbols = pageAlloc->pageDlSch.dmrs.nrOfDmrsSymbols; + dlTtiReqPdu->pdu.pdsch_pdu.dmrsAddPos = pageAlloc->pageDlSch.dmrs.dmrsAddPos; + + dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t); + + /* DL TTI Request vendor message */ + dlTtiVendorPdu->pdu_type = FAPI_PDSCH_PDU_TYPE; + dlTtiVendorPdu->pdu_size = sizeof(fapi_vendor_dl_pdsch_pdu_t); + dlTtiVendorPdu->pdu.pdsch_pdu.nr_of_antenna_ports = 1; + for(int i =0; i< FAPI_VENDOR_MAX_TXRU_NUM; i++) + { + dlTtiVendorPdu->pdu.pdsch_pdu.tx_ru_idx[i] =0; + } + } +} + /******************************************************************* * * @brief fills PDSCH PDU required for DL TTI info in MAC @@ -3216,11 +3366,11 @@ void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu dlTtiReqPdu->pdu.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts; dlTtiReqPdu->pdu.pdsch_pdu.resourceAlloc = pdschInfo->pdschFreqAlloc.resourceAllocType; /* since we are using type-1, hence rbBitmap excluded */ - dlTtiReqPdu->pdu.pdsch_pdu.rbStart = pdschInfo->pdschFreqAlloc.freqAlloc.startPrb; - dlTtiReqPdu->pdu.pdsch_pdu.rbSize = pdschInfo->pdschFreqAlloc.freqAlloc.numPrb; + dlTtiReqPdu->pdu.pdsch_pdu.rbStart = pdschInfo->pdschFreqAlloc.startPrb; + dlTtiReqPdu->pdu.pdsch_pdu.rbSize = pdschInfo->pdschFreqAlloc.numPrb; dlTtiReqPdu->pdu.pdsch_pdu.vrbToPrbMapping = pdschInfo->pdschFreqAlloc.vrbPrbMapping; - dlTtiReqPdu->pdu.pdsch_pdu.startSymbIndex = pdschInfo->pdschTimeAlloc.timeAlloc.startSymb; - dlTtiReqPdu->pdu.pdsch_pdu.nrOfSymbols = pdschInfo->pdschTimeAlloc.timeAlloc.numSymb; + dlTtiReqPdu->pdu.pdsch_pdu.startSymbIndex = pdschInfo->pdschTimeAlloc.startSymb; + dlTtiReqPdu->pdu.pdsch_pdu.nrOfSymbols = pdschInfo->pdschTimeAlloc.numSymb; dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs; dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize; dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces; @@ -3269,7 +3419,7 @@ uint8_t calcDlTtiReqPduCount(MacDlSlot *dlSlot) if(dlSlot->dlInfo.isBroadcastPres) { - if(dlSlot->dlInfo.brdcstAlloc.ssbTrans) + if(dlSlot->dlInfo.brdcstAlloc.ssbTransmissionMode) { for(idx = 0; idx < dlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++) { @@ -3277,7 +3427,7 @@ uint8_t calcDlTtiReqPduCount(MacDlSlot *dlSlot) count++; } } - if(dlSlot->dlInfo.brdcstAlloc.sib1Trans) + if(dlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode) { /* PDCCH and PDSCH PDU is filled */ count += 2; @@ -3335,7 +3485,7 @@ uint8_t calcTxDataReqPduCount(MacDlSlot *dlSlot) { uint8_t idx = 0, count = 0, ueIdx=0; - if(dlSlot->dlInfo.isBroadcastPres && dlSlot->dlInfo.brdcstAlloc.sib1Trans) + if(dlSlot->dlInfo.isBroadcastPres && dlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode) { count++; } @@ -3382,7 +3532,7 @@ uint8_t calcTxDataReqPduCount(MacDlSlot *dlSlot) * * ********************************************************************/ uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, MacCellCfg *macCellCfg, - PdschCfg pdschCfg) + PdschCfg *pdschCfg) { uint32_t payloadSize = 0; uint8_t *sib1Payload = NULLP; @@ -3395,7 +3545,7 @@ uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, MacCel pduDesc[pduIndex].num_tlvs = 1; /* fill the TLV */ - payloadSize = pdschCfg.codeword[0].tbSize; + payloadSize = pdschCfg->codeword[0].tbSize; pduDesc[pduIndex].tlvs[0].tl.tag = ((payloadSize & 0xff0000) >> 8) | FAPI_TX_DATA_PTR_TO_PAYLOAD_64; pduDesc[pduIndex].tlvs[0].tl.length = (payloadSize & 0x0000ffff); LWR_MAC_ALLOC(sib1Payload, payloadSize); @@ -3405,8 +3555,8 @@ uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, MacCel } payloadElem = (fapi_api_queue_elem_t *)sib1Payload; FILL_FAPI_LIST_ELEM(payloadElem, NULLP, FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ, 1, \ - macCellCfg->sib1Cfg.sib1PduLen); - memcpy(sib1Payload + TX_PAYLOAD_HDR_LEN, macCellCfg->sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1PduLen); + macCellCfg->cellCfg.sib1Cfg.sib1PduLen); + memcpy(sib1Payload + TX_PAYLOAD_HDR_LEN, macCellCfg->cellCfg.sib1Cfg.sib1Pdu, macCellCfg->cellCfg.sib1Cfg.sib1PduLen); #ifdef INTEL_WLS_MEM mtGetWlsHdl(&wlsHdlr); @@ -3443,8 +3593,7 @@ uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, MacCel * @return ROK * * ********************************************************************/ -uint8_t fillPageTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, DlPageAlloc *pageAllocInfo, - PdschCfg pdschCfg) +uint8_t fillPageTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, DlPageAlloc *pageAllocInfo) { uint32_t payloadSize = 0; uint8_t *pagePayload = NULLP; @@ -3457,7 +3606,7 @@ uint8_t fillPageTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, DlPage pduDesc[pduIndex].num_tlvs = 1; /* fill the TLV */ - payloadSize = pdschCfg.codeword[0].tbSize; + payloadSize = pageAllocInfo->pageDlSch.tbInfo.tbSize; pduDesc[pduIndex].tlvs[0].tl.tag = ((payloadSize & 0xff0000) >> 8) | FAPI_TX_DATA_PTR_TO_PAYLOAD_64; pduDesc[pduIndex].tlvs[0].tl.length = (payloadSize & 0x0000ffff); LWR_MAC_ALLOC(pagePayload, payloadSize); @@ -3467,8 +3616,8 @@ uint8_t fillPageTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, DlPage } payloadElem = (fapi_api_queue_elem_t *)pagePayload; FILL_FAPI_LIST_ELEM(payloadElem, NULLP, FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ, 1, \ - pageAllocInfo->dlPagePduLen); - memcpy(pagePayload + TX_PAYLOAD_HDR_LEN, pageAllocInfo->dlPagePdu, pageAllocInfo->dlPagePduLen); + pageAllocInfo->pageDlSch.dlPagePduLen); + memcpy(pagePayload + TX_PAYLOAD_HDR_LEN, pageAllocInfo->pageDlSch.dlPagePdu, pageAllocInfo->pageDlSch.dlPagePduLen); #ifdef INTEL_WLS_MEM mtGetWlsHdl(&wlsHdlr); @@ -3709,7 +3858,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) { if(currDlSlot->dlInfo.isBroadcastPres) { - if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans) + if(currDlSlot->dlInfo.brdcstAlloc.ssbTransmissionMode) { if(dlTtiReq->pdus != NULLP) { @@ -3725,12 +3874,13 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) DU_LOG("\033[0m"); } - if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans) + if(currDlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode) { /* Filling SIB1 param */ if(numPduEncoded != nPdu) { - rntiType = SI_RNTI_TYPE; + if(currDlSlot->dlInfo.brdcstAlloc.crnti == SI_RNTI) + rntiType = SI_RNTI_TYPE; /* PDCCH PDU */ fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], @@ -3739,7 +3889,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) /* PDSCH PDU */ fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], - &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg, + currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg.dci.pdschCfg, currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp, pduIndex); dlTtiReq->ue_grp_info[dlTtiReq->nGroup].pduIdx[pduIndex] = pduIndex; @@ -3758,13 +3908,11 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) if(numPduEncoded != nPdu) { rntiType = P_RNTI_TYPE; - fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], currDlSlot, -1, \ - rntiType, CORESET_TYPE0, MAX_NUM_UE); + fillPagePdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], \ + currDlSlot->pageAllocInfo, &macCellCfg); numPduEncoded++; - fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], - &currDlSlot->pageAllocInfo->pagePdschCfg, - currDlSlot->pageAllocInfo->bwp, - pduIndex); + fillPagePdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], + currDlSlot->pageAllocInfo, pduIndex, &macCellCfg); dlTtiReq->ue_grp_info[dlTtiReq->nGroup].pduIdx[pduIndex] = pduIndex; pduIndex++; numPduEncoded++; @@ -3985,20 +4133,19 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, MacDlSlot *dlSlot, p_fapi_ txDataReq->sfn = currTimingInfo.sfn; txDataReq->slot = currTimingInfo.slot; - if(dlSlot->dlInfo.brdcstAlloc.sib1Trans) + if(dlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode) { fillSib1TxDataReq(txDataReq->pdu_desc, pduIndex, &macCb.macCell[cellIdx]->macCellCfg, \ - dlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg); + dlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg.dci.pdschCfg); pduIndex++; txDataReq->num_pdus++; } if(dlSlot->pageAllocInfo != NULLP) { - fillPageTxDataReq(txDataReq->pdu_desc, pduIndex, dlSlot->pageAllocInfo, \ - dlSlot->pageAllocInfo->pagePdschCfg); + fillPageTxDataReq(txDataReq->pdu_desc, pduIndex, dlSlot->pageAllocInfo); pduIndex++; txDataReq->num_pdus++; - MAC_FREE(dlSlot->pageAllocInfo->dlPagePdu, sizeof(dlSlot->pageAllocInfo->dlPagePduLen)); + MAC_FREE(dlSlot->pageAllocInfo->pageDlSch.dlPagePdu, sizeof(dlSlot->pageAllocInfo->pageDlSch.dlPagePduLen)); MAC_FREE(dlSlot->pageAllocInfo,sizeof(DlPageAlloc)); } @@ -4146,7 +4293,7 @@ void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, Ma if(ulTtiReqPdu != NULLP) { ulTtiReqPdu->pduType = PRACH_PDU_TYPE; - ulTtiReqPdu->pdu.prach_pdu.physCellId = macCellCfg->phyCellId; + ulTtiReqPdu->pdu.prach_pdu.physCellId = macCellCfg->cellCfg.phyCellId; ulTtiReqPdu->pdu.prach_pdu.numPrachOcas = \ currUlSlot->ulInfo.prachSchInfo.numPrachOcas; ulTtiReqPdu->pdu.prach_pdu.prachFormat = \ @@ -4496,7 +4643,7 @@ void fillUlDciPdu(fapi_dl_dci_t *ulDciPtr, DciInfo *schDciInfo) ulDciPtr->pc_and_bform.digBfInterfaces = schDciInfo->dciInfo.beamPdcchInfo.digBfInterfaces; ulDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = schDciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx; ulDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = schDciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0]; - ulDciPtr->beta_pdcch_1_0 = schDciInfo->dciInfo.txPdcchPower.powerValue; + ulDciPtr->beta_pdcch_1_0 = schDciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0; ulDciPtr->powerControlOffsetSS = schDciInfo->dciInfo.txPdcchPower.powerControlOffsetSS; /* Calculating freq domain resource allocation field value and size @@ -4505,11 +4652,11 @@ void fillUlDciPdu(fapi_dl_dci_t *ulDciPtr, DciInfo *schDciInfo) * RBLen = length of contiguously allocted RBs * Spec 38.214 Sec 5.1.2.2.2 */ - if(schDciInfo->formatType == FORMAT0_0) + if(schDciInfo->dciFormatInfo.formatType == FORMAT0_0) { coreset1Size = schDciInfo->coresetCfg.coreSetSize; - rbLen = schDciInfo->format.format0_0.freqAlloc.numPrb; - rbStart = schDciInfo->format.format0_0.freqAlloc.startPrb; + rbLen = schDciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb; + rbStart = schDciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb; if((rbLen >=1) && (rbLen <= coreset1Size - rbStart)) { @@ -4522,15 +4669,15 @@ void fillUlDciPdu(fapi_dl_dci_t *ulDciPtr, DciInfo *schDciInfo) freqDomResAssignSize = ceil(log2(coreset1Size * (coreset1Size + 1) / 2)); } /* Fetching DCI field values */ - dciFormatId = schDciInfo->formatType; /* DCI indentifier for UL DCI */ - timeDomResAssign = schDciInfo->format.format0_0.rowIndex; - freqHopFlag = schDciInfo->format.format0_0.freqHopFlag; - modNCodScheme = schDciInfo->format.format0_0.mcs; - ndi = schDciInfo->format.format0_0.ndi; - redundancyVer = schDciInfo->format.format0_0.rv; - harqProcessNum = schDciInfo->format.format0_0.harqProcId; - puschTpc = schDciInfo->format.format0_0.tpcCmd; - ul_SlInd = schDciInfo->format.format0_0.sUlCfgd; + dciFormatId = schDciInfo->dciFormatInfo.formatType; /* DCI indentifier for UL DCI */ + timeDomResAssign = schDciInfo->dciFormatInfo.format.format0_0.rowIndex; + freqHopFlag = schDciInfo->dciFormatInfo.format.format0_0.freqHopFlag; + modNCodScheme = schDciInfo->dciFormatInfo.format.format0_0.mcs; + ndi = schDciInfo->dciFormatInfo.format.format0_0.ndi; + redundancyVer = schDciInfo->dciFormatInfo.format.format0_0.rvIndex; + harqProcessNum = schDciInfo->dciFormatInfo.format.format0_0.harqProcId; + puschTpc = schDciInfo->dciFormatInfo.format.format0_0.tpcCmd; + ul_SlInd = schDciInfo->dciFormatInfo.format.format0_0.sulIndicator; /* Reversing bits in each DCI field */ dciFormatId = reverseBits(dciFormatId, dciFormatIdSize); diff --git a/src/5gnrmac/lwr_mac_fsm.h b/src/5gnrmac/lwr_mac_fsm.h index 3b137826a..067a3cd7a 100644 --- a/src/5gnrmac/lwr_mac_fsm.h +++ b/src/5gnrmac/lwr_mac_fsm.h @@ -52,6 +52,15 @@ typedef enum{ P_RNTI_TYPE }RntiType; +#ifdef NR_TDD +typedef enum +{ + DL_SYMBOL, + UL_SYMBOL, + FLEXI_SYMBOL +}SymbolConfig; +#endif + uint8_t lwr_mac_procInvalidEvt(void *msg); uint8_t lwr_mac_procParamReqEvt(void *msg); uint8_t lwr_mac_procParamRspEvt(void *msg); diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index 10538aa01..e84bba36d 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -75,7 +75,7 @@ typedef enum CELL_STATE_UP, CELL_TO_BE_STOPPED, CELL_STOP_IN_PROGRESS, -}CellState; +}MacCellStatus; typedef enum { @@ -228,18 +228,18 @@ typedef struct macUeCb struct macCellCb { - uint16_t cellId; - uint16_t numOfSlots; - CellState state; - uint16_t crntiMap; - MacRaCbInfo macRaCb[MAX_NUM_UE]; - MacDlSlot dlSlot[MAX_SLOTS]; - MacUlSlot ulSlot[MAX_SLOTS]; - uint16_t numActvUe; - MacUeCfg *ueCfgTmpData[MAX_NUM_UE]; - MacUeRecfg *ueRecfgTmpData[MAX_NUM_UE]; - MacUeCb ueCb[MAX_NUM_UE]; - MacCellCfg macCellCfg; + uint16_t cellId; + uint16_t numOfSlots; + MacCellStatus state; + uint16_t crntiMap; + MacRaCbInfo macRaCb[MAX_NUM_UE]; + MacDlSlot dlSlot[MAX_SLOTS]; + MacUlSlot ulSlot[MAX_SLOTS]; + uint16_t numActvUe; + MacUeCfg *ueCfgTmpData[MAX_NUM_UE]; + MacUeRecfg *ueRecfgTmpData[MAX_NUM_UE]; + MacUeCb ueCb[MAX_NUM_UE]; + MacCellCfg macCellCfg; SlotTimingInfo currTime; }; diff --git a/src/5gnrmac/mac_cfg_hdl.c b/src/5gnrmac/mac_cfg_hdl.c index 23c1bf77a..cd3b9a543 100644 --- a/src/5gnrmac/mac_cfg_hdl.c +++ b/src/5gnrmac/mac_cfg_hdl.c @@ -136,7 +136,7 @@ uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg) { Pst cfmPst; uint16_t cellIdx; - uint8_t ret = ROK, sliceIdx = 0; + uint8_t ret = ROK, plmnIdx = 0,sliceIdx = 0; MacCellCb *macCellCb; memset((uint8_t *)&cfmPst, 0, sizeof(Pst)); @@ -152,46 +152,48 @@ uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg) GET_CELL_IDX(macCellCfg->cellId, cellIdx); macCb.macCell[cellIdx] = macCellCb; macCb.macCell[cellIdx]->cellId = macCellCfg->cellId; - macCb.macCell[cellIdx]->numOfSlots = 10 * (1 << macCellCfg->numerology); + macCb.macCell[cellIdx]->numOfSlots = 10 * (1 << macCellCfg->cellCfg.numerology); memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg)); - MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \ - macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen); - if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP) + MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, \ + macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen); + if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu == NULLP) { DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n"); return RFAILED; } - memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \ - macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen); - - macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice; - MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\ - * sizeof(Snssai*)); - if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP) - { - DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq"); - return RFAILED; - } + memcpy(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, macCellCfg->cellCfg.sib1Cfg.sib1Pdu, \ + macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen); - if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai) + for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++) { - for(sliceIdx=0; sliceIdxmacCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++) + macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = macCellCfg->cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; + MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice\ + * sizeof(Snssai*)); + if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP) + { + DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq"); + return RFAILED; + } + + if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai) { - if(macCellCfg->plmnInfoList.snssai[sliceIdx]) + for(sliceIdx=0; sliceIdxmacCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; sliceIdx++) { - MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai)); - if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx]) + if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx]) { - DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq"); - return RFAILED; + MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai)); + if(!macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx]) + { + DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq"); + return RFAILED; + } + memcpy(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx],\ + sizeof(Snssai)); } - memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\ - sizeof(Snssai)); } } } - /* Send cell cfg to scheduler */ ret = MacSchCellCfgReq(pst, macCellCfg); if(ret != ROK) @@ -230,147 +232,155 @@ uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg) { SchCellCfg schCellCfg; Pst cfgPst; - uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, sliceIdx=0; + uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, sliceIdx=0, plmnIdx = 0; memset(&cfgPst, 0, sizeof(Pst)); memset(&schCellCfg, 0, sizeof(SchCellCfg)); schCellCfg.cellId = macCellCfg->cellId; - schCellCfg.phyCellId = macCellCfg->phyCellId; - schCellCfg.numerology = macCellCfg->numerology; - schCellCfg.dupMode = macCellCfg->dupType; - schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw; - schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq; - schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq; + schCellCfg.phyCellId = macCellCfg->cellCfg.phyCellId; - /* fill ssb scheduler parameters */ - schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr; - schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn; - schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA; - schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod]; - schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset; - for(ssbMaskIdx=0; ssbMaskIdxssbCfg.ssbMask[ssbMaskIdx]; + schCellCfg.plmnInfoList[plmnIdx].plmn = macCellCfg->cellCfg.plmnInfoList[plmnIdx].plmn; + if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai) + { + schCellCfg.plmnInfoList[plmnIdx].numSliceSupport = macCellCfg->cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; + MAC_ALLOC(schCellCfg.plmnInfoList[plmnIdx].snssai, schCellCfg.plmnInfoList[plmnIdx].numSliceSupport * sizeof(Snssai*)); + if(!schCellCfg.plmnInfoList[plmnIdx].snssai) + { + DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq"); + return RFAILED; + } + for(sliceIdx=0; sliceIdxcellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx]) + { + MAC_ALLOC(schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai)); + if(!schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx]) + { + DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq"); + return RFAILED; + } + memcpy(schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai)); + } + } + } } - schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]); - /* fill SIB1 scheduler parameters */ - schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen; - schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod; - schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex; - schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex; - schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs; - schCellCfg.sib1SchCfg.pageCfg.numPO = macCellCfg->sib1Cfg.pagingCfg.numPO; - schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent; - - if(schCellCfg.sib1SchCfg.pageCfg.poPresent) - { - memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF); - } + schCellCfg.dupMode = macCellCfg->cellCfg.dupType; + schCellCfg.numerology = macCellCfg->cellCfg.numerology; + schCellCfg.dlBandwidth = macCellCfg->carrCfg.dlBw; + schCellCfg.ulBandwidth = macCellCfg->carrCfg.ulBw; - /* fill RACH config params */ - schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx; - schCellCfg.schRachCfg.prachSubcSpacing = \ - macCellCfg->prachCfg.prachSubcSpacing; - schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart; - schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm; - schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen; - schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx; - schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq; - schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1; - schCellCfg.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble; - schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach; - schCellCfg.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb; - schCellCfg.schRachCfg.prachMultCarrBand = macCellCfg->prachCfg.prachMultCarrBand; - schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr; - schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb; - schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow; + schCellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA = macCellCfg->ssbCfg.ssbOffsetPointA; /* fill initial DL BWP */ - schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb; - schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb; - schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs; - schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = + schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb; + schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb; + schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs; + schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix; + + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8; - schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 = macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16; - schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; + + schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; for(rsrcListIdx = 0; rsrcListIdxinitialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++) { - schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 = macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0; - schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType = macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType; - schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol = macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol; - schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol = + schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol = macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol; } + /* fill SIB1 scheduler parameters */ + schCellCfg.dlCfgCommon.schPcchCfg.numPO = macCellCfg->cellCfg.sib1Cfg.pagingCfg.numPO; + schCellCfg.dlCfgCommon.schPcchCfg.poPresent = macCellCfg->cellCfg.sib1Cfg.pagingCfg.poPresent; + if(schCellCfg.dlCfgCommon.schPcchCfg.poPresent) + { + memcpy(schCellCfg.dlCfgCommon.schPcchCfg.pagingOcc, macCellCfg->cellCfg.sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF); + } + /* fill initial UL BWP */ - schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb; - schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb; - schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs; - schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix; - schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \ - macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; + schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb; + schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb; + schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs; + schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix; + /* fill RACH config params */ + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1Fdm = macCellCfg->prachCfg.msg1Fdm; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.zeroCorrZoneCfg = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.raRspWindow = macCellCfg->prachCfg.raRspWindow; + + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq; + schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.msg1SubcSpacing = \ + macCellCfg->prachCfg.prachSubcSpacing; + + schCellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon.pucchResourceCommon = \ + macCellCfg->initialUlBwp.pucchCommon.pucchResourceCommon; + schCellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon.pucchGroupHopping = \ + macCellCfg->initialUlBwp.pucchCommon.pucchGroupHopping; + schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \ + macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++) { - schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 = + schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 = macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2; - schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType = + schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType = macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType; - schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol = + schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol = macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol; - schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength = + schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength = macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength; } - if(macCellCfg->plmnInfoList.snssai) - { - schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice; - MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*)); - if(!schCellCfg.plmnInfoList.snssai) - { - DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq"); - return RFAILED; - } - for(sliceIdx=0; sliceIdxplmnInfoList.snssai[sliceIdx]) - { - MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai)); - if(!schCellCfg.plmnInfoList.snssai[sliceIdx]) - { - DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq"); - return RFAILED; - } - memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai)); - } - } - } - #ifdef NR_TDD memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg)); #endif + /* fill ssb scheduler parameters */ + for(ssbMaskIdx=0; ssbMaskIdxssbCfg.ssbMask[ssbMaskIdx]; + } + schCellCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod]; + schCellCfg.ssbFrequency = macCellCfg->cellCfg.ssbFreq; + schCellCfg.dmrsTypeAPos = macCellCfg->ssbCfg.dmrsTypeAPos; + schCellCfg.scsCommon = macCellCfg->ssbCfg.scsCmn; + schCellCfg.pdcchCfgSib1.coresetZeroIndex = macCellCfg->cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex; + schCellCfg.pdcchCfgSib1.searchSpaceZeroIndex = macCellCfg->cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex; + schCellCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr; + schCellCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset; + schCellCfg.sib1PduLen = macCellCfg->cellCfg.sib1Cfg.sib1PduLen; + FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG); return(SchMessageRouter(&cfgPst, (void *)&schCellCfg)); @@ -533,10 +543,10 @@ uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId) * * ****************************************************************/ uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp) { - uint8_t ret = ROK, sliceIdx = 0; + uint8_t ret = ROK, sliceIdx = 0, plmnIdx = 0; uint16_t cellIdx=0; CellDeleteStatus status; - + #ifdef CALL_FLOW_DEBUG_LOG DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n"); #endif @@ -546,31 +556,34 @@ uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp) if(schCellDelRsp->rsp == RSP_OK) { DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \ - schCellDelRsp->cellId); + schCellDelRsp->cellId); GET_CELL_IDX(schCellDelRsp->cellId, cellIdx); if(macCb.macCell[cellIdx]) { if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId) { status = SUCCESSFUL_RSP; - if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai) + for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++) { - for(sliceIdx = 0; sliceIdxmacCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++) + if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai) { - MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai)); + for(sliceIdx = 0; sliceIdxmacCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; sliceIdx++) + { + MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai)); + } + MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].\ + numSupportedSlice * sizeof(Snssai*)); } - MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\ - numSupportedSlice * sizeof(Snssai*)); } - MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \ - macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen); + MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, \ + macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen); MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb)); } else { - DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId); - status = CELL_ID_INVALID; - ret = RFAILED; + DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId); + status = CELL_ID_INVALID; + ret = RFAILED; } } else diff --git a/src/5gnrmac/mac_slot_ind.c b/src/5gnrmac/mac_slot_ind.c index fdd2669e3..042c89d2c 100644 --- a/src/5gnrmac/mac_slot_ind.c +++ b/src/5gnrmac/mac_slot_ind.c @@ -69,8 +69,6 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo) dlSlot[dlSchedInfo->schSlotValue.broadcastTime.slot]; currDlSlot->dlInfo.isBroadcastPres = true; memcpy(&currDlSlot->dlInfo.brdcstAlloc, &dlSchedInfo->brdcstAlloc, sizeof(DlBrdcstAlloc)); - currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg.dci.pdschCfg = \ - &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg; } for(ueIdx=0; ueIdxpageAllocInfo, dlPageAlloc, sizeof(DlPageAlloc)); - currDlSlot->pageAllocInfo->pagePdcchCfg.dci.pdschCfg = \ - &currDlSlot->pageAllocInfo->pagePdschCfg; } else { diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 32ab5c23f..3c8d5fe3b 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -48,6 +48,7 @@ #include "sch.h" #include "sch_utils.h" #include "sch_fcfs.h" +#include "sch_slice_based.h" /** * @brief Task Initiation function. @@ -106,6 +107,7 @@ uint8_t schActvInit(Ent entity, Inst instId, Region region, Reason reason) void schAllApisInit(Inst inst) { schFcfsAllApisInit(&schCb[inst].allApis[SCH_FCFS]); + schSliceBasedAllApisInit(&schCb[inst].allApis[SCH_SLICE_BASED]); } /** @@ -317,6 +319,48 @@ uint16_t schGetPeriodicityInMsec(DlUlTxPeriodicity tddPeriod) return periodicityInMsec; } +/** + *@brief Fills the slotCfg from CellCfg + * + * @details + * + * Function : schFillSlotConfig + * + * This API Fills the slotCfg from CellCfg + * + * @param[in] SchCellCb *cell, TDDCfg tddCfg + * @return void + * **/ +void schFillSlotConfig(SchCellCb *cell, TDDCfg tddCfg) +{ + uint8_t slotIdx = 0, symbolIdx = 0; + + for(slotIdx =0 ;slotIdx < MAX_TDD_PERIODICITY_SLOTS; slotIdx++) + { + for(symbolIdx = 0; symbolIdx < MAX_SYMB_PER_SLOT; symbolIdx++) + { + /*Fill Full-DL Slots as well as DL symbols ini 1st Flexi Slo*/ + if(slotIdx < tddCfg.nrOfDlSlots || \ + (slotIdx == tddCfg.nrOfDlSlots && symbolIdx < tddCfg.nrOfDlSymbols)) + { + cell->slotCfg[slotIdx][symbolIdx] = DL_SYMBOL; + } + + /*Fill Full-FLEXI SLOT and as well as Flexi Symbols in 1 slot preceding FULL-UL slot*/ + else if(slotIdx < (MAX_TDD_PERIODICITY_SLOTS - tddCfg.nrOfUlSlots -1) || \ + (slotIdx == (MAX_TDD_PERIODICITY_SLOTS - tddCfg.nrOfUlSlots -1) && \ + symbolIdx < (MAX_SYMB_PER_SLOT - tddCfg.nrOfUlSymbols))) + { + cell->slotCfg[slotIdx][symbolIdx] = FLEXI_SYMBOL; + } + /*Fill Partial UL symbols and Full-UL slot*/ + else + { + cell->slotCfg[slotIdx][symbolIdx] = UL_SYMBOL; + } + } + } +} /** * @brief init TDD slot config @@ -339,15 +383,15 @@ void schInitTddSlotCfg(SchCellCb *cell, SchCellCfg *schCellCfg) periodicityInMicroSec = schGetPeriodicityInMsec(schCellCfg->tddCfg.tddPeriod); cell->numSlotsInPeriodicity = (periodicityInMicroSec * pow(2, schCellCfg->numerology))/1000; cell->slotFrmtBitMap = 0; - cell->symbFrmtBitMap = 0; + schFillSlotConfig(cell, schCellCfg->tddCfg); for(slotIdx = cell->numSlotsInPeriodicity-1; slotIdx >= 0; slotIdx--) { symbIdx = 0; /* If the first and last symbol are the same, the entire slot is the same type */ - if((schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx] == schCellCfg->tddCfg.slotCfg[slotIdx][MAX_SYMB_PER_SLOT-1]) && - schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx] != FLEXI_SLOT) + if((cell->slotCfg[slotIdx][symbIdx] == cell->slotCfg[slotIdx][MAX_SYMB_PER_SLOT-1]) && + cell->slotCfg[slotIdx][symbIdx] != FLEXI_SYMBOL) { - switch(schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx]) + switch(cell->slotCfg[slotIdx][symbIdx]) { case DL_SLOT: { @@ -368,34 +412,6 @@ void schInitTddSlotCfg(SchCellCb *cell, SchCellCfg *schCellCfg) } /* slot config is flexible. First set slotBitMap to 10 */ cell->slotFrmtBitMap = ((cell->slotFrmtBitMap<<2) | (FLEXI_SLOT)); - - /* Now set symbol bitmap */ - for(symbIdx = MAX_SYMB_PER_SLOT-1; symbIdx >= 0; symbIdx--) - { - switch(schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx]) - { - case DL_SLOT: - { - /*symbol BitMap to be set to 00 */ - cell->symbFrmtBitMap = (cell->symbFrmtBitMap<<2); - break; - } - case UL_SLOT: - { - /*symbol BitMap to be set to 01 */ - cell->symbFrmtBitMap = ((cell->symbFrmtBitMap<<2) | (UL_SLOT)); - break; - } - case FLEXI_SLOT: - { - /*symbol BitMap to be set to 10 */ - cell->symbFrmtBitMap = ((cell->symbFrmtBitMap<<2) | (FLEXI_SLOT)); - break; - } - default: - DU_LOG("\nERROR --> SCH : Invalid slot Config in schInitTddSlotCfg"); - } - } } } #endif @@ -418,7 +434,7 @@ void fillSsbStartSymb(SchCellCb *cellCb) { uint8_t cnt, scs, symbIdx, ssbStartSymbArr[SCH_MAX_SSB_BEAM]; - scs = cellCb->cellCfg.ssbSchCfg.scsCommon; + scs = cellCb->cellCfg.scsCommon; memset(ssbStartSymbArr, 0, sizeof(SCH_MAX_SSB_BEAM)); symbIdx = 0; @@ -426,41 +442,40 @@ void fillSsbStartSymb(SchCellCb *cellCb) switch(scs) { case SCS_15KHZ: - { - if(cellCb->cellCfg.dlFreq <= 300000) - cnt = 2;/* n = 0, 1 */ + { + if(cellCb->cellCfg.ssbFrequency <= 300000) + cnt = 2;/* n = 0, 1 */ else cnt = 4; /* n = 0, 1, 2, 3 */ - for(uint8_t idx=0; idxcellCfg.dlFreq <= 300000) - cnt = 1;/* n = 0 */ + { + if(cellCb->cellCfg.ssbFrequency <= 300000) + cnt = 1;/* n = 0 */ else cnt = 2; /* n = 0, 1 */ - for(uint8_t idx=0; idx SCH : SCS %d is currently not supported", scs); + DU_LOG("\nERROR --> SCH : SCS %d is currently not supported", scs); } memset(cellCb->ssbStartSymbArr, 0, sizeof(SCH_MAX_SSB_BEAM)); memcpy(cellCb->ssbStartSymbArr, ssbStartSymbArr, SCH_MAX_SSB_BEAM); - } @@ -597,7 +612,8 @@ uint8_t schInitCellCb(Inst inst, SchCellCfg *schCellCfg) * uint8_t offsetPointA : offset * @return void **/ -void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg *sib1SchCfg, uint16_t pci, uint8_t offsetPointA) +uint8_t fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots,SchPdcchConfigSib1 *pdcchCfgSib1,\ + SchSib1Cfg *sib1SchCfg, uint16_t pci, uint8_t offsetPointA, uint16_t sib1PduLen) { uint8_t coreset0Idx = 0; uint8_t searchSpace0Idx = 0; @@ -613,13 +629,15 @@ void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg uint8_t FreqDomainResource[FREQ_DOM_RSRC_SIZE] = {0}; uint16_t tbSize = 0; uint8_t ssbIdx = 0; + PdcchCfg *pdcch; + PdschCfg *pdsch; + BwpCfg *bwp; - PdcchCfg *pdcch = &(sib1SchCfg->sib1PdcchCfg); - PdschCfg *pdsch = &(sib1SchCfg->sib1PdschCfg); - BwpCfg *bwp = &(sib1SchCfg->bwp); + pdcch = &(sib1SchCfg->sib1PdcchCfg); + bwp = &(sib1SchCfg->bwp); - coreset0Idx = sib1SchCfg->coresetZeroIndex; - searchSpace0Idx = sib1SchCfg->searchSpaceZeroIndex; + coreset0Idx = pdcchCfgSib1->coresetZeroIndex; + searchSpace0Idx = pdcchCfgSib1->searchSpaceZeroIndex; /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */ //ssbMuxPattern = coresetIdxTable[coreset0Idx][0]; @@ -688,11 +706,17 @@ void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg pdcch->dci.beamPdcchInfo.digBfInterfaces = 0; pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0; pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0; - pdcch->dci.txPdcchPower.powerValue = 0; + pdcch->dci.txPdcchPower.beta_pdcch_1_0= 0; pdcch->dci.txPdcchPower.powerControlOffsetSS = 0; /* Storing pdschCfg pointer here. Required to access pdsch config while fillig up pdcch pdu */ - pdcch->dci.pdschCfg = pdsch; + SCH_ALLOC(pdcch->dci.pdschCfg, sizeof(PdschCfg)); + if(pdcch->dci.pdschCfg == NULLP) + { + DU_LOG("\nERROR --> SCH : Memory allocation failed in %s ", __func__); + return RFAILED; + } + pdsch = pdcch->dci.pdschCfg; /* fill the PDSCH PDU */ uint8_t cwCount = 0; @@ -704,17 +728,17 @@ void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg { pdsch->codeword[cwCount].targetCodeRate = 308; pdsch->codeword[cwCount].qamModOrder = 2; - pdsch->codeword[cwCount].mcsIndex = sib1SchCfg->sib1Mcs; + pdsch->codeword[cwCount].mcsIndex = DEFAULT_MCS; pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */ pdsch->codeword[cwCount].rvIndex = 0; - tbSize = schCalcTbSize(sib1SchCfg->sib1PduLen + TX_PAYLOAD_HDR_LEN); + tbSize = schCalcTbSize(sib1PduLen + TX_PAYLOAD_HDR_LEN); pdsch->codeword[cwCount].tbSize = tbSize; } pdsch->dataScramblingId = pci; pdsch->numLayers = 1; pdsch->transmissionScheme = 0; pdsch->refPoint = 0; - pdsch->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */ + pdsch->dmrs.dlDmrsSymbPos = DL_DMRS_SYMBOL_POS; pdsch->dmrs.dmrsConfigType = 0; /* type-1 */ pdsch->dmrs.dlDmrsScramblingId = pci; pdsch->dmrs.scid = 0; @@ -726,13 +750,13 @@ void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ - pdsch->pdschFreqAlloc.freqAlloc.startPrb = offsetPointA + SCH_SSB_NUM_PRB; - pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize,sib1SchCfg->sib1Mcs, NUM_PDSCH_SYMBOL); + pdsch->pdschFreqAlloc.startPrb = offsetPointA + SCH_SSB_NUM_PRB; + pdsch->pdschFreqAlloc.numPrb = schCalcNumPrb(tbSize, DEFAULT_MCS, NUM_PDSCH_SYMBOL); pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ pdsch->pdschTimeAlloc.rowIndex = 1; /* This is Intel's requirement. PDSCH should start after PDSCH DRMS symbol */ - pdsch->pdschTimeAlloc.timeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */ - pdsch->pdschTimeAlloc.timeAlloc.numSymb = NUM_PDSCH_SYMBOL; + pdsch->pdschTimeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */ + pdsch->pdschTimeAlloc.numSymb = NUM_PDSCH_SYMBOL; pdsch->beamPdschInfo.numPrgs = 1; pdsch->beamPdschInfo.prgSize = 1; pdsch->beamPdschInfo.digBfInterfaces = 0; @@ -741,6 +765,7 @@ void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg pdsch->txPdschPower.powerControlOffset = 0; pdsch->txPdschPower.powerControlOffsetSS = 0; + return ROK; } /** @@ -776,37 +801,53 @@ uint8_t SchProcCellCfgReq(Pst *pst, SchCellCfg *schCellCfg) cellCb->macInst = pst->srcInst; /* derive the SIB1 config parameters */ - fillSchSib1Cfg(schCellCfg->numerology, schCellCfg->bandwidth, cellCb->numSlots, - &(schCellCfg->sib1SchCfg), schCellCfg->phyCellId, - schCellCfg->ssbSchCfg.ssbOffsetPointA); - + ret = fillSchSib1Cfg(schCellCfg->numerology, schCellCfg->dlBandwidth, cellCb->numSlots, + &(schCellCfg->pdcchCfgSib1), &(cellCb->sib1SchCfg), schCellCfg->phyCellId, + schCellCfg->dlCfgCommon.schFreqInfoDlSib.offsetToPointA, schCellCfg->sib1PduLen); + if(ret != ROK) + { + DU_LOG("\nERROR --> SCH : Failed to fill sib1 configuration"); + return RFAILED; + } memcpy(&cellCb->cellCfg, schCellCfg, sizeof(SchCellCfg)); schProcPagingCfg(cellCb); /* Fill coreset frequencyDomainResource bitmap */ - coreset0Idx = cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId; + coreset0Idx = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId; numRbs = coresetIdxTable[coreset0Idx][1]; offset = coresetIdxTable[coreset0Idx][3]; - fillCoresetFeqDomAllocMap(((cellCb->cellCfg.ssbSchCfg.ssbOffsetPointA - offset)/6), (numRbs/6), freqDomainResource); + fillCoresetFeqDomAllocMap(((cellCb->cellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA - offset)/6), \ + (numRbs/6), freqDomainResource); covertFreqDomRsrcMapToIAPIFormat(freqDomainResource, \ - cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc); + cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc); /* Fill K0 - K1 table for common cfg*/ - BuildK0K1Table(cellCb, &cellCb->cellCfg.schInitialDlBwp.k0K1InfoTbl, true, cellCb->cellCfg.schInitialDlBwp.pdschCommon, - pdschCfg, DEFAULT_UL_ACK_LIST_COUNT, defaultUlAckTbl); + BuildK0K1Table(cellCb, &cellCb->k0K1InfoTbl, true, cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon, + pdschCfg, DEFAULT_UL_ACK_LIST_COUNT, defaultUlAckTbl); - BuildK2InfoTable(cellCb, cellCb->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList,\ - cellCb->cellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc, &cellCb->cellCfg.schInitialUlBwp.msg3K2InfoTbl, \ - &cellCb->cellCfg.schInitialUlBwp.k2InfoTbl); + BuildK2InfoTable(cellCb, cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList,\ + cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc, &cellCb->msg3K2InfoTbl, \ + &cellCb->k2InfoTbl); + + /*As per Spec 38.211, Sec 6.3.3.2; RootSeq Len(Lra) where Lra=839 or Lra=139, + *depending on the PRACH preamble format as given by Tables 6.3.3.1-1 and 6.3.3.1-2.*/ + if(prachCfgIdxTable[cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.prachCfgIdx][0] <= 3) + { + cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rootSeqLen = ROOT_SEQ_LEN_1; + } + else + { + cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rootSeqLen = ROOT_SEQ_LEN_2; + } /* Initializing global variables */ cellCb->actvUeBitMap = 0; cellCb->boIndBitMap = 0; - cellCb->cellCfg.schHqCfg.maxDlDataHqTx = SCH_MAX_NUM_DL_HQ_TX; - cellCb->cellCfg.schHqCfg.maxMsg4HqTx = SCH_MAX_NUM_MSG4_TX; - cellCb->cellCfg.schHqCfg.maxUlDataHqTx = SCH_MAX_NUM_UL_HQ_TX; - cellCb->cellCfg.schRachCfg.maxMsg3Tx = SCH_MAX_NUM_MSG3_TX; + cellCb->schHqCfg.maxDlDataHqTx = SCH_MAX_NUM_DL_HQ_TX; + cellCb->schHqCfg.maxMsg4HqTx = SCH_MAX_NUM_MSG4_TX; + cellCb->schHqCfg.maxUlDataHqTx = SCH_MAX_NUM_UL_HQ_TX; + cellCb->maxMsg3Tx = SCH_MAX_NUM_MSG3_TX; cellCb->schAlgoType = SCH_FCFS; cellCb->api = &schCb[inst].allApis[cellCb->schAlgoType]; /* For FCFS */ @@ -882,7 +923,7 @@ uint8_t SchSendCellDeleteRspToMac(SchCellDeleteReq *ueDelete, Inst inst, SchMac * ****************************************************************/ void deleteSchCellCb(SchCellCb *cellCb) { - uint8_t sliceIdx=0, slotIdx=0; + uint8_t sliceIdx=0, slotIdx=0, plmnIdx = 0; CmLListCp *list=NULL; CmLList *node=NULL, *next=NULL; SchPageInfo *tempNode = NULLP; @@ -923,15 +964,19 @@ void deleteSchCellCb(SchCellCb *cellCb) SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*)); } - if(cellCb->cellCfg.plmnInfoList.snssai) + for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++) { - for(sliceIdx=0; sliceIdxcellCfg.plmnInfoList.numSliceSupport; sliceIdx++) + if(cellCb->cellCfg.plmnInfoList[plmnIdx].snssai) { - SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai)); + for(sliceIdx=0; sliceIdxcellCfg.plmnInfoList[plmnIdx].numSliceSupport; sliceIdx++) + { + SCH_FREE(cellCb->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai)); + } + SCH_FREE(cellCb->cellCfg.plmnInfoList[plmnIdx].snssai, cellCb->cellCfg.plmnInfoList[plmnIdx].numSliceSupport*sizeof(Snssai*)); } - SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai, cellCb->cellCfg.plmnInfoList.numSliceSupport*sizeof(Snssai*)); } - + SCH_FREE(cellCb->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg, sizeof(PdschCfg)); + for(uint16_t idx =0; idxpageCb.pageIndInfoRecord[idx]; @@ -1290,18 +1335,18 @@ uint8_t allocatePrbDl(SchCellCb *cell, SlotTimingInfo slotTime, \ if(ssbOccasion && sib1Occasion) { - broadcastPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; - broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1; + broadcastPrbStart = cell->cellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA; + broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB + cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc.numPrb -1; } else if(ssbOccasion) { - broadcastPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; + broadcastPrbStart = cell->cellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA; broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB -1; } else if(sib1Occasion) { - broadcastPrbStart = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.startPrb; - broadcastPrbEnd = broadcastPrbStart + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1; + broadcastPrbStart = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc.startPrb; + broadcastPrbEnd = broadcastPrbStart + cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc.numPrb -1; } /* Iterate through all free PRB blocks */ @@ -1433,7 +1478,7 @@ uint8_t allocatePrbUl(SchCellCb *cell, SlotTimingInfo slotTime, \ isPrachOccasion = schCheckPrachOcc(cell, slotTime); if(isPrachOccasion) { - prachStartPrb = cell->cellCfg.schRachCfg.msg1FreqStart; + prachStartPrb = cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1FreqStart; prachNumPrb = schCalcPrachNumRb(cell); prachEndPrb = prachStartPrb + prachNumPrb -1; } @@ -1567,19 +1612,19 @@ uint16_t searchLargestFreeBlock(SchCellCb *cell, SlotTimingInfo slotTime,uint16_ checkOccasion = TRUE; if(ssbOccasion && sib1Occasion) { - reservedPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; + reservedPrbStart = cell->cellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA; reservedPrbEnd = reservedPrbStart + SCH_SSB_NUM_PRB + \ - cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1; + cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc.numPrb -1; } else if(ssbOccasion) { - reservedPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; + reservedPrbStart = cell->cellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA; reservedPrbEnd = reservedPrbStart + SCH_SSB_NUM_PRB -1; } else if(sib1Occasion) { - reservedPrbStart = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.startPrb; - reservedPrbEnd = reservedPrbStart + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1; + reservedPrbStart = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc.startPrb; + reservedPrbEnd = reservedPrbStart + cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc.numPrb -1; } else { @@ -1594,7 +1639,7 @@ uint16_t searchLargestFreeBlock(SchCellCb *cell, SlotTimingInfo slotTime,uint16_ checkOccasion = schCheckPrachOcc(cell, slotTime); if(checkOccasion) { - reservedPrbStart = cell->cellCfg.schRachCfg.msg1FreqStart; + reservedPrbStart = cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1FreqStart; reservedPrbEnd = reservedPrbStart + (schCalcPrachNumRb(cell)) -1; } } @@ -1703,7 +1748,7 @@ void SchSendSliceCfgRspToMac(Inst inst, SchSliceCfgRsp sliceCfgRsp) uint8_t fillSliceCfgRsp(bool sliceRecfg, SchSliceCfg *storedSliceCfg, SchCellCb *cellCb, SchSliceCfgReq *schSliceCfgReq, SchSliceCfgRsp *schSliceCfgRsp, uint8_t *count) { bool sliceFound = false; - uint8_t cfgIdx = 0, sliceIdx = 0; + uint8_t cfgIdx = 0, sliceIdx = 0, plmnIdx = 0; schSliceCfgRsp->numSliceCfgRsp = schSliceCfgReq->numOfConfiguredSlice; SCH_ALLOC(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*)); @@ -1712,19 +1757,26 @@ uint8_t fillSliceCfgRsp(bool sliceRecfg, SchSliceCfg *storedSliceCfg, SchCellCb DU_LOG("\nERROR --> SCH : Memory allocation failed at fillSliceCfgRsp"); return RFAILED; } - + for(cfgIdx = 0; cfgIdxnumSliceCfgRsp ; cfgIdx++) { sliceFound = false; /* Here comparing the slice cfg request with the slice stored in cellCfg */ if(sliceRecfg != true) { - for(sliceIdx = 0; sliceIdxcellCfg.plmnInfoList.numSliceSupport; sliceIdx++) + for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++) { - if(!memcmp(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, cellCb->cellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai))) + for(sliceIdx = 0; sliceIdxcellCfg.plmnInfoList[plmnIdx].numSliceSupport; sliceIdx++) + { + if(!memcmp(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, cellCb->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai))) + { + (*count)++; + sliceFound = true; + break; + } + } + if(sliceFound == true) { - (*count)++; - sliceFound = true; break; } } @@ -1754,7 +1806,7 @@ uint8_t fillSliceCfgRsp(bool sliceRecfg, SchSliceCfg *storedSliceCfg, SchCellCb return RFAILED; } - + schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgReq->listOfSlices[cfgIdx]->snssai; if(sliceFound == true) schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = RSP_OK; @@ -2064,10 +2116,10 @@ uint8_t SchProcSliceRecfgReq(Pst *pst, SchSliceRecfgReq *schSliceRecfgReq) *************************************************************************/ void schProcPagingCfg(SchCellCb *cell) { - PageCfg *pageCfgRcvd = NULL; + SchPcchCfg *pageCfgRcvd = NULL; uint8_t i_sIdx = 0; - pageCfgRcvd = &(cell->cellCfg.sib1SchCfg.pageCfg); + pageCfgRcvd = &(cell->cellCfg.dlCfgCommon.schPcchCfg); if(pageCfgRcvd->poPresent == TRUE) { @@ -2109,8 +2161,8 @@ void schProcPagingCfg(SchCellCb *cell) void schCfgPdcchMonOccOfPO(SchCellCb *cell) { uint8_t cnt = 0, incr = 1, i_sIdx = 0, frameOffSet = 0; - uint8_t nsValue = cell->cellCfg.sib1SchCfg.pageCfg.numPO; - uint8_t totalNumSsb = cell->cellCfg.ssbSchCfg.totNumSsb; + uint8_t nsValue = cell->cellCfg.dlCfgCommon.schPcchCfg.numPO; + uint8_t totalNumSsb = countSetBits(cell->cellCfg.ssbPosInBurst[0]); SlotTimingInfo tmpTimingInfo, pdcchTime; /*Starting with First Sfn and slot*/ @@ -2249,7 +2301,7 @@ uint8_t SchProcPagingInd(Pst *pst, SchPageInd *pageInd) } if(cellCb) { - if(pageInd->i_s > cellCb->cellCfg.sib1SchCfg.pageCfg.numPO) + if(pageInd->i_s > cellCb->cellCfg.dlCfgCommon.schPcchCfg.numPO) { DU_LOG("\nERROR --> SCH : SchProcPagingInd(): i_s should not be greater than number of paging occasion"); } diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index 5b2da4045..44149aad1 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -68,6 +68,8 @@ #define HQ_ACK 0 #define HQ_NACK 1 #define HQ_DTX 2 +#define ROOT_SEQ_LEN_1 139 +#define ROOT_SEQ_LEN_2 839 #ifdef NR_DRX /* As per 38.331 the largest offset which can be used in of size 10240. @@ -76,7 +78,7 @@ #define MAX_DRX_SIZE 512 #endif -#define NUM_SCH_TYPE 1 /*Supported number of Scheduler Algorithm types*/ +#define NUM_SCH_TYPE 2 /*Supported number of Scheduler Algorithm types*/ typedef struct schDlHqProcCb SchDlHqProcCb; typedef struct schUlHqEnt SchUlHqEnt; @@ -87,7 +89,8 @@ typedef struct schUeCb SchUeCb; typedef enum { - SCH_FCFS + SCH_FCFS, + SCH_SLICE_BASED }SchType; typedef enum @@ -134,6 +137,22 @@ typedef enum HQ_TB_WAITING }SchHqTbState; +#ifdef NR_TDD +typedef enum +{ + DL_SLOT, + UL_SLOT, + FLEXI_SLOT +}SlotConfig; + +typedef enum +{ + DL_SYMBOL, + UL_SYMBOL, + FLEXI_SYMBOL +}SchSymbolConfig; +#endif + /*Following structures to keep record and estimations of PRB allocated for each * LC taking into consideration the RRM policies*/ typedef struct lcInfo @@ -561,6 +580,23 @@ typedef struct schAllApis uint8_t (* SchScheduleUlLc)(SlotTimingInfo dciTime, SlotTimingInfo puschTime, uint8_t startStmb, \ uint8_t symbLen, bool isRetx, SchUlHqProcCb **hqP); }SchAllApis; + +typedef struct schHqCfgParam +{ + uint8_t maxDlDataHqTx; + uint8_t maxMsg4HqTx; + uint8_t maxUlDataHqTx; +}SchHqCfg; + +typedef struct +{ + /* parameters derived in scheduler */ + uint8_t n0; + BwpCfg bwp; + PdcchCfg sib1PdcchCfg; + PdschCfg sib1PdschCfg; +}SchSib1Cfg; + /** * @brief * Cell Control block per cell. @@ -589,7 +625,7 @@ typedef struct schCellCb #ifdef NR_TDD uint8_t numSlotsInPeriodicity; /*!< number of slots in configured periodicity and SCS */ uint32_t slotFrmtBitMap; /*!< 2 bits must be read together to determine D/U/S slots. 00-D, 01-U, 10-S */ - uint32_t symbFrmtBitMap; /*!< 2 bits must be read together to determine D/U/S symbols. 00-D, 01-U, 10-S */ + SchSymbolConfig slotCfg[MAX_TDD_PERIODICITY_SLOTS][MAX_SYMB_PER_SLOT]; #endif #ifdef NR_DRX SchDrxCb drxCb[MAX_DRX_SIZE]; /*!< Drx cb*/ @@ -597,6 +633,12 @@ typedef struct schCellCb SchType schAlgoType; /*!< The scheduler type which the cell is configured with.*/ SchAllApis *api; /*!< Reference of sch APIs for this cell based on the SchType*/ void *schSpcCell; /*Ref of Scheduler specific structure*/ + SchHqCfg schHqCfg; + SchK0K1TimingInfoTbl k0K1InfoTbl; + SchK2TimingInfoTbl msg3K2InfoTbl; + SchK2TimingInfoTbl k2InfoTbl; + SchSib1Cfg sib1SchCfg; /* SIB1 config */ + uint8_t maxMsg3Tx; /* MAximum num of msg3 tx*/ }SchCellCb; @@ -703,7 +745,7 @@ void updateBsrAndLcList(CmLListCp *lcLL, BsrInfo *bsrInfo, uint8_t status); void schProcPagingCfg(SchCellCb *cell); void schCfgPdcchMonOccOfPO(SchCellCb *cell); void schIncrSlot(SlotTimingInfo *timingInfo, uint8_t incr, uint16_t numSlotsPerRF); -uint8_t schFillPagePdschCfg(SchCellCb *cell, PdschCfg *pagePdschCfg, SlotTimingInfo slotTime, \ +uint8_t schFillPagePdschCfg(SchCellCb *cell, PageDlSch *pageDlSch, SlotTimingInfo slotTime, \ uint16_t tbSize, uint8_t mcs, uint16_t startPrb); /*DL HARQ Functions*/ void schDlHqEntInit(SchCellCb *cellCb, SchUeCb *ueCb); diff --git a/src/5gnrsch/sch_common.c b/src/5gnrsch/sch_common.c index 7fa1314e6..cb97e8f6e 100644 --- a/src/5gnrsch/sch_common.c +++ b/src/5gnrsch/sch_common.c @@ -77,7 +77,7 @@ uint8_t schBroadcastSsbAlloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcstA } schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot]; - ssbStartPrb = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; //+Kssb + ssbStartPrb = cell->cellCfg.ssbSubcOffset; //+Kssb ssbStartSymb = cell->ssbStartSymbArr[dlBrdcstAlloc->ssbIdxSupported-1]; /*since we are supporting only 1 ssb beam */ /* Assign interface structure */ @@ -121,8 +121,8 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst { uint8_t dmrsStartSymbol, startSymbol, numSymbol ; DmrsInfo dmrs; - ResAllocType1 freqAlloc; - TimeDomainAlloc timeAlloc; + PdschFreqAlloc freqAlloc; + PdschTimeAlloc timeAlloc; SchDlSlotInfo *schDlSlotInfo = NULLP; if(cell == NULL) @@ -136,10 +136,11 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst DU_LOG("\nERROR --> SCH: schBroadcastSsbAlloc() : dlBrdcstAlloc is NULL"); return RFAILED; } - - dmrs = cell->cellCfg.sib1SchCfg.sib1PdschCfg.dmrs; - freqAlloc = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc; - timeAlloc = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschTimeAlloc.timeAlloc; + + dlBrdcstAlloc->crnti = SI_RNTI; + dmrs = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->dmrs; + freqAlloc = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc; + timeAlloc = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschTimeAlloc; schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot]; /* Find total symbols used including DMRS */ @@ -165,10 +166,8 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst return RFAILED; } - memcpy(&dlBrdcstAlloc->sib1Alloc.bwp, &cell->cellCfg.sib1SchCfg.bwp, sizeof(BwpCfg)); - memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->cellCfg.sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg)); - memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdschCfg, &cell->cellCfg.sib1SchCfg.sib1PdschCfg, sizeof(PdschCfg)); - dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg.dci.pdschCfg = &dlBrdcstAlloc->sib1Alloc.sib1PdschCfg; + memcpy(&dlBrdcstAlloc->sib1Alloc.bwp, &cell->sib1SchCfg.bwp, sizeof(BwpCfg)); + memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg)); schDlSlotInfo->sib1Pres = true; return ROK; } @@ -434,9 +433,9 @@ uint16_t fillPucchResourceInfo(uint8_t ueId, SchPucchInfo *schPucchInfo, Inst in { /* fill pucch common cfg */ /* derive pucchResourceSet from schCellCfg */ - pucchCfg = &cell->cellCfg.schInitialUlBwp.pucchCommon; + pucchCfg = &cell->cellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon; pucchIdx = pucchCfg->pucchResourceCommon; - ulBwp = &cell->cellCfg.schInitialUlBwp.bwp; + ulBwp = &cell->cellCfg.ulCfgCommon.schInitialUlBwp.bwp; startPrb = ulBwp->freqAlloc.startPrb + pucchResourceSet[pucchIdx][3]; ret = allocatePrbUl(cell, slotInfo, pucchResourceSet[pucchIdx][1], pucchResourceSet[pucchIdx][2],\ &startPrb, PUCCH_NUM_PRB_FORMAT_0_1_4); @@ -586,7 +585,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI } msg4Alloc = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo]; - initialBwp = &cell->cellCfg.schInitialDlBwp; + initialBwp = &cell->cellCfg.dlCfgCommon.schInitialDlBwp; pdcch = &msg4Alloc->dlMsgPdcchCfg; pdsch = &msg4Alloc->dlMsgPdschCfg; bwp = &msg4Alloc->bwp; @@ -619,7 +618,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI pdcch->coresetCfg.startSymbolIndex = firstSymbol; pdcch->coresetCfg.durationSymbols = numSymbols; memcpy(pdcch->coresetCfg.freqDomainResource, \ - cell->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); + cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); pdcch->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */ pdcch->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */ @@ -639,7 +638,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI pdcch->dci.beamPdcchInfo.digBfInterfaces = 0; pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0; pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0; - pdcch->dci.txPdcchPower.powerValue = 0; + pdcch->dci.txPdcchPower.beta_pdcch_1_0 = 0; pdcch->dci.txPdcchPower.powerControlOffsetSS = 0; pdcch->dci.pdschCfg = pdsch; @@ -672,7 +671,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI pdsch->numLayers = 1; pdsch->transmissionScheme = 0; pdsch->refPoint = 0; - pdsch->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */ + pdsch->dmrs.dlDmrsSymbPos = DL_DMRS_SYMBOL_POS; pdsch->dmrs.dmrsConfigType = 0; /* type-1 */ pdsch->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId; pdsch->dmrs.scid = 0; @@ -682,12 +681,12 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; - pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschStartSymbol; - pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschNumSymbols; + pdsch->pdschTimeAlloc.startSymb = pdschStartSymbol; + pdsch->pdschTimeAlloc.numSymb = pdschNumSymbols; pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ - pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB; - pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, pdschNumSymbols); + pdsch->pdschFreqAlloc.startPrb = MAX_NUM_RB; + pdsch->pdschFreqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, pdschNumSymbols); pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ /* Find total symbols occupied including DMRS */ @@ -696,19 +695,19 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pdsch->pdschTimeAlloc.startSymb; + numSymbol = pdsch->pdschTimeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.numSymb; } /* Allocate the number of PRBs required for RAR PDSCH */ if((allocatePrbDl(cell, msg4Time, startSymbol, numSymbol,\ - &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pdsch->pdschFreqAlloc.startPrb, pdsch->pdschFreqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : Resource allocation failed for MSG4"); return RFAILED; @@ -810,8 +809,8 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c /* fill BWP */ bwp->freqAlloc.numPrb = MAX_NUM_RB; bwp->freqAlloc.startPrb = 0; - bwp->subcarrierSpacing = cell->cellCfg.sib1SchCfg.bwp.subcarrierSpacing; - bwp->cyclicPrefix = cell->cellCfg.sib1SchCfg.bwp.cyclicPrefix; + bwp->subcarrierSpacing = cell->sib1SchCfg.bwp.subcarrierSpacing; + bwp->cyclicPrefix = cell->sib1SchCfg.bwp.cyclicPrefix; /* fill the PDCCH PDU */ //Considering coreset1 also starts from same symbol as coreset0 @@ -837,7 +836,7 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c pdcch->dci.beamPdcchInfo.digBfInterfaces = 0; pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0; pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0; - pdcch->dci.txPdcchPower.powerValue = 0; + pdcch->dci.txPdcchPower.beta_pdcch_1_0 = 0; pdcch->dci.txPdcchPower.powerControlOffsetSS = 0; /* fill the PDSCH PDU */ @@ -865,7 +864,7 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c pdsch->numLayers = 1; pdsch->transmissionScheme = 0; pdsch->refPoint = 0; - pdsch->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */ + pdsch->dmrs.dlDmrsSymbPos = DL_DMRS_SYMBOL_POS; pdsch->dmrs.dmrsConfigType = 0; /* type-1 */ pdsch->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId; pdsch->dmrs.scid = 0; @@ -875,13 +874,13 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; pdsch->dmrs.dmrsAddPos = pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos; - pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschStartSymbol; - pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschNumSymbols; + pdsch->pdschTimeAlloc.startSymb = pdschStartSymbol; + pdsch->pdschTimeAlloc.numSymb = pdschNumSymbols; pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ - pdsch->pdschFreqAlloc.freqAlloc.startPrb = startPRB; /*Start PRB will be already known*/ - pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, ueCb.ueCfg.dlModInfo.mcsIndex, pdschNumSymbols); + pdsch->pdschFreqAlloc.startPrb = startPRB; /*Start PRB will be already known*/ + pdsch->pdschFreqAlloc.numPrb = schCalcNumPrb(tbSize, ueCb.ueCfg.dlModInfo.mcsIndex, pdschNumSymbols); /* Find total symbols occupied including DMRS */ dmrsStartSymbol = findDmrsStartSymbol(pdsch->dmrs.dlDmrsSymbPos); @@ -889,19 +888,19 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pdsch->pdschTimeAlloc.startSymb; + numSymbol = pdsch->pdschTimeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.numSymb; } /* Allocate the number of PRBs required for DL PDSCH */ if((allocatePrbDl(cell, slotTime, startSymbol, numSymbol,\ - &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pdsch->pdschFreqAlloc.startPrb, pdsch->pdschFreqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : allocatePrbDl() failed for DL MSG"); return RFAILED; @@ -1073,7 +1072,7 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) /* Initialization the K0K1 structure, total num of slot and calculating the slot pattern length. */ memset(k0K1InfoTbl, 0, sizeof(SchK0K1TimingInfoTbl)); k0K1InfoTbl->tblSize = cell->numSlots; - totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); /* Storing time domain resource allocation list based on common or * dedicated configuration availability. */ @@ -1103,7 +1102,8 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) { continue; } - + + ulSlotPresent = false; /* Storing K0 , start symbol and length symbol for further processing. * If K0 value is not available then we can fill the default values * given in spec 38.331. */ @@ -1144,14 +1144,21 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) { for(checkSymbol = startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[tmpSlot][checkSymbol]; + slotCfg = cell->slotCfg[tmpSlot][checkSymbol]; if(slotCfg == UL_SLOT) { - continue; + ulSlotPresent = true; + break; } } + if(ulSlotPresent == true) + { + continue; + } } + ulSlotPresent = false; //Re-initializing + /* If current slot + k0 + k1 is a DL slot then skip the slot * else if it is UL slot then store the information * else if it is FLEXI slot then check the symbols, it must have @@ -1172,7 +1179,7 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) { for(checkSymbol = 0; checkSymbol< MAX_SYMB_PER_SLOT;checkSymbol++) { - if(cell->cellCfg.tddCfg.slotCfg[tmpSlot][checkSymbol] == UL_SLOT) + if(cell->slotCfg[tmpSlot][checkSymbol] == UL_SYMBOL) { ulSlotPresent = true; break; @@ -1295,7 +1302,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) k2InfoTbl->tblSize = cell->numSlots; if(msg3K2InfoTbl) msg3K2InfoTbl->tblSize = cell->numSlots; - totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); /* Checking all possible indexes for K2. */ for(slotIdx = 0; slotIdx < cell->numSlots; slotIdx++) @@ -1313,7 +1320,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) k2Val = timeDomRsrcAllocList[k2Index].k2; if(!k2Val) { - switch(cell->cellCfg.ssbSchCfg.scsCommon) + switch(cell->cellCfg.scsCommon) { case SCS_15KHZ: k2Val = DEFAULT_K2_VALUE_FOR_SCS15; @@ -1344,7 +1351,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) dlSymbolPresent = false; for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[k2TmpVal][checkSymbol]; + currentSymbol = cell->slotCfg[k2TmpVal][checkSymbol]; if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) { dlSymbolPresent = true; @@ -1380,7 +1387,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) dlSymbolPresent = false; for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[msg3K2TmpVal][checkSymbol]; + currentSymbol = cell->slotCfg[msg3K2TmpVal][checkSymbol]; if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) { dlSymbolPresent = true; @@ -1640,11 +1647,7 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc,\ lcNode->lcId,lcNode->reqBO, dlMsgSchInfo->numLc, *accumalatedBOSize); dlMsgSchInfo->numLc++; - /* The LC has been fully allocated, clean it */ - if(lcNode->reqBO == 0) - { - handleLcLList(lcLL, lcNode->lcId, DELETE); - } + handleLcLList(lcLL, lcNode->lcId, DELETE); } else if(bsrInfo != NULLP) { @@ -1952,7 +1955,7 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.k2TblPrsnt) k2InfoTbl = &ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.k2InfoTbl; else - k2InfoTbl = &cell->cellCfg.schInitialUlBwp.k2InfoTbl; + k2InfoTbl = &cell->k2InfoTbl; for(k2TblIdx = 0; k2TblIdx < k2InfoTbl->k2TimingInfo[dciTime.slot].numK2; k2TblIdx++) { @@ -1960,9 +1963,9 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId if(!ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.k2TblPrsnt) { - k2Val = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; - startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; - symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; + k2Val = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; + startSymb = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; + symbLen = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; } else { @@ -2053,86 +2056,203 @@ void schIncrSlot(SlotTimingInfo *timingInfo, uint8_t incr, uint16_t numSlotsPerR * @return pointer to return Value(ROK, RFAILED) * * ****************************************************************/ -uint8_t schFillPagePdschCfg(SchCellCb *cell, PdschCfg *pagePdschCfg, SlotTimingInfo slotTime, uint16_t tbSize, uint8_t mcs, uint16_t startPrb) +uint8_t schFillPagePdschCfg(SchCellCb *cell, PageDlSch *pageDlSch, SlotTimingInfo slotTime, uint16_t tbSize, uint8_t mcs, uint16_t startPrb) { - uint8_t cwCount = 0; uint8_t dmrsStartSymbol, startSymbol, numSymbol; /* fill the PDSCH PDU */ - pagePdschCfg->pduBitmap = 0; /* PTRS and CBG params are excluded */ - pagePdschCfg->rnti = P_RNTI; /* SI-RNTI */ - pagePdschCfg->pduIndex = 0; - pagePdschCfg->numCodewords = 1; - for(cwCount = 0; cwCount < pagePdschCfg->numCodewords; cwCount++) - { - pagePdschCfg->codeword[cwCount].targetCodeRate = 308; - pagePdschCfg->codeword[cwCount].qamModOrder = 2; - pagePdschCfg->codeword[cwCount].mcsIndex = mcs; - pagePdschCfg->codeword[cwCount].mcsTable = 0; /* notqam256 */ - pagePdschCfg->codeword[cwCount].rvIndex = 0; - tbSize = tbSize + TX_PAYLOAD_HDR_LEN; - pagePdschCfg->codeword[cwCount].tbSize = tbSize; - } - pagePdschCfg->dataScramblingId = cell->cellCfg.phyCellId; - pagePdschCfg->numLayers = 1; - pagePdschCfg->transmissionScheme = 0; - pagePdschCfg->refPoint = 0; - pagePdschCfg->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */ - pagePdschCfg->dmrs.dmrsConfigType = 0; /* type-1 */ - pagePdschCfg->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId; - pagePdschCfg->dmrs.scid = 0; - pagePdschCfg->dmrs.numDmrsCdmGrpsNoData = 1; - pagePdschCfg->dmrs.dmrsPorts = 0x0001; - pagePdschCfg->dmrs.mappingType = DMRS_MAP_TYPE_A; /* Type-A */ - pagePdschCfg->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; - pagePdschCfg->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; - - pagePdschCfg->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ + pageDlSch->tbInfo.mcs = mcs; + tbSize = tbSize + TX_PAYLOAD_HDR_LEN; + pageDlSch->tbInfo.tbSize = tbSize; + pageDlSch->dmrs.dmrsType = 0; /* type-1 */ + pageDlSch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; + pageDlSch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; + /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ - pagePdschCfg->pdschFreqAlloc.freqAlloc.startPrb = startPrb; - pagePdschCfg->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, NUM_PDSCH_SYMBOL); - pagePdschCfg->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ - pagePdschCfg->pdschTimeAlloc.rowIndex = 1; + pageDlSch->freqAlloc.startPrb = startPrb; + pageDlSch->freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, NUM_PDSCH_SYMBOL); + pageDlSch->vrbPrbMapping = 0; /* non-interleaved */ /* This is Intel's requirement. PDSCH should start after PDSCH DRMS symbol */ - pagePdschCfg->pdschTimeAlloc.timeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */ - pagePdschCfg->pdschTimeAlloc.timeAlloc.numSymb = NUM_PDSCH_SYMBOL; + pageDlSch->timeAlloc.mappingType = DMRS_MAP_TYPE_A; /* Type-A */ + pageDlSch->timeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */ + pageDlSch->timeAlloc.numSymb = NUM_PDSCH_SYMBOL; /* Find total symbols occupied including DMRS */ - dmrsStartSymbol = findDmrsStartSymbol(pagePdschCfg->dmrs.dlDmrsSymbPos); + dmrsStartSymbol = findDmrsStartSymbol(4); /* If there are no DRMS symbols, findDmrsStartSymbol() returns MAX_SYMB_PER_SLOT, * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pagePdschCfg->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pagePdschCfg->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pageDlSch->timeAlloc.startSymb; + numSymbol = pageDlSch->timeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pagePdschCfg->dmrs.nrOfDmrsSymbols + pagePdschCfg->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pageDlSch->dmrs.nrOfDmrsSymbols + pageDlSch->timeAlloc.numSymb; } /* Allocate the number of PRBs required for DL PDSCH */ if((allocatePrbDl(cell, slotTime, startSymbol, numSymbol,\ - &pagePdschCfg->pdschFreqAlloc.freqAlloc.startPrb, pagePdschCfg->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pageDlSch->freqAlloc.startPrb, pageDlSch->freqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : allocatePrbDl() failed for DL MSG"); return RFAILED; } + return ROK; +} - pagePdschCfg->beamPdschInfo.numPrgs = 1; - pagePdschCfg->beamPdschInfo.prgSize = 1; - pagePdschCfg->beamPdschInfo.digBfInterfaces = 0; - pagePdschCfg->beamPdschInfo.prg[0].pmIdx = 0; - pagePdschCfg->beamPdschInfo.prg[0].beamIdx[0] = 0; - pagePdschCfg->txPdschPower.powerControlOffset = 0; - pagePdschCfg->txPdschPower.powerControlOffsetSS = 0; +/** + * @brief Handles retransmission for MSG3 + * + * @details + * + * Function : schMsg3RetxSchedulingForUe + * + * This function handles retransmission for MSG3 + * + * @param[in] SchRaCb *raCb, RA cb pointer + * @return + * -# ROK + * -# RFAILED + **/ +uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb) +{ + bool k2Found = false; + uint16_t dciSlot = 0; + SlotTimingInfo dciTime, msg3Time; + SchCellCb *cell = NULLP; + SlotTimingInfo currTime; + DciInfo *dciInfo = NULLP; + cell = raCb->cell; + currTime = cell->slotInfo; + + /* Calculating time frame to send DCI for MSG3 Retx*/ + ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA, cell->numSlots); +#ifdef NR_TDD + /* Consider this slot for sending DCI, only if it is a DL slot */ + if(schGetSlotSymbFrmt(dciSlot, raCb->cell->slotFrmtBitMap) == DL_SLOT) +#endif + { + /* If PDCCH is already scheduled on this slot, cannot schedule PDSCH for another UE here. */ + if(cell->schDlSlotInfo[dciSlot]->pdcchUe != 0) + return false; + k2Found = schGetMsg3K2(cell, &raCb->msg3HqProc, dciTime.slot, &msg3Time, TRUE); + + if (!k2Found) + { + return RFAILED; + } + SCH_ALLOC(dciInfo, sizeof(DciInfo)); + if(!dciInfo) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); + return RFAILED; + } + cell->schDlSlotInfo[msg3Time.slot]->ulGrant = dciInfo; + SCH_ALLOC(cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, sizeof(SchPuschInfo)); + memset(dciInfo,0,sizeof(DciInfo)); + schFillUlDciForMsg3Retx(raCb, cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, dciInfo); + } + raCb->retxMsg3HqProc = NULLP; return ROK; } +/** + * @brief Get K2 value for MSG3 + * + * @details + * + * Function : schGetMsg3K2 + * + * This function gets K2 for MSG3 + * + * @param[in] SchCellCb *cell, Cell cb struc pointer + * @param[in] SchUlHqProcCb* msg3HqProc, msg3 harq proc pointer + * @param[in] uint16_t dlTime, DL time of scheduling + * @param[in] SlotTimingInfo *msg3Time, MSG3 timing info + * @param[in] bool isRetx, indicates MSG3 retransmission + * @return + * -# true + * -# false + **/ +bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx) +{ + bool k2Found = false; + uint8_t k2TblIdx = 0; + uint8_t k2Index = 0; + uint8_t k2 = 0; + uint8_t numK2 = 0; + uint8_t puschMu = 0; + uint8_t msg3Delta = 0, msg3MinSchTime = 0; +#ifdef NR_TDD + uint8_t totalCfgSlot = 0; +#endif + SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; + SlotTimingInfo currTime, msg3TempTime; + currTime = cell->slotInfo; + puschMu = cell->cellCfg.numerology; + + if (isRetx) + { + if(!msg3HqProc) + return false; + + numK2 = cell->k2InfoTbl.k2TimingInfo[dlTime].numK2; + msg3K2InfoTbl = &cell->msg3K2InfoTbl; + msg3MinSchTime = 0; + msg3Delta = 0; + } + else + { + numK2 = cell->msg3K2InfoTbl.k2TimingInfo[dlTime].numK2; + msg3K2InfoTbl = &cell->k2InfoTbl; + msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; + msg3Delta = puschDeltaTable[puschMu]; + } + + for(k2TblIdx = 0; k2TblIdx < numK2; k2TblIdx++) + { + k2Index = msg3K2InfoTbl->k2TimingInfo[dlTime].k2Indexes[k2TblIdx]; + + k2 = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; + if (isRetx) + { + if ((msg3HqProc->strtSymbl != cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol) || + (msg3HqProc->numSymbl != cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength)) + { + continue; + } + } + /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */ + k2 = k2 + msg3Delta; + if(k2 >= msg3MinSchTime) + { + ADD_DELTA_TO_TIME(currTime, msg3TempTime, k2, cell->numSlots); +#ifdef NR_TDD + if(schGetSlotSymbFrmt(msg3TempTime.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT) + continue; +#endif + /* If PUSCH is already scheduled on this slot, another PUSCH + * pdu cannot be scheduled here */ + if(cell->schUlSlotInfo[msg3TempTime.slot]->puschUe != 0) + continue; + k2Found = true; + break; + } + } + if (k2Found == true) + { + msg3Time->slot = msg3TempTime.slot; + msg3Time->sfn = msg3TempTime.sfn; + msg3Time->slot = msg3TempTime.slot; + } + return k2Found; +} + /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrsch/sch_crc.c b/src/5gnrsch/sch_crc.c index fe17fdd62..3730988a6 100644 --- a/src/5gnrsch/sch_crc.c +++ b/src/5gnrsch/sch_crc.c @@ -57,7 +57,7 @@ uint8_t SchProcCrcInd(Pst *pst, CrcIndInfo *crcInd) if (crcInd->crcInd[count]) { /* failure case*/ - if (cell->raCb[ueId-1].msg3HqProc.tbInfo.txCntr < cell->cellCfg.schRachCfg.maxMsg3Tx) + if (cell->raCb[ueId-1].msg3HqProc.tbInfo.txCntr < cell->maxMsg3Tx) { cell->api->SchCrcInd(cell, ueId); cell->raCb[ueId - 1].retxMsg3HqProc = &cell->raCb[ueId - 1].msg3HqProc; diff --git a/src/5gnrsch/sch_fcfs.c b/src/5gnrsch/sch_fcfs.c index 26cc88733..259158eee 100644 --- a/src/5gnrsch/sch_fcfs.c +++ b/src/5gnrsch/sch_fcfs.c @@ -748,7 +748,7 @@ void schFcfsRemoveUeFrmScheduleLst(SchCellCb *cell, CmLList *node) * * @details * - * Function : schCalculateUlTbs + * Function : schFcfsCalculateUlTbs * * Functionality: Function will note the required TBS for each LCGIDX and use * the Priority LCG List and RRM policy to allocate the TBS size @@ -766,7 +766,7 @@ void schFcfsRemoveUeFrmScheduleLst(SchCellCb *cell, CmLList *node) * RFAILED > vice versa * * ****************************************************************/ -uint8_t schCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbLen,\ +uint8_t schFcfsCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbLen,\ uint16_t *startPrb, uint32_t *totTBS, bool isRetx, SchUlHqProcCb *hqP, SchFcfsHqProcCb *fcfsHqP) { uint16_t mcsIdx = 0; @@ -912,7 +912,7 @@ uint8_t schFcfsScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTime, ui cell = (*hqP)->hqEnt->cell; ueCb = (*hqP)->hqEnt->ue; fcfsHqProcCb = (SchFcfsHqProcCb *)(*hqP)->schSpcUlHqProcCb; - ret = schCalculateUlTbs(ueCb, puschTime, symbLen, &startPrb, &totDataReq, isRetx, *hqP, fcfsHqProcCb); + ret = schFcfsCalculateUlTbs(ueCb, puschTime, symbLen, &startPrb, &totDataReq, isRetx, *hqP, fcfsHqProcCb); if(totDataReq > 0 && ret == ROK) { @@ -942,7 +942,6 @@ uint8_t schFcfsScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTime, ui { /* Fill DCI for UL grant */ schFillUlDci(ueCb, puschInfo, dciInfo, isRetx, *hqP); - memcpy(&dciInfo->slotIndInfo, &dciTime, sizeof(SlotTimingInfo)); ueCb->srRcvd = false; ueCb->bsrRcvd = false; cell->schUlSlotInfo[puschTime.slot]->puschUe = ueCb->ueId; diff --git a/src/5gnrsch/sch_harq_dl.c b/src/5gnrsch/sch_harq_dl.c index 455cc87be..1ec31bc5e 100644 --- a/src/5gnrsch/sch_harq_dl.c +++ b/src/5gnrsch/sch_harq_dl.c @@ -52,7 +52,7 @@ void schDlHqAddToFreeList(SchDlHqProcCb *hqP); void schDlHqEntInit(SchCellCb *cellCb, SchUeCb *ueCb) { ueCb->dlHqEnt.numHqPrcs = SCH_MAX_NUM_DL_HQ_PROC; - ueCb->dlHqEnt.maxHqTx = cellCb->cellCfg.schHqCfg.maxDlDataHqTx; + ueCb->dlHqEnt.maxHqTx = cellCb->schHqCfg.maxDlDataHqTx; ueCb->dlHqEnt.cell = cellCb; ueCb->dlHqEnt.ue =ueCb; schDlHqEntReset(cellCb, ueCb, &ueCb->dlHqEnt); @@ -343,7 +343,7 @@ void schMsg4FeedbackUpdate(SchDlHqProcCb *hqP, uint8_t fdbk) } else { - if( hqP->tbInfo[0].txCntr >= hqP->hqEnt->cell->cellCfg.schHqCfg.maxMsg4HqTx) + if( hqP->tbInfo[0].txCntr >= hqP->hqEnt->cell->schHqCfg.maxMsg4HqTx) { schDlReleaseHqProcess(hqP); hqP->hqEnt->ue->msg4HqProc = NULLP; diff --git a/src/5gnrsch/sch_harq_ul.c b/src/5gnrsch/sch_harq_ul.c index c90765557..343859a8a 100644 --- a/src/5gnrsch/sch_harq_ul.c +++ b/src/5gnrsch/sch_harq_ul.c @@ -49,7 +49,7 @@ void schUlHqAddToFreeList(SchUlHqProcCb *hqP); void schUlHqEntInit(SchCellCb *cellCb, SchUeCb *ueCb) { ueCb->ulHqEnt.numHqPrcs = SCH_MAX_NUM_UL_HQ_PROC; - ueCb->ulHqEnt.maxHqTx = cellCb->cellCfg.schHqCfg.maxUlDataHqTx; + ueCb->ulHqEnt.maxHqTx = cellCb->schHqCfg.maxUlDataHqTx; ueCb->ulHqEnt.cell = cellCb; ueCb->ulHqEnt.ue =ueCb; schUlHqEntReset(cellCb, ueCb, &ueCb->ulHqEnt); diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index 7694acb7d..461d766d7 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -65,7 +65,7 @@ bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo) uint8_t subFrame = 0; uint16_t prachSubframe = 0; - prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx; + prachCfgIdx = cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.prachCfgIdx; /* derive the prachCfgIdx table paramters */ x = prachCfgIdxTable[prachCfgIdx][1]; @@ -82,7 +82,7 @@ bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo) /* prach ocassion present in this subframe */ #ifdef NR_TDD if(UL_SLOT != schGetSlotSymbFrmt(prachOccasionTimingInfo.slot % cell->numSlotsInPeriodicity,\ - cell->slotFrmtBitMap)) + cell->slotFrmtBitMap)) { DU_LOG("\nERROR --> SCH : PrachCfgIdx %d doesn't support UL slot", prachCfgIdx); return FALSE; @@ -109,12 +109,12 @@ bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo) uint8_t schCalcPrachNumRb(SchCellCb *cell) { uint8_t tableIdx = 0; - uint16_t puschScs = convertScsEnumValToScsVal(cell->cellCfg.schInitialUlBwp.bwp.scs); + uint16_t puschScs = convertScsEnumValToScsVal(cell->cellCfg.ulCfgCommon.schInitialUlBwp.bwp.scs); for(tableIdx=0; tableIdx < MAX_RACH_NUM_RB_IDX; tableIdx++) { - if((numRbForPrachTable[tableIdx][0] == cell->cellCfg.schRachCfg.rootSeqLen) && - (numRbForPrachTable[tableIdx][1] == cell->cellCfg.schRachCfg.prachSubcSpacing) && + if((numRbForPrachTable[tableIdx][0] == cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rootSeqLen) && + (numRbForPrachTable[tableIdx][1] == cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.msg1SubcSpacing) && (numRbForPrachTable[tableIdx][2] == puschScs)) { return numRbForPrachTable[tableIdx][3]; @@ -158,7 +158,7 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo if(!schCheckPrachOcc(cell, prachOccasionTimingInfo)) return; - prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx; + prachCfgIdx = cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.prachCfgIdx; prachFormat = prachCfgIdxTable[prachCfgIdx][0]; prachStartSymbol = prachCfgIdxTable[prachCfgIdx][4]; prachOcas = prachCfgIdxTable[prachCfgIdx][6]; @@ -166,10 +166,10 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo /* numRa determined as 𝑛 belonging {0,1,.., M − 1}, * where M is given by msg1Fdm */ - numRa = (cell->cellCfg.schRachCfg.msg1Fdm - 1); + numRa = (cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1Fdm - 1); /* freq domain resource determination for RACH*/ - freqStart = cell->cellCfg.schRachCfg.msg1FreqStart; + freqStart = cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1FreqStart; numPrachRb = schCalcPrachNumRb(cell); /* Allocate PRACH resources from the UL resource bitmap */ allocatePrbUl(cell, prachOccasionTimingInfo, prachStartSymbol, prachDuration, &freqStart, numPrachRb); @@ -265,8 +265,8 @@ uint8_t SchProcRachRsrcReq(Pst *pst, SchRachRsrcReq *schRachRsrcReq) * Preamble index from 0 to (numCbPreamblePerSsb-1) is used for CBRA * Preamble index from numCbPreamblePerSsb to totalNumOfRAPreamble * is used for CFRA */ - firstCFPreambleIndex = cellCb->cellCfg.schRachCfg.numCbPreamblePerSsb; - lastCFPreambleIndex = cellCb->cellCfg.schRachCfg.totalNumRaPreamble; + firstCFPreambleIndex = cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numCbPreamblePerSsb; + lastCFPreambleIndex = cellCb->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.totalNumRaPreamble; /* Allocate resource for each SSB index requested */ for(ssbIdx = 0; ssbIdx < schRachRsrcReq->numSsb; ssbIdx++) @@ -427,8 +427,8 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, S } /* Allocate time-domain and frequency-domain resource for MSG3 PUSCH */ - startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; - symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; + startSymb = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; + symbLen = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; startRb = MAX_NUM_RB; tbSize = schCalcTbSize(8); /* 6 bytes msg3 and 2 bytes header */ @@ -555,12 +555,12 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin RaRspWindowStatus windowStatus=0; #ifdef NR_TDD - totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); #endif - k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl; + k0K1InfoTbl = &cell->k0K1InfoTbl; if(cell->raReq[ueId-1]->isCFRA == false) { - msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl; + msg3K2InfoTbl = &cell->msg3K2InfoTbl; puschMu = cell->cellCfg.numerology; msg3Delta = puschDeltaTable[puschMu]; msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; @@ -589,7 +589,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin for(k0TblIdx = 0; k0TblIdx < k0K1InfoTbl->k0k1TimingInfo[dciSlot].numK0; k0TblIdx++) { k0Index = k0K1InfoTbl->k0k1TimingInfo[dciSlot].k0Indexes[k0TblIdx].k0Index; - k0 = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; + k0 = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; /* Calculating time frame to send RAR PDSCH */ ADD_DELTA_TO_TIME(dciTime, rarTime, k0, cell->numSlots); @@ -634,7 +634,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin for(k2TblIdx = 0; k2TblIdx < msg3K2InfoTbl->k2TimingInfo[rarSlot].numK2; k2TblIdx++) { k2Index = msg3K2InfoTbl->k2TimingInfo[rarSlot].k2Indexes[k2TblIdx]; - k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; + k2 = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */ k2 = k2 + msg3Delta; @@ -705,7 +705,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin msg3PuschInfo = schAllocMsg3Pusch(schInst, cell->raReq[ueId-1]->rachInd->crnti, k2Index, msg3Time, &(cell->raCb[ueId-1].msg3HqProc), FALSE); if(msg3PuschInfo) { - dciSlotAlloc->rarInfo.ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb; + dciSlotAlloc->rarInfo.ulGrant.bwpSize = cell->cellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.numPrb; /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */ dciSlotAlloc->rarInfo.ulGrant.freqHopFlag = 0; dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.resAlloc.type1.startPrb; @@ -827,7 +827,7 @@ uint8_t SchProcRachInd(Pst *pst, RachIndInfo *rachInd) /* Converting window size from ms to number of slots */ slotDuration = (1 / pow(2, cell->cellCfg.numerology)); - winNumSlots = (float)cell->cellCfg.schRachCfg.raRspWindow / slotDuration; + winNumSlots = (float)cell->cellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.raRspWindow / slotDuration; /* Adding window size to window start time to get window end time */ ADD_DELTA_TO_TIME(raReq->winStartTime, raReq->winEndTime, winNumSlots, cell->numSlots); @@ -862,7 +862,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl uint16_t numRbs = 0; uint16_t tbSize = 0; - SchBwpDlCfg *initialBwp = &cell->cellCfg.schInitialDlBwp; + SchBwpDlCfg *initialBwp = &cell->cellCfg.dlCfgCommon.schInitialDlBwp; PdcchCfg *pdcch = &rarAlloc->rarPdcchCfg; PdschCfg *pdsch = &rarAlloc->rarPdschCfg; BwpCfg *bwp = &rarAlloc->bwp; @@ -893,7 +893,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdcch->coresetCfg.startSymbolIndex = firstSymbol; pdcch->coresetCfg.durationSymbols = numSymbols; memcpy(pdcch->coresetCfg.freqDomainResource, \ - cell->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); + cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); pdcch->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */ pdcch->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */ @@ -913,7 +913,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdcch->dci.beamPdcchInfo.digBfInterfaces = 0; pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0; pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0; - pdcch->dci.txPdcchPower.powerValue = 0; + pdcch->dci.txPdcchPower.beta_pdcch_1_0 = 0; pdcch->dci.txPdcchPower.powerControlOffsetSS = 0; pdcch->dci.pdschCfg = pdsch; @@ -938,7 +938,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdsch->numLayers = 1; pdsch->transmissionScheme = 0; pdsch->refPoint = 0; - pdsch->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */ + pdsch->dmrs.dlDmrsSymbPos = DL_DMRS_SYMBOL_POS; pdsch->dmrs.dmrsConfigType = 0; /* type-1 */ pdsch->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId; pdsch->dmrs.scid = 0; @@ -949,13 +949,13 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; pdsch->pdschTimeAlloc.rowIndex = k0Index; - pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol; - pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol; + pdsch->pdschTimeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol; + pdsch->pdschTimeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol; pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ - pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB; - pdsch->pdschFreqAlloc.freqAlloc.numPrb = \ + pdsch->pdschFreqAlloc.startPrb = MAX_NUM_RB; + pdsch->pdschFreqAlloc.numPrb = \ schCalcNumPrb(tbSize, mcs, initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol); /* Find total symbols occupied including DMRS */ @@ -964,19 +964,19 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pdsch->pdschTimeAlloc.startSymb; + numSymbol = pdsch->pdschTimeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.numSymb; } /* Allocate the number of PRBs required for RAR PDSCH */ if((allocatePrbDl(cell, rarTime, startSymbol, numSymbol,\ - &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pdsch->pdschFreqAlloc.startPrb, pdsch->pdschFreqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : allocatePrbDl() failed for RAR"); return RFAILED; diff --git a/src/5gnrsch/sch_rr.c b/src/5gnrsch/sch_rr.c deleted file mode 100644 index c084b1edc..000000000 --- a/src/5gnrsch/sch_rr.c +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* -################################################################################ -# 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 "common_def.h" -#include "tfu.h" -#include "lrg.h" -#include "tfu.x" -#include "lrg.x" -#include "du_log.h" -#include "du_app_mac_inf.h" -#include "mac_sch_interface.h" -#include "sch.h" -#include "sch_utils.h" -/** - * @brief Handles retransmission for MSG3 - * - * @details - * - * Function : schMsg3RetxSchedulingForUe - * - * This function handles retransmission for MSG3 - * - * @param[in] SchRaCb *raCb, RA cb pointer - * @return - * -# ROK - * -# RFAILED - **/ -uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb) -{ - bool k2Found = false; - uint16_t dciSlot = 0; - SlotTimingInfo dciTime, msg3Time; - SchCellCb *cell = NULLP; - SlotTimingInfo currTime; - DciInfo *dciInfo = NULLP; - cell = raCb->cell; - currTime = cell->slotInfo; - - /* Calculating time frame to send DCI for MSG3 Retx*/ - ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA, cell->numSlots); -#ifdef NR_TDD - /* Consider this slot for sending DCI, only if it is a DL slot */ - if(schGetSlotSymbFrmt(dciSlot, raCb->cell->slotFrmtBitMap) == DL_SLOT) -#endif - { - /* If PDCCH is already scheduled on this slot, cannot schedule PDSCH for another UE here. */ - if(cell->schDlSlotInfo[dciSlot]->pdcchUe != 0) - return false; - - k2Found = schGetMsg3K2(cell, &raCb->msg3HqProc, dciTime.slot, &msg3Time, TRUE); - - if (!k2Found) - { - return RFAILED; - } - SCH_ALLOC(dciInfo, sizeof(DciInfo)); - if(!dciInfo) - { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); - return RFAILED; - } - cell->schDlSlotInfo[msg3Time.slot]->ulGrant = dciInfo; - SCH_ALLOC(cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, sizeof(SchPuschInfo)); - memset(dciInfo,0,sizeof(DciInfo)); - schFillUlDciForMsg3Retx(raCb, cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, dciInfo); - } - raCb->retxMsg3HqProc = NULLP; - return ROK; -} -/** - * @brief Get K2 value for MSG3 - * - * @details - * - * Function : schGetMsg3K2 - * - * This function gets K2 for MSG3 - * - * @param[in] SchCellCb *cell, Cell cb struc pointer - * @param[in] SchUlHqProcCb* msg3HqProc, msg3 harq proc pointer - * @param[in] uint16_t dlTime, DL time of scheduling - * @param[in] SlotTimingInfo *msg3Time, MSG3 timing info - * @param[in] bool isRetx, indicates MSG3 retransmission - * @return - * -# true - * -# false - **/ -bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx) -{ - bool k2Found = false; - uint8_t k2TblIdx = 0; - uint8_t k2Index = 0; - uint8_t k2 = 0; - uint8_t numK2 = 0; - uint8_t puschMu = 0; - uint8_t msg3Delta = 0, msg3MinSchTime = 0; -#ifdef NR_TDD - uint8_t totalCfgSlot = 0; -#endif - SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; - SlotTimingInfo currTime, msg3TempTime; - currTime = cell->slotInfo; - puschMu = cell->cellCfg.numerology; - - if (isRetx) - { - if(!msg3HqProc) - return false; - - numK2 = cell->cellCfg.schInitialUlBwp.k2InfoTbl.k2TimingInfo[dlTime].numK2; - msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl; - msg3MinSchTime = 0; - msg3Delta = 0; - } - else - { - numK2 = cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl.k2TimingInfo[dlTime].numK2; - msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.k2InfoTbl; - msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; - msg3Delta = puschDeltaTable[puschMu]; - } - - for(k2TblIdx = 0; k2TblIdx < numK2; k2TblIdx++) - { - k2Index = msg3K2InfoTbl->k2TimingInfo[dlTime].k2Indexes[k2TblIdx]; - - k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; - if (isRetx) - { - if ((msg3HqProc->strtSymbl != cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol) || - (msg3HqProc->numSymbl != cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength)) - { - continue; - } - } - /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */ - k2 = k2 + msg3Delta; - if(k2 >= msg3MinSchTime) - { - ADD_DELTA_TO_TIME(currTime, msg3TempTime, k2, cell->numSlots); -#ifdef NR_TDD - if(schGetSlotSymbFrmt(msg3TempTime.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT) - continue; -#endif - /* If PUSCH is already scheduled on this slot, another PUSCH - * pdu cannot be scheduled here */ - if(cell->schUlSlotInfo[msg3TempTime.slot]->puschUe != 0) - continue; - k2Found = true; - break; - } - } - if (k2Found == true) - { - msg3Time->slot = msg3TempTime.slot; - msg3Time->sfn = msg3TempTime.sfn; - msg3Time->slot = msg3TempTime.slot; - } - return k2Found; -} -/********************************************************************** - End of file - **********************************************************************/ diff --git a/src/5gnrsch/sch_slice_based.c b/src/5gnrsch/sch_slice_based.c new file mode 100644 index 000000000..80f4af082 --- /dev/null +++ b/src/5gnrsch/sch_slice_based.c @@ -0,0 +1,1384 @@ +/******************************************************************************* +################################################################################ +# 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. # +################################################################################ + *******************************************************************************/ + +/************************************************************************ + +Name: 5G NR SCH layer + +Type: C source file + +Desc: C source code for Slice based scheduling algorithm + +File: sch_slice_based.c + + **********************************************************************/ + +/** @file sch_slot_ind.c + @brief This module processes slot indications + */ +#include "common_def.h" +#include "tfu.h" +#include "lrg.h" +#include "tfu.x" +#include "lrg.x" +#include "du_log.h" +#include "du_app_mac_inf.h" +#include "mac_sch_interface.h" +#include "sch.h" +#include "sch_utils.h" +#include "sch_slice_based.h" +#ifdef NR_DRX +#include "sch_drx.h" +#endif + +/******************************************************************* + * + * @brief Function to handle Cell configuration request + * + * @details + * + * Function : schSliceBasedCellCfgReq + * + * Functionality: This function configures cell paremeters + * required for Slice Based scheduling + * + * @params[in] SchCellCb *cellCb, Cell control block + * @return ROK + * RFAILED + * + * ****************************************************************/ +uint8_t schSliceBasedCellCfgReq(SchCellCb *cellCb) +{ + SchSliceBasedCellCb *schSpcCellCb = NULLP; + + SCH_ALLOC(schSpcCellCb, sizeof(SchSliceBasedCellCb)); + if(!schSpcCellCb) + { + DU_LOG("\nERROR --> SCH: Memory allocation failed in schSliceBasedCellCfgReq"); + return RFAILED; + } + cmLListInit(&schSpcCellCb->ueToBeScheduled); + cellCb->schSpcCell = (void *)schSpcCellCb; + return ROK; +} + +/******************************************************************* + * + * @brief Function to handle Cell configuration request + * + * @details + * + * Function : schSliceBasedCellDelReq + * + * Functionality: This function deletes/frees cell params + * specific to Slice Based scheduling + * + * @params[in] Pointer to Cell control block + * @return void + * + * ****************************************************************/ +void schSliceBasedCellDelReq(SchCellCb *cellCb) +{ + SchSliceBasedCellCb *schSpcCellCb = NULLP; + CmLList *node=NULL, *next=NULL; + + schSpcCellCb = (SchSliceBasedCellCb *)cellCb->schSpcCell; + /* Remove all UE from ueToBeScheduled list and deallocate */ + node = schSpcCellCb->ueToBeScheduled.first; + while(node) + { + next = node->next; + SCH_FREE(node->node, sizeof(uint8_t)); + cmLListDelFrm(&schSpcCellCb->ueToBeScheduled, node); + SCH_FREE(node, sizeof(CmLList)); + node = next; + } + SCH_FREE(schSpcCellCb, sizeof(SchSliceBasedCellCb)); + cellCb->schSpcCell = NULLP; +} + +/******************************************************************* + * + * @brief Function to handle UE configuration request + * + * @details + * + * Function : SchSliceBasedAddUeConfigReq + * + * Functionality: Adds/Configures UE parameters required for + * Slice Based scheduling + * + * @params[in] Pointer to UE control block + * @return ROK + * RFAILED + * + * ****************************************************************/ +uint8_t SchSliceBasedAddUeConfigReq(SchUeCb *ueCb) +{ + SchSliceBasedUeCb *ueSliceBasedCb; + + SCH_ALLOC(ueSliceBasedCb, sizeof(SchSliceBasedHqCb)); + if(!ueSliceBasedCb) + { + DU_LOG("\nERROR --> SCH: Memory allocation failed in SchSliceBasedAddUeConfigReq"); + return RFAILED; + } + + cmLListInit(&ueSliceBasedCb->hqRetxCb.ulRetxHqList); + cmLListInit(&ueSliceBasedCb->hqRetxCb.dlRetxHqList); + ueCb->schSpcUeCb = (void *)ueSliceBasedCb; + + return ROK; +} + +/******************************************************************* + * + * @brief Handles UE reconfiguration request + * + * @details + * + * Function : SchSliceBasedModUeConfigReq + * + * Functionality: + * + * @params[in] Pointer to UE control block + * @return void + * + * ****************************************************************/ +void SchSliceBasedModUeConfigReq(SchUeCb *ueCb) +{ + /*TBD: No action required for Slice Based*/ + return; +} + +/******************************************************************* + * + * @brief Handles UE Delete Request + * + * @details + * + * Function : SchSliceBasedUeDeleteReq + * + * Functionality: Deletes/Frees UE parameters specific to + * Slice Based scheduling + * + * @params[in] Pointer to UE control block + * @return void + * + * ****************************************************************/ +void SchSliceBasedUeDeleteReq(SchUeCb *ueCb) +{ + SchSliceBasedCellCb *schSpcCellCb = NULLP; + SchSliceBasedUeCb *ueSliceBasedCb = NULLP; + CmLList *node=NULL, *next=NULL; + uint8_t ueId = 0; + + schSpcCellCb = (SchSliceBasedCellCb *)ueCb->cellCb->schSpcCell; + /* Remove all UE from ueToBeScheduled list and deallocate */ + node = schSpcCellCb->ueToBeScheduled.first; + while(node) + { + next = node->next; + ueId = *(uint8_t *)node->node; + if(ueId == ueCb->ueId) + { + SCH_FREE(node->node, sizeof(uint8_t)); + cmLListDelFrm(&schSpcCellCb->ueToBeScheduled, node); + SCH_FREE(node, sizeof(CmLList)); + break; + } + node = next; + } + + ueSliceBasedCb = (SchSliceBasedUeCb *)ueCb->schSpcUeCb; + cmLListDeleteLList(&ueSliceBasedCb->hqRetxCb.ulRetxHqList); + cmLListDeleteLList(&ueSliceBasedCb->hqRetxCb.dlRetxHqList); + + SCH_FREE(ueSliceBasedCb, sizeof(SchSliceBasedUeCb)); + ueCb->schSpcUeCb = NULLP; + return; +} + +/******************************************************************* + * + * @brief Intializes HARQ Process control block + * + * @details + * + * Function : schSliceBasedInitDlHqProcCb + * + * Functionality: Intitialized parameters of HARQ process control + * block specific to Slice Based scheduling in Downlink + * + * @params[in] Pointer to Downlink HARQ Process control block + * @return ROK + * RFAILED + * + * ****************************************************************/ +uint8_t schSliceBasedInitDlHqProcCb(SchDlHqProcCb *hqP) +{ + SchSliceBasedHqProcCb *schSpcHqP; + + SCH_ALLOC(schSpcHqP, sizeof(SchSliceBasedHqProcCb)); + if(!schSpcHqP) + { + DU_LOG("\nERROR --> SCH: Memory allocation failed in schSliceBasedInitDlHqProcCb"); + return RFAILED; + } + + cmLListInit(&schSpcHqP->lcCb.dedLcList); + cmLListInit(&schSpcHqP->lcCb.defLcList); + hqP->schSpcDlHqProcCb = (void *)schSpcHqP; + + return ROK; +} + +/******************************************************************* + * + * @brief Handles HARQ Process delete request + * + * @details + * + * Function : schSliceBasedDeleteDlHqProcCb + * + * Functionality: Deletes HARQ Process parameters specific to + * Slice Based scheduling in Downlink + * + * @params[in] Pointer to Downlink HARQ Process control block + * @return void + * + * ****************************************************************/ +void schSliceBasedDeleteDlHqProcCb(SchDlHqProcCb *hqP) +{ + SchSliceBasedHqProcCb *schSpcHqP = (SchSliceBasedHqProcCb *)hqP->schSpcDlHqProcCb; + cmLListDeleteLList(&schSpcHqP->lcCb.dedLcList); + cmLListDeleteLList(&schSpcHqP->lcCb.defLcList); + SCH_FREE(schSpcHqP, sizeof(SchSliceBasedHqProcCb)); + hqP->schSpcDlHqProcCb = NULLP; +} + +/******************************************************************* + * + * @brief Intializes HARQ Process control block + * + * @details + * + * Function : schSliceBasedInitUlHqProcCb + * + * Functionality: Intitialized parameters of HARQ process control + * block specific to Slice Based scheduling in Uplink + * + * @params[in] Pointer to Uplink HARQ Process control block + * @return ROK + * RFAILED + * + * ****************************************************************/ +uint8_t schSliceBasedInitUlHqProcCb(SchUlHqProcCb *hqP) +{ + SchSliceBasedHqProcCb *schSpcHqP; + + SCH_ALLOC(schSpcHqP, sizeof(SchSliceBasedHqProcCb)); + if(!schSpcHqP) + { + DU_LOG("\nERROR --> SCH: Memory allocation failed in schSliceBasedInitUlHqProcCb"); + return RFAILED; + } + cmLListInit(&schSpcHqP->lcCb.dedLcList); + cmLListInit(&schSpcHqP->lcCb.defLcList); + hqP->schSpcUlHqProcCb = (void *)schSpcHqP; + + return ROK; +} + +/******************************************************************* + * + * @brief Handled Deletion of HARQ Process control block + * + * @details + * + * Function : schSliceBasedDeleteUlHqProcCb + * + * Functionality: Deletes HARQ Process parameters specific to + * Slice Based scheduling in Uplink + * + * @params[in] Pointer to Uplink HARQ Process Control block + * @return void + * + * ****************************************************************/ +void schSliceBasedDeleteUlHqProcCb(SchUlHqProcCb *hqP) +{ + SchSliceBasedHqProcCb *schSpcHqP = (SchSliceBasedHqProcCb *)hqP->schSpcUlHqProcCb; + cmLListDeleteLList(&schSpcHqP->lcCb.dedLcList); + cmLListDeleteLList(&schSpcHqP->lcCb.defLcList); + SCH_FREE(schSpcHqP, sizeof(SchSliceBasedHqProcCb)); + hqP->schSpcUlHqProcCb = NULLP; +} + +/******************************************************************* + * + * @brief Handles freeing of HARQ Process + * + * @details + * + * Function : schSliceBasedFreeDlHqProcCb + * + * Functionality: Frees HARQ Process parameters specific to + * Slice Based scheduling in Downlink when HARQ process becomes free + * + * @params[in] Pointer to HARQ process control block + * @return void + * + * ****************************************************************/ +void schSliceBasedFreeDlHqProcCb(SchDlHqProcCb *hqP) +{ + SchSliceBasedHqProcCb *schSpcHqP = (SchSliceBasedHqProcCb *)hqP->schSpcDlHqProcCb; + + cmLListDeleteLList(&schSpcHqP->lcCb.dedLcList); + cmLListDeleteLList(&schSpcHqP->lcCb.defLcList); +} + +/******************************************************************* + * + * @brief Handles freeing of HARQ Process + * + * @details + * + * Function : schSliceBasedFreeUlHqProcCb + * + * Functionality: Frees HARQ Process parameters specific to + * Slice Based scheduling in Uplink when HARQ process becomes free + * + * @params[in] Pointer to HARQ process control block + * @return void + * + * ****************************************************************/ +void schSliceBasedFreeUlHqProcCb(SchUlHqProcCb *hqP) +{ + SchSliceBasedHqProcCb *schSpcHqP = (SchSliceBasedHqProcCb *)hqP->schSpcUlHqProcCb; + + cmLListDeleteLList(&schSpcHqP->lcCb.dedLcList); + cmLListDeleteLList(&schSpcHqP->lcCb.defLcList); +} + +/******************************************************************* + * + * @brief Adds HARQ process to retransmission list + * + * @details + * + * Function : schSliceBasedAddToDlHqRetxList + * + * Functionality: Adds HARQ process to retransmission list + * + * @params[in] Pointer to Downlink HARQ Process + * @return void + * + * ****************************************************************/ +void schSliceBasedAddToDlHqRetxList(SchDlHqProcCb *hqP) +{ + SchSliceBasedUeCb *schSpcUeCb; + + schSpcUeCb = (SchSliceBasedUeCb *)hqP->hqEnt->ue->schSpcUeCb; + cmLListAdd2Tail(&(schSpcUeCb->hqRetxCb.dlRetxHqList),&hqP->dlHqProcLink); +#ifdef NR_DRX + if(hqP->hqEnt->ue->ueDrxInfoPres == true) + { + schDrxStrtDlHqRttTmr(hqP); + } + else +#endif + { + schSliceBasedAddUeToSchedule(hqP->hqEnt->cell, hqP->hqEnt->ue->ueId); + } +} + +/******************************************************************* + * + * @brief Adds HARQ process to retransmission list + * + * @details + * + * Function : schSliceBasedAddToUlHqRetxList + * + * Functionality: Adds HARQ process to retransmission list + * + * @params[in] Pointer to Uplink HARQ Process + * @return void + * + * ****************************************************************/ +void schSliceBasedAddToUlHqRetxList(SchUlHqProcCb *hqP) +{ + SchSliceBasedUeCb *schSpcUeCb; + + schSpcUeCb = (SchSliceBasedUeCb *)hqP->hqEnt->ue->schSpcUeCb; + cmLListAdd2Tail(&(schSpcUeCb->hqRetxCb.ulRetxHqList),&hqP->ulHqProcLink); +#ifdef NR_DRX + if(hqP->hqEnt->ue->ueDrxInfoPres == true) + { + schDrxStrtUlHqRttTmr(hqP); + } + else +#endif + { + schSliceBasedAddUeToSchedule(hqP->hqEnt->cell, hqP->hqEnt->ue->ueId); + } +} + +/******************************************************************* + * + * @brief Add UE to ueToBeScheduled List + * + * @details + * + * Function : schSliceBasedAddUeToSchedule + * + * Functionality: + * Search if UE entry present in the list + * If yes, return. + * If no, add UE to the list + * + * @params[in] Cell control block + * Ue Id to be added + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t schSliceBasedAddUeToSchedule(SchCellCb *cellCb, uint16_t ueIdToAdd) +{ + SchSliceBasedCellCb *schSpcCellCb = NULLP; + uint8_t *ueId; + CmLList *node; + + schSpcCellCb = (SchSliceBasedCellCb *)cellCb->schSpcCell; + /* Search if UE entry is already present in ueToBeScheduled list. + * If yes, another entry for same UE not needed. Hence, return */ + node = schSpcCellCb->ueToBeScheduled.first; + while(node) + { + ueId = (uint8_t *)node->node; + if(*ueId == ueIdToAdd) + return ROK; + node = node->next; + } + + /* If UE entry not present already, add UE to the end of ueToBeScheduled list */ + SCH_ALLOC(ueId, sizeof(uint8_t)); + if(!ueId) + { + DU_LOG("\nERROR --> SCH : Memory allocation failure in schSliceBasedAddUeToSchedule"); + return RFAILED; + } + *ueId = ueIdToAdd; + if(addNodeToLList(&schSpcCellCb->ueToBeScheduled, ueId, NULLP) != ROK) + { + DU_LOG("\nERROR --> SCH : Failed to add ueId [%d] to cell->ueToBeScheduled list", *ueId); + return RFAILED; + } + return ROK; +} + +/******************************************************************* + * + * @brief Handled CRC Indication + * + * @details + * + * Function : schSliceBasedProcessCrcInd + * + * Functionality: Processes CRC Indication as required for Slice Based + * scheduling + * + * @params[in] Pointer to Cell control block + * UE Id + * @return void + * + * ****************************************************************/ +void schSliceBasedProcessCrcInd(SchCellCb *cellCb, uint16_t ueId) +{ + schSliceBasedAddUeToSchedule(cellCb, ueId); +} + +/******************************************************************* + * + * @brief Processes Buffer Occupancy report from RLC + * + * @details + * + * Function : schSliceBasedDlRlcBoInfo + * + * Functionality: Process buffer occupany report + * + * @params[in] + * @return + * + * ****************************************************************/ +void schSliceBasedDlRlcBoInfo(SchCellCb *cellCb, uint16_t ueId) +{ + schSliceBasedAddUeToSchedule(cellCb, ueId); +} + +/******************************************************************* + * + * @brief Processes BSR request + * + * @details + * + * Function : schSliceBasedBsr + * + * Functionality: Processes BSR as per Slice Based scheduling + * + * @params[in] Pointer to Cell + * UE ID + * @return void + * + * ****************************************************************/ +void schSliceBasedBsr(SchCellCb *cellCb, uint16_t ueId) +{ + schSliceBasedAddUeToSchedule(cellCb, ueId); +} + +/******************************************************************* + * + * @brief Processed UCI Indication + * + * @details + * + * Function : schSliceBasedSrUciInd + * + * Functionality: Processing of UCI indication specific to + * Slice Based scheduling + * + * @params[in] Pointer to Cell + * UE Id + * @return void + * + * ****************************************************************/ +void schSliceBasedSrUciInd(SchCellCb *cellCb, uint16_t ueId) +{ + schSliceBasedAddUeToSchedule(cellCb, ueId); +} + +/******************************************************************* + * + * @brief Processing of RACH Indication + * + * @details + * + * Function : schSliceBasedProcessRachInd + * + * Functionality: Processing of RACH Indication specific to + * Slice Based scheduling + * + * @params[in] Pointer to Cell Cb + * UE Id + * @return void + * + * ****************************************************************/ +void schSliceBasedProcessRachInd(SchCellCb *cellCb, uint16_t ueId) +{ + schSliceBasedAddUeToSchedule(cellCb, ueId); +} + +/******************************************************************* + * + * @brief Processing of DL HARQ Indication + * + * @details + * + * Function : SchSliceBasedDlHarqInd + * + * Functionality: + * + * @params[in] + * @return void + * + * ****************************************************************/ +void SchSliceBasedDlHarqInd() +{ + return; +} + +/******************************************************************* + * + * @brief Processing of Paging indication + * + * @details + * + * Function : schSliceBasedPagingInd + * + * Functionality: + * + * @params[in] + * @return void + * + * ****************************************************************/ +void schSliceBasedPagingInd() +{ + return; +} + +/******************************************************************* + * + * @brief Processing of RACH Resource Request + * + * @details + * + * Function : schSliceBasedRachRsrcReq + * + * Functionality: + * + * @params[in] + * @return void + * + * ****************************************************************/ +void schSliceBasedRachRsrcReq() +{ + return; +} + +/******************************************************************* + * + * @brief Processing of RACH Resource Release + * + * @details + * + * Function : schSliceBasedRachRsrcRel + * + * Functionality: + * + * @params[in] + * @return void + * + * ****************************************************************/ +void schSliceBasedRachRsrcRel() +{ + return; +} + +/******************************************************************* + * + * @brief Remove entry from HARQ retransmission list + * + * @details + * + * Function : schSliceBasedRemoveFrmDlHqRetxList + * + * Functionality: Remove entry from HARQ retransmission list + * + * @params[in] Pointer to UE + * Node to be deleted + * @return void + * + * ****************************************************************/ +void schSliceBasedRemoveFrmDlHqRetxList(SchUeCb *ueCb, CmLList *node) +{ + SchSliceBasedUeCb *schSpcUeCb; + + schSpcUeCb = (SchSliceBasedUeCb *)ueCb->schSpcUeCb; + cmLListDelFrm(&schSpcUeCb->hqRetxCb.dlRetxHqList, node); +} + +/******************************************************************* + * + * @brief Remove entry from HARQ retransmission list + * + * @details + * + * Function : schSliceBasedRemoveFrmUlHqRetxList + * + * Functionality: Remove entry from HARQ retransmission list + * + * @params[in] Pointer to UE + * Node to be deleted + * @return void + * + * ****************************************************************/ +void schSliceBasedRemoveFrmUlHqRetxList(SchUeCb *ueCb, CmLList *node) +{ + SchSliceBasedUeCb *schSpcUeCb; + + schSpcUeCb = (SchSliceBasedUeCb *)ueCb->schSpcUeCb; + cmLListDelFrm(&schSpcUeCb->hqRetxCb.ulRetxHqList, node); +} + +/******************************************************************* + * + * @brief Remove UE from Scheduling List + * + * @details + * + * Function : schSliceBasedRemoveUeFrmScheduleLst + * + * Functionality: Remove UE from Scheduling List + * + * @params[in] Pointer to Cell + * Node to be removed + * @return void + * + * ****************************************************************/ +void schSliceBasedRemoveUeFrmScheduleLst(SchCellCb *cell, CmLList *node) +{ + SchSliceBasedCellCb *schSpcCell; + + schSpcCell = (SchSliceBasedCellCb *)cell->schSpcCell; + SCH_FREE(node->node, sizeof(uint8_t)); + deleteNodeFromLList(&schSpcCell->ueToBeScheduled, node); +} + +/******************************************************************* + * + * @brief Handler to calculate TBS size for BSR requested + * + * @details + * + * Function : schSliceBasedCalculateUlTbs + * + * Functionality: Function will note the required TBS for each LCGIDX and use + * the Priority LCG List and RRM policy to allocate the TBS size + * + * @params [in] ueCb (Pointer to UE CB) + * [in] puschTime (Time slot where PUSCH will be sent) + * [in] symbLen (No of Symbols used for PUSCH transmission) + * [out] startPrb(Pointer to startPRB which will be calculated while + * finding the best Free Block) + * [out] totTBS(Pointer to total TBS size) + * [in] isRetx (to indicate retransmission) + * [in] hqP (UL Harq process pointer) + * + * @return uint8_t : ROK > Scheduling of UL grant is successful + * RFAILED > vice versa + * + * ****************************************************************/ +uint8_t schSliceBasedCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbLen,\ + uint16_t *startPrb, uint32_t *totTBS, bool isRetx, SchUlHqProcCb *hqP, SchSliceBasedHqProcCb *schSpcHqP) +{ + uint16_t mcsIdx = 0; + CmLListCp *lcLL = NULLP; + uint16_t lcgIdx = 0, lcId =0, maxFreePRB = 0; + uint16_t rsvdDedicatedPRB; + *startPrb = 0; + *totTBS = 0; + + /* check for BSR */ + for(lcgIdx=0; lcgIdxbsrInfo[lcgIdx].dataVol == 0) + { + continue; + } + + /*TODO: lcgIdx and LCID has been implemented as one to one mapping. + * Need to check the mapping to figure out the LCID and lcgIdx once L2 + * spec specifies any logic*/ + lcId = lcgIdx; + if(ueCb->ulInfo.ulLcCtxt[lcId].isDedicated) + { + lcLL = &(schSpcHqP->lcCb.dedLcList); + rsvdDedicatedPRB = ueCb->ulInfo.ulLcCtxt[lcId].rsvdDedicatedPRB; + } + else + { + lcLL = &(schSpcHqP->lcCb.defLcList); + } + + /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/ + if(updateLcListReqPRB(lcLL, lcId, ueCb->bsrInfo[lcgIdx].dataVol) != ROK) + { + DU_LOG("\nERROR --> SCH: LcgId:%d updation failed",lcId); + return RFAILED; + } + } + + if ((schSpcHqP->lcCb.defLcList.count == 0) && (schSpcHqP->lcCb.dedLcList.count == 0)) + { + if( (ueCb->srRcvd) || (isRetx) ) + { + *startPrb = MAX_NUM_RB; + *totTBS = schCalcTbSize(UL_GRANT_SIZE); + } + /*Returning true when NO Grant is there for UE as this is not scheduling + * error*/ + return ROK; + } + + maxFreePRB = searchLargestFreeBlock(ueCb->cellCb, puschTime, startPrb, DIR_UL); + + /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in + * the list based on RRM policy*/ + + /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or + * Num of Free PRB available is not enough to reserve Dedicated PRBs*/ + if(maxFreePRB != 0) + { + mcsIdx = ueCb->ueCfg.ulModInfo.mcsIndex; + if((schSpcHqP->lcCb.dedLcList.count == 0) || ((maxFreePRB < rsvdDedicatedPRB))) + { + schSpcHqP->lcCb.sharedNumPrb = maxFreePRB; + DU_LOG("\nDEBUG --> SCH : UL Only Default Slice is scheduled, sharedPRB Count:%d",\ + schSpcHqP->lcCb.sharedNumPrb); + + /*PRB Alloc for Default LCs*/ + prbAllocUsingRRMPolicy(&(schSpcHqP->lcCb.defLcList), FALSE, mcsIdx, symbLen,\ + &(schSpcHqP->lcCb.sharedNumPrb), NULLP, NULLP,&(ueCb->srRcvd)); + } + else + { + schSpcHqP->lcCb.sharedNumPrb = maxFreePRB - rsvdDedicatedPRB; + + /*PRB Alloc for Dedicated LCs*/ + prbAllocUsingRRMPolicy(&(schSpcHqP->lcCb.dedLcList), TRUE, mcsIdx, symbLen,\ + &(schSpcHqP->lcCb.sharedNumPrb), &(rsvdDedicatedPRB),\ + NULLP, &(ueCb->srRcvd)); + + /*PRB Alloc for Default LCs*/ + prbAllocUsingRRMPolicy(&(schSpcHqP->lcCb.defLcList), FALSE, mcsIdx, symbLen, \ + &(schSpcHqP->lcCb.sharedNumPrb), &(rsvdDedicatedPRB),\ + NULLP,&(ueCb->srRcvd)); + } + } + /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes + * using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/ + if(schSpcHqP->lcCb.dedLcList.count != 0) + updateGrantSizeForBoRpt(&(schSpcHqP->lcCb.dedLcList), NULLP, ueCb->bsrInfo, totTBS); + + updateGrantSizeForBoRpt(&(schSpcHqP->lcCb.defLcList), NULLP, ueCb->bsrInfo, totTBS); + + /*Below case will hit if NO LC(s) are allocated due to resource crunch*/ + if (*totTBS == 0) + { + if(maxFreePRB == 0) + { + DU_LOG("\nERROR --> SCH : NO FREE PRB!!"); + } + else + { + /*Schedule the LC for next slot*/ + DU_LOG("\nDEBUG --> SCH : No LC has been scheduled"); + } + return RFAILED; + } + return ROK; +} + +/******************************************************************* + * + * @brief Grants resources to LC in uplink + * + * @details + * + * Function : schProcessSrOrBsrReq + * + * Functionality: + * Grants resources to LC in uplink + * + * @params[in] PDCCH Time + * PUSCH Time + * Start Symbol + * Number of symbols + * Is retransmission + * HARQ process + * @return ROK + * RFAILED + * + *******************************************************************/ +uint8_t schSliceBasedScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTime, uint8_t startSymb , uint8_t symbLen, bool isRetx, SchUlHqProcCb **hqP) +{ + SchCellCb *cell; + SchSliceBasedHqProcCb *schSpcHqProcCb; + uint8_t ret = RFAILED; + uint16_t startPrb = 0; + uint32_t totDataReq = 0; /* in bytes */ + SchUeCb *ueCb; + SchPuschInfo *puschInfo; + DciInfo *dciInfo = NULLP; + + cell = (*hqP)->hqEnt->cell; + ueCb = (*hqP)->hqEnt->ue; + schSpcHqProcCb = (SchSliceBasedHqProcCb *)(*hqP)->schSpcUlHqProcCb; + ret = schSliceBasedCalculateUlTbs(ueCb, puschTime, symbLen, &startPrb, &totDataReq, isRetx, *hqP, schSpcHqProcCb); + + if(totDataReq > 0 && ret == ROK) + { + SCH_ALLOC(dciInfo, sizeof(DciInfo)); + if(!dciInfo) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); + if(isRetx != TRUE) + { + if(schSpcHqProcCb->lcCb.dedLcList.count != 0) + updateBsrAndLcList(&(schSpcHqProcCb->lcCb.dedLcList), ueCb->bsrInfo, RFAILED); + + updateBsrAndLcList(&(schSpcHqProcCb->lcCb.defLcList), ueCb->bsrInfo, RFAILED); + } + return RFAILED; + } + cell->schDlSlotInfo[dciTime.slot]->ulGrant = dciInfo; + memset(dciInfo,0,sizeof(DciInfo)); + + /* Update PUSCH allocation */ + if(schFillPuschAlloc(ueCb, puschTime, totDataReq, startSymb, symbLen, startPrb, isRetx, *hqP) == ROK) + { + if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo) + { + puschInfo = cell->schUlSlotInfo[puschTime.slot]->schPuschInfo; + if(puschInfo != NULLP) + { + /* Fill DCI for UL grant */ + schFillUlDci(ueCb, puschInfo, dciInfo, isRetx, *hqP); + ueCb->srRcvd = false; + ueCb->bsrRcvd = false; + cell->schUlSlotInfo[puschTime.slot]->puschUe = ueCb->ueId; + if(schSpcHqProcCb->lcCb.dedLcList.count != 0) + updateBsrAndLcList(&(schSpcHqProcCb->lcCb.dedLcList), ueCb->bsrInfo, ROK); + updateBsrAndLcList(&(schSpcHqProcCb->lcCb.defLcList), ueCb->bsrInfo, ROK); + cmLListAdd2Tail(&(ueCb->hqUlmap[puschTime.slot]->hqList), &(*hqP)->ulSlotLnk); + return ROK; + } + } + } + if(schSpcHqProcCb->lcCb.dedLcList.count != 0) + updateBsrAndLcList(&(schSpcHqProcCb->lcCb.dedLcList), ueCb->bsrInfo, RFAILED); + updateBsrAndLcList(&(schSpcHqProcCb->lcCb.defLcList), ueCb->bsrInfo, RFAILED); + } + return ROK; +} + +/******************************************************************* + * + * @brief Grants resources to LC in downlink + * + * @details + * + * Function : schSliceBasedScheduleDlLc + * + * Functionality: Grants resources to LC in uplink + * + * @params[in] PDCCH Time + * + * @return ROK + * RFAILED + * + * ****************************************************************/ +uint32_t schSliceBasedScheduleDlLc(SlotTimingInfo pdcchTime, SlotTimingInfo pdschTime, uint8_t pdschNumSymbols, bool isRetx, SchDlHqProcCb **hqP) +{ + SchSliceBasedHqProcCb *schSpcHqProcCb; + SchUeCb *ueCb; + uint8_t lcIdx = 0; + uint16_t startPrb = 0, maxFreePRB = 0; + uint16_t mcsIdx = 0; + uint32_t accumalatedSize = 0; + CmLListCp *lcLL = NULLP; + uint16_t rsvdDedicatedPRB = 0; + DlMsgAlloc *dciSlotAlloc; + + /* TX_PAYLOAD_HDR_LEN: Overhead which is to be Added once for any UE while estimating Accumulated TB Size + * Following flag added to keep the record whether TX_PAYLOAD_HDR_LEN is added to the first Node getting allocated. + * If both Dedicated and Default LC lists are present then First LC in Dedicated List will include this overhead + * else if only Default list is present then first node in this List will add this overhead len*/ + bool isTxPayloadLenAdded = FALSE; + + ueCb = (*hqP)->hqEnt->ue; + dciSlotAlloc = (*hqP)->hqEnt->cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueCb->ueId -1]; + schSpcHqProcCb = (SchSliceBasedHqProcCb *)((*hqP)->schSpcDlHqProcCb); + + if (isRetx == FALSE) + { + /*Re-Initalization per UE*/ + /* scheduled LC data fill */ + dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].numLc = 0; + isTxPayloadLenAdded = FALSE; /*Re-initlaize the flag for every UE*/ + accumalatedSize = 0; + + for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++) + { + if(ueCb->dlInfo.dlLcCtxt[lcIdx].bo) + { + /*Check the LC is Dedicated or default and accordingly LCList will + * be used*/ + if(ueCb->dlInfo.dlLcCtxt[lcIdx].isDedicated) + { + lcLL = &(schSpcHqProcCb->lcCb.dedLcList); + rsvdDedicatedPRB = ueCb->dlInfo.dlLcCtxt[lcIdx].rsvdDedicatedPRB; + } + else + { + lcLL = &(schSpcHqProcCb->lcCb.defLcList); + } + + /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/ + if(updateLcListReqPRB(lcLL, ueCb->dlInfo.dlLcCtxt[lcIdx].lcId,\ + (ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE)) != ROK) + { + DU_LOG("\nERROR --> SCH : Updation in LC List Failed"); + /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ + if(dciSlotAlloc->numSchedInfo == 0) + { + SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc)); + (*hqP)->hqEnt->cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueCb->ueId -1] = NULL; + } + else + memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo)); + return false; + } + } + ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0; + }//End of for loop + + if ((schSpcHqProcCb->lcCb.defLcList.count == 0) && (schSpcHqProcCb->lcCb.dedLcList.count == 0)) + { + DU_LOG("\nDEBUG --> SCH : No pending BO for any LC id\n"); + UNSET_ONE_BIT((*hqP)->hqEnt->ue->ueId, (*hqP)->hqEnt->cell->boIndBitMap); + + /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ + if(dciSlotAlloc->numSchedInfo == 0) + { + SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc)); + (*hqP)->hqEnt->cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueCb->ueId -1] = NULL; + } + else + memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo)); + + /*TRUE because this UE has nothing to be scheduled*/ + return true; + } + } + + /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/ + maxFreePRB = searchLargestFreeBlock((*hqP)->hqEnt->cell, pdschTime, &startPrb, DIR_DL); + + /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in + * the list based on RRM policy*/ + + /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or + * Num of Free PRB available is not enough to reserve Dedicated PRBs*/ + if(isRetx == FALSE) + { + if(maxFreePRB != 0) + { + mcsIdx = ueCb->ueCfg.dlModInfo.mcsIndex; + + if((schSpcHqProcCb->lcCb.dedLcList.count == NULLP) || ((maxFreePRB < rsvdDedicatedPRB))) + { + schSpcHqProcCb->lcCb.sharedNumPrb = maxFreePRB; + DU_LOG("\nDEBUG --> SCH : DL Only Default Slice is scheduled, sharedPRB Count:%d",\ + schSpcHqProcCb->lcCb.sharedNumPrb); + + /*PRB Alloc for Default LCs*/ + prbAllocUsingRRMPolicy(&(schSpcHqProcCb->lcCb.defLcList), FALSE, mcsIdx, pdschNumSymbols,\ + &(schSpcHqProcCb->lcCb.sharedNumPrb), NULLP, &isTxPayloadLenAdded, NULLP); + } + else + { + schSpcHqProcCb->lcCb.sharedNumPrb = maxFreePRB - rsvdDedicatedPRB; + /*PRB Alloc for Dedicated LCs*/ + prbAllocUsingRRMPolicy(&(schSpcHqProcCb->lcCb.dedLcList), TRUE, mcsIdx, pdschNumSymbols,\ + &(schSpcHqProcCb->lcCb.sharedNumPrb), &(rsvdDedicatedPRB), &isTxPayloadLenAdded, NULLP); + + /*PRB Alloc for Default LCs*/ + prbAllocUsingRRMPolicy(&(schSpcHqProcCb->lcCb.defLcList), FALSE, mcsIdx, pdschNumSymbols, \ + &(schSpcHqProcCb->lcCb.sharedNumPrb), &(rsvdDedicatedPRB), &isTxPayloadLenAdded, NULLP); + } + } + } + + /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes + * using allocated BO per LC and Update dlMsgAlloc BO report for MAC */ + if (isRetx == FALSE) + { + if(schSpcHqProcCb->lcCb.dedLcList.count != 0) + updateGrantSizeForBoRpt(&(schSpcHqProcCb->lcCb.dedLcList), dciSlotAlloc, NULLP, &(accumalatedSize)); + + updateGrantSizeForBoRpt(&(schSpcHqProcCb->lcCb.defLcList), dciSlotAlloc, NULLP, &(accumalatedSize)); + } + else + { + accumalatedSize = (*hqP)->tbInfo[0].tbSzReq; + } + + /*Below case will hit if NO LC(s) are allocated due to resource crunch*/ + if (!accumalatedSize) + { + if(maxFreePRB == 0) + { + DU_LOG("\nERROR --> SCH : NO FREE PRB!!"); + } + else + { + /*Schedule the LC for next slot*/ + DU_LOG("\nDEBUG --> SCH : No LC has been scheduled"); + } + /* Not Freeing dlMsgAlloc as ZERO BO REPORT to be sent to RLC so that + * Allocation can be done in next slot*/ + accumalatedSize = 0; + } + + return accumalatedSize; +} + +/******************************************************************* + * + * @brief Scheduling of Slots in UL And DL + * + * @details + * + * Function : schSliceBasedScheduleSlot + * + * Functionality: Scheduling of slots in UL and DL specific to + * Slice Based scheduling + * + * @params[in] Pointer to Cell + * Slot timing info + * Scheduler instance + * @return void + * + * ****************************************************************/ +void schSliceBasedScheduleSlot(SchCellCb *cell, SlotTimingInfo *slotInd, Inst schInst) +{ + SchSliceBasedCellCb *schSpcCell; + SchSliceBasedUeCb *schSpcUeCb; + SchDlHqProcCb *hqP = NULLP; + SchUlHqProcCb *ulHqP = NULLP; + CmLList *pendingUeNode; + CmLList *node; + uint8_t ueId; + bool isRarPending = false, isRarScheduled = false; + bool isMsg4Pending = false, isMsg4Scheduled = false; + bool isDlMsgPending = false, isDlMsgScheduled = false; + bool isUlGrantPending = false, isUlGrantScheduled = false; + + schSpcCell = (SchSliceBasedCellCb *)cell->schSpcCell; + + /* Select first UE in the linked list to be scheduled next */ + pendingUeNode = schSpcCell->ueToBeScheduled.first; + if(pendingUeNode) + { + if(pendingUeNode->node) + { + ueId = *(uint8_t *)(pendingUeNode->node); + schSpcUeCb = (SchSliceBasedUeCb *)cell->ueCb[ueId-1].schSpcUeCb; + + /* If RAR is pending for this UE, schedule PDCCH,PDSCH to send RAR and + * PUSCH to receive MSG3 as per k0-k2 configuration*/ + if(cell->raReq[ueId-1] != NULLP) + { + isRarPending = true; + isRarScheduled = schProcessRaReq(schInst, cell, *slotInd, ueId); + } + + /*MSG3 retransmisson*/ + if(cell->raCb[ueId-1].retxMsg3HqProc) + { + schMsg3RetxSchedulingForUe(&(cell->raCb[ueId-1])); + } + + /* If MSG4 is pending for this UE, schedule PDCCH,PDSCH to send MSG4 and + * PUCCH to receive UL msg as per k0-k1 configuration */ + if (cell->ueCb[ueId-1].retxMsg4HqProc) //should work from dlmap later tbd + { + /* Retransmission of MSG4 */ + isMsg4Pending = true; + if(schProcessMsg4Req(cell, *slotInd, ueId, TRUE, &cell->ueCb[ueId-1].retxMsg4HqProc) == ROK) + isMsg4Scheduled = true; + } + else + { + /* First transmission of MSG4 */ + if(cell->raCb[ueId-1].msg4recvd) + { + isMsg4Pending = true; + if(schProcessMsg4Req(cell, *slotInd, ueId, FALSE, &cell->ueCb[ueId-1].msg4HqProc) == ROK) + isMsg4Scheduled = true; + + /* If MSG4 scheduling failed, free the newly assigned HARQ process */ + if(!isMsg4Scheduled) + schDlReleaseHqProcess(cell->ueCb[ueId-1].msg4HqProc); + } + } + + if(isRarPending || isMsg4Pending) + { + /* If RAR or MSG is successfully scheduled then + * remove UE from linked list since no pending msgs for this UE */ + if(isRarScheduled || isMsg4Scheduled) + { + schSliceBasedRemoveUeFrmScheduleLst(cell, pendingUeNode); + } + /* If RAR/MSG4 is pending but couldnt be scheduled then, + * put this UE at the end of linked list to be scheduled later */ + else + { + cmLListAdd2Tail(&schSpcCell->ueToBeScheduled, cmLListDelFrm(&schSpcCell->ueToBeScheduled, pendingUeNode)); + } + } + +#ifdef NR_DRX + if((cell->ueCb[ueId-1].ueDrxInfoPres == true) && (cell->ueCb[ueId-1].drxUeCb.drxDlUeActiveStatus != true)) + { + if(pendingUeNode->node) + { + cmLListAdd2Tail(&schSpcCell->ueToBeScheduled, cmLListDelFrm(&schSpcCell->ueToBeScheduled, pendingUeNode)); + } + } + else +#endif + { + + /* DL Data */ + node = NULLP; + if(schSpcUeCb) + node = schSpcUeCb->hqRetxCb.dlRetxHqList.first; + if(node != NULLP) + { + /* DL Data ReTransmisson */ + isDlMsgPending = true; + isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, TRUE, ((SchDlHqProcCb**) &(node->node))); + if(isDlMsgScheduled) + { +#ifdef NR_DRX + schDrxStopDlHqRetxTmr(cell, &cell->ueCb[ueId-1], ((SchDlHqProcCb**) &(node->node))); +#endif + schSliceBasedRemoveFrmDlHqRetxList(&cell->ueCb[ueId-1], node); + } + } + else + { + /* DL Data new transmission */ + if((cell->boIndBitMap) & (1<ueCb[ueId-1], PHY_DELTA_DL + SCHED_DELTA); +#endif + } + } + } + + /* Scheduling of UL grant */ + node = NULLP; + if(schSpcUeCb) + node = schSpcUeCb->hqRetxCb.ulRetxHqList.first; + if(node != NULLP) + { + /* UL Data ReTransmisson */ + isUlGrantPending = true; + isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, TRUE, (SchUlHqProcCb**) &(node->node)); + if(isUlGrantScheduled) + { +#ifdef NR_DRX + schDrxStopUlHqRetxTmr(cell, &cell->ueCb[ueId-1], ((SchUlHqProcCb**) &(node->node))); +#endif + schSliceBasedRemoveFrmUlHqRetxList(&cell->ueCb[ueId-1], node); + } + } + else + { + /* UL Data new transmission */ + if(cell->ueCb[ueId-1].srRcvd || cell->ueCb[ueId-1].bsrRcvd) + { + isUlGrantPending = true; + isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, FALSE, &ulHqP); + if(!isUlGrantScheduled) + schUlReleaseHqProcess(ulHqP, FALSE); + else + { +#ifdef NR_DRX + schHdlDrxInActvStrtTmr(cell, &cell->ueCb[ueId-1], PHY_DELTA_UL + SCHED_DELTA); +#endif + } + } + } + + if(!isUlGrantPending && !isDlMsgPending) + { + /* No action required */ + } + else if((isUlGrantPending && !isUlGrantScheduled) || (isDlMsgPending && !isDlMsgScheduled)) + { + cmLListAdd2Tail(&schSpcCell->ueToBeScheduled, cmLListDelFrm(&schSpcCell->ueToBeScheduled, pendingUeNode)); + } + else + { + schSliceBasedRemoveUeFrmScheduleLst(cell, pendingUeNode); + } + } + } + } +} + +/******************************************************************* + * + * @brief Initializes all function pointers to Slice Based function handler + * + * @details + * + * Function : schSliceBasedAllApisInit + * + * Functionality: Initializes all function pointers to Slice Based + * function handler + * + * @params[in] Function pointer array + * @return void + * + * ****************************************************************/ +void schSliceBasedAllApisInit(SchAllApis *allSliceBasedApi) +{ + /* Interface API function pointers */ + allSliceBasedApi->SchCellCfgReq = schSliceBasedCellCfgReq; + allSliceBasedApi->SchCellDeleteReq = schSliceBasedCellDelReq; + allSliceBasedApi->SchAddUeConfigReq = SchSliceBasedAddUeConfigReq; + allSliceBasedApi->SchModUeConfigReq = SchSliceBasedModUeConfigReq; + allSliceBasedApi->SchUeDeleteReq = SchSliceBasedUeDeleteReq; + allSliceBasedApi->SchDlHarqInd = SchSliceBasedDlHarqInd; + allSliceBasedApi->SchCrcInd = schSliceBasedProcessCrcInd; + allSliceBasedApi->SchRachInd = schSliceBasedProcessRachInd; + allSliceBasedApi->SchPagingInd = schSliceBasedPagingInd; + allSliceBasedApi->SchRachRsrcReq = schSliceBasedRachRsrcReq; + allSliceBasedApi->SchRachRsrcRel = schSliceBasedRachRsrcRel; + allSliceBasedApi->SchDlRlcBoInfo = schSliceBasedDlRlcBoInfo; + allSliceBasedApi->SchSrUciInd = schSliceBasedSrUciInd; + allSliceBasedApi->SchBsr = schSliceBasedBsr; + + /* Internal API function pointers */ + allSliceBasedApi->SchAddToDlHqRetxList = schSliceBasedAddToDlHqRetxList; + allSliceBasedApi->SchAddToUlHqRetxList = schSliceBasedAddToUlHqRetxList; + allSliceBasedApi->SchRemoveFrmDlHqRetxList = schSliceBasedRemoveFrmDlHqRetxList; + allSliceBasedApi->SchRemoveFrmUlHqRetxList = schSliceBasedRemoveFrmUlHqRetxList; + allSliceBasedApi->SchAddUeToSchedule = schSliceBasedAddUeToSchedule; + allSliceBasedApi->SchRemoveUeFrmScheduleLst = schSliceBasedRemoveUeFrmScheduleLst; + allSliceBasedApi->SchInitDlHqProcCb = schSliceBasedInitDlHqProcCb; + allSliceBasedApi->SchInitUlHqProcCb = schSliceBasedInitUlHqProcCb; + allSliceBasedApi->SchFreeDlHqProcCb = schSliceBasedFreeDlHqProcCb; + allSliceBasedApi->SchFreeUlHqProcCb = schSliceBasedFreeUlHqProcCb; + allSliceBasedApi->SchDeleteDlHqProcCb = schSliceBasedDeleteDlHqProcCb; + allSliceBasedApi->SchDeleteUlHqProcCb = schSliceBasedDeleteUlHqProcCb; + allSliceBasedApi->SchScheduleSlot = schSliceBasedScheduleSlot; + allSliceBasedApi->SchScheduleDlLc = schSliceBasedScheduleDlLc; + allSliceBasedApi->SchScheduleUlLc = schSliceBasedScheduleUlLc; +} +/********************************************************************** + End of file +**********************************************************************/ + diff --git a/src/5gnrsch/sch_slice_based.h b/src/5gnrsch/sch_slice_based.h new file mode 100644 index 000000000..2763aba43 --- /dev/null +++ b/src/5gnrsch/sch_slice_based.h @@ -0,0 +1,58 @@ +/******************************************************************************* +################################################################################ +# 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. # +################################################################################ +*******************************************************************************/ + +typedef struct schSliceBasedCellCb +{ + CmLListCp ueToBeScheduled; /*!< Linked list to store UEs pending to be scheduled, */ +}SchSliceBasedCellCb; + +typedef struct schSliceBasedLcCb +{ + /* TODO: For Multiple RRMPolicies, Make DedicatedLcInfo as array/Double Pointer + * and have separate DedLCInfo for each RRMPolcyMemberList*/ + /* Dedicated LC List will be allocated, if any available*/ + CmLListCp dedLcList; /*Contain LCInfo per RRMPolicy*/ + CmLListCp defLcList; /*Linklist of LC assoc with Default S-NSSAI(s)*/ + /* SharedPRB number can be used by any LC. + * Need to calculate in every Slot based on PRB availability*/ + uint16_t sharedNumPrb; +}SchSliceBasedLcCb; + +typedef struct schSliceBasedHqProcCb +{ + SchSliceBasedLcCb lcCb; +}SchSliceBasedHqProcCb; + +typedef struct schSliceBasedHqCb +{ + CmLListCp ulRetxHqList; + CmLListCp dlRetxHqList; +}SchSliceBasedHqCb; + +typedef struct schSliceBasedUeCb +{ + SchSliceBasedHqCb hqRetxCb; +}SchSliceBasedUeCb; + +uint8_t schSliceBasedAddUeToSchedule(SchCellCb *cellCb, uint16_t ueIdToAdd); +void schSliceBasedAllApisInit(SchAllApis *allSliceBasedApi); + +/********************************************************************** + End of file + *********************************************************************/ + diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index b5a345201..861d14a61 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -320,7 +320,7 @@ PduTxOccsaion schCheckSsbOcc(SchCellCb *cell, SlotTimingInfo slotTime) { uint8_t ssb_rep; - ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod; + ssb_rep = cell->cellCfg.ssbPeriod; /* Identify SSB ocassion*/ if ((slotTime.sfn % SCH_MIB_TRANS == 0) && (slotTime.slot ==0)) @@ -363,7 +363,7 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime) } else if(cell->firstSib1Transmitted) { - if((slotTime.sfn % (cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod/10) == 0) && + if((slotTime.sfn % (SIB1_REPETITION_PERIOD/10) == 0) && (slotTime.slot == 0)) { return REPEATITION; @@ -423,7 +423,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, } else { - k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl; + k0K1InfoTbl = &cell->k0K1InfoTbl; } numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].numK0; @@ -432,9 +432,9 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k0Index; if(dedMsg != true) { - k0Val = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; - *pdschStartSymbol = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol; - *pdschSymblLen = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol; + k0Val = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; + *pdschStartSymbol = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol; + *pdschSymblLen = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol; } else { @@ -553,38 +553,45 @@ uint8_t schProcDlPageAlloc(SchCellCb *cell, SlotTimingInfo currTime, Inst schIns break; } /*Fill PDCCH: PDCCH Cfg is same as SIB1 as Paging will be a broadcast message*/ - memcpy(&dlPageAlloc.pagePdcchCfg, &cell->cellCfg.sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg)); - dlPageAlloc.pagePdcchCfg.dci.rnti = P_RNTI; - + memcpy(dlPageAlloc.pageDlDci.freqDomainResource, cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.freqDomainResource, 6 * sizeof(uint8_t)); + dlPageAlloc.pageDlDci.durationSymbols = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.durationSymbols; + dlPageAlloc.pageDlDci.cceRegMappingType = INTERLEAVED_CCE_REG_MAPPING; + dlPageAlloc.pageDlDci.cceReg.interleaved.regBundleSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.regBundleSize; + dlPageAlloc.pageDlDci.cceReg.interleaved.interleaverSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.interleaverSize; + dlPageAlloc.pageDlDci.cceReg.interleaved.shiftIndex = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.shiftIndex; + dlPageAlloc.pageDlDci.ssStartSymbolIndex = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.startSymbolIndex; + dlPageAlloc.pageDlDci.cceIndex = cell->sib1SchCfg.sib1PdcchCfg.dci.cceIndex; + dlPageAlloc.pageDlDci.aggregLevel = cell->sib1SchCfg.sib1PdcchCfg.dci.aggregLevel; + dlPageAlloc.pageDlDci.precoderGranularity = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.precoderGranularity; + dlPageAlloc.pageDlDci.coreSetSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.coreSetSize; /*Fill BWP*/ - memcpy(&dlPageAlloc.bwp, &cell->cellCfg.sib1SchCfg.bwp, sizeof(BwpCfg)); + memcpy(&dlPageAlloc.bwp, &cell->sib1SchCfg.bwp, sizeof(BwpCfg)); /*Fill PDSCH*/ - if(schFillPagePdschCfg(cell, &dlPageAlloc.pagePdschCfg, pdschTime, tbSize, pageInfo->mcs, startPrb) != ROK) + if(schFillPagePdschCfg(cell, &dlPageAlloc.pageDlSch, pdschTime, tbSize, pageInfo->mcs, startPrb) != ROK) { DU_LOG("\nERROR --> SCH: Issue in PDSCH Allocation for Paging at SFN:%d, SLOT:%d",\ pdschTime.sfn, pdschTime.slot); break; } - dlPageAlloc.pagePdcchCfg.dci.pdschCfg = &dlPageAlloc.pagePdschCfg; /*Fill Page PDU information*/ - dlPageAlloc.dlPagePduLen = pageInfo->msgLen; + dlPageAlloc.pageDlSch.dlPagePduLen = pageInfo->msgLen; - SCH_ALLOC(dlPageAlloc.dlPagePdu, sizeof(dlPageAlloc.dlPagePduLen)); + SCH_ALLOC(dlPageAlloc.pageDlSch.dlPagePdu, sizeof(dlPageAlloc.pageDlSch.dlPagePduLen)); - if(dlPageAlloc.dlPagePdu == NULLP) + if(dlPageAlloc.pageDlSch.dlPagePdu == NULLP) { DU_LOG("\nERROR --> SCH: Memory Allocation Failed during Page Resource allocation"); break; } - memcpy(dlPageAlloc.dlPagePdu, pageInfo->pagePdu, dlPageAlloc.dlPagePduLen); + memcpy(dlPageAlloc.pageDlSch.dlPagePdu, pageInfo->pagePdu, dlPageAlloc.pageDlSch.dlPagePduLen); /* Send msg to MAC */ if(sendDlPageAllocToMac(&dlPageAlloc, schInst) != ROK) { DU_LOG("\nERROR --> SCH : Sending DL Paging allocation from SCH to MAC failed"); - SCH_FREE(dlPageAlloc.dlPagePdu, sizeof(dlPageAlloc.dlPagePduLen)); + SCH_FREE(dlPageAlloc.pageDlSch.dlPagePdu, sizeof(dlPageAlloc.pageDlSch.dlPagePduLen)); break; } ret = ROK; @@ -633,8 +640,8 @@ uint8_t SchProcSlotInd(Pst *pst, SlotTimingInfo *slotInd) memset(&dlSchedInfo, 0, sizeof(DlSchedInfo)); schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue, cell->numSlots); dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc; - dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION; - dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION; + dlBrdcstAlloc->ssbTransmissionMode = NO_TRANSMISSION; + dlBrdcstAlloc->sib1TransmissionMode = NO_TRANSMISSION; memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo)); dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED; @@ -647,35 +654,35 @@ uint8_t SchProcSlotInd(Pst *pst, SlotTimingInfo *slotInd) #endif /* Check for SSB occassion */ - dlBrdcstAlloc->ssbTrans = schCheckSsbOcc(cell, dlSchedInfo.schSlotValue.broadcastTime); - if(dlBrdcstAlloc->ssbTrans) + dlBrdcstAlloc->ssbTransmissionMode = schCheckSsbOcc(cell, dlSchedInfo.schSlotValue.broadcastTime); + if(dlBrdcstAlloc->ssbTransmissionMode) { if(schBroadcastSsbAlloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK) { DU_LOG("\nERROR --> SCH : schBroadcastSsbAlloc failed"); - dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION; + dlBrdcstAlloc->ssbTransmissionMode = NO_TRANSMISSION; } else { dlSchedInfo.isBroadcastPres = true; - if((dlBrdcstAlloc->ssbTrans == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted)) + if((dlBrdcstAlloc->ssbTransmissionMode == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted)) cell->firstSsbTransmitted = true; } } /* Check for SIB1 occassion */ - dlBrdcstAlloc->sib1Trans = schCheckSib1Occ(cell, dlSchedInfo.schSlotValue.broadcastTime); - if(dlBrdcstAlloc->sib1Trans) + dlBrdcstAlloc->sib1TransmissionMode = schCheckSib1Occ(cell, dlSchedInfo.schSlotValue.broadcastTime); + if(dlBrdcstAlloc->sib1TransmissionMode) { if(schBroadcastSib1Alloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK) { DU_LOG("\nERROR --> SCH : schBroadcastSib1Alloc failed"); - dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION; + dlBrdcstAlloc->sib1TransmissionMode = NO_TRANSMISSION; } else { dlSchedInfo.isBroadcastPres = true; - if((dlBrdcstAlloc->sib1Trans == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted)) + if((dlBrdcstAlloc->sib1TransmissionMode == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted)) cell->firstSib1Transmitted = true; } } diff --git a/src/5gnrsch/sch_ue_mgr.c b/src/5gnrsch/sch_ue_mgr.c index 0d84ba58a..e15981bf5 100644 --- a/src/5gnrsch/sch_ue_mgr.c +++ b/src/5gnrsch/sch_ue_mgr.c @@ -963,7 +963,7 @@ uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSi uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo *dciInfo) { SchCellCb *cellCb = raCb->cell; - dciInfo->cellId = cellCb->cellId; + dciInfo->crnti = raCb->tcrnti; SchUlHqProcCb *msg3HqProc = &raCb->msg3HqProc; if (msg3HqProc == NULLP) @@ -972,10 +972,10 @@ uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo } /* fill bwp cfg */ - dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing; - dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix; - dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb; - dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb; + dciInfo->bwpCfg.subcarrierSpacing = cellCb->sib1SchCfg.bwp.subcarrierSpacing; + dciInfo->bwpCfg.cyclicPrefix = cellCb->sib1SchCfg.bwp.cyclicPrefix; + dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb; + dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb; /*fill coreset cfg */ //Considering number of RBs in coreset1 is same as coreset0 @@ -983,7 +983,7 @@ uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo //Considering coreset1 also starts from same symbol as coreset0 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3]; dciInfo->coresetCfg.durationSymbols = coresetIdxTable[0][2]; - memcpy(dciInfo->coresetCfg.freqDomainResource, cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); + memcpy(dciInfo->coresetCfg.freqDomainResource, cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); dciInfo->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */ dciInfo->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */ @@ -995,24 +995,24 @@ uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */ dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */ - dciInfo->formatType = FORMAT0_0; + dciInfo->dciFormatInfo.formatType = FORMAT0_0; msg3HqProc->tbInfo.rvIdx++; msg3HqProc->tbInfo.rv = schCmnDlRvTbl[msg3HqProc->tbInfo.rvIdx & 0x03]; /* fill UL grant */ - dciInfo->format.format0_0.resourceAllocType = msg3HqProc->puschResType; - dciInfo->format.format0_0.freqAlloc.startPrb = msg3HqProc->puschStartPrb; - dciInfo->format.format0_0.freqAlloc.numPrb = msg3HqProc->puschNumPrb; - dciInfo->format.format0_0.timeAlloc.startSymb = msg3HqProc->strtSymbl; - dciInfo->format.format0_0.timeAlloc.numSymb = msg3HqProc->numSymbl; - dciInfo->format.format0_0.rowIndex = 0; /* row Index */ - dciInfo->format.format0_0.mcs = msg3HqProc->tbInfo.iMcs; - dciInfo->format.format0_0.harqProcId = msg3HqProc->procId; - dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */ - dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */ - dciInfo->format.format0_0.ndi = msg3HqProc->tbInfo.ndi; /* new transmission */ - dciInfo->format.format0_0.rv = msg3HqProc->tbInfo.rv; - dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check - dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */ + dciInfo->dciFormatInfo.format.format0_0.resourceAllocType = msg3HqProc->puschResType; + dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAllocType = msg3HqProc->puschResType; + dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb = msg3HqProc->puschStartPrb; + dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb = msg3HqProc->puschNumPrb; + dciInfo->dciFormatInfo.format.format0_0.timeAlloc.startSymb = msg3HqProc->strtSymbl; + dciInfo->dciFormatInfo.format.format0_0.timeAlloc.numSymb = msg3HqProc->numSymbl; + dciInfo->dciFormatInfo.format.format0_0.rowIndex = 0; /* row Index */ + dciInfo->dciFormatInfo.format.format0_0.mcs = msg3HqProc->tbInfo.iMcs; + dciInfo->dciFormatInfo.format.format0_0.harqProcId = msg3HqProc->procId; + dciInfo->dciFormatInfo.format.format0_0.freqHopFlag = FALSE; /* disabled */ + dciInfo->dciFormatInfo.format.format0_0.ndi = msg3HqProc->tbInfo.ndi; /* new transmission */ + dciInfo->dciFormatInfo.format.format0_0.rvIndex = msg3HqProc->tbInfo.rv; + dciInfo->dciFormatInfo.format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check + dciInfo->dciFormatInfo.format.format0_0.sulIndicator = FALSE; /* SUL not configured */ /* Fill DCI Structure */ dciInfo->dciInfo.rnti = raCb->tcrnti; @@ -1025,7 +1025,7 @@ uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0; dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0; dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0; - dciInfo->dciInfo.txPdcchPower.powerValue = 0; + dciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0 = 0; dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0; dciInfo->dciInfo.pdschCfg = NULL; /* No DL data being sent */ msg3HqProc->tbInfo.txCntr++; @@ -1077,14 +1077,13 @@ uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, b coreset1 = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdcchCfg.cRSetToAddModList[0]; } - dciInfo->cellId = cellCb->cellId; dciInfo->crnti = ueCb->crnti; /* fill bwp cfg */ - dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing; - dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix; - dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb; - dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb; + dciInfo->bwpCfg.subcarrierSpacing = cellCb->sib1SchCfg.bwp.subcarrierSpacing; + dciInfo->bwpCfg.cyclicPrefix = cellCb->sib1SchCfg.bwp.cyclicPrefix; + dciInfo->bwpCfg.freqAlloc.startPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb; + dciInfo->bwpCfg.freqAlloc.numPrb = cellCb->cellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb; /*fill coreset cfg */ //Considering number of RBs in coreset1 is same as coreset0 @@ -1103,23 +1102,25 @@ uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, b dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */ dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */ - dciInfo->formatType = FORMAT0_0; + dciInfo->dciFormatInfo.formatType = FORMAT0_0; /* fill UL grant */ - dciInfo->format.format0_0.resourceAllocType = puschInfo->fdAlloc.resAllocType; - dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo->fdAlloc.resAlloc.type1.startPrb; - dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo->fdAlloc.resAlloc.type1.numPrb; - dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo->tdAlloc.startSymb; - dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo->tdAlloc.numSymb; - dciInfo->format.format0_0.rowIndex = 0; /* row Index */ - dciInfo->format.format0_0.mcs = puschInfo->tbInfo.mcs; - dciInfo->format.format0_0.harqProcId = puschInfo->harqProcId; - dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */ - dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */ - dciInfo->format.format0_0.ndi = puschInfo->tbInfo.ndi; /* new transmission */ - dciInfo->format.format0_0.rv = puschInfo->tbInfo.rv; - dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check - dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */ + dciInfo->dciFormatInfo.format.format0_0.resourceAllocType = puschInfo->fdAlloc.resAllocType; + dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAllocType = puschInfo->fdAlloc.resAllocType; + dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb = \ + puschInfo->fdAlloc.resAlloc.type1.startPrb; + dciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb = \ + puschInfo->fdAlloc.resAlloc.type1.numPrb; + dciInfo->dciFormatInfo.format.format0_0.timeAlloc.startSymb = puschInfo->tdAlloc.startSymb; + dciInfo->dciFormatInfo.format.format0_0.timeAlloc.numSymb = puschInfo->tdAlloc.numSymb; + dciInfo->dciFormatInfo.format.format0_0.rowIndex = 0; /* row Index */ + dciInfo->dciFormatInfo.format.format0_0.mcs = puschInfo->tbInfo.mcs; + dciInfo->dciFormatInfo.format.format0_0.harqProcId = puschInfo->harqProcId; + dciInfo->dciFormatInfo.format.format0_0.freqHopFlag = FALSE; /* disabled */ + dciInfo->dciFormatInfo.format.format0_0.ndi = puschInfo->tbInfo.ndi; /* new transmission */ + dciInfo->dciFormatInfo.format.format0_0.rvIndex = puschInfo->tbInfo.rv; + dciInfo->dciFormatInfo.format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check + dciInfo->dciFormatInfo.format.format0_0.sulIndicator = FALSE; /* SUL not configured */ /* Fill DCI Structure */ dciInfo->dciInfo.rnti = ueCb->crnti; @@ -1132,7 +1133,7 @@ uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, b dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0; dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0; dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0; - dciInfo->dciInfo.txPdcchPower.powerValue = 0; + dciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0 = 0; dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0; dciInfo->dciInfo.pdschCfg = NULL; /* No DL data being sent */ diff --git a/src/cm/common_def.c b/src/cm/common_def.c index 785956ca7..444db96f8 100644 --- a/src/cm/common_def.c +++ b/src/cm/common_def.c @@ -18,6 +18,14 @@ #include "common_def.h" +/*Spec 38.104, Table 5.4.2.1-1 ARFCN - FREQ mapping*/ +/*{ F_REF(Mhz), ΔF_Global, F_REF-Offs, N_REF-offs, Range of N_REF }*/ +uint32_t arfcnFreqTable[3][5] = { + { 3000, 5, 0, 0, 599999 }, /*index 0*/ + { 24250, 15, 3000, 600000, 2016666 }, /*index 1*/ + { 100000, 60, 24250.08, 2016667, 3279165 }, /*index 2*/ +}; + /** * @brief frequency domain allocation function. * @@ -417,6 +425,75 @@ uint8_t countSetBits(uint32_t num) return(count); } +/******************************************************************* +* +* @brief convert ARFCN to freq in kHZ +* +* @details +* +* Function : convertArfcnToFreqKhz +* +* Functionality: convert ARFCN to freq in kHZ as per Table below +* 3GPP TS 38.104, Table 5.4.2.1-1 +* Formula: F_REF = F_REF-Offs + ΔF_Global (N_REF – N_REF-Offs) +* +* @params[in] uint32_t number +* +* @return [out] uint32_t Freq in kHZ +* +* ****************************************************************/ +uint32_t convertArfcnToFreqKhz(uint32_t arfcn) +{ + uint8_t indexTable = 0; + uint32_t freq = 0; + + for(indexTable = 0; indexTable < 4; indexTable++) + { + if(arfcn <= arfcnFreqTable[indexTable][4]) + { + freq = arfcnFreqTable[indexTable][2] + (arfcnFreqTable[indexTable][1] * (arfcn - arfcnFreqTable[indexTable][3])); + return (freq*1000); + } + } + DU_LOG("ERROR --> DUAPP: ARFCN vaid range is between 0 and 3279165"); + return (freq*1000); +} + + +/******************************************************************* +* +* @brief convert Freq(MHZ) to ARFCN +* +* @details +* +* Function : convertFreqToArfcn +* +* Functionality: convert freq to ARFCN as per Table below +* 3GPP TS 38.104, Table 5.4.2.1-1 +* Formula: NREF = NREF-Offs + (FREF – FREF-Offs) / ΔFGlobal +* +* @params[in] uint32_t Freq(MHZ) +* +* @return [out] uint32_t ARFCN(number) +* +* ****************************************************************/ +uint32_t convertFreqToArfcn(uint32_t freq) +{ + uint8_t indexTable = 0; + uint32_t arfcn = 0; + + for(indexTable = 0; indexTable < 4; indexTable++) + { + if(freq < arfcnFreqTable[indexTable][0]) + { + arfcn = arfcnFreqTable[indexTable][3] + ((freq - arfcnFreqTable[indexTable][2]) / (arfcnFreqTable[indexTable][1])); + return (arfcn); + } + } + DU_LOG("ERROR --> DUAPP: FREQ vaid range is between 0 and 100000 MHz"); + return (arfcn); +} + /********************************************************************** End of file **********************************************************************/ diff --git a/src/cm/common_def.h b/src/cm/common_def.h index 9c3d555e7..4c0a55a93 100644 --- a/src/cm/common_def.h +++ b/src/cm/common_def.h @@ -240,13 +240,6 @@ typedef enum }ConfigType; #ifdef NR_TDD -typedef enum -{ - DL_SLOT, - UL_SLOT, - FLEXI_SLOT -}SlotConfig; - typedef enum { TX_PRDCTY_MS_0P5, @@ -330,9 +323,11 @@ typedef struct oduCellId #ifdef NR_TDD typedef struct tddCfg { - bool pres; - DlUlTxPeriodicity tddPeriod; /* DL UL Transmission periodicity */ - SlotConfig slotCfg[MAX_TDD_PERIODICITY_SLOTS][MAX_SYMB_PER_SLOT]; + DlUlTxPeriodicity tddPeriod; /*DL UL Transmission periodicity */ + uint8_t nrOfDlSlots; /*No. of consecultive full DL slots at beginning of DL-UL pattern*/ + uint8_t nrOfDlSymbols; /*No. of consecultive DL symbol at beginning of slot after last full DL slot*/ + uint8_t nrOfUlSlots; /*No. of consecutive full UL slots at the end of each DL-UL pattern*/ + uint8_t nrOfUlSymbols; /*No. of consecutive UL symbols in the end of the slot before the first full UL slot*/ }TDDCfg; #endif @@ -354,7 +349,7 @@ Region region, Pool pool, Data **ptr, Size size, uint8_t memType); uint8_t SPutStaticBufNewForDebug(char *file, const char *func, int line, \ Region region, Pool pool, Data *ptr, Size size, uint8_t memType); uint8_t countSetBits(uint32_t num); - +uint32_t convertArfcnToFreqKhz(uint32_t arfcn); #endif /********************************************************************** diff --git a/src/cm/du_app_mac_inf.h b/src/cm/du_app_mac_inf.h index d9d8bca1f..8d2980170 100644 --- a/src/cm/du_app_mac_inf.h +++ b/src/cm/du_app_mac_inf.h @@ -90,6 +90,7 @@ #define BSR_SR_DELAY_TMR_2560 2560 #define PAGING_SCHED_DELTA 4 +#define MAX_PLMN 2 typedef enum { @@ -152,7 +153,7 @@ typedef enum typedef enum { BETA_PSS_0DB, - BETA_PSS_1DB + BETA_PSS_3DB }BetaPss; typedef enum @@ -531,28 +532,91 @@ typedef struct failureCause typedef struct carrierCfg { - bool pres; - uint32_t bw; /* DL/UL bandwidth */ - uint32_t freq; /* Absolute frequency of DL/UL point A in KHz */ - uint16_t k0[NUM_NUMEROLOGY]; /* K0 for DL/UL */ - uint16_t gridSize[NUM_NUMEROLOGY]; /* DL/UL Grid size for each numerologies */ - uint16_t numAnt; /* Number of Tx/Rx antennas */ + uint32_t dlBw; /* DL bandwidth */ + uint32_t dlFreq; /* Absolute frequency of DL point A in KHz */ + uint32_t ulBw; /* UL bandwidth */ + uint32_t ulFreq; /* Absolute frequency of UL point A in KHz */ + uint16_t numTxAnt; /* Number of Tx antennas */ + uint16_t numRxAnt; /* Number of Rx antennas */ }CarrierCfg; +typedef enum +{ + OP_DISABLED, + OP_ENABLED, +}MacOpState; + +typedef enum +{ + ADMIN_LOCKED, + ADMIN_UNLOCKED, + ADMIN_SHUTTING_DOWN, +}MacAdminState; + +typedef enum +{ + CELL_IDLE, + CELL_INACTIVE, + CELL_ACTIVE, +}MacCellState; + +typedef struct plmnInfoList +{ + Plmn plmn; + uint8_t numSupportedSlice; /* Total slice supporting */ + Snssai **snssai; /* List of supporting snssai*/ +}PlmnInfoList; + +typedef struct schPageCfg +{ + uint8_t numPO; /*Derived from Ns*/ + bool poPresent; /*Whether FirstPDCCH-MonitoringPO is present or not*/ + uint16_t pagingOcc[MAX_PO_PER_PF]; /*FirstPDCCH-Monitoring Paging Occasion*/ +}SchPageCfg; + +typedef struct pdcchConfigSib1 +{ + uint8_t coresetZeroIndex; /* derived from 4 LSB of pdcchSib1 present in MIB */ + uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */ +}PdcchConfigSib1; + +typedef struct sib1CellCfg +{ + PdcchConfigSib1 pdcchCfgSib1; /*Freq pos where UE may find SS/PBCH block with SIB1*/ + uint8_t *sib1Pdu; + uint16_t sib1PduLen; + SchPageCfg pagingCfg; +} Sib1CellCfg; + + +typedef struct cellCfg +{ + MacOpState opState; + MacAdminState adminState; + MacCellState cellState; + PlmnInfoList plmnInfoList[MAX_PLMN]; /* Consits of PlmnId and Snssai list */ + uint32_t phyCellId; /* Physical cell id */ + uint32_t tac; + uint32_t ssbFreq; + uint16_t subCarrSpacing; + DuplexMode dupType; /* Duplex type: TDD/FDD */ + uint8_t numerology; /* Supported numerology */ + Sib1CellCfg sib1Cfg; /* SIB1 config */ +}CellCfg; + typedef struct ssbCfg { uint32_t ssbPbchPwr; /* SSB block power */ - BchPduOpt bchPayloadFlag; /* Options for generation of payload */ uint8_t scsCmn; /* subcarrier spacing for common */ uint16_t ssbOffsetPointA; /* SSB subcarrier offset from point A */ - BetaPss betaPss; SSBPeriod ssbPeriod; /* SSB Periodicity in msec */ uint8_t ssbScOffset; /* Subcarrier Offset */ - uint8_t mibPdu[3]; /* MIB payload */ uint32_t ssbMask[SSB_MASK_SIZE]; /* Bitmap for actually transmitted SSB. */ uint8_t beamId[NUM_SSB]; - bool multCarrBand; /* Multiple carriers in a band */ - bool multCellCarr; /* Multiple cells in single carrier */ + BetaPss betaPss; + BchPduOpt bchPayloadFlag; /* Options for generation of payload */ + uint8_t mibPdu[3]; /* MIB payload */ + uint8_t dmrsTypeAPos; /* DMRS Type A position */ }SsbCfg; typedef struct fdmInfo @@ -561,49 +625,25 @@ typedef struct fdmInfo uint8_t numRootSeq; /* Number of root sequences required for FD */ uint16_t k1; /* Frequency Offset for each FD */ uint8_t zeroCorrZoneCfg; /* Zero correlation zone cofig */ - uint8_t numUnusedRootSeq; /* Number of unused root sequence */ - uint8_t *unsuedRootSeq; /* Unused root sequence per FD */ }PrachFdmInfo; typedef struct prachCfg { - bool pres; - uint8_t prachCfgIdx; /* PRACH Cfg Index */ PrachSeqLen prachSeqLen; /* RACH Sequence length: Long/short */ uint8_t prachSubcSpacing; /* Subcarrier spacing of RACH */ - RstSetCfg prachRstSetCfg; /* PRACH restricted set config */ - uint16_t msg1FreqStart; /* Msg1-FrequencyStart */ - uint8_t msg1Fdm; /* PRACH FDM (1,2,4,8) */ - uint8_t rootSeqLen; /* Root sequence length */ + uint8_t msg1Fdm; /* Number of RACH frequency domain occasions/ PRACH FDM (1,2,4,8) */ + uint8_t prachCfgIdx; /* PRACH Cfg Index */ PrachFdmInfo fdm[8]; /* FDM info */ - uint8_t totalNumRaPreamble; /* Total number of RA preambles */ + RstSetCfg prachRstSetCfg; /* PRACH restricted set config */ uint8_t ssbPerRach; /* SSB per RACH occassion */ + uint8_t totalNumRaPreamble; /* Total number of RA preambles */ uint8_t numCbPreamblePerSsb; /* Number of CB preamble per SSB */ - bool prachMultCarrBand; /* Multiple carriers in Band */ - uint8_t prachRestrictedSet; /* Support for PRACH restricted set */ + uint16_t msg1FreqStart; /* Msg1-FrequencyStart */ uint8_t raContResTmr; /* RA Contention Resoultion Timer */ uint8_t rsrpThreshSsb; /* RSRP Threshold SSB */ uint8_t raRspWindow; /* RA Response Window */ }PrachCfg; -typedef struct schPageCfg -{ - uint8_t numPO; /*Derived from Ns*/ - bool poPresent; /*Whether FirstPDCCH-MonitoringPO is present or not*/ - uint16_t pagingOcc[MAX_PO_PER_PF]; /*FirstPDCCH-Monitoring Paging Occasion*/ -}SchPageCfg; - -typedef struct sib1CellCfg -{ - uint8_t *sib1Pdu; - uint16_t sib1PduLen; - uint16_t sib1RepetitionPeriod; - uint8_t coresetZeroIndex; /* derived from 4 LSB of pdcchSib1 present in MIB */ - uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */ - uint16_t sib1Mcs; - SchPageCfg pagingCfg; -} Sib1CellCfg; - typedef struct bwpParams { uint16_t firstPrb; @@ -662,11 +702,11 @@ typedef struct pucchConfigCommon /* PUSCH Time Domain Resource Allocation */ typedef struct puschTimeDomRsrcAlloc { - uint8_t k2; + uint8_t k2; CommonMappingType mappingType; - uint8_t startSymbol; - uint8_t symbolLength; - uint8_t startSymbolAndLength; + uint8_t startSymbol; + uint8_t symbolLength; + uint8_t startSymbolAndLength; }PuschTimeDomRsrcAlloc; @@ -679,26 +719,19 @@ typedef struct puschConfigCommon typedef struct bwpDlConfig { - BwpParams bwp; + BwpParams bwp; PdcchConfigCommon pdcchCommon; PdschConfigCommon pdschCommon; }BwpDlConfig; typedef struct bwpUlConfig { - BwpParams bwp; + BwpParams bwp; // rach config common sent in PrachCfg PucchConfigCommon pucchCommon; PuschConfigCommon puschCommon; }BwpUlConfig; -typedef struct plmnInfoList -{ - Plmn plmn; - uint8_t numSupportedSlice; /* Total slice supporting */ - Snssai **snssai; /* List of supporting snssai*/ -}PlmnInfoList; - #ifdef NR_DRX /* The following list of structures is taken from the DRX-Config section of specification 33.331. */ typedef struct drxOnDurationTimer @@ -738,28 +771,41 @@ typedef struct drxCfg }DrxCfg; #endif +typedef struct precodingConf +{ + uint16_t numLayers; + uint16_t numAntPorts; +}PrecodingConf; + +typedef struct beamformingConf +{ + uint16_t numOfBeams; + uint16_t numTxRUs; + uint16_t beamIdx; + uint16_t beamType; + uint32_t beamAzimuth; + uint32_t beamTilt; + uint32_t beamHorizWidth; + uint32_t beamVertWidth; + uint32_t coverageShape; + uint32_t digitalTilt; + uint32_t digitalAzimuth; +}BeamformingConf; + typedef struct macCellCfg { - uint16_t cellId; /* Cell Id */ - uint8_t carrierId; /* Carrired Index */ - uint16_t phyCellId; /* Physical cell id */ - uint8_t numerology; /* Supported numerology */ - DuplexMode dupType; /* Duplex type: TDD/FDD */ - CarrierCfg dlCarrCfg; /* DL Carrier configuration */ - CarrierCfg ulCarrCfg; /* UL Carrier configuration */ - bool freqShft; /* Indicates presence of 7.5kHz frequency shift */ - SsbCfg ssbCfg; /* SSB configuration */ - PrachCfg prachCfg; /* PRACH Configuration */ + uint16_t cellId; /* Cell Id */ + CarrierCfg carrCfg; /* Carrier configuration */ + CellCfg cellCfg; /* Cell Configuration*/ + SsbCfg ssbCfg; /* SSB configuration */ + PrachCfg prachCfg; /* PRACH Configuration */ #ifdef NR_TDD - TDDCfg tddCfg; /* TDD periodicity and slot configuration */ + TDDCfg tddCfg; /* TDD periodicity and slot configuration */ #endif - RSSIMeasUnit rssiUnit; /* RSSI measurement unit */ - Sib1CellCfg sib1Cfg; /* SIB1 config */ - BwpDlConfig initialDlBwp; /* Initial DL BWP */ - BwpUlConfig initialUlBwp; /* Initial UL BWP */ - uint8_t dmrsTypeAPos; /* DMRS Type A position */ - PlmnInfoList plmnInfoList; /* Consits of PlmnId and Snssai list */ - //RrmPolicy *rrmPolicy; /* RRM policy details */ + BwpDlConfig initialDlBwp; /* Initial DL BWP */ + BwpUlConfig initialUlBwp; /* Initial UL BWP */ + PrecodingConf precodingConf; + BeamformingConf beamCfg; }MacCellCfg; typedef struct macCellCfgCfm diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index ef8b485b5..2c7d5ceea 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -106,6 +106,9 @@ #define DEFAULT_K2_VALUE_FOR_SCS60 2 #define DEFAULT_K2_VALUE_FOR_SCS120 3 +#define MAX_PLMN 2 +#define DL_DMRS_SYMBOL_POS 4 /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */ + #define ADD_DELTA_TO_TIME(crntTime, toFill, incr, numOfSlot) \ { \ if ((crntTime.slot + incr) > (numOfSlot - 1)) \ @@ -453,25 +456,14 @@ typedef struct resAllocType1 uint16_t numPrb; }ResAllocType1; -typedef struct -{ - uint32_t ssbPbchPwr; /* SSB block power */ - uint8_t scsCommon; /* subcarrier spacing for common [0-3]*/ - uint8_t ssbOffsetPointA; /* SSB sub carrier offset from point A */ - SchSSBPeriod ssbPeriod; /* SSB Periodicity in msec */ - uint8_t ssbSubcOffset; /* Subcarrier Offset(Kssb) */ - uint32_t nSSBMask[SCH_SSB_MASK_SIZE]; /* Bitmap for actually transmitted SSB. */ - - /*Ref:Spec 38.331 "ssb-PositionsInBurst", Value 0 in Bitmap => corresponding SS/PBCH block is not transmitted - *value 1 => corresponding SS/PBCH block is transmitted*/ - uint8_t totNumSsb; /*S = Total Number of Actual SSB transmitted*/ -}SchSsbCfg; +typedef struct resAllocType1 FreqDomainRsrc; +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Table 9-32 BWP Information */ typedef struct bwpCfg { uint8_t subcarrierSpacing; uint8_t cyclicPrefix; - ResAllocType1 freqAlloc; + FreqDomainRsrc freqAlloc; }BwpCfg; typedef struct prg @@ -517,14 +509,17 @@ typedef struct pdschFreqAlloc { uint8_t resourceAllocType; /* since we are using type-1, rbBitmap excluded */ - ResAllocType1 freqAlloc; + uint8_t rbBitmap[36]; + uint16_t startPrb; + uint16_t numPrb; uint8_t vrbPrbMapping; -} PdschFreqAlloc; +}PdschFreqAlloc; typedef struct pdschTimeAlloc { - uint8_t rowIndex; - TimeDomainAlloc timeAlloc; + uint8_t rowIndex; + uint16_t startSymb; + uint16_t numSymb; } PdschTimeAlloc; typedef struct txPowerPdschInfo @@ -533,6 +528,7 @@ typedef struct txPowerPdschInfo uint8_t powerControlOffsetSS; } TxPowerPdschInfo; +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Table 9-43 PDSCH Configuration */ typedef struct pdschCfg { uint16_t pduBitmap; @@ -554,6 +550,7 @@ typedef struct pdschCfg /* SIB1 interface structure */ +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Table 9-35 CORESET Configuration */ typedef struct coresetCfg { uint8_t coreSetSize; @@ -563,8 +560,9 @@ typedef struct coresetCfg uint8_t cceRegMappingType; uint8_t regBundleSize; uint8_t interleaverSize; - uint8_t coreSetType; uint16_t shiftIndex; + uint8_t coreSetType; + uint8_t coresetPoolIndex; uint8_t precoderGranularity; uint8_t cceIndex; uint8_t aggregationLevel; @@ -572,10 +570,11 @@ typedef struct coresetCfg typedef struct txPowerPdcchInfo { - uint8_t powerValue; + uint8_t beta_pdcch_1_0; uint8_t powerControlOffsetSS; -} TxPowerPdcchInfo; +}TxPowerPdcchInfo; +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Table 9-42 DL-DCI Configuration */ typedef struct dlDCI { uint16_t rnti; @@ -586,65 +585,59 @@ typedef struct dlDCI BeamformingInfo beamPdcchInfo; TxPowerPdcchInfo txPdcchPower; PdschCfg *pdschCfg; -} DlDCI; +}DlDCI; typedef struct pdcchCfg { /* coreset-0 configuration */ CoresetCfg coresetCfg; - - uint16_t numDlDci; - DlDCI dci; /* as of now its only one DCI, later it will be numDlCi */ + uint16_t numDlDci; + DlDCI dci; /* as of now its only one DCI, later it will be numDlCi */ } PdcchCfg; /* end of SIB1 PDCCH structures */ -typedef struct pageCfg +typedef struct schPcchCfg { uint8_t numPO; /*Derived from Ns*/ bool poPresent; /*FirstPDCCH-MonitoringPO is present or not*/ uint16_t pagingOcc[MAX_PO_PER_PF]; /*FirstPDCCH-Monitoring Paging Occasion*/ -}PageCfg; +}SchPcchCfg; -typedef struct +typedef struct schPdcchConfigSib1 { - /* parameters recieved from DU-APP */ - uint16_t sib1PduLen; - uint16_t sib1RepetitionPeriod; uint8_t coresetZeroIndex; /* derived from 4 LSB of pdcchSib1 present in MIB */ uint8_t searchSpaceZeroIndex; /* derived from 4 MSB of pdcchSib1 present in MIB */ - uint16_t sib1Mcs; +}SchPdcchConfigSib1; - /* parameters derived in scheduler */ - uint8_t n0; - BwpCfg bwp; - PdcchCfg sib1PdcchCfg; - PdschCfg sib1PdschCfg; - PageCfg pageCfg; /*Config of Paging*/ -}SchSib1Cfg; - -typedef struct schRachCfg +typedef struct schRachCfgGeneric { uint8_t prachCfgIdx; /* PRACH config idx */ - uint8_t prachSubcSpacing; /* Subcarrier spacing of RACH */ - uint16_t msg1FreqStart; /* Msg1-FrequencyStart */ uint8_t msg1Fdm; /* PRACH FDM (1,2,4,8) */ - uint8_t rootSeqLen; /* root sequence length */ - uint16_t rootSeqIdx; /* Root sequence index */ - uint8_t numRootSeq; /* Number of root sequences required for FD */ - uint16_t k1; /* Frequency Offset for each FD */ + uint16_t msg1FreqStart; /* Msg1-FrequencyStart */ + uint8_t zeroCorrZoneCfg; /* Zero correlation zone cofig */ + int16_t preambleRcvdTargetPower; + uint8_t preambleTransMax; + uint8_t pwrRampingStep; + uint8_t raRspWindow; /* RA Response Window */ +}SchRachCfgGeneric; + +typedef struct schRachCfg +{ + SchRachCfgGeneric prachCfgGeneric; uint8_t totalNumRaPreamble; /* Total number of RA preambles */ uint8_t ssbPerRach; /* SSB per RACH occassion */ uint8_t numCbPreamblePerSsb; /* Number of CB preamble per SSB */ - uint8_t prachMultCarrBand; /* Presence of Multiple carriers in Band */ uint8_t raContResTmr; /* RA Contention Resoultion Timer */ uint8_t rsrpThreshSsb; /* RSRP Threshold SSB */ - uint8_t raRspWindow; /* RA Response Window */ - uint8_t maxMsg3Tx; /* MAximum num of msg3 tx*/ + uint16_t rootSeqIdx; /* Root sequence index */ + uint16_t rootSeqLen; /* root sequence length */ + uint8_t numRootSeq; /* Number of root sequences required for FD */ + uint8_t msg1SubcSpacing; /* Subcarrier spacing of RACH */ }SchRachCfg; typedef struct schBwpParams { - ResAllocType1 freqAlloc; + FreqDomainRsrc freqAlloc; uint8_t scs; uint8_t cyclicPrefix; }SchBwpParams; @@ -739,7 +732,6 @@ typedef struct schBwpDlCfg SchBwpParams bwp; SchPdcchCfgCmn pdcchCommon; SchPdschCfgCmn pdschCommon; - SchK0K1TimingInfoTbl k0K1InfoTbl; }SchBwpDlCfg; typedef struct schK2TimingInfo @@ -757,10 +749,9 @@ typedef struct schK2TimingInfoTbl typedef struct schBwpUlCfg { SchBwpParams bwp; + SchRachCfg schRachCfg; /* PRACH config */ SchPucchCfgCmn pucchCommon; SchPuschCfgCmn puschCommon; - SchK2TimingInfoTbl msg3K2InfoTbl; - SchK2TimingInfoTbl k2InfoTbl; }SchBwpUlCfg; typedef struct schPlmnInfoList @@ -770,13 +761,6 @@ typedef struct schPlmnInfoList Snssai **snssai; /* List of supporting snssai*/ }SchPlmnInfoList; -typedef struct schHqCfgParam -{ - uint8_t maxDlDataHqTx; - uint8_t maxMsg4HqTx; - uint8_t maxUlDataHqTx; -}SchHqCfg; - #ifdef NR_DRX /* The following list of structures is taken from the DRX-Config section of specification 33.331. */ @@ -817,25 +801,99 @@ typedef struct schDrxCfg }SchDrxCfg; #endif +/*Spec 38.331 'NrNsPmaxList'*/ +typedef struct schNrNsPmaxList +{ + long additionalPMax; + long additionalSpectrumEmission; +}SchNrNsPmaxList; + +/*Spec 38.331 'FrequencyInfoDL-SIB'*/ +typedef struct schMultiFreqBandListSib +{ + long freqBandIndNr; + SchNrNsPmaxList nrNsPmaxList[1]; +}SchMultiFreqBandListSib; + +/*Spec 38.331 'SCS-SpecificCarrier'*/ +typedef struct schScsSpecificCarrier +{ + uint16_t offsetToCarrier; + uint8_t subCarrierSpacing; + uint16_t carrierBw; + uint16_t txDirectCurrentLoc; +}SchScsSpecificCarrier; + +/*Spec 38.331 'FrequencyInfoDL-SIB'*/ +typedef struct schFreqInfoDlSib +{ + SchMultiFreqBandListSib mutiFreqBandList[1]; + uint16_t offsetToPointA; + SchScsSpecificCarrier schSpcCarrier[1]; +}SchFreqInfoDlSib; + +typedef struct schBcchCfg +{ + long modPeriodCoeff; +}SchBcchCfg; + +/*Spec 38.331 'DownlinkConfigCommonSIB'*/ +typedef struct schDlCfgCommon +{ + SchFreqInfoDlSib schFreqInfoDlSib; + SchBwpDlCfg schInitialDlBwp; /* Initial DL BWP */ + SchBcchCfg schBcchCfg; + SchPcchCfg schPcchCfg; +}SchDlCfgCommon; + +/*Spec 38.331 'FrequencyInfoUL-SIB'*/ +typedef struct schFreqInfoUlSib +{ + SchMultiFreqBandListSib mutiFreqBandList[1]; + uint16_t absoluteFreqPointA; + SchScsSpecificCarrier schSpcCarrier[1]; + int8_t schPMax; + bool frequencyShift7p5khz; +}SchFreqInfoUlSib; + +/*Spec 38.331 'UplinkConfigCommonSIB '*/ +typedef struct schUlCfgCommon +{ + SchFreqInfoUlSib schFreqInfoUlSib; + SchBwpUlCfg schInitialUlBwp; /* Initial DL BWP */ + uint16_t schTimeAlignTimer; +}SchUlCfgCommon; + +/*Ref: ORAN_WG8.V7.0.0 Sec 11.2.3.2.1*/ typedef struct schCellCfg { - uint16_t cellId; /* Cell Id */ - uint16_t phyCellId; /* Physical cell id */ - uint8_t numerology; /* Supported numerology */ - SchDuplexMode dupMode; /* Duplex type: TDD/FDD */ - uint8_t bandwidth; /* Supported B/W */ - uint32_t dlFreq; /* DL Frequency */ - uint32_t ulFreq; /* UL Frequency */ - SchSsbCfg ssbSchCfg; /* SSB config */ - SchSib1Cfg sib1SchCfg; /* SIB1 config */ - SchRachCfg schRachCfg; /* PRACH config */ - SchBwpDlCfg schInitialDlBwp; /* Initial DL BWP */ - SchBwpUlCfg schInitialUlBwp; /* Initial UL BWP */ - SchPlmnInfoList plmnInfoList; /* Consits of PlmnId and Snssai list */ - SchHqCfg schHqCfg; + uint16_t cellId; /* Cell Id */ + uint8_t numOfBeams; + uint8_t numLayers; + uint8_t numAntPorts; + uint16_t phyCellId; /* Physical cell id */ + SchPlmnInfoList plmnInfoList[MAX_PLMN]; /* Consits of PlmnId and Snssai list */ + SchDuplexMode dupMode; /* Duplex type: TDD/FDD */ + uint8_t numerology; /* Supported numerology */ + uint8_t dlBandwidth; /* Supported B/W */ + uint8_t ulBandwidth; /* Supported B/W */ + SchDlCfgCommon dlCfgCommon; /*Spec 38.331 DownlinkConfigCommonSIB*/ + SchUlCfgCommon ulCfgCommon; /*Spec 38.331 UplinkConfigCommonSIB*/ #ifdef NR_TDD - TDDCfg tddCfg; /* TDD Cfg */ + TDDCfg tddCfg; /* Spec 38.331 tdd-UL-DL-ConfigurationCommon */ #endif + + /*Ref:Spec 38.331 "ssb-PositionsInBurst", Value 0 in Bitmap => corresponding SS/PBCH block is not transmitted + *value 1 => corresponding SS/PBCH block is transmitted*/ + uint32_t ssbPosInBurst[SCH_SSB_MASK_SIZE]; /* Bitmap for actually transmitted SSB. */ + SchSSBPeriod ssbPeriod; /* SSB Periodicity in msec */ + uint32_t ssbFrequency; /* SB frequency in kHz*/ + uint8_t dmrsTypeAPos; + uint8_t scsCommon; /* subcarrier spacing for common [0-3]*/ + SchPdcchConfigSib1 pdcchCfgSib1; /* Req to configure CORESET#0 and SearchSpace#0*/ + uint32_t ssbPbchPwr; /* SSB block power */ + uint8_t ssbSubcOffset; /* Subcarrier Offset(Kssb) */ + uint16_t sib1PduLen; }SchCellCfg; typedef struct schCellCfgCfm @@ -848,16 +906,15 @@ typedef struct schCellCfgCfm typedef struct ssbInfo { uint8_t ssbIdx; /* SSB Index */ - TimeDomainAlloc tdAlloc; /* Time domain allocation */ - ResAllocType1 fdAlloc; /* Freq domain allocation */ + TimeDomainAlloc tdAlloc; /* Time domain allocation */ + FreqDomainRsrc fdAlloc; /* Freq domain allocation */ }SsbInfo; typedef struct sib1AllocInfo { BwpCfg bwp; PdcchCfg sib1PdcchCfg; - PdschCfg sib1PdschCfg; -} Sib1AllocInfo; +}Sib1AllocInfo; typedef struct prachSchInfo { @@ -870,18 +927,21 @@ typedef struct prachSchInfo /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */ typedef struct dlBrdcstAlloc { + uint16_t crnti; /* SI-RNTI */ /* Ssb transmission is determined as follows: * 0 : No tranamission * 1 : SSB Transmission * 2 : SSB Repetition */ - uint8_t ssbTrans; + uint8_t ssbTransmissionMode; uint8_t ssbIdxSupported; SsbInfo ssbInfo[MAX_SSB_IDX]; + bool systemInfoIndicator; + uint8_t *siContent; /* Sib1 transmission is determined as follows: * 0 : No tranamission * 1 : SIB1 Transmission * 2 : SIB1 Repetition */ - uint8_t sib1Trans; + uint8_t sib1TransmissionMode; Sib1AllocInfo sib1Alloc; }DlBrdcstAlloc; @@ -889,7 +949,7 @@ typedef struct msg3UlGrant { uint8_t freqHopFlag; uint16_t bwpSize; - ResAllocType1 msg3FreqAlloc; + FreqDomainRsrc msg3FreqAlloc; uint8_t k2Index; uint8_t mcs; uint8_t tpc; @@ -967,62 +1027,87 @@ typedef struct schSlotValue SlotTimingInfo ulDciTime; }SchSlotValue; +typedef struct freqDomainAlloc +{ + uint8_t resAllocType; /* Resource allocation type */ + union + { + ResAllocType0 type0; + ResAllocType1 type1; + }resAlloc; +}FreqDomainAlloc; + +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Table 9-36 DCI Format0_0 Configuration */ typedef struct format0_0 { uint8_t resourceAllocType; - /* since we are using type-1, hence rbBitmap excluded */ - ResAllocType1 freqAlloc; + FreqDomainAlloc freqAlloc; TimeDomainAlloc timeAlloc; uint16_t rowIndex; uint8_t mcs; - uint8_t harqProcId; /* HARQ Process ID */ - bool puschHopFlag; + uint8_t harqProcId; bool freqHopFlag; - uint8_t ndi; /* NDI */ - uint8_t rv; /* Redundancy Version */ + uint8_t ndi; + uint8_t rvIndex; uint8_t tpcCmd; - bool sUlCfgd; + bool sulIndicator; }Format0_0; +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Table 9-40 DCI Format 0_1 Configuration */ typedef struct format0_1 { -/* TBD */ - + uint8_t carrierIndicator; + bool sulIndicator; + uint8_t bwpIndicator; + uint8_t resourceAlloc; + FreqDomainRsrc freqAlloc; + TimeDomainAlloc timeAlloc; + uint16_t rowIndex; + uint8_t mcs; + uint8_t harqProcId; + bool freqHopFlag; + uint8_t ndi; + uint8_t rvIndex; + uint8_t firstDownlinkAssignmentIndex; + uint8_t secondDownlinkAssignmentIndex; + uint8_t tpcCommand; + uint8_t srsResourceSetIndicator; + uint8_t srsResourceIndicator; + uint8_t tpmi; + uint8_t antennaPorts; + uint8_t srsRequest; + uint8_t csiRequest; + uint8_t cbgTransmissionInfo; + uint8_t ptrsDmrs; + uint8_t betaOffsetIndicator; + bool dmrsSequenceInitialization; + bool ulschIndicatior; }Format0_1; -typedef struct format1_0 +typedef struct dciFormat { -/* TBD */ - -}Format1_0; - -typedef struct format1_1 -{ -/* TBD */ -}Format1_1; - -typedef struct dciInfo -{ - uint16_t cellId; - uint16_t crnti; /* CRNI */ - SlotTimingInfo slotIndInfo; /* Slot Info: sfn, slot number */ - BwpCfg bwpCfg; /* BWP Cfg */ - CoresetCfg coresetCfg; /* Coreset1 Cfg */ - FormatType formatType; /* DCI Format */ + FormatType formatType; /* DCI Format */ union { Format0_0 format0_0; /* Format 0_0 */ Format0_1 format0_1; /* Format 0_1 */ - Format1_0 format1_0; /* Format 1_0 */ - Format1_1 format1_1; /* Format 1_1 */ }format; - DlDCI dciInfo; +}DciFormat; + +typedef struct dciInfo +{ + uint16_t crnti; /* CRNTI */ + BwpCfg bwpCfg; /* BWP Cfg */ + CoresetCfg coresetCfg; /* Coreset1 Cfg */ + DciFormat dciFormatInfo; /* Dci Format */ + DlDCI dciInfo; /* DlDCI */ }DciInfo; +/* Reference -> O-RAN.WG8.AAD.0-v07.00, Section 11.2.4.3.8 DL Scheduling Information */ typedef struct dlSchedInfo { - uint16_t cellId; /* Cell Id */ + uint16_t cellId; /* Cell Id */ SchSlotValue schSlotValue; /* Allocation for broadcast messages */ @@ -1040,6 +1125,65 @@ typedef struct dlSchedInfo }DlSchedInfo; +/*Reference: O-RAN.WG8.AAD.v7.0.0, Sec 11.2.3.3.13 Downlink Paging Allocation*/ +typedef struct interleaved_t +{ + uint8_t regBundleSize; + uint8_t interleaverSize; + uint16_t shiftIndex; +}Interleaved; + +typedef struct pageDlDci +{ + uint8_t freqDomainResource[6]; + uint8_t durationSymbols; + uint8_t cceRegMappingType; + union + { + Interleaved interleaved; + uint8_t nonInterleaved; + }cceReg; + uint8_t ssStartSymbolIndex; + uint8_t cceIndex; + uint8_t aggregLevel; + uint8_t precoderGranularity; + uint8_t coreSetSize; +}PageDlDci; + +typedef struct resAllocType1 PageFreqDomainAlloc; + +typedef struct pageTimeDomainAlloc +{ + uint8_t mappingType; + uint16_t startSymb; + uint16_t numSymb; +}PageTimeDomainAlloc; + +typedef struct pageDmrsConfig +{ + uint8_t dmrsType; + uint8_t dmrsAddPos; + uint8_t nrOfDmrsSymbols; +}PageDmrsConfig; + +typedef struct pageTbInfo +{ + uint8_t mcs; + uint32_t tbSize; +}PageTbInfo; + +typedef struct pageDlSch +{ + PageFreqDomainAlloc freqAlloc; + PageTimeDomainAlloc timeAlloc; + PageDmrsConfig dmrs; + uint8_t vrbPrbMapping; + PageTbInfo tbInfo; + uint8_t tbScaling; + uint16_t dlPagePduLen; + uint8_t *dlPagePdu; +}PageDlSch; + typedef struct dlPageAlloc { uint16_t cellId; @@ -1048,10 +1192,8 @@ typedef struct dlPageAlloc bool shortMsgInd; uint8_t shortMsg; BwpCfg bwp; - PdcchCfg pagePdcchCfg; - PdschCfg pagePdschCfg; - uint16_t dlPagePduLen; - uint8_t *dlPagePdu; + PageDlDci pageDlDci; + PageDlSch pageDlSch; }DlPageAlloc; typedef struct tbInfo @@ -1064,16 +1206,6 @@ typedef struct tbInfo SchMcsTable mcsTable; /* MCS Table */ }TbInfo; -typedef struct freqDomainAlloc -{ - uint8_t resAllocType; /* Resource allocation type */ - union - { - ResAllocType0 type0; - ResAllocType1 type1; - }resAlloc; -}FreqDomainAlloc; - typedef struct schPuschInfo { uint8_t harqProcId; /* HARQ Process ID */ diff --git a/src/cu_stub/cu_f1ap_msg_hdl.c b/src/cu_stub/cu_f1ap_msg_hdl.c index 4f1858ec3..14f7a2827 100644 --- a/src/cu_stub/cu_f1ap_msg_hdl.c +++ b/src/cu_stub/cu_f1ap_msg_hdl.c @@ -177,7 +177,7 @@ S16 SendF1APMsg(Region region, Pool pool, uint32_t duId) { ODU_PRINT_MSG(mBuf, 0,0); - if(sctpSend(duId, mBuf) != ROK) + if(sctpSend(F1_INTERFACE, duId, mBuf) != ROK) { DU_LOG("\nERROR --> F1AP : SCTP Send failed"); ODU_PUT_MSG_BUF(mBuf); @@ -9316,7 +9316,7 @@ uint8_t BuildAndSendUeContextSetupReq(uint32_t duId, CuUeCb *ueCb) if(ueCb->state == UE_HANDOVER_IN_PROGRESS) { /* Spec 38.473 Sec 9.2.2.1 : For handover case, this IE shall be considered as target cell. */ - SEARCH_DU_DB(duIdx, ueCb->hoInfo.targetDuId, targetDuDb); + SEARCH_DU_DB(duIdx, ueCb->hoInfo.targetId, targetDuDb); /* Since we are supporting only one cell per DU, accessing 0th index to * get target cell info */ spCellId = targetDuDb->cellCb[0].nrCellId; @@ -9654,7 +9654,7 @@ uint8_t procUeContextSetupResponse(uint32_t duId, F1AP_PDU_t *f1apMsg) ueCb->gnbDuUeF1apId = duUeF1apId; ueCb->gnbCuUeF1apId = cuUeF1apId; ueCb->state = UE_HANDOVER_IN_PROGRESS; - ueCb->hoInfo.targetDuId = duId; + ueCb->hoInfo.targetId = duId; (duDb->numUe)++; ueCb->cellCb->ueCb[ueCb->cellCb->numUe] = ueCb; @@ -9720,7 +9720,7 @@ uint8_t procUeContextSetupResponse(uint32_t duId, F1AP_PDU_t *f1apMsg) /* Store source DU info in the new UE context created in * tareget DU */ - ueCb->hoInfo.sourceDuId = srcDuDb->duId; + ueCb->hoInfo.sourceId = srcDuDb->duId; /* Copy the received container to UeCb */ memcpy(&ueCbInSrcDu->f1apMsgDb.duToCuContainer, duToCuRrcContainer, sizeof(OCTET_STRING_t)); @@ -9816,7 +9816,7 @@ uint8_t procUlRrcMsg(uint32_t duId, F1AP_PDU_t *f1apMsg) if(duDb->ueCb[duUeF1apId-1].state == UE_HANDOVER_IN_PROGRESS) { uint8_t ueIdx = 0; - uint8_t srcDuId = duDb->ueCb[duUeF1apId-1].hoInfo.sourceDuId; + uint8_t srcDuId = duDb->ueCb[duUeF1apId-1].hoInfo.sourceId; DuDb *srcDuDb = NULLP; /* In target DU DB, mark UE as active and delete HO info */ @@ -11958,13 +11958,13 @@ uint8_t procUeContextModificationResponse(uint32_t duId, F1AP_PDU_t *f1apMsg) /* If UE is in handover and UE context is not yet created at target DU, then send * UE context setup request to target DU */ - if(ueCb->state == UE_HANDOVER_IN_PROGRESS) + if(ueCb->state == UE_HANDOVER_IN_PROGRESS && ueCb->hoInfo.HOType == Inter_DU_HO) { uint8_t ueIdx = 0; DuDb *tgtDuDb = NULLP; CuUeCb *ueCbInTgtDu = NULLP; - SEARCH_DU_DB(duIdx, ueCb->hoInfo.targetDuId, tgtDuDb); + SEARCH_DU_DB(duIdx, ueCb->hoInfo.targetId, tgtDuDb); if(tgtDuDb) { /* Since DU UE F1AP ID assigned by target DU to this UE in handover is @@ -11983,7 +11983,7 @@ uint8_t procUeContextModificationResponse(uint32_t duId, F1AP_PDU_t *f1apMsg) * request */ if(ueCbInTgtDu == NULLP) { - if((BuildAndSendUeContextSetupReq(ueCb->hoInfo.targetDuId, ueCb)) != ROK) + if((BuildAndSendUeContextSetupReq(ueCb->hoInfo.targetId, ueCb)) != ROK) { DU_LOG("\nERROR -> F1AP : Failed at BuildAndSendUeContextSetupReq"); return RFAILED; diff --git a/src/cu_stub/cu_stub.c b/src/cu_stub/cu_stub.c index 619b07755..b817edfc7 100644 --- a/src/cu_stub/cu_stub.c +++ b/src/cu_stub/cu_stub.c @@ -133,8 +133,8 @@ uint8_t tst() void readCuCfg() { - uint8_t numDu; - uint32_t ipv4_du, ipv4_cu; + uint8_t numDu, *numRemoteCu; + uint32_t ipv4_du, ipv4_cu, ipv4_remote_cu; DU_LOG("\nDEBUG --> CU_STUB : Reading CU configurations"); @@ -179,13 +179,15 @@ void readCuCfg() cuCb.cuCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_cu; cuCb.cuCfgParams.sctpParams.localIpAddr.ipV6Pres = false; - cuCb.cuCfgParams.sctpParams.f1SctpPort = F1_SCTP_PORT; + + /* SCTP and EGTP configuration for F1 Interface */ + cuCb.cuCfgParams.sctpParams.f1SctpInfo.port = F1_SCTP_PORT; cuCb.cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE; cuCb.cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu; cuCb.cuCfgParams.egtpParams.localPort = F1_EGTP_PORT; - cuCb.cuCfgParams.sctpParams.numDestNode = 0; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.numDestNode = 0; cuCb.cuCfgParams.egtpParams.numDu = 0; numDu = 0; @@ -196,9 +198,9 @@ void readCuCfg() cmInetAddr((S8*)REMOTE_IP_DU[numDu], &ipv4_du); /* SCTP Parameters */ - cuCb.cuCfgParams.sctpParams.destCb[numDu].destIpAddr.ipV4Addr = ipv4_du; - cuCb.cuCfgParams.sctpParams.destCb[numDu].destIpAddr.ipV6Pres = false; - cuCb.cuCfgParams.sctpParams.destCb[numDu].destPort = F1_SCTP_PORT; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.destCb[numDu].destIpAddr.ipV4Addr = ipv4_du; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.destCb[numDu].destIpAddr.ipV6Pres = false; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.destCb[numDu].destPort = F1_SCTP_PORT; /* EGTP Parameters */ cuCb.cuCfgParams.egtpParams.dstCfg[numDu].dstIp.ipV4Pres = TRUE; @@ -212,7 +214,26 @@ void readCuCfg() cuCb.cuCfgParams.egtpParams.currTunnelId = cuCb.cuCfgParams.egtpParams.minTunnelId; cuCb.cuCfgParams.egtpParams.maxTunnelId = MAX_TEID; cuCb.cuCfgParams.egtpParams.numDu = numDu; - cuCb.cuCfgParams.sctpParams.numDestNode = numDu; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.numDestNode = numDu; + + /* SCTP configuration for Xn interface */ + cuCb.cuCfgParams.sctpParams.xnSctpInfo.port = XN_SCTP_PORT; + cuCb.cuCfgParams.sctpParams.xnSctpInfo.localNodeType = LOCAL_NODE_TYPE; + numRemoteCu = &cuCb.cuCfgParams.sctpParams.xnSctpInfo.numDestNode; + (*numRemoteCu) = 0; + while((*numRemoteCu) < NUM_XN_ASSOC) + { + /* Remote CU IP address */ + memset(&ipv4_remote_cu, 0, sizeof(uint32_t)); + cmInetAddr((S8*)REMOTE_IP_CU[*numRemoteCu], &ipv4_remote_cu); + + /* SCTP Parameters */ + cuCb.cuCfgParams.sctpParams.xnSctpInfo.destCb[*numRemoteCu].destIpAddr.ipV4Addr = ipv4_remote_cu; + cuCb.cuCfgParams.sctpParams.xnSctpInfo.destCb[*numRemoteCu].destIpAddr.ipV6Pres = false; + cuCb.cuCfgParams.sctpParams.xnSctpInfo.destCb[*numRemoteCu].destPort = XN_SCTP_PORT; + + (*numRemoteCu)++; + } #endif /*PLMN*/ @@ -249,25 +270,87 @@ void readCuCfg() * RFAILED - failure * * ****************************************************************/ -void initiateInterDuHandover(uint32_t sourceDuId, uint32_t targetDuId, uint32_t ueId) +void initiateInterDuHandover(uint32_t sourceDuId, uint32_t targetDuId, uint32_t duUeF1apId) { - uint8_t duIdx = 0; - DuDb *duDb = NULLP; - CuUeCb *ueCb = NULLP; - - SEARCH_DU_DB(duIdx, sourceDuId, duDb); - if(duDb) - ueCb = &duDb->ueCb[ueId-1]; - if(ueCb) + uint8_t duIdx = 0; + DuDb *duDb = NULLP; + CuUeCb *ueCb = NULLP; + + DU_LOG("\nINFO --> CU_STUB: Inter-DU Handover Started for ueId [%d] from DU ID [%d] to DU ID [%d]", \ + duUeF1apId, sourceDuId, targetDuId); + + SEARCH_DU_DB(duIdx, sourceDuId, duDb); + if(duDb) + ueCb = &duDb->ueCb[duUeF1apId-1]; + if(ueCb) + { + ueCb->state = UE_HANDOVER_IN_PROGRESS; + ueCb->hoInfo.HOType = Inter_DU_HO; + ueCb->hoInfo.sourceId = sourceDuId; + ueCb->hoInfo.targetId = targetDuId; + + BuildAndSendUeContextModificationReq(sourceDuId, ueCb, QUERY_CONFIG); + } + else + { + DU_LOG("\nINFO --> CU_STUB: DU UE F1AP ID [%d] not found", duUeF1apId); + } +} + + +/******************************************************************* + * + * @brief Initiates inter CU handover + * + * @details + * + * Function : initiateInterCuHandover + * + * Functionality: Initiates the first procedure of inter-CU + * handover + * + * @params[in] Source CU Id + * Target CU Id + * UE Id to be handed off + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void initiateInterCuHandover(uint32_t sourceCuId, uint32_t targetCuId, uint32_t cuUeF1apId) +{ + uint8_t duIdx, ueIdx; + CuUeCb *ueCb = NULLP; + + DU_LOG("\nINFO --> CU_STUB: Inter-CU Handover Started for ueId [%d] from CU ID [%d] to CU ID [%d]", \ + cuUeF1apId, sourceCuId, targetCuId); + + for(duIdx = 0; duIdx < cuCb.numDu; duIdx++) { - ueCb->state = UE_HANDOVER_IN_PROGRESS; - ueCb->hoInfo.sourceDuId = sourceDuId; - ueCb->hoInfo.targetDuId = targetDuId; + for(ueIdx = 0; ueIdx < (MAX_NUM_CELL * MAX_NUM_UE); ueIdx++) + { + ueCb = &cuCb.duInfo[duIdx].ueCb[ueIdx]; + if(cuCb.duInfo[duIdx].ueCb[ueIdx].gnbCuUeF1apId == cuUeF1apId) + { + ueCb = &cuCb.duInfo[duIdx].ueCb[ueIdx]; + break; + } + } + if(ueCb) + break; } - DU_LOG("\nINFO --> CU_STUB: Inter-DU Handover Started for ueId [%d] from DU ID [%d] to DU ID [%d]", \ - ueId, sourceDuId, targetDuId); - BuildAndSendUeContextModificationReq(sourceDuId, ueCb, QUERY_CONFIG); + if(ueCb) + { + ueCb->state = UE_HANDOVER_IN_PROGRESS; + ueCb->hoInfo.HOType = Xn_Based_Inter_CU_HO; + ueCb->hoInfo.sourceId = sourceCuId; + ueCb->hoInfo.targetId = targetCuId; + BuildAndSendUeContextModificationReq(cuCb.duInfo[duIdx].duId, ueCb, QUERY_CONFIG); + } + else + { + DU_LOG("\nINFO --> CU_STUB: CU UE F1AP ID [%d] not found", cuUeF1apId); + } } /******************************************************************* @@ -401,16 +484,34 @@ void *cuConsoleHandler(void *args) /* Start Handover procedure towards DU when 'h' is received from console input */ else if(ch == 'h') { - uint32_t sourceDuId, targetDuId, ueId; + HandoverType hoType; + uint32_t sourceId, targetId, ueId; - DU_LOG("\nEnter Source DU ID for Inter-DU Handover"); - scanf("%d", &sourceDuId); - DU_LOG("\nEnter Target DU ID for Inter-DU Handover"); - scanf("%d", &targetDuId); - DU_LOG("\nEnter DU UE F1AP ID to be handed over"); - scanf("%d", &ueId); + DU_LOG("\n\nChoose the type of handover to initiate : \nEnter 1 for Inter-CU Handover over Xn interface\nEnter 2 for Inter-DU Handover\n"); + scanf("%d", &hoType); - initiateInterDuHandover(sourceDuId, targetDuId, ueId); + if(hoType == Xn_Based_Inter_CU_HO) + { + DU_LOG("\nEnter Source CU ID for Inter-CU Handover : "); + scanf("%d", &sourceId); + DU_LOG("\nEnter Target CU ID for Inter-CU Handover : "); + scanf("%d", &targetId); + DU_LOG("\nEnter CU UE F1AP ID to be handed over : "); + scanf("%d", &ueId); + + initiateInterCuHandover(sourceId, targetId, ueId); + } + else if(hoType == Inter_DU_HO) + { + DU_LOG("\nEnter Source DU ID for Inter-DU Handover : "); + scanf("%d", &sourceId); + DU_LOG("\nEnter Target DU ID for Inter-DU Handover : "); + scanf("%d", &targetId); + DU_LOG("\nEnter DU UE F1AP ID to be handed over : "); + scanf("%d", &ueId); + + initiateInterDuHandover(sourceId, targetId, ueId); + } } /* Start Idle mode paging when 'p' is received from console input */ else if(ch == 'p') @@ -431,20 +532,63 @@ void *cuConsoleHandler(void *args) } else if(ch == 'm') { - uint8_t ueId = 1; - uint8_t duId = 1; - uint8_t duIdx = 0; + uint8_t ueId = 1; + uint8_t duId = 0; + uint8_t duIdx = 0; + DuDb *duDb = NULLP; + CuUeCb *ueCb = NULLP; + + DU_LOG("\nEnter DU ID whose UE has to be modified"); + scanf("%d", &duId); + DU_LOG("\nEnter UE ID to be modified"); + scanf("%d", &ueId); DU_LOG("\nINFO --> CU_STUB: UE Context Mod for ueId [%d] at DU ID [%d]", \ - ueId, duId ); - DuDb *duDb = NULLP; - CuUeCb *ueCb = NULLP; + ueId, duId); SEARCH_DU_DB(duIdx, duId, duDb); if(duDb) + { ueCb = &duDb->ueCb[ueId-1]; - BuildAndSendUeContextModificationReq(duId, ueCb, MODIFY_UE); + BuildAndSendUeContextModificationReq(duId, ueCb, MODIFY_UE); + } + else + { + DU_LOG("ERROR --> DuDb is NULLP"); + } + continue; + + } + /*UE context release command from CU*/ + else if(ch == 'c') + { + uint32_t duId, cuUeF1apId, duUeF1apId; + uint8_t duIdx = 0; + DuDb *duDb = NULLP; + + DU_LOG("\nEnter DU ID on which UE has to be released"); + scanf("%d", &duId); + DU_LOG("\nEnter UE ID to be released"); + scanf("%d", &duUeF1apId); + + SEARCH_DU_DB(duIdx, duId, duDb); + if(duDb) + { + if(duDb->ueCb[duUeF1apId-1].gnbDuUeF1apId == duUeF1apId) + { + cuUeF1apId = duDb->ueCb[duUeF1apId-1].gnbCuUeF1apId; + DU_LOG("INFO --> CU_STUB: Cu UeId: %d Du UeId:%d",cuUeF1apId, duUeF1apId); + BuildAndSendUeContextReleaseCommand(duId, cuUeF1apId, duUeF1apId); + } + else + { + DU_LOG("ERROR --> CU_STUB: Du UeId:%d in UeCb mismatch",\ + duDb->ueCb[duUeF1apId-1].gnbDuUeF1apId); + } + } + sleep(5); + continue; } } } diff --git a/src/cu_stub/cu_stub.h b/src/cu_stub/cu_stub.h index 4c51a82f8..180116f4a 100644 --- a/src/cu_stub/cu_stub.h +++ b/src/cu_stub/cu_stub.h @@ -31,6 +31,11 @@ #define F1_SCTP_PORT 38472 /* As per the spec 38.472, the registered port number for F1AP is 38472 */ #define NUM_F1_ASSOC 1 #define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"} + +#define XN_SCTP_PORT 38422 /* As per 3GPP TS 38.422, The SCTP Destination Port number value assigned by IANA to be used for XnAP is 38422 */ +#define NUM_XN_ASSOC 0 +#define REMOTE_IP_CU (char*[]){"192.168.130.84"} +#define LOCAL_NODE_TYPE SERVER #endif #define F1_EGTP_PORT 2152 /* As per the spec 29.281, the registered port number for GTP-U is 2152 */ @@ -101,6 +106,12 @@ #define DRX_TO_BE_RELEASE true #endif +typedef enum +{ + Xn_Based_Inter_CU_HO = 1, + Inter_DU_HO +}HandoverType; + typedef enum { CELL_INACTIVE, @@ -134,8 +145,9 @@ typedef struct cuCfgParams typedef struct handoverInfo { - uint32_t sourceDuId; - uint32_t targetDuId; + HandoverType HOType; + uint32_t sourceId; /* If Inter_DU HO, this is Source DU ID. In case of Inter CU HO, this is Source CU ID */ + uint32_t targetId; /* If Inter_DU HO, this is Taregt DU ID. In case of Inter CU HO, this is Target CU ID */ }HandoverInfo; typedef struct dlAmCfg diff --git a/src/cu_stub/cu_stub_sctp.c b/src/cu_stub/cu_stub_sctp.c index 07b462c3e..e9bd0d64d 100644 --- a/src/cu_stub/cu_stub_sctp.c +++ b/src/cu_stub/cu_stub_sctp.c @@ -107,12 +107,25 @@ uint8_t sctpCfgReq() fillAddrLst(&sctpCb.localAddrLst, &sctpCb.sctpCfg.localIpAddr); memset(&sctpCb.f1LstnSockFd, -1, sizeof(CmInetFd)); - for(destIdx=0; destIdx < sctpCb.sctpCfg.numDestNode; destIdx++) + for(destIdx=0; destIdx < sctpCb.sctpCfg.f1SctpInfo.numDestNode; destIdx++) { - sctpCb.assocCb[assocIdx].destPort = sctpCb.sctpCfg.destCb[destIdx].destPort; + sctpCb.assocCb[assocIdx].intf = F1_INTERFACE; + sctpCb.assocCb[assocIdx].destPort = sctpCb.sctpCfg.f1SctpInfo.destCb[destIdx].destPort; sctpCb.assocCb[assocIdx].bReadFdSet = ROK; memset(&sctpCb.assocCb[assocIdx].sockFd, -1, sizeof(CmInetFd)); - fillDestNetAddr(&sctpCb.assocCb[assocIdx].destIpNetAddr, &sctpCb.sctpCfg.destCb[destIdx].destIpAddr); + fillDestNetAddr(&sctpCb.assocCb[assocIdx].destIpNetAddr, &sctpCb.sctpCfg.f1SctpInfo.destCb[destIdx].destIpAddr); + assocIdx++; + } + + sctpCb.localXnNodeType = sctpCb.sctpCfg.xnSctpInfo.localNodeType; + for(destIdx=0; destIdx < sctpCb.sctpCfg.xnSctpInfo.numDestNode; destIdx++) + { + sctpCb.assocCb[assocIdx].intf = XN_INTERFACE; + sctpCb.assocCb[assocIdx].destId = CU_ID + destIdx +1; + sctpCb.assocCb[assocIdx].destPort = sctpCb.sctpCfg.xnSctpInfo.destCb[destIdx].destPort; + sctpCb.assocCb[assocIdx].bReadFdSet = ROK; + memset(&sctpCb.assocCb[assocIdx].sockFd, -1, sizeof(CmInetFd)); + fillDestNetAddr(&sctpCb.assocCb[assocIdx].destIpNetAddr, &sctpCb.sctpCfg.xnSctpInfo.destCb[destIdx].destIpAddr); assocIdx++; } sctpCb.numAssoc = assocIdx; @@ -192,16 +205,92 @@ uint8_t sctpStartReq() { uint8_t assocIdx; uint8_t ret = ROK; + CmInetFd sockFd; socket_type = CM_INET_STREAM; - if(sctpCb.numAssoc) + /* Establish SCTP association at XN interface */ + if(sctpCb.sctpCfg.xnSctpInfo.numDestNode) + { + if(sctpCb.localXnNodeType == SERVER) + { + if((ret = cmInetSocket(socket_type, &sctpCb.xnLstnSockFd, IPPROTO_SCTP) != ROK)) + { + DU_LOG("\nERROR --> SCTP : Socket[%d] coudnt open for listening", sctpCb.f1LstnSockFd.fd); + } + else if((ret = cmInetSctpBindx(&sctpCb.xnLstnSockFd, &sctpCb.localAddrLst, sctpCb.sctpCfg.xnSctpInfo.port)) != ROK) + { + DU_LOG("\nERROR --> SCTP: Binding failed at CU"); + } + else if(ret = cmInetListen(&sctpCb.xnLstnSockFd, 1) != ROK) + { + DU_LOG("\nERROR --> SCTP : Listening on socket failed"); + cmInetClose(&sctpCb.xnLstnSockFd); + return RFAILED; + } + else + { + for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++) + { + if(sctpCb.assocCb[assocIdx].intf == XN_INTERFACE) + { + if((ret = sctpAccept(&sctpCb.xnLstnSockFd, &sctpCb.assocCb[assocIdx])) != ROK) + { + DU_LOG("\nERROR --> SCTP: Unable to accept the connection at CU"); + } + } + } + } + } + else if(sctpCb.localXnNodeType == CLIENT) + { + for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++) + { + if(sctpCb.assocCb[assocIdx].intf == XN_INTERFACE) + { + if((ret = cmInetSocket(socket_type, &sctpCb.assocCb[assocIdx].sockFd, IPPROTO_SCTP)) != ROK) + { + DU_LOG("\nERROR --> SCTP : Failed while opening a socket in ODU"); + } + else if((ret = cmInetSctpBindx(&sctpCb.assocCb[assocIdx].sockFd, &sctpCb.localAddrLst, sctpCb.sctpCfg.xnSctpInfo.port)) != ROK) + { + DU_LOG("\nERROR --> SCTP: Failed during Binding in ODU"); + } + else if((ret = sctpSetSockOpts(&sctpCb.assocCb[assocIdx].sockFd)) != ROK) + { + DU_LOG("\nERROR --> SCTP : Failed to set Socket Opt in ODU"); + } + else + { + if(ret != ROK) + { + DU_LOG("\nERROR --> SCTP : Failed while establishing Req at DU"); + ret = RFAILED; + } + else + { + ret = cmInetSctpConnectx(&sctpCb.assocCb[assocIdx].sockFd, &sctpCb.assocCb[assocIdx].destIpNetAddr, \ + &sctpCb.assocCb[assocIdx].destAddrLst, sctpCb.assocCb[assocIdx].destPort); + /* 115 error_code indicates that Operation is in progress and hence ignored if SctpConnect failed due to this */ + if(ret == 18) + { + ret = ROK; + } + } + } + } + } + } + } + + /* Establish SCTP association at F1 interface */ + if(sctpCb.sctpCfg.f1SctpInfo.numDestNode) { if((ret = cmInetSocket(socket_type, &sctpCb.f1LstnSockFd, IPPROTO_SCTP) != ROK)) { DU_LOG("\nERROR --> SCTP : Socket[%d] coudnt open for listening", sctpCb.f1LstnSockFd.fd); } - else if((ret = cmInetSctpBindx(&sctpCb.f1LstnSockFd, &sctpCb.localAddrLst, sctpCb.sctpCfg.f1SctpPort)) != ROK) + else if((ret = cmInetSctpBindx(&sctpCb.f1LstnSockFd, &sctpCb.localAddrLst, sctpCb.sctpCfg.f1SctpInfo.port)) != ROK) { DU_LOG("\nERROR --> SCTP: Binding failed at CU"); } @@ -215,9 +304,12 @@ uint8_t sctpStartReq() { for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++) { - if((ret = sctpAccept(&sctpCb.assocCb[assocIdx])) != ROK) + if(sctpCb.assocCb[assocIdx].intf == F1_INTERFACE) { - DU_LOG("\nERROR --> SCTP: Unable to accept the connection at CU"); + if((ret = sctpAccept(&sctpCb.f1LstnSockFd, &sctpCb.assocCb[assocIdx])) != ROK) + { + DU_LOG("\nERROR --> SCTP: Unable to accept the connection at CU"); + } } } } @@ -232,6 +324,7 @@ uint8_t sctpStartReq() } return (ret); } + /******************************************************************* * * @brief Sets socket options as per requirement @@ -287,7 +380,7 @@ uint8_t sctpSetSockOpts(CmInetFd *sock_Fd) * RFAILED - failure * * ****************************************************************/ -uint8_t sctpAccept(CuSctpAssocCb *assocCb) +uint8_t sctpAccept(CmInetFd *lstnSockFd, CuSctpAssocCb *assocCb) { uint8_t ret; @@ -295,7 +388,7 @@ uint8_t sctpAccept(CuSctpAssocCb *assocCb) while(!assocCb->connUp) { - ret = cmInetAccept(&sctpCb.f1LstnSockFd, &assocCb->peerAddr, &assocCb->sockFd); + ret = cmInetAccept(lstnSockFd, &assocCb->peerAddr, &assocCb->sockFd); if (ret == ROKDNA) { continue; @@ -422,11 +515,11 @@ uint8_t sctpSockPoll() Buffer *egtpBuf; MsgLen egtpBufLen; CmInetMemInfo memInfo; - sctpSockPollParams f1PollParams; + sctpSockPollParams pollParams; uint64_t numMsgRcvd = 0; CmInetAddr fromAddr; - memset(&f1PollParams, 0, sizeof(sctpSockPollParams)); + memset(&pollParams, 0, sizeof(sctpSockPollParams)); /* All sockets are non-blocking */ @@ -435,14 +528,14 @@ uint8_t sctpSockPoll() memInfo.region = CU_APP_MEM_REG; memInfo.pool = CU_POOL; - CM_INET_FD_ZERO(&f1PollParams.readFd); + CM_INET_FD_ZERO(&pollParams.readFd); while(1) { /* Receiving SCTP data */ for(assocIdx = 0; assocIdx < sctpCb.numAssoc; assocIdx++) { - if((ret = processPolling(&f1PollParams, &sctpCb.assocCb[assocIdx], timeoutPtr, &memInfo)) != ROK) + if((ret = processPolling(&pollParams, &sctpCb.assocCb[assocIdx], timeoutPtr, &memInfo)) != ROK) { DU_LOG("\nERROR --> SCTP : Failed to RecvMsg for F1 at CU\n"); } @@ -517,9 +610,16 @@ uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpAssocCb *assocCb, u DU_LOG("\nERROR --> SCTP : Failed to process sctp notify msg\n"); } } - else if(assocCb->connUp) + else if(assocCb->connUp && assocCb->intf == F1_INTERFACE) { - F1APMsgHdlr(&assocCb->duId, pollParams->mBuf); + F1APMsgHdlr(&assocCb->destId, pollParams->mBuf); + ODU_PUT_MSG_BUF(pollParams->mBuf); + } + else if(assocCb->connUp && assocCb->intf == XN_INTERFACE) + { + //TODO : Handler for messages on XN interface to be added in future commits + DU_LOG("\nDEBUG --> SCTP : Received message at XN interface"); + ODU_PRINT_MSG(pollParams->mBuf, 0,0); ODU_PUT_MSG_BUF(pollParams->mBuf); } else @@ -547,7 +647,7 @@ uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpAssocCb *assocCb, u * RFAILED - failure * * ****************************************************************/ -uint8_t sctpSend(uint32_t duId, Buffer *mBuf) +uint8_t sctpSend(InterfaceType intf, uint32_t destId, Buffer *mBuf) { uint8_t ret = ROK, assocIdx = 0; MsgLen len = 0; /* number of actually sent octets */ @@ -559,7 +659,7 @@ uint8_t sctpSend(uint32_t duId, Buffer *mBuf) for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++) { - if(sctpCb.assocCb[assocIdx].duId == duId) + if((sctpCb.assocCb[assocIdx].intf == intf) && (sctpCb.assocCb[assocIdx].destId == destId)) { ret = cmInetSctpSendMsg(&sctpCb.assocCb[assocIdx].sockFd, &sctpCb.assocCb[assocIdx].destIpNetAddr, \ sctpCb.assocCb[assocIdx].destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK); @@ -572,7 +672,7 @@ uint8_t sctpSend(uint32_t duId, Buffer *mBuf) return ROK; } } - DU_LOG("\nERROR --> SCTP : DU ID [%d] not found in SCTP DestCb list. Failed to send message", duId); + DU_LOG("\nERROR --> SCTP : Dest ID [%d] at Interface [%d] not found in SCTP DestCb list. Failed to send message", destId, intf); return RFAILED; } /* End of sctpSend */ diff --git a/src/cu_stub/cu_stub_sctp.h b/src/cu_stub/cu_stub_sctp.h index 548c29a16..d8128144e 100644 --- a/src/cu_stub/cu_stub_sctp.h +++ b/src/cu_stub/cu_stub_sctp.h @@ -24,11 +24,24 @@ #define MAX_RETRY 5 #define MAX_IPV6_LEN 16 #define MAX_DU_SUPPORTED 2 -#define MAX_ASSOC_SUPPORTED MAX_DU_SUPPORTED +#define MAX_REMOTE_CU_SUPPORTED 1 +#define MAX_ASSOC_SUPPORTED (MAX_DU_SUPPORTED + MAX_REMOTE_CU_SUPPORTED) /* Global variable declaration */ uint8_t socket_type; /* Socket type */ +typedef enum +{ + F1_INTERFACE, + XN_INTERFACE +}InterfaceType; + +typedef enum +{ + SERVER, + CLIENT +}NodeType; + typedef struct { S16 numFd; @@ -44,13 +57,14 @@ typedef struct typedef struct { - uint32_t duId; + InterfaceType intf; /* F1 or Xn Interface */ + uint32_t destId; /* For F1 interface, this is DU ID. For Xn, this is remote CU ID */ uint16_t destPort; /* DU PORTS */ Bool bReadFdSet; CmInetFd sockFd; /* Socket file descriptor */ CmInetAddr peerAddr; - CmInetNetAddrLst destAddrLst; /* DU Ip address */ - CmInetNetAddr destIpNetAddr; /* DU Ip address */ + CmInetNetAddrLst destAddrLst; /* Remote IP address list */ + CmInetNetAddr destIpNetAddr; /* Remote IP network address */ Bool connUp; /* Is connection up */ }CuSctpAssocCb; @@ -68,12 +82,19 @@ typedef struct sctpDestInfo uint16_t destPort; }SctpDestInfo; +typedef struct sctpCfgPerIntf +{ + uint16_t port; + NodeType localNodeType; /* Local node acts as Server or client while establishing SCTP assoc */ + uint8_t numDestNode; + SctpDestInfo destCb[MAX_ASSOC_SUPPORTED]; +}SctpCfgPerIntf; + typedef struct cuSctpParams { SctpIpAddr localIpAddr; - uint16_t f1SctpPort; - uint8_t numDestNode; - SctpDestInfo destCb[MAX_DU_SUPPORTED]; + SctpCfgPerIntf f1SctpInfo; + SctpCfgPerIntf xnSctpInfo; }CuSctpParams; typedef struct @@ -81,6 +102,8 @@ typedef struct CuSctpParams sctpCfg; CmInetNetAddrLst localAddrLst; CmInetFd f1LstnSockFd; /* Listening Socket file descriptor for F1 association */ + CmInetFd xnLstnSockFd; /* Listening Socket file descriptor for Xn association */ + NodeType localXnNodeType; /* Local node acts as Server or client while establishing SCTP assoc at Xn interface */ uint8_t numAssoc; CuSctpAssocCb assocCb[MAX_ASSOC_SUPPORTED]; }SctpGlobalCb; @@ -89,14 +112,14 @@ SctpGlobalCb sctpCb; uint8_t sctpActvInit(); uint8_t sctpStartReq(); -uint8_t sctpSend(uint32_t duId, Buffer *mBuf); +uint8_t sctpSend(InterfaceType intf, uint32_t destId, Buffer *mBuf); uint8_t sctpCfgReq(); uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr); uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr); uint8_t sctpSetSockOpts(CmInetFd *sock_Fd); uint8_t sctpSockPoll(); -uint8_t sctpAccept(CuSctpAssocCb *assocCb); +uint8_t sctpAccept(CmInetFd *lstnSockFd, CuSctpAssocCb *assocCb); uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpAssocCb *assocCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo); #endif diff --git a/src/du_app/du_cell_mgr.c b/src/du_app/du_cell_mgr.c index ee1c4f699..7af503fc8 100644 --- a/src/du_app/du_cell_mgr.c +++ b/src/du_app/du_cell_mgr.c @@ -367,7 +367,8 @@ uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId) raiseCellAlrm(CELL_UP_ALARM_ID, cellId->cellId); setCellOpState(cellId->cellId, ENABLED, ACTIVE); #endif - + duCfgParam.macCellCfg.cellCfg.opState = OP_ENABLED; + duCfgParam.macCellCfg.cellCfg.cellState = CELL_ACTIVE; } if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC)) diff --git a/src/du_app/du_cfg.c b/src/du_app/du_cfg.c index b5c3173ae..0daca41ab 100644 --- a/src/du_app/du_cfg.c +++ b/src/du_app/du_cfg.c @@ -77,53 +77,6 @@ char encBuf[ENC_BUF_MAX_LEN]; 9 UL UL UL UL UL UL UL UL UL UL UL UL UL UL */ -#ifdef NR_TDD -/******************************************************************* - * - * @brief Fills the Slot configuration - * - * @details - * - * Function : FillSlotConfig - * - * Functionality:Fill the Slot configuration values - * - * @params[in] void - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ -void FillSlotConfig() -{ - uint8_t slot = 0; - uint8_t symbol =0; - - memset(duCfgParam.macCellCfg.tddCfg.slotCfg, 0, sizeof(duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol]* \ - MAX_TDD_PERIODICITY_SLOTS*MAX_SYMB_PER_SLOT)); - - //Filling the DL Slots and initializing flexi slot - for(slot = 0; slot <= NUM_DL_SLOTS; slot++) - { - for(symbol =0; symbol < MAX_SYMB_PER_SLOT; symbol++) - { - duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT; - } - } - - //Filling UL Slots - for(slot = NUM_DL_SLOTS+1; slot <= NUM_DL_SLOTS+NUM_UL_SLOTS; slot++) - { - for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++) - duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = UL_SLOT; - } - //Updating Flexi Slot - slot = NUM_DL_SLOTS; - duCfgParam.macCellCfg.tddCfg.slotCfg[slot][12] = FLEXI_SLOT; - duCfgParam.macCellCfg.tddCfg.slotCfg[slot][13] = UL_SLOT; - -} -#endif - /******************************************************************* * @brief Reads the CL Configuration. * @@ -143,63 +96,78 @@ void FillSlotConfig() uint8_t readMacCfg() { - uint8_t idx=0, sliceIdx=0; + uint8_t idx=0, sliceIdx=0,plmnIdx = 0; F1TaiSliceSuppLst *taiSliceSuppLst; - duCfgParam.macCellCfg.carrierId = CARRIER_IDX; - - /* Cell configuration */ - duCfgParam.macCellCfg.numerology = NR_NUMEROLOGY; - duCfgParam.macCellCfg.dupType = DUPLEX_MODE; - /* DL carrier configuration */ - duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE; #ifdef O1_ENABLE duCfgParam.macCellCfg.cellId = cellParams.cellLocalId; - duCfgParam.macCellCfg.phyCellId = cellParams.nRPCI; - duCfgParam.macCellCfg.dlCarrCfg.bw = cellParams.bSChannelBwUL; - duCfgParam.macCellCfg.dlCarrCfg.freq = cellParams.bSChannelBwDL; + duCfgParam.macCellCfg.carrCfg.dlBw = cellParams.bSChannelBwDL; + duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(cellParams.arfcnDL); #else duCfgParam.macCellCfg.cellId = NR_CELL_ID; - duCfgParam.macCellCfg.phyCellId = NR_PCI; - duCfgParam.macCellCfg.dlCarrCfg.bw = NR_BANDWIDTH; - duCfgParam.macCellCfg.dlCarrCfg.freq = NR_DL_ARFCN; + duCfgParam.macCellCfg.carrCfg.dlBw = NR_BANDWIDTH; + duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(NR_DL_ARFCN); #endif - - duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1; - duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1; - duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1; - duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1; - duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1; - duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 273; - duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1; - duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1; - duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1; - duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1; - duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT; - + duCfgParam.macCellCfg.carrCfg.numTxAnt = NUM_TX_ANT; /* UL Carrier configuration */ - duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE; #ifdef O1_ENABLE - duCfgParam.macCellCfg.ulCarrCfg.bw = cellParams.bSChannelBwUL; - duCfgParam.macCellCfg.ulCarrCfg.freq = cellParams.bSChannelBwDL; + duCfgParam.macCellCfg.carrCfg.ulBw = cellParams.bSChannelBwUL; + duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(cellParams.arfcnUL); #else - duCfgParam.macCellCfg.ulCarrCfg.bw = NR_BANDWIDTH; - duCfgParam.macCellCfg.ulCarrCfg.freq = NR_UL_ARFCN; + duCfgParam.macCellCfg.carrCfg.ulBw = NR_BANDWIDTH; + duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(NR_UL_ARFCN); #endif - duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1; - duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1; - duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1; - duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1; - duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1; - duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1; - duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1; - duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1; - duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1; - duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1; - duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT; - - duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ; + duCfgParam.macCellCfg.carrCfg.numRxAnt = NUM_RX_ANT; + + /* Cell configuration */ +#ifdef O1_ENABLE + duCfgParam.macCellCfg.cellCfg.opState = cellParams.operationalState; + duCfgParam.macCellCfg.cellCfg.adminState = cellParams.administrativeState; + duCfgParam.macCellCfg.cellCfg.cellState = cellParams.cellState; + duCfgParam.macCellCfg.cellCfg.phyCellId = cellParams.nRPCI; + duCfgParam.macCellCfg.cellCfg.tac = cellParams.nRTAC; + duCfgParam.macCellCfg.cellCfg.ssbFreq = convertArfcnToFreqKhz(cellParams.ssbFrequency); +#else + duCfgParam.macCellCfg.cellCfg.opState = OP_DISABLED; + duCfgParam.macCellCfg.cellCfg.adminState = ADMIN_UNLOCKED; + duCfgParam.macCellCfg.cellCfg.cellState = CELL_INACTIVE; + duCfgParam.macCellCfg.cellCfg.phyCellId = NR_PCI; + duCfgParam.macCellCfg.cellCfg.tac = DU_TAC; + duCfgParam.macCellCfg.cellCfg.ssbFreq = SSB_FREQUENCY; +#endif + /* Plmn And SNSSAI Configuration */ + for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++) + { + memcpy(&duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].plmn,\ + sizeof(Plmn)); + taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].taiSliceSuppLst; + duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = taiSliceSuppLst->numSupportedSlices; + if(taiSliceSuppLst->snssai) + { + DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, (duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice) * sizeof(Snssai*)); + if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP) + { + DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg"); + return RFAILED; + } + } + for(sliceIdx=0; sliceIdx < taiSliceSuppLst->numSupportedSlices; sliceIdx++) + { + if(taiSliceSuppLst->snssai[sliceIdx] != NULLP) + { + DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai)); + if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx] == NULLP) + { + DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg"); + return RFAILED; + } + memcpy(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai)); + } + } + } + duCfgParam.macCellCfg.cellCfg.numerology = NR_NUMEROLOGY; + duCfgParam.macCellCfg.cellCfg.dupType = DUPLEX_MODE; /* SSB configuration */ duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR; @@ -225,75 +193,55 @@ uint8_t readMacCfg() { memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize); } - duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND; - duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER; /* PRACH configuration */ - duCfgParam.macCellCfg.prachCfg.pres = TRUE; - duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX; duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN; duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = convertScsEnumValToScsVal(PRACH_SUBCARRIER_SPACING); - duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG; + duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX; duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM; - duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START; - duCfgParam.macCellCfg.prachCfg.rootSeqLen = ROOT_SEQ_LEN; duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX; duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ; duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0; duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG; - duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ; - if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0) - { - DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, - NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t)); - if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP) - { - DU_LOG("\nERROR --> DU_APP : Memory allocation failed at readMacCfg"); - return RFAILED; - } - *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ; - } + duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG; + duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH; + duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START; duCfgParam.macCellCfg.prachCfg.totalNumRaPreamble = NUM_RA_PREAMBLE; - duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH; duCfgParam.macCellCfg.prachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB; - duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND; - duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER; - duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB; duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW; - duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET; -#ifdef NR_TDD + /* TDD configuration */ - duCfgParam.macCellCfg.tddCfg.pres = TRUE; +#ifdef NR_TDD duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY; + duCfgParam.macCellCfg.tddCfg.nrOfDlSlots = NUM_DL_SLOTS; + duCfgParam.macCellCfg.tddCfg.nrOfDlSymbols = NUM_DL_SYMBOLS; + duCfgParam.macCellCfg.tddCfg.nrOfUlSlots = NUM_UL_SLOTS; + duCfgParam.macCellCfg.tddCfg.nrOfUlSymbols = NUM_UL_SYMBOLS; - FillSlotConfig(); + //FillSlotConfig(); #endif - /* RSSI Measurement configuration */ - duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT; /* fill SIB1 configuration */ - duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len; - DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len); - memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \ - duCfgParam.srvdCellLst[0].duSysInfo.sib1Len); - duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD; - duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX; - duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX; - duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = DEFAULT_MCS; - - duCfgParam.macCellCfg.sib1Cfg.pagingCfg.numPO = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.ns; + duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len; + DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len); + memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \ + duCfgParam.srvdCellLst[0].duSysInfo.sib1Len); + duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex = CORESET_0_INDEX; + duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX; + + duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.ns; if((duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringType != \ - PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING) && (duCfgParam.macCellCfg.sib1Cfg.pagingCfg.numPO != 0)) + PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING) && (duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO != 0)) { - duCfgParam.macCellCfg.sib1Cfg.pagingCfg.poPresent = TRUE; - memcpy(duCfgParam.macCellCfg.sib1Cfg.pagingCfg.pagingOcc, - duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringInfo,MAX_PO_PER_PF); + duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = TRUE; + memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.pagingOcc, + duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringInfo,MAX_PO_PER_PF); } else { - duCfgParam.macCellCfg.sib1Cfg.pagingCfg.poPresent = FALSE; + duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = FALSE; } /* fill Intial DL BWP */ @@ -328,7 +276,7 @@ uint8_t readMacCfg() PDSCH_START_SYMBOL; duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol = PDSCH_LENGTH_SYMBOL; - + idx++; duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2; duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = @@ -363,39 +311,12 @@ uint8_t readMacCfg() duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength = PUSCH_LENGTH_SYMBOL; - duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS; + duCfgParam.macCellCfg.ssbCfg.dmrsTypeAPos = DMRS_TYPE_A_POS; /* fill PUCCH config common */ duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON; duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING; - - /* Plmn And SNSSAI Configuration */ - memcpy(&duCfgParam.macCellCfg.plmnInfoList.plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn,\ - sizeof(Plmn)); - taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst; - duCfgParam.macCellCfg.plmnInfoList.numSupportedSlice = taiSliceSuppLst->numSupportedSlices; - if(taiSliceSuppLst->snssai) - { - DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.plmnInfoList.snssai, (duCfgParam.macCellCfg.plmnInfoList.numSupportedSlice) * sizeof(Snssai*)); - if(duCfgParam.macCellCfg.plmnInfoList.snssai == NULLP) - { - DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg"); - return RFAILED; - } - } - for(sliceIdx=0; sliceIdxnumSupportedSlices; sliceIdx++) - { - if(taiSliceSuppLst->snssai[sliceIdx] != NULLP) - { - DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai)); - if(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx] == NULLP) - { - DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg"); - return RFAILED; - } - memcpy(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai)); - } - } + #ifndef O1_ENABLE @@ -404,8 +325,8 @@ uint8_t readMacCfg() rrmPolicy.id[0] = 1; rrmPolicy.resourceType = PRB; rrmPolicy.rRMMemberNum = 1; - memcpy(rrmPolicy.rRMPolicyMemberList[0].mcc,duCfgParam.macCellCfg.plmnInfoList.plmn.mcc, 3*sizeof(uint8_t)); - memcpy(rrmPolicy.rRMPolicyMemberList[0].mnc,duCfgParam.macCellCfg.plmnInfoList.plmn.mnc, 3*sizeof(uint8_t)); + memcpy(rrmPolicy.rRMPolicyMemberList[0].mcc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mcc, 3*sizeof(uint8_t)); + memcpy(rrmPolicy.rRMPolicyMemberList[0].mnc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mnc, 3*sizeof(uint8_t)); rrmPolicy.rRMPolicyMemberList[0].sst = 1; rrmPolicy.rRMPolicyMemberList[0].sd[0] = 2; rrmPolicy.rRMPolicyMemberList[0].sd[1] = 3; @@ -415,7 +336,7 @@ uint8_t readMacCfg() rrmPolicy.rRMPolicyDedicatedRatio = 10; cpyRrmPolicyInDuCfgParams(&rrmPolicy, 1, &duCfgParam.tempSliceCfg); - + #endif return ROK; diff --git a/src/du_app/du_cfg.h b/src/du_app/du_cfg.h index 832ef1df5..3876523e7 100644 --- a/src/du_app/du_cfg.h +++ b/src/du_app/du_cfg.h @@ -87,7 +87,8 @@ #define OFFSET_TO_POINT_A 24 /* PRB Offset to Point A */ #define BETA_PSS BETA_PSS_0DB #define SSB_PERIODICITY 20 -#define SSB_SUBCARRIER_OFFSET 0 +#define SSB_SUBCARRIER_OFFSET 0 +#define SSB_FREQUENCY 3000000 /*ssbFrequency in kHz*/ #define SSB_MULT_CARRIER_BAND FALSE #define MULT_CELL_CARRIER FALSE #define FREQ_LOC_BW 28875 /* DL frequency location and bandwidth. Spec 38.508 Table 4.3.1.0B-1*/ @@ -128,8 +129,6 @@ #define RSS_MEASUREMENT_UNIT DONT_REPORT_RSSI #define RA_CONT_RES_TIMER 64 #define RA_RSP_WINDOW 10 -#define PRACH_RESTRICTED_SET 0 /* Unrestricted */ -#define ROOT_SEQ_LEN 139 /* MACRCO Ddefine for PDCCH Configuration */ #define PDCCH_SEARCH_SPACE_ID 1 /* Common search space id */ @@ -218,7 +217,7 @@ /* Macro definitions for F1 procedures */ #define CU_DU_NAME_LEN_MAX 30 /* Max length of CU/DU name string */ #define MAX_F1_CONNECTIONS 65536 /* Max num of F1 connections */ -#define MAX_PLMN 1 /* Max num of broadcast PLMN ids */ + #define MAXNRARFCN 3279165 /* Maximum values of NRAFCN */ #define MAX_NRCELL_BANDS 2 /* Maximum number of frequency bands */ #define MAX_NUM_OF_SLICE_ITEMS 1024 /* Maximum number of signalled slice support items */ @@ -1305,7 +1304,6 @@ typedef struct rrmPolicyList DuCfgParams duCfgParam; /*function declarations */ -void FillSlotConfig(); uint8_t readClCfg(); uint8_t readCfg(); uint8_t duReadCfg(); diff --git a/src/du_app/du_f1ap_msg_hdl.c b/src/du_app/du_f1ap_msg_hdl.c index 957229d84..b17e2ccee 100644 --- a/src/du_app/du_f1ap_msg_hdl.c +++ b/src/du_app/du_f1ap_msg_hdl.c @@ -1214,7 +1214,7 @@ void freeFddNrFreqInfo(FDD_Info_t *fDD) * ****************************************************************/ void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell) { - uint8_t plmnCnt=MAX_PLMN; + uint8_t plmnCnt= 1; uint8_t extensionCnt=IE_EXTENSION_LIST_COUNT; uint8_t plmnIdx=0, sliceIdx=0; GNB_DU_Served_Cells_Item_t *srvCellItem; @@ -6717,7 +6717,7 @@ uint8_t BuildSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon) convertSsbPeriodicityValueToEnum(duCfgParam.sib1Params.srvCellCfgCommSib.ssbPrdServingCell); /* DMRS Type A position */ - spCellConfigCommon->dmrs_TypeA_Position = convertDmrsTypeAPosValueToEnum(duCfgParam.macCellCfg.dmrsTypeAPos); + spCellConfigCommon->dmrs_TypeA_Position = convertDmrsTypeAPosValueToEnum(duCfgParam.macCellCfg.ssbCfg.dmrsTypeAPos); /* SSB subcarrier spacing */ DU_ALLOC(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t)); diff --git a/src/du_app/du_mgr_main.c b/src/du_app/du_mgr_main.c index fd2902c9c..8d076f747 100644 --- a/src/du_app/du_mgr_main.c +++ b/src/du_app/du_mgr_main.c @@ -548,7 +548,7 @@ uint8_t commonInit() DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed"); return RFAILED; } - ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 16, 0); + //ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 16, 0); /* system task for EGTP */ if(ODU_CREATE_TASK(PRIOR0, &egtp_stsk) != ROK) @@ -556,7 +556,7 @@ uint8_t commonInit() DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed"); return RFAILED; } - ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 27, 0); + //ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 27, 0); /* system task for RLC_DL and MAC */ if(ODU_CREATE_TASK(PRIOR0, &rlc_mac_cl_stsk) != ROK) @@ -566,7 +566,7 @@ uint8_t commonInit() } pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 18, 0); + //ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 18, 0); /* system task for RLC UL */ if(ODU_CREATE_TASK(PRIOR1, &rlc_ul_stsk) != ROK) @@ -574,7 +574,7 @@ uint8_t commonInit() DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed"); return RFAILED; } - ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 22, 0); + //ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 22, 0); /* system task for SCTP receiver thread */ if(ODU_CREATE_TASK(PRIOR0, &sctp_stsk) != ROK) @@ -582,7 +582,7 @@ uint8_t commonInit() DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed"); return RFAILED; } - ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 25, 0); + //ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 25, 0); /* system task for lower-mac receiver thread */ if(ODU_CREATE_TASK(PRIOR0, &lwr_mac_stsk) != ROK) @@ -590,7 +590,7 @@ uint8_t commonInit() DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed"); return RFAILED; } - ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0); + //ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0); #ifndef INTEL_WLS_MEM /* system task for phy stub's slot indication generator thread */