moved the BC scheduling to a separate class/file

This commit is contained in:
Francisco Paisana 2019-10-16 12:03:30 +01:00
parent 837c16557f
commit d79e49ed4c
6 changed files with 60 additions and 101 deletions

View File

@ -148,11 +148,6 @@ protected:
// This is for computing DCI locations // This is for computing DCI locations
srslte_regs_t regs; srslte_regs_t regs;
typedef struct {
bool is_in_window;
uint32_t window_start;
uint32_t n_tx;
} sched_sib_t;
class bc_sched_t; class bc_sched_t;
class tti_sched_t : public dl_tti_sched_t, public ul_tti_sched_t class tti_sched_t : public dl_tti_sched_t, public ul_tti_sched_t
@ -266,16 +261,14 @@ protected:
void generate_phich(tti_sched_t* tti_sched); void generate_phich(tti_sched_t* tti_sched);
int generate_dl_sched(tti_sched_t* tti_sched); int generate_dl_sched(tti_sched_t* tti_sched);
int generate_ul_sched(tti_sched_t* tti_sched); int generate_ul_sched(tti_sched_t* tti_sched);
void dl_sched_bc(tti_sched_t* tti_sched);
void dl_sched_rar(tti_sched_t* tti_sched); void dl_sched_rar(tti_sched_t* tti_sched);
void dl_sched_data(tti_sched_t* tti_sched); void dl_sched_data(tti_sched_t* tti_sched);
void ul_sched_msg3(tti_sched_t* tti_sched); void ul_sched_msg3(tti_sched_t* tti_sched);
std::map<uint16_t, sched_ue> ue_db; std::map<uint16_t, sched_ue> ue_db;
sched_sib_t pending_sibs[MAX_SIBS];
typedef struct { typedef struct {
bool enabled; bool enabled;
uint16_t rnti; uint16_t rnti;
uint32_t L; uint32_t L;
uint32_t n_prb; uint32_t n_prb;
@ -297,9 +290,10 @@ protected:
prbmask_t prach_mask; prbmask_t prach_mask;
prbmask_t pucch_mask; prbmask_t pucch_mask;
uint32_t bc_aggr_level; uint32_t bc_aggr_level;
uint32_t rar_aggr_level; uint32_t rar_aggr_level;
std::unique_ptr<bc_sched_t> bc_sched;
uint32_t pdsch_re[10]; uint32_t pdsch_re[10];
uint32_t current_tti; uint32_t current_tti;

View File

@ -30,6 +30,7 @@ class sched::bc_sched_t
{ {
public: public:
bc_sched_t(cell_cfg_t* cfg_); bc_sched_t(cell_cfg_t* cfg_);
void init(rrc_interface_mac* rrc_);
void dl_sched(tti_sched_t* tti_sched); void dl_sched(tti_sched_t* tti_sched);
void reset(); void reset();
@ -43,9 +44,11 @@ private:
void update_si_windows(tti_sched_t* tti_sched); void update_si_windows(tti_sched_t* tti_sched);
void alloc_sibs(tti_sched_t* tti_sched); void alloc_sibs(tti_sched_t* tti_sched);
void alloc_paging(tti_sched_t* tti_sched);
// args // args
cell_cfg_t* cfg; cell_cfg_t* cfg;
rrc_interface_mac* rrc = nullptr;
std::array<sched_sib_t, sched_interface::MAX_SIBS> pending_sibs; std::array<sched_sib_t, sched_interface::MAX_SIBS> pending_sibs;

View File

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include "srsenb/hdr/stack/mac/scheduler.h" #include "srsenb/hdr/stack/mac/scheduler.h"
#include "srsenb/hdr/stack/mac/scheduler_ctrl.h"
#include "srslte/common/pdu.h" #include "srslte/common/pdu.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
@ -562,11 +563,18 @@ int sched::tti_sched_t::generate_format1a(
} }
/******************************************************* /*******************************************************
* *
* Initialization and sched configuration functions * Initialization and sched configuration functions
* *
*******************************************************/ *******************************************************/
sched::sched() : bc_aggr_level(0), rar_aggr_level(0), P(0), si_n_rbg(0), rar_n_rbg(0), nof_rbg(0) sched::sched() :
bc_aggr_level(0),
rar_aggr_level(0),
P(0),
si_n_rbg(0),
rar_n_rbg(0),
nof_rbg(0),
bc_sched(new bc_sched_t{&cfg})
{ {
current_tti = 0; current_tti = 0;
log_h = nullptr; log_h = nullptr;
@ -608,13 +616,14 @@ void sched::init(rrc_interface_mac* rrc_, srslte::log* log)
sched_cfg.max_aggr_level = 3; sched_cfg.max_aggr_level = 3;
log_h = log; log_h = log;
rrc = rrc_; rrc = rrc_;
bc_sched->init(rrc);
reset(); reset();
} }
int sched::reset() int sched::reset()
{ {
bzero(pending_msg3, sizeof(pending_msg3_t) * TTIMOD_SZ); bzero(pending_msg3, sizeof(pending_msg3_t) * TTIMOD_SZ);
bzero(pending_sibs, sizeof(sched_sib_t) * MAX_SIBS);
while (not pending_rars.empty()) { while (not pending_rars.empty()) {
pending_rars.pop(); pending_rars.pop();
} }
@ -1088,73 +1097,6 @@ sched::tti_sched_t* sched::new_tti(uint32_t tti_rx)
return tti_sched; return tti_sched;
} }
// Schedules Broadcast messages (SIB)
void sched::dl_sched_bc(tti_sched_t* tti_sched)
{
/* Activate/Deactivate SI windows */
for (int i = 0; i < MAX_SIBS; i++) {
// There is SIB data
if (cfg.sibs[i].len == 0) {
continue;
}
if (!pending_sibs[i].is_in_window) {
uint32_t sf = 5;
uint32_t x = 0;
if (i > 0) {
x = (i - 1) * cfg.si_window_ms;
sf = x % 10;
}
if ((tti_sched->get_sfn() % (cfg.sibs[i].period_rf)) == x / 10 && tti_sched->get_sf_idx() == sf) {
pending_sibs[i].is_in_window = true;
pending_sibs[i].window_start = tti_sched->get_tti_tx_dl();
pending_sibs[i].n_tx = 0;
}
} else {
if (i > 0) {
if (srslte_tti_interval(tti_sched->get_tti_tx_dl(), pending_sibs[i].window_start) > cfg.si_window_ms) {
// the si window has passed
pending_sibs[i].is_in_window = false;
pending_sibs[i].window_start = 0;
}
} else {
// SIB1 is always in window
if (pending_sibs[0].n_tx == 4) {
pending_sibs[0].n_tx = 0;
}
}
}
}
/* Allocate DCIs and RBGs for each SIB */
for (int i = 0; i < MAX_SIBS; i++) {
if (cfg.sibs[i].len > 0 && pending_sibs[i].is_in_window && pending_sibs[i].n_tx < 4) {
uint32_t nof_tx = (i > 0) ? SRSLTE_MIN(CEILFRAC(cfg.si_window_ms, 10), 4) : 4;
uint32_t n_sf = (tti_sched->get_tti_tx_dl() - pending_sibs[i].window_start);
// Check if there is any SIB to tx
bool sib1_flag = i == 0 and (tti_sched->get_sfn() % 2) == 0 and tti_sched->get_sf_idx() == 5;
bool other_sibs_flag =
i > 0 and n_sf >= (cfg.si_window_ms / nof_tx) * pending_sibs[i].n_tx and tti_sched->get_sf_idx() == 9;
if (!sib1_flag and !other_sibs_flag) {
continue;
}
// Schedule SIB
tti_sched->alloc_bc(bc_aggr_level, i, pending_sibs[i].n_tx);
pending_sibs[i].n_tx++;
}
}
/* Allocate DCIs and RBGs for paging */
if (rrc != nullptr) {
uint32_t paging_payload = 0;
if (rrc->is_paging_opportunity(current_tti, &paging_payload) and paging_payload > 0) {
tti_sched->alloc_paging(bc_aggr_level, paging_payload);
}
}
}
bool is_in_tti_interval(uint32_t tti, uint32_t tti1, uint32_t tti2) bool is_in_tti_interval(uint32_t tti, uint32_t tti1, uint32_t tti2)
{ {
tti %= 10240; tti %= 10240;
@ -1260,8 +1202,8 @@ int sched::generate_dl_sched(tti_sched_t* tti_sched)
bc_aggr_level = 2; bc_aggr_level = 2;
rar_aggr_level = 2; rar_aggr_level = 2;
/* Schedule Broadcast data */ /* Schedule Broadcast data (SIB and paging) */
dl_sched_bc(tti_sched); bc_sched->dl_sched(tti_sched);
/* Schedule RAR */ /* Schedule RAR */
dl_sched_rar(tti_sched); dl_sched_rar(tti_sched);

View File

@ -25,6 +25,11 @@ namespace srsenb {
sched::bc_sched_t::bc_sched_t(cell_cfg_t* cfg_) : cfg(cfg_) {} sched::bc_sched_t::bc_sched_t(cell_cfg_t* cfg_) : cfg(cfg_) {}
void sched::bc_sched_t::init(srsenb::rrc_interface_mac* rrc_)
{
rrc = rrc_;
}
void sched::bc_sched_t::dl_sched(sched::tti_sched_t* tti_sched) void sched::bc_sched_t::dl_sched(sched::tti_sched_t* tti_sched)
{ {
current_sf_idx = tti_sched->get_sf_idx(); current_sf_idx = tti_sched->get_sf_idx();
@ -37,6 +42,10 @@ void sched::bc_sched_t::dl_sched(sched::tti_sched_t* tti_sched)
/* Allocate DCIs and RBGs for each SIB */ /* Allocate DCIs and RBGs for each SIB */
alloc_sibs(tti_sched); alloc_sibs(tti_sched);
/* Allocate Paging */
// NOTE: It blocks
alloc_paging(tti_sched);
} }
void sched::bc_sched_t::update_si_windows(tti_sched_t* tti_sched) void sched::bc_sched_t::update_si_windows(tti_sched_t* tti_sched)
@ -99,6 +108,17 @@ void sched::bc_sched_t::alloc_sibs(tti_sched_t* tti_sched)
} }
} }
void sched::bc_sched_t::alloc_paging(srsenb::sched::tti_sched_t* tti_sched)
{
/* Allocate DCIs and RBGs for paging */
if (rrc != nullptr) {
uint32_t paging_payload = 0;
if (rrc->is_paging_opportunity(current_tti, &paging_payload) and paging_payload > 0) {
tti_sched->alloc_paging(bc_aggr_level, paging_payload);
}
}
}
void sched::bc_sched_t::reset() void sched::bc_sched_t::reset()
{ {
for (auto& sib : pending_sibs) { for (auto& sib : pending_sibs) {

View File

@ -556,8 +556,8 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len)
} }
} }
for (uint32_t i = 0; i < ue_to_remove.size(); i++) { for (unsigned int i : ue_to_remove) {
pending_paging.erase(ue_to_remove[i]); pending_paging.erase(i);
} }
pthread_mutex_unlock(&paging_mutex); pthread_mutex_unlock(&paging_mutex);

View File

@ -426,7 +426,7 @@ void sched_tester::test_ra()
if (tti_data.tti_tx_dl >= window[0]) { if (tti_data.tti_tx_dl >= window[0]) {
for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_rar_elems; ++i) { for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_rar_elems; ++i) {
for (uint32_t j = 0; j < tti_data.sched_result_dl.rar[i].nof_grants; ++j) { for (uint32_t j = 0; j < tti_data.sched_result_dl.rar[i].nof_grants; ++j) {
if (tti_data.sched_result_dl.rar[i].msg3_grant[j].data.prach_tti == tti_data.tti_tx_dl) { if (tti_data.sched_result_dl.rar[i].msg3_grant[j].data.prach_tti + TX_DELAY == tti_data.tti_tx_dl) {
userinfo.rar_tti = tti_data.tti_tx_dl; userinfo.rar_tti = tti_data.tti_tx_dl;
} }
} }
@ -701,17 +701,17 @@ void sched_tester::test_harqs()
to_ul_ack.insert(std::make_pair(ack_data.tti_tx_ul, ack_data)); to_ul_ack.insert(std::make_pair(ack_data.tti_tx_ul, ack_data));
} }
// // Check whether some pids got old // // Check whether some pids got old
// for (auto& user : ue_db) { // for (auto& user : ue_db) {
// for (int i = 0; i < 2 * FDD_HARQ_DELAY_MS; i++) { // for (int i = 0; i < 2 * FDD_HARQ_DELAY_MS; i++) {
// if (not(user.second.get_dl_harq(i)->is_empty(0) and user.second.get_dl_harq(1))) { // if (not(user.second.get_dl_harq(i)->is_empty(0) and user.second.get_dl_harq(1))) {
// if (srslte_tti_interval(tti_data.tti_tx_dl, user.second.get_dl_harq(i)->get_tti()) > 49) { // if (srslte_tti_interval(tti_data.tti_tx_dl, user.second.get_dl_harq(i)->get_tti()) > 49) {
// TestError("[TESTER] The pid=%d for rnti=0x%x got old.\n", user.second.get_dl_harq(i)->get_id(), // TestError("[TESTER] The pid=%d for rnti=0x%x got old.\n", user.second.get_dl_harq(i)->get_id(),
// user.first); // user.first);
// } // }
// } // }
// } // }
// } // }
} }
void sched_tester::test_sibs() void sched_tester::test_sibs()