clang-format on all the scheduler files

master
Francisco Paisana 5 years ago
parent c1f9d8768c
commit 00d24872d9

@ -68,7 +68,6 @@ public:
uint32_t max_nof_retx() const; uint32_t max_nof_retx() const;
protected: protected:
void new_tx_common(uint32_t tb_idx, uint32_t tti, int mcs, int tbs); void new_tx_common(uint32_t tb_idx, uint32_t tti, int mcs, int tbs);
void new_retx_common(uint32_t tb_idx, uint32_t tti, int* mcs, int* tbs); void new_retx_common(uint32_t tb_idx, uint32_t tti, int* mcs, int* tbs);
bool has_pending_retx_common(uint32_t tb_idx) const; bool has_pending_retx_common(uint32_t tb_idx) const;
@ -114,7 +113,6 @@ private:
class ul_harq_proc : public harq_proc class ul_harq_proc : public harq_proc
{ {
public: public:
struct ul_alloc_t { struct ul_alloc_t {
uint32_t RB_start; uint32_t RB_start;
uint32_t L; uint32_t L;

@ -22,9 +22,9 @@
#ifndef SRSENB_SCHEDULER_UE_H #ifndef SRSENB_SCHEDULER_UE_H
#define SRSENB_SCHEDULER_UE_H #define SRSENB_SCHEDULER_UE_H
#include <map>
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "srslte/interfaces/sched_interface.h" #include "srslte/interfaces/sched_interface.h"
#include <map>
#include "scheduler_harq.h" #include "scheduler_harq.h"
#include "srslte/asn1/rrc_asn1.h" #include "srslte/asn1/rrc_asn1.h"
@ -32,13 +32,13 @@
namespace srsenb { namespace srsenb {
/** This class is designed to be thread-safe because it is called from workers through scheduler thread and from /** This class is designed to be thread-safe because it is called from workers through scheduler thread and from
* higher layers and mac threads. * higher layers and mac threads.
* *
* 1 mutex is created for every user and only access to same user variables are mutexed * 1 mutex is created for every user and only access to same user variables are mutexed
*/ */
class sched_ue { class sched_ue
{
public: public:
// used by sched_metric to store the pdsch/pusch allocations // used by sched_metric to store the pdsch/pusch allocations
@ -57,8 +57,11 @@ public:
sched_ue(); sched_ue();
void reset(); void reset();
void phy_config_enabled(uint32_t tti, bool enabled); void phy_config_enabled(uint32_t tti, bool enabled);
void set_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg, sched_interface::cell_cfg_t *cell_cfg, void set_cfg(uint16_t rnti,
srslte_regs_t *regs, srslte::log *log_h); sched_interface::ue_cfg_t* cfg,
sched_interface::cell_cfg_t* cell_cfg,
srslte_regs_t* regs,
srslte::log* log_h);
void set_bearer_cfg(uint32_t lc_id, srsenb::sched_interface::ue_bearer_cfg_t* cfg); void set_bearer_cfg(uint32_t lc_id, srsenb::sched_interface::ue_bearer_cfg_t* cfg);
void rem_bearer(uint32_t lc_id); void rem_bearer(uint32_t lc_id);
@ -76,7 +79,7 @@ public:
int set_ack_info(uint32_t tti, uint32_t tb_idx, bool ack); int set_ack_info(uint32_t tti, uint32_t tb_idx, bool ack);
void set_ul_crc(uint32_t tti, bool crc_res); void set_ul_crc(uint32_t tti, bool crc_res);
/******************************************************* /*******************************************************
* Custom functions * Custom functions
*******************************************************/ *******************************************************/
@ -99,14 +102,13 @@ public:
uint32_t prb_to_rbg(uint32_t nof_prb); uint32_t prb_to_rbg(uint32_t nof_prb);
uint32_t rgb_to_prb(uint32_t nof_rbg); uint32_t rgb_to_prb(uint32_t nof_rbg);
uint32_t get_pending_dl_new_data(uint32_t tti); uint32_t get_pending_dl_new_data(uint32_t tti);
uint32_t get_pending_ul_new_data(uint32_t tti); uint32_t get_pending_ul_new_data(uint32_t tti);
uint32_t get_pending_ul_old_data(); uint32_t get_pending_ul_old_data();
uint32_t get_pending_dl_new_data_total(uint32_t tti); uint32_t get_pending_dl_new_data_total(uint32_t tti);
void reset_pending_pids(uint32_t tti_rx); void reset_pending_pids(uint32_t tti_rx);
dl_harq_proc *get_pending_dl_harq(uint32_t tti); dl_harq_proc* get_pending_dl_harq(uint32_t tti);
dl_harq_proc* get_empty_dl_harq(); dl_harq_proc* get_empty_dl_harq();
ul_harq_proc* get_ul_harq(uint32_t tti); ul_harq_proc* get_ul_harq(uint32_t tti);
@ -134,7 +136,7 @@ public:
srslte_dci_format_t get_dci_format(); srslte_dci_format_t get_dci_format();
uint32_t get_aggr_level(uint32_t nof_bits); uint32_t get_aggr_level(uint32_t nof_bits);
sched_dci_cce_t *get_locations(uint32_t current_cfi, uint32_t sf_idx); sched_dci_cce_t* get_locations(uint32_t current_cfi, uint32_t sf_idx);
bool needs_cqi(uint32_t tti, bool will_send = false); bool needs_cqi(uint32_t tti, bool will_send = false);
uint32_t get_max_retx(); uint32_t get_max_retx();
@ -143,7 +145,6 @@ public:
bool pucch_sr_collision(uint32_t current_tti, uint32_t n_cce); bool pucch_sr_collision(uint32_t current_tti, uint32_t n_cce);
private: private:
typedef struct { typedef struct {
sched_interface::ue_bearer_cfg_t cfg; sched_interface::ue_bearer_cfg_t cfg;
int buf_tx; int buf_tx;
@ -157,12 +158,12 @@ private:
static uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb); static uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb);
static int cqi_to_tbs( static int cqi_to_tbs(
uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t max_Qm, bool is_ul, uint32_t* mcs); uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t max_Qm, bool is_ul, uint32_t* mcs);
int alloc_tbs_dl(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int *mcs); int alloc_tbs_dl(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int* mcs);
int alloc_tbs_ul(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int *mcs); int alloc_tbs_ul(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int* mcs);
int alloc_tbs(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, bool is_ul, int *mcs); int alloc_tbs(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, bool is_ul, int* mcs);
static bool bearer_is_ul(ue_bearer_t *lch); static bool bearer_is_ul(ue_bearer_t* lch);
static bool bearer_is_dl(ue_bearer_t *lch); static bool bearer_is_dl(ue_bearer_t* lch);
uint32_t get_pending_dl_new_data_unlocked(uint32_t tti); uint32_t get_pending_dl_new_data_unlocked(uint32_t tti);
uint32_t get_pending_ul_old_data_unlocked(); uint32_t get_pending_ul_old_data_unlocked();
@ -221,9 +222,7 @@ private:
bool phy_config_dedicated_enabled; bool phy_config_dedicated_enabled;
asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info; asn1::rrc::phys_cfg_ded_s::ant_info_c_ dl_ant_info;
}; };
} } // namespace srsenb
#endif // SRSENB_SCHEDULER_UE_H #endif // SRSENB_SCHEDULER_UE_H

@ -712,7 +712,6 @@ int sched::cell_cfg(sched_interface::cell_cfg_t* cell_cfg)
return 0; return 0;
} }
/******************************************************* /*******************************************************
* *
* FAPI-like main sched interface. Wrappers to UE object * FAPI-like main sched interface. Wrappers to UE object

@ -105,7 +105,7 @@ bool harq_proc::has_pending_retx_common(uint32_t tb_idx) const
uint32_t harq_proc::get_tti() const uint32_t harq_proc::get_tti() const
{ {
return (uint32_t) tti; return (uint32_t)tti;
} }
void harq_proc::set_ack_common(uint32_t tb_idx, bool ack_) void harq_proc::set_ack_common(uint32_t tb_idx, bool ack_)
@ -113,7 +113,8 @@ void harq_proc::set_ack_common(uint32_t tb_idx, bool ack_)
ack_state[tb_idx] = ack_ ? ACK : NACK; ack_state[tb_idx] = ack_ ? ACK : NACK;
log_h->debug("ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d\n", ack_, id, tb_idx, n_rtx[tb_idx], max_retx); log_h->debug("ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d\n", ack_, id, tb_idx, n_rtx[tb_idx], max_retx);
if (!ack_ && (n_rtx[tb_idx] + 1 >= max_retx)) { if (!ack_ && (n_rtx[tb_idx] + 1 >= max_retx)) {
Warning("SCHED: discarting TB %d pid=%d, tti=%d, maximum number of retx exceeded (%d)\n", tb_idx, id, tti, max_retx); Warning(
"SCHED: discarting TB %d pid=%d, tti=%d, maximum number of retx exceeded (%d)\n", tb_idx, id, tti, max_retx);
active[tb_idx] = false; active[tb_idx] = false;
} else if (ack_) { } else if (ack_) {
active[tb_idx] = false; active[tb_idx] = false;
@ -296,7 +297,7 @@ void ul_harq_proc::reset_pending_data()
uint32_t ul_harq_proc::get_pending_data() const uint32_t ul_harq_proc::get_pending_data() const
{ {
return (uint32_t) pending_data; return (uint32_t)pending_data;
} }
} } // namespace srsenb

@ -54,8 +54,8 @@ void dl_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_tti_sched
uint32_t priority_idx = tti_alloc->get_tti_tx_dl() % (uint32_t)ue_db.size(); uint32_t priority_idx = tti_alloc->get_tti_tx_dl() % (uint32_t)ue_db.size();
it_t iter = ue_db.begin(); it_t iter = ue_db.begin();
std::advance(iter, priority_idx); std::advance(iter, priority_idx);
for(uint32_t ue_count = 0 ; ue_count < ue_db.size() ; ++iter, ++ue_count) { for (uint32_t ue_count = 0; ue_count < ue_db.size(); ++iter, ++ue_count) {
if(iter==ue_db.end()) { if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around iter = ue_db.begin(); // wrap around
} }
sched_ue* user = &iter->second; sched_ue* user = &iter->second;
@ -159,17 +159,18 @@ void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched
tti_alloc = tti_sched; tti_alloc = tti_sched;
current_tti = tti_alloc->get_tti_tx_ul(); current_tti = tti_alloc->get_tti_tx_ul();
if(ue_db.size()==0) if (ue_db.size() == 0)
return; return;
// give priority in a time-domain RR basis // give priority in a time-domain RR basis
uint32_t priority_idx = (current_tti+(uint32_t)ue_db.size()/2) % (uint32_t)ue_db.size(); // make DL and UL interleaved uint32_t priority_idx =
(current_tti + (uint32_t)ue_db.size() / 2) % (uint32_t)ue_db.size(); // make DL and UL interleaved
// allocate reTxs first // allocate reTxs first
it_t iter = ue_db.begin(); it_t iter = ue_db.begin();
std::advance(iter, priority_idx); std::advance(iter, priority_idx);
for(uint32_t ue_count = 0 ; ue_count < ue_db.size() ; ++iter, ++ue_count) { for (uint32_t ue_count = 0; ue_count < ue_db.size(); ++iter, ++ue_count) {
if(iter==ue_db.end()) { if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around iter = ue_db.begin(); // wrap around
} }
sched_ue* user = &iter->second; sched_ue* user = &iter->second;
@ -178,9 +179,9 @@ void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched
// give priority in a time-domain RR basis // give priority in a time-domain RR basis
iter = ue_db.begin(); iter = ue_db.begin();
std::advance(iter,priority_idx); std::advance(iter, priority_idx);
for(uint32_t ue_count = 0 ; ue_count < ue_db.size() ; ++iter, ++ue_count) { for (uint32_t ue_count = 0; ue_count < ue_db.size(); ++iter, ++ue_count) {
if(iter==ue_db.end()) { if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around iter = ue_db.begin(); // wrap around
} }
sched_ue* user = &iter->second; sched_ue* user = &iter->second;
@ -214,7 +215,7 @@ bool ul_metric_rr::find_allocation(uint32_t L, ul_harq_proc::ul_alloc_t* alloc)
} }
} }
} }
if (alloc->L==0) { if (alloc->L == 0) {
return false; return false;
} }

@ -40,7 +40,6 @@
namespace srsenb { namespace srsenb {
/******************************************************* /*******************************************************
* *
* Initialization and configuration functions * Initialization and configuration functions
@ -110,10 +109,9 @@ void sched_ue::set_cfg(uint16_t rnti_,
} }
} }
for (int i=0;i<sched_interface::MAX_LC;i++) { for (int i = 0; i < sched_interface::MAX_LC; i++) {
set_bearer_cfg(i, &cfg.ue_bearers[i]); set_bearer_cfg(i, &cfg.ue_bearers[i]);
} }
} }
void sched_ue::reset() void sched_ue::reset()
@ -144,12 +142,13 @@ void sched_ue::reset()
} }
} }
for (int i=0;i<sched_interface::MAX_LC; i++) { for (int i = 0; i < sched_interface::MAX_LC; i++) {
rem_bearer(i); rem_bearer(i);
} }
} }
void sched_ue::set_fixed_mcs(int mcs_ul, int mcs_dl) { void sched_ue::set_fixed_mcs(int mcs_ul, int mcs_dl)
{
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
fixed_mcs_ul = mcs_ul; fixed_mcs_ul = mcs_ul;
fixed_mcs_dl = mcs_dl; fixed_mcs_dl = mcs_dl;
@ -174,7 +173,6 @@ void sched_ue::set_max_mcs(int mcs_ul, int mcs_dl, int max_aggr_level_) {
} }
} }
/******************************************************* /*******************************************************
* *
* FAPI-like main scheduler interface. * FAPI-like main scheduler interface.
@ -189,7 +187,7 @@ void sched_ue::set_bearer_cfg(uint32_t lc_id, sched_interface::ue_bearer_cfg_t*
lch[lc_id].buf_tx = 0; lch[lc_id].buf_tx = 0;
lch[lc_id].buf_retx = 0; lch[lc_id].buf_retx = 0;
if (lch[lc_id].cfg.direction != sched_interface::ue_bearer_cfg_t::IDLE) { if (lch[lc_id].cfg.direction != sched_interface::ue_bearer_cfg_t::IDLE) {
Info("SCHED: Set bearer config lc_id=%d, direction=%d\n", lc_id, (int) lch[lc_id].cfg.direction); Info("SCHED: Set bearer config lc_id=%d, direction=%d\n", lc_id, (int)lch[lc_id].cfg.direction);
} }
} }
} }
@ -218,8 +216,7 @@ void sched_ue::ul_buffer_state(uint8_t lc_id, uint32_t bsr, bool set_value)
lch[lc_id].bsr += bsr; lch[lc_id].bsr += bsr;
} }
} }
Debug("SCHED: bsr=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", bsr, lc_id, Debug("SCHED: bsr=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", bsr, lc_id, lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr);
lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr);
} }
void sched_ue::ul_phr(int phr) void sched_ue::ul_phr(int phr)
@ -323,7 +320,7 @@ int sched_ue::set_ack_info(uint32_t tti, uint32_t tb_idx, bool ack)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
int ret = -1; int ret = -1;
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
if (TTI_TX(dl_harq[i].get_tti()) == tti) { if (TTI_TX(dl_harq[i].get_tti()) == tti) {
Debug("SCHED: Set ACK=%d for rnti=0x%x, pid=%d, tb=%d, tti=%d\n", ack, rnti, i, tb_idx, tti); Debug("SCHED: Set ACK=%d for rnti=0x%x, pid=%d, tb=%d, tti=%d\n", ack, rnti, i, tb_idx, tti);
dl_harq[i].set_ack(tb_idx, ack); dl_harq[i].set_ack(tb_idx, ack);
@ -349,15 +346,14 @@ void sched_ue::ul_recv_len(uint32_t lcid, uint32_t len)
} }
if (lcid < sched_interface::MAX_LC) { if (lcid < sched_interface::MAX_LC) {
if (bearer_is_ul(&lch[lcid])) { if (bearer_is_ul(&lch[lcid])) {
if (lch[lcid].bsr > (int) len) { if (lch[lcid].bsr > (int)len) {
lch[lcid].bsr -= len; lch[lcid].bsr -= len;
} else { } else {
lch[lcid].bsr = 0; lch[lcid].bsr = 0;
} }
} }
} }
Debug("SCHED: recv_len=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", len, lcid, Debug("SCHED: recv_len=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", len, lcid, lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr);
lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr);
} }
void sched_ue::set_ul_crc(uint32_t tti, bool crc_res) void sched_ue::set_ul_crc(uint32_t tti, bool crc_res)
@ -400,7 +396,8 @@ void sched_ue::set_ul_cqi(uint32_t tti, uint32_t cqi, uint32_t ul_ch_code)
ul_cqi_tti = tti; ul_cqi_tti = tti;
} }
void sched_ue::tpc_inc() { void sched_ue::tpc_inc()
{
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
if (power_headroom > 0) { if (power_headroom > 0) {
next_tpc_pusch = 3; next_tpc_pusch = 3;
@ -409,7 +406,8 @@ void sched_ue::tpc_inc() {
log_h->info("SCHED: Set TCP=%d for rnti=0x%x\n", next_tpc_pucch, rnti); log_h->info("SCHED: Set TCP=%d for rnti=0x%x\n", next_tpc_pucch, rnti);
} }
void sched_ue::tpc_dec() { void sched_ue::tpc_dec()
{
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
next_tpc_pusch = 0; next_tpc_pusch = 0;
next_tpc_pucch = 0; next_tpc_pucch = 0;
@ -631,7 +629,7 @@ int sched_ue::generate_format2a_unlocked(
dci->format = SRSLTE_DCI_FORMAT2A; dci->format = SRSLTE_DCI_FORMAT2A;
dci->rnti = rnti; dci->rnti = rnti;
dci->pid = h->get_id(); dci->pid = h->get_id();
dci->tpc_pucch = (uint8_t) next_tpc_pucch; dci->tpc_pucch = (uint8_t)next_tpc_pucch;
next_tpc_pucch = 1; next_tpc_pucch = 1;
int ret = data->tbs[0] + data->tbs[1]; int ret = data->tbs[0] + data->tbs[1];
@ -651,9 +649,9 @@ int sched_ue::generate_format2(
/* Compute precoding information */ /* Compute precoding information */
data->dci.format = SRSLTE_DCI_FORMAT2; data->dci.format = SRSLTE_DCI_FORMAT2;
if ((SRSLTE_DCI_IS_TB_EN(data->dci.tb[0]) + SRSLTE_DCI_IS_TB_EN(data->dci.tb[1])) == 1) { if ((SRSLTE_DCI_IS_TB_EN(data->dci.tb[0]) + SRSLTE_DCI_IS_TB_EN(data->dci.tb[1])) == 1) {
data->dci.pinfo = (uint8_t) (dl_pmi + 1) % (uint8_t) 5; data->dci.pinfo = (uint8_t)(dl_pmi + 1) % (uint8_t)5;
} else { } else {
data->dci.pinfo = (uint8_t) (dl_pmi & 1); data->dci.pinfo = (uint8_t)(dl_pmi & 1);
} }
return ret; return ret;
@ -732,21 +730,26 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data,
* *
*******************************************************/ *******************************************************/
bool sched_ue::bearer_is_ul(ue_bearer_t *lch) { bool sched_ue::bearer_is_ul(ue_bearer_t* lch)
return lch->cfg.direction == sched_interface::ue_bearer_cfg_t::UL || lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH; {
return lch->cfg.direction == sched_interface::ue_bearer_cfg_t::UL ||
lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH;
} }
bool sched_ue::bearer_is_dl(ue_bearer_t *lch) { bool sched_ue::bearer_is_dl(ue_bearer_t* lch)
return lch->cfg.direction == sched_interface::ue_bearer_cfg_t::DL || lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH; {
return lch->cfg.direction == sched_interface::ue_bearer_cfg_t::DL ||
lch->cfg.direction == sched_interface::ue_bearer_cfg_t::BOTH;
} }
uint32_t sched_ue::get_max_retx() { uint32_t sched_ue::get_max_retx()
{
return cfg.maxharq_tx; return cfg.maxharq_tx;
} }
bool sched_ue::is_first_dl_tx() bool sched_ue::is_first_dl_tx()
{ {
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
if (dl_harq[i].nof_tx(0) > 0) { if (dl_harq[i].nof_tx(0) > 0) {
return false; return false;
} }
@ -765,10 +768,7 @@ bool sched_ue::needs_cqi(uint32_t tti, bool will_be_sent)
bool sched_ue::needs_cqi_unlocked(uint32_t tti, bool will_be_sent) bool sched_ue::needs_cqi_unlocked(uint32_t tti, bool will_be_sent)
{ {
bool ret = false; bool ret = false;
if (phy_config_dedicated_enabled && if (phy_config_dedicated_enabled && cfg.aperiodic_cqi_period && get_pending_dl_new_data_unlocked(tti) > 0) {
cfg.aperiodic_cqi_period &&
get_pending_dl_new_data_unlocked(tti) > 0)
{
uint32_t interval = srslte_tti_interval(tti, dl_cqi_tti); uint32_t interval = srslte_tti_interval(tti, dl_cqi_tti);
bool needscqi = interval >= cfg.aperiodic_cqi_period; bool needscqi = interval >= cfg.aperiodic_cqi_period;
if (needscqi) { if (needscqi) {
@ -806,9 +806,9 @@ uint32_t sched_ue::get_pending_dl_new_data_total(uint32_t tti)
uint32_t sched_ue::get_pending_dl_new_data_total_unlocked(uint32_t tti) uint32_t sched_ue::get_pending_dl_new_data_total_unlocked(uint32_t tti)
{ {
uint32_t req_bytes = get_pending_dl_new_data_unlocked(tti); uint32_t req_bytes = get_pending_dl_new_data_unlocked(tti);
if(req_bytes>0) { if (req_bytes > 0) {
req_bytes += (req_bytes < 128) ? 2 : 3; // consider the header req_bytes += (req_bytes < 128) ? 2 : 3; // consider the header
if(is_first_dl_tx()) { if (is_first_dl_tx()) {
req_bytes += 6; // count for RAR req_bytes += 6; // count for RAR
} }
} }
@ -819,7 +819,7 @@ uint32_t sched_ue::get_pending_dl_new_data_total_unlocked(uint32_t tti)
uint32_t sched_ue::get_pending_dl_new_data_unlocked(uint32_t tti) uint32_t sched_ue::get_pending_dl_new_data_unlocked(uint32_t tti)
{ {
uint32_t pending_data = 0; uint32_t pending_data = 0;
for (int i=0;i<sched_interface::MAX_LC;i++) { for (int i = 0; i < sched_interface::MAX_LC; i++) {
if (bearer_is_dl(&lch[i])) { if (bearer_is_dl(&lch[i])) {
pending_data += lch[i].buf_retx + lch[i].buf_tx; pending_data += lch[i].buf_retx + lch[i].buf_tx;
} }
@ -848,7 +848,7 @@ uint32_t sched_ue::get_pending_ul_old_data()
uint32_t sched_ue::get_pending_ul_new_data_unlocked(uint32_t tti) uint32_t sched_ue::get_pending_ul_new_data_unlocked(uint32_t tti)
{ {
uint32_t pending_data = 0; uint32_t pending_data = 0;
for (int i=0;i<sched_interface::MAX_LC;i++) { for (int i = 0; i < sched_interface::MAX_LC; i++) {
if (bearer_is_ul(&lch[i])) { if (bearer_is_ul(&lch[i])) {
pending_data += lch[i].bsr; pending_data += lch[i].bsr;
} }
@ -866,8 +866,13 @@ uint32_t sched_ue::get_pending_ul_new_data_unlocked(uint32_t tti)
pending_data = 0; pending_data = 0;
} }
if (pending_data) { if (pending_data) {
Debug("SCHED: pending_data=%d, pending_ul_data=%d, bsr={%d,%d,%d,%d}\n", pending_data,pending_ul_data, Debug("SCHED: pending_data=%d, pending_ul_data=%d, bsr={%d,%d,%d,%d}\n",
lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr); pending_data,
pending_ul_data,
lch[0].bsr,
lch[1].bsr,
lch[2].bsr,
lch[3].bsr);
} }
return pending_data; return pending_data;
} }
@ -876,7 +881,7 @@ uint32_t sched_ue::get_pending_ul_new_data_unlocked(uint32_t tti)
uint32_t sched_ue::get_pending_ul_old_data_unlocked() uint32_t sched_ue::get_pending_ul_old_data_unlocked()
{ {
uint32_t pending_data = 0; uint32_t pending_data = 0;
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
pending_data += ul_harq[i].get_pending_data(); pending_data += ul_harq[i].get_pending_data();
} }
return pending_data; return pending_data;
@ -884,12 +889,12 @@ uint32_t sched_ue::get_pending_ul_old_data_unlocked()
uint32_t sched_ue::prb_to_rbg(uint32_t nof_prb) uint32_t sched_ue::prb_to_rbg(uint32_t nof_prb)
{ {
return (uint32_t) ceil((float) nof_prb / P); return (uint32_t)ceil((float)nof_prb / P);
} }
uint32_t sched_ue::rgb_to_prb(uint32_t nof_rbg) uint32_t sched_ue::rgb_to_prb(uint32_t nof_rbg)
{ {
return P*nof_rbg; return P * nof_rbg;
} }
uint32_t sched_ue::get_required_prb_dl(uint32_t req_bytes, uint32_t nof_ctrl_symbols) uint32_t sched_ue::get_required_prb_dl(uint32_t req_bytes, uint32_t nof_ctrl_symbols)
@ -903,10 +908,10 @@ uint32_t sched_ue::get_required_prb_dl(uint32_t req_bytes, uint32_t nof_ctrl_sym
uint32_t nbytes = 0; uint32_t nbytes = 0;
uint32_t n; uint32_t n;
int mcs0 = (is_first_dl_tx() and cell.nof_prb == 6) ? MCS_FIRST_DL : fixed_mcs_dl; int mcs0 = (is_first_dl_tx() and cell.nof_prb == 6) ? MCS_FIRST_DL : fixed_mcs_dl;
for (n=0; n < cell.nof_prb && nbytes < req_bytes; ++n) { for (n = 0; n < cell.nof_prb && nbytes < req_bytes; ++n) {
nof_re = srslte_ra_dl_approx_nof_re(&cell, n + 1, nof_ctrl_symbols); nof_re = srslte_ra_dl_approx_nof_re(&cell, n + 1, nof_ctrl_symbols);
if (mcs0 < 0) { if (mcs0 < 0) {
tbs = alloc_tbs_dl(n+1, nof_re, 0, &mcs); tbs = alloc_tbs_dl(n + 1, nof_re, 0, &mcs);
} else { } else {
tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(mcs0, false), n + 1) / 8; tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(mcs0, false), n + 1) / 8;
} }
@ -934,7 +939,7 @@ uint32_t sched_ue::get_required_prb_ul(uint32_t req_bytes)
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
for (n = 1; n < cell.nof_prb && nbytes < req_bytes + 4; n++) { for (n = 1; n < cell.nof_prb && nbytes < req_bytes + 4; n++) {
uint32_t nof_re = (2*(SRSLTE_CP_NSYMB(cell.cp)-1) - N_srs)*n*SRSLTE_NRE; uint32_t nof_re = (2 * (SRSLTE_CP_NSYMB(cell.cp) - 1) - N_srs) * n * SRSLTE_NRE;
int tbs = 0; int tbs = 0;
if (fixed_mcs_ul < 0) { if (fixed_mcs_ul < 0) {
tbs = alloc_tbs_ul(n, nof_re, 0, &mcs); tbs = alloc_tbs_ul(n, nof_re, 0, &mcs);
@ -946,7 +951,7 @@ uint32_t sched_ue::get_required_prb_ul(uint32_t req_bytes)
} }
} }
while (!srslte_dft_precoding_valid_prb(n) && n<=cell.nof_prb) { while (!srslte_dft_precoding_valid_prb(n) && n <= cell.nof_prb) {
n++; n++;
} }
@ -966,7 +971,7 @@ void sched_ue::reset_pending_pids(uint32_t tti_rx)
get_ul_harq(tti_tx_ul)->reset_pending_data(); get_ul_harq(tti_tx_ul)->reset_pending_data();
// DL harqs // DL harqs
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
dl_harq[i].reset_pending_data(); dl_harq[i].reset_pending_data();
if (not dl_harq[i].is_empty()) { if (not dl_harq[i].is_empty()) {
uint32_t tti_diff = srslte_tti_interval(tti_tx_dl, dl_harq[i].get_tti()); uint32_t tti_diff = srslte_tti_interval(tti_tx_dl, dl_harq[i].get_tti());
@ -986,9 +991,9 @@ dl_harq_proc* sched_ue::get_pending_dl_harq(uint32_t tti)
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
int oldest_idx=-1; int oldest_idx = -1;
uint32_t oldest_tti = 0; uint32_t oldest_tti = 0;
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC; i++) {
if (dl_harq[i].has_pending_retx(0, tti) || dl_harq[i].has_pending_retx(1, tti)) { if (dl_harq[i].has_pending_retx(0, tti) || dl_harq[i].has_pending_retx(1, tti)) {
uint32_t x = srslte_tti_interval(tti, dl_harq[i].get_tti()); uint32_t x = srslte_tti_interval(tti, dl_harq[i].get_tti());
if (x > oldest_tti) { if (x > oldest_tti) {
@ -997,7 +1002,7 @@ dl_harq_proc* sched_ue::get_pending_dl_harq(uint32_t tti)
} }
} }
} }
dl_harq_proc *h = NULL; dl_harq_proc* h = NULL;
if (oldest_idx >= 0) { if (oldest_idx >= 0) {
h = &dl_harq[oldest_idx]; h = &dl_harq[oldest_idx];
} }
@ -1005,7 +1010,7 @@ dl_harq_proc* sched_ue::get_pending_dl_harq(uint32_t tti)
return h; return h;
#else #else
return &dl_harq[tti%SCHED_MAX_HARQ_PROC]; return &dl_harq[tti % SCHED_MAX_HARQ_PROC];
#endif #endif
} }
@ -1013,8 +1018,8 @@ dl_harq_proc* sched_ue::get_empty_dl_harq()
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
dl_harq_proc *h = NULL; dl_harq_proc* h = NULL;
for (int i=0;i<SCHED_MAX_HARQ_PROC && !h;i++) { for (int i = 0; i < SCHED_MAX_HARQ_PROC && !h; i++) {
if (dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1)) { if (dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1)) {
h = &dl_harq[i]; h = &dl_harq[i];
} }
@ -1042,7 +1047,8 @@ dl_harq_proc* sched_ue::get_dl_harq(uint32_t idx)
return &dl_harq[idx]; return &dl_harq[idx];
} }
srslte_dci_format_t sched_ue::get_dci_format() { srslte_dci_format_t sched_ue::get_dci_format()
{
srslte_dci_format_t ret = SRSLTE_DCI_FORMAT1; srslte_dci_format_t ret = SRSLTE_DCI_FORMAT1;
if (phy_config_dedicated_enabled) { if (phy_config_dedicated_enabled) {
@ -1072,15 +1078,14 @@ srslte_dci_format_t sched_ue::get_dci_format() {
return ret; return ret;
} }
/* Find lowest DCI aggregation level supported by the UE spectral efficiency */ /* Find lowest DCI aggregation level supported by the UE spectral efficiency */
uint32_t sched_ue::get_aggr_level(uint32_t nof_bits) uint32_t sched_ue::get_aggr_level(uint32_t nof_bits)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
uint32_t l=0; uint32_t l = 0;
float max_coderate = srslte_cqi_to_coderate(dl_cqi); float max_coderate = srslte_cqi_to_coderate(dl_cqi);
float coderate = 99; float coderate = 99;
float factor=1.5; float factor = 1.5;
uint32_t l_max = 3; uint32_t l_max = 3;
if (cell.nof_prb == 6) { if (cell.nof_prb == 6) {
factor = 1.0; factor = 1.0;
@ -1090,15 +1095,20 @@ uint32_t sched_ue::get_aggr_level(uint32_t nof_bits)
do { do {
coderate = srslte_pdcch_coderate(nof_bits, l); coderate = srslte_pdcch_coderate(nof_bits, l);
l++; l++;
} while(l<l_max && factor*coderate > max_coderate); } while (l < l_max && factor * coderate > max_coderate);
Debug("SCHED: CQI=%d, l=%d, nof_bits=%d, coderate=%.2f, max_coderate=%.2f\n", dl_cqi, l, nof_bits, coderate, max_coderate); Debug("SCHED: CQI=%d, l=%d, nof_bits=%d, coderate=%.2f, max_coderate=%.2f\n",
dl_cqi,
l,
nof_bits,
coderate,
max_coderate);
return l; return l;
} }
sched_ue::sched_dci_cce_t* sched_ue::get_locations(uint32_t cfi, uint32_t sf_idx) sched_ue::sched_dci_cce_t* sched_ue::get_locations(uint32_t cfi, uint32_t sf_idx)
{ {
if (cfi > 0 && cfi <= 3) { if (cfi > 0 && cfi <= 3) {
return &dci_locations[cfi-1][sf_idx]; return &dci_locations[cfi - 1][sf_idx];
} else { } else {
Error("SCHED: Invalid CFI=%d\n", cfi); Error("SCHED: Invalid CFI=%d\n", cfi);
return &dci_locations[0][sf_idx]; return &dci_locations[0][sf_idx];
@ -1111,7 +1121,7 @@ int sched_ue::alloc_pdu(int tbs_bytes, sched_interface::dl_sched_pdu_t* pdu)
// TODO: Implement lcid priority (now lowest index is lowest priority) // TODO: Implement lcid priority (now lowest index is lowest priority)
int x = 0; int x = 0;
int i = 0; int i = 0;
for (i=0;i<sched_interface::MAX_LC && !x;i++) { for (i = 0; i < sched_interface::MAX_LC && !x; i++) {
if (lch[i].buf_retx) { if (lch[i].buf_retx) {
x = SRSLTE_MIN(lch[i].buf_retx, tbs_bytes); x = SRSLTE_MIN(lch[i].buf_retx, tbs_bytes);
lch[i].buf_retx -= x; lch[i].buf_retx -= x;
@ -1121,22 +1131,23 @@ int sched_ue::alloc_pdu(int tbs_bytes, sched_interface::dl_sched_pdu_t* pdu)
} }
} }
if (x) { if (x) {
pdu->lcid = i-1; pdu->lcid = i - 1;
pdu->nbytes = x; pdu->nbytes = x;
Debug("SCHED: Allocated lcid=%d, nbytes=%d, tbs_bytes=%d\n", pdu->lcid, pdu->nbytes, tbs_bytes); Debug("SCHED: Allocated lcid=%d, nbytes=%d, tbs_bytes=%d\n", pdu->lcid, pdu->nbytes, tbs_bytes);
} }
return x; return x;
} }
uint32_t sched_ue::format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb) { uint32_t sched_ue::format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb)
{
uint32_t P = srslte_ra_type0_P(cell_nof_prb); uint32_t P = srslte_ra_type0_P(cell_nof_prb);
uint32_t nb = (int) ceilf((float) cell_nof_prb / P); uint32_t nb = (int)ceilf((float)cell_nof_prb / P);
uint32_t nof_prb = 0; uint32_t nof_prb = 0;
for (uint32_t i = 0; i < nb; i++) { for (uint32_t i = 0; i < nb; i++) {
if (bitmask & (1 << (nb - i - 1))) { if (bitmask & (1 << (nb - i - 1))) {
for (uint32_t j = 0; j < P; j++) { for (uint32_t j = 0; j < P; j++) {
if (i*P+j < cell_nof_prb) { if (i * P + j < cell_nof_prb) {
nof_prb++; nof_prb++;
} }
} }
@ -1145,8 +1156,8 @@ uint32_t sched_ue::format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb) {
return nof_prb; return nof_prb;
} }
int sched_ue::cqi_to_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t max_Qm, bool is_ul, int sched_ue::cqi_to_tbs(
uint32_t* mcs) uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t max_Qm, bool is_ul, uint32_t* mcs)
{ {
float max_coderate = srslte_cqi_to_coderate(cqi); float max_coderate = srslte_cqi_to_coderate(cqi);
int sel_mcs = max_mcs + 1; int sel_mcs = max_mcs + 1;
@ -1162,43 +1173,33 @@ int sched_ue::cqi_to_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32
coderate = srslte_coderate(tbs, nof_re); coderate = srslte_coderate(tbs, nof_re);
srslte_mod_t mod = (is_ul) ? srslte_ra_ul_mod_from_mcs(sel_mcs) : srslte_ra_dl_mod_from_mcs(sel_mcs); srslte_mod_t mod = (is_ul) ? srslte_ra_ul_mod_from_mcs(sel_mcs) : srslte_ra_dl_mod_from_mcs(sel_mcs);
Qm = SRSLTE_MIN(max_Qm, srslte_mod_bits_x_symbol(mod)); Qm = SRSLTE_MIN(max_Qm, srslte_mod_bits_x_symbol(mod));
eff_coderate = coderate/Qm; eff_coderate = coderate / Qm;
} while((sel_mcs > 0 && coderate > max_coderate) || eff_coderate > 0.930); } while ((sel_mcs > 0 && coderate > max_coderate) || eff_coderate > 0.930);
if (mcs) { if (mcs) {
*mcs = (uint32_t)sel_mcs; *mcs = (uint32_t)sel_mcs;
} }
return tbs; return tbs;
} }
int sched_ue::alloc_tbs_dl(uint32_t nof_prb, int sched_ue::alloc_tbs_dl(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int* mcs)
uint32_t nof_re,
uint32_t req_bytes,
int *mcs)
{ {
return alloc_tbs(nof_prb, nof_re, req_bytes, false, mcs); return alloc_tbs(nof_prb, nof_re, req_bytes, false, mcs);
} }
int sched_ue::alloc_tbs_ul(uint32_t nof_prb, int sched_ue::alloc_tbs_ul(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int* mcs)
uint32_t nof_re,
uint32_t req_bytes,
int *mcs)
{ {
return alloc_tbs(nof_prb, nof_re, req_bytes, true, mcs); return alloc_tbs(nof_prb, nof_re, req_bytes, true, mcs);
} }
/* In this scheduler we tend to use all the available bandwidth and select the MCS /* In this scheduler we tend to use all the available bandwidth and select the MCS
* that approximates the minimum between the capacity and the requested rate * that approximates the minimum between the capacity and the requested rate
*/ */
int sched_ue::alloc_tbs(uint32_t nof_prb, int sched_ue::alloc_tbs(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, bool is_ul, int* mcs)
uint32_t nof_re,
uint32_t req_bytes,
bool is_ul,
int *mcs)
{ {
uint32_t sel_mcs = 0; uint32_t sel_mcs = 0;
uint32_t cqi = is_ul?ul_cqi:dl_cqi; uint32_t cqi = is_ul ? ul_cqi : dl_cqi;
uint32_t max_mcs = is_ul?max_mcs_ul:max_mcs_dl; uint32_t max_mcs = is_ul ? max_mcs_ul : max_mcs_dl;
uint32_t max_Qm = is_ul ? 4 : 6; // Allow 16-QAM in PUSCH Only uint32_t max_Qm = is_ul ? 4 : 6; // Allow 16-QAM in PUSCH Only
// TODO: Compute real spectral efficiency based on PUSCH-UCI configuration // TODO: Compute real spectral efficiency based on PUSCH-UCI configuration
@ -1222,11 +1223,10 @@ int sched_ue::alloc_tbs(uint32_t nof_prb,
} }
if (mcs && tbs_bytes >= 0) { if (mcs && tbs_bytes >= 0) {
*mcs = (int) sel_mcs; *mcs = (int)sel_mcs;
} }
return tbs_bytes; return tbs_bytes;
} }
} // namespace srsenb
}

Loading…
Cancel
Save