srsLTE/srsue/hdr/phy/phy_metrics.h

176 lines
3.4 KiB
C
Raw Normal View History

/**
2017-05-30 06:38:04 -07:00
*
* \section COPYRIGHT
2017-05-30 06:38:04 -07:00
*
2021-03-19 03:45:56 -07:00
* Copyright 2013-2021 Software Radio Systems Limited
2017-05-30 06:38:04 -07:00
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
2017-05-30 06:38:04 -07:00
*
*/
2018-03-31 10:04:04 -07:00
#ifndef SRSUE_PHY_METRICS_H
#define SRSUE_PHY_METRICS_H
2017-05-30 06:38:04 -07:00
2021-03-19 03:45:56 -07:00
#include "srsran/srsran.h"
2021-04-13 03:21:26 -07:00
#include <array>
2017-05-30 06:38:04 -07:00
namespace srsue {
2019-12-03 01:34:00 -08:00
struct info_metrics_t {
2021-04-13 03:21:26 -07:00
typedef std::array<info_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
2021-04-12 13:48:25 -07:00
2019-12-03 01:34:00 -08:00
uint32_t pci;
uint32_t dl_earfcn;
};
2021-04-12 13:48:25 -07:00
#define PHY_METRICS_SET(PARAM) \
do { \
PARAM = SRSRAN_VEC_SAFE_CMA(other.PARAM, PARAM, count); \
2021-04-12 13:48:25 -07:00
} while (false)
struct sync_metrics_t {
2021-04-13 03:21:26 -07:00
typedef std::array<sync_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
2021-04-12 13:48:25 -07:00
2018-05-10 19:49:00 -07:00
float ta_us;
2021-03-09 04:08:36 -08:00
float distance_km;
float speed_kmph;
2017-05-30 06:38:04 -07:00
float cfo;
float sfo;
2021-04-12 13:48:25 -07:00
void set(const sync_metrics_t& other)
{
ta_us = other.ta_us;
distance_km = other.distance_km;
speed_kmph = other.speed_kmph;
PHY_METRICS_SET(cfo);
PHY_METRICS_SET(sfo);
count++;
2021-04-12 13:48:25 -07:00
}
void reset()
{
count = 0;
ta_us = 0.0f;
distance_km = 0.0f;
speed_kmph = 0.0f;
cfo = 0.0f;
sfo = 0.0f;
}
private:
uint32_t count = 0;
2017-05-30 06:38:04 -07:00
};
struct ch_metrics_t {
2021-04-13 03:21:26 -07:00
typedef std::array<ch_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
2021-04-12 13:48:25 -07:00
2017-05-30 06:38:04 -07:00
float n;
float sinr;
float rsrp;
float rsrq;
float rssi;
2019-01-03 11:33:53 -08:00
float ri;
2017-05-30 06:38:04 -07:00
float pathloss;
float sync_err;
2021-04-12 13:48:25 -07:00
void set(const ch_metrics_t& other)
{
count++;
PHY_METRICS_SET(n);
// We exclude inf and nan from the average SINR
if (!std::isnan(other.sinr) || !std::isinf(other.sinr)) {
PHY_METRICS_SET(sinr);
}
2021-04-12 13:48:25 -07:00
PHY_METRICS_SET(rsrp);
PHY_METRICS_SET(rsrq);
PHY_METRICS_SET(rssi);
PHY_METRICS_SET(ri);
PHY_METRICS_SET(pathloss);
PHY_METRICS_SET(sync_err);
}
void reset()
{
count = 0;
n = 0.0;
sinr = 0.0;
rsrp = 0.0;
rsrq = 0.0;
rssi = 0.0;
ri = 0.0;
pathloss = 0.0;
sync_err = 0.0;
}
private:
uint32_t count = 0;
2017-05-30 06:38:04 -07:00
};
struct dl_metrics_t {
2021-04-13 03:21:26 -07:00
typedef std::array<dl_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
2021-04-12 13:48:25 -07:00
float fec_iters;
float mcs;
2021-04-12 13:48:25 -07:00
float evm;
void set(const dl_metrics_t& other)
{
count++;
PHY_METRICS_SET(fec_iters);
PHY_METRICS_SET(mcs);
PHY_METRICS_SET(evm);
}
void reset()
{
count = 0;
fec_iters = 0.0f;
mcs = 0.0f;
evm = 0.0f;
}
private:
uint32_t count = 0;
};
struct ul_metrics_t {
2021-04-13 03:21:26 -07:00
typedef std::array<ul_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
2021-04-12 13:48:25 -07:00
2017-05-30 06:38:04 -07:00
float mcs;
float power;
2021-04-12 13:48:25 -07:00
void set(const ul_metrics_t& other)
{
count++;
PHY_METRICS_SET(mcs);
PHY_METRICS_SET(power);
}
void reset()
{
count = 0;
mcs = 0.0f;
power = 0.0f;
}
private:
uint32_t count = 0;
2017-05-30 06:38:04 -07:00
};
2021-04-12 13:48:25 -07:00
#undef PHY_METRICS_SET
struct phy_metrics_t {
2021-04-12 13:48:25 -07:00
info_metrics_t::array_t info = {};
sync_metrics_t::array_t sync = {};
ch_metrics_t::array_t ch = {};
dl_metrics_t::array_t dl = {};
ul_metrics_t::array_t ul = {};
uint32_t nof_active_cc = 0;
2017-05-30 06:38:04 -07:00
};
} // namespace srsue
2018-03-31 10:04:04 -07:00
#endif // SRSUE_PHY_METRICS_H