lib,rlc_am_nr: made sure that the return of rx_mod_base and tx_mod_base is signed by changing from a macro to an class method.

master
Pedro Alvarez 3 years ago
parent 4b69af7ca2
commit 665aea599c

@ -25,6 +25,8 @@
#include <pthread.h> #include <pthread.h>
#include <queue> #include <queue>
const uint32_t mod_nr = 4096;
namespace srsran { namespace srsran {
/****************************** /******************************
@ -104,6 +106,8 @@ private:
rlc_am* parent = nullptr; rlc_am* parent = nullptr;
rlc_am_nr_rx* rx = nullptr; rlc_am_nr_rx* rx = nullptr;
inline int32_t tx_mod_base_nr(uint32_t sn) { return ((int32_t)sn - (int32_t)st.tx_next_ack) % mod_nr; }
/**************************************************************************** /****************************************************************************
* Configurable parameters * Configurable parameters
* Ref: 3GPP TS 38.322 v16.2.0 Section 7.4 * Ref: 3GPP TS 38.322 v16.2.0 Section 7.4
@ -166,6 +170,8 @@ private:
rlc_am_nr_tx* tx = nullptr; rlc_am_nr_tx* tx = nullptr;
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
inline int32_t rx_mod_base_nr(uint32_t sn) { return ((int32_t)sn - (int32_t)rx_next) % mod_nr; }
// RX Window // RX Window
rlc_ringbuffer_t<rlc_amd_rx_sdu_nr_t, RLC_AM_WINDOW_SIZE> rx_window; rlc_ringbuffer_t<rlc_amd_rx_sdu_nr_t, RLC_AM_WINDOW_SIZE> rx_window;

@ -20,9 +20,6 @@
#include <iostream> #include <iostream>
#define RLC_AM_NR_WINDOW_SIZE 2048 #define RLC_AM_NR_WINDOW_SIZE 2048
#define MOD_NR 4096
#define RX_MOD_BASE_NR(x) ((((int32_t)x) - (int32_t)rx_next) % MOD_NR)
//#define TX_MOD_BASE_NR(x) (((x)-vt_a) % MOD_NR)
namespace srsran { namespace srsran {
@ -509,7 +506,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes)
// 5.2.3.2.3 Actions when an AMD PDU is placed in the reception buffer // 5.2.3.2.3 Actions when an AMD PDU is placed in the reception buffer
// Update Rx_Next_Highest // Update Rx_Next_Highest
if (RX_MOD_BASE_NR(header.sn) >= RX_MOD_BASE_NR(rx_next_highest)) { if (rx_mod_base_nr(header.sn) >= rx_mod_base_nr(rx_next_highest)) {
rx_next_highest = (header.sn + 1) % MOD; rx_next_highest = (header.sn + 1) % MOD;
} }
@ -519,7 +516,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes)
* - update RX_Highest_Status to the SN of the first RLC SDU with SN > current RX_Highest_Status for which not * - update RX_Highest_Status to the SN of the first RLC SDU with SN > current RX_Highest_Status for which not
* all bytes have been received. * all bytes have been received.
*/ */
if (RX_MOD_BASE_NR(header.sn) == RX_MOD_BASE_NR(rx_highest_status)) { if (rx_mod_base_nr(header.sn) == rx_mod_base_nr(rx_highest_status)) {
uint32_t sn_upd = 0; uint32_t sn_upd = 0;
uint32_t window_top = rx_next + RLC_AM_WINDOW_SIZE; uint32_t window_top = rx_next + RLC_AM_WINDOW_SIZE;
for (sn_upd = rx_highest_status; sn_upd < window_top; ++sn_upd) { for (sn_upd = rx_highest_status; sn_upd < window_top; ++sn_upd) {
@ -541,7 +538,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes)
* - update RX_Next to the SN of the first RLC SDU with SN > current RX_Next for which not all bytes * - update RX_Next to the SN of the first RLC SDU with SN > current RX_Next for which not all bytes
* have been received. * have been received.
*/ */
if (RX_MOD_BASE_NR(header.sn) == RX_MOD_BASE_NR(rx_next)) { if (rx_mod_base_nr(header.sn) == rx_mod_base_nr(rx_next)) {
uint32_t sn_upd = 0; uint32_t sn_upd = 0;
uint32_t window_top = rx_next + RLC_AM_WINDOW_SIZE; uint32_t window_top = rx_next + RLC_AM_WINDOW_SIZE;
for (sn_upd = rx_next; sn_upd < window_top; ++sn_upd) { for (sn_upd = rx_next; sn_upd < window_top; ++sn_upd) {
@ -596,8 +593,8 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes)
bool rlc_am_nr_rx::inside_rx_window(uint32_t sn) bool rlc_am_nr_rx::inside_rx_window(uint32_t sn)
{ {
return (RX_MOD_BASE_NR(sn) >= RX_MOD_BASE_NR(rx_next)) && return (rx_mod_base_nr(sn) >= rx_mod_base_nr(rx_next)) &&
(RX_MOD_BASE_NR(sn) < RX_MOD_BASE_NR(rx_next + RLC_AM_NR_WINDOW_SIZE)); (rx_mod_base_nr(sn) < rx_mod_base_nr(rx_next + RLC_AM_NR_WINDOW_SIZE));
} }
/* /*
@ -615,7 +612,7 @@ uint32_t rlc_am_nr_rx::get_status_pdu(rlc_am_nr_status_pdu_t* status, uint32_t m
byte_buffer_t tmp_buf; byte_buffer_t tmp_buf;
uint32_t i = status->ack_sn; uint32_t i = status->ack_sn;
while (RX_MOD_BASE_NR(i) <= RX_MOD_BASE_NR(rx_highest_status)) { while (rx_mod_base_nr(i) <= rx_mod_base_nr(rx_highest_status)) {
if (rx_window.has_sn(i) || i == rx_highest_status) { if (rx_window.has_sn(i) || i == rx_highest_status) {
// only update ACK_SN if this SN has been received, or if we reached the maximum possible SN // only update ACK_SN if this SN has been received, or if we reached the maximum possible SN
status->ack_sn = i; status->ack_sn = i;

Loading…
Cancel
Save