nr,gnb,sched: simplify PDCCH allocation abortion api, and implemented method to print PDCCH allocations

master
Francisco 3 years ago committed by Francisco Paisana
parent 384004d8d1
commit bf275282ae

@ -45,6 +45,8 @@ public:
uint32_t nof_cces() const { return nof_freq_res * get_td_symbols(); } uint32_t nof_cces() const { return nof_freq_res * get_td_symbols(); }
size_t nof_allocs() const { return dfs_tree.size(); } size_t nof_allocs() const { return dfs_tree.size(); }
void print_allocations(fmt::memory_buffer& fmtbuf) const;
private: private:
const srsran_coreset_t* coreset_cfg; const srsran_coreset_t* coreset_cfg;
uint32_t coreset_id; uint32_t coreset_id;
@ -58,9 +60,7 @@ private:
struct alloc_record { struct alloc_record {
uint32_t aggr_idx; uint32_t aggr_idx;
uint32_t ss_id; uint32_t ss_id;
uint32_t idx;
srsran_dci_ctx_t* dci; srsran_dci_ctx_t* dci;
srsran_rnti_type_t rnti_type;
bool is_dl; bool is_dl;
const ue_carrier_params_t* ue; const ue_carrier_params_t* ue;
}; };
@ -140,9 +140,9 @@ public:
pdcch_ul_t* alloc_ul_pdcch(uint32_t ss_id, uint32_t aggr_idx, const ue_carrier_params_t& user); pdcch_ul_t* alloc_ul_pdcch(uint32_t ss_id, uint32_t aggr_idx, const ue_carrier_params_t& user);
/** /**
* Cancel and remove last PDCCH allocation * Cancel and remove last PDCCH allocation. It should only be called once after each alloc_dl_pdcch/alloc_ul_pdcch
*/ */
void rem_last_pdcch(srsran_dci_ctx_t& dci_ctx_to_rem); void cancel_last_pdcch();
/// Returns the number of PDCCH allocations made in the slot /// Returns the number of PDCCH allocations made in the slot
uint32_t nof_allocations() const; uint32_t nof_allocations() const;
@ -150,6 +150,9 @@ public:
/// Number of CCEs in given coreset /// Number of CCEs in given coreset
uint32_t nof_cces(uint32_t coreset_id) const; uint32_t nof_cces(uint32_t coreset_id) const;
void print_allocations(fmt::memory_buffer& fmtbuf) const;
std::string print_allocations() const;
private: private:
using slot_coreset_list = srsran::optional_array<coreset_region, SRSRAN_UE_DL_NR_MAX_NOF_CORESET>; using slot_coreset_list = srsran::optional_array<coreset_region, SRSRAN_UE_DL_NR_MAX_NOF_CORESET>;
@ -182,9 +185,10 @@ private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
const uint32_t slot_idx; const uint32_t slot_idx;
pdcch_dl_list_t& pdcch_dl_list; pdcch_dl_list_t& pdcch_dl_list;
pdcch_ul_list_t& pdcch_ul_list; pdcch_ul_list_t& pdcch_ul_list;
slot_coreset_list coresets; slot_coreset_list coresets;
const srsran_dci_ctx_t* pending_dci = nullptr; /// Saves last PDCCH allocation, in case it needs to be aborted
}; };
} // namespace sched_nr_impl } // namespace sched_nr_impl

@ -143,7 +143,7 @@ alloc_result bwp_slot_allocator::alloc_si(uint32_t aggr_idx,
pdcch->dci_cfg.coreset0_bw = srsran_coreset_get_bw(&cfg.cfg.pdcch.coreset[0]); pdcch->dci_cfg.coreset0_bw = srsran_coreset_get_bw(&cfg.cfg.pdcch.coreset[0]);
if (not fill_dci_sib(prbs, si_idx, si_ntx, *bwp_grid.cfg, pdcch->dci)) { if (not fill_dci_sib(prbs, si_idx, si_ntx, *bwp_grid.cfg, pdcch->dci)) {
// Cancel on-going PDCCH allocation // Cancel on-going PDCCH allocation
bwp_pdcch_slot.pdcchs.rem_last_pdcch(pdcch->dci.ctx); bwp_pdcch_slot.pdcchs.cancel_last_pdcch();
return alloc_result::invalid_coderate; return alloc_result::invalid_coderate;
} }
@ -156,7 +156,7 @@ alloc_result bwp_slot_allocator::alloc_si(uint32_t aggr_idx,
&cfg.cell_cfg.carrier, &slot_cfg, &cfg.cfg.pdsch, &pdcch->dci, &pdsch.sch, &pdsch.sch.grant); &cfg.cell_cfg.carrier, &slot_cfg, &cfg.cfg.pdsch, &pdcch->dci, &pdsch.sch, &pdsch.sch.grant);
if (code != SRSRAN_SUCCESS) { if (code != SRSRAN_SUCCESS) {
logger.warning("Error generating SIB PDSCH grant."); logger.warning("Error generating SIB PDSCH grant.");
bwp_pdcch_slot.pdcchs.rem_last_pdcch(pdcch->dci.ctx); bwp_pdcch_slot.pdcchs.cancel_last_pdcch();
bwp_pdcch_slot.dl.phy.pdsch.pop_back(); bwp_pdcch_slot.dl.phy.pdsch.pop_back();
return alloc_result::other_cause; return alloc_result::other_cause;
} }
@ -232,7 +232,7 @@ alloc_result bwp_slot_allocator::alloc_rar_and_msg3(uint16_t
// Generate DCI for RAR with given RA-RNTI // Generate DCI for RAR with given RA-RNTI
if (not fill_dci_rar(interv, ra_rnti, *bwp_grid.cfg, pdcch->dci)) { if (not fill_dci_rar(interv, ra_rnti, *bwp_grid.cfg, pdcch->dci)) {
// Cancel on-going PDCCH allocation // Cancel on-going PDCCH allocation
bwp_pdcch_slot.pdcchs.rem_last_pdcch(pdcch->dci.ctx); bwp_pdcch_slot.pdcchs.cancel_last_pdcch();
return alloc_result::invalid_coderate; return alloc_result::invalid_coderate;
} }
auto& phy_cfg = slot_ues[pending_rachs[0].temp_crnti]->phy(); auto& phy_cfg = slot_ues[pending_rachs[0].temp_crnti]->phy();

@ -74,12 +74,12 @@ bool coreset_region::alloc_pdcch(srsran_rnti_type_t rnti_type,
saved_dfs_tree.clear(); saved_dfs_tree.clear();
alloc_record record; alloc_record record;
record.dci = &dci; record.dci = &dci;
record.ue = user; record.ue = user;
record.aggr_idx = aggr_idx; record.aggr_idx = aggr_idx;
record.ss_id = search_space_id; record.ss_id = search_space_id;
record.is_dl = is_dl; record.is_dl = is_dl;
record.rnti_type = rnti_type; record.dci->rnti_type = rnti_type;
// Try to allocate grant. If it fails, attempt the same grant, but using a different permutation of past grant DCI // Try to allocate grant. If it fails, attempt the same grant, but using a different permutation of past grant DCI
// positions // positions
@ -171,7 +171,7 @@ bool coreset_region::alloc_dfs_node(const alloc_record& record, uint32_t start_d
srsran::span<const uint32_t> coreset_region::get_cce_loc_table(const alloc_record& record) const srsran::span<const uint32_t> coreset_region::get_cce_loc_table(const alloc_record& record) const
{ {
switch (record.rnti_type) { switch (record.dci->rnti_type) {
case srsran_rnti_type_ra: case srsran_rnti_type_ra:
return rar_cce_list[slot_idx][record.aggr_idx]; return rar_cce_list[slot_idx][record.aggr_idx];
case srsran_rnti_type_si: case srsran_rnti_type_si:
@ -182,12 +182,29 @@ srsran::span<const uint32_t> coreset_region::get_cce_loc_table(const alloc_recor
case srsran_rnti_type_sp_csi: case srsran_rnti_type_sp_csi:
return record.ue->cce_pos_list(record.ss_id, slot_idx, record.aggr_idx); return record.ue->cce_pos_list(record.ss_id, slot_idx, record.aggr_idx);
default: default:
srsran_terminate("Invalid RNTI type=%d", record.rnti_type); srsran_terminate("Invalid RNTI type=%s", srsran_rnti_type_str(record.dci->rnti_type));
break; break;
} }
return {}; return {};
} }
void coreset_region::print_allocations(fmt::memory_buffer& fmtbuf) const
{
if (not dci_list.empty()) {
fmt::format_to(fmtbuf, "CORESET#{}:\n", coreset_id);
}
for (const alloc_record& dci : dci_list) {
fmt::format_to(fmtbuf,
" {}-rnti=0x{:x}: ({}, {})\n",
srsran_rnti_type_str_short(dci.dci->rnti_type),
dci.dci->rnti,
dci.dci->location.ncce,
dci.dci->location.L);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bwp_pdcch_allocator::bwp_pdcch_allocator(const bwp_params_t& bwp_cfg_, bwp_pdcch_allocator::bwp_pdcch_allocator(const bwp_params_t& bwp_cfg_,
uint32_t slot_idx_, uint32_t slot_idx_,
pdcch_dl_list_t& dl_pdcchs, pdcch_dl_list_t& dl_pdcchs,
@ -272,7 +289,12 @@ pdcch_dl_t* bwp_pdcch_allocator::alloc_dl_pdcch_common(srsran_rnti_type_t
return nullptr; return nullptr;
} }
// Fill DCI context information
fill_dci_ctx_common(pdcch_dl_list.back().dci.ctx, rnti_type, rnti, ss, dci_fmt, user); fill_dci_ctx_common(pdcch_dl_list.back().dci.ctx, rnti_type, rnti, ss, dci_fmt, user);
// register last PDCCH coreset, in case it needs to be aborted
pending_dci = &pdcch_dl_list.back().dci.ctx;
return &pdcch_dl_list.back(); return &pdcch_dl_list.back();
} }
@ -300,27 +322,35 @@ pdcch_ul_t* bwp_pdcch_allocator::alloc_ul_pdcch(uint32_t ss_id, uint32_t aggr_id
return nullptr; return nullptr;
} }
// Fill DCI context information
fill_dci_ctx_common(pdcch_ul_list.back().dci.ctx, srsran_rnti_type_c, user.rnti, ss, dci_fmt, &user); fill_dci_ctx_common(pdcch_ul_list.back().dci.ctx, srsran_rnti_type_c, user.rnti, ss, dci_fmt, &user);
// register last PDCCH coreset, in case it needs to be aborted
pending_dci = &pdcch_ul_list.back().dci.ctx;
return &pdcch_ul_list.back(); return &pdcch_ul_list.back();
} }
void bwp_pdcch_allocator::rem_last_pdcch(srsran_dci_ctx_t& dci_ctx_to_rem) void bwp_pdcch_allocator::cancel_last_pdcch()
{ {
uint32_t cs_id = dci_ctx_to_rem.coreset_id; srsran_assert(pending_dci != nullptr, "Trying to abort PDCCH allocation that does not exist");
uint32_t cs_id = pending_dci->coreset_id;
if (&pdcch_dl_list.back().dci.ctx == &dci_ctx_to_rem) { if (&pdcch_dl_list.back().dci.ctx == pending_dci) {
pdcch_dl_list.pop_back(); pdcch_dl_list.pop_back();
} else if (&pdcch_ul_list.back().dci.ctx == &dci_ctx_to_rem) { } else if (&pdcch_ul_list.back().dci.ctx == pending_dci) {
pdcch_ul_list.pop_back(); pdcch_ul_list.pop_back();
} else { } else {
logger.error("Invalid DCI context provided to be removed"); logger.error("Invalid DCI context provided to be removed");
return; return;
} }
coresets[cs_id].rem_last_pdcch(); coresets[cs_id].rem_last_pdcch();
pending_dci = nullptr;
} }
void bwp_pdcch_allocator::reset() void bwp_pdcch_allocator::reset()
{ {
pending_dci = nullptr;
pdcch_dl_list.clear(); pdcch_dl_list.clear();
pdcch_ul_list.clear(); pdcch_ul_list.clear();
for (coreset_region& coreset : coresets) { for (coreset_region& coreset : coresets) {
@ -406,5 +436,21 @@ bool bwp_pdcch_allocator::check_args_valid(srsran_rnti_type_t rnti_type,
return true; return true;
} }
void bwp_pdcch_allocator::print_allocations(fmt::memory_buffer& fmtbuf) const
{
fmt::format_to(
fmtbuf, "PDCCH allocations ({} active coresets):{}\n", coresets.size(), nof_allocations() == 0 ? " None" : "");
for (const coreset_region& cs : coresets) {
cs.print_allocations(fmtbuf);
}
}
std::string bwp_pdcch_allocator::print_allocations() const
{
fmt::memory_buffer fmtbuf;
print_allocations(fmtbuf);
return fmt::to_string(fmtbuf);
}
} // namespace sched_nr_impl } // namespace sched_nr_impl
} // namespace srsenb } // namespace srsenb

@ -68,6 +68,8 @@ void test_coreset0_cfg()
TESTASSERT(pdcch_sched.alloc_dl_pdcch(srsran_rnti_type_c, 1, aggr_idx, ue_cc) == nullptr); TESTASSERT(pdcch_sched.alloc_dl_pdcch(srsran_rnti_type_c, 1, aggr_idx, ue_cc) == nullptr);
TESTASSERT(pdcch_sched.alloc_ul_pdcch(1, aggr_idx, ue_cc) == nullptr); TESTASSERT(pdcch_sched.alloc_ul_pdcch(1, aggr_idx, ue_cc) == nullptr);
srslog::fetch_basic_logger("TEST").info("%s", pdcch_sched.print_allocations());
// Slot with RAR // Slot with RAR
pdcch_sched.reset(); pdcch_sched.reset();
@ -84,6 +86,8 @@ void test_coreset0_cfg()
TESTASSERT(pdcch_sched.alloc_dl_pdcch(srsran_rnti_type_c, 1, aggr_idx, ue_cc) == nullptr); TESTASSERT(pdcch_sched.alloc_dl_pdcch(srsran_rnti_type_c, 1, aggr_idx, ue_cc) == nullptr);
TESTASSERT(pdcch_sched.alloc_ul_pdcch(1, aggr_idx, ue_cc) == nullptr); TESTASSERT(pdcch_sched.alloc_ul_pdcch(1, aggr_idx, ue_cc) == nullptr);
srslog::fetch_basic_logger("TEST").info("%s", pdcch_sched.print_allocations());
// Slot with DL PDSCH // Slot with DL PDSCH
pdcch_sched.reset(); pdcch_sched.reset();
@ -99,6 +103,8 @@ void test_coreset0_cfg()
// No space for 2nd PDCCH allocation // No space for 2nd PDCCH allocation
TESTASSERT(pdcch_sched.alloc_ul_pdcch(1, aggr_idx, ue_cc) == nullptr); TESTASSERT(pdcch_sched.alloc_ul_pdcch(1, aggr_idx, ue_cc) == nullptr);
srslog::fetch_basic_logger("TEST").info("%s", pdcch_sched.print_allocations());
// Slot with UL PDSCH // Slot with UL PDSCH
pdcch_sched.reset(); pdcch_sched.reset();
@ -113,6 +119,8 @@ void test_coreset0_cfg()
// No space for 2nd PDCCH allocation // No space for 2nd PDCCH allocation
TESTASSERT(pdcch_sched.alloc_dl_pdcch(srsran_rnti_type_c, 1, aggr_idx, ue_cc) == nullptr); TESTASSERT(pdcch_sched.alloc_dl_pdcch(srsran_rnti_type_c, 1, aggr_idx, ue_cc) == nullptr);
srslog::fetch_basic_logger("TEST").info("%s", pdcch_sched.print_allocations());
} }
/** /**
@ -202,6 +210,8 @@ void test_coreset2_cfg()
TESTASSERT_EQ(1, ul_pdcchs.size()); TESTASSERT_EQ(1, ul_pdcchs.size());
test_pdcch_collisions(bwp_params.cfg.pdcch, dl_pdcchs, ul_pdcchs); test_pdcch_collisions(bwp_params.cfg.pdcch, dl_pdcchs, ul_pdcchs);
srslog::fetch_basic_logger("TEST").info("%s", pdcch_sched.print_allocations());
// Verify all coresets are correctly cleaned up // Verify all coresets are correctly cleaned up
pdcch_sched.reset(); pdcch_sched.reset();
TESTASSERT_EQ(0, pdcch_sched.nof_allocations()); TESTASSERT_EQ(0, pdcch_sched.nof_allocations());

Loading…
Cancel
Save