|
|
@ -17,6 +17,64 @@
|
|
|
|
namespace srsenb {
|
|
|
|
namespace srsenb {
|
|
|
|
namespace sched_nr_impl {
|
|
|
|
namespace sched_nr_impl {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using candidate_ss_list_t =
|
|
|
|
|
|
|
|
srsran::bounded_vector<const srsran_search_space_t*, SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
candidate_ss_list_t find_ss(const srsran_pdcch_cfg_nr_t& pdcch,
|
|
|
|
|
|
|
|
uint32_t aggr_idx,
|
|
|
|
|
|
|
|
srsran_rnti_type_t rnti_type,
|
|
|
|
|
|
|
|
srsran::const_span<srsran_dci_format_nr_t> prio_dcis)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
candidate_ss_list_t ret;
|
|
|
|
|
|
|
|
auto active_ss_lst = view_active_search_spaces(pdcch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto has_dci_fmt_helper = [prio_dcis, aggr_idx](const srsran_search_space_t& ss) {
|
|
|
|
|
|
|
|
if (ss.nof_candidates[aggr_idx] > 0 and ss.nof_formats > 0) {
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < prio_dcis.size(); ++i) {
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < prio_dcis.size(); ++j) {
|
|
|
|
|
|
|
|
if (ss.formats[j] == prio_dcis[i]) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
auto is_common_ss_allowed = [rnti_type](srsran_search_space_type_t ss_type) {
|
|
|
|
|
|
|
|
switch (rnti_type) {
|
|
|
|
|
|
|
|
case srsran_rnti_type_c:
|
|
|
|
|
|
|
|
return ss_type == srsran_search_space_type_common_1 or ss_type == srsran_search_space_type_common_3;
|
|
|
|
|
|
|
|
case srsran_rnti_type_tc:
|
|
|
|
|
|
|
|
case srsran_rnti_type_ra:
|
|
|
|
|
|
|
|
// TODO: Fix UE config to not use common3
|
|
|
|
|
|
|
|
return ss_type == srsran_search_space_type_common_1 or ss_type == srsran_search_space_type_common_3;
|
|
|
|
|
|
|
|
case srsran_rnti_type_si:
|
|
|
|
|
|
|
|
return ss_type == srsran_search_space_type_common_0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
// TODO: Remaining cases
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rnti_type == srsran_rnti_type_c) {
|
|
|
|
|
|
|
|
// First search UE-specific
|
|
|
|
|
|
|
|
for (const srsran_search_space_t& ss : active_ss_lst) {
|
|
|
|
|
|
|
|
if (ss.type == srsran_search_space_type_ue and has_dci_fmt_helper(ss)) {
|
|
|
|
|
|
|
|
ret.push_back(&ss);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const srsran_search_space_t& ss : active_ss_lst) {
|
|
|
|
|
|
|
|
if (is_common_ss_allowed(ss.type) and has_dci_fmt_helper(ss)) {
|
|
|
|
|
|
|
|
ret.push_back(&ss);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
bwp_slot_grid::bwp_slot_grid(const bwp_params_t& bwp_cfg_, uint32_t slot_idx_) :
|
|
|
|
bwp_slot_grid::bwp_slot_grid(const bwp_params_t& bwp_cfg_, uint32_t slot_idx_) :
|
|
|
|
dl_prbs(bwp_cfg_.cfg.rb_width, bwp_cfg_.cfg.start_rb, bwp_cfg_.cfg.pdsch.rbg_size_cfg_1),
|
|
|
|
dl_prbs(bwp_cfg_.cfg.rb_width, bwp_cfg_.cfg.start_rb, bwp_cfg_.cfg.pdsch.rbg_size_cfg_1),
|
|
|
|
ul_prbs(bwp_cfg_.cfg.rb_width, bwp_cfg_.cfg.start_rb, bwp_cfg_.cfg.pdsch.rbg_size_cfg_1),
|
|
|
|
ul_prbs(bwp_cfg_.cfg.rb_width, bwp_cfg_.cfg.start_rb, bwp_cfg_.cfg.pdsch.rbg_size_cfg_1),
|
|
|
@ -239,6 +297,9 @@ alloc_result bwp_slot_allocator::alloc_rar_and_msg3(uint16_t
|
|
|
|
// func computes the grant allocation for this UE
|
|
|
|
// func computes the grant allocation for this UE
|
|
|
|
alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_grant)
|
|
|
|
alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_grant)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
static const uint32_t aggr_idx = 2;
|
|
|
|
|
|
|
|
static const std::array<srsran_dci_format_nr_t, 2> dci_fmt_list{srsran_dci_format_nr_1_1, srsran_dci_format_nr_1_0};
|
|
|
|
|
|
|
|
|
|
|
|
bwp_slot_grid& bwp_pdcch_slot = bwp_grid[ue.pdcch_slot];
|
|
|
|
bwp_slot_grid& bwp_pdcch_slot = bwp_grid[ue.pdcch_slot];
|
|
|
|
bwp_slot_grid& bwp_pdsch_slot = bwp_grid[ue.pdsch_slot];
|
|
|
|
bwp_slot_grid& bwp_pdsch_slot = bwp_grid[ue.pdsch_slot];
|
|
|
|
bwp_slot_grid& bwp_uci_slot = bwp_grid[ue.uci_slot]; // UCI : UL control info
|
|
|
|
bwp_slot_grid& bwp_uci_slot = bwp_grid[ue.uci_slot]; // UCI : UL control info
|
|
|
@ -263,16 +324,17 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
|
|
// Find space and allocate PDCCH
|
|
|
|
// Find space and allocate PDCCH
|
|
|
|
const uint32_t aggr_idx = 2;
|
|
|
|
srsran_rnti_type_t rnti_type =
|
|
|
|
|
|
|
|
ue->ue_cfg().ue_bearers[1].direction == mac_lc_ch_cfg_t::IDLE ? srsran_rnti_type_tc : srsran_rnti_type_c;
|
|
|
|
// Choose the ss_id the highest number of candidates
|
|
|
|
// Choose the ss_id the highest number of candidates
|
|
|
|
const srsran_search_space_t* ss = ue->find_ss(aggr_idx, true);
|
|
|
|
candidate_ss_list_t ss = find_ss(ue->phy().pdcch, aggr_idx, rnti_type, dci_fmt_list);
|
|
|
|
if (ss == nullptr) {
|
|
|
|
if (ss.empty()) {
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
logger.warning("SCHED: No PDCCH candidates for any of the rnti=0x%x search spaces", ue->rnti);
|
|
|
|
logger.warning("SCHED: No PDCCH candidates for any of the rnti=0x%x search spaces", ue->rnti);
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint32_t coreset_id = ss->coreset_id;
|
|
|
|
uint32_t coreset_id = ss[0]->coreset_id;
|
|
|
|
if (not bwp_pdcch_slot.coresets[coreset_id]->alloc_dci(pdcch_grant_type_t::dl_data, aggr_idx, ss->id, &ue.cfg())) {
|
|
|
|
if (not bwp_pdcch_slot.coresets[coreset_id]->alloc_dci(pdcch_grant_type_t::dl_data, aggr_idx, ss[0]->id, &ue.cfg())) {
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,7 +356,7 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
// Generate PDCCH
|
|
|
|
// Generate PDCCH
|
|
|
|
pdcch_dl_t& pdcch = bwp_pdcch_slot.dl.phy.pdcch_dl.back();
|
|
|
|
pdcch_dl_t& pdcch = bwp_pdcch_slot.dl.phy.pdcch_dl.back();
|
|
|
|
fill_dl_dci_ue_fields(ue, *bwp_grid.cfg, ss->id, pdcch.dci.ctx.location, pdcch.dci);
|
|
|
|
fill_dl_dci_ue_fields(ue, *bwp_grid.cfg, ss[0]->id, pdcch.dci.ctx.location, pdcch.dci);
|
|
|
|
pdcch.dci.pucch_resource = 0;
|
|
|
|
pdcch.dci.pucch_resource = 0;
|
|
|
|
pdcch.dci.dai = std::count_if(bwp_uci_slot.pending_acks.begin(),
|
|
|
|
pdcch.dci.dai = std::count_if(bwp_uci_slot.pending_acks.begin(),
|
|
|
|
bwp_uci_slot.pending_acks.end(),
|
|
|
|
bwp_uci_slot.pending_acks.end(),
|
|
|
@ -346,6 +408,9 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr
|
|
|
|
|
|
|
|
|
|
|
|
alloc_result bwp_slot_allocator::alloc_pusch(slot_ue& ue, const prb_grant& ul_prbs)
|
|
|
|
alloc_result bwp_slot_allocator::alloc_pusch(slot_ue& ue, const prb_grant& ul_prbs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
static const uint32_t aggr_idx = 2;
|
|
|
|
|
|
|
|
static const std::array<srsran_dci_format_nr_t, 2> dci_fmt_list{srsran_dci_format_nr_0_1, srsran_dci_format_nr_0_0};
|
|
|
|
|
|
|
|
|
|
|
|
auto& bwp_pdcch_slot = bwp_grid[ue.pdcch_slot];
|
|
|
|
auto& bwp_pdcch_slot = bwp_grid[ue.pdcch_slot];
|
|
|
|
auto& bwp_pusch_slot = bwp_grid[ue.pusch_slot];
|
|
|
|
auto& bwp_pusch_slot = bwp_grid[ue.pusch_slot];
|
|
|
|
alloc_result ret = verify_pusch_space(bwp_pusch_slot, &bwp_pdcch_slot);
|
|
|
|
alloc_result ret = verify_pusch_space(bwp_pusch_slot, &bwp_pdcch_slot);
|
|
|
@ -360,16 +425,18 @@ alloc_result bwp_slot_allocator::alloc_pusch(slot_ue& ue, const prb_grant& ul_pr
|
|
|
|
if (bwp_pusch_slot.ul_prbs.collides(ul_prbs)) {
|
|
|
|
if (bwp_pusch_slot.ul_prbs.collides(ul_prbs)) {
|
|
|
|
return alloc_result::sch_collision;
|
|
|
|
return alloc_result::sch_collision;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const uint32_t aggr_idx = 2;
|
|
|
|
|
|
|
|
const srsran_search_space_t* ss = ue->find_ss(aggr_idx, false);
|
|
|
|
srsran_rnti_type_t rnti_type =
|
|
|
|
if (ss == nullptr) {
|
|
|
|
ue->ue_cfg().ue_bearers[1].direction == mac_lc_ch_cfg_t::IDLE ? srsran_rnti_type_tc : srsran_rnti_type_c;
|
|
|
|
|
|
|
|
candidate_ss_list_t ss = find_ss(ue->phy().pdcch, aggr_idx, rnti_type, dci_fmt_list);
|
|
|
|
|
|
|
|
if (ss.empty()) {
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
logger.warning("SCHED: No PDCCH candidates for any of the rnti=0x%x search spaces", ue->rnti);
|
|
|
|
logger.warning("SCHED: No PDCCH candidates for any of the rnti=0x%x search spaces", ue->rnti);
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint32_t coreset_id = ss->coreset_id;
|
|
|
|
uint32_t coreset_id = ss[0]->coreset_id;
|
|
|
|
if (not bwp_pdcch_slot.coresets[coreset_id].value().alloc_dci(
|
|
|
|
if (not bwp_pdcch_slot.coresets[coreset_id].value().alloc_dci(
|
|
|
|
pdcch_grant_type_t::ul_data, aggr_idx, ss->id, &ue.cfg())) {
|
|
|
|
pdcch_grant_type_t::ul_data, aggr_idx, ss[0]->id, &ue.cfg())) {
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
// Could not find space in PDCCH
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
return alloc_result::no_cch_space;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -387,7 +454,7 @@ alloc_result bwp_slot_allocator::alloc_pusch(slot_ue& ue, const prb_grant& ul_pr
|
|
|
|
|
|
|
|
|
|
|
|
// Generate PDCCH
|
|
|
|
// Generate PDCCH
|
|
|
|
pdcch_ul_t& pdcch = pdcchs.back();
|
|
|
|
pdcch_ul_t& pdcch = pdcchs.back();
|
|
|
|
fill_ul_dci_ue_fields(ue, *bwp_grid.cfg, ss->id, pdcch.dci.ctx.location, pdcch.dci);
|
|
|
|
fill_ul_dci_ue_fields(ue, *bwp_grid.cfg, ss[0]->id, pdcch.dci.ctx.location, pdcch.dci);
|
|
|
|
pdcch.dci_cfg = ue->phy().get_dci_cfg();
|
|
|
|
pdcch.dci_cfg = ue->phy().get_dci_cfg();
|
|
|
|
// Generate PUSCH
|
|
|
|
// Generate PUSCH
|
|
|
|
bwp_pusch_slot.ul_prbs |= ul_prbs;
|
|
|
|
bwp_pusch_slot.ul_prbs |= ul_prbs;
|
|
|
|