Commit f747a4da authored by gauthier's avatar gauthier
Browse files

No ring buffer for input SDUs but list ('infinite' capacity), may have...

No ring buffer for input SDUs but list ('infinite' capacity), may have corrected also concurrency problems (sdu mngt pointer)

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6044 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 2ba14ef2
......@@ -406,6 +406,7 @@ rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP
uint16_t sdu_remaining_size = 0;
int32_t diff_time=0;
rlc_um_entity_t *rlc_p = NULL;
mem_block_t *mb_p = NULL;
status_resp.buffer_occupancy_in_pdus = 0;
status_resp.buffer_occupancy_in_bytes = 0;
......@@ -421,25 +422,25 @@ rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP
rlc_p->nb_bytes_requested_by_mac = tbs_sizeP;
status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy (rlc_p);
if (status_resp.buffer_occupancy_in_bytes > 0) {
if ((status_resp.buffer_occupancy_in_bytes > 0) && ((mb_p = list_get_head(&rlc_p->input_sdus)) != NULL)) {
status_resp.buffer_occupancy_in_bytes += rlc_p->tx_header_min_length_in_bytes;
status_resp.buffer_occupancy_in_pdus = rlc_p->nb_sdu;
status_resp.buffer_occupancy_in_bytes += rlc_p->tx_header_min_length_in_bytes;
status_resp.buffer_occupancy_in_pdus = rlc_p->input_sdus.nb_elements;
diff_time = frameP - ((struct rlc_um_tx_sdu_management *) (rlc_p->input_sdus[rlc_p->current_sdu_index])->data)->sdu_creation_time;
status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (uint32_t) diff_time : (uint32_t)(0xffffffff - diff_time + frameP) ;
//msg("rlc_p status for frameP %d diff time %d resp %d\n", frameP, diff_time,status_resp.head_sdu_creation_time) ;
diff_time = frameP - ((struct rlc_um_tx_sdu_management *)mb_p->data)->sdu_creation_time;
status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (uint32_t) diff_time : (uint32_t)(0xffffffff - diff_time + frameP) ;
//msg("rlc_p status for frameP %d diff time %d resp %d\n", frameP, diff_time,status_resp.head_sdu_creation_time) ;
sdu_size = ((struct rlc_um_tx_sdu_management *) (rlc_p->input_sdus[rlc_p->current_sdu_index])->data)->sdu_size;
sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) (rlc_p->input_sdus[rlc_p->current_sdu_index])->data)->sdu_remaining_size;
sdu_size = ((struct rlc_um_tx_sdu_management *) mb_p->data)->sdu_size;
sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) mb_p->data)->sdu_remaining_size;
status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size;
if (sdu_size == sdu_remaining_size) {
status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size;
if (sdu_size == sdu_remaining_size) {
status_resp.head_sdu_is_segmented = 0;
}
else {
status_resp.head_sdu_is_segmented = 1;
}
}
else {
status_resp.head_sdu_is_segmented = 1;
}
} else {
}
......@@ -624,7 +625,7 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP)
uint16_t data_size;
#endif
LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n",
LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d\n",
frameP,
(rlc_p->is_enb) ? "eNB" : "UE",
rlc_p->enb_module_id,
......@@ -632,13 +633,12 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP)
rlc_p->rb_id,
((struct rlc_um_data_req *) (sdu_pP->data))->data_size,
rlc_p->buffer_occupancy,
rlc_p->nb_sdu,
rlc_p->current_sdu_index,
rlc_p->next_sdu_index);
rlc_util_print_hex_octets(
rlc_p->input_sdus.nb_elements);
/*rlc_util_print_hex_octets(
RLC,
(uint8_t*)&sdu_pP->data[sizeof (struct rlc_um_data_req_alloc)],
((struct rlc_um_data_req *) (sdu_pP->data))->data_size);
((struct rlc_um_data_req *) (sdu_pP->data))->data_size);*/
/*#ifndef USER_MODE
rlc_um_time_us = (unsigned long int)(rt_get_time_ns ()/(RTIME)1000);
......@@ -648,18 +648,17 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP)
usec = rlc_um_time_us % 1000000;
msg ("[RLC_UM_LITE][RB %d] at time %2d:%2d.%6d\n", rlc_p->rb_id, min, sec , usec);
#endif*/
if (rlc_p->input_sdus[rlc_p->next_sdu_index] == NULL) {
rlc_p->input_sdus[rlc_p->next_sdu_index] = sdu_pP;
// IMPORTANT : do not change order of affectations
((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size = ((struct rlc_um_data_req *) (sdu_pP->data))->data_size;
rlc_p->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size;
rlc_p->nb_sdu += 1;
//rlc_p->nb_sdu += 1;
((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->first_byte = (uint8_t*)&sdu_pP->data[sizeof (struct rlc_um_data_req_alloc)];
((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management *)
(sdu_pP->data))->sdu_size;
((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_segmented_size = 0;
((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_creation_time = frameP;
rlc_p->next_sdu_index = (rlc_p->next_sdu_index + 1) % rlc_p->size_input_sdus_buffer;
//rlc_p->next_sdu_index = (rlc_p->next_sdu_index + 1) % rlc_p->size_input_sdus_buffer;
rlc_p->stat_tx_pdcp_sdu += 1;
rlc_p->stat_tx_pdcp_bytes += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size;
......@@ -710,8 +709,9 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP)
LOG_T(RLC, "%s", message_string);
#endif
# endif
list_add_tail_eurecom(sdu_pP, &rlc_p->input_sdus);
} else {
/*} else {
LOG_W(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC-UM_DATA_REQ input buffer full SDU garbaged\n",
frameP,
(rlc_p->is_enb) ? "eNB" : "UE",
......@@ -731,5 +731,5 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP)
rlc_p->ue_module_id,
rlc_p->rb_id);
#endif
}
}*/
}
......@@ -240,6 +240,7 @@ rlc_um_init (rlc_um_entity_t * const rlc_pP)
memset (rlc_pP, 0, sizeof (rlc_um_entity_t));
// TX SIDE
list_init (&rlc_pP->pdus_to_mac_layer, NULL);
list_init (&rlc_pP->input_sdus, NULL);
rlc_pP->protocol_state = RLC_NULL_STATE;
//rlc_pP->nb_sdu = 0;
......@@ -262,15 +263,15 @@ rlc_um_init (rlc_um_entity_t * const rlc_pP)
rlc_pP->tx_header_min_length_in_bytes = 2;
// SPARE : not 3GPP
#ifdef JUMBO_FRAME
/*#ifdef JUMBO_FRAME
rlc_pP->size_input_sdus_buffer =1024;
#else
rlc_pP->size_input_sdus_buffer =128;
#endif
#endif*/
if ((rlc_pP->input_sdus == NULL) && (rlc_pP->size_input_sdus_buffer > 0)) {
/*if ((rlc_pP->input_sdus == NULL) && (rlc_pP->size_input_sdus_buffer > 0)) {
rlc_pP->input_sdus = calloc(1 , rlc_pP->size_input_sdus_buffer * sizeof (void *));
}
}*/
if (rlc_pP->dar_buffer == NULL) {
rlc_pP->dar_buffer = calloc (1, 1024 * sizeof (void *));
}
......@@ -285,9 +286,9 @@ rlc_um_reset_state_variables (rlc_um_entity_t * const rlc_pP)
{
//-----------------------------------------------------------------------------
rlc_pP->buffer_occupancy = 0;
rlc_pP->nb_sdu = 0;
rlc_pP->next_sdu_index = 0;
rlc_pP->current_sdu_index = 0;
//rlc_pP->nb_sdu = 0;
//rlc_pP->next_sdu_index = 0;
//rlc_pP->current_sdu_index = 0;
// TX SIDE
rlc_pP->vt_us = 0;
......@@ -304,8 +305,9 @@ rlc_um_cleanup (rlc_um_entity_t * const rlc_pP)
int index;
// TX SIDE
list_free (&rlc_pP->pdus_to_mac_layer);
list_free (&rlc_pP->input_sdus);
if (rlc_pP->input_sdus) {
/*if (rlc_pP->input_sdus) {
for (index = 0; index < rlc_pP->size_input_sdus_buffer; index++) {
if (rlc_pP->input_sdus[index]) {
free_mem_block (rlc_pP->input_sdus[index]);
......@@ -313,7 +315,7 @@ rlc_um_cleanup (rlc_um_entity_t * const rlc_pP)
}
free (rlc_pP->input_sdus);
rlc_pP->input_sdus = NULL;
}
}*/
// RX SIDE
list_free (&rlc_pP->pdus_from_mac_layer);
if ((rlc_pP->output_sdu_in_construction)) {
......
......@@ -93,11 +93,12 @@ typedef struct rlc_um_entity_s {
// tranmission
//-----------------------------
// sdu communication;
mem_block_t **input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */
uint16_t size_input_sdus_buffer; /*!< \brief Size of the input SDU buffer. */
uint16_t nb_sdu; /*!< \brief Total number of SDUs in input_sdus[] */
uint16_t next_sdu_index; /*!< \brief Next SDU index for a new incomin SDU in input_sdus[]. */
uint16_t current_sdu_index; /*!< \brief Current SDU index in input_sdus array to be segmented. */
list_t input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */
//mem_block_t **input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */
//uint16_t size_input_sdus_buffer; /*!< \brief Size of the input SDU buffer. */
//uint16_t nb_sdu; /*!< \brief Total number of SDUs in input_sdus[] */
//uint16_t next_sdu_index; /*!< \brief Next SDU index for a new incomin SDU in input_sdus[]. */
//uint16_t current_sdu_index; /*!< \brief Current SDU index in input_sdus array to be segmented. */
rlc_buffer_occupancy_t buffer_occupancy; /*!< \brief Number of bytes contained in input_sdus buffer.*/
uint32_t nb_bytes_requested_by_mac; /*!< \brief Number of bytes requested by lower layer for next transmission. */
list_t pdus_to_mac_layer; /*!< \brief PDUs buffered for transmission to MAC layer. */
......
......@@ -68,7 +68,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
unsigned int num_fill_sdu;
unsigned int test_num_li;
unsigned int fill_num_li;
unsigned int sdu_buffer_index;
mem_block_t *sdu_in_buffer = NULL;
unsigned int data_pdu_size;
unsigned int fi_first_byte_pdu_is_first_byte_sdu;
......@@ -99,7 +99,8 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
list_init (&pdus, NULL); // param string identifying the list is NULL
pdu_mem_p = NULL;
while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (nb_bytes_to_transmit > 0)) {
while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) {
#if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 nb_bytes_to_transmit %d BO %d\n",
frameP,
......@@ -112,10 +113,10 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
#endif
// pdu_p management
if (!pdu_mem_p) {
if (rlc_pP->nb_sdu <= 1) {
if (rlc_pP->input_sdus.nb_elements <= 1) {
max_li_overhead = 0;
} else {
max_li_overhead = (((rlc_pP->nb_sdu - 1) * 3) / 2) + ((rlc_pP->nb_sdu - 1) % 2);
max_li_overhead = (((rlc_pP->input_sdus.nb_elements - 1) * 3) / 2) + ((rlc_pP->input_sdus.nb_elements - 1) % 2);
}
if (nb_bytes_to_transmit >= (rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead)) {
data_pdu_size = rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead;
......@@ -173,15 +174,15 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
continue_fill_pdu_with_sdu = 1;
num_fill_sdu = 0;
test_num_li = 0;
sdu_buffer_index = rlc_pP->current_sdu_index;
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
test_pdu_remaining_size = pdu_remaining_size;
test_li_length_in_bytes = 1;
test_remaining_size_to_substract = 0;
test_remaining_num_li_to_substract = 0;
while ((rlc_pP->input_sdus[sdu_buffer_index]) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[sdu_buffer_index]->data));
while ((sdu_in_buffer) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data));
if (sdu_mngt_p->sdu_remaining_size > test_pdu_remaining_size) {
// no LI
......@@ -232,7 +233,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
test_remaining_num_li_to_substract = 0;
pdu_remaining_size = pdu_remaining_size - 1;
}
sdu_buffer_index = (sdu_buffer_index + 1) % rlc_pP->size_input_sdus_buffer;
sdu_in_buffer = sdu_in_buffer->next;
}
if (test_remaining_num_li_to_substract > 0) {
// there is a LI that is not necessary
......@@ -261,13 +262,14 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
fi_first_byte_pdu_is_first_byte_sdu = 0;
fi_last_byte_pdu_is_last_byte_sdu = 0;
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
if (
((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_remaining_size ==
((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_size) {
((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data))->sdu_remaining_size ==
((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data))->sdu_size) {
fi_first_byte_pdu_is_first_byte_sdu = 1;
}
while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data));
while ((sdu_in_buffer) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data));
if (sdu_mngt_p->sdu_segmented_size == 0) {
#if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n",
......@@ -292,7 +294,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
sdu_mngt_p->sdu_size);
#endif
}
data_sdu_p = &((rlc_pP->input_sdus[rlc_pP->current_sdu_index])->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt_p->sdu_segmented_size]);
data_sdu_p = &(sdu_in_buffer->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt_p->sdu_segmented_size]);
if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) {
#if defined(TRACE_RLC_UM_SEGMENT)
......@@ -340,10 +342,11 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]);
rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL;
rlc_pP->nb_sdu -= 1;
rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer;
sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus);
free_mem_block (sdu_in_buffer);
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
sdu_mngt_p = NULL;
fi_last_byte_pdu_is_last_byte_sdu = 1;
// fi will indicate end of PDU is end of SDU, no need for LI
......@@ -409,14 +412,15 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
e_li_p++;
}
pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes);
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]);
rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL;
rlc_pP->nb_sdu -= 1;
rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer;
sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus);
free_mem_block (sdu_in_buffer);
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
sdu_mngt_p = NULL;
pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes);
} else {
#if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n",
......@@ -434,17 +438,17 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
#endif
#endif
memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size);
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]);
rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL;
rlc_pP->nb_sdu -= 1;
rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer;
// reduce the size of the PDU
continue_fill_pdu_with_sdu = 0;
fi_last_byte_pdu_is_last_byte_sdu = 1;
pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size;
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus);
free_mem_block (sdu_in_buffer);
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
sdu_mngt_p = NULL;
}
}
......@@ -486,32 +490,32 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
{
//-----------------------------------------------------------------------------
list_t pdus;
signed int pdu_remaining_size;
signed int test_pdu_remaining_size;
signed int pdu_remaining_size = 0;
signed int test_pdu_remaining_size = 0;
int nb_bytes_to_transmit = rlc_pP->nb_bytes_requested_by_mac;
rlc_um_pdu_sn_5_t *pdu_p;
struct mac_tb_req *pdu_tb_req_p;
mem_block_t *pdu_mem_p;
char *data;
char *data_sdu_p;
rlc_um_e_li_t *e_li_p;
struct rlc_um_tx_sdu_management *sdu_mngt_p;
unsigned int li_length_in_bytes;
unsigned int test_li_length_in_bytes;
unsigned int test_remaining_size_to_substract;
unsigned int test_remaining_num_li_to_substract;
unsigned int continue_fill_pdu_with_sdu;
unsigned int num_fill_sdu;
unsigned int test_num_li;
unsigned int fill_num_li;
unsigned int sdu_buffer_index;
unsigned int data_pdu_size;
unsigned int fi_first_byte_pdu_is_first_byte_sdu;
unsigned int fi_last_byte_pdu_is_last_byte_sdu;
unsigned int fi;
unsigned int max_li_overhead;
rlc_um_pdu_sn_5_t *pdu_p = NULL;
struct mac_tb_req *pdu_tb_req_p = NULL;
mem_block_t *pdu_mem_p = NULL;
char *data = NULL;
char *data_sdu_p = NULL;
rlc_um_e_li_t *e_li_p = NULL;
struct rlc_um_tx_sdu_management *sdu_mngt_p = NULL;
unsigned int li_length_in_bytes = 0;
unsigned int test_li_length_in_bytes = 0;
unsigned int test_remaining_size_to_substract = 0;
unsigned int test_remaining_num_li_to_substract = 0;
unsigned int continue_fill_pdu_with_sdu = 0;
unsigned int num_fill_sdu = 0;
unsigned int test_num_li = 0;
unsigned int fill_num_li = 0;
mem_block_t *sdu_in_buffer = NULL;
unsigned int data_pdu_size = 0;
unsigned int fi_first_byte_pdu_is_first_byte_sdu = 0;
unsigned int fi_last_byte_pdu_is_last_byte_sdu = 0;
unsigned int fi = 0;
unsigned int max_li_overhead = 0;
if (nb_bytes_to_transmit < 2) {
#if defined(TRACE_RLC_UM_SEGMENT)
......@@ -536,7 +540,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
list_init (&pdus, NULL); // param string identifying the list is NULL
pdu_mem_p = NULL;
while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (nb_bytes_to_transmit > 0)) {
while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) {
#if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 nb_bytes_to_transmit %d BO %d\n",
frameP,
......@@ -549,10 +553,10 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
#endif
// pdu_p management
if (!pdu_mem_p) {
if (rlc_pP->nb_sdu <= 1) {
if (rlc_pP->input_sdus.nb_elements <= 1) {
max_li_overhead = 0;
} else {
max_li_overhead = (((rlc_pP->nb_sdu - 1) * 3) / 2) + ((rlc_pP->nb_sdu - 1) % 2);
max_li_overhead = (((rlc_pP->input_sdus.nb_elements - 1) * 3) / 2) + ((rlc_pP->input_sdus.nb_elements - 1) % 2);
}
if (nb_bytes_to_transmit >= (rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead)) {
data_pdu_size = rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead;
......@@ -610,15 +614,15 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
continue_fill_pdu_with_sdu = 1;
num_fill_sdu = 0;
test_num_li = 0;
sdu_buffer_index = rlc_pP->current_sdu_index;
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
test_pdu_remaining_size = pdu_remaining_size;
test_li_length_in_bytes = 1;
test_remaining_size_to_substract = 0;
test_remaining_num_li_to_substract = 0;
while ((rlc_pP->input_sdus[sdu_buffer_index]) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[sdu_buffer_index]->data));
while ((sdu_in_buffer) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data));
if (sdu_mngt_p->sdu_remaining_size > test_pdu_remaining_size) {
// no LI
......@@ -671,7 +675,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
pdu_remaining_size = pdu_remaining_size - 1;
data_pdu_size -= 1;//modifier pour duy
}
sdu_buffer_index = (sdu_buffer_index + 1) % rlc_pP->size_input_sdus_buffer;
sdu_in_buffer = sdu_in_buffer->next;
}
if (test_remaining_num_li_to_substract > 0) {
// there is a LI that is not necessary
......@@ -700,13 +704,14 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
fi_first_byte_pdu_is_first_byte_sdu = 0;
fi_last_byte_pdu_is_last_byte_sdu = 0;
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
if (
((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_remaining_size ==
((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_size) {
((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data))->sdu_remaining_size ==
((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data))->sdu_size) {
fi_first_byte_pdu_is_first_byte_sdu = 1;
}
while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data));
while ((sdu_in_buffer) && (continue_fill_pdu_with_sdu > 0)) {
sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (sdu_in_buffer->data));
if (sdu_mngt_p->sdu_segmented_size == 0) {
#if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n",
......@@ -731,7 +736,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
sdu_mngt_p->sdu_size);
#endif
}
data_sdu_p = &((rlc_pP->input_sdus[rlc_pP->current_sdu_index])->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt_p->sdu_segmented_size]);
data_sdu_p = &(sdu_in_buffer->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt_p->sdu_segmented_size]);
if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) {
#if defined(TRACE_RLC_UM_SEGMENT)
......@@ -777,10 +782,10 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
memcpy(data, data_sdu_p, pdu_remaining_size);
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]);
rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL;
rlc_pP->nb_sdu -= 1;
rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer;
sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus);
free_mem_block (sdu_in_buffer);
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
sdu_mngt_p = NULL;
fi_last_byte_pdu_is_last_byte_sdu = 1;
// fi will indicate end of PDU is end of SDU, no need for LI
......@@ -846,14 +851,15 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
e_li_p++;
}
pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes);
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]);
rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL;
rlc_pP->nb_sdu -= 1;
rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer;
sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus);
free_mem_block (sdu_in_buffer);
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
sdu_mngt_p = NULL;
pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes);
} else {
#if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n",
......@@ -869,17 +875,16 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
assert(1!=1);
#endif
memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size);
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]);
rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL;
rlc_pP->nb_sdu -= 1;
rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer;
// reduce the size of the PDU
continue_fill_pdu_with_sdu = 0;
fi_last_byte_pdu_is_last_byte_sdu = 1;
pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size;
// free SDU
rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size;
sdu_in_buffer = list_remove_head(&rlc_pP->input_sdus);
free_mem_block (sdu_in_buffer);
sdu_in_buffer = list_get_head(&rlc_pP->input_sdus);
sdu_mngt_p = NULL;
}
}
......
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