From 389cf4d9434eeca33efd8bc184de80f817b6ab41 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 15 Jan 2021 13:07:30 +0000 Subject: [PATCH] Moved updating the notify info to it's own function. --- lib/include/srslte/upper/rlc_am_lte.h | 9 +++-- lib/src/upper/rlc_am_lte.cc | 55 ++++++++++++++++----------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srslte/upper/rlc_am_lte.h index abb1acf47..ed7754a49 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srslte/upper/rlc_am_lte.h @@ -124,10 +124,11 @@ private: void set_bsr_callback(bsr_callback_t callback); private: - int build_status_pdu(uint8_t* payload, uint32_t nof_bytes); - int build_retx_pdu(uint8_t* payload, uint32_t nof_bytes); - int build_segment(uint8_t* payload, uint32_t nof_bytes, rlc_amd_retx_t retx); - int build_data_pdu(uint8_t* payload, uint32_t nof_bytes); + int build_status_pdu(uint8_t* payload, uint32_t nof_bytes); + int build_retx_pdu(uint8_t* payload, uint32_t nof_bytes); + int build_segment(uint8_t* payload, uint32_t nof_bytes, rlc_amd_retx_t retx); + int build_data_pdu(uint8_t* payload, uint32_t nof_bytes); + void update_notification_ack_info(const rlc_amd_tx_pdu_t& tx_pdu, std::vector& notify_info_vec); void debug_state(); diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 9e3edd528..320f95d48 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -1050,28 +1050,7 @@ void rlc_am_lte::rlc_am_lte_tx::handle_control_pdu(uint8_t* payload, uint32_t no it = tx_window.find(i); if (it != tx_window.end()) { if (update_vt_a) { - // Notify PDCP of the number of bytes succesfully delivered - uint32_t notified_bytes = 0; - uint32_t nof_bytes = 0; - uint32_t pdcp_sn = 0; - for (uint32_t pdcp_notify_it = 0; pdcp_notify_it < it->second.header.N_li; pdcp_notify_it++) { - nof_bytes = it->second.header.li[pdcp_notify_it]; - pdcp_sn = it->second.pdcp_tx_counts[pdcp_notify_it]; - undelivered_sdu_info_queue[pdcp_sn].acked_bytes += nof_bytes; - if (undelivered_sdu_info_queue[pdcp_sn].acked_bytes >= undelivered_sdu_info_queue[pdcp_sn].total_bytes) { - undelivered_sdu_info_queue.erase(pdcp_sn); - notify_info_vec.push_back(pdcp_sn); - log->debug("Reporting to PDCP: TX COUNT=%d, nof_bytes=%d\n", pdcp_sn, nof_bytes); - } - } - pdcp_sn = it->second.pdcp_tx_counts[it->second.header.N_li]; - nof_bytes = it->second.buf->N_bytes - notified_bytes; // Notify last SDU - undelivered_sdu_info_queue[pdcp_sn].acked_bytes += nof_bytes; - if (undelivered_sdu_info_queue[pdcp_sn].acked_bytes >= undelivered_sdu_info_queue[pdcp_sn].total_bytes) { - undelivered_sdu_info_queue.erase(pdcp_sn); - notify_info_vec.push_back(pdcp_sn); - log->debug("Reporting to PDCP: TX COUNT=%d, nof_bytes=%d\n", pdcp_sn, nof_bytes); - } + update_notification_ack_info(it->second, notify_info_vec); tx_window.erase(it); vt_a = (vt_a + 1) % MOD; vt_ms = (vt_ms + 1) % MOD; @@ -1091,6 +1070,38 @@ void rlc_am_lte::rlc_am_lte_tx::handle_control_pdu(uint8_t* payload, uint32_t no pthread_mutex_unlock(&mutex); } +/* + * Helper function to detect whether a PDU has been fully ack'ed and the PDCP needs to be notified about it + * @tx_pdu: RLC PDU that was ack'ed. + * @notify_info_vec: Vector which will keep track of the PDCP PDU SNs that have been fully ack'ed. + */ +void rlc_am_lte::rlc_am_lte_tx::update_notification_ack_info(const rlc_amd_tx_pdu_t& tx_pdu, + std::vector& notify_info_vec) +{ + // Notify PDCP of the number of bytes succesfully delivered + uint32_t notified_bytes = 0; + uint32_t nof_bytes = 0; + uint32_t pdcp_sn = 0; + for (uint32_t pdcp_notify_it = 0; pdcp_notify_it < tx_pdu.header.N_li; pdcp_notify_it++) { + nof_bytes = tx_pdu.header.li[pdcp_notify_it]; + pdcp_sn = tx_pdu.pdcp_tx_counts[pdcp_notify_it]; + undelivered_sdu_info_queue[pdcp_sn].acked_bytes += nof_bytes; + if (undelivered_sdu_info_queue[pdcp_sn].acked_bytes >= undelivered_sdu_info_queue[pdcp_sn].total_bytes) { + undelivered_sdu_info_queue.erase(pdcp_sn); + notify_info_vec.push_back(pdcp_sn); + log->debug("Reporting to PDCP: PDCP SN=%d, nof_bytes=%d\n", pdcp_sn, nof_bytes); + } + } + pdcp_sn = tx_pdu.pdcp_tx_counts[tx_pdu.header.N_li]; + nof_bytes = tx_pdu.buf->N_bytes - notified_bytes; // Notify last SDU + undelivered_sdu_info_queue[pdcp_sn].acked_bytes += nof_bytes; + if (undelivered_sdu_info_queue[pdcp_sn].acked_bytes >= undelivered_sdu_info_queue[pdcp_sn].total_bytes) { + undelivered_sdu_info_queue.erase(pdcp_sn); + notify_info_vec.push_back(pdcp_sn); + log->debug("Reporting to PDCP: PDCP SN=%d, nof_bytes=%d\n", pdcp_sn, nof_bytes); + } +} + void rlc_am_lte::rlc_am_lte_tx::debug_state() { log->debug("%s vt_a = %d, vt_ms = %d, vt_s = %d, poll_sn = %d\n", RB_NAME, vt_a, vt_ms, vt_s, poll_sn);