Commit 1b029be0 authored by Cedric Roux's avatar Cedric Roux Committed by Chieh-Chun Chen

nr rlc stats: make avg time to tx optional

Introduce the function nr_rlc_activate_avg_time_to_tx() to
activate/deactivate collection of avg time to tx stats (which
may have an impact on realtime processing, so better not compute
them when not needed).

Fix a little bug in time_average_get_average() for when there is not stat.
parent c0394bc0
......@@ -61,6 +61,14 @@ void time_average_free(time_average_t *t)
free(t);
}
void time_average_reset(time_average_t *t)
{
t->r.head = t->r.maxsize - 1;
t->r.tail = 0;
t->r.size = 0;
t->accumulated_value = 0;
}
static void remove_old(time_average_t *t, uint64_t time)
{
/* remove old events */
......@@ -103,6 +111,9 @@ double time_average_get_average(time_average_t *t, uint64_t time)
{
remove_old(t, time);
if (t->r.size == 0)
return 0;
return (double)t->accumulated_value / t->r.size;
}
......
......@@ -46,6 +46,7 @@ typedef struct {
/* 'duration' is in unit microsecond */
time_average_t *time_average_new(int duration, int initial_size);
void time_average_free(time_average_t *t);
void time_average_reset(time_average_t *t);
/* add a value tagged with time 'time' unit microsecond (it also modifies 't',
* removing all data with time < 'time' - t->duration)
......
......@@ -37,8 +37,11 @@ static void nr_rlc_entity_get_stats(
{
// printf("Stats from the RLC entity asked\n");
*out = entity->stats;
out->txsdu_avg_time_to_tx = time_average_get_average(entity->txsdu_avg_time_to_tx,
time_average_now());
if (entity->avg_time_is_on)
out->txsdu_avg_time_to_tx = time_average_get_average(entity->txsdu_avg_time_to_tx,
time_average_now());
else
out->txsdu_avg_time_to_tx = 0;
}
nr_rlc_entity_t *new_nr_rlc_entity_am(
......
......@@ -137,6 +137,7 @@ typedef struct nr_rlc_entity_t {
nr_rlc_statistics_t stats;
time_average_t *txsdu_avg_time_to_tx;
int avg_time_is_on;
} nr_rlc_entity_t;
nr_rlc_entity_t *new_nr_rlc_entity_am(
......
......@@ -1718,7 +1718,8 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity,
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu)
+ sdu->size;
sdu->sdu->time_of_arrival = time_average_now();
if (entity->common.avg_time_is_on)
sdu->sdu->time_of_arrival = time_average_now();
}
/*************************************************************************/
......
......@@ -155,7 +155,8 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity,
/* update buffer status */
entity->common.bstatus.tx_size += sdu->size;
sdu->sdu->time_of_arrival = time_average_now();
if (entity->common.avg_time_is_on)
sdu->sdu->time_of_arrival = time_average_now();
}
/*************************************************************************/
......
......@@ -595,7 +595,8 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity,
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu)
+ sdu->size;
sdu->sdu->time_of_arrival = time_average_now();
if (entity->common.avg_time_is_on)
sdu->sdu->time_of_arrival = time_average_now();
}
/*************************************************************************/
......
......@@ -1111,6 +1111,33 @@ void rlc_tick(int a, int b)
exit(1);
}
void nr_rlc_activate_avg_time_to_tx(
const rnti_t rnti,
const logical_chan_id_t channel_id,
const bool is_on)
{
nr_rlc_ue_t *ue;
nr_rlc_entity_t *rb;
nr_rlc_manager_lock(nr_rlc_ue_manager);
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
switch (channel_id) {
case 1 ... 3: rb = ue->srb[channel_id - 1]; break;
case 4 ... 8: rb = ue->drb[channel_id - 4]; break;
default: rb = NULL; break;
}
if (rb != NULL) {
rb->avg_time_is_on = is_on;
time_average_reset(rb->txsdu_avg_time_to_tx);
} else {
LOG_E(RLC, "[%s] Radio Bearer (channel ID %d) is NULL for UE with rnti %x\n", __FUNCTION__, channel_id, rnti);
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
/* returns 0 in case of error, 1 if everything ok */
int const nr_rlc_get_statistics(
int rnti,
......
......@@ -51,3 +51,8 @@ void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChann
int nr_rlc_get_available_tx_space(
const rnti_t rntiP,
const logical_chan_id_t channel_idP);
void nr_rlc_activate_avg_time_to_tx(
const rnti_t rnti,
const logical_chan_id_t channel_id,
const bool is_on);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment