use utility macro for printing function name

master
Francisco Paisana 5 years ago
parent f09c8324eb
commit d18b476e37

@ -139,7 +139,7 @@ public:
protected: protected:
// Helper methods // Helper methods
template <typename Func> template <typename Func>
int ue_db_access(uint16_t rnti, Func); int ue_db_access(uint16_t rnti, Func, const char* func_name = nullptr);
// args // args
srslte::log_ref log_h; srslte::log_ref log_h;

@ -229,20 +229,13 @@ bool sched::ue_exists(uint16_t rnti)
void sched::ue_needs_ta_cmd(uint16_t rnti, uint32_t nof_ta_cmd) void sched::ue_needs_ta_cmd(uint16_t rnti, uint32_t nof_ta_cmd)
{ {
std::lock_guard<std::mutex> lock(sched_mutex); ue_db_access(rnti, [nof_ta_cmd](sched_ue& ue) { ue.set_needs_ta_cmd(nof_ta_cmd); }, __PRETTY_FUNCTION__);
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_needs_ta_cmd(nof_ta_cmd);
} else {
Error("User rnti=0x%x not found\n", rnti);
}
} }
void sched::phy_config_enabled(uint16_t rnti, bool enabled) void sched::phy_config_enabled(uint16_t rnti, bool enabled)
{ {
// TODO: Check if correct use of last_tti // TODO: Check if correct use of last_tti
if (ue_db_access(rnti, [this, enabled](sched_ue& ue) { ue.phy_config_enabled(last_tti, enabled); })) { ue_db_access(rnti, [this, enabled](sched_ue& ue) { ue.phy_config_enabled(last_tti, enabled); }, __PRETTY_FUNCTION__);
Error("Error calling phy_config_enabled, user not found\n");
}
} }
int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg_) int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg_)
@ -258,29 +251,22 @@ int sched::bearer_ue_rem(uint16_t rnti, uint32_t lc_id)
uint32_t sched::get_dl_buffer(uint16_t rnti) uint32_t sched::get_dl_buffer(uint16_t rnti)
{ {
// TODO: Check if correct use of last_tti // TODO: Check if correct use of last_tti
uint32_t ret = 0; uint32_t ret = SRSLTE_ERROR;
if (ue_db_access(rnti, [&ret](sched_ue& ue) { ret = ue.get_pending_dl_new_data(); })) { ue_db_access(rnti, [&ret](sched_ue& ue) { ret = ue.get_pending_dl_new_data(); }, __PRETTY_FUNCTION__);
Error("Error calling get_dl_buffer, user not found\n");
ret = SRSLTE_ERROR;
}
return ret; return ret;
} }
uint32_t sched::get_ul_buffer(uint16_t rnti) uint32_t sched::get_ul_buffer(uint16_t rnti)
{ {
// TODO: Check if correct use of last_tti // TODO: Check if correct use of last_tti
uint32_t ret = SRSLTE_SUCCESS; uint32_t ret = SRSLTE_ERROR;
if (ue_db_access(rnti, [this, &ret](sched_ue& ue) { ret = ue.get_pending_ul_new_data(last_tti); })) { ue_db_access(rnti, [this, &ret](sched_ue& ue) { ret = ue.get_pending_ul_new_data(last_tti); }, __PRETTY_FUNCTION__);
Error("Error calling get_ul_buffer, user not found\n");
ret = SRSLTE_ERROR;
}
return ret; return ret;
} }
int sched::dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) int sched::dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue)
{ {
return ue_db_access(rnti, return ue_db_access(rnti, [&](sched_ue& ue) { ue.dl_buffer_state(lc_id, tx_queue, retx_queue); });
[lc_id, tx_queue, retx_queue](sched_ue& ue) { ue.dl_buffer_state(lc_id, tx_queue, retx_queue); });
} }
int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code) int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code)
@ -291,10 +277,7 @@ int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code)
int sched::dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) int sched::dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack)
{ {
int ret = -1; int ret = -1;
if (ue_db_access( ue_db_access(rnti, [&](sched_ue& ue) { ret = ue.set_ack_info(tti, enb_cc_idx, tb_idx, ack); }, __PRETTY_FUNCTION__);
rnti, [tti, enb_cc_idx, tb_idx, ack, &ret](sched_ue& ue) { ret = ue.set_ack_info(tti, enb_cc_idx, tb_idx, ack); })) {
Error("Error calling dl_ack_info, user not found\n");
}
return ret; return ret;
} }
@ -326,8 +309,7 @@ int sched::dl_rach_info(uint32_t enb_cc_idx, dl_sched_rar_info_t rar_info)
int sched::ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi, uint32_t ul_ch_code) int sched::ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi, uint32_t ul_ch_code)
{ {
return ue_db_access( return ue_db_access(rnti, [&](sched_ue& ue) { ue.set_ul_cqi(tti, enb_cc_idx, cqi, ul_ch_code); });
rnti, [tti, enb_cc_idx, cqi, ul_ch_code](sched_ue& ue) { ue.set_ul_cqi(tti, enb_cc_idx, cqi, ul_ch_code); });
} }
int sched::ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value) int sched::ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value)
@ -337,17 +319,17 @@ int sched::ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value)
int sched::ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len) int sched::ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len)
{ {
return ue_db_access(rnti, [lcid, len](sched_ue& ue) { ue.ul_recv_len(lcid, len); }); return ue_db_access(rnti, [lcid, len](sched_ue& ue) { ue.ul_recv_len(lcid, len); }, __PRETTY_FUNCTION__);
} }
int sched::ul_phr(uint16_t rnti, int phr) int sched::ul_phr(uint16_t rnti, int phr)
{ {
return ue_db_access(rnti, [phr](sched_ue& ue) { ue.ul_phr(phr); }); return ue_db_access(rnti, [phr](sched_ue& ue) { ue.ul_phr(phr); }, __PRETTY_FUNCTION__);
} }
int sched::ul_sr_info(uint32_t tti, uint16_t rnti) int sched::ul_sr_info(uint32_t tti, uint16_t rnti)
{ {
return ue_db_access(rnti, [](sched_ue& ue) { ue.set_sr(); }); return ue_db_access(rnti, [](sched_ue& ue) { ue.set_sr(); }, __PRETTY_FUNCTION__);
} }
void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs)
@ -358,30 +340,28 @@ void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs)
void sched::tpc_inc(uint16_t rnti) void sched::tpc_inc(uint16_t rnti)
{ {
if (ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_inc(); })) { ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_inc(); }, __PRETTY_FUNCTION__);
Error("Error calling tpc_inc, user not found\n");
}
} }
void sched::tpc_dec(uint16_t rnti) void sched::tpc_dec(uint16_t rnti)
{ {
if (ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_dec(); })) { ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_dec(); }, __PRETTY_FUNCTION__);
Error("Error calling tpc_dec, user not found\n");
}
} }
std::array<int, SRSLTE_MAX_CARRIERS> sched::get_enb_ue_cc_map(uint16_t rnti) std::array<int, SRSLTE_MAX_CARRIERS> sched::get_enb_ue_cc_map(uint16_t rnti)
{ {
std::array<int, SRSLTE_MAX_CARRIERS> ret{}; std::array<int, SRSLTE_MAX_CARRIERS> ret{};
ret.fill(-1); // -1 for inactive carriers ret.fill(-1); // -1 for inactive carriers
ue_db_access(rnti, [this, &ret](sched_ue& ue) { ue_db_access(rnti,
for (size_t enb_cc_idx = 0; enb_cc_idx < carrier_schedulers.size(); ++enb_cc_idx) { [this, &ret](sched_ue& ue) {
auto p = ue.get_cell_index(enb_cc_idx); for (size_t enb_cc_idx = 0; enb_cc_idx < carrier_schedulers.size(); ++enb_cc_idx) {
if (p.second < SRSLTE_MAX_CARRIERS) { auto p = ue.get_cell_index(enb_cc_idx);
ret[enb_cc_idx] = p.second; if (p.second < SRSLTE_MAX_CARRIERS) {
} ret[enb_cc_idx] = p.second;
} }
}); }
},
__PRETTY_FUNCTION__);
return ret; return ret;
} }
@ -436,14 +416,18 @@ int sched::ul_sched(uint32_t tti, uint32_t cc_idx, srsenb::sched_interface::ul_s
// Common way to access ue_db elements in a read locking way // Common way to access ue_db elements in a read locking way
template <typename Func> template <typename Func>
int sched::ue_db_access(uint16_t rnti, Func f) int sched::ue_db_access(uint16_t rnti, Func f, const char* func_name)
{ {
std::lock_guard<std::mutex> lock(sched_mutex); std::lock_guard<std::mutex> lock(sched_mutex);
auto it = ue_db.find(rnti); auto it = ue_db.find(rnti);
if (it != ue_db.end()) { if (it != ue_db.end()) {
f(it->second); f(it->second);
} else { } else {
Error("User rnti=0x%x not found\n", rnti); if (func_name != nullptr) {
Error("User rnti=0x%x not found. Failed to call %s.\n", rnti, func_name);
} else {
Error("User rnti=0x%x not found.\n", rnti);
}
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

Loading…
Cancel
Save