From eebf2cb938c0f19cffff2194eb3871afe9a6d2a6 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 22 Oct 2019 15:03:09 +0200 Subject: [PATCH] rlc v2: improve buffer status reporting The old method was wrong. The new method is better, but not accurate, especially when the TX buffer contains SDU of size > 2047 bytes. Plus it's probably too slow. To be refined at some point. --- openair2/LAYER2/rlc_v2/rlc_entity_am.c | 5 +++++ openair2/LAYER2/rlc_v2/rlc_entity_um.c | 4 ++++ openair2/LAYER2/rlc_v2/rlc_oai_api.c | 15 ++++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/rlc_v2/rlc_entity_am.c b/openair2/LAYER2/rlc_v2/rlc_entity_am.c index 45c1d6332e..b4f3d2f47c 100644 --- a/openair2/LAYER2/rlc_v2/rlc_entity_am.c +++ b/openair2/LAYER2/rlc_v2/rlc_entity_am.c @@ -1394,10 +1394,15 @@ rlc_entity_buffer_status_t rlc_entity_am_buffer_status( ret.status_size = 0; /* TX PDU */ + /* todo: if an SDU has size >2047 in the tx list then processing + * stops and computed size will not be accurate. Change the computation + * to be more accurate (if needed). + */ tx_size = compute_new_pdu_size(entity, maxsize); ret.tx_size = tx_size.data_size + tx_size.header_size; /* reTX PDU */ + /* todo: report size of all available data, not just first PDU */ ret.retx_size = retx_pdu_size(entity, maxsize); return ret; diff --git a/openair2/LAYER2/rlc_v2/rlc_entity_um.c b/openair2/LAYER2/rlc_v2/rlc_entity_um.c index 75692851cd..f0fe33789b 100644 --- a/openair2/LAYER2/rlc_v2/rlc_entity_um.c +++ b/openair2/LAYER2/rlc_v2/rlc_entity_um.c @@ -407,6 +407,10 @@ rlc_entity_buffer_status_t rlc_entity_um_buffer_status( ret.status_size = 0; + /* todo: if an SDU has size >2047 in the tx list then processing + * stops and computed size will not be accurate. Change the computation + * to be more accurate (if needed). + */ tx_size = tx_pdu_size(entity, maxsize); ret.tx_size = tx_size.data_size + tx_size.header_size; diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index d51a61d4bb..d789e438be 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -170,13 +170,14 @@ mac_rlc_status_resp_t mac_rlc_status_ind( if (rb != NULL) { rlc_entity_buffer_status_t buf_stat; rb->set_time(rb, rlc_current_time); - buf_stat = rb->buffer_status(rb, tb_sizeP ? tb_sizeP : 1000000); - if (buf_stat.status_size) - ret.bytes_in_buffer = buf_stat.status_size; - else if (buf_stat.retx_size) - ret.bytes_in_buffer = buf_stat.retx_size; - else - ret.bytes_in_buffer = buf_stat.tx_size; + /* 36.321 deals with BSR values up to 3000000 bytes, after what it + * reports '> 3000000' (table 6.1.3.1-2). Passing 4000000 is thus + * more than enough. + */ + buf_stat = rb->buffer_status(rb, 4000000); + ret.bytes_in_buffer = buf_stat.status_size + + buf_stat.retx_size + + buf_stat.tx_size; ue->saved_status_ind_tb_size[channel_idP - 1] = tb_sizeP; } else { ret.bytes_in_buffer = 0;