mirror of https://github.com/PentHertz/srsLTE.git
{dl,ul}_harq: fix metrics calculation
rewrite metrics calculation for NR HARQ and remove unneeded operations.
This commit is contained in:
parent
b6f2c80f66
commit
4b3538aaa8
|
@ -50,6 +50,14 @@ public:
|
||||||
|
|
||||||
float get_average_retx();
|
float get_average_retx();
|
||||||
|
|
||||||
|
// DL HARQ metrics combined for all processes
|
||||||
|
struct dl_harq_metrics_t {
|
||||||
|
uint32_t rx_ok;
|
||||||
|
uint32_t rx_ko;
|
||||||
|
uint32_t rx_brate;
|
||||||
|
};
|
||||||
|
dl_harq_metrics_t get_metrics();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class dl_harq_process_nr
|
class dl_harq_process_nr
|
||||||
{
|
{
|
||||||
|
@ -87,12 +95,9 @@ private:
|
||||||
demux_interface_harq_nr* demux_unit = nullptr;
|
demux_interface_harq_nr* demux_unit = nullptr;
|
||||||
srslog::basic_logger& logger;
|
srslog::basic_logger& logger;
|
||||||
uint16_t last_temporal_crnti = SRSRAN_INVALID_RNTI;
|
uint16_t last_temporal_crnti = SRSRAN_INVALID_RNTI;
|
||||||
|
dl_harq_metrics_t metrics = {};
|
||||||
float average_retx = 0.0;
|
uint8_t cc_idx = 0;
|
||||||
uint64_t nof_pkts = 0;
|
pthread_rwlock_t rwlock;
|
||||||
uint8_t cc_idx = 0;
|
|
||||||
|
|
||||||
pthread_rwlock_t rwlock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unique_ptr<dl_harq_entity_nr> dl_harq_entity_nr_ptr;
|
typedef std::unique_ptr<dl_harq_entity_nr> dl_harq_entity_nr_ptr;
|
||||||
|
|
|
@ -37,8 +37,15 @@ public:
|
||||||
/***************** PHY->MAC interface for UL processes **************************/
|
/***************** PHY->MAC interface for UL processes **************************/
|
||||||
void new_grant_ul(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant, mac_interface_phy_nr::tb_action_ul_t* action);
|
void new_grant_ul(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant, mac_interface_phy_nr::tb_action_ul_t* action);
|
||||||
|
|
||||||
int get_current_tbs(uint32_t pid);
|
int get_current_tbs(uint32_t pid);
|
||||||
float get_average_retx();
|
|
||||||
|
// HARQ specific metrics interface that is combined for all processees
|
||||||
|
struct ul_harq_metrics_t {
|
||||||
|
uint32_t tx_ok;
|
||||||
|
uint32_t tx_ko;
|
||||||
|
uint32_t tx_brate;
|
||||||
|
};
|
||||||
|
ul_harq_metrics_t get_metrics();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ul_harq_process_nr
|
class ul_harq_process_nr
|
||||||
|
@ -95,9 +102,7 @@ private:
|
||||||
srslog::basic_logger& logger;
|
srslog::basic_logger& logger;
|
||||||
|
|
||||||
srsran::ul_harq_cfg_t harq_cfg = {};
|
srsran::ul_harq_cfg_t harq_cfg = {};
|
||||||
|
ul_harq_metrics_t metrics = {};
|
||||||
float average_retx = 0.0;
|
|
||||||
uint64_t nof_pkts = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unique_ptr<ul_harq_entity_nr> ul_harq_entity_nr_ptr;
|
typedef std::unique_ptr<ul_harq_entity_nr> ul_harq_entity_nr_ptr;
|
||||||
|
|
|
@ -76,7 +76,7 @@ void dl_harq_entity_nr::new_grant_dl(const mac_nr_grant_dl_t& grant, mac_interfa
|
||||||
// Set BCCH PID for SI RNTI
|
// Set BCCH PID for SI RNTI
|
||||||
proc_ptr = &bcch_proc;
|
proc_ptr = &bcch_proc;
|
||||||
} else {
|
} else {
|
||||||
if (grant.pid >= cfg.nof_procs) {
|
if (harq_procs.at(grant.pid) == nullptr) {
|
||||||
logger.error("Grant for invalid HARQ PID=%d", grant.pid);
|
logger.error("Grant for invalid HARQ PID=%d", grant.pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ void dl_harq_entity_nr::tb_decoded(const mac_nr_grant_dl_t& grant, mac_interface
|
||||||
if (grant.rnti == SRSRAN_SIRNTI) {
|
if (grant.rnti == SRSRAN_SIRNTI) {
|
||||||
bcch_proc.tb_decoded(grant, std::move(result));
|
bcch_proc.tb_decoded(grant, std::move(result));
|
||||||
} else {
|
} else {
|
||||||
if (grant.pid >= cfg.nof_procs) {
|
if (harq_procs.at(grant.pid) == nullptr) {
|
||||||
logger.error("Decoded TB for invalid HARQ PID=%d", grant.pid);
|
logger.error("Decoded TB for invalid HARQ PID=%d", grant.pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,11 @@ void dl_harq_entity_nr::reset()
|
||||||
bcch_proc.reset();
|
bcch_proc.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
float dl_harq_entity_nr::get_average_retx()
|
dl_harq_entity_nr::dl_harq_metrics_t dl_harq_entity_nr::get_metrics()
|
||||||
{
|
{
|
||||||
return average_retx;
|
dl_harq_metrics_t tmp = metrics;
|
||||||
|
metrics = {};
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl_harq_entity_nr::dl_harq_process_nr::dl_harq_process_nr(dl_harq_entity_nr* parent_) :
|
dl_harq_entity_nr::dl_harq_process_nr::dl_harq_process_nr(dl_harq_entity_nr* parent_) :
|
||||||
|
@ -194,6 +196,8 @@ void dl_harq_entity_nr::dl_harq_process_nr::new_grant_dl(const mac_nr_grant_dl_t
|
||||||
is_first_tb = false;
|
is_first_tb = false;
|
||||||
} else {
|
} else {
|
||||||
// This is a retransmission
|
// This is a retransmission
|
||||||
|
n_retx++;
|
||||||
|
|
||||||
if (not acked) {
|
if (not acked) {
|
||||||
// If data has not yet been successfully decoded, instruct the PHY to combine the received data
|
// If data has not yet been successfully decoded, instruct the PHY to combine the received data
|
||||||
action->tb.enabled = true;
|
action->tb.enabled = true;
|
||||||
|
@ -203,8 +207,7 @@ void dl_harq_entity_nr::dl_harq_process_nr::new_grant_dl(const mac_nr_grant_dl_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// increment counter and store grant
|
// store grant
|
||||||
n_retx++;
|
|
||||||
current_grant = grant;
|
current_grant = grant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,11 +227,13 @@ void dl_harq_entity_nr::dl_harq_process_nr::tb_decoded(const mac_nr_grant_dl_t&
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Delivering PDU=%d bytes to Dissassemble and Demux unit", grant.tbs);
|
logger.debug("Delivering PDU=%d bytes to Dissassemble and Demux unit", grant.tbs);
|
||||||
harq_entity->demux_unit->push_pdu(std::move(result.payload), grant.tti);
|
harq_entity->demux_unit->push_pdu(std::move(result.payload), grant.tti);
|
||||||
|
|
||||||
// Compute average number of retransmissions per packet
|
|
||||||
harq_entity->average_retx = SRSRAN_VEC_CMA((float)n_retx, harq_entity->average_retx, harq_entity->nof_pkts++);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
harq_entity->metrics.rx_ok++;
|
||||||
|
harq_entity->metrics.rx_brate += grant.tbs * 8;
|
||||||
|
} else {
|
||||||
|
harq_entity->metrics.rx_ko++;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("DL %d: %s tbs=%d, rv=%d, ack=%s, ndi=%d",
|
logger.info("DL %d: %s tbs=%d, rv=%d, ack=%s, ndi=%d",
|
||||||
|
|
|
@ -307,13 +307,6 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, const mac_nr_grant_dl_t& grant, t
|
||||||
|
|
||||||
dl_harq.at(cc_idx)->tb_decoded(grant, std::move(result));
|
dl_harq.at(cc_idx)->tb_decoded(grant, std::move(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
// do metrics
|
|
||||||
metrics[cc_idx].rx_brate += grant.tbs * 8;
|
|
||||||
metrics[cc_idx].rx_pkts++;
|
|
||||||
if (not result.ack) {
|
|
||||||
metrics[cc_idx].rx_errors++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, tb_action_ul_t* action)
|
void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, tb_action_ul_t* action)
|
||||||
|
@ -346,8 +339,6 @@ void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant,
|
||||||
}
|
}
|
||||||
|
|
||||||
ul_harq.at(cc_idx)->new_grant_ul(grant, action);
|
ul_harq.at(cc_idx)->new_grant_ul(grant, action);
|
||||||
metrics[cc_idx].tx_pkts++;
|
|
||||||
metrics[cc_idx].tx_brate += grant.tbs * 8;
|
|
||||||
|
|
||||||
// store PCAP
|
// store PCAP
|
||||||
if (action->tb.enabled && pcap) {
|
if (action->tb.enabled && pcap) {
|
||||||
|
@ -472,16 +463,32 @@ void mac_nr::get_metrics(mac_metrics_t m[SRSRAN_MAX_CARRIERS])
|
||||||
float dl_avg_ret = 0;
|
float dl_avg_ret = 0;
|
||||||
int dl_avg_ret_count = 0;
|
int dl_avg_ret_count = 0;
|
||||||
|
|
||||||
for (const auto& cc : metrics) {
|
// Get metrics from HARQ entities explicitly
|
||||||
tx_pkts += cc.tx_pkts;
|
for (uint32_t i = 0; i < metrics.size(); ++i) {
|
||||||
tx_errors += cc.tx_errors;
|
if (dl_harq.at(i) != nullptr) {
|
||||||
tx_brate += cc.tx_brate;
|
dl_harq_entity_nr::dl_harq_metrics_t harq_metrics = dl_harq.at(i)->get_metrics();
|
||||||
rx_pkts += cc.rx_pkts;
|
rx_pkts += (harq_metrics.rx_ok + harq_metrics.rx_ko);
|
||||||
rx_errors += cc.rx_errors;
|
rx_errors += harq_metrics.rx_ko;
|
||||||
rx_brate += cc.rx_brate;
|
rx_brate += harq_metrics.rx_brate;
|
||||||
ul_buffer += cc.ul_buffer;
|
}
|
||||||
|
if (ul_harq.at(i) != nullptr) {
|
||||||
|
ul_harq_entity_nr::ul_harq_metrics_t harq_metrics = ul_harq.at(i)->get_metrics();
|
||||||
|
tx_pkts += (harq_metrics.tx_ok + harq_metrics.tx_ko);
|
||||||
|
tx_errors += harq_metrics.tx_ko;
|
||||||
|
tx_brate += harq_metrics.tx_brate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assign accumulated metrics for PCELL carrier only
|
||||||
|
auto& pcell_cc = metrics[PCELL_CC_IDX];
|
||||||
|
pcell_cc.tx_pkts = tx_pkts;
|
||||||
|
pcell_cc.tx_errors = tx_errors;
|
||||||
|
pcell_cc.tx_brate = tx_brate;
|
||||||
|
pcell_cc.rx_pkts = rx_pkts;
|
||||||
|
pcell_cc.rx_errors = rx_errors;
|
||||||
|
pcell_cc.rx_brate = rx_brate;
|
||||||
|
pcell_cc.ul_buffer = mac_buffer_states.get_total_buffer_size();
|
||||||
|
|
||||||
memcpy(m, metrics.data(), sizeof(mac_metrics_t) * SRSRAN_MAX_CARRIERS);
|
memcpy(m, metrics.data(), sizeof(mac_metrics_t) * SRSRAN_MAX_CARRIERS);
|
||||||
metrics = {};
|
metrics = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ void ul_harq_entity_nr::new_grant_ul(const mac_interface_phy_nr::mac_nr_grant_ul
|
||||||
logger.warning("Ignoring grant for CS-RNTI=0x%x", grant.rnti);
|
logger.warning("Ignoring grant for CS-RNTI=0x%x", grant.rnti);
|
||||||
} else {
|
} else {
|
||||||
logger.warning("Received grant for unknown rnti=0x%x", grant.rnti);
|
logger.warning("Received grant for unknown rnti=0x%x", grant.rnti);
|
||||||
printf("Received grant for unknown rnti=0x%x\n", grant.rnti);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srsran_expect(action->tb.enabled ? action->tb.payload != nullptr : true,
|
srsran_expect(action->tb.enabled ? action->tb.payload != nullptr : true,
|
||||||
|
@ -105,9 +104,11 @@ int ul_harq_entity_nr::get_current_tbs(uint32_t pid)
|
||||||
return harq_procs.at(pid).get_current_tbs();
|
return harq_procs.at(pid).get_current_tbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
float ul_harq_entity_nr::get_average_retx()
|
ul_harq_entity_nr::ul_harq_metrics_t ul_harq_entity_nr::get_metrics()
|
||||||
{
|
{
|
||||||
return average_retx;
|
ul_harq_entity_nr::ul_harq_metrics_t tmp = metrics;
|
||||||
|
metrics = {};
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul_harq_entity_nr::ul_harq_process_nr::ul_harq_process_nr() : logger(srslog::fetch_basic_logger("MAC")) {}
|
ul_harq_entity_nr::ul_harq_process_nr::ul_harq_process_nr() : logger(srslog::fetch_basic_logger("MAC")) {}
|
||||||
|
@ -226,10 +227,8 @@ int ul_harq_entity_nr::ul_harq_process_nr::get_current_tbs()
|
||||||
void ul_harq_entity_nr::ul_harq_process_nr::generate_new_tx(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant,
|
void ul_harq_entity_nr::ul_harq_process_nr::generate_new_tx(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant,
|
||||||
mac_interface_phy_nr::tb_action_ul_t* action)
|
mac_interface_phy_nr::tb_action_ul_t* action)
|
||||||
{
|
{
|
||||||
// Compute average number of retransmissions per packet considering previous packet
|
current_grant = grant;
|
||||||
harq_entity->average_retx = SRSRAN_VEC_CMA((float)nof_retx, harq_entity->average_retx, harq_entity->nof_pkts++);
|
nof_retx = 0;
|
||||||
current_grant = grant;
|
|
||||||
nof_retx = 0;
|
|
||||||
|
|
||||||
logger.info("UL %d: New TX%s, rv=%d, tbs=%d",
|
logger.info("UL %d: New TX%s, rv=%d, tbs=%d",
|
||||||
pid,
|
pid,
|
||||||
|
@ -238,6 +237,8 @@ void ul_harq_entity_nr::ul_harq_process_nr::generate_new_tx(const mac_interface_
|
||||||
grant.tbs);
|
grant.tbs);
|
||||||
|
|
||||||
generate_tx(action);
|
generate_tx(action);
|
||||||
|
|
||||||
|
harq_entity->metrics.tx_ok++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retransmission (Section 5.4.2.2)
|
// Retransmission (Section 5.4.2.2)
|
||||||
|
@ -250,12 +251,16 @@ void ul_harq_entity_nr::ul_harq_process_nr::generate_retx(const mac_interface_ph
|
||||||
current_grant = grant;
|
current_grant = grant;
|
||||||
|
|
||||||
generate_tx(action);
|
generate_tx(action);
|
||||||
|
|
||||||
|
// increment Tx error count
|
||||||
|
harq_entity->metrics.tx_ko++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transmission of pending frame (Section 5.4.2.2)
|
// Transmission of pending frame (Section 5.4.2.2)
|
||||||
void ul_harq_entity_nr::ul_harq_process_nr::generate_tx(mac_interface_phy_nr::tb_action_ul_t* action)
|
void ul_harq_entity_nr::ul_harq_process_nr::generate_tx(mac_interface_phy_nr::tb_action_ul_t* action)
|
||||||
{
|
{
|
||||||
nof_retx++;
|
nof_retx++;
|
||||||
|
harq_entity->metrics.tx_brate += current_grant.tbs * 8;
|
||||||
|
|
||||||
action->tb.rv = current_grant.rv;
|
action->tb.rv = current_grant.rv;
|
||||||
action->tb.enabled = true;
|
action->tb.enabled = true;
|
||||||
|
|
Loading…
Reference in New Issue