mirror of https://github.com/PentHertz/srsLTE.git
use range of rbgs
This commit is contained in:
parent
46579da1ff
commit
a744729007
|
@ -79,6 +79,28 @@ using rbgmask_t = srslte::bounded_bitset<25, true>;
|
||||||
//! Bitmask that stores the allocated UL PRBs
|
//! Bitmask that stores the allocated UL PRBs
|
||||||
using prbmask_t = srslte::bounded_bitset<100, true>;
|
using prbmask_t = srslte::bounded_bitset<100, true>;
|
||||||
|
|
||||||
|
//! Struct to express a {min,...,max} range of RBGs
|
||||||
|
struct prb_range_t;
|
||||||
|
struct rbg_range_t {
|
||||||
|
uint32_t rbg_min = 0, rbg_max = 0;
|
||||||
|
rbg_range_t() = default;
|
||||||
|
rbg_range_t(uint32_t s, uint32_t e) : rbg_min(s), rbg_max(e) {}
|
||||||
|
uint32_t nof_rbgs() const { return rbg_max - rbg_min; }
|
||||||
|
|
||||||
|
static rbg_range_t prbs_to_rbgs(const prb_range_t& prbs, uint32_t P);
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Struct to express a {min,...,max} range of PRBs
|
||||||
|
struct prb_range_t {
|
||||||
|
uint32_t prb_min = 0, prb_max = 0;
|
||||||
|
prb_range_t() = default;
|
||||||
|
prb_range_t(uint32_t s, uint32_t e) : prb_min(s), prb_max(e) {}
|
||||||
|
uint32_t nof_prbs() { return prb_max - prb_min; }
|
||||||
|
|
||||||
|
static prb_range_t rbgs_to_prbs(const rbg_range_t& rbgs, uint32_t P);
|
||||||
|
static prb_range_t riv_to_prbs(uint32_t riv, uint32_t nof_prbs, int nof_vrbs = -1);
|
||||||
|
};
|
||||||
|
|
||||||
/***********************
|
/***********************
|
||||||
* Helper Functions
|
* Helper Functions
|
||||||
**********************/
|
**********************/
|
||||||
|
|
|
@ -29,28 +29,6 @@
|
||||||
|
|
||||||
namespace srsenb {
|
namespace srsenb {
|
||||||
|
|
||||||
// Range of RBGs
|
|
||||||
class prb_range_t;
|
|
||||||
struct rbg_range_t {
|
|
||||||
uint32_t rbg_start = 0, rbg_end = 0;
|
|
||||||
rbg_range_t() = default;
|
|
||||||
rbg_range_t(uint32_t s, uint32_t e) : rbg_start(s), rbg_end(e) {}
|
|
||||||
rbg_range_t(const prb_range_t& rbgs, uint32_t P);
|
|
||||||
uint32_t length() const { return rbg_end - rbg_start; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Range of PRBs
|
|
||||||
class prb_range_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t prb_start = 0, prb_end = 0;
|
|
||||||
prb_range_t() = default;
|
|
||||||
prb_range_t(uint32_t s, uint32_t e) : prb_start(s), prb_end(e) {}
|
|
||||||
prb_range_t(const rbg_range_t& rbgs, uint32_t P);
|
|
||||||
uint32_t length() { return prb_end - prb_start; }
|
|
||||||
static prb_range_t riv_to_prbs(uint32_t riv, uint32_t nof_prbs, int nof_vrbs = -1);
|
|
||||||
};
|
|
||||||
|
|
||||||
class harq_proc
|
class harq_proc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -132,7 +132,7 @@ public:
|
||||||
|
|
||||||
uint32_t get_required_prb_ul(uint32_t cc_idx, uint32_t req_bytes);
|
uint32_t get_required_prb_ul(uint32_t cc_idx, uint32_t req_bytes);
|
||||||
|
|
||||||
std::pair<uint32_t, uint32_t> get_required_dl_rbgs(uint32_t ue_cc_idx, uint32_t nof_ctrl_symbols);
|
rbg_range_t get_required_dl_rbgs(uint32_t ue_cc_idx, uint32_t nof_ctrl_symbols);
|
||||||
std::pair<uint32_t, uint32_t> get_requested_dl_bytes(uint32_t ue_cc_idx);
|
std::pair<uint32_t, uint32_t> get_requested_dl_bytes(uint32_t ue_cc_idx);
|
||||||
uint32_t get_pending_dl_new_data();
|
uint32_t get_pending_dl_new_data();
|
||||||
uint32_t get_pending_ul_new_data(uint32_t tti);
|
uint32_t get_pending_ul_new_data(uint32_t tti);
|
||||||
|
|
|
@ -468,6 +468,27 @@ void generate_cce_location(srslte_regs_t* regs_,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rbg_range_t rbg_range_t::prbs_to_rbgs(const prb_range_t& prbs, uint32_t P)
|
||||||
|
{
|
||||||
|
return rbg_range_t{srslte::ceil_div(prbs.prb_min, P), srslte::ceil_div(prbs.prb_min, P)};
|
||||||
|
}
|
||||||
|
|
||||||
|
prb_range_t prb_range_t::rbgs_to_prbs(const rbg_range_t& rbgs, uint32_t P)
|
||||||
|
{
|
||||||
|
return prb_range_t{rbgs.rbg_min * P, rbgs.rbg_max * P};
|
||||||
|
}
|
||||||
|
|
||||||
|
prb_range_t prb_range_t::riv_to_prbs(uint32_t riv, uint32_t nof_prbs, int nof_vrbs)
|
||||||
|
{
|
||||||
|
prb_range_t p;
|
||||||
|
if (nof_vrbs < 0) {
|
||||||
|
nof_vrbs = nof_prbs;
|
||||||
|
}
|
||||||
|
srslte_ra_type2_from_riv(riv, &p.prb_max, &p.prb_min, nof_prbs, (uint32_t)nof_vrbs);
|
||||||
|
p.prb_max += p.prb_min;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sched_utils
|
} // namespace sched_utils
|
||||||
|
|
||||||
} // namespace srsenb
|
} // namespace srsenb
|
||||||
|
|
|
@ -319,8 +319,8 @@ alloc_outcome_t sf_grid_t::alloc_dl(uint32_t aggr_lvl, alloc_type_t alloc_type,
|
||||||
sf_grid_t::dl_ctrl_alloc_t sf_grid_t::alloc_dl_ctrl(uint32_t aggr_lvl, alloc_type_t alloc_type)
|
sf_grid_t::dl_ctrl_alloc_t sf_grid_t::alloc_dl_ctrl(uint32_t aggr_lvl, alloc_type_t alloc_type)
|
||||||
{
|
{
|
||||||
rbg_range_t range;
|
rbg_range_t range;
|
||||||
range.rbg_start = nof_rbgs - avail_rbg;
|
range.rbg_min = nof_rbgs - avail_rbg;
|
||||||
range.rbg_end = range.rbg_start + ((alloc_type == alloc_type_t::DL_RAR) ? rar_n_rbg : si_n_rbg);
|
range.rbg_max = range.rbg_min + ((alloc_type == alloc_type_t::DL_RAR) ? rar_n_rbg : si_n_rbg);
|
||||||
|
|
||||||
if (alloc_type != alloc_type_t::DL_RAR and alloc_type != alloc_type_t::DL_BC and
|
if (alloc_type != alloc_type_t::DL_RAR and alloc_type != alloc_type_t::DL_BC and
|
||||||
alloc_type != alloc_type_t::DL_PCCH) {
|
alloc_type != alloc_type_t::DL_PCCH) {
|
||||||
|
@ -328,13 +328,13 @@ sf_grid_t::dl_ctrl_alloc_t sf_grid_t::alloc_dl_ctrl(uint32_t aggr_lvl, alloc_typ
|
||||||
return {alloc_outcome_t::ERROR, range};
|
return {alloc_outcome_t::ERROR, range};
|
||||||
}
|
}
|
||||||
// Setup range starting from left
|
// Setup range starting from left
|
||||||
if (range.rbg_end > nof_rbgs) {
|
if (range.rbg_max > nof_rbgs) {
|
||||||
return {alloc_outcome_t::RB_COLLISION, range};
|
return {alloc_outcome_t::RB_COLLISION, range};
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate DCI and RBGs
|
// allocate DCI and RBGs
|
||||||
rbgmask_t new_mask(dl_mask.size());
|
rbgmask_t new_mask(dl_mask.size());
|
||||||
new_mask.fill(range.rbg_start, range.rbg_end);
|
new_mask.fill(range.rbg_min, range.rbg_max);
|
||||||
return {alloc_dl(aggr_lvl, alloc_type, new_mask), range};
|
return {alloc_dl(aggr_lvl, alloc_type, new_mask), range};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,17 +679,17 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
|
||||||
bc->dci.location = dci_result[bc_alloc.dci_idx]->dci_pos;
|
bc->dci.location = dci_result[bc_alloc.dci_idx]->dci_pos;
|
||||||
|
|
||||||
/* Generate DCI format1A */
|
/* Generate DCI format1A */
|
||||||
prb_range_t prb_range = prb_range_t(bc_alloc.rbg_range, cc_cfg->P);
|
prb_range_t prb_range = prb_range_t::rbgs_to_prbs(bc_alloc.rbg_range, cc_cfg->P);
|
||||||
int tbs = generate_format1a(
|
int tbs = generate_format1a(
|
||||||
prb_range.prb_start, prb_range.length(), bc_alloc.req_bytes, bc_alloc.rv, bc_alloc.rnti, &bc->dci);
|
prb_range.prb_min, prb_range.nof_prbs(), bc_alloc.req_bytes, bc_alloc.rv, bc_alloc.rnti, &bc->dci);
|
||||||
|
|
||||||
// Setup BC/Paging processes
|
// Setup BC/Paging processes
|
||||||
if (bc_alloc.alloc_type == alloc_type_t::DL_BC) {
|
if (bc_alloc.alloc_type == alloc_type_t::DL_BC) {
|
||||||
if (tbs <= (int)bc_alloc.req_bytes) {
|
if (tbs <= (int)bc_alloc.req_bytes) {
|
||||||
log_h->warning("SCHED: Error SIB%d, rbgs=(%d,%d), dci=(%d,%d), len=%d\n",
|
log_h->warning("SCHED: Error SIB%d, rbgs=(%d,%d), dci=(%d,%d), len=%d\n",
|
||||||
bc_alloc.sib_idx + 1,
|
bc_alloc.sib_idx + 1,
|
||||||
bc_alloc.rbg_range.rbg_start,
|
bc_alloc.rbg_range.rbg_min,
|
||||||
bc_alloc.rbg_range.rbg_end,
|
bc_alloc.rbg_range.rbg_max,
|
||||||
bc->dci.location.L,
|
bc->dci.location.L,
|
||||||
bc->dci.location.ncce,
|
bc->dci.location.ncce,
|
||||||
bc_alloc.req_bytes);
|
bc_alloc.req_bytes);
|
||||||
|
@ -703,8 +703,8 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
|
||||||
|
|
||||||
log_h->debug("SCHED: SIB%d, rbgs=(%d,%d), dci=(%d,%d), rv=%d, len=%d, period=%d, mcs=%d\n",
|
log_h->debug("SCHED: SIB%d, rbgs=(%d,%d), dci=(%d,%d), rv=%d, len=%d, period=%d, mcs=%d\n",
|
||||||
bc_alloc.sib_idx + 1,
|
bc_alloc.sib_idx + 1,
|
||||||
bc_alloc.rbg_range.rbg_start,
|
bc_alloc.rbg_range.rbg_min,
|
||||||
bc_alloc.rbg_range.rbg_end,
|
bc_alloc.rbg_range.rbg_max,
|
||||||
bc->dci.location.L,
|
bc->dci.location.L,
|
||||||
bc->dci.location.ncce,
|
bc->dci.location.ncce,
|
||||||
bc_alloc.rv,
|
bc_alloc.rv,
|
||||||
|
@ -715,8 +715,8 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
|
||||||
// Paging
|
// Paging
|
||||||
if (tbs <= 0) {
|
if (tbs <= 0) {
|
||||||
log_h->warning("SCHED: Error Paging, rbgs=(%d,%d), dci=(%d,%d)\n",
|
log_h->warning("SCHED: Error Paging, rbgs=(%d,%d), dci=(%d,%d)\n",
|
||||||
bc_alloc.rbg_range.rbg_start,
|
bc_alloc.rbg_range.rbg_min,
|
||||||
bc_alloc.rbg_range.rbg_end,
|
bc_alloc.rbg_range.rbg_max,
|
||||||
bc->dci.location.L,
|
bc->dci.location.L,
|
||||||
bc->dci.location.ncce);
|
bc->dci.location.ncce);
|
||||||
continue;
|
continue;
|
||||||
|
@ -727,8 +727,8 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
|
||||||
bc->tbs = (uint32_t)tbs;
|
bc->tbs = (uint32_t)tbs;
|
||||||
|
|
||||||
log_h->info("SCHED: PCH, rbgs=(%d,%d), dci=(%d,%d), tbs=%d, mcs=%d\n",
|
log_h->info("SCHED: PCH, rbgs=(%d,%d), dci=(%d,%d), tbs=%d, mcs=%d\n",
|
||||||
bc_alloc.rbg_range.rbg_start,
|
bc_alloc.rbg_range.rbg_min,
|
||||||
bc_alloc.rbg_range.rbg_end,
|
bc_alloc.rbg_range.rbg_max,
|
||||||
bc->dci.location.L,
|
bc->dci.location.L,
|
||||||
bc->dci.location.ncce,
|
bc->dci.location.ncce,
|
||||||
tbs,
|
tbs,
|
||||||
|
@ -749,9 +749,9 @@ void sf_sched::set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_resu
|
||||||
rar->dci.location = dci_result[rar_alloc.alloc_data.dci_idx]->dci_pos;
|
rar->dci.location = dci_result[rar_alloc.alloc_data.dci_idx]->dci_pos;
|
||||||
|
|
||||||
/* Generate DCI format1A */
|
/* Generate DCI format1A */
|
||||||
prb_range_t prb_range = prb_range_t(rar_alloc.alloc_data.rbg_range, cc_cfg->P);
|
prb_range_t prb_range = prb_range_t::rbgs_to_prbs(rar_alloc.alloc_data.rbg_range, cc_cfg->P);
|
||||||
int tbs = generate_format1a(prb_range.prb_start,
|
int tbs = generate_format1a(prb_range.prb_min,
|
||||||
prb_range.length(),
|
prb_range.nof_prbs(),
|
||||||
rar_alloc.alloc_data.req_bytes,
|
rar_alloc.alloc_data.req_bytes,
|
||||||
0,
|
0,
|
||||||
rar_alloc.alloc_data.rnti,
|
rar_alloc.alloc_data.rnti,
|
||||||
|
@ -759,8 +759,8 @@ void sf_sched::set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_resu
|
||||||
if (tbs <= 0) {
|
if (tbs <= 0) {
|
||||||
log_h->warning("SCHED: Error RAR, ra_rnti_idx=%d, rbgs=(%d,%d), dci=(%d,%d)\n",
|
log_h->warning("SCHED: Error RAR, ra_rnti_idx=%d, rbgs=(%d,%d), dci=(%d,%d)\n",
|
||||||
rar_alloc.alloc_data.rnti,
|
rar_alloc.alloc_data.rnti,
|
||||||
rar_alloc.alloc_data.rbg_range.rbg_start,
|
rar_alloc.alloc_data.rbg_range.rbg_min,
|
||||||
rar_alloc.alloc_data.rbg_range.rbg_end,
|
rar_alloc.alloc_data.rbg_range.rbg_max,
|
||||||
rar->dci.location.L,
|
rar->dci.location.L,
|
||||||
rar->dci.location.ncce);
|
rar->dci.location.ncce);
|
||||||
continue;
|
continue;
|
||||||
|
@ -779,8 +779,8 @@ void sf_sched::set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_resu
|
||||||
"rar_grant_mcs=%d\n",
|
"rar_grant_mcs=%d\n",
|
||||||
expected_rnti,
|
expected_rnti,
|
||||||
rar_alloc.alloc_data.rnti,
|
rar_alloc.alloc_data.rnti,
|
||||||
rar_alloc.alloc_data.rbg_range.rbg_start,
|
rar_alloc.alloc_data.rbg_range.rbg_min,
|
||||||
rar_alloc.alloc_data.rbg_range.rbg_end,
|
rar_alloc.alloc_data.rbg_range.rbg_max,
|
||||||
rar->dci.location.L,
|
rar->dci.location.L,
|
||||||
rar->dci.location.ncce,
|
rar->dci.location.ncce,
|
||||||
msg3_grant.grant.rba,
|
msg3_grant.grant.rba,
|
||||||
|
|
|
@ -32,24 +32,6 @@
|
||||||
|
|
||||||
namespace srsenb {
|
namespace srsenb {
|
||||||
|
|
||||||
rbg_range_t::rbg_range_t(const prb_range_t& rbgs, uint32_t P) :
|
|
||||||
rbg_range_t(srslte::ceil_div(rbgs.prb_start, P), srslte::ceil_div(rbgs.prb_end, P))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
prb_range_t::prb_range_t(const rbg_range_t& rbgs, uint32_t P) : prb_range_t(rbgs.rbg_start * P, rbgs.rbg_end * P) {}
|
|
||||||
|
|
||||||
prb_range_t prb_range_t::riv_to_prbs(uint32_t riv, uint32_t nof_prbs, int nof_vrbs)
|
|
||||||
{
|
|
||||||
prb_range_t p;
|
|
||||||
if (nof_vrbs < 0) {
|
|
||||||
nof_vrbs = nof_prbs;
|
|
||||||
}
|
|
||||||
srslte_ra_type2_from_riv(riv, &p.prb_end, &p.prb_start, nof_prbs, (uint32_t)nof_vrbs);
|
|
||||||
p.prb_end += p.prb_start;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
*
|
*
|
||||||
* These classes manage the HARQ Processes.
|
* These classes manage the HARQ Processes.
|
||||||
|
|
|
@ -133,10 +133,10 @@ dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user)
|
||||||
h = user->get_empty_dl_harq(tti_dl, cell_idx);
|
h = user->get_empty_dl_harq(tti_dl, cell_idx);
|
||||||
if (h != nullptr) {
|
if (h != nullptr) {
|
||||||
// Allocate resources based on pending data
|
// Allocate resources based on pending data
|
||||||
std::pair<uint32_t, uint32_t> req_rbgs = user->get_required_dl_rbgs(cell_idx, tti_alloc->get_nof_ctrl_symbols());
|
rbg_range_t req_rbgs = user->get_required_dl_rbgs(cell_idx, tti_alloc->get_nof_ctrl_symbols());
|
||||||
if (req_rbgs.first > 0) {
|
if (req_rbgs.rbg_min > 0) {
|
||||||
rbgmask_t newtx_mask(tti_alloc->get_dl_mask().size());
|
rbgmask_t newtx_mask(tti_alloc->get_dl_mask().size());
|
||||||
if (find_allocation(req_rbgs.first, req_rbgs.second, &newtx_mask)) {
|
if (find_allocation(req_rbgs.rbg_min, req_rbgs.rbg_max, &newtx_mask)) {
|
||||||
// some empty spaces were found
|
// some empty spaces were found
|
||||||
code = tti_alloc->alloc_dl_user(user, newtx_mask, h->get_id());
|
code = tti_alloc->alloc_dl_user(user, newtx_mask, h->get_id());
|
||||||
if (code == alloc_outcome_t::SUCCESS) {
|
if (code == alloc_outcome_t::SUCCESS) {
|
||||||
|
|
|
@ -815,7 +815,7 @@ uint32_t sched_ue::get_pending_dl_new_data_total()
|
||||||
return req_bytes;
|
return req_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint32_t, uint32_t> sched_ue::get_required_dl_rbgs(uint32_t ue_cc_idx, uint32_t nof_ctrl_symbols)
|
rbg_range_t sched_ue::get_required_dl_rbgs(uint32_t ue_cc_idx, uint32_t nof_ctrl_symbols)
|
||||||
{
|
{
|
||||||
std::pair<uint32_t, uint32_t> req_bytes = get_requested_dl_bytes(ue_cc_idx);
|
std::pair<uint32_t, uint32_t> req_bytes = get_requested_dl_bytes(ue_cc_idx);
|
||||||
if (req_bytes.first == 0 and req_bytes.second == 0) {
|
if (req_bytes.first == 0 and req_bytes.second == 0) {
|
||||||
|
|
Loading…
Reference in New Issue