Merge remote-tracking branch 'origin/nr-mac-rlc-pdcp-stats' into integration_2022_wk36b
This commit is contained in:
@@ -1241,6 +1241,7 @@ add_library(UTIL
|
||||
${OPENAIR_DIR}/common/utils/system.c
|
||||
${OPENAIR_DIR}/common/utils/backtrace.c
|
||||
${OPENAIR_DIR}/common/utils/time_meas.c
|
||||
${OPENAIR_DIR}/common/utils/time_stat.c
|
||||
)
|
||||
|
||||
set(SECU_OSA_SRC
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include "time_stat.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
time_average_t *time_average_new(int duration, int initial_size)
|
||||
{
|
||||
time_average_t *ret;
|
||||
|
||||
/* let's only accept power of two initial_size */
|
||||
if (initial_size & (initial_size - 1)) {
|
||||
LOG_E(UTIL, "time_average_new: illegal initial_size %d, use power of two\n", initial_size);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = calloc(1, sizeof(time_average_t));
|
||||
if (ret == NULL) {
|
||||
LOG_E(UTIL, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret->duration = duration;
|
||||
ret->r.head = initial_size - 1;
|
||||
ret->r.maxsize = initial_size;
|
||||
ret->r.buffer = calloc(initial_size, sizeof(time_value_t));
|
||||
if (ret->r.buffer == NULL) {
|
||||
LOG_E(UTIL, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void time_average_free(time_average_t *t)
|
||||
{
|
||||
free(t->r.buffer);
|
||||
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 */
|
||||
while (t->r.size && t->r.buffer[t->r.tail].time < time - t->duration) {
|
||||
t->accumulated_value -= t->r.buffer[t->r.tail].value;
|
||||
t->r.size--;
|
||||
t->r.tail++;
|
||||
t->r.tail %= t->r.maxsize;
|
||||
}
|
||||
}
|
||||
|
||||
void time_average_add(time_average_t *t, uint64_t time, uint64_t value)
|
||||
{
|
||||
remove_old(t, time);
|
||||
|
||||
if (t->r.size == t->r.maxsize) {
|
||||
t->r.maxsize *= 2;
|
||||
t->r.buffer = realloc(t->r.buffer, t->r.maxsize * sizeof(time_value_t));
|
||||
if (t->r.buffer == NULL) {
|
||||
LOG_E(UTIL, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
if (t->r.head < t->r.tail) {
|
||||
memcpy(&t->r.buffer[t->r.size], &t->r.buffer[0], (t->r.head + 1) * sizeof(time_value_t));
|
||||
t->r.head += t->r.size;
|
||||
}
|
||||
}
|
||||
|
||||
t->r.head++;
|
||||
t->r.head %= t->r.maxsize;
|
||||
t->r.buffer[t->r.head].time = time;
|
||||
t->r.buffer[t->r.head].value = value;
|
||||
|
||||
t->r.size++;
|
||||
|
||||
t->accumulated_value += value;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
uint64_t time_average_now(void)
|
||||
{
|
||||
struct timespec t;
|
||||
uint64_t ret;
|
||||
|
||||
if (clock_gettime(CLOCK_REALTIME, &t)) {
|
||||
LOG_E(UTIL, "clock_gettime failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = (uint64_t)t.tv_sec * (uint64_t)1000000 + t.tv_nsec / 1000;
|
||||
/* round up if necessary */
|
||||
if (t.tv_nsec % 1000 >= 500)
|
||||
ret++;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_UTIL_TIME_STAT_H_
|
||||
#define _COMMON_UTIL_TIME_STAT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
uint64_t time; /* unit: microsecond */
|
||||
uint64_t value; /* unit: microsecond */
|
||||
} time_value_t;
|
||||
|
||||
typedef struct {
|
||||
int head;
|
||||
int tail;
|
||||
time_value_t *buffer;
|
||||
int maxsize;
|
||||
int size;
|
||||
} time_ring_t;
|
||||
|
||||
typedef struct {
|
||||
int duration; /* unit: microsecond */
|
||||
time_ring_t r;
|
||||
uint64_t accumulated_value;
|
||||
} time_average_t;
|
||||
|
||||
/* '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)
|
||||
*/
|
||||
void time_average_add(time_average_t *t, uint64_t time, uint64_t value);
|
||||
|
||||
/* get the average for time 'time' (it also modifies 't', removing all
|
||||
* data with time < 'time' - t->duration)
|
||||
*/
|
||||
double time_average_get_average(time_average_t *t, uint64_t time);
|
||||
|
||||
/* unit microsecond */
|
||||
uint64_t time_average_now(void);
|
||||
|
||||
#endif /* _COMMON_UTIL_TIME_STAT_H_ */
|
||||
@@ -133,6 +133,9 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
|
||||
gNB->tdd_beam_association[i] = -1;
|
||||
}
|
||||
|
||||
gNB->frame = frame;
|
||||
gNB->slot = slot;
|
||||
|
||||
start_meas(&RC.nrmac[module_idP]->eNB_scheduler);
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
|
||||
|
||||
|
||||
@@ -896,6 +896,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
|
||||
NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch;
|
||||
UE->mac_stats.dl.current_bytes = 0;
|
||||
UE->mac_stats.dl.current_rbs = 0;
|
||||
NR_CellGroupConfig_t *cg = UE->CellGroup;
|
||||
|
||||
/* update TA and set ta_apply every 10 frames.
|
||||
@@ -1195,6 +1196,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
current_harq_pid);
|
||||
T(T_GNB_MAC_RETRANSMISSION_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti),
|
||||
T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->transportBlock, TBS));
|
||||
UE->mac_stats.dl.total_rbs_retx += sched_pdsch->rbSize;
|
||||
} else { /* initial transmission */
|
||||
LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot);
|
||||
uint8_t *buf = (uint8_t *) harq->transportBlock;
|
||||
@@ -1210,6 +1212,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
int dlsch_total_bytes = 0;
|
||||
/* next, get RLC data */
|
||||
start_meas(&gNB_mac->rlc_data_req);
|
||||
int sdus = 0;
|
||||
|
||||
if (sched_ctrl->num_total_bytes > 0) {
|
||||
/* loop over all activated logical channels */
|
||||
@@ -1261,6 +1264,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
buf += len+sizeof(NR_MAC_SUBHEADER_LONG);
|
||||
dlsch_total_bytes += len;
|
||||
lcid_bytes += len;
|
||||
sdus += 1;
|
||||
}
|
||||
|
||||
UE->mac_stats.dl.lc_bytes[lcid] += lcid_bytes;
|
||||
@@ -1288,6 +1292,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
}
|
||||
for (; buf < bufEnd; buf++)
|
||||
*buf = lrand48() & 0xff;
|
||||
sdus +=1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1305,6 +1310,10 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
|
||||
UE->mac_stats.dl.total_bytes += TBS;
|
||||
UE->mac_stats.dl.current_bytes = TBS;
|
||||
UE->mac_stats.dl.total_rbs += sched_pdsch->rbSize;
|
||||
UE->mac_stats.dl.num_mac_sdu += sdus;
|
||||
UE->mac_stats.dl.current_rbs = sched_pdsch->rbSize;
|
||||
|
||||
/* save retransmission information */
|
||||
harq->sched_pdsch = *sched_pdsch;
|
||||
/* save which time allocation has been used, to be used on
|
||||
|
||||
@@ -88,6 +88,7 @@ int nr_process_mac_pdu( instance_t module_idP,
|
||||
|
||||
|
||||
uint8_t done = 0;
|
||||
int sdus = 0;
|
||||
|
||||
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
|
||||
|
||||
@@ -349,6 +350,7 @@ int nr_process_mac_pdu( instance_t module_idP,
|
||||
1,
|
||||
NULL);
|
||||
|
||||
sdus += 1;
|
||||
/* Updated estimated buffer when receiving data */
|
||||
if (sched_ctrl->estimated_ul_buffer >= mac_len) {
|
||||
sched_ctrl->estimated_ul_buffer -= mac_len;
|
||||
@@ -357,6 +359,7 @@ int nr_process_mac_pdu( instance_t module_idP,
|
||||
}
|
||||
|
||||
break;
|
||||
sdus += 1;
|
||||
|
||||
default:
|
||||
LOG_E(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid);
|
||||
@@ -388,6 +391,9 @@ int nr_process_mac_pdu( instance_t module_idP,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
UE->mac_stats.ul.num_mac_sdu += sdus;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1492,6 +1498,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
|
||||
NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP;
|
||||
|
||||
UE->mac_stats.ul.current_bytes = 0;
|
||||
UE->mac_stats.ul.current_rbs = 0;
|
||||
|
||||
/* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in
|
||||
* every TTI are pre-populated by the preprocessor and used below */
|
||||
@@ -1546,6 +1553,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
|
||||
* retransmissions */
|
||||
cur_harq->sched_pusch.time_domain_allocation = ps->time_domain_allocation;
|
||||
sched_ctrl->sched_ul_bytes += sched_pusch->tb_size;
|
||||
UE->mac_stats.ul.total_rbs += sched_pusch->rbSize;
|
||||
|
||||
} else {
|
||||
LOG_D(NR_MAC,
|
||||
"%d.%2d UL retransmission RNTI %04x sched %d.%2d HARQ PID %d round %d NDI %d\n",
|
||||
@@ -1557,8 +1566,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
|
||||
harq_id,
|
||||
cur_harq->round,
|
||||
cur_harq->ndi);
|
||||
UE->mac_stats.ul.total_rbs_retx += sched_pusch->rbSize;
|
||||
}
|
||||
UE->mac_stats.ul.current_bytes = sched_pusch->tb_size;
|
||||
UE->mac_stats.ul.current_rbs = sched_pusch->rbSize;
|
||||
sched_ctrl->last_ul_frame = sched_pusch->frame;
|
||||
sched_ctrl->last_ul_slot = sched_pusch->slot;
|
||||
|
||||
|
||||
@@ -668,6 +668,10 @@ typedef struct NR_mac_dir_stats {
|
||||
uint64_t errors;
|
||||
uint64_t total_bytes;
|
||||
uint32_t current_bytes;
|
||||
uint32_t total_rbs;
|
||||
uint32_t total_rbs_retx;
|
||||
uint32_t num_mac_sdu;
|
||||
uint32_t current_rbs;
|
||||
} NR_mac_dir_stats_t;
|
||||
|
||||
typedef struct NR_mac_stats {
|
||||
@@ -851,6 +855,10 @@ typedef struct gNB_MAC_INST_s {
|
||||
uint8_t min_grant_mcs;
|
||||
|
||||
nr_mac_rrc_ul_if_t mac_rrc;
|
||||
|
||||
int16_t frame;
|
||||
int16_t slot;
|
||||
|
||||
} gNB_MAC_INST;
|
||||
|
||||
#endif /*__LAYER2_NR_MAC_GNB_H__ */
|
||||
|
||||
@@ -59,6 +59,9 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
|
||||
We need to investigate why this hack is neccessary. */
|
||||
buffer[0] |= 128;
|
||||
}
|
||||
entity->stats.rxpdu_pkts++;
|
||||
entity->stats.rxpdu_bytes += size;
|
||||
|
||||
|
||||
if (entity->sn_size == 12) {
|
||||
rcvd_sn = ((buffer[0] & 0xf) << 8) |
|
||||
@@ -70,6 +73,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
|
||||
buffer[2];
|
||||
header_size = 3;
|
||||
}
|
||||
entity->stats.rxpdu_sn = rcvd_sn;
|
||||
|
||||
/* SRBs always have MAC-I, even if integrity is not active */
|
||||
if (entity->has_integrity || entity->type == NR_PDCP_SRB) {
|
||||
@@ -80,6 +84,11 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
|
||||
|
||||
if (size < header_size + integrity_size + 1) {
|
||||
LOG_E(PDCP, "bad PDU received (size = %d)\n", size);
|
||||
|
||||
entity->stats.rxpdu_dd_pkts++;
|
||||
entity->stats.rxpdu_dd_bytes += size;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,12 +118,20 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
|
||||
if (memcmp(integrity, buffer + size - integrity_size, 4) != 0) {
|
||||
LOG_E(PDCP, "discard NR PDU, integrity failed\n");
|
||||
// return;
|
||||
entity->stats.rxpdu_dd_pkts++;
|
||||
entity->stats.rxpdu_dd_bytes += size;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (rcvd_count < entity->rx_deliv
|
||||
|| nr_pdcp_sdu_in_list(entity->rx_list, rcvd_count)) {
|
||||
LOG_W(PDCP, "discard NR PDU rcvd_count=%d, entity->rx_deliv %d,sdu_in_list %d\n", rcvd_count,entity->rx_deliv,nr_pdcp_sdu_in_list(entity->rx_list,rcvd_count));
|
||||
entity->stats.rxpdu_dd_pkts++;
|
||||
entity->stats.rxpdu_dd_bytes += size;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,6 +156,10 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
|
||||
cur->buffer, cur->size);
|
||||
entity->rx_list = cur->next;
|
||||
entity->rx_size -= cur->size;
|
||||
entity->stats.txsdu_pkts++;
|
||||
entity->stats.txsdu_bytes += cur->size;
|
||||
|
||||
|
||||
nr_pdcp_free_sdu(cur);
|
||||
count++;
|
||||
}
|
||||
@@ -165,6 +186,9 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity,
|
||||
int integrity_size;
|
||||
char buf[size + 3 + 4];
|
||||
int dc_bit;
|
||||
entity->stats.rxsdu_pkts++;
|
||||
entity->stats.rxsdu_bytes += size;
|
||||
|
||||
|
||||
count = entity->tx_next;
|
||||
sn = entity->tx_next & entity->sn_max;
|
||||
@@ -215,6 +239,11 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity,
|
||||
|
||||
entity->deliver_pdu(entity->deliver_pdu_data, entity, buf,
|
||||
header_size + size + integrity_size, sdu_id);
|
||||
entity->stats.txpdu_pkts++;
|
||||
entity->stats.txpdu_bytes += header_size + size + integrity_size;
|
||||
entity->stats.txpdu_sn = sn;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* may be called several times, take care to clean previous settings */
|
||||
@@ -346,6 +375,13 @@ void nr_pdcp_entity_delete(nr_pdcp_entity_t *entity)
|
||||
free(entity);
|
||||
}
|
||||
|
||||
static void nr_pdcp_entity_get_stats(nr_pdcp_entity_t *entity,
|
||||
nr_pdcp_statistics_t *out)
|
||||
{
|
||||
*out = entity->stats;
|
||||
}
|
||||
|
||||
|
||||
nr_pdcp_entity_t *new_nr_pdcp_entity(
|
||||
nr_pdcp_entity_type_t type,
|
||||
int is_gnb, int rb_id, int pdusession_id,int has_sdap,
|
||||
@@ -381,6 +417,7 @@ nr_pdcp_entity_t *new_nr_pdcp_entity(
|
||||
|
||||
ret->delete_entity = nr_pdcp_entity_delete;
|
||||
|
||||
ret->get_stats = nr_pdcp_entity_get_stats;
|
||||
ret->deliver_sdu = deliver_sdu;
|
||||
ret->deliver_sdu_data = deliver_sdu_data;
|
||||
|
||||
|
||||
@@ -32,6 +32,39 @@ typedef enum {
|
||||
NR_PDCP_SRB
|
||||
} nr_pdcp_entity_type_t;
|
||||
|
||||
typedef struct {
|
||||
//nr_pdcp_entity_type_t mode;
|
||||
/* PDU stats */
|
||||
/* TX */
|
||||
uint32_t txpdu_pkts; /* aggregated number of tx packets */
|
||||
uint32_t txpdu_bytes; /* aggregated bytes of tx packets */
|
||||
uint32_t txpdu_sn; /* current sequence number of last tx packet (or TX_NEXT) */
|
||||
/* RX */
|
||||
uint32_t rxpdu_pkts; /* aggregated number of rx packets */
|
||||
uint32_t rxpdu_bytes; /* aggregated bytes of rx packets */
|
||||
uint32_t rxpdu_sn; /* current sequence number of last rx packet (or RX_NEXT) */
|
||||
/* TODO? */
|
||||
uint32_t rxpdu_oo_pkts; /* aggregated number of out-of-order rx pkts (or RX_REORD) */
|
||||
/* TODO? */
|
||||
uint32_t rxpdu_oo_bytes; /* aggregated amount of out-of-order rx bytes */
|
||||
uint32_t rxpdu_dd_pkts; /* aggregated number of duplicated discarded packets (or dropped packets because of other reasons such as integrity failure) (or RX_DELIV) */
|
||||
uint32_t rxpdu_dd_bytes; /* aggregated amount of discarded packets' bytes */
|
||||
/* TODO? */
|
||||
uint32_t rxpdu_ro_count; /* this state variable indicates the COUNT value following the COUNT value associated with the PDCP Data PDU which triggered t-Reordering. (RX_REORD) */
|
||||
|
||||
/* SDU stats */
|
||||
/* TX */
|
||||
uint32_t txsdu_pkts; /* number of SDUs delivered */
|
||||
uint32_t txsdu_bytes; /* number of bytes of SDUs delivered */
|
||||
|
||||
/* RX */
|
||||
uint32_t rxsdu_pkts; /* number of SDUs received */
|
||||
uint32_t rxsdu_bytes; /* number of bytes of SDUs received */
|
||||
|
||||
uint8_t mode; /* 0: PDCP AM, 1: PDCP UM, 2: PDCP TM */
|
||||
} nr_pdcp_statistics_t;
|
||||
|
||||
|
||||
typedef struct nr_pdcp_entity_t {
|
||||
nr_pdcp_entity_type_t type;
|
||||
|
||||
@@ -40,6 +73,7 @@ typedef struct nr_pdcp_entity_t {
|
||||
void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size,
|
||||
int sdu_id);
|
||||
void (*delete_entity)(struct nr_pdcp_entity_t *entity);
|
||||
void (*get_stats)(struct nr_pdcp_entity_t *entity, nr_pdcp_statistics_t *out);
|
||||
|
||||
/* set_security: pass -1 to integrity_algorithm / ciphering_algorithm
|
||||
* to keep the current algorithm
|
||||
@@ -114,6 +148,7 @@ typedef struct nr_pdcp_entity_t {
|
||||
nr_pdcp_sdu_t *rx_list;
|
||||
int rx_size;
|
||||
int rx_maxsize;
|
||||
nr_pdcp_statistics_t stats;
|
||||
} nr_pdcp_entity_t;
|
||||
|
||||
nr_pdcp_entity_t *new_nr_pdcp_entity(
|
||||
|
||||
@@ -1441,6 +1441,44 @@ void nr_pdcp_tick(int frame, int subframe)
|
||||
/*
|
||||
* For the SDAP API
|
||||
*/
|
||||
nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(){
|
||||
return nr_pdcp_ue_manager;
|
||||
nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager() {
|
||||
return nr_pdcp_ue_manager;
|
||||
}
|
||||
|
||||
/* returns false in case of error, true if everything ok */
|
||||
const bool nr_pdcp_get_statistics(
|
||||
int rnti,
|
||||
int srb_flag,
|
||||
int rb_id,
|
||||
nr_pdcp_statistics_t *out)
|
||||
{
|
||||
nr_pdcp_ue_t *ue;
|
||||
nr_pdcp_entity_t *rb;
|
||||
bool ret;
|
||||
|
||||
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
|
||||
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti);
|
||||
|
||||
if (srb_flag == 1) {
|
||||
if (rb_id < 1 || rb_id > 2)
|
||||
rb = NULL;
|
||||
else
|
||||
rb = ue->srb[rb_id - 1];
|
||||
} else {
|
||||
if (rb_id < 1 || rb_id > 5)
|
||||
rb = NULL;
|
||||
else
|
||||
rb = ue->drb[rb_id - 1];
|
||||
}
|
||||
|
||||
if (rb != NULL) {
|
||||
rb->get_stats(rb, out);
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,21 @@
|
||||
|
||||
#include "LOG/log.h"
|
||||
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
static void nr_rlc_entity_get_stats(
|
||||
nr_rlc_entity_t *entity,
|
||||
nr_rlc_statistics_t *out)
|
||||
{
|
||||
// printf("Stats from the RLC entity asked\n");
|
||||
*out = entity->stats;
|
||||
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(
|
||||
int rx_maxsize,
|
||||
int tx_maxsize,
|
||||
@@ -86,6 +101,7 @@ nr_rlc_entity_t *new_nr_rlc_entity_am(
|
||||
ret->common.reestablishment = nr_rlc_entity_am_reestablishment;
|
||||
ret->common.delete = nr_rlc_entity_am_delete;
|
||||
ret->common.available_tx_space = nr_rlc_entity_am_available_tx_space;
|
||||
ret->common.get_stats = nr_rlc_entity_get_stats;
|
||||
|
||||
ret->common.deliver_sdu = deliver_sdu;
|
||||
ret->common.deliver_sdu_data = deliver_sdu_data;
|
||||
@@ -94,6 +110,13 @@ nr_rlc_entity_t *new_nr_rlc_entity_am(
|
||||
ret->common.max_retx_reached = max_retx_reached;
|
||||
ret->common.max_retx_reached_data = max_retx_reached_data;
|
||||
|
||||
ret->common.stats.mode = NR_RLC_AM;
|
||||
|
||||
/* let's take average over the last 100 milliseconds
|
||||
* initial_size of 1024 is arbitrary
|
||||
*/
|
||||
ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024);
|
||||
|
||||
return (nr_rlc_entity_t *)ret;
|
||||
}
|
||||
|
||||
@@ -137,10 +160,18 @@ nr_rlc_entity_t *new_nr_rlc_entity_um(
|
||||
ret->common.reestablishment = nr_rlc_entity_um_reestablishment;
|
||||
ret->common.delete = nr_rlc_entity_um_delete;
|
||||
ret->common.available_tx_space = nr_rlc_entity_um_available_tx_space;
|
||||
ret->common.get_stats = nr_rlc_entity_get_stats;
|
||||
|
||||
ret->common.deliver_sdu = deliver_sdu;
|
||||
ret->common.deliver_sdu_data = deliver_sdu_data;
|
||||
|
||||
ret->common.stats.mode = NR_RLC_UM;
|
||||
|
||||
/* let's take average over the last 100 milliseconds
|
||||
* initial_size of 1024 is arbitrary
|
||||
*/
|
||||
ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024);
|
||||
|
||||
return (nr_rlc_entity_t *)ret;
|
||||
}
|
||||
|
||||
@@ -169,9 +200,17 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm(
|
||||
ret->common.reestablishment = nr_rlc_entity_tm_reestablishment;
|
||||
ret->common.delete = nr_rlc_entity_tm_delete;
|
||||
ret->common.available_tx_space = nr_rlc_entity_tm_available_tx_space;
|
||||
ret->common.get_stats = nr_rlc_entity_get_stats;
|
||||
|
||||
ret->common.deliver_sdu = deliver_sdu;
|
||||
ret->common.deliver_sdu_data = deliver_sdu_data;
|
||||
|
||||
ret->common.stats.mode = NR_RLC_TM;
|
||||
|
||||
/* let's take average over the last 100 milliseconds
|
||||
* initial_size of 1024 is arbitrary
|
||||
*/
|
||||
ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024);
|
||||
|
||||
return (nr_rlc_entity_t *)ret;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,79 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
#define NR_SDU_MAX 16000 /* max NR PDCP SDU size is 9000, let's take more */
|
||||
|
||||
typedef enum {
|
||||
NR_RLC_AM,
|
||||
NR_RLC_UM,
|
||||
NR_RLC_TM,
|
||||
} nr_rlc_mode_t;
|
||||
|
||||
typedef struct {
|
||||
nr_rlc_mode_t mode; /* AM, UM, or TM */
|
||||
|
||||
/* PDU stats */
|
||||
/* TX */
|
||||
uint32_t txpdu_pkts; /* aggregated number of transmitted RLC PDUs */
|
||||
uint32_t txpdu_bytes; /* aggregated amount of transmitted bytes in RLC PDUs */
|
||||
/* TODO? */
|
||||
uint32_t txpdu_wt_ms; /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */
|
||||
uint32_t txpdu_dd_pkts; /* aggregated number of dropped or discarded tx packets by RLC */
|
||||
uint32_t txpdu_dd_bytes; /* aggregated amount of bytes dropped or discarded tx packets by RLC */
|
||||
uint32_t txpdu_retx_pkts; /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */
|
||||
uint32_t txpdu_retx_bytes; /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */
|
||||
uint32_t txpdu_segmented; /* aggregated number of segmentations */
|
||||
uint32_t txpdu_status_pkts; /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */
|
||||
uint32_t txpdu_status_bytes; /* aggregated amount of tx status bytes (only applicable to RLC AM) */
|
||||
/* TODO? */
|
||||
uint32_t txbuf_occ_bytes; /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
|
||||
/* TODO? */
|
||||
uint32_t txbuf_occ_pkts; /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
|
||||
/* txbuf_wd_ms: the time window for which the txbuf occupancy value is obtained - NOT IMPLEMENTED */
|
||||
|
||||
/* RX */
|
||||
uint32_t rxpdu_pkts; /* aggregated number of received RLC PDUs */
|
||||
uint32_t rxpdu_bytes; /* amount of bytes received by the RLC */
|
||||
uint32_t rxpdu_dup_pkts; /* aggregated number of duplicate packets */
|
||||
uint32_t rxpdu_dup_bytes; /* aggregated amount of duplicated bytes */
|
||||
uint32_t rxpdu_dd_pkts; /* aggregated number of rx packets dropped or discarded by RLC */
|
||||
uint32_t rxpdu_dd_bytes; /* aggregated amount of rx bytes dropped or discarded by RLC */
|
||||
uint32_t rxpdu_ow_pkts; /* aggregated number of out of window received RLC pdu */
|
||||
uint32_t rxpdu_ow_bytes; /* aggregated number of out of window bytes received RLC pdu */
|
||||
uint32_t rxpdu_status_pkts; /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */
|
||||
uint32_t rxpdu_status_bytes; /* aggregated amount of rx status bytes (only applicable to RLC AM) */
|
||||
/* rxpdu_rotout_ms: flag indicating rx reordering timeout in ms - NOT IMPLEMENTED */
|
||||
/* rxpdu_potout_ms: flag indicating the poll retransmit time out in ms - NOT IMPLEMENTED */
|
||||
/* rxpdu_sptout_ms: flag indicating status prohibit timeout in ms - NOT IMPLEMENTED */
|
||||
/* TODO? */
|
||||
uint32_t rxbuf_occ_bytes; /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
|
||||
/* TODO? */
|
||||
uint32_t rxbuf_occ_pkts; /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
|
||||
|
||||
/* SDU stats */
|
||||
/* TX */
|
||||
uint32_t txsdu_pkts; /* number of SDUs delivered */
|
||||
uint32_t txsdu_bytes; /* number of bytes of SDUs delivered */
|
||||
|
||||
/* RX */
|
||||
uint32_t rxsdu_pkts; /* number of SDUs received */
|
||||
uint32_t rxsdu_bytes; /* number of bytes of SDUs received */
|
||||
uint32_t rxsdu_dd_pkts; /* number of dropped or discarded SDUs */
|
||||
uint32_t rxsdu_dd_bytes; /* number of bytes of SDUs dropped or discarded */
|
||||
|
||||
/* Average time for an SDU to be passed to MAC.
|
||||
* Actually measures the time it takes for any part of an SDU to be
|
||||
* passed to MAC for the first time, that is: the first TX of (part of) the
|
||||
* SDU.
|
||||
* Since the MAC schedules in advance, it does not measure the time of
|
||||
* transmission over the air, just the time to reach the MAC layer.
|
||||
*/
|
||||
double txsdu_avg_time_to_tx;
|
||||
|
||||
} nr_rlc_statistics_t;
|
||||
|
||||
typedef struct {
|
||||
int status_size;
|
||||
int tx_size;
|
||||
@@ -52,6 +123,8 @@ typedef struct nr_rlc_entity_t {
|
||||
|
||||
int (*available_tx_space)(struct nr_rlc_entity_t *entity);
|
||||
|
||||
void (*get_stats)(struct nr_rlc_entity_t *entity, nr_rlc_statistics_t *out);
|
||||
|
||||
/* callbacks provided to the RLC module */
|
||||
void (*deliver_sdu)(void *deliver_sdu_data, struct nr_rlc_entity_t *entity,
|
||||
char *buf, int size);
|
||||
@@ -67,6 +140,10 @@ typedef struct nr_rlc_entity_t {
|
||||
void *max_retx_reached_data;
|
||||
/* buffer status computation */
|
||||
nr_rlc_entity_buffer_status_t bstatus;
|
||||
|
||||
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(
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "nr_rlc_pdu.h"
|
||||
|
||||
#include "LOG/log.h"
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
/* for a given SDU/SDU segment, computes the corresponding PDU header size */
|
||||
static int compute_pdu_header_size(nr_rlc_entity_am_t *entity,
|
||||
@@ -221,6 +222,9 @@ static void reassemble_and_deliver(nr_rlc_entity_am_t *entity, int sn)
|
||||
entity->common.deliver_sdu(entity->common.deliver_sdu_data,
|
||||
(nr_rlc_entity_t *)entity,
|
||||
sdu, so);
|
||||
|
||||
entity->common.stats.txsdu_pkts++;
|
||||
entity->common.stats.txsdu_bytes += so;
|
||||
}
|
||||
|
||||
static void reception_actions(nr_rlc_entity_am_t *entity, nr_rlc_pdu_t *pdu)
|
||||
@@ -684,6 +688,9 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
|
||||
int is_first;
|
||||
int is_last;
|
||||
|
||||
entity->common.stats.rxpdu_pkts++;
|
||||
entity->common.stats.rxpdu_bytes += size;
|
||||
|
||||
nr_rlc_pdu_decoder_init(&decoder, buffer, size);
|
||||
dc = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder);
|
||||
|
||||
@@ -733,6 +740,10 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
|
||||
LOG_D(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n",
|
||||
__FILE__, __LINE__, __FUNCTION__,
|
||||
sn, entity->rx_next);
|
||||
|
||||
entity->common.stats.rxpdu_ow_pkts++;
|
||||
entity->common.stats.rxpdu_ow_bytes += size;
|
||||
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@@ -740,6 +751,10 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity,
|
||||
if (segment_already_received(entity, sn, so, data_size)) {
|
||||
LOG_D(RLC, "%s:%d:%s: warning: discard PDU, already received\n",
|
||||
__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
entity->common.stats.rxpdu_dup_pkts++;
|
||||
entity->common.stats.rxpdu_dup_bytes += size;
|
||||
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@@ -779,6 +794,9 @@ discard:
|
||||
if (p)
|
||||
entity->status_triggered = 1;
|
||||
|
||||
entity->common.stats.rxpdu_dd_pkts++;
|
||||
entity->common.stats.rxpdu_dd_bytes += size;
|
||||
|
||||
#undef R
|
||||
}
|
||||
|
||||
@@ -1309,6 +1327,11 @@ static int generate_status(nr_rlc_entity_am_t *entity, char *buffer, int size)
|
||||
/* start t_status_prohibit */
|
||||
entity->t_status_prohibit_start = entity->t_current;
|
||||
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += encoder.byte;
|
||||
entity->common.stats.txpdu_status_pkts++;
|
||||
entity->common.stats.txpdu_status_bytes += encoder.byte;
|
||||
|
||||
return encoder.byte;
|
||||
}
|
||||
|
||||
@@ -1473,6 +1496,8 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer,
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.retx_size += compute_pdu_header_size(entity, next_sdu)
|
||||
+ next_sdu->size;
|
||||
|
||||
entity->common.stats.txpdu_segmented++;
|
||||
}
|
||||
|
||||
/* put SDU/SDU segment in the wait list */
|
||||
@@ -1496,7 +1521,14 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer,
|
||||
entity->force_poll = 0;
|
||||
}
|
||||
|
||||
return serialize_sdu(entity, sdu, buffer, size, p);
|
||||
int ret_size = serialize_sdu(entity, sdu, buffer, size, p);
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += ret_size;
|
||||
entity->common.stats.txpdu_retx_pkts++;
|
||||
entity->common.stats.txpdu_retx_bytes += ret_size;
|
||||
|
||||
return ret_size;
|
||||
// return serialize_sdu(entity, sdu, buffer, size, p);
|
||||
}
|
||||
|
||||
static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size)
|
||||
@@ -1544,6 +1576,8 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size)
|
||||
entity->tx_list = next_sdu;
|
||||
if (entity->tx_end == NULL)
|
||||
entity->tx_end = entity->tx_list;
|
||||
|
||||
entity->common.stats.txpdu_segmented++;
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, next_sdu)
|
||||
+ next_sdu->size;
|
||||
@@ -1582,8 +1616,21 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size)
|
||||
p = 1;
|
||||
entity->force_poll = 0;
|
||||
}
|
||||
int ret_size = serialize_sdu(entity, sdu, buffer, size, p);
|
||||
|
||||
return serialize_sdu(entity, sdu, buffer, size, p);
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += ret_size;
|
||||
|
||||
if (sdu->sdu->time_of_arrival) {
|
||||
uint64_t time_now = time_average_now();
|
||||
uint64_t waited_time = time_now - sdu->sdu->time_of_arrival;
|
||||
/* set time_of_arrival to 0 so as to update stats only once */
|
||||
sdu->sdu->time_of_arrival = 0;
|
||||
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
|
||||
}
|
||||
|
||||
return ret_size;
|
||||
// return serialize_sdu(entity, sdu, buffer, size, p);
|
||||
}
|
||||
|
||||
nr_rlc_entity_buffer_status_t nr_rlc_entity_am_buffer_status(
|
||||
@@ -1635,6 +1682,9 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity;
|
||||
nr_rlc_sdu_segment_t *sdu;
|
||||
|
||||
entity->common.stats.rxsdu_pkts++;
|
||||
entity->common.stats.rxsdu_bytes += size;
|
||||
|
||||
if (size > NR_SDU_MAX) {
|
||||
LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n",
|
||||
__FILE__, __LINE__, __FUNCTION__, size);
|
||||
@@ -1667,6 +1717,9 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu)
|
||||
+ sdu->size;
|
||||
|
||||
if (entity->common.avg_time_is_on)
|
||||
sdu->sdu->time_of_arrival = time_average_now();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -1908,6 +1961,7 @@ void nr_rlc_entity_am_delete(nr_rlc_entity_t *_entity)
|
||||
{
|
||||
nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity;
|
||||
clear_entity(entity);
|
||||
time_average_free(entity->common.txsdu_avg_time_to_tx);
|
||||
free(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "nr_rlc_pdu.h"
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
#include "LOG/log.h"
|
||||
|
||||
@@ -36,9 +37,16 @@ void nr_rlc_entity_tm_recv_pdu(nr_rlc_entity_t *_entity,
|
||||
char *buffer, int size)
|
||||
{
|
||||
nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity;
|
||||
|
||||
entity->common.stats.rxpdu_pkts++;
|
||||
entity->common.stats.rxpdu_bytes += size;
|
||||
|
||||
entity->common.deliver_sdu(entity->common.deliver_sdu_data,
|
||||
(nr_rlc_entity_t *)entity,
|
||||
buffer, size);
|
||||
|
||||
entity->common.stats.txsdu_pkts++;
|
||||
entity->common.stats.txsdu_bytes += size;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -68,6 +76,16 @@ static int generate_tx_pdu(nr_rlc_entity_tm_t *entity, char *buffer, int size)
|
||||
memcpy(buffer, sdu->sdu->data, sdu->size);
|
||||
|
||||
entity->tx_size -= sdu->size;
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += size;
|
||||
|
||||
if (sdu->sdu->time_of_arrival) {
|
||||
uint64_t time_now = time_average_now();
|
||||
uint64_t waited_time = time_now - sdu->sdu->time_of_arrival;
|
||||
/* set time_of_arrival to 0 so as to update stats only once */
|
||||
sdu->sdu->time_of_arrival = 0;
|
||||
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
|
||||
}
|
||||
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size -= sdu->size;
|
||||
@@ -109,6 +127,9 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity;
|
||||
nr_rlc_sdu_segment_t *sdu;
|
||||
|
||||
entity->common.stats.rxsdu_pkts++;
|
||||
entity->common.stats.rxsdu_bytes += size;
|
||||
|
||||
if (size > NR_SDU_MAX) {
|
||||
LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n",
|
||||
__FILE__, __LINE__, __FUNCTION__, size);
|
||||
@@ -118,6 +139,10 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
if (entity->tx_size + size > entity->tx_maxsize) {
|
||||
LOG_D(RLC, "%s:%d:%s: warning: SDU rejected, SDU buffer full\n",
|
||||
__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
entity->common.stats.rxsdu_dd_pkts++;
|
||||
entity->common.stats.rxsdu_dd_bytes += size;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,6 +154,9 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size += sdu->size;
|
||||
|
||||
if (entity->common.avg_time_is_on)
|
||||
sdu->sdu->time_of_arrival = time_average_now();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -172,6 +200,7 @@ void nr_rlc_entity_tm_delete(nr_rlc_entity_t *_entity)
|
||||
{
|
||||
nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity;
|
||||
clear_entity(entity);
|
||||
time_average_free(entity->common.txsdu_avg_time_to_tx);
|
||||
free(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "nr_rlc_pdu.h"
|
||||
|
||||
#include "LOG/log.h"
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
/* for a given SDU/SDU segment, computes the corresponding PDU header size */
|
||||
static int compute_pdu_header_size(nr_rlc_entity_um_t *entity,
|
||||
@@ -179,6 +180,9 @@ static void reassemble_and_deliver(nr_rlc_entity_um_t *entity, int sn)
|
||||
entity->common.deliver_sdu(entity->common.deliver_sdu_data,
|
||||
(nr_rlc_entity_t *)entity,
|
||||
sdu, so);
|
||||
|
||||
entity->common.stats.txsdu_pkts++;
|
||||
entity->common.stats.txsdu_bytes += so;
|
||||
}
|
||||
|
||||
static void reception_actions(nr_rlc_entity_um_t *entity, nr_rlc_pdu_t *pdu)
|
||||
@@ -208,6 +212,15 @@ static void reception_actions(nr_rlc_entity_um_t *entity, nr_rlc_pdu_t *pdu)
|
||||
nr_rlc_pdu_t *p = entity->rx_list;
|
||||
entity->rx_size -= p->size;
|
||||
entity->rx_list = p->next;
|
||||
|
||||
entity->common.stats.rxpdu_dd_pkts++;
|
||||
/* we don't count PDU header bytes here, so be it */
|
||||
entity->common.stats.rxpdu_dd_bytes += p->size;
|
||||
|
||||
entity->common.stats.rxpdu_ow_pkts++;
|
||||
/* we don't count PDU header bytes here, so be it */
|
||||
entity->common.stats.rxpdu_ow_bytes += p->size;
|
||||
|
||||
nr_rlc_free_pdu(p);
|
||||
}
|
||||
|
||||
@@ -272,6 +285,9 @@ void nr_rlc_entity_um_recv_pdu(nr_rlc_entity_t *_entity,
|
||||
int is_first;
|
||||
int is_last;
|
||||
|
||||
entity->common.stats.rxpdu_pkts++;
|
||||
entity->common.stats.rxpdu_bytes += size;
|
||||
|
||||
nr_rlc_pdu_decoder_init(&decoder, buffer, size);
|
||||
|
||||
si = nr_rlc_pdu_decoder_get_bits(&decoder, 2); R(decoder);
|
||||
@@ -290,6 +306,10 @@ void nr_rlc_entity_um_recv_pdu(nr_rlc_entity_t *_entity,
|
||||
entity->common.deliver_sdu(entity->common.deliver_sdu_data,
|
||||
(nr_rlc_entity_t *)entity,
|
||||
buffer + 1, size - 1);
|
||||
|
||||
entity->common.stats.txsdu_pkts++;
|
||||
entity->common.stats.txsdu_bytes += size - 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -350,6 +370,9 @@ err:
|
||||
goto discard;
|
||||
|
||||
discard:
|
||||
entity->common.stats.rxpdu_dd_pkts++;
|
||||
entity->common.stats.rxpdu_dd_bytes += size;
|
||||
|
||||
return;
|
||||
|
||||
#undef R
|
||||
@@ -434,6 +457,8 @@ static nr_rlc_sdu_segment_t *resegment(nr_rlc_sdu_segment_t *sdu,
|
||||
next->so = sdu->so + sdu->size;
|
||||
next->is_first = 0;
|
||||
|
||||
entity->common.stats.txpdu_segmented++;
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
@@ -478,6 +503,8 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size)
|
||||
entity->tx_list = next_sdu;
|
||||
if (entity->tx_end == NULL)
|
||||
entity->tx_end = entity->tx_list;
|
||||
|
||||
entity->common.stats.txpdu_segmented++;
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, next_sdu)
|
||||
+ next_sdu->size;
|
||||
@@ -490,6 +517,18 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size)
|
||||
ret = serialize_sdu(entity, sdu, buffer, size);
|
||||
|
||||
entity->tx_size -= sdu->size;
|
||||
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += size;
|
||||
|
||||
if (sdu->sdu->time_of_arrival) {
|
||||
uint64_t time_now = time_average_now();
|
||||
uint64_t waited_time = time_now - sdu->sdu->time_of_arrival;
|
||||
/* set time_of_arrival to 0 so as to update stats only once */
|
||||
sdu->sdu->time_of_arrival = 0;
|
||||
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
|
||||
}
|
||||
|
||||
nr_rlc_free_sdu_segment(sdu);
|
||||
|
||||
return ret;
|
||||
@@ -527,6 +566,9 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity;
|
||||
nr_rlc_sdu_segment_t *sdu;
|
||||
|
||||
entity->common.stats.rxsdu_pkts++;
|
||||
entity->common.stats.rxsdu_bytes += size;
|
||||
|
||||
if (size > NR_SDU_MAX) {
|
||||
LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n",
|
||||
__FILE__, __LINE__, __FUNCTION__, size);
|
||||
@@ -536,6 +578,10 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
if (entity->tx_size + size > entity->tx_maxsize) {
|
||||
LOG_W(RLC, "%s:%d:%s: warning: SDU rejected, SDU buffer full\n",
|
||||
__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
entity->common.stats.rxsdu_dd_pkts++;
|
||||
entity->common.stats.rxsdu_dd_bytes += size;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -548,6 +594,9 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu)
|
||||
+ sdu->size;
|
||||
|
||||
if (entity->common.avg_time_is_on)
|
||||
sdu->sdu->time_of_arrival = time_average_now();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -584,6 +633,11 @@ static void check_t_reassembly(nr_rlc_entity_um_t *entity)
|
||||
nr_rlc_pdu_t *p = cur;
|
||||
cur = cur->next;
|
||||
entity->rx_list = cur;
|
||||
|
||||
entity->common.stats.rxpdu_dd_pkts++;
|
||||
/* we don't count PDU header bytes here, so be it */
|
||||
entity->common.stats.rxpdu_dd_bytes += p->size;
|
||||
|
||||
nr_rlc_free_pdu(p);
|
||||
}
|
||||
|
||||
@@ -693,6 +747,7 @@ void nr_rlc_entity_um_delete(nr_rlc_entity_t *_entity)
|
||||
{
|
||||
nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity;
|
||||
clear_entity(entity);
|
||||
time_average_free(entity->common.txsdu_avg_time_to_tx);
|
||||
free(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -1110,3 +1110,66 @@ void rlc_tick(int a, int b)
|
||||
__FILE__, __LINE__, __FUNCTION__);
|
||||
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 false in case of error, true if everything ok */
|
||||
const bool nr_rlc_get_statistics(
|
||||
int rnti,
|
||||
int srb_flag,
|
||||
int rb_id,
|
||||
nr_rlc_statistics_t *out)
|
||||
{
|
||||
nr_rlc_ue_t *ue;
|
||||
nr_rlc_entity_t *rb;
|
||||
bool ret;
|
||||
|
||||
nr_rlc_manager_lock(nr_rlc_ue_manager);
|
||||
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
|
||||
|
||||
rb = NULL;
|
||||
|
||||
if (srb_flag) {
|
||||
if (rb_id >= 1 && rb_id <= 2)
|
||||
rb = ue->srb[rb_id - 1];
|
||||
} else {
|
||||
if (rb_id >= 1 && rb_id <= 5)
|
||||
rb = ue->drb[rb_id - 1];
|
||||
}
|
||||
|
||||
if (rb != NULL) {
|
||||
rb->get_stats(rb, out);
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
nr_rlc_manager_unlock(nr_rlc_ue_manager);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef _NR_RLC_SDU_H_
|
||||
#define _NR_RLC_SDU_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct nr_rlc_sdu_t {
|
||||
int sn;
|
||||
int upper_layer_id;
|
||||
@@ -34,6 +36,12 @@ typedef struct nr_rlc_sdu_t {
|
||||
* when it equals ref_count we can free the SDU
|
||||
* completely
|
||||
*/
|
||||
|
||||
/* for statistics, will be set to 0 after SDU (or first part of it) has
|
||||
* been serialized for MAC for the first time so that only the first
|
||||
* transmission is used for statistics
|
||||
*/
|
||||
uint64_t time_of_arrival; /* unit microsecond */
|
||||
} nr_rlc_sdu_t;
|
||||
|
||||
typedef struct nr_rlc_sdu_segment_t {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -g --coverage -I.
|
||||
CFLAGS=-Wall -g --coverage -I. -I../../../..
|
||||
|
||||
LIB=nr_rlc_entity.o nr_rlc_entity_am.o nr_rlc_entity_um.o nr_rlc_entity_tm.o \
|
||||
nr_rlc_pdu.o nr_rlc_sdu.o
|
||||
nr_rlc_pdu.o nr_rlc_sdu.o time_stat.o
|
||||
|
||||
tests:
|
||||
@./run_tests.sh
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "../../../../common/utils/time_stat.h"
|
||||
|
||||
time_average_t *time_average_new(int duration, int initial_size)
|
||||
{
|
||||
return (void *)0;
|
||||
}
|
||||
|
||||
void time_average_free(time_average_t *t)
|
||||
{
|
||||
}
|
||||
|
||||
void time_average_add(time_average_t *t, uint64_t time, uint64_t value)
|
||||
{
|
||||
}
|
||||
|
||||
double time_average_get_average(time_average_t *t, uint64_t time)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t time_average_now(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user