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.

This commit is contained in:
Pedro Alvarez 2021-12-02 14:18:07 +00:00
parent 4b69af7ca2
commit 665aea599c
2 changed files with 12 additions and 9 deletions

View File

@ -25,6 +25,8 @@
#include <pthread.h>
#include <queue>
const uint32_t mod_nr = 4096;
namespace srsran {
/******************************
@ -104,6 +106,8 @@ private:
rlc_am* parent = 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
* Ref: 3GPP TS 38.322 v16.2.0 Section 7.4
@ -166,6 +170,8 @@ private:
rlc_am_nr_tx* tx = 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
rlc_ringbuffer_t<rlc_amd_rx_sdu_nr_t, RLC_AM_WINDOW_SIZE> rx_window;

View File

@ -20,9 +20,6 @@
#include <iostream>
#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 {
@ -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
// 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;
}
@ -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
* 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 window_top = rx_next + RLC_AM_WINDOW_SIZE;
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
* 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 window_top = rx_next + RLC_AM_WINDOW_SIZE;
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)
{
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));
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));
}
/*
@ -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;
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) {
// only update ACK_SN if this SN has been received, or if we reached the maximum possible SN
status->ack_sn = i;