Port misc SSN changes to dev.

master
faluco 3 years ago committed by faluco
parent 0ee82ed0f6
commit 453a7760b3

@ -291,7 +291,7 @@ public:
} }
return obj; return obj;
} }
bool pop_wait_until(T& obj, const std::chrono::system_clock::time_point& until) { return pop_(obj, true, &until); } bool pop_wait_until(T& obj, const std::chrono::steady_clock::time_point& until) { return pop_(obj, true, &until); }
void clear() void clear()
{ {
T obj; T obj;
@ -405,7 +405,7 @@ protected:
return {}; return {};
} }
bool pop_(T& obj, bool block, const std::chrono::system_clock::time_point* until = nullptr) bool pop_(T& obj, bool block, const std::chrono::steady_clock::time_point* until = nullptr)
{ {
std::unique_lock<std::mutex> lock(mutex); std::unique_lock<std::mutex> lock(mutex);
if (not active) { if (not active) {

@ -95,6 +95,8 @@ public:
return value; return value;
} }
bool timedwait_pop(myobj* value, const struct timespec* abstime) { return pop_(value, true, abstime); }
bool empty() bool empty()
{ // queue is empty? { // queue is empty?
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
@ -130,7 +132,7 @@ public:
} }
private: private:
bool pop_(myobj* value, bool block) bool pop_(myobj* value, bool block, const struct timespec* abstime = nullptr)
{ {
if (!enable) { if (!enable) {
return false; return false;
@ -142,7 +144,13 @@ private:
goto exit; goto exit;
} }
while (q.empty() && enable) { while (q.empty() && enable) {
if (abstime == nullptr) {
pthread_cond_wait(&cv_empty, &mutex); pthread_cond_wait(&cv_empty, &mutex);
} else {
if (pthread_cond_timedwait(&cv_empty, &mutex, abstime)) {
goto exit;
}
}
} }
if (!enable) { if (!enable) {
goto exit; goto exit;

@ -80,7 +80,9 @@ bool threads_new_rt_cpu(pthread_t* thread, void* (*start_routine)(void*), void*
#else #else
// All threads have normal priority except prio_offset=0,1,2,3,4 // All threads have normal priority except prio_offset=0,1,2,3,4
if (prio_offset >= 0 && prio_offset < 5) { if (prio_offset >= 0 && prio_offset < 5) {
param.sched_priority = sched_get_priority_max(SCHED_FIFO) - prio_offset; // Subtract one to the priority offset to avoid scheduling threads with the highest priority that could contend with
// OS critical tasks.
param.sched_priority = sched_get_priority_max(SCHED_FIFO) - prio_offset - 1;
if (pthread_attr_init(&attr)) { if (pthread_attr_init(&attr)) {
perror("pthread_attr_init"); perror("pthread_attr_init");
} else { } else {

@ -13,6 +13,8 @@
#ifndef SRSENB_PHY_METRICS_H #ifndef SRSENB_PHY_METRICS_H
#define SRSENB_PHY_METRICS_H #define SRSENB_PHY_METRICS_H
#include <limits>
namespace srsenb { namespace srsenb {
// PHY metrics per user // PHY metrics per user
@ -20,7 +22,15 @@ namespace srsenb {
struct ul_metrics_t { struct ul_metrics_t {
float n; float n;
float pusch_sinr; float pusch_sinr;
// Initialize this member with an invalid value as this field is optional.
float pusch_rssi = std::numeric_limits<float>::quiet_NaN();
// Initialize this member with an invalid value as this field is optional.
int64_t pusch_tpc = 0;
float pucch_sinr; float pucch_sinr;
// Initialize this member with an invalid value as this field is optional.
float pucch_rssi = std::numeric_limits<float>::quiet_NaN();
// Initialize this member with an invalid value as this field is optional.
float pucch_ni = std::numeric_limits<float>::quiet_NaN();
float rssi; float rssi;
float turbo_iters; float turbo_iters;
float mcs; float mcs;
@ -30,6 +40,8 @@ struct ul_metrics_t {
struct dl_metrics_t { struct dl_metrics_t {
float mcs; float mcs;
// Initialize this member with an invalid value as this field is optional.
int64_t pucch_tpc = 0;
int n_samples; int n_samples;
}; };

@ -21,6 +21,7 @@ namespace srsenb {
/// MAC metrics per user /// MAC metrics per user
struct mac_ue_metrics_t { struct mac_ue_metrics_t {
uint16_t rnti; uint16_t rnti;
uint32_t pci;
uint32_t nof_tti; uint32_t nof_tti;
uint32_t cc_idx; uint32_t cc_idx;
int tx_pkts; int tx_pkts;
@ -35,6 +36,8 @@ struct mac_ue_metrics_t {
float dl_ri; float dl_ri;
float dl_pmi; float dl_pmi;
float phr; float phr;
float dl_cqi_offset;
float ul_snr_offset;
// NR-only UL PHY metrics // NR-only UL PHY metrics
float pusch_sinr; float pusch_sinr;

@ -77,6 +77,7 @@ public:
std::array<int, SRSRAN_MAX_CARRIERS> get_enb_ue_cc_map(uint16_t rnti) final; std::array<int, SRSRAN_MAX_CARRIERS> get_enb_ue_cc_map(uint16_t rnti) final;
std::array<int, SRSRAN_MAX_CARRIERS> get_enb_ue_activ_cc_map(uint16_t rnti) final; std::array<int, SRSRAN_MAX_CARRIERS> get_enb_ue_activ_cc_map(uint16_t rnti) final;
int ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes) final; int ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes) final;
int metrics_read(uint16_t rnti, mac_ue_metrics_t& metrics);
class carrier_sched; class carrier_sched;

@ -18,6 +18,7 @@
#include "sched_ue_ctrl/sched_ue_cell.h" #include "sched_ue_ctrl/sched_ue_cell.h"
#include "sched_ue_ctrl/tpc.h" #include "sched_ue_ctrl/tpc.h"
#include "srsenb/hdr/common/common_enb.h" #include "srsenb/hdr/common/common_enb.h"
#include "srsenb/hdr/stack/mac/common/mac_metrics.h"
#include "srsran/srslog/srslog.h" #include "srsran/srslog/srslog.h"
#include <bitset> #include <bitset>
#include <map> #include <map>
@ -73,6 +74,7 @@ public:
const ue_cfg_t& get_ue_cfg() const { return cfg; } const ue_cfg_t& get_ue_cfg() const { return cfg; }
uint32_t get_aggr_level(uint32_t enb_cc_idx, uint32_t nof_bits); uint32_t get_aggr_level(uint32_t enb_cc_idx, uint32_t nof_bits);
void ul_buffer_add(uint8_t lcid, uint32_t bytes); void ul_buffer_add(uint8_t lcid, uint32_t bytes);
void metrics_read(mac_ue_metrics_t& metrics);
/******************************************************* /*******************************************************
* Functions used by scheduler metric objects * Functions used by scheduler metric objects

@ -43,6 +43,8 @@ struct sched_ue_cell {
const ue_cc_cfg* get_ue_cc_cfg() const { return configured() ? &ue_cfg->supported_cc_list[ue_cc_idx] : nullptr; } const ue_cc_cfg* get_ue_cc_cfg() const { return configured() ? &ue_cfg->supported_cc_list[ue_cc_idx] : nullptr; }
const sched_interface::ue_cfg_t* get_ue_cfg() const { return configured() ? ue_cfg : nullptr; } const sched_interface::ue_cfg_t* get_ue_cfg() const { return configured() ? ue_cfg : nullptr; }
cc_st cc_state() const { return cc_state_; } cc_st cc_state() const { return cc_state_; }
float get_ul_snr_offset() const { return ul_snr_coeff; }
float get_dl_cqi_offset() const { return dl_cqi_coeff; }
int get_dl_cqi() const; int get_dl_cqi() const;
int get_dl_cqi(const rbgmask_t& rbgs) const; int get_dl_cqi(const rbgmask_t& rbgs) const;

@ -45,6 +45,13 @@ DECLARE_METRIC("dl_bitrate", metric_dl_bitrate, float, "");
DECLARE_METRIC("dl_bler", metric_dl_bler, float, ""); DECLARE_METRIC("dl_bler", metric_dl_bler, float, "");
DECLARE_METRIC("ul_snr", metric_ul_snr, float, ""); DECLARE_METRIC("ul_snr", metric_ul_snr, float, "");
DECLARE_METRIC("ul_mcs", metric_ul_mcs, float, ""); DECLARE_METRIC("ul_mcs", metric_ul_mcs, float, "");
DECLARE_METRIC("ul_pusch_rssi", metric_ul_pusch_rssi, float, "");
DECLARE_METRIC("ul_pucch_rssi", metric_ul_pucch_rssi, float, "");
DECLARE_METRIC("ul_pucch_ni", metric_ul_pucch_ni, float, "");
DECLARE_METRIC("ul_pusch_tpc", metric_ul_pusch_tpc, int64_t, "");
DECLARE_METRIC("ul_pucch_tpc", metric_ul_pucch_tpc, int64_t, "");
DECLARE_METRIC("dl_cqi_offset", metric_dl_cqi_offset, float, "");
DECLARE_METRIC("ul_snr_offset", metric_ul_snr_offset, float, "");
DECLARE_METRIC("ul_bitrate", metric_ul_bitrate, float, ""); DECLARE_METRIC("ul_bitrate", metric_ul_bitrate, float, "");
DECLARE_METRIC("ul_bler", metric_ul_bler, float, ""); DECLARE_METRIC("ul_bler", metric_ul_bler, float, "");
DECLARE_METRIC("ul_phr", metric_ul_phr, float, ""); DECLARE_METRIC("ul_phr", metric_ul_phr, float, "");
@ -55,6 +62,13 @@ DECLARE_METRIC_SET("ue_container",
metric_ue_rnti, metric_ue_rnti,
metric_dl_cqi, metric_dl_cqi,
metric_dl_mcs, metric_dl_mcs,
metric_ul_pusch_rssi,
metric_ul_pucch_rssi,
metric_ul_pucch_ni,
metric_ul_pusch_tpc,
metric_ul_pucch_tpc,
metric_dl_cqi_offset,
metric_ul_snr_offset,
metric_dl_bitrate, metric_dl_bitrate,
metric_dl_bler, metric_dl_bler,
metric_ul_snr, metric_ul_snr,
@ -88,24 +102,40 @@ static void fill_ue_metrics(mset_ue_container& ue, const enb_metrics_t& m, unsig
ue.write<metric_ue_rnti>(m.stack.mac.ues[i].rnti); ue.write<metric_ue_rnti>(m.stack.mac.ues[i].rnti);
ue.write<metric_dl_cqi>(std::max(0.1f, m.stack.mac.ues[i].dl_cqi)); ue.write<metric_dl_cqi>(std::max(0.1f, m.stack.mac.ues[i].dl_cqi));
if (!std::isnan(m.phy[i].dl.mcs)) { if (!std::isnan(m.phy[i].dl.mcs)) {
ue.write<metric_dl_mcs>(std::max(0.1f, m.phy[i].dl.mcs)); ue.write<metric_dl_mcs>(m.phy[i].dl.mcs);
} }
if (m.stack.mac.ues[i].tx_brate > 0 && m.stack.mac.ues[i].nof_tti > 0) { if (m.stack.mac.ues[i].tx_brate > 0 && m.stack.mac.ues[i].nof_tti > 0) {
ue.write<metric_dl_bitrate>( ue.write<metric_dl_bitrate>(
std::max(0.1f, (float)m.stack.mac.ues[i].tx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f))); std::max(0.1f, (float)m.stack.mac.ues[i].tx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f)));
} }
if (m.stack.mac.ues[i].tx_pkts > 0 && m.stack.mac.ues[i].tx_errors > 0) { if (m.stack.mac.ues[i].tx_pkts > 0 && m.stack.mac.ues[i].tx_errors > 0) {
ue.write<metric_dl_bler>(std::max(0.1f, (float)100 * m.stack.mac.ues[i].tx_errors / m.stack.mac.ues[i].tx_pkts)); ue.write<metric_dl_bler>((float)100 * m.stack.mac.ues[i].tx_errors / m.stack.mac.ues[i].tx_pkts);
} }
if (!std::isnan(m.phy[i].ul.pusch_sinr)) { if (!std::isnan(m.phy[i].ul.pusch_sinr)) {
ue.write<metric_ul_snr>(std::max(0.1f, m.phy[i].ul.pusch_sinr)); ue.write<metric_ul_snr>(m.phy[i].ul.pusch_sinr);
}
if (!std::isnan(m.phy[i].ul.pusch_rssi)) {
ue.write<metric_ul_pusch_rssi>(m.phy[i].ul.pusch_rssi);
}
if (!std::isnan(m.phy[i].ul.pucch_rssi)) {
ue.write<metric_ul_pucch_rssi>(m.phy[i].ul.pucch_rssi);
}
if (!std::isnan(m.phy[i].ul.pucch_ni)) {
ue.write<metric_ul_pucch_ni>(m.phy[i].ul.pucch_ni);
}
ue.write<metric_ul_pusch_tpc>(m.phy[i].ul.pusch_tpc);
ue.write<metric_ul_pucch_tpc>(m.phy[i].dl.pucch_tpc);
if (!std::isnan(m.stack.mac.ues[i].dl_cqi_offset)) {
ue.write<metric_dl_cqi_offset>(m.stack.mac.ues[i].dl_cqi_offset);
}
if (!std::isnan(m.stack.mac.ues[i].ul_snr_offset)) {
ue.write<metric_ul_snr_offset>(m.stack.mac.ues[i].ul_snr_offset);
} }
if (!std::isnan(m.phy[i].ul.mcs)) { if (!std::isnan(m.phy[i].ul.mcs)) {
ue.write<metric_ul_mcs>(std::max(0.1f, m.phy[i].ul.mcs)); ue.write<metric_ul_mcs>(m.phy[i].ul.mcs);
} }
if (m.stack.mac.ues[i].rx_brate > 0 && m.stack.mac.ues[i].nof_tti > 0) { if (m.stack.mac.ues[i].rx_brate > 0 && m.stack.mac.ues[i].nof_tti > 0) {
ue.write<metric_ul_bitrate>( ue.write<metric_ul_bitrate>((float)m.stack.mac.ues[i].rx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f));
std::max(0.1f, (float)m.stack.mac.ues[i].rx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f)));
} }
if (m.stack.mac.ues[i].rx_pkts > 0 && m.stack.mac.ues[i].rx_errors > 0) { if (m.stack.mac.ues[i].rx_pkts > 0 && m.stack.mac.ues[i].rx_errors > 0) {
ue.write<metric_ul_bler>(std::max(0.1f, (float)100 * m.stack.mac.ues[i].rx_errors / m.stack.mac.ues[i].rx_pkts)); ue.write<metric_ul_bler>(std::max(0.1f, (float)100 * m.stack.mac.ues[i].rx_errors / m.stack.mac.ues[i].rx_pkts));

@ -88,6 +88,7 @@ void metrics_stdout::set_metrics_helper(uint32_t num_ue
fmt::print("rx caution errors {} > {}\n", mac.ues[i].rx_errors, mac.ues[i].rx_pkts); fmt::print("rx caution errors {} > {}\n", mac.ues[i].rx_errors, mac.ues[i].rx_pkts);
} }
fmt::print("{:>4}", mac.ues[i].pci);
fmt::print(" {:>3.5}", (is_nr) ? "nr" : "lte"); fmt::print(" {:>3.5}", (is_nr) ? "nr" : "lte");
fmt::print("{:>5x}", mac.ues[i].rnti); fmt::print("{:>5x}", mac.ues[i].rnti);
if (not iszero(mac.ues[i].dl_cqi)) { if (not iszero(mac.ues[i].dl_cqi)) {
@ -185,8 +186,10 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
if (++n_reports > 10) { if (++n_reports > 10) {
n_reports = 0; n_reports = 0;
fmt::print("\n"); fmt::print("\n");
fmt::print(" -----------------DL----------------|-------------------------UL-------------------------\n"); fmt::print(
fmt::print("rat rnti cqi ri mcs brate ok nok (%) | pusch pucch phr mcs brate ok nok (%) bsr\n"); " -----------------DL----------------|-------------------------UL-------------------------\n");
fmt::print(
" pci rat rnti cqi ri mcs brate ok nok (%) | pusch pucch phr mcs brate ok nok (%) bsr\n");
} }
set_metrics_helper(metrics.stack.rrc.ues.size(), metrics.stack.mac, metrics.phy, false); set_metrics_helper(metrics.stack.rrc.ues.size(), metrics.stack.mac, metrics.phy, false);

@ -241,7 +241,11 @@ void mac::get_metrics(mac_metrics_t& metrics)
continue; continue;
} }
metrics.ues.emplace_back(); metrics.ues.emplace_back();
u.second->metrics_read(&metrics.ues.back()); auto& ue_metrics = metrics.ues.back();
u.second->metrics_read(&ue_metrics);
scheduler.metrics_read(u.first, ue_metrics);
ue_metrics.pci = (ue_metrics.cc_idx < cell_config.size()) ? cell_config[ue_metrics.cc_idx].cell.id : 0;
} }
metrics.cc_info.resize(detected_rachs.size()); metrics.cc_info.resize(detected_rachs.size());
for (unsigned cc = 0, e = detected_rachs.size(); cc != e; ++cc) { for (unsigned cc = 0, e = detected_rachs.size(); cc != e; ++cc) {
@ -570,11 +574,22 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx
// Trigger scheduler RACH // Trigger scheduler RACH
scheduler.dl_rach_info(enb_cc_idx, rar_info); scheduler.dl_rach_info(enb_cc_idx, rar_info);
logger.info( auto get_pci = [this, enb_cc_idx]() {
"RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x", tti, enb_cc_idx, preamble_idx, time_adv, rnti); srsran::rwlock_read_guard lock(rwlock);
srsran::console("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", return (enb_cc_idx < cell_config.size()) ? cell_config[enb_cc_idx].cell.id : 0;
};
uint32_t pci = get_pci();
logger.info("RACH: tti=%d, cc=%d, pci=%d, preamble=%d, offset=%d, temp_crnti=0x%x",
tti,
enb_cc_idx,
pci,
preamble_idx,
time_adv,
rnti);
srsran::console("RACH: tti=%d, cc=%d, pci=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n",
tti, tti,
enb_cc_idx, enb_cc_idx,
pci,
preamble_idx, preamble_idx,
time_adv, time_adv,
rnti); rnti);

@ -361,6 +361,12 @@ bool sched::is_generated(srsran::tti_point tti_rx, uint32_t enb_cc_idx) const
return sched_results.has_sf(tti_rx) and sched_results.get_sf(tti_rx)->is_generated(enb_cc_idx); return sched_results.has_sf(tti_rx) and sched_results.get_sf(tti_rx)->is_generated(enb_cc_idx);
} }
int sched::metrics_read(uint16_t rnti, mac_ue_metrics_t& metrics)
{
return ue_db_access_locked(
rnti, [&metrics](sched_ue& ue) { ue.metrics_read(metrics); }, "metrics_read");
}
// 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_locked(uint16_t rnti, Func&& f, const char* func_name, bool log_fail) int sched::ue_db_access_locked(uint16_t rnti, Func&& f, const char* func_name, bool log_fail)

@ -854,9 +854,9 @@ void sf_sched::set_ul_sched_result(const sf_cch_allocator::alloc_result_t& dci_r
uint32_t old_pending_bytes = user->get_pending_ul_old_data(); uint32_t old_pending_bytes = user->get_pending_ul_old_data();
if (logger.info.enabled()) { if (logger.info.enabled()) {
fmt::memory_buffer str_buffer; fmt::memory_buffer str_buffer;
fmt::format_to( fmt::format_to(str_buffer,
str_buffer, "SCHED: {} {} rnti=0x{:x}, cc={}, pid={}, dci=({},{}), prb={}, n_rtx={}, cfi={}, tbs={}, bsr={} "
"SCHED: {} {} rnti=0x{:x}, cc={}, pid={}, dci=({},{}), prb={}, n_rtx={}, cfi={}, tbs={}, bsr={} ({}-{})", "({}-{}), tti_tx_ul={}",
ul_alloc.is_msg3 ? "Msg3" : "UL", ul_alloc.is_msg3 ? "Msg3" : "UL",
ul_alloc.is_retx() ? "retx" : "tx", ul_alloc.is_retx() ? "retx" : "tx",
user->get_rnti(), user->get_rnti(),
@ -870,7 +870,8 @@ void sf_sched::set_ul_sched_result(const sf_cch_allocator::alloc_result_t& dci_r
tbs, tbs,
new_pending_bytes, new_pending_bytes,
total_data_before, total_data_before,
old_pending_bytes); old_pending_bytes,
get_tti_tx_ul().to_uint());
logger.info("%s", srsran::to_c_str(str_buffer)); logger.info("%s", srsran::to_c_str(str_buffer));
} }

@ -164,6 +164,13 @@ void sched_ue::unset_sr()
sr = false; sr = false;
} }
void sched_ue::metrics_read(mac_ue_metrics_t& metrics)
{
sched_ue_cell& pcell = cells[cfg.supported_cc_list[0].enb_cc_idx];
metrics.ul_snr_offset = pcell.get_ul_snr_offset();
metrics.dl_cqi_offset = pcell.get_dl_cqi_offset();
}
tti_point prev_meas_gap_start(tti_point tti, uint32_t period, uint32_t offset) tti_point prev_meas_gap_start(tti_point tti, uint32_t period, uint32_t offset)
{ {
return tti_point{static_cast<uint32_t>(floor(static_cast<float>((tti - offset).to_uint()) / period)) * period + return tti_point{static_cast<uint32_t>(floor(static_cast<float>((tti - offset).to_uint()) / period)) * period +

@ -75,14 +75,17 @@ void rlc::add_user(uint16_t rnti)
void rlc::rem_user(uint16_t rnti) void rlc::rem_user(uint16_t rnti)
{ {
pthread_rwlock_wrlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
users[rnti].rlc->stop(); users[rnti].rlc->stop();
users.erase(rnti);
} else { } else {
logger.error("Removing rnti=0x%x. Already removed", rnti); logger.error("Removing rnti=0x%x. Already removed", rnti);
} }
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
pthread_rwlock_wrlock(&rwlock);
users.erase(rnti);
pthread_rwlock_unlock(&rwlock);
} }
void rlc::clear_buffer(uint16_t rnti) void rlc::clear_buffer(uint16_t rnti)

Loading…
Cancel
Save