From fa34aaa16e8f30044600b0e58e5d429e5d63461a Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 14 May 2021 17:28:46 +0100 Subject: [PATCH] ensure the DL mask count is reduced enough to fit required bytes --- lib/include/srsran/adt/bounded_bitset.h | 7 +++++++ srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/include/srsran/adt/bounded_bitset.h b/lib/include/srsran/adt/bounded_bitset.h index afc099bc5..d16966c39 100644 --- a/lib/include/srsran/adt/bounded_bitset.h +++ b/lib/include/srsran/adt/bounded_bitset.h @@ -363,6 +363,13 @@ public: return get_word_(0); } + void from_uint64(uint64_t v) + { + srsran_assert(nof_words_() == 1, "ERROR: cannot convert bitset of size=%zd to uint64_t", size()); + srsran_assert(v < (1U << size()), "ERROR: Provided uint64=%ld does not fit in bitset of size=%zd", v, size()); + buffer[0] = v; + } + template OutputIt to_hex(OutputIt&& mem_buffer) const noexcept { diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc index 7b09e22e8..416b11981 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc @@ -392,10 +392,15 @@ bool find_optimal_rbgmask(const sched_ue_cell& ue_cell, }; std::tuple ret = false_position_method( 1U, tb_table.size(), (int)req_bytes.stop(), compute_tbs_approx, [](int y) { return y == SRSRAN_ERROR; }); - uint32_t upper_nprb = std::get<2>(ret); + uint32_t upper_nrbg = std::get<2>(ret); int upper_tbs = std::get<3>(ret); if (upper_tbs >= (int)req_bytes.stop()) { - tb = tb_table[upper_nprb - 1]; + tb = tb_table[upper_nrbg - 1]; + int pos = 0; + for (uint32_t n_rbgs = newtxmask.count(); n_rbgs > upper_nrbg; --n_rbgs) { + pos = newtxmask.find_lowest(pos + 1, newtxmask.size()); + } + newtxmask.from_uint64(~((1U << (uint64_t)pos) - 1U) & ((1U << newtxmask.size()) - 1U)); } return true; }