From af0b80b0a7c41bb29fbeb155d6086f5f57e83503 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 28 Jan 2020 15:46:20 +0000 Subject: [PATCH] fix test for prb==6 and accidental adaptive retx in UL --- srsenb/src/stack/mac/scheduler_carrier.cc | 2 +- srsenb/src/stack/mac/scheduler_grid.cc | 2 +- srsenb/test/mac/scheduler_test_rand.cc | 73 +++++++++++++++-------- 3 files changed, 51 insertions(+), 26 deletions(-) diff --git a/srsenb/src/stack/mac/scheduler_carrier.cc b/srsenb/src/stack/mac/scheduler_carrier.cc index e0b1a6926..b44cf073a 100644 --- a/srsenb/src/stack/mac/scheduler_carrier.cc +++ b/srsenb/src/stack/mac/scheduler_carrier.cc @@ -220,7 +220,7 @@ void ra_sched::ul_sched(sf_sched* tti_sched) int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) { - log_h->info("SCHED: New RAR tti=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d\n", + log_h->info("SCHED: New PRACH tti=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d\n", rar_info.prach_tti, rar_info.preamble_idx, rar_info.temp_crnti, diff --git a/srsenb/src/stack/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc index 93b9e1dd4..515247ce0 100644 --- a/srsenb/src/stack/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -616,7 +616,7 @@ alloc_outcome_t sf_sched::alloc_ul_user(sched_ue* user, ul_harq_proc::ul_alloc_t bool has_retx = h->has_pending_retx(); if (has_retx) { ul_harq_proc::ul_alloc_t prev_alloc = h->get_alloc(); - if (prev_alloc.L == alloc.L and prev_alloc.RB_start == prev_alloc.L) { + if (prev_alloc.L == alloc.L and prev_alloc.RB_start == alloc.RB_start) { alloc_type = ul_alloc_t::NOADAPT_RETX; } else { alloc_type = ul_alloc_t::ADAPT_RETX; diff --git a/srsenb/test/mac/scheduler_test_rand.cc b/srsenb/test/mac/scheduler_test_rand.cc index 67bc6acb2..b80fc0d37 100644 --- a/srsenb/test/mac/scheduler_test_rand.cc +++ b/srsenb/test/mac/scheduler_test_rand.cc @@ -171,6 +171,7 @@ struct sched_tester : public srsenb::sched { uint32_t tti_tx_dl; uint32_t tti_tx_ul; uint32_t current_cfi; + uint32_t nof_prachs = 0; bool ul_pending_msg3_present = false; srsenb::sf_sched::pending_msg3_t ul_pending_msg3; srslte::bounded_bitset<128, true> used_cce; @@ -185,8 +186,9 @@ struct sched_tester : public srsenb::sched { bool drb_cfg_flag = false; srsenb::sched_interface::ue_bearer_cfg_t bearer_cfg; srsenb::sched_interface::ue_cfg_t user_cfg; - uint32_t dl_data = 0; - uint32_t ul_data = 0; + uint32_t dl_data = 0; + uint32_t ul_data = 0; + uint32_t preamble_idx = 0; }; struct ack_info_t { uint16_t rnti; @@ -239,9 +241,10 @@ int sched_tester::add_user(uint16_t rnti, srsenb::sched_interface::ue_cfg_t ue_cfg_) { ue_info info; - info.prach_tti = tti_data.tti_rx; - info.bearer_cfg = bearer_cfg; - info.user_cfg = ue_cfg_; + info.prach_tti = tti_data.tti_rx; + info.bearer_cfg = bearer_cfg; + info.user_cfg = ue_cfg_; + info.preamble_idx = tti_data.nof_prachs++; tester_ues.insert(std::make_pair(rnti, info)); if (ue_cfg(rnti, &ue_cfg_) != SRSLTE_SUCCESS) { @@ -251,6 +254,7 @@ int sched_tester::add_user(uint16_t rnti, rar_info.prach_tti = tti_data.tti_rx; rar_info.temp_crnti = rnti; rar_info.msg3_size = 7; + rar_info.preamble_idx = info.preamble_idx; dl_rach_info(CARRIER_IDX, rar_info); // setup bearers @@ -288,7 +292,8 @@ void sched_tester::new_test_tti(uint32_t tti_) tti_data.used_cce.resize(srslte_regs_pdcch_ncce(®s, tti_data.current_cfi)); tti_data.used_cce.reset(); tti_data.ue_data.clear(); - tti_data.total_ues = tester_user_results(); + tti_data.total_ues = tester_user_results(); + tti_data.nof_prachs = 0; } int sched_tester::process_tti_args() @@ -446,7 +451,8 @@ int sched_tester::test_ra() if (tti_data.tti_tx_dl >= window[0]) { for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_rar_elems; ++i) { for (uint32_t j = 0; j < tti_data.sched_result_dl.rar[i].nof_grants; ++j) { - if (tti_data.sched_result_dl.rar[i].msg3_grant[j].data.prach_tti + TX_DELAY == tti_data.tti_tx_dl) { + auto& data = tti_data.sched_result_dl.rar[i].msg3_grant[j].data; + if (data.prach_tti == (uint32_t)userinfo.prach_tti and data.preamble_idx == userinfo.preamble_idx) { userinfo.rar_tti = tti_data.tti_tx_dl; } } @@ -489,7 +495,15 @@ int sched_tester::test_ra() } } for (uint32_t i = 0; i < tti_data.sched_result_ul.nof_dci_elems; ++i) { - msg3_count -= tti_data.sched_result_ul.pusch[i].needs_pdcch ? 0 : 1; + auto& pusch_alloc = tti_data.sched_result_ul.pusch[i]; + if (not pusch_alloc.needs_pdcch) { + // can be adaptive retx or msg3 + auto& ue = tester_ues[pusch_alloc.dci.rnti]; + if (tti_data.tti_tx_ul == (uint32_t)ue.msg3_tti) { + msg3_count--; + } + } + // msg3_count -= tti_data.sched_result_ul.pusch[i].needs_pdcch ? 0 : 1; } CONDERROR(msg3_count > 0, "[TESTER] There are pending msg3 that do not belong to any active UE\n"); @@ -869,50 +883,58 @@ int sched_tester::test_collisions() srslte_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); - for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_data_elems; ++i) { - alloc_mask.reset(); + for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_bc_elems; ++i) { srslte_pdsch_grant_t grant; CONDERROR(srslte_ra_dl_dci_to_grant( - &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.data[i].dci, &grant) == SRSLTE_ERROR, + &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.bc[i].dci, &grant) == SRSLTE_ERROR, "Failed to decode PDSCH grant\n"); + alloc_mask.reset(); for (uint32_t j = 0; j < alloc_mask.size(); ++j) { if (grant.prb_idx[0][j]) { alloc_mask.set(j); - } else { - alloc_mask.reset(j); } } if ((dl_allocs & alloc_mask).any()) { - TESTERROR("[TESTER] Detected collision in the DL data allocation (%s intersects %s)\n", + TESTERROR("[TESTER] Detected collision in the DL bc allocation (%s intersects %s)\n", dl_allocs.to_string().c_str(), alloc_mask.to_string().c_str()); } dl_allocs |= alloc_mask; - ue_stats[tti_data.sched_result_dl.data[i].dci.rnti].nof_dl_rbs += alloc_mask.count(); } - for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_bc_elems; ++i) { + for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_rar_elems; ++i) { + alloc_mask.reset(); srslte_pdsch_grant_t grant; CONDERROR(srslte_ra_dl_dci_to_grant( - &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.bc[i].dci, &grant) == SRSLTE_ERROR, + &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.rar[i].dci, &grant) == SRSLTE_ERROR, "Failed to decode PDSCH grant\n"); - alloc_mask.reset(); for (uint32_t j = 0; j < alloc_mask.size(); ++j) { if (grant.prb_idx[0][j]) { alloc_mask.set(j); + } else { + alloc_mask.reset(j); } } if ((dl_allocs & alloc_mask).any()) { - TESTERROR("[TESTER] Detected collision in the DL bc allocation (%s intersects %s)\n", + TESTERROR("[TESTER] Detected collision in the DL RAR allocation (%s intersects %s)\n", dl_allocs.to_string().c_str(), alloc_mask.to_string().c_str()); } dl_allocs |= alloc_mask; } - for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_rar_elems; ++i) { + + // forbid Data in DL if it conflicts with PRACH for PRB==6 + if (cfg.cell.nof_prb == 6) { + uint32_t tti_rx_ack = TTI_RX_ACK(tti_data.tti_rx); + if (srslte_prach_tti_opportunity_config_fdd(cfg.prach_config, tti_rx_ack, -1)) { + dl_allocs.fill(0, dl_allocs.size()); + } + } + + for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_data_elems; ++i) { alloc_mask.reset(); srslte_pdsch_grant_t grant; CONDERROR(srslte_ra_dl_dci_to_grant( - &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.rar[i].dci, &grant) == SRSLTE_ERROR, + &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.data[i].dci, &grant) == SRSLTE_ERROR, "Failed to decode PDSCH grant\n"); for (uint32_t j = 0; j < alloc_mask.size(); ++j) { if (grant.prb_idx[0][j]) { @@ -922,11 +944,12 @@ int sched_tester::test_collisions() } } if ((dl_allocs & alloc_mask).any()) { - TESTERROR("[TESTER] Detected collision in the DL RAR allocation (%s intersects %s)\n", + TESTERROR("[TESTER] Detected collision in the DL data allocation (%s intersects %s)\n", dl_allocs.to_string().c_str(), alloc_mask.to_string().c_str()); } dl_allocs |= alloc_mask; + ue_stats[tti_data.sched_result_dl.data[i].dci.rnti].nof_dl_rbs += alloc_mask.count(); } // TEST: check if resulting DL mask is equal to scheduler internal DL mask @@ -945,7 +968,9 @@ int sched_tester::test_collisions() } } if (rbgmask != carrier_schedulers[0]->get_sf_sched_ptr(tti_data.tti_rx)->get_dl_mask()) { - TESTERROR("[TESTER] The UL PRB mask and the scheduler result UL mask are not consistent\n"); + TESTERROR("[TESTER] The UL PRB mask and the scheduler result UL mask are not consistent (%s!=%s)\n", + rbgmask.to_string().c_str(), + carrier_schedulers[CARRIER_IDX]->get_sf_sched_ptr(tti_data.tti_rx)->get_dl_mask().to_string().c_str()); } return SRSLTE_SUCCESS; } @@ -1044,7 +1069,7 @@ srsenb::sched_interface::cell_cfg_t generate_cell_cfg() cell_cfg_phy.id = 1; cell_cfg_phy.cp = SRSLTE_CP_NORM; cell_cfg_phy.nof_ports = 1; - cell_cfg_phy.nof_prb = 100; + cell_cfg_phy.nof_prb = 6; cell_cfg_phy.phich_length = SRSLTE_PHICH_NORM; cell_cfg_phy.phich_resources = SRSLTE_PHICH_R_1;