From b869b0d8e2c0aa7bbbb5b2c34a9f13cbc8b5392c Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 5 Mar 2021 17:19:22 +0000 Subject: [PATCH] sched,bugfix&refactor: set dci_format before generating the remaining dci parameters in sched_ue::generate_dl_dci_format(...) --- srsenb/hdr/stack/mac/sched_ue.h | 6 ++++ srsenb/src/stack/mac/sched_ue.cc | 53 +++++++++++++++++++------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/srsenb/hdr/stack/mac/sched_ue.h b/srsenb/hdr/stack/mac/sched_ue.h index d29fb7ea8..c70891c7f 100644 --- a/srsenb/hdr/stack/mac/sched_ue.h +++ b/srsenb/hdr/stack/mac/sched_ue.h @@ -157,6 +157,12 @@ private: bool needs_cqi(uint32_t tti, uint32_t enb_cc_idx, bool will_send = false); + int generate_format1_common(uint32_t pid, + sched_interface::dl_sched_data_t* data, + tti_point tti_tx_dl, + uint32_t enb_cc_idx, + uint32_t cfi, + const rbgmask_t& user_mask); int generate_format1(uint32_t pid, sched_interface::dl_sched_data_t* data, tti_point tti_tx_dl, diff --git a/srsenb/src/stack/mac/sched_ue.cc b/srsenb/src/stack/mac/sched_ue.cc index e517753aa..41dba6d4e 100644 --- a/srsenb/src/stack/mac/sched_ue.cc +++ b/srsenb/src/stack/mac/sched_ue.cc @@ -370,6 +370,13 @@ int sched_ue::generate_dl_dci_format(uint32_t pid, srslte_dci_format_t dci_format = get_dci_format(); int tbs_bytes = 0; + // Set common DCI fields + srslte_dci_dl_t* dci = &data->dci; + dci->rnti = rnti; + dci->pid = pid; + dci->ue_cc_idx = cells[enb_cc_idx].get_ue_cc_idx(); + dci->format = dci_format; + switch (dci_format) { case SRSLTE_DCI_FORMAT1A: tbs_bytes = generate_format1a(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); @@ -387,14 +394,9 @@ int sched_ue::generate_dl_dci_format(uint32_t pid, logger.error("DCI format (%d) not implemented", dci_format); } - // Set common DCI fields + // If allocation successful, encode TPC if (tbs_bytes > 0) { - srslte_dci_dl_t* dci = &data->dci; - dci->rnti = rnti; - dci->pid = pid; - dci->ue_cc_idx = cells[enb_cc_idx].get_ue_cc_idx(); - data->dci.format = dci_format; - dci->tpc_pucch = cells[enb_cc_idx].tpc_fsm.encode_pucch_tpc(); + dci->tpc_pucch = cells[enb_cc_idx].tpc_fsm.encode_pucch_tpc(); } return tbs_bytes; @@ -407,8 +409,6 @@ int sched_ue::generate_format1a(uint32_t pid, uint32_t cfi, const rbgmask_t& user_mask) { - int tbs_bytes = generate_format1(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); - srslte_dci_dl_t* dci = &data->dci; dci->alloc_type = SRSLTE_RA_ALLOC_TYPE2; @@ -423,28 +423,24 @@ int sched_ue::generate_format1a(uint32_t pid, logger.warning("SCHED: Can't use distributed RA due to DCI size ambiguity"); } - return tbs_bytes; + return generate_format1_common(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); } -// > return 0 if allocation is invalid -int sched_ue::generate_format1(uint32_t pid, - sched_interface::dl_sched_data_t* data, - tti_point tti_tx_dl, - uint32_t enb_cc_idx, - uint32_t cfi, - const rbgmask_t& user_mask) +int sched_ue::generate_format1_common(uint32_t pid, + sched_interface::dl_sched_data_t* data, + tti_point tti_tx_dl, + uint32_t enb_cc_idx, + uint32_t cfi, + const rbgmask_t& user_mask) { dl_harq_proc* h = &cells[enb_cc_idx].harq_ent.dl_harq_procs()[pid]; srslte_dci_dl_t* dci = &data->dci; - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0; - dci->type0_alloc.rbg_bitmask = (uint32_t)user_mask.to_uint64(); - tbs_info tbinfo; if (h->is_empty(0)) { tbinfo = allocate_new_dl_mac_pdu(data, h, user_mask, tti_tx_dl, enb_cc_idx, cfi, 0); } else { - h->new_retx(user_mask, 0, tti_tx_dl, &tbinfo.mcs, &tbinfo.tbs_bytes, data->dci.location.ncce); + h->new_retx(user_mask, 0, tti_tx_dl, &tbinfo.mcs, &tbinfo.tbs_bytes, dci->location.ncce); logger.debug("SCHED: Alloc format1 previous mcs=%d, tbs=%d", tbinfo.mcs, tbinfo.tbs_bytes); } @@ -459,6 +455,21 @@ int sched_ue::generate_format1(uint32_t pid, return tbinfo.tbs_bytes; } +int sched_ue::generate_format1(uint32_t pid, + sched_interface::dl_sched_data_t* data, + tti_point tti_tx_dl, + uint32_t enb_cc_idx, + uint32_t cfi, + const rbgmask_t& user_mask) +{ + srslte_dci_dl_t* dci = &data->dci; + + dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci->type0_alloc.rbg_bitmask = (uint32_t)user_mask.to_uint64(); + + return generate_format1_common(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); +} + /** * Based on the amount of tx data, allocated PRBs, DCI params, etc. compute a valid MCS and resulting TBS * @param enb_cc_idx user carrier index