From 01530385f1b8a2080af5cd9d9555d990c4bb0013 Mon Sep 17 00:00:00 2001
From: fnabet <fabrice.nabet@alcatelonetouch.com>
Date: Wed, 15 Mar 2017 18:56:53 +0100
Subject: [PATCH] RLC AM fix Tx Status Report

---
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c               | 7 +++++--
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c       | 5 +++--
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c | 6 ++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
index c399fb8447..7d193bcd01 100644
--- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
+++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
@@ -134,8 +134,11 @@ rlc_am_get_status_pdu_buffer_occupancy(
 			} // end if segments
 			else
 			{
-				 /* Go to next received PDU or PDU Segment */
-				 cursor_p = cursor_p->next;
+				  /* Go to next received PDU or PDU segment with different SN */
+				  do
+				  {
+					  cursor_p = cursor_p->next;
+				  } while ((cursor_p != NULL) && (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn == sn_cursor));
 			}
 
 			sn_prev = RLC_AM_NEXT_SN(sn_cursor);
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 c66b826fd6..048466a1a9 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
@@ -638,7 +638,6 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu(
 		  mem_block_t* trunc_pdu = create_new_segment_from_pdu(tb_pP,next_waited_so,pdu_rx_info_p->payload_size - next_waited_so);
 
 		  if (trunc_pdu != NULL) {
-			  ((rlc_am_rx_pdu_management_t *) (trunc_pdu->data))->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING;
 			  /* Insert PDU Segment */
 			  list2_insert_after_element(trunc_pdu, previous_cursor_p, &rlc_pP->receiver_buffer);
 
@@ -1317,7 +1316,9 @@ rlc_am_rx_list_reassemble_rlc_sdus(
 	  }
 
 	  /* Reset Management pointers */
-	  if (cursor_p != NULL) {
+	  if ((cursor_p != NULL) &&
+			  ((((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn == RLC_AM_NEXT_SN(sn)) ||
+					  (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING))) {
 		  rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data));
 	  }
 	  else {
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 0d01d0b1ce..3a00946160 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
@@ -723,8 +723,10 @@ rlc_am_send_status_pdu(
     	  }
       } // end while on all PDU segments of sn_cursor
       else {
-    	  /* Go to next received PDU or PDU segment if sn_cursor is fully received */
-    	  cursor_p = cursor_p->next;
+    	  /* Go to next received PDU or PDU segment with different SN */
+    	  do {
+    		  	  cursor_p = cursor_p->next;
+    	  	  } while ((cursor_p != NULL) && (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn == sn_cursor));
       }
 
       /* Increment sn_nack except if sn_nack = vrMS and if current SN was not fully received */
-- 
GitLab