added map between cc_idx and enb cell specifier

master
Francisco Paisana 5 years ago
parent eeb47f8fa4
commit 1da86df597

@ -32,7 +32,7 @@ class ra_sched;
class sched::carrier_sched
{
public:
explicit carrier_sched(rrc_interface_mac* rrc_, std::map<uint16_t, sched_ue>* ue_db_, uint32_t cc_idx_);
explicit carrier_sched(rrc_interface_mac* rrc_, std::map<uint16_t, sched_ue>* ue_db_, uint32_t enb_cc_idx_);
void reset();
void carrier_cfg(const sched_params_t& sched_params_);
void set_metric(sched::metric_dl* dl_metric_, sched::metric_ul* ul_metric_);
@ -61,7 +61,7 @@ private:
std::map<uint16_t, sched_ue>* ue_db = nullptr;
metric_dl* dl_metric = nullptr;
metric_ul* ul_metric = nullptr;
const uint32_t cc_idx;
const uint32_t enb_cc_idx;
// derived from args
prbmask_t prach_mask;

@ -41,7 +41,7 @@ struct alloc_outcome_t {
alloc_outcome_t(result_enum e) : result(e) {}
operator result_enum() { return result; }
operator bool() { return result == SUCCESS; }
const char* to_string() const;
const char* to_string() const;
};
//! Params relative to a single TTI
@ -218,7 +218,7 @@ public:
sched_interface::dl_sched_res_t dl_sched_result;
sched_interface::ul_sched_res_t ul_sched_result;
void init(const sched_params_t& sched_params_, uint32_t cc_idx_);
void init(const sched_params_t& sched_params_, uint32_t enb_cc_idx_);
void new_tti(uint32_t tti_rx_, uint32_t start_cfi);
alloc_outcome_t alloc_bc(uint32_t aggr_lvl, uint32_t sib_idx, uint32_t sib_ntx);
alloc_outcome_t alloc_paging(uint32_t aggr_lvl, uint32_t paging_payload);
@ -245,7 +245,8 @@ public:
uint32_t get_tti_rx() const { return tti_params.tti_rx; }
uint32_t get_sfn() const { return tti_params.sfn; }
uint32_t get_sf_idx() const { return tti_params.sf_idx; }
uint32_t get_cc_idx() const { return cc_idx; }
uint32_t get_cc_idx() const { return enb_cc_idx; }
const tti_params_t& get_tti_params() const { return tti_params; }
private:
bool is_dl_alloc(sched_ue* user) const final;
@ -269,7 +270,7 @@ private:
// consts
const sched_params_t* sched_params = nullptr;
srslte::log* log_h = nullptr;
uint32_t cc_idx = 0;
uint32_t enb_cc_idx = 0;
// internal state
tti_params_t tti_params{10241};

@ -34,6 +34,7 @@
namespace srsenb {
class sched_params_t;
struct tti_params_t;
struct sched_ue_carrier {
const static int SCHED_MAX_HARQ_PROC = SRSLTE_FDD_NOF_HARQ;
@ -136,9 +137,10 @@ public:
void set_max_mcs(int mcs_ul, int mcs_dl, int max_aggr_level = -1);
void set_fixed_mcs(int mcs_ul, int mcs_dl);
dl_harq_proc* find_dl_harq(uint32_t tti_rx, uint32_t cc_idx);
dl_harq_proc* get_dl_harq(uint32_t idx, uint32_t cc_idx);
uint16_t get_rnti() const { return rnti; }
dl_harq_proc* find_dl_harq(uint32_t tti_rx, uint32_t cc_idx);
dl_harq_proc* get_dl_harq(uint32_t idx, uint32_t cc_idx);
uint16_t get_rnti() const { return rnti; }
std::pair<bool, uint32_t> get_cell_index(uint32_t enb_cc_idx) const;
/*******************************************************
* Functions used by scheduler metric objects
@ -159,6 +161,12 @@ public:
dl_harq_proc* get_empty_dl_harq(uint32_t cc_idx);
ul_harq_proc* get_ul_harq(uint32_t tti, uint32_t cc_idx);
/*******************************************************
* Functions used by the scheduler carrier object
*******************************************************/
void finish_tti(const tti_params_t& tti_params, uint32_t enb_cc_idx);
/*******************************************************
* Functions used by the scheduler object
*******************************************************/
@ -278,7 +286,8 @@ private:
bool phy_config_dedicated_enabled = false;
asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info;
std::vector<sched_ue_carrier> carriers;
std::vector<sched_ue_carrier> carriers; ///< map of UE CellIndex to carrier configuration
std::map<uint32_t, uint32_t> enb_ue_cellindex_map;
};
} // namespace srsenb

@ -468,7 +468,7 @@ int mac::sr_detected(uint32_t tti, uint16_t rnti)
return ret;
}
int mac::rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv)
int mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx, uint32_t time_adv)
{
log_h->step(tti);
@ -515,11 +515,10 @@ int mac::rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_
}
// Trigger scheduler RACH
scheduler.dl_rach_info(primary_cc_idx, rar_info);
scheduler.dl_rach_info(enb_cc_idx, rar_info);
log_h->info("RACH: tti=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", tti, preamble_idx, time_adv, rnti);
log_h->console("RACH: tti=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n",
tti, preamble_idx, time_adv, rnti);
log_h->console("RACH: tti=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", tti, preamble_idx, time_adv, rnti);
// Increase RNTI counter
last_rnti++;
if (last_rnti >= 60000) {

@ -331,9 +331,9 @@ int sched::dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cq
return ue_db_access(rnti, [tti, cc_idx, cqi_value](sched_ue& ue) { ue.set_dl_cqi(tti, cc_idx, cqi_value); });
}
int sched::dl_rach_info(uint32_t cc_idx, dl_sched_rar_info_t rar_info)
int sched::dl_rach_info(uint32_t enb_cc_idx, dl_sched_rar_info_t rar_info)
{
return carrier_schedulers[cc_idx]->dl_rach_info(rar_info);
return carrier_schedulers[enb_cc_idx]->dl_rach_info(rar_info);
}
int sched::ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code)

@ -276,10 +276,12 @@ const ra_sched::pending_msg3_t& ra_sched::find_pending_msg3(uint32_t tti) const
* Carrier scheduling
*******************************************************/
sched::carrier_sched::carrier_sched(rrc_interface_mac* rrc_, std::map<uint16_t, sched_ue>* ue_db_, uint32_t cc_idx_) :
sched::carrier_sched::carrier_sched(rrc_interface_mac* rrc_,
std::map<uint16_t, sched_ue>* ue_db_,
uint32_t enb_cc_idx_) :
rrc(rrc_),
ue_db(ue_db_),
cc_idx(cc_idx_)
enb_cc_idx(enb_cc_idx_)
{
tti_dl_mask.resize(1, 0);
}
@ -318,7 +320,7 @@ void sched::carrier_sched::carrier_cfg(const sched_params_t& sched_params_)
// Initiate the tti_scheduler for each TTI
for (tti_sched_result_t& tti_sched : tti_scheds) {
tti_sched.init(*sched_params, cc_idx);
tti_sched.init(*sched_params, enb_cc_idx);
}
}
@ -372,9 +374,9 @@ tti_sched_result_t* sched::carrier_sched::generate_tti_result(uint32_t tti_rx)
/* Select the winner DCI allocation combination */
tti_sched->generate_dcis();
/* reset PIDs with pending data or blocked */
/* clean-up blocked pids */
for (auto& user : *ue_db) {
user.second.reset_pending_pids(tti_rx, cc_idx);
user.second.finish_tti(tti_sched->get_tti_params(), enb_cc_idx);
}
}
@ -388,10 +390,16 @@ void sched::carrier_sched::generate_phich(tti_sched_result_t* tti_sched)
for (auto& ue_pair : *ue_db) {
sched_ue& user = ue_pair.second;
uint16_t rnti = ue_pair.first;
auto p = user.get_cell_index(enb_cc_idx);
if (not p.first) {
// user does not support this carrier
continue;
}
uint32_t cell_index = p.second;
// user.has_pucch = false; // FIXME: What is this for?
ul_harq_proc* h = user.get_ul_harq(tti_sched->get_tti_rx(), cc_idx);
ul_harq_proc* h = user.get_ul_harq(tti_sched->get_tti_rx(), cell_index);
/* Indicate PHICH acknowledgment if needed */
if (h->has_pending_ack()) {
@ -426,7 +434,7 @@ void sched::carrier_sched::alloc_dl_users(tti_sched_result_t* tti_result)
}
// call DL scheduler metric to fill RB grid
dl_metric->sched_users(*ue_db, tti_result, cc_idx);
dl_metric->sched_users(*ue_db, tti_result, enb_cc_idx);
}
int sched::carrier_sched::alloc_ul_users(tti_sched_result_t* tti_sched)
@ -452,12 +460,7 @@ int sched::carrier_sched::alloc_ul_users(tti_sched_result_t* tti_sched)
ul_mask |= pucch_mask;
/* Call scheduler for UL data */
ul_metric->sched_users(*ue_db, tti_sched, cc_idx);
/* Update pending data counters after this TTI */
for (auto& user : *ue_db) {
user.second.get_ul_harq(tti_tx_ul, cc_idx)->reset_pending_data();
}
ul_metric->sched_users(*ue_db, tti_sched, enb_cc_idx);
return SRSLTE_SUCCESS;
}

@ -382,10 +382,10 @@ alloc_outcome_t tti_grid_t::alloc_ul_data(sched_ue* user, ul_harq_proc::ul_alloc
* TTI resource Scheduling Methods
*******************************************************/
void tti_sched_result_t::init(const sched_params_t& sched_params_, uint32_t cc_idx_)
void tti_sched_result_t::init(const sched_params_t& sched_params_, uint32_t enb_cc_idx_)
{
sched_params = &sched_params_;
cc_idx = cc_idx_;
enb_cc_idx = enb_cc_idx_;
log_h = sched_params->log_h;
tti_alloc.init(*sched_params, 0);
}
@ -576,8 +576,8 @@ alloc_outcome_t tti_sched_result_t::alloc_ul_user(sched_ue* user, ul_harq_proc::
{
// check whether adaptive/non-adaptive retx/newtx
tti_sched_result_t::ul_alloc_t::type_t alloc_type;
ul_harq_proc* h = user->get_ul_harq(get_tti_tx_ul(), cc_idx);
bool has_retx = h->has_pending_retx();
ul_harq_proc* h = user->get_ul_harq(get_tti_tx_ul(), user->get_cell_index(enb_cc_idx).second);
bool has_retx = h->has_pending_retx();
if (has_retx) {
ul_harq_proc::ul_alloc_t prev_alloc = h->get_alloc();
if (prev_alloc.L == alloc.L and prev_alloc.RB_start == prev_alloc.L) {
@ -723,7 +723,8 @@ void tti_sched_result_t::set_dl_data_sched_result(const pdcch_grid_t::alloc_resu
// Generate DCI Format1/2/2A
sched_ue* user = data_alloc.user_ptr;
dl_harq_proc* h = user->get_dl_harq(data_alloc.pid, cc_idx);
uint32_t cell_index = user->get_cell_index(enb_cc_idx).second;
dl_harq_proc* h = user->get_dl_harq(data_alloc.pid, cell_index);
uint32_t data_before = user->get_pending_dl_new_data();
srslte_dci_format_t dci_format = user->get_dci_format();
bool is_newtx = h->is_empty();
@ -731,13 +732,13 @@ void tti_sched_result_t::set_dl_data_sched_result(const pdcch_grid_t::alloc_resu
int tbs = 0;
switch (dci_format) {
case SRSLTE_DCI_FORMAT1:
tbs = user->generate_format1(h, data, get_tti_tx_dl(), cc_idx, get_cfi(), data_alloc.user_mask);
tbs = user->generate_format1(h, data, get_tti_tx_dl(), cell_index, get_cfi(), data_alloc.user_mask);
break;
case SRSLTE_DCI_FORMAT2:
tbs = user->generate_format2(h, data, get_tti_tx_dl(), cc_idx, get_cfi(), data_alloc.user_mask);
tbs = user->generate_format2(h, data, get_tti_tx_dl(), cell_index, get_cfi(), data_alloc.user_mask);
break;
case SRSLTE_DCI_FORMAT2A:
tbs = user->generate_format2a(h, data, get_tti_tx_dl(), cc_idx, get_cfi(), data_alloc.user_mask);
tbs = user->generate_format2a(h, data, get_tti_tx_dl(), cell_index, get_cfi(), data_alloc.user_mask);
break;
default:
Error("DCI format (%d) not implemented\n", dci_format);
@ -777,7 +778,8 @@ void tti_sched_result_t::set_ul_sched_result(const pdcch_grid_t::alloc_result_t&
for (const auto& ul_alloc : ul_data_allocs) {
sched_interface::ul_sched_data_t* pusch = &ul_sched_result.pusch[ul_sched_result.nof_dci_elems];
sched_ue* user = ul_alloc.user_ptr;
sched_ue* user = ul_alloc.user_ptr;
uint32_t cell_index = user->get_cell_index(enb_cc_idx).second;
srslte_dci_location_t cce_range = {0, 0};
if (ul_alloc.needs_pdcch()) {
@ -790,9 +792,9 @@ void tti_sched_result_t::set_ul_sched_result(const pdcch_grid_t::alloc_result_t&
/* Generate DCI Format1A */
uint32_t pending_data_before = user->get_pending_ul_new_data(get_tti_tx_ul());
int tbs = user->generate_format0(
pusch, get_tti_tx_ul(), cc_idx, ul_alloc.alloc, ul_alloc.needs_pdcch(), cce_range, fixed_mcs);
pusch, get_tti_tx_ul(), cell_index, ul_alloc.alloc, ul_alloc.needs_pdcch(), cce_range, fixed_mcs);
ul_harq_proc* h = user->get_ul_harq(get_tti_tx_ul(), cc_idx);
ul_harq_proc* h = user->get_ul_harq(get_tti_tx_ul(), cell_index);
if (tbs <= 0) {
log_h->warning("SCHED: Error %s %s rnti=0x%x, pid=%d, dci=(%d,%d), prb=(%d,%d), tbs=%d, bsr=%d\n",
ul_alloc.type == ul_alloc_t::MSG3 ? "Msg3" : "UL",
@ -828,7 +830,7 @@ void tti_sched_result_t::set_ul_sched_result(const pdcch_grid_t::alloc_result_t&
tbs,
user->get_pending_ul_new_data(get_tti_tx_ul()),
pending_data_before,
user->get_pending_ul_old_data(cc_idx));
user->get_pending_ul_old_data(cell_index));
ul_sched_result.nof_dci_elems++;
}

@ -41,7 +41,7 @@ void dl_metric_rr::set_params(const sched_params_t& sched_params_)
log_h = sched_params_.log_h;
}
void dl_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_tti_sched_t* tti_sched, uint32_t cc_idx)
void dl_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_tti_sched_t* tti_sched, uint32_t enb_cc_idx)
{
tti_alloc = tti_sched;
@ -58,7 +58,7 @@ void dl_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_tti_sched
iter = ue_db.begin(); // wrap around
}
sched_ue* user = &iter->second;
allocate_user(user, cc_idx);
allocate_user(user, enb_cc_idx);
}
}
@ -77,20 +77,26 @@ bool dl_metric_rr::find_allocation(uint32_t nof_rbg, rbgmask_t* rbgmask)
return nof_rbg == 0;
}
dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user, uint32_t cc_idx)
dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user, uint32_t enb_cc_idx)
{
if (tti_alloc->is_dl_alloc(user)) {
return nullptr;
}
auto p = user->get_cell_index(enb_cc_idx);
if (not p.first) {
return nullptr;
}
uint32_t cell_idx = p.second;
// FIXME: First do reTxs for all users. Only then do the rest.
alloc_outcome_t code;
uint32_t tti_dl = tti_alloc->get_tti_tx_dl();
dl_harq_proc* h = user->get_pending_dl_harq(tti_dl, cc_idx);
dl_harq_proc* h = user->get_pending_dl_harq(tti_dl, cell_idx);
uint32_t req_bytes = user->get_pending_dl_new_data_total();
// Schedule retx if we have space
#if ASYNC_DL_SCHED
if (h) {
if (h != nullptr) {
#else
if (h && !h->is_empty()) {
#endif
@ -111,7 +117,8 @@ dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user, uint32_t cc_idx)
code = tti_alloc->alloc_dl_user(user, retx_mask, h->get_id());
if (code == alloc_outcome_t::SUCCESS) {
return h;
} else if (code == alloc_outcome_t::DCI_COLLISION) {
}
if (code == alloc_outcome_t::DCI_COLLISION) {
return nullptr;
}
}
@ -119,15 +126,15 @@ dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user, uint32_t cc_idx)
// If could not schedule the reTx, or there wasn't any pending retx, find an empty PID
#if ASYNC_DL_SCHED
h = user->get_empty_dl_harq(cc_idx);
if (h) {
h = user->get_empty_dl_harq(cell_idx);
if (h != nullptr) {
#else
if (h && h->is_empty()) {
#endif
// Allocate resources based on pending data
if (req_bytes) {
if (req_bytes > 0) {
uint32_t pending_rbg =
user->prb_to_rbg(user->get_required_prb_dl(cc_idx, req_bytes, tti_alloc->get_nof_ctrl_symbols()));
user->prb_to_rbg(user->get_required_prb_dl(cell_idx, req_bytes, tti_alloc->get_nof_ctrl_symbols()));
rbgmask_t newtx_mask(tti_alloc->get_dl_mask().size());
find_allocation(pending_rbg, &newtx_mask);
if (newtx_mask.any()) { // some empty spaces were found
@ -153,7 +160,7 @@ void ul_metric_rr::set_params(const sched_params_t& sched_params_)
log_h = sched_params_.log_h;
}
void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched_t* tti_sched, uint32_t cc_idx)
void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched_t* tti_sched, uint32_t enb_cc_idx)
{
tti_alloc = tti_sched;
current_tti = tti_alloc->get_tti_tx_ul();
@ -174,7 +181,7 @@ void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched
iter = ue_db.begin(); // wrap around
}
sched_ue* user = &iter->second;
allocate_user_retx_prbs(user, cc_idx);
allocate_user_retx_prbs(user, enb_cc_idx);
}
// give priority in a time-domain RR basis
@ -185,7 +192,7 @@ void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched
iter = ue_db.begin(); // wrap around
}
sched_ue* user = &iter->second;
allocate_user_newtx_prbs(user, cc_idx);
allocate_user_newtx_prbs(user, enb_cc_idx);
}
}
@ -226,13 +233,20 @@ bool ul_metric_rr::find_allocation(uint32_t L, ul_harq_proc::ul_alloc_t* alloc)
return alloc->L == L;
}
ul_harq_proc* ul_metric_rr::allocate_user_retx_prbs(sched_ue* user, uint32_t cc_idx)
ul_harq_proc* ul_metric_rr::allocate_user_retx_prbs(sched_ue* user, uint32_t enb_cc_idx)
{
if (tti_alloc->is_ul_alloc(user)) {
return nullptr;
}
auto p = user->get_cell_index(enb_cc_idx);
if (not p.first) {
// this cc is not activated for this user
return nullptr;
}
uint32_t cell_idx = p.second;
alloc_outcome_t ret;
ul_harq_proc* h = user->get_ul_harq(current_tti, cc_idx);
ul_harq_proc* h = user->get_ul_harq(current_tti, cell_idx);
// if there are procedures and we have space
if (h->has_pending_retx()) {
@ -261,18 +275,25 @@ ul_harq_proc* ul_metric_rr::allocate_user_retx_prbs(sched_ue* user, uint32_t cc_
return nullptr;
}
ul_harq_proc* ul_metric_rr::allocate_user_newtx_prbs(sched_ue* user, uint32_t cc_idx)
ul_harq_proc* ul_metric_rr::allocate_user_newtx_prbs(sched_ue* user, uint32_t enb_cc_idx)
{
if (tti_alloc->is_ul_alloc(user)) {
return nullptr;
}
auto p = user->get_cell_index(enb_cc_idx);
if (not p.first) {
// this cc is not activated for this user
return nullptr;
}
uint32_t cell_idx = p.second;
uint32_t pending_data = user->get_pending_ul_new_data(current_tti);
ul_harq_proc* h = user->get_ul_harq(current_tti, cc_idx);
ul_harq_proc* h = user->get_ul_harq(current_tti, cell_idx);
// find an empty PID
if (h->is_empty(0) and pending_data > 0) {
uint32_t pending_rb = user->get_required_prb_ul(cc_idx, pending_data);
ul_harq_proc::ul_alloc_t alloc;
uint32_t pending_rb = user->get_required_prb_ul(cell_idx, pending_data);
ul_harq_proc::ul_alloc_t alloc{};
find_allocation(pending_rb, &alloc);
if (alloc.L > 0) { // at least one PRB was scheduled

@ -83,6 +83,7 @@ void sched_ue::set_cfg(uint16_t rnti_, const sched_params_t& sched_params_, sche
// Init sched_ue carriers
// TODO: check config for number of carriers
carriers.emplace_back(&cfg, &cell, rnti, 0, log_h);
enb_ue_cellindex_map.insert(std::make_pair(0, 0)); // FIXME: use real values
// Generate allowed CCE locations
for (int cfi = 0; cfi < 3; cfi++) {
@ -956,6 +957,30 @@ dl_harq_proc* sched_ue::get_dl_harq(uint32_t idx, uint32_t cc_idx)
return &carriers[cc_idx].dl_harq[idx];
}
std::pair<bool, uint32_t> sched_ue::get_cell_index(uint32_t enb_cc_idx) const
{
auto it = enb_ue_cellindex_map.find(enb_cc_idx);
if (it == enb_ue_cellindex_map.end()) {
log_h->error("The carrier with eNB_cc_idx=%d does not exist\n", enb_cc_idx);
return std::make_pair(false, 0);
}
return std::make_pair(true, it->second);
}
void sched_ue::finish_tti(const tti_params_t& tti_params, uint32_t enb_cc_idx)
{
auto it = enb_ue_cellindex_map.find(enb_cc_idx);
if (it == enb_ue_cellindex_map.end()) {
return;
}
/* Clean-up all the UL Harqs with maxretx == 0 */
get_ul_harq(tti_params.tti_tx_ul, it->second)->reset_pending_data();
/* reset PIDs with pending data or blocked */
reset_pending_pids(tti_params.tti_rx, it->second);
}
srslte_dci_format_t sched_ue::get_dci_format()
{
srslte_dci_format_t ret = SRSLTE_DCI_FORMAT1;

Loading…
Cancel
Save