Commit 00306352 authored by fnabet's avatar fnabet

RLC AM Tx buffer: fix sn modulo window size access

parent b0d468c0
......@@ -120,8 +120,8 @@ rlc_am_pdu_sdu_data_cnf(
int pdu_sdu_index;
int sdu_index;
for (pdu_sdu_index = 0; pdu_sdu_index < rlc_pP->tx_data_pdu_buffer[snP].nb_sdus; pdu_sdu_index++) {
sdu_index = rlc_pP->tx_data_pdu_buffer[snP].sdus_index[pdu_sdu_index];
for (pdu_sdu_index = 0; pdu_sdu_index < rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].nb_sdus; pdu_sdu_index++) {
sdu_index = rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].sdus_index[pdu_sdu_index];
assert(sdu_index >= 0);
assert(sdu_index < RLC_AM_SDU_CONTROL_BUFFER_SIZE);
rlc_pP->input_sdus[sdu_index].nb_pdus_ack += 1;
......
......@@ -175,9 +175,9 @@ rlc_am_cleanup(
if (rlc_pP->tx_data_pdu_buffer != NULL) {
for (i=0; i < RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; i++) {
if (rlc_pP->tx_data_pdu_buffer[i].mem_block != NULL) {
free_mem_block(rlc_pP->tx_data_pdu_buffer[i].mem_block, __func__);
rlc_pP->tx_data_pdu_buffer[i].mem_block = NULL;
if (rlc_pP->tx_data_pdu_buffer[i % RLC_AM_WINDOW_SIZE].mem_block != NULL) {
free_mem_block(rlc_pP->tx_data_pdu_buffer[i % RLC_AM_WINDOW_SIZE].mem_block, __func__);
rlc_pP->tx_data_pdu_buffer[i % RLC_AM_WINDOW_SIZE].mem_block = NULL;
}
}
......
......@@ -51,8 +51,8 @@ boolean_t rlc_am_nack_pdu (
// - indicate to upper layers that max retransmission has been reached.
mem_block_t* mb_p = rlc_pP->tx_data_pdu_buffer[snP].mem_block;
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[snP];
mem_block_t* mb_p = rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].mem_block;
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE];
//int pdu_sdu_index;
//int sdu_index;
boolean_t status = TRUE;
......@@ -208,23 +208,24 @@ void rlc_am_ack_pdu (
rlc_am_entity_t *const rlc_pP,
const rlc_sn_t snP)
{
mem_block_t* mb_p = rlc_pP->tx_data_pdu_buffer[snP].mem_block;
mem_block_t* mb_p = rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].mem_block;
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer = &rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE];
rlc_pP->tx_data_pdu_buffer[snP].flags.retransmit = 0;
tx_data_pdu_buffer->flags.retransmit = 0;
if ((rlc_pP->tx_data_pdu_buffer[snP].flags.ack == 0) && (mb_p != NULL)) {
if ((tx_data_pdu_buffer->flags.ack == 0) && (mb_p != NULL)) {
//if (mb_pP != NULL) {
free_mem_block(mb_p, __func__);
rlc_pP->tx_data_pdu_buffer[snP].mem_block = NULL;
tx_data_pdu_buffer->mem_block = NULL;
LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[ACK-PDU] ACK PDU SN %05d previous retx_count %d \n",
PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),
snP,
rlc_pP->tx_data_pdu_buffer[snP].retx_count);
tx_data_pdu_buffer->retx_count);
if (rlc_pP->tx_data_pdu_buffer[snP].retx_payload_size) {
rlc_pP->retrans_num_bytes_to_retransmit -= rlc_pP->tx_data_pdu_buffer[snP].retx_payload_size;
rlc_pP->tx_data_pdu_buffer[snP].retx_payload_size = 0;
rlc_pP->tx_data_pdu_buffer[snP].num_holes = 0;
if (tx_data_pdu_buffer->retx_payload_size) {
rlc_pP->retrans_num_bytes_to_retransmit -= tx_data_pdu_buffer->retx_payload_size;
tx_data_pdu_buffer->retx_payload_size = 0;
tx_data_pdu_buffer->num_holes = 0;
rlc_pP->retrans_num_pdus --;
}
......@@ -235,12 +236,12 @@ void rlc_am_ack_pdu (
if (mb_p != NULL) {
free_mem_block(mb_p, __func__);
rlc_pP->tx_data_pdu_buffer[snP].mem_block = NULL;
tx_data_pdu_buffer->mem_block = NULL;
}
}
rlc_pP->tx_data_pdu_buffer[snP].flags.ack = 1;
rlc_pP->tx_data_pdu_buffer[snP].flags.transmitted = 0;
rlc_pP->tx_data_pdu_buffer[snP].flags.retransmit = 0;
tx_data_pdu_buffer->flags.ack = 1;
tx_data_pdu_buffer->flags.transmitted = 0;
tx_data_pdu_buffer->flags.retransmit = 0;
}
//-----------------------------------------------------------------------------
......@@ -249,12 +250,12 @@ mem_block_t* rlc_am_retransmit_get_copy (
rlc_am_entity_t *const rlc_pP,
const rlc_sn_t snP)
{
mem_block_t* mb_original_p = rlc_pP->tx_data_pdu_buffer[snP].mem_block;
mem_block_t* mb_original_p = rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].mem_block;
AssertFatal (mb_original_p != NULL, "RLC AM PDU Copy Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n",
snP,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id);
rlc_am_tx_data_pdu_management_t *pdu_mngt = &rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE];
rlc_am_tx_data_pdu_management_t *pdu_mngt = &rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE];
/* We need to allocate a new buffer and copy to it because header content may change for Polling bit */
int size = pdu_mngt->header_and_payload_size + sizeof(struct mac_tb_req);
......@@ -1061,6 +1062,7 @@ void rlc_am_tx_buffer_display (
{
rlc_sn_t sn = rlc_pP->vt_a;
int i, loop = 0;
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer_p;
if (message_pP) {
LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT" Retransmission buffer %s VT(A)=%04d VT(S)=%04d:",
......@@ -1076,25 +1078,26 @@ void rlc_am_tx_buffer_display (
}
while (rlc_pP->vt_s != sn) {
if (rlc_pP->tx_data_pdu_buffer[sn].mem_block) {
tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE];
if (tx_data_pdu_buffer_p->mem_block) {
if ((loop % 1) == 0) {
LOG_D(RLC, "\nTX SN:\t");
}
if (rlc_pP->tx_data_pdu_buffer[sn].flags.retransmit) {
LOG_D(RLC, "%04d %d/%d Bytes (NACK RTX:%02d ",sn, rlc_pP->tx_data_pdu_buffer[sn].header_and_payload_size, rlc_pP->tx_data_pdu_buffer[sn].payload_size,
rlc_pP->tx_data_pdu_buffer[sn].retx_count);
if (tx_data_pdu_buffer_p->flags.retransmit) {
LOG_D(RLC, "%04d %d/%d Bytes (NACK RTX:%02d ",sn, tx_data_pdu_buffer_p->header_and_payload_size, tx_data_pdu_buffer_p->payload_size,
tx_data_pdu_buffer_p->retx_count);
} else {
LOG_D(RLC, "%04d %d/%d Bytes (RTX:%02d ",sn, rlc_pP->tx_data_pdu_buffer[sn].header_and_payload_size, rlc_pP->tx_data_pdu_buffer[sn].payload_size,
rlc_pP->tx_data_pdu_buffer[sn].retx_count);
LOG_D(RLC, "%04d %d/%d Bytes (RTX:%02d ",sn, tx_data_pdu_buffer_p->header_and_payload_size, tx_data_pdu_buffer_p->payload_size,
tx_data_pdu_buffer_p->retx_count);
}
if (rlc_pP->tx_data_pdu_buffer[sn].num_holes == 0) {
LOG_D(RLC, "SO:%04d->%04d)\t", rlc_pP->tx_data_pdu_buffer[sn].nack_so_start, rlc_pP->tx_data_pdu_buffer[sn].nack_so_stop);
if (tx_data_pdu_buffer_p->num_holes == 0) {
LOG_D(RLC, "SO:%04d->%04d)\t", tx_data_pdu_buffer_p->nack_so_start, tx_data_pdu_buffer_p->nack_so_stop);
} else {
for (i=0; i<rlc_pP->tx_data_pdu_buffer[sn].num_holes; i++) {
for (i=0; i<tx_data_pdu_buffer_p->num_holes; i++) {
assert(i < RLC_AM_MAX_HOLES_REPORT_PER_PDU);
LOG_D(RLC, "SO:%04d->%04d)\t", rlc_pP->tx_data_pdu_buffer[sn].hole_so_start[i], rlc_pP->tx_data_pdu_buffer[sn].hole_so_stop[i]);
LOG_D(RLC, "SO:%04d->%04d)\t", tx_data_pdu_buffer_p->hole_so_start[i], tx_data_pdu_buffer_p->hole_so_stop[i]);
}
}
......
......@@ -19,6 +19,7 @@
* contact@openairinterface.org
*/
#if 0
#define RLC_AM_MODULE 1
#define RLC_AM_SEGMENT_HOLES_C 1
//-----------------------------------------------------------------------------
......@@ -315,3 +316,4 @@ void rlc_am_add_hole (
assert(rlc_pP->tx_data_pdu_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU);
assert(rlc_pP->tx_data_pdu_buffer[snP].nack_so_start < rlc_pP->tx_data_pdu_buffer[snP].payload_size);
}
#endif
......@@ -32,7 +32,7 @@
* @ingroup _rlc_am_internal_segment_impl_
* @{
*/
#if 0
#ifndef __RLC_AM_SEGMENT_HOLES_H__
# define __RLC_AM_SEGMENT_HOLES_H__
//-----------------------------------------------------------------------------
......@@ -108,3 +108,4 @@ protected_rlc_am_segments_holes(void rlc_am_add_hole (
sdu_size_t so_stopP);)
/** @} */
#endif
#endif
......@@ -268,7 +268,7 @@ rlc_am_receive_process_control_pdu(
{
rlc_am_pdu_sn_10_t *rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t*)*first_byte_ppP;
sdu_size_t initial_pdu_size = *tb_size_in_bytes_pP;
rlc_sn_t ack_sn = rlc_pP->control_pdu_info.ack_sn;
rlc_sn_t ack_sn = RLC_AM_NEXT_SN(rlc_pP->vt_a);
rlc_sn_t sn_cursor = rlc_pP->vt_a;
rlc_sn_t vt_a_new = rlc_pP->vt_a;
rlc_sn_t sn_data_cnf;
......@@ -288,7 +288,7 @@ rlc_am_receive_process_control_pdu(
rlc_pP->control_pdu_info.ack_sn);
rlc_am_display_control_pdu_infos(&rlc_pP->control_pdu_info);
ack_sn = rlc_pP->control_pdu_info.ack_sn;
// 5.2.1 Retransmission
//
// The transmitting side of an AM RLC entity can receive a negative acknowledgement (notification of reception failure
......@@ -337,7 +337,7 @@ rlc_am_receive_process_control_pdu(
vt_a_new = nack_sn;
// catch DataCfn
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[nack_sn];
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[nack_sn % RLC_AM_WINDOW_SIZE];
if (tx_data_pdu_buffer_p->retx_payload_size == tx_data_pdu_buffer_p->payload_size) {
sn_data_cnf = RLC_AM_PREV_SN(nack_sn);
}
......
......@@ -83,18 +83,20 @@ rlc_am_check_timer_poll_retransmit(
// force BO to be > 0
rlc_sn_t sn = RLC_AM_PREV_SN(rlc_pP->vt_s);
rlc_sn_t sn_end = RLC_AM_PREV_SN(rlc_pP->vt_a);
rlc_am_tx_data_pdu_management_t *tx_data_pdu_buffer_p;
/* Look for the first retransmittable PDU starting from vtS - 1 */
while (sn != sn_end) {
AssertFatal (rlc_pP->tx_data_pdu_buffer[sn].mem_block != NULL, "RLC AM Tpoll Retx expiry sn=%d is empty vtA=%d vtS=%d LcId=%d\n",
tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE];
AssertFatal (tx_data_pdu_buffer_p->mem_block != NULL, "RLC AM Tpoll Retx expiry sn=%d is empty vtA=%d vtS=%d LcId=%d\n",
sn, rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id);
if ((rlc_pP->tx_data_pdu_buffer[sn].flags.ack == 0) && (rlc_pP->tx_data_pdu_buffer[sn].flags.max_retransmit == 0)) {
rlc_pP->tx_data_pdu_buffer[sn].flags.retransmit = 1;
if (rlc_pP->tx_data_pdu_buffer[sn].retx_count == rlc_pP->tx_data_pdu_buffer[sn].retx_count_next) {
rlc_pP->tx_data_pdu_buffer[sn].retx_count_next ++;
if ((tx_data_pdu_buffer_p->flags.ack == 0) && (tx_data_pdu_buffer_p->flags.max_retransmit == 0)) {
tx_data_pdu_buffer_p->flags.retransmit = 1;
if (tx_data_pdu_buffer_p->retx_count == tx_data_pdu_buffer_p->retx_count_next) {
tx_data_pdu_buffer_p->retx_count_next ++;
}
rlc_pP->retrans_num_pdus += 1;
rlc_pP->retrans_num_bytes_to_retransmit += rlc_pP->tx_data_pdu_buffer[sn].payload_size;
rlc_pP->retrans_num_bytes_to_retransmit += tx_data_pdu_buffer_p->payload_size;
break;
}
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment