From 40fa3e076cd50b403f5034063890ac07b1053547 Mon Sep 17 00:00:00 2001
From: gabrielC <couturier.gabriel@gmail.com>
Date: Wed, 15 Mar 2017 16:58:54 +0100
Subject: [PATCH] RLC AM Rx fixes

---
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c       | 12 +++++++++---
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c |  8 ++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c
index fd84cd5e354..c66b826fd69 100644
--- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c
+++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c
@@ -490,7 +490,7 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu_segment(
 
 		  mem_block_t* trunc_segment = create_new_segment_from_pdu(tb_pP,so_start_segment - pdu_rx_info_p->so,so_end_segment - so_start_segment + 1);
 		  if (trunc_segment != NULL) {
-			  LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT]  CREATE SEGMENT FROM SEGMENT OFFSET=%d DATA LENGTH=%d SN=%d\n",
+			  LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT]  CREATE SEGMENT FROM SEGMENT OFFSET=%d DATA LENGTH=%d SN=%d\n",
 			  	              PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),so_start_segment - pdu_rx_info_p->so,so_end_segment - so_start_segment + 1,pdu_rx_info_p->sn);
 
 			  if (previous_cursor_p != NULL) {
@@ -610,7 +610,13 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu(
 	      LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU]  PDU REPLACES STORED PDU SEGMENTS SN=%d\n",
 	              PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_rx_info_p->sn);
 
-		  list2_insert_after_element(tb_pP, previous_cursor_p, &rlc_pP->receiver_buffer);
+	      if (previous_cursor_p != NULL) {
+	          list2_insert_after_element(tb_pP, previous_cursor_p, &rlc_pP->receiver_buffer);
+	      }
+	      else {
+	          list2_insert_before_element(tb_pP, cursor_next_p, &rlc_pP->receiver_buffer);
+	      }
+
 		  return pdu_status;
 	  } // End SN != vrR or SO != 0
 	  else {
@@ -636,7 +642,7 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu(
 			  /* Insert PDU Segment */
 			  list2_insert_after_element(trunc_pdu, previous_cursor_p, &rlc_pP->receiver_buffer);
 
-		      LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU]  CREATE PDU SEGMENT FROM PDU OFFSET =%d SN=%d\n",
+		      LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU]  CREATE PDU SEGMENT FROM PDU OFFSET =%d SN=%d\n",
 		              PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),next_waited_so,pdu_rx_info_p->sn);
 
 			  /* clean previous stored segments in duplicate */
diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c
index 50ed5dca560..0d01d0b1ce9 100644
--- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c
+++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c
@@ -736,8 +736,12 @@ rlc_am_send_status_pdu(
     } // End main while NACK_SN
 
     /* Clear E1 of last nack_sn entry */
-	AssertFatal ((control_pdu_info.num_nack) || (all_segments_received == 0), "RLC AM Tx Status PDU Data Error no NACK_SN LcId=%d\n",rlc_pP->channel_id);
-    control_pdu_info.nack_list[control_pdu_info.num_nack - 1].e1  = 0;
+	AssertFatal ((control_pdu_info.num_nack) || (all_segments_received == 0), "RLC AM Tx Status PDU Data Error no NACK_SN vrR=%d vrMS=%d lastSN_NACK=%d Completed=%d NbBytesAvailable=%d LcId=%d\n",
+	        rlc_pP->vr_r,rlc_pP->vr_ms,sn_nack,status_report_completed,(nb_bits_to_transmit >> 3),rlc_pP->channel_id);
+	if (control_pdu_info.num_nack) {
+	    control_pdu_info.nack_list[control_pdu_info.num_nack - 1].e1  = 0;
+	}
+
 
     /* Set ACK_SN unless it was set before */
     if (!status_report_completed){
-- 
GitLab