sched,nr: implement prb grant fmt formatting

master
Francisco Paisana 3 years ago
parent 8686a17f69
commit b486d2a1b5

@ -340,3 +340,4 @@ uint32_t srsran_ra_nr_type1_riv(uint32_t N_prb, uint32_t start_rb, uint32_t leng
{
return srsran_sliv_from_s_and_l(N_prb, start_rb, length_rb);
}

@ -234,4 +234,21 @@ inline prb_interval find_empty_interval_of_length(const prb_bitmap& mask, size_t
} // namespace sched_nr_impl
} // namespace srsenb
namespace fmt {
template <>
struct formatter<srsenb::sched_nr_impl::prb_grant> : public formatter<srsenb::sched_nr_impl::rbg_bitmap> {
template <typename FormatContext>
auto format(const srsenb::sched_nr_impl::prb_grant& grant, FormatContext& ctx)
-> decltype(std::declval<FormatContext>().out())
{
if (grant.is_alloc_type1()) {
return formatter<srsran::interval<uint32_t> >{}.format(grant.prbs(), ctx);
}
return formatter<srsenb::sched_nr_impl::rbg_bitmap>::format(grant.rbgs(), ctx);
}
};
} // namespace fmt
#endif // SRSRAN_SCHED_NR_RB_H

@ -53,7 +53,6 @@ private:
void alloc_dl_ues();
void alloc_ul_ues();
void log_result() const;
const sched_cell_params& cfg;
serv_cell_manager& cell;

@ -122,24 +122,30 @@ void log_sched_bwp_result(srslog::basic_logger& logger,
fmt::memory_buffer fmtbuf;
if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_c) {
const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti];
fmt::format_to(
fmtbuf,
"SCHED: DL {}, cc={}, rnti=0x{:x}, pid={}, f={}, nrtx={}, dai={}, tbs={}, pdsch_slot={}, tti_ack={}",
fmt::format_to(fmtbuf,
"SCHED: DL {}, cc={}, rnti=0x{:x}, pid={}, f={}, grant={}, nrtx={}, dai={}, tbs={}, "
"pdsch_slot={}, tti_ack={}",
ue.h_dl->nof_retx() == 0 ? "tx" : "retx",
res_grid.cfg->cc,
ue.rnti,
pdcch.dci.pid,
srsran_dci_format_nr_string(pdcch.dci.ctx.format),
ue.h_dl->prbs(),
ue.h_dl->nof_retx(),
pdcch.dci.dai,
ue.h_dl->tbs(),
ue.pdsch_slot,
ue.uci_slot);
} else if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_ra) {
const pdsch_t& pdsch = bwp_slot.pdschs[std::distance(bwp_slot.dl_pdcchs.data(), &pdcch)];
srsran::const_span<bool> prbs{pdsch.sch.grant.prb_idx, pdsch.sch.grant.prb_idx + pdsch.sch.grant.nof_prb};
uint32_t start_idx = std::distance(prbs.begin(), std::find(prbs.begin(), prbs.end(), true));
uint32_t end_idx = std::distance(prbs.begin(), std::find(prbs.begin() + start_idx, prbs.end(), false));
fmt::format_to(fmtbuf,
"SCHED: DL RAR, cc={}, ra-rnti=0x{:x}, pdsch_slot={}, msg3_slot={}",
"SCHED: DL RAR, cc={}, ra-rnti=0x{:x}, grant={}, pdsch_slot={}, msg3_slot={}",
res_grid.cfg->cc,
pdcch.dci.ctx.rnti,
srsran::interval<uint32_t>{start_idx, end_idx},
pdcch_slot,
pdcch_slot + res_grid.cfg->pusch_ra_list[0].msg3_delay);
} else {

@ -129,66 +129,6 @@ void slot_cc_worker::alloc_ul_ues()
cell.bwps[0].data_sched->sched_ul_users(slot_ues, bwp_alloc);
}
void slot_cc_worker::log_result() const
{
const bwp_slot_grid& bwp_slot = cell.bwps[0].grid[slot_rx + TX_ENB_DELAY];
for (const pdcch_dl_t& pdcch : bwp_slot.dl_pdcchs) {
fmt::memory_buffer fmtbuf;
if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_c) {
const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti];
fmt::format_to(
fmtbuf,
"SCHED: DL {}, cc={}, rnti=0x{:x}, pid={}, f={}, nrtx={}, dai={}, tbs={}, tti_pdsch={}, tti_ack={}",
ue.h_dl->nof_retx() == 0 ? "tx" : "retx",
cell.cfg.cc,
ue.rnti,
pdcch.dci.pid,
srsran_dci_format_nr_string(pdcch.dci.ctx.format),
ue.h_dl->nof_retx(),
pdcch.dci.dai,
ue.h_dl->tbs(),
ue.pdsch_slot,
ue.uci_slot);
} else if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_ra) {
fmt::format_to(fmtbuf, "SCHED: DL RAR, cc={}, ra-rnti=0x{:x}", cell.cfg.cc, pdcch.dci.ctx.rnti);
} else {
fmt::format_to(fmtbuf, "SCHED: unknown format");
}
logger.info("%s", srsran::to_c_str(fmtbuf));
}
for (const pdcch_ul_t& pdcch : bwp_slot.ul_pdcchs) {
fmt::memory_buffer fmtbuf;
if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_c) {
const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti];
fmt::format_to(fmtbuf,
"SCHED: UL {}, cc={}, rnti=0x{:x}, pid={}, f={}, nrtx={}, tbs={}, tti_pusch={}",
ue.h_dl->nof_retx() == 0 ? "tx" : "retx",
cell.cfg.cc,
ue.rnti,
pdcch.dci.pid,
srsran_dci_format_nr_string(pdcch.dci.ctx.format),
ue.h_dl->nof_retx(),
ue.h_ul->tbs(),
ue.pusch_slot);
} else if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_tc) {
const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti];
fmt::format_to(fmtbuf,
"SCHED: UL Msg3, cc={}, tc-rnti=0x{:x}, pid={}, nrtx={}, f={}, tti_pusch={}",
cell.cfg.cc,
ue.rnti,
pdcch.dci.pid,
ue.h_dl->nof_retx(),
srsran_dci_format_nr_string(pdcch.dci.ctx.format),
ue.pusch_slot);
} else {
fmt::format_to(fmtbuf, "SCHED: unknown rnti format");
}
logger.info("%s", srsran::to_c_str(fmtbuf));
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sched_worker_manager::sched_worker_manager(ue_map_t& ue_db_,

@ -27,3 +27,4 @@ add_test(sched_nr_prb_test sched_nr_prb_test)
add_executable(sched_nr_rar_test sched_nr_rar_test.cc)
target_link_libraries(sched_nr_rar_test srsgnb_mac sched_nr_test_suite srsran_common)
add_test(sched_nr_rar_test sched_nr_rar_test)

@ -49,6 +49,10 @@ void test_bwp_prb_grant()
TESTASSERT(grant.is_alloc_type0() and grant.rbgs().count() == 1);
grant = grant2;
TESTASSERT(grant.is_alloc_type1() and grant.prbs().length() == 3);
// TEST: formatting
TESTASSERT_EQ("[2, 5)", fmt::format("{}", grant2));
TESTASSERT_EQ("0x10000", fmt::format("0x{:x}", grant3));
}
void test_bwp_rb_bitmap()

@ -179,9 +179,9 @@ void sched_nr_cfg_parallel_cc_test()
int main()
{
auto& test_logger = srslog::fetch_basic_logger("TEST");
test_logger.set_level(srslog::basic_levels::warning);
test_logger.set_level(srslog::basic_levels::info);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.set_level(srslog::basic_levels::warning);
mac_logger.set_level(srslog::basic_levels::info);
auto& pool_logger = srslog::fetch_basic_logger("POOL");
pool_logger.set_level(srslog::basic_levels::info);

Loading…
Cancel
Save